microbit-web-components
Version:
Web Components library for micro:bit
1 lines • 2.83 kB
JavaScript
var __awaiter=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))(function(n,i){function a(e){try{u(s.next(e))}catch(e){i(e)}}function o(e){try{u(s["throw"](e))}catch(e){i(e)}}function u(e){e.done?n(e.value):new r(function(t){t(e.value)}).then(a,o)}u((s=s.apply(e,t||[])).next())})};var __generator=this&&this.__generator||function(e,t){var r={label:0,sent:function(){if(i[0]&1)throw i[1];return i[1]},trys:[],ops:[]},s,n,i,a;return a={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function o(e){return function(t){return u([e,t])}}function u(a){if(s)throw new TypeError("Generator is already executing.");while(r)try{if(s=1,n&&(i=a[0]&2?n["return"]:a[0]?n["throw"]||((i=n["return"])&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;if(n=0,i)a=[a[0]&2,i.value];switch(a[0]){case 0:case 1:i=a;break;case 4:r.label++;return{value:a[1],done:false};case 5:r.label++;n=a[1];a=[0];continue;case 7:a=r.ops.pop();r.trys.pop();continue;default:if(!(i=r.trys,i=i.length>0&&i[i.length-1])&&(a[0]===6||a[0]===2)){r=0;continue}if(a[0]===3&&(!i||a[1]>i[0]&&a[1]<i[3])){r.label=a[1];break}if(a[0]===6&&r.label<i[1]){r.label=i[1];i=a;break}if(i&&r.label<i[2]){r.label=i[2];r.ops.push(a);break}if(i[2])r.ops.pop();r.trys.pop();continue}a=t.call(e,r)}catch(e){a=[6,e];n=0}finally{s=i=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};System.register(["./p-79150c1d.system.js","./p-86f8a157.system.js"],function(e){"use strict";var t,r,s,n;return{setters:[function(e){t=e.r;r=e.h;s=e.g},function(e){n=e.m}],execute:function(){var i=function(){function e(e){t(this,e);this.services=null;this.releaseClass="microbit-release";this.shortPressClass="microbit-short-press";this.longPressClass="microbit-long-press";this.className=this.releaseClass;n.addListener(this)}e.prototype.servicesUpdated=function(){return __awaiter(this,void 0,void 0,function(){var e,t;var r=this;return __generator(this,function(s){switch(s.label){case 0:if(!this.services||!this.services.buttonService){this.className=this.releaseClass;return[2]}e=this.services.buttonService;return[4,e.addEventListener("buttonastatechanged",function(e){return r.setClassName(e.detail)})];case 1:s.sent();t=this.setClassName;return[4,e.readButtonAState()];case 2:t.apply(this,[s.sent()]);return[2]}})})};e.prototype.setClassName=function(e){this.className=e===1?this.shortPressClass:e===2?this.longPressClass:this.releaseClass};e.prototype.render=function(){return r("span",{class:this.className},r("slot",null))};Object.defineProperty(e.prototype,"el",{get:function(){return s(this)},enumerable:true,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{services:["servicesUpdated"]}},enumerable:true,configurable:true});return e}();e("microbit_button_a",i)}}});