functionI(t,e,n,s){vari,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeofReflect&&"function"==typeofReflect.decorate)r=Reflect.decorate(t,e,n,s);elsefor(vara=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);returno>3&&r&&Object.defineProperty(e,n,r),r}varD;functionT(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionA(t,e,n){returnT(D.RUNTIME,n)}functionx(t,e,n){returnT(D.DEVTOOL,n)}!function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(D||(D={}));classR{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===D.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classqextendsR{constructor(t,e){super(t),this.id=e.elementId,this.pageId=e.pageId,this.nodeId=e.nodeId,this.videoId=e.videoId}asyncgetData(t){returnthis.invokeMethod("Element.getData",t)}asyncsetData(t){returnthis.invokeMethod("Element.setData",t)}asynccallMethod(t){returnthis.invokeMethod("Element.callMethod",t)}asyncgetElement(t){returnthis.invokeMethod("Element.getElement",t)}asyncgetElements(t){returnthis.invokeMethod("Element.getElements",t)}asyncgetOffset(){returnthis.invokeMethod("Element.getOffset")}asyncgetHTML(t){returnthis.invokeMethod("Element.getHTML",t)}asyncgetAttributes(t){returnthis.invokeMethod("Element.getAttributes",t)}asyncgetStyles(t){returnthis.invokeMethod("Element.getStyles",t)}asyncgetDOMProperties(t){returnthis.invokeMethod("Element.getDOMProperties",t)}asyncgetProperties(t){returnthis.invokeMethod("Element.getProperties",t)}asynctap(){returnthis.invokeMethod("Element.tap")}asynctouchstart(t){returnthis.invokeMethod("Element.touchstart",t)}asynctouchmove(t){returnthis.invokeMethod("Element.touchmove",t)}asynctouchend(t){returnthis.invokeMethod("Element.touchend",t)}asynctriggerEvent(t){returnthis.invokeMethod("Element.triggerEvent",t)}asynccallFunction(t){returnthis.invokeMethod("Element.callFunction",t)}asynccallContextMethod(t){returnthis.invokeMethod("Element.callContextMethod",t)}invokeMethod(t,e={}){returne.elementId=this.id,e.pageId=this.pageId,this.nodeId&&(e.nodeId=this.nodeId),this.videoId&&(e.videoId=this.videoId),this.invoke(t,e)}}I([A],q.prototype,"getData",null),I([A],q.prototype,"setData",null),I([A],q.prototype,"callMethod",null),I([x],q.prototype,"getElement",null),I([x],q.prototype,"getElements",null),I([x],q.prototype,"getOffset",null),I([x],q.prototype,"getHTML",null),I([x],q.prototype,"getAttributes",null),I([x],q.prototype,"getStyles",null),I([x],q.prototype,"getDOMProperties",null),I([x],q.prototype,"getProperties",null),I([x],q.prototype,"tap",null),I([x],q.prototype,"touchstart",null),I([x],q.prototype,"touchmove",null),I([x],q.prototype,"touchend",null),I([x],q.prototype,"triggerEvent",null),I([x],q.prototype,"callFunction",null),I([x],q.prototype,"callContextMethod",null);classj{constructor(t,e,n){this.puppet=t,this.id=e.elementId,this.pageId=e.pageId,this.nodeId=e.nodeId||null,this.videoId=e.videoId||null,this.tagName=e.tagName,this.elementMap=n,"body"!==this.tagName&&"page-body"!==this.tagName||(this.tagName="page"),this.api=newq(t,e)}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnj.create(this.puppet,Object.assign({},e,{pageId:this.pageId}),this.elementMap)}catch(t){returnnull}}async$$(t){const{elements:e}=awaitthis.api.getElements({selector:t});returne.map(t=>j.create(this.puppet,Object.assign({},t,{pageId:this.pageId}),this.elementMap))}asyncsize(){const[t,e]=awaitthis.domProperty(["offsetWidth","offsetHeight"]);return{width:t,height:e}}asyncoffset(){returnthis.api.getOffset()}asynctext(){returnthis.domProperty("innerText")}asyncattribute(t){if(!m(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!m(t))throwError("name must be a string");if(this.puppet.checkProperty){lete=this.publicProps;if(e||(this.publicProps=e=awaitthis._property("__propPublic")),!e[t])throwError(`${this.tagName}.${t} not exists`)}returnthis._property(t)}asynchtml(){return(awaitthis.api.getHTML({type:"inner"})).html}asyncouterHtml(){return(awaitthis.api.getHTML({type:"outer"})).html}asyncstyle(t){if(!m(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnawaitthis.touchstart(),awaitv(350),this.touchend()}asynctrigger(t,e){constn={type:t};returnw(e)||(n.detail=e),this.api.triggerEvent(n)}asynctouchstart(t){returnthis.api.touchstart(t)}asynctouchmove(t){returnthis.api.touchmove(t)}asynctouchend(t){returnthis.api.touchend(t)}asyncdomProperty(t){returnC(asynct=>(awaitthis.api.getDOMProperties({names:t})).properties,t)}_property(t){returnC(asynct=>(awaitthis.api.getProperties({names:t})).properties,t)}send(t,e){returne.elementId=this.id,e.pageId=this.pageId,this.nodeId&&(e.nodeId=this.nodeId),this.videoId&&(e.videoId=this.videoId),this.puppet.send(t,e)}asynccallFunction(t,...e){return(awaitthis.api.callFunction({functionName:t,args:e})).result}staticcreate(t,e,n){lets,i=n.get(e.elementId);if(i)returni;if(e.nodeId)s=S;elseswitch(e.tagName){case"input":s=$;break;case"textarea":s=F;break;case"scroll-view":s=O;break;case"swiper":s=L;break;case"movable-view":s=U;break;case"switch":s=H;break;case"slider":s=N;break;case"video":s=B;break;default:s=j}returni=news(t,e,n),n.set(e.elementId,i),i}}classSextendsj{asyncsetData(t){returnthis.api.setData({data:t})}asyncdata(t){conste={};returnt&&(e.path=t),(awaitthis.api.getData(e)).data}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}}class$extendsj{asyncinput(t){returnthis.callFunction("input.input",t)}}classFextendsj{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classOextendsj{asyncscrollTo(t,e){returnthis.callFunction("scroll-view.scrollTo",t,e)}asyncproperty(t){return"scrollTop"===t?this.callFunction("scroll-view.scrollTop"):"scrollLeft"===t?this.callFunction("scroll-view.scrollLeft"):super.property(t)}asyncscrollWidth(){returnthis.callFunction("scroll-view.scrollWidth")}asyncscrollHeight(){returnthis.callFunction("scroll-view.scrollHeight")}}classLextendsj{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classUextendsj{asyncmoveTo(t,e){returnthis.callFunction("movable-view.moveTo",t,e)}asyncproperty(t){return"x"===t?this._property("_translateX"):"y"===t?this._property("_translateY"):super.property(t)}}classHextendsj{asynctap(){returnthis.callFunction("switch.tap")}}classNextendsj{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classBextendsj{asynccallContextMethod(t,...e){returnthis.api.callContextMethod({method:t,args:e})}}class_extendsR{constructor(t,e){super(t),this.id=e.id}asyncgetData(t){returnthis.invokeMethod("Page.getData",t)}asyncsetData(t){returnthis.invokeMethod("Page.setData",t)}asynccallMethod(t){returnthis.invokeMethod("Page.callMethod",t)}asyncgetElement(t){returnthis.invokeMethod("Page.getElement",t)}asyncgetElements(t){returnthis.invokeMethod("Page.getElements",t)}asyncgetWindowProperties(t){returnthis.invokeMethod("Page.getWindowProperties",t)}invokeMethod(t,e={}){returne.pageId=this.id,this.invoke(t,e)}}I([A],_.prototype,"getData",null),I([A],_.prototype,"setData",null),I([A],_.prototype,"callMethod",null),I([x],_.prototype,"getElement",null),I([x],_.prototype,"getElements",null),I([x],_.prototype,"getWindowProperties",null);classW{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=new_(t,e)}asyncwaitFor(t){returny(t)?awaitv(t):h(t)?l(t):m(t)?l(async()=>(awaitthis.$$(t)).length>0):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnj.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap)}catch(t){returnnull}}async$$(t){const{elements:e}=awaitthis.api.getElements({selector:t});returne.map(e=>j.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap))}asyncdata(t){conste={};returnt&&(e.path=t),(awaitthis.api.getData(e)).data}asyncsetData(t){returnthis.api.setData({data:t})}asyncsize(){const[t,e]=awaitthis.windowProperty(["document.documentElement.scrollWidth","document.documentElement.scrollHeight"]);return{width:t,height:e}}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}asyncscrollTop(){returnthis.windowProperty("document.documentElement.scrollTop")}asyncwindowProperty(t){conste=m(t);e&&(t=[t]);const{properties:n}=awaitthis.api.getWindowProperties({names:t});returne?n[0]:n}staticcreate(t,e,n){lets=n.get(e.id);returns||(s=newW(t,e),n.set(e.id,s),s)}}classVextendsR{asyncgetPageStack(){returnthis.invoke("App.getPageStack")}asynccallUniMethod(t){returnthis.invoke("App.callUniMethod",t)}asyncgetCurrentPage(){returnthis.invoke("App.getCurrentPage")}asyncmockUniMethod(t){returnthis.invoke("App.mockUniMethod",t)}asynccallFunction(t){returnthis.invoke("App.callFunction",t)}asynccaptureScreenshot(t){returnthis.invoke("App.captureScreenshot",t)}asyncexit(){returnthis.invoke("App.exit")}asyncaddBinding(t){returnthis.invoke("App.addBinding",t)}asyncenableLog(){returnthis.invoke("App.enableLog")}onLogAdded(t){returnthis.on("App.logAdded",t)}onBindingCalled(t){returnthis.on("App.bindingCalled",t)}onExceptionThrown(t){returnthis.on("App.exceptionThrown",t)}}I([A],V.prototype,"getPageStack",null),I([A],V.prototype,"callUniMethod",null),I([A],V.prototype,"getCurrentPage",null),I([x],V.prototype,"mockUniMethod",null),I([x],V.prototype,"callFunction",null),I([x],V.prototype,"captureScreenshot",null),I([x],V.prototype,"exit",null),I([x],V.prototype,"addBinding",null),I([x],V.prototype,"enableLog",null);classzextendsR{asyncgetInfo(){returnthis.invoke("Tool.getInfo")}asyncenableRemoteDebug(t){returnthis.invoke("Tool.enableRemoteDebug")}asyncclose(){returnthis.invoke("Tool.close")}asyncgetTestAccounts(){returnthis.invoke("Tool.getTestAccounts")}onRemoteDebugConnected(t){this.puppet.once("Tool.onRemoteDebugConnected",t),this.puppet.once("Tool.onPreviewConnected",t)}}functionG(t){returnnewPromise(e=>setTimeout(e,t))}I([x],z.prototype,"getInfo",null),I([x],z.prototype,"enableRemoteDebug",null),I([x],z.prototype,"close",null),I([x],z.prototype,"getTestAccounts",null);classJextendsr.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newV(t),this.toolApi=newz(t),this.appApi.onLogAdded(t=>{this.emit("console",t)}),this.appApi.onBindingCalled(({name:t,args:e})=>{try{constn=this.appBindings.get(t);n&&n(...e)}catch(t){}}),this.appApi.onExceptionThrown(t=>{this.emit("exception",t)})}asyncpageStack(){return(awaitthis.appApi.getPageStack()).pageStack.map(t=>W.create(this.puppet,t,this.pageMap))}asyncnavigateTo(t){returnthis.changeRoute("navigateTo",t)}asyncredirectTo(t){returnthis.changeRoute("redirectTo",t)}asyncnavigateBack(){returnthis.changeRoute("navigateBack")}asyncreLaunch(t){returnthis.changeRoute("reLaunch",t)}asyncswitchTab(t){returnthis.changeRoute("switchTab",t)}asynccurrentPage(){const{id:t,path:e,query:n}=awaitthis.appApi.getCurrentPage();returnW.create(this.puppet,{id:t,path:e,query:n},this.pageMap)}asyncsystemInfo(){returnthis.callUniMethod("getSystemInfoSync")}asynccallUniMethod(t,...e){return(awaitthis.appApi.callUniMethod({method:t,args:e})).result}asyncmockUniMethod(t,e,...n){returnh(e)||m(s=e)&&(s=d(s),g(s,"function")||g(s,"() =>"))?this.appApi.mockUniMethod({method:t,functionDeclaration:e.toString(),args:n}):this.appApi.mockUniMethod({method:t,result:e});vars}asyncrestoreUniMethod(t){returnthis.appApi.mockUniMethod({method:t})}asyncevaluate(t,...e){return(awaitthis.appApi.callFunction({functionDeclaration:t.toString(),args:e})).result}asyncpageScrollTo(t){awaitthis.callUniMethod("pageScrollTo",{scrollTop:t,duration:0})}asyncclose(){try{awaitthis.appApi.exit()}catch(t){}awaitG(1e3),this.puppet.disposeRuntimeServer(),awaitthis.toolApi.close(),this.disconnect()}asyncteardown(){returnthis["disconnect"===this.options.teardown?"disconnect":"close"]()}asyncremote(t){if(!this.puppet.devtools.remote)returnconsole.warn(`Failed to enable remote, ${this.puppet.devtools.name} is unimplemented`);const{qrCode:e}=awaitthis.toolApi.enableRemoteDebug({auto:t});varn;e&&await(n=e,newPromise(t=>{b.generate(n,{small:!0},e=>{process.stdout.write(e),t()})}));consts=newPromise(t=>{this.toolApi.onRemoteDebugConnected(async()=>{awaitG(1e3),t()})}),i=newPromise(t=>{this.puppet.setRemoteRuntimeConnectionCallback(()=>{t()})});returnPromise.all([s,i])}disconnect(){this.puppet.dispose()}on(t,e){return"console"===t&&this.appApi.enableLog(),super.on(t,e),this}asyncexposeFunction(t,e){if(this.appBindings.has(t))throwError(`Failed to expose function with name ${t}: already exists!`);this.appBindings.set(t,e),awaitthis.appApi.addBinding({name:t})}asynccheckVersion(){}asyncscreenshot(t){const{data:e}=awaitthis.appApi.captureScreenshot({fullPage:null==t?void0:t.fullPage});if(!(null==t?void0:t.path))returne;awaitu.writeFile(t.path,e,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),awaitG(3e3),this.currentPage()}}classX{constructor(t){this.options=t}has(t){return!!this.options[t]}send(t,e,n){consts=this.options[e];if(!s)returnPromise.reject(Error(`adapter for ${e} not found`));consti=s.reflect;returni?(s.params&&(n=s.params(n)),"function"==typeofi?i(t.send.bind(t),n):(e=i,t.send(e,n))):Promise.reject(Error(e+"'s reflect is required"))}}classYextendsr.EventEmitter{constructor(t,e){if(super(),this.target=e||("h5"===t?require("@dcloudio/uni-h5/lib/h5/uni.automator.js"):require(`@dcloudio/uni-${t}/lib/uni.automator.js`)),!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newX(this.target.adapter||{})}setRuntimeServer(t){this.wss=t}setRemoteRuntimeConnectionCallback(t){this.remoteRuntimeConnectionCallback=t}setRuntimeConnection(t){this.runtimeConnection=t,this.remoteRuntimeConnectionCallback&&(this.remoteRuntimeConnectionCallback(),this.remoteRuntimeConnectionCallback=null)}setDevtoolConnection(t){this.devtoolConnection=t}disposeRuntimeServer(){this.wss&&this.wss.close()}disposeRuntime(){this.runtimeConnection.dispose()}disposeDevtool(){this.devtoolConnection&&this.devtoolConnection.dispose()}dispose(){this.disposeRuntime(),this.disposeDevtool(),this.disposeRuntimeServer()}send(t,e){returnthis.runtimeConnection.send(t,e)}validateProject(t){consts=this.target.devtools.required;return!s||!s.find(s=>!e.existsSync(n.join(t,s)))}validateDevtools(t){conste=this.target.devtools.validate;returne?e(t,this):Promise.resolve(t)}createDevtools(t,e,n){consts=this.target.devtools.create;returns?(e.timeout=n,s(t,e,this)):Promise.resolve()}shouldCompile(t,e){this.compiled=!0;constn=this.target.shouldCompile;returnthis.compiled=n?n(t,e):!1!==t.compile,this.compiled}getcheckProperty(){return"mp-weixin"===this.platform}getdevtools(){returnthis.target.devtools}getmode(){constt=this.target.mode;returnt||("production"===process.env.NODE_ENV?"build":"dev")}}constK=s("automator:compiler"),Q=/The\s+(.*)\s+directory is ready/;classZ{constructor(t){this.puppet=t}compile(t){conste=this.puppet.mode,s=this.puppet.platform;leti=t.silent;consto=t.port,r=t.host,a=process.env.UNI_NPM_PATH||"npm",c=`${e}:${s}`,p=t.projectPath,l=["run",c,"--","--auto-port",P(o)];r&&(l.push("--auto-host"),l.push(r));constu={cwd:t.cliPath||t.projectPath,env:process.env};returnnewPromise((t,o)=>{constr=function(o){constr=o.toString().trim();if(!i&&console.log(r),r.includes("App running at:"))t({path:""});elseif(r.includes("DONE Build complete")){leto=`unpackage/dist/${e}/${s}`;consta=r.match(Q);a&&a.length>1&&(o=a[1]),i=!0,c.kill("SIGTERM"),t({path:n.join(p,o)})}};K(`${a}${l.join("")}`);constc=M.spawn(a,l,u);c.on("error",(function(t){o(t)})),c.stdout.on("data",r),c.stderr.on("data",r)})}}classtt{asynclaunch(t){lete=t[t.platform]||{};this.puppet=newY(t.platform,e.puppet);const{port:n,cliPath:i,timeout:o,projectPath:r}=awaitthis.validate(t);e=awaitthis.puppet.validateDevtools(e);leta=r;if(this.puppet.shouldCompile(t,e)){this.compiler=newZ(this.puppet);conste=awaitthis.compiler.compile({host:t.host,port:n,cliPath:i,projectPath:r,silent:!!t.silent});e.path&&(a=e.path)}constc=[];returnc.push(this.createRuntimeConnection(n,o)),c.push(this.puppet.createDevtools(a,e,o)),newPromise((t,n)=>{Promise.all(c).then(([n,i])=>{n&&this.puppet.setRuntimeConnection(n),i&&this.puppet.setDevtoolConnection(i),s("automator:program")("ready");consto=e.teardown||"disconnect";t(newJ(this.puppet,{teardown:o}))}).catch(t=>n(t))})}resolveCliPath(t){if(!t)returnt;try{conste=require(n.join(t,"package.json"));if(e.devDependencies&&e.devDependencies["@dcloudio/vue-cli-plugin-uni"])returnt}catch(t){}throwError(`Cli ${t} doesn't exist`)}resolveProjectPath(t,s){if(t||(t=process.cwd()),i(t)&&(t=n.resolve(t)),e.existsSync(t)||function(t){throwError(t)}(`Project path ${t} doesn't exist`),!1===s.compile&&!this.puppet.validateProject(t)){conste=n.join(t,"dist/"+this.puppet.mode+"/"+this.puppet.platform);if(this.puppet.validateProject(e))returne;s.compile=!0}returnt}asyncvalidate(t){conste=this.resolveProjectPath(t.projectPath,t);letn=t.cliPath;return!1!==t.compile&&(n=this.resolveCliPath(t.cliPath||""),!n&&(n=this.resolveCliPath(e))),{port:awaitasyncfunction(t,e){constn=awaitf(t||e);if(t&&n!==t)throwError(`Port ${t} is in use, please specify another port`);returnn}(t.port||9520),cliPath:n,timeout:t.timeout||1e5,projectPath:e}}asynccreateRuntimeConnection(t,e){returnE.createRuntimeConnection(t,this.puppet,e)}}module.exports=class{constructor(){this.launcher=newtt}asynclaunch(t){returnthis.launcher.launch(t)}};
functionI(t,e,n,s){vari,o=arguments.length,r=o<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,n):s;if("object"==typeofReflect&&"function"==typeofReflect.decorate)r=Reflect.decorate(t,e,n,s);elsefor(vara=t.length-1;a>=0;a--)(i=t[a])&&(r=(o<3?i(r):o>3?i(e,n,r):i(e,n))||r);returno>3&&r&&Object.defineProperty(e,n,r),r}varD;functionT(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionA(t,e,n){returnT(D.RUNTIME,n)}functionx(t,e,n){returnT(D.DEVTOOL,n)}!function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(D||(D={}));classR{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===D.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classqextendsR{constructor(t,e){super(t),this.id=e.elementId,this.pageId=e.pageId,this.nodeId=e.nodeId,this.videoId=e.videoId}asyncgetData(t){returnthis.invokeMethod("Element.getData",t)}asyncsetData(t){returnthis.invokeMethod("Element.setData",t)}asynccallMethod(t){returnthis.invokeMethod("Element.callMethod",t)}asyncgetElement(t){returnthis.invokeMethod("Element.getElement",t)}asyncgetElements(t){returnthis.invokeMethod("Element.getElements",t)}asyncgetOffset(){returnthis.invokeMethod("Element.getOffset")}asyncgetHTML(t){returnthis.invokeMethod("Element.getHTML",t)}asyncgetAttributes(t){returnthis.invokeMethod("Element.getAttributes",t)}asyncgetStyles(t){returnthis.invokeMethod("Element.getStyles",t)}asyncgetDOMProperties(t){returnthis.invokeMethod("Element.getDOMProperties",t)}asyncgetProperties(t){returnthis.invokeMethod("Element.getProperties",t)}asynctap(){returnthis.invokeMethod("Element.tap")}asynctouchstart(t){returnthis.invokeMethod("Element.touchstart",t)}asynctouchmove(t){returnthis.invokeMethod("Element.touchmove",t)}asynctouchend(t){returnthis.invokeMethod("Element.touchend",t)}asynctriggerEvent(t){returnthis.invokeMethod("Element.triggerEvent",t)}asynccallFunction(t){returnthis.invokeMethod("Element.callFunction",t)}asynccallContextMethod(t){returnthis.invokeMethod("Element.callContextMethod",t)}invokeMethod(t,e={}){returne.elementId=this.id,e.pageId=this.pageId,this.nodeId&&(e.nodeId=this.nodeId),this.videoId&&(e.videoId=this.videoId),this.invoke(t,e)}}I([A],q.prototype,"getData",null),I([A],q.prototype,"setData",null),I([A],q.prototype,"callMethod",null),I([x],q.prototype,"getElement",null),I([x],q.prototype,"getElements",null),I([x],q.prototype,"getOffset",null),I([x],q.prototype,"getHTML",null),I([x],q.prototype,"getAttributes",null),I([x],q.prototype,"getStyles",null),I([x],q.prototype,"getDOMProperties",null),I([x],q.prototype,"getProperties",null),I([x],q.prototype,"tap",null),I([x],q.prototype,"touchstart",null),I([x],q.prototype,"touchmove",null),I([x],q.prototype,"touchend",null),I([x],q.prototype,"triggerEvent",null),I([x],q.prototype,"callFunction",null),I([x],q.prototype,"callContextMethod",null);classj{constructor(t,e,n){this.puppet=t,this.id=e.elementId,this.pageId=e.pageId,this.nodeId=e.nodeId||null,this.videoId=e.videoId||null,this.tagName=e.tagName,this.elementMap=n,"body"!==this.tagName&&"page-body"!==this.tagName||(this.tagName="page"),this.api=newq(t,e)}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnj.create(this.puppet,Object.assign({},e,{pageId:this.pageId}),this.elementMap)}catch(t){returnnull}}async$$(t){const{elements:e}=awaitthis.api.getElements({selector:t});returne.map(t=>j.create(this.puppet,Object.assign({},t,{pageId:this.pageId}),this.elementMap))}asyncsize(){const[t,e]=awaitthis.domProperty(["offsetWidth","offsetHeight"]);return{width:t,height:e}}asyncoffset(){returnthis.api.getOffset()}asynctext(){returnthis.domProperty("innerText")}asyncattribute(t){if(!m(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!m(t))throwError("name must be a string");if(this.puppet.checkProperty){lete=this.publicProps;if(e||(this.publicProps=e=awaitthis._property("__propPublic")),!e[t])throwError(`${this.tagName}.${t} not exists`)}returnthis._property(t)}asynchtml(){return(awaitthis.api.getHTML({type:"inner"})).html}asyncouterHtml(){return(awaitthis.api.getHTML({type:"outer"})).html}asyncstyle(t){if(!m(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnawaitthis.touchstart(),awaitv(350),this.touchend()}asynctrigger(t,e){constn={type:t};returnw(e)||(n.detail=e),this.api.triggerEvent(n)}asynctouchstart(t){returnthis.api.touchstart(t)}asynctouchmove(t){returnthis.api.touchmove(t)}asynctouchend(t){returnthis.api.touchend(t)}asyncdomProperty(t){returnC(asynct=>(awaitthis.api.getDOMProperties({names:t})).properties,t)}_property(t){returnC(asynct=>(awaitthis.api.getProperties({names:t})).properties,t)}send(t,e){returne.elementId=this.id,e.pageId=this.pageId,this.nodeId&&(e.nodeId=this.nodeId),this.videoId&&(e.videoId=this.videoId),this.puppet.send(t,e)}asynccallFunction(t,...e){return(awaitthis.api.callFunction({functionName:t,args:e})).result}staticcreate(t,e,n){lets,i=n.get(e.elementId);if(i)returni;if(e.nodeId)s=S;elseswitch(e.tagName){case"input":s=$;break;case"textarea":s=F;break;case"scroll-view":s=O;break;case"swiper":s=L;break;case"movable-view":s=U;break;case"switch":s=N;break;case"slider":s=H;break;case"video":s=B;break;default:s=j}returni=news(t,e,n),n.set(e.elementId,i),i}}classSextendsj{asyncsetData(t){returnthis.api.setData({data:t})}asyncdata(t){conste={};returnt&&(e.path=t),(awaitthis.api.getData(e)).data}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}}class$extendsj{asyncinput(t){returnthis.callFunction("input.input",t)}}classFextendsj{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classOextendsj{asyncscrollTo(t,e){returnthis.callFunction("scroll-view.scrollTo",t,e)}asyncproperty(t){return"scrollTop"===t?this.callFunction("scroll-view.scrollTop"):"scrollLeft"===t?this.callFunction("scroll-view.scrollLeft"):super.property(t)}asyncscrollWidth(){returnthis.callFunction("scroll-view.scrollWidth")}asyncscrollHeight(){returnthis.callFunction("scroll-view.scrollHeight")}}classLextendsj{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classUextendsj{asyncmoveTo(t,e){returnthis.callFunction("movable-view.moveTo",t,e)}asyncproperty(t){return"x"===t?this._property("_translateX"):"y"===t?this._property("_translateY"):super.property(t)}}classNextendsj{asynctap(){returnthis.callFunction("switch.tap")}}classHextendsj{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classBextendsj{asynccallContextMethod(t,...e){returnthis.api.callContextMethod({method:t,args:e})}}class_extendsR{constructor(t,e){super(t),this.id=e.id}asyncgetData(t){returnthis.invokeMethod("Page.getData",t)}asyncsetData(t){returnthis.invokeMethod("Page.setData",t)}asynccallMethod(t){returnthis.invokeMethod("Page.callMethod",t)}asyncgetElement(t){returnthis.invokeMethod("Page.getElement",t)}asyncgetElements(t){returnthis.invokeMethod("Page.getElements",t)}asyncgetWindowProperties(t){returnthis.invokeMethod("Page.getWindowProperties",t)}invokeMethod(t,e={}){returne.pageId=this.id,this.invoke(t,e)}}I([A],_.prototype,"getData",null),I([A],_.prototype,"setData",null),I([A],_.prototype,"callMethod",null),I([x],_.prototype,"getElement",null),I([x],_.prototype,"getElements",null),I([x],_.prototype,"getWindowProperties",null);classW{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=new_(t,e)}asyncwaitFor(t){returny(t)?awaitv(t):h(t)?l(t):m(t)?l(async()=>(awaitthis.$$(t)).length>0):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnj.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap)}catch(t){returnnull}}async$$(t){const{elements:e}=awaitthis.api.getElements({selector:t});returne.map(e=>j.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap))}asyncdata(t){conste={};returnt&&(e.path=t),(awaitthis.api.getData(e)).data}asyncsetData(t){returnthis.api.setData({data:t})}asyncsize(){const[t,e]=awaitthis.windowProperty(["document.documentElement.scrollWidth","document.documentElement.scrollHeight"]);return{width:t,height:e}}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}asyncscrollTop(){returnthis.windowProperty("document.documentElement.scrollTop")}asyncwindowProperty(t){conste=m(t);e&&(t=[t]);const{properties:n}=awaitthis.api.getWindowProperties({names:t});returne?n[0]:n}staticcreate(t,e,n){lets=n.get(e.id);returns||(s=newW(t,e),n.set(e.id,s),s)}}classVextendsR{asyncgetPageStack(){returnthis.invoke("App.getPageStack")}asynccallUniMethod(t){returnthis.invoke("App.callUniMethod",t)}asyncgetCurrentPage(){returnthis.invoke("App.getCurrentPage")}asyncmockUniMethod(t){returnthis.invoke("App.mockUniMethod",t)}asynccallFunction(t){returnthis.invoke("App.callFunction",t)}asynccaptureScreenshot(t){returnthis.invoke("App.captureScreenshot",t)}asyncexit(){returnthis.invoke("App.exit")}asyncaddBinding(t){returnthis.invoke("App.addBinding",t)}asyncenableLog(){returnthis.invoke("App.enableLog")}onLogAdded(t){returnthis.on("App.logAdded",t)}onBindingCalled(t){returnthis.on("App.bindingCalled",t)}onExceptionThrown(t){returnthis.on("App.exceptionThrown",t)}}I([A],V.prototype,"getPageStack",null),I([A],V.prototype,"callUniMethod",null),I([A],V.prototype,"getCurrentPage",null),I([x],V.prototype,"mockUniMethod",null),I([x],V.prototype,"callFunction",null),I([x],V.prototype,"captureScreenshot",null),I([x],V.prototype,"exit",null),I([x],V.prototype,"addBinding",null),I([x],V.prototype,"enableLog",null);classzextendsR{asyncgetInfo(){returnthis.invoke("Tool.getInfo")}asyncenableRemoteDebug(t){returnthis.invoke("Tool.enableRemoteDebug")}asyncclose(){returnthis.invoke("Tool.close")}asyncgetTestAccounts(){returnthis.invoke("Tool.getTestAccounts")}onRemoteDebugConnected(t){this.puppet.once("Tool.onRemoteDebugConnected",t),this.puppet.once("Tool.onPreviewConnected",t)}}functionG(t){returnnewPromise(e=>setTimeout(e,t))}I([x],z.prototype,"getInfo",null),I([x],z.prototype,"enableRemoteDebug",null),I([x],z.prototype,"close",null),I([x],z.prototype,"getTestAccounts",null);classJextendsr.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newV(t),this.toolApi=newz(t),this.appApi.onLogAdded(t=>{this.emit("console",t)}),this.appApi.onBindingCalled(({name:t,args:e})=>{try{constn=this.appBindings.get(t);n&&n(...e)}catch(t){}}),this.appApi.onExceptionThrown(t=>{this.emit("exception",t)})}asyncpageStack(){return(awaitthis.appApi.getPageStack()).pageStack.map(t=>W.create(this.puppet,t,this.pageMap))}asyncnavigateTo(t){returnthis.changeRoute("navigateTo",t)}asyncredirectTo(t){returnthis.changeRoute("redirectTo",t)}asyncnavigateBack(){returnthis.changeRoute("navigateBack")}asyncreLaunch(t){returnthis.changeRoute("reLaunch",t)}asyncswitchTab(t){returnthis.changeRoute("switchTab",t)}asynccurrentPage(){const{id:t,path:e,query:n}=awaitthis.appApi.getCurrentPage();returnW.create(this.puppet,{id:t,path:e,query:n},this.pageMap)}asyncsystemInfo(){returnthis.callUniMethod("getSystemInfoSync")}asynccallUniMethod(t,...e){return(awaitthis.appApi.callUniMethod({method:t,args:e})).result}asyncmockUniMethod(t,e,...n){returnh(e)||m(s=e)&&(s=d(s),g(s,"function")||g(s,"() =>"))?this.appApi.mockUniMethod({method:t,functionDeclaration:e.toString(),args:n}):this.appApi.mockUniMethod({method:t,result:e});vars}asyncrestoreUniMethod(t){returnthis.appApi.mockUniMethod({method:t})}asyncevaluate(t,...e){return(awaitthis.appApi.callFunction({functionDeclaration:t.toString(),args:e})).result}asyncpageScrollTo(t){awaitthis.callUniMethod("pageScrollTo",{scrollTop:t,duration:0})}asyncclose(){try{awaitthis.appApi.exit()}catch(t){}awaitG(1e3),this.puppet.disposeRuntimeServer(),awaitthis.toolApi.close(),this.disconnect()}asyncteardown(){returnthis["disconnect"===this.options.teardown?"disconnect":"close"]()}asyncremote(t){if(!this.puppet.devtools.remote)returnconsole.warn(`Failed to enable remote, ${this.puppet.devtools.name} is unimplemented`);const{qrCode:e}=awaitthis.toolApi.enableRemoteDebug({auto:t});varn;e&&await(n=e,newPromise(t=>{b.generate(n,{small:!0},e=>{process.stdout.write(e),t()})}));consts=newPromise(t=>{this.toolApi.onRemoteDebugConnected(async()=>{awaitG(1e3),t()})}),i=newPromise(t=>{this.puppet.setRemoteRuntimeConnectionCallback(()=>{t()})});returnPromise.all([s,i])}disconnect(){this.puppet.dispose()}on(t,e){return"console"===t&&this.appApi.enableLog(),super.on(t,e),this}asyncexposeFunction(t,e){if(this.appBindings.has(t))throwError(`Failed to expose function with name ${t}: already exists!`);this.appBindings.set(t,e),awaitthis.appApi.addBinding({name:t})}asynccheckVersion(){}asyncscreenshot(t){const{data:e}=awaitthis.appApi.captureScreenshot({fullPage:null==t?void0:t.fullPage});if(!(null==t?void0:t.path))returne;awaitu.writeFile(t.path,e,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),awaitG(3e3),this.currentPage()}}classX{constructor(t){this.options=t}has(t){return!!this.options[t]}send(t,e,n){consts=this.options[e];if(!s)returnPromise.reject(Error(`adapter for ${e} not found`));consti=s.reflect;returni?(s.params&&(n=s.params(n)),"function"==typeofi?i(t.send.bind(t),n):(e=i,t.send(e,n))):Promise.reject(Error(e+"'s reflect is required"))}}classYextendsr.EventEmitter{constructor(t,e){if(super(),this.target=e||("h5"===t?require("@dcloudio/uni-h5/lib/h5/uni.automator.js"):require(`@dcloudio/uni-${t}/lib/uni.automator.js`)),!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newX(this.target.adapter||{})}setCompiler(t){this.compiler=t}setRuntimeServer(t){this.wss=t}setRemoteRuntimeConnectionCallback(t){this.remoteRuntimeConnectionCallback=t}setRuntimeConnection(t){this.runtimeConnection=t,this.remoteRuntimeConnectionCallback&&(this.remoteRuntimeConnectionCallback(),this.remoteRuntimeConnectionCallback=null)}setDevtoolConnection(t){this.devtoolConnection=t}disposeRuntimeServer(){this.wss&&this.wss.close()}disposeRuntime(){this.runtimeConnection.dispose()}disposeDevtool(){this.compiler&&this.compiler.stop(),this.devtoolConnection&&this.devtoolConnection.dispose()}dispose(){this.disposeRuntime(),this.disposeDevtool(),this.disposeRuntimeServer()}send(t,e){returnthis.runtimeConnection.send(t,e)}validateProject(t){consts=this.target.devtools.required;return!s||!s.find(s=>!e.existsSync(n.join(t,s)))}validateDevtools(t){conste=this.target.devtools.validate;returne?e(t,this):Promise.resolve(t)}createDevtools(t,e,n){consts=this.target.devtools.create;returns?(e.timeout=n,s(t,e,this)):Promise.resolve()}shouldCompile(t,e){this.compiled=!0;constn=this.target.shouldCompile;returnthis.compiled=n?n(t,e):!1!==t.compile,this.compiled}getcheckProperty(){return"mp-weixin"===this.platform}getdevtools(){returnthis.target.devtools}getmode(){constt=this.target.mode;returnt||("production"===process.env.NODE_ENV?"build":"dev")}}constK=s("automator:compiler"),Q=/The\s+(.*)\s+directory is ready/;classZ{constructor(t){this.puppet=t,this.puppet.setCompiler(this)}compile(t){conste=this.puppet.mode,s=this.puppet.platform;leti=t.silent;consto=t.port,r=t.host,a=process.env.UNI_NPM_PATH||"npm",c=`${e}:${s}`,p=t.projectPath,l=["run",c,"--","--auto-port",P(o)];r&&(l.push("--auto-host"),l.push(r));constu={cwd:t.cliPath||t.projectPath,env:process.env};leth;returnnewPromise((t,o)=>{constr=o=>{constr=o.toString().trim();if(!i&&console.log(r),r.includes("- Network:")&&(h=r.match(/Network:(.*)/)[1].trim()),r.includes("App running at:"))K("url: "+h),t({path:h});elseif(r.includes("DONE Build complete")){leto=`unpackage/dist/${e}/${s}`;consta=r.match(Q);a&&a.length>1&&(o=a[1]),i=!0,this.stop(),t({path:n.join(p,o)})}};K(`${a}${l.join("")}`),this.cliProcess=M.spawn(a,l,u),this.cliProcess.on("error",t=>{o(t)}),this.cliProcess.stdout.on("data",r),this.cliProcess.stderr.on("data",r)})}stop(){this.cliProcess&&this.cliProcess.kill("SIGTERM")}}classtt{asynclaunch(t){lete=t[t.platform]||{};this.puppet=newY(t.platform,e.puppet);const{port:n,cliPath:i,timeout:o,projectPath:r}=awaitthis.validate(t);e=awaitthis.puppet.validateDevtools(e);leta=r;if(this.puppet.shouldCompile(t,e)){this.compiler=newZ(this.puppet);conste=awaitthis.compiler.compile({host:t.host,port:n,cliPath:i,projectPath:r,silent:!!t.silent});e.path&&(a=e.path)}constc=[];returnc.push(this.createRuntimeConnection(n,o)),c.push(this.puppet.createDevtools(a,e,o)),newPromise((t,n)=>{Promise.all(c).then(([n,i])=>{n&&this.puppet.setRuntimeConnection(n),i&&this.puppet.setDevtoolConnection(i),s("automator:program")("ready");consto=e.teardown||"disconnect";t(newJ(this.puppet,{teardown:o}))}).catch(t=>n(t))})}resolveCliPath(t){if(!t)returnt;try{conste=require(n.join(t,"package.json"));if(e.devDependencies&&e.devDependencies["@dcloudio/vue-cli-plugin-uni"])returnt}catch(t){}throwError(`Cli ${t} doesn't exist`)}resolveProjectPath(t,s){if(t||(t=process.cwd()),i(t)&&(t=n.resolve(t)),e.existsSync(t)||function(t){throwError(t)}(`Project path ${t} doesn't exist`),!1===s.compile&&!this.puppet.validateProject(t)){conste=n.join(t,"dist/"+this.puppet.mode+"/"+this.puppet.platform);if(this.puppet.validateProject(e))returne;s.compile=!0}returnt}asyncvalidate(t){conste=this.resolveProjectPath(t.projectPath,t);letn=t.cliPath;return!1!==t.compile&&(n=this.resolveCliPath(t.cliPath||""),!n&&(n=this.resolveCliPath(e))),{port:awaitasyncfunction(t,e){constn=awaitf(t||e);if(t&&n!==t)throwError(`Port ${t} is in use, please specify another port`);returnn}(t.port||9520),cliPath:n,timeout:t.timeout||1e5,projectPath:e}}asynccreateRuntimeConnection(t,e){returnE.createRuntimeConnection(t,this.puppet,e)}}module.exports=class{constructor(){this.launcher=newtt}asynclaunch(t){returnthis.launcher.launch(t)}};