提交 51de406e 编写于 作者: fxy060608's avatar fxy060608

Merge branch 'dev' of https://github.com/dcloudio/uni-app into alpha

# Conflicts:
#	packages/uni-app-plus/dist/view.umd.min.js
#	packages/uni-automator/package.json
......@@ -13,7 +13,8 @@ import {
import ViewPlugin from 'uni-platform/view/framework/plugins/index'
global.UniViewJSBridge = {
global.UniViewJSBridge = {
subscribe: UniViewJSBridge.subscribe,
publishHandler: UniViewJSBridge.publishHandler,
subscribeHandler: UniViewJSBridge.subscribeHandler
}
......
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("debug")),o=e(require("puppeteer")),a=e(require("postcss-selector-parser"));function n(e){e.walk(e=>{if("tag"===e.type){const t=e.value;e.value="page"===t?"uni-page-body":"uni-"+t}})}const s=["Page.getElement","Page.getElements","Element.getElement","Element.getElements"];const c=t("automator:devtool");let r,l;const i={"Tool.close":{reflect:async()=>{await r.close()}},"App.exit":{reflect:async()=>{}},"App.enableLog":{reflect:()=>Promise.resolve()},"App.captureScreenshot":{reflect:async(e,t)=>{const o=await l.screenshot({encoding:"base64",fullPage:!!t.fullPage});return c("App.captureScreenshot "+o.length),{data:o}}}};!function(e){s.forEach(t=>{e[t]=function(e){return{reflect:async(t,o)=>t(e,o,!1),params:e=>(e.selector&&(e.selector=a(n).processSync(e.selector)),e)}}(t)})}(i);const p={devtools:{name:"google chrome",paths:[],validate:async function(e){return e.options=e.options||{},e.executablePath&&!e.options.executablePath&&(e.options.executablePath=e.executablePath),e.options.defaultViewport=Object.assign({width:375,height:667,deviceScaleFactor:2,hasTouch:!0,isMobile:!0},e.options.defaultViewport||{}),e.teardown="close",e},create:async function(e,t,a){r=await o.launch(t.options);const n=r.process();n?c("%s %o",n.spawnfile,t.options):c("%o",t.options),l=await r.newPage(),l.on("console",e=>{a.emit("App.logAdded",{type:e.type(),args:[e.text()]})}),l.on("pageerror",e=>{a.emit("App.exceptionThrown",e)}),await l.goto(t.url||e),await l.waitFor(1e3)}},shouldCompile:(e,t)=>!t.url,adapter:i};module.exports=p;
var n,e=Object.prototype.hasOwnProperty,t=Array.isArray,r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function o(n,o){if(t(n))return n;if(o&&(i=o,u=n,e.call(i,u)))return[n];var i,u,a=[];return n.replace(r,(function(n,e,t,r){return a.push(t?r.replace(/\\(\\)?/g,"$1"):e||n),r})),a}function i(n){return n.__wxWebviewId__?n.__wxWebviewId__:n.privateProperties?n.privateProperties.slaveId:n.$page?n.$page.id:void 0}function u(n){return n.route||n.uri}function a(n){return n.options||n.$page&&n.$page.options||{}}function c(n){return{id:i(n),path:u(n),query:a(n)}}function s(n){var e=function(n){return getCurrentPages().find((function(e){return i(e)===n}))}(n);return e&&e.$vm}function f(n,e){var t=s(n);return t&&function n(e,t){var r;return e&&(!function(n,e){return function(n){if(n._$id)return n._$id;var e=function(n){for(var e=n.$parent;e;){if(e._$id)return e;e=e.$parent}}(n);if(!n.$parent)return"-1";var t=n.$vnode,r=t.context;return r&&r!==e&&r._$id?r._$id+";"+e._$id+","+t.data.attrs._i:e._$id+","+t.data.attrs._i}(n)===e}(e,t)?e.$children.find((function(e){return r=n(e,t)})):r=e),r}(t,e)}function g(n,e){var t;return n&&(t=e?function(n,e){var t,r=o(e,n);for(t=r.shift();null!=t;){if(null==(n=n[t]))return;t=r.shift()}return n}(n.$data,e):Object.assign({},n.$data)),Promise.resolve({data:t})}function d(n,e){return n&&Object.keys(e).forEach((function(t){n[t]=e[t]})),Promise.resolve()}function p(e,t,r){return new Promise((function(o,i){if(!e)return i(n.VM_NOT_EXISTS);if(!e[t])return i(n.VM_NOT_EXISTS);var u,a=e[t].apply(e,r);!(u=a)||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then?o({result:a}):a.then((function(n){o({result:n})}))}))}!function(n){n.VM_NOT_EXISTS="VM_NOT_EXISTS",n.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(n||(n={}));var l=/Sync$/;var v={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(n){return c(n)}))})},getCurrentPage:function(){var n=getCurrentPages(),e=n.length;return new Promise((function(t,r){e?t(c(n[e-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n){var e=n.method,t=n.args;return new Promise((function(n,r){if(!uni[e])return r(Error("uni."+e+" not exists"));if(function(n){return l.test(n)}(e))return n({result:uni[e].apply(uni,t)});var o=[Object.assign({},t[0]||{},{success:function(t){setTimeout((function(){n({result:t})}),"pageScrollTo"===e?350:0)},fail:function(n){r(Error(n.errMsg.replace(e+":fail ","")))}})];uni[e].apply(uni,o)}))}},_={getData:function(n){return g(s(n.pageId),n.path)},setData:function(n){return d(s(n.pageId),n.data)},callMethod:function(e){var t,r=((t={})[n.VM_NOT_EXISTS]="Page["+e.pageId+"] not exists",t[n.METHOD_NOT_EXISTS]="page."+e.method+" not exists",t);return new Promise((function(n,t){p(s(e.pageId),e.method,e.args).then((function(e){return n(e)})).catch((function(n){t(Error(r[n]))}))}))}};function h(n){return n.nodeId||n.elementId}var m={getData:function(n){return g(f(n.pageId,h(n)),n.path)},setData:function(n){return d(f(n.pageId,h(n)),n.data)},callMethod:function(e){var t,r=h(e),o=((t={})[n.VM_NOT_EXISTS]="Component["+e.pageId+":"+r+"] not exists",t[n.METHOD_NOT_EXISTS]="component."+e.method+" not exists",t);return new Promise((function(n,t){p(f(e.pageId,r),e.method,e.args).then((function(e){return n(e)})).catch((function(n){t(Error(o[n]))}))}))}},S={};Object.keys(v).forEach((function(n){S["App."+n]=v[n]})),Object.keys(_).forEach((function(n){S["Page."+n]=_[n]})),Object.keys(m).forEach((function(n){S["Element."+n]=m[n]}));var T=process.env.UNI_AUTOMATOR_WS_ENDPOINT;setTimeout((function(){!function(n){void 0===n&&(n={}),UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(n){t(n)}));var e=uni.connectSocket({url:T,complete:function(){}}),t=function(n){return e.send({data:JSON.stringify(n)})};e.onOpen((function(e){n.success&&n.success(),console.log("已开启自动化测试...")})),e.onMessage((function(n){var e=JSON.parse(n.data),r=e.id,o=e.method,i=e.params,u={id:r},a=S[o];if(!a){var c=i.pageId;if(!c){var s=getCurrentPages();s.length&&(c=s[s.length-1].$page.id)}return UniServiceJSBridge.publishHandler("sendAutoMessage",{id:r,method:o,params:i},c)}try{a(i).then((function(n){n&&(u.result=n)})).catch((function(n){u.error={message:n.message}})).finally((function(){t(u)}))}catch(n){u.error={message:n.message},t(u)}})),e.onError((function(n){console.log("automator.onError",n)})),e.onClose((function(){n.fail&&n.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}()}),500);
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function e(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var u=arguments[t],i=0,c=u.length;i<c;i++,o++)r[o]=u[i];return r}var t="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),n=new Uint8Array(16);function r(){if(!t)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return t(n)}for(var o=[],u=0;u<256;++u)o[u]=(u+256).toString(16).substr(1);function i(e,t,n){var u=t&&n||0;"string"==typeof e&&(t="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||r)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t)for(var c=0;c<16;++c)t[u+c]=i[c];return t||function(e,t){var n=t||0,r=o;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("")}(i)}var c=Object.prototype.hasOwnProperty,a=Array.isArray,s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function l(e,t){if(a(e))return e;if(t&&(n=t,r=e,c.call(n,r)))return[e];var n,r,o=[];return e.replace(s,(function(e,t,n,r){return o.push(n?r.replace(/\\(\\)?/g,"$1"):t||e),r})),o}function f(e,t){var n,r=l(t,e);for(n=r.shift();null!=n;){if(null==(e=e[n]))return;n=r.shift()}return e}var d=new Map;function m(e){var t=d.get(e);if(!t)throw Error("element destroyed");return t.element}function p(e){if(!function(e){if(e){var t=e.tagName;return 0===t.indexOf("UNI-")||"BODY"===t}return!1}(e))throw Error("no such element");var t,n,r={elementId:(t=e,n=t._id,n||(n=i(),t._id=n,d.set(n,{id:n,element:t})),n),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")},o=e.__vue__;return o&&!o.$options.isReserved&&(r.nodeId=function(e){if(e._$id)return e._$id;var t=function(e){for(var t=e.$parent;t;){if(t._$id)return t;t=t.$parent}}(e);if(!e.$parent)return"-1";var n=e.$vnode,r=n.context;return r&&r!==t&&r._$id?r._$id+";"+t._$id+","+n.data.attrs._i:t._$id+","+n.data.attrs._i}(o)),"video"===r.tagName&&(r.videoId=r.nodeId),r}function v(e,t){return Promise.resolve(p(e.querySelector(t)))}function g(e,t){var n=[];return document.querySelectorAll(t).forEach((function(e){try{n.push(p(e))}catch(e){}})),Promise.resolve({elements:n})}function _(e,t){return Promise.resolve({properties:t.map((function(t){var n=f(e,t);return"document.documentElement.scrollTop"===t&&0===n&&(n=f(e,"document.body.scrollTop")),n}))})}function h(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.map((function(e){return new Touch(e)})),o=n.changedTouches.map((function(e){return new Touch(e)}));return e.dispatchEvent(new TouchEvent(t,{cancelable:!0,bubbles:!0,touches:r,targetTouches:[],changedTouches:o})),Promise.resolve()}var y={input:{input:function(e,t){var n=e.__vue__;n.inputValue=t,n._onInput({target:{value:t}})}},textarea:{input:function(e,t){e.__vue__.valueSync=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,u=r.getBoundingClientRect().left;n.value=t,n._onClick({x:(t-n.min)*o/(n.max-n.min)+u})}}};var w={getElement:function(e){return v(document,e.selector)},getElements:function(e){return g(document,e.selector)},getWindowProperties:function(e){return _(window,e.names)}},$={getElement:function(e){return v(m(e.elementId),e.selector)},getElements:function(e){return g(m(e.elementId),e.selector)},getDOMProperties:function(e){return _(m(e.elementId),e.names)},getProperties:function(e){return _(m(e.elementId).__vue__,e.names)},getOffset:function(e){var t=m(e.elementId).getBoundingClientRect();return Promise.resolve({left:t.left+window.pageXOffset,top:t.top+window.pageYOffset})},getAttributes:function(e){return t=m(e.elementId),n=e.names,Promise.resolve({attributes:n.map((function(e){return String(t.getAttribute(e))}))});var t,n},getStyles:function(e){return t=m(e.elementId),n=e.names,r=getComputedStyle(t),Promise.resolve({styles:n.map((function(e){return r[e]}))});var t,n,r},getHTML:function(e){return t=m(e.elementId),n=e.type,Promise.resolve({html:(r="outer"===n?t.outerHTML:t.innerHTML,r.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,n,r},tap:function(e){return m(e.elementId).click(),Promise.resolve()},touchstart:function(e){return h(m(e.elementId),"touchstart",e)},touchmove:function(e){return h(m(e.elementId),"touchmove",e)},touchend:function(e){return h(m(e.elementId),"touchend",e)},callFunction:function(t){return n=m(t.elementId),r=t.functionName,o=t.args,(u=f(y,r))?Promise.resolve({result:u.apply(null,e([n],o))}):Promise.reject(Error(r+" not exists"));var n,r,o,u},triggerEvent:function(e){return t=m(e.elementId),n=e.type,r=e.detail,(o=t.__vue__).$trigger&&o.$trigger(n,{},r),Promise.resolve();var t,n,r,o}},b={};function T(e){return UniViewJSBridge.publishHandler("onAutoMessageReceive",e)}Object.keys(w).forEach((function(e){b["Page."+e]=w[e]})),Object.keys($).forEach((function(e){b["Element."+e]=$[e]})),UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var t=e.id,n=e.method,r=e.params,o={id:t},u=b[n];if(!u)return o.error={message:n+" unimplemented"},T(o);try{u(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){T(o)}))}catch(e){o.error={message:e.message},T(o)}}));
......@@ -1654,8 +1654,8 @@ var serviceContext = (function () {
}
}
// tabBar不允许传递参数
if (routeOptions.meta.isTabBar) {
// switchTab不允许传递参数,reLaunch到一个tabBar页面是可以的
if (type === 'switchTab' && routeOptions.meta.isTabBar) {
url = pagePath;
}
......@@ -8378,7 +8378,7 @@ var serviceContext = (function () {
const urls = url.split('?');
const path = urls[0];
const routeStyles = __uniRoutes.find(route => route.path === path).window;
const globalStyle = __uniConfig.window;
const globalStyle = __uniConfig.window || {};
if (!animationType) {
animationType = routeStyles.animationType || globalStyle.animationType || ANI_SHOW;
}
......@@ -12064,16 +12064,16 @@ var serviceContext = (function () {
createSelectorQuery: createSelectorQuery
});
const callbacks$c = [];
let callback$1;
onMethod('onKeyboardHeightChange', res => {
callbacks$c.forEach(callbackId => {
invoke$1(callbackId, res);
});
});
if (callback$1) {
invoke$1(callback$1, res);
}
});
function onKeyboardHeightChange (callbackId) {
callbacks$c.push(callbackId);
callback$1 = callbackId;
}
var require_context_module_1_24 = /*#__PURE__*/Object.freeze({
......@@ -12152,16 +12152,16 @@ var serviceContext = (function () {
const hideTabBarRedDot$1 = removeTabBarBadge$1;
const callbacks$d = [];
const callbacks$c = [];
onMethod('onTabBarMidButtonTap', res => {
callbacks$d.forEach(callbackId => {
callbacks$c.forEach(callbackId => {
invoke$1(callbackId, res);
});
});
function onTabBarMidButtonTap (callbackId) {
callbacks$d.push(callbackId);
callbacks$c.push(callbackId);
}
var require_context_module_1_28 = /*#__PURE__*/Object.freeze({
......@@ -12172,22 +12172,22 @@ var serviceContext = (function () {
onTabBarMidButtonTap: onTabBarMidButtonTap
});
const callbacks$e = [];
const callbacks$d = [];
onMethod('onViewDidResize', res => {
callbacks$e.forEach(callbackId => {
callbacks$d.forEach(callbackId => {
invoke$1(callbackId, res);
});
});
function onWindowResize (callbackId) {
callbacks$e.push(callbackId);
callbacks$d.push(callbackId);
}
function offWindowResize (callbackId) {
// TODO 目前 on 和 off 即使传入同一个 function,获取到的 callbackId 也不会一致,导致不能 off 掉指定
// 后续修复
// 此处和微信平台一致查询不到去掉最后一个
callbacks$e.splice(callbacks$e.indexOf(callbackId), 1);
callbacks$d.splice(callbacks$d.indexOf(callbackId), 1);
}
var require_context_module_1_29 = /*#__PURE__*/Object.freeze({
......
因为 它太大了无法显示 source diff 。你可以改为 查看blob
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("fs")),i=t(require("debug")),s=t(require("postcss-selector-parser")),a=require("path"),r=require("util"),n=t(require("licia/dateFormat"));function c(t){t.walk(t=>{if("tag"===t.type){const e=t.value;t.value="page"===e?"body":"uni-"+e}})}const o=["Page.getElement","Page.getElements","Element.getElement","Element.getElements"];const l=require("adbkit"),h=i("automator:adb"),d=r.promisify(e.readdir),u=r.promisify(e.stat);class p{constructor(t){this.device={id:""},this.device.id=t.id,this.apk=t.executablePath,this.appid=t.appid||"HBuilder",this.package=t.package||"io.dcloud.HBuilder",this.client=l.createClient()}async init(){if(!this.device.id){const t=await this.client.listDevices();if(!t.length)throw Error("Device id is not provided");this.device.id=t[0].id}this.sdcard=(await this.shell(this.COMMAND_EXTERNAL)).trim(),h(`${n("yyyy-mm-dd HH:MM:ss:l")} init ${this.device.id} ${this.sdcard}`)}version(){return this.shell(this.COMMAND_VERSION).then(t=>{const e=t.match(/versionName=(.*)/);return e&&e.length>1?e[1]:""})}install(){return h(`${n("yyyy-mm-dd HH:MM:ss:l")} install ${this.apk}`),this.client.install(this.device.id,this.apk).then(()=>this.init())}push(t){return async function t(e){const i=await d(e);return(await Promise.all(i.map(async i=>{const s=a.resolve(e,i);return(await u(s)).isDirectory()?t(s):s}))).reduce((t,e)=>t.concat(e),[])}(t).then(e=>{const i=e.map(e=>{const i=a.join(this.DIR_WWW,a.relative(t,e));return h(`${n("yyyy-mm-dd HH:MM:ss:l")} push ${e} ${i}`),this.client.push(this.device.id,e,i)});return Promise.all(i)}).then(t=>!0)}start(){return this.exit().then(()=>this.shell(this.COMMAND_START))}exit(){return this.shell(this.COMMAND_STOP)}captureScreenshot(){return this.client.screencap(this.device.id).then(t=>new Promise(e=>{const i=[];t.on("data",(function(t){i.push(t)})),t.on("end",(function(){e(Buffer.concat(i).toString("base64"))}))}))}shouldPush(){return this.client.stat(this.device.id,this.FILE_APP_SERVICE).then(()=>!1).catch(()=>!0)}shell(t){return h(`${n("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${t}`),this.client.shell(this.device.id,t).then(l.util.readAll).then(t=>{const e=t.toString();return h(`${n("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`),e})}get DIR_WWW(){return`${this.sdcard}/Android/data/${this.package}/apps/${this.appid}/www/`}get FILE_APP_SERVICE(){return`${this.sdcard}/Android/data/${this.package}/apps/${this.appid}/www/app-service.js`}get COMMAND_EXTERNAL(){return"echo $EXTERNAL_STORAGE"}get COMMAND_VERSION(){return"dumpsys package "+this.package}get COMMAND_STOP(){return"am force-stop "+this.package}get COMMAND_START(){return`am start -n ${this.package}/io.dcloud.PandoraEntry --es ${this.appid} --ez needUpdateApp false --ez reload true`}}const m=i("automator:devtool");let y,f=!1;const g={"Tool.close":{reflect:async()=>{}},"App.exit":{reflect:async()=>y.exit()},"App.enableLog":{reflect:()=>Promise.resolve()},"App.captureScreenshot":{reflect:async(t,e)=>{const i=await y.captureScreenshot(e);return m("App.captureScreenshot "+i.length),{data:i}}}};!function(t){o.forEach(e=>{t[e]=function(t){return{reflect:async(e,i)=>e(t,i,!1),params:t=>(t.selector&&(t.selector=s(c).processSync(t.selector)),t)}}(e)})}(g);const v={devtools:{name:"App",paths:[],required:["manifest.json","app-service.js"],validate:async function(t,i){if(t.platform=(t.platform||process.env.UNI_OS_NAME).toLocaleLowerCase(),Object.assign(t,t[t.platform]),y=function(t,e){return new p(e)}(t.platform,t),await y.init(),!await y.version()){if(!t.executablePath)throw Error(`app-plus->${t.platform}->executablePath is not provided`);if(!e.existsSync(t.executablePath))throw Error(t.executablePath+" not exists");f=!0}return t},create:async function(t,e,i){f&&await y.install(),(i.compiled||await y.shouldPush())&&await y.push(t),await y.start()}},adapter:g};module.exports=v;
......@@ -12,4 +12,4 @@ MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function e(){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 u=arguments[n],i=0,a=u.length;i<a;i++,o++)r[o]=u[i];return r}var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),t=new Uint8Array(16);function r(){if(!n)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(t)}for(var o=[],u=0;u<256;++u)o[u]=(u+256).toString(16).substr(1);function i(e,n,t){var u=n&&t||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||r)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n)for(var a=0;a<16;++a)n[u+a]=i[a];return n||function(e,n){var t=n||0,r=o;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("")}(i)}var a=Object.prototype.hasOwnProperty,c=Array.isArray,s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function f(e,n){if(c(e))return e;if(n&&(t=n,r=e,a.call(t,r)))return[e];var t,r,o=[];return e.replace(s,(function(e,n,t,r){return o.push(t?r.replace(/\\(\\)?/g,"$1"):n||e),r})),o}function l(e,n){var t,r=f(n,e);for(t=r.shift();null!=t;){if(null==(e=e[t]))return;t=r.shift()}return e}var d=new Map;function g(e){var n=d.get(e);if(!n)throw Error("element destroyed");return n.element}function m(e){if(!function(e){if(e){var n=e.tagName;return 0===n.indexOf("UNI-")||"BODY"===n}return!1}(e))throw Error("no such element");var n,t,r={elementId:(n=e,t=n._id,t||(t=i(),n._id=t,d.set(t,{id:t,element:n})),t),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")},o=e.__vue__;return o&&!o.$options.isReserved&&(r.nodeId=o._uid),"video"===r.tagName&&(r.videoId=r.nodeId),r}function p(e,n){return Promise.resolve(m(e.querySelector(n)))}function v(e,n){var t=[];return document.querySelectorAll(n).forEach((function(e){try{t.push(m(e))}catch(e){}})),Promise.resolve({elements:t})}function _(e,n){return Promise.resolve({properties:n.map((function(n){return l(e,n)}))})}function h(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.map((function(e){return new Touch(e)})),o=t.changedTouches.map((function(e){return new Touch(e)}));return e.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,touches:r,targetTouches:[],changedTouches:o})),Promise.resolve()}var y={input:{input:function(e,n){var t=e.__vue__;t.inputValue=n,t._onInput({target:{value:n}})}},textarea:{input:function(e,n){e.__vue__.valueSync=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,u=r.getBoundingClientRect().left;t.value=n,t._onClick({x:(n-t.min)*o/(t.max-t.min)+u})}}};var T,I={getElement:function(e){return p(document,e.selector)},getElements:function(e){return v(document,e.selector)},getWindowProperties:function(e){return _(window,e.names)}},E={getElement:function(e){return p(g(e.elementId),e.selector)},getElements:function(e){return v(g(e.elementId),e.selector)},getDOMProperties:function(e){return _(g(e.elementId),e.names)},getProperties:function(e){return _(g(e.elementId).__vue__,e.names)},getOffset:function(e){var n=g(e.elementId).getBoundingClientRect();return Promise.resolve({left:n.left+window.pageXOffset,top:n.top+window.pageYOffset})},getAttributes:function(e){return n=g(e.elementId),t=e.names,Promise.resolve({attributes:t.map((function(e){return String(n.getAttribute(e))}))});var n,t},getStyles:function(e){return n=g(e.elementId),t=e.names,r=getComputedStyle(n),Promise.resolve({styles:t.map((function(e){return r[e]}))});var n,t,r},getHTML:function(e){return n=g(e.elementId),t=e.type,Promise.resolve({html:(r="outer"===t?n.outerHTML:n.innerHTML,r.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,t,r},tap:function(e){return g(e.elementId).click(),Promise.resolve()},touchstart:function(e){return h(g(e.elementId),"touchstart",e)},touchmove:function(e){return h(g(e.elementId),"touchmove",e)},touchend:function(e){return h(g(e.elementId),"touchend",e)},callFunction:function(n){return t=g(n.elementId),r=n.functionName,o=n.args,(u=l(y,r))?Promise.resolve({result:u.apply(null,e([t],o))}):Promise.reject(Error(r+" not exists"));var t,r,o,u},triggerEvent:function(e){return n=g(e.elementId),t=e.type,r=e.detail,(o=n.__vue__).$trigger&&o.$trigger(t,{},r),Promise.resolve();var n,t,r,o}},S={};function O(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 M(e){return{id:w(e),path:P(e),query:b(e)}}function $(e){var n=function(e){return getCurrentPages().find((function(n){return w(n)===e}))}(e);return n&&n.$vm}function N(e,n){var t=$(e);return t&&function e(n,t){var r,o;return n&&(n._uid&&n._uid===t||n.$scope&&((o=n.$scope).__wxExparserNodeId__||o.nodeId||o.id)===t?r=n:n.$children.find((function(n){return r=e(n,t)}))),r}(t,n)}function x(e,n){var t;return e&&(t=n?l(e.$data,n):Object.assign({},e.$data)),Promise.resolve({data:t})}function C(e,n){return e&&Object.keys(n).forEach((function(t){e[t]=n[t]})),Promise.resolve()}function A(e,n,t){return new Promise((function(r,o){if(!e)return o(T.VM_NOT_EXISTS);if(!e[n])return o(T.VM_NOT_EXISTS);var u,i=e[n].apply(e,t);!(u=i)||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then?r({result:i}):i.then((function(e){r({result:e})}))}))}Object.keys(I).forEach((function(e){S["Page."+e]=I[e]})),Object.keys(E).forEach((function(e){S["Element."+e]=E[e]})),UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var n=e.id,t=e.method,r=e.params,o={id:n},u=S[t];if(!u)return o.error={message:t+" unimplemented"},O(o);try{u(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){O(o)}))}catch(e){o.error={message:e.message},O(o)}})),function(e){e.VM_NOT_EXISTS="VM_NOT_EXISTS",e.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(T||(T={}));var V=/Sync$/;var j={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(e){return M(e)}))})},getCurrentPage:function(){var e=getCurrentPages(),n=e.length;return new Promise((function(t,r){n?t(M(e[n-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(e){var n=e.method,t=e.args;return new Promise((function(e,r){if(!uni[n])return r(Error("uni."+n+" not exists"));if(function(e){return V.test(e)}(n))return e({result:uni[n].apply(uni,t)});var o=[Object.assign({},t[0]||{},{success:function(t){setTimeout((function(){e({result:t})}),"pageScrollTo"===n?350:0)},fail:function(e){r(Error(e.errMsg.replace(n+":fail ","")))}})];uni[n].apply(uni,o)}))}},k={getData:function(e){return x($(e.pageId),e.path)},setData:function(e){return C($(e.pageId),e.data)},callMethod:function(e){var n,t=((n={})[T.VM_NOT_EXISTS]="Page["+e.pageId+"] not exists",n[T.METHOD_NOT_EXISTS]="page."+e.method+" not exists",n);return new Promise((function(n,r){A($(e.pageId),e.method,e.args).then((function(e){return n(e)})).catch((function(e){r(Error(t[e]))}))}))}};function D(e){return e.nodeId||e.elementId}var R={getData:function(e){return x(N(e.pageId,D(e)),e.path)},setData:function(e){return C(N(e.pageId,D(e)),e.data)},callMethod:function(e){var n,t=D(e),r=((n={})[T.VM_NOT_EXISTS]="Component["+e.pageId+":"+t+"] not exists",n[T.METHOD_NOT_EXISTS]="component."+e.method+" not exists",n);return new Promise((function(n,o){A(N(e.pageId,t),e.method,e.args).then((function(e){return n(e)})).catch((function(e){o(Error(r[e]))}))}))}},H={};Object.keys(j).forEach((function(e){H["App."+e]=j[e]})),Object.keys(k).forEach((function(e){H["Page."+e]=k[e]})),Object.keys(R).forEach((function(e){H["Element."+e]=R[e]}));var X=process.env.UNI_AUTOMATOR_WS_ENDPOINT;setTimeout((function(){!function(e){void 0===e&&(e={}),UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(e){t(e)}));var n=uni.connectSocket({url:X,complete:function(){}}),t=function(e){return n.send({data:JSON.stringify(e)})};n.onOpen((function(n){e.success&&e.success(),console.log("已开启自动化测试...")})),n.onMessage((function(e){var n=JSON.parse(e.data),r=n.id,o=n.method,u=n.params,i={id:r},a=H[o];if(!a)return UniServiceJSBridge.publishHandler("sendAutoMessage",{id:r,method:o,params:u});try{a(u).then((function(e){e&&(i.result=e)})).catch((function(e){i.error={message:e.message}})).finally((function(){t(i)}))}catch(e){i.error={message:e.message},t(i)}})),n.onError((function(e){console.log("automator.onError",e)})),n.onClose((function(){e.fail&&e.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}()}),500);
function e(){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 u=arguments[n],i=0,a=u.length;i<a;i++,o++)r[o]=u[i];return r}var n="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto),t=new Uint8Array(16);function r(){if(!n)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return n(t)}for(var o=[],u=0;u<256;++u)o[u]=(u+256).toString(16).substr(1);function i(e,n,t){var u=n&&t||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null);var i=(e=e||{}).random||(e.rng||r)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,n)for(var a=0;a<16;++a)n[u+a]=i[a];return n||function(e,n){var t=n||0,r=o;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("")}(i)}var a=Object.prototype.hasOwnProperty,c=Array.isArray,s=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function f(e,n){if(c(e))return e;if(n&&(t=n,r=e,a.call(t,r)))return[e];var t,r,o=[];return e.replace(s,(function(e,n,t,r){return o.push(t?r.replace(/\\(\\)?/g,"$1"):n||e),r})),o}function l(e,n){var t,r=f(n,e);for(t=r.shift();null!=t;){if(null==(e=e[t]))return;t=r.shift()}return e}var d=new Map;function g(e){var n=d.get(e);if(!n)throw Error("element destroyed");return n.element}function m(e){if(!function(e){if(e){var n=e.tagName;return 0===n.indexOf("UNI-")||"BODY"===n}return!1}(e))throw Error("no such element");var n,t,r={elementId:(n=e,t=n._id,t||(t=i(),n._id=t,d.set(t,{id:t,element:n})),t),tagName:e.tagName.toLocaleLowerCase().replace("uni-","")},o=e.__vue__;return o&&!o.$options.isReserved&&(r.nodeId=function(e){return e._uid}(o)),"video"===r.tagName&&(r.videoId=r.nodeId),r}function p(e,n){return Promise.resolve(m(e.querySelector(n)))}function v(e,n){var t=[];return document.querySelectorAll(n).forEach((function(e){try{t.push(m(e))}catch(e){}})),Promise.resolve({elements:t})}function _(e,n){return Promise.resolve({properties:n.map((function(n){var t=l(e,n);return"document.documentElement.scrollTop"===n&&0===t&&(t=l(e,"document.body.scrollTop")),t}))})}function h(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.map((function(e){return new Touch(e)})),o=t.changedTouches.map((function(e){return new Touch(e)}));return e.dispatchEvent(new TouchEvent(n,{cancelable:!0,bubbles:!0,touches:r,targetTouches:[],changedTouches:o})),Promise.resolve()}var y={input:{input:function(e,n){var t=e.__vue__;t.inputValue=n,t._onInput({target:{value:n}})}},textarea:{input:function(e,n){e.__vue__.valueSync=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,u=r.getBoundingClientRect().left;t.value=n,t._onClick({x:(n-t.min)*o/(t.max-t.min)+u})}}};var T,I={getElement:function(e){return p(document,e.selector)},getElements:function(e){return v(document,e.selector)},getWindowProperties:function(e){return _(window,e.names)}},E={getElement:function(e){return p(g(e.elementId),e.selector)},getElements:function(e){return v(g(e.elementId),e.selector)},getDOMProperties:function(e){return _(g(e.elementId),e.names)},getProperties:function(e){return _(g(e.elementId).__vue__,e.names)},getOffset:function(e){var n=g(e.elementId).getBoundingClientRect();return Promise.resolve({left:n.left+window.pageXOffset,top:n.top+window.pageYOffset})},getAttributes:function(e){return n=g(e.elementId),t=e.names,Promise.resolve({attributes:t.map((function(e){return String(n.getAttribute(e))}))});var n,t},getStyles:function(e){return n=g(e.elementId),t=e.names,r=getComputedStyle(n),Promise.resolve({styles:t.map((function(e){return r[e]}))});var n,t,r},getHTML:function(e){return n=g(e.elementId),t=e.type,Promise.resolve({html:(r="outer"===t?n.outerHTML:n.innerHTML,r.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,t,r},tap:function(e){return g(e.elementId).click(),Promise.resolve()},touchstart:function(e){return h(g(e.elementId),"touchstart",e)},touchmove:function(e){return h(g(e.elementId),"touchmove",e)},touchend:function(e){return h(g(e.elementId),"touchend",e)},callFunction:function(n){return t=g(n.elementId),r=n.functionName,o=n.args,(u=l(y,r))?Promise.resolve({result:u.apply(null,e([t],o))}):Promise.reject(Error(r+" not exists"));var t,r,o,u},triggerEvent:function(e){return n=g(e.elementId),t=e.type,r=e.detail,(o=n.__vue__).$trigger&&o.$trigger(t,{},r),Promise.resolve();var n,t,r,o}},S={};function O(e){return UniViewJSBridge.publishHandler("onAutoMessageReceive",e)}function P(e){return e.__wxWebviewId__?e.__wxWebviewId__:e.privateProperties?e.privateProperties.slaveId:e.$page?e.$page.id:void 0}function w(e){return e.route||e.uri}function b(e){return e.options||e.$page&&e.$page.options||{}}function M(e){return{id:P(e),path:w(e),query:b(e)}}function $(e){var n=function(e){return getCurrentPages().find((function(n){return P(n)===e}))}(e);return n&&n.$vm}function N(e,n){var t=$(e);return t&&function e(n,t){var r;return n&&(!function(e,n){return e._uid===n}(n,t)?n.$children.find((function(n){return r=e(n,t)})):r=n),r}(t,n)}function C(e,n){var t;return e&&(t=n?l(e.$data,n):Object.assign({},e.$data)),Promise.resolve({data:t})}function x(e,n){return e&&Object.keys(n).forEach((function(t){e[t]=n[t]})),Promise.resolve()}function A(e,n,t){return new Promise((function(r,o){if(!e)return o(T.VM_NOT_EXISTS);if(!e[n])return o(T.VM_NOT_EXISTS);var u,i=e[n].apply(e,t);!(u=i)||"object"!=typeof u&&"function"!=typeof u||"function"!=typeof u.then?r({result:i}):i.then((function(e){r({result:e})}))}))}Object.keys(I).forEach((function(e){S["Page."+e]=I[e]})),Object.keys(E).forEach((function(e){S["Element."+e]=E[e]})),UniViewJSBridge.subscribe("sendAutoMessage",(function(e){var n=e.id,t=e.method,r=e.params,o={id:n},u=S[t];if(!u)return o.error={message:t+" unimplemented"},O(o);try{u(r).then((function(e){e&&(o.result=e)})).catch((function(e){o.error={message:e.message}})).finally((function(){O(o)}))}catch(e){o.error={message:e.message},O(o)}})),function(e){e.VM_NOT_EXISTS="VM_NOT_EXISTS",e.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(T||(T={}));var V=/Sync$/;var j={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(e){return M(e)}))})},getCurrentPage:function(){var e=getCurrentPages(),n=e.length;return new Promise((function(t,r){n?t(M(e[n-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(e){var n=e.method,t=e.args;return new Promise((function(e,r){if(!uni[n])return r(Error("uni."+n+" not exists"));if(function(e){return V.test(e)}(n))return e({result:uni[n].apply(uni,t)});var o=[Object.assign({},t[0]||{},{success:function(t){setTimeout((function(){e({result:t})}),"pageScrollTo"===n?350:0)},fail:function(e){r(Error(e.errMsg.replace(n+":fail ","")))}})];uni[n].apply(uni,o)}))}},k={getData:function(e){return C($(e.pageId),e.path)},setData:function(e){return x($(e.pageId),e.data)},callMethod:function(e){var n,t=((n={})[T.VM_NOT_EXISTS]="Page["+e.pageId+"] not exists",n[T.METHOD_NOT_EXISTS]="page."+e.method+" not exists",n);return new Promise((function(n,r){A($(e.pageId),e.method,e.args).then((function(e){return n(e)})).catch((function(e){r(Error(t[e]))}))}))}};function D(e){return e.nodeId||e.elementId}var R={getData:function(e){return C(N(e.pageId,D(e)),e.path)},setData:function(e){return x(N(e.pageId,D(e)),e.data)},callMethod:function(e){var n,t=D(e),r=((n={})[T.VM_NOT_EXISTS]="Component["+e.pageId+":"+t+"] not exists",n[T.METHOD_NOT_EXISTS]="component."+e.method+" not exists",n);return new Promise((function(n,o){A(N(e.pageId,t),e.method,e.args).then((function(e){return n(e)})).catch((function(e){o(Error(r[e]))}))}))}},H={};Object.keys(j).forEach((function(e){H["App."+e]=j[e]})),Object.keys(k).forEach((function(e){H["Page."+e]=k[e]})),Object.keys(R).forEach((function(e){H["Element."+e]=R[e]}));var X=process.env.UNI_AUTOMATOR_WS_ENDPOINT;setTimeout((function(){!function(e){void 0===e&&(e={}),UniServiceJSBridge.subscribe("onAutoMessageReceive",(function(e){t(e)}));var n=uni.connectSocket({url:X,complete:function(){}}),t=function(e){return n.send({data:JSON.stringify(e)})};n.onOpen((function(n){e.success&&e.success(),console.log("已开启自动化测试...")})),n.onMessage((function(e){var n=JSON.parse(e.data),r=n.id,o=n.method,u=n.params,i={id:r},a=H[o];if(!a){var c=u.pageId;if(!c){var s=getCurrentPages();s.length&&(c=s[s.length-1].$page.id)}return UniServiceJSBridge.publishHandler("sendAutoMessage",{id:r,method:o,params:u},c)}try{a(u).then((function(e){e&&(i.result=e)})).catch((function(e){i.error={message:e.message}})).finally((function(){t(i)}))}catch(e){i.error={message:e.message},t(i)}})),n.onError((function(e){console.log("automator.onError",e)})),n.onClose((function(){e.fail&&e.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))}()}),500);
var n,t=Object.prototype.hasOwnProperty,e=Array.isArray,r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function o(n,o){if(e(n))return n;if(o&&(u=o,i=n,t.call(u,i)))return[n];var u,i,a=[];return n.replace(r,(function(n,t,e,r){return a.push(e?r.replace(/\\(\\)?/g,"$1"):t||n),r})),a}function u(n){return n.__wxWebviewId__?n.__wxWebviewId__:n.privateProperties?n.privateProperties.slaveId:n.$page?n.$page.id:void 0}function i(n){return n.route||n.uri}function a(n){return n.options||n.$page&&n.$page.options||{}}function c(n){return{id:u(n),path:i(n),query:a(n)}}function s(n){var t=function(n){return getCurrentPages().find((function(t){return u(t)===n}))}(n);return t&&t.$vm}function f(n,t){var e=s(n);return e&&function n(t,e){var r,o;return t&&(t._uid&&t._uid===e||t.$scope&&((o=t.$scope).__wxExparserNodeId__||o.nodeId||o.id)===e?r=t:t.$children.find((function(t){return r=n(t,e)}))),r}(e,t)}function p(n,t){var e;return n&&(e=t?function(n,t){var e,r=o(t,n);for(e=r.shift();null!=e;){if(null==(n=n[e]))return;e=r.shift()}return n}(n.$data,t):Object.assign({},n.$data)),Promise.resolve({data:e})}function g(n,t){return n&&Object.keys(t).forEach((function(e){n[e]=t[e]})),Promise.resolve()}function l(t,e,r){return new Promise((function(o,u){if(!t)return u(n.VM_NOT_EXISTS);if(!t[e])return u(n.VM_NOT_EXISTS);var i,a=t[e].apply(t,r);!(i=a)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then?o({result:a}):a.then((function(n){o({result:n})}))}))}!function(n){n.VM_NOT_EXISTS="VM_NOT_EXISTS",n.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(n||(n={}));var d=/Sync$/;var m={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(n){return c(n)}))})},getCurrentPage:function(){var n=getCurrentPages(),t=n.length;return new Promise((function(e,r){t?e(c(n[t-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n){var t=n.method,e=n.args;return new Promise((function(n,r){if(!uni[t])return r(Error("uni."+t+" not exists"));if(function(n){return d.test(n)}(t))return n({result:uni[t].apply(uni,e)});var o=[Object.assign({},e[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===t?350:0)},fail:function(n){r(Error(n.errMsg.replace(t+":fail ","")))}})];uni[t].apply(uni,o)}))}},_={getData:function(n){return p(s(n.pageId),n.path)},setData:function(n){return g(s(n.pageId),n.data)},callMethod:function(t){var e,r=((e={})[n.VM_NOT_EXISTS]="Page["+t.pageId+"] not exists",e[n.METHOD_NOT_EXISTS]="page."+t.method+" not exists",e);return new Promise((function(n,e){l(s(t.pageId),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(r[n]))}))}))}};function h(n){return n.nodeId||n.elementId}var v={getData:function(n){return p(f(n.pageId,h(n)),n.path)},setData:function(n){return g(f(n.pageId,h(n)),n.data)},callMethod:function(t){var e,r=h(t),o=((e={})[n.VM_NOT_EXISTS]="Component["+t.pageId+":"+r+"] not exists",e[n.METHOD_NOT_EXISTS]="component."+t.method+" not exists",e);return new Promise((function(n,e){l(f(t.pageId,r),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(o[n]))}))}))}},T={};Object.keys(m).forEach((function(n){T["App."+n]=m[n]})),Object.keys(_).forEach((function(n){T["Page."+n]=_[n]})),Object.keys(v).forEach((function(n){T["Element."+n]=v[n]}));var E=process.env.UNI_AUTOMATOR_WS_ENDPOINT;swan.$$initRuntimeAutomator=function(n){void 0===n&&(n={});var t=uni.connectSocket({url:E,complete:function(){}}),e=function(n){return t.send({data:JSON.stringify(n)})};t.onOpen((function(t){n.success&&n.success(),console.log("已开启自动化测试...")})),t.onMessage((function(n){var t=JSON.parse(n.data),r=t.id,o=t.method,u=t.params,i={id:r},a=T[o];if(!a)return i.error={message:o+" unimplemented"},e(i);try{a(u).then((function(n){n&&(i.result=n)})).catch((function(n){i.error={message:n.message}})).finally((function(){e(i)}))}catch(n){i.error={message:n.message},e(i)}})),t.onError((function(n){console.log("automator.onError",n)})),t.onClose((function(){n.fail&&n.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){swan.$$initRuntimeAutomator()}),500);
var n,t=Object.prototype.hasOwnProperty,e=Array.isArray,r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function o(n,o){if(e(n))return n;if(o&&(u=o,i=n,t.call(u,i)))return[n];var u,i,a=[];return n.replace(r,(function(n,t,e,r){return a.push(e?r.replace(/\\(\\)?/g,"$1"):t||n),r})),a}function u(n){return n.__wxWebviewId__?n.__wxWebviewId__:n.privateProperties?n.privateProperties.slaveId:n.$page?n.$page.id:void 0}function i(n){return n.route||n.uri}function a(n){return n.options||n.$page&&n.$page.options||{}}function c(n){return{id:u(n),path:i(n),query:a(n)}}function s(n){var t=function(n){return getCurrentPages().find((function(t){return u(t)===n}))}(n);return t&&t.$vm}function f(n,t){var e=s(n);return e&&function n(t,e){var r;return t&&(!function(n,t){return n.$scope&&((e=n.$scope).__wxExparserNodeId__||e.nodeId||e.id)===t;var e}(t,e)?t.$children.find((function(t){return r=n(t,e)})):r=t),r}(e,t)}function p(n,t){var e;return n&&(e=t?function(n,t){var e,r=o(t,n);for(e=r.shift();null!=e;){if(null==(n=n[e]))return;e=r.shift()}return n}(n.$data,t):Object.assign({},n.$data)),Promise.resolve({data:e})}function g(n,t){return n&&Object.keys(t).forEach((function(e){n[e]=t[e]})),Promise.resolve()}function l(t,e,r){return new Promise((function(o,u){if(!t)return u(n.VM_NOT_EXISTS);if(!t[e])return u(n.VM_NOT_EXISTS);var i,a=t[e].apply(t,r);!(i=a)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then?o({result:a}):a.then((function(n){o({result:n})}))}))}!function(n){n.VM_NOT_EXISTS="VM_NOT_EXISTS",n.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(n||(n={}));var d=/Sync$/;var m={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(n){return c(n)}))})},getCurrentPage:function(){var n=getCurrentPages(),t=n.length;return new Promise((function(e,r){t?e(c(n[t-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n){var t=n.method,e=n.args;return new Promise((function(n,r){if(!uni[t])return r(Error("uni."+t+" not exists"));if(function(n){return d.test(n)}(t))return n({result:uni[t].apply(uni,e)});var o=[Object.assign({},e[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===t?350:0)},fail:function(n){r(Error(n.errMsg.replace(t+":fail ","")))}})];uni[t].apply(uni,o)}))}},_={getData:function(n){return p(s(n.pageId),n.path)},setData:function(n){return g(s(n.pageId),n.data)},callMethod:function(t){var e,r=((e={})[n.VM_NOT_EXISTS]="Page["+t.pageId+"] not exists",e[n.METHOD_NOT_EXISTS]="page."+t.method+" not exists",e);return new Promise((function(n,e){l(s(t.pageId),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(r[n]))}))}))}};function h(n){return n.nodeId||n.elementId}var v={getData:function(n){return p(f(n.pageId,h(n)),n.path)},setData:function(n){return g(f(n.pageId,h(n)),n.data)},callMethod:function(t){var e,r=h(t),o=((e={})[n.VM_NOT_EXISTS]="Component["+t.pageId+":"+r+"] not exists",e[n.METHOD_NOT_EXISTS]="component."+t.method+" not exists",e);return new Promise((function(n,e){l(f(t.pageId,r),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(o[n]))}))}))}},T={};Object.keys(m).forEach((function(n){T["App."+n]=m[n]})),Object.keys(_).forEach((function(n){T["Page."+n]=_[n]})),Object.keys(v).forEach((function(n){T["Element."+n]=v[n]}));var E=process.env.UNI_AUTOMATOR_WS_ENDPOINT;swan.$$initRuntimeAutomator=function(n){void 0===n&&(n={});var t=uni.connectSocket({url:E,complete:function(){}}),e=function(n){return t.send({data:JSON.stringify(n)})};t.onOpen((function(t){n.success&&n.success(),console.log("已开启自动化测试...")})),t.onMessage((function(n){var t=JSON.parse(n.data),r=t.id,o=t.method,u=t.params,i={id:r},a=T[o];if(!a)return i.error={message:o+" unimplemented"},e(i);try{a(u).then((function(n){n&&(i.result=n)})).catch((function(n){i.error={message:n.message}})).finally((function(){e(i)}))}catch(n){i.error={message:n.message},e(i)}})),t.onError((function(n){console.log("automator.onError",n)})),t.onClose((function(){n.fail&&n.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){swan.$$initRuntimeAutomator()}),500);
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("os")),r=e(require("path")),s=e(require("debug")),a=e(require("licia/isWindows")),n=e(require("fs")),o=e(require("child_process")),i=e(require("licia/sleep")),c=e(require("licia/toStr")),l=e(require("licia/waitUntil")),p=e(require("licia/concat")),u=e(require("licia/getPort")),m=e(require("licia/dateFormat"));require("jimp"),require("licia/isStr");var d=e(require("ws")),h=require("events"),f=e(require("licia/uuid")),g=e(require("licia/stringify"));const w=/(^[a-z][a-z0-9-]*)/i,y=/^navigator/i,E=/^swan-nav$/i;var b;!function(e){e.SELECTOR="selector",e.TAGNAME="tagName"}(b||(b={}));const v={[b.SELECTOR]:[{test:y,processor:e=>e.replace(y,"nav")},{test:w,processor:e=>"swan-"+e}],[b.TAGNAME]:[{test:E,processor:e=>e.replace(E,"swan-navigator")},{test:w,processor:e=>e.toLocaleLowerCase().replace("swan-","")}]},j=e=>t=>{const r=(v[e]||[]).filter(e=>e.test.test(t));for(const e of r)t=e.processor(t);return t},P=j(b.SELECTOR),q=j(b.TAGNAME),O=e=>Object.assign({},e,{type:"id",info:{id:e.elementId}});require("qrcode-terminal"),require("qrcode-reader");class M extends h.EventEmitter{constructor(e){super(),this.ws=e,this.ws.addEventListener("message",e=>{this.emit("message",e.data)}),this.ws.addEventListener("close",()=>{this.emit("close")})}send(e){this.ws.send(e)}close(){this.ws.close()}}class C extends h.EventEmitter{constructor(e,t,r){super(),this.puppet=t,this.namespace=r,this.callbacks=new Map,this.transport=e,this.debug=s("automator:protocol:"+this.namespace),this.onMessage=e=>{this.debug(`${m("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`);const{id:t,method:r,error:s,result:a,params:n}=JSON.parse(e);if(!t)return this.puppet.emit(r,n);const{callbacks:o}=this;if(t&&o.has(t)){const e=o.get(t);o.delete(t),s?e.reject(Error(s.message)):e.resolve(a)}},this.onClose=()=>{this.callbacks.forEach(e=>{e.reject(Error("Connection closed"))})},this.transport.on("message",this.onMessage),this.transport.on("close",this.onClose)}send(e,t={},r=!0){if(r&&this.puppet.adapter.has(e))return this.puppet.adapter.send(this,e,t);const s=f(),a=g({id:s,method:e,params:t});return this.debug(`${m("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${a}`),new Promise((e,t)=>{try{this.transport.send(a)}catch(e){t(Error("Connection closed"))}this.callbacks.set(s,{resolve:e,reject:t})})}dispose(){this.transport.close()}static createDevtoolConnection(e,t){return new Promise((r,s)=>{const a=new d(e);a.addEventListener("open",()=>{r(new C(new M(a),t,"devtool"))}),a.addEventListener("error",s)})}static createRuntimeConnection(e,t,r){return new Promise((a,n)=>{s("automator:runtime")(`${m("yyyy-mm-dd HH:MM:ss:l")} port=${e}`);const o=new d.Server({port:e});l(async()=>{if(t.runtimeConnection)return!0},r,1e3).catch(e=>{throw Error("Failed to connect to runtime, please make sure the project is running")}),o.on("connection",(function(e){s("automator:runtime")(m("yyyy-mm-dd HH:MM:ss:l")+" connected");const r=new C(new M(e),t,"runtime");t.setRuntimeConnection(r),a(r)})),t.setRuntimeServer(o)})}}const $=s("automator:devtool");async function S(e,t,r){const{port:s,cliPath:a,timeout:n,cwd:u="",account:d="",args:h=[],launch:f=!0}=t;let g=!1,w=!1;if(!1!==f){const t={detached:!0,stdio:"ignore"};u&&(t.cwd=u);let r=p(h,["--auto",e,"--auto-port",c(s)]);d&&(r=p(r,["--auto-account",d]));try{$("%s %o %o",a,r,t);const e=o.spawn(a,r,t);e.on("error",e=>{g=!0}),e.on("exit",()=>{setTimeout(()=>{w=!0},15e3)}),e.unref()}catch(e){g=!1}}else setTimeout(()=>{w=!0},15e3);const y=await l(async()=>{try{if(g||w)return!0;return await async function(e,t){let r;try{r=await C.createDevtoolConnection(e.wsEndpoint,t)}catch(t){throw Error(`Failed connecting to ${e.wsEndpoint}, check if target project window is opened with automation enabled`)}return r}({wsEndpoint:"ws://127.0.0.1:"+s},r)}catch(e){}},n,1e3);if(g)throw Error(`Failed to launch ${r.devtools.name}, please make sure cliPath is correctly specified`);if(w)throw Error(`Failed to launch ${r.devtools.name} , please make sure http port is open`);return await i(5e3),$(m("yyyy-mm-dd HH:MM:ss:l")+" connected"),y}const A=[];["","-rc"].forEach(e=>{a?(A.push(r.join(t.homedir(),`AppData/Local/Programs/swan-ide-gui${e}/cli.bat`)),A.push(`C:/Program Files/swan-ide-gui${e}/cli.bat`)):A.push(`/Applications/百度开发者工具${e}.app/Contents/MacOS/cli`)});const T={devtools:{name:"Baidu DevTools",remote:!0,automator:!0,paths:A,required:["project.swan.json","app.json","app.js"],defaultPort:9430,validate:async function(e,t){const r=function(e,t){const r=t.devtools.paths.slice(0);e&&r.unshift(e);for(const e of r)if(n.existsSync(e))return e;throw Error(t.devtools.name+" not found, please specify executablePath option")}(e.executablePath,t);let s=e.port||t.devtools.defaultPort;if(!1!==e.launch)try{s=await async function(e,t){const r=await u(e||t);if(e&&r!==e)throw Error(`Port ${e} is in use, please specify another port`);return r}(s)}catch(t){e.launch=!1}else{s===await u(s)&&(e.launch=!0)}return Object.assign(Object.assign({},e),{port:s,cliPath:r})},async create(e,t,r){const a=await S(e,t,r);return s("automator:devtool")("initRuntimeAutomator"),a.send("smartapp.swan",{api:"$$initRuntimeAutomator",params:[]}),a}},adapter:{"Tool.enableRemoteDebug":{reflect:async e=>({qrCode:(await e("Tool.enablePreview")).url})},"App.exit":{reflect:async()=>Promise.resolve()},"Page.getElement":{reflect:async(e,t)=>(await e("Page.getElements",t)).elements[0]},"Page.getElements":{reflect:async(e,t)=>{return{elements:(await e("smartapp.element.getBySelector",Object.assign(Object.assign({},t),{properties:["id","tagName"],selector:(r=t.selector,r.split(" ").map(e=>P(e)).join(" "))}))).map(e=>{const t=e.properties;return{elementId:t.id,nodeId:t.id,tagName:q(t.tagName)}})};var r}},"Page.getWindowProperties":{reflect:async(e,t)=>{const r=t.names.map(e=>e.replace("document.documentElement.","")),s=(await e("smartapp.element.getBySelector",{properties:r,selector:"html"}))[0];return{properties:r.map(e=>s.properties[e])}}},"Element.getHTML":{reflect:async(e,t)=>{const r=[t.type+"HTML"];return{html:(await e("Element.getDOMProperties",Object.assign(Object.assign({},t),{names:r}))).properties[0]}}},"Element.getElement":{reflect:async(e,t)=>(await e("Element.getElements",t)).elements[0]},"Element.getElements":{reflect:async(e,t)=>{const{elements:r}=await e("Page.getElements",Object.assign(Object.assign({},t),{selector:`#${t.elementId} ${t.selector}`}));return r.forEach(e=>{e.nodeId=e.id}),{elements:r}}},"Element.getAttributes":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getAttribute",Object.assign({attribute:s},t)));return{attributes:r}},params:O},"Element.getStyles":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getComputedStyle",Object.assign({style:s},t)));return{styles:r}},params:O},"Element.getDOMProperties":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getProperty",Object.assign({property:s},t)));return{properties:r}},params:O},"Element.getProperties":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getAttribute",Object.assign({attribute:s},t)));return{properties:r}},params:O},"Element.getOffset":{reflect:async(e,t)=>({left:await e("smartapp.element.getProperty",Object.assign({property:"offsetLeft"},t)),top:await e("smartapp.element.getProperty",Object.assign({property:"offsetTop"},t))}),params:O},"Element.tap":{reflect:"smartapp.element.touch",params:O}}};module.exports=T;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("os")),r=e(require("path")),s=e(require("debug")),a=e(require("licia/isWindows")),n=e(require("fs")),o=e(require("child_process")),i=e(require("licia/sleep")),c=e(require("licia/toStr")),l=e(require("licia/waitUntil")),p=e(require("licia/concat")),u=e(require("licia/getPort")),m=e(require("licia/dateFormat"));require("jimp"),require("licia/isStr");var d=e(require("ws")),h=require("events"),f=e(require("licia/uuid")),g=e(require("licia/stringify"));const w=/(^[a-z][a-z0-9-]*)/i,y=/^navigator/i,E=/^swan-nav$/i;var b;!function(e){e.SELECTOR="selector",e.TAGNAME="tagName"}(b||(b={}));const v={[b.SELECTOR]:[{test:y,processor:e=>e.replace(y,"nav")},{test:w,processor:e=>"swan-"+e}],[b.TAGNAME]:[{test:E,processor:e=>e.replace(E,"swan-navigator")},{test:w,processor:e=>e.toLocaleLowerCase().replace("swan-","")}]},j=e=>t=>{const r=(v[e]||[]).filter(e=>e.test.test(t));for(const e of r)t=e.processor(t);return t},P=j(b.SELECTOR),q=j(b.TAGNAME),O=e=>Object.assign({},e,{type:"id",info:{id:e.elementId}});require("qrcode-terminal"),require("qrcode-reader");class M extends h.EventEmitter{constructor(e){super(),this.ws=e,this.ws.addEventListener("message",e=>{this.emit("message",e.data)}),this.ws.addEventListener("close",()=>{this.emit("close")})}send(e){this.ws.send(e)}close(){this.ws.close()}}class C extends h.EventEmitter{constructor(e,t,r){super(),this.puppet=t,this.namespace=r,this.callbacks=new Map,this.transport=e,this.debug=s("automator:protocol:"+this.namespace),this.onMessage=e=>{this.debug(`${m("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`);const{id:t,method:r,error:s,result:a,params:n}=JSON.parse(e);if(!t)return this.puppet.emit(r,n);const{callbacks:o}=this;if(t&&o.has(t)){const e=o.get(t);o.delete(t),s?e.reject(Error(s.message)):e.resolve(a)}},this.onClose=()=>{this.callbacks.forEach(e=>{e.reject(Error("Connection closed"))})},this.transport.on("message",this.onMessage),this.transport.on("close",this.onClose)}send(e,t={},r=!0){if(r&&this.puppet.adapter.has(e))return this.puppet.adapter.send(this,e,t);const s=f(),a=g({id:s,method:e,params:t});return this.debug(`${m("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${a}`),new Promise((e,t)=>{try{this.transport.send(a)}catch(e){t(Error("Connection closed"))}this.callbacks.set(s,{resolve:e,reject:t})})}dispose(){this.transport.close()}static createDevtoolConnection(e,t){return new Promise((r,s)=>{const a=new d(e);a.addEventListener("open",()=>{r(new C(new M(a),t,"devtool"))}),a.addEventListener("error",s)})}static createRuntimeConnection(e,t,r){return new Promise((a,n)=>{s("automator:runtime")(`${m("yyyy-mm-dd HH:MM:ss:l")} port=${e}`);const o=new d.Server({port:e});l(async()=>{if(t.runtimeConnection)return!0},r,1e3).catch(e=>{throw Error("Failed to connect to runtime, please make sure the project is running")}),o.on("connection",(function(e){s("automator:runtime")(m("yyyy-mm-dd HH:MM:ss:l")+" connected");const r=new C(new M(e),t,"runtime");t.setRuntimeConnection(r),a(r)})),t.setRuntimeServer(o)})}}const $=s("automator:devtool");async function S(e,t,r){const{port:s,cliPath:a,timeout:n,cwd:u="",account:d="",args:h=[],launch:f=!0}=t;let g=!1,w=!1;if(!1!==f){const t={stdio:"ignore"};u&&(t.cwd=u);let r=p(h,[]);r=p(r,["--auto"]),r=p(r,[e,"--auto-port",c(s)]),d&&(r=p(r,["--auto-account",d]));try{$("%s %o %o",a,r,t);const e=o.spawn(a,r,t);e.on("error",e=>{g=!0}),e.on("exit",()=>{setTimeout(()=>{w=!0},15e3)}),e.unref()}catch(e){g=!1}}else setTimeout(()=>{w=!0},15e3);const y=await l(async()=>{try{if(g||w)return!0;return await async function(e,t){let r;try{r=await C.createDevtoolConnection(e.wsEndpoint,t)}catch(t){throw Error(`Failed connecting to ${e.wsEndpoint}, check if target project window is opened with automation enabled`)}return r}({wsEndpoint:"ws://127.0.0.1:"+s},r)}catch(e){}},n,1e3);if(g)throw Error(`Failed to launch ${r.devtools.name}, please make sure cliPath is correctly specified`);if(w)throw Error(`Failed to launch ${r.devtools.name} , please make sure http port is open`);return await i(5e3),$(m("yyyy-mm-dd HH:MM:ss:l")+" connected"),y}const A=[];["","-rc"].forEach(e=>{a?(A.push(r.join(t.homedir(),`AppData/Local/Programs/swan-ide-gui${e}/cli.bat`)),A.push(`C:/Program Files/swan-ide-gui${e}/cli.bat`)):A.push(`/Applications/百度开发者工具${e}.app/Contents/MacOS/cli`)});const T={devtools:{name:"Baidu DevTools",remote:!0,automator:!0,paths:A,required:["project.swan.json","app.json","app.js"],defaultPort:9430,validate:async function(e,t){const r=function(e,t){const r=t.devtools.paths.slice(0);e&&r.unshift(e);for(const e of r)if(n.existsSync(e))return e;throw Error(t.devtools.name+" not found, please specify executablePath option")}(e.executablePath,t);let s=e.port||t.devtools.defaultPort;if(!1!==e.launch)try{s=await async function(e,t){const r=await u(e||t);if(e&&r!==e)throw Error(`Port ${e} is in use, please specify another port`);return r}(s)}catch(t){e.launch=!1}else{s===await u(s)&&(e.launch=!0)}return Object.assign(Object.assign({},e),{port:s,cliPath:r})},async create(e,t,r){const a=await S(e,t,r);return s("automator:devtool")("initRuntimeAutomator"),a.send("smartapp.swan",{api:"$$initRuntimeAutomator",params:[]}),a}},adapter:{"Tool.enableRemoteDebug":{reflect:async e=>({qrCode:(await e("Tool.enablePreview")).url})},"App.exit":{reflect:async()=>Promise.resolve()},"Page.getElement":{reflect:async(e,t)=>(await e("Page.getElements",t)).elements[0]},"Page.getElements":{reflect:async(e,t)=>{return{elements:(await e("smartapp.element.getBySelector",Object.assign(Object.assign({},t),{properties:["id","tagName"],selector:(r=t.selector,r.split(" ").map(e=>P(e)).join(" "))}))).map(e=>{const t=e.properties;return{elementId:t.id,nodeId:t.id,tagName:q(t.tagName)}})};var r}},"Page.getWindowProperties":{reflect:async(e,t)=>{const r=t.names.map(e=>e.replace("document.documentElement.","")),s=(await e("smartapp.element.getBySelector",{properties:r,selector:"html"}))[0];return{properties:r.map(e=>s.properties[e])}}},"Element.getHTML":{reflect:async(e,t)=>{const r=[t.type+"HTML"];return{html:(await e("Element.getDOMProperties",Object.assign(Object.assign({},t),{names:r}))).properties[0]}}},"Element.getElement":{reflect:async(e,t)=>(await e("Element.getElements",t)).elements[0]},"Element.getElements":{reflect:async(e,t)=>{const{elements:r}=await e("Page.getElements",Object.assign(Object.assign({},t),{selector:`#${t.elementId} ${t.selector}`}));return r.forEach(e=>{e.nodeId=e.id}),{elements:r}}},"Element.getAttributes":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getAttribute",Object.assign({attribute:s},t)));return{attributes:r}},params:O},"Element.getStyles":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getComputedStyle",Object.assign({style:s},t)));return{styles:r}},params:O},"Element.getDOMProperties":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getProperty",Object.assign({property:s},t)));return{properties:r}},params:O},"Element.getProperties":{reflect:async(e,t)=>{const r=[];for(const s of t.names)r.push(await e("smartapp.element.getAttribute",Object.assign({attribute:s},t)));return{properties:r}},params:O},"Element.getOffset":{reflect:async(e,t)=>({left:await e("smartapp.element.getProperty",Object.assign({property:"offsetLeft"},t)),top:await e("smartapp.element.getProperty",Object.assign({property:"offsetTop"},t))}),params:O},"Element.tap":{reflect:"smartapp.element.touch",params:O}}};module.exports=T;
var n,t=Object.prototype.hasOwnProperty,e=Array.isArray,r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function o(n,o){if(e(n))return n;if(o&&(u=o,i=n,t.call(u,i)))return[n];var u,i,a=[];return n.replace(r,(function(n,t,e,r){return a.push(e?r.replace(/\\(\\)?/g,"$1"):t||n),r})),a}function u(n){return n.__wxWebviewId__?n.__wxWebviewId__:n.privateProperties?n.privateProperties.slaveId:n.$page?n.$page.id:void 0}function i(n){return n.route||n.uri}function a(n){return n.options||n.$page&&n.$page.options||{}}function c(n){return{id:u(n),path:i(n),query:a(n)}}function s(n){var t=function(n){return getCurrentPages().find((function(t){return u(t)===n}))}(n);return t&&t.$vm}function f(n,t){var e=s(n);return e&&function n(t,e){var r,o;return t&&(t._uid&&t._uid===e||t.$scope&&((o=t.$scope).__wxExparserNodeId__||o.nodeId||o.id)===e?r=t:t.$children.find((function(t){return r=n(t,e)}))),r}(e,t)}function p(n,t){var e;return n&&(e=t?function(n,t){var e,r=o(t,n);for(e=r.shift();null!=e;){if(null==(n=n[e]))return;e=r.shift()}return n}(n.$data,t):Object.assign({},n.$data)),Promise.resolve({data:e})}function g(n,t){return n&&Object.keys(t).forEach((function(e){n[e]=t[e]})),Promise.resolve()}function l(t,e,r){return new Promise((function(o,u){if(!t)return u(n.VM_NOT_EXISTS);if(!t[e])return u(n.VM_NOT_EXISTS);var i,a=t[e].apply(t,r);!(i=a)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then?o({result:a}):a.then((function(n){o({result:n})}))}))}!function(n){n.VM_NOT_EXISTS="VM_NOT_EXISTS",n.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(n||(n={}));var d=/Sync$/;var m={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(n){return c(n)}))})},getCurrentPage:function(){var n=getCurrentPages(),t=n.length;return new Promise((function(e,r){t?e(c(n[t-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n){var t=n.method,e=n.args;return new Promise((function(n,r){if(!uni[t])return r(Error("uni."+t+" not exists"));if(function(n){return d.test(n)}(t))return n({result:uni[t].apply(uni,e)});var o=[Object.assign({},e[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===t?350:0)},fail:function(n){r(Error(n.errMsg.replace(t+":fail ","")))}})];uni[t].apply(uni,o)}))}},_={getData:function(n){return p(s(n.pageId),n.path)},setData:function(n){return g(s(n.pageId),n.data)},callMethod:function(t){var e,r=((e={})[n.VM_NOT_EXISTS]="Page["+t.pageId+"] not exists",e[n.METHOD_NOT_EXISTS]="page."+t.method+" not exists",e);return new Promise((function(n,e){l(s(t.pageId),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(r[n]))}))}))}};function h(n){return n.nodeId||n.elementId}var v={getData:function(n){return p(f(n.pageId,h(n)),n.path)},setData:function(n){return g(f(n.pageId,h(n)),n.data)},callMethod:function(t){var e,r=h(t),o=((e={})[n.VM_NOT_EXISTS]="Component["+t.pageId+":"+r+"] not exists",e[n.METHOD_NOT_EXISTS]="component."+t.method+" not exists",e);return new Promise((function(n,e){l(f(t.pageId,r),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(o[n]))}))}))}},T={};Object.keys(m).forEach((function(n){T["App."+n]=m[n]})),Object.keys(_).forEach((function(n){T["Page."+n]=_[n]})),Object.keys(v).forEach((function(n){T["Element."+n]=v[n]}));var E=process.env.UNI_AUTOMATOR_WS_ENDPOINT;wx.$$initRuntimeAutomator=function(n){void 0===n&&(n={});var t=uni.connectSocket({url:E,complete:function(){}}),e=function(n){return t.send({data:JSON.stringify(n)})};t.onOpen((function(t){n.success&&n.success(),console.log("已开启自动化测试...")})),t.onMessage((function(n){var t=JSON.parse(n.data),r=t.id,o=t.method,u=t.params,i={id:r},a=T[o];if(!a)return i.error={message:o+" unimplemented"},e(i);try{a(u).then((function(n){n&&(i.result=n)})).catch((function(n){i.error={message:n.message}})).finally((function(){e(i)}))}catch(n){i.error={message:n.message},e(i)}})),t.onError((function(n){console.log("automator.onError",n)})),t.onClose((function(){n.fail&&n.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){wx.$$initRuntimeAutomator()}),500);
var n,t=Object.prototype.hasOwnProperty,e=Array.isArray,r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;function o(n,o){if(e(n))return n;if(o&&(u=o,i=n,t.call(u,i)))return[n];var u,i,a=[];return n.replace(r,(function(n,t,e,r){return a.push(e?r.replace(/\\(\\)?/g,"$1"):t||n),r})),a}function u(n){return n.__wxWebviewId__?n.__wxWebviewId__:n.privateProperties?n.privateProperties.slaveId:n.$page?n.$page.id:void 0}function i(n){return n.route||n.uri}function a(n){return n.options||n.$page&&n.$page.options||{}}function c(n){return{id:u(n),path:i(n),query:a(n)}}function s(n){var t=function(n){return getCurrentPages().find((function(t){return u(t)===n}))}(n);return t&&t.$vm}function f(n,t){var e=s(n);return e&&function n(t,e){var r;return t&&(!function(n,t){return n.$scope&&((e=n.$scope).__wxExparserNodeId__||e.nodeId||e.id)===t;var e}(t,e)?t.$children.find((function(t){return r=n(t,e)})):r=t),r}(e,t)}function p(n,t){var e;return n&&(e=t?function(n,t){var e,r=o(t,n);for(e=r.shift();null!=e;){if(null==(n=n[e]))return;e=r.shift()}return n}(n.$data,t):Object.assign({},n.$data)),Promise.resolve({data:e})}function g(n,t){return n&&Object.keys(t).forEach((function(e){n[e]=t[e]})),Promise.resolve()}function l(t,e,r){return new Promise((function(o,u){if(!t)return u(n.VM_NOT_EXISTS);if(!t[e])return u(n.VM_NOT_EXISTS);var i,a=t[e].apply(t,r);!(i=a)||"object"!=typeof i&&"function"!=typeof i||"function"!=typeof i.then?o({result:a}):a.then((function(n){o({result:n})}))}))}!function(n){n.VM_NOT_EXISTS="VM_NOT_EXISTS",n.METHOD_NOT_EXISTS="METHOD_NOT_EXISTS"}(n||(n={}));var d=/Sync$/;var m={getPageStack:function(){return Promise.resolve({pageStack:getCurrentPages().map((function(n){return c(n)}))})},getCurrentPage:function(){var n=getCurrentPages(),t=n.length;return new Promise((function(e,r){t?e(c(n[t-1])):r(Error("getCurrentPages().length=0"))}))},callUniMethod:function(n){var t=n.method,e=n.args;return new Promise((function(n,r){if(!uni[t])return r(Error("uni."+t+" not exists"));if(function(n){return d.test(n)}(t))return n({result:uni[t].apply(uni,e)});var o=[Object.assign({},e[0]||{},{success:function(e){setTimeout((function(){n({result:e})}),"pageScrollTo"===t?350:0)},fail:function(n){r(Error(n.errMsg.replace(t+":fail ","")))}})];uni[t].apply(uni,o)}))}},_={getData:function(n){return p(s(n.pageId),n.path)},setData:function(n){return g(s(n.pageId),n.data)},callMethod:function(t){var e,r=((e={})[n.VM_NOT_EXISTS]="Page["+t.pageId+"] not exists",e[n.METHOD_NOT_EXISTS]="page."+t.method+" not exists",e);return new Promise((function(n,e){l(s(t.pageId),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(r[n]))}))}))}};function h(n){return n.nodeId||n.elementId}var v={getData:function(n){return p(f(n.pageId,h(n)),n.path)},setData:function(n){return g(f(n.pageId,h(n)),n.data)},callMethod:function(t){var e,r=h(t),o=((e={})[n.VM_NOT_EXISTS]="Component["+t.pageId+":"+r+"] not exists",e[n.METHOD_NOT_EXISTS]="component."+t.method+" not exists",e);return new Promise((function(n,e){l(f(t.pageId,r),t.method,t.args).then((function(t){return n(t)})).catch((function(n){e(Error(o[n]))}))}))}},T={};Object.keys(m).forEach((function(n){T["App."+n]=m[n]})),Object.keys(_).forEach((function(n){T["Page."+n]=_[n]})),Object.keys(v).forEach((function(n){T["Element."+n]=v[n]}));var E=process.env.UNI_AUTOMATOR_WS_ENDPOINT;wx.$$initRuntimeAutomator=function(n){void 0===n&&(n={});var t=uni.connectSocket({url:E,complete:function(){}}),e=function(n){return t.send({data:JSON.stringify(n)})};t.onOpen((function(t){n.success&&n.success(),console.log("已开启自动化测试...")})),t.onMessage((function(n){var t=JSON.parse(n.data),r=t.id,o=t.method,u=t.params,i={id:r},a=T[o];if(!a)return i.error={message:o+" unimplemented"},e(i);try{a(u).then((function(n){n&&(i.result=n)})).catch((function(n){i.error={message:n.message}})).finally((function(){e(i)}))}catch(n){i.error={message:n.message},e(i)}})),t.onError((function(n){console.log("automator.onError",n)})),t.onClose((function(){n.fail&&n.fail({errMsg:"$$initRuntimeAutomator:fail"}),console.log("automator.onClose")}))},setTimeout((function(){wx.$$initRuntimeAutomator()}),500);
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("debug")),r=e(require("licia/isWindows")),n=e(require("jimp"));require("licia/isStr");var o=e(require("licia/getPort")),s=e(require("fs")),i=e(require("child_process")),a=e(require("licia/sleep")),c=e(require("licia/toStr")),l=e(require("licia/waitUntil")),u=e(require("licia/concat")),d=e(require("licia/dateFormat")),p=e(require("ws")),h=require("events"),m=e(require("licia/uuid")),w=e(require("licia/stringify"));require("qrcode-terminal");const f=require("qrcode-reader");class y extends h.EventEmitter{constructor(e){super(),this.ws=e,this.ws.addEventListener("message",e=>{this.emit("message",e.data)}),this.ws.addEventListener("close",()=>{this.emit("close")})}send(e){this.ws.send(e)}close(){this.ws.close()}}class g extends h.EventEmitter{constructor(e,r,n){super(),this.puppet=r,this.namespace=n,this.callbacks=new Map,this.transport=e,this.debug=t("automator:protocol:"+this.namespace),this.onMessage=e=>{this.debug(`${d("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`);const{id:t,method:r,error:n,result:o,params:s}=JSON.parse(e);if(!t)return this.puppet.emit(r,s);const{callbacks:i}=this;if(t&&i.has(t)){const e=i.get(t);i.delete(t),n?e.reject(Error(n.message)):e.resolve(o)}},this.onClose=()=>{this.callbacks.forEach(e=>{e.reject(Error("Connection closed"))})},this.transport.on("message",this.onMessage),this.transport.on("close",this.onClose)}send(e,t={},r=!0){if(r&&this.puppet.adapter.has(e))return this.puppet.adapter.send(this,e,t);const n=m(),o=w({id:n,method:e,params:t});return this.debug(`${d("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${o}`),new Promise((e,t)=>{try{this.transport.send(o)}catch(e){t(Error("Connection closed"))}this.callbacks.set(n,{resolve:e,reject:t})})}dispose(){this.transport.close()}static createDevtoolConnection(e,t){return new Promise((r,n)=>{const o=new p(e);o.addEventListener("open",()=>{r(new g(new y(o),t,"devtool"))}),o.addEventListener("error",n)})}static createRuntimeConnection(e,r,n){return new Promise((o,s)=>{t("automator:runtime")(`${d("yyyy-mm-dd HH:MM:ss:l")} port=${e}`);const i=new p.Server({port:e});l(async()=>{if(r.runtimeConnection)return!0},n,1e3).catch(e=>{throw Error("Failed to connect to runtime, please make sure the project is running")}),i.on("connection",(function(e){t("automator:runtime")(d("yyyy-mm-dd HH:MM:ss:l")+" connected");const n=new g(new y(e),r,"runtime");r.setRuntimeConnection(n),o(n)})),r.setRuntimeServer(i)})}}const v=t("automator:devtool");async function b(e,t,r){const{port:n,cliPath:o,timeout:s,cwd:p="",account:h="",args:m=[],launch:w=!0}=t;let f=!1,y=!1;if(!1!==w){const t={detached:!0,stdio:"ignore"};p&&(t.cwd=p);let r=u(m,["--auto",e,"--auto-port",c(n)]);h&&(r=u(r,["--auto-account",h]));try{v("%s %o %o",o,r,t);const e=i.spawn(o,r,t);e.on("error",e=>{f=!0}),e.on("exit",()=>{setTimeout(()=>{y=!0},15e3)}),e.unref()}catch(e){f=!1}}else setTimeout(()=>{y=!0},15e3);const b=await l(async()=>{try{if(f||y)return!0;return await async function(e,t){let r;try{r=await g.createDevtoolConnection(e.wsEndpoint,t)}catch(t){throw Error(`Failed connecting to ${e.wsEndpoint}, check if target project window is opened with automation enabled`)}return r}({wsEndpoint:"ws://127.0.0.1:"+n},r)}catch(e){}},s,1e3);if(f)throw Error(`Failed to launch ${r.devtools.name}, please make sure cliPath is correctly specified`);if(y)throw Error(`Failed to launch ${r.devtools.name} , please make sure http port is open`);return await a(5e3),v(d("yyyy-mm-dd HH:MM:ss:l")+" connected"),b}const E={devtools:{name:"Wechat web devTools",remote:!0,automator:!0,paths:[r?"C:/Program Files (x86)/Tencent/微信web开发者工具/cli.bat":"/Applications/wechatwebdevtools.app/Contents/MacOS/cli"],required:["project.config.json","app.json","app.js"],defaultPort:9420,validate:async function(e,t){const r=function(e,t){const r=t.devtools.paths.slice(0);e&&r.unshift(e);for(const e of r)if(s.existsSync(e))return e;throw Error(t.devtools.name+" not found, please specify executablePath option")}(e.executablePath,t);let n=e.port||t.devtools.defaultPort;if(!1!==e.launch)try{n=await async function(e,t){const r=await o(e||t);if(e&&r!==e)throw Error(`Port ${e} is in use, please specify another port`);return r}(n)}catch(t){e.launch=!1}else{n===await o(n)&&(e.launch=!0)}return Object.assign(Object.assign({},e),{port:n,cliPath:r})},async create(e,r,n){const o=await b(e,r,n);return t("automator:devtool")("initRuntimeAutomator"),o.send("App.callWxMethod",{method:"$$initRuntimeAutomator",args:[]}),o}},adapter:{"Tool.enableRemoteDebug":{reflect:async(e,t)=>{let{qrCode:r}=await e("Tool.enableRemoteDebug",t,!1);return r&&(r=await function(e){const t=new Buffer(e,"base64");return new Promise(async(e,r)=>{const o=await n.read(t),s=new f;s.callback=function(t,n){if(t)return r(t);e(n.result)},s.decode(o.bitmap)})}(r)),{qrCode:r}}},"App.callFunction":{reflect:async(e,t)=>{return e("App.callFunction",Object.assign(Object.assign({},t),{functionDeclaration:(r=t.functionDeclaration,"}"===r[r.length-1]?r.replace("{","{\nvar uni = wx;\n"):r.replace("=>","=>{\nvar uni = wx;\nreturn ")+"}")}),!1);var r}},"Element.getHTML":{reflect:async(e,t)=>({html:(await e("Element.getWXML",t,!1)).wxml})}}};module.exports=E;
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("debug")),r=e(require("licia/isWindows")),n=e(require("jimp"));require("licia/isStr");var o=e(require("licia/getPort")),s=e(require("fs")),i=e(require("child_process")),a=e(require("licia/sleep")),c=e(require("licia/toStr")),l=e(require("licia/waitUntil")),u=e(require("licia/concat")),d=e(require("licia/dateFormat")),p=e(require("ws")),h=require("events"),m=e(require("licia/uuid")),w=e(require("licia/stringify"));require("qrcode-terminal");const f=require("qrcode-reader");class y extends h.EventEmitter{constructor(e){super(),this.ws=e,this.ws.addEventListener("message",e=>{this.emit("message",e.data)}),this.ws.addEventListener("close",()=>{this.emit("close")})}send(e){this.ws.send(e)}close(){this.ws.close()}}class g extends h.EventEmitter{constructor(e,r,n){super(),this.puppet=r,this.namespace=n,this.callbacks=new Map,this.transport=e,this.debug=t("automator:protocol:"+this.namespace),this.onMessage=e=>{this.debug(`${d("yyyy-mm-dd HH:MM:ss:l")} ◀ RECV ${e}`);const{id:t,method:r,error:n,result:o,params:s}=JSON.parse(e);if(!t)return this.puppet.emit(r,s);const{callbacks:i}=this;if(t&&i.has(t)){const e=i.get(t);i.delete(t),n?e.reject(Error(n.message)):e.resolve(o)}},this.onClose=()=>{this.callbacks.forEach(e=>{e.reject(Error("Connection closed"))})},this.transport.on("message",this.onMessage),this.transport.on("close",this.onClose)}send(e,t={},r=!0){if(r&&this.puppet.adapter.has(e))return this.puppet.adapter.send(this,e,t);const n=m(),o=w({id:n,method:e,params:t});return this.debug(`${d("yyyy-mm-dd HH:MM:ss:l")} SEND ► ${o}`),new Promise((e,t)=>{try{this.transport.send(o)}catch(e){t(Error("Connection closed"))}this.callbacks.set(n,{resolve:e,reject:t})})}dispose(){this.transport.close()}static createDevtoolConnection(e,t){return new Promise((r,n)=>{const o=new p(e);o.addEventListener("open",()=>{r(new g(new y(o),t,"devtool"))}),o.addEventListener("error",n)})}static createRuntimeConnection(e,r,n){return new Promise((o,s)=>{t("automator:runtime")(`${d("yyyy-mm-dd HH:MM:ss:l")} port=${e}`);const i=new p.Server({port:e});l(async()=>{if(r.runtimeConnection)return!0},n,1e3).catch(e=>{throw Error("Failed to connect to runtime, please make sure the project is running")}),i.on("connection",(function(e){t("automator:runtime")(d("yyyy-mm-dd HH:MM:ss:l")+" connected");const n=new g(new y(e),r,"runtime");r.setRuntimeConnection(n),o(n)})),r.setRuntimeServer(i)})}}const v=t("automator:devtool");async function b(e,t,r){const{port:n,cliPath:o,timeout:s,cwd:p="",account:h="",args:m=[],launch:w=!0}=t;let f=!1,y=!1;if(!1!==w){const t={stdio:"ignore",detached:!0};p&&(t.cwd=p);let r=u(m,[]);r=u(r,["auto","--project"]),r=u(r,[e,"--auto-port",c(n)]),h&&(r=u(r,["--auto-account",h]));try{v("%s %o %o",o,r,t);const e=i.spawn(o,r,t);e.on("error",e=>{f=!0}),e.on("exit",()=>{setTimeout(()=>{y=!0},15e3)}),e.unref()}catch(e){f=!1}}else setTimeout(()=>{y=!0},15e3);const b=await l(async()=>{try{if(f||y)return!0;return await async function(e,t){let r;try{r=await g.createDevtoolConnection(e.wsEndpoint,t)}catch(t){throw Error(`Failed connecting to ${e.wsEndpoint}, check if target project window is opened with automation enabled`)}return r}({wsEndpoint:"ws://127.0.0.1:"+n},r)}catch(e){}},s,1e3);if(f)throw Error(`Failed to launch ${r.devtools.name}, please make sure cliPath is correctly specified`);if(y)throw Error(`Failed to launch ${r.devtools.name} , please make sure http port is open`);return await a(5e3),v(d("yyyy-mm-dd HH:MM:ss:l")+" connected"),b}const E={devtools:{name:"Wechat web devTools",remote:!0,automator:!0,paths:[r?"C:/Program Files (x86)/Tencent/微信web开发者工具/cli.bat":"/Applications/wechatwebdevtools.app/Contents/MacOS/cli"],required:["project.config.json","app.json","app.js"],defaultPort:9420,validate:async function(e,t){const r=function(e,t){const r=t.devtools.paths.slice(0);e&&r.unshift(e);for(const e of r)if(s.existsSync(e))return e;throw Error(t.devtools.name+" not found, please specify executablePath option")}(e.executablePath,t);let n=e.port||t.devtools.defaultPort;if(!1!==e.launch)try{n=await async function(e,t){const r=await o(e||t);if(e&&r!==e)throw Error(`Port ${e} is in use, please specify another port`);return r}(n)}catch(t){e.launch=!1}else{n===await o(n)&&(e.launch=!0)}return Object.assign(Object.assign({},e),{port:n,cliPath:r})},async create(e,r,n){const o=await b(e,r,n);return t("automator:devtool")("initRuntimeAutomator"),o.send("App.callWxMethod",{method:"$$initRuntimeAutomator",args:[]}),o}},adapter:{"Tool.enableRemoteDebug":{reflect:async(e,t)=>{let{qrCode:r}=await e("Tool.enableRemoteDebug",t,!1);return r&&(r=await function(e){const t=new Buffer(e,"base64");return new Promise(async(e,r)=>{const o=await n.read(t),s=new f;s.callback=function(t,n){if(t)return r(t);e(n.result)},s.decode(o.bitmap)})}(r)),{qrCode:r}}},"App.callFunction":{reflect:async(e,t)=>{return e("App.callFunction",Object.assign(Object.assign({},t),{functionDeclaration:(r=t.functionDeclaration,"}"===r[r.length-1]?r.replace("{","{\nvar uni = wx;\n"):r.replace("=>","=>{\nvar uni = wx;\nreturn ")+"}")}),!1);var r}},"Element.getHTML":{reflect:async(e,t)=>({html:(await e("Element.getWXML",t,!1)).wxml})}}};module.exports=E;
......@@ -1211,7 +1211,7 @@ function parseBaseApp (vm, {
return appOptions
}
const mocks = ['nodeId', 'componentName'];
const mocks = ['nodeId', 'componentName' ,'_componentId'];
function isPage () {
return !this.ownerId
......
......@@ -87,7 +87,7 @@ class WebpackAppPlusPlugin {
done(`Build complete. FILES:` + JSON.stringify(changedFiles))
}
} else {
done(`Build complete. Watching for changes...`)
!process.env.UNI_AUTOMATOR_WS_ENDPOINT && done(`Build complete. Watching for changes...`)
}
isFirst = false
} else {
......
......@@ -154,7 +154,7 @@ async function build (args, api, options) {
return reject('Build failed with errors.')
}
if (!args.silent && process.env.UNI_PLATFORM !== 'app-plus') {
if (!args.silent && (process.env.UNI_PLATFORM !== 'app-plus' || process.env.UNI_AUTOMATOR_WS_ENDPOINT)) {
const targetDirShort = path.relative(
api.service.context,
process.env.UNI_OUTPUT_DIR
......
......@@ -153,7 +153,8 @@ const v3 = {
options: {
compiler: vueLoader.compiler,
before: [
beforeCode + statCode + getGlobalUsingComponentsCode()
beforeCode + require('../util').getAutomatorCode() + statCode +
getGlobalUsingComponentsCode()
]
}
}]
......
......@@ -88,7 +88,7 @@ function getStylesCode(loaderContext) {
resourcePath,
stringifyRequest,
needsHotReload,
true, // needs explicit injection?
true, // needs explicit injection?
'app-vue'
)
}
......@@ -98,9 +98,12 @@ function getStylesCode(loaderContext) {
module.exports = function(source, map) {
// 追加小程序全局自定义组件(仅v3)
source = getGlobalUsingComponentsCode() + source
const automatorCode = process.env.UNI_AUTOMATOR_WS_ENDPOINT ?
`import '@dcloudio/uni-app-plus/dist/automator.view'` :
''
return `
import 'uni-pages?${JSON.stringify({type:'view'})}'
${automatorCode}
function initView(){
${getStylesCode(this)}
typeof injectStyles ==='function' && injectStyles()
......
......@@ -15,7 +15,7 @@ class DownloadTask {
}
abort () {
invokeMethod('operateRequestTask', {
invokeMethod('operateDownloadTask', {
downloadTaskId: this.id,
operationType: 'abort'
})
......
export const mocks = ['nodeId', 'componentName']
export const mocks = ['nodeId', 'componentName', '_componentId']
export function isPage () {
return !this.ownerId
......@@ -6,4 +6,4 @@ export function isPage () {
export function initRelation (detail) {
this.dispatch('__l', detail)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册