@@ -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.
***************************************************************************** */functionQ(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}varZ;functiontt(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionet(t,e,n){returntt(Z.RUNTIME,n)}functionnt(t,e,n){returntt(Z.DEVTOOL,n)}/^win/.test(process.platform),function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(Z||(Z={}));classst{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===Z.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classitextendsst{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)}}Q([et],it.prototype,"getData",null),Q([et],it.prototype,"setData",null),Q([et],it.prototype,"callMethod",null),Q([nt],it.prototype,"getElement",null),Q([nt],it.prototype,"getElements",null),Q([nt],it.prototype,"getOffset",null),Q([nt],it.prototype,"getHTML",null),Q([nt],it.prototype,"getAttributes",null),Q([nt],it.prototype,"getStyles",null),Q([nt],it.prototype,"getDOMProperties",null),Q([nt],it.prototype,"getProperties",null),Q([nt],it.prototype,"tap",null),Q([nt],it.prototype,"longpress",null),Q([nt],it.prototype,"touchstart",null),Q([nt],it.prototype,"touchmove",null),Q([nt],it.prototype,"touchend",null),Q([nt],it.prototype,"triggerEvent",null),Q([nt],it.prototype,"callFunction",null),Q([nt],it.prototype,"callContextMethod",null);constot=require("util");classrt{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=newit(t,e)}toJSON(){returnJSON.stringify({id:this.id,tagName:this.tagName,pageId:this.pageId,nodeId:this.nodeId,videoId:this.videoId})}toString(){returnthis.toJSON()}[ot.inspect.custom](){returnthis.toJSON()}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnrt.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=>rt.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(!$.default(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!$.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(!$.default(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnthis.nvue?this.api.longpress():(awaitthis.touchstart(),awaitF.default(350),this.touchend())}asynctrigger(t,e){constn={type:t};returnL.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){returnY((asynct=>(awaitthis.api.getDOMProperties({names:t})).properties),t)}_property(t){returnY((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=at;elseswitch(e.tagName){case"input":s=ct;break;case"textarea":s=pt;break;case"scroll-view":s=lt;break;case"swiper":s=ut;break;case"movable-view":s=ht;break;case"switch":s=dt;break;case"slider":s=mt;break;case"video":s=gt;break;default:s=rt}returni=news(t,e,n),n.set(e.elementId,i),i}}classatextendsrt{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}}classctextendsrt{asyncinput(t){returnthis.callFunction("input.input",t)}}classptextendsrt{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classltextendsrt{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")}}classutextendsrt{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classhtextendsrt{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)}}classdtextendsrt{asynctap(){returnthis.callFunction("switch.tap")}}classmtextendsrt{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classgtextendsrt{asynccallContextMethod(t,...e){returnawaitthis.api.callContextMethod({method:t,args:e})}}classytextendsst{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)}}Q([et],yt.prototype,"getData",null),Q([et],yt.prototype,"setData",null),Q([et],yt.prototype,"callMethod",null),Q([nt],yt.prototype,"getElement",null),Q([nt],yt.prototype,"getElements",null),Q([nt],yt.prototype,"getWindowProperties",null);constvt=require("util");classft{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=newyt(t,e)}toJSON(){returnJSON.stringify({id:this.id,path:this.path,query:this.query})}toString(){returnthis.toJSON()}[vt.inspect.custom](){returnthis.toJSON()}asyncwaitFor(t){return_.default(t)?awaitF.default(t):x.default(t)?S.default(t):$.default(t)?S.default((async()=>(awaitthis.$$(t)).length>0)):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnrt.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=>rt.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=$.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=newft(t,e),n.set(e.id,s),s)}}classwtextendsst{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)}}Q([et],wt.prototype,"getPageStack",null),Q([et],wt.prototype,"callUniMethod",null),Q([et],wt.prototype,"getCurrentPage",null),Q([et],wt.prototype,"mockUniMethod",null),Q([nt],wt.prototype,"callFunction",null),Q([nt],wt.prototype,"captureScreenshot",null),Q([nt],wt.prototype,"exit",null),Q([nt],wt.prototype,"addBinding",null),Q([nt],wt.prototype,"enableLog",null);classPtextendsst{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)}}functionMt(t){returnnewPromise((e=>setTimeout(e,t)))}Q([nt],Pt.prototype,"getInfo",null),Q([nt],Pt.prototype,"enableRemoteDebug",null),Q([nt],Pt.prototype,"close",null),Q([nt],Pt.prototype,"getTestAccounts",null);classktextendso.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newwt(t),this.toolApi=newPt(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=>ft.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();returnft.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,$.default(s)&&(s=O.default(s),U.default(s,"function")||U.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){}awaitMt(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=>{W.default.generate(n,{small:!0},(e=>{process.stdout.write(e),t(void0)}))})));consts=newPromise((t=>{this.toolApi.onRemoteDebugConnected((async()=>{awaitMt(1e3),t(void0)}))})),i=newPromise((t=>{this.puppet.setRemoteRuntimeConnectionCallback((()=>{t(void0)}))}));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;awaitq.default.writeFile(t.path,e,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),awaitMt(3e3),this.currentPage()}}classEt{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`))}}constIt=T.default("automator:puppet"),bt=".automator.json";functionCt(t){try{returnrequire(t)}catch(t){}}functionTt(t,e,n,s){consti=function(t,e,n){lets,i;returnprocess.env.UNI_OUTPUT_DIR?(i=C.default.join(process.env.UNI_OUTPUT_DIR,`../.automator/${e}`,bt),s=Ct(i)):(i=C.default.join(t,`dist/${n}/.automator/${e}`,bt),s=Ct(i),s||(i=C.default.join(t,`unpackage/dist/${n}/.automator/${e}`,bt),s=Ct(i))),It(`${i}=>${JSON.stringify(s)}`),s}(t,n,s);if(!i||!i.wsEndpoint)return!1;consto=require("../package.json").version;if(i.version!==o)returnIt(`unmet=>${i.version}!==${o}`),!1;constr=function(t){lete;try{constt=B.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);returnIt(`wsEndpoint=>${r}`),i.wsEndpoint===r}classDtextendso.EventEmitter{constructor(t,e){if(super(),e)this.target=e;else{if(this.target=null,"h5"===t)try{this.target=K("@dcloudio/uni-h5/lib/h5/uni.automator.js")}catch(t){}this.target||(this.target=K(`@dcloudio/uni-${"app"===t?"app-plus":t}/lib/uni.automator.js`))}if(!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newEt(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=>!b.default.existsSync(C.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;consti=this.target.shouldCompile;returni?this.compiled=i(n,s):!0===n.compile?this.compiled=!0:this.compiled=!Tt(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")}}constAt=T.default("automator:compiler"),Nt=/The\s+(.*)\s+directory is ready/;classjt{constructor(t){this.puppet=t,this.puppet.setCompiler(this)}compile(t){conste=this.puppet.mode,n=this.puppet.platform;lets=t.silent;consti=t.port,o=t.host,r=`${e}:${n}`,a=t.projectPath,[c,p]=this.getSpawnArgs(t,r);p.push("--auto-port"),p.push(V.default(i)),o&&(p.push("--auto-host"),p.push(o));constl={cwd:t.cliPath,env:Object.assign(Object.assign({},process.env),{NODE_ENV:"build"===e?"production":"development"})};returnnewPromise(((t,i)=>{consto=i=>{consto=i.toString().trim();if(!s&&console.log(o),o.includes("- Network")||o.includes("> Network")||o.includes("➜ Network")){conste=o.match(/Network:(.*)/)[1].trim();At(`url: ${e}`),t({path:e})}elseif(o.includes("DONE Build complete")){consti=o.match(Nt);letr="";i&&i.length>1?r=C.default.join(a,i[1]):(r=C.default.join(a,`dist/${e}/${n}`),b.default.existsSync(r)||(r=C.default.join(a,`unpackage/dist/${e}/${n}`))),s=!0,this.stop(),t({path:r})}};At(`${c}${p.join("")} %o`,l),this.cliProcess=k.spawn(c,p,l),this.cliProcess.on("error",(t=>{i(t)})),this.cliProcess.stdout.on("data",o),this.cliProcess.stderr.on("data",o)}))}stop(){this.cliProcess&&this.cliProcess.kill("SIGTERM")}getSpawnArgs(t,e){letn;consts=t.cliPath;try{n=require(C.default.join(s,"package.json"))}catch(t){}leti=!1;returnn&&(n.devDependencies&&n.devDependencies["@dcloudio/vite-plugin-uni"]&&(i=!0),!i&&n.dependencies&&n.dependencies["@dcloudio/vite-plugin-uni"]&&(i=!0),n.scripts&&n.scripts[e])?[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),process.env.UNI_INPUT_DIR=t.projectPath,process.env.UNI_OUTPUT_DIR=C.default.join(t.projectPath,`unpackage/dist/${this.puppet.mode}/${this.puppet.platform}`),i?[process.env.UNI_NODE_PATH||"node",[require.resolve("@dcloudio/vite-plugin-uni/bin/uni.js",{paths:[s]}),"-p",this.puppet.platform]]:[process.env.UNI_NODE_PATH||"node",[C.default.join(s,"bin/uniapp-cli.js")]])}}classRt{asynclaunch(t){lete=("app"===t.platform?t.app||t["app-plus"]:t[t.platform])||{};this.puppet=newDt(t.platform,e.puppet);const{port:n,cliPath:s,timeout:i,projectPath:o}=awaitthis.validate(t);e=awaitthis.puppet.validateDevtools(e);letr=this.puppet.shouldCompile(o,n,t,e),a=process.env.UNI_OUTPUT_DIR||o;if(r||this.puppet.validateProject(a)||(a=C.default.join(o,"dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(a)||(a=C.default.join(o,"unpackage/dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(a)||(r=!0))),r){this.puppet.compiled=t.compile=!0,this.compiler=newjt(this.puppet);conste=awaitthis.compiler.compile({host:t.host,port:n,cliPath:s,projectPath:o,silent:!!t.silent});e.path&&(a=e.path)}constc=[];returnc.push(this.createRuntimeConnection(n,i)),c.push(this.puppet.createDevtools(a,e,i)),newPromise(((t,s)=>{Promise.all(c).then((([s,i])=>{s&&this.puppet.setRuntimeConnection(s),i&&this.puppet.setDevtoolConnection(i),T.default("automator:program")("ready");consto=e.teardown||"disconnect";t(newkt(this.puppet,{teardown:o,port:n}))})).catch((t=>s(t)))}))}resolveCliPath(t){if(!t)returnt;try{const{dependencies:e,devDependencies:n}=require(C.default.join(t,"package.json"));if(St(n)||St(e))returnt}catch(t){}}resolveProjectPath(t,e){returnt||(t=process.env.UNI_INPUT_DIR||process.cwd()),D.default(t)&&(t=C.default.resolve(t)),b.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");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||6e4,projectPath:e}}asynccreateRuntimeConnection(t,e){returnX.createRuntimeConnection(t,this.puppet,e)}}functionSt(t){return!!t&&!(!t["@dcloudio/vue-cli-plugin-uni"]&&!t["@dcloudio/vite-plugin-uni"])}module.exports=class{constructor(){this.launcher=newRt}asynclaunch(t){returnthis.launcher.launch(t)}};
***************************************************************************** */functionQ(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}varZ;functiontt(t,e){constn=e.value;returne.value=asyncfunction(e){return(await(null==n?void0:n.call(this,e)))(t)},e}functionet(t,e,n){returntt(Z.RUNTIME,n)}functionnt(t,e,n){returntt(Z.DEVTOOL,n)}/^win/.test(process.platform),function(t){t.RUNTIME="runtime",t.DEVTOOL="devtool"}(Z||(Z={}));classst{constructor(t){this.puppet=t}invoke(t,e){returnasyncn=>this.puppet.devtoolConnection?(n===Z.DEVTOOL?this.puppet.devtoolConnection:this.puppet.runtimeConnection).send(t,e):this.puppet.runtimeConnection.send(t,e)}on(t,e){this.puppet.on(t,e)}}classitextendsst{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)}}Q([et],it.prototype,"getData",null),Q([et],it.prototype,"setData",null),Q([et],it.prototype,"callMethod",null),Q([nt],it.prototype,"getElement",null),Q([nt],it.prototype,"getElements",null),Q([nt],it.prototype,"getOffset",null),Q([nt],it.prototype,"getHTML",null),Q([nt],it.prototype,"getAttributes",null),Q([nt],it.prototype,"getStyles",null),Q([nt],it.prototype,"getDOMProperties",null),Q([nt],it.prototype,"getProperties",null),Q([nt],it.prototype,"tap",null),Q([nt],it.prototype,"longpress",null),Q([nt],it.prototype,"touchstart",null),Q([nt],it.prototype,"touchmove",null),Q([nt],it.prototype,"touchend",null),Q([nt],it.prototype,"triggerEvent",null),Q([nt],it.prototype,"callFunction",null),Q([nt],it.prototype,"callContextMethod",null);constot=require("util");classrt{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=newit(t,e)}toJSON(){returnJSON.stringify({id:this.id,tagName:this.tagName,pageId:this.pageId,nodeId:this.nodeId,videoId:this.videoId})}toString(){returnthis.toJSON()}[ot.inspect.custom](){returnthis.toJSON()}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnrt.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=>rt.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(!O.default(t))throwError("name must be a string");return(awaitthis.api.getAttributes({names:[t]})).attributes[0]}asyncvalue(){returnthis.property("value")}asyncproperty(t){if(!O.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(!O.default(t))throwError("name must be a string");return(awaitthis.api.getStyles({names:[t]})).styles[0]}asynctap(){returnthis.api.tap()}asynclongpress(){returnthis.nvue?this.api.longpress():(awaitthis.touchstart(),awaitF.default(350),this.touchend())}asynctrigger(t,e){constn={type:t};returnL.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){returnY((asynct=>(awaitthis.api.getDOMProperties({names:t})).properties),t)}_property(t){returnY((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=at;elseswitch(e.tagName){case"input":s=ct;break;case"textarea":s=pt;break;case"scroll-view":s=lt;break;case"swiper":s=ut;break;case"movable-view":s=ht;break;case"switch":s=dt;break;case"slider":s=mt;break;case"video":s=gt;break;default:s=rt}returni=news(t,e,n),n.set(e.elementId,i),i}}classatextendsrt{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}}classctextendsrt{asyncinput(t){returnthis.callFunction("input.input",t)}}classptextendsrt{asyncinput(t){returnthis.callFunction("textarea.input",t)}}classltextendsrt{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")}}classutextendsrt{asyncswipeTo(t){returnthis.callFunction("swiper.swipeTo",t)}}classhtextendsrt{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)}}classdtextendsrt{asynctap(){returnthis.callFunction("switch.tap")}}classmtextendsrt{asyncslideTo(t){returnthis.callFunction("slider.slideTo",t)}}classgtextendsrt{asynccallContextMethod(t,...e){returnawaitthis.api.callContextMethod({method:t,args:e})}}classytextendsst{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)}}Q([et],yt.prototype,"getData",null),Q([et],yt.prototype,"setData",null),Q([et],yt.prototype,"callMethod",null),Q([nt],yt.prototype,"getElement",null),Q([nt],yt.prototype,"getElements",null),Q([nt],yt.prototype,"getWindowProperties",null);constvt=require("util");classft{constructor(t,e){this.puppet=t,this.id=e.id,this.path=e.path,this.query=e.query,this.elementMap=newMap,this.api=newyt(t,e)}toJSON(){returnJSON.stringify({id:this.id,path:this.path,query:this.query})}toString(){returnthis.toJSON()}[vt.inspect.custom](){returnthis.toJSON()}asyncwaitFor(t){return_.default(t)?awaitF.default(t):q.default(t)?j.default(t):O.default(t)?j.default((async()=>(awaitthis.$$(t)).length>0)):void0}async$(t){try{conste=awaitthis.api.getElement({selector:t});returnrt.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=>rt.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=O.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=newft(t,e),n.set(e.id,s),s)}}classwtextendsst{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)}}Q([et],wt.prototype,"getPageStack",null),Q([et],wt.prototype,"callUniMethod",null),Q([et],wt.prototype,"getCurrentPage",null),Q([et],wt.prototype,"mockUniMethod",null),Q([nt],wt.prototype,"callFunction",null),Q([nt],wt.prototype,"captureScreenshot",null),Q([nt],wt.prototype,"exit",null),Q([nt],wt.prototype,"addBinding",null),Q([nt],wt.prototype,"enableLog",null);classPtextendsst{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)}}functionMt(t){returnnewPromise((e=>setTimeout(e,t)))}Q([nt],Pt.prototype,"getInfo",null),Q([nt],Pt.prototype,"enableRemoteDebug",null),Q([nt],Pt.prototype,"close",null),Q([nt],Pt.prototype,"getTestAccounts",null);classEtextendso.EventEmitter{constructor(t,e){super(),this.puppet=t,this.options=e,this.pageMap=newMap,this.appBindings=newMap,this.appApi=newwt(t),this.toolApi=newPt(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=>ft.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();returnft.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){returnq.default(e)||(s=e,O.default(s)&&(s=x.default(s),$.default(s,"function")||$.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){}awaitMt(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=>{W.default.generate(n,{small:!0},(e=>{process.stdout.write(e),t(void0)}))})));consts=newPromise((t=>{this.toolApi.onRemoteDebugConnected((async()=>{awaitMt(1e3),t(void0)}))})),i=newPromise((t=>{this.puppet.setRemoteRuntimeConnectionCallback((()=>{t(void0)}))}));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.default.writeFile(t.path,e,"base64")}asynctestAccounts(){return(awaitthis.toolApi.getTestAccounts()).accounts}asyncchangeRoute(t,e){returnawaitthis.callUniMethod(t,{url:e}),awaitMt(3e3),this.currentPage()}}classkt{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`))}}constIt=T.default("automator:puppet"),bt=".automator.json";functionCt(t){try{returnrequire(t)}catch(t){}}functionTt(t,e,n,s){consti=function(t,e,n){lets,i;returnprocess.env.UNI_OUTPUT_DIR?(i=C.default.join(process.env.UNI_OUTPUT_DIR,`../.automator/${e}`,bt),s=Ct(i)):(i=C.default.join(t,`dist/${n}/.automator/${e}`,bt),s=Ct(i),s||(i=C.default.join(t,`unpackage/dist/${n}/.automator/${e}`,bt),s=Ct(i))),It(`${i}=>${JSON.stringify(s)}`),s}(t,n,s);if(!i||!i.wsEndpoint)return!1;consto=require("../package.json").version;if(i.version!==o)returnIt(`unmet=>${i.version}!==${o}`),!1;constr=function(t){lete;try{constt=B.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);returnIt(`wsEndpoint=>${r}`),i.wsEndpoint===r}classDtextendso.EventEmitter{constructor(t,e){if(super(),e)this.target=e;else{if(this.target=null,"h5"===t)try{this.target=K("@dcloudio/uni-h5/lib/h5/uni.automator.js")}catch(t){}this.target||(this.target=K(`@dcloudio/uni-${"app"===t?"app-plus":t}/lib/uni.automator.js`))}if(!this.target)throwError("puppet is not provided");this.platform=t,this.adapter=newkt(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=>!b.default.existsSync(C.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;consti=this.target.shouldCompile;returni?this.compiled=i(n,s):!0===n.compile?this.compiled=!0:this.compiled=!Tt(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")}}constNt=T.default("automator:compiler"),At=/The\s+(.*)\s+directory is ready/;classRt{constructor(t){this.puppet=t,this.puppet.setCompiler(this)}compile(t){conste=this.puppet.mode,n=this.puppet.platform;lets=t.silent;consti=t.port,o=t.host,r=`${e}:${n}`,a=t.projectPath,[c,p]=this.getSpawnArgs(t,r);p.push("--auto-port"),p.push(V.default(i)),o&&(p.push("--auto-host"),p.push(o));constl={cwd:t.cliPath,env:Object.assign(Object.assign({},process.env),{NODE_ENV:"build"===e?"production":"development"})};returnnewPromise(((t,i)=>{consto=i=>{consto=i.toString().trim();if(!s&&console.log(o),o.includes("- Network")||o.includes("> Network")||o.includes("➜ Network")){conste=o.match(/Network:(.*)/)[1].trim();Nt(`url: ${e}`),t({path:e})}elseif(o.includes("DONE Build complete")){consti=o.match(At);letr="";i&&i.length>1?r=C.default.join(a,i[1]):(r=C.default.join(a,`dist/${e}/${n}`),b.default.existsSync(r)||(r=C.default.join(a,`unpackage/dist/${e}/${n}`))),s=!0,this.stop(),t({path:r})}};Nt(`${c}${p.join("")} %o`,l),this.cliProcess=E.spawn(c,p,l),this.cliProcess.on("error",(t=>{i(t)})),this.cliProcess.stdout.on("data",o),this.cliProcess.stderr.on("data",o)}))}stop(){this.cliProcess&&this.cliProcess.kill("SIGTERM")}getSpawnArgs(t,e){letn;consts=t.cliPath;try{n=require(C.default.join(s,"package.json"))}catch(t){}leti=!1;if(n&&(n.devDependencies&&n.devDependencies["@dcloudio/vite-plugin-uni"]&&(i=!0),!i&&n.dependencies&&n.dependencies["@dcloudio/vite-plugin-uni"]&&(i=!0),n.scripts&&n.scripts[e]))return[process.env.UNI_NPM_PATH||(/^win/.test(process.platform)?"npm.cmd":"npm"),["run",e,"--"]];if(["android","ios"].includes(process.env.UNI_OS_NAME)&&(process.env.UNI_APP_PLATFORM=process.env.UNI_OS_NAME),process.env.UNI_INPUT_DIR=t.projectPath,process.env.UNI_OUTPUT_DIR=C.default.join(t.projectPath,`unpackage/dist/${this.puppet.mode}/${this.puppet.platform}`),process.env.UNI_HBUILDERX_PLUGINS||b.default.existsSync(C.default.resolve(s,"../about"))&&(process.env.UNI_HBUILDERX_PLUGINS=C.default.dirname(s)),i){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",[C.default.join(s,"bin/uniapp-cli.js")]]}}classSt{asynclaunch(t){lete=("app"===t.platform?t.app||t["app-plus"]:t[t.platform])||{};this.puppet=newDt(t.platform,e.puppet);const{port:n,cliPath:s,timeout:i,projectPath:o}=awaitthis.validate(t);e=awaitthis.puppet.validateDevtools(e);letr=this.puppet.shouldCompile(o,n,t,e),a=process.env.UNI_OUTPUT_DIR||o;if(r||this.puppet.validateProject(a)||(a=C.default.join(o,"dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(a)||(a=C.default.join(o,"unpackage/dist/"+this.puppet.mode+"/"+this.puppet.platform),this.puppet.validateProject(a)||(r=!0))),r){this.puppet.compiled=t.compile=!0,this.compiler=newRt(this.puppet);conste=awaitthis.compiler.compile({host:t.host,port:n,cliPath:s,projectPath:o,silent:!!t.silent});e.path&&(a=e.path)}constc=[];returnc.push(this.createRuntimeConnection(n,i)),c.push(this.puppet.createDevtools(a,e,i)),newPromise(((t,s)=>{Promise.all(c).then((([s,i])=>{s&&this.puppet.setRuntimeConnection(s),i&&this.puppet.setDevtoolConnection(i),T.default("automator:program")("ready");consto=e.teardown||"disconnect";t(newEt(this.puppet,{teardown:o,port:n}))})).catch((t=>s(t)))}))}resolveCliPath(t){if(!t)returnt;try{const{dependencies:e,devDependencies:n}=require(C.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=C.default.resolve(t)),b.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");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}}asynccreateRuntimeConnection(t,e){returnz.createRuntimeConnection(t,this.puppet,e)}}functionjt(t){return!!t&&!(!t["@dcloudio/vue-cli-plugin-uni"]&&!t["@dcloudio/vite-plugin-uni"])}module.exports=class{constructor(){this.launcher=newSt}asynclaunch(t){returnthis.launcher.launch(t)}};