quickgame-cli
Version:
quickgame cli
1 lines • 3.14 kB
JavaScript
var _interopRequireDefault=require("@babel/runtime/helpers/interopRequireDefault"),_typeof2=_interopRequireDefault(require("@babel/runtime/helpers/typeof"));(()=>{function r(e,t,n){(t=(e=>(e=((e,t)=>{if("object"!=(0,_typeof2.default)(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0===n)return("string"===t?String:Number)(e);if(n=n.call(e,t||"default"),"object"!=(0,_typeof2.default)(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")})(e,"string"),"symbol"==(0,_typeof2.default)(e)?e:e+""))(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n}function o(e){var t=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:[];if(r(this,"binaryType",""),r(this,"bufferedAmount",0),r(this,"extensions",""),r(this,"onclose",null),r(this,"onerror",null),r(this,"onmessage",null),r(this,"onopen",null),r(this,"protocol",""),r(this,"readyState",3),"string"==typeof e&&/(^ws:\/\/)|(^wss:\/\/)/.test(e))return this.url=e,this.readyState=o.CONNECTING,e=qg.connectSocket({url:e,protocols:Array.isArray(n)?n:[n],tcpNoDelay:!0}),i.set(this,e),e.onClose(function(e){t.readyState=o.CLOSED,"function"==typeof t.onclose&&t.onclose(e)}),e.onMessage(function(e){"function"==typeof t.onmessage&&t.onmessage(e)}),e.onOpen(function(){t.readyState=o.OPEN,"function"==typeof t.onopen&&t.onopen()}),e.onError(function(e){"function"==typeof t.onerror&&t.onerror(new Error(e.errMsg))}),this;throw new TypeError("Failed to construct 'WebSocket': The URL '".concat(e,"' is invalid"))}var i=new WeakMap,a=(o.prototype.close=function(e,t){this.readyState=o.CLOSING,i.get(this).close({code:e,reason:t})},o.prototype.send=function(e){if(!("string"==typeof e||e instanceof ArrayBuffer||ArrayBuffer.isView(e)))throw new TypeError("Failed to send message: The data ".concat(e," is invalid"));i.get(this).send({data:e})},r(o,"CONNECTING",0),r(o,"OPEN",1),r(o,"CLOSING",2),r(o,"CLOSED",3),window.WebSocket=o,qg.getFileSystemManager?qg.getFileSystemManager():null),e=(window.fsUtils=Object.assign(window.fsUtils,{readCompressedFileSync:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"br";try{return a.readCompressedFileSync({filePath:t,compressionAlgorithm:e})}catch(e){return console.warn("readCompressedFileSync failed: path: ".concat(t,", message: ").concat(e.message)),new Error(e.message)}},readJsonSync:function(t){try{var e=a.readFileSync(t,"utf8");return JSON.parse(e)}catch(e){return console.warn("Read json failed: path: ".concat(t," message: ").concat(e.message)),new Error(e.message)}},unzip:function(t,e,n){a.unzip({zipFilePath:t,targetPath:e,success:function(){n&&n(null)},fail:function(e){console.warn("unzip failed: path: ".concat(t," message: ").concat(e.errMsg)),n&&n(new Error("unzip failed: ".concat(e.errMsg)))}})}}),{get length(){return qg.getStorageInfoSync().keys.length},key:function(e){return qg.getStorageInfoSync().keys[e]},getItem:function(e){return qg.getStorageSync(e)},setItem:function(e,t){return qg.setStorageSync(e,t)},removeItem:function(e){qg.removeStorageSync(e)},clear:function(){qg.clearStorageSync()}});window.localStorage=e})();