@statechannels/channel-provider
Advanced tools
Comparing version 0.0.2-rc0 to 0.0.3
@@ -1,1 +0,1 @@ | ||
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var r,o,i,s,a;function u(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function c(e){return(c="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)}a=function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){if(!u&&"function"==typeof s&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return o(t[a][1][e]||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof s&&s,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,u=365.25*s;function l(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n,f,p=c(e);if("string"===p&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*u;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===p&&!1===isNaN(e))return t.long?(n=e,(f=Math.abs(n))>=s?l(n,f,s,"day"):f>=i?l(n,f,i,"hour"):f>=o?l(n,f,o,"minute"):f>=r?l(n,f,r,"second"):n+" ms"):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],2:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var c,l=[],f=!1,p=-1;function h(){f&&c&&(f=!1,c.length?l=c.concat(l):p=-1,l.length&&d())}function d(){if(!f){var e=u(h);f=!0;for(var t=l.length;t;){for(c=l,l=[];++p<t;)c&&c[p].run();p=-1,t=l.length}c=null,f=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function v(e,t){this.fun=e,this.array=t}function m(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new v(e,t)),1!==l.length||f||u(d)},v.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=m,i.addListener=m,i.once=m,i.off=m,i.removeListener=m,i.removeAllListeners=m,i.emit=m,i.prependListener=m,i.prependOnceListener=m,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],3:[function(e,t,n){t.exports=function(t){function n(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var t;function s(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];if(s.enabled){var i=s,a=Number(new Date),u=a-(t||a);i.diff=u,i.prev=t,i.curr=a,t=a,n[0]=r.coerce(n[0]),"string"!=typeof n[0]&&n.unshift("%O");var c=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,(function(e,t){if("%%"===e)return e;c++;var o=r.formatters[t];if("function"==typeof o){var s=n[c];e=o.call(i,s),n.splice(c,1),c--}return e})),r.formatArgs.call(i,n),(i.log||r.log).apply(i,n)}}return s.namespace=e,s.enabled=r.enabled(e),s.useColors=r.useColors(),s.color=n(e),s.destroy=o,s.extend=i,"function"==typeof r.init&&r.init(s),r.instances.push(s),s}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){var n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){var e=[].concat(u(r.names.map(s)),u(r.skips.map(s).map((function(e){return"-"+e})))).join(",");return r.enable(""),e},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),Object.keys(t).forEach((function(e){r[e]=t[e]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}},{ms:1}],4:[function(e,t,n){(function(r){n.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":c(console))&&console.log&&(e=console).log.apply(e,arguments)},n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){var e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(n),t.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":3,_process:2}]},{},[4])(4)},"object"===c(t)&&void 0!==e?e.exports=a():(o=[],void 0===(i="function"==typeof(r=a)?r.apply(t,o):r)||(e.exports=i))},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,o="~";function i(){}function s(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new s(n,r||e,i),u=o?o+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r<i;r++)s[r]=n[r].fn;return s},c.prototype.listenerCount=function(e){var t=o?o+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,r,i,s){var a=o?o+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,r),!0;case 5:return l.fn.call(l.context,t,n,r,i),!0;case 6:return l.fn.call(l.context,t,n,r,i,s),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,r);break;default:if(!u)for(p=1,u=new Array(f-1);p<f;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},c.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return u(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||r&&!s.once||n&&s.context!==n||u(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=1===c.length?c[0]:c:u(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&u(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=o,c.EventEmitter=c,e.exports=c},function(e,t,n){"use strict";n.r(t);var r,o=n(0),i=n.n(o),s=n(1),a=n.n(s),u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},l=i()("channel-provider:messaging"),f=function(){function e(e){var t=void 0===e?{}:e,n=t.timeoutMs,r=void 0===n?50:n,o=t.maxRetries,i=void 0===o?5:o;this.attempts=0,this.url="",this.timeoutMs=r,this.maxRetries=i}return e.prototype.setUrl=function(e){this.url=e},e.prototype.send=function(e,t,n){var r=this;this.attempts+=1,l("Sending message: %o (attempt #%o)",t,this.attempts),e.postMessage(t,n),l("Sent message: %o",t),this.timeoutListener=setTimeout((function(){r.attempts<r.maxRetries?(l("Request %o timed out after %o ms, retrying",t,r.timeoutMs),r.send(e,t,n)):(l("Request %o timed out after %o attempts; is the wallet unreachable?",t,r.attempts),console.warn("Request timed out after "+r.attempts+" attempts",t))}),this.timeoutMs)},e.prototype.request=function(e,t,n){return u(this,void 0,void 0,(function(){var r=this;return c(this,(function(o){return t.id||(t.id=Date.now()),[2,new Promise((function(o,i){window.addEventListener("message",r.createListenerForMessage(t,o,i,n)),l("Requesting: %o",t),r.send(e,t,r.url)}))]}))}))},e.prototype.acknowledge=function(){l("ACK signal received"),this.timeoutListener&&clearTimeout(this.timeoutListener),this.attempts=0},e.prototype.createListenerForMessage=function(e,t,n,r){var o=function(i){i.data&&i.data.jsonrpc&&i.data.result&&i.data.id===e.id?(r&&r(i.data.result),window.removeEventListener("message",o),l("Received response: %o",i.data),t(i.data.result)):i.data.error&&n(i.data.error)};return o},e}();!function(e){e.Close="ui:wallet:close",e.Acknowledge="ui:wallet:ack"}(r||(r={}));var p=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},h=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},d=i()("channel-provider:ui"),v=function(){function e(){this.url=""}return Object.defineProperty(e.prototype,"container",{get:function(){return document.querySelector("#channelProviderUiContainer")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iframe",{get:function(){return document.querySelector("#channelProviderUi")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"styles",{get:function(){return document.querySelector("#channelProviderUiStyles")},enumerable:!0,configurable:!0}),e.prototype.setUrl=function(e){this.url=e},e.prototype.mount=function(){return p(this,void 0,void 0,(function(){var e=this;return h(this,(function(t){return[2,new Promise((function(t){if(e.iframe)t();else{var n=document.createElement("iframe"),r=document.createElement("style"),o=document.createElement("div");r.id="channelProviderUiStyles",r.innerHTML="iframe#wallet {\n border: 0;\n position: absolute;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n width: 700px;\n height: 500px;\n top: 50%;\n margin-top: -250px;\n overflow: hidden;\n z-index: 1;\n}\ndiv#walletContainer {\n position: absolute;\n left: 0px;\n top: 0px;\n width: 100%;\n height: 100%;\n background: #000;\n opacity: 0.32;\n z-index: 0;\n}",o.id="channelProviderUiContainer",n.id="channelProviderUi",n.src=e.url,n.onload=function(){t()},o.appendChild(n),document.head.appendChild(r),document.body.appendChild(o)}}))]}))}))},e.prototype.unmount=function(){this.iframe&&(this.iframe.remove(),d("UI IFrame removed")),this.container&&(this.container.remove(),d("UI Container removed")),this.styles&&(this.styles.remove(),d("UI Styles removed"))},e.prototype.getTarget=function(){return p(this,void 0,void 0,(function(){var e=this;return h(this,(function(t){return[2,new Promise((function(t){return p(e,void 0,void 0,(function(){var e;return h(this,(function(n){switch(n.label){case 0:return this.iframe?[3,2]:[4,this.mount()];case 1:n.sent(),n.label=2;case 2:return e=this.iframe,t(e.contentWindow),[2]}}))}))}))]}))}))},e}(),m=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},y=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},g=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},b=i()("channel-provider"),C=new(function(){function e(){this.url="http://localhost:1701",this.events=new a.a,this.ui=new v,this.messaging=new f}return e.prototype.enable=function(e){return m(this,void 0,void 0,(function(){return y(this,(function(t){return window.addEventListener("message",this.onMessage.bind(this)),e&&(this.url=e),this.ui.setUrl(this.url),this.messaging.setUrl(this.url),this.events.emit("connect"),[2]}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=[]),m(this,void 0,void 0,(function(){var n;return y(this,(function(r){switch(r.label){case 0:return[4,this.ui.getTarget()];case 1:return n=r.sent(),[4,this.messaging.request(n,{jsonrpc:"2.0",method:e,params:t})];case 2:return[2,r.sent()]}}))}))},e.prototype.subscribe=function(e,t){return void 0===t&&(t=[]),m(this,void 0,void 0,(function(){return y(this,(function(n){switch(n.label){case 0:return[4,this.send("chan_subscribe",g([e],t))];case 1:return[2,n.sent().subscription]}}))}))},e.prototype.unsubscribe=function(e){return m(this,void 0,void 0,(function(){var t;return y(this,(function(n){switch(n.label){case 0:return[4,this.send("chan_unsubscribe",[e])];case 1:return t=n.sent(),this.off(e),[2,t.success]}}))}))},e.prototype.on=function(e,t){this.events.on(e,t)},e.prototype.off=function(e,t){this.events.off(e,t)},e.prototype.onMessage=function(e){return m(this,void 0,void 0,(function(){var t,n;return y(this,(function(o){switch(o.label){case 0:return(t=e.data)===r.Close?(b("Close signal received: %o",t),this.ui.unmount(),[2]):t===r.Acknowledge?(this.messaging.acknowledge(),[2]):!t.jsonrpc||"result"in t?[2]:[4,this.ui.getTarget()];case 1:return n=o.sent(),this.messaging.send(n,t,this.url),[2]}}))}))},e}());n.d(t,"channelProvider",(function(){return C})),n.d(t,"ChannelProviderUIMessage",(function(){return r}))}])); | ||
!function(e,t){for(var n in t)e[n]=t[n]}(window,function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(e,t,n){"use strict";var r,o,i,s,a;function u(e){return function(e){if(Array.isArray(e)){for(var t=0,n=new Array(e.length);t<e.length;t++)n[t]=e[t];return n}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}function c(e){return(c="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)}a=function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){if(!u&&"function"==typeof s&&s)return s(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,(function(e){return o(t[a][1][e]||e)}),l,l.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof s&&s,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){var r=1e3,o=60*r,i=60*o,s=24*i,a=7*s,u=365.25*s;function l(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}t.exports=function(e,t){t=t||{};var n,f,p=c(e);if("string"===p&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var t=/^((?:\d+)?\-?\d?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var n=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return n*u;case"weeks":case"week":case"w":return n*a;case"days":case"day":case"d":return n*s;case"hours":case"hour":case"hrs":case"hr":case"h":return n*i;case"minutes":case"minute":case"mins":case"min":case"m":return n*o;case"seconds":case"second":case"secs":case"sec":case"s":return n*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return n;default:return}}}}(e);if("number"===p&&!1===isNaN(e))return t.long?(n=e,(f=Math.abs(n))>=s?l(n,f,s,"day"):f>=i?l(n,f,i,"hour"):f>=o?l(n,f,o,"minute"):f>=r?l(n,f,r,"second"):n+" ms"):function(e){var t=Math.abs(e);return t>=s?Math.round(e/s)+"d":t>=i?Math.round(e/i)+"h":t>=o?Math.round(e/o)+"m":t>=r?Math.round(e/r)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},{}],2:[function(e,t,n){var r,o,i=t.exports={};function s(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{o="function"==typeof clearTimeout?clearTimeout:a}catch(e){o=a}}();var c,l=[],f=!1,p=-1;function h(){f&&c&&(f=!1,c.length?l=c.concat(l):p=-1,l.length&&d())}function d(){if(!f){var e=u(h);f=!0;for(var t=l.length;t;){for(c=l,l=[];++p<t;)c&&c[p].run();p=-1,t=l.length}c=null,f=!1,function(e){if(o===clearTimeout)return clearTimeout(e);if((o===a||!o)&&clearTimeout)return o=clearTimeout,clearTimeout(e);try{o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function v(){}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new m(e,t)),1!==l.length||f||u(d)},m.prototype.run=function(){this.fun.apply(null,this.array)},i.title="browser",i.browser=!0,i.env={},i.argv=[],i.version="",i.versions={},i.on=v,i.addListener=v,i.once=v,i.off=v,i.removeListener=v,i.removeAllListeners=v,i.emit=v,i.prependListener=v,i.prependOnceListener=v,i.listeners=function(e){return[]},i.binding=function(e){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(e){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}},{}],3:[function(e,t,n){t.exports=function(t){function n(e){for(var t=0,n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return r.colors[Math.abs(t)%r.colors.length]}function r(e){var t;function s(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];if(s.enabled){var i=s,a=Number(new Date),u=a-(t||a);i.diff=u,i.prev=t,i.curr=a,t=a,n[0]=r.coerce(n[0]),"string"!=typeof n[0]&&n.unshift("%O");var c=0;n[0]=n[0].replace(/%([a-zA-Z%])/g,(function(e,t){if("%%"===e)return e;c++;var o=r.formatters[t];if("function"==typeof o){var s=n[c];e=o.call(i,s),n.splice(c,1),c--}return e})),r.formatArgs.call(i,n),(i.log||r.log).apply(i,n)}}return s.namespace=e,s.enabled=r.enabled(e),s.useColors=r.useColors(),s.color=n(e),s.destroy=o,s.extend=i,"function"==typeof r.init&&r.init(s),r.instances.push(s),s}function o(){var e=r.instances.indexOf(this);return-1!==e&&(r.instances.splice(e,1),!0)}function i(e,t){var n=r(this.namespace+(void 0===t?":":t)+e);return n.log=this.log,n}function s(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return r.debug=r,r.default=r,r.coerce=function(e){return e instanceof Error?e.stack||e.message:e},r.disable=function(){var e=[].concat(u(r.names.map(s)),u(r.skips.map(s).map((function(e){return"-"+e})))).join(",");return r.enable(""),e},r.enable=function(e){var t;r.save(e),r.names=[],r.skips=[];var n=("string"==typeof e?e:"").split(/[\s,]+/),o=n.length;for(t=0;t<o;t++)n[t]&&("-"===(e=n[t].replace(/\*/g,".*?"))[0]?r.skips.push(new RegExp("^"+e.substr(1)+"$")):r.names.push(new RegExp("^"+e+"$")));for(t=0;t<r.instances.length;t++){var i=r.instances[t];i.enabled=r.enabled(i.namespace)}},r.enabled=function(e){if("*"===e[e.length-1])return!0;var t,n;for(t=0,n=r.skips.length;t<n;t++)if(r.skips[t].test(e))return!1;for(t=0,n=r.names.length;t<n;t++)if(r.names[t].test(e))return!0;return!1},r.humanize=e("ms"),Object.keys(t).forEach((function(e){r[e]=t[e]})),r.instances=[],r.names=[],r.skips=[],r.formatters={},r.selectColor=n,r.enable(r.load()),r}},{ms:1}],4:[function(e,t,n){(function(r){n.log=function(){var e;return"object"===("undefined"==typeof console?"undefined":c(console))&&console.log&&(e=console).log.apply(e,arguments)},n.formatArgs=function(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+t.exports.humanize(this.diff),this.useColors){var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var r=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(r++,"%c"===e&&(o=r))})),e.splice(o,0,n)}},n.save=function(e){try{e?n.storage.setItem("debug",e):n.storage.removeItem("debug")}catch(e){}},n.load=function(){var e;try{e=n.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e},n.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},n.storage=function(){try{return localStorage}catch(e){}}(),n.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.exports=e("./common")(n),t.exports.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}).call(this,e("_process"))},{"./common":3,_process:2}]},{},[4])(4)},"object"===c(t)&&void 0!==e?e.exports=a():(o=[],void 0===(i="function"==typeof(r=a)?r.apply(t,o):r)||(e.exports=i))},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,o="~";function i(){}function s(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function a(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var a=new s(n,r||e,i),u=o?o+t:t;return e._events[u]?e._events[u].fn?e._events[u]=[e._events[u],a]:e._events[u].push(a):(e._events[u]=a,e._eventsCount++),e}function u(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),c.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},c.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,s=new Array(i);r<i;r++)s[r]=n[r].fn;return s},c.prototype.listenerCount=function(e){var t=o?o+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,r,i,s){var a=o?o+e:e;if(!this._events[a])return!1;var u,c,l=this._events[a],f=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),f){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,n),!0;case 4:return l.fn.call(l.context,t,n,r),!0;case 5:return l.fn.call(l.context,t,n,r,i),!0;case 6:return l.fn.call(l.context,t,n,r,i,s),!0}for(c=1,u=new Array(f-1);c<f;c++)u[c-1]=arguments[c];l.fn.apply(l.context,u)}else{var p,h=l.length;for(c=0;c<h;c++)switch(l[c].once&&this.removeListener(e,l[c].fn,void 0,!0),f){case 1:l[c].fn.call(l[c].context);break;case 2:l[c].fn.call(l[c].context,t);break;case 3:l[c].fn.call(l[c].context,t,n);break;case 4:l[c].fn.call(l[c].context,t,n,r);break;default:if(!u)for(p=1,u=new Array(f-1);p<f;p++)u[p-1]=arguments[p];l[c].fn.apply(l[c].context,u)}}return!0},c.prototype.on=function(e,t,n){return a(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return a(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return u(this,i),this;var s=this._events[i];if(s.fn)s.fn!==t||r&&!s.once||n&&s.context!==n||u(this,i);else{for(var a=0,c=[],l=s.length;a<l;a++)(s[a].fn!==t||r&&!s[a].once||n&&s[a].context!==n)&&c.push(s[a]);c.length?this._events[i]=1===c.length?c[0]:c:u(this,i)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&u(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=o,c.EventEmitter=c,e.exports=c},function(e,t,n){"use strict";n.r(t);var r,o=n(0),i=n.n(o),s=n(1),a=n.n(s),u=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},c=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},l=i()("channel-provider:messaging"),f=function(){function e(e){var t=void 0===e?{}:e,n=t.timeoutMs,r=void 0===n?50:n,o=t.maxRetries,i=void 0===o?5:o;this.attempts=0,this.url="",this.timeoutMs=r,this.maxRetries=i}return e.prototype.setUrl=function(e){this.url=e},e.prototype.send=function(e,t,n){var r=this;this.attempts+=1,l("Sending message: %o (attempt #%o)",t,this.attempts),e.postMessage(t,n),l("Sent message: %o",t),this.timeoutListener=setTimeout((function(){r.attempts<r.maxRetries?(l("Request %o timed out after %o ms, retrying",t,r.timeoutMs),r.send(e,t,n)):(l("Request %o timed out after %o attempts; is the wallet unreachable?",t,r.attempts),console.warn("Request timed out after "+r.attempts+" attempts",t))}),this.timeoutMs)},e.prototype.request=function(e,t,n){return u(this,void 0,void 0,(function(){var r=this;return c(this,(function(o){return t.id||(t.id=Date.now()),[2,new Promise((function(o,i){window.addEventListener("message",r.createListenerForMessage(t,o,i,n)),l("Requesting: %o",t),r.send(e,t,r.url)}))]}))}))},e.prototype.acknowledge=function(){l("ACK signal received"),this.timeoutListener&&clearTimeout(this.timeoutListener),this.attempts=0},e.prototype.createListenerForMessage=function(e,t,n,r){var o=function(i){i.data&&i.data.jsonrpc&&i.data.result&&i.data.id===e.id?(r&&r(i.data.result),window.removeEventListener("message",o),l("Received response: %o",i.data),t(i.data.result)):i.data.error&&n(i.data.error)};return o},e}();!function(e){e.Close="ui:wallet:close",e.Acknowledge="ui:wallet:ack"}(r||(r={}));var p,h=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},d=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},m=i()("channel-provider:ui");!function(e){e.Styles="channelProviderUiStyles",e.Container="channelProviderUiContainer",e.IFrame="channelProviderUi"}(p||(p={}));var v="iframe#"+p.IFrame+" {\n border: 0;\n position: absolute;\n left: 0;\n right: 0;\n margin-left: auto;\n margin-right: auto;\n width: 700px;\n height: 500px;\n top: 50%;\n margin-top: -250px;\n overflow: hidden;\n z-index: 1;\n}\ndiv#"+p.Container+" {\n position: absolute;\n left: 0px;\n top: 0px;\n width: 100%;\n height: 100%;\n background: #000;\n opacity: 0.32;\n z-index: 0;\n}",y=function(){function e(){this.url=""}return Object.defineProperty(e.prototype,"container",{get:function(){return document.querySelector("#"+p.Container)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iframe",{get:function(){return document.querySelector("#"+p.IFrame)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"styles",{get:function(){return document.querySelector("#"+p.Styles)},enumerable:!0,configurable:!0}),e.prototype.setUrl=function(e){this.url=e},e.prototype.mount=function(){return h(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t){if(e.iframe)t();else{var n=document.createElement("iframe"),r=document.createElement("style"),o=document.createElement("div");r.id=p.Styles,r.innerHTML=v,o.id=p.Container,n.id=p.IFrame,n.src=e.url,n.onload=function(){t()},o.appendChild(n),document.head.appendChild(r),document.body.appendChild(o)}}))]}))}))},e.prototype.unmount=function(){this.iframe&&(this.iframe.remove(),m("UI IFrame removed")),this.container&&(this.container.remove(),m("UI Container removed")),this.styles&&(this.styles.remove(),m("UI Styles removed"))},e.prototype.getTarget=function(){return h(this,void 0,void 0,(function(){var e=this;return d(this,(function(t){return[2,new Promise((function(t){return h(e,void 0,void 0,(function(){var e;return d(this,(function(n){switch(n.label){case 0:return this.iframe?[3,2]:[4,this.mount()];case 1:n.sent(),n.label=2;case 2:return e=this.iframe,t(e.contentWindow),[2]}}))}))}))]}))}))},e}(),g=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{u(r.next(e))}catch(e){i(e)}}function a(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}u((r=r.apply(e,t||[])).next())}))},b=function(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=(o=s.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}},C=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r},w=i()("channel-provider"),F=new(function(){function e(){this.url="http://localhost:1701",this.events=new a.a,this.ui=new y,this.messaging=new f}return e.prototype.enable=function(e){return g(this,void 0,void 0,(function(){return b(this,(function(t){return window.addEventListener("message",this.onMessage.bind(this)),e&&(this.url=e),this.ui.setUrl(this.url),this.messaging.setUrl(this.url),this.events.emit("connect"),[2]}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=[]),g(this,void 0,void 0,(function(){var n;return b(this,(function(r){switch(r.label){case 0:return[4,this.ui.getTarget()];case 1:return n=r.sent(),[4,this.messaging.request(n,{jsonrpc:"2.0",method:e,params:t})];case 2:return[2,r.sent()]}}))}))},e.prototype.subscribe=function(e,t){return void 0===t&&(t=[]),g(this,void 0,void 0,(function(){return b(this,(function(n){switch(n.label){case 0:return[4,this.send("chan_subscribe",C([e],t))];case 1:return[2,n.sent().subscription]}}))}))},e.prototype.unsubscribe=function(e){return g(this,void 0,void 0,(function(){var t;return b(this,(function(n){switch(n.label){case 0:return[4,this.send("chan_unsubscribe",[e])];case 1:return t=n.sent(),this.off(e),[2,t.success]}}))}))},e.prototype.on=function(e,t){this.events.on(e,t)},e.prototype.off=function(e,t){this.events.off(e,t)},e.prototype.onMessage=function(e){return g(this,void 0,void 0,(function(){var t,n;return b(this,(function(o){switch(o.label){case 0:return(t=e.data)===r.Close?(w("Close signal received: %o",t),this.ui.unmount(),[2]):t===r.Acknowledge?(this.messaging.acknowledge(),[2]):!t.jsonrpc||"result"in t?[2]:[4,this.ui.getTarget()];case 1:return n=o.sent(),this.messaging.send(n,t,this.url),[2]}}))}))},e}());n.d(t,"channelProvider",(function(){return F})),n.d(t,"ChannelProviderUIMessage",(function(){return r}))}])); |
{ | ||
"name": "@statechannels/channel-provider", | ||
"license": "MIT", | ||
"version": "0.0.2-rc0", | ||
"version": "0.0.3", | ||
"main": "dist/channel-provider.min.js", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
@@ -5,3 +5,9 @@ import debug from 'debug'; | ||
const cssStyles = `iframe#wallet { | ||
export enum UIElementNames { | ||
Styles = 'channelProviderUiStyles', | ||
Container = 'channelProviderUiContainer', | ||
IFrame = 'channelProviderUi' | ||
} | ||
export const cssStyles = `iframe#${UIElementNames.IFrame} { | ||
border: 0; | ||
@@ -20,3 +26,3 @@ position: absolute; | ||
} | ||
div#walletContainer { | ||
div#${UIElementNames.Container} { | ||
position: absolute; | ||
@@ -34,11 +40,11 @@ left: 0px; | ||
protected get container(): HTMLDivElement | null { | ||
return document.querySelector('#channelProviderUiContainer'); | ||
return document.querySelector(`#${UIElementNames.Container}`); | ||
} | ||
protected get iframe(): HTMLIFrameElement | null { | ||
return document.querySelector('#channelProviderUi'); | ||
return document.querySelector(`#${UIElementNames.IFrame}`); | ||
} | ||
protected get styles(): HTMLStyleElement | null { | ||
return document.querySelector('#channelProviderUiStyles'); | ||
return document.querySelector(`#${UIElementNames.Styles}`); | ||
} | ||
@@ -63,8 +69,8 @@ | ||
style.id = 'channelProviderUiStyles'; | ||
style.id = UIElementNames.Styles; | ||
style.innerHTML = cssStyles; | ||
container.id = 'channelProviderUiContainer'; | ||
container.id = UIElementNames.Container; | ||
iframe.id = 'channelProviderUi'; | ||
iframe.id = UIElementNames.IFrame; | ||
iframe.src = this.url; | ||
@@ -71,0 +77,0 @@ iframe.onload = () => { |
@@ -1,2 +0,2 @@ | ||
import {UIService} from '../src/ui-service'; | ||
import {cssStyles, UIElementNames, UIService} from '../src/ui-service'; | ||
@@ -11,6 +11,11 @@ describe('UIService', () => { | ||
it('should reference the correct UI elements in the style definition', () => { | ||
expect(cssStyles).toMatch(`iframe#${UIElementNames.IFrame}`); | ||
expect(cssStyles).toMatch(`div#${UIElementNames.Container}`); | ||
}); | ||
it('should mount the UI', async () => { | ||
expect(document.querySelector('#channelProviderUiStyles')).toBeInstanceOf(HTMLStyleElement); | ||
expect(document.querySelector('#channelProviderUiContainer')).toBeInstanceOf(HTMLDivElement); | ||
expect(document.querySelector('#channelProviderUi')).toBeInstanceOf(HTMLIFrameElement); | ||
expect(document.querySelector(`#${UIElementNames.Styles}`)).toBeInstanceOf(HTMLStyleElement); | ||
expect(document.querySelector(`#${UIElementNames.Container}`)).toBeInstanceOf(HTMLDivElement); | ||
expect(document.querySelector(`#${UIElementNames.IFrame}`)).toBeInstanceOf(HTMLIFrameElement); | ||
}); | ||
@@ -21,5 +26,5 @@ | ||
expect(document.querySelector('#channelProviderUiStyles')).toBe(null); | ||
expect(document.querySelector('#channelProviderUiContainer')).toBe(null); | ||
expect(document.querySelector('#channelProviderUi')).toBe(null); | ||
expect(document.querySelector(`#${UIElementNames.Styles}`)).toBe(null); | ||
expect(document.querySelector(`#${UIElementNames.Container}`)).toBe(null); | ||
expect(document.querySelector(`#${UIElementNames.IFrame}`)).toBe(null); | ||
}); | ||
@@ -26,0 +31,0 @@ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
193683
2072