phaser3-rex-plugins
Version:
2 lines (1 loc) • 8.14 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).rexlzstringplugin=t();}(undefined,(function(){function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(o=n.key,i=void 0,"symbol"==typeof(i=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return ("string"===t?String:Number)(e)}(o,"string"))?i:String(i)),n);}var o,i;}function r(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(e){return n=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},n(e)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function i(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return !1;if(Reflect.construct.sham)return !1;if("function"==typeof Proxy)return !0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return !1}}();return function(){var r,o=n(e);if(t){var s=n(this).constructor;r=Reflect.construct(o,arguments,s);}else r=o.apply(this,arguments);return i(this,r)}}function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var c={exports:{}};!function(e){var t=function(){function e(e,t){if(!o[e]){o[e]={};for(var r=0;r<e.length;r++)o[e][e.charAt(r)]=r;}return o[e][t]}var t=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",o={},i={compressToBase64:function(e){if(null==e)return "";var t=i._compress(e,6,(function(e){return r.charAt(e)}));switch(t.length%4){default:case 0:return t;case 1:return t+"===";case 2:return t+"==";case 3:return t+"="}},decompressFromBase64:function(t){return null==t?"":""==t?null:i._decompress(t.length,32,(function(n){return e(r,t.charAt(n))}))},compressToUTF16:function(e){return null==e?"":i._compress(e,15,(function(e){return t(e+32)}))+" "},decompressFromUTF16:function(e){return null==e?"":""==e?null:i._decompress(e.length,16384,(function(t){return e.charCodeAt(t)-32}))},compressToUint8Array:function(e){for(var t=i.compress(e),r=new Uint8Array(2*t.length),n=0,o=t.length;o>n;n++){var s=t.charCodeAt(n);r[2*n]=s>>>8,r[2*n+1]=s%256;}return r},decompressFromUint8Array:function(e){if(null==e)return i.decompress(e);for(var r=new Array(e.length/2),n=0,o=r.length;o>n;n++)r[n]=256*e[2*n]+e[2*n+1];var s=[];return r.forEach((function(e){s.push(t(e));})),i.decompress(s.join(""))},compressToEncodedURIComponent:function(e){return null==e?"":i._compress(e,6,(function(e){return n.charAt(e)}))},decompressFromEncodedURIComponent:function(t){return null==t?"":""==t?null:(t=t.replace(/ /g,"+"),i._decompress(t.length,32,(function(r){return e(n,t.charAt(r))})))},compress:function(e){return i._compress(e,16,(function(e){return t(e)}))},_compress:function(e,t,r){if(null==e)return "";var n,o,i,s={},u={},c="",a="",f="",p=2,l=3,h=2,d=[],m=0,y=0;for(i=0;i<e.length;i+=1)if(c=e.charAt(i),Object.prototype.hasOwnProperty.call(s,c)||(s[c]=l++,u[c]=!0),a=f+c,Object.prototype.hasOwnProperty.call(s,a))f=a;else {if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;h>n;n++)m<<=1,y==t-1?(y=0,d.push(r(m)),m=0):y++;for(o=f.charCodeAt(0),n=0;8>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;}else {for(o=1,n=0;h>n;n++)m=m<<1|o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o=0;for(o=f.charCodeAt(0),n=0;16>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;}0==--p&&(p=Math.pow(2,h),h++),delete u[f];}else for(o=s[f],n=0;h>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;0==--p&&(p=Math.pow(2,h),h++),s[a]=l++,f=String(c);}if(""!==f){if(Object.prototype.hasOwnProperty.call(u,f)){if(f.charCodeAt(0)<256){for(n=0;h>n;n++)m<<=1,y==t-1?(y=0,d.push(r(m)),m=0):y++;for(o=f.charCodeAt(0),n=0;8>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;}else {for(o=1,n=0;h>n;n++)m=m<<1|o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o=0;for(o=f.charCodeAt(0),n=0;16>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;}0==--p&&(p=Math.pow(2,h),h++),delete u[f];}else for(o=s[f],n=0;h>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;0==--p&&(p=Math.pow(2,h),h++);}for(o=2,n=0;h>n;n++)m=m<<1|1&o,y==t-1?(y=0,d.push(r(m)),m=0):y++,o>>=1;for(;;){if(m<<=1,y==t-1){d.push(r(m));break}y++;}return d.join("")},decompress:function(e){return null==e?"":""==e?null:i._decompress(e.length,32768,(function(t){return e.charCodeAt(t)}))},_decompress:function(e,r,n){var o,i,s,u,c,a,f,p=[],l=4,h=4,d=3,m="",y=[],v={val:n(0),position:r,index:1};for(o=0;3>o;o+=1)p[o]=o;for(s=0,c=Math.pow(2,2),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;switch(s){case 0:for(s=0,c=Math.pow(2,8),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;f=t(s);break;case 1:for(s=0,c=Math.pow(2,16),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;f=t(s);break;case 2:return ""}for(p[3]=f,i=f,y.push(f);;){if(v.index>e)return "";for(s=0,c=Math.pow(2,d),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;switch(f=s){case 0:for(s=0,c=Math.pow(2,8),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;p[h++]=t(s),f=h-1,l--;break;case 1:for(s=0,c=Math.pow(2,16),a=1;a!=c;)u=v.val&v.position,v.position>>=1,0==v.position&&(v.position=r,v.val=n(v.index++)),s|=(u>0?1:0)*a,a<<=1;p[h++]=t(s),f=h-1,l--;break;case 2:return y.join("")}if(0==l&&(l=Math.pow(2,d),d++),p[f])m=p[f];else {if(f!==h)return null;m=i+i.charAt(0);}y.push(m),p[h++]=i+m.charAt(0),i=m,0==--l&&(l=Math.pow(2,d),d++);}}};return i}();null!=e&&(e.exports=t);}(c);var a=u(c.exports),f=Phaser.Utils.Objects.GetFastValue,p=function(){function t(r){e(this,t),this.resetFromJSON(r);}return r(t,[{key:"resetFromJSON",value:function(e){return this.setEncoding(f(e,"encoding",0)),this}},{key:"toJSON",value:function(){return {encoding:this.encoding}}},{key:"setEncoding",value:function(e){return void 0===e?e=0:"string"==typeof e&&(e=l[e.toLowerCase()]||0),this.encoding=e,this}},{key:"compress",value:function(e){var t=h[this.encoding];return a[t](e)}},{key:"decompress",value:function(e){var t=d[this.encoding];return a[t](e)}}]),t}(),l={none:0,base64:1,utf16:2,uri:3},h=["compress","compressToBase64","compressToUTF16","compressToEncodedURIComponent"],d=["decompress","decompressFromBase64","decompressFromUTF16","decompressFromEncodedURIComponent"];return function(t){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&o(e,t);}(i,Phaser.Plugins.BasePlugin);var n=s(i);function i(t){var r;return e(this,i),(r=n.call(this,t)).lzstring=new p,r}return r(i,[{key:"start",value:function(){this.game.events.on("destroy",this.destroy,this);}},{key:"destroy",value:function(){this.lzstring=null,this.pluginManager=null,this.game=null,this.scene=null,this.systems=null;}},{key:"add",value:function(e){return new p(e)}}]),i}()}));