@metricinsights/pp-dev 1.5.0-beta.6 ā 1.5.0-beta.7
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.
- package/dist/cjs/cli.js +1 -1
- package/dist/cjs/index-BPWVgnnE.js +2 -0
- package/dist/cjs/index-BPWVgnnE.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/package.json +1 -1
- package/dist/esm/cli.js +1 -1
- package/dist/esm/index-D9RNUMPH.js +2 -0
- package/dist/esm/index-D9RNUMPH.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/package.json +1 -1
- package/package.json +1 -1
- package/dist/cjs/index-BXC_G2Qq.js +0 -2
- package/dist/cjs/index-BXC_G2Qq.js.map +0 -1
- package/dist/esm/index-Dthlsvfo.js +0 -2
- package/dist/esm/index-Dthlsvfo.js.map +0 -1
package/dist/cjs/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("path"),t=require("fs"),o=require("node:events"),n=require("node:perf_hooks"),i=require("chokidar"),r=require("cac"),s=require("./plugin-ydXTL_i4.js"),a=require("./index-BXC_G2Qq.js"),l=require("vite"),c=require("url"),d=require("dir-compare"),p=require("diff-match-patch"),f=require("isbinaryfile"),u=require("os"),g=require("crypto"),h=require("svgtofont"),m=require("ws");require("http-proxy-middleware"),require("picocolors"),require("node:string_decoder"),require("axios"),require("node:http"),require("node:https"),require("jsdom"),require("process"),require("child_process"),require("node:path"),require("jszip"),require("module"),require("zlib"),require("express"),require("node:crypto"),require("node:fs"),require("node:os"),require("./helpers.js"),require("ejs");const v=e=>e&&"object"==typeof e&&"default"in e?e.default:e;function b(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const o in e)t[o]=e[o];return t.default=e,Object.freeze(t)}const w=b(e),y=b(t),P=b(d),x=v(p),S=b(u),E=b(g),T=v(h);function L(e){return null!=e&&!1!==e}let k=null;const D=[{key:"r",description:"restart the server",async action(e){await e.restart()}},{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 I=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class F{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:t,newAssetsPath:o,destinationPath:n,changelogTemplate:i,diffFileTemplateHandler:r,diffLineTemplateHandler:a,changelogFilename:l,contextLines:c}=e;if(this.logger=s.createLogger(),!t||!o||!n)throw new Error("Previous assets path, current assets path and destination path are required");if(t===o)throw new Error("Previous and current assets paths must be different");if(!this.isExists(t))throw new Error(`Previous assets path ${t} does not exist`);if(!this.isExists(o))throw new Error(`Current assets path ${o} does not exist`);if(this.isZipFile(t)){const e=w.resolve(S.tmpdir(),E.createHash("md5").update(t).digest("hex"));this.oldAssetsPath=this.unzipFile(t,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(t))throw new Error(`Invalid previous assets path ${t}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(t);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(o)){const e=w.resolve(S.tmpdir(),E.createHash("md5").update(o).digest("hex"));this.newAssetsPath=this.unzipFile(o,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(o))throw new Error(`Invalid current assets path ${o}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(o);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${o} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=n,this.mkdirpSync(this.destinationPath),this.changelogFilename=l||"CHANGELOG.html",i&&(this.templateIsValid(i)?this.changelogTemplate=i:this.logger.warn(s.colors.yellow("Invalid changelog template, using default"))),"function"==typeof r&&(this.diffFileTemplateHandler=r),"function"==typeof a&&(this.diffLineTemplateHandler=a),c&&(this.contextLines=c)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return y.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return y.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===y.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){y.existsSync(e)||y.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){y.rmSync(t,{force:!0,recursive:!0}),await s.extractZipSafe(e,t)}normalizeAssetFolderPath(e){const t=y.readdirSync(e);return 1===t.length&&y.lstatSync(w.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(w.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${r=o??"",r.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var r}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(s.colors.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await P.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(I.test(e)&&(e=e.replace(I,"$1$3")),I.test(t)&&(t=t.replace(I,"$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 x,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let r=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:r+o+1,lineType:t})).slice(0,n);return-1!==t&&(r+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(w.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(w.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?w.join(e.path1,e.name1):null,o=e.path2&&e.name2?w.join(e.path2,e.name2):null,n=this.pathToPosix(w.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(w.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(w.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await f.isBinaryFile(t)||await f.isBinaryFile(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(y.readFileSync(t,"utf-8"),y.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(s.colors.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(s.colors.green("Writing changelog file"));const o=this.changelogTemplate.split("%FILES%");o.splice(1,0,t);const n=o.join("");y.writeFileSync(w.join(this.destinationPath,this.changelogFilename),n),this.logger.info(s.colors.green(`Changelog file written to ${w.join(this.destinationPath,this.changelogFilename)}`))}}class _{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await T({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}class ${wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new m.WebSocketServer({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===m.WebSocket.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===s.PP_DEV_HMR_WS_PATH&&(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)};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){s.createLogger().error(`ws handler for "${o.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===m.WebSocket.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 j=r.cac("pp-dev");function A(e,t,o){const n=[...s.PP_DEV_CONFIG_NAMES,"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=>w.join(e,t)),r=i.watch(n,{ignored:e=>{const t=w.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=>{o(s.colors.blue(`š§ Config file changed: ${w.relative(e,n)}`)),a&&clearTimeout(a),a=setTimeout(async()=>{try{o(s.colors.yellow("š Restarting dev server due to config change...")),await t()}catch(e){o(s.colors.red(`ā Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{o(s.colors.red(`ā Config watcher error: ${e}`))}),{watcher:r,restartCallback:t,logger:o}}function C(e){e.watcher&&e.watcher.close()}function N(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 R(e){const{changelog:t,executionRoot:o,newAssetsPath:n,backupsDirPath:i,changelogDestinationPath:r,logLevel:a}=e;let l;if("string"==typeof t)l=w.resolve(o,t);else{if(!y.existsSync(i))return void s.createLogger(a).warn(s.colors.yellow("backups directory not found, skipping changelog generation"));const e=y.readdirSync(i,{withFileTypes:!0});if(!e.length)return void s.createLogger(a).warn(s.colors.yellow("no backups found, skipping changelog generation"));const t=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!t.length)return void s.createLogger(a).warn(s.colors.yellow("no ZIP backups found, skipping changelog generation"));const o=t.reduce((e,t)=>y.statSync(w.resolve(i,e.name)).mtimeMs>y.statSync(w.resolve(i,t.name)).mtimeMs?e:t).name;l=w.resolve(i,o)}const c=new F({oldAssetsPath:l,newAssetsPath:n,destinationPath:r});await c.generateChangelog()}let M=global.__pp_dev_profile_session,q=0;const O=e=>{if(M)return new Promise((t,o)=>{M.post("Profiler.stop",(n,{profile:i})=>{if(n)o(n);else{const o=w.resolve(`./pp-dev-profile-${q++}.cpuprofile`);y.writeFileSync(o,JSON.stringify(i)),e(s.colors.yellow(`CPU profile written to ${s.colors.white(s.colors.dim(o))}`)),M=void 0,t()}})})},V=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function H(e){const t={...e};return delete t["--"],delete t.c,delete t.config,delete t.base,delete t.l,delete t.logLevel,delete t.clearScreen,delete t.d,delete t.debug,delete t.f,delete t.filter,delete t.m,delete t.mode,t}j.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"),j.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,t)=>{V(t);let o=null,i=null,r=!1;const c=e?w.resolve(process.cwd(),e):process.cwd(),d=s.createLogger(t.logLevel),p=async()=>{if(!r){r=!0;try{o&&(d.info(s.colors.yellow("š Stopping existing dev server...")),await o.close(),o=null);const{clearConfigCache:f,getConfig:u}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config);f();const{createServer:g}=await(import("vite")),h=t.mode||"development",m=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(h,m);const v=await l.loadConfigFromFile({mode:h,command:"serve"},t.config,e,t.logLevel);let b=await a.getViteConfig(void 0,{mode:h,root:m});if(v){const{plugins:e,...t}=v.config;b=l.mergeConfig(b,t)}if(o=await g(l.mergeConfig(b,{root:e,base:t.base,mode:t.mode,configFile:t.config,logLevel:t.logLevel,clearScreen:t.clearScreen,optimizeDeps:{force:t.force},server:H(t),customLogger:d},!0)),!o.config.base||"/"===o.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!o.httpServer)throw new Error("HTTP server not available");await o.listen();const y=global.__pp_dev_start_time??!1,P=y?s.colors.dim(`ready in ${s.colors.reset(s.colors.bold(Math.ceil(n.performance.now()-y)))} ms`):"";d.info(`\n ${s.colors.green(`${s.colors.bold("PP-DEV")} v${s.VERSION}`)} ${P}\n`),o.printUrls();const x=await u(m);if(!1!==x.inspector?.enabled){const e=o.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${o.config.server.port??5173}`;d.info(`\n ${s.colors.cyan("š Request Inspector")} ${s.colors.dim(t+s.INSPECTOR_PATH)}\n`)}!function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=t;const o=s.createLogger();t.print&&o.info(s.colors.dim(s.colors.green(" ā"))+s.colors.dim(" press ")+s.colors.bold("h")+s.colors.dim(" to show help"));const n=(t.customShortcuts??[]).filter(L).concat(D);k?.(),k=null;let i=!1;const r=process.stdin.isPaused(),a=process.stdin,l=Boolean(a.isRaw),c=async t=>{if(""===t)return void process.kill(process.pid,"SIGINT");if(""===t)return void await e.close().finally(()=>process.exit(0));if(i)return;"h"===t&&o.info(["",s.colors.bold(" Shortcuts"),...n.map(e=>s.colors.dim(" press ")+s.colors.bold(e.key)+s.colors.dim(` to ${e.description}`))].join("\n"));const r=n.find(e=>e.key===t);r&&(i=!0,await r.action(e),i=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",c).setEncoding("utf8").resume();const d=e.httpServer,p=()=>{k===p&&(d.removeListener("close",p),process.stdin.off("data",c),l||process.stdin.setRawMode(!1),r&&process.stdin.pause(),k=null)};k=p,d.on("close",p)}(o,{print:!0,customShortcuts:[...M?[{key:"p",description:"start/stop the profiler",async action(e){if(M)await O(d.info);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{M=new e.Session,M.connect(),M.post("Profiler.enable",()=>{M?.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("/")}`}})}}]}),i||(i=A(c,p,d.info),d.info(s.colors.blue("š§ Config file watcher started"))),r=!1}catch(e){r=!1,d.error(s.colors.red(`error when starting dev server:\n${e.stack}`),{error:e}),O(d.info),process.exit(1)}}},f=async e=>{d.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));try{i&&(C(i),i=null),o&&(await o.close(),o=null),O(d.info),d.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){d.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>f("SIGINT")),process.on("SIGTERM",()=>f("SIGTERM")),process.on("uncaughtException",e=>{d.error(s.colors.red(`ā Uncaught Exception: ${e}`)),f("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{d.error(s.colors.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),f("unhandledRejection")}),await p()}),j.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port",{default:3e3}).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").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,t)=>{V(t);let n=null,i=null,r=null,l=null,d=!1;const p=s.createLogger(),f=async()=>{if(!d){d=!0;try{const{next:g,constants:h}=await a.safeNextImport(),{PHASE_DEVELOPMENT_SERVER:m}=h;r&&(await r.close(),r=null),i&&(p.info(s.colors.yellow("š Stopping existing Next.js server...")),await new Promise(e=>{i.close(()=>{i=null,e()})})),n&&"function"==typeof n.close&&(await n.close(),n=null);const{clearConfigCache:v}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config);v();const{join:b,basename:P}=await(import("path")),{createServer:x}=await(import("http")),S=await(import("next/dist/server/config.js")),E=S.default.default||S["module.exports"].default||S.default,T=H(t),L=e?b(process.cwd(),e):process.cwd();a.loadPPDevEnv(t.mode||"development",L),p.info(L);const k=await E(m,L);let D=k?.ppDev||{};if(0===Object.keys(D).length)try{const{getConfig:e}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config),t=await e(L);Object.keys(t).length>0?(D=t,p.info(s.colors.blue("š§ Loaded pp-dev config from standalone config file"))):p.info(s.colors.yellow("ā ļø No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){p.info(s.colors.yellow("ā ļø Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else p.info(s.colors.blue("š§ Loaded pp-dev config from Next.js config"));let I=null;try{const{getPkg:e}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config);I=e(L).name}catch{I=P(L)}s.validatePPDevConfig(D,I??"");const F=s.normalizePPDevConfig(D,I??""),_=F.backendBaseURL??"http://localhost:8080",j=F.templateLess,R=F.v7Features,M=F.disableSSLValidation,q=F.enableProxyCache,O=F.proxyCacheTTL,V=F.personalAccessToken,U=F.miHudLess,z=F.inspectorEnabled,W=F.inspectorMaxMemory,B=F.inspectorCaptureLimit,Z=F.appId??(process.env.MI_APP_ID&&parseInt(process.env.MI_APP_ID,10)||void 0)??(process.env.MI_PORTAL_PAGE_ID&&parseInt(process.env.MI_PORTAL_PAGE_ID,10)||void 0)??1,G=k?.basePath;let J="";G?J=G:(J=j?s.PATH_PAGE_PREFIX:R?s.PATH_TEMPLATE_LOCAL_PREFIX:s.PATH_TEMPLATE_PREFIX,J+=`/${I}`);const X=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}:{}}(t),K=async e=>{delete process.env.TURBOPACK,n&&"function"==typeof n.close&&(await n.close(),n=null);const t={dev:!0,customServer:!0,hostname:T.host||"localhost",port:T.port,dir:L,conf:{...k,basePath:J,assetPrefix:J}};e.webpack?t.webpack=!0:e.turbopack&&(t.turbopack=!0),n=g(t),await n.prepare()};if(X.webpack)await K({webpack:!0});else if(X.turbopack)try{await K({turbopack:!0})}catch(e){if(!N(e))throw e;p.warn(s.colors.yellow("ā Turbopack is unavailable (native bindings). Falling back to Webpack.")),await K({webpack:!0})}else try{await K({})}catch(e){if(!N(e))throw e;p.warn(s.colors.yellow("ā Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await K({webpack:!0})}if(!n)throw new Error("Next.js app failed to initialize");if(J.endsWith("/")||(J+="/"),"/"===J)throw new Error('basePath cannot be equal to "/" or equal to empty string');p.info(s.colors.green("ā
Next.js app prepared successfully")),p.info(s.colors.blue(`š§ pp-dev plugin configured for template: ${I}`)),p.info(s.colors.blue(`š§ Base path configured: ${J}`)),_&&(p.info(s.colors.blue(`š Backend URL: ${_}`)),p.info(s.colors.blue(`š Custom App ID: ${Z}`)));const Y=n.getRequestHandler(),Q="number"==typeof T.port?T.port:3e3,ee="string"==typeof T.host?T.host||"0.0.0.0":"localhost",te=new Set;i=x(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=c.parse(o,!0);if(ne.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(ie.length>0){let l=0;const d=()=>{if(l>=ie.length)return void r();const o=ie[l];l++,o(e,t,d)};return void d()}return void r()}let s=0;const a=()=>{if(s>=ne.length)return void r();const o=ne[s];s++,o(e,t,a)};return void a()}async function r(){if(n.startsWith(J))i=c.parse(o,!0);else{if(n===J.replace(/\/$/,"")){const e=o.replace(n,J);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:J}),void t.end()}await Y(e,t,i)}r()}catch(f){p.error(`Error handling request: ${f instanceof Error?f.message:String(f)}`,{error:f instanceof Error?f:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let oe=null,ne=[],ie=[];if(!1!==z){const e=new s.RequestStore(W);s.registerInspectorRoutes(s.internalServer,e,B);const t=s.createRequestCaptureMiddleware(e,B);ne.push(t)}if(_){const e=new URL(_).host,t=s.createUserHostGuard();ie.unshift(t),ne.unshift(t),_.startsWith("https://")&&(o.EventEmitter.defaultMaxListeners=Math.max(o.EventEmitter.defaultMaxListeners,20));const l={headers:{host:e,referer:_,origin:_.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},appId:Z,templateLess:j,disableSSLValidation:M,v7Features:R,personalAccessToken:V??process.env.MI_ACCESS_TOKEN};oe=new s.MiAPI(_,l);const c=s.initPPRedirect(J,I??void 0),d=(e,t,o)=>{c(e,t,o)};ie.push(d),ne.push(d);const f=a.createDevPanelAssetMiddleware(J);if(ie.push(f),ne.push(f),q){let e=+O;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={devServer:{middlewares:{use:e=>e},config:{logger:console}},ttl:e},o=s.initProxyCache(t),n=(e,t,n)=>{o(e,t,n)};ne.push(n),p.info(s.colors.blue(`š§ Proxy cache middleware added with TTL: ${e}ms`))}const g=new RegExp(`^((${u=J,u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})|/)$`),m=s.initLoadPPData(g,oe,Object.assign({base:J},l,{miHudLess:U})),v=(e,t,o)=>{m(e,t,o)};ne.push(v);const b=J.endsWith("/")?J.substring(0,J.length-1):J,x={middlewares:{use:e=>e},config:{logger:console}},S=s.initProxy({devServer:x,baseURL:_,proxyIgnore:["/@vite","/@metricinsights","/@",b,"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:M,miAPI:oe,templateName:I??void 0}),T=(e,t,o)=>{S(e,t,o)};ne.push(T);const D=s.internalServer,A=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(s.INSPECTOR_PATH)||e.url?.startsWith(s.VARIABLES_EDITOR_PATH)){return void D(e,t,()=>{})}o()};ie.push(A),ne.push(A);const C=s.initRewriteResponse(e=>{const t=e.split("?")[0];return t.startsWith(J)&&!t.includes("/_next/")},(t,o)=>{const n=oe.buildPage(t,U),i=a.injectDevPanel(n,J,{backendBaseURL:_,templateLess:j,appId:Z,devPanelPosition:F.devPanelPosition,devPanelHidden:F.devPanelHidden,devPanelAutoHide:F.devPanelAutoHide});return Buffer.from(s.urlReplacer(e,o.headers.host??"",i))}),N=(e,t,o)=>{C(e,t,o)};ne.push(N),r=new $;let H=k?.distDir;try{process.env[s.PP_DEV_NEXT_BUILD_ENV_VAR]="1";const e=await E(h.PHASE_PRODUCTION_BUILD,L);H=e?.distDir??H}catch{}const z=(H??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),W=z&&".next"!==z?z:"out";let B,G="0.0.0";try{const e=JSON.parse(y.readFileSync(w.join(L,"package.json"),"utf-8"));G="string"==typeof e.version?e.version:G,B="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const X=new s.DistService(I??P(L),{root:L,backupFolder:w.resolve(L,F.syncBackupsDir),nextBuild:{projectRoot:L,distDir:W,packageVersion:G,packageRepositoryUrl:B}}),K={ws:r.ws,config:{clientInjectionPlugin:{v7Features:R}}};new s.ClientService(K,{distService:X,miAPI:oe}),s.registerVariablesEditorRoutes(s.internalServer,{distService:X,miAPI:oe}),s.registerUserRoutes(s.internalServer,{miAPI:oe}),s.startKeepingUsers({persist:F.persistUsers,miAPI:oe,projectRoot:L,miUrl:_});const Y="function"==typeof n?.getUpgradeHandler?n.getUpgradeHandler():null;i.on("upgrade",(e,t,o)=>{r?.handleUpgrade(e,t,o)||(Y?Y(e,t,o):t.destroy())}),p.info(s.colors.blue(`š§ ${ne.length} pp-dev middlewares initialized`)),p.info(s.colors.blue(`š§ ${ie.length} essential middlewares for internal routes`)),p.info(s.colors.blue(`š§ MiAPI initialized for backend: ${_}`)),p.info(s.colors.blue(`š§ Custom App ID: ${Z}`))}i.listen(Q,ee,()=>{p.info(s.colors.green(`ā
pp-dev Next.js server running at http://${ee}:${Q}`)),p.info(s.colors.blue(`š± Next.js app accessible at http://${ee}:${Q}${J}`)),!1!==z&&p.info(s.colors.cyan(`š Request Inspector: http://${ee}:${Q}${s.INSPECTOR_PATH}`)),p.info(s.colors.blue("š§ Base path handling active")),l||(l=A(L,f,p.info),p.info(s.colors.blue("š§ Config file watcher started"))),i.on("connection",e=>{te.add(e),e.on("close",()=>te.delete(e))});const e=async e=>{p.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));const t=setTimeout(()=>{p.info(s.colors.yellow("ā° Shutdown timeout reached, forcing exit")),process.exit(0)},5e3);try{l&&(C(l),l=null);for(const e of Array.from(te))e.destroy();te.clear(),r&&(await r.close(),r=null),await new Promise(e=>{i.close(()=>{p.info(s.colors.yellow("š HTTP server closed")),e()})}),n&&"function"==typeof n.close&&(await n.close(),p.info(s.colors.yellow("š Next.js app closed"))),clearTimeout(t),p.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),p.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};let t=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(t=e,p.info(s.colors.green("ā
Using global process object for event handlers")))}if("function"==typeof t.on)try{t.on("SIGINT",()=>e("SIGINT")),t.on("SIGTERM",()=>e("SIGTERM")),t.on("uncaughtException",t=>{p.error(s.colors.red(`ā Uncaught Exception: ${t}`)),e("uncaughtException")}),t.on("unhandledRejection",(t,o)=>{p.error(s.colors.red(`ā Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")}),p.info(s.colors.green("ā
Process event handlers registered successfully"))}catch(e){p.warn(s.colors.yellow(`ā ļø Failed to register process event handlers: ${e}`))}else p.warn(s.colors.yellow("ā ļø process.on is not available, graceful shutdown handlers will not be registered")),p.info(s.colors.blue("š” This might be due to bundling or environment constraints"))}),d=!1}catch(e){d=!1,p.error(s.colors.red(`ā Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(p.error(s.colors.red("ā Next.js Peer Dependency Error:")),p.error(s.colors.red(e.message)),p.error(s.colors.yellow("\nš” To fix this issue:")),p.error(s.colors.blue(" 1. Install Next.js in your project:")),p.error(s.colors.white(" npm install next@^16")),p.error(s.colors.blue(" 2. Or use yarn:")),p.error(s.colors.white(" yarn add next@^16")),p.error(s.colors.blue(" 3. Or use pnpm:")),p.error(s.colors.white(" pnpm add next@^16")),p.error(s.colors.yellow("\nš For more information, see:")),p.error(s.colors.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}var u}},u=async e=>{p.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));try{l&&(C(l),l=null),r&&(await r.close(),r=null),i&&await new Promise(e=>{i.close(()=>{i=null,e()})}),n&&"function"==typeof n.close&&(await n.close(),n=null),p.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){p.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>u("SIGINT")),process.on("SIGTERM",()=>u("SIGTERM")),process.on("uncaughtException",e=>{p.error(s.colors.red(`ā Uncaught Exception: ${e}`)),u("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{p.error(s.colors.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),u("unhandledRejection")}),await f()}),j.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,t)=>{V(t);const o=H(t),n=a.resolveBuildCliOverrides(t);try{const i=t.mode||"production",r=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(i,r);const s=await l.loadConfigFromFile({mode:i,command:"build"},t.config,e,t.logLevel);let c=await a.getViteConfig(n,{mode:i,root:r});if(s){const{plugins:e,...t}=s.config;c=l.mergeConfig(c,t)}const d=l.mergeConfig(c,{root:e,base:t.base,mode:t.mode,configFile:t.config,logLevel:t.logLevel,clearScreen:t.clearScreen,optimizeDeps:{force:t.force},build:o},!0);if(await l.build(d),o.changelog){const n=e||process.cwd(),i=d.build?.outDir||"dist";let r="dist-zip";d.ppDevConfig&&(!1===d.ppDevConfig.distZip?r=i:"object"==typeof d.ppDevConfig.distZip&&"string"==typeof d.ppDevConfig.distZip.outDir&&(r=d.ppDevConfig.distZip.outDir)),await R({changelog:o.changelog,executionRoot:n,newAssetsPath:w.resolve(n,i),backupsDirPath:w.resolve(n,d.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:w.resolve(n,r),logLevel:t.logLevel})}}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t)=>{V(t);const o=s.createLogger(t.logLevel),n=e?w.resolve(process.cwd(),e):process.cwd(),i=a.resolveBuildCliOverrides(t);process.env[s.PP_DEV_NEXT_BUILD_ENV_VAR]="1";try{a.loadPPDevEnv(t.mode||"production",n);const{constants:e}=await a.safeNextImport(),r=await(import("next/dist/server/config.js")),l=r.default.default||r["module.exports"].default||r.default,c=await l(e.PHASE_PRODUCTION_BUILD,n);let d,p=c?.ppDev||{};if(0===Object.keys(p).length){const{getConfig:e}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config);p=await e(n)}try{const{getPkg:e}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config);d=e(n).name}catch{d=w.basename(n)}const f=s.normalizePPDevConfig(p,d),u=a.applyDistZipOverride(f.distZip,i,s.createDefaultZipFileName(d)),g=a.applyVersionManifestOverride(f.versionPlugin,i),h=s.removeStaleDevTypes(n,c);h&&o.info(s.colors.dim(`[pp-dev] Removed stale dev route types: ${w.relative(n,h)}`)),o.info(s.colors.cyan("[pp-dev] Running `next build`...")),await s.runNextBuildProcess(n);const m="string"==typeof c?.distDir&&c.distDir?c.distDir:".next",v=".next"===m?"out":m,b=w.resolve(n,v);if(!y.existsSync(b)||!y.statSync(b).isDirectory())throw new Error(`Next.js build output directory not found: ${b}. "next-build" requires "output: 'export'" in next.config (static export).`);const P=JSON.parse(y.readFileSync(w.join(n,"package.json"),"utf-8"));if(!1!==g&&!1!==g.enabled&&(s.writeBuildVersionManifest({outDir:b,packageVersion:"string"==typeof P.version?P.version:"0.0.0",versionFileTemplate:g.versionFileTemplate,packageRepositoryUrl:"string"==typeof P.repository?P.repository:P.repository?.url,enabled:g.enabled}),o.info(s.colors.green(`ā
VERSION / BUILD-MANIFEST written to ${w.relative(n,b)}`))),!1!==u){const e=w.resolve(n,u.outDir),t=u.inDir?w.resolve(b,u.inDir):b,i=s.resolveOutputFilePath(e,u.outFileName,"ZIP output file name");y.mkdirSync(w.dirname(i),{recursive:!0});const r=await s.zipDirectoryToBuffer(t);y.writeFileSync(i,r),o.info(s.colors.green(`ā
Zip archive written to ${w.relative(n,i)}`))}if(t.changelog){const e=!1!==u?u.outDir:v;await R({changelog:t.changelog,executionRoot:n,newAssetsPath:b,backupsDirPath:w.resolve(n,f.syncBackupsDir),changelogDestinationPath:w.resolve(n,e),logLevel:t.logLevel})}}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t,o)=>{V(o);const{oldAssetsPath:n=e,newAssetsPath:i=t,destination:r=".",filename:a="CHANGELOG.html",logLevel:l}=o,c=process.cwd();n&&i||(s.createLogger(l).error(s.colors.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=w.resolve(c,n),p=w.resolve(c,i),f=w.resolve(c,r),u=new F({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:a});await u.generateChangelog()}),j.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,t,o)=>{V(o);const{source:n=e,destination:i=t,fontName:r="icon-font"}=o,a=process.cwd(),l=w.resolve(a,n),c=w.resolve(a,i),d=new _({sourceDir:l,outputDir:c,fontName:r}),p=s.createLogger(o.logLevel);p.info(`Generating icon font from SVG files in ${s.colors.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${s.colors.dim(c)}`)}),j.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,t)=>{V(t);try{const o=t.mode||"production",n=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(o,n);const i=await l.loadConfigFromFile({mode:o,command:"build"},t.config,e,t.logLevel);let r=await a.getViteConfig(void 0,{mode:o,root:n});if(i){const{plugins:e,...t}=i.config;r=l.mergeConfig(r,t)}const s=await l.resolveConfig(l.mergeConfig(r,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode}),"serve");await l.optimizeDeps(s,t.force,!0)}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}}),j.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,t)=>{V(t);try{const o=t.mode||"production",n=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(o,n);const i=await l.loadConfigFromFile({mode:o,command:"build"},t.config,e,t.logLevel);let r=await a.getViteConfig(void 0,{mode:o,root:n});if(i){const{plugins:e,...t}=i.config;r=l.mergeConfig(r,t)}(await l.preview(l.mergeConfig(r,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode,build:{outDir:t.outDir},preview:{port:t.port,strictPort:t.strictPort,host:t.host,https:t.https,open:t.open}}))).printUrls()}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t)=>{const o=s.createLogger(t.logLevel),{isLegacyFlatConfig:n,isLegacyPPWatchConfig:i,isAlreadyMigrated:r,migrateLegacyFlatConfig:a,migratePPWatchConfig:l,generateConfigFileContent:c,discoverMigrateSource:d,loadPackageJsonMigrateConfig:p}=await Promise.resolve().then(()=>require("./migrate-XcY45UiD.js")),f=t.format??"ts",u=!1!==t.backup,g=process.cwd(),h=d(g,e);h||(o.warn(s.colors.yellow("No pp-dev or pp-watch config file found in the current directory.")),o.info(s.colors.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:m,isWatchConfig:v,isPackageJsonConfig:b}=h;o.info(s.colors.blue(`Found config: ${w.relative(g,m)}`));const{getPkg:P}=await Promise.resolve().then(()=>require("./index-BXC_G2Qq.js")).then(e=>e.config),x=P();let S,E={};try{if(/\.[cm]?ts$/i.test(m)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:g,entryPoints:[m],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`;y.writeFileSync(n,o);try{const e=await(import(t(w.resolve(g,n)).toString()));E=e.default?.default??e.default??e}finally{y.existsSync(n)&&y.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(m)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(w.resolve(g,m)).toString()));E=t.default?.default??t.default??t}else b?E=p(m):m.endsWith(".json")&&(E=JSON.parse(y.readFileSync(m,"utf-8")))}catch(e){o.error(s.colors.red(`Failed to load config file: ${e.message}`)),process.exit(1)}E&&"object"==typeof E||(o.error(s.colors.red("Config file did not export a valid object.")),process.exit(1)),r(E)?(o.info(s.colors.green("Config is already in 1.0 format ā nothing to migrate.")),process.exit(0)):v||i(E)?(o.info(s.colors.blue("Detected pp-watch config format ā migrating to 1.0")),S=l(E)):n(E)?(o.info(s.colors.blue("Detected 0.x flat config format ā migrating to 1.0")),S=a(E,x.name)):(o.warn(s.colors.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=c(S,f),L=t.output??w.join(g,`pp-dev.config.${f}`);if(t.dryRun&&(o.info(s.colors.green(`\n--- Migrated config (dry-run) ā ${w.relative(g,L)} ---\n`)),process.exit(0)),u&&!b&&y.existsSync(m)){const e=`${m}.bak`;y.copyFileSync(m,e),o.info(s.colors.blue(`Backed up original to: ${w.relative(g,e)}`))}y.writeFileSync(L,T,"utf-8"),o.info(s.colors.green(`ā
Migration complete ā ${w.relative(g,L)}`)),b?o.info(s.colors.yellow('You can now remove the "pp-dev" field from package.json.')):m!==L&&y.existsSync(m)&&o.info(s.colors.yellow(`You can now delete the old config: ${w.relative(g,m)}`))}),j.help(),j.version(s.VERSION),j.parse(),exports.stopProfiler=O;
|
|
1
|
+
"use strict";const e=require("path"),t=require("fs"),o=require("node:events"),n=require("node:perf_hooks"),i=require("chokidar"),r=require("cac"),s=require("./plugin-ydXTL_i4.js"),a=require("./index-BPWVgnnE.js"),l=require("vite"),c=require("url"),d=require("dir-compare"),p=require("diff-match-patch"),f=require("isbinaryfile"),u=require("os"),g=require("crypto"),h=require("svgtofont"),m=require("ws");require("http-proxy-middleware"),require("picocolors"),require("node:string_decoder"),require("axios"),require("node:http"),require("node:https"),require("jsdom"),require("process"),require("child_process"),require("node:path"),require("jszip"),require("module"),require("zlib"),require("express"),require("node:crypto"),require("node:fs"),require("node:os"),require("./helpers.js"),require("ejs");const v=e=>e&&"object"==typeof e&&"default"in e?e.default:e;function b(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const o in e)t[o]=e[o];return t.default=e,Object.freeze(t)}const w=b(e),y=b(t),P=b(d),x=v(p),S=b(u),E=b(g),T=v(h);function L(e){return null!=e&&!1!==e}let k=null;const D=[{key:"r",description:"restart the server",async action(e){await e.restart()}},{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 I=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class F{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:t,newAssetsPath:o,destinationPath:n,changelogTemplate:i,diffFileTemplateHandler:r,diffLineTemplateHandler:a,changelogFilename:l,contextLines:c}=e;if(this.logger=s.createLogger(),!t||!o||!n)throw new Error("Previous assets path, current assets path and destination path are required");if(t===o)throw new Error("Previous and current assets paths must be different");if(!this.isExists(t))throw new Error(`Previous assets path ${t} does not exist`);if(!this.isExists(o))throw new Error(`Current assets path ${o} does not exist`);if(this.isZipFile(t)){const e=w.resolve(S.tmpdir(),E.createHash("md5").update(t).digest("hex"));this.oldAssetsPath=this.unzipFile(t,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(t))throw new Error(`Invalid previous assets path ${t}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(t);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(o)){const e=w.resolve(S.tmpdir(),E.createHash("md5").update(o).digest("hex"));this.newAssetsPath=this.unzipFile(o,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(o))throw new Error(`Invalid current assets path ${o}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(o);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${o} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=n,this.mkdirpSync(this.destinationPath),this.changelogFilename=l||"CHANGELOG.html",i&&(this.templateIsValid(i)?this.changelogTemplate=i:this.logger.warn(s.colors.yellow("Invalid changelog template, using default"))),"function"==typeof r&&(this.diffFileTemplateHandler=r),"function"==typeof a&&(this.diffLineTemplateHandler=a),c&&(this.contextLines=c)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return y.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return y.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===y.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){y.existsSync(e)||y.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){y.rmSync(t,{force:!0,recursive:!0}),await s.extractZipSafe(e,t)}normalizeAssetFolderPath(e){const t=y.readdirSync(e);return 1===t.length&&y.lstatSync(w.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(w.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${r=o??"",r.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var r}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(s.colors.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await P.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(I.test(e)&&(e=e.replace(I,"$1$3")),I.test(t)&&(t=t.replace(I,"$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 x,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let r=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:r+o+1,lineType:t})).slice(0,n);return-1!==t&&(r+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(w.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(w.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?w.join(e.path1,e.name1):null,o=e.path2&&e.name2?w.join(e.path2,e.name2):null,n=this.pathToPosix(w.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(w.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(w.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await f.isBinaryFile(t)||await f.isBinaryFile(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(y.readFileSync(t,"utf-8"),y.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(s.colors.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(s.colors.green("Writing changelog file"));const o=this.changelogTemplate.split("%FILES%");o.splice(1,0,t);const n=o.join("");y.writeFileSync(w.join(this.destinationPath,this.changelogFilename),n),this.logger.info(s.colors.green(`Changelog file written to ${w.join(this.destinationPath,this.changelogFilename)}`))}}class _{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await T({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}class ${wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new m.WebSocketServer({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===m.WebSocket.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===s.PP_DEV_HMR_WS_PATH&&(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)};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){s.createLogger().error(`ws handler for "${o.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===m.WebSocket.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 j=r.cac("pp-dev");function A(e,t,o){const n=[...s.PP_DEV_CONFIG_NAMES,"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=>w.join(e,t)),r=i.watch(n,{ignored:e=>{const t=w.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=>{o(s.colors.blue(`š§ Config file changed: ${w.relative(e,n)}`)),a&&clearTimeout(a),a=setTimeout(async()=>{try{o(s.colors.yellow("š Restarting dev server due to config change...")),await t()}catch(e){o(s.colors.red(`ā Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{o(s.colors.red(`ā Config watcher error: ${e}`))}),{watcher:r,restartCallback:t,logger:o}}function C(e){e.watcher&&e.watcher.close()}function N(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 R(e){const{changelog:t,executionRoot:o,newAssetsPath:n,backupsDirPath:i,changelogDestinationPath:r,logLevel:a}=e;let l;if("string"==typeof t)l=w.resolve(o,t);else{if(!y.existsSync(i))return void s.createLogger(a).warn(s.colors.yellow("backups directory not found, skipping changelog generation"));const e=y.readdirSync(i,{withFileTypes:!0});if(!e.length)return void s.createLogger(a).warn(s.colors.yellow("no backups found, skipping changelog generation"));const t=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!t.length)return void s.createLogger(a).warn(s.colors.yellow("no ZIP backups found, skipping changelog generation"));const o=t.reduce((e,t)=>y.statSync(w.resolve(i,e.name)).mtimeMs>y.statSync(w.resolve(i,t.name)).mtimeMs?e:t).name;l=w.resolve(i,o)}const c=new F({oldAssetsPath:l,newAssetsPath:n,destinationPath:r});await c.generateChangelog()}let M=global.__pp_dev_profile_session,q=0;const O=e=>{if(M)return new Promise((t,o)=>{M.post("Profiler.stop",(n,{profile:i})=>{if(n)o(n);else{const o=w.resolve(`./pp-dev-profile-${q++}.cpuprofile`);y.writeFileSync(o,JSON.stringify(i)),e(s.colors.yellow(`CPU profile written to ${s.colors.white(s.colors.dim(o))}`)),M=void 0,t()}})})},V=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function H(e){const t={...e};return delete t["--"],delete t.c,delete t.config,delete t.base,delete t.l,delete t.logLevel,delete t.clearScreen,delete t.d,delete t.debug,delete t.f,delete t.filter,delete t.m,delete t.mode,t}j.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"),j.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,t)=>{V(t);let o=null,i=null,r=!1;const c=e?w.resolve(process.cwd(),e):process.cwd(),d=s.createLogger(t.logLevel),p=async()=>{if(!r){r=!0;try{o&&(d.info(s.colors.yellow("š Stopping existing dev server...")),await o.close(),o=null);const{clearConfigCache:f,getConfig:u}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config);f();const{createServer:g}=await(import("vite")),h=t.mode||"development",m=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(h,m);const v=await l.loadConfigFromFile({mode:h,command:"serve"},t.config,e,t.logLevel);let b=await a.getViteConfig(void 0,{mode:h,root:m});if(v){const{plugins:e,...t}=v.config;b=l.mergeConfig(b,t)}if(o=await g(l.mergeConfig(b,{root:e,base:t.base,mode:t.mode,configFile:t.config,logLevel:t.logLevel,clearScreen:t.clearScreen,optimizeDeps:{force:t.force},server:H(t),customLogger:d},!0)),!o.config.base||"/"===o.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!o.httpServer)throw new Error("HTTP server not available");await o.listen();const y=global.__pp_dev_start_time??!1,P=y?s.colors.dim(`ready in ${s.colors.reset(s.colors.bold(Math.ceil(n.performance.now()-y)))} ms`):"";d.info(`\n ${s.colors.green(`${s.colors.bold("PP-DEV")} v${s.VERSION}`)} ${P}\n`),o.printUrls();const x=await u(m);if(!1!==x.inspector?.enabled){const e=o.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${o.config.server.port??5173}`;d.info(`\n ${s.colors.cyan("š Request Inspector")} ${s.colors.dim(t+s.INSPECTOR_PATH)}\n`)}!function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=t;const o=s.createLogger();t.print&&o.info(s.colors.dim(s.colors.green(" ā"))+s.colors.dim(" press ")+s.colors.bold("h")+s.colors.dim(" to show help"));const n=(t.customShortcuts??[]).filter(L).concat(D);k?.(),k=null;let i=!1;const r=process.stdin.isPaused(),a=process.stdin,l=Boolean(a.isRaw),c=async t=>{if(""===t)return void process.kill(process.pid,"SIGINT");if(""===t)return void await e.close().finally(()=>process.exit(0));if(i)return;"h"===t&&o.info(["",s.colors.bold(" Shortcuts"),...n.map(e=>s.colors.dim(" press ")+s.colors.bold(e.key)+s.colors.dim(` to ${e.description}`))].join("\n"));const r=n.find(e=>e.key===t);r&&(i=!0,await r.action(e),i=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",c).setEncoding("utf8").resume();const d=e.httpServer,p=()=>{k===p&&(d.removeListener("close",p),process.stdin.off("data",c),l||process.stdin.setRawMode(!1),r&&process.stdin.pause(),k=null)};k=p,d.on("close",p)}(o,{print:!0,customShortcuts:[...M?[{key:"p",description:"start/stop the profiler",async action(e){if(M)await O(d.info);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{M=new e.Session,M.connect(),M.post("Profiler.enable",()=>{M?.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("/")}`}})}}]}),i||(i=A(c,p,d.info),d.info(s.colors.blue("š§ Config file watcher started"))),r=!1}catch(e){r=!1,d.error(s.colors.red(`error when starting dev server:\n${e.stack}`),{error:e}),O(d.info),process.exit(1)}}},f=async e=>{d.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));try{i&&(C(i),i=null),o&&(await o.close(),o=null),O(d.info),d.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){d.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>f("SIGINT")),process.on("SIGTERM",()=>f("SIGTERM")),process.on("uncaughtException",e=>{d.error(s.colors.red(`ā Uncaught Exception: ${e}`)),f("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{d.error(s.colors.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),f("unhandledRejection")}),await p()}),j.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port",{default:3e3}).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").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,t)=>{V(t);let n=null,i=null,r=null,l=null,d=!1;const p=s.createLogger(),f=async()=>{if(!d){d=!0;try{const{next:g,constants:h}=await a.safeNextImport(),{PHASE_DEVELOPMENT_SERVER:m}=h;r&&(await r.close(),r=null),i&&(p.info(s.colors.yellow("š Stopping existing Next.js server...")),await new Promise(e=>{i.close(()=>{i=null,e()})})),n&&"function"==typeof n.close&&(await n.close(),n=null);const{clearConfigCache:v}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config);v();const{join:b,basename:P}=await(import("path")),{createServer:x}=await(import("http")),S=await(import("next/dist/server/config.js")),E=S.default.default||S["module.exports"].default||S.default,T=H(t),L=e?b(process.cwd(),e):process.cwd();a.loadPPDevEnv(t.mode||"development",L),p.info(L);const k=await E(m,L);let D=k?.ppDev||{};if(0===Object.keys(D).length)try{const{getConfig:e}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config),t=await e(L);Object.keys(t).length>0?(D=t,p.info(s.colors.blue("š§ Loaded pp-dev config from standalone config file"))):p.info(s.colors.yellow("ā ļø No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){p.info(s.colors.yellow("ā ļø Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else p.info(s.colors.blue("š§ Loaded pp-dev config from Next.js config"));let I=null;try{const{getPkg:e}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config);I=e(L).name}catch{I=P(L)}s.validatePPDevConfig(D,I??"");const F=s.normalizePPDevConfig(D,I??""),_=F.backendBaseURL??"http://localhost:8080",j=F.templateLess,R=F.v7Features,M=F.disableSSLValidation,q=F.enableProxyCache,O=F.proxyCacheTTL,V=F.personalAccessToken,U=F.miHudLess,z=F.inspectorEnabled,W=F.inspectorMaxMemory,B=F.inspectorCaptureLimit,Z=F.appId??(process.env.MI_APP_ID&&parseInt(process.env.MI_APP_ID,10)||void 0)??(process.env.MI_PORTAL_PAGE_ID&&parseInt(process.env.MI_PORTAL_PAGE_ID,10)||void 0)??1,G=k?.basePath;let J="";G?J=G:(J=j?s.PATH_PAGE_PREFIX:R?s.PATH_TEMPLATE_LOCAL_PREFIX:s.PATH_TEMPLATE_PREFIX,J+=`/${I}`);const X=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}:{}}(t),K=async e=>{delete process.env.TURBOPACK,n&&"function"==typeof n.close&&(await n.close(),n=null);const t={dev:!0,customServer:!0,hostname:T.host||"localhost",port:T.port,dir:L,conf:{...k,basePath:J,assetPrefix:J}};e.webpack?t.webpack=!0:e.turbopack&&(t.turbopack=!0),n=g(t),await n.prepare()};if(X.webpack)await K({webpack:!0});else if(X.turbopack)try{await K({turbopack:!0})}catch(e){if(!N(e))throw e;p.warn(s.colors.yellow("ā Turbopack is unavailable (native bindings). Falling back to Webpack.")),await K({webpack:!0})}else try{await K({})}catch(e){if(!N(e))throw e;p.warn(s.colors.yellow("ā Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await K({webpack:!0})}if(!n)throw new Error("Next.js app failed to initialize");if(J.endsWith("/")||(J+="/"),"/"===J)throw new Error('basePath cannot be equal to "/" or equal to empty string');p.info(s.colors.green("ā
Next.js app prepared successfully")),p.info(s.colors.blue(`š§ pp-dev plugin configured for template: ${I}`)),p.info(s.colors.blue(`š§ Base path configured: ${J}`)),_&&(p.info(s.colors.blue(`š Backend URL: ${_}`)),p.info(s.colors.blue(`š Custom App ID: ${Z}`)));const Y=n.getRequestHandler(),Q="number"==typeof T.port?T.port:3e3,ee="string"==typeof T.host?T.host||"0.0.0.0":"localhost",te=new Set;i=x(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=c.parse(o,!0);if(ne.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(ie.length>0){let l=0;const d=()=>{if(l>=ie.length)return void r();const o=ie[l];l++,o(e,t,d)};return void d()}return void r()}let s=0;const a=()=>{if(s>=ne.length)return void r();const o=ne[s];s++,o(e,t,a)};return void a()}async function r(){if(n.startsWith(J))i=c.parse(o,!0);else{if(n===J.replace(/\/$/,"")){const e=o.replace(n,J);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:J}),void t.end()}await Y(e,t,i)}r()}catch(f){p.error(`Error handling request: ${f instanceof Error?f.message:String(f)}`,{error:f instanceof Error?f:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let oe=null,ne=[],ie=[];if(!1!==z){const e=new s.RequestStore(W);s.registerInspectorRoutes(s.internalServer,e,B);const t=s.createRequestCaptureMiddleware(e,B);ne.push(t)}if(_){const e=new URL(_).host,t=s.createUserHostGuard();ie.unshift(t),ne.unshift(t),_.startsWith("https://")&&(o.EventEmitter.defaultMaxListeners=Math.max(o.EventEmitter.defaultMaxListeners,20));const l={headers:{host:e,referer:_,origin:_.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},appId:Z,templateLess:j,disableSSLValidation:M,v7Features:R,personalAccessToken:V??process.env.MI_ACCESS_TOKEN};oe=new s.MiAPI(_,l);const c=s.initPPRedirect(J,I??void 0),d=(e,t,o)=>{c(e,t,o)};ie.push(d),ne.push(d);const f=a.createDevPanelAssetMiddleware(J);if(ie.push(f),ne.push(f),q){let e=+O;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={devServer:{middlewares:{use:e=>e},config:{logger:console}},ttl:e},o=s.initProxyCache(t),n=(e,t,n)=>{o(e,t,n)};ne.push(n),p.info(s.colors.blue(`š§ Proxy cache middleware added with TTL: ${e}ms`))}const g=new RegExp(`^((${u=J,u.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})|/)$`),m=s.initLoadPPData(g,oe,Object.assign({base:J},l,{miHudLess:U})),v=(e,t,o)=>{m(e,t,o)};ne.push(v);const b=J.endsWith("/")?J.substring(0,J.length-1):J,x={middlewares:{use:e=>e},config:{logger:console}},S=s.initProxy({devServer:x,baseURL:_,proxyIgnore:["/@vite","/@metricinsights","/@",b,"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:M,miAPI:oe,templateName:I??void 0}),T=(e,t,o)=>{S(e,t,o)};ne.push(T);const D=s.internalServer,A=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(s.INSPECTOR_PATH)||e.url?.startsWith(s.VARIABLES_EDITOR_PATH)){return void D(e,t,()=>{})}o()};ie.push(A),ne.push(A);const C=s.initRewriteResponse(e=>{const t=e.split("?")[0];return t.startsWith(J)&&!t.includes("/_next/")},(t,o)=>{const n=oe.buildPage(t,U),i=a.injectDevPanel(n,J,{backendBaseURL:_,templateLess:j,appId:Z,devPanelPosition:F.devPanelPosition,devPanelHidden:F.devPanelHidden,devPanelAutoHide:F.devPanelAutoHide});return Buffer.from(s.urlReplacer(e,o.headers.host??"",i))}),N=(e,t,o)=>{C(e,t,o)};ne.push(N),r=new $;let H=k?.distDir;try{process.env[s.PP_DEV_NEXT_BUILD_ENV_VAR]="1";const e=await E(h.PHASE_PRODUCTION_BUILD,L);H=e?.distDir??H}catch{}const z=(H??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),W=z&&".next"!==z?z:"out";let B,G="0.0.0";try{const e=JSON.parse(y.readFileSync(w.join(L,"package.json"),"utf-8"));G="string"==typeof e.version?e.version:G,B="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const X=new s.DistService(I??P(L),{root:L,backupFolder:w.resolve(L,F.syncBackupsDir),nextBuild:{projectRoot:L,distDir:W,packageVersion:G,packageRepositoryUrl:B}}),K={ws:r.ws,config:{clientInjectionPlugin:{v7Features:R}}};new s.ClientService(K,{distService:X,miAPI:oe}),s.registerVariablesEditorRoutes(s.internalServer,{distService:X,miAPI:oe}),s.registerUserRoutes(s.internalServer,{miAPI:oe}),s.startKeepingUsers({persist:F.persistUsers,miAPI:oe,projectRoot:L,miUrl:_});const Y="function"==typeof n?.getUpgradeHandler?n.getUpgradeHandler():null;i.on("upgrade",(e,t,o)=>{r?.handleUpgrade(e,t,o)||(Y?Y(e,t,o):t.destroy())}),p.info(s.colors.blue(`š§ ${ne.length} pp-dev middlewares initialized`)),p.info(s.colors.blue(`š§ ${ie.length} essential middlewares for internal routes`)),p.info(s.colors.blue(`š§ MiAPI initialized for backend: ${_}`)),p.info(s.colors.blue(`š§ Custom App ID: ${Z}`))}i.listen(Q,ee,()=>{p.info(s.colors.green(`ā
pp-dev Next.js server running at http://${ee}:${Q}`)),p.info(s.colors.blue(`š± Next.js app accessible at http://${ee}:${Q}${J}`)),!1!==z&&p.info(s.colors.cyan(`š Request Inspector: http://${ee}:${Q}${s.INSPECTOR_PATH}`)),p.info(s.colors.blue("š§ Base path handling active")),l||(l=A(L,f,p.info),p.info(s.colors.blue("š§ Config file watcher started"))),i.on("connection",e=>{te.add(e),e.on("close",()=>te.delete(e))});const e=async e=>{p.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));const t=setTimeout(()=>{p.info(s.colors.yellow("ā° Shutdown timeout reached, forcing exit")),process.exit(0)},5e3);try{l&&(C(l),l=null);for(const e of Array.from(te))e.destroy();te.clear(),r&&(await r.close(),r=null),await new Promise(e=>{i.close(()=>{p.info(s.colors.yellow("š HTTP server closed")),e()})}),n&&"function"==typeof n.close&&(await n.close(),p.info(s.colors.yellow("š Next.js app closed"))),clearTimeout(t),p.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),p.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};let t=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(t=e,p.info(s.colors.green("ā
Using global process object for event handlers")))}if("function"==typeof t.on)try{t.on("SIGINT",()=>e("SIGINT")),t.on("SIGTERM",()=>e("SIGTERM")),t.on("uncaughtException",t=>{p.error(s.colors.red(`ā Uncaught Exception: ${t}`)),e("uncaughtException")}),t.on("unhandledRejection",(t,o)=>{p.error(s.colors.red(`ā Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")}),p.info(s.colors.green("ā
Process event handlers registered successfully"))}catch(e){p.warn(s.colors.yellow(`ā ļø Failed to register process event handlers: ${e}`))}else p.warn(s.colors.yellow("ā ļø process.on is not available, graceful shutdown handlers will not be registered")),p.info(s.colors.blue("š” This might be due to bundling or environment constraints"))}),d=!1}catch(e){d=!1,p.error(s.colors.red(`ā Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(p.error(s.colors.red("ā Next.js Peer Dependency Error:")),p.error(s.colors.red(e.message)),p.error(s.colors.yellow("\nš” To fix this issue:")),p.error(s.colors.blue(" 1. Install Next.js in your project:")),p.error(s.colors.white(" npm install next@^16")),p.error(s.colors.blue(" 2. Or use yarn:")),p.error(s.colors.white(" yarn add next@^16")),p.error(s.colors.blue(" 3. Or use pnpm:")),p.error(s.colors.white(" pnpm add next@^16")),p.error(s.colors.yellow("\nš For more information, see:")),p.error(s.colors.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}var u}},u=async e=>{p.info(s.colors.yellow(`\nš Received ${e}, shutting down gracefully...`));try{l&&(C(l),l=null),r&&(await r.close(),r=null),i&&await new Promise(e=>{i.close(()=>{i=null,e()})}),n&&"function"==typeof n.close&&(await n.close(),n=null),p.info(s.colors.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){p.error(s.colors.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>u("SIGINT")),process.on("SIGTERM",()=>u("SIGTERM")),process.on("uncaughtException",e=>{p.error(s.colors.red(`ā Uncaught Exception: ${e}`)),u("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{p.error(s.colors.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),u("unhandledRejection")}),await f()}),j.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,t)=>{V(t);const o=H(t),n=a.resolveBuildCliOverrides(t);try{const i=t.mode||"production",r=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(i,r);const s=await l.loadConfigFromFile({mode:i,command:"build"},t.config,e,t.logLevel);let c=await a.getViteConfig(n,{mode:i,root:r});if(s){const{plugins:e,...t}=s.config;c=l.mergeConfig(c,t)}const d=l.mergeConfig(c,{root:e,base:t.base,mode:t.mode,configFile:t.config,logLevel:t.logLevel,clearScreen:t.clearScreen,optimizeDeps:{force:t.force},build:o},!0);if(await l.build(d),o.changelog){const n=e||process.cwd(),i=d.build?.outDir||"dist";let r="dist-zip";d.ppDevConfig&&(!1===d.ppDevConfig.distZip?r=i:"object"==typeof d.ppDevConfig.distZip&&"string"==typeof d.ppDevConfig.distZip.outDir&&(r=d.ppDevConfig.distZip.outDir)),await R({changelog:o.changelog,executionRoot:n,newAssetsPath:w.resolve(n,i),backupsDirPath:w.resolve(n,d.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:w.resolve(n,r),logLevel:t.logLevel})}}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t)=>{V(t);const o=s.createLogger(t.logLevel),n=e?w.resolve(process.cwd(),e):process.cwd(),i=a.resolveBuildCliOverrides(t);process.env[s.PP_DEV_NEXT_BUILD_ENV_VAR]="1";try{a.loadPPDevEnv(t.mode||"production",n);const{constants:e}=await a.safeNextImport(),r=await(import("next/dist/server/config.js")),l=r.default.default||r["module.exports"].default||r.default,c=await l(e.PHASE_PRODUCTION_BUILD,n);let d,p=c?.ppDev||{};if(0===Object.keys(p).length){const{getConfig:e}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config);p=await e(n)}try{const{getPkg:e}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config);d=e(n).name}catch{d=w.basename(n)}const f=s.normalizePPDevConfig(p,d),u=a.applyDistZipOverride(f.distZip,i,s.createDefaultZipFileName(d)),g=a.applyVersionManifestOverride(f.versionPlugin,i),h=s.removeStaleDevTypes(n,c);h&&o.info(s.colors.dim(`[pp-dev] Removed stale dev route types: ${w.relative(n,h)}`)),o.info(s.colors.cyan("[pp-dev] Running `next build`...")),await s.runNextBuildProcess(n);const m="string"==typeof c?.distDir&&c.distDir?c.distDir:".next",v=".next"===m?"out":m,b=w.resolve(n,v);if(!y.existsSync(b)||!y.statSync(b).isDirectory())throw new Error(`Next.js build output directory not found: ${b}. "next-build" requires "output: 'export'" in next.config (static export).`);const P=JSON.parse(y.readFileSync(w.join(n,"package.json"),"utf-8"));if(!1!==g&&!1!==g.enabled&&(s.writeBuildVersionManifest({outDir:b,packageVersion:"string"==typeof P.version?P.version:"0.0.0",versionFileTemplate:g.versionFileTemplate,packageRepositoryUrl:"string"==typeof P.repository?P.repository:P.repository?.url,enabled:g.enabled}),o.info(s.colors.green(`ā
VERSION / BUILD-MANIFEST written to ${w.relative(n,b)}`))),!1!==u){const e=w.resolve(n,u.outDir),t=u.inDir?w.resolve(b,u.inDir):b,i=s.resolveOutputFilePath(e,u.outFileName,"ZIP output file name");y.mkdirSync(w.dirname(i),{recursive:!0});const r=await s.zipDirectoryToBuffer(t);y.writeFileSync(i,r),o.info(s.colors.green(`ā
Zip archive written to ${w.relative(n,i)}`))}if(t.changelog){const e=!1!==u?u.outDir:v;await R({changelog:t.changelog,executionRoot:n,newAssetsPath:b,backupsDirPath:w.resolve(n,f.syncBackupsDir),changelogDestinationPath:w.resolve(n,e),logLevel:t.logLevel})}}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t,o)=>{V(o);const{oldAssetsPath:n=e,newAssetsPath:i=t,destination:r=".",filename:a="CHANGELOG.html",logLevel:l}=o,c=process.cwd();n&&i||(s.createLogger(l).error(s.colors.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=w.resolve(c,n),p=w.resolve(c,i),f=w.resolve(c,r),u=new F({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:a});await u.generateChangelog()}),j.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,t,o)=>{V(o);const{source:n=e,destination:i=t,fontName:r="icon-font"}=o,a=process.cwd(),l=w.resolve(a,n),c=w.resolve(a,i),d=new _({sourceDir:l,outputDir:c,fontName:r}),p=s.createLogger(o.logLevel);p.info(`Generating icon font from SVG files in ${s.colors.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${s.colors.dim(c)}`)}),j.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,t)=>{V(t);try{const o=t.mode||"production",n=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(o,n);const i=await l.loadConfigFromFile({mode:o,command:"build"},t.config,e,t.logLevel);let r=await a.getViteConfig(void 0,{mode:o,root:n});if(i){const{plugins:e,...t}=i.config;r=l.mergeConfig(r,t)}const s=await l.resolveConfig(l.mergeConfig(r,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode}),"serve");await l.optimizeDeps(s,t.force,!0)}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}}),j.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,t)=>{V(t);try{const o=t.mode||"production",n=w.resolve(process.cwd(),e??".");a.loadPPDevEnv(o,n);const i=await l.loadConfigFromFile({mode:o,command:"build"},t.config,e,t.logLevel);let r=await a.getViteConfig(void 0,{mode:o,root:n});if(i){const{plugins:e,...t}=i.config;r=l.mergeConfig(r,t)}(await l.preview(l.mergeConfig(r,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode,build:{outDir:t.outDir},preview:{port:t.port,strictPort:t.strictPort,host:t.host,https:t.https,open:t.open}}))).printUrls()}catch(e){s.createLogger(t.logLevel).error(s.colors.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{O(e=>s.createLogger(t.logLevel).info(e))}}),j.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,t)=>{const o=s.createLogger(t.logLevel),{isLegacyFlatConfig:n,isLegacyPPWatchConfig:i,isAlreadyMigrated:r,migrateLegacyFlatConfig:a,migratePPWatchConfig:l,generateConfigFileContent:c,discoverMigrateSource:d,loadPackageJsonMigrateConfig:p}=await Promise.resolve().then(()=>require("./migrate-XcY45UiD.js")),f=t.format??"ts",u=!1!==t.backup,g=process.cwd(),h=d(g,e);h||(o.warn(s.colors.yellow("No pp-dev or pp-watch config file found in the current directory.")),o.info(s.colors.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:m,isWatchConfig:v,isPackageJsonConfig:b}=h;o.info(s.colors.blue(`Found config: ${w.relative(g,m)}`));const{getPkg:P}=await Promise.resolve().then(()=>require("./index-BPWVgnnE.js")).then(e=>e.config),x=P();let S,E={};try{if(/\.[cm]?ts$/i.test(m)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:g,entryPoints:[m],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`;y.writeFileSync(n,o);try{const e=await(import(t(w.resolve(g,n)).toString()));E=e.default?.default??e.default??e}finally{y.existsSync(n)&&y.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(m)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(w.resolve(g,m)).toString()));E=t.default?.default??t.default??t}else b?E=p(m):m.endsWith(".json")&&(E=JSON.parse(y.readFileSync(m,"utf-8")))}catch(e){o.error(s.colors.red(`Failed to load config file: ${e.message}`)),process.exit(1)}E&&"object"==typeof E||(o.error(s.colors.red("Config file did not export a valid object.")),process.exit(1)),r(E)?(o.info(s.colors.green("Config is already in 1.0 format ā nothing to migrate.")),process.exit(0)):v||i(E)?(o.info(s.colors.blue("Detected pp-watch config format ā migrating to 1.0")),S=l(E)):n(E)?(o.info(s.colors.blue("Detected 0.x flat config format ā migrating to 1.0")),S=a(E,x.name)):(o.warn(s.colors.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=c(S,f),L=t.output??w.join(g,`pp-dev.config.${f}`);if(t.dryRun&&(o.info(s.colors.green(`\n--- Migrated config (dry-run) ā ${w.relative(g,L)} ---\n`)),process.exit(0)),u&&!b&&y.existsSync(m)){const e=`${m}.bak`;y.copyFileSync(m,e),o.info(s.colors.blue(`Backed up original to: ${w.relative(g,e)}`))}y.writeFileSync(L,T,"utf-8"),o.info(s.colors.green(`ā
Migration complete ā ${w.relative(g,L)}`)),b?o.info(s.colors.yellow('You can now remove the "pp-dev" field from package.json.')):m!==L&&y.existsSync(m)&&o.info(s.colors.yellow(`You can now delete the old config: ${w.relative(g,m)}`))}),j.help(),j.version(s.VERSION),j.parse(),exports.stopProfiler=O;
|
|
2
2
|
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const e=require("child_process"),t=require("./plugin-ydXTL_i4.js"),n=require("vite"),i=require("fs"),r=require("path"),s=require("url");require("./helpers.js");const o=require("ejs");var a="undefined"!=typeof document?document.currentScript:null;const c=e=>e&&"object"==typeof e&&"default"in e?e.default:e;function l(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const n in e)t[n]=e[n];return t.default=e,Object.freeze(t)}const p=l(i),u=l(r),d=c(r),f=c(o),m=u.dirname(t.PP_DEV_CLIENT_ENTRY),P=u.join(m,"index.html");let _=null;function v(e){return{css:u.posix.join(e,t.PACKAGE_NAME,"client/client.css"),js:u.posix.join(e,t.PACKAGE_NAME,"client/client.js")}}function h(e){return function(){if(_)return _;const e=p.readFileSync(P,{encoding:"utf8"});return _=f.compile(e,{openDelimiter:"{",closeDelimiter:"}",async:!1,rmWhitespace:!0,compileDebug:!1}),_}()({PACKAGE_NAME:t.PACKAGE_NAME,VERSION:t.VERSION,backendBaseURL:e.backendBaseURL,templateLess:e.templateLess,appId:e.appId,canSync:e.canSync??!0,devPanelPosition:e.devPanelPosition??"bottom-right",devPanelHidden:e.devPanelHidden??!1,devPanelAutoHide:e.devPanelAutoHide??!1})}const E={".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".map":"application/json; charset=utf-8"};let g;try{g="undefined"!=typeof __filename&&__filename?u.resolve(u.dirname(__filename),".."):void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BPWVgnnE.js",document.baseURI).href}&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BPWVgnnE.js",document.baseURI).href,1)&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BPWVgnnE.js",document.baseURI).href)?u.resolve(s.fileURLToPath(new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BPWVgnnE.js",document.baseURI).href)),".."):process.cwd()}catch{g=process.cwd()}const y=n.normalizePath(u.join(t.PP_DEV_PACKAGE_DIR,"dist/client")),T=new RegExp(`^\\/?${t.PACKAGE_NAME}\\/client\\/(.*)$`);let R=null,j=null;function I(e){return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${t.PACKAGE_NAME}/client`),e),resolveId(e){const t=e.match(T);if(t){const e=n.normalizePath(u.join(y,t[1]));return e.startsWith(`${y}/`)?{id:e}:null}},transformIndexHtml:async(e,n)=>{const i=n.server?.config.base||"",r=function(){if(j)return j;const e=u.resolve(g,"client","index.html");return R||(R=p.readFileSync(e,{encoding:"utf8"})),j=f.compile(R,{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:e,rmWhitespace:!0,compileDebug:!1}),j}(),s=v(i),o={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:s.css}}]},{backendBaseURL:a,templateLess:c=!1,appId:l,canSync:d=!0,devPanelPosition:m="bottom-right",devPanelHidden:P=!1,devPanelAutoHide:_=!1}=n.server?.config.clientInjectionPlugin||{},h={PACKAGE_NAME:t.PACKAGE_NAME,VERSION:t.VERSION,backendBaseURL:a,templateLess:c,appId:l,canSync:d,devPanelPosition:m,devPanelHidden:P,devPanelAutoHide:_};return o.tags.push({tag:"div",injectTo:"body-prepend",children:await r(h)}),o.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:s.js,type:"module"}}),o},configureServer(e){const i=n.normalizePath(u.resolve(e.config.root,u.dirname(t.PP_DEV_CLIENT_ENTRY)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(i)}}}const b=(e,t)=>` * ${t}`;function A(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,b)}\n */`}async function D(){try{const[e,t]=await Promise.all([import("next"),import("next/constants.js")]);return{next:e.default,constants:t}}catch(e){throw new Error(`Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^15\n\nThis package requires Next.js >=15 <17 as a peer dependency.\n\nError: ${e}`)}}let w=new Set;function N(e="development",t=process.cwd()){for(const e of w)delete process.env[e];const i=new Set(Object.keys(process.env).filter(e=>e.startsWith("MI_"))),r=n.loadEnv(e,t,"MI_");for(const[e,t]of Object.entries(r))process.env[e]=t;return w=new Set(Object.keys(r).filter(e=>!i.has(e))),r}const S=new Map,$=new Map;function L(e=process.cwd()){const t=Date.now(),n=d.resolve(e),r=$.get(n);if(r&&t-r.timestamp<6e4)return r.data;try{const e=JSON.parse(i.readFileSync(d.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return $.set(n,{data:e,timestamp:t}),e}catch{const e={};return $.set(n,{data:e,timestamp:t}),e}}let x=null;const C="__pp_dev_injected_dirname",F="__pp_dev_injected_filename",O="__pp_dev_injected_import_meta_url",U={__dirname:C,__filename:F,"import.meta.url":O,"import.meta.dirname":C,"import.meta.filename":F},M={name:"pp-dev:config-module-location",setup(e){e.onLoad({filter:/\.([cm]?[jt]s|[jt]sx)$/},e=>{const t=i.readFileSync(e.path,"utf-8").replace(/^#![^\r\n]*/,"");return{contents:`const ${C} = ${JSON.stringify(d.dirname(e.path))};const ${F} = ${JSON.stringify(e.path)};const ${O} = ${JSON.stringify(s.pathToFileURL(e.path).href)};`+t,loader:e.path.endsWith(".tsx")?"tsx":e.path.endsWith(".jsx")?"jsx":/ts$/.test(e.path)?"ts":"js"}})}};async function V(e,t){const n=`bundled:${e}`,r=S.get(n);if(r&&Date.now()-r.timestamp<3e4)return r.data;let o=!1;if(/\.m[jt]s$/.test(e))o=!0;else if(/\.c[jt]s$/.test(e))o=!1;else{const e=L(t);o=!!e&&"module"===e.type}const a=await async function(){return x||(x=await(import("esbuild"))),x}(),c=await a.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:o?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0,plugins:[M],define:U,...o?{banner:{js:"import { createRequire as __ppDevCreateRequire } from 'node:module';const require = __ppDevCreateRequire(import.meta.url);"}}:{}}),{text:l}=c.outputFiles[0],p=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.${o?"mjs":"cjs"}`,u=d.resolve(t,p),f=s.pathToFileURL(u).toString();i.writeFileSync(u,l);let m={};try{const t=(await(import(f))).default;m=t?.default||t,S.set(n,{data:m,timestamp:Date.now(),filePath:e})}finally{try{i.unlinkSync(u)}catch{}}return m}async function H(e){const t=`json:${e}`,n=S.get(t);if(n&&Date.now()-n.timestamp<3e4)return n.data;const r=JSON.parse(i.readFileSync(e,{encoding:"utf-8"}));return S.set(t,{data:r,timestamp:Date.now(),filePath:e}),r}const Z=new Map;function G(e=process.cwd()){return L(e)}async function k(e=process.cwd()){const n=d.resolve(e),r=function(e){const t=Date.now(),n=Z.get(e);if(n&&t-n.timestamp<1e4)return n.files;const r=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,s=i.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isFile()&&r.test(e.name)).map(e=>e.name);return Z.set(e,{files:s,timestamp:t}),s}(n);let s={},o=!1;const a=await async function(e,t,n){for(const i of t)if(e.includes(i)){const e=d.resolve(n,i);if(/\.[cm]?[jt]s$/i.test(i))return await V(e,n);if(i.endsWith(".json"))return await H(e)}return null}(r,t.PP_DEV_CONFIG_NAMES,n);a&&(s=a,o=!0);const c=L(n)["pp-dev"];return o||!c||"object"!=typeof c||Array.isArray(c)||(s=c),s}const q=Object.freeze({__proto__:null,clearConfigCache:function(){S.clear(),$.clear(),Z.clear()},getConfig:k,getPkg:G});function B(e){if(void 0!==e)return"1"===e||"true"===e.toLowerCase()||"0"!==e&&"false"!==e.toLowerCase()&&void 0}function z(e,n,i){if(!1===n.distZipEnabled)return!1;if(!0!==n.distZipEnabled&&void 0===n.distZipDir&&void 0===n.distZipFilename)return!1!==e&&{...e,outFileName:t.normalizeRelativeOutputPath(e.outFileName,"ZIP output file name")};const r=!1===e?{outFileName:i,outDir:"dist-zip"}:e,s=n.distZipFilename??r.outFileName;return{...r,...void 0!==n.distZipDir?{outDir:n.distZipDir}:{},outFileName:t.normalizeRelativeOutputPath(s,"ZIP output file name")}}function K(e,n){if(!1===n.versionManifestEnabled)return!1;if(!0!==n.versionManifestEnabled&&void 0===n.versionFileTemplate)return!1!==e&&void 0!==e.versionFileTemplate?{...e,versionFileTemplate:t.normalizeRelativeOutputPath(e.versionFileTemplate,"VERSION file name template")}:e;const i=!1===e?{enabled:!0}:e,r=n.versionFileTemplate??i.versionFileTemplate,s=void 0!==r?t.normalizeRelativeOutputPath(r,"VERSION file name template"):void 0;return{...i,enabled:!0,...void 0!==s?{versionFileTemplate:s}:{}}}const X=new Set(["mi","app","proxy","build","sync","inspector","devPanel"]);function W(t){if("string"==typeof t)return t;if(t&&"object"==typeof t&&"url"in t&&"string"==typeof t.url)return t.url;const n=["CI_REPOSITORY_URL","GIT_URL","BUILD_REPOSITORY_URI","CI_PROJECT_URL","BITBUCKET_GIT_HTTP_ORIGIN","BUILDKITE_REPO"];for(const e of n){const t=process.env[e];if("string"==typeof t&&t.trim())return t}const i=process.env.GITHUB_REPOSITORY;if("string"==typeof i&&i.trim()){return`${(process.env.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,"")}/${i.replace(/^\/+/,"")}`}const r=process.env.CI_PROJECT_PATH;if("string"==typeof r&&r.trim()){return`${(process.env.CI_SERVER_URL||"https://gitlab.com").replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`}const s=process.env.BITBUCKET_REPO_FULL_NAME;if("string"==typeof s&&s.trim())return`https://bitbucket.org/${s.replace(/^\/+/,"")}`;const o=process.env.TRAVIS_REPO_SLUG;if("string"==typeof o&&o.trim())return`https://github.com/${o.replace(/^\/+/,"")}`;try{const t=e.execSync("git config --get remote.origin.url",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}}function J(e){return e?.ppDev||{}}exports.applyDistZipOverride=z,exports.applyVersionManifestOverride=K,exports.config=q,exports.createDevPanelAssetMiddleware=function(e){const n=u.posix.join(e,t.PACKAGE_NAME,"client")+"/",i=new Set(["client.js","client.css","client.js.map","client.css.map"]);return(e,t,r)=>{const s=(e.url??"").split("?")[0];if(!s.startsWith(n))return void r();const o=s.slice(n.length);if(!i.has(o))return void r();const a=u.join(m,o);p.readFile(a,(e,n)=>{e?r():(t.statusCode=200,t.setHeader("Content-Type",E[u.extname(o)]??"application/octet-stream"),t.setHeader("Cache-Control","no-cache"),t.end(n))})}},exports.getNextVersion=async function(){try{return(await(import("next/package.json"))).version}catch{return null}},exports.getPPDevConfigFromNextConfig=J,exports.getViteConfig=async function(e,n={}){const i=n.root??process.cwd();N(n.mode,i);const r=G(i),s=r.name,o=await k(i);t.validatePPDevConfig(o,s);const a=t.normalizePPDevConfig(o,s);e&&(a.distZip=z(a.distZip,e,t.createDefaultZipFileName(s)),a.versionPlugin=K(a.versionPlugin,e));const{default:c}=await Promise.resolve().then(()=>require("./plugin.js")),l=[c(a),I()],{outDir:p,distZip:u,versionPlugin:d,imageOptimizer:f,templateLess:m,integrateMiTopBar:P}=a;if(P&&l.push(function(e){return{name:"mi-topbar-plugin",transformIndexHtml(){const t=[];return(!0===e||"object"==typeof e&&!0===e.addRootElement)&&t.push({tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}),(!0===e||"object"==typeof e&&!0===e.addSharedComponentsScripts)&&t.push({tag:"script",injectTo:"head-prepend",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"head-prepend",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head-prepend",attrs:{href:"/css/main.css",rel:"stylesheet"}}),t}}}(P)),f){const{ViteImageOptimizer:e}=await(import("vite-plugin-image-optimizer"));l.push(e("object"==typeof f?f:void 0))}if(d){const{versionPlugin:e}=await Promise.resolve().then(()=>require("./version-plugin-new7ayDW.js"));l.push(e({outDir:p,packageVersion:r.version??"0.0.0",packageRepositoryUrl:W(r.repository),..."object"==typeof d?d:{}}))}if(u){const{default:e}=await(import("vite-plugin-zip-pack"));l.push({...e("object"==typeof u?u:{outFileName:t.createDefaultZipFileName(s)}),enforce:"post"})}return{base:m?`${t.PATH_PAGE_PREFIX}/${s}`:`${t.PATH_TEMPLATE_PREFIX}/${s}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:A}},outDir:p},css:{modules:{localsConvention:"dashes"}},ppDevConfig:a,plugins:l}},exports.injectDevPanel=function(e,t,n){if(!/<\/?(html|body|head)\b/i.test(e))return e;const{css:i,js:r}=v(t),s=`<link rel="stylesheet" href="${i}">`,o=`${h(n)}${`<script type="module" src="${r}"><\/script>`}`;let a=e,c=!1;if(/<\/head>/i.test(a)&&(a=a.replace(/<\/head>/i,`${s}</head>`),c=!0),/<body[^>]*>/i.test(a)){const e=c?"":s;a=a.replace(/(<body[^>]*>)/i,`$1${e}${o}`)}else a=`${c?"":s}${a}${o}`;return a},exports.isNextAvailable=async function(){try{return await(import("next")),!0}catch{return!1}},exports.loadPPDevEnv=N,exports.resolveBuildCliOverrides=function(e){return{distZipEnabled:e.distZip??B(process.env.PP_DEV_DIST_ZIP),distZipDir:e.distZipDir??process.env.PP_DEV_DIST_ZIP_DIR,distZipFilename:e.distZipFilename??process.env.PP_DEV_DIST_ZIP_FILENAME,versionManifestEnabled:e.versionManifest??B(process.env.PP_DEV_VERSION_MANIFEST),versionFileTemplate:e.versionFileTemplate??process.env.PP_DEV_VERSION_FILE_TEMPLATE}},exports.safeNextImport=D,exports.withPPDev=function(e,n){return async(i,r={})=>{try{const{constants:s}=await D(),{PHASE_DEVELOPMENT_SERVER:o,PHASE_PRODUCTION_BUILD:a}=s;i!==a||process.env[t.PP_DEV_NEXT_BUILD_ENV_VAR]||t.createLogger().warn(t.colors.yellow('ā Building with plain `next build`. Use `pp-dev next-build` instead to get VERSION/BUILD-MANIFEST/zip build output in the same format as `pp-dev build` (see the "Next.js Build" section in the pp-dev README).'));const c=await k(),l=G().name,p="function"==typeof e?await e(i,r):e,u=function(...e){const t={},n=t;for(const t of e)if(t)for(const[e,i]of Object.entries(t))void 0!==i&&(X.has(e)&&i&&"object"==typeof i&&!Array.isArray(i)?n[e]={...n[e]??{},...i}:n[e]=i);return t}(c,J(p),n);t.validatePPDevConfig(u,l);const d=t.normalizePPDevConfig(u,l),{templateLess:f,v7Features:m}=d,P=i===o,_=function(e,n,i,r){return i?r?n?`${t.PATH_PAGE_PREFIX}/${e}`:`${t.PATH_TEMPLATE_LOCAL_PREFIX}/${e}`:n?`${t.PATH_PAGE_PREFIX}/${e}`:`${t.PATH_TEMPLATE_PREFIX}/${e}`:`${t.PATH_PAGE_PREFIX}/${e}`}(d.templateName,f,P,m),v={basePath:_,trailingSlash:!!P||void 0};if(!f){const e=P&&m?t.PATH_TEMPLATE_LOCAL_PREFIX:t.PATH_TEMPLATE_PREFIX;v.assetPrefix=`${e}/${d.templateName}`}const h=Object.assign({},v,p);return Object.defineProperty(h,"ppDev",{value:u,enumerable:!1,configurable:!0}),h}catch(e){throw t.createLogger().error("Error in withPPDev:",{error:e instanceof Error?e:new Error(String(e))}),e}}};
|
|
2
|
+
//# sourceMappingURL=index-BPWVgnnE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-BPWVgnnE.js","sources":["../../../src/lib/dev-panel.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/lib/env.ts","../../../src/config.ts","../../../src/lib/build-cli-overrides.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["CLIENT_DIST_DIR","path","dirname","PP_DEV_CLIENT_ENTRY","TEMPLATE_PATH","join","compiledTemplate","getDevPanelAssetPaths","base","css","posix","PACKAGE_NAME","js","renderDevPanelMarkup","data","templateContent","fs","readFileSync","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","VERSION","backendBaseURL","templateLess","appId","canSync","devPanelPosition","devPanelHidden","devPanelAutoHide","CONTENT_TYPES","DIRNAME","__filename","resolve","url","document","require","pathToFileURL","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","fileURLToPath","process","cwd","normalizePath","PP_DEV_PACKAGE_DIR","PACKAGE_REGEXP","RegExp","cachedTemplateContent","cachedTemplate","clientInjectionPlugin","opts","name","apply","config","optimizeDeps","exclude","push","resolveId","source","match","resolvedId","startsWith","id","transformIndexHtml","html","ctx","server","templatePath","cache","filename","assetPaths","result","tags","tag","injectTo","attrs","rel","templateData","children","type","configureServer","clientDir","root","allow","replacer","substring","$1","header","_chunk","replace","safeNextImport","next","constants","Promise","all","default","error","Error","previouslyLoadedKeys","Set","loadPPDevEnv","mode","envDir","key","env","fromEnvironment","Object","keys","filter","loadEnv","value","entries","has","configCache","Map","packageJsonCache","getPackageJson","projectRoot","now","Date","cached","get","timestamp","JSON","parse","flag","set","empty","esbuildModule","MODULE_LOCATION","MODULE_LOCATION_DEFINE","__dirname","moduleLocationPlugin","setup","build","onLoad","args","contents","stringify","loader","endsWith","test","loadBundledConfig","filePath","cacheKey","isESM","pkg","esbuild","getEsbuild","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","packages","format","mainFields","sourcemap","metafile","plugins","define","banner","text","code","outputFiles","fileNameTmp","Math","random","toString","slice","tempFilePath","fileUrl","writeFileSync","conf","unlinkSync","loadJSONConfig","dirContentCache","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","isFile","map","getDirectoryContent","configFound","newConfig","dirFiles","configNames","configName","includes","configPath","loadConfig","PP_DEV_CONFIG_NAMES","packageConfig","Array","isArray","clear","parseBooleanFlag","undefined","toLowerCase","applyDistZipOverride","overrides","defaultFileName","distZipEnabled","distZipDir","distZipFilename","outFileName","normalizeRelativeOutputPath","baseConfig","outDir","applyVersionManifestOverride","versionManifestEnabled","versionFileTemplate","enabled","normalizedVersionFileTemplate","PP_DEV_CONFIG_GROUPS","resolveRepositoryUrl","repository","directCiRepositoryUrlEnvVars","variableName","ciRepositoryUrl","trim","githubRepository","GITHUB_REPOSITORY","GITHUB_SERVER_URL","gitlabProjectPath","CI_PROJECT_PATH","CI_SERVER_URL","bitbucketRepositoryFullName","BITBUCKET_REPO_FULL_NAME","travisRepositorySlug","TRAVIS_REPO_SLUG","gitRemoteOriginUrl","execSync","stdio","getPPDevConfigFromNextConfig","nextConfig","ppDev","assetPrefix","allowed","req","res","pathname","split","fileName","length","readFile","err","content","statusCode","setHeader","extname","end","version","environment","templateName","ppDevConfig","validatePPDevConfig","normalizedPPDevConfig","normalizePPDevConfig","distZip","createDefaultZipFileName","versionPlugin","vitePPDev","then","imageOptimizer","integrateMiTopBar","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","versionPluginFn","packageVersion","packageRepositoryUrl","zipPack","enforce","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","port","minify","assetsInlineLimit","rollupOptions","output","modules","localsConvention","linkTag","bodyPrepend","linkInjected","head","options","PP_DEV_DIST_ZIP","PP_DEV_DIST_ZIP_DIR","PP_DEV_DIST_ZIP_FILENAME","versionManifest","PP_DEV_VERSION_MANIFEST","PP_DEV_VERSION_FILE_TEMPLATE","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","PP_DEV_NEXT_BUILD_ENV_VAR","createLogger","warn","colors","yellow","nextConfiguration","mergedConfig","configs","merged","mutableMerged","mergePPDevConfigs","normalized","v7Features","isDevelopment","basePath","PATH_TEMPLATE_LOCAL_PREFIX","createBasePath","trailingSlash","prefix","assign","defineProperty","enumerable","configurable","String"],"mappings":"ggBA4BMA,EAAkBC,EAAKC,QAAQC,uBAC/BC,EAAgBH,EAAKI,KAAKL,EAAiB,cAEjD,IAAIM,EAA4C,KAqB1C,SAAUC,EAAsBC,GACpC,MAAO,CACLC,IAAKR,EAAKS,MAAML,KAAKG,EAAMG,EAAAA,aAAc,qBACzCC,GAAIX,EAAKS,MAAML,KAAKG,EAAMG,EAAAA,aAAc,oBAE5C,CAGM,SAAUE,EAAqBC,GAGnC,OA9BF,WACE,GAAIR,EACF,OAAOA,EAGT,MAAMS,EAAkBC,EAAGC,aAAab,EAAe,CAAEc,SAAU,SAUnE,OARAZ,EAAmBa,EAAIC,QAAQL,EAAiB,CAC9CM,cAAe,IACfC,eAAgB,IAChBC,OAAO,EACPC,cA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K,GAAGuQ,EAAAA,oBAAoBtB,IAEvB,GAAGuB,EAAAA,wBAAwBvB,IAKjC,GAAGsB,EAAAA,oBAAoBtB,GAChC,CAuDuB8D,CAAeL,EAAWzD,aAAcjP,EAAc4S,EAAeD,GAEhFzG,EAAyB,CAC7B2G,WACAG,gBAAeJ,QAAuBpH,GAGxC,IAAKxL,EAAc,CACjB,MAAMiT,EAASL,GAAiBD,EAAaG,EAAAA,2BAA6BtC,EAAAA,qBAE1EtE,EAAW8B,YAAc,GAAGiF,KAAUP,EAAWzD,cACnD,CAKA,MAAM7L,EAASmC,OAAO2N,OAAO,CAAA,EAAIhH,EAAYkG,GAQ7C,OANA7M,OAAO4N,eAAe/P,EAAQ,QAAS,CACrCuC,MAAO0M,EACPe,YAAY,EACZC,cAAc,IAGTjQ,CACT,CAAE,MAAOyB,GAKP,MAJemN,EAAAA,eAERnN,MAAM,sBAAuB,CAAEA,MAAOA,aAAiBC,MAAQD,EAAQ,IAAIC,MAAMwO,OAAOzO,MAEzFA,CACR,EAEJ"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";require("child_process");const e=require("./plugin-ydXTL_i4.js"),r=require("./index-
|
|
1
|
+
"use strict";require("child_process");const e=require("./plugin-ydXTL_i4.js"),r=require("./index-BPWVgnnE.js"),i=require("./helpers.js");require("http-proxy-middleware"),require("url"),require("vite"),require("picocolors"),require("node:string_decoder"),require("axios"),require("node:http"),require("node:https"),require("jsdom"),require("path"),require("fs"),require("crypto"),require("process"),require("os"),require("node:path"),require("jszip"),require("module"),require("zlib"),require("express"),require("node:crypto"),require("node:fs"),require("node:os"),require("ejs"),exports.AuthProvider=e.AuthProvider,exports.authProvider=e.authProvider,exports.normalizePPDevConfig=e.normalizePPDevConfig,exports.validatePPDevConfig=e.validatePPDevConfig,exports.getNextVersion=r.getNextVersion,exports.getPPDevConfigFromNextConfig=r.getPPDevConfigFromNextConfig,exports.getViteConfig=r.getViteConfig,exports.isNextAvailable=r.isNextAvailable,exports.safeNextImport=r.safeNextImport,exports.withPPDev=r.withPPDev,exports.defineConfig=i.defineConfig;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/package.json
CHANGED
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,e as l,P as c,b as d,n as p,d as f,r as u,f as g,w as h,g as m,z as b,V as w,I as v,v as y,h as P,i as x,j as S,R as T,k,l as E,m as L,o as $,M as I,p as F,q as D,s as j,t as _,u as A,x as N,y as C,D as R,C as M,A as O,B as z,E as U,F as H}from"./plugin-CovBU2l1.js";import{r as V,l as W,g as Z,s as G,a as B,b as q,c as J,i as K}from"./index-Dthlsvfo.js";import{loadConfigFromFile as Y,mergeConfig as X,build as Q,resolveConfig as ee,optimizeDeps as te,preview as oe}from"vite";import{parse as ne}from"url";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 ce from"svgtofont";import{WebSocketServer as de,WebSocket as pe}from"ws";import"http-proxy-middleware";import"picocolors";import"node:string_decoder";import"axios";import"node:http";import"node:https";import"jsdom";import"process";import"child_process";import"node:path";import"jszip";import"module";import"zlib";import"express";import"node:crypto";import"node:fs";import"node:os";import"./helpers.js";import"ejs";function fe(e){return null!=e&&!1!==e}let ue=null;const ge=[{key:"r",description:"restart the server",async action(e){await e.restart()}},{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 he=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class me{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 l(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)=>(he.test(e)&&(e=e.replace(he,"$1$3")),he.test(t)&&(t=t.replace(he,"$1$3")),0===e.localeCompare(t)?0:e.localeCompare(t)>0?1:-1)});return e.diffSet?.filter(e=>"equal"!==e.state||e.name1!==e.name2)||[]}async generateAssetFilesDiff(e,t){const o=new 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 be{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await ce({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}class we{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new de({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===pe.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===c&&(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)};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===pe.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 ve=s("pp-dev");function ye(t,o,n){const s=[...H,"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,restartCallback:o,logger:n}}function Pe(e){e.watcher&&e.watcher.close()}function xe(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 Se(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 me({oldAssetsPath:p,newAssetsPath:s,destinationPath:c});await f.generateChangelog()}let Te=global.__pp_dev_profile_session,ke=0;const Ee=o=>{if(Te)return new Promise((n,i)=>{Te.post("Profiler.stop",(s,{profile:r})=>{if(s)i(s);else{const i=e.resolve(`./pp-dev-profile-${ke++}.cpuprofile`);t.writeFileSync(i,JSON.stringify(r)),o(a.yellow(`CPU profile written to ${a.white(a.dim(i))}`)),Te=void 0,n()}})})},Le=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function $e(e){const t={...e};return delete t["--"],delete t.c,delete t.config,delete t.base,delete t.l,delete t.logLevel,delete t.clearScreen,delete t.d,delete t.debug,delete t.f,delete t.filter,delete t.m,delete t.mode,t}ve.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"),ve.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)=>{Le(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:f,getConfig:u}=await import("./index-Dthlsvfo.js").then(e=>e.h);f();const{createServer:g}=await(import("vite")),h=o.mode||"development",m=e.resolve(process.cwd(),t??".");W(h,m);const b=await Y({mode:h,command:"serve"},o.config,t,o.logLevel);let y=await Z(void 0,{mode:h,root:m});if(b){const{plugins:e,...t}=b.config;y=X(y,t)}if(i=await g(X(y,{root:t,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},server:$e(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${w}`)} ${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+v)}\n`)}!function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=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(ge);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 process.kill(process.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)}(i,{print:!0,customShortcuts:[...Te?[{key:"p",description:"start/stop the profiler",async action(e){if(Te)await Ee(d.info);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{Te=new e.Session,Te.connect(),Te.post("Profiler.enable",()=>{Te?.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=ye(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}),Ee(d.info),process.exit(1)}}},f=async e=>{d.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));try{s&&(Pe(s),s=null),i&&(await i.close(),i=null),Ee(d.info),d.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>f("SIGINT")),process.on("SIGTERM",()=>f("SIGTERM")),process.on("uncaughtException",e=>{d.error(a.red(`ā Uncaught Exception: ${e}`)),f("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{d.error(a.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),f("unhandledRejection")}),await p()}),ve.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port",{default:3e3}).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").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)=>{Le(i);let s=null,l=null,c=null,f=null,u=!1;const g=r(),h=async()=>{if(!u){u=!0;try{const{next:m,constants:b}=await G(),{PHASE_DEVELOPMENT_SERVER:w}=b;c&&(await c.close(),c=null),l&&(g.info(a.yellow("š Stopping existing Next.js server...")),await new Promise(e=>{l.close(()=>{l=null,e()})})),s&&"function"==typeof s.close&&(await s.close(),s=null);const{clearConfigCache:H}=await import("./index-Dthlsvfo.js").then(e=>e.h);H();const{join:V,basename:Z}=await(import("path")),{createServer:B}=await(import("http")),q=await(import("next/dist/server/config.js")),Y=q.default.default||q["module.exports"].default||q.default,X=$e(i),Q=n?V(process.cwd(),n):process.cwd();W(i.mode||"development",Q),g.info(Q);const ee=await Y(w,Q);let te=ee?.ppDev||{};if(0===Object.keys(te).length)try{const{getConfig:e}=await import("./index-Dthlsvfo.js").then(e=>e.h),t=await e(Q);Object.keys(t).length>0?(te=t,g.info(a.blue("š§ Loaded pp-dev config from standalone config file"))):g.info(a.yellow("ā ļø No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){g.info(a.yellow("ā ļø Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else g.info(a.blue("š§ Loaded pp-dev config from Next.js config"));let oe=null;try{const{getPkg:e}=await import("./index-Dthlsvfo.js").then(e=>e.h);oe=e(Q).name}catch{oe=Z(Q)}y(te,oe??"");const ie=p(te,oe??""),se=ie.backendBaseURL??"http://localhost:8080",re=ie.templateLess,ae=ie.v7Features,le=ie.disableSSLValidation,ce=ie.enableProxyCache,de=ie.proxyCacheTTL,pe=ie.personalAccessToken,fe=ie.miHudLess,ue=ie.inspectorEnabled,ge=ie.inspectorMaxMemory,he=ie.inspectorCaptureLimit,me=ie.appId??(process.env.MI_APP_ID&&parseInt(process.env.MI_APP_ID,10)||void 0)??(process.env.MI_PORTAL_PAGE_ID&&parseInt(process.env.MI_PORTAL_PAGE_ID,10)||void 0)??1,be=ee?.basePath;let ve="";be?ve=be:(ve=re?P:ae?x:S,ve+=`/${oe}`);const Se=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),Te=async e=>{delete process.env.TURBOPACK,s&&"function"==typeof s.close&&(await s.close(),s=null);const t={dev:!0,customServer:!0,hostname:X.host||"localhost",port:X.port,dir:Q,conf:{...ee,basePath:ve,assetPrefix:ve}};e.webpack?t.webpack=!0:e.turbopack&&(t.turbopack=!0),s=m(t),await s.prepare()};if(Se.webpack)await Te({webpack:!0});else if(Se.turbopack)try{await Te({turbopack:!0})}catch(e){if(!xe(e))throw e;g.warn(a.yellow("ā Turbopack is unavailable (native bindings). Falling back to Webpack.")),await Te({webpack:!0})}else try{await Te({})}catch(e){if(!xe(e))throw e;g.warn(a.yellow("ā Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await Te({webpack:!0})}if(!s)throw new Error("Next.js app failed to initialize");if(ve.endsWith("/")||(ve+="/"),"/"===ve)throw new Error('basePath cannot be equal to "/" or equal to empty string');g.info(a.green("ā
Next.js app prepared successfully")),g.info(a.blue(`š§ pp-dev plugin configured for template: ${oe}`)),g.info(a.blue(`š§ Base path configured: ${ve}`)),se&&(g.info(a.blue(`š Backend URL: ${se}`)),g.info(a.blue(`š Custom App ID: ${me}`)));const ke=s.getRequestHandler(),Ee="number"==typeof X.port?X.port:3e3,Le="string"==typeof X.host?X.host||"0.0.0.0":"localhost",Ie=new Set;l=B(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=ne(o,!0);if(De.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(je.length>0){let l=0;const c=()=>{if(l>=je.length)return void s();const o=je[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=De.length)return void s();const o=De[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(ve))i=ne(o,!0);else{if(n===ve.replace(/\/$/,"")){const e=o.replace(n,ve);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:ve}),void t.end()}await ke(e,t,i)}s()}catch(d){g.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 Fe=null,De=[],je=[];if(!1!==ue){const e=new T(ge);k(E,e,he);const t=L(e,he);De.push(t)}if(se){const n=new URL(se).host,i=$();je.unshift(i),De.unshift(i),se.startsWith("https://")&&(o.defaultMaxListeners=Math.max(o.defaultMaxListeners,20));const p={headers:{host:n,referer:se,origin:se.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},appId:me,templateLess:re,disableSSLValidation:le,v7Features:ae,personalAccessToken:pe??process.env.MI_ACCESS_TOKEN};Fe=new I(se,p);const f=F(ve,oe??void 0),u=(e,t,o)=>{f(e,t,o)};je.push(u),De.push(u);const h=J(ve);if(je.push(h),De.push(h),ce){let e=+de;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={middlewares:{use:e=>e},config:{logger:console}},o=D({devServer:t,ttl:e}),n=(e,t,n)=>{o(e,t,n)};De.push(n),g.info(a.blue(`š§ Proxy cache middleware added with TTL: ${e}ms`))}const m=new RegExp(`^((${r=ve,r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})|/)$`),w=j(m,Fe,Object.assign({base:ve},p,{miHudLess:fe})),y=(e,t,o)=>{w(e,t,o)};De.push(y);const P=ve.endsWith("/")?ve.substring(0,ve.length-1):ve,x={middlewares:{use:e=>e},config:{logger:console}},S=_({devServer:x,baseURL:se,proxyIgnore:["/@vite","/@metricinsights","/@",P,"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:le,miAPI:Fe,templateName:oe??void 0}),T=(e,t,o)=>{S(e,t,o)};De.push(T);const k=E,L=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(v)||e.url?.startsWith(A)){return void k(e,t,()=>{})}o()};je.push(L),De.push(L);const H=N(e=>{const t=e.split("?")[0];return t.startsWith(ve)&&!t.includes("/_next/")},(e,t)=>{const o=Fe.buildPage(e,fe),i=K(o,ve,{backendBaseURL:se,templateLess:re,appId:me,devPanelPosition:ie.devPanelPosition,devPanelHidden:ie.devPanelHidden,devPanelAutoHide:ie.devPanelAutoHide});return Buffer.from(C(n,t.headers.host??"",i))}),V=(e,t,o)=>{H(e,t,o)};De.push(V),c=new we;let W=ee?.distDir;try{process.env[d]="1";const e=await Y(b.PHASE_PRODUCTION_BUILD,Q);W=e?.distDir??W}catch{}const G=(W??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),B=G&&".next"!==G?G:"out";let q,X="0.0.0";try{const o=JSON.parse(t.readFileSync(e.join(Q,"package.json"),"utf-8"));X="string"==typeof o.version?o.version:X,q="string"==typeof o.repository?o.repository:o.repository?.url}catch{}const te=new R(oe??Z(Q),{root:Q,backupFolder:e.resolve(Q,ie.syncBackupsDir),nextBuild:{projectRoot:Q,distDir:B,packageVersion:X,packageRepositoryUrl:q}}),ne={ws:c.ws,config:{clientInjectionPlugin:{v7Features:ae}}};new M(ne,{distService:te,miAPI:Fe}),O(E,{distService:te,miAPI:Fe}),z(E,{miAPI:Fe}),U({persist:ie.persistUsers,miAPI:Fe,projectRoot:Q,miUrl:se});const ue="function"==typeof s?.getUpgradeHandler?s.getUpgradeHandler():null;l.on("upgrade",(e,t,o)=>{c?.handleUpgrade(e,t,o)||(ue?ue(e,t,o):t.destroy())}),g.info(a.blue(`š§ ${De.length} pp-dev middlewares initialized`)),g.info(a.blue(`š§ ${je.length} essential middlewares for internal routes`)),g.info(a.blue(`š§ MiAPI initialized for backend: ${se}`)),g.info(a.blue(`š§ Custom App ID: ${me}`))}l.listen(Ee,Le,()=>{g.info(a.green(`ā
pp-dev Next.js server running at http://${Le}:${Ee}`)),g.info(a.blue(`š± Next.js app accessible at http://${Le}:${Ee}${ve}`)),!1!==ue&&g.info(a.cyan(`š Request Inspector: http://${Le}:${Ee}${v}`)),g.info(a.blue("š§ Base path handling active")),f||(f=ye(Q,h,g.info),g.info(a.blue("š§ Config file watcher started"))),l.on("connection",e=>{Ie.add(e),e.on("close",()=>Ie.delete(e))});const e=async e=>{g.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));const t=setTimeout(()=>{g.info(a.yellow("ā° Shutdown timeout reached, forcing exit")),process.exit(0)},5e3);try{f&&(Pe(f),f=null);for(const e of Array.from(Ie))e.destroy();Ie.clear(),c&&(await c.close(),c=null),await new Promise(e=>{l.close(()=>{g.info(a.yellow("š HTTP server closed")),e()})}),s&&"function"==typeof s.close&&(await s.close(),g.info(a.yellow("š Next.js app closed"))),clearTimeout(t),g.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),g.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};let t=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(t=e,g.info(a.green("ā
Using global process object for event handlers")))}if("function"==typeof t.on)try{t.on("SIGINT",()=>e("SIGINT")),t.on("SIGTERM",()=>e("SIGTERM")),t.on("uncaughtException",t=>{g.error(a.red(`ā Uncaught Exception: ${t}`)),e("uncaughtException")}),t.on("unhandledRejection",(t,o)=>{g.error(a.red(`ā Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")}),g.info(a.green("ā
Process event handlers registered successfully"))}catch(e){g.warn(a.yellow(`ā ļø Failed to register process event handlers: ${e}`))}else g.warn(a.yellow("ā ļø process.on is not available, graceful shutdown handlers will not be registered")),g.info(a.blue("š” This might be due to bundling or environment constraints"))}),u=!1}catch(e){u=!1,g.error(a.red(`ā Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(g.error(a.red("ā Next.js Peer Dependency Error:")),g.error(a.red(e.message)),g.error(a.yellow("\nš” To fix this issue:")),g.error(a.blue(" 1. Install Next.js in your project:")),g.error(a.white(" npm install next@^16")),g.error(a.blue(" 2. Or use yarn:")),g.error(a.white(" yarn add next@^16")),g.error(a.blue(" 3. Or use pnpm:")),g.error(a.white(" pnpm add next@^16")),g.error(a.yellow("\nš For more information, see:")),g.error(a.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}var r}},m=async e=>{g.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));try{f&&(Pe(f),f=null),c&&(await c.close(),c=null),l&&await new Promise(e=>{l.close(()=>{l=null,e()})}),s&&"function"==typeof s.close&&(await s.close(),s=null),g.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){g.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>m("SIGINT")),process.on("SIGTERM",()=>m("SIGTERM")),process.on("uncaughtException",e=>{g.error(a.red(`ā Uncaught Exception: ${e}`)),m("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{g.error(a.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),m("unhandledRejection")}),await h()}),ve.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)=>{Le(o);const n=$e(o),i=V(o);try{const s=o.mode||"production",r=e.resolve(process.cwd(),t??".");W(s,r);const a=await Y({mode:s,command:"build"},o.config,t,o.logLevel);let l=await Z(i,{mode:s,root:r});if(a){const{plugins:e,...t}=a.config;l=X(l,t)}const c=X(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 Q(c),n.changelog){const i=t||process.cwd(),s=c.build?.outDir||"dist";let r="dist-zip";c.ppDevConfig&&(!1===c.ppDevConfig.distZip?r=s:"object"==typeof c.ppDevConfig.distZip&&"string"==typeof c.ppDevConfig.distZip.outDir&&(r=c.ppDevConfig.distZip.outDir)),await Se({changelog:n.changelog,executionRoot:i,newAssetsPath:e.resolve(i,s),backupsDirPath:e.resolve(i,c.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:e.resolve(i,r),logLevel:o.logLevel})}}catch(e){r(o.logLevel).error(a.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ee(e=>r(o.logLevel).info(e))}}),ve.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)=>{Le(n);const i=r(n.logLevel),s=o?e.resolve(process.cwd(),o):process.cwd(),l=V(n);process.env[d]="1";try{W(n.mode||"production",s);const{constants:o}=await G(),r=await(import("next/dist/server/config.js")),c=r.default.default||r["module.exports"].default||r.default,d=await c(o.PHASE_PRODUCTION_BUILD,s);let w,v=d?.ppDev||{};if(0===Object.keys(v).length){const{getConfig:e}=await import("./index-Dthlsvfo.js").then(e=>e.h);v=await e(s)}try{const{getPkg:e}=await import("./index-Dthlsvfo.js").then(e=>e.h);w=e(s).name}catch{w=e.basename(s)}const y=p(v,w),P=B(y.distZip,l,f(w)),x=q(y.versionPlugin,l),S=u(s,d);S&&i.info(a.dim(`[pp-dev] Removed stale dev route types: ${e.relative(s,S)}`)),i.info(a.cyan("[pp-dev] Running `next build`...")),await g(s);const T="string"==typeof d?.distDir&&d.distDir?d.distDir:".next",k=".next"===T?"out":T,E=e.resolve(s,k);if(!t.existsSync(E)||!t.statSync(E).isDirectory())throw new Error(`Next.js build output directory not found: ${E}. "next-build" requires "output: 'export'" in next.config (static export).`);const L=JSON.parse(t.readFileSync(e.join(s,"package.json"),"utf-8"));if(!1!==x&&!1!==x.enabled&&(h({outDir:E,packageVersion:"string"==typeof L.version?L.version:"0.0.0",versionFileTemplate:x.versionFileTemplate,packageRepositoryUrl:"string"==typeof L.repository?L.repository:L.repository?.url,enabled:x.enabled}),i.info(a.green(`ā
VERSION / BUILD-MANIFEST written to ${e.relative(s,E)}`))),!1!==P){const o=e.resolve(s,P.outDir),n=P.inDir?e.resolve(E,P.inDir):E,r=m(o,P.outFileName,"ZIP output file name");t.mkdirSync(e.dirname(r),{recursive:!0});const l=await b(n);t.writeFileSync(r,l),i.info(a.green(`ā
Zip archive written to ${e.relative(s,r)}`))}if(n.changelog){const t=!1!==P?P.outDir:k;await Se({changelog:n.changelog,executionRoot:s,newAssetsPath:E,backupsDirPath:e.resolve(s,y.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{Ee(e=>r(n.logLevel).info(e))}}),ve.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)=>{Le(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 me({oldAssetsPath:f,newAssetsPath:u,destinationPath:g,changelogFilename:c});await h.generateChangelog()}),ve.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)=>{Le(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 be({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)}`)}),ve.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(t,o)=>{Le(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");W(n,i);const s=await Y({mode:n,command:"build"},o.config,t,o.logLevel);let r=await Z(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=X(r,t)}const a=await ee(X(r,{root:t,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode}),"serve");await te(a,o.force,!0)}catch(e){r(o.logLevel).error(a.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}}),ve.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)=>{Le(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");W(n,i);const s=await Y({mode:n,command:"build"},o.config,t,o.logLevel);let r=await Z(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=X(r,t)}(await oe(X(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{Ee(e=>r(o.logLevel).info(e))}}),ve.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-BLpzi5Zj.js")),h=n.format??"ts",m=!1!==n.backup,b=process.cwd(),w=u(b,o);w||(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}=w;i.info(a.blue(`Found config: ${e.relative(b,v)}`));const{getPkg:x}=await import("./index-Dthlsvfo.js").then(e=>e.h),S=x();let T,k={};try{if(/\.[cm]?ts$/i.test(v)){const o=await(import("esbuild")),{pathToFileURL:n}=await(import("url")),i=(await o.build({absWorkingDir:b,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(b,s)).toString()));k=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(b,v)).toString()));k=o.default?.default??o.default??o}else P?k=g(v):v.endsWith(".json")&&(k=JSON.parse(t.readFileSync(v,"utf-8")))}catch(e){i.error(a.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(a.red("Config file did not export a valid object.")),process.exit(1)),c(k)?(i.info(a.green("Config is already in 1.0 format ā nothing to migrate.")),process.exit(0)):y||l(k)?(i.info(a.blue("Detected pp-watch config format ā migrating to 1.0")),T=p(k)):s(k)?(i.info(a.blue("Detected 0.x flat config format ā migrating to 1.0")),T=d(k,S.name)):(i.warn(a.yellow("Could not detect config format. No known keys found.")),process.exit(1));const E=f(T,h),L=n.output??e.join(b,`pp-dev.config.${h}`);if(n.dryRun&&(i.info(a.green(`\n--- Migrated config (dry-run) ā ${e.relative(b,L)} ---\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(b,o)}`))}t.writeFileSync(L,E,"utf-8"),i.info(a.green(`ā
Migration complete ā ${e.relative(b,L)}`)),P?i.info(a.yellow('You can now remove the "pp-dev" field from package.json.')):v!==L&&t.existsSync(v)&&i.info(a.yellow(`You can now delete the old config: ${e.relative(b,v)}`))}),ve.help(),ve.version(w),ve.parse();export{Ee as stopProfiler};
|
|
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,e as l,P as c,b as d,n as p,d as f,r as u,f as g,w as h,g as m,z as b,V as w,I as v,v as y,h as P,i as x,j as S,R as T,k,l as E,m as L,o as $,M as I,p as F,q as D,s as j,t as _,u as A,x as N,y as C,D as R,C as M,A as O,B as z,E as U,F as H}from"./plugin-CovBU2l1.js";import{r as V,l as W,g as Z,s as G,a as B,b as q,c as J,i as K}from"./index-D9RNUMPH.js";import{loadConfigFromFile as Y,mergeConfig as X,build as Q,resolveConfig as ee,optimizeDeps as te,preview as oe}from"vite";import{parse as ne}from"url";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 ce from"svgtofont";import{WebSocketServer as de,WebSocket as pe}from"ws";import"http-proxy-middleware";import"picocolors";import"node:string_decoder";import"axios";import"node:http";import"node:https";import"jsdom";import"process";import"child_process";import"node:path";import"jszip";import"module";import"zlib";import"express";import"node:crypto";import"node:fs";import"node:os";import"./helpers.js";import"ejs";function fe(e){return null!=e&&!1!==e}let ue=null;const ge=[{key:"r",description:"restart the server",async action(e){await e.restart()}},{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 he=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class me{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 l(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)=>(he.test(e)&&(e=e.replace(he,"$1$3")),he.test(t)&&(t=t.replace(he,"$1$3")),0===e.localeCompare(t)?0:e.localeCompare(t)>0?1:-1)});return e.diffSet?.filter(e=>"equal"!==e.state||e.name1!==e.name2)||[]}async generateAssetFilesDiff(e,t){const o=new 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 be{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await ce({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}class we{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;constructor(){this.wss=new de({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===pe.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===c&&(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)};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===pe.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 ve=s("pp-dev");function ye(t,o,n){const s=[...H,"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,restartCallback:o,logger:n}}function Pe(e){e.watcher&&e.watcher.close()}function xe(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 Se(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 me({oldAssetsPath:p,newAssetsPath:s,destinationPath:c});await f.generateChangelog()}let Te=global.__pp_dev_profile_session,ke=0;const Ee=o=>{if(Te)return new Promise((n,i)=>{Te.post("Profiler.stop",(s,{profile:r})=>{if(s)i(s);else{const i=e.resolve(`./pp-dev-profile-${ke++}.cpuprofile`);t.writeFileSync(i,JSON.stringify(r)),o(a.yellow(`CPU profile written to ${a.white(a.dim(i))}`)),Te=void 0,n()}})})},Le=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function $e(e){const t={...e};return delete t["--"],delete t.c,delete t.config,delete t.base,delete t.l,delete t.logLevel,delete t.clearScreen,delete t.d,delete t.debug,delete t.f,delete t.filter,delete t.m,delete t.mode,t}ve.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"),ve.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)=>{Le(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:f,getConfig:u}=await import("./index-D9RNUMPH.js").then(e=>e.h);f();const{createServer:g}=await(import("vite")),h=o.mode||"development",m=e.resolve(process.cwd(),t??".");W(h,m);const b=await Y({mode:h,command:"serve"},o.config,t,o.logLevel);let y=await Z(void 0,{mode:h,root:m});if(b){const{plugins:e,...t}=b.config;y=X(y,t)}if(i=await g(X(y,{root:t,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},server:$e(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${w}`)} ${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+v)}\n`)}!function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=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(ge);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 process.kill(process.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)}(i,{print:!0,customShortcuts:[...Te?[{key:"p",description:"start/stop the profiler",async action(e){if(Te)await Ee(d.info);else{const e=await import("node:inspector").then(e=>e.default);await new Promise(t=>{Te=new e.Session,Te.connect(),Te.post("Profiler.enable",()=>{Te?.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=ye(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}),Ee(d.info),process.exit(1)}}},f=async e=>{d.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));try{s&&(Pe(s),s=null),i&&(await i.close(),i=null),Ee(d.info),d.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>f("SIGINT")),process.on("SIGTERM",()=>f("SIGTERM")),process.on("uncaughtException",e=>{d.error(a.red(`ā Uncaught Exception: ${e}`)),f("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{d.error(a.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),f("unhandledRejection")}),await p()}),ve.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port",{default:3e3}).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").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)=>{Le(i);let s=null,l=null,c=null,f=null,u=!1;const g=r(),h=async()=>{if(!u){u=!0;try{const{next:m,constants:b}=await G(),{PHASE_DEVELOPMENT_SERVER:w}=b;c&&(await c.close(),c=null),l&&(g.info(a.yellow("š Stopping existing Next.js server...")),await new Promise(e=>{l.close(()=>{l=null,e()})})),s&&"function"==typeof s.close&&(await s.close(),s=null);const{clearConfigCache:H}=await import("./index-D9RNUMPH.js").then(e=>e.h);H();const{join:V,basename:Z}=await(import("path")),{createServer:B}=await(import("http")),q=await(import("next/dist/server/config.js")),Y=q.default.default||q["module.exports"].default||q.default,X=$e(i),Q=n?V(process.cwd(),n):process.cwd();W(i.mode||"development",Q),g.info(Q);const ee=await Y(w,Q);let te=ee?.ppDev||{};if(0===Object.keys(te).length)try{const{getConfig:e}=await import("./index-D9RNUMPH.js").then(e=>e.h),t=await e(Q);Object.keys(t).length>0?(te=t,g.info(a.blue("š§ Loaded pp-dev config from standalone config file"))):g.info(a.yellow("ā ļø No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){g.info(a.yellow("ā ļø Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else g.info(a.blue("š§ Loaded pp-dev config from Next.js config"));let oe=null;try{const{getPkg:e}=await import("./index-D9RNUMPH.js").then(e=>e.h);oe=e(Q).name}catch{oe=Z(Q)}y(te,oe??"");const ie=p(te,oe??""),se=ie.backendBaseURL??"http://localhost:8080",re=ie.templateLess,ae=ie.v7Features,le=ie.disableSSLValidation,ce=ie.enableProxyCache,de=ie.proxyCacheTTL,pe=ie.personalAccessToken,fe=ie.miHudLess,ue=ie.inspectorEnabled,ge=ie.inspectorMaxMemory,he=ie.inspectorCaptureLimit,me=ie.appId??(process.env.MI_APP_ID&&parseInt(process.env.MI_APP_ID,10)||void 0)??(process.env.MI_PORTAL_PAGE_ID&&parseInt(process.env.MI_PORTAL_PAGE_ID,10)||void 0)??1,be=ee?.basePath;let ve="";be?ve=be:(ve=re?P:ae?x:S,ve+=`/${oe}`);const Se=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),Te=async e=>{delete process.env.TURBOPACK,s&&"function"==typeof s.close&&(await s.close(),s=null);const t={dev:!0,customServer:!0,hostname:X.host||"localhost",port:X.port,dir:Q,conf:{...ee,basePath:ve,assetPrefix:ve}};e.webpack?t.webpack=!0:e.turbopack&&(t.turbopack=!0),s=m(t),await s.prepare()};if(Se.webpack)await Te({webpack:!0});else if(Se.turbopack)try{await Te({turbopack:!0})}catch(e){if(!xe(e))throw e;g.warn(a.yellow("ā Turbopack is unavailable (native bindings). Falling back to Webpack.")),await Te({webpack:!0})}else try{await Te({})}catch(e){if(!xe(e))throw e;g.warn(a.yellow("ā Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await Te({webpack:!0})}if(!s)throw new Error("Next.js app failed to initialize");if(ve.endsWith("/")||(ve+="/"),"/"===ve)throw new Error('basePath cannot be equal to "/" or equal to empty string');g.info(a.green("ā
Next.js app prepared successfully")),g.info(a.blue(`š§ pp-dev plugin configured for template: ${oe}`)),g.info(a.blue(`š§ Base path configured: ${ve}`)),se&&(g.info(a.blue(`š Backend URL: ${se}`)),g.info(a.blue(`š Custom App ID: ${me}`)));const ke=s.getRequestHandler(),Ee="number"==typeof X.port?X.port:3e3,Le="string"==typeof X.host?X.host||"0.0.0.0":"localhost",Ie=new Set;l=B(async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=ne(o,!0);if(De.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")){if(je.length>0){let l=0;const c=()=>{if(l>=je.length)return void s();const o=je[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=De.length)return void s();const o=De[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(ve))i=ne(o,!0);else{if(n===ve.replace(/\/$/,"")){const e=o.replace(n,ve);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:ve}),void t.end()}await ke(e,t,i)}s()}catch(d){g.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 Fe=null,De=[],je=[];if(!1!==ue){const e=new T(ge);k(E,e,he);const t=L(e,he);De.push(t)}if(se){const n=new URL(se).host,i=$();je.unshift(i),De.unshift(i),se.startsWith("https://")&&(o.defaultMaxListeners=Math.max(o.defaultMaxListeners,20));const p={headers:{host:n,referer:se,origin:se.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},appId:me,templateLess:re,disableSSLValidation:le,v7Features:ae,personalAccessToken:pe??process.env.MI_ACCESS_TOKEN};Fe=new I(se,p);const f=F(ve,oe??void 0),u=(e,t,o)=>{f(e,t,o)};je.push(u),De.push(u);const h=J(ve);if(je.push(h),De.push(h),ce){let e=+de;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={middlewares:{use:e=>e},config:{logger:console}},o=D({devServer:t,ttl:e}),n=(e,t,n)=>{o(e,t,n)};De.push(n),g.info(a.blue(`š§ Proxy cache middleware added with TTL: ${e}ms`))}const m=new RegExp(`^((${r=ve,r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")})|/)$`),w=j(m,Fe,Object.assign({base:ve},p,{miHudLess:fe})),y=(e,t,o)=>{w(e,t,o)};De.push(y);const P=ve.endsWith("/")?ve.substring(0,ve.length-1):ve,x={middlewares:{use:e=>e},config:{logger:console}},S=_({devServer:x,baseURL:se,proxyIgnore:["/@vite","/@metricinsights","/@",P,"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:le,miAPI:Fe,templateName:oe??void 0}),T=(e,t,o)=>{S(e,t,o)};De.push(T);const k=E,L=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(v)||e.url?.startsWith(A)){return void k(e,t,()=>{})}o()};je.push(L),De.push(L);const H=N(e=>{const t=e.split("?")[0];return t.startsWith(ve)&&!t.includes("/_next/")},(e,t)=>{const o=Fe.buildPage(e,fe),i=K(o,ve,{backendBaseURL:se,templateLess:re,appId:me,devPanelPosition:ie.devPanelPosition,devPanelHidden:ie.devPanelHidden,devPanelAutoHide:ie.devPanelAutoHide});return Buffer.from(C(n,t.headers.host??"",i))}),V=(e,t,o)=>{H(e,t,o)};De.push(V),c=new we;let W=ee?.distDir;try{process.env[d]="1";const e=await Y(b.PHASE_PRODUCTION_BUILD,Q);W=e?.distDir??W}catch{}const G=(W??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),B=G&&".next"!==G?G:"out";let q,X="0.0.0";try{const o=JSON.parse(t.readFileSync(e.join(Q,"package.json"),"utf-8"));X="string"==typeof o.version?o.version:X,q="string"==typeof o.repository?o.repository:o.repository?.url}catch{}const te=new R(oe??Z(Q),{root:Q,backupFolder:e.resolve(Q,ie.syncBackupsDir),nextBuild:{projectRoot:Q,distDir:B,packageVersion:X,packageRepositoryUrl:q}}),ne={ws:c.ws,config:{clientInjectionPlugin:{v7Features:ae}}};new M(ne,{distService:te,miAPI:Fe}),O(E,{distService:te,miAPI:Fe}),z(E,{miAPI:Fe}),U({persist:ie.persistUsers,miAPI:Fe,projectRoot:Q,miUrl:se});const ue="function"==typeof s?.getUpgradeHandler?s.getUpgradeHandler():null;l.on("upgrade",(e,t,o)=>{c?.handleUpgrade(e,t,o)||(ue?ue(e,t,o):t.destroy())}),g.info(a.blue(`š§ ${De.length} pp-dev middlewares initialized`)),g.info(a.blue(`š§ ${je.length} essential middlewares for internal routes`)),g.info(a.blue(`š§ MiAPI initialized for backend: ${se}`)),g.info(a.blue(`š§ Custom App ID: ${me}`))}l.listen(Ee,Le,()=>{g.info(a.green(`ā
pp-dev Next.js server running at http://${Le}:${Ee}`)),g.info(a.blue(`š± Next.js app accessible at http://${Le}:${Ee}${ve}`)),!1!==ue&&g.info(a.cyan(`š Request Inspector: http://${Le}:${Ee}${v}`)),g.info(a.blue("š§ Base path handling active")),f||(f=ye(Q,h,g.info),g.info(a.blue("š§ Config file watcher started"))),l.on("connection",e=>{Ie.add(e),e.on("close",()=>Ie.delete(e))});const e=async e=>{g.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));const t=setTimeout(()=>{g.info(a.yellow("ā° Shutdown timeout reached, forcing exit")),process.exit(0)},5e3);try{f&&(Pe(f),f=null);for(const e of Array.from(Ie))e.destroy();Ie.clear(),c&&(await c.close(),c=null),await new Promise(e=>{l.close(()=>{g.info(a.yellow("š HTTP server closed")),e()})}),s&&"function"==typeof s.close&&(await s.close(),g.info(a.yellow("š Next.js app closed"))),clearTimeout(t),g.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),g.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};let t=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(t=e,g.info(a.green("ā
Using global process object for event handlers")))}if("function"==typeof t.on)try{t.on("SIGINT",()=>e("SIGINT")),t.on("SIGTERM",()=>e("SIGTERM")),t.on("uncaughtException",t=>{g.error(a.red(`ā Uncaught Exception: ${t}`)),e("uncaughtException")}),t.on("unhandledRejection",(t,o)=>{g.error(a.red(`ā Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")}),g.info(a.green("ā
Process event handlers registered successfully"))}catch(e){g.warn(a.yellow(`ā ļø Failed to register process event handlers: ${e}`))}else g.warn(a.yellow("ā ļø process.on is not available, graceful shutdown handlers will not be registered")),g.info(a.blue("š” This might be due to bundling or environment constraints"))}),u=!1}catch(e){u=!1,g.error(a.red(`ā Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(g.error(a.red("ā Next.js Peer Dependency Error:")),g.error(a.red(e.message)),g.error(a.yellow("\nš” To fix this issue:")),g.error(a.blue(" 1. Install Next.js in your project:")),g.error(a.white(" npm install next@^16")),g.error(a.blue(" 2. Or use yarn:")),g.error(a.white(" yarn add next@^16")),g.error(a.blue(" 3. Or use pnpm:")),g.error(a.white(" pnpm add next@^16")),g.error(a.yellow("\nš For more information, see:")),g.error(a.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}var r}},m=async e=>{g.info(a.yellow(`\nš Received ${e}, shutting down gracefully...`));try{f&&(Pe(f),f=null),c&&(await c.close(),c=null),l&&await new Promise(e=>{l.close(()=>{l=null,e()})}),s&&"function"==typeof s.close&&(await s.close(),s=null),g.info(a.green("ā
Graceful shutdown completed")),process.exit(0)}catch(e){g.error(a.red(`ā Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",()=>m("SIGINT")),process.on("SIGTERM",()=>m("SIGTERM")),process.on("uncaughtException",e=>{g.error(a.red(`ā Uncaught Exception: ${e}`)),m("uncaughtException")}),process.on("unhandledRejection",(e,t)=>{g.error(a.red(`ā Unhandled Rejection at: ${t}, reason: ${e}`)),m("unhandledRejection")}),await h()}),ve.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)=>{Le(o);const n=$e(o),i=V(o);try{const s=o.mode||"production",r=e.resolve(process.cwd(),t??".");W(s,r);const a=await Y({mode:s,command:"build"},o.config,t,o.logLevel);let l=await Z(i,{mode:s,root:r});if(a){const{plugins:e,...t}=a.config;l=X(l,t)}const c=X(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 Q(c),n.changelog){const i=t||process.cwd(),s=c.build?.outDir||"dist";let r="dist-zip";c.ppDevConfig&&(!1===c.ppDevConfig.distZip?r=s:"object"==typeof c.ppDevConfig.distZip&&"string"==typeof c.ppDevConfig.distZip.outDir&&(r=c.ppDevConfig.distZip.outDir)),await Se({changelog:n.changelog,executionRoot:i,newAssetsPath:e.resolve(i,s),backupsDirPath:e.resolve(i,c.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:e.resolve(i,r),logLevel:o.logLevel})}}catch(e){r(o.logLevel).error(a.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ee(e=>r(o.logLevel).info(e))}}),ve.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)=>{Le(n);const i=r(n.logLevel),s=o?e.resolve(process.cwd(),o):process.cwd(),l=V(n);process.env[d]="1";try{W(n.mode||"production",s);const{constants:o}=await G(),r=await(import("next/dist/server/config.js")),c=r.default.default||r["module.exports"].default||r.default,d=await c(o.PHASE_PRODUCTION_BUILD,s);let w,v=d?.ppDev||{};if(0===Object.keys(v).length){const{getConfig:e}=await import("./index-D9RNUMPH.js").then(e=>e.h);v=await e(s)}try{const{getPkg:e}=await import("./index-D9RNUMPH.js").then(e=>e.h);w=e(s).name}catch{w=e.basename(s)}const y=p(v,w),P=B(y.distZip,l,f(w)),x=q(y.versionPlugin,l),S=u(s,d);S&&i.info(a.dim(`[pp-dev] Removed stale dev route types: ${e.relative(s,S)}`)),i.info(a.cyan("[pp-dev] Running `next build`...")),await g(s);const T="string"==typeof d?.distDir&&d.distDir?d.distDir:".next",k=".next"===T?"out":T,E=e.resolve(s,k);if(!t.existsSync(E)||!t.statSync(E).isDirectory())throw new Error(`Next.js build output directory not found: ${E}. "next-build" requires "output: 'export'" in next.config (static export).`);const L=JSON.parse(t.readFileSync(e.join(s,"package.json"),"utf-8"));if(!1!==x&&!1!==x.enabled&&(h({outDir:E,packageVersion:"string"==typeof L.version?L.version:"0.0.0",versionFileTemplate:x.versionFileTemplate,packageRepositoryUrl:"string"==typeof L.repository?L.repository:L.repository?.url,enabled:x.enabled}),i.info(a.green(`ā
VERSION / BUILD-MANIFEST written to ${e.relative(s,E)}`))),!1!==P){const o=e.resolve(s,P.outDir),n=P.inDir?e.resolve(E,P.inDir):E,r=m(o,P.outFileName,"ZIP output file name");t.mkdirSync(e.dirname(r),{recursive:!0});const l=await b(n);t.writeFileSync(r,l),i.info(a.green(`ā
Zip archive written to ${e.relative(s,r)}`))}if(n.changelog){const t=!1!==P?P.outDir:k;await Se({changelog:n.changelog,executionRoot:s,newAssetsPath:E,backupsDirPath:e.resolve(s,y.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{Ee(e=>r(n.logLevel).info(e))}}),ve.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)=>{Le(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 me({oldAssetsPath:f,newAssetsPath:u,destinationPath:g,changelogFilename:c});await h.generateChangelog()}),ve.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)=>{Le(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 be({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)}`)}),ve.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(t,o)=>{Le(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");W(n,i);const s=await Y({mode:n,command:"build"},o.config,t,o.logLevel);let r=await Z(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=X(r,t)}const a=await ee(X(r,{root:t,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode}),"serve");await te(a,o.force,!0)}catch(e){r(o.logLevel).error(a.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}}),ve.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)=>{Le(o);try{const n=o.mode||"production",i=e.resolve(process.cwd(),t??".");W(n,i);const s=await Y({mode:n,command:"build"},o.config,t,o.logLevel);let r=await Z(void 0,{mode:n,root:i});if(s){const{plugins:e,...t}=s.config;r=X(r,t)}(await oe(X(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{Ee(e=>r(o.logLevel).info(e))}}),ve.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-BLpzi5Zj.js")),h=n.format??"ts",m=!1!==n.backup,b=process.cwd(),w=u(b,o);w||(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}=w;i.info(a.blue(`Found config: ${e.relative(b,v)}`));const{getPkg:x}=await import("./index-D9RNUMPH.js").then(e=>e.h),S=x();let T,k={};try{if(/\.[cm]?ts$/i.test(v)){const o=await(import("esbuild")),{pathToFileURL:n}=await(import("url")),i=(await o.build({absWorkingDir:b,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(b,s)).toString()));k=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(b,v)).toString()));k=o.default?.default??o.default??o}else P?k=g(v):v.endsWith(".json")&&(k=JSON.parse(t.readFileSync(v,"utf-8")))}catch(e){i.error(a.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(a.red("Config file did not export a valid object.")),process.exit(1)),c(k)?(i.info(a.green("Config is already in 1.0 format ā nothing to migrate.")),process.exit(0)):y||l(k)?(i.info(a.blue("Detected pp-watch config format ā migrating to 1.0")),T=p(k)):s(k)?(i.info(a.blue("Detected 0.x flat config format ā migrating to 1.0")),T=d(k,S.name)):(i.warn(a.yellow("Could not detect config format. No known keys found.")),process.exit(1));const E=f(T,h),L=n.output??e.join(b,`pp-dev.config.${h}`);if(n.dryRun&&(i.info(a.green(`\n--- Migrated config (dry-run) ā ${e.relative(b,L)} ---\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(b,o)}`))}t.writeFileSync(L,E,"utf-8"),i.info(a.green(`ā
Migration complete ā ${e.relative(b,L)}`)),P?i.info(a.yellow('You can now remove the "pp-dev" field from package.json.')):v!==L&&t.existsSync(v)&&i.info(a.yellow(`You can now delete the old config: ${e.relative(b,v)}`))}),ve.help(),ve.version(w),ve.parse();export{Ee as stopProfiler};
|
|
2
2
|
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{execSync as e}from"child_process";import{G as t,H as n,V as i,J as s,F as r,K as o,v as a,n as c,d as p,h as l,j as u,b as d,c as m,a as f,i as v}from"./plugin-CovBU2l1.js";import{normalizePath as g,loadEnv as h}from"vite";import*as _ from"fs";import{readdirSync as y,readFileSync as j,writeFileSync as b,unlinkSync as P}from"fs";import*as E from"path";import $ from"path";import{fileURLToPath as w,pathToFileURL as I}from"url";import"./helpers.js";import D from"ejs";const T=E.dirname(n),R=E.join(T,"index.html");let S=null;function O(e){return{css:E.posix.join(e,t,"client/client.css"),js:E.posix.join(e,t,"client/client.js")}}function x(e){return function(){if(S)return S;const e=_.readFileSync(R,{encoding:"utf8"});return S=D.compile(e,{openDelimiter:"{",closeDelimiter:"}",async:!1,rmWhitespace:!0,compileDebug:!1}),S}()({PACKAGE_NAME:t,VERSION:i,backendBaseURL:e.backendBaseURL,templateLess:e.templateLess,appId:e.appId,canSync:e.canSync??!0,devPanelPosition:e.devPanelPosition??"bottom-right",devPanelHidden:e.devPanelHidden??!1,devPanelAutoHide:e.devPanelAutoHide??!1})}function N(e,t,n){if(!/<\/?(html|body|head)\b/i.test(e))return e;const{css:i,js:s}=O(t),r=`<link rel="stylesheet" href="${i}">`,o=`${x(n)}${`<script type="module" src="${s}"><\/script>`}`;let a=e,c=!1;if(/<\/head>/i.test(a)&&(a=a.replace(/<\/head>/i,`${r}</head>`),c=!0),/<body[^>]*>/i.test(a)){const e=c?"":r;a=a.replace(/(<body[^>]*>)/i,`$1${e}${o}`)}else a=`${c?"":r}${a}${o}`;return a}const F={".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".map":"application/json; charset=utf-8"};function L(e){const n=E.posix.join(e,t,"client")+"/",i=new Set(["client.js","client.css","client.js.map","client.css.map"]);return(e,t,s)=>{const r=(e.url??"").split("?")[0];if(!r.startsWith(n))return void s();const o=r.slice(n.length);if(!i.has(o))return void s();const a=E.join(T,o);_.readFile(a,(e,n)=>{e?s():(t.statusCode=200,t.setHeader("Content-Type",F[E.extname(o)]??"application/octet-stream"),t.setHeader("Cache-Control","no-cache"),t.end(n))})}}let C;try{C="undefined"!=typeof __filename&&__filename?E.resolve(E.dirname(__filename),".."):void 0!==import.meta&&import.meta&&import.meta.url?E.resolve(w(new URL(".",import.meta.url)),".."):process.cwd()}catch{C=process.cwd()}const A=g(E.join(s,"dist/client")),U=new RegExp(`^\\/?${t}\\/client\\/(.*)$`);let Z=null,H=null;function M(e){return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${t}/client`),e),resolveId(e){const t=e.match(U);if(t){const e=g(E.join(A,t[1]));return e.startsWith(`${A}/`)?{id:e}:null}},transformIndexHtml:async(e,n)=>{const s=n.server?.config.base||"",r=function(){if(H)return H;const e=E.resolve(C,"client","index.html");return Z||(Z=_.readFileSync(e,{encoding:"utf8"})),H=D.compile(Z,{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:e,rmWhitespace:!0,compileDebug:!1}),H}(),o=O(s),a={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:o.css}}]},{backendBaseURL:c,templateLess:p=!1,appId:l,canSync:u=!0,devPanelPosition:d="bottom-right",devPanelHidden:m=!1,devPanelAutoHide:f=!1}=n.server?.config.clientInjectionPlugin||{},v={PACKAGE_NAME:t,VERSION:i,backendBaseURL:c,templateLess:p,appId:l,canSync:u,devPanelPosition:d,devPanelHidden:m,devPanelAutoHide:f};return a.tags.push({tag:"div",injectTo:"body-prepend",children:await r(v)}),a.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:o.js,type:"module"}}),a},configureServer(e){const t=g(E.resolve(e.config.root,E.dirname(n)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t)}}}const V=(e,t)=>` * ${t}`;function k(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,V)}\n */`}async function B(){try{const[e,t]=await Promise.all([import("next"),import("next/constants.js")]);return{next:e.default,constants:t}}catch(e){throw new Error(`Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^15\n\nThis package requires Next.js >=15 <17 as a peer dependency.\n\nError: ${e}`)}}async function G(){try{return await(import("next")),!0}catch{return!1}}async function W(){try{return(await(import("next/package.json"))).version}catch{return null}}let z=new Set;function J(e="development",t=process.cwd()){for(const e of z)delete process.env[e];const n=new Set(Object.keys(process.env).filter(e=>e.startsWith("MI_"))),i=h(e,t,"MI_");for(const[e,t]of Object.entries(i))process.env[e]=t;return z=new Set(Object.keys(i).filter(e=>!n.has(e))),i}const q=new Map,K=new Map;function Y(e=process.cwd()){const t=Date.now(),n=$.resolve(e),i=K.get(n);if(i&&t-i.timestamp<6e4)return i.data;try{const e=JSON.parse(j($.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return K.set(n,{data:e,timestamp:t}),e}catch{const e={};return K.set(n,{data:e,timestamp:t}),e}}let Q=null;const X="__pp_dev_injected_dirname",ee="__pp_dev_injected_filename",te="__pp_dev_injected_import_meta_url",ne={__dirname:X,__filename:ee,"import.meta.url":te,"import.meta.dirname":X,"import.meta.filename":ee},ie={name:"pp-dev:config-module-location",setup(e){e.onLoad({filter:/\.([cm]?[jt]s|[jt]sx)$/},e=>{const t=j(e.path,"utf-8").replace(/^#![^\r\n]*/,"");return{contents:`const ${X} = ${JSON.stringify($.dirname(e.path))};const ${ee} = ${JSON.stringify(e.path)};const ${te} = ${JSON.stringify(I(e.path).href)};`+t,loader:e.path.endsWith(".tsx")?"tsx":e.path.endsWith(".jsx")?"jsx":/ts$/.test(e.path)?"ts":"js"}})}};async function se(e,t){const n=`bundled:${e}`,i=q.get(n);if(i&&Date.now()-i.timestamp<3e4)return i.data;let s=!1;if(/\.m[jt]s$/.test(e))s=!0;else if(/\.c[jt]s$/.test(e))s=!1;else{const e=Y(t);s=!!e&&"module"===e.type}const r=await async function(){return Q||(Q=await(import("esbuild"))),Q}(),o=await r.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:s?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0,plugins:[ie],define:ne,...s?{banner:{js:"import { createRequire as __ppDevCreateRequire } from 'node:module';const require = __ppDevCreateRequire(import.meta.url);"}}:{}}),{text:a}=o.outputFiles[0],c=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.${s?"mjs":"cjs"}`,p=$.resolve(t,c),l=I(p).toString();b(p,a);let u={};try{const t=(await(import(l))).default;u=t?.default||t,q.set(n,{data:u,timestamp:Date.now(),filePath:e})}finally{try{P(p)}catch{}}return u}async function re(e){const t=`json:${e}`,n=q.get(t);if(n&&Date.now()-n.timestamp<3e4)return n.data;const i=JSON.parse(j(e,{encoding:"utf-8"}));return q.set(t,{data:i,timestamp:Date.now(),filePath:e}),i}const oe=new Map;function ae(e=process.cwd()){return Y(e)}async function ce(e=process.cwd()){const t=$.resolve(e),n=function(e){const t=Date.now(),n=oe.get(e);if(n&&t-n.timestamp<1e4)return n.files;const i=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,s=y(e,{withFileTypes:!0}).filter(e=>e.isFile()&&i.test(e.name)).map(e=>e.name);return oe.set(e,{files:s,timestamp:t}),s}(t);let i={},s=!1;const o=await async function(e,t,n){for(const i of t)if(e.includes(i)){const e=$.resolve(n,i);if(/\.[cm]?[jt]s$/i.test(i))return await se(e,n);if(i.endsWith(".json"))return await re(e)}return null}(n,r,t);o&&(i=o,s=!0);const a=Y(t)["pp-dev"];return s||!a||"object"!=typeof a||Array.isArray(a)||(i=a),i}const pe=Object.freeze({__proto__:null,clearConfigCache:function(){q.clear(),K.clear(),oe.clear()},getConfig:ce,getPkg:ae});function le(e){if(void 0!==e)return"1"===e||"true"===e.toLowerCase()||"0"!==e&&"false"!==e.toLowerCase()&&void 0}function ue(e){return{distZipEnabled:e.distZip??le(process.env.PP_DEV_DIST_ZIP),distZipDir:e.distZipDir??process.env.PP_DEV_DIST_ZIP_DIR,distZipFilename:e.distZipFilename??process.env.PP_DEV_DIST_ZIP_FILENAME,versionManifestEnabled:e.versionManifest??le(process.env.PP_DEV_VERSION_MANIFEST),versionFileTemplate:e.versionFileTemplate??process.env.PP_DEV_VERSION_FILE_TEMPLATE}}function de(e,t,n){if(!1===t.distZipEnabled)return!1;if(!0!==t.distZipEnabled&&void 0===t.distZipDir&&void 0===t.distZipFilename)return!1!==e&&{...e,outFileName:o(e.outFileName,"ZIP output file name")};const i=!1===e?{outFileName:n,outDir:"dist-zip"}:e,s=t.distZipFilename??i.outFileName;return{...i,...void 0!==t.distZipDir?{outDir:t.distZipDir}:{},outFileName:o(s,"ZIP output file name")}}function me(e,t){if(!1===t.versionManifestEnabled)return!1;if(!0!==t.versionManifestEnabled&&void 0===t.versionFileTemplate)return!1!==e&&void 0!==e.versionFileTemplate?{...e,versionFileTemplate:o(e.versionFileTemplate,"VERSION file name template")}:e;const n=!1===e?{enabled:!0}:e,i=t.versionFileTemplate??n.versionFileTemplate,s=void 0!==i?o(i,"VERSION file name template"):void 0;return{...n,enabled:!0,...void 0!==s?{versionFileTemplate:s}:{}}}const fe=new Set(["mi","app","proxy","build","sync","inspector","devPanel"]);function ve(t){if("string"==typeof t)return t;if(t&&"object"==typeof t&&"url"in t&&"string"==typeof t.url)return t.url;const n=["CI_REPOSITORY_URL","GIT_URL","BUILD_REPOSITORY_URI","CI_PROJECT_URL","BITBUCKET_GIT_HTTP_ORIGIN","BUILDKITE_REPO"];for(const e of n){const t=process.env[e];if("string"==typeof t&&t.trim())return t}const i=process.env.GITHUB_REPOSITORY;if("string"==typeof i&&i.trim()){return`${(process.env.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,"")}/${i.replace(/^\/+/,"")}`}const s=process.env.CI_PROJECT_PATH;if("string"==typeof s&&s.trim()){return`${(process.env.CI_SERVER_URL||"https://gitlab.com").replace(/\/+$/,"")}/${s.replace(/^\/+/,"")}`}const r=process.env.BITBUCKET_REPO_FULL_NAME;if("string"==typeof r&&r.trim())return`https://bitbucket.org/${r.replace(/^\/+/,"")}`;const o=process.env.TRAVIS_REPO_SLUG;if("string"==typeof o&&o.trim())return`https://github.com/${o.replace(/^\/+/,"")}`;try{const t=e("git config --get remote.origin.url",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}}async function ge(e,t={}){const n=t.root??process.cwd();J(t.mode,n);const i=ae(n),s=i.name,r=await ce(n);a(r,s);const o=c(r,s);e&&(o.distZip=de(o.distZip,e,p(s)),o.versionPlugin=me(o.versionPlugin,e));const{default:d}=await(import("./plugin.js")),m=[d(o),M()],{outDir:f,distZip:v,versionPlugin:g,imageOptimizer:h,templateLess:_,integrateMiTopBar:y}=o;if(y&&m.push(function(e){return{name:"mi-topbar-plugin",transformIndexHtml(){const t=[];return(!0===e||"object"==typeof e&&!0===e.addRootElement)&&t.push({tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}),(!0===e||"object"==typeof e&&!0===e.addSharedComponentsScripts)&&t.push({tag:"script",injectTo:"head-prepend",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"head-prepend",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head-prepend",attrs:{href:"/css/main.css",rel:"stylesheet"}}),t}}}(y)),h){const{ViteImageOptimizer:e}=await(import("vite-plugin-image-optimizer"));m.push(e("object"==typeof h?h:void 0))}if(g){const{versionPlugin:e}=await(import("./version-plugin-Bt9UayFc.js"));m.push(e({outDir:f,packageVersion:i.version??"0.0.0",packageRepositoryUrl:ve(i.repository),..."object"==typeof g?g:{}}))}if(v){const{default:e}=await(import("vite-plugin-zip-pack"));m.push({...e("object"==typeof v?v:{outFileName:p(s)}),enforce:"post"})}return{base:_?`${l}/${s}`:`${u}/${s}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:k}},outDir:f},css:{modules:{localsConvention:"dashes"}},ppDevConfig:o,plugins:m}}function he(e){return e?.ppDev||{}}function _e(e,t){return async(n,i={})=>{try{const{constants:s}=await B(),{PHASE_DEVELOPMENT_SERVER:r,PHASE_PRODUCTION_BUILD:o}=s;n!==o||process.env[d]||m().warn(f.yellow('ā Building with plain `next build`. Use `pp-dev next-build` instead to get VERSION/BUILD-MANIFEST/zip build output in the same format as `pp-dev build` (see the "Next.js Build" section in the pp-dev README).'));const p=await ce(),g=ae().name,h="function"==typeof e?await e(n,i):e,_=function(...e){const t={},n=t;for(const t of e)if(t)for(const[e,i]of Object.entries(t))void 0!==i&&(fe.has(e)&&i&&"object"==typeof i&&!Array.isArray(i)?n[e]={...n[e]??{},...i}:n[e]=i);return t}(p,he(h),t);a(_,g);const y=c(_,g),{templateLess:j,v7Features:b}=y,P=n===r,E=function(e,t,n,i){return n?i?t?`${l}/${e}`:`${v}/${e}`:t?`${l}/${e}`:`${u}/${e}`:`${l}/${e}`}(y.templateName,j,P,b),$={basePath:E,trailingSlash:!!P||void 0};if(!j){const e=P&&b?v:u;$.assetPrefix=`${e}/${y.templateName}`}const w=Object.assign({},$,h);return Object.defineProperty(w,"ppDev",{value:_,enumerable:!1,configurable:!0}),w}catch(e){throw m().error("Error in withPPDev:",{error:e instanceof Error?e:new Error(String(e))}),e}}}export{de as a,me as b,L as c,W as d,he as e,G as f,ge as g,pe as h,N as i,J as l,ue as r,B as s,_e as w};
|
|
2
|
+
//# sourceMappingURL=index-D9RNUMPH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-D9RNUMPH.js","sources":["../../../src/lib/dev-panel.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/lib/env.ts","../../../src/config.ts","../../../src/lib/build-cli-overrides.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["CLIENT_DIST_DIR","path","dirname","PP_DEV_CLIENT_ENTRY","TEMPLATE_PATH","join","compiledTemplate","getDevPanelAssetPaths","base","css","posix","PACKAGE_NAME","js","renderDevPanelMarkup","data","templateContent","fs","readFileSync","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","VERSION","backendBaseURL","templateLess","appId","canSync","devPanelPosition","devPanelHidden","devPanelAutoHide","injectDevPanel","html","test","linkTag","bodyPrepend","result","linkInjected","replace","head","CONTENT_TYPES","createDevPanelAssetMiddleware","assetPrefix","allowed","Set","req","res","next","pathname","url","split","startsWith","fileName","slice","length","has","filePath","readFile","err","content","statusCode","setHeader","extname","end","DIRNAME","__filename","resolve","fileURLToPath","URL","process","cwd","normalizePath","PP_DEV_PACKAGE_DIR","PACKAGE_REGEXP","RegExp","cachedTemplateContent","cachedTemplate","clientInjectionPlugin","opts","name","apply","config","optimizeDeps","exclude","push","resolveId","source","match","resolvedId","id","transformIndexHtml","ctx","server","templatePath","cache","filename","assetPaths","tags","tag","injectTo","attrs","rel","href","templateData","children","src","type","configureServer","clientDir","root","allow","replacer","substring","$1","header","_chunk","safeNextImport","constants","Promise","all","default","error","Error","isNextAvailable","getNextVersion","version","previouslyLoadedKeys","loadPPDevEnv","mode","envDir","key","env","fromEnvironment","Object","keys","filter","loadEnv","value","entries","configCache","Map","packageJsonCache","getPackageJson","projectRoot","now","Date","cached","get","timestamp","JSON","parse","flag","set","empty","esbuildModule","MODULE_LOCATION","MODULE_LOCATION_DEFINE","__dirname","moduleLocationPlugin","setup","build","onLoad","args","contents","stringify","pathToFileURL","loader","endsWith","loadBundledConfig","cacheKey","isESM","pkg","esbuild","getEsbuild","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","packages","format","mainFields","sourcemap","metafile","plugins","define","banner","text","code","outputFiles","fileNameTmp","Math","random","toString","tempFilePath","fileUrl","writeFileSync","conf","unlinkSync","loadJSONConfig","dirContentCache","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","isFile","map","getDirectoryContent","configFound","newConfig","dirFiles","configNames","configName","includes","configPath","loadConfig","PP_DEV_CONFIG_NAMES","packageConfig","Array","isArray","clear","parseBooleanFlag","undefined","toLowerCase","resolveBuildCliOverrides","options","distZipEnabled","distZip","PP_DEV_DIST_ZIP","distZipDir","PP_DEV_DIST_ZIP_DIR","distZipFilename","PP_DEV_DIST_ZIP_FILENAME","versionManifestEnabled","versionManifest","PP_DEV_VERSION_MANIFEST","versionFileTemplate","PP_DEV_VERSION_FILE_TEMPLATE","applyDistZipOverride","overrides","defaultFileName","outFileName","normalizeRelativeOutputPath","baseConfig","outDir","applyVersionManifestOverride","enabled","normalizedVersionFileTemplate","PP_DEV_CONFIG_GROUPS","resolveRepositoryUrl","repository","directCiRepositoryUrlEnvVars","variableName","ciRepositoryUrl","trim","githubRepository","GITHUB_REPOSITORY","GITHUB_SERVER_URL","gitlabProjectPath","CI_PROJECT_PATH","CI_SERVER_URL","bitbucketRepositoryFullName","BITBUCKET_REPO_FULL_NAME","travisRepositorySlug","TRAVIS_REPO_SLUG","gitRemoteOriginUrl","execSync","stdio","getViteConfig","environment","templateName","ppDevConfig","validatePPDevConfig","normalizedPPDevConfig","normalizePPDevConfig","createDefaultZipFileName","versionPlugin","vitePPDev","imageOptimizer","integrateMiTopBar","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","versionPluginFn","packageVersion","packageRepositoryUrl","zipPack","enforce","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","port","minify","assetsInlineLimit","rollupOptions","output","modules","localsConvention","getPPDevConfigFromNextConfig","nextConfig","ppDev","withPPDev","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","PP_DEV_NEXT_BUILD_ENV_VAR","createLogger","warn","colors","yellow","nextConfiguration","mergedConfig","configs","merged","mutableMerged","mergePPDevConfigs","normalized","v7Features","isDevelopment","basePath","PATH_TEMPLATE_LOCAL_PREFIX","createBasePath","trailingSlash","prefix","assign","defineProperty","enumerable","configurable","String"],"mappings":"2dA4BA,MAAMA,EAAkBC,EAAKC,QAAQC,GAC/BC,EAAgBH,EAAKI,KAAKL,EAAiB,cAEjD,IAAIM,EAA4C,KAqB1C,SAAUC,EAAsBC,GACpC,MAAO,CACLC,IAAKR,EAAKS,MAAML,KAAKG,EAAMG,EAAc,qBACzCC,GAAIX,EAAKS,MAAML,KAAKG,EAAMG,EAAc,oBAE5C,CAGM,SAAUE,EAAqBC,GAGnC,OA9BF,WACE,GAAIR,EACF,OAAOA,EAGT,MAAMS,EAAkBC,EAAGC,aAAab,EAAe,CAAEc,SAAU,SAUnE,OARAZ,EAAmBa,EAAIC,QAAQL,EAAiB,CAC9CM,cAAe,IACfC,eAAgB,IAChBC,OAAO,EACPC,cAAc,EACdC,cAAc,IAGTnB,CACT,CAYmBoB,EAEVC,CAAS,CACdhB,eACAiB,UACAC,eAAgBf,EAAKe,eACrBC,aAAchB,EAAKgB,aACnBC,MAAOjB,EAAKiB,MACZC,QAASlB,EAAKkB,UAAW,EAGzBC,iBAAkBnB,EAAKmB,kBAAoB,eAC3CC,eAAgBpB,EAAKoB,iBAAkB,EACvCC,iBAAkBrB,EAAKqB,mBAAoB,GAE/C,UAUgBC,EAAeC,EAAc7B,EAAcM,GACzD,IAAK,0BAA0BwB,KAAKD,GAClC,OAAOA,EAGT,MAAM5B,IAAEA,EAAGG,GAAEA,GAAOL,EAAsBC,GAGpC+B,EAAU,gCAAgC9B,MAE1C+B,EAAc,GAJA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,MAAMiT,EAASL,GAAiBD,EAAaG,EAA6B/B,EAE1EhD,EAAW9M,YAAc,GAAGgS,KAAUP,EAAWhD,cACnD,CAKA,MAAM/O,EAASiG,OAAOsM,OAAO,CAAA,EAAInF,EAAYqE,GAQ7C,OANAxL,OAAOuM,eAAexS,EAAQ,QAAS,CACrCqG,MAAOqL,EACPe,YAAY,EACZC,cAAc,IAGT1S,CACT,CAAE,MAAOqF,GAKP,MAJegM,IAERhM,MAAM,sBAAuB,CAAEA,MAAOA,aAAiBC,MAAQD,EAAQ,IAAIC,MAAMqN,OAAOtN,MAEzFA,CACR,EAEJ"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"child_process";export{L as AuthProvider,N as authProvider,n as normalizePPDevConfig,v as validatePPDevConfig}from"./plugin-CovBU2l1.js";export{d as getNextVersion,e as getPPDevConfigFromNextConfig,g as getViteConfig,f as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-
|
|
1
|
+
import"child_process";export{L as AuthProvider,N as authProvider,n as normalizePPDevConfig,v as validatePPDevConfig}from"./plugin-CovBU2l1.js";export{d as getNextVersion,e as getPPDevConfigFromNextConfig,g as getViteConfig,f as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-D9RNUMPH.js";export{defineConfig}from"./helpers.js";import"http-proxy-middleware";import"url";import"vite";import"picocolors";import"node:string_decoder";import"axios";import"node:http";import"node:https";import"jsdom";import"path";import"fs";import"crypto";import"process";import"os";import"node:path";import"jszip";import"module";import"zlib";import"express";import"node:crypto";import"node:fs";import"node:os";import"ejs";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("child_process"),t=require("./plugin-ydXTL_i4.js"),n=require("vite"),i=require("fs"),r=require("path"),s=require("url");require("./helpers.js");const o=require("ejs");var a="undefined"!=typeof document?document.currentScript:null;const c=e=>e&&"object"==typeof e&&"default"in e?e.default:e;function l(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const n in e)t[n]=e[n];return t.default=e,Object.freeze(t)}const p=l(i),u=l(r),d=c(r),f=c(o),m=u.dirname(t.PP_DEV_CLIENT_ENTRY),P=u.join(m,"index.html");let v=null;function E(e){return{css:u.posix.join(e,t.PACKAGE_NAME,"client/client.css"),js:u.posix.join(e,t.PACKAGE_NAME,"client/client.js")}}function g(e){return function(){if(v)return v;const e=p.readFileSync(P,{encoding:"utf8"});return v=f.compile(e,{openDelimiter:"{",closeDelimiter:"}",async:!1,rmWhitespace:!0,compileDebug:!1}),v}()({PACKAGE_NAME:t.PACKAGE_NAME,VERSION:t.VERSION,backendBaseURL:e.backendBaseURL,templateLess:e.templateLess,appId:e.appId,canSync:e.canSync??!0,devPanelPosition:e.devPanelPosition??"bottom-right",devPanelHidden:e.devPanelHidden??!1,devPanelAutoHide:e.devPanelAutoHide??!1})}const _={".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".map":"application/json; charset=utf-8"};let h;try{h="undefined"!=typeof __filename&&__filename?u.resolve(u.dirname(__filename),".."):void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BXC_G2Qq.js",document.baseURI).href}&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BXC_G2Qq.js",document.baseURI).href,1)&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BXC_G2Qq.js",document.baseURI).href)?u.resolve(s.fileURLToPath(new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:a&&"SCRIPT"===a.tagName.toUpperCase()&&a.src||new URL("index-BXC_G2Qq.js",document.baseURI).href)),".."):process.cwd()}catch{h=process.cwd()}const y=n.normalizePath(u.join(t.PP_DEV_PACKAGE_DIR,"dist/client")),T=new RegExp(`^\\/?${t.PACKAGE_NAME}\\/client\\/(.*)$`);let I=null,R=null;function j(e){return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${t.PACKAGE_NAME}/client`),e),resolveId(e){const t=e.match(T);if(t){const e=n.normalizePath(u.join(y,t[1]));return e.startsWith(`${y}/`)?{id:e}:null}},transformIndexHtml:async(e,n)=>{const i=n.server?.config.base||"",r=function(){if(R)return R;const e=u.resolve(h,"client","index.html");return I||(I=p.readFileSync(e,{encoding:"utf8"})),R=f.compile(I,{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:e,rmWhitespace:!0,compileDebug:!1}),R}(),s=E(i),o={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:s.css}}]},{backendBaseURL:a,templateLess:c=!1,appId:l,canSync:d=!0,devPanelPosition:m="bottom-right",devPanelHidden:P=!1,devPanelAutoHide:v=!1}=n.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:t.PACKAGE_NAME,VERSION:t.VERSION,backendBaseURL:a,templateLess:c,appId:l,canSync:d,devPanelPosition:m,devPanelHidden:P,devPanelAutoHide:v};return o.tags.push({tag:"div",injectTo:"body-prepend",children:await r(g)}),o.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:s.js,type:"module"}}),o},configureServer(e){const i=n.normalizePath(u.resolve(e.config.root,u.dirname(t.PP_DEV_CLIENT_ENTRY)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(i)}}}const b=(e,t)=>` * ${t}`;function A(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,b)}\n */`}async function D(){try{const[e,t]=await Promise.all([import("next"),import("next/constants.js")]);return{next:e.default,constants:t}}catch(e){throw new Error(`Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^15\n\nThis package requires Next.js >=15 <17 as a peer dependency.\n\nError: ${e}`)}}let w=new Set;function N(e="development",t=process.cwd()){for(const e of w)delete process.env[e];const i=new Set(Object.keys(process.env).filter(e=>e.startsWith("MI_"))),r=n.loadEnv(e,t,"MI_");for(const[e,t]of Object.entries(r))process.env[e]=t;return w=new Set(Object.keys(r).filter(e=>!i.has(e))),r}const S=new Map,L=3e4,F=new Map;function $(e=process.cwd()){const t=Date.now(),n=d.resolve(e),r=F.get(n);if(r&&t-r.timestamp<6e4)return r.data;try{const e=JSON.parse(i.readFileSync(d.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return F.set(n,{data:e,timestamp:t}),e}catch{const e={};return F.set(n,{data:e,timestamp:t}),e}}let C=null;async function x(e,t){const n=`ts:${e}`,r=S.get(n);if(r&&Date.now()-r.timestamp<L)return r.data;let o=!1;if(/\.m[jt]s$/.test(e))o=!0;else if(/\.c[jt]s$/.test(e))o=!1;else{const e=$(t);o=!!e&&"module"===e.type}const a=await async function(){return C||(C=await(import("esbuild"))),C}(),c=await a.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:o?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:l}=c.outputFiles[0],p=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,u=d.resolve(t,p),f=s.pathToFileURL(u).toString();i.writeFileSync(u,l);let m={};try{const t=(await(import(f))).default;m=t?.default||t,S.set(n,{data:m,timestamp:Date.now(),filePath:e})}finally{i.existsSync(u)&&i.unlink(u,()=>{})}return m}async function O(e){const t=`js:${e}`,n=S.get(t);if(n&&Date.now()-n.timestamp<L)return n.data;const i=(await(import(s.pathToFileURL(e).toString()))).default;return S.set(t,{data:i,timestamp:Date.now(),filePath:e}),i}async function U(e){const t=`json:${e}`,n=S.get(t);if(n&&Date.now()-n.timestamp<L)return n.data;const r=JSON.parse(i.readFileSync(e,{encoding:"utf-8"}));return S.set(t,{data:r,timestamp:Date.now(),filePath:e}),r}const M=new Map;function V(e=process.cwd()){return $(e)}async function H(e=process.cwd()){const n=d.resolve(e),r=function(e){const t=Date.now(),n=M.get(e);if(n&&t-n.timestamp<1e4)return n.files;const r=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,s=i.readdirSync(e,{withFileTypes:!0}).filter(e=>e.isFile()&&r.test(e.name)).map(e=>e.name);return M.set(e,{files:s,timestamp:t}),s}(n);let s={},o=!1;const a=await async function(e,t,n){for(const i of t)if(e.includes(i)){const e=d.resolve(n,i);if(/\.[cm]?ts$/i.test(i))return await x(e,n);if(/\.[cm]?js$/i.test(i))return await O(e);if(i.endsWith(".json"))return await U(e)}return null}(r,t.PP_DEV_CONFIG_NAMES,n);a&&(s=a,o=!0);const c=$(n)["pp-dev"];return o||!c||"object"!=typeof c||Array.isArray(c)||(s=c),s}const Z=Object.freeze({__proto__:null,clearConfigCache:function(){S.clear(),F.clear(),M.clear()},getConfig:H,getPkg:V});function G(e){if(void 0!==e)return"1"===e||"true"===e.toLowerCase()||"0"!==e&&"false"!==e.toLowerCase()&&void 0}function k(e,n,i){if(!1===n.distZipEnabled)return!1;if(!0!==n.distZipEnabled&&void 0===n.distZipDir&&void 0===n.distZipFilename)return!1!==e&&{...e,outFileName:t.normalizeRelativeOutputPath(e.outFileName,"ZIP output file name")};const r=!1===e?{outFileName:i,outDir:"dist-zip"}:e,s=n.distZipFilename??r.outFileName;return{...r,...void 0!==n.distZipDir?{outDir:n.distZipDir}:{},outFileName:t.normalizeRelativeOutputPath(s,"ZIP output file name")}}function B(e,n){if(!1===n.versionManifestEnabled)return!1;if(!0!==n.versionManifestEnabled&&void 0===n.versionFileTemplate)return!1!==e&&void 0!==e.versionFileTemplate?{...e,versionFileTemplate:t.normalizeRelativeOutputPath(e.versionFileTemplate,"VERSION file name template")}:e;const i=!1===e?{enabled:!0}:e,r=n.versionFileTemplate??i.versionFileTemplate,s=void 0!==r?t.normalizeRelativeOutputPath(r,"VERSION file name template"):void 0;return{...i,enabled:!0,...void 0!==s?{versionFileTemplate:s}:{}}}const z=new Set(["mi","app","proxy","build","sync","inspector","devPanel"]);function q(t){if("string"==typeof t)return t;if(t&&"object"==typeof t&&"url"in t&&"string"==typeof t.url)return t.url;const n=["CI_REPOSITORY_URL","GIT_URL","BUILD_REPOSITORY_URI","CI_PROJECT_URL","BITBUCKET_GIT_HTTP_ORIGIN","BUILDKITE_REPO"];for(const e of n){const t=process.env[e];if("string"==typeof t&&t.trim())return t}const i=process.env.GITHUB_REPOSITORY;if("string"==typeof i&&i.trim()){return`${(process.env.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,"")}/${i.replace(/^\/+/,"")}`}const r=process.env.CI_PROJECT_PATH;if("string"==typeof r&&r.trim()){return`${(process.env.CI_SERVER_URL||"https://gitlab.com").replace(/\/+$/,"")}/${r.replace(/^\/+/,"")}`}const s=process.env.BITBUCKET_REPO_FULL_NAME;if("string"==typeof s&&s.trim())return`https://bitbucket.org/${s.replace(/^\/+/,"")}`;const o=process.env.TRAVIS_REPO_SLUG;if("string"==typeof o&&o.trim())return`https://github.com/${o.replace(/^\/+/,"")}`;try{const t=e.execSync("git config --get remote.origin.url",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}}function K(e){return e?.ppDev||{}}exports.applyDistZipOverride=k,exports.applyVersionManifestOverride=B,exports.config=Z,exports.createDevPanelAssetMiddleware=function(e){const n=u.posix.join(e,t.PACKAGE_NAME,"client")+"/",i=new Set(["client.js","client.css","client.js.map","client.css.map"]);return(e,t,r)=>{const s=(e.url??"").split("?")[0];if(!s.startsWith(n))return void r();const o=s.slice(n.length);if(!i.has(o))return void r();const a=u.join(m,o);p.readFile(a,(e,n)=>{e?r():(t.statusCode=200,t.setHeader("Content-Type",_[u.extname(o)]??"application/octet-stream"),t.setHeader("Cache-Control","no-cache"),t.end(n))})}},exports.getNextVersion=async function(){try{return(await(import("next/package.json"))).version}catch{return null}},exports.getPPDevConfigFromNextConfig=K,exports.getViteConfig=async function(e,n={}){const i=n.root??process.cwd();N(n.mode,i);const r=V(i),s=r.name,o=await H(i);t.validatePPDevConfig(o,s);const a=t.normalizePPDevConfig(o,s);e&&(a.distZip=k(a.distZip,e,t.createDefaultZipFileName(s)),a.versionPlugin=B(a.versionPlugin,e));const{default:c}=await Promise.resolve().then(()=>require("./plugin.js")),l=[c(a),j()],{outDir:p,distZip:u,versionPlugin:d,imageOptimizer:f,templateLess:m,integrateMiTopBar:P}=a;if(P&&l.push(function(e){return{name:"mi-topbar-plugin",transformIndexHtml(){const t=[];return(!0===e||"object"==typeof e&&!0===e.addRootElement)&&t.push({tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}),(!0===e||"object"==typeof e&&!0===e.addSharedComponentsScripts)&&t.push({tag:"script",injectTo:"head-prepend",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"head-prepend",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head-prepend",attrs:{href:"/css/main.css",rel:"stylesheet"}}),t}}}(P)),f){const{ViteImageOptimizer:e}=await(import("vite-plugin-image-optimizer"));l.push(e("object"==typeof f?f:void 0))}if(d){const{versionPlugin:e}=await Promise.resolve().then(()=>require("./version-plugin-new7ayDW.js"));l.push(e({outDir:p,packageVersion:r.version??"0.0.0",packageRepositoryUrl:q(r.repository),..."object"==typeof d?d:{}}))}if(u){const{default:e}=await(import("vite-plugin-zip-pack"));l.push({...e("object"==typeof u?u:{outFileName:t.createDefaultZipFileName(s)}),enforce:"post"})}return{base:m?`${t.PATH_PAGE_PREFIX}/${s}`:`${t.PATH_TEMPLATE_PREFIX}/${s}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:A}},outDir:p},css:{modules:{localsConvention:"dashes"}},ppDevConfig:a,plugins:l}},exports.injectDevPanel=function(e,t,n){if(!/<\/?(html|body|head)\b/i.test(e))return e;const{css:i,js:r}=E(t),s=`<link rel="stylesheet" href="${i}">`,o=`${g(n)}${`<script type="module" src="${r}"><\/script>`}`;let a=e,c=!1;if(/<\/head>/i.test(a)&&(a=a.replace(/<\/head>/i,`${s}</head>`),c=!0),/<body[^>]*>/i.test(a)){const e=c?"":s;a=a.replace(/(<body[^>]*>)/i,`$1${e}${o}`)}else a=`${c?"":s}${a}${o}`;return a},exports.isNextAvailable=async function(){try{return await(import("next")),!0}catch{return!1}},exports.loadPPDevEnv=N,exports.resolveBuildCliOverrides=function(e){return{distZipEnabled:e.distZip??G(process.env.PP_DEV_DIST_ZIP),distZipDir:e.distZipDir??process.env.PP_DEV_DIST_ZIP_DIR,distZipFilename:e.distZipFilename??process.env.PP_DEV_DIST_ZIP_FILENAME,versionManifestEnabled:e.versionManifest??G(process.env.PP_DEV_VERSION_MANIFEST),versionFileTemplate:e.versionFileTemplate??process.env.PP_DEV_VERSION_FILE_TEMPLATE}},exports.safeNextImport=D,exports.withPPDev=function(e,n){return async(i,r={})=>{try{const{constants:s}=await D(),{PHASE_DEVELOPMENT_SERVER:o,PHASE_PRODUCTION_BUILD:a}=s;i!==a||process.env[t.PP_DEV_NEXT_BUILD_ENV_VAR]||t.createLogger().warn(t.colors.yellow('ā Building with plain `next build`. Use `pp-dev next-build` instead to get VERSION/BUILD-MANIFEST/zip build output in the same format as `pp-dev build` (see the "Next.js Build" section in the pp-dev README).'));const c=await H(),l=V().name,p="function"==typeof e?await e(i,r):e,u=function(...e){const t={},n=t;for(const t of e)if(t)for(const[e,i]of Object.entries(t))void 0!==i&&(z.has(e)&&i&&"object"==typeof i&&!Array.isArray(i)?n[e]={...n[e]??{},...i}:n[e]=i);return t}(c,K(p),n);t.validatePPDevConfig(u,l);const d=t.normalizePPDevConfig(u,l),{templateLess:f,v7Features:m}=d,P=i===o,v=function(e,n,i,r){return i?r?n?`${t.PATH_PAGE_PREFIX}/${e}`:`${t.PATH_TEMPLATE_LOCAL_PREFIX}/${e}`:n?`${t.PATH_PAGE_PREFIX}/${e}`:`${t.PATH_TEMPLATE_PREFIX}/${e}`:`${t.PATH_PAGE_PREFIX}/${e}`}(d.templateName,f,P,m),E={basePath:v,trailingSlash:!!P||void 0};if(!f){const e=P&&m?t.PATH_TEMPLATE_LOCAL_PREFIX:t.PATH_TEMPLATE_PREFIX;E.assetPrefix=`${e}/${d.templateName}`}const g=Object.assign({},E,p);return Object.defineProperty(g,"ppDev",{value:u,enumerable:!1,configurable:!0}),g}catch(e){throw t.createLogger().error("Error in withPPDev:",{error:e instanceof Error?e:new Error(String(e))}),e}}};
|
|
2
|
-
//# sourceMappingURL=index-BXC_G2Qq.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BXC_G2Qq.js","sources":["../../../src/lib/dev-panel.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/lib/env.ts","../../../src/config.ts","../../../src/lib/build-cli-overrides.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["CLIENT_DIST_DIR","path","dirname","PP_DEV_CLIENT_ENTRY","TEMPLATE_PATH","join","compiledTemplate","getDevPanelAssetPaths","base","css","posix","PACKAGE_NAME","js","renderDevPanelMarkup","data","templateContent","fs","readFileSync","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","VERSION","backendBaseURL","templateLess","appId","canSync","devPanelPosition","devPanelHidden","devPanelAutoHide","CONTENT_TYPES","DIRNAME","__filename","resolve","url","document","require","pathToFileURL","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","fileURLToPath","process","cwd","normalizePath","PP_DEV_PACKAGE_DIR","PACKAGE_REGEXP","RegExp","cachedTemplateContent","cachedTemplate","clientInjectionPlugin","opts","name","apply","config","optimizeDeps","exclude","push","resolveId","source","match","resolvedId","startsWith","id","transformIndexHtml","html","ctx","server","templatePath","cache","filename","assetPaths","result","tags","tag","injectTo","attrs","rel","templateData","children","type","configureServer","clientDir","root","allow","replacer","substring","$1","header","_chunk","replace","safeNextImport","next","constants","Promise","all","default","error","Error","previouslyLoadedKeys","Set","loadPPDevEnv","mode","envDir","key","env","fromEnvironment","Object","keys","filter","loadEnv","value","entries","has","configCache","Map","CACHE_TTL","packageJsonCache","getPackageJson","projectRoot","now","Date","cached","get","timestamp","JSON","parse","flag","set","empty","esbuildModule","loadTsConfig","filePath","cacheKey","isESM","test","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","packages","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","toString","slice","tempFilePath","fileUrl","writeFileSync","conf","existsSync","unlink","loadJsConfig","loadJSONConfig","dirContentCache","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","isFile","map","getDirectoryContent","configFound","newConfig","dirFiles","configNames","configName","includes","configPath","endsWith","loadConfig","PP_DEV_CONFIG_NAMES","packageConfig","Array","isArray","clear","parseBooleanFlag","undefined","toLowerCase","applyDistZipOverride","overrides","defaultFileName","distZipEnabled","distZipDir","distZipFilename","outFileName","normalizeRelativeOutputPath","baseConfig","outDir","applyVersionManifestOverride","versionManifestEnabled","versionFileTemplate","enabled","normalizedVersionFileTemplate","PP_DEV_CONFIG_GROUPS","resolveRepositoryUrl","repository","directCiRepositoryUrlEnvVars","variableName","ciRepositoryUrl","trim","githubRepository","GITHUB_REPOSITORY","GITHUB_SERVER_URL","gitlabProjectPath","CI_PROJECT_PATH","CI_SERVER_URL","bitbucketRepositoryFullName","BITBUCKET_REPO_FULL_NAME","travisRepositorySlug","TRAVIS_REPO_SLUG","gitRemoteOriginUrl","execSync","stdio","getPPDevConfigFromNextConfig","nextConfig","ppDev","assetPrefix","allowed","req","res","pathname","split","fileName","length","readFile","err","content","statusCode","setHeader","extname","end","version","environment","templateName","ppDevConfig","validatePPDevConfig","normalizedPPDevConfig","normalizePPDevConfig","distZip","createDefaultZipFileName","versionPlugin","vitePPDev","then","plugins","imageOptimizer","integrateMiTopBar","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","versionPluginFn","packageVersion","packageRepositoryUrl","zipPack","enforce","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","linkTag","bodyPrepend","linkInjected","head","options","PP_DEV_DIST_ZIP","PP_DEV_DIST_ZIP_DIR","PP_DEV_DIST_ZIP_FILENAME","versionManifest","PP_DEV_VERSION_MANIFEST","PP_DEV_VERSION_FILE_TEMPLATE","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","PP_DEV_NEXT_BUILD_ENV_VAR","createLogger","warn","colors","yellow","nextConfiguration","mergedConfig","configs","merged","mutableMerged","mergePPDevConfigs","normalized","v7Features","isDevelopment","basePath","PATH_TEMPLATE_LOCAL_PREFIX","createBasePath","trailingSlash","prefix","assign","defineProperty","enumerable","configurable","String"],"mappings":"ggBA4BMA,EAAkBC,EAAKC,QAAQC,uBAC/BC,EAAgBH,EAAKI,KAAKL,EAAiB,cAEjD,IAAIM,EAA4C,KAqB1C,SAAUC,EAAsBC,GACpC,MAAO,CACLC,IAAKR,EAAKS,MAAML,KAAKG,EAAMG,EAAAA,aAAc,qBACzCC,GAAIX,EAAKS,MAAML,KAAKG,EAAMG,EAAAA,aAAc,oBAE5C,CAGM,SAAUE,EAAqBC,GAGnC,OA9BF,WACE,GAAIR,EACF,OAAOA,EAGT,MAAMS,EAAkBC,EAAGC,aAAab,EAAe,CAAEc,SAAU,SAUnE,OARAZ,EAAmBa,EAAIC,QAAQL,EAAiB,CAC9CM,cAAe,IACfC,eAAgB,IAChBC,OAAO,EACPC,cAAc,EACdC,cAAc,IAGTnB,CACT,CAYmBoB,EAEVC,CAAS,cACdhB,EAAAA,qBACAiB,EAAAA,QACAC,eAAgBf,EAAKe,eACrBC,aAAchB,EAAKgB,aACnBC,MAAOjB,EAAKiB,MACZC,QAASlB,EAAKkB,UAAW,EAGzBC,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,EAEJ"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{execSync as e}from"child_process";import{G as t,H as n,V as i,J as s,F as r,K as o,v as a,n as c,d as p,h as l,j as u,b as d,c as m,a as f,i as v}from"./plugin-CovBU2l1.js";import{normalizePath as g,loadEnv as h}from"vite";import*as y from"fs";import{readdirSync as j,readFileSync as P,writeFileSync as b,existsSync as E,unlink as w}from"fs";import*as _ from"path";import I from"path";import{fileURLToPath as $,pathToFileURL as D}from"url";import"./helpers.js";import T from"ejs";const S=_.dirname(n),R=_.join(S,"index.html");let O=null;function F(e){return{css:_.posix.join(e,t,"client/client.css"),js:_.posix.join(e,t,"client/client.js")}}function N(e){return function(){if(O)return O;const e=y.readFileSync(R,{encoding:"utf8"});return O=T.compile(e,{openDelimiter:"{",closeDelimiter:"}",async:!1,rmWhitespace:!0,compileDebug:!1}),O}()({PACKAGE_NAME:t,VERSION:i,backendBaseURL:e.backendBaseURL,templateLess:e.templateLess,appId:e.appId,canSync:e.canSync??!0,devPanelPosition:e.devPanelPosition??"bottom-right",devPanelHidden:e.devPanelHidden??!1,devPanelAutoHide:e.devPanelAutoHide??!1})}function L(e,t,n){if(!/<\/?(html|body|head)\b/i.test(e))return e;const{css:i,js:s}=F(t),r=`<link rel="stylesheet" href="${i}">`,o=`${N(n)}${`<script type="module" src="${s}"><\/script>`}`;let a=e,c=!1;if(/<\/head>/i.test(a)&&(a=a.replace(/<\/head>/i,`${r}</head>`),c=!0),/<body[^>]*>/i.test(a)){const e=c?"":r;a=a.replace(/(<body[^>]*>)/i,`$1${e}${o}`)}else a=`${c?"":r}${a}${o}`;return a}const x={".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".map":"application/json; charset=utf-8"};function A(e){const n=_.posix.join(e,t,"client")+"/",i=new Set(["client.js","client.css","client.js.map","client.css.map"]);return(e,t,s)=>{const r=(e.url??"").split("?")[0];if(!r.startsWith(n))return void s();const o=r.slice(n.length);if(!i.has(o))return void s();const a=_.join(S,o);y.readFile(a,(e,n)=>{e?s():(t.statusCode=200,t.setHeader("Content-Type",x[_.extname(o)]??"application/octet-stream"),t.setHeader("Cache-Control","no-cache"),t.end(n))})}}let C;try{C="undefined"!=typeof __filename&&__filename?_.resolve(_.dirname(__filename),".."):void 0!==import.meta&&import.meta&&import.meta.url?_.resolve($(new URL(".",import.meta.url)),".."):process.cwd()}catch{C=process.cwd()}const U=g(_.join(s,"dist/client")),Z=new RegExp(`^\\/?${t}\\/client\\/(.*)$`);let H=null,M=null;function V(e){return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${t}/client`),e),resolveId(e){const t=e.match(Z);if(t){const e=g(_.join(U,t[1]));return e.startsWith(`${U}/`)?{id:e}:null}},transformIndexHtml:async(e,n)=>{const s=n.server?.config.base||"",r=function(){if(M)return M;const e=_.resolve(C,"client","index.html");return H||(H=y.readFileSync(e,{encoding:"utf8"})),M=T.compile(H,{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:e,rmWhitespace:!0,compileDebug:!1}),M}(),o=F(s),a={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:o.css}}]},{backendBaseURL:c,templateLess:p=!1,appId:l,canSync:u=!0,devPanelPosition:d="bottom-right",devPanelHidden:m=!1,devPanelAutoHide:f=!1}=n.server?.config.clientInjectionPlugin||{},v={PACKAGE_NAME:t,VERSION:i,backendBaseURL:c,templateLess:p,appId:l,canSync:u,devPanelPosition:d,devPanelHidden:m,devPanelAutoHide:f};return a.tags.push({tag:"div",injectTo:"body-prepend",children:await r(v)}),a.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:o.js,type:"module"}}),a},configureServer(e){const t=g(_.resolve(e.config.root,_.dirname(n)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t)}}}const k=(e,t)=>` * ${t}`;function B(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,k)}\n */`}async function G(){try{const[e,t]=await Promise.all([import("next"),import("next/constants.js")]);return{next:e.default,constants:t}}catch(e){throw new Error(`Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^15\n\nThis package requires Next.js >=15 <17 as a peer dependency.\n\nError: ${e}`)}}async function z(){try{return await(import("next")),!0}catch{return!1}}async function W(){try{return(await(import("next/package.json"))).version}catch{return null}}let K=new Set;function J(e="development",t=process.cwd()){for(const e of K)delete process.env[e];const n=new Set(Object.keys(process.env).filter(e=>e.startsWith("MI_"))),i=h(e,t,"MI_");for(const[e,t]of Object.entries(i))process.env[e]=t;return K=new Set(Object.keys(i).filter(e=>!n.has(e))),i}const Y=new Map,q=3e4,Q=new Map;function X(e=process.cwd()){const t=Date.now(),n=I.resolve(e),i=Q.get(n);if(i&&t-i.timestamp<6e4)return i.data;try{const e=JSON.parse(P(I.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return Q.set(n,{data:e,timestamp:t}),e}catch{const e={};return Q.set(n,{data:e,timestamp:t}),e}}let ee=null;async function te(e,t){const n=`ts:${e}`,i=Y.get(n);if(i&&Date.now()-i.timestamp<q)return i.data;let s=!1;if(/\.m[jt]s$/.test(e))s=!0;else if(/\.c[jt]s$/.test(e))s=!1;else{const e=X(t);s=!!e&&"module"===e.type}const r=await async function(){return ee||(ee=await(import("esbuild"))),ee}(),o=await r.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:s?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:a}=o.outputFiles[0],c=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,p=I.resolve(t,c),l=D(p).toString();b(p,a);let u={};try{const t=(await(import(l))).default;u=t?.default||t,Y.set(n,{data:u,timestamp:Date.now(),filePath:e})}finally{E(p)&&w(p,()=>{})}return u}async function ne(e){const t=`js:${e}`,n=Y.get(t);if(n&&Date.now()-n.timestamp<q)return n.data;const i=(await(import(D(e).toString()))).default;return Y.set(t,{data:i,timestamp:Date.now(),filePath:e}),i}async function ie(e){const t=`json:${e}`,n=Y.get(t);if(n&&Date.now()-n.timestamp<q)return n.data;const i=JSON.parse(P(e,{encoding:"utf-8"}));return Y.set(t,{data:i,timestamp:Date.now(),filePath:e}),i}const se=new Map;function re(e=process.cwd()){return X(e)}async function oe(e=process.cwd()){const t=I.resolve(e),n=function(e){const t=Date.now(),n=se.get(e);if(n&&t-n.timestamp<1e4)return n.files;const i=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,s=j(e,{withFileTypes:!0}).filter(e=>e.isFile()&&i.test(e.name)).map(e=>e.name);return se.set(e,{files:s,timestamp:t}),s}(t);let i={},s=!1;const o=await async function(e,t,n){for(const i of t)if(e.includes(i)){const e=I.resolve(n,i);if(/\.[cm]?ts$/i.test(i))return await te(e,n);if(/\.[cm]?js$/i.test(i))return await ne(e);if(i.endsWith(".json"))return await ie(e)}return null}(n,r,t);o&&(i=o,s=!0);const a=X(t)["pp-dev"];return s||!a||"object"!=typeof a||Array.isArray(a)||(i=a),i}const ae=Object.freeze({__proto__:null,clearConfigCache:function(){Y.clear(),Q.clear(),se.clear()},getConfig:oe,getPkg:re});function ce(e){if(void 0!==e)return"1"===e||"true"===e.toLowerCase()||"0"!==e&&"false"!==e.toLowerCase()&&void 0}function pe(e){return{distZipEnabled:e.distZip??ce(process.env.PP_DEV_DIST_ZIP),distZipDir:e.distZipDir??process.env.PP_DEV_DIST_ZIP_DIR,distZipFilename:e.distZipFilename??process.env.PP_DEV_DIST_ZIP_FILENAME,versionManifestEnabled:e.versionManifest??ce(process.env.PP_DEV_VERSION_MANIFEST),versionFileTemplate:e.versionFileTemplate??process.env.PP_DEV_VERSION_FILE_TEMPLATE}}function le(e,t,n){if(!1===t.distZipEnabled)return!1;if(!0!==t.distZipEnabled&&void 0===t.distZipDir&&void 0===t.distZipFilename)return!1!==e&&{...e,outFileName:o(e.outFileName,"ZIP output file name")};const i=!1===e?{outFileName:n,outDir:"dist-zip"}:e,s=t.distZipFilename??i.outFileName;return{...i,...void 0!==t.distZipDir?{outDir:t.distZipDir}:{},outFileName:o(s,"ZIP output file name")}}function ue(e,t){if(!1===t.versionManifestEnabled)return!1;if(!0!==t.versionManifestEnabled&&void 0===t.versionFileTemplate)return!1!==e&&void 0!==e.versionFileTemplate?{...e,versionFileTemplate:o(e.versionFileTemplate,"VERSION file name template")}:e;const n=!1===e?{enabled:!0}:e,i=t.versionFileTemplate??n.versionFileTemplate,s=void 0!==i?o(i,"VERSION file name template"):void 0;return{...n,enabled:!0,...void 0!==s?{versionFileTemplate:s}:{}}}const de=new Set(["mi","app","proxy","build","sync","inspector","devPanel"]);function me(t){if("string"==typeof t)return t;if(t&&"object"==typeof t&&"url"in t&&"string"==typeof t.url)return t.url;const n=["CI_REPOSITORY_URL","GIT_URL","BUILD_REPOSITORY_URI","CI_PROJECT_URL","BITBUCKET_GIT_HTTP_ORIGIN","BUILDKITE_REPO"];for(const e of n){const t=process.env[e];if("string"==typeof t&&t.trim())return t}const i=process.env.GITHUB_REPOSITORY;if("string"==typeof i&&i.trim()){return`${(process.env.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,"")}/${i.replace(/^\/+/,"")}`}const s=process.env.CI_PROJECT_PATH;if("string"==typeof s&&s.trim()){return`${(process.env.CI_SERVER_URL||"https://gitlab.com").replace(/\/+$/,"")}/${s.replace(/^\/+/,"")}`}const r=process.env.BITBUCKET_REPO_FULL_NAME;if("string"==typeof r&&r.trim())return`https://bitbucket.org/${r.replace(/^\/+/,"")}`;const o=process.env.TRAVIS_REPO_SLUG;if("string"==typeof o&&o.trim())return`https://github.com/${o.replace(/^\/+/,"")}`;try{const t=e("git config --get remote.origin.url",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}}async function fe(e,t={}){const n=t.root??process.cwd();J(t.mode,n);const i=re(n),s=i.name,r=await oe(n);a(r,s);const o=c(r,s);e&&(o.distZip=le(o.distZip,e,p(s)),o.versionPlugin=ue(o.versionPlugin,e));const{default:d}=await(import("./plugin.js")),m=[d(o),V()],{outDir:f,distZip:v,versionPlugin:g,imageOptimizer:h,templateLess:y,integrateMiTopBar:j}=o;if(j&&m.push(function(e){return{name:"mi-topbar-plugin",transformIndexHtml(){const t=[];return(!0===e||"object"==typeof e&&!0===e.addRootElement)&&t.push({tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}),(!0===e||"object"==typeof e&&!0===e.addSharedComponentsScripts)&&t.push({tag:"script",injectTo:"head-prepend",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"head-prepend",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head-prepend",attrs:{href:"/css/main.css",rel:"stylesheet"}}),t}}}(j)),h){const{ViteImageOptimizer:e}=await(import("vite-plugin-image-optimizer"));m.push(e("object"==typeof h?h:void 0))}if(g){const{versionPlugin:e}=await(import("./version-plugin-Bt9UayFc.js"));m.push(e({outDir:f,packageVersion:i.version??"0.0.0",packageRepositoryUrl:me(i.repository),..."object"==typeof g?g:{}}))}if(v){const{default:e}=await(import("vite-plugin-zip-pack"));m.push({...e("object"==typeof v?v:{outFileName:p(s)}),enforce:"post"})}return{base:y?`${l}/${s}`:`${u}/${s}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:B}},outDir:f},css:{modules:{localsConvention:"dashes"}},ppDevConfig:o,plugins:m}}function ve(e){return e?.ppDev||{}}function ge(e,t){return async(n,i={})=>{try{const{constants:s}=await G(),{PHASE_DEVELOPMENT_SERVER:r,PHASE_PRODUCTION_BUILD:o}=s;n!==o||process.env[d]||m().warn(f.yellow('ā Building with plain `next build`. Use `pp-dev next-build` instead to get VERSION/BUILD-MANIFEST/zip build output in the same format as `pp-dev build` (see the "Next.js Build" section in the pp-dev README).'));const p=await oe(),g=re().name,h="function"==typeof e?await e(n,i):e,y=function(...e){const t={},n=t;for(const t of e)if(t)for(const[e,i]of Object.entries(t))void 0!==i&&(de.has(e)&&i&&"object"==typeof i&&!Array.isArray(i)?n[e]={...n[e]??{},...i}:n[e]=i);return t}(p,ve(h),t);a(y,g);const j=c(y,g),{templateLess:P,v7Features:b}=j,E=n===r,w=function(e,t,n,i){return n?i?t?`${l}/${e}`:`${v}/${e}`:t?`${l}/${e}`:`${u}/${e}`:`${l}/${e}`}(j.templateName,P,E,b),_={basePath:w,trailingSlash:!!E||void 0};if(!P){const e=E&&b?v:u;_.assetPrefix=`${e}/${j.templateName}`}const I=Object.assign({},_,h);return Object.defineProperty(I,"ppDev",{value:y,enumerable:!1,configurable:!0}),I}catch(e){throw m().error("Error in withPPDev:",{error:e instanceof Error?e:new Error(String(e))}),e}}}export{le as a,ue as b,A as c,W as d,ve as e,z as f,fe as g,ae as h,L as i,J as l,pe as r,G as s,ge as w};
|
|
2
|
-
//# sourceMappingURL=index-Dthlsvfo.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-Dthlsvfo.js","sources":["../../../src/lib/dev-panel.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/lib/env.ts","../../../src/config.ts","../../../src/lib/build-cli-overrides.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["CLIENT_DIST_DIR","path","dirname","PP_DEV_CLIENT_ENTRY","TEMPLATE_PATH","join","compiledTemplate","getDevPanelAssetPaths","base","css","posix","PACKAGE_NAME","js","renderDevPanelMarkup","data","templateContent","fs","readFileSync","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","VERSION","backendBaseURL","templateLess","appId","canSync","devPanelPosition","devPanelHidden","devPanelAutoHide","injectDevPanel","html","test","linkTag","bodyPrepend","result","linkInjected","replace","head","CONTENT_TYPES","createDevPanelAssetMiddleware","assetPrefix","allowed","Set","req","res","next","pathname","url","split","startsWith","fileName","slice","length","has","filePath","readFile","err","content","statusCode","setHeader","extname","end","DIRNAME","__filename","resolve","fileURLToPath","URL","process","cwd","normalizePath","PP_DEV_PACKAGE_DIR","PACKAGE_REGEXP","RegExp","cachedTemplateContent","cachedTemplate","clientInjectionPlugin","opts","name","apply","config","optimizeDeps","exclude","push","resolveId","source","match","resolvedId","id","transformIndexHtml","ctx","server","templatePath","cache","filename","assetPaths","tags","tag","injectTo","attrs","rel","href","templateData","children","src","type","configureServer","clientDir","root","allow","replacer","substring","$1","header","_chunk","safeNextImport","constants","Promise","all","default","error","Error","isNextAvailable","getNextVersion","version","previouslyLoadedKeys","loadPPDevEnv","mode","envDir","key","env","fromEnvironment","Object","keys","filter","loadEnv","value","entries","configCache","Map","CACHE_TTL","packageJsonCache","getPackageJson","projectRoot","now","Date","cached","get","timestamp","JSON","parse","flag","set","empty","esbuildModule","loadTsConfig","cacheKey","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","packages","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","toString","tempFilePath","fileUrl","pathToFileURL","writeFileSync","conf","existsSync","unlink","loadJsConfig","loadJSONConfig","dirContentCache","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","isFile","map","getDirectoryContent","configFound","newConfig","dirFiles","configNames","configName","includes","configPath","endsWith","loadConfig","PP_DEV_CONFIG_NAMES","packageConfig","Array","isArray","clear","parseBooleanFlag","undefined","toLowerCase","resolveBuildCliOverrides","options","distZipEnabled","distZip","PP_DEV_DIST_ZIP","distZipDir","PP_DEV_DIST_ZIP_DIR","distZipFilename","PP_DEV_DIST_ZIP_FILENAME","versionManifestEnabled","versionManifest","PP_DEV_VERSION_MANIFEST","versionFileTemplate","PP_DEV_VERSION_FILE_TEMPLATE","applyDistZipOverride","overrides","defaultFileName","outFileName","normalizeRelativeOutputPath","baseConfig","outDir","applyVersionManifestOverride","enabled","normalizedVersionFileTemplate","PP_DEV_CONFIG_GROUPS","resolveRepositoryUrl","repository","directCiRepositoryUrlEnvVars","variableName","ciRepositoryUrl","trim","githubRepository","GITHUB_REPOSITORY","GITHUB_SERVER_URL","gitlabProjectPath","CI_PROJECT_PATH","CI_SERVER_URL","bitbucketRepositoryFullName","BITBUCKET_REPO_FULL_NAME","travisRepositorySlug","TRAVIS_REPO_SLUG","gitRemoteOriginUrl","execSync","stdio","getViteConfig","environment","templateName","ppDevConfig","validatePPDevConfig","normalizedPPDevConfig","normalizePPDevConfig","createDefaultZipFileName","versionPlugin","vitePPDev","plugins","imageOptimizer","integrateMiTopBar","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","versionPluginFn","packageVersion","packageRepositoryUrl","zipPack","enforce","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","getPPDevConfigFromNextConfig","nextConfig","ppDev","withPPDev","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","PP_DEV_NEXT_BUILD_ENV_VAR","createLogger","warn","colors","yellow","nextConfiguration","mergedConfig","configs","merged","mutableMerged","mergePPDevConfigs","normalized","v7Features","isDevelopment","basePath","PATH_TEMPLATE_LOCAL_PREFIX","createBasePath","trailingSlash","prefix","assign","defineProperty","enumerable","configurable","String"],"mappings":"ueA4BA,MAAMA,EAAkBC,EAAKC,QAAQC,GAC/BC,EAAgBH,EAAKI,KAAKL,EAAiB,cAEjD,IAAIM,EAA4C,KAqB1C,SAAUC,EAAsBC,GACpC,MAAO,CACLC,IAAKR,EAAKS,MAAML,KAAKG,EAAMG,EAAc,qBACzCC,GAAIX,EAAKS,MAAML,KAAKG,EAAMG,EAAc,oBAE5C,CAGM,SAAUE,EAAqBC,GAGnC,OA9BF,WACE,GAAIR,EACF,OAAOA,EAGT,MAAMS,EAAkBC,EAAGC,aAAab,EAAe,CAAEc,SAAU,SAUnE,OARAZ,EAAmBa,EAAIC,QAAQL,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