UNPKG

@liascript/exporter

Version:
2 lines (1 loc) 3.56 kB
!function(){var e=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire55a5;e.register("h7G9L",(function(t,n){var r,i;r=t.exports,i=function(){return v},Object.defineProperty(r,"Sync",{get:i,set:undefined,enumerable:!0,configurable:!0});var o=e("f1evb"),u=e("hnmIs"),s=e("9Klpk"),c=e("3bWnf"),a=e("eT7f3"),l=e("9WzNc"),f=e("div3d"),d=e("kb0qF"),h=e("bWNdT"),y=e("32Euv"),p=e("auvHb"),b=e("ie2ZQ"),v=function(e){"use strict";(0,d.default)(n,e);var t=(0,h.default)(n);function n(){var e;return(0,s.default)(this,n),e=t.apply(this,arguments),(0,a.default)((0,o.default)(e),"subject","liasync"),(0,a.default)((0,o.default)(e),"connected",!1),e}return(0,c.default)(n,[{key:"connect",value:function(e){var t=this,r=this;return(0,u.default)((function(){return(0,y.__generator)(this,(function(i){return(0,l.default)((0,f.default)(n.prototype),"connect",t).call(r,e),r.init(!0),[2]}))}))()}},{key:"destroy",value:function(){this.listener&&window.removeEventListener("message",this.listener),(0,l.default)((0,f.default)(n.prototype),"destroy",this).call(this)}},{key:"init",value:function(e,t){if(e){this.subject=this.room||"liasync";var n=this;this.listener=function(e){try{var t=e.data;switch(t.subject){case"init":t.body&&(n.connected=!0,n.sendConnect());break;case"publish":t.body&&n.pubsubReceive(t.body);break;default:t.body&&n.applyUpdate((0,b.decode)(t.body))}}catch(e){console.warn("Edrys",e.message)}},window.addEventListener("message",this.listener),this.broadcast(!0,null,"init"),setTimeout((function(){n.connected||n.sendDisconnectError("This seems not to be an Edrys classroom")}),2e3)}}},{key:"broadcast",value:function(e,t,n){var r=e?n||this.subject:"publish";window.parent.postMessage({subject:r,body:t?(0,b.encode)(t):null},"*")}}]),n}(p.Sync)})),e.register("84cK9",(function(e,t){var n,r,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function s(e){if(n===setTimeout)return setTimeout(e,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(e){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(e){r=u}}();var c,a=[],l=!1,f=-1;function d(){l&&c&&(l=!1,c.length?a=c.concat(a):f=-1,a.length&&h())}function h(){if(!l){var e=s(d);l=!0;for(var t=a.length;t;){for(c=a,a=[];++f<t;)c&&c[f].run();f=-1,t=a.length}c=null,l=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function y(e,t){this.fun=e,this.array=t}function p(){}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];a.push(new y(e,t)),1!==a.length||l||s(h)},y.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=p,i.addListener=p,i.once=p,i.off=p,i.removeListener=p,i.removeAllListeners=p,i.emit=p,i.prependListener=p,i.prependOnceListener=p,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}}))}();