diff options
Diffstat (limited to 'main.6a141175.js')
-rw-r--r-- | main.6a141175.js | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/main.6a141175.js b/main.6a141175.js new file mode 100644 index 0000000..c1a67fd --- /dev/null +++ b/main.6a141175.js @@ -0,0 +1,10 @@ +parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(parcelRequire=f,i)throw i;return f}({"SiMs":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.notif_alert=a,exports.notif_info=c,exports.notif_success=o,exports.notif_warn=i;var e=void 0,n=[];function t(a){var i=document.querySelector(".statusline .notification-area");if(null===i.querySelector(".notification")&&void 0===e){if(screen.availHeight>screen.availWidth&&!document.body.classList.contains("ignore-landscape-warning"))return e=setInterval(function(){(screen.availHeight<screen.availWidth||document.body.classList.contains("ignore-landscape-warning"))&&(clearInterval(e),e=void 0,t(n.pop()))},1e3),void n.push(a);var c=document.createElement("div");c.className="notification",c.appendChild(a[0]),c.appendChild(a[1]),i.appendChild(c),i.classList.add("show"),setTimeout(function(){i.classList.remove("show"),c.querySelector("p").style.opacity="0",setTimeout(function(){i.removeChild(c),n.length>0&&t(n.pop())},1e3)},1e4)}else n.push(a)}function a(e){var n=document.createElement("div");n.className="notification-content";var a=document.createElement("p");a.innerHTML=e,n.appendChild(a);var i=document.createElement("i");i.className="alert fas fa-exclamation-triangle",n.appendChild(i),t([i,n])}function i(e){var n=document.createElement("div");n.className="notification-content";var a=document.createElement("p");a.innerHTML=e,n.appendChild(a);var i=document.createElement("i");i.className="warning fas fa-exclamation-triangle",n.appendChild(i),t([i,n])}function c(e){var n=document.createElement("div");n.className="notification-content";var a=document.createElement("p");a.innerHTML=e,n.appendChild(a);var i=document.createElement("i");i.className="info fas fa-info-circle",n.appendChild(i),t([i,n])}function o(e){var n=document.createElement("div");n.className="notification-content";var a=document.createElement("p");a.innerHTML=e,n.appendChild(a);var i=document.createElement("i");i.className="success fas fa-check-circle",n.appendChild(i),t([i,n])} +},{}],"COPm":[function(require,module,exports) { +"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.uBitBLE=exports.MESEvents=void 0;var e=require("./notification");function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function n(e,t){r(e,t),t.add(e)}function r(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function o(e,t,n){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return n}function i(){i=function(){return e};var e={},n=Object.prototype,r=n.hasOwnProperty,o=Object.defineProperty||function(e,t,n){e[t]=n.value},a="function"==typeof Symbol?Symbol:{},c=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",s=a.toStringTag||"@@toStringTag";function l(e,t,n){return Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(C){l=function(e,t,n){return e[t]=n}}function f(e,t,n,r){var i=t&&t.prototype instanceof d?t:d,a=Object.create(i.prototype),c=new T(r||[]);return o(a,"_invoke",{value:S(e,n,c)}),a}function v(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(C){return{type:"throw",arg:C}}}e.wrap=f;var h={};function d(){}function p(){}function y(){}var g={};l(g,c,function(){return this});var b=Object.getPrototypeOf,_=b&&b(b(P([])));_&&_!==n&&r.call(_,c)&&(g=_);var w=y.prototype=d.prototype=Object.create(g);function m(e){["next","throw","return"].forEach(function(t){l(e,t,function(e){return this._invoke(t,e)})})}function E(e,n){var i;o(this,"_invoke",{value:function(o,a){function c(){return new n(function(i,c){!function o(i,a,c,u){var s=v(e[i],e,a);if("throw"!==s.type){var l=s.arg,f=l.value;return f&&"object"==t(f)&&r.call(f,"__await")?n.resolve(f.__await).then(function(e){o("next",e,c,u)},function(e){o("throw",e,c,u)}):n.resolve(f).then(function(e){l.value=e,c(l)},function(e){return o("throw",e,c,u)})}u(s.arg)}(o,a,i,c)})}return i=i?i.then(c,c):c()}})}function S(e,t,n){var r="suspendedStart";return function(o,i){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===o)throw i;return U()}for(n.method=o,n.arg=i;;){var a=n.delegate;if(a){var c=x(a,n);if(c){if(c===h)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var u=v(e,t,n);if("normal"===u.type){if(r=n.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(r="completed",n.method="throw",n.arg=u.arg)}}}function x(e,t){var n=t.method,r=e.iterator[n];if(void 0===r)return t.delegate=null,"throw"===n&&e.iterator.return&&(t.method="return",t.arg=void 0,x(e,t),"throw"===t.method)||"return"!==n&&(t.method="throw",t.arg=new TypeError("The iterator does not provide a '"+n+"' method")),h;var o=v(r,e.iterator,t.arg);if("throw"===o.type)return t.method="throw",t.arg=o.arg,t.delegate=null,h;var i=o.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,h):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,h)}function D(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(D,this),this.reset(!0)}function P(e){if(e){var t=e[c];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:U}}function U(){return{value:void 0,done:!0}}return p.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:p,configurable:!0}),p.displayName=l(y,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,y):(e.__proto__=y,l(e,s,"GeneratorFunction")),e.prototype=Object.create(w),e},e.awrap=function(e){return{__await:e}},m(E.prototype),l(E.prototype,u,function(){return this}),e.AsyncIterator=E,e.async=function(t,n,r,o,i){void 0===i&&(i=Promise);var a=new E(f(t,n,r,o),i);return e.isGeneratorFunction(n)?a:a.next().then(function(e){return e.done?e.value:a.next()})},m(w),l(w,s,"Generator"),l(w,c,function(){return this}),l(w,"toString",function(){return"[object Generator]"}),e.keys=function(e){var t=Object(e),n=[];for(var r in t)n.push(r);return n.reverse(),function e(){for(;n.length;){var r=n.pop();if(r in t)return e.value=r,e.done=!1,e}return e.done=!0,e}},e.values=P,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(O),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var c=r.call(i,"catchLoc"),u=r.call(i,"finallyLoc");if(c&&u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,h):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),h},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),O(n),h}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var o=r.arg;O(n)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:P(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),h}},e}function a(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(s){return void n(s)}c.done?t(u):Promise.resolve(u).then(r,o)}function c(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){a(i,r,o,c,u,"next",e)}function u(e){a(i,r,o,c,u,"throw",e)}c(void 0)})}}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&s(e,t)}function s(e,t){return(s=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e})(e,t)}function l(e){var t=h();return function(){var n,r=d(e);if(t){var o=d(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return f(this,n)}}function f(e,n){if(n&&("object"===t(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return v(e)}function v(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(e){return!1}}function d(e){return(d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function p(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function y(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_(r.key),r)}}function g(e,t,n){return t&&y(e.prototype,t),n&&y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function b(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){var n=w(e,"string");return"symbol"===t(n)?n:String(n)}function w(e,n){if("object"!==t(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,n||"default");if("object"!==t(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}var m="6e400001-b5a3-f393-e0a9-e50e24dcca9e",E="6e400002-b5a3-f393-e0a9-e50e24dcca9e",S="6e400003-b5a3-f393-e0a9-e50e24dcca9e",x="e95d93af-251d-470a-a062-fa1922dfa9a8",D="e95db84c-251d-470a-a062-fa1922dfa9a8",O="e95d23c4-251d-470a-a062-fa1922dfa9a8",T="e95d9775-251d-470a-a062-fa1922dfa9a8",P="e95d5404-251d-470a-a062-fa1922dfa9a8",U={MES_DPAD_CONTROLLER_ID:1104,MES_DPAD_BUTTON_A_DOWN:1,MES_DPAD_BUTTON_A_UP:2,MES_DPAD_BUTTON_B_DOWN:3,MES_DPAD_BUTTON_B_UP:4,MES_DPAD_BUTTON_C_DOWN:5,MES_DPAD_BUTTON_C_UP:6,MES_DPAD_BUTTON_D_DOWN:7,MES_DPAD_BUTTON_D_UP:8,MES_DPAD_BUTTON_1_DOWN:9,MES_DPAD_BUTTON_1_UP:10,MES_DPAD_BUTTON_2_DOWN:11,MES_DPAD_BUTTON_2_UP:12,MES_DPAD_BUTTON_3_DOWN:13,MES_DPAD_BUTTON_3_UP:14,MES_DPAD_BUTTON_4_DOWN:15,MES_DPAD_BUTTON_4_UP:16};exports.MESEvents=U;var C=function(){function e(){p(this,e),b(this,"SERVICE_UUID",null)}return g(e,null,[{key:"doGattEvent",value:function(){e.gattEventQueue<=0||e.gattEventQueue.pop()()}}]),e}();b(C,"gattEventQueue",[]);var k=function(e){u(n,C);var t=l(n);function n(e,r){var o;return p(this,n),b(v(o=t.call(this)),"service",void 0),o.service=e,o.ubitEvent=r,console.debug("EventService initialized."),o}return g(n,[{key:"sendEvent",value:function(e,t){var n=this;C.gattEventQueue.push(function(){n.ubitEvent.writeValue(new Uint16Array([e,t]))})}}],[{key:"getService",value:function(){var e=c(i().mark(function e(t){var r,o;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.debug("Getting EventService"),e.next=3,t.getPrimaryService(n.SERVICE_UUID);case 3:return r=e.sent,console.debug("Getting ClientEvent characteristic"),e.next=7,r.getCharacteristic(P);case 7:return o=e.sent,e.abrupt("return",new n(r,o));case 9:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()}]),n}();b(k,"SERVICE_UUID",x);var N=new WeakSet,L=function(e){u(r,C);var t=l(r);function r(e,o,i){var a;return p(this,r),n(v(a=t.call(this)),N),b(v(a),"handlers",[]),a.service=e,a.uartTx=o,a.uartRx=i,console.debug("UartService initialized."),a}return g(r,[{key:"sendUart",value:function(){var e=c(i().mark(function e(t){var n,r,o=arguments;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=!(o.length>1&&void 0!==o[1])||o[1],r=new TextEncoder,e.prev=2,e.next=5,this.uartRx.writeValue(r.encode(t));case 5:e.next=10;break;case 7:e.prev=7,e.t0=e.catch(2),n||console.error(e.t0);case 10:case"end":return e.stop()}},e,this,[[2,7]])}));return function(t){return e.apply(this,arguments)}}()},{key:"onUartTx",value:function(e){this.handlers.push(e)}}],[{key:"getService",value:function(){var e=c(i().mark(function e(t){var n,a,c,u=this;return i().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return console.debug("Getting UartService"),e.next=3,t.getPrimaryService(r.SERVICE_UUID);case 3:return n=e.sent,console.debug("Getting Uart characteristics"),e.next=7,n.getCharacteristic(E);case 7:return a=e.sent,e.next=10,a.startNotifications();case 10:return e.next=12,a.addEventListener("characteristicvaluechanged",function(e){o(u,N,A).call(u,e)});case 12:return e.next=14,n.getCharacteristic(S);case 14:return c=e.sent,e.abrupt("return",new r(n,a,c));case 16:case"end":return e.stop()}},e)}));return function(t){return e.apply(this,arguments)}}()}]),r}();function A(e){for(var t=0;t<this.handlers.length;t++)this.handlers[t]()}b(L,"SERVICE_UUID",m);var j=new WeakSet,B=new WeakSet,M=function(){function t(){p(this,t),n(this,B),n(this,j),b(this,"eventService",void 0),b(this,"eventServiceAvailable",!1),b(this,"uartService",void 0),b(this,"uartServiceAvailable",!1),b(this,"uartTxHandlers",[]),b(this,"device",void 0),this.onConnectCallback=[],this.onDisconnectCallback=[],this.pushInterval=setInterval(C.doGattEvent,40)}return g(t,[{key:"onConnect",value:function(e){this.onConnectCallback.push(e)}},{key:"onDisconnect",value:function(e){this.onDisconnectCallback.push(e)}},{key:"isConnected",value:function(){return!!this.device&&this.device.gatt.connected}},{key:"disconnect",value:function(){this.isConnected()&&this.device.gatt.disconnect()}},{key:"searchDevice",value:function(){var t=c(i().mark(function t(){var n,r,a,c,u=this;return i().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,navigator.bluetooth.requestDevice({filters:[{namePrefix:"BBC micro:bit"}],optionalServices:[x,m]});case 2:return this.device=t.sent,this.device.addEventListener("gattserverdisconnected",function(e){return o(u,j,G).call(u,e)}),console.log("Connected to new device",this.device.name,this.device.id),console.debug("Connection to GATT server..."),t.next=8,this.device.gatt.connect();case 8:return n=t.sent,o(this,B,I).call(this),console.debug("Getting services..."),t.prev=11,t.next=14,k.getService(n);case 14:r=t.sent,this.eventService=r,this.eventServiceAvailable=!0,t.next=24;break;case 19:t.prev=19,t.t0=t.catch(11),this.eventServiceAvailable=!1,console.debug("Could not get EventService"),(0,e.notif_warn)("Connected device's firmware does not support bluetooth EventService, gamepad will not work.");case 24:return t.prev=24,t.next=27,L.getService(n);case 27:for(a=t.sent,this.uartService=a,c=0;c<this.uartTxHandlers.length;c++)this.uartService.onUartTx(this.uartTxHandlers[c]);this.uartServiceAvailable=!0,t.next=38;break;case 33:t.prev=33,t.t1=t.catch(24),this.uartServiceAvailable=!1,console.debug("Could not get UartService",t.t1),(0,e.notif_info)("Connected device's firmware does not support bluetooth UartService, joysticks won't work.");case 38:case"end":return t.stop()}},t,this,[[11,19],[24,33]])}));return function(){return t.apply(this,arguments)}}()},{key:"sendEvent",value:function(e,t){this.isConnected()&&this.eventServiceAvailable?this.eventService.sendEvent(e,t):console.debug("Could not send event {".concat(e,", ").concat(t,"}, because: ").concat(this.isConnected()?"Device does not have EventService characteristic":"No device connected","."))}},{key:"sendUart",value:function(e){this.isConnected()&&this.uartServiceAvailable?this.uartService.sendUart(e):console.debug("Could not send uart data, because: ".concat(this.isConnected()?"Device does not have UartService characteristic":"No device connected","."))}},{key:"onUartTx",value:function(e){this.uartTxHandlers.push(e),this.uartServiceAvailable&&this.uartService.onUartTx(e)}}]),t}();function G(e){console.debug("Device disconnected",e);for(var t=0;t<this.onDisconnectCallback.length;t++)this.onDisconnectCallback[t]()}function I(){console.debug("Device connected");for(var e=0;e<this.onConnectCallback.length;e++)this.onConnectCallback[e]()}function R(e){var t=[];for(var n in e.properties)!0===e.properties[n]&&t.push(n.toUpperCase());return"["+t.join(", ")+"]"}function W(e){for(var t=[],n=0;n<e.target.value.byteLength;n++)t[n]=e.target.value.getUint8(n);return String.fromCharCode.apply(null,t)}exports.uBitBLE=M; +},{"./notification":"SiMs"}],"W7Xq":[function(require,module,exports) { +"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(){return(e="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var a=i(t,e);if(a){var s=Object.getOwnPropertyDescriptor(a,e);return s.get?s.get.call(arguments.length<3?t:n):s.value}}).apply(this,arguments)}function i(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=l(t)););return t}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&a(t,e)}function a(t,e){return(a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function s(t){var e=h();return function(){var i,n=l(t);if(e){var a=l(this).constructor;i=Reflect.construct(n,arguments,a)}else i=n.apply(this,arguments);return r(this,i)}}function r(e,i){if(i&&("object"===t(i)||"function"==typeof i))return i;if(void 0!==i)throw new TypeError("Derived constructors may only return object or undefined");return o(e)}function o(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(t){return!1}}function l(t){return(l=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){return f(t)||g(t,e)||d(t,e)||c()}function c(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function d(t,e){if(t){if("string"==typeof t)return y(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?y(t,e):void 0}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,n=new Array(e);i<e;i++)n[i]=t[i];return n}function g(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var n,a,s,r,o=[],h=!0,l=!1;try{if(s=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;h=!1}else for(;!(h=(n=s.call(i)).done)&&(o.push(n.value),o.length!==e);h=!0);}catch(u){l=!0,a=u}finally{try{if(!h&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(l)throw a}}return o}}function f(t){if(Array.isArray(t))return t}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function p(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,x(n.key),n)}}function b(t,e,i){return e&&p(t.prototype,e),i&&p(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}function w(t,e,i){m(t,e),e.set(t,i)}function m(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function k(t,e,i){return(e=x(e))in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function x(e){var i=T(e,"string");return"symbol"===t(i)?i:String(i)}function T(e,i){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var a=n.call(e,i||"default");if("object"!==t(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===i?String:Number)(e)}function Y(t,e){return A(t,P(t,e,"get"))}function A(t,e){return e.get?e.get.call(t):e.value}function X(t,e,i){return E(t,P(t,e,"set"),i),i}function P(t,e,i){if(!e.has(t))throw new TypeError("attempted to "+i+" private field on non-instance");return e.get(t)}function E(t,e,i){if(e.set)e.set.call(t,i);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=i}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.Square=exports.GamepadJoystick=exports.GamepadButton=exports.Gamepad=void 0;var S=new WeakMap,O=new WeakMap,M=new WeakMap,B=new WeakMap,j=new WeakMap,I=function(){function t(e,i){var n=this;v(this,t),k(this,"canvas",void 0),w(this,S,{writable:!0,value:window.devicePixelRatio}),w(this,O,{writable:!0,value:void 0}),w(this,M,{writable:!0,value:void 0}),w(this,B,{writable:!0,value:void 0}),w(this,j,{writable:!0,value:[]}),k(this,"touches",{}),k(this,"showTouches",!1),this.canvas=document.createElement("canvas"),this.canvas.setAttribute("id",e),i.appendChild(this.canvas),addEventListener("resize",function(){return n.resize()}),this.resize(),console.debug("Created canvas",this.canvas),setInterval(function(){n.drawElements()},10)}return b(t,[{key:"resize",value:function(){X(this,B,this.canvas.getContext("2d")),X(this,M,+getComputedStyle(this.canvas).getPropertyValue("height").slice(0,-2)),X(this,O,+getComputedStyle(this.canvas).getPropertyValue("width").slice(0,-2)),this.canvas.setAttribute("height",Y(this,M)*Y(this,S)),this.canvas.setAttribute("width",Y(this,O)*Y(this,S))}},{key:"screenToCanvasX",value:function(t){return t*Y(this,S)}},{key:"screenToCanvasY",value:function(t){return t*Y(this,S)}},{key:"getTarget",value:function(t,e){t*=Y(this,S),e*=Y(this,S);for(var i=0;i<Y(this,j).length;i++)if(Y(this,j)[i]instanceof D&&Y(this,j)[i].collides(Y(this,B),t,e))return Y(this,j)[i]}},{key:"drawElements",value:function(){Y(this,B).clearRect(0,0,Y(this,O)*Y(this,S),Y(this,M)*Y(this,S));for(var t=0;t<Y(this,j).length;t++)Y(this,j)[t].draw(Y(this,B));this.showTouches&&this.drawTouches()}},{key:"drawTouches",value:function(t){for(var e=["200, 0, 0","0, 200, 0","0, 0, 200","200, 200, 0","200, 200, 200"],i=0,n=Object.entries(this.touches);i<n.length;i++){var a=u(n[i],2),s=a[0],r=a[1];Y(this,B).beginPath(),Y(this,B).arc(r.x*Y(this,S),r.y*Y(this,S),20*Y(this,S),0,2*Math.PI,!0),Y(this,B).fillStyle="rgba(".concat(e[s],", 0.2)"),Y(this,B).fill(),Y(this,B).lineWidth=2,Y(this,B).strokeStyle="rgba(".concat(e[s],", 0.8)"),Y(this,B).stroke()}}},{key:"addElement",value:function(t){Y(this,j).push(t),t.init()}},{key:"removeElementById",value:function(t){for(var e=0;e<Y(this,j).length;e++)if(t===Y(this,j)[e].id)return void Y(this,j).splice(e,1)}},{key:"removeAllElements",value:function(){Y(this,j).splice(0,Y(this,j).length)}}]),t}(),C=function(){function t(e,i){v(this,t),k(this,"gamepad",void 0),k(this,"id",void 0),k(this,"x",void 0),k(this,"y",void 0),k(this,"alignX",void 0),k(this,"alignY",void 0),k(this,"path",void 0),k(this,"isInside",void 0),k(this,"isActive",void 0),k(this,"type","Element");var n=Object.assign({id:null,x:0,y:0,alignX:null,alignY:null},e);this.id=n.id,this.x=n.x,this.y=n.y,this.alignX=n.alignX,this.alignY=n.alignY,this.gamepad=i}return b(t,[{key:"init",value:function(){}},{key:"getScaleX",value:function(t){return t.canvas.width/100}},{key:"getScaleY",value:function(t){return t.canvas.height/100}},{key:"getX",value:function(t){var e=this.x*this.getScaleY(t);return"center"===this.alignX&&(e=t.canvas.width/2+e),"right"===this.alignX&&(e=t.canvas.width-e),e}},{key:"getY",value:function(t){var e=this.y*this.getScaleY(t);return"center"===this.alignY&&(e=t.canvas.height/2+e),"bottom"===this.alignY&&(e=t.canvas.height-e),e}},{key:"draw",value:function(t){}},{key:"collides",value:function(t,e,i){return this.isInside=t.isPointInPath(this.path,e,i),this.isInside}}]),t}(),R=function(t){n(i,C);var e=s(i);function i(){return v(this,i),e.apply(this,arguments)}return b(i,[{key:"draw",value:function(t){this.path=new Path2D;var e=20*this.getScaleY(t);this.path.rect(this.getX(t)-e/2,this.getY(t)-e/2,e,e),t.fillStyle="rgba(100, 100, 100, 0.8)",t.fill(this.path)}}]),i}();exports.Square=R;var D=function(t){n(i,C);var e=s(i);function i(){var t;v(this,i);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return k(o(t=e.call.apply(e,[this].concat(a))),"type","TouchElement"),k(o(t),"touchCount",0),t}return b(i,[{key:"setActive",value:function(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];["end","cancel"].includes(t.type)&&this.touchCount--;var i="start"==t.type;i!==this.isActive&&0==this.touchCount&&(this.isActive=i,e&&this.gamepad.handleTouchEventCallbacks(this.createTouchEventObject(this.isActive?"touchstart":"touchend"))),"start"==t.type&&this.touchCount++}},{key:"createTouchEventObject",value:function(t){return{id:this.id,action:t,type:this.type}}}]),i}(),L=function(t){n(i,D);var e=s(i);function i(t){var n;v(this,i);var a=Object.assign({keyboardButton:null,altText:null,altTextAlign:"left",shape:"round"},t);return k(o(n=e.call(this,t)),"shape",void 0),k(o(n),"altText",void 0),k(o(n),"altTextAlign",void 0),k(o(n),"type","GamepadButton"),n.keyboardButton=a.keyboardButton,n.shape=a.shape,n.altText=a.altText,n.altTextAlign=a.altTextAlign,n}return b(i,[{key:"init",value:function(){null!==this.keyboardButton&&this.gamepad.registerKeybinding(this.keyboardButton,this)}},{key:"draw",value:function(t){if(this.path=new Path2D,"round"===this.shape)this.path.arc(this.getX(t),this.getY(t),10*this.getScaleY(t),0,4*Math.PI,!0);else if("square"===this.shape){var e=20*this.getScaleY(t);this.path.rect(this.getX(t)-e/2,this.getY(t)-e/2,e,e)}this.isActive?t.fillStyle="rgba(80, 80, 80, 1)":t.fillStyle="rgba(100, 100, 100, 0.8)",t.fill(this.path);var i="".concat(Math.floor((8*this.getScaleY(t)).toString()),"px 'Press Start 2P'");if(t.font=i,t.textBaseline="middle",t.textAlign="center",t.fillStyle="rgba(255, 255, 255, 1)",t.fillText(this.id,this.getX(t),this.getY(t)),null!==this.altText&&this.gamepad.showAltText){t.beginPath(),t.font="".concat(Math.floor((3*this.getScaleY(t)).toString()),"px 'Press Start 2P'"),t.textBaseline="middle",t.textAlign="center",t.fillStyle="rgba(150, 150, 150, 1)";var n=this.getX(t),a=this.getY(t);switch(this.altTextAlign){case"left":n-=13*this.getScaleY(t);break;case"right":n+=13*this.getScaleY(t);break;case"top":a-=13*this.getScaleY(t);break;case"bottom":a+=13*this.getScaleY(t)}t.fillText(this.altText,n,a)}}}]),i}();exports.GamepadButton=L;var K=new WeakMap,q=new WeakMap,W=new WeakMap,G=function(t){n(a,D);var i=s(a);function a(t){var e;v(this,a);var n=Object.assign({lockX:!1,lockY:!1,autoCenter:!0,bindUp:null,bindLeft:null,bindRight:null,bindDown:null},t);return k(o(e=i.call(this,t)),"type","GamepadJoystick"),k(o(e),"mouseX",0),k(o(e),"mouseY",0),k(o(e),"cR",0),k(o(e),"cX",0),k(o(e),"cY",0),w(o(e),K,{writable:!0,value:void 0}),w(o(e),q,{writable:!0,value:void 0}),w(o(e),W,{writable:!0,value:{}}),X(o(e),K,n.lockX),X(o(e),q,n.lockY),e.bindUp=n.bindUp,e.bindLeft=n.bindLeft,e.bindRight=n.bindRight,e.bindDown=n.bindDown,e}return b(a,[{key:"init",value:function(){null!==this.bindUp&&this.gamepad.registerKeybinding(this.bindUp,this),null!==this.bindLeft&&this.gamepad.registerKeybinding(this.bindLeft,this),null!==this.bindRight&&this.gamepad.registerKeybinding(this.bindRight,this),null!==this.bindDown&&this.gamepad.registerKeybinding(this.bindDown,this)}},{key:"isKeyPressed",value:function(t){return null!==t&&Y(this,W).hasOwnProperty(t)&&Y(this,W)[t]>0}},{key:"createTouchEventObject",value:function(t){return{id:this.id,action:t,type:this.type,x:Math.round(this.mouseX/this.cR*100),y:Math.round(this.mouseY/this.cR*100)}}},{key:"setActive",value:function(t){e(l(a.prototype),"setActive",this).call(this,t,!1),t.hasOwnProperty("key")&&(Y(this,W).hasOwnProperty(t.key)||(Y(this,W)[t.key]=0),["start"].includes(t.type)&&Y(this,W)[t.key]++,["end","cancel"].includes(t.type)&&Y(this,W)[t.key]--);var i=this.cR;Y(this,K)||(t.hasOwnProperty("x")&&(this.mouseX=this.cX-this.gamepad.stage.screenToCanvasX(t.x),this.mouseX=Math.min(Math.abs(this.mouseX),i)*Math.sign(this.mouseX),this.mouseX*=-1),this.isKeyPressed(this.bindLeft)&&(this.mouseX=-i),this.isKeyPressed(this.bindRight)&&(this.mouseX=i),this.isKeyPressed(this.bindLeft)&&this.isKeyPressed(this.bindRight)&&(this.mouseX=0),this.isActive||(this.mouseX=0)),Y(this,q)||(t.hasOwnProperty("y")&&(this.mouseY=this.cY-this.gamepad.stage.screenToCanvasY(t.y),this.mouseY=Math.min(Math.abs(this.mouseY),i)*Math.sign(this.mouseY)),this.isKeyPressed(this.bindUp)&&(this.mouseY=i),this.isKeyPressed(this.bindDown)&&(this.mouseY=-i),this.isKeyPressed(this.bindUp)&&this.isKeyPressed(this.bindDown)&&(this.mouseY=0),this.isActive||(this.mouseY=0));var n="touchmove";this.isActive&&1==this.touchCount&&"start"===t.type&&(n="touchstart"),this.isActive||(n="touchend"),this.gamepad.handleTouchEventCallbacks(this.createTouchEventObject(n))}},{key:"draw",value:function(t){this.cX=this.getX(t),this.cY=this.getY(t),this.cR=25*this.getScaleY(t),this.path=new Path2D,this.path.arc(this.cX,this.cY,this.cR,0,4*Math.PI,!0),this.isActive?t.fillStyle="rgba(85, 85, 85, 0.8)":t.fillStyle="rgba(100, 100, 100, 0.8)",t.fill(this.path),t.beginPath(),t.arc(this.cX+this.mouseX,this.cY-this.mouseY,15*this.getScaleY(t),0,4*Math.PI,!0),t.fillStyle="rgba(130, 130, 130, 1)",t.fill()}}]),a}();exports.GamepadJoystick=G;var U=new WeakMap,_=new WeakMap,z=new WeakMap,V=new WeakMap,J=new WeakMap,H=new WeakMap,N=function(){function t(){v(this,t),k(this,"stage",void 0),w(this,U,{writable:!0,value:void 0}),w(this,_,{writable:!0,value:void 0}),w(this,z,{writable:!0,value:{}}),w(this,V,{writable:!0,value:{}}),w(this,J,{writable:!0,value:{}}),w(this,H,{writable:!0,value:[]}),k(this,"showDebug",!1),k(this,"showAltText",!0),k(this,"enableVibration",!0),this.stage=new I("GamePad",document.querySelector(".gamepad-wrapper")),this.addEventListeners()}return b(t,[{key:"addEventListeners",value:function(){var t=this,e=["keydown","keyup"];for(var i in e)document.addEventListener(e[i],function(e){return t.handleKeyEvent(e)},!1);for(var i in e=["touchstart","touchend","touchcancel","touchmove"])this.stage.canvas.addEventListener(e[i],function(e){return t.handleTouchEvent(e)},!1);for(var i in e=["mousedown","mouseup","mousemove"])this.stage.canvas.addEventListener(e[i],function(e){return t.handleMouseEvent(e)},!1)}},{key:"registerKeybinding",value:function(t,e){Y(this,V)[t]=e}},{key:"handleKeyEvent",value:function(t){if(Y(this,J).hasOwnProperty(t.keyCode)||(Y(this,J)[t.keyCode]={pressed:!1}),Y(this,V).hasOwnProperty(t.key)){var e="Key ".concat(t.key),i=Y(this,V)[t.key],n={touchId:e,key:t.key,type:{keydown:"start",keyup:"end"}[t.type]};switch(t.type){case"keydown":if(Y(this,J)[t.keyCode].pressed)return;Y(this,J)[t.keyCode].pressed=!0,Y(this,z)[e]={},Y(this,z)[e].target=i,Y(this,z)[e].hasOwnProperty("target")&&null!=Y(this,z)[e].target&&Y(this,z)[e].target.setActive(n);break;case"keyup":if(!Y(this,J)[t.keyCode].pressed)return;Y(this,J)[t.keyCode].pressed=!1,Y(this,z)[e].hasOwnProperty("target")&&null!=Y(this,z)[e].target&&Y(this,z)[e].target.setActive(n),delete Y(this,z)[e]}}this.stage.touches=Y(this,z),this.debugTouches()}},{key:"handleMouseEvent",value:function(t){this.processGamepadTouchEvent({x:t.clientX,y:t.clientY,touchId:"mouse",type:{mousedown:"start",mouseup:"end",mousemove:"move"}[t.type]})}},{key:"handleTouchEvent",value:function(t){t.preventDefault();for(var e={touchstart:"start",touchend:"end",touchcancel:"end",touchmove:"move"},i=0;i<t.changedTouches.length;i++){var n=t.changedTouches[i];this.processGamepadTouchEvent({x:n.clientX,y:n.clientY,touchId:n.identifier,type:e[t.type]})}}},{key:"processGamepadTouchEvent",value:function(t){var e=this.stage.getTarget(t.x,t.y);switch(t.type){case"start":Y(this,z)[t.touchId]={},Y(this,z)[t.touchId].target=e;case"move":Y(this,z).hasOwnProperty(t.touchId)&&(Y(this,z)[t.touchId].x=t.x,Y(this,z)[t.touchId].y=t.y,Y(this,z)[t.touchId].hasOwnProperty("target")&&null!=Y(this,z)[t.touchId].target&&Y(this,z)[t.touchId].target.setActive(t));break;case"end":case"cancel":Y(this,z)[t.touchId].hasOwnProperty("target")&&null!=Y(this,z)[t.touchId].target&&Y(this,z)[t.touchId].target.setActive(t),delete Y(this,z)[t.touchId];break;default:console.log("Unknown touch event",t.type)}this.stage.touches=Y(this,z),this.debugTouches()}},{key:"debugTouches",value:function(){var t="";if(this.showDebug)for(var e=0,i=Object.entries(Y(this,z));e<i.length;e++){var n=u(i[e],2),a=n[0],s=n[1];t+="[".concat(a,"] "),s.hasOwnProperty("x")&&(t+="x: ".concat(Math.round(s.x,2),", y: ").concat(Math.round(s.y),",")),t+="target: ".concat(s.target?s.target.id:null,"\n")}document.querySelector(".gamepad-touches").innerHTML=t}},{key:"handleTouchEventCallbacks",value:function(t){if(this.enableVibration&&["touchstart","touchend"].includes(t.action))try{window.navigator.vibrate(5)}catch(t){console.error(t)}for(var e=0;e<Y(this,H).length;e++)Y(this,H)[e](t)}},{key:"onTouchEvent",value:function(t){Y(this,H).push(t)}},{key:"addElements",value:function(t){for(var e=0;e<t.length;e++)t[e].gamepad=this,this.stage.addElement(t[e])}},{key:"removeElementsById",value:function(t){for(var e=0;e<t.length;e++)this.stage.removeElementById(t[e])}},{key:"removeAllElements",value:function(){this.stage.removeAllElements()}},{key:"setGamepadLayout",value:function(t){switch(console.debug("Setting the gamepad layout to ".concat(t,", deleting all current elements.")),this.removeAllElements(),t){case"1":this.addElements([new R({id:"filler1",x:40,y:0,alignX:"left",alignY:"center"}),new L({id:"C",x:20,y:0,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowLeft",altText:"◀",altTextAlign:"right"}),new L({id:"D",x:60,y:0,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowRight",altText:"▶",altTextAlign:"left"}),new L({id:"A",x:40,y:-20,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowUp",altText:"▲",altTextAlign:"bottom"}),new L({id:"B",x:40,y:20,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowDown",altText:"▼",altTextAlign:"top"}),new L({id:"3",x:20,y:0,alignX:"right",alignY:"center",shape:"round",keyboardButton:"3",altText:"3",altTextAlign:"left"}),new L({id:"4",x:60,y:0,alignX:"right",alignY:"center",shape:"round",keyboardButton:"4",altText:"4",altTextAlign:"right"}),new L({id:"1",x:40,y:-20,alignX:"right",alignY:"center",shape:"round",keyboardButton:"1",altText:"1",altTextAlign:"bottom"}),new L({id:"2",x:40,y:20,alignX:"right",alignY:"center",shape:"round",keyboardButton:"2",altText:"2",altTextAlign:"top"})]);break;case"2":this.addElements([new R({id:"filler2",x:40,y:0,alignX:"right",alignY:"center"}),new R({id:"filler1",x:40,y:0,alignX:"left",alignY:"center"}),new L({id:"C",x:20,y:0,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowLeft",altText:"◀",altTextAlign:"right"}),new L({id:"D",x:60,y:0,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowRight",altText:"▶",altTextAlign:"left"}),new L({id:"A",x:40,y:-20,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowUp",altText:"▲",altTextAlign:"bottom"}),new L({id:"B",x:40,y:20,alignX:"left",alignY:"center",shape:"square",keyboardButton:"ArrowDown",altText:"▼",altTextAlign:"top"}),new L({id:"3",x:20,y:0,alignX:"right",alignY:"center",shape:"square",keyboardButton:"3"}),new L({id:"4",x:60,y:0,alignX:"right",alignY:"center",shape:"square",keyboardButton:"4"}),new L({id:"1",x:40,y:-20,alignX:"right",alignY:"center",shape:"square",keyboardButton:"1"}),new L({id:"2",x:40,y:20,alignX:"right",alignY:"center",shape:"square",keyboardButton:"2"})]);break;case"9":this.addElements([new G({id:"left",x:40,y:0,alignX:"left",alignY:"center",lockX:!0,bindUp:"ArrowUp",bindDown:"ArrowDown"}),new G({id:"right",x:40,y:0,alignX:"right",alignY:"center",lockY:!0,bindLeft:"ArrowLeft",bindRight:"ArrowRight"})])}}}]),t}();exports.Gamepad=N; +},{}],"d6sW":[function(require,module,exports) { +"use strict";var t=require("./uBit"),e=require("./notification"),r=require("./gamepad");function n(t){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function o(t,e){return l(t)||u(t,e)||i(t,e)||a()}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(t,e){if(t){if("string"==typeof t)return c(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,l=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(s){l=!0,o=s}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(l)throw o}}return c}}function l(t){if(Array.isArray(t))return t}function s(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function d(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?s(Object(r),!0).forEach(function(e){h(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):s(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function h(t,e,r){return(e=f(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function f(t){var e=g(t,"string");return"symbol"===n(e)?e:String(e)}function g(t,e){if("object"!==n(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}function v(){v=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(M){l=function(t,e,r){return t[e]=r}}function s(t,e,r,n){var a=e&&e.prototype instanceof f?e:f,i=Object.create(a.prototype),c=new T(n||[]);return o(i,"_invoke",{value:E(t,r,c)}),i}function d(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(M){return{type:"throw",arg:M}}}t.wrap=s;var h={};function f(){}function g(){}function y(){}var p={};l(p,i,function(){return this});var m=Object.getPrototypeOf,b=m&&m(m(P([])));b&&b!==e&&r.call(b,i)&&(p=b);var w=y.prototype=f.prototype=Object.create(p);function S(t){["next","throw","return"].forEach(function(e){l(t,e,function(t){return this._invoke(e,t)})})}function _(t,e){var a;o(this,"_invoke",{value:function(o,i){function c(){return new e(function(a,c){!function o(a,i,c,u){var l=d(t[a],t,i);if("throw"!==l.type){var s=l.arg,h=s.value;return h&&"object"==n(h)&&r.call(h,"__await")?e.resolve(h.__await).then(function(t){o("next",t,c,u)},function(t){o("throw",t,c,u)}):e.resolve(h).then(function(t){s.value=t,c(s)},function(t){return o("throw",t,c,u)})}u(l.arg)}(o,i,a,c)})}return a=a?a.then(c,c):c()}})}function E(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return x()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=O(i,r);if(c){if(c===h)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=d(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===h)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function O(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,O(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=d(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function D(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function L(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(D,this),this.reset(!0)}function P(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:x}}function x(){return{value:void 0,done:!0}}return g.prototype=y,o(w,"constructor",{value:y,configurable:!0}),o(y,"constructor",{value:g,configurable:!0}),g.displayName=l(y,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===g||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,y):(t.__proto__=y,l(t,u,"GeneratorFunction")),t.prototype=Object.create(w),t},t.awrap=function(t){return{__await:t}},S(_.prototype),l(_.prototype,c,function(){return this}),t.AsyncIterator=_,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new _(s(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(t){return t.done?t.value:i.next()})},S(w),l(w,u,"Generator"),l(w,i,function(){return this}),l(w,"toString",function(){return"[object Generator]"}),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(L),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),L(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;L(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:P(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function y(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(l){return void r(l)}c.done?e(u):Promise.resolve(u).then(n,o)}function p(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(t){y(a,n,o,i,c,"next",t)}function c(t){y(a,n,o,i,c,"throw",t)}i(void 0)})}}var m="service-worker.js";navigator.serviceWorker&&navigator.serviceWorker.register(m,{scope:"/microbit-gamepad/"}).then(function(t){t.onupdatefound=function(){var r=t.installing;null!=r&&(r.onstatechange=function(){"installed"===r.state&&(navigator.serviceWorker.controller?(0,e.notif_info)("New content is available, relaunch the app to install it."):(0,e.notif_success)("Content is cached for offline use."))})},t.update()}).catch(function(t){(0,e.notif_warn)("Could not install service worker..."),console.error("Error during service worker registration:",t)}),document.getElementById("btn_ignore_landscape_warning").addEventListener("click",function(){document.body.classList.add("ignore-landscape-warning")}),navigator.bluetooth||(console.error("You do not have a bluetooth enabled browser, you need to have a bluetooth enabled browser..."),(0,e.notif_alert)("Your browser does not seem to support bluetooth, try using Google Chrome or Microsoft Edge."));var b=new r.Gamepad;window.gamepad=b;var w=new t.uBitBLE;window.ubit=w,document.querySelector(".settings-dialog #layout").addEventListener("change",function(t){b.setGamepadLayout(t.target.value),localStorage.setItem("gamepadLayout",t.target.value),document.querySelector(".button-states pre").innerHTML="No buttons pressed yet"}),null===localStorage.getItem("gamepadLayout")&&localStorage.setItem("gamepadLayout","1"),b.setGamepadLayout(localStorage.getItem("gamepadLayout")),document.querySelector(".button-states pre").innerHTML="No buttons pressed yet",document.querySelector(".settings-dialog #layout").value=localStorage.getItem("gamepadLayout"),document.querySelector(".settings-dialog #show-touches").addEventListener("change",function(t){b.stage.showTouches=t.target.checked,localStorage.setItem("showTouches",t.target.checked)}),null===localStorage.getItem("showTouches")&&localStorage.setItem("showTouches",!1),b.stage.showTouches="true"==localStorage.getItem("showTouches"),document.querySelector(".settings-dialog #show-touches").checked="true"==localStorage.getItem("showTouches"),document.querySelector(".settings-dialog #show-gamepad-alt-text").addEventListener("change",function(t){b.showAltText=t.target.checked,localStorage.setItem("showAltText",t.target.checked)}),null===localStorage.getItem("showAltText")&&localStorage.setItem("showAltText",!1),b.showAltText="true"==localStorage.getItem("showAltText"),document.querySelector(".settings-dialog #show-gamepad-alt-text").checked="true"==localStorage.getItem("showAltText"),document.querySelector(".settings-dialog #enable-haptic").addEventListener("change",function(t){b.enableVibration=t.target.checked,localStorage.setItem("enableHaptic",t.target.checked)}),null===localStorage.getItem("enableHaptic")&&localStorage.setItem("enableHaptic",!0),b.enableVibration="true"==localStorage.getItem("enableHaptic"),document.querySelector(".settings-dialog #enable-haptic").checked="true"==localStorage.getItem("enableHaptic"),document.querySelector(".settings-dialog #enable-debug").addEventListener("change",function(t){b.showDebug=t.target.checked,t.target.checked?document.body.classList.add("debug"):document.body.classList.remove("debug"),localStorage.setItem("enableDebug",t.target.checked)}),null===localStorage.getItem("enableDebug")&&localStorage.setItem("enableDebug",!1),b.showDebug="true"==localStorage.getItem("enableDebug"),"true"===localStorage.getItem("enableDebug")?document.body.classList.add("debug"):document.body.classList.remove("debug"),document.querySelector(".settings-dialog #enable-debug").checked="true"==localStorage.getItem("enableDebug"),document.querySelector("#btn_show_settings").addEventListener("click",function(){document.querySelector(".settings-dialog").classList.add("shown")}),document.querySelector("#btn_hide_settings").addEventListener("click",function(){document.querySelector(".settings-dialog").classList.remove("shown")}),document.querySelector("#btn_disconnect").addEventListener("click",function(){w.disconnect()}),document.getElementById("btn_connect").addEventListener("click",p(v().mark(function t(){return v().wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return navigator.bluetooth||(0,e.notif_alert)("You need a bluetooth enabled browser for this app to work, try chrome."),t.prev=1,t.next=4,w.searchDevice();case 4:t.next=9;break;case 6:t.prev=6,t.t0=t.catch(1),(0,e.notif_alert)("Could not connect to device: ".concat(t.t0,"."));case 9:case"end":return t.stop()}},t,null,[[1,6]])})));var S={};b.onTouchEvent(function(t){["touchstart","touchmove"].includes(t.action)&&(S[t.id]=d({state:!0},t)),["touchend"].includes(t.action)&&(S[t.id]=d({state:!1},t));for(var e="",r=0,n=Object.entries(S);r<n.length;r++){var a=o(n[r],2),i=a[0],c=a[1];e+="".concat(i,": ").concat(c.state?"Pressed":"Not pressed"),c.hasOwnProperty("x")&&(e+=" (x: ".concat(c.x,", y: ").concat(c.y,")")),e+="\n"}document.querySelector(".button-states pre").innerHTML=e});var _={};b.onTouchEvent(function(e){var r=t.MESEvents.MES_DPAD_CONTROLLER_ID,n=null;"touchstart"==e.action?"A"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_A_DOWN:"B"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_B_DOWN:"C"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_C_DOWN:"D"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_D_DOWN:"1"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_1_DOWN:"2"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_2_DOWN:"3"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_3_DOWN:"4"==e.id&&(n=t.MESEvents.MES_DPAD_BUTTON_4_DOWN):"touchend"==e.action&&("A"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_A_UP:"B"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_B_UP:"C"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_C_UP:"D"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_D_UP:"1"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_1_UP:"2"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_2_UP:"3"==e.id?n=t.MESEvents.MES_DPAD_BUTTON_3_UP:"4"==e.id&&(n=t.MESEvents.MES_DPAD_BUTTON_4_UP)),w.isConnected()&&null!=n&&w.sendEvent(r,n),"right"==e.id&&(_.x=e.x),"left"==e.id&&(_.y=e.y)}),w.onConnect(function(){document.body.classList.add("connected")}),w.onDisconnect(function(){document.body.classList.remove("connected")});var E=0;setInterval(function(){0==E&&_.hasOwnProperty("x")&&w.sendUart("x:".concat(_.x,"\n")),1==E&&_.hasOwnProperty("y")&&w.sendUart("y:".concat(_.y,"\n")),++E>1&&(E=0)},20); +},{"./uBit":"COPm","./notification":"SiMs","./gamepad":"W7Xq"}]},{},["d6sW"], null) +//# sourceMappingURL=/microbit-gamepad/main.6a141175.js.map
\ No newline at end of file |