提交 5aab4c8f 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

chore(automator): 自动化测试支持 input 方法

上级 bc1cc557
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __spreadArrays(){for(var s=0,i=0,il=arguments.length;i<il;i++)s+=arguments[i].length;var r=Array(s),k=0;for(i=0;i<il;i++)for(var a=arguments[i],j=0,jl=a.length;j<jl;j++,k++)r[k]=a[j];return r}var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}for(var byteToHex=[],i=0;i<256;++i)byteToHex[i]=(i+256).toString(16).substr(1);function v4(options,buf,offset){var i=buf&&offset||0;"string"==typeof options&&(buf="binary"===options?new Array(16):null,options=null);var rnds=(options=options||{}).random||(options.rng||rng)();if(rnds[6]=15&rnds[6]|64,rnds[8]=63&rnds[8]|128,buf)for(var ii=0;ii<16;++ii)buf[i+ii]=rnds[ii];return buf||function(buf,offset){var i=offset||0,bth=byteToHex;return[bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]]].join("")}(rnds)}var hasOwnProperty=Object.prototype.hasOwnProperty,isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function getPaths(path,data){if(isArray(path))return path;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];var val,key,res=[];return path.replace(PATH_RE,(function(match,p1,offset,string){return res.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}function getDataByPath(data,path){var dataPath,paths=getPaths(path,data);for(dataPath=paths.shift();null!=dataPath;){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}return data}function getVmNodeId(vm){if(vm._$weex)return vm._uid;if(vm._$id)return vm._$id;var parent_1=function(vm){for(var parent=vm.$parent;parent;){if(parent._$id)return parent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";var vnode=vm.$vnode,context=vnode.context;return context&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}var elementMap=new Map;function transEl(el){var _a;if(!function(el){if(el){var tagName=el.tagName;return 0===tagName.indexOf("UNI-")||"BODY"===tagName||0===tagName.indexOf("V-UNI-")}return!1}(el))throw Error("no such element");var element,elementId,vm,elem={elementId:(element=el,elementId=element._id,elementId||(elementId=v4(),element._id=elementId,elementMap.set(elementId,{id:elementId,element:element})),elementId),tagName:el.tagName.toLocaleLowerCase().replace("uni-","")};el.__vue__?(vm=el.__vue__)&&(vm.$parent&&vm.$parent.$el===el&&(vm=vm.$parent),vm&&!(null===(_a=vm.$options)||void 0===_a?void 0:_a.isReserved)&&(elem.nodeId=getVmNodeId(vm))):(vm=el.__vnode)&&(vm.el===el&&(vm=vm.ctx.parent),vm&&(elem.nodeId=getVmNodeId(vm)));return"video"===elem.tagName&&(elem.videoId=elem.nodeId),elem}var FUNCTIONS={input:{input:function(el,value){var vm=el.__vue__;vm.valueSync=value,vm.$triggerInput({},{value:value})}},textarea:{input:function(el,value){var vm=el.__vue__;vm.valueSync=value,vm.$triggerInput({},{value:value})}},"scroll-view":{scrollTo:function(el,x,y){var main=el.__vue__.$refs.main;main.scrollLeft=x,main.scrollTop=y},scrollTop:function(el){return el.__vue__.$refs.main.scrollTop},scrollLeft:function(el){return el.__vue__.$refs.main.scrollLeft},scrollWidth:function(el){return el.__vue__.$refs.main.scrollWidth},scrollHeight:function(el){return el.__vue__.$refs.main.scrollHeight}},swiper:{swipeTo:function(el,index){el.__vue__.current=index}},"movable-view":{moveTo:function(el,x,y){el.__vue__._animationTo(x,y)}},switch:{tap:function(el){el.click()}},slider:{slideTo:function(el,value){var vm=el.__vue__,slider=vm.$refs["uni-slider"],offsetWidth=slider.offsetWidth,boxLeft=slider.getBoundingClientRect().left;vm.value=value,vm._onClick({x:(value-vm.min)*offsetWidth/(vm.max-vm.min)+boxLeft})}}};function createTouchList(touchInits){var _a,touches=touchInits.map((function(touch){return function(touch){if(document.createTouch)return document.createTouch(window,touch.target,touch.identifier,touch.pageX,touch.pageY,touch.screenX,touch.screenY);return new Touch(touch)}(touch)}));return document.createTouchList?(_a=document).createTouchList.apply(_a,touches):touches}var WebAdapter={getWindow:function(pageId){return window},getDocument:function(pageId){return document},getEl:function(elementId){var element=elementMap.get(elementId);if(!element)throw Error("element destroyed");return element.element},getOffset:function(node){var rect=node.getBoundingClientRect();return Promise.resolve({left:rect.left+window.pageXOffset,top:rect.top+window.pageYOffset})},querySelector:function(context,selector){return"page"===selector&&(selector="body"),Promise.resolve(transEl(context.querySelector(selector)))},querySelectorAll:function(context,selector){var elements=[],nodeList=document.querySelectorAll(selector);return[].forEach.call(nodeList,(function(node){try{elements.push(transEl(node))}catch(e){}})),Promise.resolve({elements:elements})},queryProperties:function(context,names){return Promise.resolve({properties:names.map((function(name){var value=getDataByPath(context,name.replace(/-([a-z])/g,(function(g){return g[1].toUpperCase()})));return"document.documentElement.scrollTop"===name&&0===value&&(value=getDataByPath(context,"document.body.scrollTop")),"innerText"===name?value.replace(/\n/g,""):value}))})},queryAttributes:function(context,names){return Promise.resolve({attributes:names.map((function(name){return String(context.getAttribute(name))}))})},queryStyles:function(context,names){var style=getComputedStyle(context);return Promise.resolve({styles:names.map((function(name){return style[name]}))})},queryHTML:function(context,type){return Promise.resolve({html:(html="outer"===type?context.outerHTML:context.innerHTML,html.replace(/\n/g,"").replace(/(<uni-text[^>]*>)(<span[^>]*>[^<]*<\/span>)(.*?<\/uni-text>)/g,"$1$3").replace(/<\/?[^>]*>/g,(function(replacement){return-1<replacement.indexOf("<body")?"<page>":"</body>"===replacement?"</page>":0!==replacement.indexOf("<uni-")&&0!==replacement.indexOf("</uni-")?"":replacement.replace(/uni-/g,"").replace(/ role=""/g,"").replace(/ aria-label=""/g,"")})))});var html},dispatchTapEvent:function(el){return el.click(),Promise.resolve()},dispatchLongpressEvent:function(el){return Promise.resolve()},dispatchTouchEvent:function(el,type,eventInitDict){eventInitDict||(eventInitDict={}),eventInitDict.touches||(eventInitDict.touches=[]),eventInitDict.changedTouches||(eventInitDict.changedTouches=[]),eventInitDict.touches.length||eventInitDict.touches.push({identifier:Date.now(),target:el});var touches=createTouchList(eventInitDict.touches),changedTouches=createTouchList(eventInitDict.changedTouches),targetTouches=createTouchList([]);return el.dispatchEvent(new TouchEvent(type,{cancelable:!0,bubbles:!0,touches:touches,targetTouches:targetTouches,changedTouches:changedTouches})),Promise.resolve()},callFunction:function(el,functionName,args){var fn=getDataByPath(FUNCTIONS,functionName);return fn?Promise.resolve({result:fn.apply(null,__spreadArrays([el],args))}):Promise.reject(Error(functionName+" not exists"))},triggerEvent:function(el,type,detail){var vm=el.__vue__;return vm.$trigger&&vm.$trigger(type,{},detail),Promise.resolve()}};var Api=Object.assign({},function(adapter){return{"Page.getElement":function(params){return adapter.querySelector(adapter.getDocument(params.pageId),params.selector)},"Page.getElements":function(params){return adapter.querySelectorAll(adapter.getDocument(params.pageId),params.selector)},"Page.getWindowProperties":function(params){return adapter.queryProperties(adapter.getWindow(params.pageId),params.names)}}}(WebAdapter),function(adapter){var getEl=function(params){return adapter.getEl(params.elementId,params.pageId)};return{"Element.getElement":function(params){return adapter.querySelector(getEl(params),params.selector)},"Element.getElements":function(params){return adapter.querySelectorAll(getEl(params),params.selector)},"Element.getDOMProperties":function(params){return adapter.queryProperties(getEl(params),params.names)},"Element.getProperties":function(params){var el=getEl(params),ctx=el.__vue__||el.attr||{};return el.__vueParentComponent&&(ctx=Object.assign({},ctx,el.__vueParentComponent.attrs,el.__vueParentComponent.props)),adapter.queryProperties(ctx,params.names)},"Element.getOffset":function(params){return adapter.getOffset(getEl(params))},"Element.getAttributes":function(params){return adapter.queryAttributes(getEl(params),params.names)},"Element.getStyles":function(params){return adapter.queryStyles(getEl(params),params.names)},"Element.getHTML":function(params){return adapter.queryHTML(getEl(params),params.type)},"Element.tap":function(params){return adapter.dispatchTapEvent(getEl(params))},"Element.longpress":function(params){return adapter.dispatchLongpressEvent(getEl(params))},"Element.touchstart":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchstart",params)},"Element.touchmove":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchmove",params)},"Element.touchend":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchend",params)},"Element.callFunction":function(params){return adapter.callFunction(getEl(params),params.functionName,params.args)},"Element.triggerEvent":function(params){return adapter.triggerEvent(getEl(params),params.type,params.detail)}}}(WebAdapter));function send(data){return UniViewJSBridge.publishHandler("onAutoMessageReceive",data)}UniViewJSBridge.subscribe("sendAutoMessage",(function(_a){var id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn)return data.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)}}));
import{__spreadArray}from"tslib";var getRandomValues="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),rnds8=new Uint8Array(16);function rng(){if(!getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return getRandomValues(rnds8)}for(var byteToHex=[],i=0;i<256;++i)byteToHex[i]=(i+256).toString(16).substr(1);function v4(options,buf,offset){var i=buf&&offset||0;"string"==typeof options&&(buf="binary"===options?new Array(16):null,options=null);var rnds=(options=options||{}).random||(options.rng||rng)();if(rnds[6]=15&rnds[6]|64,rnds[8]=63&rnds[8]|128,buf)for(var ii=0;ii<16;++ii)buf[i+ii]=rnds[ii];return buf||function(buf,offset){var i=offset||0,bth=byteToHex;return[bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],"-",bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]],bth[buf[i++]]].join("")}(rnds)}var hasOwnProperty=Object.prototype.hasOwnProperty,isArray=Array.isArray,PATH_RE=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function getPaths(path,data){if(isArray(path))return path;if(data&&(val=data,key=path,hasOwnProperty.call(val,key)))return[path];var val,key,res=[];return path.replace(PATH_RE,(function(match,p1,offset,string){return res.push(offset?string.replace(/\\(\\)?/g,"$1"):p1||match),string})),res}function getDataByPath(data,path){var dataPath,paths=getPaths(path,data);for(dataPath=paths.shift();null!=dataPath;){if(null==(data=data[dataPath]))return;dataPath=paths.shift()}return data}function getVmNodeId(vm){if(vm._$weex)return vm._uid;if(vm._$id)return vm._$id;var parent_1=function(vm){for(var parent=vm.$parent;parent;){if(parent._$id)return parent;parent=parent.$parent}}(vm);if(!vm.$parent)return"-1";var vnode=vm.$vnode,context=vnode.context;return context&&context!==parent_1&&context._$id?context._$id+";"+parent_1._$id+","+vnode.data.attrs._i:parent_1._$id+","+vnode.data.attrs._i}var elementMap=new Map;function transEl(el){var _a,_b;if(!function(el){if(el){var tagName=el.tagName;return 0===tagName.indexOf("UNI-")||"BODY"===tagName||0===tagName.indexOf("V-UNI-")}return!1}(el))throw Error("no such element");var element,elementId,vm,elem={elementId:(element=el,elementId=element._id,elementId||(elementId=v4(),element._id=elementId,elementMap.set(elementId,{id:elementId,element:element})),elementId),tagName:el.tagName.toLocaleLowerCase().replace("uni-","")};el.__vue__?(vm=el.__vue__)&&(vm.$parent&&vm.$parent.$el===el&&(vm=vm.$parent),vm&&!(null===(_a=vm.$options)||void 0===_a?void 0:_a.isReserved)&&(elem.nodeId=getVmNodeId(vm))):(vm=el.__vnode)&&(vm.el===el&&(vm=vm.ctx.parent),vm&&!(null===(_b=vm.type)||void 0===_b?void 0:_b.__reserved)&&(elem.nodeId=getVmNodeId(vm)));return"video"===elem.tagName&&(elem.videoId=elem.nodeId),elem}var FUNCTIONS={input:{input:function(el,value){var vm=el.__vue__;vm?(vm.valueSync=value,vm.$triggerInput({},{value:value})):(vm=el.__vnode).ctx.exposed.$triggerInput({value:value})}},textarea:{input:function(el,value){var vm=el.__vue__;vm?(vm.valueSync=value,vm.$triggerInput({},{value:value})):(vm=el.__vnode).ctx.exposed.$triggerInput({value:value})}},"scroll-view":{scrollTo:function(el,x,y){var main=el.__vue__.$refs.main;main.scrollLeft=x,main.scrollTop=y},scrollTop:function(el){return el.__vue__.$refs.main.scrollTop},scrollLeft:function(el){return el.__vue__.$refs.main.scrollLeft},scrollWidth:function(el){return el.__vue__.$refs.main.scrollWidth},scrollHeight:function(el){return el.__vue__.$refs.main.scrollHeight}},swiper:{swipeTo:function(el,index){el.__vue__.current=index}},"movable-view":{moveTo:function(el,x,y){el.__vue__._animationTo(x,y)}},switch:{tap:function(el){el.click()}},slider:{slideTo:function(el,value){var vm=el.__vue__,slider=vm.$refs["uni-slider"],offsetWidth=slider.offsetWidth,boxLeft=slider.getBoundingClientRect().left;vm.value=value,vm._onClick({x:(value-vm.min)*offsetWidth/(vm.max-vm.min)+boxLeft})}}};function createTouchList(touchInits){var _a,touches=touchInits.map((function(touch){return function(touch){if(document.createTouch)return document.createTouch(window,touch.target,touch.identifier,touch.pageX,touch.pageY,touch.screenX,touch.screenY);return new Touch(touch)}(touch)}));return document.createTouchList?(_a=document).createTouchList.apply(_a,touches):touches}var WebAdapter={getWindow:function(pageId){return window},getDocument:function(pageId){return document},getEl:function(elementId){var element=elementMap.get(elementId);if(!element)throw Error("element destroyed");return element.element},getOffset:function(node){var rect=node.getBoundingClientRect();return Promise.resolve({left:rect.left+window.pageXOffset,top:rect.top+window.pageYOffset})},querySelector:function(context,selector){return"page"===selector&&(selector="body"),Promise.resolve(transEl(context.querySelector(selector)))},querySelectorAll:function(context,selector){var elements=[],nodeList=document.querySelectorAll(selector);return[].forEach.call(nodeList,(function(node){try{elements.push(transEl(node))}catch(e){}})),Promise.resolve({elements:elements})},queryProperties:function(context,names){return Promise.resolve({properties:names.map((function(name){var value=getDataByPath(context,name.replace(/-([a-z])/g,(function(g){return g[1].toUpperCase()})));return"document.documentElement.scrollTop"===name&&0===value&&(value=getDataByPath(context,"document.body.scrollTop")),"innerText"===name?value.replace(/\n/g,""):value}))})},queryAttributes:function(context,names){return Promise.resolve({attributes:names.map((function(name){return String(context.getAttribute(name))}))})},queryStyles:function(context,names){var style=getComputedStyle(context);return Promise.resolve({styles:names.map((function(name){return style[name]}))})},queryHTML:function(context,type){return Promise.resolve({html:(html="outer"===type?context.outerHTML:context.innerHTML,html.replace(/\n/g,"").replace(/(<uni-text[^>]*>)(<span[^>]*>[^<]*<\/span>)(.*?<\/uni-text>)/g,"$1$3").replace(/<\/?[^>]*>/g,(function(replacement){return-1<replacement.indexOf("<body")?"<page>":"</body>"===replacement?"</page>":0!==replacement.indexOf("<uni-")&&0!==replacement.indexOf("</uni-")?"":replacement.replace(/uni-/g,"").replace(/ role=""/g,"").replace(/ aria-label=""/g,"")})))});var html},dispatchTapEvent:function(el){return el.click(),Promise.resolve()},dispatchLongpressEvent:function(el){return Promise.resolve()},dispatchTouchEvent:function(el,type,eventInitDict){eventInitDict||(eventInitDict={}),eventInitDict.touches||(eventInitDict.touches=[]),eventInitDict.changedTouches||(eventInitDict.changedTouches=[]),eventInitDict.touches.length||eventInitDict.touches.push({identifier:Date.now(),target:el});var touches=createTouchList(eventInitDict.touches),changedTouches=createTouchList(eventInitDict.changedTouches),targetTouches=createTouchList([]);return el.dispatchEvent(new TouchEvent(type,{cancelable:!0,bubbles:!0,touches:touches,targetTouches:targetTouches,changedTouches:changedTouches})),Promise.resolve()},callFunction:function(el,functionName,args){var fn=getDataByPath(FUNCTIONS,functionName);return fn?Promise.resolve({result:fn.apply(null,__spreadArray([el],args,!0))}):Promise.reject(Error("".concat(functionName," not exists")))},triggerEvent:function(el,type,detail){var vm=el.__vue__;return vm.$trigger&&vm.$trigger(type,{},detail),Promise.resolve()}};var Api=Object.assign({},function(adapter){return{"Page.getElement":function(params){return adapter.querySelector(adapter.getDocument(params.pageId),params.selector)},"Page.getElements":function(params){return adapter.querySelectorAll(adapter.getDocument(params.pageId),params.selector)},"Page.getWindowProperties":function(params){return adapter.queryProperties(adapter.getWindow(params.pageId),params.names)}}}(WebAdapter),function(adapter){var getEl=function(params){return adapter.getEl(params.elementId,params.pageId)};return{"Element.getElement":function(params){return adapter.querySelector(getEl(params),params.selector)},"Element.getElements":function(params){return adapter.querySelectorAll(getEl(params),params.selector)},"Element.getDOMProperties":function(params){return adapter.queryProperties(getEl(params),params.names)},"Element.getProperties":function(params){var el=getEl(params),ctx=el.__vue__||el.attr||{};return el.__vueParentComponent&&(ctx=Object.assign({},ctx,el.__vueParentComponent.attrs,el.__vueParentComponent.props)),adapter.queryProperties(ctx,params.names)},"Element.getOffset":function(params){return adapter.getOffset(getEl(params))},"Element.getAttributes":function(params){return adapter.queryAttributes(getEl(params),params.names)},"Element.getStyles":function(params){return adapter.queryStyles(getEl(params),params.names)},"Element.getHTML":function(params){return adapter.queryHTML(getEl(params),params.type)},"Element.tap":function(params){return adapter.dispatchTapEvent(getEl(params))},"Element.longpress":function(params){return adapter.dispatchLongpressEvent(getEl(params))},"Element.touchstart":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchstart",params)},"Element.touchmove":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchmove",params)},"Element.touchend":function(params){return adapter.dispatchTouchEvent(getEl(params),"touchend",params)},"Element.callFunction":function(params){return adapter.callFunction(getEl(params),params.functionName,params.args)},"Element.triggerEvent":function(params){return adapter.triggerEvent(getEl(params),params.type,params.detail)}}}(WebAdapter));function send(data){return UniViewJSBridge.publishHandler("onAutoMessageReceive",data)}UniViewJSBridge.subscribe("sendAutoMessage",(function(_a){var id=_a.id,method=_a.method,params=_a.params,data={id:id},fn=Api[method];if(!fn)return data.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)}}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var e=function(){return e=Object.assign||function(e){for(var n,t=1,r=arguments.length;t<r;t++)for(var o in n=arguments[t])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e},e.apply(this,arguments)};function n(){for(var e=0,n=0,t=arguments.length;n<t;n++)e+=arguments[n].length;var r=Array(e),o=0;for(n=0;n<t;n++)for(var i=arguments[n],u=0,a=i.length;u<a;u++,o++)r[o]=i[u];return r}var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),r=new Uint8Array(16);function o(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(r)}for(var i=[],u=0;u<256;++u)i[u]=(u+256).toString(16).substr(1);function a(e,n,t){var r=n&&t||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null);var u=(e=e||{}).random||(e.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,n)for(var a=0;a<16;++a)n[r+a]=u[a];return n||function(e,n){var t=n||0,r=i;return[r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],"-",r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]],r[e[t++]]].join("")}(u)}var c=Object.prototype.hasOwnProperty,s=function(e){return null==e},l=Array.isArray,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function d(e,n){if(l(e))return e;if(n&&(t=n,r=e,c.call(t,r)))return[e];var t,r,o=[];return e.replace(f,(function(e,n,t,r){return o.push(t?r.replace(/\\(\\)?/g,"$1"):n||e),r})),o}function g(e,n){var t,r=d(n,e);for(t=r.shift();!s(t);){if(null==(e=e[t]))return;t=r.shift()}return e}function p(e){return e._uid||e.uid}var m=new Map;function v(e){var n;if(!function(e){if(e){var n=e.tagName;return 0===n.indexOf("UNI-")||"BODY"===n||0===n.indexOf("V-UNI-")}return!1}(e))throw Error("no such element");var t,r,o,i={elementId:(t=e,r=t._id,r||(r=a(),t._id=r,m.set(r,{id:r,element:t})),r),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")};e.__vue__?(o=e.__vue__)&&(o.$parent&&o.$parent.$el===e&&(o=o.$parent),o&&!(null===(n=o.$options)||void 0===n?void 0:n.isReserved)&&(i.nodeId=p(o))):(o=e.__vnode)&&(o.el===e&&(o=o.ctx.parent),o&&(i.nodeId=p(o)));return"video"===i.tagName&&(i.videoId=i.nodeId),i}var h={input:{input:function(e,n){var t=e.__vue__;t.valueSync=n,t.$triggerInput({},{value:n})}},textarea:{input:function(e,n){var t=e.__vue__;t.valueSync=n,t.$triggerInput({},{value:n})}},"scroll-view":{scrollTo:function(e,n,t){var r=e.__vue__.$refs.main;r.scrollLeft=n,r.scrollTop=t},scrollTop:function(e){return e.__vue__.$refs.main.scrollTop},scrollLeft:function(e){return e.__vue__.$refs.main.scrollLeft},scrollWidth:function(e){return e.__vue__.$refs.main.scrollWidth},scrollHeight:function(e){return e.__vue__.$refs.main.scrollHeight}},swiper:{swipeTo:function(e,n){e.__vue__.current=n}},"movable-view":{moveTo:function(e,n,t){e.__vue__._animationTo(n,t)}},switch:{tap:function(e){e.click()}},slider:{slideTo:function(e,n){var t=e.__vue__,r=t.$refs["uni-slider"],o=r.offsetWidth,i=r.getBoundingClientRect().left;t.value=n,t._onClick({x:(n-t.min)*o/(t.max-t.min)+i})}}};function _(e){var n,t=e.map((function(e){return function(e){if(document.createTouch)return document.createTouch(window,e.target,e.identifier,e.pageX,e.pageY,e.screenX,e.screenY);return new Touch(e)}(e)}));return document.createTouchList?(n=document).createTouchList.apply(n,t):t}var y={getWindow:function(e){return window},getDocument:function(e){return document},getEl:function(e){var n=m.get(e);if(!n)throw Error("element destroyed");return n.element},getOffset:function(e){var n=e.getBoundingClientRect();return Promise.resolve({left:n.left+window.pageXOffset,top:n.top+window.pageYOffset})},querySelector:function(e,n){return"page"===n&&(n="body"),Promise.resolve(v(e.querySelector(n)))},querySelectorAll:function(e,n){var t=[],r=document.querySelectorAll(n);return[].forEach.call(r,(function(e){try{t.push(v(e))}catch(e){}})),Promise.resolve({elements:t})},queryProperties:function(e,n){return Promise.resolve({properties:n.map((function(n){var t=g(e,n.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()})));return"document.documentElement.scrollTop"===n&&0===t&&(t=g(e,"document.body.scrollTop")),"innerText"===n?t.replace(/\n/g,""):t}))})},queryAttributes:function(e,n){return Promise.resolve({attributes:n.map((function(n){return String(e.getAttribute(n))}))})},queryStyles:function(e,n){var t=getComputedStyle(e);return Promise.resolve({styles:n.map((function(e){return t[e]}))})},queryHTML:function(e,n){return Promise.resolve({html:(t="outer"===n?e.outerHTML:e.innerHTML,t.replace(/\n/g,"").replace(/(<uni-text[^>]*>)(<span[^>]*>[^<]*<\/span>)(.*?<\/uni-text>)/g,"$1$3").replace(/<\/?[^>]*>/g,(function(e){return-1<e.indexOf("<body")?"<page>":"</body>"===e?"</page>":0!==e.indexOf("<uni-")&&0!==e.indexOf("</uni-")?"":e.replace(/uni-/g,"").replace(/ role=""/g,"").replace(/ aria-label=""/g,"")})))});var t},dispatchTapEvent:function(e){return e.click(),Promise.resolve()},dispatchLongpressEvent:function(e){return Promise.resolve()},dispatchTouchEvent:function(e,n,t){t||(t={}),t.touches||(t.touches=[]),t.changedTouches||(t.changedTouches=[]),t.touches.length||t.touches.push({identifier:Date.now(),target:e});var r=_(t.touches),o=_(t.changedTouches),i=_([]);return e.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,touches:r,targetTouches:i,changedTouches:o})),Promise.resolve()},callFunction:function(e,t,r){var o=g(h,t);return o?Promise.resolve({result:o.apply(null,n([e],r))}):Promise.reject(Error(t+" not exists"))},triggerEvent:function(e,n,t){var r=e.__vue__;return r.$trigger&&r.$trigger(n,{},t),Promise.resolve()}};var S,T=Object.assign({},function(e){return{"Page.getElement":function(n){return e.querySelector(e.getDocument(n.pageId),n.selector)},"Page.getElements":function(n){return e.querySelectorAll(e.getDocument(n.pageId),n.selector)},"Page.getWindowProperties":function(n){return e.queryProperties(e.getWindow(n.pageId),n.names)}}}(y),function(e){var n=function(n){return e.getEl(n.elementId,n.pageId)};return{"Element.getElement":function(t){return e.querySelector(n(t),t.selector)},"Element.getElements":function(t){return e.querySelectorAll(n(t),t.selector)},"Element.getDOMProperties":function(t){return e.queryProperties(n(t),t.names)},"Element.getProperties":function(t){var r=n(t),o=r.__vue__||r.attr||{};return r.__vueParentComponent&&(o=Object.assign({},o,r.__vueParentComponent.attrs,r.__vueParentComponent.props)),e.queryProperties(o,t.names)},"Element.getOffset":function(t){return e.getOffset(n(t))},"Element.getAttributes":function(t){return e.queryAttributes(n(t),t.names)},"Element.getStyles":function(t){return e.queryStyles(n(t),t.names)},"Element.getHTML":function(t){return e.queryHTML(n(t),t.type)},"Element.tap":function(t){return e.dispatchTapEvent(n(t))},"Element.longpress":function(t){return e.dispatchLongpressEvent(n(t))},"Element.touchstart":function(t){return e.dispatchTouchEvent(n(t),"touchstart",t)},"Element.touchmove":function(t){return e.dispatchTouchEvent(n(t),"touchmove",t)},"Element.touchend":function(t){return e.dispatchTouchEvent(n(t),"touchend",t)},"Element.callFunction":function(t){return e.callFunction(n(t),t.functionName,t.args)},"Element.triggerEvent":function(t){return e.triggerEvent(n(t),t.type,t.detail)}}}(y));function E(e){return UniViewJSBridge.publishHandler("onAutoMessageReceive",e)}function w(e){return e.__wxWebviewId__?e.__wxWebviewId__:e.privateProperties?e.privateProperties.slaveId:e.$page?e.$page.id:void 0}function P(e){return e.route||e.uri}function O(e){return e.options||e.$page&&e.$page.options||{}}function b(e){return{id:w(e),path:P(e),query:O(e)}}function M(e){var n=function(e){return getCurrentPages().find((function(n){return w(n)===e}))}(e);return n&&n.$vm}function I(e,n){return e._uid===n||e.uid===n}function C(e,n,t){var r,o,i;if(void 0===t&&(t=!1),t)if(e.component&&I(e.component,n))i=e.component;else{var u=[];e.children instanceof Array?u=e.children:(null===(o=null===(r=e.component)||void 0===r?void 0:r.subTree)||void 0===o?void 0:o.children)&&(u=e.component.subTree.children),u.find((function(e){return i=C(e,n,!0)}))}else e&&(I(e,n)?i=e:e.$children.find((function(e){return i=C(e,n)})));return i}function x(e,n){var t=M(e);if(t)return N(t)?C(t.$.subTree,n,!0):C(t,n)}function $(e,n){var t,r=e.$data||e.data;return e&&(t=n?g(r,n):Object.assign({},r)),Promise.resolve({data:t})}function k(e,n){if(e){var t=N(e);Object.keys(n).forEach((function(r){t?(e.$data||e.data)[r]=n[r]:e[r]=n[r]}))}return Promise.resolve()}function A(e,n,t){return N(e)&&(e=e.$vm||e.ctx),new Promise((function(r,o){var i,u;if(!e)return o(S.VM_NOT_EXISTS);if(!e[n]&&!(null===(u=e.$.exposed)||void 0===u?void 0:u[n]))return o(S.METHOD_NOT_EXISTS);var a,c=e[n]?e[n].apply(e,t):(i=e.$.exposed)[n].apply(i,t);!(a=c)||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?r({result:c}):c.then((function(e){r({result:e})}))}))}function N(e){return!e.$children}function W(){return window.__uniapp_x_}UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var n=e.id,t=e.method,r=e.params,o={id:n},i=T[t];if(!i)return o.error={message:t+" unimplemented"},E(o);try{i(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){E(o)}))}catch(e){o.error={message:e.message},E(o)}})),function(e){e.VM_NOT_EXISTS="VM_NOT_EXISTS",e.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(S||(S={}));var B=1,D={};function V(e,n){var t=0;n&&(t=B++,D[t]=n);var r={data:{id:t,type:"automator",data:e}};console.log("postMessageToUniXWebView",r),window.__uniapp_x_.postMessage(JSON.stringify(r))}var q=new Map,L=function(n){return new Promise((function(t,r){var o=q.values().next().value;if(o){var i=n.method;if("onOpen"===i)return U(o,t);if(i.startsWith("on"))return o.instance[i]((function(e){t(e)}));"sendMessage"===i&&(i="send"),o.instance[i](e(e({},n),{success:function(e){t({result:e}),"close"===i&&q.delete(q.keys().next().value)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))};function U(e,n){if(e.isOpend)n({data:e.openData});else{var t=setInterval((function(){e.isOpend&&(clearInterval(t),n(e.openData))}),200);setTimeout((function(){clearInterval(t)}),2e3)}}var R=["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"],X=new Map,H=["onCompassChange","onThemeChange","onUserCaptureScreen","onWindowResize","onMemoryWarning","onAccelerometerChange","onKeyboardHeightChange","onNetworkStatusChange","onPushMessage","onLocationChange","onGetWifiList","onWifiConnected","onWifiConnectedWithPartialInfo","onSocketOpen","onSocketError","onSocketMessage","onSocketClose"],j={},J=/^\$|Sync$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/,F=/^on|^off/;function Y(e){return J.test(e)||-1!==R.indexOf(e)}var z={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(e){return b(e)}))})},getCurrentPage:function(){var e=getCurrentPages(),n=e.length;return new Promise((function(t,r){n?t(b(e[n-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n,t){var r=n.method,o=n.args;return new Promise((function(n,i){if("connectSocket"!==r){var u,a;if(H.includes(r)){X.has(r)||X.set(r,new Map);var c=o[0],s=function(e){t({id:c,result:{method:r,data:e}})};return r.startsWith("onSocket")?L({method:r.replace("Socket","")}).then((function(e){return s(e)})).catch((function(e){return s(e)})):(X.get(r).set(c,s),uni[r](s)),n({result:null})}if(r.startsWith("off")&&H.includes(r.replace("off","on"))){var l=r.replace("off","on");if(X.has(l)){var f=o[0];if(void 0!==f){var d=X.get(l).get(f);uni[r](d),X.get(l).delete(f)}else{X.get(l).forEach((function(e){uni[r](e)})),X.delete(l)}}return n({result:null})}if(r.indexOf("Socket")>0)return L(e({method:r.replace("Socket","")},o[0])).then((function(e){return n(e)})).catch((function(e){return i(e)}));if(!uni[r])return i(Error("uni."+r+" not exists"));if(Y(r))return n({result:uni[r].apply(uni,o)});var g=[Object.assign({},o[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===r?350:0)},fail:function(e){i(Error(e.errMsg.replace(r+":fail ","")))}})];uni[r].apply(uni,g)}else(u=o[0].id,a=o[0].url,new Promise((function(e,n){var t=uni.connectSocket({url:a,success:function(){e({result:{errMsg:"connectSocket:ok"}})},fail:function(){n({result:{errMsg:"connectSocket:fail"}})}});q.set(u,{instance:t,isOpend:!1}),t.onOpen((function(e){q.get(u).isOpend=!0,q.get(u).openData=e}))}))).then((function(e){return n(e)})).catch((function(e){return i(e)}))}))},mockUniMethod:function(e){var n=e.method;if(!uni[n])throw Error("uni."+n+" not exists");if(!function(e){return!F.test(e)}(n))throw Error("You can't mock uni."+n);var t,r=e.result,o=e.functionDeclaration;return s(r)&&s(o)?(j[n]&&(uni[n]=j[n],delete j[n]),Promise.resolve()):(t=s(o)?Y(n)?function(){return r}:function(e){setTimeout((function(){r.errMsg&&-1!==r.errMsg.indexOf(":fail")?e.fail&&e.fail(r):e.success&&e.success(r),e.complete&&e.complete(r)}),4)}:function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];return new Function("return "+o)().apply(t,n.concat(e.args))},t.origin=j[n]||uni[n],j[n]||(j[n]=uni[n]),uni[n]=t,Promise.resolve())},captureScreenshot:function(e){return new Promise((function(n,t){W()?V({action:"captureScreenshot",args:e},(function(e,r){e?t(Error("captureScreenshot fail: "+e)):n(r)})):t(Error("captureScreenshot fail: supported only on the app platform."))}))},socketEmitter:function(n){return new Promise((function(t,r){(function(n){return new Promise((function(t,r){if(q.has(n.id)){var o=q.get(n.id),i=o.instance,u=n.method,a=n.id;if("onOpen"==u)return U(o,t);if(u.startsWith("on"))return i[u]((function(e){t({method:"Socket."+u,id:a,data:e})}));i[u](e(e({},n),{success:function(e){t(e),"close"===u&&q.delete(n.id)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))})(n).then((function(e){return t(e)})).catch((function(e){return r(e)}))}))}},G=z,K={getData:function(e){return $(M(e.pageId),e.path)},setData:function(e){return k(M(e.pageId),e.data)},callMethod:function(e){var n,t=((n={})[S.VM_NOT_EXISTS]="Page["+e.pageId+"] not exists",n[S.METHOD_NOT_EXISTS]="page."+e.method+" not exists",n);return new Promise((function(n,r){A(M(e.pageId),e.method,e.args).then((function(e){return n(e)})).catch((function(e){r(Error(t[e]))}))}))},callMethodWithCallback:function(e){var n,t=((n={})[S.VM_NOT_EXISTS]="callMethodWithCallback:fail, Page["+e.pageId+"] not exists",n[S.METHOD_NOT_EXISTS]="callMethodWithCallback:fail, page."+e.method+" not exists",n),r=e.args[e.args.length-1];A(M(e.pageId),e.method,e.args).catch((function(e){r({errMsg:t[e]})}))}};function Q(e){return e.nodeId||e.elementId}var Z={getData:function(e){return $(x(e.pageId,Q(e)),e.path)},setData:function(e){return k(x(e.pageId,Q(e)),e.data)},callMethod:function(e){var n,t=Q(e),r=((n={})[S.VM_NOT_EXISTS]="Component["+e.pageId+":"+t+"] not exists",n[S.METHOD_NOT_EXISTS]="component."+e.method+" not exists",n);return new Promise((function(n,o){A(x(e.pageId,t),e.method,e.args).then((function(e){return n(e)})).catch((function(e){o(Error(r[e]))}))}))}},ee={};Object.keys(G).forEach((function(e){ee["App."+e]=G[e]})),Object.keys(K).forEach((function(e){ee["Page."+e]=K[e]})),Object.keys(Z).forEach((function(e){ee["Element."+e]=Z[e]}));var ne,te,re=process.env.UNI_AUTOMATOR_WS_ENDPOINT;function oe(e){te.send({data:JSON.stringify(e)})}function ie(e){var n=JSON.parse(e.data),t=n.id,r=n.method,o=n.params,i={id:t},u=ee[r];if(!u){if(ne){var a=ne(t,r,o,i);if(!0===a)return;u=a}if(!u)return i.error={message:r+" unimplemented"},oe(i)}try{u(o,oe).then((function(e){e&&(i.result=e)})).catch((function(e){i.error={message:e.message}})).finally((function(){oe(i)}))}catch(e){i.error={message:e.message},oe(i)}}function ue(e){void 0===e&&(e={}),(te=uni.connectSocket({url:e.wsEndpoint||re,complete:function(){}})).onMessage(ie),te.onOpen((function(n){e.success&&e.success(),console.log("已开启自动化测试...")})),te.onError((function(e){console.log("automator.onError",e)})),te.onClose((function(){e.fail&&e.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}ne=function(e,n,t,r){var o=t.pageId,i=function(e){var n=getCurrentPages();if(!e)return n[n.length-1];return n.find((function(n){return n.$page.id===e}))}(o);return i?(i.$page.meta.isNVue,UniServiceJSBridge.publishHandler("sendAutoMessage",{id:e,method:n,params:t},o),!0):(r.error={message:"page["+o+"] not exists"},oe(r),!0)},UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(e){oe(e)})),setTimeout((function(){if(W())V({action:"ready"});else{if(re&&re.endsWith(":0000"))return;ue()}}),500),window.initRuntimeAutomator=ue,window.onPostMessageFromUniXWebView=function(e,n,t){console.log("onPostMessageFromUniXWebView",e,n,t,D);var r=D[e];r&&(delete D[e],r(t,n))};
import{__spreadArray as e,__assign as t}from"tslib";var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),r=new Uint8Array(16);function o(){if(!n)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(r)}for(var i=[],u=0;u<256;++u)i[u]=(u+256).toString(16).substr(1);function a(e,t,n){var r=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var u=(e=e||{}).random||(e.rng||o)();if(u[6]=15&u[6]|64,u[8]=63&u[8]|128,t)for(var a=0;a<16;++a)t[r+a]=u[a];return t||function(e,t){var n=t||0,r=i;return[r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],"-",r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]],r[e[n++]]].join("")}(u)}var c=Object.prototype.hasOwnProperty,s=function(e){return null==e},l=Array.isArray,f=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function d(e,t){if(l(e))return e;if(t&&(n=t,r=e,c.call(n,r)))return[e];var n,r,o=[];return e.replace(f,(function(e,t,n,r){return o.push(n?r.replace(/\\(\\)?/g,"$1"):t||e),r})),o}function g(e,t){var n,r=d(t,e);for(n=r.shift();!s(n);){if(null==(e=e[n]))return;n=r.shift()}return e}function p(e){return e._uid||e.uid}var m=new Map;function v(e){var t,n;if(!function(e){if(e){var t=e.tagName;return 0===t.indexOf("UNI-")||"BODY"===t||0===t.indexOf("V-UNI-")}return!1}(e))throw Error("no such element");var r,o,i,u={elementId:(r=e,o=r._id,o||(o=a(),r._id=o,m.set(o,{id:o,element:r})),o),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")};e.__vue__?(i=e.__vue__)&&(i.$parent&&i.$parent.$el===e&&(i=i.$parent),i&&!(null===(t=i.$options)||void 0===t?void 0:t.isReserved)&&(u.nodeId=p(i))):(i=e.__vnode)&&(i.el===e&&(i=i.ctx.parent),i&&!(null===(n=i.type)||void 0===n?void 0:n.__reserved)&&(u.nodeId=p(i)));return"video"===u.tagName&&(u.videoId=u.nodeId),u}var h={input:{input:function(e,t){var n=e.__vue__;n?(n.valueSync=t,n.$triggerInput({},{value:t})):(n=e.__vnode).ctx.exposed.$triggerInput({value:t})}},textarea:{input:function(e,t){var n=e.__vue__;n?(n.valueSync=t,n.$triggerInput({},{value:t})):(n=e.__vnode).ctx.exposed.$triggerInput({value:t})}},"scroll-view":{scrollTo:function(e,t,n){var r=e.__vue__.$refs.main;r.scrollLeft=t,r.scrollTop=n},scrollTop:function(e){return e.__vue__.$refs.main.scrollTop},scrollLeft:function(e){return e.__vue__.$refs.main.scrollLeft},scrollWidth:function(e){return e.__vue__.$refs.main.scrollWidth},scrollHeight:function(e){return e.__vue__.$refs.main.scrollHeight}},swiper:{swipeTo:function(e,t){e.__vue__.current=t}},"movable-view":{moveTo:function(e,t,n){e.__vue__._animationTo(t,n)}},switch:{tap:function(e){e.click()}},slider:{slideTo:function(e,t){var n=e.__vue__,r=n.$refs["uni-slider"],o=r.offsetWidth,i=r.getBoundingClientRect().left;n.value=t,n._onClick({x:(t-n.min)*o/(n.max-n.min)+i})}}};function _(e){var t,n=e.map((function(e){return function(e){if(document.createTouch)return document.createTouch(window,e.target,e.identifier,e.pageX,e.pageY,e.screenX,e.screenY);return new Touch(e)}(e)}));return document.createTouchList?(t=document).createTouchList.apply(t,n):n}var y={getWindow:function(e){return window},getDocument:function(e){return document},getEl:function(e){var t=m.get(e);if(!t)throw Error("element destroyed");return t.element},getOffset:function(e){var t=e.getBoundingClientRect();return Promise.resolve({left:t.left+window.pageXOffset,top:t.top+window.pageYOffset})},querySelector:function(e,t){return"page"===t&&(t="body"),Promise.resolve(v(e.querySelector(t)))},querySelectorAll:function(e,t){var n=[],r=document.querySelectorAll(t);return[].forEach.call(r,(function(e){try{n.push(v(e))}catch(e){}})),Promise.resolve({elements:n})},queryProperties:function(e,t){return Promise.resolve({properties:t.map((function(t){var n=g(e,t.replace(/-([a-z])/g,(function(e){return e[1].toUpperCase()})));return"document.documentElement.scrollTop"===t&&0===n&&(n=g(e,"document.body.scrollTop")),"innerText"===t?n.replace(/\n/g,""):n}))})},queryAttributes:function(e,t){return Promise.resolve({attributes:t.map((function(t){return String(e.getAttribute(t))}))})},queryStyles:function(e,t){var n=getComputedStyle(e);return Promise.resolve({styles:t.map((function(e){return n[e]}))})},queryHTML:function(e,t){return Promise.resolve({html:(n="outer"===t?e.outerHTML:e.innerHTML,n.replace(/\n/g,"").replace(/(<uni-text[^>]*>)(<span[^>]*>[^<]*<\/span>)(.*?<\/uni-text>)/g,"$1$3").replace(/<\/?[^>]*>/g,(function(e){return-1<e.indexOf("<body")?"<page>":"</body>"===e?"</page>":0!==e.indexOf("<uni-")&&0!==e.indexOf("</uni-")?"":e.replace(/uni-/g,"").replace(/ role=""/g,"").replace(/ aria-label=""/g,"")})))});var n},dispatchTapEvent:function(e){return e.click(),Promise.resolve()},dispatchLongpressEvent:function(e){return Promise.resolve()},dispatchTouchEvent:function(e,t,n){n||(n={}),n.touches||(n.touches=[]),n.changedTouches||(n.changedTouches=[]),n.touches.length||n.touches.push({identifier:Date.now(),target:e});var r=_(n.touches),o=_(n.changedTouches),i=_([]);return e.dispatchEvent(new TouchEvent(t,{cancelable:!0,bubbles:!0,touches:r,targetTouches:i,changedTouches:o})),Promise.resolve()},callFunction:function(t,n,r){var o=g(h,n);return o?Promise.resolve({result:o.apply(null,e([t],r,!0))}):Promise.reject(Error("".concat(n," not exists")))},triggerEvent:function(e,t,n){var r=e.__vue__;return r.$trigger&&r.$trigger(t,{},n),Promise.resolve()}};var S,T=Object.assign({},function(e){return{"Page.getElement":function(t){return e.querySelector(e.getDocument(t.pageId),t.selector)},"Page.getElements":function(t){return e.querySelectorAll(e.getDocument(t.pageId),t.selector)},"Page.getWindowProperties":function(t){return e.queryProperties(e.getWindow(t.pageId),t.names)}}}(y),function(e){var t=function(t){return e.getEl(t.elementId,t.pageId)};return{"Element.getElement":function(n){return e.querySelector(t(n),n.selector)},"Element.getElements":function(n){return e.querySelectorAll(t(n),n.selector)},"Element.getDOMProperties":function(n){return e.queryProperties(t(n),n.names)},"Element.getProperties":function(n){var r=t(n),o=r.__vue__||r.attr||{};return r.__vueParentComponent&&(o=Object.assign({},o,r.__vueParentComponent.attrs,r.__vueParentComponent.props)),e.queryProperties(o,n.names)},"Element.getOffset":function(n){return e.getOffset(t(n))},"Element.getAttributes":function(n){return e.queryAttributes(t(n),n.names)},"Element.getStyles":function(n){return e.queryStyles(t(n),n.names)},"Element.getHTML":function(n){return e.queryHTML(t(n),n.type)},"Element.tap":function(n){return e.dispatchTapEvent(t(n))},"Element.longpress":function(n){return e.dispatchLongpressEvent(t(n))},"Element.touchstart":function(n){return e.dispatchTouchEvent(t(n),"touchstart",n)},"Element.touchmove":function(n){return e.dispatchTouchEvent(t(n),"touchmove",n)},"Element.touchend":function(n){return e.dispatchTouchEvent(t(n),"touchend",n)},"Element.callFunction":function(n){return e.callFunction(t(n),n.functionName,n.args)},"Element.triggerEvent":function(n){return e.triggerEvent(t(n),n.type,n.detail)}}}(y));function E(e){return UniViewJSBridge.publishHandler("onAutoMessageReceive",e)}function w(e){return e.__wxWebviewId__?e.__wxWebviewId__:e.privateProperties?e.privateProperties.slaveId:e.$page?e.$page.id:void 0}function P(e){return e.route||e.uri}function b(e){return e.options||e.$page&&e.$page.options||{}}function I(e){return{id:w(e),path:P(e),query:b(e)}}function O(e){var t=function(e){return getCurrentPages().find((function(t){return w(t)===e}))}(e);return t&&t.$vm}function M(e,t){return e._uid===t||e.uid===t}function C(e,t,n){var r,o,i;if(void 0===n&&(n=!1),n)if(e.component&&M(e.component,t))i=e.component;else{var u=[];e.children instanceof Array?u=e.children:(null===(o=null===(r=e.component)||void 0===r?void 0:r.subTree)||void 0===o?void 0:o.children)&&(u=e.component.subTree.children),u.find((function(e){return i=C(e,t,!0)}))}else e&&(M(e,t)?i=e:e.$children.find((function(e){return i=C(e,t)})));return i}function x(e,t){var n=O(e);if(n)return N(n)?C(n.$.subTree,t,!0):C(n,t)}function $(e,t){var n,r=e.$data||e.data;return e&&(n=t?g(r,t):Object.assign({},r)),Promise.resolve({data:n})}function k(e,t){if(e){var n=N(e);Object.keys(t).forEach((function(r){n?(e.$data||e.data)[r]=t[r]:e[r]=t[r]}))}return Promise.resolve()}function A(e,t,n){return N(e)&&(e=e.$vm||e.ctx),new Promise((function(r,o){var i,u;if(!e)return o(S.VM_NOT_EXISTS);if(!e[t]&&!(null===(u=e.$.exposed)||void 0===u?void 0:u[t]))return o(S.METHOD_NOT_EXISTS);var a,c=e[t]?e[t].apply(e,n):(i=e.$.exposed)[t].apply(i,n);!(a=c)||"object"!=typeof a&&"function"!=typeof a||"function"!=typeof a.then?r({result:c}):c.then((function(e){r({result:e})}))}))}function N(e){return!e.$children}function W(){return window.__uniapp_x_}UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var t=e.id,n=e.method,r=e.params,o={id:t},i=T[n];if(!i)return o.error={message:n+" unimplemented"},E(o);try{i(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){E(o)}))}catch(e){o.error={message:e.message},E(o)}})),function(e){e.VM_NOT_EXISTS="VM_NOT_EXISTS",e.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(S||(S={}));var B=1,D={};function V(e,t){var n=0;t&&(n=B++,D[n]=t);var r={data:{id:n,type:"automator",data:e}};console.log("postMessageToUniXWebView",r),window.__uniapp_x_.postMessage(JSON.stringify(r))}var q=new Map,L=function(e){return new Promise((function(n,r){var o=q.values().next().value;if(o){var i=e.method;if("onOpen"===i)return U(o,n);if(i.startsWith("on"))return o.instance[i]((function(e){n(e)}));"sendMessage"===i&&(i="send"),o.instance[i](t(t({},e),{success:function(e){n({result:e}),"close"===i&&q.delete(q.keys().next().value)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))};function U(e,t){if(e.isOpend)t({data:e.openData});else{var n=setInterval((function(){e.isOpend&&(clearInterval(n),t(e.openData))}),200);setTimeout((function(){clearInterval(n)}),2e3)}}var R=["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"],X=new Map,H=["onCompassChange","onThemeChange","onUserCaptureScreen","onWindowResize","onMemoryWarning","onAccelerometerChange","onKeyboardHeightChange","onNetworkStatusChange","onPushMessage","onLocationChange","onGetWifiList","onWifiConnected","onWifiConnectedWithPartialInfo","onSocketOpen","onSocketError","onSocketMessage","onSocketClose"],j={},J=/^\$|Sync$|Window$|WindowStyle$|sendHostEvent|sendNativeEvent|restoreGlobal|requireGlobal|getCurrentSubNVue|getMenuButtonBoundingClientRect|^report|interceptors|Interceptor$|getSubNVueById|requireNativePlugin|upx2px|hideKeyboard|canIUse|^create|Sync$|Manager$|base64ToArrayBuffer|arrayBufferToBase64|getLocale|setLocale|invokePushCallback|getWindowInfo|getDeviceInfo|getAppBaseInfo|getSystemSetting|getAppAuthorizeSetting|initUTS|requireUTS|registerUTS/,F=/^on|^off/;function Y(e){return J.test(e)||-1!==R.indexOf(e)}var z={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(e){return I(e)}))})},getCurrentPage:function(){var e=getCurrentPages(),t=e.length;return new Promise((function(n,r){t?n(I(e[t-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(e,n){var r=e.method,o=e.args;return new Promise((function(e,i){if("connectSocket"!==r){var u,a;if(H.includes(r)){X.has(r)||X.set(r,new Map);var c=o[0],s=function(e){n({id:c,result:{method:r,data:e}})};return r.startsWith("onSocket")?L({method:r.replace("Socket","")}).then((function(e){return s(e)})).catch((function(e){return s(e)})):(X.get(r).set(c,s),uni[r](s)),e({result:null})}if(r.startsWith("off")&&H.includes(r.replace("off","on"))){var l=r.replace("off","on");if(X.has(l)){var f=o[0];if(void 0!==f){var d=X.get(l).get(f);uni[r](d),X.get(l).delete(f)}else{X.get(l).forEach((function(e){uni[r](e)})),X.delete(l)}}return e({result:null})}if(r.indexOf("Socket")>0)return L(t({method:r.replace("Socket","")},o[0])).then((function(t){return e(t)})).catch((function(e){return i(e)}));if(!uni[r])return i(Error("uni."+r+" not exists"));if(Y(r))return e({result:uni[r].apply(uni,o)});var g=[Object.assign({},o[0]||{},{success:function(t){setTimeout((function(){e({result:t})}),"pageScrollTo"===r?350:0)},fail:function(e){i(Error(e.errMsg.replace(r+":fail ","")))}})];uni[r].apply(uni,g)}else(u=o[0].id,a=o[0].url,new Promise((function(e,t){var n=uni.connectSocket({url:a,success:function(){e({result:{errMsg:"connectSocket:ok"}})},fail:function(){t({result:{errMsg:"connectSocket:fail"}})}});q.set(u,{instance:n,isOpend:!1}),n.onOpen((function(e){q.get(u).isOpend=!0,q.get(u).openData=e}))}))).then((function(t){return e(t)})).catch((function(e){return i(e)}))}))},mockUniMethod:function(e){var t=e.method;if(!uni[t])throw Error("uni.".concat(t," not exists"));if(!function(e){return!F.test(e)}(t))throw Error("You can't mock uni.".concat(t));var n,r=e.result,o=e.functionDeclaration;return s(r)&&s(o)?(j[t]&&(uni[t]=j[t],delete j[t]),Promise.resolve()):(n=s(o)?Y(t)?function(){return r}:function(e){setTimeout((function(){r.errMsg&&-1!==r.errMsg.indexOf(":fail")?e.fail&&e.fail(r):e.success&&e.success(r),e.complete&&e.complete(r)}),4)}:function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new Function("return "+o)().apply(n,t.concat(e.args))},n.origin=j[t]||uni[t],j[t]||(j[t]=uni[t]),uni[t]=n,Promise.resolve())},captureScreenshot:function(e){return new Promise((function(t,n){W()?V({action:"captureScreenshot",args:e},(function(e,r){e?n(Error("captureScreenshot fail: ".concat(e))):t(r)})):n(Error("captureScreenshot fail: supported only on the app platform."))}))},socketEmitter:function(e){return new Promise((function(n,r){(function(e){return new Promise((function(n,r){if(q.has(e.id)){var o=q.get(e.id),i=o.instance,u=e.method,a=e.id;if("onOpen"==u)return U(o,n);if(u.startsWith("on"))return i[u]((function(e){n({method:"Socket.".concat(u),id:a,data:e})}));i[u](t(t({},e),{success:function(t){n(t),"close"===u&&q.delete(e.id)},fail:function(e){r(e)}}))}else r({errMsg:"socketTask not exists."})}))})(e).then((function(e){return n(e)})).catch((function(e){return r(e)}))}))}},G=z,K={getData:function(e){return $(O(e.pageId),e.path)},setData:function(e){return k(O(e.pageId),e.data)},callMethod:function(e){var t,n=((t={})[S.VM_NOT_EXISTS]="Page[".concat(e.pageId,"] not exists"),t[S.METHOD_NOT_EXISTS]="page.".concat(e.method," not exists"),t);return new Promise((function(t,r){A(O(e.pageId),e.method,e.args).then((function(e){return t(e)})).catch((function(e){r(Error(n[e]))}))}))},callMethodWithCallback:function(e){var t,n=((t={})[S.VM_NOT_EXISTS]="callMethodWithCallback:fail, Page[".concat(e.pageId,"] not exists"),t[S.METHOD_NOT_EXISTS]="callMethodWithCallback:fail, page.".concat(e.method," not exists"),t),r=e.args[e.args.length-1];A(O(e.pageId),e.method,e.args).catch((function(e){r({errMsg:n[e]})}))}};function Q(e){return e.nodeId||e.elementId}var Z={getData:function(e){return $(x(e.pageId,Q(e)),e.path)},setData:function(e){return k(x(e.pageId,Q(e)),e.data)},callMethod:function(e){var t,n=Q(e),r=((t={})[S.VM_NOT_EXISTS]="Component[".concat(e.pageId,":").concat(n,"] not exists"),t[S.METHOD_NOT_EXISTS]="component.".concat(e.method," not exists"),t);return new Promise((function(t,o){A(x(e.pageId,n),e.method,e.args).then((function(e){return t(e)})).catch((function(e){o(Error(r[e]))}))}))}},ee={};Object.keys(G).forEach((function(e){ee["App."+e]=G[e]})),Object.keys(K).forEach((function(e){ee["Page."+e]=K[e]})),Object.keys(Z).forEach((function(e){ee["Element."+e]=Z[e]}));var te,ne,re=process.env.UNI_AUTOMATOR_WS_ENDPOINT;function oe(e){ne.send({data:JSON.stringify(e)})}function ie(e){var t=JSON.parse(e.data),n=t.id,r=t.method,o=t.params,i={id:n},u=ee[r];if(!u){if(te){var a=te(n,r,o,i);if(!0===a)return;u=a}if(!u)return i.error={message:r+" unimplemented"},oe(i)}try{u(o,oe).then((function(e){e&&(i.result=e)})).catch((function(e){i.error={message:e.message}})).finally((function(){oe(i)}))}catch(e){i.error={message:e.message},oe(i)}}function ue(e){void 0===e&&(e={}),(ne=uni.connectSocket({url:e.wsEndpoint||re,complete:function(){}})).onMessage(ie),ne.onOpen((function(t){e.success&&e.success(),console.log("已开启自动化测试...")})),ne.onError((function(e){console.log("automator.onError",e)})),ne.onClose((function(){e.fail&&e.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}te=function(e,t,n,r){var o=n.pageId,i=function(e){var t=getCurrentPages();if(!e)return t[t.length-1];return t.find((function(t){return t.$page.id===e}))}(o);return i?(i.$page.meta.isNVue,UniServiceJSBridge.publishHandler("sendAutoMessage",{id:e,method:t,params:n},o),!0):(r.error={message:"page["+o+"] not exists"},oe(r),!0)},UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(e){oe(e)})),setTimeout((function(){if(W())V({action:"ready"});else{if(re&&re.endsWith(":0000"))return;ue()}}),500),window.initRuntimeAutomator=ue,window.onPostMessageFromUniXWebView=function(e,t,n){console.log("onPostMessageFromUniXWebView",e,t,n,D);var r=D[e];r&&(delete D[e],r(n,t))};
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册