mirror of
https://github.com/VickScarlet/lifeRestart.git
synced 2026-03-25 16:48:23 +08:00
1 line
29 KiB
JavaScript
1 line
29 KiB
JavaScript
!function(t,o){o.un,o.uns;var i=o.static,n=o.class,a=o.getset,r=(o.__newvec,laya.utils.Browser),l=o.Config,s=(laya.events.Event,laya.events.EventDispatcher),u=laya.resource.HTMLImage,v=laya.utils.Handler,d=laya.display.Input,p=laya.net.Loader,c=(laya.net.LocalStorage,laya.maths.Matrix,laya.renders.Render,laya.utils.RunDriver),e=laya.media.SoundChannel,f=laya.media.SoundManager,m=laya.net.URL,g=laya.utils.Utils,y=(n(h,"laya.qg.mini.MiniFileMgr",null,"MiniFileMgr$3"),h.isLocalNativeFile=function(i){for(var e=0,t=x.nativefiles.length;e<t;e++)if(-1!=i.indexOf(x.nativefiles[e]))return!0;return!1},h.getFileInfo=function(i){i=h.filesListObj[i];return null==i?null:i},h.read=function(i,e,t,n,o,a){void 0===e&&(e="utf8"),void 0===o&&(o=!1),void 0===a&&(a=""),i=""==(n=void 0===n?"":n)||-1==n.indexOf("http://")&&-1==n.indexOf("https://")?i:h.getFileNativePath(i),h.fs.readFile({filePath:i,encoding:e,success:function(i){null!=t&&t.runWith([0,i])},fail:function(i){i&&""!=n?h.downFiles(n,e,t,n,o,a):null!=t&&t.runWith([1])}})},h.downFiles=function(e,t,n,o,a,l,s){void 0===t&&(t="utf8"),void 0===o&&(o=""),void 0===a&&(a=!1),void 0===l&&(l=""),void 0===s&&(s=!0),h.wxdown({url:e,success:function(i){200===i.statusCode?h.readFile(i.tempFilePath,t,n,o,a,l,s):403===i.statusCode?null!=n&&n.runWith([0,e]):null!=n&&n.runWith([1,i])},fail:function(i){null!=n&&n.runWith([1,i])}}).onProgressUpdate(function(i){null!=n&&n.runWith([2,i.progress])})},h.readFile=function(e,t,n,o,a,i,l){void 0===o&&(o=""),void 0===a&&(a=!1),void 0===i&&(i=""),void 0===l&&(l=!0),h.fs.readFile({filePath:e,encoding:t=void 0===t?"utf8":t,success:function(i){-1!=e.indexOf("http://")||-1!=e.indexOf("https://")?(x.autoCacheFile||a)&&h.copyFile(e,o,n,t,l):null!=n&&n.runWith([0,i])},fail:function(i){i&&null!=n&&n.runWith([1,i])}})},h.downOtherFiles=function(i,e,t,n,o){void 0===t&&(t=""),void 0===n&&(n=!1),void 0===o&&(o=!0),h.wxdown({url:i,success:function(i){200===i.statusCode?(x.autoCacheFile||n)&&-1==t.indexOf("qlogo.cn")&&-1==t.indexOf(".php")?(null!=e&&e.runWith([0,i.tempFilePath]),h.copyFile(i.tempFilePath,t,null,"",o)):null!=e&&e.runWith([0,i.tempFilePath]):null!=e&&e.runWith([1,i])},fail:function(i){null!=e&&e.runWith([1,i])}})},h.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="utf8"),x.window.navigator.userAgent.indexOf("MiniGame")<0&&x.window.navigator.userAgent.indexOf("OPPO")<0?o.loader.load(i,t):"image"==e||"sound"==e?h.downOtherFiles(i,t,i,!0,!1):h.downFiles(i,n,t,i,!0,e,!1)},h.copyFile=function(t,n,o,a,l){void 0===a&&(a=""),void 0===l&&(l=!0);var i=t.split("/"),s=i[i.length-1],i=h.getFileInfo(n),r=h.getFileNativePath(s),u=h.getCacheUseSize();i?i.readyUrl!=n?h.fs.getFileInfo({filePath:t,success:function(i){l&&52428800<=u+4194304+i.size&&(i.size>x.minClearSize&&(x.minClearSize=i.size),h.onClearCacheRes()),h.deleteFile(t,n,o,a,i.size)},fail:function(i){null!=o&&o.runWith([1,i])}}):null!=o&&o.runWith([0]):h.fs.getFileInfo({filePath:t,success:function(e){l&&52428800<=u+4194304+e.size&&(e.size>x.minClearSize&&(x.minClearSize=e.size),h.onClearCacheRes()),h.fs.copyFile({srcPath:t,destPath:r,success:function(i){h.onSaveFile(n,s,!0,a,o,e.size)},fail:function(i){null!=o&&o.runWith([1,i])}})},fail:function(i){null!=o&&o.runWith([1,i])}})},h.onClearCacheRes=function(){var i,e=x.minClearSize,t=[];for(i in h.filesListObj)"fileUsedSize"!=i&&t.push(h.filesListObj[i]);h.sortOn(t,"times",16);for(var n=0,o=1,a=t.length;o<a;o++){var l=t[o];if(e<=n)break;n+=l.size,h.deleteFile("",l.readyUrl)}},h.sortOn=function(i,t,e){return 16==(e=void 0===e?0:e)?i.sort(function(i,e){return i[t]-e[t]}):18==e?i.sort(function(i,e){return e[t]-i[t]}):i.sort(function(i,e){return i[t]-e[t]})},h.getFileNativePath=function(i){return laya.qg.mini.MiniFileMgr.fileNativeDir+"/"+i},h.deleteFile=function(n,o,a,l,s){void 0===l&&(l=""),void 0===s&&(s=0);var i=h.getFileInfo(o=void 0===o?"":o),i=h.getFileNativePath(i.md5);h.fs.unlink({filePath:i,success:function(i){var e,t=""!=n;""!=n?(e=h.getFileNativePath(n),h.fs.copyFile({srcPath:n,destPath:e,success:function(i){h.onSaveFile(o,n,t,l,a,i.size)},fail:function(i){null!=a&&a.runWith([1,i])}})):h.onSaveFile(o,n,t,l,a,s)},fail:function(i){}})},h.deleteAll=function(){var i,e=[];for(i in h.filesListObj)"fileUsedSize"!=i&&e.push(h.filesListObj[i]);for(var t=1,n=e.length;t<n;t++){var o=e[t];h.deleteFile("",o.readyUrl)}laya.qg.mini.MiniFileMgr.filesListObj&&laya.qg.mini.MiniFileMgr.filesListObj.fileUsedSize&&(laya.qg.mini.MiniFileMgr.filesListObj.fileUsedSize=0),laya.qg.mini.MiniFileMgr.writeFilesList("",JSON.stringify({}),!1)},h.onSaveFile=function(i,e,t,n,o,a){void 0===t&&(t=!0),void 0===n&&(n=""),void 0===a&&(a=0);var l=i;null==h.filesListObj.fileUsedSize&&(h.filesListObj.fileUsedSize=0),t?(h.getFileNativePath(e),h.filesListObj[l]={md5:e,readyUrl:i,size:a,times:r.now(),encoding:n},h.filesListObj.fileUsedSize=parseInt(h.filesListObj.fileUsedSize)+a,h.writeFilesList(l,JSON.stringify(h.filesListObj),!0),null!=o&&o.runWith([0])):h.filesListObj[l]&&(a=parseInt(h.filesListObj[l].size),h.filesListObj.fileUsedSize=parseInt(h.filesListObj.fileUsedSize)-a,delete h.filesListObj[l],h.writeFilesList(l,JSON.stringify(h.filesListObj),!1),null!=o&&o.runWith([0]))},h.writeFilesList=function(i,e,t){h.fs.writeFile({filePath:h.fileNativeDir+"/"+h.fileListName,encoding:"utf8",data:e,success:function(i){},fail:function(i){}}),!x.isZiYu&&x.isPosMsgYu&&x.window.qg.postMessage&&x.window.qg.postMessage({url:i,data:h.filesListObj[i],isLoad:"filenative",isAdd:t})},h.getCacheUseSize=function(){return h.filesListObj&&h.filesListObj.fileUsedSize?h.filesListObj.fileUsedSize:0},h.existDir=function(i,e){h.fs.mkdir({dirPath:i,success:function(i){null!=e&&e.runWith([0,{data:JSON.stringify({})}])},fail:function(i){-1!=i.errMsg.indexOf("file already exists")?h.readSync(h.fileListName,"utf8",e):null!=e&&e.runWith([1,i])}})},h.readSync=function(i,e,t,n){void 0===e&&(e="utf8"),void 0===n&&(n="");var o,i=h.getFileNativePath(i);try{h.fs.readFile({filePath:i,encoding:e,success:function(i){o=i.data,null!=t&&t.runWith([0,{data:o}])},fail:function(){null!=t&&t.runWith([1])}})}catch(i){null!=t&&t.runWith([1])}},h.setNativeFileDir=function(i){h.fileNativeDir=qg.env.USER_DATA_PATH+i},h.filesListObj={},h.fileNativeDir=null,h.fileListName="layaairfiles.txt",h.ziyuFileData={},h.ziyuFileTextureData={},h.loadPath="",h.DESCENDING=2,h.NUMERIC=16,i(h,["fs",function(){return this.fs=x.window.qg.getFileSystemManager()},"wxdown",function(){return this.wxdown=x.window.qg.downloadFile}]),h);function h(){}var w=(n(_,"laya.qg.mini.MiniImage",null,"MiniImage$3"),_.prototype._loadImage=function(i){var e=this,t=x.window.qg.env.USER_DATA_PATH;if(-1==i.indexOf(t)&&-1==i.indexOf(t))if(x.isZiYu)_.onCreateImage(i,e,!0);else{var n,o,t=!1;if(y.isLocalNativeFile(i)){if(-1!=i.indexOf("http://usr/")||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(i=""!=y.loadPath?i.split(y.loadPath)[1]:(o=i,(i=""!=(n=""!=m.rootPath?m.rootPath:m.basePath)?i.split(n)[1]:i)||o)),x.subNativeFiles&&0==x.subNativeheads.length)for(var a in x.subNativeFiles){var l=x.subNativeFiles[a];x.subNativeheads=x.subNativeheads.concat(l);for(var s=0;s<l.length;s++)x.subMaps[l[s]]=a+"/"+l[s]}!x.subNativeFiles||-1==i.indexOf("/")||(n=i.split("/")[0]+"/")&&-1!=x.subNativeheads.indexOf(n)&&(o=x.subMaps[n],i=i.replace(n,o))}else t=!0,i=m.formatURL(i);y.getFileInfo(i)?_.onCreateImage(i,e,!t):-1!=i.indexOf("http://usr/")||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||x.isZiYu?_.onCreateImage(i,e,!0):y.downOtherFiles(encodeURI(i),new v(_,_.onDownImgCallBack,[i,e]),i)}else _.onCreateImage(i,e,!0)},_.onDownImgCallBack=function(i,e,t,n){void 0===n&&(n=""),t?e.onError(null):_.onCreateImage(i,e,!1,n)},_.onCreateImage=function(e,t,i,n){var o,a,l;function s(){l.onload=null,l.onerror=null,delete t.imgCache[e]}void 0===i&&(i=!1),void 0===n&&(n=""),a=x.autoCacheFile?i?x.isZiYu?(o=m.formatURL(e),y.ziyuFileTextureData[o]||e):e:""!=n?n:(a=y.getFileInfo(e).md5,y.getFileNativePath(a)):i?e:n,null==t.imgCache&&(t.imgCache={});i=function(){s(),t.onLoaded(l)},n=function(){s(),t.event("error","Load image failed")};"nativeimage"==t._type?((l=new r.window.Image).crossOrigin="",l.onload=i,l.onerror=n,l.src=a,t.imgCache[e]=l):new u.create(a,{onload:i,onerror:n,onCreate:function(i){l=i,t.imgCache[e]=i}})},_);function _(){}var F=(n(E,"laya.qg.mini.MiniInput",null,"MiniInput$3"),E._createInputElement=function(){d._initInput(d.area=r.createElement("textarea")),d._initInput(d.input=r.createElement("input")),d.inputContainer=r.createElement("div"),d.inputContainer.style.position="absolute",d.inputContainer.style.zIndex=1e5,r.container.appendChild(d.inputContainer),d.inputContainer.setPos=function(i,e){d.inputContainer.style.left=i+"px",d.inputContainer.style.top=e+"px"},o.stage.on("resize",null,E._onStageResize),x.window.qg.onWindowResize&&x.window.qg.onWindowResize(function(i){x.window.dispatchEvent&&x.window.dispatchEvent("resize")}),f._soundClass=S,f._musicClass=S;var i=x.systemInfo.model,e=x.systemInfo.system;i&&-1!=i.indexOf("iPhone")&&(r.onIPhone=!0,r.onIOS=!0,r.onIPad=!0,r.onAndroid=!1),!e||-1==e.indexOf("Android")&&-1==e.indexOf("Adr")||(r.onAndroid=!0,r.onIPhone=!1,r.onIOS=!1,r.onIPad=!1)},E._onStageResize=function(){},E.wxinputFocus=function(i){var e=d.inputElement.target;e&&!e.editable||(x.window.qg.showKeyboard({defaultValue:e.text,maxLength:e.maxChars,multiple:e.multiline,confirmHold:!0,confirmType:"done",success:function(i){},fail:function(i){}}),x.window.qg.onKeyboardComplete(function(i){x.window.qg.offKeyboardComplete();i=i?i.value:"";e._restrictPattern&&(i=i.replace(/\u2006|\x27/g,""),e._restrictPattern.test(i)&&(i=i.replace(e._restrictPattern,""))),e.text=i,e.event("input"),laya.qg.mini.MiniInput.inputEnter(!0)}),x.window.qg.onKeyboardConfirm(function(i){i=i?i.value:"";e._restrictPattern&&(i=i.replace(/\u2006|\x27/g,""),e._restrictPattern.test(i)&&(i=i.replace(e._restrictPattern,""))),e.text=i,e.event("input"),laya.qg.mini.MiniInput.inputEnter(!0)}),x.window.qg.onKeyboardInput(function(i){i=i?i.value:"";!e.multiline&&-1!=i.indexOf("\n")||(e._restrictPattern&&(i=i.replace(/\u2006|\x27/g,""),e._restrictPattern.test(i)&&(i=i.replace(e._restrictPattern,""))),e.text=i,e.event("input")),laya.qg.mini.MiniInput.inputEnter(!1)}))},E.inputEnter=function(i){i&&E.hideKeyboard(),d.inputElement.target&&(d.inputElement.target.focus=!1)},E.wxinputblur=function(){},E.hideKeyboard=function(){x.window.qg.offKeyboardConfirm(),x.window.qg.offKeyboardInput(),x.window.qg.hideKeyboard({success:function(i){console.log("隐藏键盘")},fail:function(i){console.log("隐藏键盘出错:"+(i?i.errMsg:""))}})},E);function E(){}n(C,"laya.qg.mini.MiniLocalStorage",null,"MiniLocalStorage$3"),C.__init__=function(){C.items=C},C.setItem=function(i,e){x.window.qg.setStorageSync(i,e)},C.getItem=function(i){return x.window.qg.getStorageSync(i)},C.setJSON=function(e,t){try{C.setItem(e,JSON.stringify(t))}catch(i){C.setItem(e,t)}},C.getJSON=function(e){e=C.getItem(e);try{return JSON.parse(e)}catch(i){return e}},C.removeItem=function(i){x.window.qg.removeStorageSync(i)},C.clear=function(){x.window.qg.clearStorageSync()},C.getStorageInfoSync=function(){try{var i=x.window.qg.getStorageInfoSync();return console.log(i.keys),console.log(i.currentSize),console.log(i.limitSize),i}catch(i){}return null},C.support=!0,C.items=null;function C(){}n(L,"laya.qg.mini.MiniLocation",null,"MiniLocation$3"),L.__init__=function(){x.window.navigator.geolocation.getCurrentPosition=L.getCurrentPosition,x.window.navigator.geolocation.watchPosition=L.watchPosition,x.window.navigator.geolocation.clearWatch=L.clearWatch},L.getCurrentPosition=function(e,i,t){var n;(n={success:function(i){null!=e&&e(i)}}).fail=i,x.window.qg.getLocation(n)},L.watchPosition=function(i,e,t){var n;return L._curID++,(n={}).success=i,n.error=e,L._watchDic[L._curID]=n,o.timer.loop(1e3,null,L._myLoop),L._curID},L.clearWatch=function(i){delete L._watchDic[i],L._hasWatch()||o.timer.clear(null,L._myLoop)},L._hasWatch=function(){for(var i in L._watchDic)if(L._watchDic[i])return!0;return!1},L._myLoop=function(){L.getCurrentPosition(L._mySuccess,L._myError)},L._mySuccess=function(i){var e,t={};for(e in t.coords=i,t.timestamp=r.now(),L._watchDic)L._watchDic[e].success&&L._watchDic[e].success(t)},L._myError=function(i){for(var e in L._watchDic)L._watchDic[e].error&&L._watchDic[e].error(i)},L._watchDic={},L._curID=0;function L(){}!function(){function i(i,e){this.videoend=!1,this.videourl="",this.videoElement=null,this.videoW=NaN,this.videoH=NaN,this.onPlayFunc=null,this.onEndedFunC=null,this._duration=NaN,this.position=NaN,void 0===e&&(e=240),this.videoW=i=void 0===i?320:i,this.videoH=e}n(i,"laya.qg.mini.MiniVideo",null,"MiniVideo$1");var e=i.prototype;e.on=function(i,e,t){"loadedmetadata"==i?this.onPlayFunc=t.bind(e):"ended"==i&&(this.onEndedFunC=t.bind(e)),this.videoElement.onTimeUpdate=this.onTimeUpdateFunc.bind(this)},e.onTimeUpdateFunc=function(i){this.position=i.position,this._duration=i.duration},e.onPlayFunction=function(){this.videoElement&&(this.videoElement.readyState=200),null!=this.onPlayFunc&&this.onPlayFunc()},e.onEndedFunction=function(){this.videoend=!0,null!=this.onEndedFunC&&this.onEndedFunC()},e.off=function(i,e,t){"loadedmetadata"==i?(this.onPlayFunc=t.bind(e),this.videoElement.offPlay=this.onPlayFunction.bind(this)):"ended"==i&&(this.onEndedFunC=t.bind(e),this.videoElement.offEnded=this.onEndedFunction.bind(this))},e.load=function(i){this.videoElement?this.videoElement.src=i:(this.videoElement=x.window.qg.createVideo({width:this.videoW,height:this.videoH,autoplay:!0,src:i}),this.videoElement.onPlay=this.onPlayFunction.bind(this),this.videoElement.onEnded=this.onEndedFunction.bind(this))},e.play=function(){this.videoElement&&(this.videoend=!1,this.videoElement.play())},e.pause=function(){this.videoElement&&(this.videoend=!0,this.videoElement.pause())},e.size=function(i,e){this.videoElement&&(this.videoElement.width=i,this.videoElement.height=e)},e.destroy=function(){this.videoElement&&this.videoElement.destroy(),this.videoElement=null,this.onEndedFunC=null,this.onPlayFunc=null,this.videoend=!1,this.videourl=null},e.reload=function(){this.videoElement&&(this.videoElement.src=this.videourl)},a(0,e,"duration",function(){return this._duration}),a(0,e,"paused",function(){return!!this.videoElement&&this.videoElement.paused}),a(0,e,"loop",function(){return!!this.videoElement&&this.videoElement.loop},function(i){this.videoElement&&(this.videoElement.loop=i)}),a(0,e,"currentTime",function(){return this.videoElement?this.videoElement.initialTime:0},function(i){this.videoElement&&(this.videoElement.initialTime=i)}),a(0,e,"ended",function(){return this.videoend}),a(0,e,"muted",function(){return!!this.videoElement&&this.videoElement.muted},function(i){this.videoElement&&(this.videoElement.muted=i)}),a(0,e,"videoWidth",function(){return this.videoElement?this.videoElement.width:0}),a(0,e,"videoHeight",function(){return this.videoElement?this.videoElement.height:0}),a(0,e,"playbackRate",function(){return this.videoElement?this.videoElement.playbackRate:0},function(i){this.videoElement&&(this.videoElement.playbackRate=i)}),a(0,e,"x",function(){return this.videoElement?this.videoElement.x:0},function(i){this.videoElement&&(this.videoElement.x=i)}),a(0,e,"y",function(){return this.videoElement?this.videoElement.y:0},function(i){this.videoElement&&(this.videoElement.y=i)}),a(0,e,"currentSrc",function(){return this.videoElement.src}),i.__init__=function(){laya.device.media.Video=i}}();var x=(n(P,"laya.qg.mini.QGMiniAdapter"),P.getJson=function(i){return JSON.parse(i)},P.init=function(i,e){if(void 0===i&&(i=!1),void 0===e&&(e=!1),!P._inited&&(P._inited=!0,(P.window=t).hasOwnProperty("qg")&&!(P.window.navigator.userAgent.indexOf("OPPO")<0))){P.isZiYu=e,P.isPosMsgYu=i,P.EnvConfig={};try{laya.webgl.resource.WebGLCanvas.premulAlpha=!0}catch(i){}P.isZiYu||(qg||console.log("======qg null======================"),qg.env||console.log("======qg.env null======================"),y.setNativeFileDir("/layaairGame"),y.existDir(y.fileNativeDir,v.create(P,P.onMkdirCallBack))),P.window.qg.getSystemInfo({success:function(i){P.systemInfo=i}}),P.window.focus=function(){},o._getUrlPath=function(){},o.getUrlPath=function(){},P.window.logtime=function(i){},P.window.alertTimeLog=function(i){},P.window.resetShareInfo=function(){},P.window.document.body.appendChild=function(){},P.EnvConfig.pixelRatioInt=0,c.getPixelRatio=P.pixelRatio,P._preCreateElement=r.createElement,r.createElement=P.createElement,c.createShaderCondition=P.createShaderCondition,g.parseXMLFromString=P.parseXMLFromString,d._createInputElement=F._createInputElement,P.EnvConfig.load=p.prototype.load,p.prototype.load=b.prototype.load,p.prototype._loadImage=w.prototype._loadImage,P.onReciveData(),l.useRetinalCanvas=!0}},P.onReciveData=function(){laya.qg.mini.QGMiniAdapter.isZiYu&&P.window.qg.onMessage&&P.window.qg.onMessage(function(i){"opendatacontext"==i.isLoad?i.url&&(y.ziyuFileData[i.url]=i.atlasdata,y.ziyuFileTextureData[i.imgReadyUrl]=i.imgNativeUrl):"openJsondatacontext"==i.isLoad?i.url&&(y.ziyuFileData[i.url]=i.atlasdata):"openJsondatacontextPic"==i.isLoad&&(y.ziyuFileTextureData[i.imgReadyUrl]=i.imgNativeUrl)})},P.measureText=function(i){i=P._measureText(i);return i||(i={width:16},console.warn("-------微信获取文字宽度失败----等待修复---------")),i},P.getUrlEncode=function(i,e){return"arraybuffer"==e?"":"utf8"},P.downLoadFile=function(i,e,t,n){void 0===e&&(e=""),void 0===n&&(n="utf8"),y.getFileInfo(i)?null!=t&&t.runWith([0]):y.downLoadFile(i,e,t,n)},P.remove=function(i,e){y.deleteFile("",i,e,"",0)},P.removeAll=function(){y.deleteAll()},P.hasNativeFile=function(i){return y.isLocalNativeFile(i)},P.getFileInfo=function(i){return y.getFileInfo(i)},P.getFileList=function(){return y.filesListObj},P.exitMiniProgram=function(){P.window.qg.exitMiniProgram()},P.onMkdirCallBack=function(i,e){i||(y.filesListObj=JSON.parse(e.data))},P.pixelRatio=function(){if(!P.EnvConfig.pixelRatioInt)try{return P.systemInfo.pixelRatio=P.window.devicePixelRatio,P.EnvConfig.pixelRatioInt=P.systemInfo.pixelRatio,P.systemInfo.pixelRatio}catch(i){}return P.EnvConfig.pixelRatioInt},P.createElement=function(i){var e;if("canvas"==i)return 1==P.idx?P.isZiYu?(e=P.window.document.createElement("canvas")).style={}:e=P.window.__canvas:e=P.window.document.createElement("canvas"),P.idx++,e;if("textarea"==i||"input"==i)return P.onCreateInput(i);if("div"!=i)return P._preCreateElement(i);i=P._preCreateElement(i);return i.contains=function(i){return null},i.removeChild=function(i){},i},P.onCreateInput=function(i){i=P._preCreateElement(i);return i.focus=F.wxinputFocus,i.blur=F.wxinputblur,i.style={},i.value=0,i.parentElement={},i.placeholder={},i.type={},i.setColor=function(i){},i.setType=function(i){},i.setFontFace=function(i){},i.addEventListener=function(i){},i.contains=function(i){return null},i.removeChild=function(i){},i},P.createShaderCondition=function(i){var e=this;return function(){return e[i.replace("this.","")]}},P.sendAtlasToOpenDataContext=function(i){if(!laya.qg.mini.QGMiniAdapter.isZiYu){var e=p.getRes(m.formatURL(i));if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";e.meta.image.split(",");if(e.meta&&e.meta.image)for(var t=e.meta.image.split(","),n=0<=i.indexOf("/")?"/":"\\",n=i.lastIndexOf(n),o=0<=n?i.substr(0,n+1):"",a=0,l=t.length;a<l;a++)t[a]=o+t[a];else t=[i.replace(".json",".png")];for(a=0;a<t.length;a++){var s=t[a];P.postInfoToContext(i,s,e)}}},P.postInfoToContext=function(i,e,t){var n={frames:t.frames,meta:t.meta},t=e,e=y.getFileInfo(m.formatURL(e)),o=e?(o=e.md5,y.getFileNativePath(o)):t;if(!o)throw"获取图集的磁盘url路径不存在!";P.window.qg.postMessage&&P.window.qg.postMessage({url:i,atlasdata:n,imgNativeUrl:o,imgReadyUrl:t,isLoad:"opendatacontext"})},P.sendSinglePicToOpenDataContext=function(i){var e,t=m.formatURL(i),n=y.getFileInfo(t);if(n?(e=n.md5,e=y.getFileNativePath(e),i=t):e=i,!e)throw"获取图集的磁盘url路径不存在!";P.window.qg.postMessage&&P.window.qg.postMessage({url:i,imgNativeUrl:e,imgReadyUrl:i,isLoad:"openJsondatacontextPic"})},P.sendJsonDataToDataContext=function(i){if(!laya.qg.mini.QGMiniAdapter.isZiYu){var e=p.getRes(i);if(!e)throw"传递的url没有获取到对应的图集数据信息,请确保图集已经过!";P.window.qg.postMessage&&P.window.qg.postMessage({url:i,atlasdata:e,isLoad:"openJsondatacontext"})}},P.EnvConfig=null,P.window=null,P._preCreateElement=null,P._inited=!1,P.systemInfo={},P.isZiYu=!1,P.isPosMsgYu=!1,P.autoCacheFile=!0,P.minClearSize=5242880,P.subNativeFiles=null,P.subNativeheads=[],P.subMaps=[],P.AutoCacheDownFile=!1,P._measureText=null,P.parseXMLFromString=function(i){var e;i=i.replace(/>\s+</g,"><");try{e=(new t.DOMParser).parseFromString(i,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return e},P.idx=1,i(P,["nativefiles",function(){return this.nativefiles=["layaNativeDir","qgfile"]}]),P);function P(){}!function(o){function a(){a.__super.call(this)}n(a,"laya.qg.mini.MiniAccelerator",o,"MiniAccelerator$3");var i=a.prototype;i.on=function(i,e,t,n){return o.prototype.on.call(this,i,e,t,n),a.startListen(this.onAccelerometerChange),this},i.off=function(i,e,t,n){return void 0===n&&(n=!1),this.hasListener(i)||a.stopListen(),o.prototype.off.call(this,i,e,t,n)},a.__init__=function(){try{var i=laya.device.motion.Accelerator;if(!i)return;i.prototype.on=a.prototype.on,i.prototype.off=a.prototype.off}catch(i){}},a.startListen=function(i){if(a._callBack=i,!a._isListening){a._isListening=!0;try{x.window.qg.onAccelerometerChange(laya.qg.mini.MiniAccelerator.onAccelerometerChange)}catch(i){}}},a.stopListen=function(){a._isListening=!1;try{x.window.qg.stopAccelerometer({})}catch(i){}},a.onAccelerometerChange=function(i){var e={};e.acceleration=i,e.accelerationIncludingGravity=i,e.rotationRate={},null!=a._callBack&&a._callBack(e)},a._isListening=!1,a._callBack=null}(s);var b=(n(O,"laya.qg.mini.MiniLoader",s,"MiniLoader$3"),O.prototype.load=function(i,e,t,n,o){void 0===t&&(t=!0),void 0===o&&(o=!1);var a=this;if(a._url=i){if(0===(i=m.customFormat(i)).indexOf("data:image")?a._type=e="image":a._type=e=e||a.getTypeFromUrl(a._url),a._cache=t,a._data=null,!o&&p.loadedMap[m.formatURL(i)])return a._data=p.loadedMap[m.formatURL(i)],this.event("progress",1),void this.event("complete",a._data);if(null!=p.parserMap[e])return a._customParse=!0,void(p.parserMap[e]instanceof laya.utils.Handler?p.parserMap[e].runWith(this):p.parserMap[e].call(null,this));var l=x.getUrlEncode(i,e),s=g.getFileExtension(i);if(-1!=O._fileTypeArr.indexOf(s)||"image"==e)x.EnvConfig.load.call(this,i,e,t,n,o);else if(x.isZiYu&&!y.ziyuFileData[i]&&(i=m.formatURL(i)),x.isZiYu&&y.ziyuFileData[i]){s=y.ziyuFileData[i];a.onLoaded(s)}else if(y.getFileInfo(m.formatURL(i))){var r=y.getFileInfo(m.formatURL(i));r.encoding=null==r.encoding?"utf8":r.encoding;var u=y.getFileNativePath(r.md5);y.readFile(u,r.encoding,new v(O,O.onReadNativeCallBack,[l,i,e,t,n,o,a]),m.formatURL(i))}else{if(y.isLocalNativeFile(i)){if(x.subNativeFiles&&0==x.subNativeheads.length)for(var d in x.subNativeFiles){var c=x.subNativeFiles[d];x.subNativeheads=x.subNativeheads.concat(c);for(var f=0;f<c.length;f++)x.subMaps[c[f]]=d+"/"+c[f]}return!x.subNativeFiles||-1==i.indexOf("/")||(u=i.split("/")[0]+"/")&&-1!=x.subNativeheads.indexOf(u)&&(h=x.subMaps[u],i=i.replace(u,h)),void y.read(i,l,new v(O,O.onReadNativeCallBack,[l,i,e,t,n,o,a]))}var h=i;-1!=m.formatURL(i).indexOf(x.window.qg.env.USER_DATA_PATH)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")||x.AutoCacheDownFile?(r=y.getFileInfo(i))?(r.encoding=null==r.encoding?"utf8":r.encoding,y.readFile(r.url,l,new v(O,O.onReadNativeCallBack,[l,i,e,t,n,o,a]),i)):"image"==a.type||"htmlimage"==a.type?x.EnvConfig.load.call(a,i,e,t,n,o):(i=m.formatURL(i),"image"!=e&&(-1==i.indexOf("http://")&&-1==i.indexOf("https://")||y.isLocalNativeFile(i))?y.readFile(i,l,new v(O,O.onReadNativeCallBack,[l,i,e,t,n,o,a]),i):y.downFiles(i,l,new v(O,O.onReadNativeCallBack,[l,i,e,t,n,o,a]),i,t)):x.EnvConfig.load.call(a,h,e,t,n,o)}}else a.onLoaded(null)},O.onReadNativeCallBack=function(i,e,t,n,o,a,l,s,r){void 0===n&&(n=!0),void 0===a&&(a=!1),(s=void 0===s?0:s)?1==s&&(console.log("-----------本地加载失败,尝试外网加载----"),x.EnvConfig.load.call(l,e,t,n,o,a)):(r="json"==t||"atlas"==t?x.getJson(r.data):"xml"==t?g.parseXMLFromString(r.data):r.data,!x.isZiYu&&x.isPosMsgYu&&"arraybuffer"!=t&&x.window.qg.postMessage&&x.window.qg.postMessage({url:e,data:r,isLoad:"filedata"}),l.onLoaded(r))},i(O,["_fileTypeArr",function(){return this._fileTypeArr=["png","jpg","bmp","jpeg","gif"]}]),O);function O(){O.__super.call(this)}var S=function(){function i(){this._sound=null,this.url=null,this.loaded=!1,this.readyUrl=null,i.__super.call(this),this._sound=i._createSound()}n(i,"laya.qg.mini.MiniSound",s,"MiniSound$3");var e=i.prototype;return e.load=function(i){if(y.isLocalNativeFile(i)?-1==i.indexOf("http://")&&-1==i.indexOf("https://")||(""!=y.loadPath?i=i.split(y.loadPath)[1]:""!=(e=""!=m.rootPath?m.rootPath:m.basePath)&&(i=i.split(e)[1])):i=m.formatURL(i),this.url=i,this.readyUrl=i,x.autoCacheFile&&y.getFileInfo(i))this.onDownLoadCallBack(i,0);else if(x.autoCacheFile)if(y.isLocalNativeFile(i)){var e,t=i;if(i=(i=""!=(e=""!=m.rootPath?m.rootPath:m.basePath)?i.split(e)[1]:i)||t,x.subNativeFiles&&0==x.subNativeheads.length)for(var n in x.subNativeFiles){var o=x.subNativeFiles[n];x.subNativeheads=x.subNativeheads.concat(o);for(var a=0;a<o.length;a++)x.subMaps[o[a]]=n+"/"+o[a]}!x.subNativeFiles||-1==i.indexOf("/")||(e=i.split("/")[0]+"/")&&-1!=x.subNativeheads.indexOf(e)&&(t=x.subMaps[e],i=i.replace(e,t)),this.onDownLoadCallBack(i,0)}else-1==i.indexOf("http://")&&-1==i.indexOf("https://")||-1!=i.indexOf(x.window.my.env.USER_DATA_PATH)?this.onDownLoadCallBack(i,0):y.downOtherFiles(i,v.create(this,this.onDownLoadCallBack,[i]),i);else this.onDownLoadCallBack(i,0)},e.onDownLoadCallBack=function(i,e,t){var n,o;void 0===t&&(t=""),e?this.event("error"):x.autoCacheFile?(n=y.isLocalNativeFile(i)?(o=i,(n=""==(e=""!=m.rootPath?m.rootPath:m.basePath)||-1==i.indexOf("http://")&&-1==i.indexOf("https://")?n:i.split(e)[1])||o):(o=y.getFileInfo(i))&&o.md5?(o=o.md5,y.getFileNativePath(o)):encodeURI(i),this._sound.src=this.url=n):this._sound.src=i},e.play=function(i,e){if(void 0===i&&(i=0),void 0===e&&(e=0),!this.url)return null;var t=new I(this);return t.url=this.url,t.loops=e,t.loop=0===e,t.startTime=i,t.play(),f.addChannel(t),t},e.dispose=function(){this._sound&&(this._sound.destroy(),this._sound=null,this.readyUrl=this.url=null)},a(0,e,"duration",function(){return this._sound.duration}),i._createSound=function(){return i._audioCache.length?i._audioCache.pop():(i._id++,x.window.qg.createInnerAudioContext())},i._id=0,i._audioCache=[],i}(),I=function(i){function e(i){this._audio=null,this._onEnd=null,this._onCanplay=null,this._onError=null,this._miniSound=null,e.__super.call(this),this._audio=i._sound,this._miniSound=i,this._onEnd=e.bindToThis(this.__onEnd,this),this._onCanplay=e.bindToThis(this.onCanPlay,this),this._onError=e.bindToThis(this.onError,this),this.addEventListener()}n(e,"laya.qg.mini.MiniSoundChannel",i,"MiniSoundChannel$3");var t=e.prototype;return t.addEventListener=function(){this._audio.onError(this._onError),this._audio.onCanplay(this._onCanplay)},t.offEventListener=function(){this._audio.offError(this._onError),this._audio.offCanplay(this._onCanplay),this._audio.offEnded(this._onEnd)},t.onError=function(i){console.log("-----1---------------minisound-----url:",this.url),this.event("error",[i]),this._audio&&(this._miniSound.dispose(),this.offEventListener(),this._audio=this._miniSound=null)},t.onCanPlay=function(){this._audio&&(this.event("complete"),this.offEventListener(),this._audio.onEnded(this._onEnd),this.isStopped?this.stop():this.play())},t.__onEnd=function(){if(1==this.loops)return this.completeHandler&&(o.timer.once(10,this,this.__runComplete,[this.completeHandler],!1),this.completeHandler=null),this.stop(),void this.event("complete");0<this.loops&&this.loops--,this.startTime=0,this.play()},t.play=function(){this.isStopped=!1,f.addChannel(this),this._audio&&this._audio.src&&this._audio.play()},t.stop=function(){i.prototype.stop.call(this),this.isStopped=!0,f.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.stop(),this.loop||(this.offEventListener(),this._miniSound.dispose(),this._miniSound=null,this._audio=null))},t.pause=function(){this.isStopped=!0,this._audio&&this._audio.pause()},t.resume=function(){this._audio&&(this.isStopped=!1,f.addChannel(this),this._audio.play())},a(0,t,"startTime",function(){return this._audio?this._audio.startTime:0},function(i){this._audio&&(this._audio.startTime=i)}),a(0,t,"autoplay",function(){return!!this._audio&&this._audio.autoplay},function(i){this._audio&&(this._audio.autoplay=i)}),a(0,t,"duration",function(){return this._audio?this._audio.duration:0}),a(0,t,"position",function(){return this._audio?this._audio.currentTime:0}),a(0,t,"loop",function(){return!!this._audio&&this._audio.loop},function(i){this._audio&&(this._audio.loop=i)}),a(0,t,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),e.bindToThis=function(i,e){return i.bind(e)},e}(e)}(window,(document,Laya)),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";for(var t in Object.defineProperty(e,"__esModule",{value:!0}),Laya){var n=Laya[t];n&&n.__isclass&&(e[t]=n)}}); |