@metricinsights/pp-dev 0.12.3 → 0.12.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.12.4-beta.1](https://github.com/mi-examples/pp-dev/compare/v0.12.3...v0.12.4-beta.1) (2026-01-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **plugin:** move topbar scripts injection to head-prepend ([a248f91](https://github.com/mi-examples/pp-dev/commit/a248f91b14817a36a37d56e9107762b514bf90ac))
7
+
1
8
  # [@metricinsights/pp-dev-v0.12.3-beta.1](https://github.com/mi-examples/pp-dev-js/compare/v0.12.2...v0.12.3-beta.1) (2025-12-19)
2
9
 
3
10
 
package/dist/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [0.12.4-beta.1](https://github.com/mi-examples/pp-dev/compare/v0.12.3...v0.12.4-beta.1) (2026-01-14)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **plugin:** move topbar scripts injection to head-prepend ([a248f91](https://github.com/mi-examples/pp-dev/commit/a248f91b14817a36a37d56e9107762b514bf90ac))
7
+
1
8
  # [@metricinsights/pp-dev-v0.12.3-beta.1](https://github.com/mi-examples/pp-dev-js/compare/v0.12.2...v0.12.3-beta.1) (2025-12-19)
2
9
 
3
10
 
package/dist/cjs/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";const e=require("path"),o=require("fs"),t=require("node:perf_hooks"),n=require("chokidar"),i=require("cac"),r=require("vite"),s=require("./index-DJdZe-Ks.js"),a=require("./plugin-xN0M6WT7.js"),l=require("url"),c=require("dir-compare"),d=require("diff-match-patch"),p=require("isbinaryfile"),f=require("os"),h=require("crypto"),g=require("extract-zip"),u=require("svgtofont");function m(e){const o=Object.create(null);if(e)for(const t in e)if("default"!==t){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}return o.default=e,Object.freeze(o)}require("ejs"),require("http-proxy-middleware"),require("picocolors"),require("axios"),require("jsdom"),require("https"),require("memory-cache"),require("process"),require("child_process"),require("console"),require("zlib"),require("express");const b=m(e),w=m(o),v=m(c),y=m(f),x=m(h);function P(e){return null!=e&&!1!==e}const T=[{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 L=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class ${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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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:o,newAssetsPath:t,destinationPath:n,changelogTemplate:i,diffFileTemplateHandler:r,diffLineTemplateHandler:s,changelogFilename:l,contextLines:c}=e;if(this.logger=a.createLogger(),!o||!t||!n)throw new Error("Previous assets path, current assets path and destination path are required");if(o===t)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(t))throw new Error(`Current assets path ${t} does not exist`);if(this.isZipFile(o)){const e=b.resolve(y.tmpdir(),x.createHash("md5").update(o).digest("hex"));this.oldAssetsPath=this.unzipFile(o,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(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(t)){const e=b.resolve(y.tmpdir(),x.createHash("md5").update(t).digest("hex"));this.newAssetsPath=this.unzipFile(t,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(t))throw new Error(`Invalid current assets path ${t}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(t);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${t} 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(a.colors.yellow("Invalid changelog template, using default"))),"function"==typeof r&&(this.diffFileTemplateHandler=r),"function"==typeof s&&(this.diffLineTemplateHandler=s),c&&(this.contextLines=c)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return w.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return w.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===w.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){w.existsSync(e)||w.mkdirSync(e,{recursive:!0})}async unzipFile(e,o){return w.rmSync(o,{force:!0,recursive:!0}),g(e,{dir:o})}normalizeAssetFolderPath(e){const o=w.readdirSync(e);return 1===o.length&&w.lstatSync(b.join(e,o[0])).isDirectory()?this.normalizeAssetFolderPath(b.join(e,o[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 o=e.filter(((e,o,t)=>0!==e.lineType||(o>=0&&o<this.contextLines||o>t.length-(this.contextLines+1)&&o<=t.length-1||t.slice(o-this.contextLines,o+this.contextLines+1).some((e=>0!==e.lineType))))).map(((e,o,t)=>{if(o>0){const n=t[o-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(o)}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:o,lineContent:t,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="${o}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${o}"`:""}\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=t??"",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:o}=e;return-1===o?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,o){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,o):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${o}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(a.colors.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await v.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,o)=>(L.test(e)&&(e=e.replace(L,"$1$3")),L.test(o)&&(o=o.replace(L,"$1$3")),0===e.localeCompare(o)?0:e.localeCompare(o)>0?1:-1)});return e.diffSet?.filter((e=>"equal"!==e.state||e.name1!==e.name2))||[]}async generateAssetFilesDiff(e,o){const t=new d,n=t.diff_linesToChars_(e,o),i=t.diff_main(n.chars1,n.chars2,!1);t.diff_charsToLines_(i,n.lineArray);let r=0;return i.map((e=>{const[o,t]=e,n=t.endsWith("\n")?t.split("\n").length-1:t.split("\n").length,i=t.split("\n").map(((e,t)=>({lineContent:e,lineNumber:r+t+1,lineType:o}))).slice(0,n);return-1!==o&&(r+=n),i})).flat()}async generateFilesDiff(e){if("equal"===e.state){const o=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),t=this.pathToPosix(b.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${o}</span> -> <span class="to">${t}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const o=e.path1&&e.name1?b.join(e.path1,e.name1):null,t=e.path2&&e.name2?b.join(e.path2,e.name2):null,n=this.pathToPosix(b.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&o)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&t)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&o&&t){const i=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(b.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await p.isBinaryFile(o)||await p.isBinaryFile(t)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(w.readFileSync(o,"utf-8"),w.readFileSync(t,"utf-8"))))}return""}async generateChangelog(){this.logger.info(a.colors.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),o=(await Promise.all(e.map((e=>this.generateFilesDiff(e))))).join("");this.logger.info(a.colors.green("Writing changelog file"));const t=this.changelogTemplate.split("%FILES%");t.splice(1,0,o);const n=t.join("");w.writeFileSync(b.join(this.destinationPath,this.changelogFilename),n),this.logger.info(a.colors.green(`Changelog file written to ${b.join(this.destinationPath,this.changelogFilename)}`))}}class S{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await u({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const F=i.cac("pp-dev");function C(e,o,t){const i=[...s.PP_DEV_CONFIG_NAMES,...s.PP_WATCH_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((o=>b.join(e,o))),r=n.watch(i,{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let l=null;return r.on("change",(n=>{t(a.colors.blue(`🔧 Config file changed: ${b.relative(e,n)}`)),l&&clearTimeout(l),l=setTimeout((async()=>{try{t(a.colors.yellow("🔄 Restarting dev server due to config change...")),await o()}catch(e){t(a.colors.red(`❌ Failed to restart dev server: ${e}`))}}),500)})),r.on("error",(e=>{t(a.colors.red(`❌ Config watcher error: ${e}`))})),{watcher:r,restartCallback:o,logger:t}}function j(e){e.watcher&&e.watcher.close()}let E=global.__pp_dev_profile_session,A=0;const D=e=>{if(E)return new Promise(((o,t)=>{E.post("Profiler.stop",((n,{profile:i})=>{if(n)t(n);else{const t=b.resolve(`./pp-dev-profile-${A++}.cpuprofile`);w.writeFileSync(t,JSON.stringify(i)),e(a.colors.yellow(`CPU profile written to ${a.colors.white(a.colors.dim(t))}`)),E=void 0,o()}}))}))},I=e=>{for(const[o,t]of Object.entries(e))Array.isArray(t)&&(e[o]=t[t.length-1])};function N(e){const o={...e};return delete o["--"],delete o.c,delete o.config,delete o.base,delete o.l,delete o.logLevel,delete o.clearScreen,delete o.d,delete o.debug,delete o.f,delete o.filter,delete o.m,delete o.mode,o}F.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"),F.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,o)=>{I(o);let n=null,i=null,l=!1;const c=e?b.resolve(process.cwd(),e):process.cwd(),d=a.createLogger(o.logLevel),p=async()=>{if(!l){l=!0;try{n&&(d.info(a.colors.yellow("🛑 Stopping existing dev server...")),await n.close(),n=null);const{clearConfigCache:f}=await Promise.resolve().then((()=>require("./index-DJdZe-Ks.js"))).then((e=>e.config));f();const{createServer:h}=await import("vite"),g=await r.loadConfigFromFile({mode:o.mode||"development",command:"serve"},o.config,e,o.logLevel);let u=await s.getViteConfig();const m=r.loadEnv(o.mode||"development",e??process.cwd(),"");if(m&&Object.keys(m).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=m[e])})),g){const{plugins:e,...o}=g.config;u=r.mergeConfig(u,o)}if(n=await h(r.mergeConfig(u,{root:e,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},server:N(o),customLogger:d},!0)),!n.config.base||"/"===n.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!n.httpServer)throw new Error("HTTP server not available");await n.listen();const b=global.__pp_dev_start_time??!1,w=b?a.colors.dim(`ready in ${a.colors.reset(a.colors.bold(Math.ceil(t.performance.now()-b)))} ms`):"";d.info(`\n ${a.colors.green(`${a.colors.bold("PP-DEV")} v${s.VERSION}`)} ${w}\n`),n.printUrls(),function(e,o){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=o;const t=a.createLogger();o.print&&t.info(a.colors.dim(a.colors.green(" ➜"))+a.colors.dim(" press ")+a.colors.bold("h")+a.colors.dim(" to show help"));const n=(o.customShortcuts??[]).filter(P).concat(T);let i=!1;const r=async o=>{if(""===o||""===o)return void await e.close().finally((()=>process.exit(1)));if(i)return;"h"===o&&t.info(["",a.colors.bold(" Shortcuts"),...n.map((e=>a.colors.dim(" press ")+a.colors.bold(e.key)+a.colors.dim(` to ${e.description}`)))].join("\n"));const r=n.find((e=>e.key===o));r&&(i=!0,await r.action(e),i=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",r).setEncoding("utf8").resume(),e.httpServer.on("close",(()=>{process.stdin.off("data",r).pause()}))}(n,{print:!0,customShortcuts:[...E?[{key:"p",description:"start/stop the profiler",async action(e){if(E)await D(d.info);else{const e=await import("node:inspector").then((e=>e.default));await new Promise((o=>{E=new e.Session,E.connect(),E.post("Profiler.enable",(()=>{E?.post("Profiler.start",(()=>{d.info("Profiler started"),o()}))}))}))}}}]:[],{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),i||(i=C(c,p,d.info),d.info(a.colors.blue("🔧 Config file watcher started"))),l=!1}catch(e){l=!1,d.error(a.colors.red(`error when starting dev server:\n${e.stack}`),{error:e}),D(d.info),process.exit(1)}}},f=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{i&&(j(i),i=null),n&&(await n.close(),n=null),D(d.info),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.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(a.colors.red(`❌ Uncaught Exception: ${e}`)),f("uncaughtException")})),process.on("unhandledRejection",((e,o)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${o}, reason: ${e}`)),f("unhandledRejection")})),await p()})),F.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").action((async(e,o)=>{I(o);let t=null,n=null,i=null,c=!1;e?b.resolve(process.cwd(),e):process.cwd();const d=a.createLogger(),p=async()=>{if(!c){c=!0;try{n&&(d.info(a.colors.yellow("🛑 Stopping existing Next.js server...")),await new Promise((e=>{n.close((()=>{n=null,e()}))}))),t&&"function"==typeof t.close&&(await t.close(),t=null);const{clearConfigCache:f}=await Promise.resolve().then((()=>require("./index-DJdZe-Ks.js"))).then((e=>e.config));if(f(),!s.isNextAvailable())throw new Error("Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^13\n\nThis package requires Next.js >=13 <16 as a peer dependency.");const{next:h}=await s.safeNextImport(),{join:g,basename:u}=await import("path"),{createServer:m}=await import("http"),{default:b}=(await import("next/dist/server/config.js")).default,w=N(o),v=r.loadEnv(o.mode||"development",e??process.cwd(),"");v&&Object.keys(v).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=v[e])}));const y=e?g(process.cwd(),e):process.cwd();d.info(y);const x=await b("development",y);let P=x?.experimental?.ppDev||x?.ppDev||{};if(0===Object.keys(P).length)try{const{getConfig:e}=await Promise.resolve().then((()=>require("./index-DJdZe-Ks.js"))).then((e=>e.config)),o=await e();Object.keys(o).length>0?(P=o,d.info(a.colors.blue("🔧 Loaded pp-dev config from standalone config file"))):d.info(a.colors.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){d.info(a.colors.yellow("⚠️ Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else d.info(a.colors.blue("🔧 Loaded pp-dev config from Next.js config"));const{backendBaseURL:T=process.env.MI_BACKEND_URL||"http://localhost:8080",portalPageId:L=parseInt(process.env.MI_PORTAL_PAGE_ID||"1"),templateLess:$=!0,v7Features:S=!0,disableSSLValidation:F=!1,enableProxyCache:E=!0,proxyCacheTTL:A=6e5,personalAccessToken:D=process.env.MI_ACCESS_TOKEN,distZip:I=!1,syncBackupsDir:k="./backups",miHudLess:_=!1}=P;let q=P.templateName;if(!q)try{const{getPkg:e}=await Promise.resolve().then((()=>require("./index-DJdZe-Ks.js"))).then((e=>e.config));q=e().name}catch(e){q=u(y)}let R=$?"/p":"/pl";if(R+=`/${q}`,t=h({dev:!0,hostname:w.host||"localhost",port:w.port,dir:y,conf:{...x,basePath:R,assetPrefix:R}}),await t.prepare(),R.endsWith("/")||(R+="/"),"/"===R)throw new Error('basePath cannot be equal to "/" or equal to empty string');R.substring(0,R.lastIndexOf("/"));d.info(a.colors.green("✅ Next.js app prepared successfully")),d.info(a.colors.blue(`🔧 pp-dev plugin configured for template: ${q}`)),d.info(a.colors.blue(`🔧 Base path configured: ${R}`)),T&&(d.info(a.colors.blue(`🌐 Backend URL: ${T}`)),d.info(a.colors.blue(`🆔 Portal Page ID: ${L}`)));const M=t.getRequestHandler(),z="number"==typeof w.port?w.port:3e3,G="string"==typeof w.host?w.host||"0.0.0.0":"localhost",H=new Set;n=m((async(e,o)=>{try{const t=e.url||"/",n=t.split("?")[0];let i=l.parse(t,!0);if(U.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")||n.startsWith("/api/")){if(W.length>0){let c=0;const d=()=>{if(c>=W.length)return void r();const t=W[c];c++,t(e,o,d)};return void d()}return void r()}let s=0;const a=()=>{if(s>=U.length)return void r();const t=U[s];s++,t(e,o,a)};return void a()}async function r(){if(n.startsWith(R)){const o=n.substring(R.length);e.url=o||"/",i=l.parse(o,!0)}else if(n===R.replace(/\/$/,""))e.url="/",i=l.parse("/",!0);else if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return o.writeHead(302,{Location:R}),void o.end();await M(e,o,i)}r()}catch(p){console.error("[DEBUG] Error:",p),o.statusCode=500,o.end("Internal Server Error")}}));let O=null,U=[],W=[];if(T){const e=new URL(T).host,o={headers:{host:e,referer:T,origin:T.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},portalPageId:L,appId:L,templateLess:$,disableSSLValidation:F,v7Features:S,personalAccessToken:D??process.env.MI_ACCESS_TOKEN};O=new a.MiAPI(T,o);const t=a.initPPRedirect(R,q),n=(e,o,n)=>{t(e,o,n)};if(W.push(n),U.push(n),E){let e=+A;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const o={devServer:{middlewares:{use:e=>e},config:{logger:console}},ttl:e},t=a.initProxyCache(o),n=(e,o,n)=>{t(e,o,n)};U.push(n),d.info(a.colors.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const i=R.endsWith("/")?R.substring(0,R.length-1):R,r={middlewares:{use:e=>e},config:{logger:console}},s=a.initProxy({devServer:r,baseURL:T,proxyIgnore:["/@vite","/@metricinsights","/@",i,"/_next","/favicon.ico","/__nextjs_","/api"],disableSSLValidation:F,miAPI:O}),l=(e,o,t)=>{s(e,o,t)};U.push(l);const c=new RegExp(`^((${R})|/)$`),p=a.initLoadPPData(c,O,{base:R,v7Features:S}),f=(e,o,t)=>{p(e,o,t)};U.push(f);const h=a.internalServer,g=(e,o,t)=>{if(e.url?.startsWith("/@api/")){h(e,o,(()=>{}))}else t()};W.push(g),U.push(g);const u=a.initRewriteResponse((e=>e.split("?")[0].endsWith("index.html")),((o,t)=>Buffer.from(a.urlReplacer(e,t.headers.host??"",O.buildPage(o,_))))),m=(e,o,t)=>{u(e,o,t)};U.push(m),d.info(a.colors.blue(`🔧 ${U.length} pp-dev middlewares initialized`)),d.info(a.colors.blue(`🔧 ${W.length} essential middlewares for internal routes`)),d.info(a.colors.blue(`🔧 MiAPI initialized for backend: ${T}`)),d.info(a.colors.blue(`🔧 Portal Page ID: ${L}`))}n.listen(z,G,(()=>{d.info(a.colors.green(`✅ pp-dev Next.js server running at http://${G}:${z}`)),d.info(a.colors.blue(`📱 Next.js app accessible at http://${G}:${z}${R}`)),d.info(a.colors.blue("🔧 Base path handling active")),i||(i=C(y,p,d.info),d.info(a.colors.blue("🔧 Config file watcher started"))),n.on("connection",(e=>{H.add(e),e.on("close",(()=>H.delete(e)))}));const e=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));const o=setTimeout((()=>{d.info(a.colors.yellow("⏰ Shutdown timeout reached, forcing exit")),process.exit(0)}),5e3);try{i&&(j(i),i=null);for(const e of Array.from(H))e.destroy();H.clear(),await new Promise((e=>{n.close((()=>{d.info(a.colors.yellow("🛑 HTTP server closed")),e()}))})),t&&"function"==typeof t.close&&(await t.close(),d.info(a.colors.yellow("🛑 Next.js app closed"))),clearTimeout(o),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(o),d.error(a.colors.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};let o=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(o=e,d.info(a.colors.green("✅ Using global process object for event handlers")))}if("function"==typeof o.on)try{o.on("SIGINT",(()=>e("SIGINT"))),o.on("SIGTERM",(()=>e("SIGTERM"))),o.on("uncaughtException",(o=>{d.error(a.colors.red(`❌ Uncaught Exception: ${o}`)),e("uncaughtException")})),o.on("unhandledRejection",((o,t)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${t}, reason: ${o}`)),e("unhandledRejection")})),d.info(a.colors.green("✅ Process event handlers registered successfully"))}catch(e){d.warn(a.colors.yellow(`⚠️ Failed to register process event handlers: ${e}`))}else d.warn(a.colors.yellow("⚠️ process.on is not available, graceful shutdown handlers will not be registered")),d.info(a.colors.blue("💡 This might be due to bundling or environment constraints"))})),c=!1}catch(e){c=!1,d.error(a.colors.red(`❌ Failed to start Next.js server: ${e}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(d.error(a.colors.red("❌ Next.js Peer Dependency Error:")),d.error(a.colors.red(e.message)),d.error(a.colors.yellow("\n💡 To fix this issue:")),d.error(a.colors.blue(" 1. Install Next.js in your project:")),d.error(a.colors.white(" npm install next@^15")),d.error(a.colors.blue(" 2. Or use yarn:")),d.error(a.colors.white(" yarn add next@^15")),d.error(a.colors.blue(" 3. Or use pnpm:")),d.error(a.colors.white(" pnpm add next@^15")),d.error(a.colors.yellow("\n📖 For more information, see:")),d.error(a.colors.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}},f=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{i&&(j(i),i=null),n&&await new Promise((e=>{n.close((()=>{n=null,e()}))})),t&&"function"==typeof t.close&&(await t.close(),t=null),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.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(a.colors.red(`❌ Uncaught Exception: ${e}`)),f("uncaughtException")})),process.on("unhandledRejection",((e,o)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${o}, reason: ${e}`)),f("unhandledRejection")})),await p()})),F.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)").action((async(e,o)=>{I(o);const t=N(o);try{const n=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let i=await s.getViteConfig();if(n){const{plugins:e,...o}=n.config;i=r.mergeConfig(i,o)}const l=r.mergeConfig(i,{root:e,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},build:t},!0);if(await r.build(l),t.changelog){const n=e||process.cwd(),i=l.build?.outDir||"dist";let r="";if("string"==typeof t.changelog)r=b.resolve(n,t.changelog);else{const e=b.resolve(n,l.ppDevConfig?.syncBackupsDir||"backups");if(!w.existsSync(e))return void a.createLogger(o.logLevel).warn(a.colors.yellow("backups directory not found, skipping changelog generation"));const t=w.readdirSync(e,{withFileTypes:!0});if(!t.length)return void a.createLogger(o.logLevel).warn(a.colors.yellow("no backups found, skipping changelog generation"));const i=t.filter((e=>e.isFile()&&e.name.endsWith(".zip"))).reduce(((o,t)=>w.statSync(b.resolve(e,o.name)).mtimeMs>w.statSync(b.resolve(e,t.name)).mtimeMs?o:t),t[0]).name;r=b.resolve(e,i)}const s=b.resolve(n,i);let c="dist-zip";l.ppDevConfig&&(!1===l.ppDevConfig.distZip?c=l.build?.outDir||"dist":"object"==typeof l.ppDevConfig.distZip&&"string"==typeof l.ppDevConfig.distZip.outDir&&(c=l.ppDevConfig.distZip.outDir));const d=new $({oldAssetsPath:r,newAssetsPath:s,destinationPath:b.resolve(n,c)});await d.generateChangelog()}}catch(e){a.createLogger(o.logLevel).error(a.colors.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{D((e=>a.createLogger(o.logLevel).info(e)))}})),F.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,o,t)=>{I(t);const{oldAssetsPath:n=e,newAssetsPath:i=o,destination:r=".",filename:s="CHANGELOG.html",logLevel:l}=t,c=process.cwd();n&&i||(a.createLogger(l).error(a.colors.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=b.resolve(c,n),p=b.resolve(c,i),f=b.resolve(c,r),h=new $({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:s});await h.generateChangelog()})),F.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,o,t)=>{I(t);const{source:n=e,destination:i=o,fontName:r="icon-font"}=t,s=process.cwd(),l=b.resolve(s,n),c=b.resolve(s,i),d=new S({sourceDir:l,outputDir:c,fontName:r}),p=a.createLogger(t.logLevel);p.info(`Generating icon font from SVG files in ${a.colors.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${a.colors.dim(c)}`)})),F.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action((async(e,o)=>{I(o);try{const t=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let n=await s.getViteConfig();if(t){const{plugins:e,...o}=t.config;n=r.mergeConfig(n,o)}const i=await r.resolveConfig(r.mergeConfig(n,{root:e,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode}),"serve");await r.optimizeDeps(i,o.force,!0)}catch(e){a.createLogger(o.logLevel).error(a.colors.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})),F.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,o)=>{I(o);try{const t=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let n=await s.getViteConfig();if(t){const{plugins:e,...o}=t.config;n=r.mergeConfig(n,o)}(await r.preview(r.mergeConfig(n,{root:e,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){a.createLogger(o.logLevel).error(a.colors.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{D((e=>a.createLogger(o.logLevel).info(e)))}})),F.help(),F.version(s.VERSION),F.parse(),exports.stopProfiler=D;
1
+ "use strict";const e=require("path"),o=require("fs"),t=require("node:perf_hooks"),n=require("chokidar"),i=require("cac"),r=require("vite"),s=require("./index-1BlQDvLy.js"),a=require("./plugin-xN0M6WT7.js"),l=require("url"),c=require("dir-compare"),d=require("diff-match-patch"),p=require("isbinaryfile"),f=require("os"),h=require("crypto"),g=require("extract-zip"),u=require("svgtofont");function m(e){const o=Object.create(null);if(e)for(const t in e)if("default"!==t){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}return o.default=e,Object.freeze(o)}require("ejs"),require("http-proxy-middleware"),require("picocolors"),require("axios"),require("jsdom"),require("https"),require("memory-cache"),require("process"),require("child_process"),require("console"),require("zlib"),require("express");const b=m(e),w=m(o),v=m(c),y=m(f),x=m(h);function P(e){return null!=e&&!1!==e}const T=[{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 L=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class ${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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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:o,newAssetsPath:t,destinationPath:n,changelogTemplate:i,diffFileTemplateHandler:r,diffLineTemplateHandler:s,changelogFilename:l,contextLines:c}=e;if(this.logger=a.createLogger(),!o||!t||!n)throw new Error("Previous assets path, current assets path and destination path are required");if(o===t)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(t))throw new Error(`Current assets path ${t} does not exist`);if(this.isZipFile(o)){const e=b.resolve(y.tmpdir(),x.createHash("md5").update(o).digest("hex"));this.oldAssetsPath=this.unzipFile(o,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(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(t)){const e=b.resolve(y.tmpdir(),x.createHash("md5").update(t).digest("hex"));this.newAssetsPath=this.unzipFile(t,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(t))throw new Error(`Invalid current assets path ${t}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(t);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${t} 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(a.colors.yellow("Invalid changelog template, using default"))),"function"==typeof r&&(this.diffFileTemplateHandler=r),"function"==typeof s&&(this.diffLineTemplateHandler=s),c&&(this.contextLines=c)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return w.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return w.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===w.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){w.existsSync(e)||w.mkdirSync(e,{recursive:!0})}async unzipFile(e,o){return w.rmSync(o,{force:!0,recursive:!0}),g(e,{dir:o})}normalizeAssetFolderPath(e){const o=w.readdirSync(e);return 1===o.length&&w.lstatSync(b.join(e,o[0])).isDirectory()?this.normalizeAssetFolderPath(b.join(e,o[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 o=e.filter(((e,o,t)=>0!==e.lineType||(o>=0&&o<this.contextLines||o>t.length-(this.contextLines+1)&&o<=t.length-1||t.slice(o-this.contextLines,o+this.contextLines+1).some((e=>0!==e.lineType))))).map(((e,o,t)=>{if(o>0){const n=t[o-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(o)}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:o,lineContent:t,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="${o}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${o}"`:""}\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=t??"",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:o}=e;return-1===o?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,o){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,o):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${o}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(a.colors.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await v.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,o)=>(L.test(e)&&(e=e.replace(L,"$1$3")),L.test(o)&&(o=o.replace(L,"$1$3")),0===e.localeCompare(o)?0:e.localeCompare(o)>0?1:-1)});return e.diffSet?.filter((e=>"equal"!==e.state||e.name1!==e.name2))||[]}async generateAssetFilesDiff(e,o){const t=new d,n=t.diff_linesToChars_(e,o),i=t.diff_main(n.chars1,n.chars2,!1);t.diff_charsToLines_(i,n.lineArray);let r=0;return i.map((e=>{const[o,t]=e,n=t.endsWith("\n")?t.split("\n").length-1:t.split("\n").length,i=t.split("\n").map(((e,t)=>({lineContent:e,lineNumber:r+t+1,lineType:o}))).slice(0,n);return-1!==o&&(r+=n),i})).flat()}async generateFilesDiff(e){if("equal"===e.state){const o=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),t=this.pathToPosix(b.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${o}</span> -> <span class="to">${t}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const o=e.path1&&e.name1?b.join(e.path1,e.name1):null,t=e.path2&&e.name2?b.join(e.path2,e.name2):null,n=this.pathToPosix(b.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&o)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&t)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&o&&t){const i=this.pathToPosix(b.join(".",e.relativePath,e.name1??"")),r=this.pathToPosix(b.join(".",e.relativePath,e.name2??"")),s=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${r}</span></span\n >`:n;return this.diffFileTemplate(s,await p.isBinaryFile(o)||await p.isBinaryFile(t)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(w.readFileSync(o,"utf-8"),w.readFileSync(t,"utf-8"))))}return""}async generateChangelog(){this.logger.info(a.colors.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),o=(await Promise.all(e.map((e=>this.generateFilesDiff(e))))).join("");this.logger.info(a.colors.green("Writing changelog file"));const t=this.changelogTemplate.split("%FILES%");t.splice(1,0,o);const n=t.join("");w.writeFileSync(b.join(this.destinationPath,this.changelogFilename),n),this.logger.info(a.colors.green(`Changelog file written to ${b.join(this.destinationPath,this.changelogFilename)}`))}}class S{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await u({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const F=i.cac("pp-dev");function C(e,o,t){const i=[...s.PP_DEV_CONFIG_NAMES,...s.PP_WATCH_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((o=>b.join(e,o))),r=n.watch(i,{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let l=null;return r.on("change",(n=>{t(a.colors.blue(`🔧 Config file changed: ${b.relative(e,n)}`)),l&&clearTimeout(l),l=setTimeout((async()=>{try{t(a.colors.yellow("🔄 Restarting dev server due to config change...")),await o()}catch(e){t(a.colors.red(`❌ Failed to restart dev server: ${e}`))}}),500)})),r.on("error",(e=>{t(a.colors.red(`❌ Config watcher error: ${e}`))})),{watcher:r,restartCallback:o,logger:t}}function j(e){e.watcher&&e.watcher.close()}let E=global.__pp_dev_profile_session,A=0;const D=e=>{if(E)return new Promise(((o,t)=>{E.post("Profiler.stop",((n,{profile:i})=>{if(n)t(n);else{const t=b.resolve(`./pp-dev-profile-${A++}.cpuprofile`);w.writeFileSync(t,JSON.stringify(i)),e(a.colors.yellow(`CPU profile written to ${a.colors.white(a.colors.dim(t))}`)),E=void 0,o()}}))}))},I=e=>{for(const[o,t]of Object.entries(e))Array.isArray(t)&&(e[o]=t[t.length-1])};function N(e){const o={...e};return delete o["--"],delete o.c,delete o.config,delete o.base,delete o.l,delete o.logLevel,delete o.clearScreen,delete o.d,delete o.debug,delete o.f,delete o.filter,delete o.m,delete o.mode,o}F.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"),F.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,o)=>{I(o);let n=null,i=null,l=!1;const c=e?b.resolve(process.cwd(),e):process.cwd(),d=a.createLogger(o.logLevel),p=async()=>{if(!l){l=!0;try{n&&(d.info(a.colors.yellow("🛑 Stopping existing dev server...")),await n.close(),n=null);const{clearConfigCache:f}=await Promise.resolve().then((()=>require("./index-1BlQDvLy.js"))).then((e=>e.config));f();const{createServer:h}=await import("vite"),g=await r.loadConfigFromFile({mode:o.mode||"development",command:"serve"},o.config,e,o.logLevel);let u=await s.getViteConfig();const m=r.loadEnv(o.mode||"development",e??process.cwd(),"");if(m&&Object.keys(m).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=m[e])})),g){const{plugins:e,...o}=g.config;u=r.mergeConfig(u,o)}if(n=await h(r.mergeConfig(u,{root:e,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},server:N(o),customLogger:d},!0)),!n.config.base||"/"===n.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!n.httpServer)throw new Error("HTTP server not available");await n.listen();const b=global.__pp_dev_start_time??!1,w=b?a.colors.dim(`ready in ${a.colors.reset(a.colors.bold(Math.ceil(t.performance.now()-b)))} ms`):"";d.info(`\n ${a.colors.green(`${a.colors.bold("PP-DEV")} v${s.VERSION}`)} ${w}\n`),n.printUrls(),function(e,o){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=o;const t=a.createLogger();o.print&&t.info(a.colors.dim(a.colors.green(" ➜"))+a.colors.dim(" press ")+a.colors.bold("h")+a.colors.dim(" to show help"));const n=(o.customShortcuts??[]).filter(P).concat(T);let i=!1;const r=async o=>{if(""===o||""===o)return void await e.close().finally((()=>process.exit(1)));if(i)return;"h"===o&&t.info(["",a.colors.bold(" Shortcuts"),...n.map((e=>a.colors.dim(" press ")+a.colors.bold(e.key)+a.colors.dim(` to ${e.description}`)))].join("\n"));const r=n.find((e=>e.key===o));r&&(i=!0,await r.action(e),i=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",r).setEncoding("utf8").resume(),e.httpServer.on("close",(()=>{process.stdin.off("data",r).pause()}))}(n,{print:!0,customShortcuts:[...E?[{key:"p",description:"start/stop the profiler",async action(e){if(E)await D(d.info);else{const e=await import("node:inspector").then((e=>e.default));await new Promise((o=>{E=new e.Session,E.connect(),E.post("Profiler.enable",(()=>{E?.post("Profiler.start",(()=>{d.info("Profiler started"),o()}))}))}))}}}]:[],{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),i||(i=C(c,p,d.info),d.info(a.colors.blue("🔧 Config file watcher started"))),l=!1}catch(e){l=!1,d.error(a.colors.red(`error when starting dev server:\n${e.stack}`),{error:e}),D(d.info),process.exit(1)}}},f=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{i&&(j(i),i=null),n&&(await n.close(),n=null),D(d.info),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.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(a.colors.red(`❌ Uncaught Exception: ${e}`)),f("uncaughtException")})),process.on("unhandledRejection",((e,o)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${o}, reason: ${e}`)),f("unhandledRejection")})),await p()})),F.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").action((async(e,o)=>{I(o);let t=null,n=null,i=null,c=!1;e?b.resolve(process.cwd(),e):process.cwd();const d=a.createLogger(),p=async()=>{if(!c){c=!0;try{n&&(d.info(a.colors.yellow("🛑 Stopping existing Next.js server...")),await new Promise((e=>{n.close((()=>{n=null,e()}))}))),t&&"function"==typeof t.close&&(await t.close(),t=null);const{clearConfigCache:f}=await Promise.resolve().then((()=>require("./index-1BlQDvLy.js"))).then((e=>e.config));if(f(),!s.isNextAvailable())throw new Error("Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^13\n\nThis package requires Next.js >=13 <16 as a peer dependency.");const{next:h}=await s.safeNextImport(),{join:g,basename:u}=await import("path"),{createServer:m}=await import("http"),{default:b}=(await import("next/dist/server/config.js")).default,w=N(o),v=r.loadEnv(o.mode||"development",e??process.cwd(),"");v&&Object.keys(v).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=v[e])}));const y=e?g(process.cwd(),e):process.cwd();d.info(y);const x=await b("development",y);let P=x?.experimental?.ppDev||x?.ppDev||{};if(0===Object.keys(P).length)try{const{getConfig:e}=await Promise.resolve().then((()=>require("./index-1BlQDvLy.js"))).then((e=>e.config)),o=await e();Object.keys(o).length>0?(P=o,d.info(a.colors.blue("🔧 Loaded pp-dev config from standalone config file"))):d.info(a.colors.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){d.info(a.colors.yellow("⚠️ Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else d.info(a.colors.blue("🔧 Loaded pp-dev config from Next.js config"));const{backendBaseURL:T=process.env.MI_BACKEND_URL||"http://localhost:8080",portalPageId:L=parseInt(process.env.MI_PORTAL_PAGE_ID||"1"),templateLess:$=!0,v7Features:S=!0,disableSSLValidation:F=!1,enableProxyCache:E=!0,proxyCacheTTL:A=6e5,personalAccessToken:D=process.env.MI_ACCESS_TOKEN,distZip:I=!1,syncBackupsDir:k="./backups",miHudLess:_=!1}=P;let q=P.templateName;if(!q)try{const{getPkg:e}=await Promise.resolve().then((()=>require("./index-1BlQDvLy.js"))).then((e=>e.config));q=e().name}catch(e){q=u(y)}let R=$?"/p":"/pl";if(R+=`/${q}`,t=h({dev:!0,hostname:w.host||"localhost",port:w.port,dir:y,conf:{...x,basePath:R,assetPrefix:R}}),await t.prepare(),R.endsWith("/")||(R+="/"),"/"===R)throw new Error('basePath cannot be equal to "/" or equal to empty string');R.substring(0,R.lastIndexOf("/"));d.info(a.colors.green("✅ Next.js app prepared successfully")),d.info(a.colors.blue(`🔧 pp-dev plugin configured for template: ${q}`)),d.info(a.colors.blue(`🔧 Base path configured: ${R}`)),T&&(d.info(a.colors.blue(`🌐 Backend URL: ${T}`)),d.info(a.colors.blue(`🆔 Portal Page ID: ${L}`)));const M=t.getRequestHandler(),z="number"==typeof w.port?w.port:3e3,G="string"==typeof w.host?w.host||"0.0.0.0":"localhost",H=new Set;n=m((async(e,o)=>{try{const t=e.url||"/",n=t.split("?")[0];let i=l.parse(t,!0);if(U.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")||n.startsWith("/api/")){if(W.length>0){let c=0;const d=()=>{if(c>=W.length)return void r();const t=W[c];c++,t(e,o,d)};return void d()}return void r()}let s=0;const a=()=>{if(s>=U.length)return void r();const t=U[s];s++,t(e,o,a)};return void a()}async function r(){if(n.startsWith(R)){const o=n.substring(R.length);e.url=o||"/",i=l.parse(o,!0)}else if(n===R.replace(/\/$/,""))e.url="/",i=l.parse("/",!0);else if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return o.writeHead(302,{Location:R}),void o.end();await M(e,o,i)}r()}catch(p){console.error("[DEBUG] Error:",p),o.statusCode=500,o.end("Internal Server Error")}}));let O=null,U=[],W=[];if(T){const e=new URL(T).host,o={headers:{host:e,referer:T,origin:T.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},portalPageId:L,appId:L,templateLess:$,disableSSLValidation:F,v7Features:S,personalAccessToken:D??process.env.MI_ACCESS_TOKEN};O=new a.MiAPI(T,o);const t=a.initPPRedirect(R,q),n=(e,o,n)=>{t(e,o,n)};if(W.push(n),U.push(n),E){let e=+A;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const o={devServer:{middlewares:{use:e=>e},config:{logger:console}},ttl:e},t=a.initProxyCache(o),n=(e,o,n)=>{t(e,o,n)};U.push(n),d.info(a.colors.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const i=R.endsWith("/")?R.substring(0,R.length-1):R,r={middlewares:{use:e=>e},config:{logger:console}},s=a.initProxy({devServer:r,baseURL:T,proxyIgnore:["/@vite","/@metricinsights","/@",i,"/_next","/favicon.ico","/__nextjs_","/api"],disableSSLValidation:F,miAPI:O}),l=(e,o,t)=>{s(e,o,t)};U.push(l);const c=new RegExp(`^((${R})|/)$`),p=a.initLoadPPData(c,O,{base:R,v7Features:S}),f=(e,o,t)=>{p(e,o,t)};U.push(f);const h=a.internalServer,g=(e,o,t)=>{if(e.url?.startsWith("/@api/")){h(e,o,(()=>{}))}else t()};W.push(g),U.push(g);const u=a.initRewriteResponse((e=>e.split("?")[0].endsWith("index.html")),((o,t)=>Buffer.from(a.urlReplacer(e,t.headers.host??"",O.buildPage(o,_))))),m=(e,o,t)=>{u(e,o,t)};U.push(m),d.info(a.colors.blue(`🔧 ${U.length} pp-dev middlewares initialized`)),d.info(a.colors.blue(`🔧 ${W.length} essential middlewares for internal routes`)),d.info(a.colors.blue(`🔧 MiAPI initialized for backend: ${T}`)),d.info(a.colors.blue(`🔧 Portal Page ID: ${L}`))}n.listen(z,G,(()=>{d.info(a.colors.green(`✅ pp-dev Next.js server running at http://${G}:${z}`)),d.info(a.colors.blue(`📱 Next.js app accessible at http://${G}:${z}${R}`)),d.info(a.colors.blue("🔧 Base path handling active")),i||(i=C(y,p,d.info),d.info(a.colors.blue("🔧 Config file watcher started"))),n.on("connection",(e=>{H.add(e),e.on("close",(()=>H.delete(e)))}));const e=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));const o=setTimeout((()=>{d.info(a.colors.yellow("⏰ Shutdown timeout reached, forcing exit")),process.exit(0)}),5e3);try{i&&(j(i),i=null);for(const e of Array.from(H))e.destroy();H.clear(),await new Promise((e=>{n.close((()=>{d.info(a.colors.yellow("🛑 HTTP server closed")),e()}))})),t&&"function"==typeof t.close&&(await t.close(),d.info(a.colors.yellow("🛑 Next.js app closed"))),clearTimeout(o),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(o),d.error(a.colors.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};let o=process;if("function"!=typeof process.on){const e=globalThis.process||global.process;e&&"function"==typeof e.on&&(o=e,d.info(a.colors.green("✅ Using global process object for event handlers")))}if("function"==typeof o.on)try{o.on("SIGINT",(()=>e("SIGINT"))),o.on("SIGTERM",(()=>e("SIGTERM"))),o.on("uncaughtException",(o=>{d.error(a.colors.red(`❌ Uncaught Exception: ${o}`)),e("uncaughtException")})),o.on("unhandledRejection",((o,t)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${t}, reason: ${o}`)),e("unhandledRejection")})),d.info(a.colors.green("✅ Process event handlers registered successfully"))}catch(e){d.warn(a.colors.yellow(`⚠️ Failed to register process event handlers: ${e}`))}else d.warn(a.colors.yellow("⚠️ process.on is not available, graceful shutdown handlers will not be registered")),d.info(a.colors.blue("💡 This might be due to bundling or environment constraints"))})),c=!1}catch(e){c=!1,d.error(a.colors.red(`❌ Failed to start Next.js server: ${e}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(d.error(a.colors.red("❌ Next.js Peer Dependency Error:")),d.error(a.colors.red(e.message)),d.error(a.colors.yellow("\n💡 To fix this issue:")),d.error(a.colors.blue(" 1. Install Next.js in your project:")),d.error(a.colors.white(" npm install next@^15")),d.error(a.colors.blue(" 2. Or use yarn:")),d.error(a.colors.white(" yarn add next@^15")),d.error(a.colors.blue(" 3. Or use pnpm:")),d.error(a.colors.white(" pnpm add next@^15")),d.error(a.colors.yellow("\n📖 For more information, see:")),d.error(a.colors.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}},f=async e=>{d.info(a.colors.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{i&&(j(i),i=null),n&&await new Promise((e=>{n.close((()=>{n=null,e()}))})),t&&"function"==typeof t.close&&(await t.close(),t=null),d.info(a.colors.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(a.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(a.colors.red(`❌ Uncaught Exception: ${e}`)),f("uncaughtException")})),process.on("unhandledRejection",((e,o)=>{d.error(a.colors.red(`❌ Unhandled Rejection at: ${o}, reason: ${e}`)),f("unhandledRejection")})),await p()})),F.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)").action((async(e,o)=>{I(o);const t=N(o);try{const n=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let i=await s.getViteConfig();if(n){const{plugins:e,...o}=n.config;i=r.mergeConfig(i,o)}const l=r.mergeConfig(i,{root:e,base:o.base,mode:o.mode,configFile:o.config,logLevel:o.logLevel,clearScreen:o.clearScreen,optimizeDeps:{force:o.force},build:t},!0);if(await r.build(l),t.changelog){const n=e||process.cwd(),i=l.build?.outDir||"dist";let r="";if("string"==typeof t.changelog)r=b.resolve(n,t.changelog);else{const e=b.resolve(n,l.ppDevConfig?.syncBackupsDir||"backups");if(!w.existsSync(e))return void a.createLogger(o.logLevel).warn(a.colors.yellow("backups directory not found, skipping changelog generation"));const t=w.readdirSync(e,{withFileTypes:!0});if(!t.length)return void a.createLogger(o.logLevel).warn(a.colors.yellow("no backups found, skipping changelog generation"));const i=t.filter((e=>e.isFile()&&e.name.endsWith(".zip"))).reduce(((o,t)=>w.statSync(b.resolve(e,o.name)).mtimeMs>w.statSync(b.resolve(e,t.name)).mtimeMs?o:t),t[0]).name;r=b.resolve(e,i)}const s=b.resolve(n,i);let c="dist-zip";l.ppDevConfig&&(!1===l.ppDevConfig.distZip?c=l.build?.outDir||"dist":"object"==typeof l.ppDevConfig.distZip&&"string"==typeof l.ppDevConfig.distZip.outDir&&(c=l.ppDevConfig.distZip.outDir));const d=new $({oldAssetsPath:r,newAssetsPath:s,destinationPath:b.resolve(n,c)});await d.generateChangelog()}}catch(e){a.createLogger(o.logLevel).error(a.colors.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{D((e=>a.createLogger(o.logLevel).info(e)))}})),F.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,o,t)=>{I(t);const{oldAssetsPath:n=e,newAssetsPath:i=o,destination:r=".",filename:s="CHANGELOG.html",logLevel:l}=t,c=process.cwd();n&&i||(a.createLogger(l).error(a.colors.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=b.resolve(c,n),p=b.resolve(c,i),f=b.resolve(c,r),h=new $({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:s});await h.generateChangelog()})),F.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,o,t)=>{I(t);const{source:n=e,destination:i=o,fontName:r="icon-font"}=t,s=process.cwd(),l=b.resolve(s,n),c=b.resolve(s,i),d=new S({sourceDir:l,outputDir:c,fontName:r}),p=a.createLogger(t.logLevel);p.info(`Generating icon font from SVG files in ${a.colors.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${a.colors.dim(c)}`)})),F.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action((async(e,o)=>{I(o);try{const t=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let n=await s.getViteConfig();if(t){const{plugins:e,...o}=t.config;n=r.mergeConfig(n,o)}const i=await r.resolveConfig(r.mergeConfig(n,{root:e,base:o.base,configFile:o.config,logLevel:o.logLevel,mode:o.mode}),"serve");await r.optimizeDeps(i,o.force,!0)}catch(e){a.createLogger(o.logLevel).error(a.colors.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})),F.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,o)=>{I(o);try{const t=await r.loadConfigFromFile({mode:o.mode||"production",command:"build"},o.config,e,o.logLevel);let n=await s.getViteConfig();if(t){const{plugins:e,...o}=t.config;n=r.mergeConfig(n,o)}(await r.preview(r.mergeConfig(n,{root:e,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){a.createLogger(o.logLevel).error(a.colors.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{D((e=>a.createLogger(o.logLevel).info(e)))}})),F.help(),F.version(s.VERSION),F.parse(),exports.stopProfiler=D;
2
2
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- "use strict";const e=require("./plugin-xN0M6WT7.js"),t=require("fs"),n=require("path"),i=require("url"),s=require("vite"),a=require("ejs");var r="undefined"!=typeof document?document.currentScript:null;function o(e){const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const c=o(t),p=o(n),l=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-DJdZe-Ks.js",document.baseURI).href),"../../.."),u=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-DJdZe-Ks.js",document.baseURI).href),"../.."),f=t.existsSync(n.resolve(l,"package.json"))?l:u,m=n.resolve(f,"dist/client/client.js"),{version:d,name:g}=JSON.parse(t.readFileSync(n.resolve(f,"package.json")).toString()),h=d,v=g,j=[".pp-watch.config.js",".pp-watch.config.ts",".pp-watch.config.json"],y=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"];const w=new class{cache=new Map;_maxSize;constructor(e=10){this._maxSize=e}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=e}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this._maxSize){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}clear(){this.cache.clear()}has(e){return this.cache.has(e)}}(5),x=new Map,b=p.dirname("undefined"!=typeof __filename&&__filename||i.fileURLToPath(new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-DJdZe-Ks.js",document.baseURI).href))),P=`/${v}/client`,S=`/${P}`,_=new RegExp(`^\\/?${v}\\/client\\/(.*)$`);const R={templateCompilations:0,cacheHits:0,totalRequests:0};function D(e){let t="",n=!1,i=null;return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${v}/client`),e),resolveId(e){if(_.test(e))return{id:s.normalizePath(p.join(f,"dist/client",e.replace(_,"$1")))}},transformIndexHtml:async(e,s)=>{R.totalRequests++;const r=s.server?.config.base||"";r!==t&&(t=r,n=!0,i=null),i&&!n||(w.has(t)?(i=w.get(t),R.cacheHits++):(i=function(e,t=!0){const n=e;if(t&&w.has(n))return w.get(n);const i=p.resolve(b,"client","index.html");let s;x.has(i)?s=x.get(i):(s=c.readFileSync(i,{encoding:"utf8"}),x.set(i,s));const r=S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=a.compile(s.replace(new RegExp(r,"g"),p.posix.join(e,P)),{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:i,rmWhitespace:!0,compileDebug:!1});return t&&w.set(n,o),o}(t,true),R.templateCompilations++),n=!1);const o=function(e){return{css:p.posix.join(e,v,"client/client.css"),js:p.posix.join(e,v,"client/client.js")}}(t),l={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:o.css}}]},{backendBaseURL:u,templateLess:f,portalPageId:m,canSync:d=!0}=s.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:v,VERSION:h,backendBaseURL:u,templateLess:f,portalPageId:m,canSync:d};return l.tags.push({tag:"div",injectTo:"body-prepend",children:await i(g)}),l.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:o.js,type:"module"}}),l},configureServer(e){const t=s.normalizePath(p.resolve(e.config.root,p.dirname(m)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t),e.middlewares.use("/@api/__pp-dev-metrics",((e,t)=>{t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(R,null,2))}))},closeBundle(){w.clear(),x.clear()}}}const $=(e,t)=>` * ${t}`;function N(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,$)}\n */`}async function C(){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}`)}}const I=new Map,T=3e4;let L=null;function O(){const e=Date.now();if(L&&e-L.timestamp<6e4)return L.data;const i=process.cwd();try{const s=JSON.parse(t.readFileSync(n.resolve(i,"package.json"),{encoding:"utf-8",flag:"r"}));return L={data:s,timestamp:e},s}catch{const t={};return L={data:t,timestamp:e},t}}let U=null;async function F(e){const s=process.cwd(),a=`ts:${e}`,r=I.get(a);if(r&&Date.now()-r.timestamp<T)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=O();o=!!e&&"module"===e.type}const c=await async function(){return U||(U=await import("esbuild")),U}(),p=await c.build({absWorkingDir:s,entryPoints:[e],outfile:"out.js",write:!1,target:["node14.18","node16"],platform:"node",bundle:!0,format:o?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:l}=p.outputFiles[0],u=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,f=i.pathToFileURL(n.resolve(s,u)).toString();t.writeFileSync(u,l);let m={};try{const t=(await import(f)).default;m=t?.default||t,I.set(a,{data:m,timestamp:Date.now(),filePath:e})}finally{t.existsSync(u)&&t.unlink(u,(()=>{}))}return m}async function E(e){const t=`js:${e}`,n=I.get(t);if(n&&Date.now()-n.timestamp<T)return n.data;const s=(await import(i.pathToFileURL(e).toString())).default;return I.set(t,{data:s,timestamp:Date.now(),filePath:e}),s}async function k(e){const n=`json:${e}`,i=I.get(n);if(i&&Date.now()-i.timestamp<T)return i.data;const s=JSON.parse(t.readFileSync(e,{encoding:"utf-8"}));return I.set(n,{data:s,timestamp:Date.now(),filePath:e}),s}let z=null;async function q(e,t){for(const i of t)if(e.includes(i)){if(/\.[cm]?ts$/i.test(i))return await F(i);if(/\.[cm]?js$/i.test(i))return await E(n.resolve(".",i));if(i.endsWith(".json"))return await k(n.resolve(".",i))}return null}function M(){return O()}async function V(){const e=function(){const e=Date.now();if(z&&e-z.timestamp<1e4)return z.files;const n=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,i=process.cwd(),s=t.readdirSync(i,{withFileTypes:!0}).filter((e=>e.isFile()&&n.test(e.name))).map((e=>e.name));return z={files:s,timestamp:e},s}();let n={},i=!1;const s=await q(e,y);if(s&&(n=s,i=!0),e.length&&!i){const t=await q(e,j);t&&(n={backendBaseURL:t.baseURL,portalPageId:t.portalPageId},i=!0)}const a=O();return i||"object"!=typeof a["pp-dev"]||(n=a["pp-dev"]),n}const A=Object.freeze({__proto__:null,clearConfigCache:function(){I.clear(),L=null,z=null},getConfig:V,getPkg:M});function H(e){return e?.experimental?.ppDev||e?.ppDev||{}}function B(e,t,n){return Object.assign({},e,t,n)}exports.PP_DEV_CONFIG_NAMES=y,exports.PP_WATCH_CONFIG_NAMES=j,exports.VERSION=h,exports.config=A,exports.getNextVersion=async function(){try{return(await import("next/package.json")).version}catch{return null}},exports.getPPDevConfigFromNextConfig=H,exports.getViteConfig=async function(){const t=M().name,n=await V(),i=e.normalizeVitePPDevConfig(Object.assign(n,{templateName:t})),s=[e.vitePPDev(i),D()],{outDir:a,distZip:r,imageOptimizer:o,templateLess:c,integrateMiTopBar:p}=i;if(p&&s.push({name:"mi-topbar-plugin",transformIndexHtml:()=>[{tag:"script",injectTo:"body",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"body",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head",attrs:{href:"/css/main.css",rel:"stylesheet"}},{tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}]}),o){const{ViteImageOptimizer:e}=await import("vite-plugin-image-optimizer");s.push(e("object"==typeof o?o:void 0))}if(r){const{default:e}=await import("vite-plugin-zip-pack");s.push({...e("object"==typeof r?r:{outFileName:`${t}.zip`}),enforce:"post"})}return{base:c?`/p/${t}`:`/pt/${t}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:N}},outDir:a},css:{modules:{localsConvention:"dashes"},scss:{api:"modern"}},ppDevConfig:i,plugins:s}},exports.isNextAvailable=async function(){try{return await import("next"),!0}catch(e){return!1}},exports.safeNextImport=C,exports.withPPDev=function(e,t){return async(n,i={})=>{try{const{constants:s}=await C(),{PHASE_DEVELOPMENT_SERVER:a}=s,r=await V(),o=M().name,c="function"==typeof e?await e(n,i):e,p=H(c),l=n===a,u=function(e,t,n,i){return n?t?`/p/${e}`:`/pl/${e}`:i?`/pt/${e}`:`/pl/${e}`}(o,r.templateLess??!1,l,r.v7Features??!1),f={basePath:u,trailingSlash:!!l||void 0};if(l){const e=function(e,t){const{appId:n,portalPageId:i,backendBaseURL:s,templateLess:a,v7Features:r,...o}=t,c=n||i,p={backendBaseURL:s,portalPageId:c,appId:c,templateLess:a,v7Features:r,...o};return{serverRuntimeConfig:{templateName:e,ppDevConfig:p},publicRuntimeConfig:{templateName:e,ppDevConfig:p},experimental:{ppDev:p}}}(o,Object.assign({},r,p,t));return B(f,c,e)}return B(f,c)}catch(t){console.error("Error in withPPDev:",t),console.warn("Falling back to original Next.js configuration");try{return"function"==typeof e?await e(n,i):e}catch(e){return console.error("Error in fallback configuration:",e),{}}}}};
2
- //# sourceMappingURL=index-DJdZe-Ks.js.map
1
+ "use strict";const e=require("./plugin-xN0M6WT7.js"),t=require("fs"),n=require("path"),i=require("url"),a=require("vite"),s=require("ejs");var r="undefined"!=typeof document?document.currentScript:null;function o(e){const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const c=o(t),p=o(n),l=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-1BlQDvLy.js",document.baseURI).href),"../../.."),u=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-1BlQDvLy.js",document.baseURI).href),"../.."),f=t.existsSync(n.resolve(l,"package.json"))?l:u,m=n.resolve(f,"dist/client/client.js"),{version:d,name:g}=JSON.parse(t.readFileSync(n.resolve(f,"package.json")).toString()),h=d,v=g,j=[".pp-watch.config.js",".pp-watch.config.ts",".pp-watch.config.json"],y=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"];const w=new class{cache=new Map;_maxSize;constructor(e=10){this._maxSize=e}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=e}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this._maxSize){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}clear(){this.cache.clear()}has(e){return this.cache.has(e)}}(5),x=new Map,P=p.dirname("undefined"!=typeof __filename&&__filename||i.fileURLToPath(new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-1BlQDvLy.js",document.baseURI).href))),b=`/${v}/client`,S=`/${b}`,_=new RegExp(`^\\/?${v}\\/client\\/(.*)$`);const R={templateCompilations:0,cacheHits:0,totalRequests:0};function D(e){let t="",n=!1,i=null;return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${v}/client`),e),resolveId(e){if(_.test(e))return{id:a.normalizePath(p.join(f,"dist/client",e.replace(_,"$1")))}},transformIndexHtml:async(e,a)=>{R.totalRequests++;const r=a.server?.config.base||"";r!==t&&(t=r,n=!0,i=null),i&&!n||(w.has(t)?(i=w.get(t),R.cacheHits++):(i=function(e,t=!0){const n=e;if(t&&w.has(n))return w.get(n);const i=p.resolve(P,"client","index.html");let a;x.has(i)?a=x.get(i):(a=c.readFileSync(i,{encoding:"utf8"}),x.set(i,a));const r=S.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=s.compile(a.replace(new RegExp(r,"g"),p.posix.join(e,b)),{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:i,rmWhitespace:!0,compileDebug:!1});return t&&w.set(n,o),o}(t,true),R.templateCompilations++),n=!1);const o=function(e){return{css:p.posix.join(e,v,"client/client.css"),js:p.posix.join(e,v,"client/client.js")}}(t),l={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:o.css}}]},{backendBaseURL:u,templateLess:f,portalPageId:m,canSync:d=!0}=a.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:v,VERSION:h,backendBaseURL:u,templateLess:f,portalPageId:m,canSync:d};return l.tags.push({tag:"div",injectTo:"body-prepend",children:await i(g)}),l.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:o.js,type:"module"}}),l},configureServer(e){const t=a.normalizePath(p.resolve(e.config.root,p.dirname(m)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t),e.middlewares.use("/@api/__pp-dev-metrics",((e,t)=>{t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(R,null,2))}))},closeBundle(){w.clear(),x.clear()}}}const $=(e,t)=>` * ${t}`;function N(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,$)}\n */`}async function C(){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}`)}}const I=new Map,T=3e4;let L=null;function O(){const e=Date.now();if(L&&e-L.timestamp<6e4)return L.data;const i=process.cwd();try{const a=JSON.parse(t.readFileSync(n.resolve(i,"package.json"),{encoding:"utf-8",flag:"r"}));return L={data:a,timestamp:e},a}catch{const t={};return L={data:t,timestamp:e},t}}let U=null;async function F(e){const a=process.cwd(),s=`ts:${e}`,r=I.get(s);if(r&&Date.now()-r.timestamp<T)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=O();o=!!e&&"module"===e.type}const c=await async function(){return U||(U=await import("esbuild")),U}(),p=await c.build({absWorkingDir:a,entryPoints:[e],outfile:"out.js",write:!1,target:["node14.18","node16"],platform:"node",bundle:!0,format:o?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:l}=p.outputFiles[0],u=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,f=i.pathToFileURL(n.resolve(a,u)).toString();t.writeFileSync(u,l);let m={};try{const t=(await import(f)).default;m=t?.default||t,I.set(s,{data:m,timestamp:Date.now(),filePath:e})}finally{t.existsSync(u)&&t.unlink(u,(()=>{}))}return m}async function E(e){const t=`js:${e}`,n=I.get(t);if(n&&Date.now()-n.timestamp<T)return n.data;const a=(await import(i.pathToFileURL(e).toString())).default;return I.set(t,{data:a,timestamp:Date.now(),filePath:e}),a}async function k(e){const n=`json:${e}`,i=I.get(n);if(i&&Date.now()-i.timestamp<T)return i.data;const a=JSON.parse(t.readFileSync(e,{encoding:"utf-8"}));return I.set(n,{data:a,timestamp:Date.now(),filePath:e}),a}let z=null;async function q(e,t){for(const i of t)if(e.includes(i)){if(/\.[cm]?ts$/i.test(i))return await F(i);if(/\.[cm]?js$/i.test(i))return await E(n.resolve(".",i));if(i.endsWith(".json"))return await k(n.resolve(".",i))}return null}function M(){return O()}async function V(){const e=function(){const e=Date.now();if(z&&e-z.timestamp<1e4)return z.files;const n=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,i=process.cwd(),a=t.readdirSync(i,{withFileTypes:!0}).filter((e=>e.isFile()&&n.test(e.name))).map((e=>e.name));return z={files:a,timestamp:e},a}();let n={},i=!1;const a=await q(e,y);if(a&&(n=a,i=!0),e.length&&!i){const t=await q(e,j);t&&(n={backendBaseURL:t.baseURL,portalPageId:t.portalPageId},i=!0)}const s=O();return i||"object"!=typeof s["pp-dev"]||(n=s["pp-dev"]),n}const A=Object.freeze({__proto__:null,clearConfigCache:function(){I.clear(),L=null,z=null},getConfig:V,getPkg:M});function H(e){return e?.experimental?.ppDev||e?.ppDev||{}}function B(e,t,n){return Object.assign({},e,t,n)}exports.PP_DEV_CONFIG_NAMES=y,exports.PP_WATCH_CONFIG_NAMES=j,exports.VERSION=h,exports.config=A,exports.getNextVersion=async function(){try{return(await import("next/package.json")).version}catch{return null}},exports.getPPDevConfigFromNextConfig=H,exports.getViteConfig=async function(){const t=M().name,n=await V(),i=e.normalizeVitePPDevConfig(Object.assign(n,{templateName:t})),a=[e.vitePPDev(i),D()],{outDir:s,distZip:r,imageOptimizer:o,templateLess:c,integrateMiTopBar:p}=i;if(p&&a.push({name:"mi-topbar-plugin",transformIndexHtml:()=>[{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"}},{tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}]}),o){const{ViteImageOptimizer:e}=await import("vite-plugin-image-optimizer");a.push(e("object"==typeof o?o:void 0))}if(r){const{default:e}=await import("vite-plugin-zip-pack");a.push({...e("object"==typeof r?r:{outFileName:`${t}.zip`}),enforce:"post"})}return{base:c?`/p/${t}`:`/pt/${t}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:N}},outDir:s},css:{modules:{localsConvention:"dashes"},scss:{api:"modern"}},ppDevConfig:i,plugins:a}},exports.isNextAvailable=async function(){try{return await import("next"),!0}catch(e){return!1}},exports.safeNextImport=C,exports.withPPDev=function(e,t){return async(n,i={})=>{try{const{constants:a}=await C(),{PHASE_DEVELOPMENT_SERVER:s}=a,r=await V(),o=M().name,c="function"==typeof e?await e(n,i):e,p=H(c),l=n===s,u=function(e,t,n,i){return n?t?`/p/${e}`:`/pl/${e}`:i?`/pt/${e}`:`/pl/${e}`}(o,r.templateLess??!1,l,r.v7Features??!1),f={basePath:u,trailingSlash:!!l||void 0};if(l){const e=function(e,t){const{appId:n,portalPageId:i,backendBaseURL:a,templateLess:s,v7Features:r,...o}=t,c=n||i,p={backendBaseURL:a,portalPageId:c,appId:c,templateLess:s,v7Features:r,...o};return{serverRuntimeConfig:{templateName:e,ppDevConfig:p},publicRuntimeConfig:{templateName:e,ppDevConfig:p},experimental:{ppDev:p}}}(o,Object.assign({},r,p,t));return B(f,c,e)}return B(f,c)}catch(t){console.error("Error in withPPDev:",t),console.warn("Falling back to original Next.js configuration");try{return"function"==typeof e?await e(n,i):e}catch(e){return console.error("Error in fallback configuration:",e),{}}}}};
2
+ //# sourceMappingURL=index-1BlQDvLy.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-DJdZe-Ks.js","sources":["../../../src/constants.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/config.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","document","require","pathToFileURL","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PP_WATCH_CONFIG_NAMES","PP_DEV_CONFIG_NAMES","templateCache","cache","Map","_maxSize","constructor","maxSize","this","value","get","key","has","delete","set","size","firstKey","keys","next","undefined","clear","fileCache","DIRNAME","path","dirname","PACKAGE_IMPORT","CLIENT_PATH","PACKAGE_REGEXP","RegExp","performanceMetrics","templateCompilations","cacheHits","totalRequests","clientInjectionPlugin","opts","base","baseChanged","currentTemplate","apply","config","optimizeDeps","exclude","push","resolveId","source","test","id","normalizePath","join","replace","transformIndexHtml","async","html","ctx","serverBase","server","enableCache","cacheKey","templatePath","templateContent","fs","encoding","escapedClientPath","compiledTemplate","compile","posix","openDelimiter","closeDelimiter","filename","rmWhitespace","compileDebug","getTemplate","assetPaths","css","js","getAssetPaths","result","tags","tag","injectTo","attrs","rel","backendBaseURL","templateLess","portalPageId","canSync","templateData","children","type","configureServer","clientDir","root","allow","middlewares","use","req","res","setHeader","end","stringify","closeBundle","replacer","substring","$1","header","chunk","safeNextImport","constants","Promise","all","import","default","error","Error","configCache","CACHE_TTL","packageJsonCache","getPackageJson","now","Date","timestamp","data","cwd","process","flag","empty","esbuildModule","loadTsConfig","filePath","cached","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","slice","fileUrl","writeFileSync","conf","unlink","loadJsConfig","loadJSONConfig","dirContentCache","loadConfig","dirFiles","configNames","configName","includes","endsWith","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","filter","isFile","map","getDirectoryContent","configFound","newConfig","length","watchConfig","baseURL","getPPDevConfigFromNextConfig","nextConfig","experimental","ppDev","mergeConfigs","baseConfig","nextConfiguration","additionalConfig","Object","assign","templateName","ppDevConfig","normalizedPPDevConfig","normalizeVitePPDevConfig","plugins","vitePPDev","outDir","distZip","imageOptimizer","integrateMiTopBar","defer","ViteImageOptimizer","zipPack","outFileName","enforce","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","scss","api","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","nextConfigPPDev","isDevelopment","basePath","v7Features","createBasePath","trailingSlash","runtimeConfig","devConfig","appId","originalAppId","rest","normalizedConfig","serverRuntimeConfig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ACK1I,EACH,MAAqB6G,IACrB,OAA8BA,IAG7B+B,EACH,OAAyB/B,IACzB,OAA8BA,GACpC,CAyGuBgC,CACfhC,EACAzJ,EAAO4C,eAAgB,EACvB0I,EACAtL,EAAOwL,aAAc,GAGjBpC,EAAyB,CAC7BmC,WACAG,gBAAeJ,QAAuB1M,GAGxC,GAAI0M,EAAe,CAGjB,MACMK,EAjHd,SAA6BlC,EAAsBmC,GACjD,MACEC,MAAOC,EAAajJ,aACpBA,EAAYF,eACZA,EAAcC,aACdA,EAAY4I,WACZA,KACGO,GACDH,EAEEC,EAAQC,GAAiBjJ,EAEzBmJ,EAAmB,CACvBrJ,iBACAE,aAAcgJ,EACdA,QACAjJ,eACA4I,gBACGO,GAGL,MAAO,CACLE,oBAAqB,CACnBxC,eACAC,YAAasC,GAEfE,oBAAqB,CACnBzC,eACAC,YAAasC,GAEf/C,aAAc,CACZC,MAAO8C,GAGb,CA+E8BG,CAAoB1C,EADxBF,OAAOC,OAAO,CAAE,EAAExJ,EAAQqL,EAAiB3B,IAG7D,OAAOP,EAAaC,EAAYC,EAAmBsC,GAIrD,OAAOxC,EAAaC,EAAYC,GAChC,MAAO5E,GACP2H,QAAQ3H,MAAM,sBAAuBA,GACrC2H,QAAQC,KAAK,kDAGb,IAKE,MAH0B,mBAAjBnB,QACGA,EAAaC,EAAOnC,GAC1BkC,EAEN,MAAOoB,GAGP,OAFAF,QAAQ3H,MAAM,mCAAoC6H,GAE3C,CAAE,IAIjB"}
1
+ {"version":3,"file":"index-1BlQDvLy.js","sources":["../../../src/constants.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/config.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","document","require","pathToFileURL","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PP_WATCH_CONFIG_NAMES","PP_DEV_CONFIG_NAMES","templateCache","cache","Map","_maxSize","constructor","maxSize","this","value","get","key","has","delete","set","size","firstKey","keys","next","undefined","clear","fileCache","DIRNAME","path","dirname","PACKAGE_IMPORT","CLIENT_PATH","PACKAGE_REGEXP","RegExp","performanceMetrics","templateCompilations","cacheHits","totalRequests","clientInjectionPlugin","opts","base","baseChanged","currentTemplate","apply","config","optimizeDeps","exclude","push","resolveId","source","test","id","normalizePath","join","replace","transformIndexHtml","async","html","ctx","serverBase","server","enableCache","cacheKey","templatePath","templateContent","fs","encoding","escapedClientPath","compiledTemplate","compile","posix","openDelimiter","closeDelimiter","filename","rmWhitespace","compileDebug","getTemplate","assetPaths","css","js","getAssetPaths","result","tags","tag","injectTo","attrs","rel","backendBaseURL","templateLess","portalPageId","canSync","templateData","children","type","configureServer","clientDir","root","allow","middlewares","use","req","res","setHeader","end","stringify","closeBundle","replacer","substring","$1","header","chunk","safeNextImport","constants","Promise","all","import","default","error","Error","configCache","CACHE_TTL","packageJsonCache","getPackageJson","now","Date","timestamp","data","cwd","process","flag","empty","esbuildModule","loadTsConfig","filePath","cached","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","slice","fileUrl","writeFileSync","conf","unlink","loadJsConfig","loadJSONConfig","dirContentCache","loadConfig","dirFiles","configNames","configName","includes","endsWith","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","filter","isFile","map","getDirectoryContent","configFound","newConfig","length","watchConfig","baseURL","getPPDevConfigFromNextConfig","nextConfig","experimental","ppDev","mergeConfigs","baseConfig","nextConfiguration","additionalConfig","Object","assign","templateName","ppDevConfig","normalizedPPDevConfig","normalizeVitePPDevConfig","plugins","vitePPDev","outDir","distZip","imageOptimizer","integrateMiTopBar","defer","ViteImageOptimizer","zipPack","outFileName","enforce","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","scss","api","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","nextConfigPPDev","isDevelopment","basePath","v7Features","createBasePath","trailingSlash","runtimeConfig","devConfig","appId","originalAppId","rest","normalizedConfig","serverRuntimeConfig","publicRuntimeConfig","createRuntimeConfig","console","warn","fallbackError"],"mappings":"icAIMA,EAAkBC,EAAOA,QAEN,oBAAfC,YAA8BA,YAAeC,EAAAA,cAAc,oBAAAC,SAAAC,QAAA,OAAAC,cAAAJ,YAAAK,KAAAC,GAAA,WAAAA,EAAAC,QAAAC,eAAAF,EAAAG,KAAA,IAAAC,IAAA,oBAAAR,SAAAS,SAAAN,MACnE,YAGIO,EAAmBb,EAAOA,QAEP,oBAAfC,YAA8BA,YAAeC,EAAAA,cAAc,oBAAAC,SAAAC,QAAA,OAAAC,cAAAJ,YAAAK,KAAAC,GAAA,WAAAA,EAAAC,QAAAC,eAAAF,EAAAG,KAAA,IAAAC,IAAA,oBAAAR,SAAAS,SAAAN,MACnE,SAGWQ,EAAqBC,EAAUA,WAACf,UAAQD,EAAiB,iBAAmBA,EAAkBc,EAM9FG,EAAsBhB,EAAAA,QAAQc,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAAA,aAAarB,EAAOA,QAACc,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAEfO,EAAwB,CAAC,sBAAuB,sBAAuB,yBAEvEC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCoCF,MAAMC,EAAgB,IApDtB,MACUC,MAAQ,IAAIC,IACZC,SAER,WAAAC,CAAYC,EAAkB,IAC5BC,KAAKH,SAAWE,EAGlB,WAAIA,GACF,OAAOC,KAAKH,SAGd,WAAIE,CAAQE,GACVD,KA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=require("./index-DJdZe-Ks.js");require("http-proxy-middleware"),require("vite"),require("picocolors"),require("axios"),require("jsdom"),require("https"),require("memory-cache"),require("path"),require("fs"),require("url"),require("crypto"),require("process"),require("child_process"),require("console"),require("zlib"),require("express"),require("ejs"),exports.AuthProvider=e.AuthProvider,exports.authProvider=e.authProvider,exports.getNextVersion=r.getNextVersion,exports.getPPDevConfigFromNextConfig=r.getPPDevConfigFromNextConfig,exports.getViteConfig=r.getViteConfig,exports.isNextAvailable=r.isNextAvailable,exports.safeNextImport=r.safeNextImport,exports.withPPDev=r.withPPDev;
1
+ "use strict";const e=require("./plugin-xN0M6WT7.js"),r=require("./index-1BlQDvLy.js");require("http-proxy-middleware"),require("vite"),require("picocolors"),require("axios"),require("jsdom"),require("https"),require("memory-cache"),require("path"),require("fs"),require("url"),require("crypto"),require("process"),require("child_process"),require("console"),require("zlib"),require("express"),require("ejs"),exports.AuthProvider=e.AuthProvider,exports.authProvider=e.authProvider,exports.getNextVersion=r.getNextVersion,exports.getPPDevConfigFromNextConfig=r.getPPDevConfigFromNextConfig,exports.getViteConfig=r.getViteConfig,exports.isNextAvailable=r.isNextAvailable,exports.safeNextImport=r.safeNextImport,exports.withPPDev=r.withPPDev;
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "commonjs",
4
- "version": "0.12.3-beta.1",
4
+ "version": "0.12.4-beta.1",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "repository": {
94
94
  "type": "git",
95
- "url": "git+https://github.com/mi-examples/pp-dev-js.git"
95
+ "url": "git+https://github.com/mi-examples/pp-dev.git"
96
96
  },
97
97
  "keywords": [
98
98
  "mi",
@@ -103,8 +103,8 @@
103
103
  "helper"
104
104
  ],
105
105
  "bugs": {
106
- "url": "https://github.com/mi-examples/pp-dev-js/issues"
106
+ "url": "https://github.com/mi-examples/pp-dev/issues"
107
107
  },
108
- "homepage": "https://github.com/mi-examples/pp-dev-js#readme",
108
+ "homepage": "https://github.com/mi-examples/pp-dev#readme",
109
109
  "private": false
110
110
  }
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import*as e from"path";import*as t from"fs";import{performance as o}from"node:perf_hooks";import{watch as n}from"chokidar";import{cac as i}from"cac";import{loadConfigFromFile as s,mergeConfig as r,build as a,resolveConfig as l,optimizeDeps as c,preview as d,loadEnv as p}from"vite";import{g as f,V as h,i as u,s as g,P as m,a as b}from"./index-CmcaJY7U.js";import{c as w,a as v,M as y,i as x,b as T,d as P,e as $,f as S,g as L,u as F}from"./plugin-_rCgP0h-.js";import{parse as j}from"url";import*as E from"dir-compare";import k from"diff-match-patch";import{isBinaryFile as A}from"isbinaryfile";import*as D from"os";import*as C from"crypto";import I from"extract-zip";import N from"svgtofont";import"ejs";import"http-proxy-middleware";import"picocolors";import"axios";import"jsdom";import"https";import"memory-cache";import"process";import"child_process";import"console";import"zlib";import"express";function _(e){return null!=e&&!1!==e}const R=[{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 M=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class z{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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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:r,diffLineTemplateHandler:a,changelogFilename:l,contextLines:c}=t;if(this.logger=w(),!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(D.tmpdir(),C.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(D.tmpdir(),C.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=l||"CHANGELOG.html",s&&(this.templateIsValid(s)?this.changelogTemplate=s:this.logger.warn(v.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 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){return t.rmSync(o,{force:!0,recursive:!0}),I(e,{dir: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(v.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await E.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(M.test(e)&&(e=e.replace(M,"$1$3")),M.test(t)&&(t=t.replace(M,"$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 k,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 A(n)||await A(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(v.green("Generating changelog"));const o=await this.generateAssetFoldersDiff(),n=(await Promise.all(o.map((e=>this.generateFilesDiff(e))))).join("");this.logger.info(v.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(v.green(`Changelog file written to ${e.join(this.destinationPath,this.changelogFilename)}`))}}class H{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await N({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const G=i("pp-dev");function O(t,o,i){const s=[...m,...b,"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=n(s,{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let a=null;return r.on("change",(n=>{i(v.blue(`🔧 Config file changed: ${e.relative(t,n)}`)),a&&clearTimeout(a),a=setTimeout((async()=>{try{i(v.yellow("🔄 Restarting dev server due to config change...")),await o()}catch(e){i(v.red(`❌ Failed to restart dev server: ${e}`))}}),500)})),r.on("error",(e=>{i(v.red(`❌ Config watcher error: ${e}`))})),{watcher:r,restartCallback:o,logger:i}}function U(e){e.watcher&&e.watcher.close()}let W=global.__pp_dev_profile_session,q=0;const B=o=>{if(W)return new Promise(((n,i)=>{W.post("Profiler.stop",((s,{profile:r})=>{if(s)i(s);else{const i=e.resolve(`./pp-dev-profile-${q++}.cpuprofile`);t.writeFileSync(i,JSON.stringify(r)),o(v.yellow(`CPU profile written to ${v.white(v.dim(i))}`)),W=void 0,n()}}))}))},V=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function Z(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}G.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"),G.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,n)=>{V(n);let i=null,a=null,l=!1;const c=t?e.resolve(process.cwd(),t):process.cwd(),d=w(n.logLevel),u=async()=>{if(!l){l=!0;try{i&&(d.info(v.yellow("🛑 Stopping existing dev server...")),await i.close(),i=null);const{clearConfigCache:e}=await import("./index-CmcaJY7U.js").then((e=>e.d));e();const{createServer:g}=await import("vite"),m=await s({mode:n.mode||"development",command:"serve"},n.config,t,n.logLevel);let b=await f();const y=p(n.mode||"development",t??process.cwd(),"");if(y&&Object.keys(y).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=y[e])})),m){const{plugins:e,...t}=m.config;b=r(b,t)}if(i=await g(r(b,{root:t,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:Z(n),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 x=global.__pp_dev_start_time??!1,T=x?v.dim(`ready in ${v.reset(v.bold(Math.ceil(o.now()-x)))} ms`):"";d.info(`\n ${v.green(`${v.bold("PP-DEV")} v${h}`)} ${T}\n`),i.printUrls(),function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=t;const o=w();t.print&&o.info(v.dim(v.green(" ➜"))+v.dim(" press ")+v.bold("h")+v.dim(" to show help"));const n=(t.customShortcuts??[]).filter(_).concat(R);let i=!1;const s=async t=>{if(""===t||""===t)return void await e.close().finally((()=>process.exit(1)));if(i)return;"h"===t&&o.info(["",v.bold(" Shortcuts"),...n.map((e=>v.dim(" press ")+v.bold(e.key)+v.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",s).setEncoding("utf8").resume(),e.httpServer.on("close",(()=>{process.stdin.off("data",s).pause()}))}(i,{print:!0,customShortcuts:[...W?[{key:"p",description:"start/stop the profiler",async action(e){if(W)await B(d.info);else{const e=await import("node:inspector").then((e=>e.default));await new Promise((t=>{W=new e.Session,W.connect(),W.post("Profiler.enable",(()=>{W?.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("/")}`}})}}]}),a||(a=O(c,u,d.info),d.info(v.blue("🔧 Config file watcher started"))),l=!1}catch(e){l=!1,d.error(v.red(`error when starting dev server:\n${e.stack}`),{error:e}),B(d.info),process.exit(1)}}},g=async e=>{d.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{a&&(U(a),a=null),i&&(await i.close(),i=null),B(d.info),d.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(v.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",(()=>g("SIGINT"))),process.on("SIGTERM",(()=>g("SIGTERM"))),process.on("uncaughtException",(e=>{d.error(v.red(`❌ Uncaught Exception: ${e}`)),g("uncaughtException")})),process.on("unhandledRejection",((e,t)=>{d.error(v.red(`❌ Unhandled Rejection at: ${t}, reason: ${e}`)),g("unhandledRejection")})),await u()})),G.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").action((async(t,o)=>{V(o);let n=null,i=null,s=null,r=!1;t?e.resolve(process.cwd(),t):process.cwd();const a=w(),l=async()=>{if(!r){r=!0;try{i&&(a.info(v.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:e}=await import("./index-CmcaJY7U.js").then((e=>e.d));if(e(),!u())throw new Error("Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^13\n\nThis package requires Next.js >=13 <16 as a peer dependency.");const{next:c}=await g(),{join:d,basename:f}=await import("path"),{createServer:h}=await import("http"),{default:m}=(await import("next/dist/server/config.js")).default,b=Z(o),w=p(o.mode||"development",t??process.cwd(),"");w&&Object.keys(w).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=w[e])}));const E=t?d(process.cwd(),t):process.cwd();a.info(E);const k=await m("development",E);let A=k?.experimental?.ppDev||k?.ppDev||{};if(0===Object.keys(A).length)try{const{getConfig:e}=await import("./index-CmcaJY7U.js").then((e=>e.d)),t=await e();Object.keys(t).length>0?(A=t,a.info(v.blue("🔧 Loaded pp-dev config from standalone config file"))):a.info(v.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){a.info(v.yellow("⚠️ Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else a.info(v.blue("🔧 Loaded pp-dev config from Next.js config"));const{backendBaseURL:D=process.env.MI_BACKEND_URL||"http://localhost:8080",portalPageId:C=parseInt(process.env.MI_PORTAL_PAGE_ID||"1"),templateLess:I=!0,v7Features:N=!0,disableSSLValidation:_=!1,enableProxyCache:R=!0,proxyCacheTTL:M=6e5,personalAccessToken:z=process.env.MI_ACCESS_TOKEN,distZip:H=!1,syncBackupsDir:G="./backups",miHudLess:W=!1}=A;let q=A.templateName;if(!q)try{const{getPkg:e}=await import("./index-CmcaJY7U.js").then((e=>e.d));q=e().name}catch(e){q=f(E)}let B=I?"/p":"/pl";if(B+=`/${q}`,n=c({dev:!0,hostname:b.host||"localhost",port:b.port,dir:E,conf:{...k,basePath:B,assetPrefix:B}}),await n.prepare(),B.endsWith("/")||(B+="/"),"/"===B)throw new Error('basePath cannot be equal to "/" or equal to empty string');B.substring(0,B.lastIndexOf("/"));a.info(v.green("✅ Next.js app prepared successfully")),a.info(v.blue(`🔧 pp-dev plugin configured for template: ${q}`)),a.info(v.blue(`🔧 Base path configured: ${B}`)),D&&(a.info(v.blue(`🌐 Backend URL: ${D}`)),a.info(v.blue(`🆔 Portal Page ID: ${C}`)));const V=n.getRequestHandler(),K="number"==typeof b.port?b.port:3e3,Y="string"==typeof b.host?b.host||"0.0.0.0":"localhost",J=new Set;i=h((async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=j(o,!0);if(X.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")||n.startsWith("/api/")){if(ee.length>0){let l=0;const c=()=>{if(l>=ee.length)return void s();const o=ee[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=X.length)return void s();const o=X[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(B)){const t=n.substring(B.length);e.url=t||"/",i=j(t,!0)}else if(n===B.replace(/\/$/,""))e.url="/",i=j("/",!0);else if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return t.writeHead(302,{Location:B}),void t.end();await V(e,t,i)}s()}catch(d){console.error("[DEBUG] Error:",d),t.statusCode=500,t.end("Internal Server Error")}}));let Q=null,X=[],ee=[];if(D){const e=new URL(D).host,t={headers:{host:e,referer:D,origin:D.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},portalPageId:C,appId:C,templateLess:I,disableSSLValidation:_,v7Features:N,personalAccessToken:z??process.env.MI_ACCESS_TOKEN};Q=new y(D,t);const o=x(B,q),n=(e,t,n)=>{o(e,t,n)};if(ee.push(n),X.push(n),R){let e=+M;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={middlewares:{use:e=>e},config:{logger:console}},o=T({devServer:t,ttl:e}),n=(e,t,n)=>{o(e,t,n)};X.push(n),a.info(v.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const i=B.endsWith("/")?B.substring(0,B.length-1):B,s={middlewares:{use:e=>e},config:{logger:console}},r=P({devServer:s,baseURL:D,proxyIgnore:["/@vite","/@metricinsights","/@",i,"/_next","/favicon.ico","/__nextjs_","/api"],disableSSLValidation:_,miAPI:Q}),l=(e,t,o)=>{r(e,t,o)};X.push(l);const c=new RegExp(`^((${B})|/)$`),d=$(c,Q,{base:B,v7Features:N}),p=(e,t,o)=>{d(e,t,o)};X.push(p);const f=S,h=(e,t,o)=>{if(e.url?.startsWith("/@api/")){f(e,t,(()=>{}))}else o()};ee.push(h),X.push(h);const u=L((e=>e.split("?")[0].endsWith("index.html")),((t,o)=>Buffer.from(F(e,o.headers.host??"",Q.buildPage(t,W))))),g=(e,t,o)=>{u(e,t,o)};X.push(g),a.info(v.blue(`🔧 ${X.length} pp-dev middlewares initialized`)),a.info(v.blue(`🔧 ${ee.length} essential middlewares for internal routes`)),a.info(v.blue(`🔧 MiAPI initialized for backend: ${D}`)),a.info(v.blue(`🔧 Portal Page ID: ${C}`))}i.listen(K,Y,(()=>{a.info(v.green(`✅ pp-dev Next.js server running at http://${Y}:${K}`)),a.info(v.blue(`📱 Next.js app accessible at http://${Y}:${K}${B}`)),a.info(v.blue("🔧 Base path handling active")),s||(s=O(E,l,a.info),a.info(v.blue("🔧 Config file watcher started"))),i.on("connection",(e=>{J.add(e),e.on("close",(()=>J.delete(e)))}));const e=async e=>{a.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));const t=setTimeout((()=>{a.info(v.yellow("⏰ Shutdown timeout reached, forcing exit")),process.exit(0)}),5e3);try{s&&(U(s),s=null);for(const e of Array.from(J))e.destroy();J.clear(),await new Promise((e=>{i.close((()=>{a.info(v.yellow("🛑 HTTP server closed")),e()}))})),n&&"function"==typeof n.close&&(await n.close(),a.info(v.yellow("🛑 Next.js app closed"))),clearTimeout(t),a.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),a.error(v.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,a.info(v.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=>{a.error(v.red(`❌ Uncaught Exception: ${t}`)),e("uncaughtException")})),t.on("unhandledRejection",((t,o)=>{a.error(v.red(`❌ Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")})),a.info(v.green("✅ Process event handlers registered successfully"))}catch(e){a.warn(v.yellow(`⚠️ Failed to register process event handlers: ${e}`))}else a.warn(v.yellow("⚠️ process.on is not available, graceful shutdown handlers will not be registered")),a.info(v.blue("💡 This might be due to bundling or environment constraints"))})),r=!1}catch(e){r=!1,a.error(v.red(`❌ Failed to start Next.js server: ${e}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(a.error(v.red("❌ Next.js Peer Dependency Error:")),a.error(v.red(e.message)),a.error(v.yellow("\n💡 To fix this issue:")),a.error(v.blue(" 1. Install Next.js in your project:")),a.error(v.white(" npm install next@^15")),a.error(v.blue(" 2. Or use yarn:")),a.error(v.white(" yarn add next@^15")),a.error(v.blue(" 3. Or use pnpm:")),a.error(v.white(" pnpm add next@^15")),a.error(v.yellow("\n📖 For more information, see:")),a.error(v.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}},c=async e=>{a.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{s&&(U(s),s=null),i&&await new Promise((e=>{i.close((()=>{i=null,e()}))})),n&&"function"==typeof n.close&&(await n.close(),n=null),a.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){a.error(v.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",(()=>c("SIGINT"))),process.on("SIGTERM",(()=>c("SIGTERM"))),process.on("uncaughtException",(e=>{a.error(v.red(`❌ Uncaught Exception: ${e}`)),c("uncaughtException")})),process.on("unhandledRejection",((e,t)=>{a.error(v.red(`❌ Unhandled Rejection at: ${t}, reason: ${e}`)),c("unhandledRejection")})),await l()})),G.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)").action((async(o,n)=>{V(n);const i=Z(n);try{const l=await s({mode:n.mode||"production",command:"build"},n.config,o,n.logLevel);let c=await f();if(l){const{plugins:e,...t}=l.config;c=r(c,t)}const d=r(c,{root:o,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await a(d),i.changelog){const s=o||process.cwd(),r=d.build?.outDir||"dist";let a="";if("string"==typeof i.changelog)a=e.resolve(s,i.changelog);else{const o=e.resolve(s,d.ppDevConfig?.syncBackupsDir||"backups");if(!t.existsSync(o))return void w(n.logLevel).warn(v.yellow("backups directory not found, skipping changelog generation"));const i=t.readdirSync(o,{withFileTypes:!0});if(!i.length)return void w(n.logLevel).warn(v.yellow("no backups found, skipping changelog generation"));const r=i.filter((e=>e.isFile()&&e.name.endsWith(".zip"))).reduce(((n,i)=>t.statSync(e.resolve(o,n.name)).mtimeMs>t.statSync(e.resolve(o,i.name)).mtimeMs?n:i),i[0]).name;a=e.resolve(o,r)}const l=e.resolve(s,r);let c="dist-zip";d.ppDevConfig&&(!1===d.ppDevConfig.distZip?c=d.build?.outDir||"dist":"object"==typeof d.ppDevConfig.distZip&&"string"==typeof d.ppDevConfig.distZip.outDir&&(c=d.ppDevConfig.distZip.outDir));const p=new z({oldAssetsPath:a,newAssetsPath:l,destinationPath:e.resolve(s,c)});await p.generateChangelog()}}catch(e){w(n.logLevel).error(v.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{B((e=>w(n.logLevel).info(e)))}})),G.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)=>{V(n);const{oldAssetsPath:i=t,newAssetsPath:s=o,destination:r=".",filename:a="CHANGELOG.html",logLevel:l}=n,c=process.cwd();i&&s||(w(l).error(v.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=e.resolve(c,i),p=e.resolve(c,s),f=e.resolve(c,r),h=new z({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:a});await h.generateChangelog()})),G.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)=>{V(n);const{source:i=t,destination:s=o,fontName:r="icon-font"}=n,a=process.cwd(),l=e.resolve(a,i),c=e.resolve(a,s),d=new H({sourceDir:l,outputDir:c,fontName:r}),p=w(n.logLevel);p.info(`Generating icon font from SVG files in ${v.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${v.dim(c)}`)})),G.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=await s({mode:t.mode||"production",command:"build"},t.config,e,t.logLevel);let n=await f();if(o){const{plugins:e,...t}=o.config;n=r(n,t)}const i=await l(r(n,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode}),"serve");await c(i,t.force,!0)}catch(e){w(t.logLevel).error(v.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})),G.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=await s({mode:t.mode||"production",command:"build"},t.config,e,t.logLevel);let n=await f();if(o){const{plugins:e,...t}=o.config;n=r(n,t)}(await d(r(n,{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){w(t.logLevel).error(v.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{B((e=>w(t.logLevel).info(e)))}})),G.help(),G.version(h),G.parse();export{B as stopProfiler};
1
+ import*as e from"path";import*as t from"fs";import{performance as o}from"node:perf_hooks";import{watch as n}from"chokidar";import{cac as i}from"cac";import{loadConfigFromFile as s,mergeConfig as r,build as a,resolveConfig as l,optimizeDeps as c,preview as d,loadEnv as p}from"vite";import{g as f,V as h,i as u,s as g,P as m,a as b}from"./index-DboCTg4P.js";import{c as w,a as v,M as y,i as x,b as T,d as P,e as $,f as S,g as L,u as F}from"./plugin-_rCgP0h-.js";import{parse as j}from"url";import*as E from"dir-compare";import k from"diff-match-patch";import{isBinaryFile as A}from"isbinaryfile";import*as D from"os";import*as C from"crypto";import I from"extract-zip";import N from"svgtofont";import"ejs";import"http-proxy-middleware";import"picocolors";import"axios";import"jsdom";import"https";import"memory-cache";import"process";import"child_process";import"console";import"zlib";import"express";function _(e){return null!=e&&!1!==e}const R=[{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 M=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class z{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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, 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:r,diffLineTemplateHandler:a,changelogFilename:l,contextLines:c}=t;if(this.logger=w(),!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(D.tmpdir(),C.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(D.tmpdir(),C.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=l||"CHANGELOG.html",s&&(this.templateIsValid(s)?this.changelogTemplate=s:this.logger.warn(v.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 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){return t.rmSync(o,{force:!0,recursive:!0}),I(e,{dir: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(v.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await E.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(M.test(e)&&(e=e.replace(M,"$1$3")),M.test(t)&&(t=t.replace(M,"$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 k,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 A(n)||await A(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(v.green("Generating changelog"));const o=await this.generateAssetFoldersDiff(),n=(await Promise.all(o.map((e=>this.generateFilesDiff(e))))).join("");this.logger.info(v.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(v.green(`Changelog file written to ${e.join(this.destinationPath,this.changelogFilename)}`))}}class H{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){await N({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const G=i("pp-dev");function O(t,o,i){const s=[...m,...b,"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=n(s,{ignored:/(^|[\/\\])\../,persistent:!0,ignoreInitial:!0,followSymlinks:!1});let a=null;return r.on("change",(n=>{i(v.blue(`🔧 Config file changed: ${e.relative(t,n)}`)),a&&clearTimeout(a),a=setTimeout((async()=>{try{i(v.yellow("🔄 Restarting dev server due to config change...")),await o()}catch(e){i(v.red(`❌ Failed to restart dev server: ${e}`))}}),500)})),r.on("error",(e=>{i(v.red(`❌ Config watcher error: ${e}`))})),{watcher:r,restartCallback:o,logger:i}}function U(e){e.watcher&&e.watcher.close()}let W=global.__pp_dev_profile_session,q=0;const B=o=>{if(W)return new Promise(((n,i)=>{W.post("Profiler.stop",((s,{profile:r})=>{if(s)i(s);else{const i=e.resolve(`./pp-dev-profile-${q++}.cpuprofile`);t.writeFileSync(i,JSON.stringify(r)),o(v.yellow(`CPU profile written to ${v.white(v.dim(i))}`)),W=void 0,n()}}))}))},V=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};function Z(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}G.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"),G.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,n)=>{V(n);let i=null,a=null,l=!1;const c=t?e.resolve(process.cwd(),t):process.cwd(),d=w(n.logLevel),u=async()=>{if(!l){l=!0;try{i&&(d.info(v.yellow("🛑 Stopping existing dev server...")),await i.close(),i=null);const{clearConfigCache:e}=await import("./index-DboCTg4P.js").then((e=>e.d));e();const{createServer:g}=await import("vite"),m=await s({mode:n.mode||"development",command:"serve"},n.config,t,n.logLevel);let b=await f();const y=p(n.mode||"development",t??process.cwd(),"");if(y&&Object.keys(y).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=y[e])})),m){const{plugins:e,...t}=m.config;b=r(b,t)}if(i=await g(r(b,{root:t,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:Z(n),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 x=global.__pp_dev_start_time??!1,T=x?v.dim(`ready in ${v.reset(v.bold(Math.ceil(o.now()-x)))} ms`):"";d.info(`\n ${v.green(`${v.bold("PP-DEV")} v${h}`)} ${T}\n`),i.printUrls(),function(e,t){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;e._shortcutsOptions=t;const o=w();t.print&&o.info(v.dim(v.green(" ➜"))+v.dim(" press ")+v.bold("h")+v.dim(" to show help"));const n=(t.customShortcuts??[]).filter(_).concat(R);let i=!1;const s=async t=>{if(""===t||""===t)return void await e.close().finally((()=>process.exit(1)));if(i)return;"h"===t&&o.info(["",v.bold(" Shortcuts"),...n.map((e=>v.dim(" press ")+v.bold(e.key)+v.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",s).setEncoding("utf8").resume(),e.httpServer.on("close",(()=>{process.stdin.off("data",s).pause()}))}(i,{print:!0,customShortcuts:[...W?[{key:"p",description:"start/stop the profiler",async action(e){if(W)await B(d.info);else{const e=await import("node:inspector").then((e=>e.default));await new Promise((t=>{W=new e.Session,W.connect(),W.post("Profiler.enable",(()=>{W?.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("/")}`}})}}]}),a||(a=O(c,u,d.info),d.info(v.blue("🔧 Config file watcher started"))),l=!1}catch(e){l=!1,d.error(v.red(`error when starting dev server:\n${e.stack}`),{error:e}),B(d.info),process.exit(1)}}},g=async e=>{d.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{a&&(U(a),a=null),i&&(await i.close(),i=null),B(d.info),d.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){d.error(v.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",(()=>g("SIGINT"))),process.on("SIGTERM",(()=>g("SIGTERM"))),process.on("uncaughtException",(e=>{d.error(v.red(`❌ Uncaught Exception: ${e}`)),g("uncaughtException")})),process.on("unhandledRejection",((e,t)=>{d.error(v.red(`❌ Unhandled Rejection at: ${t}, reason: ${e}`)),g("unhandledRejection")})),await u()})),G.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").action((async(t,o)=>{V(o);let n=null,i=null,s=null,r=!1;t?e.resolve(process.cwd(),t):process.cwd();const a=w(),l=async()=>{if(!r){r=!0;try{i&&(a.info(v.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:e}=await import("./index-DboCTg4P.js").then((e=>e.d));if(e(),!u())throw new Error("Next.js is required but not available. Please install Next.js as a dependency:\nnpm install next@^13\n\nThis package requires Next.js >=13 <16 as a peer dependency.");const{next:c}=await g(),{join:d,basename:f}=await import("path"),{createServer:h}=await import("http"),{default:m}=(await import("next/dist/server/config.js")).default,b=Z(o),w=p(o.mode||"development",t??process.cwd(),"");w&&Object.keys(w).forEach((e=>{e.startsWith("MI_")&&(process.env[e]=w[e])}));const E=t?d(process.cwd(),t):process.cwd();a.info(E);const k=await m("development",E);let A=k?.experimental?.ppDev||k?.ppDev||{};if(0===Object.keys(A).length)try{const{getConfig:e}=await import("./index-DboCTg4P.js").then((e=>e.d)),t=await e();Object.keys(t).length>0?(A=t,a.info(v.blue("🔧 Loaded pp-dev config from standalone config file"))):a.info(v.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){a.info(v.yellow("⚠️ Failed to load standalone pp-dev config, using defaults")),console.debug("Error loading standalone config:",e)}else a.info(v.blue("🔧 Loaded pp-dev config from Next.js config"));const{backendBaseURL:D=process.env.MI_BACKEND_URL||"http://localhost:8080",portalPageId:C=parseInt(process.env.MI_PORTAL_PAGE_ID||"1"),templateLess:I=!0,v7Features:N=!0,disableSSLValidation:_=!1,enableProxyCache:R=!0,proxyCacheTTL:M=6e5,personalAccessToken:z=process.env.MI_ACCESS_TOKEN,distZip:H=!1,syncBackupsDir:G="./backups",miHudLess:W=!1}=A;let q=A.templateName;if(!q)try{const{getPkg:e}=await import("./index-DboCTg4P.js").then((e=>e.d));q=e().name}catch(e){q=f(E)}let B=I?"/p":"/pl";if(B+=`/${q}`,n=c({dev:!0,hostname:b.host||"localhost",port:b.port,dir:E,conf:{...k,basePath:B,assetPrefix:B}}),await n.prepare(),B.endsWith("/")||(B+="/"),"/"===B)throw new Error('basePath cannot be equal to "/" or equal to empty string');B.substring(0,B.lastIndexOf("/"));a.info(v.green("✅ Next.js app prepared successfully")),a.info(v.blue(`🔧 pp-dev plugin configured for template: ${q}`)),a.info(v.blue(`🔧 Base path configured: ${B}`)),D&&(a.info(v.blue(`🌐 Backend URL: ${D}`)),a.info(v.blue(`🆔 Portal Page ID: ${C}`)));const V=n.getRequestHandler(),K="number"==typeof b.port?b.port:3e3,Y="string"==typeof b.host?b.host||"0.0.0.0":"localhost",J=new Set;i=h((async(e,t)=>{try{const o=e.url||"/",n=o.split("?")[0];let i=j(o,!0);if(X.length>0){if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_")||n.startsWith("/api/")){if(ee.length>0){let l=0;const c=()=>{if(l>=ee.length)return void s();const o=ee[l];l++,o(e,t,c)};return void c()}return void s()}let r=0;const a=()=>{if(r>=X.length)return void s();const o=X[r];r++,o(e,t,a)};return void a()}async function s(){if(n.startsWith(B)){const t=n.substring(B.length);e.url=t||"/",i=j(t,!0)}else if(n===B.replace(/\/$/,""))e.url="/",i=j("/",!0);else if(n.startsWith("/_next/")||"/favicon.ico"===n||n.startsWith("/__nextjs_"));else if("/"===n)return t.writeHead(302,{Location:B}),void t.end();await V(e,t,i)}s()}catch(d){console.error("[DEBUG] Error:",d),t.statusCode=500,t.end("Internal Server Error")}}));let Q=null,X=[],ee=[];if(D){const e=new URL(D).host,t={headers:{host:e,referer:D,origin:D.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},portalPageId:C,appId:C,templateLess:I,disableSSLValidation:_,v7Features:N,personalAccessToken:z??process.env.MI_ACCESS_TOKEN};Q=new y(D,t);const o=x(B,q),n=(e,t,n)=>{o(e,t,n)};if(ee.push(n),X.push(n),R){let e=+M;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={middlewares:{use:e=>e},config:{logger:console}},o=T({devServer:t,ttl:e}),n=(e,t,n)=>{o(e,t,n)};X.push(n),a.info(v.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const i=B.endsWith("/")?B.substring(0,B.length-1):B,s={middlewares:{use:e=>e},config:{logger:console}},r=P({devServer:s,baseURL:D,proxyIgnore:["/@vite","/@metricinsights","/@",i,"/_next","/favicon.ico","/__nextjs_","/api"],disableSSLValidation:_,miAPI:Q}),l=(e,t,o)=>{r(e,t,o)};X.push(l);const c=new RegExp(`^((${B})|/)$`),d=$(c,Q,{base:B,v7Features:N}),p=(e,t,o)=>{d(e,t,o)};X.push(p);const f=S,h=(e,t,o)=>{if(e.url?.startsWith("/@api/")){f(e,t,(()=>{}))}else o()};ee.push(h),X.push(h);const u=L((e=>e.split("?")[0].endsWith("index.html")),((t,o)=>Buffer.from(F(e,o.headers.host??"",Q.buildPage(t,W))))),g=(e,t,o)=>{u(e,t,o)};X.push(g),a.info(v.blue(`🔧 ${X.length} pp-dev middlewares initialized`)),a.info(v.blue(`🔧 ${ee.length} essential middlewares for internal routes`)),a.info(v.blue(`🔧 MiAPI initialized for backend: ${D}`)),a.info(v.blue(`🔧 Portal Page ID: ${C}`))}i.listen(K,Y,(()=>{a.info(v.green(`✅ pp-dev Next.js server running at http://${Y}:${K}`)),a.info(v.blue(`📱 Next.js app accessible at http://${Y}:${K}${B}`)),a.info(v.blue("🔧 Base path handling active")),s||(s=O(E,l,a.info),a.info(v.blue("🔧 Config file watcher started"))),i.on("connection",(e=>{J.add(e),e.on("close",(()=>J.delete(e)))}));const e=async e=>{a.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));const t=setTimeout((()=>{a.info(v.yellow("⏰ Shutdown timeout reached, forcing exit")),process.exit(0)}),5e3);try{s&&(U(s),s=null);for(const e of Array.from(J))e.destroy();J.clear(),await new Promise((e=>{i.close((()=>{a.info(v.yellow("🛑 HTTP server closed")),e()}))})),n&&"function"==typeof n.close&&(await n.close(),a.info(v.yellow("🛑 Next.js app closed"))),clearTimeout(t),a.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){clearTimeout(t),a.error(v.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,a.info(v.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=>{a.error(v.red(`❌ Uncaught Exception: ${t}`)),e("uncaughtException")})),t.on("unhandledRejection",((t,o)=>{a.error(v.red(`❌ Unhandled Rejection at: ${o}, reason: ${t}`)),e("unhandledRejection")})),a.info(v.green("✅ Process event handlers registered successfully"))}catch(e){a.warn(v.yellow(`⚠️ Failed to register process event handlers: ${e}`))}else a.warn(v.yellow("⚠️ process.on is not available, graceful shutdown handlers will not be registered")),a.info(v.blue("💡 This might be due to bundling or environment constraints"))})),r=!1}catch(e){r=!1,a.error(v.red(`❌ Failed to start Next.js server: ${e}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(a.error(v.red("❌ Next.js Peer Dependency Error:")),a.error(v.red(e.message)),a.error(v.yellow("\n💡 To fix this issue:")),a.error(v.blue(" 1. Install Next.js in your project:")),a.error(v.white(" npm install next@^15")),a.error(v.blue(" 2. Or use yarn:")),a.error(v.white(" yarn add next@^15")),a.error(v.blue(" 3. Or use pnpm:")),a.error(v.white(" pnpm add next@^15")),a.error(v.yellow("\n📖 For more information, see:")),a.error(v.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}},c=async e=>{a.info(v.yellow(`\n🛑 Received ${e}, shutting down gracefully...`));try{s&&(U(s),s=null),i&&await new Promise((e=>{i.close((()=>{i=null,e()}))})),n&&"function"==typeof n.close&&(await n.close(),n=null),a.info(v.green("✅ Graceful shutdown completed")),process.exit(0)}catch(e){a.error(v.red(`❌ Error during graceful shutdown: ${e}`)),process.exit(1)}};process.on("SIGINT",(()=>c("SIGINT"))),process.on("SIGTERM",(()=>c("SIGTERM"))),process.on("uncaughtException",(e=>{a.error(v.red(`❌ Uncaught Exception: ${e}`)),c("uncaughtException")})),process.on("unhandledRejection",((e,t)=>{a.error(v.red(`❌ Unhandled Rejection at: ${t}, reason: ${e}`)),c("unhandledRejection")})),await l()})),G.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)").action((async(o,n)=>{V(n);const i=Z(n);try{const l=await s({mode:n.mode||"production",command:"build"},n.config,o,n.logLevel);let c=await f();if(l){const{plugins:e,...t}=l.config;c=r(c,t)}const d=r(c,{root:o,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await a(d),i.changelog){const s=o||process.cwd(),r=d.build?.outDir||"dist";let a="";if("string"==typeof i.changelog)a=e.resolve(s,i.changelog);else{const o=e.resolve(s,d.ppDevConfig?.syncBackupsDir||"backups");if(!t.existsSync(o))return void w(n.logLevel).warn(v.yellow("backups directory not found, skipping changelog generation"));const i=t.readdirSync(o,{withFileTypes:!0});if(!i.length)return void w(n.logLevel).warn(v.yellow("no backups found, skipping changelog generation"));const r=i.filter((e=>e.isFile()&&e.name.endsWith(".zip"))).reduce(((n,i)=>t.statSync(e.resolve(o,n.name)).mtimeMs>t.statSync(e.resolve(o,i.name)).mtimeMs?n:i),i[0]).name;a=e.resolve(o,r)}const l=e.resolve(s,r);let c="dist-zip";d.ppDevConfig&&(!1===d.ppDevConfig.distZip?c=d.build?.outDir||"dist":"object"==typeof d.ppDevConfig.distZip&&"string"==typeof d.ppDevConfig.distZip.outDir&&(c=d.ppDevConfig.distZip.outDir));const p=new z({oldAssetsPath:a,newAssetsPath:l,destinationPath:e.resolve(s,c)});await p.generateChangelog()}}catch(e){w(n.logLevel).error(v.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{B((e=>w(n.logLevel).info(e)))}})),G.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)=>{V(n);const{oldAssetsPath:i=t,newAssetsPath:s=o,destination:r=".",filename:a="CHANGELOG.html",logLevel:l}=n,c=process.cwd();i&&s||(w(l).error(v.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const d=e.resolve(c,i),p=e.resolve(c,s),f=e.resolve(c,r),h=new z({oldAssetsPath:d,newAssetsPath:p,destinationPath:f,changelogFilename:a});await h.generateChangelog()})),G.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)=>{V(n);const{source:i=t,destination:s=o,fontName:r="icon-font"}=n,a=process.cwd(),l=e.resolve(a,i),c=e.resolve(a,s),d=new H({sourceDir:l,outputDir:c,fontName:r}),p=w(n.logLevel);p.info(`Generating icon font from SVG files in ${v.dim(l)}`),await d.generate(),p.info(`Icon font generated and saved to ${v.dim(c)}`)})),G.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=await s({mode:t.mode||"production",command:"build"},t.config,e,t.logLevel);let n=await f();if(o){const{plugins:e,...t}=o.config;n=r(n,t)}const i=await l(r(n,{root:e,base:t.base,configFile:t.config,logLevel:t.logLevel,mode:t.mode}),"serve");await c(i,t.force,!0)}catch(e){w(t.logLevel).error(v.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})),G.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=await s({mode:t.mode||"production",command:"build"},t.config,e,t.logLevel);let n=await f();if(o){const{plugins:e,...t}=o.config;n=r(n,t)}(await d(r(n,{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){w(t.logLevel).error(v.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{B((e=>w(t.logLevel).info(e)))}})),G.help(),G.version(h),G.parse();export{B as stopProfiler};
2
2
  //# sourceMappingURL=cli.js.map
@@ -1,2 +1,2 @@
1
- import{n as e,v as t}from"./plugin-_rCgP0h-.js";import*as n from"fs";import{readFileSync as a,existsSync as s,readdirSync as i,writeFileSync as o,unlink as r}from"fs";import*as c from"path";import p,{resolve as l}from"path";import{fileURLToPath as m,pathToFileURL as u}from"url";import{normalizePath as f}from"vite";import{compile as d}from"ejs";const g=l("undefined"!=typeof __filename&&__filename||m(import.meta.url),"../../.."),h=l("undefined"!=typeof __filename&&__filename||m(import.meta.url),"../.."),j=s(l(g,"package.json"))?g:h,v=l(j,"dist/client/client.js"),{version:w,name:y}=JSON.parse(a(l(j,"package.json")).toString()),b=w,x=y,$=[".pp-watch.config.js",".pp-watch.config.ts",".pp-watch.config.json"],D=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"];const _=new class{cache=new Map;_maxSize;constructor(e=10){this._maxSize=e}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=e}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this._maxSize){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}clear(){this.cache.clear()}has(e){return this.cache.has(e)}}(5),S=new Map,P=c.dirname("undefined"!=typeof __filename&&__filename||m(new URL(".",import.meta.url))),k=`/${x}/client`,E=`/${k}`,I=new RegExp(`^\\/?${x}\\/client\\/(.*)$`);const N={templateCompilations:0,cacheHits:0,totalRequests:0};function O(e){let t="",a=!1,s=null;return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${x}/client`),e),resolveId(e){if(I.test(e))return{id:f(c.join(j,"dist/client",e.replace(I,"$1")))}},transformIndexHtml:async(e,i)=>{N.totalRequests++;const o=i.server?.config.base||"";o!==t&&(t=o,a=!0,s=null),s&&!a||(_.has(t)?(s=_.get(t),N.cacheHits++):(s=function(e,t=!0){const a=e;if(t&&_.has(a))return _.get(a);const s=c.resolve(P,"client","index.html");let i;S.has(s)?i=S.get(s):(i=n.readFileSync(s,{encoding:"utf8"}),S.set(s,i));const o=E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=d(i.replace(new RegExp(o,"g"),c.posix.join(e,k)),{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:s,rmWhitespace:!0,compileDebug:!1});return t&&_.set(a,r),r}(t,true),N.templateCompilations++),a=!1);const r=function(e){return{css:c.posix.join(e,x,"client/client.css"),js:c.posix.join(e,x,"client/client.js")}}(t),p={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:r.css}}]},{backendBaseURL:l,templateLess:m,portalPageId:u,canSync:f=!0}=i.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:x,VERSION:b,backendBaseURL:l,templateLess:m,portalPageId:u,canSync:f};return p.tags.push({tag:"div",injectTo:"body-prepend",children:await s(g)}),p.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:r.js,type:"module"}}),p},configureServer(e){const t=f(c.resolve(e.config.root,c.dirname(v)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t),e.middlewares.use("/@api/__pp-dev-metrics",((e,t)=>{t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(N,null,2))}))},closeBundle(){_.clear(),S.clear()}}}const R=(e,t)=>` * ${t}`;function z(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,R)}\n */`}async function L(){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 T(){try{return await import("next"),!0}catch(e){return!1}}async function C(){try{return(await import("next/package.json")).version}catch{return null}}const F=new Map,B=3e4;let H=null;function M(){const e=Date.now();if(H&&e-H.timestamp<6e4)return H.data;const t=process.cwd();try{const n=JSON.parse(a(p.resolve(t,"package.json"),{encoding:"utf-8",flag:"r"}));return H={data:n,timestamp:e},n}catch{const t={};return H={data:t,timestamp:e},t}}let U=null;async function V(e){const t=process.cwd(),n=`ts:${e}`,a=F.get(n);if(a&&Date.now()-a.timestamp<B)return a.data;let i=!1;if(/\.m[jt]s$/.test(e))i=!0;else if(/\.c[jt]s$/.test(e))i=!1;else{const e=M();i=!!e&&"module"===e.type}const c=await async function(){return U||(U=await import("esbuild")),U}(),l=await c.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:["node14.18","node16"],platform:"node",bundle:!0,format:i?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:m}=l.outputFiles[0],f=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,d=u(p.resolve(t,f)).toString();o(f,m);let g={};try{const t=(await import(d)).default;g=t?.default||t,F.set(n,{data:g,timestamp:Date.now(),filePath:e})}finally{s(f)&&r(f,(()=>{}))}return g}async function q(e){const t=`js:${e}`,n=F.get(t);if(n&&Date.now()-n.timestamp<B)return n.data;const a=(await import(u(e).toString())).default;return F.set(t,{data:a,timestamp:Date.now(),filePath:e}),a}async function A(e){const t=`json:${e}`,n=F.get(t);if(n&&Date.now()-n.timestamp<B)return n.data;const s=JSON.parse(a(e,{encoding:"utf-8"}));return F.set(t,{data:s,timestamp:Date.now(),filePath:e}),s}let J=null;async function W(e,t){for(const n of t)if(e.includes(n)){if(/\.[cm]?ts$/i.test(n))return await V(n);if(/\.[cm]?js$/i.test(n))return await q(p.resolve(".",n));if(n.endsWith(".json"))return await A(p.resolve(".",n))}return null}function G(){return M()}async function K(){const e=function(){const e=Date.now();if(J&&e-J.timestamp<1e4)return J.files;const t=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,n=process.cwd(),a=i(n,{withFileTypes:!0}).filter((e=>e.isFile()&&t.test(e.name))).map((e=>e.name));return J={files:a,timestamp:e},a}();let t={},n=!1;const a=await W(e,D);if(a&&(t=a,n=!0),e.length&&!n){const a=await W(e,$);a&&(t={backendBaseURL:a.baseURL,portalPageId:a.portalPageId},n=!0)}const s=M();return n||"object"!=typeof s["pp-dev"]||(t=s["pp-dev"]),t}const Z=Object.freeze({__proto__:null,clearConfigCache:function(){F.clear(),H=null,J=null},getConfig:K,getPkg:G});async function Q(){const n=G().name,a=await K(),s=e(Object.assign(a,{templateName:n})),i=[t(s),O()],{outDir:o,distZip:r,imageOptimizer:c,templateLess:p,integrateMiTopBar:l}=s;if(l&&i.push({name:"mi-topbar-plugin",transformIndexHtml:()=>[{tag:"script",injectTo:"body",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"body",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head",attrs:{href:"/css/main.css",rel:"stylesheet"}},{tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}]}),c){const{ViteImageOptimizer:e}=await import("vite-plugin-image-optimizer");i.push(e("object"==typeof c?c:void 0))}if(r){const{default:e}=await import("vite-plugin-zip-pack");i.push({...e("object"==typeof r?r:{outFileName:`${n}.zip`}),enforce:"post"})}return{base:p?`/p/${n}`:`/pt/${n}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:z}},outDir:o},css:{modules:{localsConvention:"dashes"},scss:{api:"modern"}},ppDevConfig:s,plugins:i}}function X(e){return e?.experimental?.ppDev||e?.ppDev||{}}function Y(e,t,n){return Object.assign({},e,t,n)}function ee(e,t){return async(n,a={})=>{try{const{constants:s}=await L(),{PHASE_DEVELOPMENT_SERVER:i}=s,o=await K(),r=G().name,c="function"==typeof e?await e(n,a):e,p=X(c),l=n===i,m=function(e,t,n,a){return n?t?`/p/${e}`:`/pl/${e}`:a?`/pt/${e}`:`/pl/${e}`}(r,o.templateLess??!1,l,o.v7Features??!1),u={basePath:m,trailingSlash:!!l||void 0};if(l){const e=function(e,t){const{appId:n,portalPageId:a,backendBaseURL:s,templateLess:i,v7Features:o,...r}=t,c=n||a,p={backendBaseURL:s,portalPageId:c,appId:c,templateLess:i,v7Features:o,...r};return{serverRuntimeConfig:{templateName:e,ppDevConfig:p},publicRuntimeConfig:{templateName:e,ppDevConfig:p},experimental:{ppDev:p}}}(r,Object.assign({},o,p,t));return Y(u,c,e)}return Y(u,c)}catch(t){console.error("Error in withPPDev:",t),console.warn("Falling back to original Next.js configuration");try{return"function"==typeof e?await e(n,a):e}catch(e){return console.error("Error in fallback configuration:",e),{}}}}}export{D as P,b as V,$ as a,X as b,C as c,Z as d,Q as g,T as i,L as s,ee as w};
2
- //# sourceMappingURL=index-CmcaJY7U.js.map
1
+ import{n as e,v as t}from"./plugin-_rCgP0h-.js";import*as n from"fs";import{readFileSync as a,existsSync as s,readdirSync as i,writeFileSync as o,unlink as r}from"fs";import*as c from"path";import p,{resolve as l}from"path";import{fileURLToPath as m,pathToFileURL as u}from"url";import{normalizePath as f}from"vite";import{compile as d}from"ejs";const g=l("undefined"!=typeof __filename&&__filename||m(import.meta.url),"../../.."),h=l("undefined"!=typeof __filename&&__filename||m(import.meta.url),"../.."),j=s(l(g,"package.json"))?g:h,v=l(j,"dist/client/client.js"),{version:w,name:y}=JSON.parse(a(l(j,"package.json")).toString()),b=w,x=y,$=[".pp-watch.config.js",".pp-watch.config.ts",".pp-watch.config.json"],D=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"];const _=new class{cache=new Map;_maxSize;constructor(e=10){this._maxSize=e}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=e}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this._maxSize){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}clear(){this.cache.clear()}has(e){return this.cache.has(e)}}(5),S=new Map,P=c.dirname("undefined"!=typeof __filename&&__filename||m(new URL(".",import.meta.url))),k=`/${x}/client`,E=`/${k}`,I=new RegExp(`^\\/?${x}\\/client\\/(.*)$`);const N={templateCompilations:0,cacheHits:0,totalRequests:0};function O(e){let t="",a=!1,s=null;return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${x}/client`),e),resolveId(e){if(I.test(e))return{id:f(c.join(j,"dist/client",e.replace(I,"$1")))}},transformIndexHtml:async(e,i)=>{N.totalRequests++;const o=i.server?.config.base||"";o!==t&&(t=o,a=!0,s=null),s&&!a||(_.has(t)?(s=_.get(t),N.cacheHits++):(s=function(e,t=!0){const a=e;if(t&&_.has(a))return _.get(a);const s=c.resolve(P,"client","index.html");let i;S.has(s)?i=S.get(s):(i=n.readFileSync(s,{encoding:"utf8"}),S.set(s,i));const o=E.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=d(i.replace(new RegExp(o,"g"),c.posix.join(e,k)),{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:s,rmWhitespace:!0,compileDebug:!1});return t&&_.set(a,r),r}(t,true),N.templateCompilations++),a=!1);const r=function(e){return{css:c.posix.join(e,x,"client/client.css"),js:c.posix.join(e,x,"client/client.js")}}(t),p={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:r.css}}]},{backendBaseURL:l,templateLess:m,portalPageId:u,canSync:f=!0}=i.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:x,VERSION:b,backendBaseURL:l,templateLess:m,portalPageId:u,canSync:f};return p.tags.push({tag:"div",injectTo:"body-prepend",children:await s(g)}),p.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:r.js,type:"module"}}),p},configureServer(e){const t=f(c.resolve(e.config.root,c.dirname(v)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t),e.middlewares.use("/@api/__pp-dev-metrics",((e,t)=>{t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(N,null,2))}))},closeBundle(){_.clear(),S.clear()}}}const R=(e,t)=>` * ${t}`;function z(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,R)}\n */`}async function L(){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 T(){try{return await import("next"),!0}catch(e){return!1}}async function C(){try{return(await import("next/package.json")).version}catch{return null}}const F=new Map,B=3e4;let H=null;function M(){const e=Date.now();if(H&&e-H.timestamp<6e4)return H.data;const t=process.cwd();try{const n=JSON.parse(a(p.resolve(t,"package.json"),{encoding:"utf-8",flag:"r"}));return H={data:n,timestamp:e},n}catch{const t={};return H={data:t,timestamp:e},t}}let U=null;async function V(e){const t=process.cwd(),n=`ts:${e}`,a=F.get(n);if(a&&Date.now()-a.timestamp<B)return a.data;let i=!1;if(/\.m[jt]s$/.test(e))i=!0;else if(/\.c[jt]s$/.test(e))i=!1;else{const e=M();i=!!e&&"module"===e.type}const c=await async function(){return U||(U=await import("esbuild")),U}(),l=await c.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:["node14.18","node16"],platform:"node",bundle:!0,format:i?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:m}=l.outputFiles[0],f=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,d=u(p.resolve(t,f)).toString();o(f,m);let g={};try{const t=(await import(d)).default;g=t?.default||t,F.set(n,{data:g,timestamp:Date.now(),filePath:e})}finally{s(f)&&r(f,(()=>{}))}return g}async function q(e){const t=`js:${e}`,n=F.get(t);if(n&&Date.now()-n.timestamp<B)return n.data;const a=(await import(u(e).toString())).default;return F.set(t,{data:a,timestamp:Date.now(),filePath:e}),a}async function A(e){const t=`json:${e}`,n=F.get(t);if(n&&Date.now()-n.timestamp<B)return n.data;const s=JSON.parse(a(e,{encoding:"utf-8"}));return F.set(t,{data:s,timestamp:Date.now(),filePath:e}),s}let J=null;async function W(e,t){for(const n of t)if(e.includes(n)){if(/\.[cm]?ts$/i.test(n))return await V(n);if(/\.[cm]?js$/i.test(n))return await q(p.resolve(".",n));if(n.endsWith(".json"))return await A(p.resolve(".",n))}return null}function G(){return M()}async function K(){const e=function(){const e=Date.now();if(J&&e-J.timestamp<1e4)return J.files;const t=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,n=process.cwd(),a=i(n,{withFileTypes:!0}).filter((e=>e.isFile()&&t.test(e.name))).map((e=>e.name));return J={files:a,timestamp:e},a}();let t={},n=!1;const a=await W(e,D);if(a&&(t=a,n=!0),e.length&&!n){const a=await W(e,$);a&&(t={backendBaseURL:a.baseURL,portalPageId:a.portalPageId},n=!0)}const s=M();return n||"object"!=typeof s["pp-dev"]||(t=s["pp-dev"]),t}const Z=Object.freeze({__proto__:null,clearConfigCache:function(){F.clear(),H=null,J=null},getConfig:K,getPkg:G});async function Q(){const n=G().name,a=await K(),s=e(Object.assign(a,{templateName:n})),i=[t(s),O()],{outDir:o,distZip:r,imageOptimizer:c,templateLess:p,integrateMiTopBar:l}=s;if(l&&i.push({name:"mi-topbar-plugin",transformIndexHtml:()=>[{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"}},{tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}]}),c){const{ViteImageOptimizer:e}=await import("vite-plugin-image-optimizer");i.push(e("object"==typeof c?c:void 0))}if(r){const{default:e}=await import("vite-plugin-zip-pack");i.push({...e("object"==typeof r?r:{outFileName:`${n}.zip`}),enforce:"post"})}return{base:p?`/p/${n}`:`/pt/${n}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:z}},outDir:o},css:{modules:{localsConvention:"dashes"},scss:{api:"modern"}},ppDevConfig:s,plugins:i}}function X(e){return e?.experimental?.ppDev||e?.ppDev||{}}function Y(e,t,n){return Object.assign({},e,t,n)}function ee(e,t){return async(n,a={})=>{try{const{constants:s}=await L(),{PHASE_DEVELOPMENT_SERVER:i}=s,o=await K(),r=G().name,c="function"==typeof e?await e(n,a):e,p=X(c),l=n===i,m=function(e,t,n,a){return n?t?`/p/${e}`:`/pl/${e}`:a?`/pt/${e}`:`/pl/${e}`}(r,o.templateLess??!1,l,o.v7Features??!1),u={basePath:m,trailingSlash:!!l||void 0};if(l){const e=function(e,t){const{appId:n,portalPageId:a,backendBaseURL:s,templateLess:i,v7Features:o,...r}=t,c=n||a,p={backendBaseURL:s,portalPageId:c,appId:c,templateLess:i,v7Features:o,...r};return{serverRuntimeConfig:{templateName:e,ppDevConfig:p},publicRuntimeConfig:{templateName:e,ppDevConfig:p},experimental:{ppDev:p}}}(r,Object.assign({},o,p,t));return Y(u,c,e)}return Y(u,c)}catch(t){console.error("Error in withPPDev:",t),console.warn("Falling back to original Next.js configuration");try{return"function"==typeof e?await e(n,a):e}catch(e){return console.error("Error in fallback configuration:",e),{}}}}}export{D as P,b as V,$ as a,X as b,C as c,Z as d,Q as g,T as i,L as s,ee as w};
2
+ //# sourceMappingURL=index-DboCTg4P.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CmcaJY7U.js","sources":["../../../src/constants.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/config.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","url","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PP_WATCH_CONFIG_NAMES","PP_DEV_CONFIG_NAMES","templateCache","cache","Map","_maxSize","constructor","maxSize","this","value","get","key","has","delete","set","size","firstKey","keys","next","undefined","clear","fileCache","DIRNAME","path","dirname","URL","PACKAGE_IMPORT","CLIENT_PATH","PACKAGE_REGEXP","RegExp","performanceMetrics","templateCompilations","cacheHits","totalRequests","clientInjectionPlugin","opts","base","baseChanged","currentTemplate","apply","config","optimizeDeps","exclude","push","resolveId","source","test","id","normalizePath","join","replace","transformIndexHtml","async","html","ctx","serverBase","server","enableCache","cacheKey","templatePath","templateContent","fs","encoding","escapedClientPath","compiledTemplate","compile","posix","openDelimiter","closeDelimiter","filename","rmWhitespace","compileDebug","getTemplate","assetPaths","css","js","getAssetPaths","result","tags","tag","injectTo","attrs","rel","href","backendBaseURL","templateLess","portalPageId","canSync","templateData","children","src","type","configureServer","clientDir","root","allow","middlewares","use","req","res","setHeader","end","stringify","closeBundle","replacer","substring","$1","header","chunk","safeNextImport","constants","Promise","all","import","default","error","Error","isNextAvailable","getNextVersion","configCache","CACHE_TTL","packageJsonCache","getPackageJson","now","Date","timestamp","data","cwd","process","flag","empty","esbuildModule","loadTsConfig","filePath","cached","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","slice","fileUrl","pathToFileURL","writeFileSync","conf","unlink","loadJsConfig","loadJSONConfig","dirContentCache","loadConfig","dirFiles","configNames","configName","includes","endsWith","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","filter","isFile","map","getDirectoryContent","configFound","newConfig","length","watchConfig","baseURL","getViteConfig","templateName","ppDevConfig","normalizedPPDevConfig","normalizeVitePPDevConfig","Object","assign","plugins","vitePPDev","outDir","distZip","imageOptimizer","integrateMiTopBar","defer","ViteImageOptimizer","zipPack","outFileName","enforce","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","scss","api","getPPDevConfigFromNextConfig","nextConfig","experimental","ppDev","mergeConfigs","baseConfig","nextConfiguration","additionalConfig","withPPDev","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","nextConfigPPDev","isDevelopment","basePath","v7Features","createBasePath","trailingSlash","runtimeConfig","devConfig","appId","originalAppId","rest","normalizedConfig","serverRuntimeConfig","publicRuntimeConfig","createRuntimeConfig","console","warn","fallbackError"],"mappings":"0VAIA,MAAMA,EAAkBC,EAEC,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,YAGIC,EAAmBJ,EAEA,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,SAGWE,EAAqBC,EAAWN,EAAQD,EAAiB,iBAAmBA,EAAkBK,EAM9FG,EAAsBP,EAAQK,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAaZ,EAAQK,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAEfO,EAAwB,CAAC,sBAAuB,sBAAuB,yBAEvEC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCoCF,MAAMC,EAAgB,IApDtB,MACUC,MAAQ,IAAIC,IACZC,SAER,WAAAC,CAAYC,EAAkB,IAC5BC,KAAKH,SAAWE,EAGlB,WAAIA,GACF,OAAOC,KAAKH,SAGd,WAAIE,CAAQE,GACVD,KAAKH,SAAWI,EAGlB,GAAAC,CAAIC,GACF,GAAIH,KAAKL,MAAMS,IAAID,GAAM,CACvB,MAAMF,EAAQD,KAAKL,MAAMO,IAAIC,GAK7B,OAHAH,KAAKL,MAAMU,OAAOF,GAClBH,KAAKL,MAAMW,IAAIH,EAAKF,GAEbA,GAKX,GAAAK,CAAIH,EAAQF,GACV,GAAID,KAAKL,MAAMS,IAAID,GACjBH,KAAKL,MAAMU,OAAOF,QACb,GAAIH,KAAKL,MAAMY,MAAQP,KAAKH,SAAU,CAC3C,MAAMW,EAAWR,KAAKL,MAAMc,OAAOC,OAAOT,WAEzBU,IAAbH,GACFR,KAAKL,MAAMU,OAAOG,GAItBR,KAAKL,MAAMW,IAAIH,EAAKF,GAGtB,KAAAW,GACEZ,KAAKL,MAAMiB,QAGb,GAA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GAEfE,oBAAqB,CACnBpD,eACAC,YAAaiD,GAEfrB,aAAc,CACZC,MAAOoB,GAGb,CA+E8BG,CAAoBrD,EADxBI,OAAOC,OAAO,CAAE,EAAE1J,EAAQ4L,EAAiBtC,IAG7D,OAAO8B,EAAaC,EAAYC,EAAmBY,GAIrD,OAAOd,EAAaC,EAAYC,GAChC,MAAO3G,GACPgI,QAAQhI,MAAM,sBAAuBA,GACrCgI,QAAQC,KAAK,kDAGb,IAKE,MAH0B,mBAAjBnB,QACGA,EAAaC,EAAOT,GAC1BQ,EAEN,MAAOoB,GAGP,OAFAF,QAAQhI,MAAM,mCAAoCkI,GAE3C,CAAE,IAIjB"}
1
+ {"version":3,"file":"index-DboCTg4P.js","sources":["../../../src/constants.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/config.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","url","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PP_WATCH_CONFIG_NAMES","PP_DEV_CONFIG_NAMES","templateCache","cache","Map","_maxSize","constructor","maxSize","this","value","get","key","has","delete","set","size","firstKey","keys","next","undefined","clear","fileCache","DIRNAME","path","dirname","URL","PACKAGE_IMPORT","CLIENT_PATH","PACKAGE_REGEXP","RegExp","performanceMetrics","templateCompilations","cacheHits","totalRequests","clientInjectionPlugin","opts","base","baseChanged","currentTemplate","apply","config","optimizeDeps","exclude","push","resolveId","source","test","id","normalizePath","join","replace","transformIndexHtml","async","html","ctx","serverBase","server","enableCache","cacheKey","templatePath","templateContent","fs","encoding","escapedClientPath","compiledTemplate","compile","posix","openDelimiter","closeDelimiter","filename","rmWhitespace","compileDebug","getTemplate","assetPaths","css","js","getAssetPaths","result","tags","tag","injectTo","attrs","rel","href","backendBaseURL","templateLess","portalPageId","canSync","templateData","children","src","type","configureServer","clientDir","root","allow","middlewares","use","req","res","setHeader","end","stringify","closeBundle","replacer","substring","$1","header","chunk","safeNextImport","constants","Promise","all","import","default","error","Error","isNextAvailable","getNextVersion","configCache","CACHE_TTL","packageJsonCache","getPackageJson","now","Date","timestamp","data","cwd","process","flag","empty","esbuildModule","loadTsConfig","filePath","cached","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","slice","fileUrl","pathToFileURL","writeFileSync","conf","unlink","loadJsConfig","loadJSONConfig","dirContentCache","loadConfig","dirFiles","configNames","configName","includes","endsWith","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","filter","isFile","map","getDirectoryContent","configFound","newConfig","length","watchConfig","baseURL","getViteConfig","templateName","ppDevConfig","normalizedPPDevConfig","normalizeVitePPDevConfig","Object","assign","plugins","vitePPDev","outDir","distZip","imageOptimizer","integrateMiTopBar","defer","ViteImageOptimizer","zipPack","outFileName","enforce","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","scss","api","getPPDevConfigFromNextConfig","nextConfig","experimental","ppDev","mergeConfigs","baseConfig","nextConfiguration","additionalConfig","withPPDev","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","nextConfigPPDev","isDevelopment","basePath","v7Features","createBasePath","trailingSlash","runtimeConfig","devConfig","appId","originalAppId","rest","normalizedConfig","serverRuntimeConfig","publicRuntimeConfig","createRuntimeConfig","console","warn","fallbackError"],"mappings":"0VAIA,MAAMA,EAAkBC,EAEC,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,YAGIC,EAAmBJ,EAEA,oBAAfC,YAA8BA,YAAeC,cAA0BC,KAC/E,SAGWE,EAAqBC,EAAWN,EAAQD,EAAiB,iBAAmBA,EAAkBK,EAM9FG,EAAsBP,EAAQK,EAAoB,0BA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B,QACGA,EAAaC,EAAOT,GAC1BQ,EAEN,MAAOoB,GAGP,OAFAF,QAAQhI,MAAM,mCAAoCkI,GAE3C,CAAE,IAIjB"}
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export{A as AuthProvider,h as authProvider}from"./plugin-_rCgP0h-.js";export{c as getNextVersion,b as getPPDevConfigFromNextConfig,g as getViteConfig,i as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-CmcaJY7U.js";import"http-proxy-middleware";import"vite";import"picocolors";import"axios";import"jsdom";import"https";import"memory-cache";import"path";import"fs";import"url";import"crypto";import"process";import"child_process";import"console";import"zlib";import"express";import"ejs";
1
+ export{A as AuthProvider,h as authProvider}from"./plugin-_rCgP0h-.js";export{c as getNextVersion,b as getPPDevConfigFromNextConfig,g as getViteConfig,i as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-DboCTg4P.js";import"http-proxy-middleware";import"vite";import"picocolors";import"axios";import"jsdom";import"https";import"memory-cache";import"path";import"fs";import"url";import"crypto";import"process";import"child_process";import"console";import"zlib";import"express";import"ejs";
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "module",
4
- "version": "0.12.3-beta.1",
4
+ "version": "0.12.4-beta.1",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "repository": {
94
94
  "type": "git",
95
- "url": "git+https://github.com/mi-examples/pp-dev-js.git"
95
+ "url": "git+https://github.com/mi-examples/pp-dev.git"
96
96
  },
97
97
  "keywords": [
98
98
  "mi",
@@ -103,8 +103,8 @@
103
103
  "helper"
104
104
  ],
105
105
  "bugs": {
106
- "url": "https://github.com/mi-examples/pp-dev-js/issues"
106
+ "url": "https://github.com/mi-examples/pp-dev/issues"
107
107
  },
108
- "homepage": "https://github.com/mi-examples/pp-dev-js#readme",
108
+ "homepage": "https://github.com/mi-examples/pp-dev#readme",
109
109
  "private": false
110
110
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "module",
4
- "version": "0.12.3",
4
+ "version": "0.12.4",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -22,9 +22,17 @@
22
22
  "postbuild": "npm pack && node scripts/rename-pack.js",
23
23
  "startup:optimize": "tsx scripts/startup-optimizer.js",
24
24
  "startup:profile": "node --prof bin/pp-dev.js",
25
- "test": "cd test && npm run build",
26
25
  "release": "semantic-release",
27
- "version": "npm version --commit-hooks false --git-tag-version false"
26
+ "version": "npm version --commit-hooks false --git-tag-version false",
27
+ "test": "npm run test:all",
28
+ "test:unit": "vitest run --config vitest.config.ts",
29
+ "test:unit:watch": "vitest --config vitest.config.ts",
30
+ "test:unit:coverage": "vitest run --config vitest.config.ts --coverage",
31
+ "test:integration": "vitest run --config vitest.integration.config.ts",
32
+ "test:integration:watch": "vitest --config vitest.integration.config.ts",
33
+ "test:e2e": "node scripts/run-tests.js",
34
+ "test:e2e:ui": "npx playwright test --ui",
35
+ "test:all": "npm run test:unit && npm run test:integration"
28
36
  },
29
37
  "exports": {
30
38
  ".": {
@@ -96,6 +104,7 @@
96
104
  "winston": "^3.17.0"
97
105
  },
98
106
  "devDependencies": {
107
+ "@playwright/test": "^1.57.0",
99
108
  "@rollup/plugin-terser": "^0.4.4",
100
109
  "@rollup/plugin-typescript": "^12.1.1",
101
110
  "@rollup/plugin-url": "^8.0.2",
@@ -108,6 +117,7 @@
108
117
  "@types/jsdom": "^21.1.7",
109
118
  "@types/memory-cache": "^0.2.6",
110
119
  "@types/node": "^22.15.0",
120
+ "@vitest/coverage-v8": "^3.0.0",
111
121
  "esbuild": "^0.25.8",
112
122
  "prettier": "^3.3.3",
113
123
  "rimraf": "^6.0.1",
@@ -115,9 +125,10 @@
115
125
  "rollup-plugin-scss": "^4.0.1",
116
126
  "rollup-plugin-visualizer": "^5.12.0",
117
127
  "semantic-release": "^25.0.2",
118
- "semantic-release-monorepo": "^8.0.2",
119
128
  "tslib": "^2.8.1",
120
- "tsx": "^4.19.2"
129
+ "tsx": "^4.19.2",
130
+ "vitest": "^3.0.0",
131
+ "yargs": "^17.7.2"
121
132
  },
122
133
  "files": [
123
134
  "bin",
@@ -134,7 +145,7 @@
134
145
  },
135
146
  "repository": {
136
147
  "type": "git",
137
- "url": "git+https://github.com/mi-examples/pp-dev-js.git"
148
+ "url": "git+https://github.com/mi-examples/pp-dev.git"
138
149
  },
139
150
  "keywords": [
140
151
  "mi",
@@ -145,7 +156,7 @@
145
156
  "helper"
146
157
  ],
147
158
  "bugs": {
148
- "url": "https://github.com/mi-examples/pp-dev-js/issues"
159
+ "url": "https://github.com/mi-examples/pp-dev/issues"
149
160
  },
150
- "homepage": "https://github.com/mi-examples/pp-dev-js#readme"
161
+ "homepage": "https://github.com/mi-examples/pp-dev#readme"
151
162
  }