@metricinsights/pp-dev 0.13.2 → 0.14.1

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.
@@ -1,7 +1,6 @@
1
1
  import { InlineConfig } from 'vite';
2
2
  import { ViteImageOptimizer } from 'vite-plugin-image-optimizer';
3
3
  import next, { NextConfig } from 'next';
4
- import * as nextConstants from 'next/constants';
5
4
 
6
5
  type RequiredSelection<T, K extends keyof T> = Required<Pick<T, K>> & Omit<T, K>;
7
6
  interface DistZipOptions {
@@ -136,6 +135,212 @@ type PPWatchConfig = {
136
135
  portalPageId: number;
137
136
  };
138
137
 
138
+ // Keep in sync with the `.js` file.
139
+ declare const MODERN_BROWSERSLIST_TARGET: [
140
+ 'chrome 64',
141
+ 'edge 79',
142
+ 'firefox 67',
143
+ 'opera 51',
144
+ 'safari 12',
145
+ ]
146
+
147
+ type ValueOf<T> = Required<T>[keyof T];
148
+ declare const COMPILER_NAMES: {
149
+ readonly client: "client";
150
+ readonly server: "server";
151
+ readonly edgeServer: "edge-server";
152
+ };
153
+ type CompilerNameValues = ValueOf<typeof COMPILER_NAMES>;
154
+ declare enum AdapterOutputType {
155
+ /**
156
+ * `PAGES` represents all the React pages that are under `pages/`.
157
+ */
158
+ PAGES = "PAGES",
159
+ /**
160
+ * `PAGES_API` represents all the API routes under `pages/api/`.
161
+ */
162
+ PAGES_API = "PAGES_API",
163
+ /**
164
+ * `APP_PAGE` represents all the React pages that are under `app/` with the
165
+ * filename of `page.{j,t}s{,x}`.
166
+ */
167
+ APP_PAGE = "APP_PAGE",
168
+ /**
169
+ * `APP_ROUTE` represents all the API routes and metadata routes that are under `app/` with the
170
+ * filename of `route.{j,t}s{,x}`.
171
+ */
172
+ APP_ROUTE = "APP_ROUTE",
173
+ /**
174
+ * `PRERENDER` represents an ISR enabled route that might
175
+ * have a seeded cache entry or fallback generated during build
176
+ */
177
+ PRERENDER = "PRERENDER",
178
+ /**
179
+ * `STATIC_FILE` represents a static file (ie /_next/static)
180
+ */
181
+ STATIC_FILE = "STATIC_FILE",
182
+ /**
183
+ * `MIDDLEWARE` represents the middleware output if present
184
+ */
185
+ MIDDLEWARE = "MIDDLEWARE"
186
+ }
187
+ declare const COMPILER_INDEXES: {
188
+ [compilerKey in CompilerNameValues]: number;
189
+ };
190
+ declare const UNDERSCORE_NOT_FOUND_ROUTE = "/_not-found";
191
+ declare const UNDERSCORE_NOT_FOUND_ROUTE_ENTRY = "/_not-found/page";
192
+ declare const PHASE_EXPORT = "phase-export";
193
+ declare const PHASE_PRODUCTION_BUILD = "phase-production-build";
194
+ declare const PHASE_PRODUCTION_SERVER = "phase-production-server";
195
+ declare const PHASE_DEVELOPMENT_SERVER = "phase-development-server";
196
+ declare const PHASE_TEST = "phase-test";
197
+ declare const PHASE_INFO = "phase-info";
198
+ declare const PAGES_MANIFEST = "pages-manifest.json";
199
+ declare const WEBPACK_STATS = "webpack-stats.json";
200
+ declare const APP_PATHS_MANIFEST = "app-paths-manifest.json";
201
+ declare const APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
202
+ declare const BUILD_MANIFEST = "build-manifest.json";
203
+ declare const APP_BUILD_MANIFEST = "app-build-manifest.json";
204
+ declare const FUNCTIONS_CONFIG_MANIFEST = "functions-config-manifest.json";
205
+ declare const SUBRESOURCE_INTEGRITY_MANIFEST = "subresource-integrity-manifest";
206
+ declare const NEXT_FONT_MANIFEST = "next-font-manifest";
207
+ declare const EXPORT_MARKER = "export-marker.json";
208
+ declare const EXPORT_DETAIL = "export-detail.json";
209
+ declare const PRERENDER_MANIFEST = "prerender-manifest.json";
210
+ declare const ROUTES_MANIFEST = "routes-manifest.json";
211
+ declare const IMAGES_MANIFEST = "images-manifest.json";
212
+ declare const SERVER_FILES_MANIFEST = "required-server-files.json";
213
+ declare const DEV_CLIENT_PAGES_MANIFEST = "_devPagesManifest.json";
214
+ declare const MIDDLEWARE_MANIFEST = "middleware-manifest.json";
215
+ declare const TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST = "_clientMiddlewareManifest.json";
216
+ declare const TURBOPACK_CLIENT_BUILD_MANIFEST = "client-build-manifest.json";
217
+ declare const DEV_CLIENT_MIDDLEWARE_MANIFEST = "_devMiddlewareManifest.json";
218
+ declare const REACT_LOADABLE_MANIFEST = "react-loadable-manifest.json";
219
+ declare const SERVER_DIRECTORY = "server";
220
+ declare const CONFIG_FILES: string[];
221
+ declare const BUILD_ID_FILE = "BUILD_ID";
222
+ declare const BLOCKED_PAGES: string[];
223
+ declare const CLIENT_PUBLIC_FILES_PATH = "public";
224
+ declare const CLIENT_STATIC_FILES_PATH = "static";
225
+ declare const STRING_LITERAL_DROP_BUNDLE = "__NEXT_DROP_CLIENT_FILE__";
226
+ declare const NEXT_BUILTIN_DOCUMENT = "__NEXT_BUILTIN_DOCUMENT__";
227
+ declare const BARREL_OPTIMIZATION_PREFIX = "__barrel_optimize__";
228
+ declare const CLIENT_REFERENCE_MANIFEST = "client-reference-manifest";
229
+ declare const SERVER_REFERENCE_MANIFEST = "server-reference-manifest";
230
+ declare const MIDDLEWARE_BUILD_MANIFEST = "middleware-build-manifest";
231
+ declare const MIDDLEWARE_REACT_LOADABLE_MANIFEST = "middleware-react-loadable-manifest";
232
+ declare const INTERCEPTION_ROUTE_REWRITE_MANIFEST = "interception-route-rewrite-manifest";
233
+ declare const DYNAMIC_CSS_MANIFEST = "dynamic-css-manifest";
234
+ declare const CLIENT_STATIC_FILES_RUNTIME_MAIN = "main";
235
+ declare const CLIENT_STATIC_FILES_RUNTIME_MAIN_APP = "main-app";
236
+ declare const APP_CLIENT_INTERNALS = "app-pages-internals";
237
+ declare const CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH = "react-refresh";
238
+ declare const CLIENT_STATIC_FILES_RUNTIME_AMP = "amp";
239
+ declare const CLIENT_STATIC_FILES_RUNTIME_WEBPACK = "webpack";
240
+ declare const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS = "polyfills";
241
+ declare const CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL: unique symbol;
242
+ declare const DEFAULT_RUNTIME_WEBPACK = "webpack-runtime";
243
+ declare const EDGE_RUNTIME_WEBPACK = "edge-runtime-webpack";
244
+ declare const STATIC_PROPS_ID = "__N_SSG";
245
+ declare const SERVER_PROPS_ID = "__N_SSP";
246
+ declare const DEFAULT_SERIF_FONT: {
247
+ name: string;
248
+ xAvgCharWidth: number;
249
+ azAvgWidth: number;
250
+ unitsPerEm: number;
251
+ };
252
+ declare const DEFAULT_SANS_SERIF_FONT: {
253
+ name: string;
254
+ xAvgCharWidth: number;
255
+ azAvgWidth: number;
256
+ unitsPerEm: number;
257
+ };
258
+ declare const STATIC_STATUS_PAGES: string[];
259
+ declare const TRACE_OUTPUT_VERSION = 1;
260
+ declare const TURBO_TRACE_DEFAULT_MEMORY_LIMIT = 6000;
261
+ declare const RSC_MODULE_TYPES: {
262
+ readonly client: "client";
263
+ readonly server: "server";
264
+ };
265
+ declare const EDGE_UNSUPPORTED_NODE_APIS: string[];
266
+ declare const SYSTEM_ENTRYPOINTS: Set<string>;
267
+
268
+ declare const nextConstants_APP_BUILD_MANIFEST: typeof APP_BUILD_MANIFEST;
269
+ declare const nextConstants_APP_CLIENT_INTERNALS: typeof APP_CLIENT_INTERNALS;
270
+ declare const nextConstants_APP_PATHS_MANIFEST: typeof APP_PATHS_MANIFEST;
271
+ declare const nextConstants_APP_PATH_ROUTES_MANIFEST: typeof APP_PATH_ROUTES_MANIFEST;
272
+ type nextConstants_AdapterOutputType = AdapterOutputType;
273
+ declare const nextConstants_AdapterOutputType: typeof AdapterOutputType;
274
+ declare const nextConstants_BARREL_OPTIMIZATION_PREFIX: typeof BARREL_OPTIMIZATION_PREFIX;
275
+ declare const nextConstants_BLOCKED_PAGES: typeof BLOCKED_PAGES;
276
+ declare const nextConstants_BUILD_ID_FILE: typeof BUILD_ID_FILE;
277
+ declare const nextConstants_BUILD_MANIFEST: typeof BUILD_MANIFEST;
278
+ declare const nextConstants_CLIENT_PUBLIC_FILES_PATH: typeof CLIENT_PUBLIC_FILES_PATH;
279
+ declare const nextConstants_CLIENT_REFERENCE_MANIFEST: typeof CLIENT_REFERENCE_MANIFEST;
280
+ declare const nextConstants_CLIENT_STATIC_FILES_PATH: typeof CLIENT_STATIC_FILES_PATH;
281
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_AMP: typeof CLIENT_STATIC_FILES_RUNTIME_AMP;
282
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN: typeof CLIENT_STATIC_FILES_RUNTIME_MAIN;
283
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN_APP: typeof CLIENT_STATIC_FILES_RUNTIME_MAIN_APP;
284
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS: typeof CLIENT_STATIC_FILES_RUNTIME_POLYFILLS;
285
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL: typeof CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL;
286
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH: typeof CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH;
287
+ declare const nextConstants_CLIENT_STATIC_FILES_RUNTIME_WEBPACK: typeof CLIENT_STATIC_FILES_RUNTIME_WEBPACK;
288
+ declare const nextConstants_COMPILER_INDEXES: typeof COMPILER_INDEXES;
289
+ declare const nextConstants_COMPILER_NAMES: typeof COMPILER_NAMES;
290
+ declare const nextConstants_CONFIG_FILES: typeof CONFIG_FILES;
291
+ type nextConstants_CompilerNameValues = CompilerNameValues;
292
+ declare const nextConstants_DEFAULT_RUNTIME_WEBPACK: typeof DEFAULT_RUNTIME_WEBPACK;
293
+ declare const nextConstants_DEFAULT_SANS_SERIF_FONT: typeof DEFAULT_SANS_SERIF_FONT;
294
+ declare const nextConstants_DEFAULT_SERIF_FONT: typeof DEFAULT_SERIF_FONT;
295
+ declare const nextConstants_DEV_CLIENT_MIDDLEWARE_MANIFEST: typeof DEV_CLIENT_MIDDLEWARE_MANIFEST;
296
+ declare const nextConstants_DEV_CLIENT_PAGES_MANIFEST: typeof DEV_CLIENT_PAGES_MANIFEST;
297
+ declare const nextConstants_DYNAMIC_CSS_MANIFEST: typeof DYNAMIC_CSS_MANIFEST;
298
+ declare const nextConstants_EDGE_RUNTIME_WEBPACK: typeof EDGE_RUNTIME_WEBPACK;
299
+ declare const nextConstants_EDGE_UNSUPPORTED_NODE_APIS: typeof EDGE_UNSUPPORTED_NODE_APIS;
300
+ declare const nextConstants_EXPORT_DETAIL: typeof EXPORT_DETAIL;
301
+ declare const nextConstants_EXPORT_MARKER: typeof EXPORT_MARKER;
302
+ declare const nextConstants_FUNCTIONS_CONFIG_MANIFEST: typeof FUNCTIONS_CONFIG_MANIFEST;
303
+ declare const nextConstants_IMAGES_MANIFEST: typeof IMAGES_MANIFEST;
304
+ declare const nextConstants_INTERCEPTION_ROUTE_REWRITE_MANIFEST: typeof INTERCEPTION_ROUTE_REWRITE_MANIFEST;
305
+ declare const nextConstants_MIDDLEWARE_BUILD_MANIFEST: typeof MIDDLEWARE_BUILD_MANIFEST;
306
+ declare const nextConstants_MIDDLEWARE_MANIFEST: typeof MIDDLEWARE_MANIFEST;
307
+ declare const nextConstants_MIDDLEWARE_REACT_LOADABLE_MANIFEST: typeof MIDDLEWARE_REACT_LOADABLE_MANIFEST;
308
+ declare const nextConstants_MODERN_BROWSERSLIST_TARGET: typeof MODERN_BROWSERSLIST_TARGET;
309
+ declare const nextConstants_NEXT_BUILTIN_DOCUMENT: typeof NEXT_BUILTIN_DOCUMENT;
310
+ declare const nextConstants_NEXT_FONT_MANIFEST: typeof NEXT_FONT_MANIFEST;
311
+ declare const nextConstants_PAGES_MANIFEST: typeof PAGES_MANIFEST;
312
+ declare const nextConstants_PHASE_DEVELOPMENT_SERVER: typeof PHASE_DEVELOPMENT_SERVER;
313
+ declare const nextConstants_PHASE_EXPORT: typeof PHASE_EXPORT;
314
+ declare const nextConstants_PHASE_INFO: typeof PHASE_INFO;
315
+ declare const nextConstants_PHASE_PRODUCTION_BUILD: typeof PHASE_PRODUCTION_BUILD;
316
+ declare const nextConstants_PHASE_PRODUCTION_SERVER: typeof PHASE_PRODUCTION_SERVER;
317
+ declare const nextConstants_PHASE_TEST: typeof PHASE_TEST;
318
+ declare const nextConstants_PRERENDER_MANIFEST: typeof PRERENDER_MANIFEST;
319
+ declare const nextConstants_REACT_LOADABLE_MANIFEST: typeof REACT_LOADABLE_MANIFEST;
320
+ declare const nextConstants_ROUTES_MANIFEST: typeof ROUTES_MANIFEST;
321
+ declare const nextConstants_RSC_MODULE_TYPES: typeof RSC_MODULE_TYPES;
322
+ declare const nextConstants_SERVER_DIRECTORY: typeof SERVER_DIRECTORY;
323
+ declare const nextConstants_SERVER_FILES_MANIFEST: typeof SERVER_FILES_MANIFEST;
324
+ declare const nextConstants_SERVER_PROPS_ID: typeof SERVER_PROPS_ID;
325
+ declare const nextConstants_SERVER_REFERENCE_MANIFEST: typeof SERVER_REFERENCE_MANIFEST;
326
+ declare const nextConstants_STATIC_PROPS_ID: typeof STATIC_PROPS_ID;
327
+ declare const nextConstants_STATIC_STATUS_PAGES: typeof STATIC_STATUS_PAGES;
328
+ declare const nextConstants_STRING_LITERAL_DROP_BUNDLE: typeof STRING_LITERAL_DROP_BUNDLE;
329
+ declare const nextConstants_SUBRESOURCE_INTEGRITY_MANIFEST: typeof SUBRESOURCE_INTEGRITY_MANIFEST;
330
+ declare const nextConstants_SYSTEM_ENTRYPOINTS: typeof SYSTEM_ENTRYPOINTS;
331
+ declare const nextConstants_TRACE_OUTPUT_VERSION: typeof TRACE_OUTPUT_VERSION;
332
+ declare const nextConstants_TURBOPACK_CLIENT_BUILD_MANIFEST: typeof TURBOPACK_CLIENT_BUILD_MANIFEST;
333
+ declare const nextConstants_TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST: typeof TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST;
334
+ declare const nextConstants_TURBO_TRACE_DEFAULT_MEMORY_LIMIT: typeof TURBO_TRACE_DEFAULT_MEMORY_LIMIT;
335
+ declare const nextConstants_UNDERSCORE_NOT_FOUND_ROUTE: typeof UNDERSCORE_NOT_FOUND_ROUTE;
336
+ declare const nextConstants_UNDERSCORE_NOT_FOUND_ROUTE_ENTRY: typeof UNDERSCORE_NOT_FOUND_ROUTE_ENTRY;
337
+ type nextConstants_ValueOf<T> = ValueOf<T>;
338
+ declare const nextConstants_WEBPACK_STATS: typeof WEBPACK_STATS;
339
+ declare namespace nextConstants {
340
+ export { nextConstants_APP_BUILD_MANIFEST as APP_BUILD_MANIFEST, nextConstants_APP_CLIENT_INTERNALS as APP_CLIENT_INTERNALS, nextConstants_APP_PATHS_MANIFEST as APP_PATHS_MANIFEST, nextConstants_APP_PATH_ROUTES_MANIFEST as APP_PATH_ROUTES_MANIFEST, nextConstants_AdapterOutputType as AdapterOutputType, nextConstants_BARREL_OPTIMIZATION_PREFIX as BARREL_OPTIMIZATION_PREFIX, nextConstants_BLOCKED_PAGES as BLOCKED_PAGES, nextConstants_BUILD_ID_FILE as BUILD_ID_FILE, nextConstants_BUILD_MANIFEST as BUILD_MANIFEST, nextConstants_CLIENT_PUBLIC_FILES_PATH as CLIENT_PUBLIC_FILES_PATH, nextConstants_CLIENT_REFERENCE_MANIFEST as CLIENT_REFERENCE_MANIFEST, nextConstants_CLIENT_STATIC_FILES_PATH as CLIENT_STATIC_FILES_PATH, nextConstants_CLIENT_STATIC_FILES_RUNTIME_AMP as CLIENT_STATIC_FILES_RUNTIME_AMP, nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN as CLIENT_STATIC_FILES_RUNTIME_MAIN, nextConstants_CLIENT_STATIC_FILES_RUNTIME_MAIN_APP as CLIENT_STATIC_FILES_RUNTIME_MAIN_APP, nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS as CLIENT_STATIC_FILES_RUNTIME_POLYFILLS, nextConstants_CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL as CLIENT_STATIC_FILES_RUNTIME_POLYFILLS_SYMBOL, nextConstants_CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH as CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH, nextConstants_CLIENT_STATIC_FILES_RUNTIME_WEBPACK as CLIENT_STATIC_FILES_RUNTIME_WEBPACK, nextConstants_COMPILER_INDEXES as COMPILER_INDEXES, nextConstants_COMPILER_NAMES as COMPILER_NAMES, nextConstants_CONFIG_FILES as CONFIG_FILES, nextConstants_DEFAULT_RUNTIME_WEBPACK as DEFAULT_RUNTIME_WEBPACK, nextConstants_DEFAULT_SANS_SERIF_FONT as DEFAULT_SANS_SERIF_FONT, nextConstants_DEFAULT_SERIF_FONT as DEFAULT_SERIF_FONT, nextConstants_DEV_CLIENT_MIDDLEWARE_MANIFEST as DEV_CLIENT_MIDDLEWARE_MANIFEST, nextConstants_DEV_CLIENT_PAGES_MANIFEST as DEV_CLIENT_PAGES_MANIFEST, nextConstants_DYNAMIC_CSS_MANIFEST as DYNAMIC_CSS_MANIFEST, nextConstants_EDGE_RUNTIME_WEBPACK as EDGE_RUNTIME_WEBPACK, nextConstants_EDGE_UNSUPPORTED_NODE_APIS as EDGE_UNSUPPORTED_NODE_APIS, nextConstants_EXPORT_DETAIL as EXPORT_DETAIL, nextConstants_EXPORT_MARKER as EXPORT_MARKER, nextConstants_FUNCTIONS_CONFIG_MANIFEST as FUNCTIONS_CONFIG_MANIFEST, nextConstants_IMAGES_MANIFEST as IMAGES_MANIFEST, nextConstants_INTERCEPTION_ROUTE_REWRITE_MANIFEST as INTERCEPTION_ROUTE_REWRITE_MANIFEST, nextConstants_MIDDLEWARE_BUILD_MANIFEST as MIDDLEWARE_BUILD_MANIFEST, nextConstants_MIDDLEWARE_MANIFEST as MIDDLEWARE_MANIFEST, nextConstants_MIDDLEWARE_REACT_LOADABLE_MANIFEST as MIDDLEWARE_REACT_LOADABLE_MANIFEST, nextConstants_MODERN_BROWSERSLIST_TARGET as MODERN_BROWSERSLIST_TARGET, nextConstants_NEXT_BUILTIN_DOCUMENT as NEXT_BUILTIN_DOCUMENT, nextConstants_NEXT_FONT_MANIFEST as NEXT_FONT_MANIFEST, nextConstants_PAGES_MANIFEST as PAGES_MANIFEST, nextConstants_PHASE_DEVELOPMENT_SERVER as PHASE_DEVELOPMENT_SERVER, nextConstants_PHASE_EXPORT as PHASE_EXPORT, nextConstants_PHASE_INFO as PHASE_INFO, nextConstants_PHASE_PRODUCTION_BUILD as PHASE_PRODUCTION_BUILD, nextConstants_PHASE_PRODUCTION_SERVER as PHASE_PRODUCTION_SERVER, nextConstants_PHASE_TEST as PHASE_TEST, nextConstants_PRERENDER_MANIFEST as PRERENDER_MANIFEST, nextConstants_REACT_LOADABLE_MANIFEST as REACT_LOADABLE_MANIFEST, nextConstants_ROUTES_MANIFEST as ROUTES_MANIFEST, nextConstants_RSC_MODULE_TYPES as RSC_MODULE_TYPES, nextConstants_SERVER_DIRECTORY as SERVER_DIRECTORY, nextConstants_SERVER_FILES_MANIFEST as SERVER_FILES_MANIFEST, nextConstants_SERVER_PROPS_ID as SERVER_PROPS_ID, nextConstants_SERVER_REFERENCE_MANIFEST as SERVER_REFERENCE_MANIFEST, nextConstants_STATIC_PROPS_ID as STATIC_PROPS_ID, nextConstants_STATIC_STATUS_PAGES as STATIC_STATUS_PAGES, nextConstants_STRING_LITERAL_DROP_BUNDLE as STRING_LITERAL_DROP_BUNDLE, nextConstants_SUBRESOURCE_INTEGRITY_MANIFEST as SUBRESOURCE_INTEGRITY_MANIFEST, nextConstants_SYSTEM_ENTRYPOINTS as SYSTEM_ENTRYPOINTS, nextConstants_TRACE_OUTPUT_VERSION as TRACE_OUTPUT_VERSION, nextConstants_TURBOPACK_CLIENT_BUILD_MANIFEST as TURBOPACK_CLIENT_BUILD_MANIFEST, nextConstants_TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST as TURBOPACK_CLIENT_MIDDLEWARE_MANIFEST, nextConstants_TURBO_TRACE_DEFAULT_MEMORY_LIMIT as TURBO_TRACE_DEFAULT_MEMORY_LIMIT, nextConstants_UNDERSCORE_NOT_FOUND_ROUTE as UNDERSCORE_NOT_FOUND_ROUTE, nextConstants_UNDERSCORE_NOT_FOUND_ROUTE_ENTRY as UNDERSCORE_NOT_FOUND_ROUTE_ENTRY, nextConstants_WEBPACK_STATS as WEBPACK_STATS };
341
+ export type { nextConstants_CompilerNameValues as CompilerNameValues, nextConstants_ValueOf as ValueOf };
342
+ }
343
+
139
344
  /**
140
345
  * Safe Next.js import utility
141
346
  * Handles peer dependency availability and provides helpful error messages
@@ -217,45 +422,35 @@ declare class AuthProvider {
217
422
  }
218
423
  declare const authProvider: AuthProvider;
219
424
 
220
- declare module "vite" {
425
+ declare module 'vite' {
221
426
  interface UserConfig {
222
427
  ppDevConfig?: NormalizedVitePPDevOptions;
223
428
  }
224
429
  }
225
- declare module "next" {
430
+ declare module 'next' {
226
431
  interface NextConfig {
227
- ppDev?: PPDevConfig;
228
- }
229
- interface ExperimentalConfig {
432
+ /** PP-Dev config. Prefer pp-dev.config.js to avoid Next.js validation warnings. */
230
433
  ppDev?: PPDevConfig;
231
434
  }
232
435
  }
233
436
  declare function getViteConfig(): Promise<InlineConfig>;
234
437
  /**
235
- * Gets pp-dev configuration from Next.js config
438
+ * Gets pp-dev configuration from Next.js config.
236
439
  *
237
- * This function extracts pp-dev configuration from Next.js configuration.
238
- * It checks both `config.ppDev` and `config.experimental.ppDev` locations.
440
+ * We no longer use experimental.ppDev (triggers Next.js "Unrecognized key" warning).
441
+ * Config is read from: (1) top-level ppDev, (2) standalone pp-dev.config.js via getConfig().
239
442
  *
240
443
  * @param nextConfig - Next.js configuration object
241
444
  * @returns PP-Dev configuration or empty object if not found
242
445
  *
243
446
  * @example
244
447
  * ```ts
245
- * // In next.config.js or next.config.ts
246
- * module.exports = {
247
- * ppDev: {
248
- * backendBaseURL: 'http://localhost:8080',
249
- * portalPageId: 1
250
- * }
251
- * // OR
252
- * experimental: {
253
- * ppDev: {
254
- * backendBaseURL: 'http://localhost:8080',
255
- * portalPageId: 1
256
- * }
257
- * }
258
- * }
448
+ * // In next.config.js - use withPPDev to avoid validation warnings
449
+ * const { withPPDev } = require('@metricinsights/pp-dev');
450
+ * module.exports = withPPDev({ ... }, { backendBaseURL: '...' });
451
+ *
452
+ * // Or use standalone pp-dev.config.js (preferred - no Next.js config pollution)
453
+ * module.exports = { ... }; // your next config
259
454
  * ```
260
455
  */
261
456
  declare function getPPDevConfigFromNextConfig(nextConfig: any): PPDevConfig;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "module",
4
- "version": "0.13.2",
4
+ "version": "0.14.1",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -66,7 +66,8 @@
66
66
  "node": ">=22.14"
67
67
  },
68
68
  "overrides": {
69
- "chokidar": "^4.0.3"
69
+ "chokidar": "^4.0.3",
70
+ "minimatch": ">=10.2.1"
70
71
  },
71
72
  "peerDependencies": {
72
73
  "next": ">= 13 < 17"
@@ -81,56 +82,57 @@
81
82
  "axios": "^1.13.5",
82
83
  "cac": "^6.7.14",
83
84
  "chokidar": "^4.0.3",
84
- "deepmerge-ts": "^7.1.3",
85
+ "deepmerge-ts": "^7.1.5",
85
86
  "diff-match-patch": "^1.0.5",
86
87
  "dir-compare": "^5.0.0",
87
- "ejs": "^3.1.10",
88
+ "ejs": "^4.0.1",
88
89
  "express": "^5.2.1",
89
90
  "extract-zip": "^2.0.1",
90
91
  "file-type": "^19.6.0",
91
92
  "formdata-node": "^6.0.3",
92
- "http-proxy-middleware": "^3.0.3",
93
- "isbinaryfile": "^5.0.4",
93
+ "http-proxy-middleware": "^3.0.5",
94
+ "isbinaryfile": "^5.0.7",
94
95
  "jsdom": "^25.0.1",
95
96
  "memory-cache": "^0.2.0",
96
97
  "picocolors": "^1.1.1",
97
- "rollup": "^4.40.0",
98
- "sass": "^1.87.0",
98
+ "rollup": "^4.58.0",
99
+ "sass": "^1.97.3",
99
100
  "sharp": "^0.34.5",
100
101
  "source-map-support": "^0.5.21",
101
- "svgo": "^3.3.2",
102
- "svgtofont": "^6.0.1",
103
- "typescript": "^5.6.0",
102
+ "svgo": "^4.0.0",
103
+ "svgtofont": "^6.5.1",
104
+ "typescript": "^5.9.3",
104
105
  "vite": "^7.3.1",
105
- "vite-plugin-image-optimizer": "^1.1.8",
106
+ "vite-plugin-image-optimizer": "^1.1.9",
106
107
  "vite-plugin-zip-pack": "^1.2.4",
107
- "winston": "^3.17.0"
108
+ "winston": "^3.19.0"
108
109
  },
109
110
  "devDependencies": {
110
- "@playwright/test": "^1.57.0",
111
+ "@playwright/test": "^1.58.2",
112
+ "next": "^15.5.12",
111
113
  "@rollup/plugin-terser": "^0.4.4",
112
- "@rollup/plugin-typescript": "^12.1.1",
114
+ "@rollup/plugin-typescript": "^12.3.0",
113
115
  "@rollup/plugin-url": "^8.0.2",
114
116
  "@semantic-release/changelog": "^6.0.3",
115
117
  "@semantic-release/git": "^10.0.1",
116
118
  "@types/diff": "^8.0.0",
117
119
  "@types/diff-match-patch": "^1.0.36",
118
120
  "@types/ejs": "^3.1.5",
119
- "@types/express": "^5.0.0",
121
+ "@types/express": "^5.0.6",
120
122
  "@types/jsdom": "^21.1.7",
121
123
  "@types/memory-cache": "^0.2.6",
122
- "@types/node": "^22.15.0",
123
- "@vitest/coverage-v8": "^3.0.0",
124
- "esbuild": "^0.25.8",
125
- "prettier": "^3.3.3",
126
- "rimraf": "^6.0.1",
127
- "rollup-plugin-dts": "^6.2.1",
124
+ "@types/node": "^22.19.11",
125
+ "@vitest/coverage-v8": "^3.2.4",
126
+ "esbuild": "^0.27.3",
127
+ "prettier": "^3.8.1",
128
+ "rimraf": "^6.1.3",
129
+ "rollup-plugin-dts": "^6.3.0",
128
130
  "rollup-plugin-scss": "^4.0.1",
129
- "rollup-plugin-visualizer": "^5.12.0",
130
- "semantic-release": "^25.0.2",
131
+ "rollup-plugin-visualizer": "6.0.5",
132
+ "semantic-release": "^25.0.3",
131
133
  "tslib": "^2.8.1",
132
- "tsx": "^4.19.2",
133
- "vitest": "^3.0.0",
134
+ "tsx": "^4.21.0",
135
+ "vitest": "^3.2.4",
134
136
  "yargs": "^17.7.2"
135
137
  },
136
138
  "files": [
@@ -1,2 +0,0 @@
1
- "use strict";const e=require("./plugin-DGza708W.js"),t=require("fs"),n=require("path"),i=require("url"),a=require("vite"),s=require("ejs");var r="undefined"!=typeof document?document.currentScript:null;function o(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const n in e)if("default"!==n){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}return t.default=e,Object.freeze(t)}const c=o(t),p=o(n),l=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href),"../../.."),u=n.resolve("undefined"!=typeof __filename&&__filename||i.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href),"../.."),f=t.existsSync(n.resolve(l,"package.json"))?l:u,d=n.resolve(f,"dist/client/client.js"),{version:m,name:g}=JSON.parse(t.readFileSync(n.resolve(f,"package.json")).toString()),h=m,j=g,v=[".pp-watch.config.js",".pp-watch.config.ts",".pp-watch.config.json"],y=[".pp-dev.config.js",".pp-dev.config.cjs",".pp-dev.config.mjs",".pp-dev.config.ts",".pp-dev.config.cts",".pp-dev.config.mts",".pp-dev.config.json","pp-dev.config.js","pp-dev.config.cjs","pp-dev.config.mjs","pp-dev.config.ts","pp-dev.config.cts","pp-dev.config.mts","pp-dev.config.json"];const w=new class{cache;_maxSize;constructor(e=10){this._maxSize=e,this.cache=new Map}get maxSize(){return this._maxSize}set maxSize(e){this._maxSize=e}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,t),t}}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this._maxSize){const e=this.cache.keys().next().value;void 0!==e&&this.cache.delete(e)}this.cache.set(e,t)}clear(){this.cache.clear()}has(e){return this.cache.has(e)}}(5),x=new Map;let b;try{b="undefined"!=typeof __filename&&__filename?p.resolve(p.dirname(__filename),".."):void 0!=={url:"undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href}&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href,1)&&("undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href)?p.resolve(i.fileURLToPath(new URL(".","undefined"==typeof document?require("url").pathToFileURL(__filename).href:r&&"SCRIPT"===r.tagName.toUpperCase()&&r.src||new URL("index-Db30nx7C.js",document.baseURI).href)),".."):process.cwd()}catch{b=process.cwd()}const R=`/${j}/client`,_=`/${R}`,P=new RegExp(`^\\/?${j}\\/client\\/(.*)$`);const S={templateCompilations:0,cacheHits:0,totalRequests:0};function C(e){let t="",n=!1,i=null;return{name:"pp-dev:client",apply:"serve",config:e=>(e.optimizeDeps?.exclude?.push(`${j}/client`),e),resolveId(e){if(P.test(e))return{id:a.normalizePath(p.join(f,"dist/client",e.replace(P,"$1")))}},transformIndexHtml:async(e,a)=>{S.totalRequests++;const r=a.server?.config.base||"";r!==t&&(t=r,n=!0,i=null),i&&!n||(w.has(t)?(i=w.get(t),S.cacheHits++):(i=function(e,t=!0){const n=e;if(t&&w.has(n))return w.get(n);const i=p.resolve(b,"client","index.html");let a;x.has(i)?a=x.get(i):(a=c.readFileSync(i,{encoding:"utf8"}),x.set(i,a));const r=_.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),o=s.compile(a.replace(new RegExp(r,"g"),p.posix.join(e,R)),{openDelimiter:"{",closeDelimiter:"}",async:!0,cache:!0,filename:i,rmWhitespace:!0,compileDebug:!1});return t&&w.set(n,o),o}(t,true),S.templateCompilations++),n=!1);const o=function(e){return{css:p.posix.join(e,j,"client/client.css"),js:p.posix.join(e,j,"client/client.js")}}(t),l={html:e,tags:[{tag:"link",injectTo:"head",attrs:{rel:"stylesheet",href:o.css}}]},{backendBaseURL:u,templateLess:f,portalPageId:d,canSync:m=!0}=a.server?.config.clientInjectionPlugin||{},g={PACKAGE_NAME:j,VERSION:h,backendBaseURL:u,templateLess:f,portalPageId:d,canSync:m};return l.tags.push({tag:"div",injectTo:"body-prepend",children:await i(g)}),l.tags.push({tag:"script",injectTo:"body-prepend",attrs:{src:o.js,type:"module"}}),l},configureServer(e){const t=a.normalizePath(p.resolve(e.config.root,p.dirname(d)));e.config.server?.fs?.allow&&e.config.server.fs.allow.push(t),e.middlewares.use("/@api/__pp-dev-metrics",((e,t)=>{t.setHeader("Content-Type","application/json"),t.end(JSON.stringify(S,null,2))}))},closeBundle(){w.clear(),x.clear()}}}const U=(e,t)=>` * ${t}`;function I(e){return`/*!\n${"***** DO NOT EDIT THIS CODE! *****\n***** ------- *****".replace(/^(.*)$/gm,U)}\n */`}async function T(){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 D=new Map,L=3e4;let N=null;function $(){const e=Date.now();if(N&&e-N.timestamp<6e4)return N.data;const n=process.cwd();try{const i=JSON.parse(t.readFileSync(p.default.resolve(n,"package.json"),{encoding:"utf-8",flag:"r"}));return N={data:i,timestamp:e},i}catch{const t={};return N={data:t,timestamp:e},t}}let F=null;async function O(e){const n=process.cwd(),a=`ts:${e}`,s=D.get(a);if(s&&Date.now()-s.timestamp<L)return s.data;let r=!1;if(/\.m[jt]s$/.test(e))r=!0;else if(/\.c[jt]s$/.test(e))r=!1;else{const e=$();r=!!e&&"module"===e.type}const o=await async function(){return F||(F=await import("esbuild")),F}(),c=await o.build({absWorkingDir:n,entryPoints:[e],outfile:"out.js",write:!1,target:["node14.18","node16"],platform:"node",bundle:!0,format:r?"esm":"cjs",mainFields:["main"],sourcemap:"inline",metafile:!0}),{text:l}=c.outputFiles[0],u=`${`pp-config.timestamp-${Date.now()}-${Math.random().toString(16).slice(2)}`}.js`,f=i.pathToFileURL(p.default.resolve(n,u)).toString();t.writeFileSync(u,l);let d={};try{const t=(await import(f)).default;d=t?.default||t,D.set(a,{data:d,timestamp:Date.now(),filePath:e})}finally{t.existsSync(u)&&t.unlink(u,(()=>{}))}return d}async function E(e){const t=`js:${e}`,n=D.get(t);if(n&&Date.now()-n.timestamp<L)return n.data;const a=(await import(i.pathToFileURL(e).toString())).default;return D.set(t,{data:a,timestamp:Date.now(),filePath:e}),a}async function k(e){const n=`json:${e}`,i=D.get(n);if(i&&Date.now()-i.timestamp<L)return i.data;const a=JSON.parse(t.readFileSync(e,{encoding:"utf-8"}));return D.set(n,{data:a,timestamp:Date.now(),filePath:e}),a}let z=null;async function q(e,t){for(const n of t)if(e.includes(n)){if(/\.[cm]?ts$/i.test(n))return await O(n);if(/\.[cm]?js$/i.test(n))return await E(p.default.resolve(".",n));if(n.endsWith(".json"))return await k(p.default.resolve(".",n))}return null}function M(){return $()}async function V(){const e=function(){const e=Date.now();if(z&&e-z.timestamp<1e4)return z.files;const n=/\.config\.(([cm]?ts)|([cm]?js)|(json))$/,i=process.cwd(),a=t.readdirSync(i,{withFileTypes:!0}).filter((e=>e.isFile()&&n.test(e.name))).map((e=>e.name));return z={files:a,timestamp:e},a}();let n={},i=!1;const a=await q(e,y);if(a&&(n=a,i=!0),e.length&&!i){const t=await q(e,v);t&&(n={backendBaseURL:t.baseURL,portalPageId:t.portalPageId},i=!0)}const s=$();return i||"object"!=typeof s["pp-dev"]||(n=s["pp-dev"]),n}const A=Object.freeze({__proto__:null,clearConfigCache:function(){D.clear(),N=null,z=null},getConfig:V,getConfigCacheStats:function(){return{configEntries:D.size,packageJsonCached:!!N,dirContentCached:!!z}},getPkg:M});function H(e){return e?.experimental?.ppDev||e?.ppDev||{}}function B(e,t,n){return Object.assign({},e,t,n)}exports.PP_DEV_CONFIG_NAMES=y,exports.PP_WATCH_CONFIG_NAMES=v,exports.VERSION=h,exports.config=A,exports.getNextVersion=async function(){try{return(await import("next/package.json")).version}catch{return null}},exports.getPPDevConfigFromNextConfig=H,exports.getViteConfig=async function(){const t=M().name,n=await V(),i=e.normalizeVitePPDevConfig(Object.assign(n,{templateName:t})),{default:a}=await Promise.resolve().then((()=>require("./plugin.js"))),s=[a(i),C()],{outDir:r,distZip:o,imageOptimizer:c,templateLess:p,integrateMiTopBar:l}=i;if(l&&s.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}}}(l)),c){const{ViteImageOptimizer:e}=await import("vite-plugin-image-optimizer");s.push(e("object"==typeof c?c:void 0))}if(o){const{default:e}=await import("vite-plugin-zip-pack");s.push({...e("object"==typeof o?o:{outFileName:`${t}.zip`}),enforce:"post"})}return{base:p?`/p/${t}`:`/pt/${t}`,server:{port:3e3},build:{minify:!1,assetsInlineLimit:4096,rollupOptions:{output:{banner:I}},outDir:r},css:{modules:{localsConvention:"dashes"},scss:{api:"modern"}},ppDevConfig:i,plugins:s}},exports.isNextAvailable=async function(){try{return await import("next"),!0}catch(e){return!1}},exports.safeNextImport=T,exports.withPPDev=function(e,t){return async(n,i={})=>{try{const{constants:a}=await T(),{PHASE_DEVELOPMENT_SERVER:s}=a,r=await V(),o=M().name,c="function"==typeof e?await e(n,i):e,p=H(c),l=n===s,u=function(e,t,n,i){return n?t?`/p/${e}`:`/pl/${e}`:i?`/pt/${e}`:`/pl/${e}`}(o,r.templateLess??!1,l,r.v7Features??!1),f={basePath:u,trailingSlash:!!l||void 0};if(l){const e=function(e,t){const{appId:n,portalPageId:i,backendBaseURL:a,templateLess:s,v7Features:r,...o}=t,c=n||i,p={backendBaseURL:a,portalPageId:c,appId:c,templateLess:s,v7Features:r,...o};return{serverRuntimeConfig:{templateName:e,ppDevConfig:p},publicRuntimeConfig:{templateName:e,ppDevConfig:p},experimental:{ppDev:p}}}(o,Object.assign({},r,p,t));return B(f,c,e)}return B(f,c)}catch(t){console.error("Error in withPPDev:",t),console.warn("Falling back to original Next.js configuration");try{return"function"==typeof e?await e(n,i):e}catch(e){return console.error("Error in fallback configuration:",e),{}}}}};
2
- //# sourceMappingURL=index-Db30nx7C.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-Db30nx7C.js","sources":["../../../src/constants.ts","../../../src/plugins/client-injection-plugin.ts","../../../src/banner/header.ts","../../../src/lib/next-import.ts","../../../src/config.ts","../../../src/index.ts","../../../src/plugins/mi-topbar-plugin.ts"],"sourcesContent":[null,null,null,null,null,null,null],"names":["afterBundlePath","resolve","__filename","fileURLToPath","document","require","pathToFileURL","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","beforeBundlePath","PP_DEV_PACKAGE_DIR","existsSync","PP_DEV_CLIENT_ENTRY","version","name","JSON","parse","readFileSync","toString","VERSION","PACKAGE_NAME","PP_WATCH_CONFIG_NAMES","PP_DEV_CONFIG_NAMES","templateCache","cache","_maxSize","constructor","maxSize","this","Map","value","get","key","has","delete","set","size","firstKey","keys","next","undefined","clear","fileCache","DIRNAME","path","dirname","url","process","cwd","PACKAGE_IMPORT","CLIENT_PATH","PACKAGE_REGEXP","RegExp","performanceMetrics","templateCompilations","cacheHits","totalRequests","clientInjectionPlugin","opts","base","baseChanged","currentTemplate","apply","config","optimizeDeps","exclude","push","resolveId","source","test","id","normalizePath","join","replace","transformIndexHtml","async","html","ctx","serverBase","server","enableCache","cacheKey","templatePath","templateContent","fs","encoding","escapedClientPath","compiledTemplate","compile","posix","openDelimiter","closeDelimiter","filename","rmWhitespace","compileDebug","getTemplate","assetPaths","css","js","getAssetPaths","result","tags","tag","injectTo","attrs","rel","backendBaseURL","templateLess","portalPageId","canSync","templateData","children","type","configureServer","clientDir","root","allow","middlewares","use","req","res","setHeader","end","stringify","closeBundle","replacer","substring","$1","header","chunk","safeNextImport","constants","Promise","all","import","default","error","Error","configCache","CACHE_TTL","packageJsonCache","getPackageJson","now","Date","timestamp","data","flag","empty","esbuildModule","loadTsConfig","filePath","cached","isESM","pkg","esbuild","getEsbuild","build","absWorkingDir","entryPoints","outfile","write","target","platform","bundle","format","mainFields","sourcemap","metafile","text","code","outputFiles","fileNameTmp","Math","random","slice","fileUrl","writeFileSync","conf","unlink","loadJsConfig","loadJSONConfig","dirContentCache","loadConfig","dirFiles","configNames","configName","includes","endsWith","getPkg","getConfig","dirContent","files","endsWithRegExp","readdirSync","withFileTypes","filter","isFile","map","getDirectoryContent","configFound","newConfig","length","watchConfig","baseURL","configEntries","packageJsonCached","dirContentCached","getPPDevConfigFromNextConfig","nextConfig","experimental","ppDev","mergeConfigs","baseConfig","nextConfiguration","additionalConfig","Object","assign","templateName","ppDevConfig","normalizedPPDevConfig","normalizeVitePPDevConfig","vitePPDev","then","plugins","outDir","distZip","imageOptimizer","integrateMiTopBar","addRootElement","addSharedComponentsScripts","defer","miTopBarPlugin","ViteImageOptimizer","zipPack","outFileName","enforce","port","minify","assetsInlineLimit","rollupOptions","output","banner","modules","localsConvention","scss","api","nextjsConfig","phase","PHASE_DEVELOPMENT_SERVER","nextConfigPPDev","isDevelopment","basePath","v7Features","createBasePath","trailingSlash","runtimeConfig","devConfig","appId","originalAppId","rest","normalizedConfig","serverRuntimeConfig","publicRuntimeConfig","createRuntimeConfig","console","warn","fallbackError"],"mappings":"kfAIMA,EAAkBC,EAAAA,QAEC,oBAAfC,YAA8BA,YAAeC,EAAAA,cAAc,oBAAAC,SAAAC,QAAA,OAAAC,cAAAJ,YAAAK,KAAAC,GAAA,WAAAA,EAAAC,QAAAC,eAAAF,EAAAG,KAAA,IAAAC,IAAA,oBAAAR,SAAAS,SAAAN,MACnE,YAGIO,EAAmBb,EAAAA,QAEA,oBAAfC,YAA8BA,YAAeC,EAAAA,cAAc,oBAAAC,SAAAC,QAAA,OAAAC,cAAAJ,YAAAK,KAAAC,GAAA,WAAAA,EAAAC,QAAAC,eAAAF,EAAAG,KAAA,IAAAC,IAAA,oBAAAR,SAAAS,SAAAN,MACnE,SAGWQ,EAAqBC,EAAAA,WAAWf,UAAQD,EAAiB,iBAAmBA,EAAkBc,EAM9FG,EAAsBhB,EAAAA,QAAQc,EAAoB,0BAEzDG,QAAEA,EAAOC,KAAEA,GAASC,KAAKC,MAAMC,EAAAA,aAAarB,EAAAA,QAAQc,EAAoB,iBAAiBQ,YAElFC,EAAUN,EACVO,EAAeN,EAEfO,EAAwB,CAAC,sBAAuB,sBAAuB,yBAEvEC,EAAsB,CACjC,oBACA,qBACA,qBACA,oBACA,qBACA,qBACA,sBACA,mBACA,oBACA,oBACA,mBACA,oBACA,oBACA,sBCsCF,MAAMC,EAAyD,IAtD/D,MACUC,MACAC,SAER,WAAAC,CAAYC,EAAkB,IAC5BC,KAAKH,SAAWE,EAChBC,KAAKJ,MAAQ,IAAIK,GACnB,CAEA,WAAIF,GACF,OAAOC,KAAKH,QACd,CAEA,WAAIE,CA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H,MAAqB8G,IACrB,OAA8BA,IAG7BmC,EACH,OAAyBnC,IACzB,OAA8BA,GACpC,CAyGuBoC,CACfpC,EACA1J,EAAO4C,eAAgB,EACvB+I,EACA3L,EAAO6L,aAAc,GAGjBxC,EAAyB,CAC7BuC,WACAG,gBAAeJ,QAAuBlN,GAGxC,GAAIkN,EAAe,CAGjB,MACMK,EAjHd,SAA6BtC,EAAsBuC,GACjD,MACEC,MAAOC,EAAatJ,aACpBA,EAAYF,eACZA,EAAcC,aACdA,EAAYiJ,WACZA,KACGO,GACDH,EAEEC,EAAQC,GAAiBtJ,EAEzBwJ,EAAmB,CACvB1J,iBACAE,aAAcqJ,EACdA,QACAtJ,eACAiJ,gBACGO,GAGL,MAAO,CACLE,oBAAqB,CACnB5C,eACAC,YAAa0C,GAEfE,oBAAqB,CACnB7C,eACAC,YAAa0C,GAEfnD,aAAc,CACZC,MAAOkD,GAGb,CA+E8BG,CAAoB9C,EADxBF,OAAOC,OAAO,CAAA,EAAIzJ,EAAQ0L,EAAiB/B,IAG7D,OAAOP,EAAaC,EAAYC,EAAmB0C,EACrD,CAGA,OAAO5C,EAAaC,EAAYC,EAClC,CAAE,MAAO7E,GACPgI,QAAQhI,MAAM,sBAAuBA,GACrCgI,QAAQC,KAAK,kDAGb,IAKE,MAH0B,mBAAjBnB,QACGA,EAAaC,EAAOvC,GAC1BsC,CAER,CAAE,MAAOoB,GAGP,OAFAF,QAAQhI,MAAM,mCAAoCkI,GAE3C,CAAA,CACT,CACF,EAEJ"}
@@ -1,2 +0,0 @@
1
- "use strict";const e=require("http-proxy-middleware"),t=require("vite"),r=require("picocolors"),s=require("axios"),a=require("jsdom"),n=require("https"),i=require("memory-cache"),o=require("path"),c=require("fs"),l=require("url"),p=require("crypto"),d=require("process"),h=require("child_process"),u=require("console"),g=require("zlib"),f=require("express");var m="undefined"!=typeof document?document.currentScript:null;const w=e=>e&&"object"==typeof e&&"default"in e?e:{default:e};function y(e){if(e&&"object"==typeof e&&"default"in e)return e;const t=Object.create(null);if(e)for(const r in e)if("default"!==r){const s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const b=w(s),v=y(i),k=y(o),x=y(p),P=y(d),T=y(h),A=y(u),S=w(f),$=(e,t,r)=>{const s=new RegExp(`(!!)?(https?(:(\\\\)?/(\\\\)?/)${e})`,"gi");return r.replace(s,((e,...r)=>e.startsWith("!!")?r[1]:`http${r[2]}${t}`))},I=(e,t,r)=>{e.setHeader("location",t),e.statusCode=r,e.end()};let E=new Map;const L="default",R=(e="info",r=L)=>{if(E&&"function"==typeof E.has||(E=new Map),E.has(r))return E.get(r);if(r===L){const s=t.createLogger(e);return E.set(r,s),s}const s=t.createLogger(e);return E.set(r,s),s},C=r.createColors(),D=function(){const e={personal:{placeholder:"API Token",caption:`You can get the API Token\n <a href="https://${host}/api-token" target="_blank" \n style="color: #007bff; text-decoration: none;">here</a>`,endpoint:"/@api/login"},regular:{placeholder:"Legacy Token",caption:`You can get the Legacy Token\n <a href="https://${host}/api/get_token" target="_blank" \n style="color: #007bff; text-decoration: none;">here</a>`,endpoint:"/@api/login"}};function t(t,r,s){const a=e[t];a&&(r.placeholder=a.placeholder,s.innerHTML=a.caption)}function r(e,t){t.textContent=e,t.classList.add("show")}function s(e){e.classList.remove("show")}function a(e,t,a,n){a.addEventListener("click",(async a=>{if(a.preventDefault(),s(n),!t.value.trim())return r(`${t.placeholder} is required`,n),void t.focus();const i=document.getElementById("token-type-switcher"),o=i?.querySelector(".token-type-option.active"),c=o?.dataset.value||"personal";await async function(e,t,s,a){try{s.classList.add("loading");const n=await fetch("/@api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e,tokenType:t}),redirect:"follow"}),i=n.url&&new URL(n.url,window.location.origin);if(!i||i.pathname.startsWith("/login")||i.pathname.startsWith("/@api/"))try{const e=await n.json();r(`Login failed: ${e?.error||"Unknown error occurred"}`,a)}catch(e){r("Login failed: Unable to parse response",a)}else window.location.href=n.url}catch(e){r("Login failed: Network error. Please check your connection.",a)}finally{s.classList.remove("loading")}}(t.value.trim(),c,e,n)})),t.addEventListener("keydown",(e=>{"Enter"===e.key&&(e.preventDefault(),a.click())})),t.addEventListener("input",(()=>{s(n)}))}function n(e){const r=e.firstChild;if(!r)return;const s=r.lastChild?.cloneNode(!0);if(!s)return;s.innerHTML="";const n=s.cloneNode(!0);n.innerText="OR",n.setAttribute("role","separator"),n.setAttribute("aria-label","Alternative login method");const i=s.cloneNode(!0),o=document.createElement("div"),c=document.createElement("style");c.textContent="\n.helper-login-wrapper {\n font-family: Arial, sans-serif;\n color: #222;\n padding: 8px;\n background-color: #f8f9fa;\n border-radius: 8px;\n border: 1px solid #ddd;\n width: 100%;\n max-width: 400px;\n margin: 0 auto;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n}\n\n.helper-login-wrapper .title {\n font-weight: bold;\n font-size: 18px;\n margin-bottom: 12px;\n text-align: center;\n}\n\n.helper-login-wrapper .control {\n display: flex;\n flex-direction: column;\n gap: 12px;\n}\n\n.helper-login-wrapper .control input {\n border: 1px solid #ddd;\n border-radius: 4px;\n width: 100%;\n box-sizing: border-box;\n text-align: center;\n height: 26px;\n padding: 0 8px;\n font-size: 14px;\n}\n\n.helper-login-wrapper .control input:focus {\n outline: none;\n border-color: #007bff;\n box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);\n}\n\n.helper-login-wrapper .control .caption {\n font-size: 12px;\n color: #666;\n text-align: center;\n}\n\n.helper-login-wrapper .footer {\n margin-top: 16px;\n text-align: center;\n}\n\n.helper-login-wrapper .footer .btn.submit {\n background-color: #007bff;\n color: white;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n width: 100%;\n font-size: 14px;\n transition: background-color 0.3s;\n height: 26px;\n font-weight: 500;\n}\n\n.helper-login-wrapper .footer .btn.submit:hover {\n background-color: #0056b3;\n}\n\n.helper-login-wrapper .footer .btn.submit:disabled {\n background-color: #6c757d;\n cursor: not-allowed;\n}\n\n.helper-login-wrapper .token-type-switcher {\n display: flex;\n border: 1px solid #ccc;\n border-radius: 4px;\n overflow: hidden;\n margin-bottom: 12px;\n width: 100%;\n}\n\n.helper-login-wrapper .token-type-option {\n padding: 4px 8px;\n cursor: pointer;\n background-color: #f8f9fa;\n color: #666;\n font-size: 12px;\n text-align: center;\n transition: background-color 0.2s, color 0.2s;\n border-right: 1px solid #ccc;\n flex: 1;\n user-select: none;\n}\n\n.helper-login-wrapper .token-type-option:last-child {\n border-right: none;\n}\n\n.helper-login-wrapper .token-type-option.active {\n background-color: #007bff;\n color: white;\n font-weight: bold;\n}\n\n.helper-login-wrapper .token-type-option:not(.active):hover {\n background-color: #e9ecef;\n}\n\n.helper-login-wrapper .error-message {\n color: #dc3545;\n font-size: 12px;\n text-align: center;\n margin-top: 8px;\n display: none;\n}\n\n.helper-login-wrapper .error-message.show {\n display: block;\n}\n\n.helper-login-wrapper .loading {\n opacity: 0.6;\n pointer-events: none;\n}\n",document.head.appendChild(c),o.innerHTML=`\n<div class="helper-login-wrapper" role="form" aria-label="PP Dev Helper Login">\n <div class="title" role="heading" aria-level="2">PP Dev Helper</div>\n\n <div class="token-type-switcher" id="token-type-switcher" role="tablist" aria-label="Token type selection">\n <div class="token-type-option active" data-value="personal" role="tab" aria-selected="true" tabindex="0">\n API Token\n </div>\n <div class="token-type-option" data-value="regular" role="tab" aria-selected="false" tabindex="0">\n Legacy Token\n </div>\n </div>\n\n <div class="control">\n <input \n type="password" \n id="helper-token" \n placeholder="API Token"\n aria-label="Token input"\n aria-describedby="token-caption"\n >\n <span class="caption" id="token-caption">\n You can get the API Token\n <a href="https://${host}/api-token" target="_blank" style="color: #007bff; text-decoration: none;">here</a>\n </span>\n </div>\n\n <div class="error-message" id="error-message" role="alert" aria-live="polite"></div>\n\n <div class="footer">\n <button id="helper-token-submit" class="btn submit" type="button">\n Token Login\n </button>\n </div>\n</div>`,i.appendChild(o),r.appendChild(n),r.appendChild(i);const l=document.getElementById("token-type-switcher"),p=document.getElementById("helper-token"),d=document.getElementById("token-caption"),h=document.getElementById("helper-token-submit"),u=document.getElementById("error-message"),g=o.querySelector(".helper-login-wrapper");l&&p&&d&&h&&u&&g?(!function(e,r,s){const a=e.querySelectorAll(".token-type-option"),n=e=>{const n=e.dataset.value;a.forEach((e=>{e.classList.remove("active"),e.setAttribute("aria-selected","false"),e.setAttribute("tabindex","-1")})),e.classList.add("active"),e.setAttribute("aria-selected","true"),e.setAttribute("tabindex","0"),t(n,r,s)};a.forEach((e=>{e.addEventListener("click",(e=>{const t=e.currentTarget;n(t)})),e.addEventListener("keydown",(t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n(e))}))}))}(l,p,d),a(g,p,h,u),t("personal",p,d)):console.error("Failed to find required form elements")}const i=new MutationObserver((e=>{for(const t of e)if("childList"===t.type){const e=document.querySelector("#mi-react-root form");if(e){i.disconnect(),n(e);break}}}));i.observe(document.body,{childList:!0,subtree:!0});const o=document.querySelector("#mi-react-root form");o&&(i.disconnect(),n(o))},O=/^(https?:\/\/)([^/]+)(\/.*)?$/i,F="X-PP-Proxy";function N(t){const{rewritePath:r=/^\/(?!pt).*/i,baseURL:s="",disableSSLValidation:a=!1,miAPI:n}=t;if(!s)throw new Error("Base url is required");const i=s.replace(O,"$2"),o=s.replace(O,"$1$2"),c=import("file-type"),l=R();return e.createProxyMiddleware({selfHandleResponse:!0,pathFilter:(e,s)=>!(t.proxyIgnore||[]).some((t=>"string"==typeof t?e.startsWith(t):"function"!=typeof t.test||t.test(e)))&&("string"==typeof r?e.startsWith(r):Array.isArray(r)?r.some((t=>e.startsWith(t))):"function"==typeof r.test&&r.test(e)),target:s,changeOrigin:!0,autoRewrite:!0,cookieDomainRewrite:{[i]:"localhost"},logger:{info:()=>{},log:()=>{},error:()=>{},warn:()=>{}},secure:!a,headers:{host:i,origin:o},on:{proxyReq(e,t,r){const a=t.headers.host,i=e.getHeader("referer");return l.info(`${C.blue("Proxies request:")} ${C.green(t.method)} ${t.url} -> ${C.green(e.method)} ${e.protocol}//${e.host}${e.path}`),a&&i&&"string"==typeof i&&e.setHeader("referer",i.replace(new RegExp(`https?://${a}`),s)),n.personalAccessToken&&e.setHeader("Authorization",`Bearer ${n.personalAccessToken}`),t.socket.on("close",(()=>{setTimeout((()=>{e.destroyed||e.destroy()}),200)})),e},proxyRes:(t,r,s)=>{if(t.headers["content-type"]?.includes("text/event-stream")||t.headers["transfer-encoding"]?.includes("chunked")&&"no"===t.headers["x-accel-buffering"]){l.info(`${C.blue("Start streaming for request:")} ${C.green(r.method)} ${r.url}`);const e=async(e,t,r)=>{r.setHeader(F,1),r.setHeaders(new Map(Object.entries(e.headers))),e.pipe(r)};return e(t,r,s)}const a=e.responseInterceptor((async(e,t,r,s)=>{s.setHeader(F,1);if(await(await c).fileTypeFromBuffer(e))return e;{let t=e.toString("utf8");try{const e=new URL(r.url??"",`http://${i}`);if(e.searchParams&&e.searchParams.has("proxyRedirect")){const e=function(){const e="pp-dev::redirectCount",t="pp-dev::lastRedirect";let r=+(localStorage.getItem(e)??0);localStorage.getItem(t);Number.isNaN(r)&&(r=0);let s=window.location.href;const a=function(){const n=new URLSearchParams(window.location.search);if(!n.has("proxyRedirect"))return console.debug("No proxyRedirect param. Cleaning up."),void localStorage.removeItem(e);s!==window.location.href?(s=window.location.href,setTimeout(a,r<3?3e3:5e3)):window.location.href=n.get("proxyRedirect"),localStorage.setItem(e,""+ ++r),localStorage.setItem(t,(new Date).toISOString())};setTimeout(a,3e3)};t+=`<script>(${e.toString()})()<\/script>`}e.pathname.startsWith("/login")&&(t+=`<script>const host = "${i}";\n(${D.toString()})()<\/script>`)}catch{}const s=r.headers.host??"";return((e,t,r)=>{const s=new RegExp(`${e.replace(/\\*\//gi,"\\\\/")}`,"gi"),a=new RegExp(`${e}`,"gi"),n=r.replace(s,t);return n===r?n.replace(a,t):n})("/auth/saml/login","/login",$(i,s,t))}}));return a(t,r,s)},error(e,t,r){const s=`Proxy error: "${e.message}" when trying to "${t.method} ${t.url}"\n\n${e.stack}`;l.error(s),r.writable&&r.writeHead(500,{"Content-Type":"text/plain"}),r.end(s)}}})}class U{axios;constructor(e){this.axios=e}async checkAuth(e){return this.axios.get("/data/page/index/auth/info",{headers:Object.assign({},e,{accept:"text/html"}),maxRedirects:0}).then((()=>!0)).catch((()=>!1))}}class j extends U{formdataModulePromise=import("formdata-node");constructor(e){super(e)}getDownloadUrl(e){return`/admin/page/downloadassets/id/${e}`}getDownloadTemplateUrl(e){return`/admin/pagetemplate/downloadassets/id/${e}`}getUploadUrl(e){return`/admin/page/uploadassets/id/${e}`}getUploadTemplateUrl(e){return`/admin/pagetemplate/uploadassets/id/${e}`}async downloadPageAssets(e,t){return this.axios.get(this.getDownloadUrl(e),{withCredentials:!0,headers:Object.assign({},t,{accept:"*/*"}),responseType:"arraybuffer"}).then((e=>e.data))}async uploadPageAssets(e,t,r){const s=new(await this.formdataModulePromise).FormData,{File:a}=await this.formdataModulePromise,n=new a([t],"file.zip",{type:"application/zip"});s.append("file",n);const i=this.getUploadUrl(e);return this.axios.post(i,s,{withCredentials:!0,headers:Object.assign({},r,{accept:"application/json","Content-Type":"multipart/form-data",Referer:this.axios.getUri({url:i})})}).then((e=>e.data))}async downloadTemplateAssets(e,t){return this.axios.get(this.getDownloadTemplateUrl(e),{withCredentials:!0,headers:Object.assign({},t,{accept:"*/*"}),responseType:"arraybuffer"}).then((e=>e.data))}async uploadTemplateAssets(e,t,r){const s=new(await this.formdataModulePromise).FormData,{File:a}=await this.formdataModulePromise,n=new a([t],"file.zip",{type:"application/zip"});s.append("file",n,"file.zip");const i=this.getUploadTemplateUrl(e);return this.axios.post(i,s,{withCredentials:!0,headers:Object.assign({},r,{accept:"application/json","Content-Type":"multipart/form-data",Referer:this.axios.getUri({url:i})})}).then((e=>e.data))}}class M extends j{getDownloadUrl(e){return`/api/page/id/${e}/asset/download`}getDownloadTemplateUrl(e){return`/api/page_template/id/${e}/asset/download`}getUploadUrl(e){return`/api/page/id/${e}/asset/upload`}getUploadTemplateUrl(e){return`/api/page_template/id/${e}/asset/upload`}}class B extends U{async getAll(e){return(await this.axios.get("/api/page",{withCredentials:!0,headers:Object.assign({},e,{Accept:"application/json","Content-Type":"application/json","Cache-Control":"no-cache",Pragma:"no-cache",Expires:"0"})})).data.pages}async get(e,t){return(await this.axios.get(`/api/page/id/${e}`,{withCredentials:!0,headers:Object.assign({},t,{accept:"application/json","content-type":"application/json"})})).data.page}async getPageContent(e,t){return(await this.axios.get(`/p/${e}`,{withCredentials:!0,headers:Object.assign({},t,{accept:"text/html","content-type":"application/json"})})).data}async create(e,t){return(await this.axios.post("/api/page",e,{withCredentials:!0,headers:Object.assign({},t,{accept:"application/json","content-type":"application/json"})})).data.page}}class H extends U{async getAll(e,t){return(await this.axios.get("/api/page_template",{withCredentials:!0,headers:Object.assign({},t,{Accept:"application/json","Content-Type":"application/json","Cache-Control":"no-cache",Pragma:"no-cache",Expires:"0"}),params:{internal_name:e}})).data.page_templates}async get(e,t){return(await this.axios.get(`/api/page_template/id/${e}`,{withCredentials:!0,headers:Object.assign({},t,{accept:"application/json","content-type":"application/json"})})).data.page_template}}function z(e){const t=e.response?.status||0,r=e.response?.data?.message||e.message||"Unknown error";switch(t){case 412:return r.toLowerCase().includes("session expired")?{status:t,message:r,code:"SESSION_EXPIRED",userFriendlyMessage:"Your session has expired",suggestions:["Refresh your token in the portal","Re-authenticate with the portal","Check if your token has been revoked","Ensure your token has the correct permissions"]}:{status:t,message:r,code:"AUTH_FAILED",userFriendlyMessage:"Authentication failed",suggestions:["Verify your token is correct","Check token permissions","Ensure the token hasn't expired","Try generating a new token"]};case 401:return{status:t,message:r,code:"UNAUTHORIZED",userFriendlyMessage:"Unauthorized access",suggestions:["Check if your token is valid","Verify you have the required permissions","Ensure the token hasn't been revoked","Try logging in again"]};case 403:return{status:t,message:r,code:"FORBIDDEN",userFriendlyMessage:"Access forbidden",suggestions:["Check your user permissions","Verify the portal page ID is correct","Ensure your token has the right scope","Contact your administrator"]};default:return{status:t,message:r,code:"UNKNOWN_ERROR",userFriendlyMessage:"An unexpected error occurred",suggestions:["Check your network connection","Verify the portal URL is correct","Try again in a few moments","Check the portal status"]}}}const V="[DEV PAGE. DO NOT DELETE]",_=new Map;class q{#e;#t;#r=null;#s;#a;#n;#i;#o;#c;#l;portalPageId;templateLess;assetsApi;pageApi;pageTemplateApi;logger;constructor(e,t){const{headers:r={},portalPageId:s,templateLess:a=!0,disableSSLValidation:i=!1,v7Features:o=!1,personalAccessToken:c}=t||{};this.#e=r,this.#a=[],this.#s="",this.#n=o,this.#i=c,this.#o=!1,this.#c=Promise.resolve(!1);const l=`${e}:${i}`;_.has(l)?this.#t=_.get(l):(i&&(process.env.NODE_TLS_REJECT_UNAUTHORIZED="0",b.default.defaults.httpsAgent=new n.Agent({rejectUnauthorized:!1})),this.#t=b.default.create({baseURL:e,headers:r,timeout:3e4,maxRedirects:5,httpAgent:new n.Agent({keepAlive:!0,maxSockets:10}),httpsAgent:new n.Agent({keepAlive:!0,maxSockets:10})}),_.set(l,this.#t)),this.portalPageId=s,this.templateLess=a,this.assetsApi=new(o?M:j)(this.#t),this.pageApi=new B(this.#t),this.pageTemplateApi=new H(this.#t),this.logger=R()}async isTemplateLoaded(){return this.#c}get isV710OrHigher(){return this.#o}#p(e){const t=Object.assign({},e,{host:void 0,referer:void 0});return Object.keys(t).forEach((e=>void 0===t[e]&&delete t[e])),this.#e=t,!t.authorization&&this.#i&&(t.authorization=`Bearer ${this.#i}`),t}get personalAccessToken(){return this.#i}set personalAccessToken(e){this.#i=e}updateHeaders(e){this.#p(e)}get localTemplateHTML(){return'<!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8" />\n <title>%%PAGE TITLE%%</title>\n <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>\n <meta name="theme-color" content="rgba(255, 255, 255, 1)"/>\n <link rel="shortcut icon" type="image/x-icon" sizes="any" href="/img/favicon/favicon.ico"/>\n <link rel="icon" type="image/png" sizes="16x16" href="/img/favicon/favicon-16x16.png"/>\n <link rel="icon" type="image/png" sizes="32x32" href="/img/favicon/favicon-32x32.png"/>\n <link rel="icon" type="image/png" sizes="48x48" href="/img/favicon/favicon-48x48.png"/>\n <meta name="msapplication-config" content="/auth/browserconfig.xml"/>\n <link rel="apple-touch-icon" sizes="180x180" href="/img/favicon/apple-touch-icon.png"/>\n <link rel="manifest" href="/auth/site.webmanifest"/>\n <link rel="manifest" href="/auth/manifest.json"/>\n <link rel="stylesheet" type="text/css" href="/auth/theme-vars.css"/>\n <link rel="icon" type="image/svg+xml" href="/favicon.ico" />\n <meta name="viewport" content="width=device-width, initial-scale=1.0" />\n <script src="/js/libs/underscore-latest.min.js" charset="utf-8"><\/script>\n <script src="/js/jquery/jquery-latest.min.js" charset="utf-8"><\/script>\n <script src="/js/application/rating_component.js" charset="utf-8"><\/script>\n </head>\n <body>\n <div id="mi-react-root"></div>\n <script src="/auth/info.js"><\/script>\n <script src="/js/main.js" defer><\/script>\n <link rel="stylesheet" href="/css/main.css" />\n </body>\n </html>'}async getPageTemplate(e){if(await this.#c||this.#r||(this.#c=new Promise((e=>{this.#l=e}))),this.#r)return Promise.resolve(this.#r);if(void 0===this.templateLess&&(this.templateLess=!1),this.#n){const t=await this.pageApi.get(this.portalPageId,this.#p(e)).then((e=>(this.logger.info(C.green("Page fetched")),e))).catch((async t=>{throw this.#l(!1),await this.pageApi.checkAuth(this.#p(e))?(this.logger.error(C.red(`Error fetching page data: ${t.message}\n${t.stack}`)),new Error("The current user does not have access to this page. Check your configuration to ensure the portalPageId is correct.")):t}));return void 0!==t.template_id&&(this.#o=!0),this.#r=this.localTemplateHTML,this.#r=this.#r.replace(/%%PAGE TITLE%%/g,t.name||"Local template"),this.logger.info(C.green("Local page template fetched")),this.#l(!0),this.#r}let t=(await this.pageApi.getAll(this.#p(e)).then((e=>(this.logger.info(C.green("Page list fetched")),e))).catch((async t=>{throw this.#l(!1),await this.pageApi.checkAuth(this.#p(e))?(this.logger.error(C.red(`Error fetching page list: ${t.message}\n${t.stack}`)),new Error("Current user does not have access to page list")):t}))).find((e=>e.name===V));return t||(this.logger.warn(C.yellow("Creating dev page template...")),t=await this.pageApi.create({enabled:"Y",name:V,internal_name:"dev-page-template",visible_in_homepage:"Y"},this.#p(e)).then((e=>(this.logger.info(C.green("Dev page created")),e))).catch((e=>{throw this.logger.error(C.red(`Error creating dev page: ${e.message}`)),this.#l(!1),new Error(`Error when creating dev page.\n That can be caused by missing permissions or page with name "${V}" already exists`)}))),await this.pageApi.getPageContent(t.internal_name,this.#p(e)).then((e=>(this.#r=e,e))).then((e=>(this.#l(!0),this.logger.info(C.green("Page template fetched")),e))).catch((e=>{throw this.#l(!1),this.logger.error(C.red(`Error fetching page template: ${e.message}`)),new Error("Error fetching page template")}))}async getPageVariables(e,t){return this.#r=await this.getPageTemplate(t),this.portalPageId||(this.portalPageId=e,this.templateLess=!1),await this.pageApi.get(e,this.#p(t)).then((e=>{const{tags:t="[]",name:r,template:s}=e;if(s&&t){const e=JSON.parse(t);return this.#a=e,this.#s=r,e}return this.#a=[],this.#s=r,[]})).catch((t=>{if(this.logger.error(C.red(`Error fetching page variables: ${t.message}`)),404===t.response?.status)throw new Error(`Portal Page with id "${e}" not found on instance ${this.#t.getUri()}`);if(401===t.response?.status)throw new Error(`Current user does not have access to page with id "${e}" on instance ${this.#t.getUri()}`);throw t}))}async getPageInfo(e,t){this.portalPageId||(this.portalPageId=e);const r=this.#p(t),s=this.portalPageId;try{return this.#n?await this.#d(s,r):await this.#h(s,r)}catch(e){this.#u(e,s)}}async#d(e,t){const r=await this.pageApi.get(e,t);return this.logger.info(C.green("Page fetched")),void 0!==r.template_id&&(this.#o=!0),r}async#h(e,t){return await this.pageApi.get(e,t)}#u(e,t){if(this.#n&&e.message?.includes("access"))throw new Error("The current user does not have access to this page. Check your configuration to ensure the portalPageId is correct.");if(404===e.response?.status)throw new Error(`Portal Page with id "${t}" not found on instance ${this.#t.getUri()}`);throw 401===e.response?.status&&this.logger.error(C.red(`Current user does not have access to page with id "${t}" on instance ${this.#t.getUri()}`)),e}buildPage(e,t=!1){let r="string"==typeof e?e:e.toString("utf-8");for(const e of this.#a)r=r.replace(new RegExp(`\\[${e.name}\\]`,"g"),e.value);const s=new a.JSDOM(t?r:this.#r),n="%%PLACEHOLDER%%";if(!t){const e=s.window.document.createElement("div");e.innerHTML=n;const t=s.window.document.querySelector(".main-side");if(t){const r=t.querySelectorAll("script");r.length?t.insertBefore(e,r.item(r.length-1)):t.append(e)}else{const t=s.window.document.createElement("div");t.append(e),s.window.document.body.append(t)}const r=s.window.document.querySelector("head"),a=r.querySelector("title");a?a.text=this.#s:r.innerHTML+=`<title>${this.#s}</title>`}return s.serialize().replace(new RegExp(`<div>\\s*${n}\\s*<\\/div>`,"i"),r)}async getAssets(){if(this.portalPageId){if(this.templateLess)return await this.assetsApi.downloadPageAssets(this.portalPageId,this.#e);{const e=await this.pageApi.get(this.portalPageId,this.#e);if(this.#o){const t=await this.pageTemplateApi.get(e.template_id,this.#e);return await this.assetsApi.downloadTemplateAssets(t.id,this.#e)}if(e.template)return await this.assetsApi.downloadTemplateAssets(e.template,this.#e)}}}async updateAssets(e){if(this.portalPageId){if(this.templateLess)return await this.assetsApi.uploadPageAssets(this.portalPageId,e,this.#e);{const t=await this.pageApi.get(this.portalPageId,this.#e);if(this.#o){const r=await this.pageTemplateApi.get(t.template_id,this.#e);return await this.assetsApi.uploadTemplateAssets(r.id,e,this.#e)}if(t.template)return await this.assetsApi.uploadTemplateAssets(t.template,e,this.#e)}}}async validateCredentials(e){try{const t=e||this.#e;return await this.get("/api/user",t,!0),{isValid:!0}}catch(e){const t=z(e);return{isValid:!1,error:t.userFriendlyMessage,code:t.code}}}async get(e,t,r=!1){const s=r?t:Object.assign({},this.#p(this.#e),t);try{return await this.#t.get(e,{headers:s})}catch(e){if("UNKNOWN_ERROR"!==z(e).code){const t=z(e);throw this.logger.error(C.red(`API request failed: ${t.userFriendlyMessage}`)),function(e,t,r){const s=z(t),a=`[${r}] `;e.error(C.red(`${a}${s.userFriendlyMessage}`)),e.error(C.red(`Status: ${s.status} (${s.code})`)),e.error(C.red(`Details: ${s.message}`)),s.suggestions.length>0&&(e.info(C.yellow("Suggestions:")),s.suggestions.forEach(((t,r)=>{e.info(C.yellow(` ${r+1}. ${t}`))})))}(this.logger,e,"API Request"),e.response||(e.response={status:t.status,data:{message:t.message}}),e.tokenErrorInfo=t,e}throw e}}}class Z{server;opts;eventMap;logger;constructor(e,t){this.server=e,this.opts=t||{},this.eventMap=new Map,this.eventMap.set("info-data:request",this.onInfoDataRequest.bind(this)),this.eventMap.set("template:sync",this.onTemplateSync.bind(this)),this.logger=R(),this.init()}init(){const{ws:e}=this.server;for(const[t,r]of this.eventMap)e.on(t,r)}onInfoDataRequest(){this.server.ws.send({type:"custom",event:"info-data:response",data:{}})}async onTemplateSync(){if(!this.opts.distService||!this.opts.miAPI)return this.server.ws.send("template:sync:response",{error:"Dist service or MiAPI is not defined"}),void this.logger.error(C.red("Dist service or MiAPI is not defined"));{const{distService:e,miAPI:t}=this.opts;if(this.server.config.clientInjectionPlugin?.v7Features){if(!t?.isV710OrHigher)return void this.server.ws.send("template:sync:response",{error:"This feature is available only for MI v7.1.0 or higher",config:{canSync:!1}});this.server.ws.send("client:config:update",{config:{canSync:!0}})}const r=await(t?.getAssets().catch((async e=>{if(s.isAxiosError(e)){if("SESSION_EXPIRED"===z(e).code){this.logger.info(C.yellow("Session expired - attempting to validate credentials"));try{const e=await(t?.validateCredentials());e&&!e.isValid?(this.logger.error(C.red(`Authentication error: ${e.error}`)),this.server.ws.send("template:sync:response",{error:e.error,code:e.code,refresh:!0})):(this.logger.info(C.yellow("Session expired")),this.server.ws.send("template:sync:response",{error:"Session expired",code:"SESSION_EXPIRED",refresh:!0}))}catch(e){this.logger.info(C.yellow("Session expired")),this.server.ws.send("template:sync:response",{error:"Session expired",code:"SESSION_EXPIRED",refresh:!0})}return e}if(e.cause instanceof Error&&("ECONNRESET"===e.cause.code||"ENOTFOUND"===e.cause.code))return this.logger.info(C.yellow("Server in maintenance mode, VPN connection is needed or no internet connection")),this.server.ws.send("template:sync:response",{error:"Server in maintenance mode, VPN connection is needed or no internet connection",code:"CONNECTION_ERROR"}),e}throw e})));if(r instanceof Error)return;const a=r?await(e?.saveBackupAndBuild(r).catch((e=>{if("Backup file is not a ZIP file"===e.message)return this.logger.error(C.red("Backup file is not a ZIP file")),e}))):await(e?.buildNewAssets());if(!(a&&a instanceof Buffer))return a instanceof Error?(this.server.ws.send("template:sync:response",{error:a.message}),void this.logger.error(C.red(a.message))):(this.server.ws.send("template:sync:response",{error:"Failed to build new assets"}),void this.logger.error(C.red("Failed to build new assets")));{const r=await(t?.updateAssets(a));if("OK"===r?.status){const t=e?.getBackupMeta(),{lastBackupName:r,lastBackupHash:s,lastBackupDate:a}=t||{lastBackupName:"",lastBackupHash:"",lastBackupDate:(new Date).toISOString()};this.server.ws.send("template:sync:response",{syncedAt:new Date(a),currentHash:s,backupFilename:r}),this.logger.info(C.green("Template synced"))}else this.server.ws.send("template:sync:response",{error:"Failed to update assets"}),this.logger.error(C.red("Failed to update assets"))}}}}const W=/\.(?:[a-z0-9]+)$/i,X=6e5,Y=104857600,K=1e3;class J extends v.Cache{totalSize=0;maxSize;maxItems;constructor(e,t){super(),this.maxSize=e,this.maxItems=t}put(e,t,r){const s=this.get(e);s&&(this.totalSize-=s.size);const a=super.put(e,t,r);return this.totalSize+=t.size,this.cleanup(),a}cleanup(){const e=this.keys();if(e.length>this.maxItems){const t=e.length-this.maxItems,r=e.sort(((e,t)=>{const r=this.get(e),s=this.get(t);return(r?.timestamp||0)-(s?.timestamp||0)}));for(let e=0;e<t;e++){const t=r[e],s=this.get(t);s&&(this.totalSize-=s.size,this.del(t))}}for(;this.totalSize>this.maxSize&&e.length>0;){const t=e.sort(((e,t)=>{const r=this.get(e),s=this.get(t);return(r?.timestamp||0)-(s?.timestamp||0)}))[0];if(t){const e=this.get(t);e&&(this.totalSize-=e.size,this.del(t))}}}getTotalSize(){return this.totalSize}getItemCount(){return this.keys().length}}const G=new J(Y,K);function Q(e){if(0===e.length)return Buffer.alloc(0);if(1===e.length)return e[0];const t=e.reduce(((e,t)=>Buffer.byteLength(t)+e),0);return Buffer.concat(e,t)}function ee(e){const{devServer:t,ttl:r=X,maxSize:s=Y,maxItems:a=K}=e,n=R();return s===Y&&a===K||(G.maxSize=s,G.maxItems=a),t.cache=G,(e,t,s)=>{const a=e.originalUrl||e.url||"",i=function(e){const t=e.split("?")[0];return W.test(t)?t.includes("/auth/info.js")?"":e:""}(a);if(!i)return s();const o=G.get(i);if(o)return n.info(`${C.blue("Proxies request:")} ${C.green(e.method)} ${a} -> ${C.blue("Cache")} ${i}`),function(e,t){try{for(const[r,s]of Object.entries(t))null!=s&&e.setHeader(r,s)}catch(e){console.warn("Failed to set some response headers:",e)}}(t,o.headers),t.write(o.content),void t.end();const c=t.end,l=t.write,p=[];t.write=function(e,r,s){if(!t.hasHeader(F))return l.call(this,e,r,s);if("string"==typeof e){const t=r||"utf8";p.push(Buffer.from(e,t))}else Buffer.isBuffer(e)?p.push(e):null!=e&&p.push(Buffer.from(String(e),"utf8"));return!0},t.end=function(e,s,a){if(!t.hasHeader(F))return c.call(this,e,s,a);if(null!=e)if("string"==typeof e){const t=s||"utf8";p.push(Buffer.from(e,t))}else Buffer.isBuffer(e)?p.push(e):p.push(Buffer.from(String(e),"utf8"));let o;try{o=Q(p);const e=Buffer.byteLength(o);if(e>0&&e<10485760){const s={headers:t.getHeaders(),content:o,timestamp:Date.now(),size:e};G.put(i,s,r),n.info(`${C.blue("[Cached]")} ${i} (${(e/1024).toFixed(1)}KB)`)}}catch(e){n.error(`Failed to cache response for ${i}: ${e}`),o=Q(p)}const l=s||"utf8";return c.call(this,o,l,a)},s()}}const te="pageName",re="date",se=k.dirname("undefined"!=typeof __filename&&__filename||l.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:m&&"SCRIPT"===m.tagName.toUpperCase()&&m.src||new URL("plugin-DGza708W.js",document.baseURI).href)),ae=k.resolve(se,"..",".."),ne=k.resolve(ae,"..",".."),ie=k.resolve(ne,".pp-dev-meta"),oe=k.resolve(ie,"sync-service.meta.json");class ce{backupFolder;backupNameTemplate;dateFormat;pageName;currentMeta=null;distZipFolder;distZipFilename;logger;constructor(e,t){this.pageName=e;const{backupFolder:r=k.resolve(P.cwd(),"backups"),distZipFolder:s=k.resolve(P.cwd(),"dist-zip"),distZipFilename:a=`${this.pageName}.zip`,backupNameTemplate:n=`{${te}}-{${re}}.zip`,dateFormat:i=e=>e.toISOString().replace(/:/g,"-").replace(/\..*$/,"")}=t||{};this.backupFolder=r,this.backupNameTemplate=n,this.dateFormat=i,this.distZipFolder=s,this.distZipFilename=a,this.syncMeta(),this.logger=R()}async checkMeta(){try{await c.promises.stat(ie)}catch{await c.promises.mkdir(ie)}try{await c.promises.stat(this.backupFolder)}catch{await c.promises.mkdir(this.backupFolder)}}async readMetaFile(){return await this.checkMeta(),await c.promises.readFile(oe,{encoding:"utf-8"}).catch((()=>"{}"))}async writeMetaFile(e){return await this.checkMeta(),await c.promises.writeFile(oe,JSON.stringify(e,null,2),{encoding:"utf-8"})}async syncMeta(){this.currentMeta?await this.writeMetaFile(this.currentMeta):this.currentMeta=JSON.parse(await this.readMetaFile())}async getLatestSavedBackup(){const{lastBackupName:e}=this.currentMeta;if(!e)return null;const t=k.resolve(this.backupFolder,e);try{return await c.promises.stat(t),t}catch{return null}}backupName(e,t=new Date){return this.backupNameTemplate.replace(`{${te}}`,e).replace(`{${re}}`,this.dateFormat(t))}getBackupMeta(){return this.currentMeta}async saveBackup(e){if("PK"!==e.toString("utf-8").slice(0,4))throw new Error("Backup file is not a ZIP file");const t=x.createHash("md5").update(e).digest("hex");if(await this.getLatestSavedBackup()){const{lastBackupHash:e}=this.currentMeta;if(e===t)return}const r=new Date,s=this.backupName(this.pageName,r);return this.currentMeta.lastBackupName=s,this.currentMeta.lastBackupHash=t,this.currentMeta.lastBackupDate=r.toISOString(),await this.syncMeta(),await c.promises.writeFile(k.resolve(this.backupFolder,s),e).finally((()=>{this.logger.info(`Backup saved to ${s}`)}))}async buildNewAssets(){const e=new Promise(((e,t)=>{let r="";this.logger.info(C.cyan("[DistService] Build started"));const s=T.spawn("node",[k.resolve(ae,"./bin/pp-dev.js"),"build"],{cwd:P.cwd(),env:Object.assign({},P.env,{NODE_ENV:"production"}),stdio:"inherit"});s.on("message",(e=>{r+=e})),s.on("close",(s=>{0===s?e(r):t(new Error(`build command exited with code ${s}`))})),s.on("error",(e=>{t(e)}))}));try{await e.finally((()=>{this.logger.info(C.cyan("[DistService] Build finished"))}));const t=k.resolve(P.cwd(),this.distZipFolder,this.distZipFilename);if(!await c.promises.stat(t))throw new Error(`File ${t} not found`);return await c.promises.readFile(t)}catch(e){throw A.log(e),e}}async saveBackupAndBuild(e){return await this.saveBackup(e),await this.buildNewAssets()}}function le(e,t){return async(r,s,a)=>{if(await e(r.url??"",r,s)){R().info(`Rewrite response for ${r.url}`);const e=s.end,a=[];s.write=function(e){return a.push(e),!0},s.end=function(n,i,o){"string"==typeof n&&a.push(Buffer.from(n));const c=s.getHeader("content-encoding"),l=function(e,t){switch(t){case"gzip":return g.unzipSync(e);case"br":return g.brotliDecompressSync(e);case"deflate":return g.deflateSync(e);default:return e}}(Buffer.from(Buffer.concat(a)),c),p="function"!=typeof i&&i?i:"utf-8",d="function"==typeof i?i:o;return e.call(this,function(e,t){switch(t){case"gzip":return g.gzipSync(e);case"br":return g.brotliCompressSync(e);case"deflate":return g.inflateSync(e);default:return e}}(t(l,r,s),c),p,d),this}}a()}}function pe(e,t){const r=(e=(e=e.startsWith("/")?e:`/${e}`).endsWith("/")?e:`${e}/`).endsWith("/")?e.slice(0,-1):e,s=R();return(a,n,i)=>{const o=new l.URL(a.url??"","http://localhost"),{pathname:c,search:p}=o,d=["/",r];if(t&&(d.push(`/pt/${t}`),d.push(`/pl/${t}`)),d.includes(c)){const t=`${e}${p}`;return s.info(C.yellow(`Redirecting to: ${t}`)),I(n,t,302)}i()}}class de{state={isAuthenticated:!1,isRedirected:!1,lastChecked:0};listeners=new Set;getState(){return{...this.state}}isAuthenticated(){return this.state.isAuthenticated}isRedirected(){return this.state.isRedirected}setAuthenticated(e){this.state.isAuthenticated=e,this.state.lastChecked=Date.now(),this.notifyListeners()}setRedirected(e){this.state.isRedirected=e,this.notifyListeners()}updateState(e){void 0!==e.isAuthenticated&&(this.state.isAuthenticated=e.isAuthenticated),void 0!==e.isRedirected&&(this.state.isRedirected=e.isRedirected),this.state.lastChecked=Date.now(),this.notifyListeners()}reset(){this.state={isAuthenticated:!1,isRedirected:!1,lastChecked:0},this.notifyListeners()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}notifyListeners(){this.listeners.forEach((e=>{try{e(this.getState())}catch(e){console.error("Error in auth state listener:",e)}}))}getDebugInfo(){return{...this.getState(),listenerCount:this.listeners.size}}}const he=new de,ue=new Map;function ge(e){const t=ue.get(e);return t?Date.now()-t.timestamp>18e4?(ue.delete(e),null):t.data:null}function fe(e,t){ue.set(e,{timestamp:Date.now(),data:t})}const me="/home?proxyRedirect=";function we(e,t,r){const{templateLess:s=!1,miHudLess:a=!1,portalPageId:n,base:i,v7Features:o}=r,c=R();if(s&&a&&void 0===n)throw new Error("Portal page ID is required when both templateLess and miHudLess are true");let l=he.getState();return he.subscribe((e=>{l=e})),async(r,p,d)=>{try{const h=!(s&&a),u=e.test(function(e){return e.split("?")[0]}(r.url??""));if(!l.isAuthenticated&&!l.isRedirected&&r.url?.startsWith("/home")&&!r.url?.startsWith(me)){c.info(C.blue("Trying to authenticate and redirect to base"));try{return h?await be(t,{templateLess:s,miHudLess:a,portalPageId:n,redirectUrl:o&&i?`${i}`:`${me}${encodeURIComponent("/")}`},r,p,(()=>{}),c):await ye(t,{templateLess:s,miHudLess:a,portalPageId:n,redirectUrl:o&&i?`${i}`:`${me}${encodeURIComponent("/")}`},r,p,(()=>{}),c),he.setRedirected(!0),c.info(C.blue("Successfully authenticated. Redirecting to base")),I(p,i??"/",302)}catch(e){return d()}}if(!u)return d();if(!h){return await ye(t,{templateLess:s,miHudLess:a,portalPageId:n,redirectUrl:o&&i?`${i}`:`${me}${encodeURIComponent("/")}`},r,p,d,c)}return await be(t,{templateLess:s,miHudLess:a,portalPageId:n,redirectUrl:o&&i?`${i}`:`${me}${encodeURIComponent("/")}`},r,p,d,c)}catch(e){return c.error(C.red(`Unexpected error in load-pp-data middleware: ${e instanceof Error?e.message:String(e)}`)),he.reset(),d(e)}}}async function ye(e,t,r,s,a,n){const{portalPageId:i,redirectOnAuthFailure:o,redirectUrl:c}=t;if(void 0===i){const e=new Error("Portal page ID is required for page info only mode");return n.error(C.red(e.message)),a(e)}const l=r.headers??{};n.info(C.green("Start loading page info"));try{const t=`pageInfo:${i}`;return ge(t)?(n.info(C.green("Page info loaded from cache")),a()):(await e.getPageInfo(i,l),n.info(C.blue("Clearing proxy cache after successful login")),G.clear(),fe(t,{success:!0}),he.updateState({isAuthenticated:!0}),n.info(C.green("Page info loaded successfully")),a())}catch(e){return he.reset(),ve(e,o??!0,c||`${me}${encodeURIComponent("/")}`,s,a,n,"Page info")}}async function be(e,t,r,s,a,n){const{templateLess:i,portalPageId:o,redirectOnAuthFailure:c,redirectUrl:l}=t,p=r.headers??{};n.info(C.green("Start loading page data"));try{const t=`pageData:${i}:${o}`;if(ge(t))return n.info(C.green("Page data loaded from cache")),a();const r=i||void 0===o?e.getPageTemplate(p):e.getPageVariables(o,p);return await r,n.info(C.blue("Clearing proxy cache after successful login")),G.clear(),fe(t,{success:!0}),n.info(C.green("Page data loaded successfully")),a()}catch(e){return he.reset(),ve(e,c??!0,l||`${me}${encodeURIComponent("/")}`,s,a,n,"Page data")}}function ve(e,t,r,s,a,n,i){if(function(e){return null!==e&&"object"==typeof e&&"response"in e&&void 0!==e.response}(e)&&(n.info(C.red(`${i} loading failed. Not authorized`)),t)){const e=`${r}`;return n.info(C.yellow(`Redirecting to: ${e}`)),I(s,e,302)}const o=e instanceof Error?e.message:String(e);return n.info(C.red(`${i} loading failed. Error: ${o}`)),a(e)}const ke=S.default();function xe(e,t,r){return t(e)?{isValid:!0}:{isValid:!1,error:r}}ke.use(S.default.json()),ke.use(S.default.urlencoded({extended:!0})),exports.AuthProvider=de,exports.MiAPI=q,exports.authProvider=he,exports.colors=C,exports.createLogger=R,exports.initLoadPPData=we,exports.initPPRedirect=pe,exports.initProxy=N,exports.initProxyCache=ee,exports.initRewriteResponse=le,exports.internalServer=ke,exports.normalizeVitePPDevConfig=function(e){const t=function(e){const t=[xe(e,(e=>"object"==typeof e&&null!==e),"VitePPDevOptions must be an object"),xe(e.templateName,(e=>"string"==typeof e&&e.length>0),"VitePPDevOptions.templateName must be a non-empty string"),xe(e.backendBaseURL,(e=>void 0===e||"string"==typeof e&&e.length>0),"VitePPDevOptions.backendBaseURL must be a non-empty string if provided"),xe(e.portalPageId,(e=>void 0===e||"number"==typeof e&&e>0),"VitePPDevOptions.portalPageId must be a positive number if provided"),xe(e.appId,(e=>void 0===e||"number"==typeof e&&e>0),"VitePPDevOptions.appId must be a positive number if provided"),xe(e.proxyCacheTTL,(e=>void 0===e||"number"==typeof e&&e>0),"VitePPDevOptions.proxyCacheTTL must be a positive number if provided"),xe(e.integrateMiTopBar,(t=>{if(void 0===t)return!0;if(null===t)return!1;if("boolean"!=typeof t&&"object"!=typeof t)return!1;if(!0===t&&!0!==e.miHudLess)return!1;if("object"==typeof t&&null!==t){if(void 0!==t.addRootElement&&"boolean"!=typeof t.addRootElement)return!1;if(void 0!==t.addSharedComponentsScripts&&"boolean"!=typeof t.addSharedComponentsScripts)return!1;if(!0!==e.miHudLess&&(!0===t.addRootElement||!0===t.addSharedComponentsScripts))return!1}return!0}),"VitePPDevOptions.integrateMiTopBar must be a boolean or an object with addRootElement and addSharedComponentsScripts booleans")];return t.find((e=>!e.isValid))||{isValid:!0}}(e);if(!t.isValid)throw new Error(t.error);const r=e.appId??e.portalPageId,{enableProxyCache:s=!0,proxyCacheTTL:a=6e5,disableSSLValidation:n=!1,imageOptimizer:i=!0,miHudLess:o=!1,integrateMiTopBar:c=!1,templateLess:l=!1,outDir:p="dist",distZip:d=!0,syncBackupsDir:h="backups",v7Features:u=!1,personalAccessToken:g=process.env.MI_ACCESS_TOKEN}=e||{};let f=d;f=!0===f?{outFileName:`${e.templateName}.zip`,outDir:"dist-zip"}:"object"==typeof d&&{outFileName:"string"==typeof d.outFileName?d.outFileName.replace("[templateName]",e.templateName):`${e.templateName}.zip`,outDir:d.outDir??"dist-zip"};let m=i;return"boolean"==typeof i?!0===m&&(m={}):"object"!=typeof i&&(m=!1),{enableProxyCache:s,proxyCacheTTL:a,disableSSLValidation:n,imageOptimizer:m,templateLess:l,miHudLess:o,outDir:p,distZip:f,syncBackupsDir:h,v7Features:u,personalAccessToken:g,portalPageId:r,integrateMiTopBar:c,...e}},exports.urlReplacer=$,exports.vitePPDev=function(e){const{templateName:t,templateLess:r,backendBaseURL:s,miHudLess:a,portalPageId:n,enableProxyCache:i,proxyCacheTTL:o,disableSSLValidation:c,distZip:l,syncBackupsDir:p,v7Features:d,personalAccessToken:h}=e||{};let u=!0;return process.cwd(),{name:"vite-pp-dev",apply:"serve",config:e=>{const a=function(e){return[xe(e.base,(e=>"string"==typeof e&&e.length>0&&"/"!==e),'Server base path cannot be empty or "/"'),xe(e.port,(e=>void 0===e||"number"==typeof e&&e>0&&e<65536),"Server port must be a valid port number (1-65535)")].find((e=>!e.isValid))||{isValid:!0}}({base:e.base||"",...e.server});if(!a.isValid)throw new Error(a.error);return e.clientInjectionPlugin={backendBaseURL:s,portalPageId:n,templateLess:r,v7Features:d},d&&(e.base=`/pl/${t}`),e},transformIndexHtml:async(e,t)=>{const r={html:e,tags:[]};return u&&(u=!1,r.tags.push({tag:"script",injectTo:"body",children:`${Math.random()}`})),r},configureServer:u=>{let g=u.config.base;g.endsWith("/")||(g+="/");const f=g.substring(0,g.lastIndexOf("/"));if(u.middlewares.use(pe(g,t)),s){const w=new URL(s).host,y={headers:{host:w,referer:s,origin:s.replace(/^(https?:\/\/)([^/]+)(\/.*)?$/i,"$1$2")},portalPageId:n,appId:n,templateLess:r,disableSSLValidation:c,v7Features:d,personalAccessToken:h??process.env.MI_ACCESS_TOKEN},b=[xe((m=y).headers,(e=>"object"==typeof e&&"string"==typeof e.host&&"string"==typeof e.referer&&"string"==typeof e.origin),"MiAPI headers must be properly configured"),xe(m.portalPageId,(e=>void 0===e||"number"==typeof e&&e>0),"MiAPI portalPageId must be a positive number if provided"),xe(m.appId,(e=>void 0===e||"number"==typeof e&&e>0),"MiAPI appId must be a positive number if provided"),xe(m.personalAccessToken,(e=>void 0===e||"string"==typeof e),"MiAPI personalAccessToken must be a string if provided")].find((e=>!e.isValid))||{isValid:!0};if(!b.isValid)throw new Error(b.error);const v=new q(s,y);if(i){let e=+o;(!e||Number.isNaN(e)||e<0)&&(e=6e5);const t={devServer:u,ttl:e},r=function(e){return[xe(e.ttl,(e=>"number"==typeof e&&e>0),"Proxy cache TTL must be a positive number")].find((e=>!e.isValid))||{isValid:!0}}(t);if(!r.isValid)throw new Error(r.error);u.middlewares.use(ee(t))}const k=new RegExp(`^((${g})|/)$`);u.middlewares.use(we(k,v,Object.assign({},e))),u.middlewares.use(N({baseURL:s,proxyIgnore:["/@vite","/@metricinsights","/@",f],disableSSLValidation:c,miAPI:v}));const x=(e,t,r,s,a)=>{const n={error:r};s&&(n.details=s),a&&(n.code=a),e.status(t).json(n).end()},P=(e,t,r)=>{u.config.logger.error(`${r} token validation error:`,t);const s=z(t);if(t.tokenErrorInfo){const r=t.tokenErrorInfo;u.config.logger.info(`Using enhanced error info: ${r.code} - ${r.userFriendlyMessage}`);const s=r.status||500,a=r.code,n=r.userFriendlyMessage,i=r.message;x(e,s,n,i,a)}else{let t,a,n;switch(u.config.logger.info(`Using original error info: ${s.code} - ${s.userFriendlyMessage}`),s.code){case"SESSION_EXPIRED":t=412,a="personal"===r?"Personal access token expired":"Session expired",n="personal"===r?"PAT_EXPIRED":"SESSION_EXPIRED";break;case"UNAUTHORIZED":t=401,a="Unauthorized",n="UNAUTHORIZED";break;case"FORBIDDEN":t=403,a="Access forbidden",n="FORBIDDEN";break;default:t=500,a="Internal server error",n=s.code}const i="personal"===r&&"PAT_EXPIRED"===n?"Your personal access token has expired. Please generate a new token from the portal.":"regular"===r&&"SESSION_EXPIRED"===n?"Your portal session has expired. Please refresh your token or re-authenticate.":s.userFriendlyMessage;x(e,t,a,i,n)}return null};ke.post("/@api/login",(async(e,t,r)=>{const{token:s,tokenType:a}=e.body;if(s){if(u.config.logger.info(`Attempting to validate ${a} token...`),"personal"===a){if(!await v.get("/data/page/index/auth/info",{"Content-Type":"application/json",Accept:"application/json",Authorization:`Bearer ${s}`},!0).then((async e=>"number"==typeof e.data?.user?.user_id?(v.personalAccessToken=s,u.config.logger.info(`Personal access token validated successfully for user ${e.data.user.user_id}`),e):(x(t,400,"Token expired or invalid"),null))).catch((e=>P(t,e,"personal"))))return;I(t,"/",302)}else if("regular"===a){if(!await v.get("/api/user",{"Content-Type":"application/json",Accept:"application/json",Token:s},!0).then((e=>e.data?.users?.length?(v.personalAccessToken=void 0,u.config.logger.info(`Regular token validated successfully for ${e.data.users.length} user(s)`),t.setHeader("set-cookie",e.headers["set-cookie"]??""),e):(x(t,400,"Token expired or invalid"),null))).catch((e=>P(t,e,"regular"))))return;I(t,"/",302)}}else x(t,400,"Token is required")})),u.middlewares.use(ke);const T=!1!==l?new ce(t,Object.assign({backupDir:p},"object"==typeof l?{distZipFolder:l.outDir,distZipFilename:l.outFileName}:void 0)):void 0;return new Z(u,{distService:T,miAPI:v}),()=>{u.middlewares.use(le((e=>e.split("?")[0].endsWith("index.html")),((e,t)=>Buffer.from($(w,t.headers.host??"",v.buildPage(e,a))))))}}var m}}};
2
- //# sourceMappingURL=plugin-DGza708W.js.map