varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,cacheStringFunction=function(fn){varcache=Object.create(null);returnfunction(str){returncache[str]||(cache[str]=fn(str))}},hyphenateRE=/\B([A-Z])/g,hyphenate=cacheStringFunction((function(str){returnstr.replace(hyphenateRE,"-$1").toLowerCase()})),camelizeRE=/-(\w)/g,camelize=cacheStringFunction((function(str){returnstr.replace(camelizeRE,(function(_,c){returnc?c.toUpperCase():""}))})),capitalize=cacheStringFunction((function(str){returnstr.charAt(0).toUpperCase()+str.slice(1)})),PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetDataByPath(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnfunction(vm){if(vm._$weex)returnvm._uid;if(vm._$id)returnvm._$id;varparent_1=function(vm){for(varparent=vm.$parent;parent;){if(parent._$id)returnparent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";varvnode=vm.$vnode,context=vnode.context;returncontext&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}(vm)===nodeId}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?getDataByPath(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};
varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,cacheStringFunction=function(fn){varcache=Object.create(null);returnfunction(str){returncache[str]||(cache[str]=fn(str))}},hyphenateRE=/\B([A-Z])/g,hyphenate=cacheStringFunction((function(str){returnstr.replace(hyphenateRE,"-$1").toLowerCase()})),camelizeRE=/-(\w)/g,camelize=cacheStringFunction((function(str){returnstr.replace(camelizeRE,(function(_,c){returnc?c.toUpperCase():""}))})),capitalize=cacheStringFunction((function(str){returnstr.charAt(0).toUpperCase()+str.slice(1)})),PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetDataByPath(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnfunction(vm){if(vm._$weex)returnvm._uid;if(vm._$id)returnvm._$id;varparent_1=function(vm){for(varparent=vm.$parent;parent;){if(parent._$id)returnparent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";varvnode=vm.$vnode,context=vnode.context;returncontext&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}(vm)===nodeId}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?getDataByPath(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())},captureScreenshot:function(){returnnewPromise((function(resolve,reject){varpages=getCurrentPages(),len=pages.length;if(len){varpage=pages[len-1];if(page){varwebview=page.$getAppWebview(),bitmap_1=newplus.nativeObj.Bitmap("captureScreenshot");webview.draw(bitmap_1,(function(res){vardata=bitmap_1.toBase64Data().replace("data:image/null;base64,","");bitmap_1.clear(),resolve({data:data})}),(function(err){reject(Error("captureScreenshot fail: "+err.message))}))}}elsereject(Error("getCurrentPage fail."))}))}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};
varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnvm.$scope&&((scope=vm.$scope).__wxExparserNodeId__||scope.nodeId||scope.id)===nodeId;varscope}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?function(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}},Api={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varsocketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){socketTask.send({data:JSON.stringify(data)})}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn&&!fn)returndata.error={message:method+" unimplemented"},send(data);try{fn(params).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}swan.$$initRuntimeAutomator=function(options){void0===options&&(options={}),(socketTask=uni.connectSocket({url:wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){swan.$$initRuntimeAutomator()}),500);
varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnvm.$scope&&((scope=vm.$scope).__wxExparserNodeId__||scope.nodeId||scope.id)===nodeId;varscope}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?function(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())},captureScreenshot:function(){returnnewPromise((function(resolve,reject){varpages=getCurrentPages(),len=pages.length;if(len){varpage=pages[len-1];if(page){varwebview=page.$getAppWebview(),bitmap_1=newplus.nativeObj.Bitmap("captureScreenshot");webview.draw(bitmap_1,(function(res){vardata=bitmap_1.toBase64Data().replace("data:image/null;base64,","");bitmap_1.clear(),resolve({data:data})}),(function(err){reject(Error("captureScreenshot fail: "+err.message))}))}}elsereject(Error("getCurrentPage fail."))}))}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}},Api={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varsocketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){socketTask.send({data:JSON.stringify(data)})}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn&&!fn)returndata.error={message:method+" unimplemented"},send(data);try{fn(params).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}swan.$$initRuntimeAutomator=function(options){void0===options&&(options={}),(socketTask=uni.connectSocket({url:wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){swan.$$initRuntimeAutomator()}),500);
varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnvm.$scope&&((scope=vm.$scope).__wxExparserNodeId__||scope.nodeId||scope.id)===nodeId;varscope}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?function(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}},Api={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varsocketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){socketTask.send({data:JSON.stringify(data)})}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn&&!fn)returndata.error={message:method+" unimplemented"},send(data);try{fn(params).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}wx.$$initRuntimeAutomator=function(options){void0===options&&(options={}),(socketTask=uni.connectSocket({url:wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){wx.$$initRuntimeAutomator()}),500);
varCALL_METHOD_ERROR,hasOwnProperty=Object.prototype.hasOwnProperty,isUndef=function(v){returnnull==v},isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongetPaths(path,data){if(isArray(path))returnpath;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];varval,key,res=[];returnpath.replace(PATH_RE,(function(match,p1,offset,string){returnres.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}functiongetPageId(page){returnpage.__wxWebviewId__?page.__wxWebviewId__:page.privateProperties?page.privateProperties.slaveId:page.$page?page.$page.id:void0}functiongetPagePath(page){returnpage.route||page.uri}functiongetPageQuery(page){returnpage.options||page.$page&&page.$page.options||{}}functionparsePage(page){return{id:getPageId(page),path:getPagePath(page),query:getPageQuery(page)}}functiongetPageVm(id){varpage=function(id){returngetCurrentPages().find((function(page){returngetPageId(page)===id}))}(id);returnpage&&page.$vm}functionfindComponentVm(vm,nodeId){varres;returnvm&&(!function(vm,nodeId){returnvm.$scope&&((scope=vm.$scope).__wxExparserNodeId__||scope.nodeId||scope.id)===nodeId;varscope}(vm,nodeId)?vm.$children.find((function(child){returnres=findComponentVm(child,nodeId)})):res=vm),res}functiongetComponentVm(pageId,nodeId){varpageVm=getPageVm(pageId);returnpageVm&&findComponentVm(pageVm,nodeId)}functiongetData(vm,path){vardata;returnvm&&(data=path?function(data,path){vardataPath,paths=getPaths(path,data);for(dataPath=paths.shift();!isUndef(dataPath);){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}returndata}(vm.$data,path):Object.assign({},vm.$data)),Promise.resolve({data:data})}functionsetData(vm,data){returnvm&&Object.keys(data).forEach((function(name){vm[name]=data[name]})),Promise.resolve()}functioncallMethod(vm,method,args){returnnewPromise((function(resolve,reject){if(!vm)returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);if(!vm[method])returnreject(CALL_METHOD_ERROR.VM_NOT_EXISTS);varobj,ret=vm[method].apply(vm,args);!(obj=ret)||"object"!=typeofobj&&"function"!=typeofobj||"function"!=typeofobj.then?resolve({result:ret}):ret.then((function(res){resolve({result:res})}))}))}!function(CALL_METHOD_ERROR){CALL_METHOD_ERROR.VM_NOT_EXISTS="VM_NOT_EXISTS",CALL_METHOD_ERROR.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(CALL_METHOD_ERROR||(CALL_METHOD_ERROR={}));varSYNC_APIS=["stopRecord","getRecorderManager","pauseVoice","stopVoice","pauseBackgroundAudio","stopBackgroundAudio","getBackgroundAudioManager","createAudioContext","createInnerAudioContext","createVideoContext","createCameraContext","createMapContext","canIUse","startAccelerometer","stopAccelerometer","startCompass","stopCompass","hideToast","hideLoading","showNavigationBarLoading","hideNavigationBarLoading","navigateBack","createAnimation","pageScrollTo","createSelectorQuery","createCanvasContext","createContext","drawCanvas","hideKeyboard","stopPullDownRefresh","arrayBufferToBase64","base64ToArrayBuffer"],originUni={},SYNC_API_RE=/Sync$/,MOCK_API_BLACKLIST_RE=/^on|^off/;functionisSyncApi(method){returnSYNC_API_RE.test(method)||-1!==SYNC_APIS.indexOf(method)}varApp$1={getPageStack:function(){returnPromise.resolve({pageStack:getCurrentPages().map((function(page){returnparsePage(page)}))})},getCurrentPage:function(){varpages=getCurrentPages(),len=pages.length;returnnewPromise((function(resolve,reject){len?resolve(parsePage(pages[len-1])):reject(Error("getCurrentPages().length=0"))}))},callUniMethod:function(params){varmethod=params.method,args=params.args;returnnewPromise((function(resolve,reject){if(!uni[method])returnreject(Error("uni."+method+" not exists"));if(isSyncApi(method))returnresolve({result:uni[method].apply(uni,args)});varparams=[Object.assign({},args[0]||{},{success:function(result){setTimeout((function(){resolve({result:result})}),"pageScrollTo"===method?350:0)},fail:function(res){reject(Error(res.errMsg.replace(method+":fail ","")))}})];uni[method].apply(uni,params)}))},mockUniMethod:function(params){varmethod=params.method;if(!uni[method])throwError("uni."+method+" not exists");if(!function(method){return!MOCK_API_BLACKLIST_RE.test(method)}(method))throwError("You can't mock uni."+method);varmockFn,result=params.result,functionDeclaration=params.functionDeclaration;returnisUndef(result)&&isUndef(functionDeclaration)?(originUni[method]&&(uni[method]=originUni[method],deleteoriginUni[method]),Promise.resolve()):(mockFn=isUndef(functionDeclaration)?isSyncApi(method)?function(){returnresult}:function(params){setTimeout((function(){result.errMsg&&-1!==result.errMsg.indexOf(":fail")?params.fail&¶ms.fail(result):params.success&¶ms.success(result),params.complete&¶ms.complete(result)}),4)}:function(){for(varargs=[],_i=0;_i<arguments.length;_i++)args[_i]=arguments[_i];returnnewFunction("return "+functionDeclaration)().apply(mockFn,args.concat(params.args))},mockFn.origin=originUni[method]||uni[method],originUni[method]||(originUni[method]=uni[method]),uni[method]=mockFn,Promise.resolve())},captureScreenshot:function(){returnnewPromise((function(resolve,reject){varpages=getCurrentPages(),len=pages.length;if(len){varpage=pages[len-1];if(page){varwebview=page.$getAppWebview(),bitmap_1=newplus.nativeObj.Bitmap("captureScreenshot");webview.draw(bitmap_1,(function(res){vardata=bitmap_1.toBase64Data().replace("data:image/null;base64,","");bitmap_1.clear(),resolve({data:data})}),(function(err){reject(Error("captureScreenshot fail: "+err.message))}))}}elsereject(Error("getCurrentPage fail."))}))}},Page$1={getData:function(params){returngetData(getPageVm(params.pageId),params.path)},setData:function(params){returnsetData(getPageVm(params.pageId),params.data)},callMethod:function(params){var_a,err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Page["+params.pageId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="page."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getPageVm(params.pageId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}};functiongetNodeId(params){returnparams.nodeId||params.elementId}varElement$1={getData:function(params){returngetData(getComponentVm(params.pageId,getNodeId(params)),params.path)},setData:function(params){returnsetData(getComponentVm(params.pageId,getNodeId(params)),params.data)},callMethod:function(params){var_a,nodeId=getNodeId(params),err=((_a={})[CALL_METHOD_ERROR.VM_NOT_EXISTS]="Component["+params.pageId+":"+nodeId+"] not exists",_a[CALL_METHOD_ERROR.METHOD_NOT_EXISTS]="component."+params.method+" not exists",_a);returnnewPromise((function(resolve,reject){callMethod(getComponentVm(params.pageId,nodeId),params.method,params.args).then((function(res){returnresolve(res)})).catch((function(type){reject(Error(err[type]))}))}))}},Api={};Object.keys(App$1).forEach((function(method){Api["App."+method]=App$1[method]})),Object.keys(Page$1).forEach((function(method){Api["Page."+method]=Page$1[method]})),Object.keys(Element$1).forEach((function(method){Api["Element."+method]=Element$1[method]}));varsocketTask,wsEndpoint=process.env.UNI_AUTOMATOR_WS_ENDPOINT;functionsend(data){socketTask.send({data:JSON.stringify(data)})}functiononMessage(res){var_a=JSON.parse(res.data),id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn&&!fn)returndata.error={message:method+" unimplemented"},send(data);try{fn(params).then((function(res){res&&(data.result=res)})).catch((function(err){data.error={message:err.message}})).finally((function(){send(data)}))}catch(err){data.error={message:err.message},send(data)}}wx.$$initRuntimeAutomator=function(options){void0===options&&(options={}),(socketTask=uni.connectSocket({url:wsEndpoint,complete:function(){}})).onMessage(onMessage),socketTask.onOpen((function(res){options.success&&options.success(),console.log("已开启自动化测试...")})),socketTask.onError((function(res){console.log("automator.onError",res)})),socketTask.onClose((function(){options.fail&&options.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){wx.$$initRuntimeAutomator()}),500);