@oppo-minigame/cli
Version:
Command line interface for rapid OPPO minigame development
1 lines • 8.39 kB
JavaScript
!function(e){var t={};function s(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,s),r.l=!0,r.exports}s.m=e,s.c=t,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)s.d(n,r,function(t){return e[t]}.bind(null,r));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";s.r(t);const n=e=>{if(!e||"object"!=typeof e||e instanceof Array)return;const t=Object.keys(e);if(0!=t.length)for(let s of t)if(null!=e[s]&&"object"==typeof e[s]&&!(e[s]instanceof Array))if(e[s]instanceof ArrayBuffer){const t=new Uint8Array(e[s]);o(`buffer:${e.primaryKey||e.responseURL}:${s}`,t),e[s]=`buffer:${e.primaryKey||e.responseURL}:${s}`}else e[s]instanceof Uint8Array?(o(`buffer:${e.primaryKey||e.responseURL}:${s}`,e[s]),e[s]=`buffer:${e.primaryKey||e.responseURL}:${s}`):n(e[s])},r=e=>{if(!e||"object"!=typeof e||e instanceof Array)return;const t=Object.keys(e);if(0!=t.length)for(let s of t)null!=e[s]&&"object"==typeof e[s]?r(e[s]):"string"==typeof e[s]&&"buffer"==e[s].split(":")[0]&&(e[s]=new Uint8Array(a(e[s])))},i=e=>{if(!e||"object"!=typeof e||e instanceof Array)return;const t=Object.keys(e);if(0!=t.length)for(let s of t)null!=e[s]&&"object"==typeof e[s]?i(e[s]):"string"==typeof e[s]&&"buffer"==e[s].split(":")[0]&&c(e[s])},o=(e,t)=>{const s=qg.getFileSystemManager(),n=qg.env.USER_DATA_PATH+"/"+e;s.writeFileSync(n,t,"binary")},a=e=>{const t=qg.getFileSystemManager(),s=qg.env.USER_DATA_PATH+"/"+e;return t.readFileSync(s,"binary")},c=e=>{const t=qg.getFileSystemManager(),s=qg.env.USER_DATA_PATH+"/"+e;t.unlinkSync(s)};var u=class{constructor(e){this.fs=qg.getFileSystemManager()}read(e){try{this.fs.accessSync(qg.env.USER_DATA_PATH+"/dbs");const e=this.fs.readFileSync(qg.env.USER_DATA_PATH+"/dbs","utf8");return e?JSON.parse(e):null}catch(e){return null}}write(e){var t=this.read(e);t||(t={});const{name:s,callback:r=(e=>e),indexNames:i,storeDatas:o,...a}=e,{indexNames:c={},...u}=t[s]||{};window.qg&&o&&(Object.keys(o).forEach(e=>{const t=o[e];"object"==typeof t&&n(t)}),t[s]||(t[s]={}),t[s].storeDatas=o),t[s]={...u,...a,storeDatas:o,indexNames:{...c,...i}},this.fs.writeFile({filePath:qg.env.USER_DATA_PATH+"/dbs",data:JSON.stringify(t),encoding:"utf8",success:function(){r(!0)},fail:function(){r(!1)}})}append(){}};var l=class{constructor(e=[]){this.contains=function(e){return!!~this.item.indexOf(e)},this.item=e,this.length=this.item.length}};var h=class{constructor(e){if(this.direction="next",this._storeDatas=e.storeDatas.slice(),this.request=e.request||null,this.source=e.source||null,this._storeDatas.length>0){const e=this._storeDatas.shift();this.key=e[this.source.name],this.primaryKey=e.primaryKey}}continue(){if(this._storeDatas.length>0){const e=this._storeDatas.shift();this.key=e[this.source.name],this.primaryKey=e.primaryKey,this.request.onsuccess({target:{result:this}})}else this.request.onsuccess({target:{result:null}})}};var f=class{constructor(e){this.name=e.name,this.keyPath=e.keyPath,this.multiEntry=!1,this.unique=e.unique||!1,this.objectStore=e.objectStore}get(e){}getKey(e){}getAll(e,t){}getAllKeys(e,t){}count(e){}openCursor(e){}openKeyCursor(){const e=this.objectStore._iDBRequest;return setTimeout(()=>{if(e.onsuccess){const t=(new u).read(),{source:{name:s},result:n}=e,r=t[n.name].storeDatas?t[n.name].storeDatas[s]:[],i=[];Object.keys(r).forEach(e=>{i.push(r[e])}),e.onsuccess({target:{result:i.length>0?new h({source:this,request:e,storeDatas:i}):null}})}},10),e}};var m=class{constructor(e,t){this.name=e,this.keyPath=t.keyPath||"",this.indexNames=t.indexNames||new l,this.transaction=t.transaction,this.autoIncrement=t.autoIncrement||!1,this._iDBRequest=new w(this.transaction.db.name,this.transaction.db.version,{source:this}),this._fs=new u}put(e,t){const{db:s}=this.transaction,{storeDatas:n={}}=s;t||(t=e[""+this.keyPath]),n[""+this.name]||(n[""+this.name]={}),Object.keys(e).forEach(t=>{e[t]instanceof Date&&"timestamp"==t&&(e[t]=e[t].getTime())});let r=n[""+this.name][t];return r={...r,...e,primaryKey:t},n[""+this.name][t]=r,s.storeDatas=n,this._fs.write({...s}),setTimeout(()=>{this._iDBRequest.onsuccess&&this._iDBRequest.onsuccess({target:{result:null}})},0),this._iDBRequest}add(e,t){return this.put(e,t)}delete(e){const{db:t}=this.transaction,{storeDatas:s={}}=t,n=s[""+this.name];return n&&n[e]?(i(n[e]),delete n[e],this._fs.write({...t}),setTimeout(()=>{this._iDBRequest.onsuccess&&this._iDBRequest.onsuccess({target:{result:null}})},0)):setTimeout(()=>{this._iDBRequest.onerror&&this._iDBRequest.onerror({preventDefault:()=>{}})},0),this._iDBRequest}clear(){}get(e){if(~e.indexOf("wasm.framework.unityweb")||~e.indexOf("data.unityweb")||~e.indexOf("wasm.code.unityweb"))setTimeout(()=>{this._iDBRequest.onsuccess&&this._iDBRequest.onsuccess({target:{}})},0);else{const{db:t}=this.transaction,{storeDatas:s={}}=t;if(s[""+this.name]&&s[""+this.name][e]){const t=this._iDBRequest.result=s[""+this.name][e];if(r(t),t.timestamp){const{timestamp:e}=t;t.timestamp=new Date(e)}setTimeout(()=>{this._iDBRequest.onsuccess&&this._iDBRequest.onsuccess({target:{result:t}})},0)}else setTimeout(()=>{this._iDBRequest.onerror&&this._iDBRequest.onerror({error:`${this.name} not found | ${e} not found`,preventDefault(){}})},0)}return this._iDBRequest}getKey(e){}getAll(e,t){}getAllKeys(e,t){}count(e){}index(e){return new f({name:e,keyPath:e,objectStore:this})}createIndex(e,t,s){this.indexNames.item.push(e),(new u).write({name:this.transaction.db.name,indexNames:{[""+this.name]:{keyPath:this.keyPath,indexNames:this.indexNames}}})}deleteIndex(e){}};class d extends EventTarget{constructor(e){super(),this.objectStoreNames=e.objectStoreNames,this.mode=null,this.db=e.db,this.error=e.error||null,this.abort=e.abort||null}objectStore(e){if(this.objectStoreNames&&this.objectStoreNames.contains&&!this.objectStoreNames.contains(e))throw"NotFoundError";var t;return this.db.indexNames&&~this.db.indexNames[e]&&(t=this.db.indexNames[e]),new m(e,{transaction:this,indexNames:t?t.indexNames:new l,keyPath:t?t.keyPath:""})}}var y=d;class b extends EventTarget{constructor(e,t,s){super(),this.name=e,this.version=t,this.objectStoreNames=new l,this.onabort=null,this.onclose=null,this.onerror=null,this.onversionchange=null;var n=new u,r=n.read(),i=r&&r[e];const{callback:o=(e=>e),initTransaction:a}=s;a&&(a=new y({db:this})),setTimeout(()=>{if(!i||i.version<t)n.write({name:e,version:t,callback:e=>{o(e)}});else{if(i.version<t)throw"The value of version is less than exist version";o(!1)}},0)}close(){}createObjectStore(e,t){var s=new m(e,{...t,transaction:new y({db:this})});return this.objectStoreNames.item.push(e),setTimeout(()=>{(new u).write({name:this.name,objectStoreNames:this.objectStoreNames})},0),s}deleteObjectStore(e){}transaction(e,t){var s=(new u).read(),n=s&&s[this.name]||{},r=n&&n.objectStoreNames&&n.objectStoreNames.item||[],i=[];return("string"==typeof e?[e]:e).forEach(e=>{if(r.length>0&&-1===r.indexOf(e))throw"The specified object store was not found.";i.push(e)}),new y({db:{...this,...n},objectStoreNames:new l(i)})}}var p=b;class g extends EventTarget{constructor(e,t,s={}){super(),this.transaction=s.transaction||null,this.result=new p(e,t,{...s,initTransaction:this.transaction}),this.error=null,this.source=s.source||null,this.readyState=s.readyState||null,this.onerror=null,this.onsuccess=null}}var w=g;var D=class extends w{constructor(e,t,s){super(e,t,s),this.onblocked=null,this.onupgradeneeded=null}};var v=class{constructor(){this.timer=null}open(e,t){var s=new D(e,t,{callback:e=>{e&&s.onupgradeneeded&&setTimeout(()=>{s.onupgradeneeded({target:s})},0),s.onsuccess&&setTimeout(()=>{s.onsuccess({target:s})},0)}});return s}databases(){}deleteDatabase(){}cmp(e,t){}};delete window.indexedDB,window.indexedDB=new v,console.log("store version: ","0.0.7")}]);