@@ -12,4 +12,4 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */functionit(t,e,n,s){varo,i=arguments.length,r=i<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--)(o=t[a])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);returni>3&&r&&Object.defineProperty(e,n,r),r}varrt;functionat(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionct(t,e,n){returnat(rt.RUNTIME,n)}functionpt(t,e,n){returnat(rt.DEVTOOL,n)}/^win/.test(process.platform),function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(rt||(rt={}));classlt{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===rt.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classutextendslt{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")}asynclongpress(){returnthis.invokeMethod("Element.longpress")}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)}}it([ct],ut.prototype,"getData",null),it([ct],ut.prototype,"setData",null),it([ct],ut.prototype,"callMethod",null),it([pt],ut.prototype,"getElement",null),it([pt],ut.prototype,"getElements",null),it([pt],ut.prototype,"getOffset",null),it([pt],ut.prototype,"getHTML",null),it([pt],ut.prototype,"getAttributes",null),it([pt],ut.prototype,"getStyles",null),it([pt],ut.prototype,"getDOMProperties",null),it([pt],ut.prototype,"getProperties",null),it([pt],ut.prototype,"tap",null),it([pt],ut.prototype,"longpress",null),it([pt],ut.prototype,"touchstart",null),it([pt],ut.prototype,"touchmove",null),it([pt],ut.prototype,"touchend",null),it([pt],ut.prototype,"triggerEvent",null),it([pt],ut.prototype,"callFunction",null),it([pt],ut.prototype,"callContextMethod",null);constht=Object.prototype.hasOwnProperty,dt=Array.isArray,mt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongt(t,e){if(dt(t))returnt;if(e&&(n=e,s=t,ht.call(n,s)))return[t];varn,s;consto=[];returnt.replace(mt,(function(t,e,n,s){returno.push(n?s.replace(/\\(\\)?/g,"$1"):e||t),s})),o}functionyt(t,e){constn=gt(e,t);lets;for(s=n.shift();null!=s;){if(null==(t=t[s]))return;s=n.shift()}returnt}constft=require("util");classvt{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.nvue=e.nvue,this.elementMap=n,"body"!==this.tagName&&"page-body"!==this.tagName||(this.tagName="page"),this.api=newut(t,e)}toJSON(){returnJSON.stringify({id:this.id,tagName:this.tagName,pageId:this.pageId,nodeId:this.nodeId,videoId:this.videoId})}toString(){returnthis.toJSON()}[ft.inspect.custom](){returnthis.toJSON()}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnvt.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=>vt.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(){const{left:t,top:e}=awaitthis.api.getOffset();return{left:t,top:e}}asynctext(){returnthis.domProperty("innerText")}asyncattribute(t){if(!q.default(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!q.default(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(!q.default(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnthis.nvue||"true"===process.env.UNI_APP_X?this.api.longpress():(awaitthis.touchstart(),awaitW.default(350),this.touchend())}asynctrigger(t,e){constn={type:t};returnB.default(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){returnst((asynct=>(awaitthis.api.getDOMProperties({names:t})).properties),t)}_property(t){returnst((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,o=n.get(e.elementId);if(o)returno;if(e.nodeId)s=wt;elseswitch(e.tagName.toLowerCase()){case"input":s=Pt;break;case"textarea":s=Mt;break;case"scroll-view":s=kt;break;case"swiper":s=Et;break;case"movable-view":s=It;break;case"switch":s=bt;break;case"slider":s=Ct;break;case"video":s=At;break;default:s=vt}returno=news(t,e,n),n.set(e.elementId,o),o}}classwtextendsvt{asyncsetData(t){returnthis.api.setData({data:t})}asyncdata(t){conste={};if(t&&(e.path=t),"true"!==process.env.UNI_APP_X)return(awaitthis.api.getData(e)).data;constn=(awaitthis.api.getData(e)).data;returnt?yt(n,t):n}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}}classPtextendsvt{asyncinput(t){returnthis.callFunction("input.input",t)}}classMtextendsvt{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classktextendsvt{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")}}classEtextendsvt{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classItextendsvt{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)}}classbtextendsvt{asynctap(){returnthis.callFunction("switch.tap")}}classCtextendsvt{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classAtextendsvt{asynccallContextMethod(t,...e){returnawaitthis.api.callContextMethod({method:t,args:e})}}classStextendslt{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)}asynccallMethodWithCallback(t){returnthis.invokeMethod("Page.callMethodWithCallback",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)}}it([ct],St.prototype,"getData",null),it([ct],St.prototype,"setData",null),it([ct],St.prototype,"callMethod",null),it([ct],St.prototype,"callMethodWithCallback",null),it([pt],St.prototype,"getElement",null),it([pt],St.prototype,"getElements",null),it([pt],St.prototype,"getWindowProperties",null);constTt=require("util");classDt{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=newSt(t,e)}toJSON(){returnJSON.stringify({id:this.id,path:this.path,query:this.query})}toString(){returnthis.toJSON()}[Tt.inspect.custom](){returnthis.toJSON()}asyncwaitFor(t){returnF.default(t)?awaitW.default(t):x.default(t)?O.default(t):q.default(t)?O.default((async()=>(awaitthis.$$(t)).length>0)):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnvt.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=>vt.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap)))}asyncdata(t){conste={};if(t&&(e.path=t),"true"!==process.env.UNI_APP_X)return(awaitthis.api.getData(e)).data;constn=(awaitthis.api.getData(e)).data;returnt?yt(n,t):n}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}asynccallMethodWithCallback(t,...e){returnawaitthis.api.callMethodWithCallback({method:t,args:e})}asyncscrollTop(){returnthis.windowProperty("document.documentElement.scrollTop")}asyncwindowProperty(t){conste=q.default(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.query=e.query,s):(s=newDt(t,e),n.set(e.id,s),s)}}classNtextendslt{asyncgetPageStack(){returnthis.invoke("App.getPageStack")}asynccallUniMethod(t){returnthis.invoke("App.callUniMethod",t)}asyncgetCurrentPage(){returnthis.invoke("App.getCurrentPage")}asyncmockUniMethod(t){returnthis.invoke("App.mockUniMethod",t)}asynccaptureScreenshotByRuntime(t){returnthis.invoke("App.captureScreenshot",t)}asynccaptureScreenshotWithADBByRuntime(t){returnthis.invoke("App.captureScreenshotWithADB",t)}asyncsocketEmitter(t){returnthis.invoke("App.socketEmitter",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)}}it([ct],Nt.prototype,"getPageStack",null),it([ct],Nt.prototype,"callUniMethod",null),it([ct],Nt.prototype,"getCurrentPage",null),it([ct],Nt.prototype,"mockUniMethod",null),it([ct],Nt.prototype,"captureScreenshotByRuntime",null),it([ct],Nt.prototype,"captureScreenshotWithADBByRuntime",null),it([ct],Nt.prototype,"socketEmitter",null),it([pt],Nt.prototype,"callFunction",null),it([pt],Nt.prototype,"captureScreenshot",null),it([pt],Nt.prototype,"exit",null),it([pt],Nt.prototype,"addBinding",null),it([pt],Nt.prototype,"enableLog",null);classUtextendslt{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)}}function_t(t){returnnewPromise((e=>setTimeout(e,t)))}it([pt],Ut.prototype,"getInfo",null),it([pt],Ut.prototype,"enableRemoteDebug",null),it([pt],Ut.prototype,"close",null),it([pt],Ut.prototype,"getTestAccounts",null);classRtextendsa.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newNt(t),this.toolApi=newUt(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=>Dt.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();returnDt.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){returnx.default(e)||(s=e,q.default(s)&&(s=$.default(s),L.default(s,"function")||L.default(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){}await_t(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=>{V.default.generate(n,{small:!0},(e=>{process.stdout.write(e),t(void0)}))})));consts=newPromise((t=>{this.toolApi.onRemoteDebugConnected((async()=>{await_t(1e3),t(void0)}))})),o=newPromise((t=>{this.puppet.setRemoteRuntimeConnectionCallback((()=>{t(void0)}))}));returnPromise.all([s,o])}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){conste=this.puppet.isX&&"app-plus"===this.puppet.platform?(null==t?void0:t.adb)?"captureScreenshotWithADBByRuntime":"captureScreenshotByRuntime":"captureScreenshot",{data:n}=awaitthis.appApi[e]({fullPage:null==t?void0:t.fullPage,area:null==t?void0:t.area});if(!(null==t?void0:t.path))returnn;awaitj.default.writeFile(t.path,n,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),await_t(3e3),this.currentPage()}asyncsocketEmitter(t){returnthis.appApi.socketEmitter(t)}}classOt{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`));consto=s.reflect;returno?(s.params&&(n=s.params(n)),"function"==typeofo?o(t.send.bind(t),n):(e=o,t.send(e,n))):Promise.reject(Error(`${e}'s reflect is required`))}}constjt=T.default("automator:puppet"),xt=".automator.json";function$t(t){try{returnrequire(t)}catch(t){}}functionqt(t,e,n,s){consto=function(t,e,n){lets,o;returnprocess.env.UNI_OUTPUT_DIR?(o=S.default.join(process.env.UNI_OUTPUT_DIR,`../.automator/${e}`,xt),s=$t(o)):(o=S.default.join(t,`dist/${n}/.automator/${e}`,xt),s=$t(o),s||(o=S.default.join(t,`unpackage/dist/${n}/.automator/${e}`,xt),s=$t(o))),jt(`${o}=>${JSON.stringify(s)}`),s}(t,n,s);if(!o||!o.wsEndpoint)return!1;consti=require("../package.json").version;if(o.version!==i)returnjt(`unmet=>${o.version}!==${i}`),!1;constr=function(t){lete;try{constt=X.default.v4.sync();e=H.default.ip(t&&t.interface),e&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(e)||(e=void0))}catch(t){}return"ws://"+(e||"localhost")+":"+t}(e);returnjt(`wsEndpoint=>${r}`),o.wsEndpoint===r}classLtextendsa.EventEmitter{constructor(t,e){if(super(),this.isX=!1,"true"===process.env.UNI_APP_X&&(this.isX=!0),e)this.target=e;else{if(this.target=null,"h5"===t)try{this.target=ot("@dcloudio/uni-h5/lib/h5/uni.automator.js")}catch(t){}this.target||(this.target=ot(`@dcloudio/uni-${"app"===t?"app-plus":t}/lib/uni.automator.js`))}if(!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newOt(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){conste=this.target.devtools.required;return!e||!e.find((e=>!A.default.existsSync(S.default.join(t,e))))}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,n,s){this.compiled=!0;consto=this.target.shouldCompile;returno?this.compiled=o(n,s):!0===n.compile?this.compiled=!0:this.compiled=!qt(t,e,this.platform,this.mode),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")}}constFt=T.default("automator:compiler"),Wt=/The\s+(.*)\s+directory is ready/;classBt{constructor(t){this.puppet=t,this.puppet.setCompiler(this)}compile(t){conste=this.puppet.mode,n=this.puppet.platform;lets=t.silent;consto=t.port,i=t.host,r=`${e}:${n}`,a=t.projectPath,[c,p]=this.getSpawnArgs(t,r);p.push("--auto-port"),p.push(G.default(o)),i&&(p.push("--auto-host"),p.push(i));constl={cwd:t.cliPath,env:Object.assign(Object.assign({},process.env),{NODE_ENV:"build"===e?"production":"development"})};returnnewPromise(((t,o)=>{consti=i=>{constr=i.toString().trim();if(!s&&console.log(r),r.includes("- Network")||r.includes("> Network")||r.includes("➜ Network")){conste=r.match(/Network:(.*)/)[1].trim();Ft(`url: ${e}`),t({path:e})}elseif(r.includes("DONE Build failed"))o(r);elseif(r.includes("DONE Build complete")){consto=r.match(Wt);leti="";if(o&&o.length>1)i=S.default.join(a,o[1]);else{constt=this.puppet.isX&&"app-plus"===n?"app":n;i=S.default.join(a,`dist/${e}/${t}`),A.default.existsSync(i)||(i=S.default.join(a,`unpackage/dist/${e}/${t}`))}s=!0,this.stop(),t({path:i})}};Ft(`${c}${p.join("")} %o`,l),this.cliProcess=I.spawn(c,p,l),this.cliProcess.on("error",(t=>{o(t)})),this.cliProcess.stdout.on("data",i),this.cliProcess.stderr.on("data",i)}))}stop(){this.cliProcess&&this.cliProcess.kill("SIGTERM")}getSpawnArgs(t,e){letn;consts=t.cliPath;try{n=require(S.default.join(s,"package.json"))}catch(t){}leto=this.puppet.isX;if(n&&(n.devDependencies&&n.devDependencies["@dcloudio/vite-plugin-uni"]&&(o=!0),!o&&n.dependencies&&n.dependencies["@dcloudio/vite-plugin-uni"]&&(o=!0),n.scripts&&n.scripts[e]))return[process.env.UNI_NPM_PATH||(/^win/.test(process.platform)?"npm.cmd":"npm"),["run",e,"--"]];["android","ios"].includes(process.env.UNI_OS_NAME)&&(process.env.UNI_APP_PLATFORM=process.env.UNI_OS_NAME);leti=this.puppet.platform;if("app-plus"===this.puppet.platform&&this.puppet.isX&&(i="app"),process.env.UNI_INPUT_DIR=t.projectPath,process.env.UNI_OUTPUT_DIR=S.default.join(t.projectPath,`unpackage/dist/${this.puppet.mode}/${i}`),process.env.UNI_HBUILDERX_PLUGINS||A.default.existsSync(S.default.resolve(s,"../about"))&&(process.env.UNI_HBUILDERX_PLUGINS=S.default.dirname(s)),o){constt="app-plus"===this.puppet.platform?"app":this.puppet.platform;returnprocess.env.UNI_PLATFORM=t,[process.env.UNI_NODE_PATH||"node",[require.resolve("@dcloudio/vite-plugin-uni/bin/uni.js",{paths:[s]}),"-p",t]]}return[process.env.UNI_NODE_PATH||"node",[S.default.join(s,"bin/uniapp-cli.js")]]}}constHt=T.default("automator:launcher");classXt{asynclaunch(t){const{port:e,cliPath:n,timeout:o,projectPath:i}=awaitthis.validate(t);letr={};"app"===t.platform||"app-plus"===t.platform?(r=t.app||t["app-plus"],"true"===process.env.UNI_APP_X&&r["uni-app-x"]&&(r=s.recursive(!0,r,r["uni-app-x"])),deleter["uni-app-x"]):r=t[t.platform],r||(r={}),r.projectPath=i,Ht(r),this.puppet=newLt(t.platform,r.puppet),r=awaitthis.puppet.validateDevtools(r);leta=this.puppet.shouldCompile(i,e,t,r),c=process.env.UNI_OUTPUT_DIR||i;if(a||this.puppet.validateProject(c)||(c=S.default.join(i,"dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(c)||(c=S.default.join(i,"unpackage/dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(c)||(a=!0))),a){this.puppet.compiled=t.compile=!0,this.compiler=newBt(this.puppet);consts=awaitthis.compiler.compile({host:t.host,port:e,cliPath:n,projectPath:i,silent:!!t.silent});s.path&&(c=s.path)}constp=[];returnp.push(this.createRuntimeConnection(e,o)),p.push(this.puppet.createDevtools(c,r,o)),newPromise(((t,n)=>{Promise.all(p).then((([n,s])=>{n&&this.puppet.setRuntimeConnection(n),s&&this.puppet.setDevtoolConnection(s),T.default("automator:program")("ready");consto=r.teardown||"disconnect";t(newRt(this.puppet,{teardown:o,port:e}))})).catch((t=>n(t)))}))}resolveCliPath(t){if(!t)returnt;try{const{dependencies:e,devDependencies:n}=require(S.default.join(t,"package.json"));if(Jt(n)||Jt(e))returnt}catch(t){}}resolveProjectPath(t,e){returnt||(t=process.env.UNI_INPUT_DIR||process.cwd()),D.default(t)&&(t=S.default.resolve(t)),A.default.existsSync(t)||function(t){throwError(t)}(`Project path ${t} doesn't exist`),t}asyncvalidate(t){conste=this.resolveProjectPath(t.projectPath,t);letn=process.env.UNI_CLI_PATH||t.cliPath;if(n=this.resolveCliPath(n||""),!n&&(n=this.resolveCliPath(process.cwd())),!n&&(n=this.resolveCliPath(e)),!n)throwError("cliPath is not provided");if("false"!==process.env.UNI_APP_X){constt=this.getManifestJson(e);"uni-app-x"int&&(process.env.UNI_APP_X="true",t.appid&&(process.env.UNI_APP_ID=t.appid))}process.env.UNI_AUTOMATOR_PORT&&(t.port=parseInt(process.env.UNI_AUTOMATOR_PORT));return{port:awaitasyncfunction(t,e){constn=awaitJ.default(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||6e5,projectPath:e}}getManifestJson(t){if(t){conste=S.default.join(t,"manifest.json");if(A.default.existsSync(e))returno.parse(A.default.readFileSync(e,"utf8"))}return{}}asynccreateRuntimeConnection(t,e){returnnt.createRuntimeConnection(t,this.puppet,e)}}functionJt(t){return!!t&&!(!t["@dcloudio/vue-cli-plugin-uni"]&&!t["@dcloudio/vite-plugin-uni"])}exports.default=class{constructor(){this.launcher=newXt}asynclaunch(t){returnthis.launcher.launch(t)}},exports.initUni=t=>newProxy({},{get(e,n){return"connectSocket"===n?async(...e)=>{consts=`${Date.now()}-${Math.random()}`;returne[0].id=s,awaitt.callUniMethod(n,...e).then((n=>{Z(e[0],n),Q.set(s,newMap);consto={id:s,onMessage:e=>{t.socketEmitter({id:s,method:"onMessage"}),Q.get(s).set("onMessage",e)},send:e=>{t.socketEmitter({id:s,method:"send",data:e.data}).then((t=>{Z(e,t)})).catch((t=>{tt(e,t)}))},close:e=>{t.socketEmitter({id:s,method:"close",code:e.code,reason:e.reason}).then((t=>{Z(e,t),Q.delete(s)})).catch((t=>{tt(e,t)}))},onOpen:e=>{t.socketEmitter({id:s,method:"onOpen"}),Q.get(s).set("onOpen",e)},onClose:e=>{t.socketEmitter({id:s,method:"onClose"}),Q.get(s).set("onClose",e)},onError:e=>{t.socketEmitter({id:s,method:"onError"}),Q.get(s).set("onError",e)}};returnQ.get(s).set("socketTask",o),o})).catch((t=>(tt(e[0],t),null)))}:(s=n,Y.includes(s)?e=>{K.has(n)||K.set(n,newMap);consts=K.get(n),o=`${Date.now()}-${Math.random()}`;s.set(o,e),t.callUniMethod(n,o)}:function(t){returnt.startsWith("off")&&Y.includes(t.replace("off","on"))}(n)?asynce=>{consts=n.replace("off","on");if(K.has(s))if(e){consto=K.get(s);o.forEach(((s,i)=>{s===e&&(o.delete(i),t.callUniMethod(n,i))}))}elseK.delete(s),t.callUniMethod(n)}:async(...e)=>awaitt.callUniMethod(n,...e).then((t=>(Z(e[0],t),t))).catch((t=>(tt(e[0],t),t))));vars}});
***************************************************************************** */functionit(t,e,n,s){varo,i=arguments.length,r=i<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--)(o=t[a])&&(r=(i<3?o(r):i>3?o(e,n,r):o(e,n))||r);returni>3&&r&&Object.defineProperty(e,n,r),r}varrt;functionat(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionct(t,e,n){returnat(rt.RUNTIME,n)}functionpt(t,e,n){returnat(rt.DEVTOOL,n)}/^win/.test(process.platform),function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(rt||(rt={}));classlt{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===rt.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classutextendslt{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")}asynclongpress(){returnthis.invokeMethod("Element.longpress")}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)}}it([ct],ut.prototype,"getData",null),it([ct],ut.prototype,"setData",null),it([ct],ut.prototype,"callMethod",null),it([pt],ut.prototype,"getElement",null),it([pt],ut.prototype,"getElements",null),it([pt],ut.prototype,"getOffset",null),it([pt],ut.prototype,"getHTML",null),it([pt],ut.prototype,"getAttributes",null),it([pt],ut.prototype,"getStyles",null),it([pt],ut.prototype,"getDOMProperties",null),it([pt],ut.prototype,"getProperties",null),it([pt],ut.prototype,"tap",null),it([pt],ut.prototype,"longpress",null),it([pt],ut.prototype,"touchstart",null),it([pt],ut.prototype,"touchmove",null),it([pt],ut.prototype,"touchend",null),it([pt],ut.prototype,"triggerEvent",null),it([pt],ut.prototype,"callFunction",null),it([pt],ut.prototype,"callContextMethod",null);constht=Object.prototype.hasOwnProperty,dt=Array.isArray,mt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;functiongt(t,e){if(dt(t))returnt;if(e&&(n=e,s=t,ht.call(n,s)))return[t];varn,s;consto=[];returnt.replace(mt,(function(t,e,n,s){returno.push(n?s.replace(/\\(\\)?/g,"$1"):e||t),s})),o}functionyt(t,e){constn=gt(e,t);lets;for(s=n.shift();null!=s;){if(null==(t=t[s]))return;s=n.shift()}returnt}constft=require("util");classvt{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.nvue=e.nvue,this.elementMap=n,"body"!==this.tagName&&"page-body"!==this.tagName||(this.tagName="page"),this.api=newut(t,e)}toJSON(){returnJSON.stringify({id:this.id,tagName:this.tagName,pageId:this.pageId,nodeId:this.nodeId,videoId:this.videoId})}toString(){returnthis.toJSON()}[ft.inspect.custom](){returnthis.toJSON()}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnvt.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=>vt.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(){const{left:t,top:e}=awaitthis.api.getOffset();return{left:t,top:e}}asynctext(){returnthis.domProperty("innerText")}asyncattribute(t){if(!q.default(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!q.default(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(!q.default(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnthis.nvue||"true"===process.env.UNI_APP_X?this.api.longpress():(awaitthis.touchstart(),awaitW.default(350),this.touchend())}asynctrigger(t,e){constn={type:t};returnB.default(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){returnst((asynct=>(awaitthis.api.getDOMProperties({names:t})).properties),t)}_property(t){returnst((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,o=n.get(e.elementId);if(o)returno;if(e.nodeId)s=wt;elseswitch(e.tagName.toLowerCase()){case"input":s=Pt;break;case"textarea":s=Mt;break;case"scroll-view":s=kt;break;case"swiper":s=Et;break;case"movable-view":s=It;break;case"switch":s=bt;break;case"slider":s=Ct;break;case"video":s=At;break;default:s=vt}returno=news(t,e,n),n.set(e.elementId,o),o}}classwtextendsvt{asyncsetData(t){returnthis.api.setData({data:t})}asyncdata(t){conste={};if(t&&(e.path=t),"true"!==process.env.UNI_APP_X)return(awaitthis.api.getData(e)).data;constn=(awaitthis.api.getData(e)).data;returnt?yt(n,t):n}asynccallMethod(t,...e){return(awaitthis.api.callMethod({method:t,args:e})).result}}classPtextendsvt{asyncinput(t){returnthis.callFunction("input.input",t)}}classMtextendsvt{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classktextendsvt{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")}}classEtextendsvt{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classItextendsvt{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)}}classbtextendsvt{asynctap(){returnthis.callFunction("switch.tap")}}classCtextendsvt{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classAtextendsvt{asynccallContextMethod(t,...e){returnawaitthis.api.callContextMethod({method:t,args:e})}}classStextendslt{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)}asynccallMethodWithCallback(t){returnthis.invokeMethod("Page.callMethodWithCallback",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)}}it([ct],St.prototype,"getData",null),it([ct],St.prototype,"setData",null),it([ct],St.prototype,"callMethod",null),it([ct],St.prototype,"callMethodWithCallback",null),it([pt],St.prototype,"getElement",null),it([pt],St.prototype,"getElements",null),it([pt],St.prototype,"getWindowProperties",null);constTt=require("util");classDt{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=newSt(t,e)}toJSON(){returnJSON.stringify({id:this.id,path:this.path,query:this.query})}toString(){returnthis.toJSON()}[Tt.inspect.custom](){returnthis.toJSON()}asyncwaitFor(t){returnF.default(t)?awaitW.default(t):x.default(t)?O.default(t):q.default(t)?O.default((async()=>(awaitthis.$$(t)).length>0)):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnvt.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=>vt.create(this.puppet,Object.assign({selector:t},e,{pageId:this.id}),this.elementMap)))}asyncdata(t){conste={};if(t&&(e.path=t),"true"!==process.env.UNI_APP_X)return(awaitthis.api.getData(e)).data;constn=(awaitthis.api.getData(e)).data;returnt?yt(n,t):n}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}asynccallMethodWithCallback(t,...e){returnawaitthis.api.callMethodWithCallback({method:t,args:e})}asyncscrollTop(){returnthis.windowProperty("document.documentElement.scrollTop")}asyncwindowProperty(t){conste=q.default(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.query=e.query,s):(s=newDt(t,e),n.set(e.id,s),s)}}classNtextendslt{asyncgetPageStack(){returnthis.invoke("App.getPageStack")}asynccallUniMethod(t){returnthis.invoke("App.callUniMethod",t)}asyncgetCurrentPage(){returnthis.invoke("App.getCurrentPage")}asyncmockUniMethod(t){returnthis.invoke("App.mockUniMethod",t)}asynccaptureScreenshotByRuntime(t){returnthis.invoke("App.captureScreenshot",t)}asynccaptureScreenshotWithADBByRuntime(t){returnthis.invoke("App.captureScreenshotWithADB",t)}asyncsocketEmitter(t){returnthis.invoke("App.socketEmitter",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)}}it([ct],Nt.prototype,"getPageStack",null),it([ct],Nt.prototype,"callUniMethod",null),it([ct],Nt.prototype,"getCurrentPage",null),it([ct],Nt.prototype,"mockUniMethod",null),it([ct],Nt.prototype,"captureScreenshotByRuntime",null),it([ct],Nt.prototype,"captureScreenshotWithADBByRuntime",null),it([ct],Nt.prototype,"socketEmitter",null),it([pt],Nt.prototype,"callFunction",null),it([pt],Nt.prototype,"captureScreenshot",null),it([pt],Nt.prototype,"exit",null),it([pt],Nt.prototype,"addBinding",null),it([pt],Nt.prototype,"enableLog",null);classUtextendslt{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)}}function_t(t){returnnewPromise((e=>setTimeout(e,t)))}it([pt],Ut.prototype,"getInfo",null),it([pt],Ut.prototype,"enableRemoteDebug",null),it([pt],Ut.prototype,"close",null),it([pt],Ut.prototype,"getTestAccounts",null);classRtextendsa.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newNt(t),this.toolApi=newUt(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=>Dt.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();returnDt.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){returnx.default(e)||(s=e,q.default(s)&&(s=$.default(s),L.default(s,"function")||L.default(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){}await_t(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=>{V.default.generate(n,{small:!0},(e=>{process.stdout.write(e),t(void0)}))})));consts=newPromise((t=>{this.toolApi.onRemoteDebugConnected((async()=>{await_t(1e3),t(void0)}))})),o=newPromise((t=>{this.puppet.setRemoteRuntimeConnectionCallback((()=>{t(void0)}))}));returnPromise.all([s,o])}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){conste=this.puppet.isX&&"app-plus"===this.puppet.platform?(null==t?void0:t.adb)?"captureScreenshotWithADBByRuntime":"captureScreenshotByRuntime":"captureScreenshot",{data:n}=awaitthis.appApi[e]({fullPage:null==t?void0:t.fullPage,area:null==t?void0:t.area});if(!(null==t?void0:t.path))returnn;awaitj.default.writeFile(t.path,n,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),await_t(3e3),this.currentPage()}asyncsocketEmitter(t){returnthis.appApi.socketEmitter(t)}}classOt{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`));consto=s.reflect;returno?(s.params&&(n=s.params(n)),"function"==typeofo?o(t.send.bind(t),n):(e=o,t.send(e,n))):Promise.reject(Error(`${e}'s reflect is required`))}}constjt=T.default("automator:puppet"),xt=".automator.json";function$t(t){try{returnrequire(t)}catch(t){}}functionqt(t,e,n,s){consto=function(t,e,n){lets,o;returnprocess.env.UNI_OUTPUT_DIR?(o=S.default.join(process.env.UNI_OUTPUT_DIR,`../.automator/${e}`,xt),s=$t(o)):(o=S.default.join(t,`dist/${n}/.automator/${e}`,xt),s=$t(o),s||(o=S.default.join(t,`unpackage/dist/${n}/.automator/${e}`,xt),s=$t(o))),jt(`${o}=>${JSON.stringify(s)}`),s}(t,n,s);if(!o||!o.wsEndpoint)return!1;consti=require("../package.json").version;if(o.version!==i)returnjt(`unmet=>${o.version}!==${i}`),!1;constr=function(t){lete;try{constt=X.default.v4.sync();e=H.default.ip(t&&t.interface),e&&(/^10[.]|^172[.](1[6-9]|2[0-9]|3[0-1])[.]|^192[.]168[.]/.test(e)||(e=void0))}catch(t){}return"ws://"+(e||"localhost")+":"+t}(e);returnjt(`wsEndpoint=>${r}`),o.wsEndpoint===r}classLtextendsa.EventEmitter{constructor(t,e){if(super(),this.isX=!1,"true"===process.env.UNI_APP_X&&(this.isX=!0),e)this.target=e;else{if(this.target=null,"h5"===t)try{this.target=ot("@dcloudio/uni-h5/lib/h5/uni.automator.js")}catch(t){}this.target||(this.target=ot(`@dcloudio/uni-${"app"===t?"app-plus":t}/lib/uni.automator.js`))}if(!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newOt(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){conste=this.target.devtools.required;return!e||!e.find((e=>!A.default.existsSync(S.default.join(t,e))))}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,n,s){this.compiled=!0;consto=this.target.shouldCompile;returno?this.compiled=o(n,s):!0===n.compile?this.compiled=!0:this.compiled=!qt(t,e,this.platform,this.mode),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")}}constFt=T.default("automator:compiler"),Wt=/The\s+(.*)\s+directory is ready/;classBt{constructor(t){this.puppet=t,this.puppet.setCompiler(this)}compile(t){conste=this.puppet.mode,n=this.puppet.platform;lets=t.silent;consto=t.port,i=t.host,r=`${e}:${n}`,a=t.projectPath,[c,p]=this.getSpawnArgs(t,r);p.push("--auto-port"),p.push(G.default(o)),i&&(p.push("--auto-host"),p.push(i));constl={cwd:t.cliPath,env:Object.assign(Object.assign({},process.env),{NODE_ENV:"build"===e?"production":"development"})};returnnewPromise(((t,o)=>{consti=i=>{constr=i.toString().trim();if(!s&&console.log(r),r.includes("- Network")||r.includes("> Network")||r.includes("➜ Network")){conste=r.match(/Network:(.*)/)[1].trim();Ft(`url: ${e}`),t({path:e})}elseif(r.includes("DONE Build failed"))o(r);elseif(r.includes("DONE Build complete")){consto=r.match(Wt);leti="";if(o&&o.length>1)i=S.default.join(a,o[1]);else{constt=this.puppet.isX&&"app-plus"===n?"app":n;i=S.default.join(a,`dist/${e}/${t}`),A.default.existsSync(i)||(i=S.default.join(a,`unpackage/dist/${e}/${t}`))}s=!0,this.stop(),t({path:i})}};Ft(`${c}${p.join("")} %o`,l),this.cliProcess=I.spawn(c,p,l),this.cliProcess.on("error",(t=>{o(t)})),this.cliProcess.stdout.on("data",i),this.cliProcess.stderr.on("data",i)}))}stop(){this.cliProcess&&this.cliProcess.kill("SIGTERM")}getSpawnArgs(t,e){letn;consts=t.cliPath;try{n=require(S.default.join(s,"package.json"))}catch(t){}leto=this.puppet.isX;if(n&&(n.devDependencies&&n.devDependencies["@dcloudio/vite-plugin-uni"]&&(o=!0),!o&&n.dependencies&&n.dependencies["@dcloudio/vite-plugin-uni"]&&(o=!0),n.scripts&&n.scripts[e]))return[process.env.UNI_NPM_PATH||(/^win/.test(process.platform)?"npm.cmd":"npm"),["run",e,"--"]];["android","ios"].includes(process.env.UNI_OS_NAME)&&(process.env.UNI_APP_PLATFORM=process.env.UNI_OS_NAME);leti=this.puppet.platform;if("app-plus"===this.puppet.platform&&this.puppet.isX&&(i="app"),process.env.UNI_INPUT_DIR=t.projectPath,process.env.UNI_OUTPUT_DIR=S.default.join(t.projectPath,`unpackage/dist/${this.puppet.mode}/${i}`),process.env.UNI_HBUILDERX_PLUGINS||A.default.existsSync(S.default.resolve(s,"../about"))&&(process.env.UNI_HBUILDERX_PLUGINS=S.default.dirname(s)),o){constt="app-plus"===this.puppet.platform?"app":this.puppet.platform;returnprocess.env.UNI_PLATFORM=t,[process.env.UNI_NODE_PATH||"node",[require.resolve("@dcloudio/vite-plugin-uni/bin/uni.js",{paths:[s]}),"-p",t]]}return[process.env.UNI_NODE_PATH||"node",[S.default.join(s,"bin/uniapp-cli.js")]]}}constHt=T.default("automator:launcher");classXt{asynclaunch(t){const{port:e,cliPath:n,timeout:o,projectPath:i}=awaitthis.validate(t);letr={};"app"===t.platform||"app-plus"===t.platform?(r=t.app||t["app-plus"],"true"===process.env.UNI_APP_X&&r["uni-app-x"]&&(r=s.recursive(!0,r,r["uni-app-x"])),deleter["uni-app-x"]):r=t[t.platform],r||(r={}),r.projectPath=i,Ht(r),this.puppet=newLt(t.platform,r.puppet),r=awaitthis.puppet.validateDevtools(r);leta=this.puppet.shouldCompile(i,e,t,r),c=process.env.UNI_OUTPUT_DIR||i;if(a||this.puppet.validateProject(c)||(c=S.default.join(i,"dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(c)||(c=S.default.join(i,"unpackage/dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(c)||(a=!0))),a){this.puppet.compiled=t.compile=!0,this.compiler=newBt(this.puppet);consts=awaitthis.compiler.compile({host:t.host,port:e,cliPath:n,projectPath:i,silent:!!t.silent});s.path&&(c=s.path)}constp=[];returnp.push(this.createRuntimeConnection(e,o)),p.push(this.puppet.createDevtools(c,r,o)),newPromise(((t,n)=>{Promise.all(p).then((([n,s])=>{n&&this.puppet.setRuntimeConnection(n),s&&this.puppet.setDevtoolConnection(s),T.default("automator:program")("ready");consto=r.teardown||"disconnect";t(newRt(this.puppet,{teardown:o,port:e}))})).catch((t=>n(t)))}))}resolveCliPath(t){if(!t)returnt;try{const{dependencies:e,devDependencies:n}=require(S.default.join(t,"package.json"));if(Jt(n)||Jt(e))returnt}catch(t){}}resolveProjectPath(t,e){returnt||(t=process.env.UNI_INPUT_DIR||process.cwd()),D.default(t)&&(t=S.default.resolve(t)),A.default.existsSync(t)||function(t){throwError(t)}(`Project path ${t} doesn't exist`),t}asyncvalidate(t){conste=this.resolveProjectPath(t.projectPath,t);letn=process.env.UNI_CLI_PATH||t.cliPath;if(n=this.resolveCliPath(n||""),!n&&(n=this.resolveCliPath(process.cwd())),!n&&(n=this.resolveCliPath(e)),!n)throwError("cliPath is not provided");if("false"!==process.env.UNI_APP_X){constt=this.getManifestJson(e);("true"===process.env.UNI_APP_X||"uni-app-x"int)&&(process.env.UNI_APP_X="true",t.appid&&(process.env.UNI_APP_ID=t.appid))}process.env.UNI_AUTOMATOR_PORT&&(t.port=parseInt(process.env.UNI_AUTOMATOR_PORT));return{port:awaitasyncfunction(t,e){constn=awaitJ.default(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||6e5,projectPath:e}}getManifestJson(t){if(t){conste=S.default.join(t,"manifest.json");if(A.default.existsSync(e))returno.parse(A.default.readFileSync(e,"utf8"))}return{}}asynccreateRuntimeConnection(t,e){returnnt.createRuntimeConnection(t,this.puppet,e)}}functionJt(t){return!!t&&!(!t["@dcloudio/vue-cli-plugin-uni"]&&!t["@dcloudio/vite-plugin-uni"])}exports.default=class{constructor(){this.launcher=newXt}asynclaunch(t){returnthis.launcher.launch(t)}},exports.initUni=t=>newProxy({},{get(e,n){return"connectSocket"===n?async(...e)=>{consts=`${Date.now()}-${Math.random()}`;returne[0].id=s,awaitt.callUniMethod(n,...e).then((n=>{Z(e[0],n),Q.set(s,newMap);consto={id:s,onMessage:e=>{t.socketEmitter({id:s,method:"onMessage"}),Q.get(s).set("onMessage",e)},send:e=>{t.socketEmitter({id:s,method:"send",data:e.data}).then((t=>{Z(e,t)})).catch((t=>{tt(e,t)}))},close:e=>{t.socketEmitter({id:s,method:"close",code:e.code,reason:e.reason}).then((t=>{Z(e,t),Q.delete(s)})).catch((t=>{tt(e,t)}))},onOpen:e=>{t.socketEmitter({id:s,method:"onOpen"}),Q.get(s).set("onOpen",e)},onClose:e=>{t.socketEmitter({id:s,method:"onClose"}),Q.get(s).set("onClose",e)},onError:e=>{t.socketEmitter({id:s,method:"onError"}),Q.get(s).set("onError",e)}};returnQ.get(s).set("socketTask",o),o})).catch((t=>(tt(e[0],t),null)))}:(s=n,Y.includes(s)?e=>{K.has(n)||K.set(n,newMap);consts=K.get(n),o=`${Date.now()}-${Math.random()}`;s.set(o,e),t.callUniMethod(n,o)}:function(t){returnt.startsWith("off")&&Y.includes(t.replace("off","on"))}(n)?asynce=>{consts=n.replace("off","on");if(K.has(s))if(e){consto=K.get(s);o.forEach(((s,i)=>{s===e&&(o.delete(i),t.callUniMethod(n,i))}))}elseK.delete(s),t.callUniMethod(n)}:async(...e)=>awaitt.callUniMethod(n,...e).then((t=>(Z(e[0],t),t))).catch((t=>(tt(e[0],t),t))));vars}});