UNPKG

microbit-web-components

Version:
1 lines 2.89 kB
var __awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))(function(i,s){function u(e){try{a(r.next(e))}catch(e){s(e)}}function o(e){try{a(r["throw"](e))}catch(e){s(e)}}function a(e){e.done?i(e.value):new n(function(t){t(e.value)}).then(u,o)}a((r=r.apply(e,t||[])).next())})};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},r,i,s,u;return u={next:o(0),throw:o(1),return:o(2)},typeof Symbol==="function"&&(u[Symbol.iterator]=function(){return this}),u;function o(e){return function(t){return a([e,t])}}function a(u){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(s=u[0]&2?i["return"]:u[0]?i["throw"]||((s=i["return"])&&s.call(i),0):i.next)&&!(s=s.call(i,u[1])).done)return s;if(i=0,s)u=[u[0]&2,s.value];switch(u[0]){case 0:case 1:s=u;break;case 4:n.label++;return{value:u[1],done:false};case 5:n.label++;i=u[1];u=[0];continue;case 7:u=n.ops.pop();n.trys.pop();continue;default:if(!(s=n.trys,s=s.length>0&&s[s.length-1])&&(u[0]===6||u[0]===2)){n=0;continue}if(u[0]===3&&(!s||u[1]>s[0]&&u[1]<s[3])){n.label=u[1];break}if(u[0]===6&&n.label<s[1]){n.label=s[1];s=u;break}if(s&&n.label<s[2]){n.label=s[2];n.ops.push(u);break}if(s[2])n.ops.pop();n.trys.pop();continue}u=t.call(e,n)}catch(e){u=[6,e];i=0}finally{r=s=0}if(u[0]&5)throw u[1];return{value:u[0]?u[1]:void 0,done:true}}};System.register(["./p-79150c1d.system.js","./p-86f8a157.system.js"],function(e){"use strict";var t,n,r,i;return{setters:[function(e){t=e.r;n=e.h;r=e.g},function(e){i=e.m}],execute:function(){var s=function(){function e(e){t(this,e);this.services=null;this.buttonLabel="";this.delimiter="";this.disabled=true;this.text="";i.addListener(this)}e.prototype.servicesUpdated=function(){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){this.disabled=!this.services||!this.services.uartService;return[2]})})};e.prototype.handleKey=function(e){if(e.keyCode==13){this.sendText()}else{this.text=e.target.value}};e.prototype.sendText=function(){return __awaiter(this,void 0,void 0,function(){var e;return __generator(this,function(t){switch(t.label){case 0:e=""+this.text+this.delimiter;return[4,this.services.uartService.sendText(e)];case 1:t.sent();return[2]}})})};e.prototype.render=function(){var e=this;var t;if(this.buttonLabel){t=n("input",{type:"submit",disabled:this.disabled,value:this.buttonLabel,onClick:function(){return e.sendText()}})}return n("span",null,n("input",{type:"text",disabled:this.disabled,maxLength:20,onKeyUp:function(t){return e.handleKey(t)}}),t)};Object.defineProperty(e.prototype,"el",{get:function(){return r(this)},enumerable:true,configurable:true});Object.defineProperty(e,"watchers",{get:function(){return{services:["servicesUpdated"]}},enumerable:true,configurable:true});return e}();e("microbit_send",s)}}});