Files
lifeRestart/public/libs/laya/min/laya.ttmini.min.js
Vick Scarlet f40698d63e add laya
2021-10-31 00:13:22 +08:00

1 line
29 KiB
JavaScript
Raw Blame History

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