1 |
- !function i(o,r,s){function l(n,e){if(!r[n]){if(!o[n]){var t="function"==typeof require&&require;if(!e&&t)return t(n,!0);if(u)return u(n,!0);var a=new Error("Cannot find module '"+n+"'");throw a.code="MODULE_NOT_FOUND",a}var c=r[n]={exports:{}};o[n][0].call(c.exports,function(e){return l(o[n][1][e]||e)},c,c.exports,i,o,r,s)}return r[n].exports}for(var u="function"==typeof require&&require,e=0;e<s.length;e++)l(s[e]);return l}({1:[function(l,e,n){"use strict";var u=l("./cache-manager"),t=window.fsUtils,d=t.fs,f=t.downloadFile,c=t.readText,i=t.readArrayBuffer,a=t.readJson,h=t.loadSubpackage,g=t.getUserDataPath,o=t.exists,m=/^https?:\/\/.*/,p=cc.assetManager.downloader,r=cc.assetManager.parser,s=cc.assetManager.presets;p.maxConcurrency=12,p.maxRequestsPerFrame=64,s.scene.maxConcurrency=12,s.scene.maxRequestsPerFrame=64;var _={},b=cc.sys;function v(e,n,t){m.test(e)?t&&t(new Error("Can not load remote scripts")):(b.platform!==b.Platform.TAOBAO_CREATIVE_APP&&l("../../../".concat(e)),t&&t(null))}function y(t,e,a){cc.AudioPlayer.load(t).then(function(e){var n={player:e,url:t,duration:e.duration,type:e.type};a(null,n)}).catch(function(e){a(e)})}function w(a,n,c,e,i){var t=function(e,n){var t=!1,a=!1;if(e.startsWith(g()))t=!0;else if(m.test(e)){if(!n.reload){var c=u.cachedFiles.get(e);if(c)a=!0,e=c.url;else{var i=u.tempFiles.get(e);i&&(t=!0,e=i)}}}else t=!0;return{url:e,inLocal:t,inCache:a}}(a,c);t.inLocal?n(t.url,c,i):t.inCache?(u.updateLastTime(a),n(t.url,c,function(e,n){e&&u.removeCache(a),i(e,n)})):f(a,null,c.header,e,function(e,t){e?i(e,null):n(t,c,function(e,n){e||(u.tempFiles.add(a,t),u.cacheFile(a,t,c.cacheEnabled,c.__cacheBundleRoot__,!0)),i(e,n)})})}function F(e,n,t){i(e,t)}function E(e,n,t){c(e,t)}function C(e,n,t){a(e,t)}function x(e,n,t){w(e,C,n,n.onFileProgress,t)}function A(e,n,t){w(e,F,n,n.onFileProgress,t)}function M(e,n,t){t(null,__globalAdapter.loadFont(e)||"Arial")}function P(n,e,t){o(n,function(e){e?t(null,n):t(new Error("file ".concat(n," does not exist!")))})}function I(e,n,t){w(e,P,n,n.onFileProgress,t)}b.platform===b.Platform.BAIDU_MINI_GAME&&(l=__baiduRequire),b.platform===b.Platform.TAOBAO_MINI_GAME&&(l=globalThis.__taobaoRequire);function T(e,t,a){i(e,function(e,n){if(e)return a(e);K(n,t,a)})}function D(e,t,a){i(e,function(e,n){if(e)return a(e);B(n,t,a)})}function O(e,t,a){i(e,function(e,n){if(e)return a(e);N(n,t,a)})}function S(e,t,a){c(e,function(e,n){if(e)return a(e);R(n,t,a)})}var K=r.parsePVRTex,B=r.parsePKMTex,N=r.parseASTCTex,R=r.parsePlist;p.downloadScript=v,r.parsePVRTex=T,r.parsePKMTex=D,r.parseASTCTex=O,r.parsePlist=S,p.register({".js":v,".mp3":I,".ogg":I,".wav":I,".m4a":I,".png":I,".jpg":I,".bmp":I,".jpeg":I,".gif":I,".ico":I,".tiff":I,".image":I,".webp":I,".pvr":I,".pkm":I,".astc":I,".font":I,".eot":I,".ttf":I,".woff":I,".svg":I,".ttc":I,".ccon":function(c,e,a){x(c,e,function(e,n){if(e)a(e);else{var t=cc.internal.parseCCONJson(n);Promise.all(t.chunks.map(function(e){return new Promise(function(t,a){A("".concat(cc.path.mainFileName(c)).concat(e),{},function(e,n){e?a(e):t(new Uint8Array(n))})})})).then(function(e){var n=new cc.internal.CCON(t.document,e);a(null,n)}).catch(function(e){a(e)})}})},".cconb":function(e,n,a){A(e,n,function(e,n){if(e)a(e);else try{var t=cc.internal.decodeCCONBinary(new Uint8Array(n));a(null,t)}catch(e){a(e)}})},".txt":I,".xml":I,".vsh":I,".fsh":I,".atlas":I,".tmx":I,".tsx":I,".plist":I,".fnt":I,".json":x,".ExportJson":I,".binary":I,".bin":I,".dbbin":I,".skel":I,".mp4":I,".avi":I,".mov":I,".mpg":I,".mpeg":I,".rm":I,".rmvb":I,bundle:function(e,t,c){var a=cc.path.basename(e),n=t.version||cc.assetManager.downloader.bundleVers[a],i=n?"".concat(n,"."):"";if(_[a]){var o=b.platform===b.Platform.TAOBAO_MINI_GAME?"".concat(a,"/config.").concat(i,"json"):"subpackages/".concat(a,"/config.").concat(i,"json");h(a,t.onFileProgress,function(e){e?c(e,null):x(o,t,function(e,n){!function(e){e&&(b.platform===b.Platform.TAOBAO_MINI_GAME?e.base="".concat(a,"/"):e.base="subpackages/".concat(a,"/"))}(n),c(e,n)})})}else{var r,s;m.test(e)||e.startsWith(g())?(s=e,r="src/bundle-scripts/".concat(a,"/index.").concat(i,"js"),u.makeBundleFolder(a)):-1!==p.remoteBundles.indexOf(a)?(s="".concat(p.remoteServerAddress,"remote/").concat(a),r="src/bundle-scripts/".concat(a,"/index.").concat(i,"js"),u.makeBundleFolder(a)):(s="assets/".concat(a),r="assets/".concat(a,"/index.").concat(i,"js")),b.platform===b.Platform.TAOBAO_MINI_GAME?l(r):b.platform!==b.Platform.TAOBAO_CREATIVE_APP&&l("./".concat(r)),t.__cacheBundleRoot__=a,x("".concat(s,"/config.").concat(i,"json"),t,function(e,a){if(e)c&&c(e);else if(a.isZip){var n=a.zipVersion;!function(t,a,c){var e=u.cachedFiles.get(t);e?(u.updateLastTime(t),c&&c(null,e.url)):m.test(t)?f(t,null,a.header,a.onFileProgress,function(e,n){e?c&&c(e):u.unzipAndCacheBundle(t,n,a.__cacheBundleRoot__,c)}):u.unzipAndCacheBundle(t,t,a.__cacheBundleRoot__,c)}("".concat(s,"/res.").concat(n?"".concat(n,"."):"","zip"),t,function(e,n){if(e)c&&c(e);else{if(a.base="".concat(n,"/res/"),b.platform===b.Platform.ALIPAY_MINI_GAME&&b.os===b.OS.ANDROID){var t="".concat(n,"res/");d.accessSync({path:t}).success&&(a.base=t)}c&&c(null,a)}})}else a.base="".concat(s,"/"),c&&c(null,a)})}},default:function(e,n,t){w(e,E,n,n.onFileProgress,t)}}),r.register({".png":p.downloadDomImage,".jpg":p.downloadDomImage,".bmp":p.downloadDomImage,".jpeg":p.downloadDomImage,".gif":p.downloadDomImage,".ico":p.downloadDomImage,".tiff":p.downloadDomImage,".image":p.downloadDomImage,".webp":p.downloadDomImage,".pvr":T,".pkm":D,".astc":O,".font":M,".eot":M,".ttf":M,".woff":M,".svg":M,".ttc":M,".mp3":y,".ogg":y,".wav":y,".m4a":y,".txt":E,".xml":E,".vsh":E,".fsh":E,".atlas":E,".tmx":E,".tsx":E,".fnt":E,".plist":S,".binary":F,".bin":F,".dbbin":F,".skel":F,".ExportJson":C}),cc.assetManager.transformPipeline.append(function(e){for(var n=e.output=e.input,t=0,a=n.length;t<a;t++){var c=n[t],i=c.options;if(c.config)i.__cacheBundleRoot__=c.config.name;else{if("bundle"===c.ext)continue;i.cacheEnabled=void 0!==i.cacheEnabled&&i.cacheEnabled}".cconb"===c.ext?c.url=c.url.replace(c.ext,".bin"):".ccon"===c.ext&&(c.url=c.url.replace(c.ext,".json"))}});var k=cc.assetManager.init;cc.assetManager.init=function(e){k.call(cc.assetManager,e);var n=cc.settings.querySettings("assets","subpackages");n&&n.forEach(function(e){return _[e]="subpackages/".concat(e)}),u.init()}},{"./cache-manager":3}],2:[function(e,n,t){"use strict";!function(){if(cc&&cc.internal&&cc.internal.EditBox){var t=cc.internal.EditBox,e=cc.js,a=t.KeyboardReturnType,c=null,i=null;e.extend(n,t._EditBoxImpl),t._EditBoxImpl=n,Object.assign(n.prototype,{init:function(e){e?this._delegate=e:cc.error("EditBox init failed")},beginEditing:function(){var n=this;this._editing||this._ensureKeyboardHide(function(){var e=n._delegate;n._showKeyboard(),n._registerKeyboardEvent(),n._editing=!0,i=n,e._editBoxEditingDidBegan()})},endEditing:function(){this._hideKeyboard();var e=this._eventListeners;e.onKeyboardComplete&&e.onKeyboardComplete()},_registerKeyboardEvent:function(){var t=this,a=this._delegate,e=this._eventListeners;e.onKeyboardInput=function(e){a._string!==e.value&&a._editBoxTextChanged(e.value)},e.onKeyboardConfirm=function(e){e&&e.value?a._editBoxEditingReturn(e.value):a._editBoxEditingReturn();var n=t._eventListeners;n.onKeyboardComplete&&n.onKeyboardComplete()},e.onKeyboardComplete=function(e){t._editing=!1,i=null,cc.sys.platform!==cc.sys.Platform.WECHAT_MINI_PROGRAM&&t._unregisterKeyboardEvent(),e&&e.value?a._editBoxEditingDidEnded(e.value):a._editBoxEditingDidEnded()},__globalAdapter.onKeyboardInput(e.onKeyboardInput),__globalAdapter.onKeyboardConfirm(e.onKeyboardConfirm),__globalAdapter.onKeyboardComplete(e.onKeyboardComplete)},_unregisterKeyboardEvent:function(){var e=this._eventListeners;e.onKeyboardInput&&(__globalAdapter.offKeyboardInput(e.onKeyboardInput),e.onKeyboardInput=null),e.onKeyboardConfirm&&(__globalAdapter.offKeyboardConfirm(e.onKeyboardConfirm),e.onKeyboardConfirm=null),e.onKeyboardComplete&&(__globalAdapter.offKeyboardComplete(e.onKeyboardComplete),e.onKeyboardComplete=null)},_otherEditing:function(){return!!i&&i!==this&&i._editing},_ensureKeyboardHide:function(e){var n=this._otherEditing();if(!n&&!c)return e();c&&clearTimeout(c),n&&i.endEditing(),c=setTimeout(function(){c=null,e()},600)},_showKeyboard:function(){var e=this._delegate,n=e.inputMode===t.InputMode.ANY;__globalAdapter.showKeyboard({defaultValue:e.string,maxLength:e.maxLength<0?65535:e.maxLength,multiple:n,confirmHold:!1,confirmType:function(e){switch(e){case a.DEFAULT:case a.DONE:return"done";case a.SEND:return"send";case a.SEARCH:return"search";case a.GO:return"go";case a.NEXT:return"next"}return"done"}(e.returnType),success:function(e){},fail:function(e){cc.warn(e.errMsg)}})},_hideKeyboard:function(){__globalAdapter.hideKeyboard({success:function(e){},fail:function(e){cc.warn(e.errMsg)}})}})}function n(){this._delegate=null,this._editing=!1,this._eventListeners={onKeyboardInput:null,onKeyboardConfirm:null,onKeyboardComplete:null}}}()},{}],3:[function(e,n,t){"use strict";var a=window.fsUtils,c=a.getUserDataPath,i=a.readJsonSync,r=a.makeDirSync,o=a.writeFileSync,u=a.copyFile,d=a.downloadFile,s=a.deleteFile,l=a.rmdirSync,f=a.unzip,h=a.isOutOfStorage,g=!1,m=null,p=!1,_=0,b=/^https?:\/\/.*/,v={cacheDir:"gamecaches",cachedFileName:"cacheList.json",cacheEnabled:!0,autoClear:!0,cacheInterval:500,deleteInterval:500,writeFileInterval:2e3,outOfStorage:!1,tempFiles:null,cachedFiles:null,cacheQueue:{},version:"1.0",getCache:function(e){return this.cachedFiles.has(e)?this.cachedFiles.get(e).url:""},getTemp:function(e){return this.tempFiles.has(e)?this.tempFiles.get(e):""},init:function(){this.cacheDir=c()+"/"+this.cacheDir;var e=this.cacheDir+"/"+this.cachedFileName,n=i(e);n instanceof Error||!n.version?(n instanceof Error||l(this.cacheDir,!0),this.cachedFiles=new cc.AssetManager.Cache,r(this.cacheDir,!0),o(e,JSON.stringify({files:this.cachedFiles._map,version:this.version}),"utf8")):this.cachedFiles=new cc.AssetManager.Cache(n.files),this.tempFiles=new cc.AssetManager.Cache},updateLastTime:function(e){this.cachedFiles.has(e)&&(this.cachedFiles.get(e).lastTime=Date.now())},_write:function(){m=null,o(this.cacheDir+"/"+this.cachedFileName,JSON.stringify({files:this.cachedFiles._map,version:this.version}),"utf8")},writeCacheFile:function(){m=m||setTimeout(this._write.bind(this),this.writeFileInterval)},_cache:function(){g=!1;var n=this,t="";for(var e in this.cacheQueue){t=e;break}if(t){var a=this.cacheQueue[t],c=a.srcUrl,i=a.isCopy,o=a.cacheBundleRoot,r=Date.now().toString(),s="";s=o?"".concat(this.cacheDir,"/").concat(o,"/").concat(r).concat(_++).concat(cc.path.extname(t)):"".concat(this.cacheDir,"/").concat(r).concat(_++).concat(cc.path.extname(t)),i?u(c,s,l):d(c,s,null,l)}function l(e){if(e){if(h(e.message))return n.outOfStorage=!0,void(n.autoClear&&n.clearLRU())}else n.cachedFiles.add(t,{bundle:o,url:s,lastTime:r}),n.writeCacheFile();delete n.cacheQueue[t],cc.js.isEmptyObject(n.cacheQueue)||g||(g=!0,setTimeout(n._cache.bind(n),n.cacheInterval))}},cacheFile:function(e,n,t,a,c){!(t=void 0!==t?t:this.cacheEnabled)||this.cacheQueue[e]||this.cachedFiles.has(e)||(this.cacheQueue[e]={srcUrl:n,cacheBundleRoot:a,isCopy:c},g||this.outOfStorage||(g=!0,setTimeout(this._cache.bind(this),this.cacheInterval)))},clearCache:function(){var n=this;l(this.cacheDir,!0),this.cachedFiles=new cc.AssetManager.Cache,r(this.cacheDir,!0),this.outOfStorage=!1,clearTimeout(m),this._write(),cc.assetManager.bundles.forEach(function(e){b.test(e.base)&&n.makeBundleFolder(e.name)})},clearLRU:function(){if(!p){p=!0;var t=[],a=this;if(this.cachedFiles.forEach(function(n,e){a._isZipFile(e)&&cc.assetManager.bundles.find(function(e){return-1!==e.base.indexOf(n.url)})||t.push({originUrl:e,url:n.url,lastTime:n.lastTime})}),t.sort(function(e,n){return e.lastTime-n.lastTime}),t.length=Math.floor(t.length/3),0!==t.length){for(var e=0,n=t.length;e<n;e++)this.cachedFiles.remove(t[e].originUrl);clearTimeout(m),this._write(),setTimeout(function e(){var n=t.pop();a._isZipFile(n.originUrl)?(l(n.url,!0),a._deleteFileCB()):s(n.url,a._deleteFileCB.bind(a)),0<t.length?setTimeout(e,a.deleteInterval):p=!1},a.deleteInterval)}}},removeCache:function(e){if(this.cachedFiles.has(e)){var n=this.cachedFiles.remove(e).url;clearTimeout(m),this._write(),this._isZipFile(e)?(l(n,!0),this._deleteFileCB()):s(n,this._deleteFileCB.bind(this))}},_deleteFileCB:function(e){e||(this.outOfStorage=!1)},makeBundleFolder:function(e){r(this.cacheDir+"/"+e,!0)},unzipAndCacheBundle:function(n,e,t,a){var c=Date.now().toString(),i="".concat(this.cacheDir,"/").concat(t,"/").concat(c).concat(_++),o=this;r(i,!0),f(e,i,function(e){if(e)return l(i,!0),h(e.message)&&(o.outOfStorage=!0,o.autoClear&&o.clearLRU()),void(a&&a(e));o.cachedFiles.add(n,{bundle:t,url:i,lastTime:c}),o.writeCacheFile(),a&&a(null,i)})},_isZipFile:function(e){return".zip"===e.slice(-4)}};cc.assetManager.cacheManager=n.exports=v},{}],4:[function(e,n,t){"use strict";e("./Editbox"),e("./AssetManager"),e("./misc")},{"./AssetManager":1,"./Editbox":2,"./misc":5}],5:[function(e,n,t){"use strict";cc.macro.DOWNLOAD_MAX_CONCURRENT=10},{}],6:[function(e,n,t){"use strict";cc.ImageAsset&&Object.defineProperty(cc.ImageAsset.prototype,"data",{get:function(){return this._nativeData&&this._nativeData._data||this._nativeData}})},{}],7:[function(e,n,t){"use strict";if(cc&&cc.LabelComponent){var a=cc.LabelComponent,c=document.createElement("canvas"),i=c.getContext("2d"),o={canvas:c,context:i};cc.game.on(cc.Game.EVENT_ENGINE_INITED,function(){Object.assign(a._canvasPool,{get:function(){return o},put:function(){}})})}},{}],8:[function(e,n,t){"use strict";e("../fs-utils"),e("../../../../common/engine/index"),e("./Label"),e("./ImageAsset")},{"../../../../common/engine/index":4,"../fs-utils":9,"./ImageAsset":6,"./Label":7}],9:[function(c,e,n){"use strict";var i=tt.getFileSystemManager?tt.getFileSystemManager():null,t=/size.*limit.*exceeded/,r={fs:i,isOutOfStorage:function(e){return t.test(e)},getUserDataPath:function(){return tt.env.USER_DATA_PATH},checkFsValid:function(){return!!i||(console.warn("can not get the file system!"),!1)},deleteFile:function(n,t){i.unlink({filePath:n,success:function(){t&&t(null)},fail:function(e){console.warn("Delete file failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error(e.errMsg))}})},downloadFile:function(n,e,t,a,c){var i={url:n,success:function(e){200===e.statusCode?c&&c(null,e.tempFilePath||e.filePath):(e.filePath&&r.deleteFile(e.filePath),console.warn("Download file failed: path: ".concat(n," message: ").concat(e.statusCode)),c&&c(new Error(e.statusCode),null))},fail:function(e){console.warn("Download file failed: path: ".concat(n," message: ").concat(e.errMsg)),c&&c(new Error(e.errMsg),null)}};e&&(i.filePath=e),t&&(i.header=t);var o=tt.downloadFile(i);a&&o.onProgressUpdate(a)},saveFile:function(n,e,t){tt.saveFile({tempFilePath:n,filePath:e,success:function(e){t&&t(null)},fail:function(e){console.warn("Save file failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error(e.errMsg))}})},copyFile:function(n,e,t){i.copyFile({srcPath:n,destPath:e,success:function(){t&&t(null)},fail:function(e){console.warn("Copy file failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error(e.errMsg))}})},writeFile:function(n,e,t,a){i.writeFile({filePath:n,encoding:t,data:e,success:function(){a&&a(null)},fail:function(e){console.warn("Write file failed: path: ".concat(n," message: ").concat(e.errMsg)),a&&a(new Error(e.errMsg))}})},writeFileSync:function(n,e,t){try{return i.writeFileSync(n,e,t),null}catch(e){return console.warn("Write file failed: path: ".concat(n," message: ").concat(e.message)),new Error(e.message)}},readFile:function(n,e,t){i.readFile({filePath:n,encoding:e,success:function(e){t&&t(null,e.data)},fail:function(e){console.warn("Read file failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error(e.errMsg),null)}})},readDir:function(n,t){i.readdir({dirPath:n,success:function(e){t&&t(null,e.files)},fail:function(e){console.warn("Read directory failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error(e.errMsg),null)}})},readText:function(e,n){r.readFile(e,"utf8",n)},readArrayBuffer:function(e,n){r.readFile(e,void 0,n)},readJson:function(a,c){r.readFile(a,"utf8",function(n,e){var t=null;if(!n)try{t=JSON.parse(e)}catch(e){console.warn("Read json failed: path: ".concat(a," message: ").concat(e.message)),n=new Error(e.message)}c&&c(n,t)})},readJsonSync:function(n){try{var e=i.readFileSync(n,"utf8");return JSON.parse(e)}catch(e){return console.warn("Read json failed: path: ".concat(n," message: ").concat(e.message)),new Error(e.message)}},makeDirSync:function(n,e){try{return i.mkdirSync(n,e),null}catch(e){return console.warn("Make directory failed: path: ".concat(n," message: ").concat(e.message)),new Error(e.message)}},rmdirSync:function(n,e){try{i.rmdirSync(n,e)}catch(e){return console.warn("rm directory failed: path: ".concat(n," message: ").concat(e.message)),new Error(e.message)}},exists:function(e,n){i.access({path:e,success:function(){n&&n(!0)},fail:function(){n&&n(!1)}})},loadSubpackage:function(n,e,t){if(!tt.loadSubpackage)return console.warn("tt.loadSubpackage not supported, fallback to loading bundle"),c("subpackages/".concat(n,"/game.js")),void(t&&t());var a=tt.loadSubpackage({name:n,success:function(){t&&t()},fail:function(e){console.warn("Load Subpackage failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error("Failed to load subpackage ".concat(n,": ").concat(e.errMsg)))}});return e&&a.onProgressUpdate(e),a},unzip:function(n,e,t){i.unzip({zipFilePath:n,targetPath:e,success:function(){t&&t(null)},fail:function(e){console.warn("unzip failed: path: ".concat(n," message: ").concat(e.errMsg)),t&&t(new Error("unzip failed: "+e.errMsg))}})}};window.fsUtils=e.exports=r},{}]},{},[8]);
|