@metricinsights/pp-dev 1.5.0-beta.18 → 1.5.0-beta.19

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 (40) hide show
  1. package/dist/cjs/cli.js +1 -1
  2. package/dist/cjs/cli.js.map +1 -1
  3. package/dist/cjs/package.json +2 -2
  4. package/dist/cjs/plugin.js +1 -1
  5. package/dist/cjs/plugin.js.map +1 -1
  6. package/dist/cjs/request-capture.middleware-C99WIh5-.js +2 -0
  7. package/dist/cjs/request-capture.middleware-C99WIh5-.js.map +1 -0
  8. package/dist/client/request-inspector.css +3 -0
  9. package/dist/client/request-inspector.css.map +1 -0
  10. package/dist/client/request-inspector.html +87 -0
  11. package/dist/client/request-inspector.js +527 -0
  12. package/dist/client/request-inspector.js.map +1 -0
  13. package/dist/client/variables-editor.css +3 -0
  14. package/dist/client/variables-editor.css.map +1 -0
  15. package/dist/client/variables-editor.html +44 -0
  16. package/dist/client/variables-editor.js +3419 -0
  17. package/dist/client/variables-editor.js.map +1 -0
  18. package/dist/esm/{auth.provider-BijrVDxp.js → auth.provider-C3RNvaVR.js} +2 -2
  19. package/dist/esm/{auth.provider-BijrVDxp.js.map → auth.provider-C3RNvaVR.js.map} +1 -1
  20. package/dist/esm/cli.js +1 -1
  21. package/dist/esm/cli.js.map +1 -1
  22. package/dist/esm/{index-CL8_j3ER.js → index-Dlv5DGp7.js} +2 -2
  23. package/dist/esm/{index-CL8_j3ER.js.map → index-Dlv5DGp7.js.map} +1 -1
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/{migrate-B0hgQCl_.js → migrate-Dm-PSAv7.js} +2 -2
  26. package/dist/esm/{migrate-B0hgQCl_.js.map → migrate-Dm-PSAv7.js.map} +1 -1
  27. package/dist/esm/package.json +2 -2
  28. package/dist/esm/plugin.js +1 -1
  29. package/dist/esm/plugin.js.map +1 -1
  30. package/dist/esm/request-capture.middleware-DEQ-qw2b.js +2 -0
  31. package/dist/esm/request-capture.middleware-DEQ-qw2b.js.map +1 -0
  32. package/dist/esm/{version-manifest-1KdgXTW2.js → version-manifest-D2Vzplem.js} +2 -2
  33. package/dist/esm/{version-manifest-1KdgXTW2.js.map → version-manifest-D2Vzplem.js.map} +1 -1
  34. package/dist/esm/{version-plugin-BExwn1e0.js → version-plugin-A4qfBm0G.js} +2 -2
  35. package/dist/esm/{version-plugin-BExwn1e0.js.map → version-plugin-A4qfBm0G.js.map} +1 -1
  36. package/package.json +2 -2
  37. package/dist/cjs/variables-editor-CdUFaTjF.js +0 -106
  38. package/dist/cjs/variables-editor-CdUFaTjF.js.map +0 -1
  39. package/dist/esm/variables-editor-CrhYJD_R.js +0 -106
  40. package/dist/esm/variables-editor-CrhYJD_R.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{readFileSync as e,existsSync as t}from"fs";import{resolve as i}from"path";import{fileURLToPath as s}from"url";import{createColors as r}from"picocolors";import n from"node:path";import{createLogger as o}from"vite";const a=i("undefined"!=typeof __filename&&__filename||s(import.meta.url),"../../.."),p=i("undefined"!=typeof __filename&&__filename||s(import.meta.url),"../.."),d=t(i(a,"package.json"))?a:p,c=i(d,"dist/client/client.js"),{version:l,name:u}=JSON.parse(e(i(d,"package.json")).toString()),m=l,f=u,h="/p",v="/pt",g="/pl",w="PP_DEV_NEXT_BUILD",b=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"],y="info";let E,k;function S(){return E??={level:y,logger:o(y)},E.logger}function A(e){return void 0!==e&&e!==E?.level&&(E={level:e,logger:o(e)}),k??={info:(e,t)=>S().info(e,t),warn:(e,t)=>S().warn(e,t),warnOnce:(e,t)=>S().warnOnce(e,t),error:(e,t)=>S().error(e,t),clearScreen:e=>S().clearScreen(e),hasErrorLogged:e=>S().hasErrorLogged(e),get hasWarned(){return S().hasWarned},set hasWarned(e){S().hasWarned=e}},k}const L=r();function D(e,t){if(!e||e.includes("\0")||n.posix.isAbsolute(e)||n.win32.isAbsolute(e)||n.win32.parse(e).root)throw new Error(`[pp-dev] ${t} must be a relative path inside its output directory.`);const i=n.posix.normalize(e.replace(/\\/g,"/"));if("."===i||".."===i||i.startsWith("../"))throw new Error(`[pp-dev] ${t} must stay inside its output directory.`);return i}function N(e){return D(`${e.replace(/^@/,"").replace(/[\\/]+/g,"-")}.zip`,"default ZIP output file name")}function _(e,t,i){const s=D(t,i),r=n.resolve(e),o=n.resolve(r,...s.split("/")),a=n.relative(r,o);if(".."===a||a.startsWith(`..${n.sep}`)||n.isAbsolute(a))throw new Error(`[pp-dev] ${i} must resolve inside its output directory.`);return o}const j=["top-left","top-right","bottom-left","bottom-right"],T=2147483647;function P(e,t){const i=e.mi?.mode??"standalone",s=e.app?.type??"template",r=e.mi?.apiVersion??7,n=e.mi?.url??process.env.MI_BACKEND_URL;if(!(e.app?.name??t))throw new Error("[pp-dev] app.name is required (or set package.json#name)");const o=e.sync?.maxBackups;if(void 0!==o&&!1!==o&&!(Number.isInteger(o)&&o>=0))throw new Error(`[pp-dev] sync.maxBackups must be a whole number ≥ 0 or false (0 and false keep every backup), got ${JSON.stringify(o)}`);const a=e.sync?.buildTimeoutMs;if(void 0!==a&&!(Number.isInteger(a)&&a>0&&a<=T))throw new Error(`[pp-dev] sync.buildTimeoutMs must be a whole number of milliseconds between 1 and 2147483647, got ${JSON.stringify(a)}`);if(e.mi?.include&&"standalone"!==i)throw console.warn('[pp-dev] mi.include is only valid when mi.mode is "standalone"'),new Error('[pp-dev] mi.include requires mi.mode to be "standalone"');if(!n){if("embedding"===i||"template"===s)throw new Error('[pp-dev] mi.url is required when mi.mode is "embedding" or app.type is "template"');"standalone"===i&&"page"===s&&console.warn("[pp-dev] mi.url is not set — dev server will run without a backend proxy")}if("template"===s&&!e.app?.id)throw new Error('[pp-dev] app.id is required when app.type is "template"');if("page"===s&&n&&("standalone"===i||r>=7)&&!e.app?.id)throw new Error('[pp-dev] app.id is required when backend page data is loaded for app.type "page"');if(void 0!==e.devPanel?.position&&!j.includes(e.devPanel.position))throw new Error(`[pp-dev] devPanel.position must be one of: ${j.join(", ")}`)}function R(e,t){const{mi:i={},app:s={},proxy:r={},build:n={},sync:o={},inspector:a={},devPanel:p={},users:d={}}=e,c=i.mode??"standalone",l=s.type??"template",u=i.apiVersion??7,m="standalone"===c;let f=!1;"top-bar"===i.include?f=!0:"shared-components"===i.include&&(f={addSharedComponentsScripts:!0,addRootElement:!1});const h="page"===l,v=s.name??t;if(!v)throw new Error("[pp-dev] app.name is required (or set package.json#name)");const g="VERSION-v{packageversion}-{currentDate}.json";let w;const b=n.zip;let y;w=!1!==b&&(!0===b||void 0===b?{outFileName:N(v),outDir:"dist-zip"}:{outFileName:D(b.fileName??N(v),"build.zip.fileName"),outDir:b.outDir??"dist-zip",...b.inDir?{inDir:b.inDir}:{}});const E=n.versionFile;let k;y=!1!==E&&(!0===E||void 0===E?{versionFileTemplate:g,enabled:!0}:{versionFileTemplate:D(E.fileNameTemplate??g,"build.versionFile.fileNameTemplate"),enabled:E.enabled??!0});const S=n.imageOptimisations;return k=!1!==S&&(!0===S||void 0===S?{}:S),{templateName:v,backendBaseURL:i.url??process.env.MI_BACKEND_URL,appId:s.id,templateLess:h,miHudLess:m,integrateMiTopBar:f,enableProxyCache:r.cache??!0,proxyCacheTTL:r.cacheTtl??6e5,disableSSLValidation:r.tls?.allowSelfSigned??!1,imageOptimizer:k,outDir:n.outDir??"dist",distZip:w,versionPlugin:y,syncBackupsDir:o.backupsDir??"backups",syncMaxBackups:o.maxBackups,syncBuildTimeoutMs:o.buildTimeoutMs,v7Features:u>=7,personalAccessToken:i.token??process.env.MI_ACCESS_TOKEN,inspectorEnabled:a.enabled??!0,inspectorMaxMemory:a.maxMemory??1073741824,inspectorCaptureLimit:a.captureLimit??10485760,devPanelPosition:p.position??"bottom-right",devPanelHidden:p.hidden??!1,devPanelAutoHide:p.autoHide??!1,persistUsers:d.persist??!1}}class x{state={isAuthenticated:!1,isRedirected:!1,lastChecked:0};listeners=new Set;getState(){return{...this.state}}isAuthenticated(){return this.state.isAuthenticated}isRedirected(){return this.state.isRedirected}setAuthenticated(e){this.state.isAuthenticated=e,this.state.lastChecked=Date.now(),this.notifyListeners()}setRedirected(e){this.state.isRedirected=e,this.notifyListeners()}updateState(e){void 0!==e.isAuthenticated&&(this.state.isAuthenticated=e.isAuthenticated),void 0!==e.isRedirected&&(this.state.isRedirected=e.isRedirected),this.state.lastChecked=Date.now(),this.notifyListeners()}reset(){this.state={isAuthenticated:!1,isRedirected:!1,lastChecked:0},this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){this.listeners.forEach(e=>{try{e(this.getState())}catch(e){A().error(`Error in auth state listener: ${e instanceof Error?e.stack??e.message:String(e)}`)}})}}const C=new x;export{x as A,w as P,m as V,L as a,N as b,A as c,h as d,g as e,v as f,b as g,f as h,c as i,d as j,D as k,C as l,R as n,_ as r,P as v};
2
- //# sourceMappingURL=auth.provider-BijrVDxp.js.map
1
+ import{readFileSync as e,existsSync as t}from"fs";import{resolve as i}from"path";import{fileURLToPath as s}from"url";import{createColors as r}from"picocolors";import n from"node:path";import{createLogger as o}from"vite";const a=i("undefined"!=typeof __filename&&__filename||s(import.meta.url),"../../.."),p=i("undefined"!=typeof __filename&&__filename||s(import.meta.url),"../.."),d=t(i(a,"package.json"))?a:p,c=i(d,"dist/client/client.js"),{version:l,name:u}=JSON.parse(e(i(d,"package.json")).toString()),m=l,f=u,h="/p",v="/pt",g="/pl",w="PP_DEV_NEXT_BUILD",b=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"],y="info";let E,k;function S(){return E??={level:y,logger:o(y)},E.logger}function A(e){return void 0!==e&&e!==E?.level&&(E={level:e,logger:o(e)}),k??={info:(e,t)=>S().info(e,t),warn:(e,t)=>S().warn(e,t),warnOnce:(e,t)=>S().warnOnce(e,t),error:(e,t)=>S().error(e,t),clearScreen:e=>S().clearScreen(e),hasErrorLogged:e=>S().hasErrorLogged(e),get hasWarned(){return S().hasWarned},set hasWarned(e){S().hasWarned=e}},k}const L=r();function D(e,t){if(!e||e.includes("\0")||n.posix.isAbsolute(e)||n.win32.isAbsolute(e)||n.win32.parse(e).root)throw new Error(`[pp-dev] ${t} must be a relative path inside its output directory.`);const i=n.posix.normalize(e.replace(/\\/g,"/"));if("."===i||".."===i||i.startsWith("../"))throw new Error(`[pp-dev] ${t} must stay inside its output directory.`);return i}function N(e){return D(`${e.replace(/^@/,"").replace(/[\\/]+/g,"-")}.zip`,"default ZIP output file name")}function _(e,t,i){const s=D(t,i),r=n.resolve(e),o=n.resolve(r,...s.split("/")),a=n.relative(r,o);if(".."===a||a.startsWith(`..${n.sep}`)||n.isAbsolute(a))throw new Error(`[pp-dev] ${i} must resolve inside its output directory.`);return o}const j=["top-left","top-right","bottom-left","bottom-right"],T=2147483647;function P(e,t){const i=e.mi?.mode??"standalone",s=e.app?.type??"template",r=e.mi?.apiVersion??7,n=e.mi?.url??process.env.MI_BACKEND_URL;if(!(e.app?.name??t))throw new Error("[pp-dev] app.name is required (or set package.json#name)");const o=e.sync?.maxBackups;if(void 0!==o&&!1!==o&&!(Number.isInteger(o)&&o>=0))throw new Error(`[pp-dev] sync.maxBackups must be a whole number ≥ 0 or false (0 and false keep every backup), got ${JSON.stringify(o)}`);const a=e.sync?.buildTimeoutMs;if(void 0!==a&&!(Number.isInteger(a)&&a>0&&a<=T))throw new Error(`[pp-dev] sync.buildTimeoutMs must be a whole number of milliseconds between 1 and 2147483647, got ${JSON.stringify(a)}`);if(e.mi?.include&&"standalone"!==i)throw console.warn('[pp-dev] mi.include is only valid when mi.mode is "standalone"'),new Error('[pp-dev] mi.include requires mi.mode to be "standalone"');if(!n){if("embedding"===i||"template"===s)throw new Error('[pp-dev] mi.url is required when mi.mode is "embedding" or app.type is "template"');"standalone"===i&&"page"===s&&console.warn("[pp-dev] mi.url is not set — dev server will run without a backend proxy")}if("template"===s&&!e.app?.id)throw new Error('[pp-dev] app.id is required when app.type is "template"');if("page"===s&&n&&("standalone"===i||r>=7)&&!e.app?.id)throw new Error('[pp-dev] app.id is required when backend page data is loaded for app.type "page"');if(void 0!==e.devPanel?.position&&!j.includes(e.devPanel.position))throw new Error(`[pp-dev] devPanel.position must be one of: ${j.join(", ")}`)}function R(e,t){const{mi:i={},app:s={},proxy:r={},build:n={},sync:o={},inspector:a={},devPanel:p={},users:d={}}=e,c=i.mode??"standalone",l=s.type??"template",u=i.apiVersion??7,m="standalone"===c;let f=!1;"top-bar"===i.include?f=!0:"shared-components"===i.include&&(f={addSharedComponentsScripts:!0,addRootElement:!1});const h="page"===l,v=s.name??t;if(!v)throw new Error("[pp-dev] app.name is required (or set package.json#name)");const g="VERSION-v{packageversion}-{currentDate}.json";let w;const b=n.zip;let y;w=!1!==b&&(!0===b||void 0===b?{outFileName:N(v),outDir:"dist-zip"}:{outFileName:D(b.fileName??N(v),"build.zip.fileName"),outDir:b.outDir??"dist-zip",...b.inDir?{inDir:b.inDir}:{}});const E=n.versionFile;let k;y=!1!==E&&(!0===E||void 0===E?{versionFileTemplate:g,enabled:!0}:{versionFileTemplate:D(E.fileNameTemplate??g,"build.versionFile.fileNameTemplate"),enabled:E.enabled??!0});const S=n.imageOptimisations;return k=!1!==S&&(!0===S||void 0===S?{}:S),{templateName:v,backendBaseURL:i.url??process.env.MI_BACKEND_URL,appId:s.id,templateLess:h,miHudLess:m,integrateMiTopBar:f,enableProxyCache:r.cache??!0,proxyCacheTTL:r.cacheTtl??6e5,disableSSLValidation:r.tls?.allowSelfSigned??!1,imageOptimizer:k,outDir:n.outDir??"dist",distZip:w,versionPlugin:y,syncBackupsDir:o.backupsDir??"backups",syncMaxBackups:o.maxBackups,syncBuildTimeoutMs:o.buildTimeoutMs,v7Features:u>=7,personalAccessToken:i.token??process.env.MI_ACCESS_TOKEN,inspectorEnabled:a.enabled??!0,inspectorMaxMemory:a.maxMemory??1073741824,inspectorCaptureLimit:a.captureLimit??10485760,devPanelPosition:p.position??"bottom-right",devPanelHidden:p.hidden??!1,devPanelAutoHide:p.autoHide??!1,persistUsers:d.persist??!1}}class x{state={isAuthenticated:!1,isRedirected:!1,lastChecked:0};listeners=new Set;getState(){return{...this.state}}isAuthenticated(){return this.state.isAuthenticated}isRedirected(){return this.state.isRedirected}setAuthenticated(e){this.state.isAuthenticated=e,this.state.lastChecked=Date.now(),this.notifyListeners()}setRedirected(e){this.state.isRedirected=e,this.notifyListeners()}updateState(e){void 0!==e.isAuthenticated&&(this.state.isAuthenticated=e.isAuthenticated),void 0!==e.isRedirected&&(this.state.isRedirected=e.isRedirected),this.state.lastChecked=Date.now(),this.notifyListeners()}reset(){this.state={isAuthenticated:!1,isRedirected:!1,lastChecked:0},this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){this.listeners.forEach(e=>{try{e(this.getState())}catch(e){A().error(`Error in auth state listener: ${e instanceof Error?e.stack??e.message:String(e)}`)}})}}const C=new x;export{x as A,b as P,m as V,L as a,h as b,A as c,g as d,v as e,w as f,N as g,f as h,c as i,d as j,D as k,C as l,R as n,_ as r,P as v};
2
+ //# sourceMappingURL=auth.provider-C3RNvaVR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"auth.provider-BijrVDxp.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/auth.provider.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","url","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_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","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","normalizePPDevConfig","proxy","build","inspector","users","miHudLess","integrateMiTopBar","addSharedComponentsScripts","addRootElement","templateLess","resolvedName","defaultVersionFileTemplate","distZip","zipCfg","zip","versionPlugin","outFileName","outDir","inDir","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","AuthProvider","state","isAuthenticated","isRedirected","lastChecked","listeners","Set","getState","this","setAuthenticated","authenticated","Date","now","notifyListeners","setRedirected","redirected","updateState","updates","reset","subscribe","listener","add","delete","forEach","stack","message","String","authProvider"],"mappings":"4NAIA,MAAMA,EAAkBC,EAEC,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,YAGIC,EAAmBJ,EAEA,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,SAGWE,EAAqBC,EAAWN,EAAQD,EAAiB,iBAClEA,EACAK,EAESG,EAAsBP,EAAQK,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAaZ,EAAQK,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAKfO,EAAmB,KACnBC,EAAuB,MACvBC,EAA6B,MAQ7BC,EAA4B,oBAE5BC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCtDIC,EAA0B,OAEhC,IAAIC,EACAC,EAEJ,SAASC,IAGP,OAFAF,IAAY,CAAEG,MAAOJ,EAAeK,OAAQC,EAAiBN,IAEtDC,EAAQI,MACjB,CAUM,SAAUE,EAAaH,GAoB3B,YAnBcI,IAAVJ,GAAuBA,IAAUH,GAASG,QAC5CH,EAAU,CAAEG,QAAOC,OAAQC,EAAiBF,KAG9CF,IAAW,CACTO,KAAM,CAACC,EAAKC,IAAYR,IAASM,KAAKC,EAAKC,GAC3CC,KAAM,CAACF,EAAKC,IAAYR,IAASS,KAAKF,EAAKC,GAC3CE,SAAU,CAACH,EAAKC,IAAYR,IAASU,SAASH,EAAKC,GACnDG,MAAO,CAACJ,EAAKC,IAAYR,IAASW,MAAMJ,EAAKC,GAC7CI,YAAcC,GAASb,IAASY,YAAYC,GAC5CC,eAAiBH,GAAUX,IAASc,eAAeH,GACnD,aAAII,GACF,OAAOf,IAASe,SAClB,EACA,aAAIA,CAAUC,GACZhB,IAASe,UAAYC,CACvB,GAGKjB,CACT,CCxCO,MAAMkB,EAASC,ICKhB,SAAUC,EAA4BC,EA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,MAAMgJ,EAAe,IAAI3B"}
1
+ {"version":3,"file":"auth.provider-C3RNvaVR.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/auth.provider.ts"],"sourcesContent":[null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","url","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_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","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","normalizePPDevConfig","proxy","build","inspector","users","miHudLess","integrateMiTopBar","addSharedComponentsScripts","addRootElement","templateLess","resolvedName","defaultVersionFileTemplate","distZip","zipCfg","zip","versionPlugin","outFileName","outDir","inDir","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","AuthProvider","state","isAuthenticated","isRedirected","lastChecked","listeners","Set","getState","this","setAuthenticated","authenticated","Date","now","notifyListeners","setRedirected","redirected","updateState","updates","reset","subscribe","listener","add","delete","forEach","stack","message","String","authProvider"],"mappings":"4NAIA,MAAMA,EAAkBC,EAEC,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,YAGIC,EAAmBJ,EAEA,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,SAGWE,EAAqBC,EAAWN,EAAQD,EAAiB,iBAClEA,EACAK,EAESG,EAAsBP,EAAQK,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAaZ,EAAQK,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAKfO,EAAmB,KACnBC,EAAuB,MACvBC,EAA6B,MAQ7BC,EAA4B,oBAE5BC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCtDIC,EAA0B,OAEhC,IAAIC,EACAC,EAEJ,SAASC,IAGP,OAFAF,IAAY,CAAEG,MAAOJ,EAAeK,OAAQC,EAAiBN,IAEtDC,EAAQI,MACjB,CAUM,SAAUE,EAAaH,GAoB3B,YAnBcI,IAAVJ,GAAuBA,IAAUH,GAASG,QAC5CH,EAAU,CAAEG,QAAOC,OAAQC,EAAiBF,KAG9CF,IAAW,CACTO,KAAM,CAACC,EAAKC,IAAYR,IAASM,KAAKC,EAAKC,GAC3CC,KAAM,CAACF,EAAKC,IAAYR,IAASS,KAAKF,EAAKC,GAC3CE,SAAU,CAACH,EAAKC,IAAYR,IAASU,SAASH,EAAKC,GACnDG,MAAO,CAACJ,EAAKC,IAAYR,IAASW,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LZ,KAAKH,UAAUiB,OAAOF,GAE1B,CAKQ,eAAAP,GACNL,KAAKH,UAAUkB,QAASH,IACtB,IACEA,EAASZ,KAAKD,WAChB,CAAE,MAAO5H,GAEPP,IAAeO,MACb,iCAAiCA,aAAiBiB,MAASjB,EAAM6I,OAAS7I,EAAM8I,QAAWC,OAAO/I,KAEtG,GAEJ,EAIK,MAAMgJ,EAAe,IAAI3B"}
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import*as e from"path";import*as t from"fs";import{EventEmitter as o}from"node:events";import{performance as n}from"node:perf_hooks";import{watch as i}from"chokidar";import{cac as s}from"cac";import{c as r,a,P as l,n as c,b as d,r as p,V as f,v as u,d as g,e as h,f as m,g as w}from"./auth.provider-BijrVDxp.js";import{r as b,l as v,g as y,s as P,a as x,b as S,c as k,i as T}from"./index-CL8_j3ER.js";import{loadConfigFromFile as L,mergeConfig as E,build as $,resolveConfig as F,optimizeDeps as D,preview as I}from"vite";import{parse as j}from"url";import{e as N,P as _,c as C,r as A,a as M,z as R,I as H,R as O,b as z,i as U,d as V,V as W,f as Z,M as B,g as G,h as q,j as J,k as K,l as Y,u as X,D as Q,C as ee,m as te,n as oe,s as ne}from"./variables-editor-CrhYJD_R.js";import*as ie from"dir-compare";import se from"diff-match-patch";import{isBinaryFile as re}from"isbinaryfile";import*as ae from"os";import*as le from"crypto";import{WebSocketServer as ce,WebSocket as de}from"ws";import{w as pe}from"./version-manifest-1KdgXTW2.js";import"picocolors";import"node:path";import"child_process";import"node:module";import"./helpers.js";import"ejs";import"zlib";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"node:crypto";import"node:fs";import"node:os";import"express";import"process";import"jszip";import"module";import"fs/promises";import"util";function fe(e){return null!=e&&!1!==e}let ue=null;const ge=new WeakMap;function he(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;ge.set(e,t);const o=r();t.print&&o.info(a.dim(a.green(" ➜"))+a.dim(" press ")+a.bold("h")+a.dim(" to show help"));const n=(t.customShortcuts??[]).filter(fe).concat(me);ue?.(),ue=null;let i=!1;const s=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(i)return;"h"===t&&o.info(["",a.bold(" Shortcuts"),...n.map(e=>a.dim(" press ")+a.bold(e.key)+a.dim(` to ${e.description}`))].join("\n"));const s=n.find(e=>e.key===t);s&&(i=!0,await s.action(e),i=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{ue===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),s&&process.stdin.pause(),ue=null)};ue=f,p.on("close",f)}const me=[{key:"r",description:"restart the server",async action(e){const t=ge.get(e);await e.restart(),t&&he(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"))}}];const we=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class be{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(t){const{oldAssetsPath:o,newAssetsPath:n,destinationPath:i,changelogTemplate:s,diffFileTemplateHandler:l,diffLineTemplateHandler:c,changelogFilename:d,contextLines:p}=t;if(this.logger=r(),!o||!n||!i)throw new Error("Previous assets path, current assets path and destination path are required");if(o===n)throw new Error("Previous and current assets paths must be different");if(!this.isExists(o))throw new Error(`Previous assets path ${o} does not exist`);if(!this.isExists(n))throw new Error(`Current assets path ${n} does not exist`);if(this.isZipFile(o)){const t=e.resolve(ae.tmpdir(),le.createHash("md5").update(o).digest("hex"));this.oldAssetsPath=this.unzipFile(o,t).then(()=>this.normalizeAssetFolderPath(t)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);return e})}else{if(!this.isFolder(o))throw new Error(`Invalid previous assets path ${o}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(o);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(n)){const t=e.resolve(ae.tmpdir(),le.createHash("md5").update(n).digest("hex"));this.newAssetsPath=this.unzipFile(n,t).then(()=>this.normalizeAssetFolderPath(t)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Current assets path ${e} is empty`);return e})}else{if(!this.isFolder(n))throw new Error(`Invalid current assets path ${n}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(n);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${n} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=i,this.mkdirpSync(this.destinationPath),this.changelogFilename=d||"CHANGELOG.html",s&&(this.templateIsValid(s)?this.changelogTemplate=s:this.logger.warn(a.yellow("Invalid changelog template, using default"))),"function"==typeof l&&(this.diffFileTemplateHandler=l),"function"==typeof c&&(this.diffLineTemplateHandler=c),p&&(this.contextLines=p)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return t.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return t.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===t.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){t.existsSync(e)||t.mkdirSync(e,{recursive:!0})}async unzipFile(e,o){t.rmSync(o,{force:!0,recursive:!0}),await N(e,o)}normalizeAssetFolderPath(o){const n=t.readdirSync(o);return 1===n.length&&t.lstatSync(e.join(o,n[0])).isDirectory()?this.normalizeAssetFolderPath(e.join(o,n[0])):o}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?"-":" "}">${s=o??"",s.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var s}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(a.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await ie.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(we.test(e)&&(e=e.replace(we,"$1$3")),we.test(t)&&(t=t.replace(we,"$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 se,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let s=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:s+o+1,lineType:t})).slice(0,n);return-1!==t&&(s+=n),i}).flat()}async generateFilesDiff(o){if("equal"===o.state){const t=this.pathToPosix(e.join(".",o.relativePath,o.name1??"")),n=this.pathToPosix(e.join(".",o.relativePath,o.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${t}</span> -> <span class="to">${n}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const n=o.path1&&o.name1?e.join(o.path1,o.name1):null,i=o.path2&&o.name2?e.join(o.path2,o.name2):null,s=this.pathToPosix(e.join(".",o.relativePath,(o.name1||o.name2)??""));if("left"===o.state&&n)return this.diffFileTemplate(`<span class="removed">Removed ${s}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===o.state&&i)return this.diffFileTemplate(`<span class="added">Added ${s}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===o.state&&n&&i){const r=this.pathToPosix(e.join(".",o.relativePath,o.name1??"")),a=this.pathToPosix(e.join(".",o.relativePath,o.name2??"")),l=o.name1!==o.name2?`<span class="renamed"\n >Renamed <span class="from">${r}</span> -> <span class="to">${a}</span></span\n >`:s;return this.diffFileTemplate(l,await re(n)||await re(i)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(t.readFileSync(n,"utf-8"),t.readFileSync(i,"utf-8"))))}return""}async generateChangelog(){this.logger.info(a.green("Generating changelog"));const o=await this.generateAssetFoldersDiff(),n=(await Promise.all(o.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(a.green("Writing changelog file"));const i=this.changelogTemplate.split("%FILES%");i.splice(1,0,n);const s=i.join("");t.writeFileSync(e.join(this.destinationPath,this.changelogFilename),s),this.logger.info(a.green(`Changelog file written to ${e.join(this.destinationPath,this.changelogFilename)}`))}}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}})}}class ye{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new ce({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)=>{this.eventListeners.get(e)?.delete(t),"close"!==e&&"error"!==e||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===de.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){if((e.url??"").split("?")[0]!==_)return!1;return C(e)?(t.once("error",()=>t.destroy()),t.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>t.destroy()),!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,t){let o;try{o=JSON.parse(t.toString())}catch{return}if(!o||"custom"!==o.type||"string"!=typeof o.event)return;const n=this.eventListeners.get(o.event);if(n)for(const t of n)try{t(o.data,e)}catch(e){r().error(`ws handler for "${o.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===de.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}}function Pe(e){return e instanceof Error?e.stack??e.message:String(e)}function xe({logger:e,knownRejections:t=[],shutdown:o,shutdownTimeoutMs:n=5e3,processRef:i=process}){let s=!1,r=0;const l=async(t,l)=>{if((e=>{r=Math.max(r,e)})(l),s)return void("SIGINT"!==t&&"SIGTERM"!==t&&"SIGHUP"!==t||(e.warn(a.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),i.exit(r)));s=!0,e.info(a.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const c=setTimeout(()=>{e.error(a.red(`⏰ Shutdown did not finish within ${n} ms, forcing exit`)),i.exit(1)},n);try{await o(),clearTimeout(c),e.info(a.green("✅ Graceful shutdown completed")),i.exit(r)}catch(t){clearTimeout(c),e.error(a.red(`❌ Error during graceful shutdown: ${Pe(t)}`)),i.exit(1)}},c=()=>{l("SIGINT",0)},d=()=>{l("SIGTERM",0)},p=()=>{l("SIGHUP",0)},f=t=>{e.error(a.red(`❌ Uncaught exception: ${Pe(t)}`)),l("uncaughtException",1)},u=o=>{const n=t.find(e=>e.matches(o));n?e.info(a.dim(n.message)):e.error(a.red(`❌ Unhandled promise rejection (the server keeps running): ${Pe(o)}`))};return i.on("SIGINT",c),i.on("SIGTERM",d),i.on("SIGHUP",p),i.on("uncaughtException",f),i.on("unhandledRejection",u),()=>{i.off("SIGINT",c),i.off("SIGTERM",d),i.off("SIGHUP",p),i.off("uncaughtException",f),i.off("unhandledRejection",u)}}const Se={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 ke=["--","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 Te(e){const t={...e};for(const e of ke)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 Le=["https","open","cors","strictPort","force"];const Ee=s("pp-dev");function $e(t,o,n){const s=[...w,"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"].map(o=>e.join(t,o)),r=i(s,{ignored:t=>{const o=e.basename(t);return/(^|[\/\\])\../.test(t)&&!o.startsWith(".env")&&!o.startsWith(".pp-dev")&&!o.startsWith(".pp-watch")},persistent:!0,ignoreInitial:!0,followSymlinks:!1});let l=null;return r.on("change",i=>{n(a.blue(`🔧 Config file changed: ${e.relative(t,i)}`)),l&&clearTimeout(l),l=setTimeout(async()=>{try{n(a.yellow("🔄 Restarting dev server due to config change...")),await o()}catch(e){n(a.red(`❌ Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{n(a.red(`❌ Config watcher error: ${e}`))}),{watcher:r}}function Fe(e){e.watcher&&e.watcher.close()}function De(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)}async function Ie(o){const{changelog:n,executionRoot:i,newAssetsPath:s,backupsDirPath:l,changelogDestinationPath:c,logLevel:d}=o;let p;if("string"==typeof n)p=e.resolve(i,n);else{if(!t.existsSync(l))return void r(d).warn(a.yellow("backups directory not found, skipping changelog generation"));const o=t.readdirSync(l,{withFileTypes:!0});if(!o.length)return void r(d).warn(a.yellow("no backups found, skipping changelog generation"));const n=o.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!n.length)return void r(d).warn(a.yellow("no ZIP backups found, skipping changelog generation"));const i=n.reduce((o,n)=>t.statSync(e.resolve(l,o.name)).mtimeMs>t.statSync(e.resolve(l,n.name)).mtimeMs?o:n).name;p=e.resolve(l,i)}const f=new be({oldAssetsPath:p,newAssetsPath:s,destinationPath:c});await f.generateChangelog()}let je=global.__pp_dev_profile_session,Ne=0;const _e=o=>{if(je)return new Promise((n,i)=>{je.post("Profiler.stop",(s,{profile:r})=>{if(s)i(s);else{const i=e.resolve(`./pp-dev-profile-${Ne++}.cpuprofile`);t.writeFileSync(i,JSON.stringify(r)),o(a.yellow(`CPU profile written to ${a.white(a.dim(i))}`)),je=void 0,n()}})})},Ce=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};Ee.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"),Ee.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(t,o)=>{Ce(o);let i=null,s=null,l=!1;const c=t?e.resolve(process.cwd(),t):process.cwd(),d=r(o.logLevel),p=async()=>{if(!l){l=!0;try{i&&(d.info(a.yellow("🛑 Stopping existing dev server...")),await i.close(),i=null);const{clearConfigCache:r,getConfig:u}=await import("./index-CL8_j3ER.js").then(e=>e.h);r();const{createServer:g}=await(import("vite")),h=o.mode||"development",m=e.resolve(process.cwd(),t??".");v(h,m);const w=await L({mode:h,command:"serve"},o.config,t,o.logLevel);let b=await y(void 0,{mode:h,root:m});if(w){const{plugins:e,...t}=w.config;b=E(b,t)}if(i=await g(E(b,{root:t,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},server:Te(o),customLogger:d},!0)),!i.config.base||"/"===i.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!i.httpServer)throw new Error("HTTP server not available");await i.listen();const P=global.__pp_dev_start_time??!1,x=P?a.dim(`ready in ${a.reset(a.bold(Math.ceil(n.now()-P)))} ms`):"";d.info(`\n ${a.green(`${a.bold("PP-DEV")} v${f}`)} ${x}\n`),i.printUrls();const S=await u(m);if(!1!==S.inspector?.enabled){const e=i.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${i.config.server.port??5173}`;d.info(`\n ${a.cyan("🔍 Request Inspector")} ${a.dim(t+H)}\n`)}he(i,{print:!0,customShortcuts:[...je?[{key:"p",description:"start/stop the profiler",async action(e){if(je)await _e(d.info);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{je=new e.Session,je.connect(),je.post("Profiler.enable",()=>{je?.post("Profiler.start",()=>{d.info("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=$e(c,p,d.info),d.info(a.blue("🔧 Config file watcher started"))),l=!1}catch(e){l=!1,d.error(a.red(`error when starting dev server:\n${e.stack}`),{error:e}),_e(d.info),process.exit(1)}}};xe({logger:d,shutdown:async()=>{s&&(Fe(s),s=null),i&&(await i.close(),i=null),_e(d.info)}}),await p()}),Ee.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(n,i)=>{Ce(i);const s=Le.filter(e=>void 0!==i[e]);s.length>0&&r(i.logLevel).warn(a.yellow(`⚠️ ${s.map(e=>`--${e}`).join(", ")} ${1===s.length?"has":"have"} no effect with pp-dev next and will be removed.`));const{host:d,port:p}=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="number"==typeof t?t:"string"==typeof t?Number.parseInt(t,10):NaN;return{host:o,port:Number.isInteger(n)&&n>=0?n:3e3}}(i.host,i.port);let f=null,w=null,b=null,y=null,x=null,S=!1;const L=new Set,E=r(i.logLevel),$=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 s=n,r=new Map(e.map(e=>[e,o(e).filter(t=>!s.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(r.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=r,n=null,a}}}(),F=async()=>{f&&"function"==typeof f.close&&await f.close(),f=null},D=async()=>{const e=w;if(e){for(const e of L)e.destroy();L.clear(),await new Promise(t=>{e.close(()=>t())}),w===e&&(w=null)}},I=async()=>{if(!S){S=!0;try{const{next:r,constants:N}=await P(),{PHASE_DEVELOPMENT_SERVER:_}=N;y?.dispose(),y=null,b&&(await b.close(),b=null),w&&(E.info(a.yellow("🛑 Stopping existing Next.js server...")),await D()),await F();const{clearConfigCache:C}=await import("./index-CL8_j3ER.js").then(e=>e.h);C();const{join:A}=await(import("path")),{createServer:M}=await(import("http")),R=await(import("next/dist/server/config.js")),ie=R.default.default||R["module.exports"].default||R.default,se=n?A(process.cwd(),n):process.cwd();v(i.mode||"development",se);const re=await ie(_,se);let ae=re?.ppDev||{};if(0===Object.keys(ae).length)try{const{getConfig:e}=await import("./index-CL8_j3ER.js").then(e=>e.h),t=await e(se);Object.keys(t).length>0?(ae=t,E.info(a.blue("🔧 Loaded pp-dev config from standalone config file"))):E.info(a.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){E.warn(a.yellow(`⚠️ Failed to load standalone pp-dev config, using defaults: ${e instanceof Error?e.message:String(e)}`))}else E.info(a.blue("🔧 Loaded pp-dev config from Next.js config"));const{getPkg:le}=await import("./index-CL8_j3ER.js").then(e=>e.h),ce=le(se).name;u(ae,ce);const de=c(ae,ce),{templateName:pe}=de,fe=de.backendBaseURL,ue=de.templateLess,ge=de.v7Features,he=de.disableSSLValidation,me=de.enableProxyCache,we=de.proxyCacheTTL,be=de.personalAccessToken,ve=de.miHudLess,Pe=de.inspectorEnabled,xe=de.inspectorMaxMemory,Se=de.inspectorCaptureLimit,ke=de.appId,Te=re?.basePath;let Le="";Te?Le=Te:(Le=ue?g:ge?h:m,Le+=`/${pe}`);const Ee=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}:{}}(i),Fe=async e=>{delete process.env.TURBOPACK,await F();const t={dev:!0,customServer:!0,hostname:d,port:p,dir:se,conf:{...re,basePath:Le,assetPrefix:Le}};e.webpack?t.webpack=!0:e.turbopack&&(t.turbopack=!0),$.beforeCreate(),f=r(t),await f.prepare(),$.afterCreate()};if(Ee.webpack)await Fe({webpack:!0});else if(Ee.turbopack)try{await Fe({turbopack:!0})}catch(e){if(!De(e))throw e;E.warn(a.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await Fe({webpack:!0})}else try{await Fe({})}catch(e){if(!De(e))throw e;E.warn(a.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await Fe({webpack:!0})}if(!f)throw new Error("Next.js app failed to initialize");if(Le.endsWith("/")||(Le+="/"),"/"===Le)throw new Error('basePath cannot be equal to "/" or equal to empty string');E.info(a.green("✅ Next.js app prepared successfully")),E.info(a.blue(`🔧 pp-dev plugin configured for template: ${pe}`)),E.info(a.blue(`🔧 Base path configured: ${Le}`)),fe&&(E.info(a.blue(`🌐 Backend URL: ${fe}`)),E.info(a.blue(`🆔 Custom App ID: ${ke}`)));const Ie=f.getRequestHandler(),je=p,Ne=d;w=M(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=j(o,!0);if(Ce.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(Ae.length>0){let l=0;const c=()=>{if(l>=Ae.length)return void s();const o=Ae[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=Ce.length)return void s();const o=Ce[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(Le))i=j(o,!0);else{if(n===Le.replace(/\/$/,"")){const e=o.replace(n,Le);return t.writeHead(302,{Location:e}),void t.end()}if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return t.writeHead(302,{Location:Le}),void t.end()}await Ie(e,t,i)}s()}catch(d){E.error(`Error handling request: ${d instanceof Error?d.message:String(d)}`,{error:d instanceof Error?d:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let _e=null,Ce=[],Ae=[];if(!1!==Pe){const e=new O(xe);z(U,e,Se);const t=V(e,Se);Ce.push(t)}const Me=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(H)||e.url?.startsWith(W)){return void U(e,t,()=>{})}o()};if(fe||!1===Pe||(Ae.push(Me),Ce.push(Me)),fe){const n=new URL(fe).host,i=Z();Ae.unshift(i),Ce.unshift(i),fe.startsWith("https://")&&(o.defaultMaxListeners=Math.max(o.defaultMaxListeners,20));const r={headers:{host:n,referer:fe,origin:fe.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},appId:ke,templateLess:ue,disableSSLValidation:he,v7Features:ge,personalAccessToken:be??process.env.MI_ACCESS_TOKEN};_e=new B(fe,r);const c=G(Le,pe),d=(e,t,o)=>{c(e,t,o)};Ae.push(d),Ce.push(d);const p=k(Le);if(Ae.push(p),Ce.push(p),me){let e=+we;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={middlewares:{use:e=>e},config:{logger:console}},o=q({devServer:t,ttl:e}),n=(e,t,n)=>{o(e,t,n)};Ce.push(n),E.info(a.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const u=new RegExp(`^((${s=Le,s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})|/)$`),g=J(u,_e,Object.assign({base:Le},r,{miHudLess:ve})),h=(e,t,o)=>{g(e,t,o)};Ce.push(h);const m=Le.endsWith("/")?Le.substring(0,Le.length-1):Le,v={middlewares:{use:e=>e},config:{logger:console}},P=K({devServer:v,baseURL:fe,proxyIgnore:["/@vite","/@metricinsights","/@",m,"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:he,miAPI:_e,templateName:pe}),x=(e,t,o)=>{P(e,t,o)};Ce.push(x),Ae.push(Me),Ce.push(Me);const S=Y(e=>{const t=e.split("?")[0];return t.startsWith(Le)&&!t.includes("/_next/")},(e,t)=>{const o=_e.buildPage(e,ve),i=T(o,Le,{backendBaseURL:fe,templateLess:ue,appId:ke,devPanelPosition:de.devPanelPosition,devPanelHidden:de.devPanelHidden,devPanelAutoHide:de.devPanelAutoHide});return Buffer.from(X(n,t.headers.host??"",i))}),L=(e,t,o)=>{S(e,t,o)};Ce.push(L),b=new ye;let $=re?.distDir;const F=process.env[l];process.env[l]="1";try{const e=await ie(N.PHASE_PRODUCTION_BUILD,se);$=e?.distDir??$}catch{}finally{void 0===F?delete process.env[l]:process.env[l]=F}const D=($??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),I=D&&".next"!==D?D:"out";let j,_="0.0.0";try{const o=JSON.parse(t.readFileSync(e.join(se,"package.json"),"utf-8"));_="string"==typeof o.version?o.version:_,j="string"==typeof o.repository?o.repository:o.repository?.url}catch{}const C=new Q(pe,{root:se,backupFolder:e.resolve(se,de.syncBackupsDir),maxBackups:de.syncMaxBackups,buildTimeoutMs:de.syncBuildTimeoutMs,nextBuild:{projectRoot:se,distDir:I,packageVersion:_,packageRepositoryUrl:j}}),A={ws:b.ws,config:{clientInjectionPlugin:{v7Features:ge}}};y=new ee(A,{distService:C,miAPI:_e}),te(U,{distService:C,miAPI:_e}),oe(U,{miAPI:_e}),ne({persist:de.persistUsers,miAPI:_e,projectRoot:se,miUrl:fe});const M="function"==typeof f?.getUpgradeHandler?f.getUpgradeHandler():null;w.on("upgrade",(e,t,o)=>{b?.handleUpgrade(e,t,o)||(M?M(e,t,o):t.destroy())}),E.info(a.blue(`🔧 ${Ce.length} pp-dev middlewares initialized`)),E.info(a.blue(`🔧 ${Ae.length} essential middlewares for internal routes`)),E.info(a.blue(`🔧 MiAPI initialized for backend: ${fe}`)),E.info(a.blue(`🔧 Custom App ID: ${ke}`))}w.listen(je,Ne,()=>{E.info(a.green(`✅ pp-dev Next.js server running at http://${Ne}:${je}`)),E.info(a.blue(`📱 Next.js app accessible at http://${Ne}:${je}${Le}`)),!1!==Pe&&E.info(a.cyan(`🔍 Request Inspector: http://${Ne}:${je}${H}`)),E.info(a.blue("🔧 Base path handling active")),x||(x=$e(se,I,E.info),E.info(a.blue("🔧 Config file watcher started"))),w.on("connection",e=>{L.add(e),e.on("close",()=>L.delete(e))})}),S=!1}catch(e){S=!1,E.error(a.red(`❌ Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(E.error(a.red("❌ Next.js Peer Dependency Error:")),E.error(a.red(e.message)),E.error(a.yellow("\n💡 To fix this issue:")),E.error(a.blue(" 1. Install Next.js in your project:")),E.error(a.white(" npm install next@^16")),E.error(a.blue(" 2. Or use yarn:")),E.error(a.white(" yarn add next@^16")),E.error(a.blue(" 3. Or use pnpm:")),E.error(a.white(" pnpm add next@^16")),E.error(a.yellow("\n📖 For more information, see:")),E.error(a.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}var s}};xe({logger:E,knownRejections:[Se],shutdown:async()=>{x&&(Fe(x),x=null),y?.dispose(),y=null,b&&(await b.close(),b=null),await D(),await F()}}),await I()}),Ee.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(t,o)=>{Ce(o);const n=Te(o),i=b(o);try{const s=o.mode||"production",r=e.resolve(process.cwd(),t??".");v(s,r);const a=await L({mode:s,command:"build"},o.config,t,o.logLevel);let l=await y(i,{mode:s,root:r});if(a){const{plugins:e,...t}=a.config;l=E(l,t)}const c=E(l,{root:t,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},build:n},!0);if(await $(c),o.changelog){const n=t||process.cwd(),i=c.build?.outDir||"dist";let s="dist-zip";c.ppDevConfig&&(!1===c.ppDevConfig.distZip?s=i:"object"==typeof c.ppDevConfig.distZip&&"string"==typeof c.ppDevConfig.distZip.outDir&&(s=c.ppDevConfig.distZip.outDir)),await Ie({changelog:o.changelog,executionRoot:n,newAssetsPath:e.resolve(n,i),backupsDirPath:e.resolve(n,c.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:e.resolve(n,s),logLevel:o.logLevel})}}catch(e){r(o.logLevel).error(a.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{_e(e=>r(o.logLevel).info(e))}}),Ee.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(o,n)=>{Ce(n);const i=r(n.logLevel),s=o?e.resolve(process.cwd(),o):process.cwd(),f=b(n);process.env[l]="1";try{v(n.mode||"production",s);const{constants:o}=await P(),r=await(import("next/dist/server/config.js")),l=r.default.default||r["module.exports"].default||r.default,u=await l(o.PHASE_PRODUCTION_BUILD,s);let g=u?.ppDev||{};if(0===Object.keys(g).length){const{getConfig:e}=await import("./index-CL8_j3ER.js").then(e=>e.h);g=await e(s)}const{getPkg:h}=await import("./index-CL8_j3ER.js").then(e=>e.h),m=c(g,h(s).name),w=x(m.distZip,f,d(m.templateName)),b=S(m.versionPlugin,f),y=A(s,u);y&&i.info(a.dim(`[pp-dev] Removed stale dev route types: ${e.relative(s,y)}`)),i.info(a.cyan("[pp-dev] Running `next build`...")),await M(s);const k="string"==typeof u?.distDir&&u.distDir?u.distDir:".next",T=".next"===k?"out":k,L=e.resolve(s,T);if(!t.existsSync(L)||!t.statSync(L).isDirectory())throw new Error(`Next.js build output directory not found: ${L}. "next-build" requires "output: 'export'" in next.config (static export).`);const E=JSON.parse(t.readFileSync(e.join(s,"package.json"),"utf-8"));if(!1!==b&&!1!==b.enabled&&(await pe({outDir:L,packageVersion:"string"==typeof E.version?E.version:"0.0.0",versionFileTemplate:b.versionFileTemplate,packageRepositoryUrl:"string"==typeof E.repository?E.repository:E.repository?.url,enabled:b.enabled}),i.info(a.green(`✅ VERSION / BUILD-MANIFEST written to ${e.relative(s,L)}`))),!1!==w){const o=e.resolve(s,w.outDir),n=w.inDir?e.resolve(L,w.inDir):L,r=p(o,w.outFileName,"ZIP output file name");t.mkdirSync(e.dirname(r),{recursive:!0});const l=await R(n);t.writeFileSync(r,l),i.info(a.green(`✅ Zip archive written to ${e.relative(s,r)}`))}if(n.changelog){const t=!1!==w?w.outDir:T;await Ie({changelog:n.changelog,executionRoot:s,newAssetsPath:L,backupsDirPath:e.resolve(s,m.syncBackupsDir),changelogDestinationPath:e.resolve(s,t),logLevel:n.logLevel})}}catch(e){r(n.logLevel).error(a.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{_e(e=>r(n.logLevel).info(e))}}),Ee.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(t,o,n)=>{Ce(n);const{oldAssetsPath:i=t,newAssetsPath:s=o,destination:l=".",filename:c="CHANGELOG.html",logLevel:d}=n,p=process.cwd();i&&s||(r(d).error(a.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const f=e.resolve(p,i),u=e.resolve(p,s),g=e.resolve(p,l),h=new be({oldAssetsPath:f,newAssetsPath:u,destinationPath:g,changelogFilename:c});await h.generateChangelog()}),Ee.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(t,o,n)=>{Ce(n);const{source:i=t,destination:s=o,fontName:l="icon-font"}=n,c=process.cwd(),d=e.resolve(c,i),p=e.resolve(c,s),f=new ve({sourceDir:d,outputDir:p,fontName:l}),u=r(n.logLevel);u.info(`Generating icon font from SVG files in ${a.dim(d)}`),await f.generate(),u.info(`Icon font generated and saved to ${a.dim(p)}`)}),Ee.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(t,o)=>{Ce(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");v(n,i);const s=await L({mode:n,command:"build"},o.config,t,o.logLevel);let r=await y(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=E(r,t)}const a=await F(E(r,{root:t,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode}),"serve");await D(a,o.force,!0)}catch(e){r(o.logLevel).error(a.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}}),Ee.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(t,o)=>{Ce(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");v(n,i);const s=await L({mode:n,command:"build"},o.config,t,o.logLevel);let r=await y(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=E(r,t)}(await I(E(r,{root:t,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode,build:{outDir:o.outDir},preview:{port:o.port,strictPort:o.strictPort,host:o.host,https:o.https,open:o.open}}))).printUrls()}catch(e){r(o.logLevel).error(a.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{_e(e=>r(o.logLevel).info(e))}}),Ee.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(o,n)=>{const i=r(n.logLevel),{isLegacyFlatConfig:s,isLegacyPPWatchConfig:l,isAlreadyMigrated:c,migrateLegacyFlatConfig:d,migratePPWatchConfig:p,generateConfigFileContent:f,discoverMigrateSource:u,loadPackageJsonMigrateConfig:g}=await(import("./migrate-B0hgQCl_.js")),h=n.format??"ts",m=!1!==n.backup,w=process.cwd(),b=u(w,o);b||(i.warn(a.yellow("No pp-dev or pp-watch config file found in the current directory.")),i.info(a.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:y,isPackageJsonConfig:P}=b;i.info(a.blue(`Found config: ${e.relative(w,v)}`));const{getPkg:x}=await import("./index-CL8_j3ER.js").then(e=>e.h),S=x();let k,T={};try{if(/\.[cm]?ts$/i.test(v)){const o=await(import("esbuild")),{pathToFileURL:n}=await(import("url")),i=(await o.build({absWorkingDir:w,entryPoints:[v],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:"esm",mainFields:["main"]})).outputFiles[0].text,s=`pp-migrate-tmp-${Date.now()}.mjs`;t.writeFileSync(s,i);try{const t=await(import(n(e.resolve(w,s)).toString()));T=t.default?.default??t.default??t}finally{t.existsSync(s)&&t.unlinkSync(s)}}else if(/\.[cm]?js$/i.test(v)){const{pathToFileURL:t}=await(import("url")),o=await(import(t(e.resolve(w,v)).toString()));T=o.default?.default??o.default??o}else P?T=g(v):v.endsWith(".json")&&(T=JSON.parse(t.readFileSync(v,"utf-8")))}catch(e){i.error(a.red(`Failed to load config file: ${e.message}`)),process.exit(1)}T&&"object"==typeof T||(i.error(a.red("Config file did not export a valid object.")),process.exit(1)),c(T)?(i.info(a.green("Config is already in 1.0 format — nothing to migrate.")),process.exit(0)):y||l(T)?(i.info(a.blue("Detected pp-watch config format → migrating to 1.0")),k=p(T)):s(T)?(i.info(a.blue("Detected 0.x flat config format → migrating to 1.0")),k=d(T,S.name)):(i.warn(a.yellow("Could not detect config format. No known keys found.")),process.exit(1));const L=f(k,h),E=n.output??e.join(w,`pp-dev.config.${h}`);if(n.dryRun&&(i.info(a.green(`\n--- Migrated config (dry-run) → ${e.relative(w,E)} ---\n`)),process.exit(0)),m&&!P&&t.existsSync(v)){const o=`${v}.bak`;t.copyFileSync(v,o),i.info(a.blue(`Backed up original to: ${e.relative(w,o)}`))}t.writeFileSync(E,L,"utf-8"),i.info(a.green(`✅ Migration complete → ${e.relative(w,E)}`)),P?i.info(a.yellow('You can now remove the "pp-dev" field from package.json.')):v!==E&&t.existsSync(v)&&i.info(a.yellow(`You can now delete the old config: ${e.relative(w,v)}`))}),Ee.help(),Ee.version(f),Ee.parse();export{_e as stopProfiler};
1
+ import{cac as e}from"cac";import{c as t,a as o,P as n,V as i,v as s,n as r,b as a,d as l,e as c,f as d,g as p,r as f}from"./auth.provider-C3RNvaVR.js";import*as u from"path";import{performance as g}from"node:perf_hooks";import{loadConfigFromFile as h,mergeConfig as m,build as b,resolveConfig as w,optimizeDeps as v,preview as y}from"vite";import{I as P,P as x,c as S,R as k,r as T,i as L,a as E,V as F,b as D,g as $,M as j,d as I,e as N,f as _,h as C,j as A,k as M,l as R,m as H,u as O,D as U,s as z,n as V,o as W,p as Z,z as B}from"./request-capture.middleware-DEQ-qw2b.js";import{watch as G}from"chokidar";import{l as q,g as J,s as K,c as Y,i as X,r as Q,a as ee,b as te}from"./index-Dlv5DGp7.js";import*as oe from"fs";import{EventEmitter as ne}from"node:events";import{parse as ie}from"url";import{WebSocketServer as se,WebSocket as re}from"ws";import*as ae from"dir-compare";import le from"diff-match-patch";import{isBinaryFile as ce}from"isbinaryfile";import*as de from"os";import*as pe from"crypto";import{w as fe}from"./version-manifest-D2Vzplem.js";import"picocolors";import"node:path";import"zlib";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"process";import"jszip";import"child_process";import"module";import"node:crypto";import"node:fs";import"node:os";import"express";import"node:module";import"./helpers.js";import"ejs";import"fs/promises";import"util";function ue(e){return null!=e&&!1!==e}let ge=null;const he=new WeakMap;function me(e,n){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;he.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 s=(n.customShortcuts??[]).filter(ue).concat(be);ge?.(),ge=null;let r=!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(r)return;"h"===t&&i.info(["",o.bold(" Shortcuts"),...s.map(e=>o.dim(" press ")+o.bold(e.key)+o.dim(` to ${e.description}`))].join("\n"));const n=s.find(e=>e.key===t);n&&(r=!0,await n.action(e),r=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{ge===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),a&&process.stdin.pause(),ge=null)};ge=f,p.on("close",f)}const be=[{key:"r",description:"restart the server",async action(e){const t=he.get(e);await e.restart(),t&&me(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"))}}];function we(e){return e instanceof Error?e.stack??e.message:String(e)}function ve({logger:e,knownRejections:t=[],shutdown:n,shutdownTimeoutMs:i=5e3,processRef:s=process}){let r=!1,a=0;const l=async(t,l)=>{if((e=>{a=Math.max(a,e)})(l),r)return void("SIGINT"!==t&&"SIGTERM"!==t&&"SIGHUP"!==t||(e.warn(o.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),s.exit(a)));r=!0,e.info(o.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const c=setTimeout(()=>{e.error(o.red(`⏰ Shutdown did not finish within ${i} ms, forcing exit`)),s.exit(1)},i);try{await n(),clearTimeout(c),e.info(o.green("✅ Graceful shutdown completed")),s.exit(a)}catch(t){clearTimeout(c),e.error(o.red(`❌ Error during graceful shutdown: ${we(t)}`)),s.exit(1)}},c=()=>{l("SIGINT",0)},d=()=>{l("SIGTERM",0)},p=()=>{l("SIGHUP",0)},f=t=>{e.error(o.red(`❌ Uncaught exception: ${we(t)}`)),l("uncaughtException",1)},u=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): ${we(n)}`))};return s.on("SIGINT",c),s.on("SIGTERM",d),s.on("SIGHUP",p),s.on("uncaughtException",f),s.on("unhandledRejection",u),()=>{s.off("SIGINT",c),s.off("SIGTERM",d),s.off("SIGHUP",p),s.off("uncaughtException",f),s.off("unhandledRejection",u)}}const ye=["--","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 Pe(e){const t={...e};for(const e of ye)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 xe=["https","open","cors","strictPort","force"];function Se(e,t,i){const s=[...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"].map(t=>u.join(e,t)),r=G(s,{ignored:e=>{const t=u.basename(e);return/(^|[\/\\])\../.test(e)&&!t.startsWith(".env")&&!t.startsWith(".pp-dev")&&!t.startsWith(".pp-watch")},persistent:!0,ignoreInitial:!0,followSymlinks:!1});let a=null;return r.on("change",n=>{i(o.blue(`🔧 Config file changed: ${u.relative(e,n)}`)),a&&clearTimeout(a),a=setTimeout(async()=>{try{i(o.yellow("🔄 Restarting dev server due to config change...")),await t()}catch(e){i(o.red(`❌ Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{i(o.red(`❌ Config watcher error: ${e}`))}),{watcher:r}}function ke(e){e.watcher&&e.watcher.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 Le=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};async function Ee(e){const{root:t,mode:o,command:n}=e,i=u.resolve(process.cwd(),t??".");q(o,i);const s=await h({mode:o,command:n},e.configFile,t,e.logLevel);let r=await J(e.buildOverrides,{mode:o,root:i});if(s){const e={...s.config};delete e.plugins,r=m(r,e)}return{config:r,envDir:i}}let Fe=global.__pp_dev_profile_session,De=0;const $e=e=>{if(Fe)return new Promise((t,n)=>{Fe.post("Profiler.stop",(i,{profile:s})=>{if(i)n(i);else{const n=u.resolve(`./pp-dev-profile-${De++}.cpuprofile`);oe.writeFileSync(n,JSON.stringify(s)),e(o.yellow(`CPU profile written to ${o.white(o.dim(n))}`)),Fe=void 0,t()}})})};class je{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new se({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)=>{this.eventListeners.get(e)?.delete(t),"close"!==e&&"error"!==e||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===re.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){if((e.url??"").split("?")[0]!==x)return!1;return S(e)?(t.once("error",()=>t.destroy()),t.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>t.destroy()),!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===re.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 Ie={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 Ne=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class _e{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:s,changelogTemplate:r,diffFileTemplateHandler:a,diffLineTemplateHandler:l,changelogFilename:c,contextLines:d}=e;if(this.logger=t(),!n||!i||!s)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=u.resolve(de.tmpdir(),pe.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=u.resolve(de.tmpdir(),pe.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=s,this.mkdirpSync(this.destinationPath),this.changelogFilename=c||"CHANGELOG.html",r&&(this.templateIsValid(r)?this.changelogTemplate=r: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 oe.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return oe.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===oe.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){oe.existsSync(e)||oe.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){oe.rmSync(t,{force:!0,recursive:!0}),await V(e,t)}normalizeAssetFolderPath(e){const t=oe.readdirSync(e);return 1===t.length&&oe.lstatSync(u.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(u.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?"-":" "}">${s=o??"",s.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var s}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 ae.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 le,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let s=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:s+o+1,lineType:t})).slice(0,n);return-1!==t&&(s+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(u.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(u.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?u.join(e.path1,e.name1):null,o=e.path2&&e.name2?u.join(e.path2,e.name2):null,n=this.pathToPosix(u.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(u.join(".",e.relativePath,e.name1??"")),s=this.pathToPosix(u.join(".",e.relativePath,e.name2??"")),r=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${s}</span></span\n >`:n;return this.diffFileTemplate(r,await ce(t)||await ce(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(oe.readFileSync(t,"utf-8"),oe.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("");oe.writeFileSync(u.join(this.destinationPath,this.changelogFilename),i),this.logger.info(o.green(`Changelog file written to ${u.join(this.destinationPath,this.changelogFilename)}`))}}async function Ce(e){const{changelog:n,executionRoot:i,newAssetsPath:s,backupsDirPath:r,changelogDestinationPath:a,logLevel:l}=e;let c;if("string"==typeof n)c=u.resolve(i,n);else{if(!oe.existsSync(r))return void t(l).warn(o.yellow("backups directory not found, skipping changelog generation"));const e=oe.readdirSync(r,{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)=>oe.statSync(u.resolve(r,e.name)).mtimeMs>oe.statSync(u.resolve(r,t.name)).mtimeMs?e:t).name;c=u.resolve(r,i)}const d=new _e({oldAssetsPath:c,newAssetsPath:s,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)=>{Le(n);let s=null,r=null,a=!1;const l=e?u.resolve(process.cwd(),e):process.cwd(),c=t(n.logLevel),d=async()=>{if(!a){a=!0;try{s&&(c.info(o.yellow("🛑 Stopping existing dev server...")),await s.close(),s=null);const{clearConfigCache:p,getConfig:f}=await import("./index-Dlv5DGp7.js").then(e=>e.h);p();const{createServer:u}=await(import("vite")),h=n.mode||"development",{config:b,envDir:w}=await Ee({root:e,mode:h,command:"serve",configFile:n.config,logLevel:n.logLevel});if(s=await u(m(b,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:Pe(n),customLogger:c},!0)),!s.config.base||"/"===s.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!s.httpServer)throw new Error("HTTP server not available");await s.listen();const v=global.__pp_dev_start_time??!1,y=v?o.dim(`ready in ${o.reset(o.bold(Math.ceil(g.now()-v)))} ms`):"";c.info(`\n ${o.green(`${o.bold("PP-DEV")} v${i}`)} ${y}\n`),s.printUrls();const x=await f(w);if(!1!==x.inspector?.enabled){const e=s.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${s.config.server.port??5173}`;c.info(`\n ${o.cyan("🔍 Request Inspector")} ${o.dim(t+P)}\n`)}me(s,{print:!0,customShortcuts:[...(t=c.info,Fe?[{key:"p",description:"start/stop the profiler",async action(){if(Fe)await $e(t);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(o=>{Fe=new e.Session,Fe.connect(),Fe.post("Profiler.enable",()=>{Fe?.post("Profiler.start",()=>{t("Profiler started"),o()})})})}}}]:[]),{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),r||(r=Se(l,d,c.info),c.info(o.blue("🔧 Config file watcher started"))),a=!1}catch(e){a=!1,c.error(o.red(`error when starting dev server:\n${e.stack}`),{error:e}),$e(c.info),process.exit(1)}var t}};ve({logger:c,shutdown:async()=>{r&&(ke(r),r=null),s&&(await s.close(),s=null),$e(c.info)}}),await d()})}(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)=>{Le(n);const i=xe.filter(e=>void 0!==n[e]);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.`));const{host:p,port:f}=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="number"==typeof t?t:"string"==typeof t?Number.parseInt(t,10):NaN;return{host:o,port:Number.isInteger(n)&&n>=0?n:3e3}}(n.host,n.port);let g=null,h=null,m=null,b=null,w=null,v=!1;const y=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 s=n,r=new Map(e.map(e=>[e,o(e).filter(t=>!s.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(r.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=r,n=null,a}}}(),V=async()=>{g&&"function"==typeof g.close&&await g.close(),g=null},W=async()=>{const e=h;if(e){for(const e of y)e.destroy();y.clear(),await new Promise(t=>{e.close(()=>t())}),h===e&&(h=null)}},Z=async()=>{if(!v){v=!0;try{const{next:t,constants:i}=await K(),{PHASE_DEVELOPMENT_SERVER:B}=i;b?.dispose(),b=null,m&&(await m.close(),m=null),h&&(x.info(o.yellow("🛑 Stopping existing Next.js server...")),await W()),await V();const{clearConfigCache:G}=await import("./index-Dlv5DGp7.js").then(e=>e.h);G();const{join:J}=await(import("path")),{createServer:Q}=await(import("http")),ee=await(import("next/dist/server/config.js")),te=ee.default.default||ee["module.exports"].default||ee.default,se=e?J(process.cwd(),e):process.cwd();q(n.mode||"development",se);const re=await te(B,se);let ae=re?.ppDev||{};if(0===Object.keys(ae).length)try{const{getConfig:e}=await import("./index-Dlv5DGp7.js").then(e=>e.h),t=await e(se);Object.keys(t).length>0?(ae=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:le}=await import("./index-Dlv5DGp7.js").then(e=>e.h),ce=le(se).name;s(ae,ce);const de=r(ae,ce),{templateName:pe}=de,fe=de.backendBaseURL,ue=de.templateLess,ge=de.v7Features,he=de.disableSSLValidation,me=de.enableProxyCache,be=de.proxyCacheTTL,we=de.personalAccessToken,ve=de.miHudLess,ye=de.inspectorEnabled,Pe=de.inspectorMaxMemory,xe=de.inspectorCaptureLimit,ke=de.appId,Le=re?.basePath;let Ee="";Le?Ee=Le:(Ee=ue?a:ge?l:c,Ee+=`/${pe}`);const Fe=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),De=async e=>{delete process.env.TURBOPACK,await V();const o={dev:!0,customServer:!0,hostname:p,port:f,dir:se,conf:{...re,basePath:Ee,assetPrefix:Ee}};e.webpack?o.webpack=!0:e.turbopack&&(o.turbopack=!0),S.beforeCreate(),g=t(o),await g.prepare(),S.afterCreate()};if(Fe.webpack)await De({webpack:!0});else if(Fe.turbopack)try{await De({turbopack:!0})}catch(e){if(!Te(e))throw e;x.warn(o.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await De({webpack:!0})}else try{await De({})}catch(e){if(!Te(e))throw e;x.warn(o.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await De({webpack:!0})}if(!g)throw new Error("Next.js app failed to initialize");if(Ee.endsWith("/")||(Ee+="/"),"/"===Ee)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: ${pe}`)),x.info(o.blue(`🔧 Base path configured: ${Ee}`)),fe&&(x.info(o.blue(`🌐 Backend URL: ${fe}`)),x.info(o.blue(`🆔 Custom App ID: ${ke}`)));const $e=g.getRequestHandler(),Ie=f,Ne=p;h=Q(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=ie(o,!0);if(Ce.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(Ae.length>0){let l=0;const c=()=>{if(l>=Ae.length)return void s();const o=Ae[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=Ce.length)return void s();const o=Ce[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(Ee))i=ie(o,!0);else{if(n===Ee.replace(/\/$/,"")){const e=o.replace(n,Ee);return t.writeHead(302,{Location:e}),void t.end()}if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return t.writeHead(302,{Location:Ee}),void t.end()}await $e(e,t,i)}s()}catch(d){x.error(`Error handling request: ${d instanceof Error?d.message:String(d)}`,{error:d instanceof Error?d:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let _e=null;const Ce=[],Ae=[];if(!1!==ye){const e=new k(Pe);T(L,e,xe);const t=E(e,xe);Ce.push(t)}const Me=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(P)||e.url?.startsWith(F)){return void L(e,t,()=>{})}o()};if(fe||!1===ye||(Ae.push(Me),Ce.push(Me)),fe){const e=new URL(fe).host,t=D();Ae.unshift(t),Ce.unshift(t),fe.startsWith("https://")&&(ne.defaultMaxListeners=Math.max(ne.defaultMaxListeners,20));const n=$(fe,{appId:ke,templateLess:ue,disableSSLValidation:he,v7Features:ge,personalAccessToken:we});_e=new j(fe,n);const s=I(Ee,pe),r=(e,t,o)=>{s(e,t,o)};Ae.push(r),Ce.push(r);const a=Y(Ee);if(Ae.push(a),Ce.push(a),me){const e=N(be),t={middlewares:{use:e=>e},config:{logger:console}},n=_({devServer:t,ttl:e}),i=(e,t,o)=>{n(e,t,o)};Ce.push(i),x.info(o.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const l=C(Ee),c=A(l,_e,Object.assign({base:Ee},n,{miHudLess:ve})),p=(e,t,o)=>{c(e,t,o)};Ce.push(p);const f={middlewares:{use:e=>e},config:{logger:console}},w=M({devServer:f,baseURL:fe,proxyIgnore:[...R(Ee),"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:he,miAPI:_e,templateName:pe}),v=(e,t,o)=>{w(e,t,o)};Ce.push(v),Ae.push(Me),Ce.push(Me);const y=H(e=>{const t=e.split("?")[0];return t.startsWith(Ee)&&!t.includes("/_next/")},(t,o)=>{const n=_e.buildPage(t,ve),i=X(n,Ee,{backendBaseURL:fe,templateLess:ue,appId:ke,devPanelPosition:de.devPanelPosition,devPanelHidden:de.devPanelHidden,devPanelAutoHide:de.devPanelAutoHide});return Buffer.from(O(e,o.headers.host??"",i))}),P=(e,t,o)=>{y(e,t,o)};Ce.push(P),m=new je;let S=re?.distDir;const k=process.env[d];process.env[d]="1";try{const e=await te(i.PHASE_PRODUCTION_BUILD,se);S=e?.distDir??S}catch{}finally{void 0===k?delete process.env[d]:process.env[d]=k}const T=(S??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),E=T&&".next"!==T?T:"out";let F,V="0.0.0";try{const e=JSON.parse(oe.readFileSync(u.join(se,"package.json"),"utf-8"));V="string"==typeof e.version?e.version:V,F="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const W=new U(pe,{root:se,backupFolder:u.resolve(se,de.syncBackupsDir),maxBackups:de.syncMaxBackups,buildTimeoutMs:de.syncBuildTimeoutMs,nextBuild:{projectRoot:se,distDir:E,packageVersion:V,packageRepositoryUrl:F}}),Z={ws:m.ws,config:{clientInjectionPlugin:{v7Features:ge}}};b=z({server:Z,internalServer:L,distService:W,miAPI:_e,persistUsers:de.persistUsers,projectRoot:se,miUrl:fe});const B="function"==typeof g?.getUpgradeHandler?g.getUpgradeHandler():null;h.on("upgrade",(e,t,o)=>{m?.handleUpgrade(e,t,o)||(B?B(e,t,o):t.destroy())}),x.info(o.blue(`🔧 ${Ce.length} pp-dev middlewares initialized`)),x.info(o.blue(`🔧 ${Ae.length} essential middlewares for internal routes`)),x.info(o.blue(`🔧 MiAPI initialized for backend: ${fe}`)),x.info(o.blue(`🔧 Custom App ID: ${ke}`))}h.listen(Ie,Ne,()=>{x.info(o.green(`✅ pp-dev Next.js server running at http://${Ne}:${Ie}`)),x.info(o.blue(`📱 Next.js app accessible at http://${Ne}:${Ie}${Ee}`)),!1!==ye&&x.info(o.cyan(`🔍 Request Inspector: http://${Ne}:${Ie}${P}`)),x.info(o.blue("🔧 Base path handling active")),w||(w=Se(se,Z,x.info),x.info(o.blue("🔧 Config file watcher started"))),h.on("connection",e=>{y.add(e),e.on("close",()=>y.delete(e))})}),v=!1}catch(e){v=!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)}}};ve({logger:x,knownRejections:[Ie],shutdown:async()=>{w&&(ke(w),w=null),b?.dispose(),b=null,m&&(await m.close(),m=null),await W(),await V()}}),await Z()})}(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)=>{Le(n);const i=Pe(n),s=Q(n);try{const t=n.mode||"production",{config:o}=await Ee({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel,buildOverrides:s}),r=m(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 b(r),n.changelog){const t=e||process.cwd(),o=r.build?.outDir||"dist";let i="dist-zip";r.ppDevConfig&&(!1===r.ppDevConfig.distZip?i=o:"object"==typeof r.ppDevConfig.distZip&&"string"==typeof r.ppDevConfig.distZip.outDir&&(i=r.ppDevConfig.distZip.outDir)),await Ce({changelog:n.changelog,executionRoot:t,newAssetsPath:u.resolve(t,o),backupsDirPath:u.resolve(t,r.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:u.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))}})}(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)=>{Le(n);const i=t(n.logLevel),s=e?u.resolve(process.cwd(),e):process.cwd(),a=Q(n);process.env[d]="1";try{q(n.mode||"production",s);const{constants:e}=await K(),t=await(import("next/dist/server/config.js")),l=t.default.default||t["module.exports"].default||t.default,c=await l(e.PHASE_PRODUCTION_BUILD,s);let d=c?.ppDev||{};if(0===Object.keys(d).length){const{getConfig:e}=await import("./index-Dlv5DGp7.js").then(e=>e.h);d=await e(s)}const{getPkg:g}=await import("./index-Dlv5DGp7.js").then(e=>e.h),h=r(d,g(s).name),m=ee(h.distZip,a,p(h.templateName)),b=te(h.versionPlugin,a),w=W(s,c);w&&i.info(o.dim(`[pp-dev] Removed stale dev route types: ${u.relative(s,w)}`)),i.info(o.cyan("[pp-dev] Running `next build`...")),await Z(s);const v="string"==typeof c?.distDir&&c.distDir?c.distDir:".next",y=".next"===v?"out":v,P=u.resolve(s,y);if(!oe.existsSync(P)||!oe.statSync(P).isDirectory())throw new Error(`Next.js build output directory not found: ${P}. "next-build" requires "output: 'export'" in next.config (static export).`);const x=JSON.parse(oe.readFileSync(u.join(s,"package.json"),"utf-8"));if(!1!==b&&!1!==b.enabled&&(await fe({outDir:P,packageVersion:"string"==typeof x.version?x.version:"0.0.0",versionFileTemplate:b.versionFileTemplate,packageRepositoryUrl:"string"==typeof x.repository?x.repository:x.repository?.url,enabled:b.enabled}),i.info(o.green(`✅ VERSION / BUILD-MANIFEST written to ${u.relative(s,P)}`))),!1!==m){const e=u.resolve(s,m.outDir),t=m.inDir?u.resolve(P,m.inDir):P,n=f(e,m.outFileName,"ZIP output file name");oe.mkdirSync(u.dirname(n),{recursive:!0});const r=await B(t);oe.writeFileSync(n,r),i.info(o.green(`✅ Zip archive written to ${u.relative(s,n)}`))}if(n.changelog){const e=!1!==m?m.outDir:y;await Ce({changelog:n.changelog,executionRoot:s,newAssetsPath:P,backupsDirPath:u.resolve(s,h.syncBackupsDir),changelogDestinationPath:u.resolve(s,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))}})}(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)=>{Le(i);const{oldAssetsPath:s=e,newAssetsPath:r=n,destination:a=".",filename:l="CHANGELOG.html",logLevel:c}=i,d=process.cwd();s&&r||(t(c).error(o.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const p=u.resolve(d,s),f=u.resolve(d,r),g=u.resolve(d,a),h=new _e({oldAssetsPath:p,newAssetsPath:f,destinationPath:g,changelogFilename:l});await h.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)=>{Le(i);const{source:s=e,destination:r=n,fontName:a="icon-font"}=i,l=process.cwd(),c=u.resolve(l,s),d=u.resolve(l,r),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)=>{Le(n);try{const t=n.mode||"production",{config:o}=await Ee({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel}),i=await w(m(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode}),"serve");await v(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)=>{Le(n);try{const t=n.mode||"production",{config:o}=await Ee({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel});(await y(m(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{$e(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:s,isLegacyPPWatchConfig:r,isAlreadyMigrated:a,migrateLegacyFlatConfig:l,migratePPWatchConfig:c,generateConfigFileContent:d,discoverMigrateSource:p,loadPackageJsonMigrateConfig:f}=await(import("./migrate-Dm-PSAv7.js")),g=n.format??"ts",h=!1!==n.backup,m=process.cwd(),b=p(m,e);b||(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:v,isPackageJsonConfig:y}=b;i.info(o.blue(`Found config: ${u.relative(m,w)}`));const{getPkg:P}=await import("./index-Dlv5DGp7.js").then(e=>e.h),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:m,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`;oe.writeFileSync(n,o);try{const e=await(import(t(u.resolve(m,n)).toString()));k=e.default?.default??e.default??e}finally{oe.existsSync(n)&&oe.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(w)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(u.resolve(m,w)).toString()));k=t.default?.default??t.default??t}else y?k=f(w):w.endsWith(".json")&&(k=JSON.parse(oe.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)):v||r(k)?(i.info(o.blue("Detected pp-watch config format → migrating to 1.0")),S=c(k)):s(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,g),L=n.output??u.join(m,`pp-dev.config.${g}`);if(n.dryRun&&(i.info(o.green(`\n--- Migrated config (dry-run) → ${u.relative(m,L)} ---\n`)),process.exit(0)),h&&!y&&oe.existsSync(w)){const e=`${w}.bak`;oe.copyFileSync(w,e),i.info(o.blue(`Backed up original to: ${u.relative(m,e)}`))}oe.writeFileSync(L,T,"utf-8"),i.info(o.green(`✅ Migration complete → ${u.relative(m,L)}`)),y?i.info(o.yellow('You can now remove the "pp-dev" field from package.json.')):w!==L&&oe.existsSync(w)&&i.info(o.yellow(`You can now delete the old config: ${u.relative(m,w)}`))})}(Me),Me.help(),Me.version(i),Me.parse();export{$e as stopProfiler};
2
2
  //# sourceMappingURL=cli.js.map