@liascript/exporter
Version:
A generic exporter for LiaScript
2 lines (1 loc) • 4.89 kB
JavaScript
!function(){var t=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequire55a5;t.register("lCGwp",(function(e,n){var r,i;r=e.exports,i=function(){return m},Object.defineProperty(r,"Sync",{get:i,set:undefined,enumerable:!0,configurable:!0});var o=t("hnmIs"),u=t("9Klpk"),c=t("3bWnf"),s=t("9WzNc"),a=t("div3d"),l=t("kb0qF"),f=t("5ENmm"),d=t("bWNdT"),h=t("32Euv"),p=t("auvHb"),b={nostr:null,mqtt:null,torrent:null},m=function(e){"use strict";(0,l.default)(r,e);var n=(0,d.default)(r);function r(t,e,i,o,c){var s,a=arguments.length>5&&void 0!==arguments[5]&&arguments[5],l=!(arguments.length>6&&void 0!==arguments[6])||arguments[6];return(0,u.default)(this,r),(s=n.call(this,e,i,o,c,a,l)).backend=t,s}return(0,c.default)(r,[{key:"destroy",value:function(){this.connection&&this.connection.leave(),(0,s.default)((0,a.default)(r.prototype),"destroy",this).call(this)}},{key:"connect",value:function(e){var n=this,i=this;return(0,o.default)((function(){return(0,h.__generator)(this,(function(o){if((0,s.default)((0,a.default)(r.prototype),"connect",n).call(i,e),b[i.backend])return i.init(!0),[2];switch(i.backend){case"nostr":t("5ZdQa").then((function(t){b.nostr=t.joinRoom,i.init(!0)})).catch((function(t){i.init(!1,t.message)}));break;case"mqtt":t("8G6Vu").then((function(t){b.mqtt=t.joinRoom,i.init(!0)})).catch((function(t){i.init(!1,t.message)}));break;case"torrent":t("kEbLv").then((function(t){b.torrent=t.joinRoom,i.init(!0)})).catch((function(t){i.init(!1,t.message)}))}return[2]}))}))()}},{key:"init",value:function(t,e){var n=this.uniqueID();if(t&&n){var r={appId:"liascript"};this.password&&(r.password=this.password);var i=JSON.parse("null");i&&(r.rtcConfig=i),this.connection=b[this.backend](r,n),this.connection.onPeerJoin((function(t){return console.log("".concat(t," joined"))})),this.connection.onPeerLeave((function(t){return console.log("".concat(t," left"))}));var o=(0,f.default)(this.connection.makeAction("message"),2),u=o[0],c=o[1];this.pub=u,this.sub=c;var s=this;this.sub((function(t,e){if(t)try{var n=(0,f.default)(t,3),r=n[0],i=n[1],o=n[2];if(r){if(null===i)return;o==s.db.timestamp?s.applyUpdate(p.base64_to_unit8(i)):o>s.db.timestamp?s.broadcast(!0,s.db.encode()):(s.db.timestamp=o,s.applyUpdate(p.base64_to_unit8(i),!0))}else s.pubsubReceive(p.base64_to_unit8(i))}catch(t){console.warn(s.backend,t.message)}})),this.sendConnect()}else{var a=this.backend+" unknown error";e&&(a="Could not load resource: "+e),this.sendDisconnectError(a)}}},{key:"broadcast",value:function(t,e){if(this.publish){var n=null==e?null:p.uint8_to_base64(e);this.pub([t,n,this.db.timestamp])}}}]),r}(p.Sync)})),t.register("5ZdQa",(function(e,n){e.exports=t("3OMJO")(t("5B9gS").getBundleURL("bFNS0")+t("b9xd4").resolve("6gAOH")).then((function(){return t("1UDrq")}))})),t.register("8G6Vu",(function(e,n){e.exports=t("3OMJO")(t("5B9gS").getBundleURL("bFNS0")+t("b9xd4").resolve("7U1md")).then((function(){return t("aB40U")}))})),t.register("kEbLv",(function(e,n){e.exports=t("3OMJO")(t("5B9gS").getBundleURL("bFNS0")+t("b9xd4").resolve("jnhCd")).then((function(){return t("E0fFs")}))})),t.register("84cK9",(function(t,e){var n,r,i=t.exports={};function o(){throw new Error("setTimeout has not been defined")}function u(){throw new Error("clearTimeout has not been defined")}function c(t){if(n===setTimeout)return setTimeout(t,0);if((n===o||!n)&&setTimeout)return n=setTimeout,setTimeout(t,0);try{return n(t,0)}catch(e){try{return n.call(null,t,0)}catch(e){return n.call(this,t,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:o}catch(t){n=o}try{r="function"==typeof clearTimeout?clearTimeout:u}catch(t){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 t=c(d);l=!0;for(var e=a.length;e;){for(s=a,a=[];++f<e;)s&&s[f].run();f=-1,e=a.length}s=null,l=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===u||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function b(){}i.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)e[n-1]=arguments[n];a.push(new p(t,e)),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=b,i.addListener=b,i.once=b,i.off=b,i.removeListener=b,i.removeAllListeners=b,i.emit=b,i.prependListener=b,i.prependOnceListener=b,i.listeners=function(t){return[]},i.binding=function(t){throw new Error("process.binding is not supported")},i.cwd=function(){return"/"},i.chdir=function(t){throw new Error("process.chdir is not supported")},i.umask=function(){return 0}}))}();