UNPKG

@liascript/exporter

Version:
2 lines (1 loc) 4.13 kB
!function(){function e(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}var t=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire55a5;t.register("h7G9L",(function(n,r){e(n.exports,"Sync",(function(){return b}));var i=t("f1evb"),o=t("hnmIs"),u=t("9Klpk"),c=t("3bWnf"),s=t("eT7f3"),a=t("9WzNc"),l=t("div3d"),f=t("kb0qF"),d=t("bWNdT"),h=t("32Euv"),p=t("auvHb"),y=t("ie2ZQ"),b=function(e){"use strict";(0,f.default)(n,e);var t=(0,d.default)(n);function n(){var e;return(0,u.default)(this,n),e=t.apply(this,arguments),(0,s.default)((0,i.default)(e),"subject","liasync"),(0,s.default)((0,i.default)(e),"connected",!1),e}return(0,c.default)(n,[{key:"connect",value:function(e){var t=this,r=this;return(0,o.default)((function(){return(0,h.__generator)(this,(function(i){return(0,a.default)((0,l.default)(n.prototype),"connect",t).call(r,e),r.init(!0),[2]}))}))()}},{key:"destroy",value:function(){this.listener&&window.removeEventListener("message",this.listener),(0,a.default)((0,l.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,y.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,y.encode)(t):null},"*")}}]),n}(p.Sync)})),t.register("9WzNc",(function(n,r){e(n.exports,"default",(function(){return u}));var i=t("jwduU");function o(e,t,n){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=(0,i.default)(e,t);if(r){var o=Object.getOwnPropertyDescriptor(r,t);return o.get?o.get.call(n||e):o.value}},o(e,t,n)}function u(e,t,n){return o(e,t,n)}})),t.register("jwduU",(function(n,r){e(n.exports,"default",(function(){return o}));var i=t("div3d");function o(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=(0,i.default)(e)););return e}})),t.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 c(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 s,a=[],l=!1,f=-1;function d(){l&&s&&(l=!1,s.length?a=s.concat(a):f=-1,a.length&&h())}function h(){if(!l){var e=c(d);l=!0;for(var t=a.length;t;){for(s=a,a=[];++f<t;)s&&s[f].run();f=-1,t=a.length}s=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 p(e,t){this.fun=e,this.array=t}function y(){}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 p(e,t)),1!==a.length||l||c(h)},p.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=y,i.addListener=y,i.once=y,i.off=y,i.removeListener=y,i.removeAllListeners=y,i.emit=y,i.prependListener=y,i.prependOnceListener=y,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}}))}();