@metricinsights/pp-dev 1.5.0-beta.20 → 1.5.0-beta.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +15 -9
  2. package/dist/README.md +15 -9
  3. package/dist/cjs/auth.provider-CyXyBAm3.js +2 -0
  4. package/dist/cjs/auth.provider-CyXyBAm3.js.map +1 -0
  5. package/dist/cjs/cli.js +1 -1
  6. package/dist/cjs/{index-DFNyrsll.js → index-CeIQtamz.js} +2 -2
  7. package/dist/cjs/index-CeIQtamz.js.map +1 -0
  8. package/dist/cjs/index.js +1 -1
  9. package/dist/cjs/migrate-C1svbbPB.js +2 -0
  10. package/dist/cjs/{migrate-D_y8SIv9.js.map → migrate-C1svbbPB.js.map} +1 -1
  11. package/dist/cjs/package.json +1 -1
  12. package/dist/cjs/plugin.js +1 -1
  13. package/dist/cjs/request-capture.middleware-Jk6Vxx40.js +2 -0
  14. package/dist/cjs/request-capture.middleware-Jk6Vxx40.js.map +1 -0
  15. package/dist/cjs/{version-manifest-DsHoDq-U.js → version-manifest-C15hpGGV.js} +2 -2
  16. package/dist/cjs/{version-manifest-DsHoDq-U.js.map → version-manifest-C15hpGGV.js.map} +1 -1
  17. package/dist/cjs/version-plugin-DtPQBhEK.js +2 -0
  18. package/dist/cjs/{version-plugin-Cm56j0DZ.js.map → version-plugin-DtPQBhEK.js.map} +1 -1
  19. package/dist/esm/auth.provider-Cq0EuReh.js +2 -0
  20. package/dist/esm/auth.provider-Cq0EuReh.js.map +1 -0
  21. package/dist/esm/cli.js +1 -1
  22. package/dist/esm/index-DioJ4R68.js +2 -0
  23. package/dist/esm/index-DioJ4R68.js.map +1 -0
  24. package/dist/esm/index.js +1 -1
  25. package/dist/esm/migrate-FpJKfYgz.js +2 -0
  26. package/dist/esm/{migrate-BHq9PUZz.js.map → migrate-FpJKfYgz.js.map} +1 -1
  27. package/dist/esm/package.json +1 -1
  28. package/dist/esm/plugin.js +1 -1
  29. package/dist/esm/plugin.js.map +1 -1
  30. package/dist/esm/request-capture.middleware-B9t-px8Z.js +2 -0
  31. package/dist/esm/request-capture.middleware-B9t-px8Z.js.map +1 -0
  32. package/dist/esm/{version-manifest-CuZrGM-C.js → version-manifest-qxz5FXuG.js} +2 -2
  33. package/dist/esm/{version-manifest-CuZrGM-C.js.map → version-manifest-qxz5FXuG.js.map} +1 -1
  34. package/dist/esm/version-plugin-b2xMXK9M.js +2 -0
  35. package/dist/esm/{version-plugin-CbEJf2b3.js.map → version-plugin-b2xMXK9M.js.map} +1 -1
  36. package/dist/types/index.d.ts +3 -2
  37. package/package.json +1 -1
  38. package/dist/cjs/auth.provider-CnmH_J2r.js +0 -2
  39. package/dist/cjs/auth.provider-CnmH_J2r.js.map +0 -1
  40. package/dist/cjs/index-DFNyrsll.js.map +0 -1
  41. package/dist/cjs/migrate-D_y8SIv9.js +0 -2
  42. package/dist/cjs/request-capture.middleware-BUpxzWDS.js +0 -2
  43. package/dist/cjs/request-capture.middleware-BUpxzWDS.js.map +0 -1
  44. package/dist/cjs/version-plugin-Cm56j0DZ.js +0 -2
  45. package/dist/esm/auth.provider-B9ybFjL5.js +0 -2
  46. package/dist/esm/auth.provider-B9ybFjL5.js.map +0 -1
  47. package/dist/esm/index-ypcJ5r5C.js +0 -2
  48. package/dist/esm/index-ypcJ5r5C.js.map +0 -1
  49. package/dist/esm/migrate-BHq9PUZz.js +0 -2
  50. package/dist/esm/request-capture.middleware-VCmWYJoS.js +0 -2
  51. package/dist/esm/request-capture.middleware-VCmWYJoS.js.map +0 -1
  52. package/dist/esm/version-plugin-CbEJf2b3.js +0 -2
package/dist/esm/cli.js CHANGED
@@ -1,2 +1,2 @@
1
- import{cac as e}from"cac";import{c as t,a as o,P as n,V as i,v as s,n as r,b as a,d as l,e as c,f as d,g as p,r as f}from"./auth.provider-B9ybFjL5.js";import*as u from"path";import{performance as g}from"node:perf_hooks";import{loadConfigFromFile as h,mergeConfig as m,build as w,resolveConfig as b,optimizeDeps as v,preview as y}from"vite";import{I as P,P as x,c as S,a as k,i as T,h as L,R as E,r as F,b as D,V as $,d as j,g as I,M as N,e as _,f as C,j as A,k as M,l as R,m as H,n as O,o as U,u as z,D as V,s as W,p as Z,q as B,t as G,z as q}from"./request-capture.middleware-VCmWYJoS.js";import{watch as J}from"chokidar";import{l as K,g as Y,s as X,c as Q,i as ee,r as te,a as oe,b as ne}from"./index-ypcJ5r5C.js";import*as ie from"fs";import{EventEmitter as se}from"node:events";import{parse as re}from"url";import{WebSocketServer as ae,WebSocket as le}from"ws";import*as ce from"dir-compare";import de from"diff-match-patch";import{isBinaryFile as pe}from"isbinaryfile";import*as fe from"os";import*as ue from"crypto";import{w as ge}from"./version-manifest-CuZrGM-C.js";import"picocolors";import"node:path";import"zlib";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"process";import"jszip";import"child_process";import"module";import"node:crypto";import"node:fs";import"node:os";import"express";import"node:net";import"node:module";import"./helpers.js";import"ejs";import"fs/promises";import"util";function he(e){return null!=e&&!1!==e}let me=null;const we=new WeakMap;function be(e,n){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;we.set(e,n);const i=t();n.print&&i.info(o.dim(o.green(" ➜"))+o.dim(" press ")+o.bold("h")+o.dim(" to show help"));const s=(n.customShortcuts??[]).filter(he).concat(ve);me?.(),me=null;let r=!1;const a=process.stdin.isPaused(),l=process.stdin,c=Boolean(l.isRaw),d=async t=>{if(""===t)return void function(e=process){"win32"===e.platform?e.emit("SIGINT","SIGINT"):e.kill(e.pid,"SIGINT")}();if(""===t)return void await e.close().finally(()=>process.exit(0));if(r)return;"h"===t&&i.info(["",o.bold(" Shortcuts"),...s.map(e=>o.dim(" press ")+o.bold(e.key)+o.dim(` to ${e.description}`))].join("\n"));const n=s.find(e=>e.key===t);n&&(r=!0,await n.action(e),r=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{me===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),a&&process.stdin.pause(),me=null)};me=f,p.on("close",f)}const ve=[{key:"r",description:"restart the server",async action(e){const t=we.get(e);await e.restart(),t&&be(e,{...t,print:!1})}},{key:"u",description:"show server url",action(e){e.config.logger.info(""),e.printUrls()}},{key:"o",description:"open in browser",action(e){e.openBrowser()}},{key:"c",description:"clear console",action(e){e.config.logger.clearScreen("error")}},{key:"q",description:"quit",async action(e){await e.close().finally(()=>process.exit())}},{key:"C",description:"clear proxy cache",action(e){e.cache&&(e.cache.clear(),e.config.logger.info("Proxy cache cleared"))}}];function ye(e){return e instanceof Error?e.stack??e.message:String(e)}function Pe({logger:e,knownRejections:t=[],shutdown:n,shutdownTimeoutMs:i=5e3,processRef:s=process}){let r=!1,a=0;const l=async(t,l)=>{if((e=>{a=Math.max(a,e)})(l),r)return void("SIGINT"!==t&&"SIGTERM"!==t&&"SIGHUP"!==t||(e.warn(o.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),s.exit(a)));r=!0,e.info(o.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const c=setTimeout(()=>{e.error(o.red(`⏰ Shutdown did not finish within ${i} ms, forcing exit`)),s.exit(1)},i);try{await n(),clearTimeout(c),e.info(o.green("✅ Graceful shutdown completed")),s.exit(a)}catch(t){clearTimeout(c),e.error(o.red(`❌ Error during graceful shutdown: ${ye(t)}`)),s.exit(1)}},c=()=>{l("SIGINT",0)},d=()=>{l("SIGTERM",0)},p=()=>{l("SIGHUP",0)},f=t=>{e.error(o.red(`❌ Uncaught exception: ${ye(t)}`)),l("uncaughtException",1)},u=n=>{const i=t.find(e=>e.matches(n));i?e.info(o.dim(i.message)):e.error(o.red(`❌ Unhandled promise rejection (the server keeps running): ${ye(n)}`))};return s.on("SIGINT",c),s.on("SIGTERM",d),s.on("SIGHUP",p),s.on("uncaughtException",f),s.on("unhandledRejection",u),()=>{s.off("SIGINT",c),s.off("SIGTERM",d),s.off("SIGHUP",p),s.off("uncaughtException",f),s.off("unhandledRejection",u)}}const xe=["--","c","config","base","l","logLevel","clearScreen","configLoader","profile","d","debug","f","filter","m","mode","force","w","changelog","distZip","distZipDir","distZipFilename","versionManifest","versionFileTemplate","webpack","turbopack"];function Se(e){const t={...e};for(const e of xe)delete t[e];return"sourcemap"in t&&(t.sourcemap="true"===t.sourcemap||"false"!==t.sourcemap&&t.sourcemap),"watch"in t&&(t.watch=t.watch?{}:void 0),t}const ke=["https","open","cors","strictPort","force"];function Te(e,t,i){const s=[...n,"package.json","next.config.js","next.config.mjs","next.config.ts","vite.config.js","vite.config.mjs","vite.config.ts",".env",".env.local",".env.development",".env.development.local"].map(t=>u.join(e,t)),r=J(s,{ignored:e=>{const t=u.basename(e);return/(^|[\/\\])\../.test(e)&&!t.startsWith(".env")&&!t.startsWith(".pp-dev")&&!t.startsWith(".pp-watch")},persistent:!0,ignoreInitial:!0,followSymlinks:!1});let a=null;return r.on("change",n=>{i(o.blue(`🔧 Config file changed: ${u.relative(e,n)}`)),a&&clearTimeout(a),a=setTimeout(async()=>{try{i(o.yellow("🔄 Restarting dev server due to config change...")),await t()}catch(e){i(o.red(`❌ Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{i(o.red(`❌ Config watcher error: ${e}`))}),{watcher:r}}function Le(e){e.watcher&&e.watcher.close()}function Ee(e){if(!e||"object"!=typeof e||!("message"in e))return!1;const t=String(e.message);return/Turbopack is not supported/i.test(t)||/native bindings are not available/i.test(t)||/Only WebAssembly \(WASM\) bindings were loaded/i.test(t)}const Fe=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};async function De(e){const{root:t,mode:o,command:n}=e,i=u.resolve(process.cwd(),t??".");K(o,i);const s=await h({mode:o,command:n},e.configFile,t,e.logLevel);let r=await Y(e.buildOverrides,{mode:o,root:i});if(s){const e={...s.config};delete e.plugins,r=m(r,e)}return{config:r,envDir:i}}let $e=global.__pp_dev_profile_session,je=0;const Ie=e=>{if($e)return new Promise((t,n)=>{$e.post("Profiler.stop",(i,{profile:s})=>{if(i)n(i);else{const n=u.resolve(`./pp-dev-profile-${je++}.cpuprofile`);ie.writeFileSync(n,JSON.stringify(s)),e(o.yellow(`CPU profile written to ${o.white(o.dim(n))}`)),$e=void 0,t()}})})};function Ne(e){e.once("error",()=>e.destroy()),e.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>e.destroy())}class _e{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;allowedHosts;constructor({allowedHosts:e=[]}={}){this.allowedHosts=e,this.wss=new ae({noServer:!0}),this.wss.on("connection",e=>this.onConnection(e)),this.wss.on("error",e=>this.fireLifecycle("error",e)),this.ws={on:(e,t)=>{"close"!==e&&"error"!==e?this.getEventSet(e).add(t):this.getLifecycleSet(e).add(t)},off:(e,t)=>{this.eventListeners.get(e)?.delete(t),"close"!==e&&"error"!==e||this.lifecycleListeners.get(e)?.delete(t)},send:(e,t)=>{if("string"==typeof e)for(const o of this.clients.keys())this.sendToSocket(o,e,t);else{const t=JSON.stringify(e);for(const e of this.clients.keys())e.readyState===le.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===x&&(S(e,this.allowedHosts)?(Ne(t),!0):(this.wss.handleUpgrade(e,t,o,t=>{this.wss.emit("connection",t,e)}),!0))}async close(){this.fireLifecycle("close");for(const e of this.clients.keys())e.terminate();this.clients.clear(),await new Promise(e=>this.wss.close(()=>e()))}onConnection(e){const t={send:(t,o)=>this.sendToSocket(e,t,o),socket:e};this.clients.set(e,t),e.on("message",e=>this.onMessage(t,e)),e.on("close",()=>this.clients.delete(e)),e.on("error",()=>{})}onMessage(e,o){let n;try{n=JSON.parse(o.toString())}catch{return}if(!n||"custom"!==n.type||"string"!=typeof n.event)return;const i=this.eventListeners.get(n.event);if(i)for(const o of i)try{o(n.data,e)}catch(e){t().error(`ws handler for "${n.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===le.OPEN&&e.send(JSON.stringify({type:"custom",event:t,data:o}))}fireLifecycle(e,t){for(const o of this.lifecycleListeners.get(e)??[])try{o(t)}catch{}}getEventSet(e){let t=this.eventListeners.get(e);return t||(t=new Set,this.eventListeners.set(e,t)),t}getLifecycleSet(e){let t=this.lifecycleListeners.get(e);return t||(t=new Set,this.lifecycleListeners.set(e,t)),t}}const Ce={matches:e=>e instanceof Error&&"Worker creator already registered"===e.message,message:"Next.js kept its Turbopack worker pool from before the restart ('Worker creator already registered')"};const Ae=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class Me{oldAssetsPath;newAssetsPath;destinationPath;changelogFilename;changelogTemplate='<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8" />\n <title>Changelog Diff</title>\n <style>\n tr,\n td {\n padding: 0;\n }\n .diff-file {\n margin-top: 20px;\n border: 1px solid #e1e4e8;\n border-radius: 6px;\n }\n .diff-file-title {\n padding: 10px 20px;\n background-color: #f6f8fa;\n border-bottom: 1px solid #e1e4e8;\n border-radius: 6px 6px 0 0;\n font-weight: bold;\n }\n .diff-file-title .renamed {\n font-weight: normal;\n }\n .diff-file-title .renamed .from {\n color: #cb2431;\n }\n .diff-file-title .renamed .to {\n color: #22863a;\n }\n .diff-file-title .added {\n color: #22863a;\n }\n .diff-file-title .deleted {\n color: #cb2431;\n }\n .diff-file-content {\n }\n .diff-table {\n tab-size: 8;\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n }\n .blob-num {\n position: relative;\n color: #1f2328;\n width: 1%;\n min-width: 50px;\n padding: 0 10px;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n line-height: 20px;\n text-align: right;\n white-space: nowrap;\n vertical-align: top;\n cursor: pointer;\n -webkit-user-select: none;\n user-select: none;\n }\n .blob-num.addition {\n background-color: #ccffd8;\n border-color: #1f883e;\n }\n .blob-num.deletion {\n background-color: #ffd7d5;\n border-color: #cf222e;\n }\n .blob-num::before {\n content: attr(data-line-number);\n }\n .blob-code {\n position: relative;\n padding: 0 10px 0 22px;\n vertical-align: top;\n color: #1f2329;\n }\n .blob-code.code-addition {\n background-color: #e6ffec;\n }\n .blob-code.code-deletion {\n background-color: #ffebe9;\n }\n .blob-code.skip,\n .blob-code.message {\n text-align: center;\n }\n .blob-code.skip .blob-code-inner,\n .blob-code.message .blob-code-inner {\n font-weight: bold;\n color: #6a737d;\n padding: 10px 0;\n }\n .blob-code-inner {\n display: table-cell;\n overflow: visible;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n word-wrap: anywhere;\n white-space: pre-wrap;\n }\n .blob-code-inner::before {\n content: attr(data-code-prefix);\n position: absolute;\n top: 1px;\n left: 8px;\n padding-right: 8px;\n }\n </style>\n </head>\n <body>\n <h1>Changelog Diff</h1>\n\n %FILES%\n </body>\n </html>';diffFileTemplateHandler;diffLineTemplateHandler;contextLines=3;logger;constructor(e){const{oldAssetsPath:n,newAssetsPath:i,destinationPath:s,changelogTemplate:r,diffFileTemplateHandler:a,diffLineTemplateHandler:l,changelogFilename:c,contextLines:d}=e;if(this.logger=t(),!n||!i||!s)throw new Error("Previous assets path, current assets path and destination path are required");if(n===i)throw new Error("Previous and current assets paths must be different");if(!this.isExists(n))throw new Error(`Previous assets path ${n} does not exist`);if(!this.isExists(i))throw new Error(`Current assets path ${i} does not exist`);if(this.isZipFile(n)){const e=u.resolve(fe.tmpdir(),ue.createHash("md5").update(n).digest("hex"));this.oldAssetsPath=this.unzipFile(n,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);return e})}else{if(!this.isFolder(n))throw new Error(`Invalid previous assets path ${n}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(n);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(i)){const e=u.resolve(fe.tmpdir(),ue.createHash("md5").update(i).digest("hex"));this.newAssetsPath=this.unzipFile(i,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Current assets path ${e} is empty`);return e})}else{if(!this.isFolder(i))throw new Error(`Invalid current assets path ${i}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(i);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${i} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=s,this.mkdirpSync(this.destinationPath),this.changelogFilename=c||"CHANGELOG.html",r&&(this.templateIsValid(r)?this.changelogTemplate=r:this.logger.warn(o.yellow("Invalid changelog template, using default"))),"function"==typeof a&&(this.diffFileTemplateHandler=a),"function"==typeof l&&(this.diffLineTemplateHandler=l),d&&(this.contextLines=d)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return ie.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return ie.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===ie.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){ie.existsSync(e)||ie.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){ie.rmSync(t,{force:!0,recursive:!0}),await Z(e,t)}normalizeAssetFolderPath(e){const t=ie.readdirSync(e);return 1===t.length&&ie.lstatSync(u.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(u.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${s=o??"",s.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var s}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(o.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await ce.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(Ae.test(e)&&(e=e.replace(Ae,"$1$3")),Ae.test(t)&&(t=t.replace(Ae,"$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 de,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let s=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:s+o+1,lineType:t})).slice(0,n);return-1!==t&&(s+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(u.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(u.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${t}</span> -> <span class="to">${o}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const t=e.path1&&e.name1?u.join(e.path1,e.name1):null,o=e.path2&&e.name2?u.join(e.path2,e.name2):null,n=this.pathToPosix(u.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&t)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&o)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&t&&o){const i=this.pathToPosix(u.join(".",e.relativePath,e.name1??"")),s=this.pathToPosix(u.join(".",e.relativePath,e.name2??"")),r=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${s}</span></span\n >`:n;return this.diffFileTemplate(r,await pe(t)||await pe(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(ie.readFileSync(t,"utf-8"),ie.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(o.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(o.green("Writing changelog file"));const n=this.changelogTemplate.split("%FILES%");n.splice(1,0,t);const i=n.join("");ie.writeFileSync(u.join(this.destinationPath,this.changelogFilename),i),this.logger.info(o.green(`Changelog file written to ${u.join(this.destinationPath,this.changelogFilename)}`))}}async function Re(e){const{changelog:n,executionRoot:i,newAssetsPath:s,backupsDirPath:r,changelogDestinationPath:a,logLevel:l}=e;let c;if("string"==typeof n)c=u.resolve(i,n);else{if(!ie.existsSync(r))return void t(l).warn(o.yellow("backups directory not found, skipping changelog generation"));const e=ie.readdirSync(r,{withFileTypes:!0});if(!e.length)return void t(l).warn(o.yellow("no backups found, skipping changelog generation"));const n=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!n.length)return void t(l).warn(o.yellow("no ZIP backups found, skipping changelog generation"));const i=n.reduce((e,t)=>ie.statSync(u.resolve(r,e.name)).mtimeMs>ie.statSync(u.resolve(r,t.name)).mtimeMs?e:t).name;c=u.resolve(r,i)}const d=new Me({oldAssetsPath:c,newAssetsPath:s,destinationPath:a});await d.generateChangelog()}class He{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){const{default:e}=await(import("svgtofont"));await e({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const Oe=e("pp-dev");Oe.option("-c, --config <file>","[string] use specified config file").option("--base <path>","[string] public base path (default: /)").option("-l, --logLevel <level>","[string] info | warn | error | silent").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("-d, --debug [feat]","[string | boolean] show debug logs").option("-f, --filter <filter>","[string] filter debug logs").option("-m, --mode <mode>","[string] set env mode"),function(e){e.command("[root]","start dev server").alias("serve").alias("dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--cors","[boolean] enable CORS").option("--strictPort","[boolean] exit if specified port is already in use").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Fe(n);let s=null,r=null,a=!1;const l=e?u.resolve(process.cwd(),e):process.cwd(),c=t(n.logLevel),d=async()=>{if(!a){a=!0;try{s&&(c.info(o.yellow("🛑 Stopping existing dev server...")),await s.close(),s=null);const{clearConfigCache:p,getConfig:f}=await import("./index-ypcJ5r5C.js").then(e=>e.h);p();const{createServer:u}=await(import("vite")),h=n.mode||"development",{config:w,envDir:b}=await De({root:e,mode:h,command:"serve",configFile:n.config,logLevel:n.logLevel});if(s=await u(m(w,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:Se(n),customLogger:c},!0)),!s.config.base||"/"===s.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!s.httpServer)throw new Error("HTTP server not available");await s.listen();const v=global.__pp_dev_start_time??!1,y=v?o.dim(`ready in ${o.reset(o.bold(Math.ceil(g.now()-v)))} ms`):"";c.info(`\n ${o.green(`${o.bold("PP-DEV")} v${i}`)} ${y}\n`),s.printUrls();const x=await f(b);if(!1!==x.inspector?.enabled){const e=s.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${s.config.server.port??5173}`;c.info(`\n ${o.cyan("🔍 Request Inspector")} ${o.dim(t+P)}\n`)}be(s,{print:!0,customShortcuts:[...(t=c.info,$e?[{key:"p",description:"start/stop the profiler",async action(){if($e)await Ie(t);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",()=>{t("Profiler started"),o()})})})}}}]:[]),{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),r||(r=Te(l,d,c.info),c.info(o.blue("🔧 Config file watcher started"))),a=!1}catch(e){a=!1,c.error(o.red(`error when starting dev server:\n${e.stack}`),{error:e}),Ie(c.info),process.exit(1)}var t}};Pe({logger:c,shutdown:async()=>{r&&(Le(r),r=null),s&&(await s.close(),s=null),Ie(c.info)}}),await d()})}(Oe),function(e){e.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname; without a value, listen on all addresses").option("--port <port>","[number] specify port",{default:3e3}).option("--https","[boolean] no effect with pp-dev next (deprecated)").option("--open [path]","[boolean | string] no effect with pp-dev next (deprecated)").option("--cors","[boolean] no effect with pp-dev next (deprecated)").option("--strictPort","[boolean] no effect with pp-dev next (deprecated)").option("--force","[boolean] no effect with pp-dev next (deprecated)").option("--webpack","[boolean] use Webpack for Next dev (use when Turbopack/native SWC is unavailable)").option("--turbopack","[boolean] use Turbopack for Next dev when native bindings work").action(async(e,n)=>{Fe(n);const i=ke.filter(e=>void 0!==n[e]);i.length>0&&t(n.logLevel).warn(o.yellow(`⚠️ ${i.map(e=>`--${e}`).join(", ")} ${1===i.length?"has":"have"} no effect with pp-dev next and will be removed.`));const{host:p,port:f}=function(e,t){let o="localhost";!0===e||""===e?o="0.0.0.0":"string"==typeof e?o=e:"number"==typeof e&&(o=String(e));const n="number"==typeof t?t:"string"==typeof t?Number.parseInt(t,10):NaN;return{host:o,port:Number.isInteger(n)&&n>=0?n:3e3}}(n.host,n.port);let g=null,h=null,m=null,w=null,b=null,v=!1;const y=new Set,x=t(n.logLevel),S=function(e=["uncaughtException"],t=process){const o=e=>t.listeners(e);let n=null,i=null;return{beforeCreate(){n=new Map(e.map(e=>[e,new Set(o(e))]))},afterCreate(){if(!n)return 0;const s=n,r=new Map(e.map(e=>[e,o(e).filter(t=>!s.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(r.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=r,n=null,a}}}(),Z=async()=>{g&&"function"==typeof g.close&&await g.close(),g=null},B=async()=>{const e=h;if(e){for(const e of y)e.destroy();y.clear(),await new Promise(t=>{e.close(()=>t())}),h===e&&(h=null)}},G=async()=>{if(!v){v=!0;try{const{next:t,constants:i}=await X(),{PHASE_DEVELOPMENT_SERVER:q}=i;w?.dispose(),w=null,m&&(await m.close(),m=null),h&&(x.info(o.yellow("🛑 Stopping existing Next.js server...")),await B()),await Z();const{clearConfigCache:J}=await import("./index-ypcJ5r5C.js").then(e=>e.h);J();const{join:Y}=await(import("path")),{createServer:te}=await(import("http")),oe=await(import("next/dist/server/config.js")),ne=oe.default.default||oe["module.exports"].default||oe.default,ae=e?Y(process.cwd(),e):process.cwd();K(n.mode||"development",ae);const le=await ne(q,ae);let ce=le?.ppDev||{};if(0===Object.keys(ce).length)try{const{getConfig:e}=await import("./index-ypcJ5r5C.js").then(e=>e.h),t=await e(ae);Object.keys(t).length>0?(ce=t,x.info(o.blue("🔧 Loaded pp-dev config from standalone config file"))):x.info(o.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){x.warn(o.yellow(`⚠️ Failed to load standalone pp-dev config, using defaults: ${e instanceof Error?e.message:String(e)}`))}else x.info(o.blue("🔧 Loaded pp-dev config from Next.js config"));const{getPkg:de}=await import("./index-ypcJ5r5C.js").then(e=>e.h),pe=de(ae).name;s(ce,pe);const fe=r(ce,pe),{templateName:ue}=fe,ge=fe.backendBaseURL,he=fe.templateLess,me=fe.v7Features,we=fe.disableSSLValidation,be=fe.enableProxyCache,ve=fe.proxyCacheTTL,ye=fe.personalAccessToken,Pe=fe.miHudLess,xe=fe.inspectorEnabled,Se=fe.inspectorMaxMemory,ke=fe.inspectorCaptureLimit,Le=fe.appId,Fe=!0===fe.allowedHosts||[...fe.allowedHosts,p.toLowerCase()],De=k({allowedHosts:fe.allowedHosts}),$e=le?.basePath;let je="";$e?je=$e:(je=he?a:me?l:c,je+=`/${ue}`);const Ie=function(e){const t="1"===process.env.PP_DEV_NEXT_WEBPACK||"true"===process.env.PP_DEV_NEXT_WEBPACK;if(t&&(e.webpack||e.turbopack))throw new Error("Do not combine PP_DEV_NEXT_WEBPACK with --webpack or --turbopack");if(t)return{webpack:!0};if(e.webpack&&e.turbopack)throw new Error("Use only one of --webpack or --turbopack");return e.webpack?{webpack:!0}:e.turbopack?{turbopack:!0}:{}}(n),Ce=async e=>{delete process.env.TURBOPACK,await Z();const o={dev:!0,customServer:!0,hostname:p,port:f,dir:ae,conf:{...le,basePath:je,assetPrefix:je}};e.webpack?o.webpack=!0:e.turbopack&&(o.turbopack=!0),S.beforeCreate(),g=t(o),await g.prepare(),S.afterCreate()};if(Ie.webpack)await Ce({webpack:!0});else if(Ie.turbopack)try{await Ce({turbopack:!0})}catch(e){if(!Ee(e))throw e;x.warn(o.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await Ce({webpack:!0})}else try{await Ce({})}catch(e){if(!Ee(e))throw e;x.warn(o.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await Ce({webpack:!0})}if(!g)throw new Error("Next.js app failed to initialize");if(je.endsWith("/")||(je+="/"),"/"===je)throw new Error('basePath cannot be equal to "/" or equal to empty string');x.info(o.green("✅ Next.js app prepared successfully")),x.info(o.blue(`🔧 pp-dev plugin configured for template: ${ue}`)),x.info(o.blue(`🔧 Base path configured: ${je}`)),ge&&(x.info(o.blue(`🌐 Backend URL: ${ge}`)),x.info(o.blue(`🆔 Custom App ID: ${Le}`)));const Ae=g.getRequestHandler(),Me=f,Re=p;h=te(async(e,t)=>{const o=e.headers.host;if(!T(o,Fe))return t.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),void t.end(L(o));try{const n=e.url||"/",i=n.split("?")[0];let s=re(n,!0);if(ze.length>0){if(i.startsWith("/_next/")||"/favicon.ico"===i||i.startsWith("/__nextjs_")){if(Ve.length>0){let c=0;const d=()=>{if(c>=Ve.length)return void r();const o=Ve[c];c++,o(e,t,d)};return void d()}return void r()}let a=0;const l=()=>{if(a>=ze.length)return void r();const o=ze[a];a++,o(e,t,l)};return void l()}async function r(){if(i.startsWith(je))s=re(n,!0);else{if(i===je.replace(/\/$/,"")){const e=n.replace(i,je);return t.writeHead(302,{Location:e}),void t.end()}if(i.startsWith("/_next/")||"/favicon.ico"===i||i.startsWith("/__nextjs_"));else if("/"===i)return t.writeHead(302,{Location:je}),void t.end()}await Ae(e,t,s)}r()}catch(p){x.error(`Error handling request: ${p instanceof Error?p.message:String(p)}`,{error:p instanceof Error?p:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let He=null;const Oe=(e,t,o)=>{T(e.headers.host,Fe)?He?He(e,t,o):h.listeners("upgrade").every(e=>e===Oe)&&t.destroy():Ne(t)};h.on("upgrade",Oe);let Ue=null;const ze=[],Ve=[];if(!1!==xe){const e=new E(Se);F(De,e,ke);const t=D(e,ke);ze.push(t)}const We=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(P)||e.url?.startsWith($)){return void De(e,t,()=>{})}o()};if(ge||!1===xe||(Ve.push(We),ze.push(We)),ge){const e=new URL(ge).host,t=j();Ve.unshift(t),ze.unshift(t),ge.startsWith("https://")&&(se.defaultMaxListeners=Math.max(se.defaultMaxListeners,20));const n=I(ge,{appId:Le,templateLess:he,disableSSLValidation:we,v7Features:me,personalAccessToken:ye});Ue=new N(ge,n);const s=_(je,ue),r=(e,t,o)=>{s(e,t,o)};Ve.push(r),ze.push(r);const a=Q(je);if(Ve.push(a),ze.push(a),be){const e=C(ve),t={middlewares:{use:e=>e},config:{logger:console}},n=A({devServer:t,ttl:e}),i=(e,t,o)=>{n(e,t,o)};ze.push(i),x.info(o.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const l=M(je),c=R(l,Ue,Object.assign({base:je},n,{miHudLess:Pe})),p=(e,t,o)=>{c(e,t,o)};ze.push(p);const f={middlewares:{use:e=>e},config:{logger:console}},h=H({devServer:f,baseURL:ge,proxyIgnore:[...O(je),"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:we,miAPI:Ue,templateName:ue}),b=(e,t,o)=>{h(e,t,o)};ze.push(b),Ve.push(We),ze.push(We);const v=U(e=>{const t=e.split("?")[0];return t.startsWith(je)&&!t.includes("/_next/")},(t,o)=>{const n=Ue.buildPage(t,Pe),i=ee(n,je,{backendBaseURL:ge,templateLess:he,appId:Le,devPanelPosition:fe.devPanelPosition,devPanelHidden:fe.devPanelHidden,devPanelAutoHide:fe.devPanelAutoHide});return Buffer.from(z(e,o.headers.host??"",i))}),y=(e,t,o)=>{v(e,t,o)};ze.push(y),m=new _e({allowedHosts:fe.allowedHosts});let P=le?.distDir;const S=process.env[d];process.env[d]="1";try{const e=await ne(i.PHASE_PRODUCTION_BUILD,ae);P=e?.distDir??P}catch{}finally{void 0===S?delete process.env[d]:process.env[d]=S}const k=(P??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),T=k&&".next"!==k?k:"out";let L,E="0.0.0";try{const e=JSON.parse(ie.readFileSync(u.join(ae,"package.json"),"utf-8"));E="string"==typeof e.version?e.version:E,L="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const F=new V(ue,{root:ae,backupFolder:u.resolve(ae,fe.syncBackupsDir),maxBackups:fe.syncMaxBackups,buildTimeoutMs:fe.syncBuildTimeoutMs,nextBuild:{projectRoot:ae,distDir:T,packageVersion:E,packageRepositoryUrl:L}}),D={ws:m.ws,config:{clientInjectionPlugin:{v7Features:me}}};w=W({server:D,internalServer:De,distService:F,miAPI:Ue,persistUsers:fe.persistUsers,projectRoot:ae,miUrl:ge});const $="function"==typeof g?.getUpgradeHandler?g.getUpgradeHandler():null;He=(e,t,o)=>{m?.handleUpgrade(e,t,o)||($?$(e,t,o):t.destroy())},x.info(o.blue(`🔧 ${ze.length} pp-dev middlewares initialized`)),x.info(o.blue(`🔧 ${Ve.length} essential middlewares for internal routes`)),x.info(o.blue(`🔧 MiAPI initialized for backend: ${ge}`)),x.info(o.blue(`🔧 Custom App ID: ${Le}`))}h.listen(Me,Re,()=>{x.info(o.green(`✅ pp-dev Next.js server running at http://${Re}:${Me}`)),x.info(o.blue(`📱 Next.js app accessible at http://${Re}:${Me}${je}`)),!1!==xe&&x.info(o.cyan(`🔍 Request Inspector: http://${Re}:${Me}${P}`)),x.info(o.blue("🔧 Base path handling active")),b||(b=Te(ae,G,x.info),x.info(o.blue("🔧 Config file watcher started"))),h.on("connection",e=>{y.add(e),e.on("close",()=>y.delete(e))})}),v=!1}catch(e){v=!1,x.error(o.red(`❌ Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(x.error(o.red("❌ Next.js Peer Dependency Error:")),x.error(o.red(e.message)),x.error(o.yellow("\n💡 To fix this issue:")),x.error(o.blue(" 1. Install Next.js in your project:")),x.error(o.white(" npm install next@^16")),x.error(o.blue(" 2. Or use yarn:")),x.error(o.white(" yarn add next@^16")),x.error(o.blue(" 3. Or use pnpm:")),x.error(o.white(" pnpm add next@^16")),x.error(o.yellow("\n📖 For more information, see:")),x.error(o.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}};Pe({logger:x,knownRejections:[Ce],shutdown:async()=>{b&&(Le(b),b=null),w?.dispose(),w=null,m&&(await m.close(),m=null),await B(),await Z()}}),await G()})}(Oe),function(e){e.command("build [root]","build for production").option("--target <target>","[string] transpile target (default: 'modules')").option("--outDir <dir>","[string] output directory (default: dist)").option("--assetsDir <dir>","[string] directory under outDir to place assets in (default: assets)").option("--assetsInlineLimit <number>","[number] static asset base64 inline threshold in bytes (default: 4096)").option("--ssr [entry]","[string] build specified entry for server-side rendering").option("--sourcemap [output]",'[boolean | "inline" | "hidden"] output source maps for build (default: false)').option("--minify [minifier]",'[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)').option("--manifest [name]","[boolean | string] emit build manifest json").option("--ssrManifest [name]","[boolean | string] emit ssr manifest json").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle (experimental)").option("--emptyOutDir","[boolean] force empty outDir when it's outside of root").option("-w, --watch","[boolean] rebuilds when modules have changed on disk").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Fe(n);const i=Se(n),s=te(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel,buildOverrides:s}),r=m(o,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await w(r),n.changelog){const t=e||process.cwd(),o=r.build?.outDir||"dist";let i="dist-zip";r.ppDevConfig&&(!1===r.ppDevConfig.distZip?i=o:"object"==typeof r.ppDevConfig.distZip&&"string"==typeof r.ppDevConfig.distZip.outDir&&(i=r.ppDevConfig.distZip.outDir)),await Re({changelog:n.changelog,executionRoot:t,newAssetsPath:u.resolve(t,o),backupsDirPath:u.resolve(t,r.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:u.resolve(t,i),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("next-build [root]","build a Next.js app for production (`next build`) and emit VERSION/BUILD-MANIFEST/zip in the same format as `pp-dev build`").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Fe(n);const i=t(n.logLevel),s=e?u.resolve(process.cwd(),e):process.cwd(),a=te(n);process.env[d]="1";try{K(n.mode||"production",s);const{constants:e}=await X(),t=await(import("next/dist/server/config.js")),l=t.default.default||t["module.exports"].default||t.default,c=await l(e.PHASE_PRODUCTION_BUILD,s);let d=c?.ppDev||{};if(0===Object.keys(d).length){const{getConfig:e}=await import("./index-ypcJ5r5C.js").then(e=>e.h);d=await e(s)}const{getPkg:g}=await import("./index-ypcJ5r5C.js").then(e=>e.h),h=r(d,g(s).name),m=oe(h.distZip,a,p(h.templateName)),w=ne(h.versionPlugin,a),b=B(s,c);b&&i.info(o.dim(`[pp-dev] Removed stale dev route types: ${u.relative(s,b)}`)),i.info(o.cyan("[pp-dev] Running `next build`...")),await G(s);const v="string"==typeof c?.distDir&&c.distDir?c.distDir:".next",y=".next"===v?"out":v,P=u.resolve(s,y);if(!ie.existsSync(P)||!ie.statSync(P).isDirectory())throw new Error(`Next.js build output directory not found: ${P}. "next-build" requires "output: 'export'" in next.config (static export).`);const x=JSON.parse(ie.readFileSync(u.join(s,"package.json"),"utf-8"));if(!1!==w&&!1!==w.enabled&&(await ge({outDir:P,packageVersion:"string"==typeof x.version?x.version:"0.0.0",versionFileTemplate:w.versionFileTemplate,packageRepositoryUrl:"string"==typeof x.repository?x.repository:x.repository?.url,enabled:w.enabled}),i.info(o.green(`✅ VERSION / BUILD-MANIFEST written to ${u.relative(s,P)}`))),!1!==m){const e=u.resolve(s,m.outDir),t=m.inDir?u.resolve(P,m.inDir):P,n=f(e,m.outFileName,"ZIP output file name");ie.mkdirSync(u.dirname(n),{recursive:!0});const r=await q(t);ie.writeFileSync(n,r),i.info(o.green(`✅ Zip archive written to ${u.relative(s,n)}`))}if(n.changelog){const e=!1!==m?m.outDir:y;await Re({changelog:n.changelog,executionRoot:s,newAssetsPath:P,backupsDirPath:u.resolve(s,h.syncBackupsDir),changelogDestinationPath:u.resolve(s,e),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("changelog [oldAssetPath] [newAssetPath]","generate changelog between two assets files/folders").option("--oldAssetsPath <oldAssetsPath>","[string] path to the old assets zip file or folder").option("--newAssetsPath <newAssetsPath>","[string] path to the new assets zip file or folder").option("--destination <destination>","[string] destination folder for the changelog (default: .)").option("--filename <filename>","[string] filename for the changelog (default: CHANGELOG.html)").action(async(e,n,i)=>{Fe(i);const{oldAssetsPath:s=e,newAssetsPath:r=n,destination:a=".",filename:l="CHANGELOG.html",logLevel:c}=i,d=process.cwd();s&&r||(t(c).error(o.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const p=u.resolve(d,s),f=u.resolve(d,r),g=u.resolve(d,a),h=new Me({oldAssetsPath:p,newAssetsPath:f,destinationPath:g,changelogFilename:l});await h.generateChangelog()})}(Oe),function(e){e.command("generate-icon-font [source] [destination]","generate icon font from SVG files").option("--source <source>","[string] path to the source directory with SVG files").option("--destination <destination>","[string] path to the destination directory to save the generated font files").option("--font-name, -n <fontName>","[string] name of the font to generate (default: 'icon-font')").action(async(e,n,i)=>{Fe(i);const{source:s=e,destination:r=n,fontName:a="icon-font"}=i,l=process.cwd(),c=u.resolve(l,s),d=u.resolve(l,r),p=new He({sourceDir:c,outputDir:d,fontName:a}),f=t(i.logLevel);f.info(`Generating icon font from SVG files in ${o.dim(c)}`),await p.generate(),f.info(`Icon font generated and saved to ${o.dim(d)}`)})}(Oe),function(e){e.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Fe(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel}),i=await b(m(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode}),"serve");await v(i,n.force,!0)}catch(e){t(n.logLevel).error(o.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})}(Oe),function(e){e.command("preview [root]","locally preview production build").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--strictPort","[boolean] exit if specified port is already in use").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--outDir <dir>","[string] output directory (default: dist)").action(async(e,n)=>{Fe(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel});(await y(m(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode,build:{outDir:n.outDir},preview:{port:n.port,strictPort:n.strictPort,host:n.host,https:n.https,open:n.open}}))).printUrls()}catch(e){t(n.logLevel).error(o.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("migrate [config]","migrate pp-dev config from 0.x flat format to 1.0 grouped format").option("--dry-run","[boolean] print migrated config without writing any files").option("--format <format>","[string] output format: ts (default), js, json").option("--output <file>","[string] output file path (default: pp-dev.config.ts)").option("--no-backup","[boolean] skip backup of original config file").action(async(e,n)=>{const i=t(n.logLevel),{isLegacyFlatConfig:s,isLegacyPPWatchConfig:r,isAlreadyMigrated:a,migrateLegacyFlatConfig:l,migratePPWatchConfig:c,generateConfigFileContent:d,discoverMigrateSource:p,loadPackageJsonMigrateConfig:f}=await(import("./migrate-BHq9PUZz.js")),g=n.format??"ts",h=!1!==n.backup,m=process.cwd(),w=p(m,e);w||(i.warn(o.yellow("No pp-dev or pp-watch config file found in the current directory.")),i.info(o.blue('Supported files: pp-dev.config.{ts,js,cjs,mjs,json}, .pp-watch.config.{ts,js,json}, or a "pp-dev" field in package.json')),process.exit(1));const{sourceFile:b,isWatchConfig:v,isPackageJsonConfig:y}=w;i.info(o.blue(`Found config: ${u.relative(m,b)}`));const{getPkg:P}=await import("./index-ypcJ5r5C.js").then(e=>e.h),x=P();let S,k={};try{if(/\.[cm]?ts$/i.test(b)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:m,entryPoints:[b],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:"esm",mainFields:["main"]})).outputFiles[0].text,n=`pp-migrate-tmp-${Date.now()}.mjs`;ie.writeFileSync(n,o);try{const e=await(import(t(u.resolve(m,n)).toString()));k=e.default?.default??e.default??e}finally{ie.existsSync(n)&&ie.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(b)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(u.resolve(m,b)).toString()));k=t.default?.default??t.default??t}else y?k=f(b):b.endsWith(".json")&&(k=JSON.parse(ie.readFileSync(b,"utf-8")))}catch(e){i.error(o.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(o.red("Config file did not export a valid object.")),process.exit(1)),a(k)?(i.info(o.green("Config is already in 1.0 format — nothing to migrate.")),process.exit(0)):v||r(k)?(i.info(o.blue("Detected pp-watch config format → migrating to 1.0")),S=c(k)):s(k)?(i.info(o.blue("Detected 0.x flat config format → migrating to 1.0")),S=l(k,x.name)):(i.warn(o.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=d(S,g),L=n.output??u.join(m,`pp-dev.config.${g}`);if(n.dryRun&&(i.info(o.green(`\n--- Migrated config (dry-run) → ${u.relative(m,L)} ---\n`)),process.exit(0)),h&&!y&&ie.existsSync(b)){const e=`${b}.bak`;ie.copyFileSync(b,e),i.info(o.blue(`Backed up original to: ${u.relative(m,e)}`))}ie.writeFileSync(L,T,"utf-8"),i.info(o.green(`✅ Migration complete → ${u.relative(m,L)}`)),y?i.info(o.yellow('You can now remove the "pp-dev" field from package.json.')):b!==L&&ie.existsSync(b)&&i.info(o.yellow(`You can now delete the old config: ${u.relative(m,b)}`))})}(Oe),Oe.help(),Oe.version(i),Oe.parse();export{Ie as stopProfiler};
1
+ import{cac as e}from"cac";import{c as t,a as o,P as n,V as i,b as s,v as r,n as a,d as l,e as c,f as d,i as p,h as f,g as u,j as g,r as h}from"./auth.provider-Cq0EuReh.js";import*as m from"path";import{performance as w}from"node:perf_hooks";import{loadConfigFromFile as b,mergeConfig as v,build as y,resolveConfig as P,optimizeDeps as x,preview as S}from"vite";import{I as k,P as T,c as L,R as E,r as F,a as D,V as $,b as j,g as I,M as N,i as _,d as C,e as A,f as M,h as R,j as H,k as O,l as U,u as z,D as V,s as W,m as Z,n as B,o as G,z as q}from"./request-capture.middleware-B9t-px8Z.js";import{watch as J}from"chokidar";import{l as K,g as Y,s as X,c as Q,i as ee,r as te,a as oe,b as ne}from"./index-DioJ4R68.js";import*as ie from"fs";import{EventEmitter as se}from"node:events";import{parse as re}from"url";import{WebSocketServer as ae,WebSocket as le}from"ws";import*as ce from"dir-compare";import de from"diff-match-patch";import{isBinaryFile as pe}from"isbinaryfile";import*as fe from"os";import*as ue from"crypto";import{w as ge}from"./version-manifest-qxz5FXuG.js";import"picocolors";import"node:path";import"node:net";import"zlib";import"axios";import"node:http";import"node:https";import"http-proxy-middleware";import"node:string_decoder";import"process";import"jszip";import"child_process";import"module";import"node:crypto";import"node:fs";import"node:os";import"express";import"node:module";import"./helpers.js";import"ejs";import"fs/promises";import"util";function he(e){return null!=e&&!1!==e}let me=null;const we=new WeakMap;function be(e,n){if(!e.httpServer||!process.stdin.isTTY||process.env.CI)return;we.set(e,n);const i=t();n.print&&i.info(o.dim(o.green(" ➜"))+o.dim(" press ")+o.bold("h")+o.dim(" to show help"));const s=(n.customShortcuts??[]).filter(he).concat(ve);me?.(),me=null;let r=!1;const a=process.stdin.isPaused(),l=process.stdin,c=Boolean(l.isRaw),d=async t=>{if(""===t)return void function(e=process){"win32"===e.platform?e.emit("SIGINT","SIGINT"):e.kill(e.pid,"SIGINT")}();if(""===t)return void await e.close().finally(()=>process.exit(0));if(r)return;"h"===t&&i.info(["",o.bold(" Shortcuts"),...s.map(e=>o.dim(" press ")+o.bold(e.key)+o.dim(` to ${e.description}`))].join("\n"));const n=s.find(e=>e.key===t);n&&(r=!0,await n.action(e),r=!1)};process.stdin.setRawMode(!0),process.stdin.on("data",d).setEncoding("utf8").resume();const p=e.httpServer,f=()=>{me===f&&(p.removeListener("close",f),process.stdin.off("data",d),c||process.stdin.setRawMode(!1),a&&process.stdin.pause(),me=null)};me=f,p.on("close",f)}const ve=[{key:"r",description:"restart the server",async action(e){const t=we.get(e);await e.restart(),t&&be(e,{...t,print:!1})}},{key:"u",description:"show server url",action(e){e.config.logger.info(""),e.printUrls()}},{key:"o",description:"open in browser",action(e){e.openBrowser()}},{key:"c",description:"clear console",action(e){e.config.logger.clearScreen("error")}},{key:"q",description:"quit",async action(e){await e.close().finally(()=>process.exit())}},{key:"C",description:"clear proxy cache",action(e){e.cache&&(e.cache.clear(),e.config.logger.info("Proxy cache cleared"))}}];function ye(e){return e instanceof Error?e.stack??e.message:String(e)}function Pe({logger:e,knownRejections:t=[],shutdown:n,shutdownTimeoutMs:i=5e3,processRef:s=process}){let r=!1,a=0;const l=async(t,l)=>{if((e=>{a=Math.max(a,e)})(l),r)return void("SIGINT"!==t&&"SIGTERM"!==t&&"SIGHUP"!==t||(e.warn(o.yellow(`\n⚠️ Received ${t} again, exiting without waiting for the shutdown`)),s.exit(a)));r=!0,e.info(o.yellow(`\n🛑 Received ${t}, shutting down gracefully...`));const c=setTimeout(()=>{e.error(o.red(`⏰ Shutdown did not finish within ${i} ms, forcing exit`)),s.exit(1)},i);try{await n(),clearTimeout(c),e.info(o.green("✅ Graceful shutdown completed")),s.exit(a)}catch(t){clearTimeout(c),e.error(o.red(`❌ Error during graceful shutdown: ${ye(t)}`)),s.exit(1)}},c=()=>{l("SIGINT",0)},d=()=>{l("SIGTERM",0)},p=()=>{l("SIGHUP",0)},f=t=>{e.error(o.red(`❌ Uncaught exception: ${ye(t)}`)),l("uncaughtException",1)},u=n=>{const i=t.find(e=>e.matches(n));i?e.info(o.dim(i.message)):e.error(o.red(`❌ Unhandled promise rejection (the server keeps running): ${ye(n)}`))};return s.on("SIGINT",c),s.on("SIGTERM",d),s.on("SIGHUP",p),s.on("uncaughtException",f),s.on("unhandledRejection",u),()=>{s.off("SIGINT",c),s.off("SIGTERM",d),s.off("SIGHUP",p),s.off("uncaughtException",f),s.off("unhandledRejection",u)}}const xe=["--","c","config","base","l","logLevel","clearScreen","configLoader","profile","d","debug","f","filter","m","mode","force","w","changelog","distZip","distZipDir","distZipFilename","versionManifest","versionFileTemplate","webpack","turbopack"];function Se(e){const t={...e};for(const e of xe)delete t[e];return"sourcemap"in t&&(t.sourcemap="true"===t.sourcemap||"false"!==t.sourcemap&&t.sourcemap),"watch"in t&&(t.watch=t.watch?{}:void 0),t}const ke=["https","open","cors","strictPort","force"];function Te(e,t,i){const s=[...n,"package.json","next.config.js","next.config.mjs","next.config.ts","vite.config.js","vite.config.mjs","vite.config.ts",".env",".env.local",".env.development",".env.development.local"].map(t=>m.join(e,t)),r=J(s,{ignored:e=>{const t=m.basename(e);return/(^|[\/\\])\../.test(e)&&!t.startsWith(".env")&&!t.startsWith(".pp-dev")&&!t.startsWith(".pp-watch")},persistent:!0,ignoreInitial:!0,followSymlinks:!1});let a=null;return r.on("change",n=>{i(o.blue(`🔧 Config file changed: ${m.relative(e,n)}`)),a&&clearTimeout(a),a=setTimeout(async()=>{try{i(o.yellow("🔄 Restarting dev server due to config change...")),await t()}catch(e){i(o.red(`❌ Failed to restart dev server: ${e?.message}. Stack: ${e?.stack}`))}},500)}),r.on("error",e=>{i(o.red(`❌ Config watcher error: ${e}`))}),{watcher:r}}function Le(e){e.watcher&&e.watcher.close()}function Ee(e){if(!e||"object"!=typeof e||!("message"in e))return!1;const t=String(e.message);return/Turbopack is not supported/i.test(t)||/native bindings are not available/i.test(t)||/Only WebAssembly \(WASM\) bindings were loaded/i.test(t)}const Fe=e=>{for(const[t,o]of Object.entries(e))Array.isArray(o)&&(e[t]=o[o.length-1])};async function De(e){const{root:t,mode:o,command:n}=e,i=m.resolve(process.cwd(),t??".");K(o,i);const s=await b({mode:o,command:n},e.configFile,t,e.logLevel);let r=await Y(e.buildOverrides,{mode:o,root:i});if(s){const e={...s.config};delete e.plugins,r=v(r,e)}return{config:r,envDir:i}}let $e=global.__pp_dev_profile_session,je=0;const Ie=e=>{if($e)return new Promise((t,n)=>{$e.post("Profiler.stop",(i,{profile:s})=>{if(i)n(i);else{const n=m.resolve(`./pp-dev-profile-${je++}.cpuprofile`);ie.writeFileSync(n,JSON.stringify(s)),e(o.yellow(`CPU profile written to ${o.white(o.dim(n))}`)),$e=void 0,t()}})})};function Ne(e){e.once("error",()=>e.destroy()),e.end("HTTP/1.1 403 Forbidden\r\nConnection: close\r\nContent-Length: 0\r\n\r\n",()=>e.destroy())}class _e{wss;eventListeners=new Map;lifecycleListeners=new Map;clients=new Map;ws;allowedHosts;constructor({allowedHosts:e=[]}={}){this.allowedHosts=e,this.wss=new ae({noServer:!0}),this.wss.on("connection",e=>this.onConnection(e)),this.wss.on("error",e=>this.fireLifecycle("error",e)),this.ws={on:(e,t)=>{"close"!==e&&"error"!==e?this.getEventSet(e).add(t):this.getLifecycleSet(e).add(t)},off:(e,t)=>{this.eventListeners.get(e)?.delete(t),"close"!==e&&"error"!==e||this.lifecycleListeners.get(e)?.delete(t)},send:(e,t)=>{if("string"==typeof e)for(const o of this.clients.keys())this.sendToSocket(o,e,t);else{const t=JSON.stringify(e);for(const e of this.clients.keys())e.readyState===le.OPEN&&e.send(t)}}}}handleUpgrade(e,t,o){return(e.url??"").split("?")[0]===T&&(s(e,this.allowedHosts)?(Ne(t),!0):(this.wss.handleUpgrade(e,t,o,t=>{this.wss.emit("connection",t,e)}),!0))}async close(){this.fireLifecycle("close");for(const e of this.clients.keys())e.terminate();this.clients.clear(),await new Promise(e=>this.wss.close(()=>e()))}onConnection(e){const t={send:(t,o)=>this.sendToSocket(e,t,o),socket:e};this.clients.set(e,t),e.on("message",e=>this.onMessage(t,e)),e.on("close",()=>this.clients.delete(e)),e.on("error",()=>{})}onMessage(e,o){let n;try{n=JSON.parse(o.toString())}catch{return}if(!n||"custom"!==n.type||"string"!=typeof n.event)return;const i=this.eventListeners.get(n.event);if(i)for(const o of i)try{o(n.data,e)}catch(e){t().error(`ws handler for "${n.event}" failed`,{error:e instanceof Error?e:new Error(String(e))})}}sendToSocket(e,t,o){e.readyState===le.OPEN&&e.send(JSON.stringify({type:"custom",event:t,data:o}))}fireLifecycle(e,t){for(const o of this.lifecycleListeners.get(e)??[])try{o(t)}catch{}}getEventSet(e){let t=this.eventListeners.get(e);return t||(t=new Set,this.eventListeners.set(e,t)),t}getLifecycleSet(e){let t=this.lifecycleListeners.get(e);return t||(t=new Set,this.lifecycleListeners.set(e,t)),t}}const Ce={matches:e=>e instanceof Error&&"Worker creator already registered"===e.message,message:"Next.js kept its Turbopack worker pool from before the restart ('Worker creator already registered')"};const Ae=/(.+)(-[a-f0-9]{6,20})(\.[a-z0-9]+)$/i;class Me{oldAssetsPath;newAssetsPath;destinationPath;changelogFilename;changelogTemplate='<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8" />\n <title>Changelog Diff</title>\n <style>\n tr,\n td {\n padding: 0;\n }\n .diff-file {\n margin-top: 20px;\n border: 1px solid #e1e4e8;\n border-radius: 6px;\n }\n .diff-file-title {\n padding: 10px 20px;\n background-color: #f6f8fa;\n border-bottom: 1px solid #e1e4e8;\n border-radius: 6px 6px 0 0;\n font-weight: bold;\n }\n .diff-file-title .renamed {\n font-weight: normal;\n }\n .diff-file-title .renamed .from {\n color: #cb2431;\n }\n .diff-file-title .renamed .to {\n color: #22863a;\n }\n .diff-file-title .added {\n color: #22863a;\n }\n .diff-file-title .deleted {\n color: #cb2431;\n }\n .diff-file-content {\n }\n .diff-table {\n tab-size: 8;\n width: 100%;\n border-collapse: separate;\n border-spacing: 0;\n }\n .blob-num {\n position: relative;\n color: #1f2328;\n width: 1%;\n min-width: 50px;\n padding: 0 10px;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n line-height: 20px;\n text-align: right;\n white-space: nowrap;\n vertical-align: top;\n cursor: pointer;\n -webkit-user-select: none;\n user-select: none;\n }\n .blob-num.addition {\n background-color: #ccffd8;\n border-color: #1f883e;\n }\n .blob-num.deletion {\n background-color: #ffd7d5;\n border-color: #cf222e;\n }\n .blob-num::before {\n content: attr(data-line-number);\n }\n .blob-code {\n position: relative;\n padding: 0 10px 0 22px;\n vertical-align: top;\n color: #1f2329;\n }\n .blob-code.code-addition {\n background-color: #e6ffec;\n }\n .blob-code.code-deletion {\n background-color: #ffebe9;\n }\n .blob-code.skip,\n .blob-code.message {\n text-align: center;\n }\n .blob-code.skip .blob-code-inner,\n .blob-code.message .blob-code-inner {\n font-weight: bold;\n color: #6a737d;\n padding: 10px 0;\n }\n .blob-code-inner {\n display: table-cell;\n overflow: visible;\n font-family:\n ui-monospace,\n SFMono-Regular,\n SF Mono,\n Menlo,\n Consolas,\n Liberation Mono,\n monospace;\n font-size: 12px;\n word-wrap: anywhere;\n white-space: pre-wrap;\n }\n .blob-code-inner::before {\n content: attr(data-code-prefix);\n position: absolute;\n top: 1px;\n left: 8px;\n padding-right: 8px;\n }\n </style>\n </head>\n <body>\n <h1>Changelog Diff</h1>\n\n %FILES%\n </body>\n </html>';diffFileTemplateHandler;diffLineTemplateHandler;contextLines=3;logger;constructor(e){const{oldAssetsPath:n,newAssetsPath:i,destinationPath:s,changelogTemplate:r,diffFileTemplateHandler:a,diffLineTemplateHandler:l,changelogFilename:c,contextLines:d}=e;if(this.logger=t(),!n||!i||!s)throw new Error("Previous assets path, current assets path and destination path are required");if(n===i)throw new Error("Previous and current assets paths must be different");if(!this.isExists(n))throw new Error(`Previous assets path ${n} does not exist`);if(!this.isExists(i))throw new Error(`Current assets path ${i} does not exist`);if(this.isZipFile(n)){const e=m.resolve(fe.tmpdir(),ue.createHash("md5").update(n).digest("hex"));this.oldAssetsPath=this.unzipFile(n,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);return e})}else{if(!this.isFolder(n))throw new Error(`Invalid previous assets path ${n}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(n);if(this.isEmptyFolder(e))throw new Error(`Previous assets path ${e} is empty`);this.oldAssetsPath=Promise.resolve(e)}}if(this.isZipFile(i)){const e=m.resolve(fe.tmpdir(),ue.createHash("md5").update(i).digest("hex"));this.newAssetsPath=this.unzipFile(i,e).then(()=>this.normalizeAssetFolderPath(e)).then(e=>{if(this.isEmptyFolder(e))throw new Error(`Current assets path ${e} is empty`);return e})}else{if(!this.isFolder(i))throw new Error(`Invalid current assets path ${i}. It must be a folder or a zip file`);{const e=this.normalizeAssetFolderPath(i);if(this.isEmptyFolder(e))throw new Error(`Current assets path ${i} is empty`);this.newAssetsPath=Promise.resolve(e)}}this.destinationPath=s,this.mkdirpSync(this.destinationPath),this.changelogFilename=c||"CHANGELOG.html",r&&(this.templateIsValid(r)?this.changelogTemplate=r:this.logger.warn(o.yellow("Invalid changelog template, using default"))),"function"==typeof a&&(this.diffFileTemplateHandler=a),"function"==typeof l&&(this.diffLineTemplateHandler=l),d&&(this.contextLines=d)}templateIsValid(e){return e.includes("%FILES%")}isExists(e){return ie.existsSync(e)}isZipFile(e){return e.endsWith(".zip")}isFolder(e){return ie.lstatSync(e).isDirectory()}isEmptyFolder(e){return 0===ie.readdirSync(e,{withFileTypes:!0}).length}mkdirpSync(e){ie.existsSync(e)||ie.mkdirSync(e,{recursive:!0})}async unzipFile(e,t){ie.rmSync(t,{force:!0,recursive:!0}),await Z(e,t)}normalizeAssetFolderPath(e){const t=ie.readdirSync(e);return 1===t.length&&ie.lstatSync(m.join(e,t[0])).isDirectory()?this.normalizeAssetFolderPath(m.join(e,t[0])):e}pathToPosix(e){return e.replace(/\\/g,"/")}diffTableTemplate(e){return`<table class="diff-table">\n <tbody>\n ${e}\n </tbody>\n </table>`}getDiffTableHTML(e){const t=e.filter((e,t,o)=>0!==e.lineType||(t>=0&&t<this.contextLines||t>o.length-(this.contextLines+1)&&t<=o.length-1||o.slice(t-this.contextLines,t+this.contextLines+1).some(e=>0!==e.lineType))).map((e,t,o)=>{if(t>0){const n=o[t-1];if(e.lineNumber-n.lineNumber>1)return[{lineNumber:-1,lineContent:"",lineType:0},e]}return[e]}).flat().map(e=>this.diffLineHTML(e)).join("");return this.diffTableTemplate(t)}diffLineMessageTemplate(e){return`<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code message">\n <span class="blob-code-inner">${e}</span>\n </td>\n </tr>`}diffLineSkipTemplate(){return'<tr>\n <td class="blob-num"></td>\n <td class="blob-num"></td>\n <td class="blob-code skip">\n <span class="blob-code-inner">Skip</span>\n </td>\n </tr>'}diffLineTemplate(e){const{lineNumber:t,lineContent:o,lineType:n}=e,i=1===n?"addition":-1===n?"deletion":"";return`<tr>\n <td\n class="blob-num ${i}${"addition"===i?" empty":""}"\n ${"addition"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td\n class="blob-num ${i}${"deletion"===i?" empty":""}"\n ${"deletion"!==i?` data-line-number="${t}"`:""}\n ></td>\n <td class="blob-code ${1===n?"code-addition":-1===n?"code-deletion":""}">\n <span class="blob-code-inner" data-code-prefix="${1===n?"+":-1===n?"-":" "}">${s=o??"",s.replace(/[\u00A0-\u9999<>&]/g,e=>"&#"+e.charCodeAt(0)+";")}</span>\n </td>\n </tr>`;var s}diffLineHTML(e){if(this.diffLineTemplateHandler)return this.diffLineTemplateHandler(e);const{lineNumber:t}=e;return-1===t?this.diffLineSkipTemplate():this.diffLineTemplate(e)}diffFileTemplate(e,t){return this.diffFileTemplateHandler?this.diffFileTemplateHandler(e,t):`<div class="diff-file">\n <div class="diff-file-title">${e}</div>\n <div class="diff-file-content">${t}</div>\n </div>`}async generateAssetFoldersDiff(){this.logger.info(o.blue(`Comparing asset folders ${await this.oldAssetsPath} and ${await this.newAssetsPath}`));const e=await ce.compare(await this.oldAssetsPath,await this.newAssetsPath,{compareContent:!0,skipSymlinks:!0,compareSize:!0,compareDate:!1,compareNameHandler:(e,t)=>(Ae.test(e)&&(e=e.replace(Ae,"$1$3")),Ae.test(t)&&(t=t.replace(Ae,"$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 de,n=o.diff_linesToChars_(e,t),i=o.diff_main(n.chars1,n.chars2,!1);o.diff_charsToLines_(i,n.lineArray);let s=0;return i.map(e=>{const[t,o]=e,n=o.endsWith("\n")?o.split("\n").length-1:o.split("\n").length,i=o.split("\n").map((e,o)=>({lineContent:e,lineNumber:s+o+1,lineType:t})).slice(0,n);return-1!==t&&(s+=n),i}).flat()}async generateFilesDiff(e){if("equal"===e.state){const t=this.pathToPosix(m.join(".",e.relativePath,e.name1??"")),o=this.pathToPosix(m.join(".",e.relativePath,e.name2??""));return this.diffFileTemplate(`<span class="renamed"\n >Renamed <span class="from">${t}</span> -> <span class="to">${o}</span></span\n >`,this.diffTableTemplate(this.diffLineMessageTemplate("No changes")))}const t=e.path1&&e.name1?m.join(e.path1,e.name1):null,o=e.path2&&e.name2?m.join(e.path2,e.name2):null,n=this.pathToPosix(m.join(".",e.relativePath,(e.name1||e.name2)??""));if("left"===e.state&&t)return this.diffFileTemplate(`<span class="removed">Removed ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File removed")));if("right"===e.state&&o)return this.diffFileTemplate(`<span class="added">Added ${n}</span>`,this.diffTableTemplate(this.diffLineMessageTemplate("File added")));if("distinct"===e.state&&t&&o){const i=this.pathToPosix(m.join(".",e.relativePath,e.name1??"")),s=this.pathToPosix(m.join(".",e.relativePath,e.name2??"")),r=e.name1!==e.name2?`<span class="renamed"\n >Renamed <span class="from">${i}</span> -> <span class="to">${s}</span></span\n >`:n;return this.diffFileTemplate(r,await pe(t)||await pe(o)?this.diffTableTemplate(this.diffLineMessageTemplate("Binary file")):this.getDiffTableHTML(await this.generateAssetFilesDiff(ie.readFileSync(t,"utf-8"),ie.readFileSync(o,"utf-8"))))}return""}async generateChangelog(){this.logger.info(o.green("Generating changelog"));const e=await this.generateAssetFoldersDiff(),t=(await Promise.all(e.map(e=>this.generateFilesDiff(e)))).join("");this.logger.info(o.green("Writing changelog file"));const n=this.changelogTemplate.split("%FILES%");n.splice(1,0,t);const i=n.join("");ie.writeFileSync(m.join(this.destinationPath,this.changelogFilename),i),this.logger.info(o.green(`Changelog file written to ${m.join(this.destinationPath,this.changelogFilename)}`))}}async function Re(e){const{changelog:n,executionRoot:i,newAssetsPath:s,backupsDirPath:r,changelogDestinationPath:a,logLevel:l}=e;let c;if("string"==typeof n)c=m.resolve(i,n);else{if(!ie.existsSync(r))return void t(l).warn(o.yellow("backups directory not found, skipping changelog generation"));const e=ie.readdirSync(r,{withFileTypes:!0});if(!e.length)return void t(l).warn(o.yellow("no backups found, skipping changelog generation"));const n=e.filter(e=>e.isFile()&&e.name.endsWith(".zip"));if(!n.length)return void t(l).warn(o.yellow("no ZIP backups found, skipping changelog generation"));const i=n.reduce((e,t)=>ie.statSync(m.resolve(r,e.name)).mtimeMs>ie.statSync(m.resolve(r,t.name)).mtimeMs?e:t).name;c=m.resolve(r,i)}const d=new Me({oldAssetsPath:c,newAssetsPath:s,destinationPath:a});await d.generateChangelog()}class He{sourceDir;outputDir;fontName;constructor(e){this.sourceDir=e.sourceDir,this.outputDir=e.outputDir,this.fontName=e.fontName}async generate(){const{default:e}=await(import("svgtofont"));await e({src:this.sourceDir,dist:this.outputDir,fontName:this.fontName,css:!0,typescript:!0,startUnicode:59905,svgicons2svgfont:{fontHeight:1024}})}}const Oe=e("pp-dev");Oe.option("-c, --config <file>","[string] use specified config file").option("--base <path>","[string] public base path (default: /)").option("-l, --logLevel <level>","[string] info | warn | error | silent").option("--clearScreen","[boolean] allow/disable clear screen when logging").option("-d, --debug [feat]","[string | boolean] show debug logs").option("-f, --filter <filter>","[string] filter debug logs").option("-m, --mode <mode>","[string] set env mode"),function(e){e.command("[root]","start dev server").alias("serve").alias("dev").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--cors","[boolean] enable CORS").option("--strictPort","[boolean] exit if specified port is already in use").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Fe(n);let s=null,r=null,a=!1;const l=e?m.resolve(process.cwd(),e):process.cwd(),c=t(n.logLevel),d=async()=>{if(!a){a=!0;try{s&&(c.info(o.yellow("🛑 Stopping existing dev server...")),await s.close(),s=null);const{clearConfigCache:p,getConfig:f}=await import("./index-DioJ4R68.js").then(e=>e.h);p();const{createServer:u}=await(import("vite")),g=n.mode||"development",{config:h,envDir:m}=await De({root:e,mode:g,command:"serve",configFile:n.config,logLevel:n.logLevel});if(s=await u(v(h,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},server:Se(n),customLogger:c},!0)),!s.config.base||"/"===s.config.base)throw new Error('base cannot be equal to "/" or empty string');if(!s.httpServer)throw new Error("HTTP server not available");await s.listen();const b=global.__pp_dev_start_time??!1,y=b?o.dim(`ready in ${o.reset(o.bold(Math.ceil(w.now()-b)))} ms`):"";c.info(`\n ${o.green(`${o.bold("PP-DEV")} v${i}`)} ${y}\n`),s.printUrls();const P=await f(m);if(!1!==P.inspector?.enabled){const e=s.resolvedUrls?.local[0],t=e?new URL(e).origin:`http://localhost:${s.config.server.port??5173}`;c.info(`\n ${o.cyan("🔍 Request Inspector")} ${o.dim(t+k)}\n`)}be(s,{print:!0,customShortcuts:[...(t=c.info,$e?[{key:"p",description:"start/stop the profiler",async action(){if($e)await Ie(t);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",()=>{t("Profiler started"),o()})})})}}}]:[]),{key:"l",description:"proxy re-login",action(e){e.ws.send({type:"custom",event:"redirect",data:{url:`/auth/index/logout?proxyRedirect=${encodeURIComponent("/")}`}})}}]}),r||(r=Te(l,d,c.info),c.info(o.blue("🔧 Config file watcher started"))),a=!1}catch(e){a=!1,c.error(o.red(`error when starting dev server:\n${e.stack}`),{error:e}),Ie(c.info),process.exit(1)}var t}};Pe({logger:c,shutdown:async()=>{r&&(Le(r),r=null),s&&(await s.close(),s=null),Ie(c.info)}}),await d()})}(Oe),function(e){e.command("next [root]","start Next.js development server with pp-dev integration").alias("next-serve").alias("next-dev").option("--host [host]","[string] specify hostname; without a value, listen on all addresses").option("--port <port>","[number] specify port",{default:3e3}).option("--https","[boolean] no effect with pp-dev next (deprecated)").option("--open [path]","[boolean | string] no effect with pp-dev next (deprecated)").option("--cors","[boolean] no effect with pp-dev next (deprecated)").option("--strictPort","[boolean] no effect with pp-dev next (deprecated)").option("--force","[boolean] no effect with pp-dev next (deprecated)").option("--webpack","[boolean] use Webpack for Next dev (use when Turbopack/native SWC is unavailable)").option("--turbopack","[boolean] use Turbopack for Next dev when native bindings work").action(async(e,n)=>{Fe(n);const i=ke.filter(e=>void 0!==n[e]);i.length>0&&t(n.logLevel).warn(o.yellow(`⚠️ ${i.map(e=>`--${e}`).join(", ")} ${1===i.length?"has":"have"} no effect with pp-dev next and will be removed.`));const{host:s,port:g}=function(e,t){let o="localhost";!0===e||""===e?o="0.0.0.0":"string"==typeof e?o=e:"number"==typeof e&&(o=String(e));const n="number"==typeof t?t:"string"==typeof t?Number.parseInt(t,10):NaN;return{host:o,port:Number.isInteger(n)&&n>=0?n:3e3}}(n.host,n.port);let h=null,w=null,b=null,v=null,y=null,P=!1;const x=new Set,S=t(n.logLevel),T=function(e=["uncaughtException"],t=process){const o=e=>t.listeners(e);let n=null,i=null;return{beforeCreate(){n=new Map(e.map(e=>[e,new Set(o(e))]))},afterCreate(){if(!n)return 0;const s=n,r=new Map(e.map(e=>[e,o(e).filter(t=>!s.get(e).has(t))]));let a=0;if(i)for(const[e,o]of i){const n=new Set(r.get(e).map(e=>e.toString()));for(const i of o)n.has(i.toString())&&(t.off(e,i),a+=1)}return i=r,n=null,a}}}(),Z=async()=>{h&&"function"==typeof h.close&&await h.close(),h=null},B=async()=>{const e=w;if(e){for(const e of x)e.destroy();x.clear(),await new Promise(t=>{e.close(()=>t())}),w===e&&(w=null)}},G=async()=>{if(!P){P=!0;try{const{next:t,constants:i}=await X(),{PHASE_DEVELOPMENT_SERVER:q}=i;v?.dispose(),v=null,b&&(await b.close(),b=null),w&&(S.info(o.yellow("🛑 Stopping existing Next.js server...")),await B()),await Z();const{clearConfigCache:J}=await import("./index-DioJ4R68.js").then(e=>e.h);J();const{join:Y}=await(import("path")),{createServer:te}=await(import("http")),oe=await(import("next/dist/server/config.js")),ne=oe.default.default||oe["module.exports"].default||oe.default,ae=e?Y(process.cwd(),e):process.cwd();K(n.mode||"development",ae);const le=await ne(q,ae);let ce=le?.ppDev||{};if(0===Object.keys(ce).length)try{const{getConfig:e}=await import("./index-DioJ4R68.js").then(e=>e.h),t=await e(ae);Object.keys(t).length>0?(ce=t,S.info(o.blue("🔧 Loaded pp-dev config from standalone config file"))):S.info(o.yellow("⚠️ No pp-dev config found in Next.js config or standalone file, using defaults"))}catch(e){S.warn(o.yellow(`⚠️ Failed to load standalone pp-dev config, using defaults: ${e instanceof Error?e.message:String(e)}`))}else S.info(o.blue("🔧 Loaded pp-dev config from Next.js config"));const{getPkg:de}=await import("./index-DioJ4R68.js").then(e=>e.h),pe=de(ae).name;r(ce,pe);const fe=a(ce,pe),{templateName:ue}=fe,ge=fe.backendBaseURL,he=fe.templateLess,me=fe.v7Features,we=fe.disableSSLValidation,be=fe.enableProxyCache,ve=fe.proxyCacheTTL,ye=fe.personalAccessToken,Pe=fe.miHudLess,xe=fe.inspectorEnabled,Se=fe.inspectorMaxMemory,ke=fe.inspectorCaptureLimit,Le=fe.appId,Fe=!0===fe.allowedHosts||[...fe.allowedHosts,s.toLowerCase()],De=L({allowedHosts:fe.allowedHosts}),$e=le?.basePath;let je="";$e?je=$e:(je=he?l:me?c:d,je+=`/${ue}`);const Ie=function(e){const t="1"===process.env.PP_DEV_NEXT_WEBPACK||"true"===process.env.PP_DEV_NEXT_WEBPACK;if(t&&(e.webpack||e.turbopack))throw new Error("Do not combine PP_DEV_NEXT_WEBPACK with --webpack or --turbopack");if(t)return{webpack:!0};if(e.webpack&&e.turbopack)throw new Error("Use only one of --webpack or --turbopack");return e.webpack?{webpack:!0}:e.turbopack?{turbopack:!0}:{}}(n),Ce=async e=>{delete process.env.TURBOPACK,await Z();const o={dev:!0,customServer:!0,hostname:s,port:g,dir:ae,conf:{...le,basePath:je,assetPrefix:je}};e.webpack?o.webpack=!0:e.turbopack&&(o.turbopack=!0),T.beforeCreate(),h=t(o),await h.prepare(),T.afterCreate()};if(Ie.webpack)await Ce({webpack:!0});else if(Ie.turbopack)try{await Ce({turbopack:!0})}catch(e){if(!Ee(e))throw e;S.warn(o.yellow("⚠ Turbopack is unavailable (native bindings). Falling back to Webpack.")),await Ce({webpack:!0})}else try{await Ce({})}catch(e){if(!Ee(e))throw e;S.warn(o.yellow("⚠ Turbopack cannot run (native Next.js bindings unavailable). Falling back to Webpack.")),await Ce({webpack:!0})}if(!h)throw new Error("Next.js app failed to initialize");if(je.endsWith("/")||(je+="/"),"/"===je)throw new Error('basePath cannot be equal to "/" or equal to empty string');S.info(o.green("✅ Next.js app prepared successfully")),S.info(o.blue(`🔧 pp-dev plugin configured for template: ${ue}`)),S.info(o.blue(`🔧 Base path configured: ${je}`)),ge&&(S.info(o.blue(`🌐 Backend URL: ${ge}`)),S.info(o.blue(`🆔 Custom App ID: ${Le}`)));const Ae=h.getRequestHandler(),Me=g,Re=s;w=te(async(e,t)=>{const o=e.headers.host;if(!p(o,Fe))return t.writeHead(403,{"Content-Type":"text/plain; charset=utf-8"}),void t.end(f(o));try{const n=e.url||"/",i=n.split("?")[0];let s=re(n,!0);if(ze.length>0){if(i.startsWith("/_next/")||"/favicon.ico"===i||i.startsWith("/__nextjs_")){if(Ve.length>0){let c=0;const d=()=>{if(c>=Ve.length)return void r();const o=Ve[c];c++,o(e,t,d)};return void d()}return void r()}let a=0;const l=()=>{if(a>=ze.length)return void r();const o=ze[a];a++,o(e,t,l)};return void l()}async function r(){if(i.startsWith(je))s=re(n,!0);else{if(i===je.replace(/\/$/,"")){const e=n.replace(i,je);return t.writeHead(302,{Location:e}),void t.end()}if(i.startsWith("/_next/")||"/favicon.ico"===i||i.startsWith("/__nextjs_"));else if("/"===i)return t.writeHead(302,{Location:je}),void t.end()}await Ae(e,t,s)}r()}catch(u){S.error(`Error handling request: ${u instanceof Error?u.message:String(u)}`,{error:u instanceof Error?u:void 0}),t.statusCode=500,t.end("Internal Server Error")}});let He=null;const Oe=(e,t,o)=>{p(e.headers.host,Fe)?He?He(e,t,o):w.listeners("upgrade").every(e=>e===Oe)&&t.destroy():Ne(t)};w.on("upgrade",Oe);let Ue=null;const ze=[],Ve=[];if(!1!==xe){const e=new E(Se);F(De,e,ke);const t=D(e,ke);ze.push(t)}const We=(e,t,o)=>{if(e.url?.startsWith("/@api/")||e.url?.startsWith(k)||e.url?.startsWith($)){return void De(e,t,()=>{})}o()};if(ge||!1===xe||(Ve.push(We),ze.push(We)),ge){const e=new URL(ge).host,t=j();Ve.unshift(t),ze.unshift(t),ge.startsWith("https://")&&(se.defaultMaxListeners=Math.max(se.defaultMaxListeners,20));const n=I(ge,{appId:Le,templateLess:he,disableSSLValidation:we,v7Features:me,personalAccessToken:ye});Ue=new N(ge,n);const s=_(je,ue),r=(e,t,o)=>{s(e,t,o)};Ve.push(r),ze.push(r);const a=Q(je);if(Ve.push(a),ze.push(a),be){const e=C(ve),t={middlewares:{use:e=>e},config:{logger:console}},n=A({devServer:t,ttl:e}),i=(e,t,o)=>{n(e,t,o)};ze.push(i),S.info(o.blue(`🔧 Proxy cache middleware added with TTL: ${e}ms`))}const l=M(je),c=R(l,Ue,Object.assign({base:je},n,{miHudLess:Pe})),d=(e,t,o)=>{c(e,t,o)};ze.push(d);const p={middlewares:{use:e=>e},config:{logger:console}},f=H({devServer:p,baseURL:ge,proxyIgnore:[...O(je),"/_next","/favicon.ico","/__nextjs_","/installHook.js.map"],disableSSLValidation:we,miAPI:Ue,templateName:ue}),g=(e,t,o)=>{f(e,t,o)};ze.push(g),Ve.push(We),ze.push(We);const w=U(e=>{const t=e.split("?")[0];return t.startsWith(je)&&!t.includes("/_next/")},(t,o)=>{const n=Ue.buildPage(t,Pe),i=ee(n,je,{backendBaseURL:ge,templateLess:he,appId:Le,devPanelPosition:fe.devPanelPosition,devPanelHidden:fe.devPanelHidden,devPanelAutoHide:fe.devPanelAutoHide});return Buffer.from(z(e,o.headers.host??"",i))}),y=(e,t,o)=>{w(e,t,o)};ze.push(y),b=new _e({allowedHosts:fe.allowedHosts});let P=le?.distDir;const x=process.env[u];process.env[u]="1";try{const e=await ne(i.PHASE_PRODUCTION_BUILD,ae);P=e?.distDir??P}catch{}finally{void 0===x?delete process.env[u]:process.env[u]=x}const k=(P??"").replace(/\\/g,"/").replace(/\/+$/,"").replace(/\/dev$/,""),T=k&&".next"!==k?k:"out";let L,E="0.0.0";try{const e=JSON.parse(ie.readFileSync(m.join(ae,"package.json"),"utf-8"));E="string"==typeof e.version?e.version:E,L="string"==typeof e.repository?e.repository:e.repository?.url}catch{}const F=new V(ue,{root:ae,backupFolder:m.resolve(ae,fe.syncBackupsDir),maxBackups:fe.syncMaxBackups,buildTimeoutMs:fe.syncBuildTimeoutMs,nextBuild:{projectRoot:ae,distDir:T,packageVersion:E,packageRepositoryUrl:L}}),D={ws:b.ws,config:{clientInjectionPlugin:{v7Features:me}}};v=W({server:D,internalServer:De,distService:F,miAPI:Ue,persistUsers:fe.persistUsers,projectRoot:ae,miUrl:ge});const $="function"==typeof h?.getUpgradeHandler?h.getUpgradeHandler():null;He=(e,t,o)=>{b?.handleUpgrade(e,t,o)||($?$(e,t,o):t.destroy())},S.info(o.blue(`🔧 ${ze.length} pp-dev middlewares initialized`)),S.info(o.blue(`🔧 ${Ve.length} essential middlewares for internal routes`)),S.info(o.blue(`🔧 MiAPI initialized for backend: ${ge}`)),S.info(o.blue(`🔧 Custom App ID: ${Le}`))}w.listen(Me,Re,()=>{S.info(o.green(`✅ pp-dev Next.js server running at http://${Re}:${Me}`)),S.info(o.blue(`📱 Next.js app accessible at http://${Re}:${Me}${je}`)),!1!==xe&&S.info(o.cyan(`🔍 Request Inspector: http://${Re}:${Me}${k}`)),S.info(o.blue("🔧 Base path handling active")),y||(y=Te(ae,G,S.info),S.info(o.blue("🔧 Config file watcher started"))),w.on("connection",e=>{x.add(e),e.on("close",()=>x.delete(e))})}),P=!1}catch(e){P=!1,S.error(o.red(`❌ Failed to start Next.js server: ${e?.message}. Stack: ${e?.stack}`)),e instanceof Error&&e.message.includes("Next.js is required")&&(S.error(o.red("❌ Next.js Peer Dependency Error:")),S.error(o.red(e.message)),S.error(o.yellow("\n💡 To fix this issue:")),S.error(o.blue(" 1. Install Next.js in your project:")),S.error(o.white(" npm install next@^16")),S.error(o.blue(" 2. Or use yarn:")),S.error(o.white(" yarn add next@^16")),S.error(o.blue(" 3. Or use pnpm:")),S.error(o.white(" pnpm add next@^16")),S.error(o.yellow("\n📖 For more information, see:")),S.error(o.blue(" https://nextjs.org/docs/getting-started"))),process.exit(1)}}};Pe({logger:S,knownRejections:[Ce],shutdown:async()=>{y&&(Le(y),y=null),v?.dispose(),v=null,b&&(await b.close(),b=null),await B(),await Z()}}),await G()})}(Oe),function(e){e.command("build [root]","build for production").option("--target <target>","[string] transpile target (default: 'modules')").option("--outDir <dir>","[string] output directory (default: dist)").option("--assetsDir <dir>","[string] directory under outDir to place assets in (default: assets)").option("--assetsInlineLimit <number>","[number] static asset base64 inline threshold in bytes (default: 4096)").option("--ssr [entry]","[string] build specified entry for server-side rendering").option("--sourcemap [output]",'[boolean | "inline" | "hidden"] output source maps for build (default: false)').option("--minify [minifier]",'[boolean | "terser" | "esbuild"] enable/disable minification, or specify minifier to use (default: esbuild)').option("--manifest [name]","[boolean | string] emit build manifest json").option("--ssrManifest [name]","[boolean | string] emit ssr manifest json").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle (experimental)").option("--emptyOutDir","[boolean] force empty outDir when it's outside of root").option("-w, --watch","[boolean] rebuilds when modules have changed on disk").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Fe(n);const i=Se(n),s=te(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel,buildOverrides:s}),r=v(o,{root:e,base:n.base,mode:n.mode,configFile:n.config,logLevel:n.logLevel,clearScreen:n.clearScreen,optimizeDeps:{force:n.force},build:i},!0);if(await y(r),n.changelog){const t=e||process.cwd(),o=r.build?.outDir||"dist";let i="dist-zip";r.ppDevConfig&&(!1===r.ppDevConfig.distZip?i=o:"object"==typeof r.ppDevConfig.distZip&&"string"==typeof r.ppDevConfig.distZip.outDir&&(i=r.ppDevConfig.distZip.outDir)),await Re({changelog:n.changelog,executionRoot:t,newAssetsPath:m.resolve(t,o),backupsDirPath:m.resolve(t,r.ppDevConfig?.syncBackupsDir||"backups"),changelogDestinationPath:m.resolve(t,i),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("next-build [root]","build a Next.js app for production (`next build`) and emit VERSION/BUILD-MANIFEST/zip in the same format as `pp-dev build`").option("--changelog [assetsFile]","[boolean | string] generate changelog between assetsFile and current build (default: false)").option("--distZip","[boolean] pack build output into a ZIP archive; use --no-distZip to disable (default: pp-dev config build.zip, or true). Env: PP_DEV_DIST_ZIP").option("--distZipDir <dir>","[string] override the ZIP output directory (default: 'dist-zip'). Env: PP_DEV_DIST_ZIP_DIR").option("--distZipFilename <filename>","[string] override the ZIP output file name (default: '<app-name>.zip'). Env: PP_DEV_DIST_ZIP_FILENAME").option("--versionManifest","[boolean] emit VERSION-*.json + BUILD-MANIFEST.json; use --no-versionManifest to disable (default: pp-dev config build.versionFile, or true). Env: PP_DEV_VERSION_MANIFEST").option("--versionFileTemplate <template>","[string] override the VERSION file name template (default: 'VERSION-v{packageversion}-{currentDate}.json'). Env: PP_DEV_VERSION_FILE_TEMPLATE").action(async(e,n)=>{Fe(n);const i=t(n.logLevel),s=e?m.resolve(process.cwd(),e):process.cwd(),r=te(n);process.env[u]="1";try{K(n.mode||"production",s);const{constants:e}=await X(),t=await(import("next/dist/server/config.js")),l=t.default.default||t["module.exports"].default||t.default,c=await l(e.PHASE_PRODUCTION_BUILD,s);let d=c?.ppDev||{};if(0===Object.keys(d).length){const{getConfig:e}=await import("./index-DioJ4R68.js").then(e=>e.h);d=await e(s)}const{getPkg:p}=await import("./index-DioJ4R68.js").then(e=>e.h),f=a(d,p(s).name),u=oe(f.distZip,r,g(f.templateName)),w=ne(f.versionPlugin,r),b=B(s,c);b&&i.info(o.dim(`[pp-dev] Removed stale dev route types: ${m.relative(s,b)}`)),i.info(o.cyan("[pp-dev] Running `next build`...")),await G(s);const v="string"==typeof c?.distDir&&c.distDir?c.distDir:".next",y=".next"===v?"out":v,P=m.resolve(s,y);if(!ie.existsSync(P)||!ie.statSync(P).isDirectory())throw new Error(`Next.js build output directory not found: ${P}. "next-build" requires "output: 'export'" in next.config (static export).`);const x=JSON.parse(ie.readFileSync(m.join(s,"package.json"),"utf-8"));if(!1!==w&&!1!==w.enabled&&(await ge({outDir:P,packageVersion:"string"==typeof x.version?x.version:"0.0.0",versionFileTemplate:w.versionFileTemplate,packageRepositoryUrl:"string"==typeof x.repository?x.repository:x.repository?.url,enabled:w.enabled}),i.info(o.green(`✅ VERSION / BUILD-MANIFEST written to ${m.relative(s,P)}`))),!1!==u){const e=m.resolve(s,u.outDir),t=u.inDir?m.resolve(P,u.inDir):P,n=h(e,u.outFileName,"ZIP output file name");ie.mkdirSync(m.dirname(n),{recursive:!0});const r=await q(t);ie.writeFileSync(n,r),i.info(o.green(`✅ Zip archive written to ${m.relative(s,n)}`))}if(n.changelog){const e=!1!==u?u.outDir:y;await Re({changelog:n.changelog,executionRoot:s,newAssetsPath:P,backupsDirPath:m.resolve(s,f.syncBackupsDir),changelogDestinationPath:m.resolve(s,e),logLevel:n.logLevel})}}catch(e){t(n.logLevel).error(o.red(`error during next-build:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("changelog [oldAssetPath] [newAssetPath]","generate changelog between two assets files/folders").option("--oldAssetsPath <oldAssetsPath>","[string] path to the old assets zip file or folder").option("--newAssetsPath <newAssetsPath>","[string] path to the new assets zip file or folder").option("--destination <destination>","[string] destination folder for the changelog (default: .)").option("--filename <filename>","[string] filename for the changelog (default: CHANGELOG.html)").action(async(e,n,i)=>{Fe(i);const{oldAssetsPath:s=e,newAssetsPath:r=n,destination:a=".",filename:l="CHANGELOG.html",logLevel:c}=i,d=process.cwd();s&&r||(t(c).error(o.red("error during changelog generation: oldAssetPath and newAssetPath are required")),process.exit(1));const p=m.resolve(d,s),f=m.resolve(d,r),u=m.resolve(d,a),g=new Me({oldAssetsPath:p,newAssetsPath:f,destinationPath:u,changelogFilename:l});await g.generateChangelog()})}(Oe),function(e){e.command("generate-icon-font [source] [destination]","generate icon font from SVG files").option("--source <source>","[string] path to the source directory with SVG files").option("--destination <destination>","[string] path to the destination directory to save the generated font files").option("--font-name, -n <fontName>","[string] name of the font to generate (default: 'icon-font')").action(async(e,n,i)=>{Fe(i);const{source:s=e,destination:r=n,fontName:a="icon-font"}=i,l=process.cwd(),c=m.resolve(l,s),d=m.resolve(l,r),p=new He({sourceDir:c,outputDir:d,fontName:a}),f=t(i.logLevel);f.info(`Generating icon font from SVG files in ${o.dim(c)}`),await p.generate(),f.info(`Icon font generated and saved to ${o.dim(d)}`)})}(Oe),function(e){e.command("optimize [root]","pre-bundle dependencies").option("--force","[boolean] force the optimizer to ignore the cache and re-bundle").action(async(e,n)=>{Fe(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel}),i=await P(v(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode}),"serve");await x(i,n.force,!0)}catch(e){t(n.logLevel).error(o.red(`error when optimizing deps:\n${e.stack}`),{error:e}),process.exit(1)}})}(Oe),function(e){e.command("preview [root]","locally preview production build").option("--host [host]","[string] specify hostname").option("--port <port>","[number] specify port").option("--strictPort","[boolean] exit if specified port is already in use").option("--https","[boolean] use TLS + HTTP/2").option("--open [path]","[boolean | string] open browser on startup").option("--outDir <dir>","[string] output directory (default: dist)").action(async(e,n)=>{Fe(n);try{const t=n.mode||"production",{config:o}=await De({root:e,mode:t,command:"build",configFile:n.config,logLevel:n.logLevel});(await S(v(o,{root:e,base:n.base,configFile:n.config,logLevel:n.logLevel,mode:n.mode,build:{outDir:n.outDir},preview:{port:n.port,strictPort:n.strictPort,host:n.host,https:n.https,open:n.open}}))).printUrls()}catch(e){t(n.logLevel).error(o.red(`error when starting preview server:\n${e.stack}`),{error:e}),process.exit(1)}finally{Ie(e=>t(n.logLevel).info(e))}})}(Oe),function(e){e.command("migrate [config]","migrate pp-dev config from 0.x flat format to 1.0 grouped format").option("--dry-run","[boolean] print migrated config without writing any files").option("--format <format>","[string] output format: ts (default), js, json").option("--output <file>","[string] output file path (default: pp-dev.config.ts)").option("--no-backup","[boolean] skip backup of original config file").action(async(e,n)=>{const i=t(n.logLevel),{isLegacyFlatConfig:s,isLegacyPPWatchConfig:r,isAlreadyMigrated:a,migrateLegacyFlatConfig:l,migratePPWatchConfig:c,generateConfigFileContent:d,discoverMigrateSource:p,loadPackageJsonMigrateConfig:f}=await(import("./migrate-FpJKfYgz.js")),u=n.format??"ts",g=!1!==n.backup,h=process.cwd(),w=p(h,e);w||(i.warn(o.yellow("No pp-dev or pp-watch config file found in the current directory.")),i.info(o.blue('Supported files: pp-dev.config.{ts,js,cjs,mjs,json}, .pp-watch.config.{ts,js,json}, or a "pp-dev" field in package.json')),process.exit(1));const{sourceFile:b,isWatchConfig:v,isPackageJsonConfig:y}=w;i.info(o.blue(`Found config: ${m.relative(h,b)}`));const{getPkg:P}=await import("./index-DioJ4R68.js").then(e=>e.h),x=P();let S,k={};try{if(/\.[cm]?ts$/i.test(b)){const e=await(import("esbuild")),{pathToFileURL:t}=await(import("url")),o=(await e.build({absWorkingDir:h,entryPoints:[b],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:"esm",mainFields:["main"]})).outputFiles[0].text,n=`pp-migrate-tmp-${Date.now()}.mjs`;ie.writeFileSync(n,o);try{const e=await(import(t(m.resolve(h,n)).toString()));k=e.default?.default??e.default??e}finally{ie.existsSync(n)&&ie.unlinkSync(n)}}else if(/\.[cm]?js$/i.test(b)){const{pathToFileURL:e}=await(import("url")),t=await(import(e(m.resolve(h,b)).toString()));k=t.default?.default??t.default??t}else y?k=f(b):b.endsWith(".json")&&(k=JSON.parse(ie.readFileSync(b,"utf-8")))}catch(e){i.error(o.red(`Failed to load config file: ${e.message}`)),process.exit(1)}k&&"object"==typeof k||(i.error(o.red("Config file did not export a valid object.")),process.exit(1)),a(k)?(i.info(o.green("Config is already in 1.0 format — nothing to migrate.")),process.exit(0)):v||r(k)?(i.info(o.blue("Detected pp-watch config format → migrating to 1.0")),S=c(k)):s(k)?(i.info(o.blue("Detected 0.x flat config format → migrating to 1.0")),S=l(k,x.name)):(i.warn(o.yellow("Could not detect config format. No known keys found.")),process.exit(1));const T=d(S,u),L=n.output??m.join(h,`pp-dev.config.${u}`);if(n.dryRun&&(i.info(o.green(`\n--- Migrated config (dry-run) → ${m.relative(h,L)} ---\n`)),process.exit(0)),g&&!y&&ie.existsSync(b)){const e=`${b}.bak`;ie.copyFileSync(b,e),i.info(o.blue(`Backed up original to: ${m.relative(h,e)}`))}ie.writeFileSync(L,T,"utf-8"),i.info(o.green(`✅ Migration complete → ${m.relative(h,L)}`)),y?i.info(o.yellow('You can now remove the "pp-dev" field from package.json.')):b!==L&&ie.existsSync(b)&&i.info(o.yellow(`You can now delete the old config: ${m.relative(h,b)}`))})}(Oe),Oe.help(),Oe.version(i),Oe.parse();export{Ie as stopProfiler};
2
2
  //# sourceMappingURL=cli.js.map
@@ -0,0 +1,2 @@
1
+ import{execSync as e}from"child_process";import{k as t,l as n,V as s,m as i,P as r,o,v as a,n as c,j as p,d as l,f as u,g as d,c as m,a as f,e as v,p as g}from"./auth.provider-Cq0EuReh.js";import{createRequire as h}from"node:module";import{normalizePath as _,loadEnv as j}from"vite";import*as y from"fs";import{readdirSync as $,readFileSync as b,writeFileSync as E,unlinkSync as w}from"fs";import*as P from"path";import I from"path";import{pathToFileURL as T}from"url";import"./helpers.js";import D from"ejs";const R=P.dirname(n),S=P.join(R,"index.html");let O=null;function x(e){return{css:P.posix.join(e,t,"client/client.css"),js:P.posix.join(e,t,"client/client.js")}}function N(e){return function(){if(O)return O;const e=y.readFileSync(S,{encoding:"utf8"});return O=D.compile(e,{openDelimiter:"{",closeDelimiter:"}",async:!1,rmWhitespace:!0,compileDebug:!1}),O}()({PACKAGE_NAME:t,VERSION:s,backendBaseURL:e.backendBaseURL,templateLess:e.templateLess,appId:e.appId,canSync:e.canSync??!0,devPanelPosition:e.devPanelPosition??"bottom-right",devPanelHidden:e.devPanelHidden??!1,devPanelAutoHide:e.devPanelAutoHide??!1})}function F(e,t,n){if(!/<\/?(html|body|head)\b/i.test(e))return e;const{css:s,js:i}=x(t),r=N(n),o=`<link rel="stylesheet" href="${s}">`,a=`${r}${`<script type="module" src="${i}"><\/script>`}`;let c=e,p=!1;if(/<\/head>/i.test(c)&&(c=c.replace(/<\/head>/i,e=>`${o}${e}`),p=!0),/<body[^>]*>/i.test(c)){const e=p?"":o;c=c.replace(/<body[^>]*>/i,t=>`${t}${e}${a}`)}else c=`${p?"":o}${c}${a}`;return c}const L={".js":"text/javascript; charset=utf-8",".css":"text/css; charset=utf-8",".map":"application/json; charset=utf-8"};function C(e){const n=P.posix.join(e,t,"client")+"/",s=new Set(["client.js","client.css","client.js.map","client.css.map"]);return(e,t,i)=>{const r=(e.url??"").split("?")[0];if(!r.startsWith(n))return void i();const o=r.slice(n.length);if(!s.has(o))return void i();const a=P.join(R,o);y.readFile(a,(e,n)=>{e?i():(t.statusCode=200,t.setHeader("Content-Type",L[P.extname(o)]??"application/octet-stream"),t.setHeader("Cache-Control","no-cache"),t.end(n))})}}const U=_(P.join(i,"dist/client")),Z=new RegExp(`^\\/?${t}\\/client\\/(.*)$`);const A=(e,t)=>` * ${t}`;function M(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,A)}\n */`}async function V(){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 k=()=>h(import.meta.url);async function H(){try{return k().resolve("next"),!0}catch{return!1}}async function B(){try{const e=k()("next/package.json");return"string"==typeof e.version?e.version:null}catch{return null}}let z=new Set;function W(e="development",t=process.cwd()){for(const e of z)delete process.env[e];const n=new Set(Object.keys(process.env).filter(e=>e.startsWith("MI_"))),s=j(e,t,"MI_");for(const[e,t]of Object.entries(s))process.env[e]=t;return z=new Set(Object.keys(s).filter(e=>!n.has(e))),s}const G=new Map,J=new Map;function q(e=process.cwd()){const t=Date.now(),n=I.resolve(e),s=J.get(n);if(s&&t-s.timestamp<6e4)return s.data;try{const e=JSON.parse(b(I.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return J.set(n,{data:e,timestamp:t}),e}catch{const e={};return J.set(n,{data:e,timestamp:t}),e}}let K=null;const Y="__pp_dev_injected_dirname",Q="__pp_dev_injected_filename",X="__pp_dev_injected_import_meta_url",ee={__dirname:Y,__filename:Q,"import.meta.url":X,"import.meta.dirname":Y,"import.meta.filename":Q},te={name:"pp-dev:config-module-location",setup(e){e.onLoad({filter:/\.([cm]?[jt]s|[jt]sx)$/},e=>{const t=b(e.path,"utf-8").replace(/^#![^\r\n]*/,"");return{contents:`const ${Y} = ${JSON.stringify(I.dirname(e.path))};const ${Q} = ${JSON.stringify(e.path)};const ${X} = ${JSON.stringify(T(e.path).href)};`+t,loader:e.path.endsWith(".tsx")?"tsx":e.path.endsWith(".jsx")?"jsx":/ts$/.test(e.path)?"ts":"js"}})}};async function ne(e,t){const n=`bundled:${e}`,s=G.get(n);if(s&&Date.now()-s.timestamp<3e4)return s.data;let i=!1;if(/\.m[jt]s$/.test(e))i=!0;else if(/\.c[jt]s$/.test(e))i=!1;else{const e=q(t);i=!!e&&"module"===e.type}const r=await async function(){return K||(K=await(import("esbuild"))),K}(),o=await r.build({absWorkingDir:t,entryPoints:[e],outfile:"out.js",write:!1,target:"node24",platform:"node",bundle:!0,packages:"external",format:i?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0,plugins:[te],define:ee,...i?{banner:{js:"import { createRequire as __ppDevCreateRequire } from 'node:module';const require = __ppDevCreateRequire(import.meta.url);"}}:{}}),{text:a}=o.outputFiles[0],c=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.${i?"mjs":"cjs"}`,p=I.resolve(t,c),l=T(p).toString();E(p,a);let u={};try{const t=(await(import(l))).default;u=t?.default||t,G.set(n,{data:u,timestamp:Date.now(),filePath:e})}finally{try{w(p)}catch{}}return u}async function se(e){const t=`json:${e}`,n=G.get(t);if(n&&Date.now()-n.timestamp<3e4)return n.data;const s=JSON.parse(b(e,{encoding:"utf-8"}));return G.set(t,{data:s,timestamp:Date.now(),filePath:e}),s}const ie=new Map;function re(e=process.cwd()){return q(e)}async function oe(e=process.cwd()){const t=I.resolve(e),n=function(e){const t=Date.now(),n=ie.get(e);if(n&&t-n.timestamp<1e4)return n.files;const s=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,i=$(e,{withFileTypes:!0}).filter(e=>e.isFile()&&s.test(e.name)).map(e=>e.name);return ie.set(e,{files:i,timestamp:t}),i}(t);let s={},i=!1;const o=await async function(e,t,n){for(const s of t)if(e.includes(s)){const e=I.resolve(n,s);if(/\.[cm]?[jt]s$/i.test(s))return await ne(e,n);if(s.endsWith(".json"))return await se(e)}return null}(n,r,t);o&&(s=o,i=!0);const a=q(t)["pp-dev"];return i||!a||"object"!=typeof a||Array.isArray(a)||(s=a),s}const ae=Object.freeze({__proto__:null,clearConfigCache:function(){G.clear(),J.clear(),ie.clear()},getConfig:oe,getPkg:re});function ce(e){if(void 0!==e)return"1"===e||"true"===e.toLowerCase()||"0"!==e&&"false"!==e.toLowerCase()&&void 0}function pe(e){return{distZipEnabled:e.distZip??ce(process.env.PP_DEV_DIST_ZIP),distZipDir:e.distZipDir??process.env.PP_DEV_DIST_ZIP_DIR,distZipFilename:e.distZipFilename??process.env.PP_DEV_DIST_ZIP_FILENAME,versionManifestEnabled:e.versionManifest??ce(process.env.PP_DEV_VERSION_MANIFEST),versionFileTemplate:e.versionFileTemplate??process.env.PP_DEV_VERSION_FILE_TEMPLATE}}function le(e,t,n){if(!1===t.distZipEnabled)return!1;if(!0!==t.distZipEnabled&&void 0===t.distZipDir&&void 0===t.distZipFilename)return!1!==e&&{...e,outFileName:o(e.outFileName,"ZIP output file name")};const s=!1===e?{outFileName:n,outDir:"dist-zip"}:e,i=t.distZipFilename??s.outFileName;return{...s,...void 0!==t.distZipDir?{outDir:t.distZipDir}:{},outFileName:o(i,"ZIP output file name")}}function ue(e,t){if(!1===t.versionManifestEnabled)return!1;if(!0!==t.versionManifestEnabled&&void 0===t.versionFileTemplate)return!1!==e&&void 0!==e.versionFileTemplate?{...e,versionFileTemplate:o(e.versionFileTemplate,"VERSION file name template")}:e;const n=!1===e?{enabled:!0}:e,s=t.versionFileTemplate??n.versionFileTemplate,i=void 0!==s?o(s,"VERSION file name template"):void 0;return{...n,enabled:!0,...void 0!==i?{versionFileTemplate:i}:{}}}const de=new Set(["mi","app","proxy","build","sync","inspector","devPanel","users","server"]);function me(t){if("string"==typeof t)return t;if(t&&"object"==typeof t&&"url"in t&&"string"==typeof t.url)return t.url;const n=["CI_REPOSITORY_URL","GIT_URL","BUILD_REPOSITORY_URI","CI_PROJECT_URL","BITBUCKET_GIT_HTTP_ORIGIN","BUILDKITE_REPO"];for(const e of n){const t=process.env[e];if("string"==typeof t&&t.trim())return t}const s=process.env.GITHUB_REPOSITORY;if("string"==typeof s&&s.trim()){return`${(process.env.GITHUB_SERVER_URL||"https://github.com").replace(/\/+$/,"")}/${s.replace(/^\/+/,"")}`}const i=process.env.CI_PROJECT_PATH;if("string"==typeof i&&i.trim()){return`${(process.env.CI_SERVER_URL||"https://gitlab.com").replace(/\/+$/,"")}/${i.replace(/^\/+/,"")}`}const r=process.env.BITBUCKET_REPO_FULL_NAME;if("string"==typeof r&&r.trim())return`https://bitbucket.org/${r.replace(/^\/+/,"")}`;const o=process.env.TRAVIS_REPO_SLUG;if("string"==typeof o&&o.trim())return`https://github.com/${o.replace(/^\/+/,"")}`;try{const t=e("git config --get remote.origin.url",{encoding:"utf8",stdio:["ignore","pipe","ignore"]}).trim();if(t)return t}catch{}}async function fe(e,s={}){const i=s.root??process.cwd();W(s.mode,i);const r=re(i),o=await oe(i);a(o,r.name);const d=c(o,r.name),{templateName:m}=d;e&&(d.distZip=le(d.distZip,e,p(m)),d.versionPlugin=ue(d.versionPlugin,e));const{default:f}=await(import("./plugin.js")),v=[f(d),{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${t}/client`),e),resolveId(e){const t=e.match(Z);if(t){const e=_(P.join(U,t[1]));return e.startsWith(`${U}/`)?{id:e}:null}},transformIndexHtml:async(e,t)=>{const n=x(t.server?.config.base||""),s={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:n.css}}]},{templateLess:i=!1,...r}=t.server?.config.clientInjectionPlugin||{};return s.tags.push({tag:"div",injectTo:"body-prepend",children:N({templateLess:i,...r})}),s.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:n.js,type:"module"}}),s},configureServer(e){const t=_(P.resolve(e.config.root,P.dirname(n)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t)}}],{outDir:g,distZip:h,versionPlugin:j,imageOptimizer:y,templateLess:$,integrateMiTopBar:b,allowedHosts:E}=d;if(b&&v.push(function(e){return{name:"mi-topbar-plugin",transformIndexHtml(){const t=[];return(!0===e||"object"==typeof e&&!0===e.addRootElement)&&t.push({tag:"div",injectTo:"body-prepend",attrs:{id:"mi-react-root"}}),(!0===e||"object"==typeof e&&!0===e.addSharedComponentsScripts)&&t.push({tag:"script",injectTo:"head-prepend",attrs:{src:"/auth/info.js"}},{tag:"script",injectTo:"head-prepend",attrs:{src:"/js/main.js",defer:"defer"}},{tag:"link",injectTo:"head-prepend",attrs:{href:"/css/main.css",rel:"stylesheet"}}),t}}}(b)),y){const{ViteImageOptimizer:e}=await(import("vite-plugin-image-optimizer"));v.push(e("object"==typeof y?y:void 0))}if(j){const{versionPlugin:e}=await(import("./version-plugin-b2xMXK9M.js"));v.push(e({outDir:g,packageVersion:r.version??"0.0.0",packageRepositoryUrl:me(r.repository),..."object"==typeof j?j:{}}))}if(h){const{default:e}=await(import("vite-plugin-zip-pack"));v.push({...e("object"==typeof h?h:{outFileName:p(m)}),enforce:"post"})}return{base:$?`${l}/${m}`:`${u}/${m}`,server:{port:3e3,...!0===E||E.length>0?{allowedHosts:E}:{}},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:M}},outDir:g},css:{modules:{localsConvention:"dashes"}},ppDevConfig:d,plugins:v}}function ve(e){return e?.ppDev||{}}function ge(e,t){return async(n,s={})=>{try{const{constants:i}=await V(),{PHASE_DEVELOPMENT_SERVER:r,PHASE_PRODUCTION_BUILD:o}=i;n!==o||process.env[d]||m().warn(f.yellow('⚠ Building with plain `next build`. Use `pp-dev next-build` instead to get VERSION/BUILD-MANIFEST/zip build output in the same format as `pp-dev build` (see the "Next.js Build" section in the pp-dev README).'));const p=await oe(),h=re().name,_="function"==typeof e?await e(n,s):e,j=function(...e){const t={},n=t;for(const t of e)if(t)for(const[e,s]of Object.entries(t))void 0!==s&&(de.has(e)&&s&&"object"==typeof s&&!Array.isArray(s)?n[e]={...n[e]??{},...s}:n[e]=s);return t}(p,ve(_),t);a(j,h);const y=c(j,h),{templateLess:$,v7Features:b}=y,E=n===r,w=function(e,t,n,s){return n?s?t?`${l}/${e}`:`${v}/${e}`:t?`${l}/${e}`:`${u}/${e}`:`${l}/${e}`}(y.templateName,$,E,b),P={basePath:w,trailingSlash:!!E||void 0};if(!$){const e=E&&b?v:u;P.assetPrefix=`${e}/${y.templateName}`}const I=Object.assign({},P,_),T=g(y.allowedHosts);return E&&T.length>0&&(I.allowedDevOrigins=[...I.allowedDevOrigins??[],...T]),Object.defineProperty(I,"ppDev",{value:j,enumerable:!1,configurable:!0}),I}catch(e){throw m().error("Error in withPPDev:",{error:e instanceof Error?e:new Error(String(e))}),e}}}export{le as a,ue as b,C as c,B as d,ve as e,H as f,fe as g,ae as h,F as i,W as l,pe as r,V as s,ge as w};
2
+ //# sourceMappingURL=index-DioJ4R68.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DioJ4R68.js","sources":["../../../src/lib/dev-panel.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/lib/env.ts","../../../src/config.ts","../../../src/lib/build-cli-overrides.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":["CLIENT_DIST_DIR","path","dirname","PP_DEV_CLIENT_ENTRY","TEMPLATE_PATH","join","compiledTemplate","getDevPanelAssetPaths","base","css","posix","PACKAGE_NAME","js","renderDevPanelMarkup","data","templateContent","fs","readFileSync","encoding","ejs","compile","openDelimiter","closeDelimiter","async","rmWhitespace","compileDebug","getTemplate","template","VERSION","backendBaseURL","templateLess","appId","canSync","devPanelPosition","devPanelHidden","devPanelAutoHide","injectDevPanel","html","test","panelMarkup","linkTag","bodyPrepend","result","linkInjected","replace","headEnd","head","bodyStart","CONTENT_TYPES","createDevPanelAssetMiddleware","assetPrefix","allowed","Set","req","res","next","pathname","url","split","startsWith","fileName","slice","length","has","filePath","readFile","err","content","statusCode","setHeader","extname","end","normalizePath","PP_DEV_PACKAGE_DIR","PACKAGE_REGEXP","RegExp","replacer","substring","$1","header","_chunk","safeNextImport","constants","Promise","all","default","error","Error","requireFromPPDev","createRequire","isNextAvailable","resolve","getNextVersion","nextPkg","version","previouslyLoadedKeys","loadPPDevEnv","mode","envDir","process","cwd","key","env","fromEnvironment","Object","keys","filter","loadEnv","value","entries","configCache","Map","packageJsonCache","getPackageJson","projectRoot","now","Date","root","cached","get","timestamp","JSON","parse","flag","set","empty","esbuildModule","MODULE_LOCATION","MODULE_LOCATION_DEFINE","__dirname","__filename","moduleLocationPlugin","name","setup","build","onLoad","args","contents","stringify","pathToFileURL","href","loader","endsWith","loadBundledConfig","cacheKey","isESM","pkg","type","esbuild","getEsbuild","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","packages","format","mainFields","sourcemap","metafile","plugins","define","banner","text","code","outputFiles","fileNameTmp","Math","random","toString","tempFilePath","fileUrl","writeFileSync","config","conf","unlinkSync","loadJSONConfig","dirContentCache","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","isFile","map","getDirectoryContent","configFound","newConfig","dirFiles","configNames","configName","includes","configPath","loadConfig","PP_DEV_CONFIG_NAMES","packageConfig","Array","isArray","clear","parseBooleanFlag","undefined","toLowerCase","resolveBuildCliOverrides","options","distZipEnabled","distZip","PP_DEV_DIST_ZIP","distZipDir","PP_DEV_DIST_ZIP_DIR","distZipFilename","PP_DEV_DIST_ZIP_FILENAME","versionManifestEnabled","versionManifest","PP_DEV_VERSION_MANIFEST","versionFileTemplate","PP_DEV_VERSION_FILE_TEMPLATE","applyDistZipOverride","overrides","defaultFileName","outFileName","normalizeRelativeOutputPath","baseConfig","outDir","applyVersionManifestOverride","enabled","normalizedVersionFileTemplate","PP_DEV_CONFIG_GROUPS","resolveRepositoryUrl","repository","directCiRepositoryUrlEnvVars","variableName","ciRepositoryUrl","trim","githubRepository","GITHUB_REPOSITORY","GITHUB_SERVER_URL","gitlabProjectPath","CI_PROJECT_PATH","CI_SERVER_URL","bitbucketRepositoryFullName","BITBUCKET_REPO_FULL_NAME","travisRepositorySlug","TRAVIS_REPO_SLUG","gitRemoteOriginUrl","execSync","stdio","getViteConfig","environment","ppDevConfig","validatePPDevConfig","normalizedPPDevConfig","normalizePPDevConfig","templateName","createDefaultZipFileName","versionPlugin","vitePPDev","apply","optimizeDeps","exclude","push","resolveId","source","match","resolvedId","id","transformIndexHtml","ctx","assetPaths","server","tags","tag","injectTo","attrs","rel","panelOptions","clientInjectionPlugin","children","src","configureServer","clientDir","allow","imageOptimizer","integrateMiTopBar","allowedHosts","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","versionPluginFn","packageVersion","packageRepositoryUrl","zipPack","enforce","PATH_PAGE_PREFIX","PATH_TEMPLATE_PREFIX","port","minify","assetsInlineLimit","rollupOptions","output","modules","localsConvention","getPPDevConfigFromNextConfig","nextConfig","ppDev","withPPDev","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","PHASE_PRODUCTION_BUILD","PP_DEV_NEXT_BUILD_ENV_VAR","createLogger","warn","colors","yellow","nextConfiguration","mergedConfig","configs","merged","mutableMerged","mergePPDevConfigs","normalized","v7Features","isDevelopment","basePath","PATH_TEMPLATE_LOCAL_PREFIX","createBasePath","trailingSlash","prefix","assign","tunnelOrigins","exactAllowedHosts","allowedDevOrigins","defineProperty","enumerable","configurable","String"],"mappings":"6fA4BA,MAAMA,EAAkBC,EAAKC,QAAQC,GAC/BC,EAAgBH,EAAKI,KAAKL,EAAiB,cAEjD,IAAIM,EAA4C,KAqB1C,SAAUC,EAAsBC,GACpC,MAAO,CACLC,IAAKR,EAAKS,MAAML,KAAKG,EAAMG,EAAc,qBACzCC,GAAIX,EAAKS,MAAML,KAAKG,EAAMG,E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,QAAuB5H,GAGxC,IAAK9K,EAAc,CACjB,MAAM+S,EAASL,GAAiBD,EAAaG,EAA6B/B,EAE1E1E,EAAW/K,YAAc,GAAG2R,KAAUP,EAAWtE,cACnD,CAKA,MAAMtN,EAAS8D,OAAOsO,OAAO,CAAA,EAAI7G,EAAY+F,GAMvCe,EAAgBC,EAAkBV,EAAWvC,cAYnD,OAVIyC,GAAiBO,EAAcjR,OAAS,IAC1CpB,EAAOuS,kBAAoB,IAAKvS,EAAOuS,mBAAqB,MAAQF,IAGtEvO,OAAO0O,eAAexS,EAAQ,QAAS,CACrCkE,MAAOqN,EACPkB,YAAY,EACZC,cAAc,IAGT1S,CACT,CAAE,MAAO4C,GAKP,MAJesO,IAERtO,MAAM,sBAAuB,CAAEA,MAAOA,aAAiBC,MAAQD,EAAQ,IAAIC,MAAM8P,OAAO/P,MAEzFA,CACR,EAEJ"}
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import"child_process";export{A as AuthProvider,l as authProvider,n as normalizePPDevConfig,v as validatePPDevConfig}from"./auth.provider-B9ybFjL5.js";export{d as getNextVersion,e as getPPDevConfigFromNextConfig,g as getViteConfig,f as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-ypcJ5r5C.js";export{defineConfig}from"./helpers.js";import"fs";import"path";import"url";import"picocolors";import"node:path";import"vite";import"node:module";import"ejs";
1
+ import"child_process";export{A as AuthProvider,q as authProvider,n as normalizePPDevConfig,v as validatePPDevConfig}from"./auth.provider-Cq0EuReh.js";export{d as getNextVersion,e as getPPDevConfigFromNextConfig,g as getViteConfig,f as isNextAvailable,s as safeNextImport,w as withPPDev}from"./index-DioJ4R68.js";export{defineConfig}from"./helpers.js";import"fs";import"path";import"url";import"picocolors";import"node:path";import"node:net";import"vite";import"node:module";import"ejs";
2
2
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ import{readFileSync as e,existsSync as i}from"fs";import t from"path";import{P as n}from"./auth.provider-Cq0EuReh.js";import"url";import"picocolors";import"node:path";import"node:net";import"vite";const o=new Set(["backendBaseURL","personalAccessToken","miHudLess","integrateMiTopBar","v7Features","appId","portalPageId","templateName","templateLess","enableProxyCache","proxyCacheTTL","disableSSLValidation","distZip","versionPlugin","imageOptimizer","outDir","syncBackupsDir"]);function r(e){return Object.keys(e).some(e=>o.has(e))}function a(e){return"baseURL"in e}function s(e){const i=new Set(["mi","app","proxy","build","sync","inspector"]);return Object.keys(e).some(e=>i.has(e))}const p=[".pp-watch.config.ts",".pp-watch.config.js",".pp-watch.config.json","pp-watch.config.ts","pp-watch.config.js","pp-watch.config.json"];function c(o,r){let a=r??null,s=!1;if(!a){for(const e of n){const n=t.join(o,e);if(i(n)){a=n;break}}if(!a)for(const e of p){const n=t.join(o,e);if(i(n)){a=n,s=!0;break}}if(!a){const n=t.join(o,"package.json");if(i(n))try{const i=JSON.parse(e(n,"utf-8"));i["pp-dev"]&&"object"==typeof i["pp-dev"]&&!Array.isArray(i["pp-dev"])&&(a=n)}catch{}}}return a?{sourceFile:a,isWatchConfig:s,isPackageJsonConfig:"package.json"===t.basename(a)}:null}function l(i){return JSON.parse(e(i,"utf-8"))["pp-dev"]}function d(e,i){const t={},n={};void 0!==e.backendBaseURL&&(n.url=e.backendBaseURL),void 0!==e.personalAccessToken&&(n.token=e.personalAccessToken),void 0!==e.miHudLess&&(n.mode=e.miHudLess?"standalone":"embedding"),e.integrateMiTopBar&&(!0===e.integrateMiTopBar?(n.mode||(n.mode="standalone"),n.include="top-bar"):"object"==typeof e.integrateMiTopBar&&(e.integrateMiTopBar.addRootElement||e.integrateMiTopBar.addSharedComponentsScripts)&&(n.mode||(n.mode="standalone"),n.include=e.integrateMiTopBar.addRootElement?"top-bar":"shared-components")),void 0!==e.v7Features&&(n.apiVersion=e.v7Features?7:6),Object.keys(n).length>0&&(t.mi=n);const o={},r=e.appId??e.portalPageId;void 0!==r&&(o.id=r),void 0!==e.templateName&&e.templateName!==i&&(o.name=e.templateName),void 0!==e.templateLess&&(o.type=e.templateLess?"page":"template"),Object.keys(o).length>0&&(t.app=o);const a={};void 0!==e.enableProxyCache&&(a.cache=e.enableProxyCache),void 0!==e.proxyCacheTTL&&(a.cacheTtl=e.proxyCacheTTL),void 0!==e.disableSSLValidation&&(a.tls={allowSelfSigned:e.disableSSLValidation}),Object.keys(a).length>0&&(t.proxy=a);const s={};if(void 0!==e.outDir&&(s.outDir=e.outDir),void 0!==e.distZip)if("object"==typeof e.distZip&&null!==e.distZip){const i={};void 0!==e.distZip.outFileName&&(i.fileName=e.distZip.outFileName),void 0!==e.distZip.outDir&&(i.outDir=e.distZip.outDir),void 0!==e.distZip.inDir&&(i.inDir=e.distZip.inDir),s.zip=!(Object.keys(i).length>0)||i}else s.zip=e.distZip;if(void 0!==e.versionPlugin)if("object"==typeof e.versionPlugin&&null!==e.versionPlugin){const i={};void 0!==e.versionPlugin.enabled&&(i.enabled=e.versionPlugin.enabled),void 0!==e.versionPlugin.versionFileTemplate&&(i.fileNameTemplate=e.versionPlugin.versionFileTemplate),s.versionFile=!(Object.keys(i).length>0)||i}else s.versionFile=e.versionPlugin;return void 0!==e.imageOptimizer&&(s.imageOptimisations=e.imageOptimizer),Object.keys(s).length>0&&(t.build=s),void 0!==e.syncBackupsDir&&(t.sync={backupsDir:e.syncBackupsDir}),t}function u(e){const i={mi:{url:e.baseURL}};return void 0!==e.portalPageId&&(i.app={id:e.portalPageId}),i}function f(e,i=0){const t=" ".repeat(i),n=" ".repeat(i+1);if(null===e)return"null";if("boolean"==typeof e)return String(e);if("number"==typeof e)return String(e);if("string"==typeof e)return`'${e.replace(/\\/g,"\\\\").replace(/'/g,"\\'")}'`;if(Array.isArray(e)){if(0===e.length)return"[]";return`[\n${e.map(e=>`${n}${f(e,i+1)}`).join(",\n")},\n${t}]`}if("object"==typeof e&&null!==e){const o=Object.entries(e).filter(([,e])=>void 0!==e);if(0===o.length)return"{}";return`{\n${o.map(([e,t])=>`${n}${e}: ${f(t,i+1)}`).join(",\n")},\n${t}}`}return String(e)}function m(e,i="ts"){if("json"===i)return JSON.stringify(e,null,2)+"\n";return`${"ts"===i?"import { defineConfig } from '@metricinsights/pp-dev';":"const { defineConfig } = require('@metricinsights/pp-dev');"}\n\n${"ts"===i?"export default":"module.exports ="} defineConfig(${f(e)});\n`}export{c as discoverMigrateSource,m as generateConfigFileContent,s as isAlreadyMigrated,r as isLegacyFlatConfig,a as isLegacyPPWatchConfig,l as loadPackageJsonMigrateConfig,d as migrateLegacyFlatConfig,u as migratePPWatchConfig};
2
+ //# sourceMappingURL=migrate-FpJKfYgz.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"migrate-BHq9PUZz.js","sources":["../../../src/lib/migrate.ts"],"sourcesContent":[null],"names":["LEGACY_FLAT_KEYS","Set","isLegacyFlatConfig","config","Object","keys","some","k","has","isLegacyPPWatchConfig","isAlreadyMigrated","NEW_KEYS","WATCH_CONFIG_NAMES","discoverMigrateSource","projectRoot","configArg","sourceFile","isWatchConfig","name","PP_DEV_CONFIG_NAMES","candidate","path","join","existsSync","pkgJsonPath","pkgJson","JSON","parse","readFileSync","Array","isArray","isPackageJsonConfig","basename","loadPackageJsonMigrateConfig","migrateLegacyFlatConfig","legacy","packageName","mi","undefined","backendBaseURL","url","personalAccessToken","token","miHudLess","mode","integrateMiTopBar","include","addRootElement","addSharedComponentsScripts","v7Features","apiVersion","length","app","appId","portalPageId","id","templateName","templateLess","type","proxy","enableProxyCache","cache","proxyCacheTTL","cacheTtl","disableSSLValidation","tls","allowSelfSigned","build","outDir","distZip","zip","outFileName","fileName","inDir","versionPlugin","vf","enabled","versionFileTemplate","fileNameTemplate","versionFile","imageOptimizer","imageOptimisations","syncBackupsDir","sync","backupsDir","migratePPWatchConfig","watchCfg","baseURL","serializeValue","value","depth","indent","repeat","innerIndent","String","replace","map","v","entries","filter","generateConfigFileContent","format","stringify"],"mappings":"oLAmCA,MAAMA,EAAmB,IAAIC,IAAI,CAC/B,iBACA,sBACA,YACA,oBACA,aACA,QAC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EAAOiD,IAAM,CAAEG,GAAI+B,EAAShC,eAGvBnD,CACT,CAIA,SAASqF,EAAeC,EAAgBC,EAAQ,GAC9C,MAAMC,EAAS,KAAKC,OAAOF,GACrBG,EAAc,KAAKD,OAAOF,EAAQ,GAExC,GAAc,OAAVD,EACF,MAAO,OAGT,GAAqB,kBAAVA,EACT,OAAOK,OAAOL,GAGhB,GAAqB,iBAAVA,EACT,OAAOK,OAAOL,GAGhB,GAAqB,iBAAVA,EACT,MAAO,IAAIA,EAAMM,QAAQ,MAAO,QAAQA,QAAQ,KAAM,UAGxD,GAAIlE,MAAMC,QAAQ2D,GAAQ,CACxB,GAAqB,IAAjBA,EAAMtC,OACR,MAAO,KAKT,MAAO,MAFOsC,EAAMO,IAAKC,GAAM,GAAGJ,IAAcL,EAAeS,EAAGP,EAAQ,MAAMpE,KAAK,YAE7DqE,IAC1B,CAEA,GAAqB,iBAAVF,GAAgC,OAAVA,EAAgB,CAC/C,MAAMS,EAAU9F,OAAO8F,QAAQT,GAAkCU,OAAO,GAAIF,UAAa3D,IAAN2D,GAEnF,GAAuB,IAAnBC,EAAQ/C,OACV,MAAO,KAKT,MAAO,MAFO+C,EAAQF,IAAI,EAAEzF,EAAG0F,KAAO,GAAGJ,IAActF,MAAMiF,EAAeS,EAAGP,EAAQ,MAEpEpE,KAAK,YAAYqE,IACtC,CAEA,OAAOG,OAAOL,EAChB,UAIgBW,EAA0BjG,EAAqBkG,EAA8B,MAC3F,GAAe,SAAXA,EACF,OAAO3E,KAAK4E,UAAUnG,EAAQ,KAAM,GAAK,KAS3C,MAAO,GALM,OAAXkG,EACI,yDACA,oEACwB,OAAXA,EAAkB,iBAAmB,mCAEFb,EAAerF,QACvE"}
1
+ {"version":3,"file":"migrate-FpJKfYgz.js","sources":["../../../src/lib/migrate.ts"],"sourcesContent":[null],"names":["LEGACY_FLAT_KEYS","Set","isLegacyFlatConfig","config","Object","keys","some","k","has","isLegacyPPWatchConfig","isAlreadyMigrated","NEW_KEYS","WATCH_CONFIG_NAMES","discoverMigrateSource","projectRoot","configArg","sourceFile","isWatchConfig","name","PP_DEV_CONFIG_NAMES","candidate","path","join","existsSync","pkgJsonPath","pkgJson","JSON","parse","readFileSync","Array","isArray","isPackageJsonConfig","basename","loadPackageJsonMigrateConfig","migrateLegacyFlatConfig","legacy","packageName","mi","undefined","backendBaseURL","url","personalAccessToken","token","miHudLess","mode","integrateMiTopBar","include","addRootElement","addSharedComponentsScripts","v7Features","apiVersion","length","app","appId","portalPageId","id","templateName","templateLess","type","proxy","enableProxyCache","cache","proxyCacheTTL","cacheTtl","disableSSLValidation","tls","allowSelfSigned","build","outDir","distZip","zip","outFileName","fileName","inDir","versionPlugin","vf","enabled","versionFileTemplate","fileNameTemplate","versionFile","imageOptimizer","imageOptimisations","syncBackupsDir","sync","backupsDir","migratePPWatchConfig","watchCfg","baseURL","serializeValue","value","depth","indent","repeat","innerIndent","String","replace","map","v","entries","filter","generateConfigFileContent","format","stringify"],"mappings":"qMAmCA,MAAMA,EAAmB,IAAIC,IAAI,CAC/B,iBACA,sBACA,YACA,oBACA,aACA,QACA,eACA,eACA,eACA,mBACA,gBACA,uBACA,UACA,gBACA,iBACA,SACA,mBAGI,SAAUC,EAAmBC,GACjC,OAAOC,OAAOC,KAAKF,GAAQG,KAAMC,GAAMP,EAAiBQ,IAAID,GAC9D,CAEM,SAAUE,EAAsBN,GACpC,MAAO,YAAaA,CACtB,CAEM,SAAUO,EAAkBP,GAChC,MAAMQ,EAAW,IAAIV,IAAI,CAAC,KAAM,MAAO,QAAS,QAAS,OAAQ,cAEjE,OAAOG,OAAOC,KAAKF,GAAQG,KAAMC,GAAMI,EAASH,IAAID,GACtD,CAIA,MAAMK,EAAqB,CACzB,sBACA,sBACA,wBACA,qBACA,qBACA,wBAaI,SAAUC,EAAsBC,EAAqBC,GACzD,IAAIC,EAA4BD,GAAa,KACzCE,GAAgB,EAEpB,IAAKD,EAAY,CACf,IAAK,MAAME,KAAQC,EAAqB,CACtC,M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GAAqB,iBAAVF,GAAgC,OAAVA,EAAgB,CAC/C,MAAMS,EAAU9F,OAAO8F,QAAQT,GAAkCU,OAAO,GAAIF,UAAa3D,IAAN2D,GAEnF,GAAuB,IAAnBC,EAAQ/C,OACV,MAAO,KAKT,MAAO,MAFO+C,EAAQF,IAAI,EAAEzF,EAAG0F,KAAO,GAAGJ,IAActF,MAAMiF,EAAeS,EAAGP,EAAQ,MAEpEpE,KAAK,YAAYqE,IACtC,CAEA,OAAOG,OAAOL,EAChB,UAIgBW,EAA0BjG,EAAqBkG,EAA8B,MAC3F,GAAe,SAAXA,EACF,OAAO3E,KAAK4E,UAAUnG,EAAQ,KAAM,GAAK,KAS3C,MAAO,GALM,OAAXkG,EACI,yDACA,oEACwB,OAAXA,EAAkB,iBAAmB,mCAEFb,EAAerF,QACvE"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "module",
4
- "version": "1.5.0-beta.20",
4
+ "version": "1.5.0-beta.22",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -1,2 +1,2 @@
1
- import{d as e,e as s,b as o,R as t,a as r,r as a,I as i,g as l,M as p,j as d,f as c,k as u,l as m,m as g,n as f,v as h,w as k,x as b,y,A as I,B as P,D as T,s as w,U as E,V as S,o as x,u as A,C as j}from"./request-capture.middleware-VCmWYJoS.js";import{a as D}from"./auth.provider-B9ybFjL5.js";export{n as normalizePPDevConfig,v as validatePPDevConfig}from"./auth.provider-B9ybFjL5.js";import"zlib";import"url";import"axios";import"node:http";import"node:https";import"./version-manifest-CuZrGM-C.js";import"crypto";import"child_process";import"fs/promises";import"path";import"util";import"node:module";import"http-proxy-middleware";import"node:string_decoder";import"fs";import"process";import"os";import"jszip";import"module";import"node:crypto";import"node:fs";import"node:os";import"node:path";import"express";import"node:net";import"picocolors";import"vite";function R(n){const{templateName:v,templateLess:R,backendBaseURL:L,miHudLess:U,appId:B,enableProxyCache:F,proxyCacheTTL:H,disableSSLValidation:N,outDir:_,distZip:O,versionPlugin:C,syncBackupsDir:M,syncMaxBackups:$,syncBuildTimeoutMs:W,v7Features:z,personalAccessToken:V,inspectorEnabled:X,inspectorMaxMemory:Z,inspectorCaptureLimit:Y,devPanelPosition:q,devPanelHidden:K,devPanelAutoHide:G,persistUsers:J,allowedHosts:Q}=n||{};let ee,se=!0;return{name:"vite-pp-dev",apply:"serve",closeBundle(){ee?.dispose(),ee=void 0},config:e=>(e.clientInjectionPlugin={backendBaseURL:L,appId:B,templateLess:R,v7Features:z,devPanelPosition:q,devPanelHidden:K,devPanelAutoHide:G},z&&(e.base=`/pl/${v}`),e),transformIndexHtml:async(e,s)=>{const o={html:e,tags:[]};return se&&(se=!1,o.tags.push({tag:"script",injectTo:"body",children:`${Math.random()}`})),o},configureServer:q=>{let K=q.config.base;if(K.endsWith("/")||(K+="/"),L&&q.middlewares.use(e()),q.middlewares.use(s(K,v)),!1!==X){const e=new t(Z);q.middlewares.use(o(e,Y));const s=r({allowedHosts:Q});a(s,e,Y),q.middlewares.use((e,o,t)=>{e.url?.startsWith("/@api/")||e.url?.startsWith(i)?s(e,o,t):t()})}if(L){q.config.logger.info(D.blue(`🌐 Backend URL: ${L}`)),q.config.logger.info(D.blue(`🆔 Custom App ID: ${B}`));const e=new URL(L).host,s=l(L,{appId:B,templateLess:R,disableSSLValidation:N,v7Features:z,personalAccessToken:V}),o=new p(L,s);F&&q.middlewares.use(d({devServer:q,ttl:c(H)}));const t=u(K);q.middlewares.use(m(t,o,Object.assign({},n,{appId:B,appBase:K}))),q.middlewares.use(g({baseURL:L,proxyIgnore:f(K),disableSSLValidation:N,miAPI:o,templateName:v}));const a=(e,s,o,t,r)=>{const a={error:o};t&&(a.details=t),r&&(a.code=r),e.status(s).json(a).end()},i=(e,s,o)=>{q.config.logger.error(`${o} token validation error:`,s);const t=j(s);if(s.tokenErrorInfo){const o=s.tokenErrorInfo;a(e,o.status||500,o.userFriendlyMessage,o.message,o.code)}else{let s,r,i;switch(t.code){case"SESSION_EXPIRED":s=412,r="personal"===o?"Personal access token expired":"Session expired",i="personal"===o?"PAT_EXPIRED":"SESSION_EXPIRED";break;case"UNAUTHORIZED":s=401,r="Unauthorized",i="UNAUTHORIZED";break;case"FORBIDDEN":s=403,r="Access forbidden",i="FORBIDDEN";break;default:s=500,r="Internal server error",i=t.code}const n="personal"===o&&"PAT_EXPIRED"===i?"Your personal access token has expired. Please generate a new token from the portal.":"regular"===o&&"SESSION_EXPIRED"===i?"Your portal session has expired. Please refresh your token or re-authenticate.":t.userFriendlyMessage;a(e,s,r,n,i)}return null},X=r({allowedHosts:Q});X.post("/@api/login",async(e,s,t)=>{const{token:r,tokenType:n}=e.body;if(h(e.headers.host))a(s,409,"Token login is only available on the main host","This tab belongs to a saved pp-dev user. Log in with a token on the main host (localhost).","USER_HOST");else if(r)if(q.config.logger.info(`Attempting to validate ${n} token...`),"personal"===n){if(!await o.get("/data/page/index/auth/info",{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${r}`},!0).then(async e=>"number"==typeof e.data?.user?.user_id?(o.personalAccessToken=r,q.config.logger.info(`Personal access token validated successfully for user ${e.data.user.user_id}`),e):(a(s,400,"Token expired or invalid"),null)).catch(e=>i(s,e,"personal")))return;k("logged in with a personal access token"),b({persist:J,miAPI:o,projectRoot:q.config.root||process.cwd(),miUrl:L}),y(s,"/",302)}else if("regular"===n){if(!await o.get("/api/user",{"Content-Type":"application/json",Accept:"application/json",Token:r},!0).then(t=>t.data?.users?.length?(o.personalAccessToken=void 0,q.config.logger.info(`Regular token validated successfully for ${t.data.users.length} user(s)`),s.setHeader("set-cookie",I(t.headers["set-cookie"],P(e))??""),t):(a(s,400,"Token expired or invalid"),null)).catch(e=>i(s,e,"regular")))return;k("logged in with a token"),y(s,"/",302)}else a(s,400,"Invalid tokenType",'tokenType must be "personal" or "regular".',"INVALID_TOKEN_TYPE");else a(s,400,"Token is required")});const Z=new T(v,Object.assign({root:q.config.root,backupFolder:M,maxBackups:$,buildTimeoutMs:W,buildInputFolder:"object"==typeof O?O.inDir??_:_},"object"==typeof O?{distZipFolder:O.outDir,distZipFilename:O.outFileName}:void 0,"object"==typeof C?{versionFileTemplate:C.versionFileTemplate}:void 0));return ee=w({server:q,internalServer:X,distService:Z,miAPI:o,persistUsers:J,projectRoot:q.config.root||process.cwd(),miUrl:L}),q.middlewares.use((e,s,o)=>{e.url?.startsWith("/@api/login")||e.url?.startsWith("/@api/variables/")||e.url?.startsWith(E)||e.url?.startsWith(S)?X(e,s,o):o()}),()=>{q.middlewares.use(x(e=>e.split("?")[0].endsWith("index.html"),(s,t)=>Buffer.from(A(e,t.headers.host??"",o.buildPage(s,U)))))}}}}}export{R as default,R as vitePPDev};
1
+ import{b as e,i as s,a as o,R as t,c as r,r as a,I as i,g as l,M as p,e as d,d as c,f as u,h as m,j as g,k as f,p as h,q as k,t as b,v as y,w as I,x as P,D as T,s as w,U as E,V as S,l as x,u as j,y as A}from"./request-capture.middleware-B9t-px8Z.js";import{a as D}from"./auth.provider-Cq0EuReh.js";export{n as normalizePPDevConfig,v as validatePPDevConfig}from"./auth.provider-Cq0EuReh.js";import"zlib";import"url";import"axios";import"node:http";import"node:https";import"./version-manifest-qxz5FXuG.js";import"crypto";import"child_process";import"fs/promises";import"path";import"util";import"node:module";import"http-proxy-middleware";import"node:string_decoder";import"fs";import"process";import"os";import"jszip";import"module";import"node:crypto";import"node:fs";import"node:os";import"node:path";import"express";import"picocolors";import"node:net";import"vite";function R(n){const{templateName:v,templateLess:R,backendBaseURL:L,miHudLess:U,appId:F,enableProxyCache:B,proxyCacheTTL:H,disableSSLValidation:N,outDir:_,distZip:O,versionPlugin:M,syncBackupsDir:$,syncMaxBackups:C,syncBuildTimeoutMs:W,v7Features:z,personalAccessToken:V,inspectorEnabled:X,inspectorMaxMemory:Z,inspectorCaptureLimit:q,devPanelPosition:Y,devPanelHidden:K,devPanelAutoHide:G,persistUsers:J,allowedHosts:Q}=n||{};let ee,se=!0;return{name:"vite-pp-dev",apply:"serve",closeBundle(){ee?.dispose(),ee=void 0},config:e=>(e.clientInjectionPlugin={backendBaseURL:L,appId:F,templateLess:R,v7Features:z,devPanelPosition:Y,devPanelHidden:K,devPanelAutoHide:G},z&&(e.base=`/pl/${v}`),e),transformIndexHtml:async(e,s)=>{const o={html:e,tags:[]};return se&&(se=!1,o.tags.push({tag:"script",injectTo:"body",children:`${Math.random()}`})),o},configureServer:Y=>{let K=Y.config.base;if(K.endsWith("/")||(K+="/"),L&&Y.middlewares.use(e()),Y.middlewares.use(s(K,v)),!1!==X){const e=new t(Z);Y.middlewares.use(o(e,q));const s=r({allowedHosts:Q});a(s,e,q),Y.middlewares.use((e,o,t)=>{e.url?.startsWith("/@api/")||e.url?.startsWith(i)?s(e,o,t):t()})}if(L){Y.config.logger.info(D.blue(`🌐 Backend URL: ${L}`)),Y.config.logger.info(D.blue(`🆔 Custom App ID: ${F}`));const e=new URL(L).host,s=l(L,{appId:F,templateLess:R,disableSSLValidation:N,v7Features:z,personalAccessToken:V}),o=new p(L,s);B&&Y.middlewares.use(d({devServer:Y,ttl:c(H)}));const t=u(K);Y.middlewares.use(m(t,o,Object.assign({},n,{appId:F,appBase:K}))),Y.middlewares.use(g({baseURL:L,proxyIgnore:f(K),disableSSLValidation:N,miAPI:o,templateName:v}));const a=(e,s,o,t,r)=>{const a={error:o};t&&(a.details=t),r&&(a.code=r),e.status(s).json(a).end()},i=(e,s,o)=>{Y.config.logger.error(`${o} token validation error:`,s);const t=A(s);if(s.tokenErrorInfo){const o=s.tokenErrorInfo;a(e,o.status||500,o.userFriendlyMessage,o.message,o.code)}else{let s,r,i;switch(t.code){case"SESSION_EXPIRED":s=412,r="personal"===o?"Personal access token expired":"Session expired",i="personal"===o?"PAT_EXPIRED":"SESSION_EXPIRED";break;case"UNAUTHORIZED":s=401,r="Unauthorized",i="UNAUTHORIZED";break;case"FORBIDDEN":s=403,r="Access forbidden",i="FORBIDDEN";break;default:s=500,r="Internal server error",i=t.code}const n="personal"===o&&"PAT_EXPIRED"===i?"Your personal access token has expired. Please generate a new token from the portal.":"regular"===o&&"SESSION_EXPIRED"===i?"Your portal session has expired. Please refresh your token or re-authenticate.":t.userFriendlyMessage;a(e,s,r,n,i)}return null},X=r({allowedHosts:Q});X.post("/@api/login",async(e,s,t)=>{const{token:r,tokenType:n}=e.body;if(h(e.headers.host))a(s,409,"Token login is only available on the main host","This tab belongs to a saved pp-dev user. Log in with a token on the main host (localhost).","USER_HOST");else if(r)if(Y.config.logger.info(`Attempting to validate ${n} token...`),"personal"===n){if(!await o.get("/data/page/index/auth/info",{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${r}`},!0).then(async e=>"number"==typeof e.data?.user?.user_id?(o.personalAccessToken=r,Y.config.logger.info(`Personal access token validated successfully for user ${e.data.user.user_id}`),e):(a(s,400,"Token expired or invalid"),null)).catch(e=>i(s,e,"personal")))return;k("logged in with a personal access token"),b({persist:J,miAPI:o,projectRoot:Y.config.root||process.cwd(),miUrl:L}),y(s,"/",302)}else if("regular"===n){if(!await o.get("/api/user",{"Content-Type":"application/json",Accept:"application/json",Token:r},!0).then(t=>t.data?.users?.length?(o.personalAccessToken=void 0,Y.config.logger.info(`Regular token validated successfully for ${t.data.users.length} user(s)`),s.setHeader("set-cookie",I(t.headers["set-cookie"],P(e))??""),t):(a(s,400,"Token expired or invalid"),null)).catch(e=>i(s,e,"regular")))return;k("logged in with a token"),y(s,"/",302)}else a(s,400,"Invalid tokenType",'tokenType must be "personal" or "regular".',"INVALID_TOKEN_TYPE");else a(s,400,"Token is required")});const Z=new T(v,Object.assign({root:Y.config.root,backupFolder:$,maxBackups:C,buildTimeoutMs:W,buildInputFolder:"object"==typeof O?O.inDir??_:_},"object"==typeof O?{distZipFolder:O.outDir,distZipFilename:O.outFileName}:void 0,"object"==typeof M?{versionFileTemplate:M.versionFileTemplate}:void 0));return ee=w({server:Y,internalServer:X,distService:Z,miAPI:o,persistUsers:J,projectRoot:Y.config.root||process.cwd(),miUrl:L}),Y.middlewares.use((e,s,o)=>{e.url?.startsWith("/@api/login")||e.url?.startsWith("/@api/variables/")||e.url?.startsWith(E)||e.url?.startsWith(S)?X(e,s,o):o()}),()=>{Y.middlewares.use(x(e=>e.split("?")[0].endsWith("index.html"),(s,t)=>Buffer.from(j(e,t.headers.host??"",o.buildPage(s,U)))))}}}}}export{R as default,R as vitePPDev};
2
2
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["../../../src/plugin.ts"],"sourcesContent":[null],"names":["vitePPDev","options","templateName","templateLess","backendBaseURL","miHudLess","appId","enableProxyCache","proxyCacheTTL","disableSSLValidation","outDir","distZip","versionPlugin","syncBackupsDir","syncMaxBackups","syncBuildTimeoutMs","v7Features","personalAccessToken","inspectorEnabled","inspectorMaxMemory","inspectorCaptureLimit","devPanelPosition","devPanelHidden","devPanelAutoHide","persistUsers","allowedHosts","clientService","isFirstRequest","name","apply","closeBundle","dispose","undefined","config","clientInjectionPlugin","base","transformIndexHtml","async","_html","_ctx","result","html","tags","push","tag","injectTo","children","Math","random","configureServer","server","endsWith","middlewares","use","createUserHostGuard","initPPRedirect","reqStore","RequestStore","createRequestCaptureMiddleware","internalServer","createInternalServer","registerInspectorRoutes","req","res","next","url","startsWith","INSPECTOR_PATH","logger","info","colors","blue","baseUrlHost","URL","host","miConfig","getMiAPIOptions","mi","MiAPI","initProxyCache","devServer","ttl","resolveProxyCacheTtl","isIndexRegExp","getIndexPageRegExp","initLoadPPData","Object","assign","appBase","proxyPassMiddleware","baseURL","proxyIgnore","getProxyIgnore","miAPI","sendErrorResponse","status","error","details","code","response","json","end","handleTokenValidationError","tokenType","errorInfo","getTokenErrorInfo","tokenErrorInfo","enhancedErrorInfo","userFriendlyMessage","message","errorMessage","errorCode","post","token","body","getUserNameFromHost","headers","get","Accept","Authorization","then","data","user","user_id","catch","invalidateProxyCache","startKeepingUsers","persist","projectRoot","root","process","cwd","miUrl","redirect","Token","users","length","setHeader","rewriteSetCookieHeader","isSecureRequest","distService","DistService","backupFolder","maxBackups","buildTimeoutMs","buildInputFolder","inDir","distZipFolder","distZipFilename","outFileName","versionFileTemplate","startSyncAndUsers","USERS_API_PATH","VARIABLES_EDITOR_PATH","initRewriteResponse","split","Buffer","from","urlReplacer","buildPage"],"mappings":"+1BAiCA,SAASA,EAAUC,GACjB,MAAMC,aACJA,EAAYC,aACZA,EAAYC,eACZA,EAAcC,UACdA,EAASC,MACTA,EAAKC,iBACLA,EAAgBC,cAChBA,EAAaC,qBACbA,EAAoBC,OACpBA,EAAMC,QACNA,EAAOC,cACPA,EAAaC,eACbA,EAAcC,eACdA,EAAcC,mBACdA,EAAkBC,WAClBA,EAAUC,oBACVA,EAAmBC,iBACnBA,EAAgBC,mBAChBA,EAAkBC,sBAClBA,EAAqBC,iBACrBA,EAAgBC,eAChBA,EAAcC,iBACdA,EAAgBC,aAChBA,EAAYC,aACZA,GACExB,GAAW,CAAA,EAEf,IACIyB,GADAC,IAAiB,EAGrB,MAAO,CACLC,KAAM,cACNC,MAAO,QAGP,WAAAC,GACEJ,IAAeK,UACfL,QAAgBM,CAClB,EACAC,OAASA,IACPA,EAAOC,sBAAwB,CAC7B9B,iBACAE,QACAH,eACAa,aACAK,mBACAC,iBACAC,oBAGEP,IACFiB,EAAOE,KAAO,OAAOjC,KAGhB+B,GAETG,mBAAoBC,MAAOC,EAAOC,KAChC,MAAMC,EAAmC,CAAEC,KAAMH,EAAOI,KAAM,IAO9D,OALIf,KACFA,IAAiB,EACjBa,EAAOE,KAAKC,KAAK,CAAEC,IAAK,SAAUC,SAAU,OAAQC,SAAU,GAAGC,KAAKC,cAGjER,GAETS,gBAAkBC,IAChB,IAAIf,EAAOe,EAAOjB,OAAOE,KAazB,GAXKA,EAAKgB,SAAS,OACjBhB,GAAQ,KAGN/B,GAEF8C,EAAOE,YAAYC,IAAIC,KAGzBJ,EAAOE,YAAYC,IAAIE,E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AkB,CAChCrG,SACAS,iBACAiF,cACA/C,MAAOhB,EACPrD,eACAwG,YAAa9E,EAAOjB,OAAOgG,MAAQC,QAAQC,MAC3CC,MAAOhI,IAcT8C,EAAOE,YAAYC,IAAI,CAACS,EAAKC,EAAKC,KAE9BF,EAAIG,KAAKC,WAAW,gBACpBJ,EAAIG,KAAKC,WAAW,qBACpBJ,EAAIG,KAAKC,WAAWsF,IACpB1F,EAAIG,KAAKC,WAAWuF,GAEpB9F,EAAeG,EAAcC,EAAcC,GAK7CA,MAGK,KACLd,EAAOE,YAAYC,IACjBqG,EACGzF,GACQA,EAAI0F,MAAM,KAAK,GAAGxG,SAAS,cAEpC,CAACgD,EAAUrC,IACF8F,OAAOC,KAAKC,EAAYtF,EAAaV,EAAIsD,QAAQ1C,MAAQ,GAAIG,EAAGkF,UAAU5D,EAAU9F,OAKrG,GAGN"}
1
+ {"version":3,"file":"plugin.js","sources":["../../../src/plugin.ts"],"sourcesContent":[null],"names":["vitePPDev","options","templateName","templateLess","backendBaseURL","miHudLess","appId","enableProxyCache","proxyCacheTTL","disableSSLValidation","outDir","distZip","versionPlugin","syncBackupsDir","syncMaxBackups","syncBuildTimeoutMs","v7Features","personalAccessToken","inspectorEnabled","inspectorMaxMemory","inspectorCaptureLimit","devPanelPosition","devPanelHidden","devPanelAutoHide","persistUsers","allowedHosts","clientService","isFirstRequest","name","apply","closeBundle","dispose","undefined","config","clientInjectionPlugin","base","transformIndexHtml","async","_html","_ctx","result","html","tags","push","tag","injectTo","children","Math","random","configureServer","server","endsWith","middlewares","use","createUserHostGuard","initPPRedirect","reqStore","RequestStore","createRequestCaptureMiddleware","internalServer","createInternalServer","registerInspectorRoutes","req","res","next","url","startsWith","INSPECTOR_PATH","logger","info","colors","blue","baseUrlHost","URL","host","miConfig","getMiAPIOptions","mi","MiAPI","initProxyCache","devServer","ttl","resolveProxyCacheTtl","isIndexRegExp","getIndexPageRegExp","initLoadPPData","Object","assign","appBase","proxyPassMiddleware","baseURL","proxyIgnore","getProxyIgnore","miAPI","sendErrorResponse","status","error","details","code","response","json","end","handleTokenValidationError","tokenType","errorInfo","getTokenErrorInfo","tokenErrorInfo","enhancedErrorInfo","userFriendlyMessage","message","errorMessage","errorCode","post","token","body","getUserNameFromHost","headers","get","Accept","Authorization","then","data","user","user_id","catch","invalidateProxyCache","startKeepingUsers","persist","projectRoot","root","process","cwd","miUrl","redirect","Token","users","length","setHeader","rewriteSetCookieHeader","isSecureRequest","distService","DistService","backupFolder","maxBackups","buildTimeoutMs","buildInputFolder","inDir","distZipFolder","distZipFilename","outFileName","versionFileTemplate","startSyncAndUsers","USERS_API_PATH","VARIABLES_EDITOR_PATH","initRewriteResponse","split","Buffer","from","urlReplacer","buildPage"],"mappings":"o2BAiCA,SAASA,EAAUC,GACjB,MAAMC,aACJA,EAAYC,aACZA,EAAYC,eACZA,EAAcC,UACdA,EAASC,MACTA,EAAKC,iBACLA,EAAgBC,cAChBA,EAAaC,qBACbA,EAAoBC,OACpBA,EAAMC,QACNA,EAAOC,cACPA,EAAaC,eACbA,EAAcC,eACdA,EAAcC,mBACdA,EAAkBC,WAClBA,EAAUC,oBACVA,EAAmBC,iBACnBA,EAAgBC,mBAChBA,EAAkBC,sBAClBA,EAAqBC,iBACrBA,EAAgBC,eAChBA,EAAcC,iBACdA,EAAgBC,aAChBA,EAAYC,aACZA,GACExB,GAAW,CAAA,EAEf,IACIyB,GADAC,IAAiB,EAGrB,MAAO,CACLC,KAAM,cACNC,MAAO,QAGP,WAAAC,GACEJ,IAAeK,UACfL,QAAgBM,CAClB,EACAC,OAASA,IACPA,EAAOC,sBAAwB,CAC7B9B,iBACAE,QACAH,eACAa,aACAK,mBACAC,iBACAC,oBAGEP,IACFiB,EAAOE,KAAO,OAAOjC,KAGhB+B,GAETG,mBAAoBC,MAAOC,EAAOC,KAChC,MAAMC,EAAmC,CAAEC,KAAMH,EAAOI,KAAM,IAO9D,OALIf,KACFA,IAAiB,EACjBa,EAAOE,KAAKC,KAAK,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