@metricinsights/pp-dev 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -212,6 +212,19 @@ Default: `backups`
212
212
 
213
213
  Description: Define the directory for the asset backups that are used for backup assets from the MI server
214
214
 
215
+ #### `v7Features`
216
+
217
+ Type: Boolean
218
+
219
+ Default: `false`
220
+
221
+ Description: Enables V7 features.
222
+ If you want to enable V7 features, you need to set this option to `true`.
223
+ This option is used for enabling new features that are available only on the Metric Insights v7 instances.
224
+ When setting this option to `true`, the CLI will use apply changes:
225
+ 1. Default development path will be changed from `/pt/<portal-page-name>` to `/pl/<portal-page-name>`. This will avoid conflicts with the Metric Insights v7 features when developing a Portal Page with the Metric Insights toolbar.
226
+ 2. The Code Sync feature will use the new URLs of the Metric Insights v7 instances (available only on the Metric Insights v7.1.0 instances or higher).
227
+
215
228
  ### CLI API description
216
229
 
217
230
  `pp-dev help` - show CLI's help
package/dist/cjs/cli.js CHANGED
@@ -4,8 +4,8 @@ var path = require('path');
4
4
  var fs = require('fs');
5
5
  var node_perf_hooks = require('node:perf_hooks');
6
6
  var cac = require('cac');
7
- var index = require('./index-niSRzSzD.js');
8
- var plugin = require('./plugin-DRnpagNh.js');
7
+ var index = require('./index-BE4YF5iw.js');
8
+ var plugin = require('./plugin-DZS4Taov.js');
9
9
  var vite = require('vite');
10
10
  var url = require('url');
11
11
  var express = require('express');
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var plugin = require('./plugin-DRnpagNh.js');
3
+ var plugin = require('./plugin-DZS4Taov.js');
4
4
  var vite = require('vite');
5
5
  var path = require('path');
6
6
  var fs = require('fs');
@@ -31,7 +31,7 @@ var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
31
31
 
32
32
  const PP_DEV_PACKAGE_DIR = path.resolve(
33
33
  // import.meta.url is `dist/node/constants.js` after bundle
34
- (typeof __filename !== 'undefined' && __filename) || url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-niSRzSzD.js', document.baseURI).href))), '../../..');
34
+ (typeof __filename !== 'undefined' && __filename) || url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BE4YF5iw.js', document.baseURI).href))), '../../..');
35
35
  const PP_DEV_CLIENT_ENTRY = path.resolve(PP_DEV_PACKAGE_DIR, 'dist/client/client.js');
36
36
  const { version, name } = JSON.parse(fs.readFileSync(path.resolve(PP_DEV_PACKAGE_DIR, 'package.json')).toString());
37
37
  const VERSION = version;
@@ -54,7 +54,7 @@ const PP_DEV_CONFIG_NAMES = [
54
54
  'pp-dev.config.json',
55
55
  ];
56
56
 
57
- const DIRNAME = path__namespace.dirname((typeof __filename !== 'undefined' && __filename) || url.fileURLToPath(new URL('.', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-niSRzSzD.js', document.baseURI).href)))));
57
+ const DIRNAME = path__namespace.dirname((typeof __filename !== 'undefined' && __filename) || url.fileURLToPath(new URL('.', (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index-BE4YF5iw.js', document.baseURI).href)))));
58
58
  const PACKAGE_IMPORT = `/${PACKAGE_NAME}/client`;
59
59
  const CLIENT_PATH = `/${PACKAGE_IMPORT}`;
60
60
  function clientInjectionPlugin(opts) {
@@ -95,14 +95,14 @@ function clientInjectionPlugin(opts) {
95
95
  },
96
96
  ],
97
97
  };
98
- const { backendBaseURL, templateLess, portalPageId } = ctx.server?.config.clientInjectionPlugin || {};
98
+ const { backendBaseURL, templateLess, portalPageId, canSync = true, } = ctx.server?.config.clientInjectionPlugin || {};
99
99
  if (!render || baseChanged) {
100
100
  render = ejs.compile(clientPanelTpl.replace(new RegExp(`${CLIENT_PATH}`, 'g'), path__namespace.posix.join(base, PACKAGE_IMPORT)), { openDelimiter: '{', closeDelimiter: '}', async: true });
101
101
  }
102
102
  result.tags.push({
103
103
  tag: 'div',
104
104
  injectTo: 'body-prepend',
105
- children: await render?.({ PACKAGE_NAME, VERSION, backendBaseURL, templateLess, portalPageId }),
105
+ children: await render?.({ PACKAGE_NAME, VERSION, backendBaseURL, templateLess, portalPageId, canSync }),
106
106
  });
107
107
  result.tags.push({
108
108
  tag: 'script',
@@ -247,6 +247,8 @@ async function getConfig() {
247
247
  return config;
248
248
  }
249
249
 
250
+ const pathPagePrefix = '/p';
251
+ const pathTemplatePrefix = '/pt';
250
252
  async function getViteConfig() {
251
253
  const pkg = getPkg();
252
254
  const templateName = pkg.name;
@@ -270,12 +272,13 @@ async function getViteConfig() {
270
272
  });
271
273
  }
272
274
  return {
273
- base: templateLess ? `/p/${templateName}` : `/pt/${templateName}`,
275
+ base: templateLess ? `${pathPagePrefix}/${templateName}` : `${pathTemplatePrefix}/${templateName}`,
274
276
  server: {
275
277
  port: 3000,
276
278
  },
277
279
  build: {
278
280
  minify: false,
281
+ assetsInlineLimit: 4096,
279
282
  rollupOptions: {
280
283
  output: {
281
284
  banner: header,
@@ -283,6 +286,12 @@ async function getViteConfig() {
283
286
  },
284
287
  outDir,
285
288
  },
289
+ css: {
290
+ modules: { localsConvention: 'dashes' },
291
+ scss: {
292
+ api: 'modern',
293
+ },
294
+ },
286
295
  ppDevConfig: normalizedPPDevConfig,
287
296
  plugins,
288
297
  };
@@ -319,4 +328,4 @@ function withPPDev(nextjsConfig, ppDevConfig) {
319
328
  exports.VERSION = VERSION;
320
329
  exports.getViteConfig = getViteConfig;
321
330
  exports.withPPDev = withPPDev;
322
- //# sourceMappingURL=index-niSRzSzD.js.map
331
+ //# sourceMappingURL=index-BE4YF5iw.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-BE4YF5iw.js","sources":["constants.ts","client-injection-plugin.ts","header.ts","config.ts","index.ts"],"sourcesContent":[null,null,null,null,null],"names":["resolve","fileURLToPath","readFileSync","path","fs","normalizePath","compile","build","pathToFileURL","writeFileSync","unlink","readdirSync","normalizeVitePPDevConfig","vitePPDev"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIO,MAAM,kBAAkB,GAAGA,YAAO;AACvC;AACA,CAAC,OAAO,UAAU,KAAK,WAAW,IAAI,UAAU,KAAKC,iBAAa,CAAC,mQAAe,CAAC,EACnF,UAAU,CACX;AAEM,MAAM,mBAAmB,GAAGD,YAAO,CAAC,kBAAkB,EAAE,uBAAuB,CAAC;AAEvF,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAACE,eAAY,CAACF,YAAO,CAAC,kBAAkB,EAAE,cAAc,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC;AAEnG,MAAM,OAAO,GAAG;AAChB,MAAM,YAAY,GAAG,IAAc;AAEnC,MAAM,qBAAqB,GAAG,CAAC,qBAAqB,EAAE,qBAAqB,EAAE,uBAAuB,CAAU;AAE9G,MAAM,mBAAmB,GAAG;IACjC,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,oBAAoB;IACpB,oBAAoB;IACpB,qBAAqB;IACrB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,oBAAoB;CACZ;;ACbV,MAAM,OAAO,GAAGG,eAAI,CAAC,OAAO,CAC1B,CAAC,OAAO,UAAU,KAAK,WAAW,IAAI,UAAU,KAAKF,iBAAa,CAAC,IAAI,GAAG,CAAC,GAAG,EAAE,mQAAe,C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AAA,MAAM,EAAE,YAAY,EAAE,GAAG,SAAS;YAElC,OAAO,MAAM,CAAC,MAAM,CAClB,EAAE,QAAQ,EAAE,YAAY,GAAG,CAAM,GAAA,EAAA,YAAY,CAAE,CAAA,GAAG,CAAO,IAAA,EAAA,YAAY,CAAE,CAAA,EAAE,aAAa,EAAE,IAAI,EAAgB,EAC5G,iBAAiB,EACjB;AACE,gBAAA,mBAAmB,EAAE;oBACnB,YAAY;AACZ,oBAAA,WAAW,EAAE,SAAS;AACvB,iBAAA;AACD,gBAAA,mBAAmB,EAAE;oBACnB,YAAY;AACZ,oBAAA,WAAW,EAAE;wBACX,cAAc,EAAE,SAAS,CAAC,cAAc;wBACxC,YAAY,EAAE,SAAS,CAAC,YAAY;wBACpC,YAAY,EAAE,SAAS,CAAC,YAAY;AACrC,qBAAA;AACF,iBAAA;AACY,aAAA,CAChB;;AAGH,QAAA,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,QAAQ,EAAE,CAAO,IAAA,EAAA,YAAY,CAAE,CAAA,EAAgB,EAAE,iBAAiB,CAAC;AAC5F,KAAC;AACH;;;;;;","x_google_ignoreList":[0,1,2,3,4]}
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- require('./plugin-DRnpagNh.js');
4
- var index = require('./index-niSRzSzD.js');
3
+ require('./plugin-DZS4Taov.js');
4
+ var index = require('./index-BE4YF5iw.js');
5
5
  require('http-proxy-middleware');
6
6
  require('url');
7
7
  require('vite');
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@metricinsights/pp-dev",
3
3
  "type": "commonjs",
4
- "version": "0.7.0",
4
+ "version": "0.9.0",
5
5
  "description": "Portal Page dev build tool",
6
6
  "bin": {
7
7
  "pp-dev": "bin/pp-dev.js"
@@ -54,6 +54,7 @@
54
54
  "dependencies": {
55
55
  "axios": "^1.7.7",
56
56
  "cac": "^6.7.14",
57
+ "deepmerge-ts": "^7.1.3",
57
58
  "diff-match-patch": "^1.0.5",
58
59
  "dir-compare": "^5.0.0",
59
60
  "ejs": "^3.1.10",
@@ -86,6 +86,14 @@ const colors = picocolors.createColors();
86
86
 
87
87
  const hostOriginRegExp = /^(https?:\/\/)([^/]+)(\/.*)?$/i;
88
88
  const PROXY_HEADER = 'X-PP-Proxy';
89
+ // TODO: Implement interceptor for streaming responses
90
+ function streamResponseInterceptor(interceptor) {
91
+ return async (proxyRes, req, res) => {
92
+ res.setHeader(PROXY_HEADER, 1);
93
+ res.setHeaders(new Map(Object.entries(proxyRes.headers)));
94
+ proxyRes.pipe(res);
95
+ };
96
+ }
89
97
  function initProxy(opts) {
90
98
  const { rewritePath = /^\/(?!pt).*/i, baseURL = '', devServer, disableSSLValidation = false } = opts;
91
99
  if (!baseURL) {
@@ -166,34 +174,55 @@ function initProxy(opts) {
166
174
  });
167
175
  return proxyReq;
168
176
  },
169
- proxyRes: httpProxyMiddleware.responseInterceptor(async (responseBuffer, proxyRes, req, res) => {
170
- res.setHeader(PROXY_HEADER, 1);
171
- const type = await (await fileType).fileTypeFromBuffer(responseBuffer);
172
- if (type) {
173
- return responseBuffer;
177
+ proxyRes: (serverRes, req, res) => {
178
+ if (serverRes.headers['content-type']?.includes('text/event-stream') ||
179
+ (serverRes.headers['transfer-encoding']?.includes('chunked') &&
180
+ serverRes.headers['x-accel-buffering'] === 'no')) {
181
+ logger.info(`${colors.blue('Start streaming for request:')} ${colors.green(req.method)} ${req.url}`);
182
+ const streamInterceptor = streamResponseInterceptor();
183
+ return streamInterceptor(serverRes, req, res);
174
184
  }
175
- else {
176
- let response = responseBuffer.toString('utf8'); // convert buffer to string
177
- try {
178
- const reqUrl = new URL(req.url ?? '', `http://${host}`);
179
- if (reqUrl.searchParams && reqUrl.searchParams.has('proxyRedirect')) {
180
- response +=
181
- '<script>' +
182
- 'const params = new URLSearchParams(window.location.search);' +
183
- "if (params.has('proxyRedirect')) {" +
184
- " setTimeout(() => { window.location = params.get('proxyRedirect'); }, 50);" +
185
- '}' +
186
- '</script>';
187
- }
185
+ const rewriteInterceptor = httpProxyMiddleware.responseInterceptor(async (responseBuffer, proxyRes, req, res) => {
186
+ res.setHeader(PROXY_HEADER, 1);
187
+ const type = await (await fileType).fileTypeFromBuffer(responseBuffer);
188
+ if (type) {
189
+ return responseBuffer;
188
190
  }
189
- catch {
190
- //
191
+ else {
192
+ let response = responseBuffer.toString('utf8'); // convert buffer to string
193
+ try {
194
+ const reqUrl = new URL(req.url ?? '', `http://${host}`);
195
+ if (reqUrl.searchParams && reqUrl.searchParams.has('proxyRedirect')) {
196
+ const redirectToFunction = function () {
197
+ let url = window.location.href;
198
+ const func = function () {
199
+ const params = new URLSearchParams(window.location.search);
200
+ if (!params.has('proxyRedirect')) {
201
+ return;
202
+ }
203
+ if (url !== window.location.href) {
204
+ url = window.location.href;
205
+ setTimeout(func, 2000);
206
+ }
207
+ else {
208
+ window.location.href = params.get('proxyRedirect');
209
+ }
210
+ };
211
+ setTimeout(func, 2000);
212
+ };
213
+ response += '<script>' + `(${redirectToFunction.toString()})()` + '</script>';
214
+ }
215
+ }
216
+ catch {
217
+ //
218
+ }
219
+ const reqHost = req.headers.host ?? '';
220
+ // manipulate response and return the result
221
+ return urlPathReplacer('/auth/saml/login', '/login', urlReplacer(host, reqHost, response));
191
222
  }
192
- const reqHost = req.headers.host ?? '';
193
- // manipulate response and return the result
194
- return urlPathReplacer('/auth/saml/login', '/login', urlReplacer(host, reqHost, response));
195
- }
196
- }),
223
+ });
224
+ return rewriteInterceptor(serverRes, req, res);
225
+ },
197
226
  error(err, req, res) {
198
227
  const errorMessage = `Proxy error: "${err.message}" when trying to "${req.method} ${req.url}"\n\n${err.stack}`;
199
228
  logger.error(errorMessage);
@@ -230,9 +259,21 @@ class AssetsAPI extends BaseAPI {
230
259
  constructor(axios) {
231
260
  super(axios);
232
261
  }
262
+ getDownloadUrl(portalPageId) {
263
+ return `/admin/page/downloadassets/id/${portalPageId}`;
264
+ }
265
+ getDownloadTemplateUrl(templateId) {
266
+ return `/admin/pagetemplate/downloadassets/id/${templateId}`;
267
+ }
268
+ getUploadUrl(portalPageId) {
269
+ return `/admin/page/uploadassets/id/${portalPageId}`;
270
+ }
271
+ getUploadTemplateUrl(templateId) {
272
+ return `/admin/pagetemplate/uploadassets/id/${templateId}`;
273
+ }
233
274
  async downloadPageAssets(portalPageId, headers) {
234
275
  return this.axios
235
- .get(`/admin/page/downloadassets/id/${portalPageId}`, {
276
+ .get(this.getDownloadUrl(portalPageId), {
236
277
  withCredentials: true,
237
278
  headers: Object.assign({}, headers, { accept: '*/*' }),
238
279
  responseType: 'arraybuffer',
@@ -249,9 +290,9 @@ class AssetsAPI extends BaseAPI {
249
290
  const formData = new (await this.formdataModulePromise).FormData();
250
291
  const assetFile = new File([file.buffer], 'file.zip', { type: 'application/zip' });
251
292
  formData.append('file', assetFile);
252
- const url = `/admin/page/uploadassets/id/${portalPageId}`;
293
+ const url = this.getUploadUrl(portalPageId);
253
294
  return this.axios
254
- .post(`/admin/page/uploadassets/id/${portalPageId}`, formData, {
295
+ .post(url, formData, {
255
296
  withCredentials: true,
256
297
  headers: Object.assign({}, headers, {
257
298
  accept: 'application/json',
@@ -263,7 +304,7 @@ class AssetsAPI extends BaseAPI {
263
304
  }
264
305
  async downloadTemplateAssets(templateId, headers) {
265
306
  return this.axios
266
- .get(`/admin/pagetemplate/downloadassets/id/${templateId}`, {
307
+ .get(this.getDownloadTemplateUrl(templateId), {
267
308
  withCredentials: true,
268
309
  headers: Object.assign({}, headers, { accept: '*/*' }),
269
310
  responseType: 'arraybuffer',
@@ -282,7 +323,7 @@ class AssetsAPI extends BaseAPI {
282
323
  type: 'application/zip',
283
324
  });
284
325
  formData.append('file', assetFile, 'file.zip');
285
- const url = `/admin/pagetemplate/uploadassets/id/${templateId}`;
326
+ const url = this.getUploadTemplateUrl(templateId);
286
327
  return this.axios
287
328
  .post(url, formData, {
288
329
  withCredentials: true,
@@ -295,6 +336,20 @@ class AssetsAPI extends BaseAPI {
295
336
  .then((res) => res.data);
296
337
  }
297
338
  }
339
+ class AssetsV7API extends AssetsAPI {
340
+ getDownloadUrl(portalPageId) {
341
+ return `/api/page/id/${portalPageId}/asset/download`;
342
+ }
343
+ getDownloadTemplateUrl(templateId) {
344
+ return `/api/page_template/id/${templateId}/asset/download`;
345
+ }
346
+ getUploadUrl(portalPageId) {
347
+ return `/api/page/id/${portalPageId}/asset/upload`;
348
+ }
349
+ getUploadTemplateUrl(templateId) {
350
+ return `/api/page_template/id/${templateId}/asset/upload`;
351
+ }
352
+ }
298
353
 
299
354
  class PageAPI extends BaseAPI {
300
355
  async getAll(headers) {
@@ -338,6 +393,33 @@ class PageAPI extends BaseAPI {
338
393
  }
339
394
  }
340
395
 
396
+ class PageTemplateAPI extends BaseAPI {
397
+ async getAll(internal_name, headers) {
398
+ return (await this.axios.get(`/api/page_template`, {
399
+ withCredentials: true,
400
+ headers: Object.assign({}, headers, {
401
+ Accept: 'application/json',
402
+ 'Content-Type': 'application/json',
403
+ 'Cache-Control': 'no-cache',
404
+ Pragma: 'no-cache',
405
+ Expires: '0',
406
+ }),
407
+ params: {
408
+ internal_name,
409
+ },
410
+ })).data.page_templates;
411
+ }
412
+ async get(id, headers) {
413
+ return (await this.axios.get(`/api/page_template/id/${id}`, {
414
+ withCredentials: true,
415
+ headers: Object.assign({}, headers, {
416
+ accept: 'application/json',
417
+ 'content-type': 'application/json',
418
+ }),
419
+ })).data.page_template;
420
+ }
421
+ }
422
+
341
423
  const TEMPLATE_PAGE_NAME = '[DEV PAGE. DO NOT DELETE]';
342
424
  class MiAPI {
343
425
  #headers;
@@ -345,18 +427,23 @@ class MiAPI {
345
427
  #pageTemplate = null;
346
428
  #pageTitle;
347
429
  #pageVars;
430
+ #v7Features;
431
+ #isV710OrHigher;
348
432
  #templateLoaded;
349
433
  #templateLoadedResolve;
350
434
  portalPageId;
351
435
  templateLess;
352
436
  assetsApi;
353
437
  pageApi;
438
+ pageTemplateApi;
354
439
  logger;
355
440
  constructor(baseURL, opts) {
356
- const { headers = {}, portalPageId, templateLess = true, disableSSLValidation = false } = opts || {};
441
+ const { headers = {}, portalPageId, templateLess = true, disableSSLValidation = false, v7Features = false, } = opts || {};
357
442
  this.#headers = headers;
358
443
  this.#pageVars = [];
359
444
  this.#pageTitle = '';
445
+ this.#v7Features = v7Features;
446
+ this.#isV710OrHigher = false;
360
447
  this.#templateLoaded = Promise.resolve(false);
361
448
  if (disableSSLValidation) {
362
449
  axios.defaults.httpsAgent = new https.Agent({ rejectUnauthorized: false });
@@ -367,13 +454,17 @@ class MiAPI {
367
454
  });
368
455
  this.portalPageId = portalPageId;
369
456
  this.templateLess = templateLess;
370
- this.assetsApi = new AssetsAPI(this.#axios);
457
+ this.assetsApi = new (!v7Features ? AssetsAPI : AssetsV7API)(this.#axios);
371
458
  this.pageApi = new PageAPI(this.#axios);
459
+ this.pageTemplateApi = new PageTemplateAPI(this.#axios);
372
460
  this.logger = createLogger();
373
461
  }
374
462
  async isTemplateLoaded() {
375
463
  return this.#templateLoaded;
376
464
  }
465
+ get isV710OrHigher() {
466
+ return this.#isV710OrHigher;
467
+ }
377
468
  #clearHeaders(headers) {
378
469
  const obj = Object.assign({}, headers, { host: undefined, referer: undefined });
379
470
  Object.keys(obj).forEach((key) => obj[key] === undefined && delete obj[key]);
@@ -383,6 +474,24 @@ class MiAPI {
383
474
  updateHeaders(headers) {
384
475
  this.#clearHeaders(headers);
385
476
  }
477
+ get localTemplateHTML() {
478
+ return /* HTML */ `<!DOCTYPE html>
479
+ <html lang="en">
480
+ <head>
481
+ <meta charset="UTF-8" />
482
+ <title>Local template</title>
483
+ <meta charset="UTF-8" />
484
+ <link rel="icon" type="image/svg+xml" href="/favicon.ico" />
485
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
486
+ </head>
487
+ <body>
488
+ <div id="mi-react-root"></div>
489
+ <script src="/auth/info.js"></script>
490
+ <script src="/js/main.js" defer></script>
491
+ <link rel="stylesheet" href="/css/main.css" />
492
+ </body>
493
+ </html>`;
494
+ }
386
495
  /**
387
496
  * Get page template
388
497
  * @param headers
@@ -399,6 +508,31 @@ class MiAPI {
399
508
  if (typeof this.templateLess === 'undefined') {
400
509
  this.templateLess = false;
401
510
  }
511
+ if (this.#v7Features) {
512
+ const page = await this.pageApi
513
+ .get(this.portalPageId, this.#clearHeaders(headers))
514
+ .then((response) => {
515
+ this.logger.info(colors.green('Page fetched'));
516
+ return response;
517
+ })
518
+ .catch(async (e) => {
519
+ this.#templateLoadedResolve(false);
520
+ if (await this.pageApi.checkAuth(this.#clearHeaders(headers))) {
521
+ this.logger.error(colors.red(`Error fetching page data: ${e.message}\n${e.stack}`));
522
+ throw new Error('Current user does not have access to the page');
523
+ }
524
+ else {
525
+ throw e;
526
+ }
527
+ });
528
+ if (typeof page.template_id !== 'undefined') {
529
+ this.#isV710OrHigher = true;
530
+ }
531
+ this.#pageTemplate = this.localTemplateHTML;
532
+ this.logger.info(colors.green('Local page template fetched'));
533
+ this.#templateLoadedResolve(true);
534
+ return this.#pageTemplate;
535
+ }
402
536
  const pageList = await this.pageApi
403
537
  .getAll(this.#clearHeaders(headers))
404
538
  .then((response) => {
@@ -515,14 +649,19 @@ class MiAPI {
515
649
  else {
516
650
  container.append(placeholder);
517
651
  }
518
- const head = dom.window.document.querySelector('head');
519
- const title = head.querySelector('title');
520
- if (title) {
521
- title.text = this.#pageTitle;
522
- }
523
- else {
524
- head.innerHTML += `<title>${this.#pageTitle}</title>`;
525
- }
652
+ }
653
+ else {
654
+ const container = dom.window.document.createElement('div');
655
+ container.append(placeholder);
656
+ dom.window.document.body.append(container);
657
+ }
658
+ const head = dom.window.document.querySelector('head');
659
+ const title = head.querySelector('title');
660
+ if (title) {
661
+ title.text = this.#pageTitle;
662
+ }
663
+ else {
664
+ head.innerHTML += `<title>${this.#pageTitle}</title>`;
526
665
  }
527
666
  }
528
667
  const serializedDom = dom.serialize();
@@ -535,8 +674,14 @@ class MiAPI {
535
674
  }
536
675
  else {
537
676
  const pageInfo = await this.pageApi.get(this.portalPageId, this.#headers);
538
- if (pageInfo.template) {
539
- return await this.assetsApi.downloadTemplateAssets(pageInfo.template, this.#headers);
677
+ if (this.#isV710OrHigher) {
678
+ const templateInfo = await this.pageTemplateApi.get(pageInfo.template_id, this.#headers);
679
+ return await this.assetsApi.downloadTemplateAssets(templateInfo.id, this.#headers);
680
+ }
681
+ else {
682
+ if (pageInfo.template) {
683
+ return await this.assetsApi.downloadTemplateAssets(pageInfo.template, this.#headers);
684
+ }
540
685
  }
541
686
  }
542
687
  }
@@ -548,8 +693,14 @@ class MiAPI {
548
693
  }
549
694
  else {
550
695
  const pageInfo = await this.pageApi.get(this.portalPageId, this.#headers);
551
- if (pageInfo.template) {
552
- return await this.assetsApi.uploadTemplateAssets(pageInfo.template, assets, this.#headers);
696
+ if (this.#isV710OrHigher) {
697
+ const templateInfo = await this.pageTemplateApi.get(pageInfo.template_id, this.#headers);
698
+ return await this.assetsApi.uploadTemplateAssets(templateInfo.id, assets, this.#headers);
699
+ }
700
+ else {
701
+ if (pageInfo.template) {
702
+ return await this.assetsApi.uploadTemplateAssets(pageInfo.template, assets, this.#headers);
703
+ }
553
704
  }
554
705
  }
555
706
  }
@@ -586,6 +737,24 @@ class ClientService {
586
737
  async onTemplateSync() {
587
738
  if (this.opts.distService && this.opts.miAPI) {
588
739
  const { distService, miAPI } = this.opts;
740
+ if (this.server.config.clientInjectionPlugin?.v7Features) {
741
+ if (!miAPI?.isV710OrHigher) {
742
+ this.server.ws.send('template:sync:response', {
743
+ error: 'This feature is available only for MI v7.1.0 or higher',
744
+ config: {
745
+ canSync: false,
746
+ },
747
+ });
748
+ return;
749
+ }
750
+ else {
751
+ this.server.ws.send('client:config:update', {
752
+ config: {
753
+ canSync: true,
754
+ },
755
+ });
756
+ }
757
+ }
589
758
  const currentAssets = await miAPI?.getAssets();
590
759
  const newAssets = currentAssets
591
760
  ? await distService?.saveBackupAndBuild(currentAssets)
@@ -676,7 +845,7 @@ function initProxyCache(opts) {
676
845
 
677
846
  const TEMPLATE_PART_PAGE_NAME = 'pageName';
678
847
  const TEMPLATE_PART_DATE = 'date';
679
- const DIRNAME = path__namespace.dirname((typeof __filename !== 'undefined' && __filename) || url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-DRnpagNh.js', document.baseURI).href))));
848
+ const DIRNAME = path__namespace.dirname((typeof __filename !== 'undefined' && __filename) || url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('plugin-DZS4Taov.js', document.baseURI).href))));
680
849
  const pluginPath = path__namespace.resolve(DIRNAME, '..', '..');
681
850
  const node_modules_path = path__namespace.resolve(pluginPath, '..', '..');
682
851
  const metaDirName = '.pp-dev-meta';
@@ -786,7 +955,7 @@ class DistService {
786
955
  this.logger.info(colors.cyan('[DistService] Build started'));
787
956
  const proc = child_process__namespace.spawn('node', [path__namespace.resolve(pluginPath, './bin/pp-dev.js'), 'build'], {
788
957
  cwd: process__namespace.cwd(),
789
- env: process__namespace.env,
958
+ env: Object.assign({}, process__namespace.env, { NODE_ENV: 'production' }),
790
959
  stdio: 'inherit',
791
960
  });
792
961
  proc.on('message', (msg) => {
@@ -894,6 +1063,7 @@ function initPPRedirect(base, templateName) {
894
1063
  const findPaths = ['/', baseWithoutTrailingSlash];
895
1064
  if (templateName) {
896
1065
  findPaths.push(`/pt/${templateName}`);
1066
+ findPaths.push(`/pl/${templateName}`);
897
1067
  }
898
1068
  // Redirect from `/` and `/pt/${templateName}` and `${base}` (without a training slash) to portal page address
899
1069
  if (findPaths.includes(pathname)) {
@@ -953,7 +1123,8 @@ function isVitePPDevOptions(options) {
953
1123
  options.imageOptimizer === undefined) &&
954
1124
  (typeof options.outDir === 'string' || options.outDir === undefined) &&
955
1125
  (typeof options.distZip === 'boolean' || typeof options.distZip === 'object' || options.distZip === undefined) &&
956
- (typeof options.syncBackupsDir === 'string' || options.syncBackupsDir === undefined));
1126
+ (typeof options.syncBackupsDir === 'string' || options.syncBackupsDir === undefined) &&
1127
+ (typeof options.v7Features === 'boolean' || options.v7Features === undefined));
957
1128
  }
958
1129
  function throwConfigError(config) {
959
1130
  if (typeof config !== 'object') {
@@ -997,10 +1168,13 @@ function throwConfigError(config) {
997
1168
  if (config.syncBackupsDir !== undefined && typeof config.syncBackupsDir !== 'string') {
998
1169
  throw new Error('VitePPDevOptions.syncBackupsDir must be a string');
999
1170
  }
1171
+ if (config.v7Features !== undefined && typeof config.v7Features !== 'boolean') {
1172
+ throw new Error('VitePPDevOptions.v7Features must be a boolean');
1173
+ }
1000
1174
  }
1001
1175
  function normalizeVitePPDevConfig(config) {
1002
1176
  !isVitePPDevOptions(config) && throwConfigError(config);
1003
- const { enableProxyCache = true, proxyCacheTTL = 10 * 60 * 1000, disableSSLValidation = false, imageOptimizer = true, miHudLess = false, templateLess = false, outDir = 'dist', distZip = true, syncBackupsDir = 'backups', } = config || {};
1177
+ const { enableProxyCache = true, proxyCacheTTL = 10 * 60 * 1000, disableSSLValidation = false, imageOptimizer = true, miHudLess = false, templateLess = false, outDir = 'dist', distZip = true, syncBackupsDir = 'backups', v7Features = false, } = config || {};
1004
1178
  let distZipConfig = distZip;
1005
1179
  if (distZipConfig === true) {
1006
1180
  distZipConfig = {
@@ -1038,11 +1212,12 @@ function normalizeVitePPDevConfig(config) {
1038
1212
  outDir,
1039
1213
  distZip: distZipConfig,
1040
1214
  syncBackupsDir,
1215
+ v7Features,
1041
1216
  ...config,
1042
1217
  };
1043
1218
  }
1044
1219
  function vitePPDev(options) {
1045
- const { templateName, templateLess, backendBaseURL, miHudLess, portalPageId, enableProxyCache, proxyCacheTTL, disableSSLValidation, distZip, syncBackupsDir, } = options || {};
1220
+ const { templateName, templateLess, backendBaseURL, miHudLess, portalPageId, enableProxyCache, proxyCacheTTL, disableSSLValidation, distZip, syncBackupsDir, v7Features, } = options || {};
1046
1221
  // Avoid server caching for index.html file when first loading
1047
1222
  let isFirstRequest = true;
1048
1223
  process.cwd();
@@ -1050,7 +1225,10 @@ function vitePPDev(options) {
1050
1225
  name: 'vite-pp-dev',
1051
1226
  apply: 'serve',
1052
1227
  config: (config) => {
1053
- config.clientInjectionPlugin = { backendBaseURL, portalPageId, templateLess };
1228
+ config.clientInjectionPlugin = { backendBaseURL, portalPageId, templateLess, v7Features };
1229
+ if (v7Features) {
1230
+ config.base = `/pl/${templateName}`;
1231
+ }
1054
1232
  if (config.root) {
1055
1233
  config.root;
1056
1234
  }
@@ -1086,6 +1264,7 @@ function vitePPDev(options) {
1086
1264
  portalPageId,
1087
1265
  templateLess,
1088
1266
  disableSSLValidation,
1267
+ v7Features,
1089
1268
  });
1090
1269
  if (enableProxyCache) {
1091
1270
  let ttl = +proxyCacheTTL;
@@ -1133,4 +1312,4 @@ exports.initRewriteResponse = initRewriteResponse;
1133
1312
  exports.normalizeVitePPDevConfig = normalizeVitePPDevConfig;
1134
1313
  exports.urlReplacer = urlReplacer;
1135
1314
  exports.vitePPDev = vitePPDev;
1136
- //# sourceMappingURL=plugin-DRnpagNh.js.map
1315
+ //# sourceMappingURL=plugin-DZS4Taov.js.map