@metricinsights/pp-dev 1.5.0-beta.33 → 1.5.0-beta.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/cjs/auth.provider-6rZUaR33.js +2 -0
  2. package/dist/cjs/auth.provider-6rZUaR33.js.map +1 -0
  3. package/dist/cjs/cli.js +1 -1
  4. package/dist/cjs/cli.js.map +1 -1
  5. package/dist/cjs/index-Cc-bAhnE.js +2 -0
  6. package/dist/cjs/index-Cc-bAhnE.js.map +1 -0
  7. package/dist/cjs/index.js +1 -1
  8. package/dist/cjs/internal.middleware-BlM7gqkq.js +2 -0
  9. package/dist/cjs/internal.middleware-BlM7gqkq.js.map +1 -0
  10. package/dist/cjs/{migrate-oVYAMhLH.js → migrate-DDdeB-Fj.js} +2 -2
  11. package/dist/cjs/{migrate-oVYAMhLH.js.map → migrate-DDdeB-Fj.js.map} +1 -1
  12. package/dist/cjs/plugin.js +1 -1
  13. package/dist/cjs/{version-manifest-fusPAO4h.js → version-manifest-DdWlzzZ6.js} +2 -2
  14. package/dist/cjs/{version-manifest-fusPAO4h.js.map → version-manifest-DdWlzzZ6.js.map} +1 -1
  15. package/dist/cjs/{version-plugin-B6tVqztE.js → version-plugin-B1Sb07cW.js} +2 -2
  16. package/dist/cjs/{version-plugin-B6tVqztE.js.map → version-plugin-B1Sb07cW.js.map} +1 -1
  17. package/dist/esm/auth.provider-BFK6x9Df.js +2 -0
  18. package/dist/esm/auth.provider-BFK6x9Df.js.map +1 -0
  19. package/dist/esm/cli.js +1 -1
  20. package/dist/esm/cli.js.map +1 -1
  21. package/dist/esm/index-PvH-M_Io.js +2 -0
  22. package/dist/esm/index-PvH-M_Io.js.map +1 -0
  23. package/dist/esm/index.js +1 -1
  24. package/dist/esm/internal.middleware-CC20He9L.js +2 -0
  25. package/dist/esm/internal.middleware-CC20He9L.js.map +1 -0
  26. package/dist/esm/{migrate-BxksV7OV.js → migrate-C1MkJPzS.js} +2 -2
  27. package/dist/esm/{migrate-BxksV7OV.js.map → migrate-C1MkJPzS.js.map} +1 -1
  28. package/dist/esm/plugin.js +1 -1
  29. package/dist/esm/version-manifest-BVgENnKn.js +2 -0
  30. package/dist/esm/{version-manifest-CGzLQLmu.js.map → version-manifest-BVgENnKn.js.map} +1 -1
  31. package/dist/esm/{version-plugin-Byv2M38F.js → version-plugin-CA9HNV-6.js} +2 -2
  32. package/dist/esm/{version-plugin-Byv2M38F.js.map → version-plugin-CA9HNV-6.js.map} +1 -1
  33. package/package.json +1 -1
  34. package/dist/cjs/auth.provider-C3O8wdGc.js +0 -2
  35. package/dist/cjs/auth.provider-C3O8wdGc.js.map +0 -1
  36. package/dist/cjs/index-DnVkH9ZF.js +0 -2
  37. package/dist/cjs/index-DnVkH9ZF.js.map +0 -1
  38. package/dist/cjs/internal.middleware-63EM6Z98.js +0 -2
  39. package/dist/cjs/internal.middleware-63EM6Z98.js.map +0 -1
  40. package/dist/esm/auth.provider-sKqGOS5N.js +0 -2
  41. package/dist/esm/auth.provider-sKqGOS5N.js.map +0 -1
  42. package/dist/esm/index-DEFt8X6C.js +0 -2
  43. package/dist/esm/index-DEFt8X6C.js.map +0 -1
  44. package/dist/esm/internal.middleware-BVjskCUz.js +0 -2
  45. package/dist/esm/internal.middleware-BVjskCUz.js.map +0 -1
  46. package/dist/esm/version-manifest-CGzLQLmu.js +0 -2
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.provider-BFK6x9Df.js","sources":["../../../src/constants.ts","../../../src/lib/logger.ts","../../../src/lib/helpers/color.helper.ts","../../../src/lib/output-path.ts","../../../src/lib/pp-dev-config.ts","../../../src/lib/dev-panel.ts","../../../src/lib/helpers/origin-guard.ts","../../../src/lib/auth.provider.ts"],"sourcesContent":[null,null,null,null,null,null,null,null],"names":["modulePath","fileURLToPath","url","afterBundlePath","resolve","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","PATH_TEMPLATE_LOCAL_PREFIX","PP_DEV_NEXT_BUILD_ENV_VAR","PP_DEV_NEXT_BUILD_DIST_DIR_ENV_VAR","PP_DEV_PROJECT_ROOT_ENV_VAR","PP_DEV_CONFIG_NAMES","DEFAULT_LEVEL","current","shared","active","level","logger","createViteLogger","createLogger","undefined","info","msg","options","warn","warnOnce","error","clearScreen","type","hasErrorLogged","hasWarned","value","colors","createColors","normalizeRelativeOutputPath","relativePath","optionName","includes","path","posix","isAbsolute","win32","root","Error","normalized","normalize","replace","startsWith","createDefaultZipFileName","appName","resolveZipSourceDir","projectRoot","outDir","inDir","resolveOutputFilePath","directory","fileName","safeRelativePath","resolvedDirectory","resolvedFile","split","relativeToDirectory","relative","sep","DEV_PANEL_POSITIONS","MAX_TIMER_DELAY_MS","validatePPDevConfig","config","templateName","miMode","mi","mode","appType","app","apiVersion","miUrl","process","env","MI_BACKEND_URL","maxBackups","sync","Number","isInteger","stringify","buildTimeoutMs","include","console","id","devPanel","position","join","allowedHosts","server","Array","isArray","every","host","trim","normalizePPDevConfig","proxy","build","inspector","users","miHudLess","integrateMiTopBar","addSharedComponentsScripts","addRootElement","templateLess","resolvedName","defaultVersionFileTemplate","distZip","zipCfg","zip","versionPlugin","outFileName","vfCfg","versionFile","imageOptimizer","versionFileTemplate","enabled","fileNameTemplate","imgCfg","imageOptimisations","backendBaseURL","appId","enableProxyCache","cache","proxyCacheTTL","cacheTtl","disableSSLValidation","tls","allowSelfSigned","syncBackupsDir","backupsDir","syncMaxBackups","syncBuildTimeoutMs","v7Features","personalAccessToken","token","MI_ACCESS_TOKEN","inspectorEnabled","inspectorMaxMemory","maxMemory","inspectorCaptureLimit","captureLimit","devPanelPosition","devPanelHidden","hidden","devPanelAutoHide","autoHide","persistUsers","persist","map","toLowerCase","CLIENT_DIST_DIR","dirname","TEMPLATE_PATH","compiledTemplate","getDevPanelAssetPaths","base","css","js","renderDevPanelMarkup","data","templateContent","fs","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","canSync","injectDevPanel","html","test","panelMarkup","linkTag","bodyPrepend","result","linkInjected","headEnd","head","bodyStart","CONTENT_TYPES","createDevPanelAssetMiddleware","assetPrefix","allowed","Set","req","res","next","pathname","slice","length","has","filePath","readFile","err","content","statusCode","setHeader","extname","end","SAFE_METHODS","isHostAllowed","named","trimmed","indexOf","isIP","ip","hostname","readHostHeader","endsWith","some","matchesAllowedHost","hostNotAllowedMessage","exactAllowedHosts","filter","crossOriginReason","origin","headers","originUrl","URL","requestHost","scheme","normalizeHost","protocol","fetchSite","method","toUpperCase","createOriginGuard","reason","status","json","AuthProvider","state","isAuthenticated","isRedirected","listeners","getState","this","setAuthenticated","authenticated","notifyListeners","setRedirected","redirected","updateState","updates","reset","subscribe","listener","add","delete","forEach","stack","message","String","authProvider"],"mappings":"2TAUA,MAAMA,EAAaC,cAA0BC,KAGvCC,EAAkBC,EAAQJ,EAAY,YAGtCK,EAAmBD,EAAQJ,EAAY,SAEhCM,EAAqBC,EAAWH,EAAQD,EAAiB,iBAClEA,EACAE,EAESG,EAAsBJ,EAAQE,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAaT,EAAQE,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAKfO,EAAmB,KACnBC,EAAuB,MACvBC,EAA6B,MAQ7BC,EAA4B,oBAO5BC,EAAqC,6BAOrCC,EAA8B,sBAE9BC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCtEIC,EAA0B,OAEhC,IAAIC,EACAC,EAEJ,SAASC,IAGP,OAFAF,IAAY,CAAEG,MAAOJ,EAAeK,OAAQC,EAAiBN,IAEtDC,EAAQI,MACjB,CAUM,SAAUE,EAA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AEtG,GAEJ,EAIK,MAAM4O,GAAe,IAAIvB"}
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import{cac as e}from"cac";import{c as t,a as o,P as n,V as i,b as r,v as s,n as a,d as l,e as c,f as d,i as p,h as f,g as u,j as g,k as h,r as m,l as w}from"./auth.provider-sKqGOS5N.js";import*as v from"path";import{performance as b}from"node:perf_hooks";import{loadConfigFromFile as y,mergeConfig as P,build as x,resolveConfig as S,optimizeDeps as k,preview as T}from"vite";import{I as L,P as E,c as D,r as F,a as $,u as j,D as I,s as N,e as C,b as _,d as A,z as M}from"./internal.middleware-BVjskCUz.js";import{watch as R}from"chokidar";import{l as H,g as O,s as U,c as z,r as V,a as G,b as Z,d as W}from"./index-DEFt8X6C.js";import*as B from"fs";import{EventEmitter as q}from"node:events";import{parse as J}from"url";import{WebSocketServer as K,WebSocket as X}from"ws";import{fork as Y}from"node:child_process";import*as Q from"dir-compare";import ee from"diff-match-patch";import{isBinaryFile as te}from"isbinaryfile";import*as oe from"os";import*as ne from"crypto";import{w as ie}from"./version-manifest-CGzLQLmu.js";import"picocolors";import"node:path";import"ejs";import"node:net";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"zlib";import"node:crypto";import"process";import"jszip";import"node:fs";import"node:fs/promises";import"child_process";import"module";import"node:os";import"express";import"node:module";import"./helpers.js";import"fs/promises";import"util";function re(e){return null!=e&&!1!==e}let se=null;const ae=new WeakMap;function le(e,n){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;ae.set(e,n);const i=t();n.print&&i.info(o.dim(o.green(" ➜"))+o.dim(" press ")+o.bold("h")+o.dim(" to show help"));const r=(n.customShortcuts??[]).filter(re).concat(ce);se?.(),se=null;let s=!1;const a=process.stdin.isPaused(),l=process.stdin,c=Boolean(l.isRaw),d=async t=>{if(""===t)return void function(e=process){"win32"===e.platform?e.emit("SIGINT","SIGINT"):e.kill(e.pid,"SIGINT")}();if(""===t)return void await e.close().finally(()=>process.exit(0));if(s)return;"h"===t&&i.info(["",o.bold(" Shortcuts"),...r.map(e=>o.dim(" press ")+o.bold(e.key)+o.dim(` to ${e.description}`))].join("\n"));const n=r.find(e=>e.key===t);n&&(s=!0,await n.action(e),s=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{se===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),a&&process.stdin.pause(),se=null)};se=f,p.on("close",f)}const ce=[{key:"r",description:"restart the server",async action(e){const t=ae.get(e);await e.restart(),t&&le(e,{...t,print:!1})}},{key:"u",description:"show server url",action(e){e.config.logger.info(""),e.printUrls()}},{key:"o",description:"open in browser",action(e){e.openBrowser()}},{key:"c",description:"clear console",action(e){e.config.logger.clearScreen("error")}},{key:"q",description:"quit",async action(e){await e.close().finally(()=>process.exit())}},{key:"C",description:"clear proxy cache",action(e){e.cache&&(e.cache.clear(),e.config.logger.info("Proxy cache cleared"))}}],de="pp-dev:ready",pe="pp-dev:shutdown";function fe(e){return e instanceof Error?e.stack??e.message:String(e)}function ue({logger:e,knownRejections:t=[],shutdown:n,shutdownTimeoutMs:i=5e3,processRef:r=process}){let s=!1,a=!1,l=0;const c=async(t,c,{repeatable:d=!0}={})=>{if((e=>{l=Math.max(l,e)})(c),s){if(d&&(e=>"SIGINT"===e||"SIGTERM"===e||"SIGHUP"===e)(t)){if(a)return void(a=!1);e.warn(o.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),r.exit(l)}return}s=!0,a=!d,e.info(o.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const p=setTimeout(()=>{e.error(o.red(`⏰ Shutdown did not finish within ${i} ms, forcing exit`)),r.exit(1)},i);try{await n(),clearTimeout(p),e.info(o.green("✅ Graceful shutdown completed")),r.exit(l)}catch(t){clearTimeout(p),e.error(o.red(`❌ Error during graceful shutdown: ${fe(t)}`)),r.exit(1)}},d=()=>{c("SIGINT",0)},p=()=>{c("SIGTERM",0)},f=()=>{c("SIGHUP",0)},u=t=>{e.error(o.red(`❌ Uncaught exception: ${fe(t)}`)),c("uncaughtException",1)},g=n=>{const i=t.find(e=>e.matches(n));i?e.info(o.dim(i.message)):e.error(o.red(`❌ Unhandled promise rejection (the server keeps running): ${fe(n)}`))},h=e=>{(function(e){return"object"==typeof e&&null!==e&&e.type===pe&&"string"==typeof e.reason})(e)&&c(e.reason,0,{repeatable:!1})},m=()=>{c("the end of the pp-dev process",0,{repeatable:!1})},w="function"==typeof r.send;return r.on("SIGINT",d),r.on("SIGTERM",p),r.on("SIGHUP",f),r.on("uncaughtException",u),r.on("unhandledRejection",g),w&&(r.on("message",h),r.on("disconnect",m)),()=>{r.off("SIGINT",d),r.off("SIGTERM",p),r.off("SIGHUP",f),r.off("uncaughtException",u),r.off("unhandledRejection",g),w&&(r.off("message",h),r.off("disconnect",m))}}const ge=["--","c","config","base","l","logLevel","clearScreen","configLoader","profile","d","debug","f","filter","m","mode","force","w","changelog","distZip","distZipDir","distZipFilename","versionManifest","versionFileTemplate","webpack","turbopack"];function he(e){const t={...e};for(const e of ge)delete t[e];return"sourcemap"in t&&(t.sourcemap="true"===t.sourcemap||"false"!==t.sourcemap&&t.sourcemap),"watch"in t&&(t.watch=t.watch?{}:void 0),t}const me=["https","open","cors","strictPort","force"];const we=[...n,"package.json","next.config.js","next.config.mjs","next.config.ts","vite.config.js","vite.config.mjs","vite.config.ts",".env",".env.local",".env.development",".env.development.local"];function ve(e){return e instanceof Error?e.stack??e.message:String(e)}function be(e,t,n,i={}){const{debounceMs:r=500}=i,s=v.resolve(e),a=new Set(we),l=R(s,{ignored:(e,t)=>!!t&&(t.isDirectory()?v.resolve(e)!==s:!a.has(v.basename(e))),depth:0,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let c=null,d=!1,p=!1,f=!1;const u=()=>{c&&clearTimeout(c),c=setTimeout(()=>{(async()=>{if(c=null,!f)if(d)p=!0;else{d=!0;try{n(o.yellow("🔄 Restarting dev server due to config change...")),await t()}catch(e){n(o.red(`❌ Failed to restart dev server: ${ve(e)}`))}finally{d=!1}p&&!f&&(p=!1,n(o.blue("🔧 Config changed again during the restart")),u())}})()},r)},g=e=>t=>{n(o.blue(`🔧 Config file ${e}: ${v.relative(s,t)}`)),u()};l.on("change",g("changed")),l.on("add",g("added")),l.on("unlink",g("removed")),l.on("error",e=>{n(o.red(`❌ Config watcher error: ${ve(e)}`))});const h=new Promise(e=>{l.once("ready",()=>{n(o.blue("🔧 Config file watcher started")),e()})});return{watcher:l,ready:h,async close(){f=!0,c&&(clearTimeout(c),c=null),await l.close()}}}function ye(e){if(!e||"object"!=typeof e||!("message"in e))return!1;const t=String(e.message);return/Turbopack is not supported/i.test(t)||/native bindings are not available/i.test(t)||/Only WebAssembly \(WASM\) bindings were loaded/i.test(t)}const Pe=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};async function xe(e){const{root:t,mode:o,command:n,isPreview:i}=e,r=v.resolve(process.cwd(),t??".");H(o,r);const s=await y({mode:o,command:n,...i?{isPreview:i}:{}},e.configFile,t,e.logLevel);let a=await O(e.buildOverrides,{mode:o,root:r});if(s){const e={...s.config};delete e.plugins,a=P(a,e)}return{config:a,envDir:r}}let Se=global.__pp_dev_profile_session,ke=0;const Te=e=>{if(Se)return new Promise((t,n)=>{Se.post("Profiler.stop",(i,{profile:r})=>{if(i)n(i);else{const n=v.resolve(`./pp-dev-profile-${ke++}.cpuprofile`);B.writeFileSync(n,JSON.stringify(r)),e(o.yellow(`CPU profile written to ${o.white(o.dim(n))}`)),Se=void 0,t()}})})};function Le(e){e.once("error",()=>e.destroy()),e.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>e.destroy())}class Ee{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;allowedHosts;constructor({allowedHosts:e=[]}={}){this.allowedHosts=e,this.wss=new K({noServer:!0}),this.wss.on("connection",e=>this.onConnection(e)),this.wss.on("error",e=>this.fireLifecycle("error",e)),this.ws={on:(e,t)=>{"close"!==e&&"error"!==e?this.getEventSet(e).add(t):this.getLifecycleSet(e).add(t)},off:(e,t)=>{"close"!==e&&"error"!==e?this.eventListeners.get(e)?.delete(t):this.lifecycleListeners.get(e)?.delete(t)},send:(e,t)=>{if("string"==typeof e)for(const o of this.clients.keys())this.sendToSocket(o,e,t);else{const t=JSON.stringify(e);for(const e of this.clients.keys())e.readyState===X.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===E&&(r(e,this.allowedHosts)?(Le(t),!0):(this.wss.handleUpgrade(e,t,o,t=>{this.wss.emit("connection",t,e)}),!0))}async close(){this.fireLifecycle("close");for(const e of this.clients.keys())e.terminate();this.clients.clear(),await new Promise(e=>this.wss.close(()=>e()))}onConnection(e){const t={send:(t,o)=>this.sendToSocket(e,t,o),socket:e};this.clients.set(e,t),e.on("message",e=>this.onMessage(t,e)),e.on("close",()=>this.clients.delete(e)),e.on("error",()=>{})}onMessage(e,o){let n;try{n=JSON.parse(o.toString())}catch{return}if(!n||"custom"!==n.type||"string"!=typeof n.event)return;const i=this.eventListeners.get(n.event);if(i)for(const o of i)try{o(n.data,e)}catch(e){t().error(`ws handler for "${n.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===X.OPEN&&e.send(JSON.stringify({type:"custom",event:t,data:o}))}fireLifecycle(e,t){for(const o of this.lifecycleListeners.get(e)??[])try{o(t)}catch{}}getEventSet(e){let t=this.eventListeners.get(e);return t||(t=new Set,this.eventListeners.set(e,t)),t}getLifecycleSet(e){let t=this.lifecycleListeners.get(e);return t||(t=new Set,this.lifecycleListeners.set(e,t)),t}}const De={matches:e=>e instanceof Error&&"Worker creator already registered"===e.message,message:"Next.js kept its Turbopack worker pool from before the restart ('Worker creator already registered')"};const Fe="PP_DEV_NEXT_SERVER_PROCESS";function $e(){const[,e,...t]=process.argv;if(!e)throw new Error("pp-dev next: cannot start the server process, no script in process.argv");return Y(e,t,{env:{...process.env,[Fe]:"1"},stdio:"inherit",execArgv:process.execArgv})}async function je(e,t="development"){const[{loadPPDevEnv:o},{clearConfigCache:n,getConfig:i,getPkg:r},{validatePPDevConfig:s}]=await Promise.all([import("./index-DEFt8X6C.js").then(e=>e.h),import("./index-DEFt8X6C.js").then(e=>e.j),import("./auth.provider-sKqGOS5N.js").then(e=>e.B)]);o(t,e),n();s(await i(e),r(e).name)}function Ie(e){return e instanceof Error?e.message:String(e)}const Ne=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class Ce{oldAssetsPath;newAssetsPath;destinationPath;changelogFilename;changelogTemplate='<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8" />\n <title>Changelog Diff</title>\n <style>\n tr,\n td {\n padding: 0;\n }\n .diff-file {\n margin-top: 20px;\n border: 1px solid #e1e4e8;\n border-radius: 6px;\n }\n .diff-file-title {\n padding: 10px 20px;\n background-color: #f6f8fa;\n border-bottom: 1px solid #e1e4e8;\n border-radius: 6px 6px 0 0;\n font-weight: bold;\n }\n .diff-file-title .renamed {\n font-weight: normal;\n }\n .diff-file-title .renamed .from {\n color: #cb2431;\n }\n .diff-file-title .renamed .to {\n color: #22863a;\n }\n .diff-file-title .added {\n color: #22863a;\n }\n .diff-file-title .deleted {\n color: #cb2431;\n }\n .diff-file-content {\n }\n .diff-table {\n tab-size: 8;\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n }\n .blob-num {\n position: relative;\n color: #1f2328;\n width: 1%;\n min-width: 50px;\n padding: 0 10px;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n line-height: 20px;\n text-align: right;\n white-space: nowrap;\n vertical-align: top;\n cursor: pointer;\n -webkit-user-select: none;\n user-select: none;\n }\n .blob-num.addition {\n background-color: #ccffd8;\n border-color: #1f883e;\n }\n .blob-num.deletion {\n background-color: #ffd7d5;\n border-color: #cf222e;\n }\n .blob-num::before {\n content: attr(data-line-number);\n }\n .blob-code {\n position: relative;\n padding: 0 10px 0 22px;\n vertical-align: top;\n color: #1f2329;\n }\n .blob-code.code-addition {\n background-color: #e6ffec;\n }\n .blob-code.code-deletion {\n background-color: #ffebe9;\n }\n .blob-code.skip,\n .blob-code.message {\n text-align: center;\n }\n .blob-code.skip .blob-code-inner,\n .blob-code.message .blob-code-inner {\n font-weight: bold;\n color: #6a737d;\n padding: 10px 0;\n }\n .blob-code-inner {\n display: table-cell;\n overflow: visible;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n word-wrap: anywhere;\n white-space: pre-wrap;\n }\n .blob-code-inner::before {\n content: attr(data-code-prefix);\n position: absolute;\n top: 1px;\n left: 8px;\n padding-right: 8px;\n }\n </style>\n </head>\n <body>\n <h1>Changelog Diff</h1>\n\n %FILES%\n </body>\n </html>';diffFileTemplateHandler;diffLineTemplateHandler;contextLines=3;logger;constructor(e){const{oldAssetsPath:n,newAssetsPath:i,destinationPath:r,changelogTemplate:s,diffFileTemplateHandler:a,diffLineTemplateHandler:l,changelogFilename:c,contextLines:d}=e;if(this.logger=t(),!n||!i||!r)throw new Error("Previous assets path, current assets path and destination path are required");if(n===i)throw new Error("Previous and current assets paths must be different");if(!this.isExists(n))throw new Error(`Previous assets path ${n} does not exist`);if(!this.isExists(i))throw new Error(`Current assets path ${i} does not exist`);if(this.isZipFile(n)){const e=v.resolve(oe.tmpdir(),ne.createHash("md5").update(n).digest("hex"));this.oldAssetsPath=this.unzipFile(n,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);return e})}else{if(!this.isFolder(n))throw new Error(`Invalid previous assets path ${n}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(n);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(i)){const e=v.resolve(oe.tmpdir(),ne.createHash("md5").update(i).digest("hex"));this.newAssetsPath=this.unzipFile(i,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Current assets path ${e} is empty`);return e})}else{if(!this.isFolder(i))throw new Error(`Invalid current assets path ${i}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(i);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${i} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=r,this.mkdirpSync(this.destinationPath),this.changelogFilename=c||"CHANGELOG.html",s&&(this.templateIsValid(s)?this.changelogTemplate=s:this.logger.warn(o.yellow("Invalid changelog template, using default"))),"function"==typeof a&&(this.diffFileTemplateHandler=a),"function"==typeof l&&(this.diffLineTemplateHandler=l),d&&(this.contextLines=d)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return B.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return B.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===B.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){B.existsSync(e)||B.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){B.rmSync(t,{force:!0,recursive:!0}),await C(e,t)}normalizeAssetFolderPath(e){const t=B.readdirSync(e);return 1===t.length&&B.lstatSync(v.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(v.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${r=o??"",r.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var r}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(o.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await Q.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(Ne.test(e)&&(e=e.replace(Ne,"$1$3")),Ne.test(t)&&(t=t.replace(Ne,"$1$3")),0===e.localeCompare(t)?0:e.localeCompare(t)>0?1:-1)});return e.diffSet?.filter(e=>"equal"!==e.state||e.name1!==e.name2)||[]}async generateAssetFilesDiff(e,t){const o=new ee,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let r=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:r+o+1,lineType:t})).slice(0,n);return-1!==t&&(r+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(v.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(v.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${t}</span> -> <span class="to">${o}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const t=e.path1&&e.name1?v.join(e.path1,e.name1):null,o=e.path2&&e.name2?v.join(e.path2,e.name2):null,n=this.pathToPosix(v.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&t)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&o)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&t&&o){const i=this.pathToPosix(v.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(v.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await te(t)||await te(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(B.readFileSync(t,"utf-8"),B.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(o.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(o.green("Writing changelog file"));const n=this.changelogTemplate.split("%FILES%");n.splice(1,0,t);const i=n.join("");B.writeFileSync(v.join(this.destinationPath,this.changelogFilename),i),this.logger.info(o.green(`Changelog file written to ${v.join(this.destinationPath,this.changelogFilename)}`))}}async function _e(e){const{changelog:n,executionRoot:i,newAssetsPath:r,backupsDirPath:s,changelogDestinationPath:a,logLevel:l}=e;let c;if("string"==typeof n)c=v.resolve(i,n);else{if(!B.existsSync(s))return void t(l).warn(o.yellow("backups directory not found, skipping changelog generation"));const e=B.readdirSync(s,{withFileTypes:!0});if(!e.length)return void t(l).warn(o.yellow("no backups found, skipping changelog generation"));const n=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!n.length)return void t(l).warn(o.yellow("no ZIP backups found, skipping changelog generation"));const i=n.reduce((e,t)=>B.statSync(v.resolve(s,e.name)).mtimeMs>B.statSync(v.resolve(s,t.name)).mtimeMs?e:t).name;c=v.resolve(s,i)}const d=new Ce({oldAssetsPath:c,newAssetsPath:r,destinationPath:a});await d.generateChangelog()}class Ae{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){const{default:e}=await(import("svgtofont"));await e({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const Me=e("pp-dev");Me.option("-c, --config <file>","[string] use specified config file").option("--base <path>","[string] public base path (default: /)").option("-l, --logLevel <level>","[string] info | warn | error | silent").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("-d, --debug [feat]","[string | boolean] show debug logs").option("-f, --filter <filter>","[string] filter debug logs").option("-m, --mode <mode>","[string] set env mode"),function(e){e.command("[root]","start dev server").alias("serve").alias("dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--cors","[boolean] enable CORS").option("--strictPort","[boolean] exit if specified port is already in use").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Pe(n);let r=null,s=null;const a=e?v.resolve(process.cwd(),e):process.cwd(),l=t(n.logLevel),c=async({restart:t=!1}={})=>{let d=null;try{const{clearConfigCache:t,getConfig:f}=await import("./index-DEFt8X6C.js").then(e=>e.j);t();const{createServer:u}=await(import("vite")),g=n.mode||"development",{config:h,envDir:m}=await xe({root:e,mode:g,command:"serve",configFile:n.config,logLevel:n.logLevel}),w=n.base??h.base;if(!w||"/"===w)throw new Error('base cannot be equal to "/" or empty string');if(d=await u(P(h,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:he(n),customLogger:l},!0)),!d.httpServer)throw new Error("HTTP server not available");if(r){const e=r;r=null,l.info(o.yellow("🛑 Stopping existing dev server...")),await e.close()}await d.listen(),r=d;const v=global.__pp_dev_start_time??!1,y=v?o.dim(`ready in ${o.reset(o.bold(Math.ceil(b.now()-v)))} ms`):"";l.info(`\n ${o.green(`${o.bold("PP-DEV")} v${i}`)} ${y}\n`),r.printUrls();const x=await f(m);if(!1!==x.inspector?.enabled){const e=r.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${r.config.server.port??5173}`;l.info(`\n ${o.cyan("🔍 Request Inspector")} ${o.dim(t+L)}\n`)}le(r,{print:!0,customShortcuts:[...(p=l.info,Se?[{key:"p",description:"start/stop the profiler",async action(){if(Se)await Te(p);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{Se=new e.Session,Se.connect(),Se.post("Profiler.enable",()=>{Se?.post("Profiler.start",()=>{p("Profiler started"),t()})})})}}}]:[]),{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),s||(s=be(a,()=>c({restart:!0}),l.info))}catch(e){if(!t)return l.error(o.red(`error when starting dev server:\n${e.stack}`),{error:e}),Te(l.info),void process.exit(1);d&&d!==r&&await d.close().catch(()=>{}),l.error(o.red(`❌ Failed to restart dev server:\n${e.stack}`),{error:e}),l.warn(o.yellow(r?"⚠️ The running dev server is kept, with its config, until the next config change":"⚠️ No dev server is running; it starts again on the next config change"))}var p};ue({logger:l,shutdown:async()=>{var e;s&&(await(e=s,e.close()),s=null),r&&(await r.close(),r=null),Te(l.info)}}),await c()})}(Me),function(e){e.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname; without a value, listen on all addresses").option("--port <port>","[number] specify port",{default:3e3}).option("--https","[boolean] no effect with pp-dev next (deprecated)").option("--open [path]","[boolean | string] no effect with pp-dev next (deprecated)").option("--cors","[boolean] no effect with pp-dev next (deprecated)").option("--strictPort","[boolean] no effect with pp-dev next (deprecated)").option("--force","[boolean] no effect with pp-dev next (deprecated)").option("--webpack","[boolean] use Webpack for Next dev (use when Turbopack/native SWC is unavailable)").option("--turbopack","[boolean] use Turbopack for Next dev when native bindings work").action(async(e,n)=>{if(Pe(n),!function(e=process.env){return"1"===e[Fe]}())return void await function(e){const{projectRoot:t,logger:n,mode:i="development",checkConfig:r=()=>je(t,i),startServerProcess:s=$e,createWatcher:a=be,stopTimeoutMs:l=1e4,processRef:c=process}=e;let d=null,p=!1,f=!1,u=null,g=null,h=!1;return new Promise(()=>{const e=async e=>{if(u){const e=u;u=null,await e.close()}c.exit(e)},i=e=>{const t=d;return t?g||(g=new Promise(i=>{if(null!==t.exitCode||null!==t.signalCode)return void i(t.exitCode);const r=setTimeout(()=>{n.warn(o.yellow(`⏰ The dev server did not stop within ${l} ms, killing it`)),t.kill("SIGKILL")},l);t.on("exit",e=>{clearTimeout(r),i(e)}),t.send({type:pe,reason:e},()=>{})}).finally(()=>{g=null}),g):Promise.resolve(0)},m=()=>{const i=s();let r;const l=new Promise(e=>r=e);d=i,p=!1,i.on("message",e=>{e?.type===de&&d===i&&(p=!0,f=!0,r(),u||h||(u=a(t,w,n.info)))});let c=!1;const m=(t,s,a)=>{if(c)return;if(c=!0,r(),d===i&&(d=null),g||h)return;const l=p,u=t??1,m=a??s??`code ${u}`;p=!1,l?(n.error(o.red(`❌ The dev server exited (${m})`)),e(u)):f?n.error(o.red(`❌ The dev server did not start after the config change (${m}); fix the config and save it again`)):e(u)};return i.on("exit",(e,t)=>m(e,t)),i.on("error",e=>m(1,null,Ie(e))),l},w=async()=>{if(!h){try{await r()}catch(e){return void n.error(o.red(`❌ The pp-dev config could not be loaded, the dev server keeps running: ${Ie(e)}`))}await i("a config change"),h||await m()}},v=async t=>{if(h)return;h=!0;const o=await i(t);await e(o??1)};c.on("SIGINT",()=>{v("SIGINT")}),c.on("SIGTERM",()=>{v("SIGTERM")}),c.on("SIGHUP",()=>{v("SIGHUP")}),c.on("exit",()=>{d&&null===d.exitCode&&null===d.signalCode&&d.kill("SIGKILL")}),m()})}({projectRoot:e?v.resolve(process.cwd(),e):process.cwd(),logger:t(n.logLevel),mode:n.mode||"development"});const i=me.filter(e=>void 0!==n[e]);let r,g;i.length>0&&t(n.logLevel).warn(o.yellow(`⚠️ ${i.map(e=>`--${e}`).join(", ")} ${1===i.length?"has":"have"} no effect with pp-dev next and will be removed.`));try{({host:r,port:g}=function(e,t){let o="localhost";!0===e||""===e?o="0.0.0.0":"string"==typeof e?o=e:"number"==typeof e&&(o=String(e));const n=void 0===t?3e3:"number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`--port must be a port number (0-65535), got ${JSON.stringify(t)}`);return{host:o,port:n}}(n.host,n.port))}catch(e){t(n.logLevel).error(o.red(`❌ ${e.message}`)),process.exit(1)}let h=null,m=null,w=null,b=null;const y=new Set,P=t(n.logLevel),x=function(e=["uncaughtException"],t=process){const o=e=>t.listeners(e);let n=null,i=null;return{beforeCreate(){n=new Map(e.map(e=>[e,new Set(o(e))]))},afterCreate(){if(!n)return 0;const r=n,s=new Map(e.map(e=>[e,o(e).filter(t=>!r.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(s.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=s,n=null,a}}}(),S=async()=>{h&&"function"==typeof h.close&&await h.close(),h=null};ue({logger:P,knownRejections:[De],shutdown:async()=>{b?.dispose(),b=null,w&&(await w.close(),w=null),await(async()=>{const e=m;if(e){for(const e of y)e.destroy();y.clear(),await new Promise(t=>{e.close(()=>t())}),m===e&&(m=null)}})(),await S()}}),await(async()=>{try{const{next:t,constants:i}=await U(),{PHASE_DEVELOPMENT_SERVER:k}=i,{createServer:T}=await(import("http")),E=await(import("next/dist/server/config.js")),C=E.default.default||E["module.exports"].default||E.default,_=e?v.resolve(process.cwd(),e):process.cwd();H(n.mode||"development",_),z();const A=await C(k,_),M=V();let R=A?.ppDev||M?.ppDev||{};if(0===Object.keys(R).length)try{const{getConfig:e}=await import("./index-DEFt8X6C.js").then(e=>e.j),t=await e(_);Object.keys(t).length>0?(R=t,P.info(o.blue("🔧 Loaded pp-dev config from standalone config file"))):P.info(o.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){P.warn(o.yellow(`⚠️ Failed to load standalone pp-dev config, using defaults: ${e instanceof Error?e.message:String(e)}`))}else P.info(o.blue("🔧 Loaded pp-dev config from Next.js config"));const{getPkg:O}=await import("./index-DEFt8X6C.js").then(e=>e.j),G=O(_).name;s(R,G);const Z=a(R,G),{templateName:W}=Z,K=Z.backendBaseURL,X=Z.templateLess,Y=Z.v7Features,Q=Z.disableSSLValidation,ee=Z.enableProxyCache,te=Z.proxyCacheTTL,oe=Z.personalAccessToken,ne=Z.miHudLess,ie=Z.inspectorEnabled,re=Z.inspectorMaxMemory,se=Z.inspectorCaptureLimit,ae=Z.appId,le=!0===Z.allowedHosts||[...Z.allowedHosts,r.toLowerCase()],ce=D({allowedHosts:Z.allowedHosts}),pe=A?.basePath;let fe="";pe?fe=pe:(fe=X?l:Y?c:d,fe+=`/${W}`);const ue=function(e){const t="1"===process.env.PP_DEV_NEXT_WEBPACK||"true"===process.env.PP_DEV_NEXT_WEBPACK;if(t&&(e.webpack||e.turbopack))throw new Error("Do not combine PP_DEV_NEXT_WEBPACK with --webpack or --turbopack");if(t)return{webpack:!0};if(e.webpack&&e.turbopack)throw new Error("Use only one of --webpack or --turbopack");return e.webpack?{webpack:!0}:e.turbopack?{turbopack:!0}:{}}(n),ge=async e=>{delete process.env.TURBOPACK,await S();const o={dev:!0,customServer:!0,hostname:r,port:g,dir:_,conf:{...A,basePath:fe,assetPrefix:fe}};e.webpack?o.webpack=!0:e.turbopack&&(o.turbopack=!0),x.beforeCreate(),h=t(o),await h.prepare(),x.afterCreate()};if(ue.webpack)await ge({webpack:!0});else if(ue.turbopack)try{await ge({turbopack:!0})}catch(e){if(!ye(e))throw e;P.warn(o.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await ge({webpack:!0})}else try{await ge({})}catch(e){if(!ye(e))throw e;P.warn(o.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await ge({webpack:!0})}if(!h)throw new Error("Next.js app failed to initialize");if(fe.endsWith("/")||(fe+="/"),"/"===fe)throw new Error('basePath cannot be equal to "/" or equal to empty string');P.info(o.green("✅ Next.js app prepared successfully")),P.info(o.blue(`🔧 pp-dev plugin configured for template: ${W}`)),P.info(o.blue(`🔧 Base path configured: ${fe}`)),K&&(P.info(o.blue(`🌐 Backend URL: ${K}`)),P.info(o.blue(`🆔 Custom App ID: ${ae}`)));const he=h.getRequestHandler(),me=g,we=r;m=T(async(e,t)=>{const o=e.headers.host;if(!p(o,le))return t.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),void t.end(f(o));try{const n=e.url||"/",i=n.split("?")[0];let r=J(n,!0);if(xe.length>0){const a=i.startsWith("/_next/")||i.startsWith("/__nextjs_");return void F(a?Se:xe,e,t,()=>{s()})}async function s(){if(i.startsWith(fe))r=J(n,!0);else{if(i===fe.replace(/\/$/,"")){const e=n.replace(i,fe);return t.writeHead(302,{Location:e}),void t.end()}if(i.startsWith("/_next/")||i.startsWith("/__nextjs_"));else if("/"===i)return t.writeHead(302,{Location:fe}),void t.end()}await he(e,t,r)}s()}catch(l){P.error(`Error handling request: ${l instanceof Error?l.message:String(l)}`,{error:l instanceof Error?l:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let ve=null;const be=(e,t,o)=>{p(e.headers.host,le)?ve?ve(e,t,o):m.listeners("upgrade").every(e=>e===be)&&t.destroy():Le(t)};m.on("upgrade",be),K?.startsWith("https://")&&(q.defaultMaxListeners=Math.max(q.defaultMaxListeners,20));const Pe=$({base:fe,templateName:W,internalServer:ce,backendBaseURL:K,mi:{appId:ae,templateLess:X,miHudLess:ne,disableSSLValidation:Q,v7Features:Y,personalAccessToken:oe},inspector:{enabled:!1!==ie,maxMemory:re,captureLimit:se},proxy:{cache:ee,cacheTtl:te,ignore:["/_next","/__nextjs_","/installHook.js.map"]},devPanelAssets:!0,rewrite:(e,t)=>({predicate:e=>{const t=e.split("?")[0];return t.startsWith(fe)&&!t.includes("/_next/")},transform:(o,n)=>{const i=e.buildPage(o,ne),r=u(i,fe,{backendBaseURL:K,templateLess:X,appId:ae,devPanelPosition:Z.devPanelPosition,devPanelHidden:Z.devPanelHidden,devPanelAutoHide:Z.devPanelAutoHide});return Buffer.from(j(t,n.headers.host??"",r))},contentType:e=>e.includes("text/html")})}),xe=Pe.rewrite?[...Pe.main,Pe.rewrite]:Pe.main,Se=Pe.essential;if(null!==Pe.proxyCacheTtl&&P.info(o.blue(`🔧 Proxy cache middleware added with TTL: ${Pe.proxyCacheTtl}ms`)),K&&Pe.mi){const e=Pe.mi;w=new Ee({allowedHosts:Z.allowedHosts});const t=A?.distDirRoot||(A?.distDir||".next").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),n=!0===A?.ppDevWrapped||!0===M?.wrapped;let r=t;if(!n)try{const e=await C(i.PHASE_PRODUCTION_BUILD,_);r=e?.distDir||t}catch{}let s,a="0.0.0";try{const e=JSON.parse(B.readFileSync(v.join(_,"package.json"),"utf-8"));a="string"==typeof e.version?e.version:a,s="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const l=new I(W,{root:_,backupFolder:v.resolve(_,Z.syncBackupsDir),maxBackups:Z.syncMaxBackups,buildTimeoutMs:Z.syncBuildTimeoutMs,nextBuild:{projectRoot:_,distDir:t,buildDistDir:r,output:A?.output,configWrapped:n,packageVersion:a,packageRepositoryUrl:s}}),c={ws:w.ws,config:{clientInjectionPlugin:{v7Features:Y}}};b=N({server:c,internalServer:ce,distService:l,miAPI:e,persistUsers:Z.persistUsers,projectRoot:_,miUrl:K});const d="function"==typeof h?.getUpgradeHandler?h.getUpgradeHandler():null;ve=(e,t,o)=>{w?.handleUpgrade(e,t,o)||(d?d(e,t,o):t.destroy())},P.info(o.blue(`🔧 ${xe.length} pp-dev middlewares initialized`)),P.info(o.blue(`🔧 ${Se.length} essential middlewares for internal routes`)),P.info(o.blue(`🔧 MiAPI initialized for backend: ${K}`)),P.info(o.blue(`🔧 Custom App ID: ${ae}`))}m.listen(me,we,()=>{const e="0.0.0.0"===we||"::"===we,t=`http://${e?"localhost":we}:${me}`;P.info(o.green(`✅ pp-dev Next.js server running at ${t}`)),P.info(o.blue(`📱 Next.js app accessible at ${t}${fe}`)),e&&P.info(o.blue("🌐 Listening on all addresses. A page opened from another device needs this machine's address in allowedDevOrigins (next.config) for Next's HMR, as with next dev -H 0.0.0.0.")),!1!==ie&&P.info(o.cyan(`🔍 Request Inspector: ${t}${L}`)),P.info(o.blue("🔧 Base path handling active")),m.on("connection",e=>{y.add(e),e.on("close",()=>y.delete(e))}),function(e=process){if("function"!=typeof e.send)return;e.stdout.write("",()=>e.send({type:de},()=>{}))}()})}catch(e){P.error(o.red(`❌ Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(P.error(o.red("❌ Next.js Peer Dependency Error:")),P.error(o.red(e.message)),P.error(o.yellow("\n💡 To fix this issue:")),P.error(o.blue(" 1. Install Next.js in your project:")),P.error(o.white(" npm install next@^16")),P.error(o.blue(" 2. Or use yarn:")),P.error(o.white(" yarn add next@^16")),P.error(o.blue(" 3. Or use pnpm:")),P.error(o.white(" pnpm add next@^16")),P.error(o.yellow("\n📖 For more information, see:")),P.error(o.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}})()})}(Me),function(e){e.command("build [root]","build for production").option("--target <target>","[string] transpile target (default: 'modules')").option("--outDir <dir>","[string] output directory (default: dist)").option("--assetsDir <dir>","[string] directory under outDir to place assets in (default: assets)").option("--assetsInlineLimit <number>","[number] static asset base64 inline threshold in bytes (default: 4096)").option("--ssr [entry]","[string] build specified entry for server-side rendering").option("--sourcemap [output]",'[boolean | "inline" | "hidden"] output source maps for build (default: false)').option("--minify [minifier]",'[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)').option("--manifest [name]","[boolean | string] emit build manifest json").option("--ssrManifest [name]","[boolean | string] emit ssr manifest json").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle (experimental)").option("--emptyOutDir","[boolean] force empty outDir when it's outside of root").option("-w, --watch","[boolean] rebuilds when modules have changed on disk").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Pe(n);const i=he(n),r=G(n);try{const t=n.mode||"production",{config:o}=await xe({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel,buildOverrides:r}),s=P(o,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await x(s),n.changelog){const t=e||process.cwd(),o=s.build?.outDir||"dist";let i="dist-zip";s.ppDevConfig&&(!1===s.ppDevConfig.distZip?i=o:"object"==typeof s.ppDevConfig.distZip&&"string"==typeof s.ppDevConfig.distZip.outDir&&(i=s.ppDevConfig.distZip.outDir)),await _e({changelog:n.changelog,executionRoot:t,newAssetsPath:v.resolve(t,o),backupsDirPath:v.resolve(t,s.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:v.resolve(t,i),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Te(e=>t(n.logLevel).info(e))}})}(Me),function(e){e.command("next-build [root]","build a Next.js app for production (`next build`) and emit VERSION/BUILD-MANIFEST/zip in the same format as `pp-dev build`").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Pe(n);const i=t(n.logLevel),r=e?v.resolve(process.cwd(),e):process.cwd(),l=G(n);process.env[g]="1";try{H(n.mode||"production",r);const{constants:e}=await U(),t=await(import("next/dist/server/config.js")),c=t.default.default||t["module.exports"].default||t.default,d=await c(e.PHASE_PRODUCTION_BUILD,r);let p=d?.ppDev||{};if(0===Object.keys(p).length){const{getConfig:e}=await import("./index-DEFt8X6C.js").then(e=>e.j);p=await e(r)}const{getPkg:f}=await import("./index-DEFt8X6C.js").then(e=>e.j),u=f(r).name;s(p,u);const g=a(p,u),b=Z(g.distZip,l,h(g.templateName)),y=W(g.versionPlugin,l),P=_(r,d);P&&i.info(o.dim(`[pp-dev] Removed stale dev route types: ${v.relative(r,P)}`)),i.info(o.cyan("[pp-dev] Running `next build`...")),await A(r);const x="string"==typeof d?.distDir&&d.distDir?d.distDir:".next",S=".next"===x?"out":x,k=v.resolve(r,S);if(!B.existsSync(k)||!B.statSync(k).isDirectory())throw new Error(`Next.js build output directory not found: ${k}. "next-build" requires "output: 'export'" in next.config (static export).`);const T=JSON.parse(B.readFileSync(v.join(r,"package.json"),"utf-8"));if(!1!==y&&!1!==y.enabled&&(await ie({outDir:k,root:r,packageVersion:"string"==typeof T.version?T.version:"0.0.0",versionFileTemplate:y.versionFileTemplate,packageRepositoryUrl:"string"==typeof T.repository?T.repository:T.repository?.url,enabled:y.enabled}),i.info(o.green(`✅ VERSION / BUILD-MANIFEST written to ${v.relative(r,k)}`))),!1!==b){const e=v.resolve(r,b.outDir),t=m(r,k,b.inDir),n=w(e,b.outFileName,"ZIP output file name");B.mkdirSync(v.dirname(n),{recursive:!0});const s=await M(t);B.writeFileSync(n,s),i.info(o.green(`✅ Zip archive written to ${v.relative(r,n)}`))}if(n.changelog){const e=!1!==b?b.outDir:S;await _e({changelog:n.changelog,executionRoot:r,newAssetsPath:k,backupsDirPath:v.resolve(r,g.syncBackupsDir),changelogDestinationPath:v.resolve(r,e),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Te(e=>t(n.logLevel).info(e))}})}(Me),function(e){e.command("changelog [oldAssetPath] [newAssetPath]","generate changelog between two assets files/folders").option("--oldAssetsPath <oldAssetsPath>","[string] path to the old assets zip file or folder").option("--newAssetsPath <newAssetsPath>","[string] path to the new assets zip file or folder").option("--destination <destination>","[string] destination folder for the changelog (default: .)").option("--filename <filename>","[string] filename for the changelog (default: CHANGELOG.html)").action(async(e,n,i)=>{Pe(i);const{oldAssetsPath:r=e,newAssetsPath:s=n,destination:a=".",filename:l="CHANGELOG.html",logLevel:c}=i,d=process.cwd();r&&s||(t(c).error(o.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const p=v.resolve(d,r),f=v.resolve(d,s),u=v.resolve(d,a),g=new Ce({oldAssetsPath:p,newAssetsPath:f,destinationPath:u,changelogFilename:l});await g.generateChangelog()})}(Me),function(e){e.command("generate-icon-font [source] [destination]","generate icon font from SVG files").option("--source <source>","[string] path to the source directory with SVG files").option("--destination <destination>","[string] path to the destination directory to save the generated font files").option("--font-name, -n <fontName>","[string] name of the font to generate (default: 'icon-font')").action(async(e,n,i)=>{Pe(i);const{source:r=e,destination:s=n,fontName:a="icon-font"}=i,l=process.cwd(),c=v.resolve(l,r),d=v.resolve(l,s),p=new Ae({sourceDir:c,outputDir:d,fontName:a}),f=t(i.logLevel);f.info(`Generating icon font from SVG files in ${o.dim(c)}`),await p.generate(),f.info(`Icon font generated and saved to ${o.dim(d)}`)})}(Me),function(e){e.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Pe(n);try{const t=n.mode||"production",{config:o}=await xe({root:e,mode:t,command:"serve",configFile:n.config,logLevel:n.logLevel}),i=await S(P(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode}),"serve");await k(i,n.force,!0)}catch(e){t(n.logLevel).error(o.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})}(Me),function(e){e.command("preview [root]","locally preview production build").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--strictPort","[boolean] exit if specified port is already in use").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--outDir <dir>","[string] output directory (default: dist)").action(async(e,n)=>{Pe(n);try{const t=n.mode||"production",{config:o}=await xe({root:e,mode:t,command:"serve",isPreview:!0,configFile:n.config,logLevel:n.logLevel});(await T(P(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode,build:{outDir:n.outDir},preview:{port:n.port,strictPort:n.strictPort,host:n.host,https:n.https,open:n.open}}))).printUrls()}catch(e){t(n.logLevel).error(o.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{Te(e=>t(n.logLevel).info(e))}})}(Me),function(e){e.command("migrate [config]","migrate pp-dev config from 0.x flat format to 1.0 grouped format").option("--dry-run","[boolean] print migrated config without writing any files").option("--format <format>","[string] output format: ts (default), js, json").option("--output <file>","[string] output file path (default: pp-dev.config.ts)").option("--no-backup","[boolean] skip backup of original config file").action(async(e,n)=>{const i=t(n.logLevel),{isLegacyFlatConfig:r,isLegacyPPWatchConfig:s,isAlreadyMigrated:a,migrateLegacyFlatConfig:l,migratePPWatchConfig:c,generateConfigFileContent:d,discoverMigrateSource:p,loadPackageJsonMigrateConfig:f}=await(import("./migrate-BxksV7OV.js")),u=n.format??"ts",g=!1!==n.backup,h=process.cwd(),m=p(h,e);m||(i.warn(o.yellow("No pp-dev or pp-watch config file found in the current directory.")),i.info(o.blue('Supported files: pp-dev.config.{ts,js,cjs,mjs,json}, .pp-watch.config.{ts,js,json}, or a "pp-dev" field in package.json')),process.exit(1));const{sourceFile:w,isWatchConfig:b,isPackageJsonConfig:y}=m;i.info(o.blue(`Found config: ${v.relative(h,w)}`));const{getPkg:P}=await import("./index-DEFt8X6C.js").then(e=>e.j),x=P();let S,k={};try{if(/\.[cm]?ts$/i.test(w)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:h,entryPoints:[w],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:"esm",mainFields:["main"]})).outputFiles[0].text,n=`pp-migrate-tmp-${Date.now()}.mjs`;B.writeFileSync(n,o);try{const e=await(import(t(v.resolve(h,n)).toString()));k=e.default?.default??e.default??e}finally{B.existsSync(n)&&B.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(w)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(v.resolve(h,w)).toString()));k=t.default?.default??t.default??t}else y?k=f(w):w.endsWith(".json")&&(k=JSON.parse(B.readFileSync(w,"utf-8")))}catch(e){i.error(o.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(o.red("Config file did not export a valid object.")),process.exit(1)),a(k)?(i.info(o.green("Config is already in 1.0 format — nothing to migrate.")),process.exit(0)):b||s(k)?(i.info(o.blue("Detected pp-watch config format → migrating to 1.0")),S=c(k)):r(k)?(i.info(o.blue("Detected 0.x flat config format → migrating to 1.0")),S=l(k,x.name)):(i.warn(o.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=d(S,u),L=n.output??v.join(h,`pp-dev.config.${u}`);if(n.dryRun&&(i.info(o.green(`\n--- Migrated config (dry-run) → ${v.relative(h,L)} ---\n`)),process.stdout.write(`${T}\n`),process.exit(0)),g&&!y&&B.existsSync(w)){const e=`${w}.bak`;B.copyFileSync(w,e),i.info(o.blue(`Backed up original to: ${v.relative(h,e)}`))}B.writeFileSync(L,T,"utf-8"),i.info(o.green(`✅ Migration complete → ${v.relative(h,L)}`)),y?i.info(o.yellow('You can now remove the "pp-dev" field from package.json.')):w!==L&&B.existsSync(w)&&i.info(o.yellow(`You can now delete the old config: ${v.relative(h,w)}`))})}(Me),Me.help(),Me.version(i),Me.parse();export{Te as stopProfiler};
1
+ import{cac as e}from"cac";import{c as t,a as o,P as n,V as i,b as r,d as s,v as a,n as l,e as c,f as d,g as p,i as f,h as u,j as g,k as h,l as m,r as v,m as w}from"./auth.provider-BFK6x9Df.js";import*as b from"path";import{performance as y}from"node:perf_hooks";import{mergeConfig as P,loadConfigFromFile as x,normalizePath as S,build as k,resolveConfig as T,optimizeDeps as E,preview as L}from"vite";import{I as D,P as F,c as j,a as $,r as I,b as N,u as C,D as _,s as A,e as M,d as R,f as H,z as O}from"./internal.middleware-CC20He9L.js";import*as U from"fs";import{watch as V}from"chokidar";import{l as z,g as G,s as Z,c as W,r as B,a as q,b as J,d as K}from"./index-PvH-M_Io.js";import{EventEmitter as X}from"node:events";import{parse as Y}from"url";import{WebSocketServer as Q,WebSocket as ee}from"ws";import{fork as te}from"node:child_process";import*as oe from"node:path";import*as ne from"dir-compare";import ie from"diff-match-patch";import{isBinaryFile as re}from"isbinaryfile";import*as se from"os";import*as ae from"crypto";import{w as le}from"./version-manifest-BVgENnKn.js";import"picocolors";import"ejs";import"node:net";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"zlib";import"node:crypto";import"process";import"jszip";import"node:fs";import"node:fs/promises";import"child_process";import"module";import"node:os";import"express";import"node:module";import"./helpers.js";import"fs/promises";import"util";function ce(e){return null!=e&&!1!==e}let de=null;const pe=new WeakMap;function fe(e,n){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;pe.set(e,n);const i=t();n.print&&i.info(o.dim(o.green(" ➜"))+o.dim(" press ")+o.bold("h")+o.dim(" to show help"));const r=(n.customShortcuts??[]).filter(ce).concat(ue);de?.(),de=null;let s=!1;const a=process.stdin.isPaused(),l=process.stdin,c=Boolean(l.isRaw),d=async t=>{if(""===t)return void function(e=process){"win32"===e.platform?e.emit("SIGINT","SIGINT"):e.kill(e.pid,"SIGINT")}();if(""===t)return void await e.close().finally(()=>process.exit(0));if(s)return;"h"===t&&i.info(["",o.bold(" Shortcuts"),...r.map(e=>o.dim(" press ")+o.bold(e.key)+o.dim(` to ${e.description}`))].join("\n"));const n=r.find(e=>e.key===t);if(n){s=!0;try{await n.action(e)}catch(e){i.error(o.red(`Shortcut '${t}' failed: ${e instanceof Error?e.stack??e.message:String(e)}`))}finally{s=!1}}};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{de===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),a&&process.stdin.pause(),de=null)};de=f,p.on("close",f)}const ue=[{key:"r",description:"restart the server",async action(e){const t=pe.get(e);await e.restart(),t&&fe(e,{...t,print:!1})}},{key:"u",description:"show server url",action(e){e.config.logger.info(""),e.printUrls()}},{key:"o",description:"open in browser",action(e){e.openBrowser()}},{key:"c",description:"clear console",action(e){e.config.logger.clearScreen("error")}},{key:"q",description:"quit",async action(e){await e.close().finally(()=>process.exit())}},{key:"C",description:"clear proxy cache",action(e){e.cache&&(e.cache.clear(),e.config.logger.info("Proxy cache cleared"))}}],ge="pp-dev:ready",he="pp-dev:shutdown";function me(e){return e instanceof Error?e.stack??e.message:String(e)}function ve({logger:e,knownRejections:t=[],shutdown:n,shutdownTimeoutMs:i=5e3,processRef:r=process}){let s=!1,a=!1,l=0;const c=async(t,c,{repeatable:d=!0}={})=>{if((e=>{l=Math.max(l,e)})(c),s){if(d&&(e=>"SIGINT"===e||"SIGTERM"===e||"SIGHUP"===e)(t)){if(a)return void(a=!1);e.warn(o.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),r.exit(l)}return}s=!0,a=!d,e.info(o.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const p=setTimeout(()=>{e.error(o.red(`⏰ Shutdown did not finish within ${i} ms, forcing exit`)),r.exit(1)},i);try{await n(),clearTimeout(p),e.info(o.green("✅ Graceful shutdown completed")),r.exit(l)}catch(t){clearTimeout(p),e.error(o.red(`❌ Error during graceful shutdown: ${me(t)}`)),r.exit(1)}},d=()=>{c("SIGINT",0)},p=()=>{c("SIGTERM",0)},f=()=>{c("SIGHUP",0)},u=t=>{e.error(o.red(`❌ Uncaught exception: ${me(t)}`)),c("uncaughtException",1)},g=n=>{const i=t.find(e=>e.matches(n));i?e.info(o.dim(i.message)):e.error(o.red(`❌ Unhandled promise rejection (the server keeps running): ${me(n)}`))},h=e=>{(function(e){return"object"==typeof e&&null!==e&&e.type===he&&"string"==typeof e.reason})(e)&&c(e.reason,0,{repeatable:!1})},m=()=>{c("the end of the pp-dev process",0,{repeatable:!1})},v="function"==typeof r.send;return r.on("SIGINT",d),r.on("SIGTERM",p),r.on("SIGHUP",f),r.on("uncaughtException",u),r.on("unhandledRejection",g),v&&(r.on("message",h),r.on("disconnect",m)),()=>{r.off("SIGINT",d),r.off("SIGTERM",p),r.off("SIGHUP",f),r.off("uncaughtException",u),r.off("unhandledRejection",g),v&&(r.off("message",h),r.off("disconnect",m))}}const we=["--","c","config","base","l","logLevel","clearScreen","configLoader","profile","d","debug","f","filter","m","mode","force","w","changelog","distZip","distZipDir","distZipFilename","versionManifest","versionFileTemplate","webpack","turbopack"];function be(e){const t={...e};for(const e of we)delete t[e];return"sourcemap"in t&&(t.sourcemap="true"===t.sourcemap||"false"!==t.sourcemap&&t.sourcemap),"watch"in t&&(t.watch=t.watch?{}:void 0),t}const ye=["https","open","cors","strictPort","force"];const Pe=[...n,"package.json","next.config.js","next.config.mjs","next.config.cjs","next.config.ts","next.config.mts","vite.config.js","vite.config.mjs","vite.config.cjs","vite.config.ts","vite.config.mts","vite.config.cts"];function xe(e="development"){return[".env",".env.local",`.env.${e}`,`.env.${e}.local`]}function Se(e){return e instanceof Error?e.stack??e.message:String(e)}function ke(e,t,n,i={}){const{debounceMs:r=500,mode:s,files:a=[]}=i,l=b.resolve(e),c=new Set(function(e="development"){return[...Pe,...xe(e)]}(s)),d=new Set,p=new Set([l]),f=e=>{const t=[];for(const o of e.map(e=>b.resolve(e))){if(d.has(o))continue;d.add(o);const e=b.dirname(o);!p.has(e)&&U.existsSync(e)&&(p.add(e),t.push(e))}return t};f(a);const u=V([...p],{ignored:(e,t)=>{if(!t)return!1;const o=b.resolve(e);return t.isDirectory()?!p.has(o):!(d.has(o)||b.dirname(o)===l&&c.has(b.basename(o)))},depth:0,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let g=null,h=!1,m=!1,v=!1;const w=()=>{g&&clearTimeout(g),g=setTimeout(()=>{(async()=>{if(g=null,!v)if(h)m=!0;else{h=!0;try{n(o.yellow("🔄 Restarting dev server due to config change...")),await t()}catch(e){n(o.red(`❌ Failed to restart dev server: ${Se(e)}`))}finally{h=!1}m&&!v&&(m=!1,n(o.blue("🔧 Config changed again during the restart")),w())}})()},r)},y=e=>t=>{n(o.blue(`🔧 Config file ${e}: ${b.relative(l,t)}`)),w()};u.on("change",y("changed")),u.on("add",y("added")),u.on("unlink",y("removed")),u.on("error",e=>{n(o.red(`❌ Config watcher error: ${Se(e)}`))});const P=new Promise(e=>{u.once("ready",()=>{n(o.blue("🔧 Config file watcher started")),e()})});return{watcher:u,ready:P,add(e){const t=f(e);t.length>0&&!v&&u.add(t)},async close(){v=!0,g&&(clearTimeout(g),g=null),await u.close()}}}function Te(e){if(!e||"object"!=typeof e||!("message"in e))return!1;const t=String(e.message);return/Turbopack is not supported/i.test(t)||/native bindings are not available/i.test(t)||/Only WebAssembly \(WASM\) bindings were loaded/i.test(t)}const Ee=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};async function Le(e){const{root:t,mode:o}=e,n=b.resolve(process.cwd(),t??".");z(o,n);const i=await async function(e){const{mode:t,command:o,isPreview:n}=e,i="build"===o||n?"production":"development",r=void 0===process.env.NODE_ENV;r&&Object.assign(process.env,{NODE_ENV:i});try{return await x({mode:t,command:o,isSsrBuild:"build"===o&&!0===e.ssr,...n?{isPreview:n}:{}},e.configFile,e.root,e.logLevel)}finally{r&&Reflect.deleteProperty(process.env,"NODE_ENV")}}(e);let r=await G(e.buildOverrides,{mode:o,root:n});i&&(r=P(r,i.config));const s=t?n:r.root?b.resolve(r.root):n,a=!1===r.envDir?null:b.resolve(s,r.envDir??".");return{config:r,envDir:n,configFile:i?{path:i.path,dependencies:i.dependencies}:null,viteEnvFiles:a?xe(o).map(e=>b.join(a,e)):[]}}function De(e){const t=function(e){const{envDir:t}=e;return!1===t?[]:xe(e.mode).map(e=>S(b.join(t,e)))}(e.config);return t.length>0&&e.watcher.unwatch(t),t}let Fe=global.__pp_dev_profile_session,je=0;const $e=e=>{if(Fe)return new Promise((t,n)=>{Fe.post("Profiler.stop",(i,{profile:r})=>{if(i)n(i);else{const n=b.resolve(`./pp-dev-profile-${je++}.cpuprofile`);U.writeFileSync(n,JSON.stringify(r)),e(o.yellow(`CPU profile written to ${o.white(o.dim(n))}`)),Fe=void 0,t()}})})};function Ie(e){e.once("error",()=>e.destroy()),e.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>e.destroy())}class Ne{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;allowedHosts;constructor({allowedHosts:e=[]}={}){this.allowedHosts=e,this.wss=new Q({noServer:!0}),this.wss.on("connection",e=>this.onConnection(e)),this.wss.on("error",e=>this.fireLifecycle("error",e)),this.ws={on:(e,t)=>{"close"!==e&&"error"!==e?this.getEventSet(e).add(t):this.getLifecycleSet(e).add(t)},off:(e,t)=>{"close"!==e&&"error"!==e?this.eventListeners.get(e)?.delete(t):this.lifecycleListeners.get(e)?.delete(t)},send:(e,t)=>{if("string"==typeof e)for(const o of this.clients.keys())this.sendToSocket(o,e,t);else{const t=JSON.stringify(e);for(const e of this.clients.keys())e.readyState===ee.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===F&&(r(e,this.allowedHosts)?(Ie(t),!0):(this.wss.handleUpgrade(e,t,o,t=>{this.wss.emit("connection",t,e)}),!0))}async close(){this.fireLifecycle("close");for(const e of this.clients.keys())e.terminate();this.clients.clear(),await new Promise(e=>this.wss.close(()=>e()))}onConnection(e){const t={send:(t,o)=>this.sendToSocket(e,t,o),socket:e};this.clients.set(e,t),e.on("message",e=>this.onMessage(t,e)),e.on("close",()=>this.clients.delete(e)),e.on("error",()=>{})}onMessage(e,o){let n;try{n=JSON.parse(o.toString())}catch{return}if(!n||"custom"!==n.type||"string"!=typeof n.event)return;const i=this.eventListeners.get(n.event);if(i)for(const o of i)try{o(n.data,e)}catch(e){t().error(`ws handler for "${n.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===ee.OPEN&&e.send(JSON.stringify({type:"custom",event:t,data:o}))}fireLifecycle(e,t){for(const o of this.lifecycleListeners.get(e)??[])try{o(t)}catch{}}getEventSet(e){let t=this.eventListeners.get(e);return t||(t=new Set,this.eventListeners.set(e,t)),t}getLifecycleSet(e){let t=this.lifecycleListeners.get(e);return t||(t=new Set,this.lifecycleListeners.set(e,t)),t}}const Ce={matches:e=>e instanceof Error&&"Worker creator already registered"===e.message,message:"Next.js kept its Turbopack worker pool from before the restart ('Worker creator already registered')"};const _e="PP_DEV_NEXT_SERVER_PROCESS";function Ae(){const[,e,...t]=process.argv;if(!e)throw new Error("pp-dev next: cannot start the server process, no script in process.argv");return te(e,t,{env:{...process.env,[_e]:"1"},stdio:"inherit",execArgv:process.execArgv})}async function Me(e,t="development"){const[{loadPPDevEnv:o},{clearConfigCache:n,findConfig:i,getPkg:r},{validatePPDevConfig:s}]=await Promise.all([import("./index-PvH-M_Io.js").then(e=>e.h),import("./index-PvH-M_Io.js").then(e=>e.j),import("./auth.provider-BFK6x9Df.js").then(e=>e.C)]);o(t,e),n();const{config:a,found:l}=await i(e);l&&s(a,r(e).name)}function Re(e){return e instanceof Error?e.message:String(e)}const He=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class Oe{oldAssetsPath;newAssetsPath;destinationPath;changelogFilename;changelogTemplate='<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8" />\n <title>Changelog Diff</title>\n <style>\n tr,\n td {\n padding: 0;\n }\n .diff-file {\n margin-top: 20px;\n border: 1px solid #e1e4e8;\n border-radius: 6px;\n }\n .diff-file-title {\n padding: 10px 20px;\n background-color: #f6f8fa;\n border-bottom: 1px solid #e1e4e8;\n border-radius: 6px 6px 0 0;\n font-weight: bold;\n }\n .diff-file-title .renamed {\n font-weight: normal;\n }\n .diff-file-title .renamed .from {\n color: #cb2431;\n }\n .diff-file-title .renamed .to {\n color: #22863a;\n }\n .diff-file-title .added {\n color: #22863a;\n }\n .diff-file-title .deleted {\n color: #cb2431;\n }\n .diff-file-content {\n }\n .diff-table {\n tab-size: 8;\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n }\n .blob-num {\n position: relative;\n color: #1f2328;\n width: 1%;\n min-width: 50px;\n padding: 0 10px;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n line-height: 20px;\n text-align: right;\n white-space: nowrap;\n vertical-align: top;\n cursor: pointer;\n -webkit-user-select: none;\n user-select: none;\n }\n .blob-num.addition {\n background-color: #ccffd8;\n border-color: #1f883e;\n }\n .blob-num.deletion {\n background-color: #ffd7d5;\n border-color: #cf222e;\n }\n .blob-num::before {\n content: attr(data-line-number);\n }\n .blob-code {\n position: relative;\n padding: 0 10px 0 22px;\n vertical-align: top;\n color: #1f2329;\n }\n .blob-code.code-addition {\n background-color: #e6ffec;\n }\n .blob-code.code-deletion {\n background-color: #ffebe9;\n }\n .blob-code.skip,\n .blob-code.message {\n text-align: center;\n }\n .blob-code.skip .blob-code-inner,\n .blob-code.message .blob-code-inner {\n font-weight: bold;\n color: #6a737d;\n padding: 10px 0;\n }\n .blob-code-inner {\n display: table-cell;\n overflow: visible;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n word-wrap: anywhere;\n white-space: pre-wrap;\n }\n .blob-code-inner::before {\n content: attr(data-code-prefix);\n position: absolute;\n top: 1px;\n left: 8px;\n padding-right: 8px;\n }\n </style>\n </head>\n <body>\n <h1>Changelog Diff</h1>\n\n %FILES%\n </body>\n </html>';diffFileTemplateHandler;diffLineTemplateHandler;contextLines=3;logger;constructor(e){const{oldAssetsPath:n,newAssetsPath:i,destinationPath:r,changelogTemplate:s,diffFileTemplateHandler:a,diffLineTemplateHandler:l,changelogFilename:c,contextLines:d}=e;if(this.logger=t(),!n||!i||!r)throw new Error("Previous assets path, current assets path and destination path are required");if(n===i)throw new Error("Previous and current assets paths must be different");if(!this.isExists(n))throw new Error(`Previous assets path ${n} does not exist`);if(!this.isExists(i))throw new Error(`Current assets path ${i} does not exist`);if(this.isZipFile(n)){const e=b.resolve(se.tmpdir(),ae.createHash("md5").update(n).digest("hex"));this.oldAssetsPath=this.unzipFile(n,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);return e})}else{if(!this.isFolder(n))throw new Error(`Invalid previous assets path ${n}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(n);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(i)){const e=b.resolve(se.tmpdir(),ae.createHash("md5").update(i).digest("hex"));this.newAssetsPath=this.unzipFile(i,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Current assets path ${e} is empty`);return e})}else{if(!this.isFolder(i))throw new Error(`Invalid current assets path ${i}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(i);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${i} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=r,this.mkdirpSync(this.destinationPath),this.changelogFilename=c||"CHANGELOG.html",s&&(this.templateIsValid(s)?this.changelogTemplate=s:this.logger.warn(o.yellow("Invalid changelog template, using default"))),"function"==typeof a&&(this.diffFileTemplateHandler=a),"function"==typeof l&&(this.diffLineTemplateHandler=l),d&&(this.contextLines=d)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return U.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return U.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===U.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){U.existsSync(e)||U.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){U.rmSync(t,{force:!0,recursive:!0}),await M(e,t)}normalizeAssetFolderPath(e){const t=U.readdirSync(e);return 1===t.length&&U.lstatSync(b.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(b.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${r=o??"",r.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var r}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(o.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await ne.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(He.test(e)&&(e=e.replace(He,"$1$3")),He.test(t)&&(t=t.replace(He,"$1$3")),0===e.localeCompare(t)?0:e.localeCompare(t)>0?1:-1)});return e.diffSet?.filter(e=>"equal"!==e.state||e.name1!==e.name2)||[]}async generateAssetFilesDiff(e,t){const o=new ie,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let r=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:r+o+1,lineType:t})).slice(0,n);return-1!==t&&(r+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(b.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${t}</span> -> <span class="to">${o}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const t=e.path1&&e.name1?b.join(e.path1,e.name1):null,o=e.path2&&e.name2?b.join(e.path2,e.name2):null,n=this.pathToPosix(b.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&t)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&o)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&t&&o){const i=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(b.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await re(t)||await re(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(U.readFileSync(t,"utf-8"),U.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(o.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(o.green("Writing changelog file"));const n=this.changelogTemplate.split("%FILES%");n.splice(1,0,t);const i=n.join("");U.writeFileSync(b.join(this.destinationPath,this.changelogFilename),i),this.logger.info(o.green(`Changelog file written to ${b.join(this.destinationPath,this.changelogFilename)}`))}}async function Ue(e){const{changelog:n,executionRoot:i,newAssetsPath:r,backupsDirPath:s,changelogDestinationPath:a,logLevel:l}=e;let c;if("string"==typeof n)c=b.resolve(i,n);else{if(!U.existsSync(s))return void t(l).warn(o.yellow("backups directory not found, skipping changelog generation"));const e=U.readdirSync(s,{withFileTypes:!0});if(!e.length)return void t(l).warn(o.yellow("no backups found, skipping changelog generation"));const n=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!n.length)return void t(l).warn(o.yellow("no ZIP backups found, skipping changelog generation"));const i=n.reduce((e,t)=>U.statSync(b.resolve(s,e.name)).mtimeMs>U.statSync(b.resolve(s,t.name)).mtimeMs?e:t).name;c=b.resolve(s,i)}const d=new Oe({oldAssetsPath:c,newAssetsPath:r,destinationPath:a});await d.generateChangelog()}class Ve{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){const{default:e}=await(import("svgtofont"));await e({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const ze=e("pp-dev");ze.option("-c, --config <file>","[string] use specified config file").option("--base <path>","[string] public base path (default: /)").option("-l, --logLevel <level>","[string] info | warn | error | silent").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("-d, --debug [feat]","[string | boolean] show debug logs").option("-f, --filter <filter>","[string] filter debug logs").option("-m, --mode <mode>","[string] set env mode"),function(e){e.command("[root]","start dev server").alias("serve").alias("dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--cors","[boolean] enable CORS").option("--strictPort","[boolean] exit if specified port is already in use").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Ee(n);let r=null,s=null;const a=e?b.resolve(process.cwd(),e):process.cwd(),l=t(n.logLevel),c=async({restart:t=!1}={})=>{let d=null;try{const{clearConfigCache:t,getConfig:f}=await import("./index-PvH-M_Io.js").then(e=>e.j);t();const{createServer:u}=await(import("vite")),g=n.mode||"development",{config:h,envDir:m,configFile:v,viteEnvFiles:w}=await Le({root:e,mode:g,command:"serve",configFile:n.config,logLevel:n.logLevel}),b=[...w,...v?[v.path,...v.dependencies]:[]],x=n.base??h.base;if(!x||"/"===x)throw new Error('base cannot be equal to "/" or empty string');if(d=await u(P(h,{root:e,base:n.base,mode:n.mode,configFile:!1,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:{...be(n),watch:{ignored:w}},customLogger:l},!0)),!d.httpServer)throw new Error("HTTP server not available");if(b.push(...De(d)),r){const e=r;r=null,l.info(o.yellow("🛑 Stopping existing dev server...")),await e.close()}await d.listen(),r=d;const S=global.__pp_dev_start_time??!1,k=S?o.dim(`ready in ${o.reset(o.bold(Math.ceil(y.now()-S)))} ms`):"";l.info(`\n ${o.green(`${o.bold("PP-DEV")} v${i}`)} ${k}\n`),r.printUrls();const T=await f(m);if(!1!==T.inspector?.enabled){const e=r.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${r.config.server.port??5173}`;l.info(`\n ${o.cyan("🔍 Request Inspector")} ${o.dim(t+D)}\n`)}fe(r,{print:!0,customShortcuts:[...(p=l.info,Fe?[{key:"p",description:"start/stop the profiler",async action(){if(Fe)await $e(p);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{Fe=new e.Session,Fe.connect(),Fe.post("Profiler.enable",()=>{Fe?.post("Profiler.start",()=>{p("Profiler started"),t()})})})}}}]:[]),{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),s?s.add(b):s=ke(a,()=>c({restart:!0}),l.info,{mode:g,files:b})}catch(e){if(!t)return l.error(o.red(`error when starting dev server:\n${e.stack}`),{error:e}),$e(l.info),void process.exit(1);d&&d!==r&&await d.close().catch(()=>{}),l.error(o.red(`❌ Failed to restart dev server:\n${e.stack}`),{error:e}),l.warn(o.yellow(r?"⚠️ The running dev server is kept, with its config, until the next config change":"⚠️ No dev server is running; it starts again on the next config change"))}var p};ve({logger:l,shutdown:async()=>{var e;s&&(await(e=s,e.close()),s=null),r&&(await r.close(),r=null),$e(l.info)}}),await c()})}(ze),function(e){e.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname; without a value, listen on all addresses").option("--port <port>","[number] specify port",{default:3e3}).option("--https","[boolean] no effect with pp-dev next (deprecated)").option("--open [path]","[boolean | string] no effect with pp-dev next (deprecated)").option("--cors","[boolean] no effect with pp-dev next (deprecated)").option("--strictPort","[boolean] no effect with pp-dev next (deprecated)").option("--force","[boolean] no effect with pp-dev next (deprecated)").option("--webpack","[boolean] use Webpack for Next dev (use when Turbopack/native SWC is unavailable)").option("--turbopack","[boolean] use Turbopack for Next dev when native bindings work").action(async(e,n)=>{if(Ee(n),Object.assign(process.env,{NODE_ENV:"development"}),!function(e=process.env){return"1"===e[_e]}())return void await function(e){const{projectRoot:t,logger:n,mode:i="development",checkConfig:r=()=>Me(t,i),startServerProcess:s=Ae,createWatcher:a=ke,stopTimeoutMs:l=1e4,processRef:c=process}=e;let d=null,p=!1,f=!1,u=null,g=null,h=!1;return new Promise(()=>{const e=async e=>{if(u){const e=u;u=null,await e.close()}c.exit(e)},m=e=>{const t=d;return t?g||(g=new Promise(i=>{if(null!==t.exitCode||null!==t.signalCode)return void i(t.exitCode);const r=setTimeout(()=>{n.warn(o.yellow(`⏰ The dev server did not stop within ${l} ms, killing it`)),t.kill("SIGKILL")},l);t.on("exit",e=>{clearTimeout(r),i(e)}),t.send({type:he,reason:e},()=>{})}).finally(()=>{g=null}),g):Promise.resolve(0)},v=()=>{const r=s();let l;const c=new Promise(e=>l=e);d=r,p=!1,r.on("message",e=>{e?.type===ge&&d===r&&(p=!0,f=!0,l(),u||h||(u=a(t,w,n.info,{mode:i,files:xe("development").map(e=>oe.join(t,e))})))});let m=!1;const v=(t,i,s)=>{if(m)return;if(m=!0,l(),d===r&&(d=null),g||h)return;const a=p,c=t??1,u=s??i??`code ${c}`;p=!1,a?(n.error(o.red(`❌ The dev server exited (${u})`)),e(c)):f?n.error(o.red(`❌ The dev server did not start after the config change (${u}); fix the config and save it again`)):e(c)};return r.on("exit",(e,t)=>v(e,t)),r.on("error",e=>v(1,null,Re(e))),c},w=async()=>{if(!h){try{await r()}catch(e){return void n.error(o.red(`❌ The pp-dev config could not be loaded, the dev server keeps running: ${Re(e)}`))}await m("a config change"),h||await v()}},b=async t=>{if(h)return;h=!0;const o=await m(t);await e(o??1)};c.on("SIGINT",()=>{b("SIGINT")}),c.on("SIGTERM",()=>{b("SIGTERM")}),c.on("SIGHUP",()=>{b("SIGHUP")}),c.on("exit",()=>{d&&null===d.exitCode&&null===d.signalCode&&d.kill("SIGKILL")}),v()})}({projectRoot:e?b.resolve(process.cwd(),e):process.cwd(),logger:t(n.logLevel),mode:n.mode||"development"});const i=ye.filter(e=>void 0!==n[e]);let r,h;i.length>0&&t(n.logLevel).warn(o.yellow(`⚠️ ${i.map(e=>`--${e}`).join(", ")} ${1===i.length?"has":"have"} no effect with pp-dev next and will be removed.`));try{({host:r,port:h}=function(e,t){let o="localhost";!0===e||""===e?o="0.0.0.0":"string"==typeof e?o=e:"number"==typeof e&&(o=String(e));const n=void 0===t?3e3:"number"==typeof t?t:"string"==typeof t&&t.trim()?Number(t):NaN;if(!Number.isInteger(n)||n<0||n>65535)throw new Error(`--port must be a port number (0-65535), got ${JSON.stringify(t)}`);return{host:o,port:n}}(n.host,n.port))}catch(e){t(n.logLevel).error(o.red(`❌ ${e.message}`)),process.exit(1)}let m=null,v=null,w=null,y=null;const P=new Set,x=t(n.logLevel),S=function(e=["uncaughtException"],t=process){const o=e=>t.listeners(e);let n=null,i=null;return{beforeCreate(){n=new Map(e.map(e=>[e,new Set(o(e))]))},afterCreate(){if(!n)return 0;const r=n,s=new Map(e.map(e=>[e,o(e).filter(t=>!r.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(s.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=s,n=null,a}}}(),k=async()=>{m&&"function"==typeof m.close&&await m.close(),m=null};ve({logger:x,knownRejections:[Ce],shutdown:async()=>{y?.dispose(),y=null,w&&(await w.close(),w=null),await(async()=>{const e=v;if(e){for(const e of P)e.destroy();P.clear(),await new Promise(t=>{e.close(()=>t())}),v===e&&(v=null)}})(),await k()}}),await(async()=>{try{const{next:t,constants:i}=await Z(),{PHASE_DEVELOPMENT_SERVER:T}=i,{createServer:E}=await(import("http")),L=await(import("next/dist/server/config.js")),F=L.default.default||L["module.exports"].default||L.default,M=e?b.resolve(process.cwd(),e):process.cwd();z(n.mode||"development",M),process.env[s]=M,W();const R=await F(T,M),H=B();let O=R?.ppDev||H?.ppDev||{};if(0===Object.keys(O).length)try{const{getConfig:e}=await import("./index-PvH-M_Io.js").then(e=>e.j),t=await e(M);Object.keys(t).length>0?(O=t,x.info(o.blue("🔧 Loaded pp-dev config from standalone config file"))):x.info(o.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){x.warn(o.yellow(`⚠️ Failed to load standalone pp-dev config, using defaults: ${e instanceof Error?e.message:String(e)}`))}else x.info(o.blue("🔧 Loaded pp-dev config from Next.js config"));const{getPkg:V}=await import("./index-PvH-M_Io.js").then(e=>e.j),G=V(M).name;a(O,G);const q=l(O,G),{templateName:J}=q,K=q.backendBaseURL,Q=q.templateLess,ee=q.v7Features,te=q.disableSSLValidation,oe=q.enableProxyCache,ne=q.proxyCacheTTL,ie=q.personalAccessToken,re=q.miHudLess,se=q.inspectorEnabled,ae=q.inspectorMaxMemory,le=q.inspectorCaptureLimit,ce=q.appId,de=!0===q.allowedHosts||[...q.allowedHosts,r.toLowerCase()],pe=j({allowedHosts:q.allowedHosts}),fe=R?.basePath;let ue="";fe?ue=fe:(ue=Q?c:ee?d:p,ue+=`/${J}`);const he=function(e){const t="1"===process.env.PP_DEV_NEXT_WEBPACK||"true"===process.env.PP_DEV_NEXT_WEBPACK;if(t&&(e.webpack||e.turbopack))throw new Error("Do not combine PP_DEV_NEXT_WEBPACK with --webpack or --turbopack");if(t)return{webpack:!0};if(e.webpack&&e.turbopack)throw new Error("Use only one of --webpack or --turbopack");return e.webpack?{webpack:!0}:e.turbopack?{turbopack:!0}:{}}(n),me=$(R),ve=async e=>{delete process.env.TURBOPACK,await k();const o={dev:!0,customServer:!0,hostname:r,port:h,dir:M,conf:{...R,distDir:me,basePath:ue,assetPrefix:ue}};e.webpack?o.webpack=!0:e.turbopack&&(o.turbopack=!0),S.beforeCreate(),m=t(o),await m.prepare(),S.afterCreate()};if(he.webpack)await ve({webpack:!0});else if(he.turbopack)try{await ve({turbopack:!0})}catch(e){if(!Te(e))throw e;x.warn(o.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await ve({webpack:!0})}else try{await ve({})}catch(e){if(!Te(e))throw e;x.warn(o.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await ve({webpack:!0})}if(!m)throw new Error("Next.js app failed to initialize");if(ue.endsWith("/")||(ue+="/"),"/"===ue)throw new Error('basePath cannot be equal to "/" or equal to empty string');x.info(o.green("✅ Next.js app prepared successfully")),x.info(o.blue(`🔧 pp-dev plugin configured for template: ${J}`)),x.info(o.blue(`🔧 Base path configured: ${ue}`)),K&&(x.info(o.blue(`🌐 Backend URL: ${K}`)),x.info(o.blue(`🆔 Custom App ID: ${ce}`)));const we=m.getRequestHandler(),be=h,ye=r;v=E(async(e,t)=>{const o=e.headers.host;if(!f(o,de))return t.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),void t.end(u(o));try{const n=e.url||"/",i=n.split("?")[0];let r=Y(n,!0);if(ke.length>0){const a=i.startsWith("/_next/")||i.startsWith("/__nextjs_");return void I(a?Ee:ke,e,t,()=>{s()})}async function s(){if(i.startsWith(ue))r=Y(n,!0);else{if(i===ue.replace(/\/$/,"")){const e=n.replace(i,ue);return t.writeHead(302,{Location:e}),void t.end()}if(i.startsWith("/_next/")||i.startsWith("/__nextjs_"));else if("/"===i)return t.writeHead(302,{Location:ue}),void t.end()}await we(e,t,r)}s()}catch(l){x.error(`Error handling request: ${l instanceof Error?l.message:String(l)}`,{error:l instanceof Error?l:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let Pe=null;const xe=(e,t,o)=>{f(e.headers.host,de)?Pe?Pe(e,t,o):v.listeners("upgrade").every(e=>e===xe)&&t.destroy():Ie(t)};v.on("upgrade",xe),K?.startsWith("https://")&&(X.defaultMaxListeners=Math.max(X.defaultMaxListeners,20));const Se=N({base:ue,templateName:J,internalServer:pe,backendBaseURL:K,mi:{appId:ce,templateLess:Q,miHudLess:re,disableSSLValidation:te,v7Features:ee,personalAccessToken:ie},inspector:{enabled:!1!==se,maxMemory:ae,captureLimit:le},proxy:{cache:oe,cacheTtl:ne,ignore:["/_next","/__nextjs_","/installHook.js.map"]},devPanelAssets:!0,rewrite:(e,t)=>({predicate:e=>{const t=e.split("?")[0];return t.startsWith(ue)&&!t.includes("/_next/")},transform:(o,n)=>{const i=e.buildPage(o,re),r=g(i,ue,{backendBaseURL:K,templateLess:Q,appId:ce,devPanelPosition:q.devPanelPosition,devPanelHidden:q.devPanelHidden,devPanelAutoHide:q.devPanelAutoHide});return Buffer.from(C(t,n.headers.host??"",r))},contentType:e=>e.includes("text/html")})}),ke=Se.rewrite?[...Se.main,Se.rewrite]:Se.main,Ee=Se.essential;if(null!==Se.proxyCacheTtl&&x.info(o.blue(`🔧 Proxy cache middleware added with TTL: ${Se.proxyCacheTtl}ms`)),K&&Se.mi){const e=Se.mi;w=new Ne({allowedHosts:q.allowedHosts});const t=!0===R?.ppDevWrapped||!0===H?.wrapped;let n=me;if(!t)try{const e=await F(i.PHASE_PRODUCTION_BUILD,M);n=e?.distDir||me}catch{}let r,s="0.0.0";try{const e=JSON.parse(U.readFileSync(b.join(M,"package.json"),"utf-8"));s="string"==typeof e.version?e.version:s,r="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const a=new _(J,{root:M,backupFolder:b.resolve(M,q.syncBackupsDir),maxBackups:q.syncMaxBackups,buildTimeoutMs:q.syncBuildTimeoutMs,nextBuild:{projectRoot:M,distDir:me,buildDistDir:n,output:R?.output,configWrapped:t,packageVersion:s,packageRepositoryUrl:r}}),l={ws:w.ws,config:{clientInjectionPlugin:{v7Features:ee}}};y=A({server:l,internalServer:pe,distService:a,miAPI:e,persistUsers:q.persistUsers,projectRoot:M,miUrl:K});const c="function"==typeof m?.getUpgradeHandler?m.getUpgradeHandler():null;Pe=(e,t,o)=>{w?.handleUpgrade(e,t,o)||(c?c(e,t,o):t.destroy())},x.info(o.blue(`🔧 ${ke.length} pp-dev middlewares initialized`)),x.info(o.blue(`🔧 ${Ee.length} essential middlewares for internal routes`)),x.info(o.blue(`🔧 MiAPI initialized for backend: ${K}`)),x.info(o.blue(`🔧 Custom App ID: ${ce}`))}const Le=v;await new Promise((e,t)=>{Le.once("error",t),Le.listen(be,ye,()=>{Le.off("error",t),e()})});{const e="0.0.0.0"===ye||"::"===ye,t=`http://${e?"localhost":ye}:${be}`;x.info(o.green(`✅ pp-dev Next.js server running at ${t}`)),x.info(o.blue(`📱 Next.js app accessible at ${t}${ue}`)),e&&x.info(o.blue("🌐 Listening on all addresses. A page opened from another device needs this machine's address in allowedDevOrigins (next.config) for Next's HMR, as with next dev -H 0.0.0.0.")),!1!==se&&x.info(o.cyan(`🔍 Request Inspector: ${t}${D}`)),x.info(o.blue("🔧 Base path handling active")),v.on("connection",e=>{P.add(e),e.on("close",()=>P.delete(e))}),function(e=process){if("function"!=typeof e.send)return;e.stdout.write("",()=>e.send({type:ge},()=>{}))}()}}catch(e){"EADDRINUSE"===e?.code&&(x.error(o.red(`❌ Port ${h} is already in use (${r}). Stop what is listening there, or pass another --port.`)),process.exit(1)),x.error(o.red(`❌ Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(x.error(o.red("❌ Next.js Peer Dependency Error:")),x.error(o.red(e.message)),x.error(o.yellow("\n💡 To fix this issue:")),x.error(o.blue(" 1. Install Next.js in your project:")),x.error(o.white(" npm install next@^16")),x.error(o.blue(" 2. Or use yarn:")),x.error(o.white(" yarn add next@^16")),x.error(o.blue(" 3. Or use pnpm:")),x.error(o.white(" pnpm add next@^16")),x.error(o.yellow("\n📖 For more information, see:")),x.error(o.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}})()})}(ze),function(e){e.command("build [root]","build for production").option("--target <target>","[string] transpile target (default: 'modules')").option("--outDir <dir>","[string] output directory (default: dist)").option("--assetsDir <dir>","[string] directory under outDir to place assets in (default: assets)").option("--assetsInlineLimit <number>","[number] static asset base64 inline threshold in bytes (default: 4096)").option("--ssr [entry]","[string] build specified entry for server-side rendering").option("--sourcemap [output]",'[boolean | "inline" | "hidden"] output source maps for build (default: false)').option("--minify [minifier]",'[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)').option("--manifest [name]","[boolean | string] emit build manifest json").option("--ssrManifest [name]","[boolean | string] emit ssr manifest json").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle (experimental)").option("--emptyOutDir","[boolean] force empty outDir when it's outside of root").option("-w, --watch","[boolean] rebuilds when modules have changed on disk").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Ee(n);const i=be(n),r=q(n);try{const t=n.mode||"production",{config:o}=await Le({root:e,mode:t,command:"build",ssr:Boolean(i.ssr),configFile:n.config,logLevel:n.logLevel,buildOverrides:r}),s=P(o,{root:e,base:n.base,mode:n.mode,configFile:!1,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await k(s),n.changelog){const t=e||process.cwd(),o=s.build?.outDir||"dist";let i="dist-zip";s.ppDevConfig&&(!1===s.ppDevConfig.distZip?i=o:"object"==typeof s.ppDevConfig.distZip&&"string"==typeof s.ppDevConfig.distZip.outDir&&(i=s.ppDevConfig.distZip.outDir)),await Ue({changelog:n.changelog,executionRoot:t,newAssetsPath:b.resolve(t,o),backupsDirPath:b.resolve(t,s.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:b.resolve(t,i),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{$e(e=>t(n.logLevel).info(e))}})}(ze),function(e){e.command("next-build [root]","build a Next.js app for production (`next build`) and emit VERSION/BUILD-MANIFEST/zip in the same format as `pp-dev build`").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Ee(n);const i=t(n.logLevel),r=e?b.resolve(process.cwd(),e):process.cwd(),c=q(n);process.env[h]="1";try{z(n.mode||"production",r);const{constants:e}=await Z(),t=await(import("next/dist/server/config.js")),d=t.default.default||t["module.exports"].default||t.default;process.env[s]=r,W();const p=await d(e.PHASE_PRODUCTION_BUILD,r),f=B();let u=p?.ppDev||f?.ppDev||{};if(0===Object.keys(u).length){const{getConfig:e}=await import("./index-PvH-M_Io.js").then(e=>e.j);u=await e(r)}const{getPkg:g}=await import("./index-PvH-M_Io.js").then(e=>e.j),h=g(r).name;a(u,h);const y=l(u,h),P=J(y.distZip,c,m(y.templateName)),x=K(y.versionPlugin,c),S=R(r,p);S&&i.info(o.dim(`[pp-dev] Removed stale dev route types: ${b.relative(r,S)}`)),i.info(o.cyan("[pp-dev] Running `next build`...")),await H(r);const k="string"==typeof p?.distDir&&p.distDir?p.distDir:".next",T=".next"===k?"out":k,E=b.resolve(r,T);if(!U.existsSync(E)||!U.statSync(E).isDirectory())throw new Error(`Next.js build output directory not found: ${E}. "next-build" requires "output: 'export'" in next.config (static export).`);const L=JSON.parse(U.readFileSync(b.join(r,"package.json"),"utf-8"));if(!1!==x&&!1!==x.enabled&&(await le({outDir:E,root:r,packageVersion:"string"==typeof L.version?L.version:"0.0.0",versionFileTemplate:x.versionFileTemplate,packageRepositoryUrl:"string"==typeof L.repository?L.repository:L.repository?.url,enabled:x.enabled}),i.info(o.green(`✅ VERSION / BUILD-MANIFEST written to ${b.relative(r,E)}`))),!1!==P){const e=b.resolve(r,P.outDir),t=v(r,E,P.inDir),n=w(e,P.outFileName,"ZIP output file name");U.mkdirSync(b.dirname(n),{recursive:!0});const s=await O(t);U.writeFileSync(n,s),i.info(o.green(`✅ Zip archive written to ${b.relative(r,n)}`))}if(n.changelog){const e=!1!==P?P.outDir:T;await Ue({changelog:n.changelog,executionRoot:r,newAssetsPath:E,backupsDirPath:b.resolve(r,y.syncBackupsDir),changelogDestinationPath:b.resolve(r,e),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{$e(e=>t(n.logLevel).info(e))}})}(ze),function(e){e.command("changelog [oldAssetPath] [newAssetPath]","generate changelog between two assets files/folders").option("--oldAssetsPath <oldAssetsPath>","[string] path to the old assets zip file or folder").option("--newAssetsPath <newAssetsPath>","[string] path to the new assets zip file or folder").option("--destination <destination>","[string] destination folder for the changelog (default: .)").option("--filename <filename>","[string] filename for the changelog (default: CHANGELOG.html)").action(async(e,n,i)=>{Ee(i);const{oldAssetsPath:r=e,newAssetsPath:s=n,destination:a=".",filename:l="CHANGELOG.html",logLevel:c}=i,d=process.cwd();r&&s||(t(c).error(o.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const p=b.resolve(d,r),f=b.resolve(d,s),u=b.resolve(d,a),g=new Oe({oldAssetsPath:p,newAssetsPath:f,destinationPath:u,changelogFilename:l});await g.generateChangelog()})}(ze),function(e){e.command("generate-icon-font [source] [destination]","generate icon font from SVG files").option("--source <source>","[string] path to the source directory with SVG files").option("--destination <destination>","[string] path to the destination directory to save the generated font files").option("--font-name, -n <fontName>","[string] name of the font to generate (default: 'icon-font')").action(async(e,n,i)=>{Ee(i);const{source:r=e,destination:s=n,fontName:a="icon-font"}=i,l=process.cwd(),c=b.resolve(l,r),d=b.resolve(l,s),p=new Ve({sourceDir:c,outputDir:d,fontName:a}),f=t(i.logLevel);f.info(`Generating icon font from SVG files in ${o.dim(c)}`),await p.generate(),f.info(`Icon font generated and saved to ${o.dim(d)}`)})}(ze),function(e){e.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Ee(n);try{const t=n.mode||"production",{config:o}=await Le({root:e,mode:t,command:"serve",configFile:n.config,logLevel:n.logLevel}),i=await T(P(o,{root:e,base:n.base,configFile:!1,logLevel:n.logLevel,mode:n.mode}),"serve");await E(i,n.force,!0)}catch(e){t(n.logLevel).error(o.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})}(ze),function(e){e.command("preview [root]","locally preview production build").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--strictPort","[boolean] exit if specified port is already in use").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--outDir <dir>","[string] output directory (default: dist)").action(async(e,n)=>{Ee(n);try{const t=n.mode||"production",{config:o}=await Le({root:e,mode:t,command:"serve",isPreview:!0,configFile:n.config,logLevel:n.logLevel});(await L(P(o,{root:e,base:n.base,configFile:!1,logLevel:n.logLevel,mode:n.mode,build:{outDir:n.outDir},preview:{port:n.port,strictPort:n.strictPort,host:n.host,https:n.https,open:n.open}}))).printUrls()}catch(e){t(n.logLevel).error(o.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{$e(e=>t(n.logLevel).info(e))}})}(ze),function(e){e.command("migrate [config]","migrate pp-dev config from 0.x flat format to 1.0 grouped format").option("--dry-run","[boolean] print migrated config without writing any files").option("--format <format>","[string] output format: ts (default), js, json").option("--output <file>","[string] output file path (default: pp-dev.config.ts)").option("--no-backup","[boolean] skip backup of original config file").action(async(e,n)=>{const i=t(n.logLevel),{isLegacyFlatConfig:r,isLegacyPPWatchConfig:s,isAlreadyMigrated:a,migrateLegacyFlatConfig:l,migratePPWatchConfig:c,generateConfigFileContent:d,discoverMigrateSource:p,loadPackageJsonMigrateConfig:f}=await(import("./migrate-C1MkJPzS.js")),u=n.format??"ts",g=!1!==n.backup,h=process.cwd(),m=p(h,e);m||(i.warn(o.yellow("No pp-dev or pp-watch config file found in the current directory.")),i.info(o.blue('Supported files: pp-dev.config.{ts,js,cjs,mjs,json}, .pp-watch.config.{ts,js,json}, or a "pp-dev" field in package.json')),process.exit(1));const{sourceFile:v,isWatchConfig:w,isPackageJsonConfig:y}=m;i.info(o.blue(`Found config: ${b.relative(h,v)}`));const{getPkg:P}=await import("./index-PvH-M_Io.js").then(e=>e.j),x=P();let S,k={};try{if(/\.[cm]?ts$/i.test(v)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:h,entryPoints:[v],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:"esm",mainFields:["main"]})).outputFiles[0].text,n=`pp-migrate-tmp-${Date.now()}.mjs`;U.writeFileSync(n,o);try{const e=await(import(t(b.resolve(h,n)).toString()));k=e.default?.default??e.default??e}finally{U.existsSync(n)&&U.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(v)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(b.resolve(h,v)).toString()));k=t.default?.default??t.default??t}else y?k=f(v):v.endsWith(".json")&&(k=JSON.parse(U.readFileSync(v,"utf-8")))}catch(e){i.error(o.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(o.red("Config file did not export a valid object.")),process.exit(1)),a(k)?(i.info(o.green("Config is already in 1.0 format — nothing to migrate.")),process.exit(0)):w||s(k)?(i.info(o.blue("Detected pp-watch config format → migrating to 1.0")),S=c(k)):r(k)?(i.info(o.blue("Detected 0.x flat config format → migrating to 1.0")),S=l(k,x.name)):(i.warn(o.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=d(S,u),E=n.output??b.join(h,`pp-dev.config.${u}`);if(n.dryRun&&(i.info(o.green(`\n--- Migrated config (dry-run) → ${b.relative(h,E)} ---\n`)),process.stdout.write(`${T}\n`),process.exit(0)),g&&!y&&U.existsSync(v)){const e=`${v}.bak`;U.copyFileSync(v,e),i.info(o.blue(`Backed up original to: ${b.relative(h,e)}`))}U.writeFileSync(E,T,"utf-8"),i.info(o.green(`✅ Migration complete → ${b.relative(h,E)}`)),y?i.info(o.yellow('You can now remove the "pp-dev" field from package.json.')):v!==E&&U.existsSync(v)&&i.info(o.yellow(`You can now delete the old config: ${b.relative(h,v)}`))})}(ze),ze.help(),ze.version(i),ze.parse();export{$e as stopProfiler};
2
2
  //# sourceMappingURL=cli.js.map