1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
|
!function(t){var n={};function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}e.m=t,e.c=n,e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{enumerable:!0,get:r})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,n){if(1&n&&(t=e(t)),8&n)return t;if(4&n&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(e.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&n&&"string"!=typeof t)for(var o in t)e.d(r,o,function(n){return t[n]}.bind(null,o));return r},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},e.p="",e(e.s=190)}([,,,function(t,n,e){var r=e(6),o=e(19),i=e(16),c=e(20),u=e(23),a=function t(n,e,a){var s,f,l,p,v=n&t.F,d=n&t.G,h=n&t.P,m=n&t.B,y=d?r:n&t.S?r[e]||(r[e]={}):(r[e]||{}).prototype,g=d?o:o[e]||(o[e]={}),_=g.prototype||(g.prototype={});for(s in d&&(a=e),a)l=((f=!v&&y&&void 0!==y[s])?y:a)[s],p=m&&f?u(l,r):h&&"function"==typeof l?u(Function.call,l):l,y&&c(y,s,l,n&t.U),g[s]!=l&&i(g,s,p),h&&_[s]!=l&&(_[s]=l)};r.core=o,a.F=1,a.G=2,a.S=4,a.P=8,a.B=16,a.W=32,a.U=64,a.R=128,t.exports=a},,function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=n.ERR_CONNECTION_DESTROYED="ConnectionDestroyed",o=n.ERR_CONNECTION_TIMEOUT="ConnectionTimeout",i=n.ERR_NOT_IN_IFRAME="NotInIframe",c={"http:":"80","https:":"443"},u=/^(https?:)?\/\/([^\/:]+)(:(\d+))?/,a={ERR_CONNECTION_DESTROYED:r,ERR_CONNECTION_TIMEOUT:o,ERR_NOT_IN_IFRAME:i,Promise:function(){try{return window?window.Promise:null}catch(t){return null}}(),debug:!1},s=function(){var t=0;return function(){return++t}}(),f=function(){for(var t=arguments.length,n=Array(t),e=0;e<t;e++)n[e]=arguments[e];var r;a.debug&&(r=console).log.apply(r,["[Penpal]"].concat(n))},l=function(t){var n=[];return t(function(){n.forEach(function(t){t()})}),{then:function(t){n.push(t)}}},p=function(t){return{name:t.name,message:t.message,stack:t.stack}},v=function(t,n,e,o){var i=n.localName,c=n.local,u=n.remote,l=n.remoteOrigin,p=!1;f(i+": Connecting call sender");var v=function(t){return function(){for(var n=arguments.length,e=Array(n),o=0;o<n;o++)e[o]=arguments[o];if(f(i+": Sending "+t+"() call"),p){var v=new Error("Unable to send "+t+"() call due to destroyed connection");throw v.code=r,v}return new a.Promise(function(n,r){var o=s();c.addEventListener("message",function e(a){if(a.source===u&&a.origin===l&&"reply"===a.data.penpal&&a.data.id===o){f(i+": Received "+t+"() reply"),c.removeEventListener("message",e);var s=a.data.returnValue;a.data.returnValueIsError&&(s=function(t){var n=new Error;return Object.keys(t).forEach(function(e){return n[e]=t[e]}),n}(s)),("fulfilled"===a.data.resolution?n:r)(s)}}),u.postMessage({penpal:"call",id:o,methodName:t,args:e},l)})}};o.then(function(){p=!0}),e.reduce(function(t,n){return t[n]=v(n),t},t)},d=function(t,n,e){var r=t.localName,o=t.local,i=t.remote,c=t.remoteOrigin,u=!1;f(r+": Connecting call receiver");var s=function(t){if(t.source===i&&t.origin===c&&"call"===t.data.penpal){var e=t.data,o=e.methodName,s=e.args,l=e.id;if(f(r+": Received "+o+"() call"),o in n){var v=function(t){return function(n){if(f(r+": Sending "+o+"() reply"),u)f(r+": Unable to send "+o+"() reply due to destroyed connection");else{var e={penpal:"reply",id:l,resolution:t,returnValue:n};"rejected"===t&&n instanceof Error&&(e.returnValue=p(n),e.returnValueIsError=!0);try{i.postMessage(e,c)}catch(t){throw"DataCloneError"===t.name&&i.postMessage({penpal:"reply",id:l,resolution:"rejected",returnValue:p(t),returnValueIsError:!0},c),t}}}};new a.Promise(function(t){return t(n[o].apply(n,s))}).then(v("fulfilled"),v("rejected"))}}};o.addEventListener("message",s),e.then(function(){u=!0,o.removeEventListener("message",s)})};a.connectToChild=function(t){var n=t.url,e=t.appendTo,i=t.methods,s=void 0
|