@hubspot/cms-dev-server 0.13.10 → 0.13.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/index.js +0 -2
  2. package/dist/internalSsr.js +20 -11
  3. package/dist/run.js +77 -36
  4. package/dist/storybook/index.js +4 -2
  5. package/dist/storybook-main/main.js +20 -11
  6. package/package.json +3 -3
  7. package/dist/fsevents-72LCIACT.node +0 -0
  8. package/types/components/ModulesList.d.ts +0 -5
  9. package/types/components/PartialsList.d.ts +0 -4
  10. package/types/generateBpmAliases.d.ts +0 -2
  11. package/types/lib/debug.d.ts +0 -1
  12. package/types/lib/fetchModuleGraphQLData.d.ts +0 -24
  13. package/types/lib/fullOriginalUrlFromRequest.d.ts +0 -5
  14. package/types/lib/locals.d.ts +0 -10
  15. package/types/lib/logColors.d.ts +0 -6
  16. package/types/lib/moduleGraph.d.ts +0 -1
  17. package/types/lib/packagePath.d.ts +0 -1
  18. package/types/lib/pathHelpers.d.ts +0 -3
  19. package/types/lib/proxyHelpers.d.ts +0 -20
  20. package/types/lib/renderComponentWithCSS.d.ts +0 -14
  21. package/types/lib/renderHelpers.d.ts +0 -1
  22. package/types/lib/renderModule.d.ts +0 -6
  23. package/types/lib/renderPartial.d.ts +0 -5
  24. package/types/lib/templates.d.ts +0 -4
  25. package/types/lib/trackUsage.d.ts +0 -3
  26. package/types/lib/urlFromRequest.d.ts +0 -3
  27. package/types/noNodeBuiltinsPlugin.d.ts +0 -3
  28. package/types/plugins/componentRoutesPlugin.d.ts +0 -3
  29. package/types/plugins/internalAppPlugin.d.ts +0 -2
  30. package/types/plugins/jsRenderingPlugin.d.ts +0 -2
  31. package/types/plugins/localProxyPlugin.d.ts +0 -3
  32. package/types/plugins/sslPlugin.d.ts +0 -2
  33. package/types/plugins/storybookPlugin.d.ts +0 -6
  34. package/types/proxyPage/constants.d.ts +0 -1
  35. package/types/proxyPage/fetchContentMetadata.d.ts +0 -7
  36. package/types/proxyPage/fetchPreviewInfo.d.ts +0 -6
  37. package/types/proxyPage/proxyPage.d.ts +0 -7
  38. package/types/proxyPage/renderLocalError.d.ts +0 -2
  39. package/types/proxyPage/utils.d.ts +0 -4
  40. package/types/resolveSharedDeps.d.ts +0 -2
  41. package/types/routes/createDevServerRoutes.d.ts +0 -3
  42. package/types/routes/homeRouteHandler.d.ts +0 -7
  43. package/types/routes/linksToAllModulesRouteHandler.d.ts +0 -2
  44. package/types/routes/linksToAllPartialsRouteHandler.d.ts +0 -2
  45. package/types/routes/module.d.ts +0 -21
  46. package/types/routes/partial.d.ts +0 -21
  47. package/types/routes/proxyPageResourceRedirect.d.ts +0 -5
  48. package/types/routes/proxyPageRouteHandler.d.ts +0 -11
  49. package/types/routes/proxyPathPageResourceRedirect.d.ts +0 -2
  50. package/types/routes/proxyPathPageRouteHandler.d.ts +0 -13
package/dist/index.js CHANGED
@@ -79,7 +79,6 @@ function clientIslandEntryPlugin() {
79
79
  // src/createViteDevServer.ts
80
80
  import { default as mkcert } from "vite-plugin-mkcert";
81
81
  import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
82
- import { default as Inspect } from "vite-plugin-inspect";
83
82
 
84
83
  // src/plugins/devSecretsPlugin.ts
85
84
  function devSecretsPlugin(secretNames) {
@@ -153,7 +152,6 @@ Custom origin: ${process.env.VITE_ORIGIN}
153
152
  clientIslandEntryPlugin(),
154
153
  resolveIslandPlugin(),
155
154
  jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
156
- Inspect(),
157
155
  devSecretsPlugin(secretNames)
158
156
  ],
159
157
  css: {
@@ -87,7 +87,7 @@ function escapeChar(unsafeChar) {
87
87
  function escapeForInlineJS(input) {
88
88
  return input.replace(badInlineJsChars, escapeChar);
89
89
  }
90
- function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
90
+ function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true } = {}) {
91
91
  const indentString = " ".repeat(baseIndent);
92
92
  jsonIndent = prettyPrint ? jsonIndent : void 0;
93
93
  return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
@@ -147,11 +147,10 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, pre
147
147
  sharedStateIDs.forEach(
148
148
  (id) => stateByID[id] = perServerRequestData.get(id)
149
149
  );
150
- const stringifiedState = JSON.stringify(
151
- stateByID,
152
- null,
153
- prettyPrint ? 2 : void 0
154
- );
150
+ const stringifiedState = jsonStringifyAndEscapeForInlineJS(stateByID, {
151
+ prettyPrint,
152
+ jsonIndent: 2
153
+ });
155
154
  return `
156
155
 
157
156
  var newState = ${stringifiedState};
@@ -526,17 +525,25 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
526
525
  );
527
526
  const globals = [`window.__hsEnvConfig = ${serializedJson};`];
528
527
  if (hsServerPageUrl) {
529
- globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
528
+ globals.push(
529
+ `window.__hsServerPageUrl = ${jsonStringifyAndEscapeForInlineJS(
530
+ hsServerPageUrl
531
+ )};`
532
+ );
530
533
  }
531
534
  if (hsBasePath) {
532
- globals.push(`window.__hsBasePath = '${hsBasePath}';`);
535
+ globals.push(
536
+ `window.__hsBasePath = ${jsonStringifyAndEscapeForInlineJS(hsBasePath)};`
537
+ );
533
538
  }
534
539
  if (!environmentConfig.getIsDeployed() && (criticalDevErrors == null ? void 0 : criticalDevErrors.length)) {
535
540
  const firstCriticalDevError = criticalDevErrors[0];
536
541
  globals.push(`
537
542
  customElements.whenDefined('vite-error-overlay').then(() => {
538
543
  const ErrorOverlay = customElements.get('vite-error-overlay');
539
- const error = new Error("${firstCriticalDevError.message}");
544
+ const error = new Error(${jsonStringifyAndEscapeForInlineJS(
545
+ firstCriticalDevError.message
546
+ )});
540
547
  const overlay = new ErrorOverlay(error);
541
548
 
542
549
  document.body.appendChild(overlay);
@@ -555,7 +562,8 @@ function namespaceModulePropsShape(props) {
555
562
  hublParameters,
556
563
  fieldValues: passedFieldValues,
557
564
  hublData,
558
- experimentalHublData
565
+ experimentalHublData,
566
+ moduleName
559
567
  } = props;
560
568
  const oldPropsShape = { ...props };
561
569
  if (oldPropsShape.dataQueryResult) {
@@ -571,7 +579,8 @@ function namespaceModulePropsShape(props) {
571
579
  fieldValues,
572
580
  hublParameters,
573
581
  hublData,
574
- experimentalHublData
582
+ experimentalHublData,
583
+ moduleName
575
584
  };
576
585
  }
577
586
  function setIn(object, nestedKeysArray, value) {
package/dist/run.js CHANGED
@@ -153,7 +153,7 @@ function escapeChar(unsafeChar) {
153
153
  function escapeForInlineJS(input) {
154
154
  return input.replace(badInlineJsChars, escapeChar);
155
155
  }
156
- function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
156
+ function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true } = {}) {
157
157
  const indentString = " ".repeat(baseIndent);
158
158
  jsonIndent = prettyPrint ? jsonIndent : void 0;
159
159
  return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
@@ -213,11 +213,10 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, pre
213
213
  sharedStateIDs.forEach(
214
214
  (id) => stateByID[id] = perServerRequestData.get(id)
215
215
  );
216
- const stringifiedState = JSON.stringify(
217
- stateByID,
218
- null,
219
- prettyPrint ? 2 : void 0
220
- );
216
+ const stringifiedState = jsonStringifyAndEscapeForInlineJS(stateByID, {
217
+ prettyPrint,
218
+ jsonIndent: 2
219
+ });
221
220
  return `
222
221
 
223
222
  var newState = ${stringifiedState};
@@ -547,17 +546,25 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
547
546
  );
548
547
  const globals = [`window.__hsEnvConfig = ${serializedJson};`];
549
548
  if (hsServerPageUrl) {
550
- globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
549
+ globals.push(
550
+ `window.__hsServerPageUrl = ${jsonStringifyAndEscapeForInlineJS(
551
+ hsServerPageUrl
552
+ )};`
553
+ );
551
554
  }
552
555
  if (hsBasePath) {
553
- globals.push(`window.__hsBasePath = '${hsBasePath}';`);
556
+ globals.push(
557
+ `window.__hsBasePath = ${jsonStringifyAndEscapeForInlineJS(hsBasePath)};`
558
+ );
554
559
  }
555
560
  if (!environmentConfig.getIsDeployed() && (criticalDevErrors == null ? void 0 : criticalDevErrors.length)) {
556
561
  const firstCriticalDevError = criticalDevErrors[0];
557
562
  globals.push(`
558
563
  customElements.whenDefined('vite-error-overlay').then(() => {
559
564
  const ErrorOverlay = customElements.get('vite-error-overlay');
560
- const error = new Error("${firstCriticalDevError.message}");
565
+ const error = new Error(${jsonStringifyAndEscapeForInlineJS(
566
+ firstCriticalDevError.message
567
+ )});
561
568
  const overlay = new ErrorOverlay(error);
562
569
 
563
570
  document.body.appendChild(overlay);
@@ -576,7 +583,8 @@ function namespaceModulePropsShape(props) {
576
583
  hublParameters,
577
584
  fieldValues: passedFieldValues,
578
585
  hublData,
579
- experimentalHublData
586
+ experimentalHublData,
587
+ moduleName
580
588
  } = props;
581
589
  const oldPropsShape = { ...props };
582
590
  if (oldPropsShape.dataQueryResult) {
@@ -592,7 +600,8 @@ function namespaceModulePropsShape(props) {
592
600
  fieldValues,
593
601
  hublParameters,
594
602
  hublData,
595
- experimentalHublData
603
+ experimentalHublData,
604
+ moduleName
596
605
  };
597
606
  }
598
607
  function setIn(object, nestedKeysArray, value) {
@@ -954,7 +963,7 @@ function trackUsage(action) {
954
963
  eventName: EVENT_NAME,
955
964
  action,
956
965
  nodeVersion: getNodeVersionData(),
957
- version: "0.13.10",
966
+ version: "0.13.11",
958
967
  os: getPlatform()
959
968
  };
960
969
  const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1233,7 +1242,8 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
1233
1242
  fieldValues: fieldOverrides = {},
1234
1243
  hublParameters,
1235
1244
  experimentalHublData,
1236
- hublData
1245
+ hublData,
1246
+ moduleName
1237
1247
  } = moduleProps;
1238
1248
  const ungatedForServerSideProps = isUngatedFor(
1239
1249
  environmentConfig.getGates(),
@@ -1305,7 +1315,8 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
1305
1315
  hublParameters,
1306
1316
  dataQueryResult,
1307
1317
  experimentalHublData,
1308
- hublData
1318
+ hublData,
1319
+ moduleName
1309
1320
  });
1310
1321
  if (ungatedForServerSideProps && componentModule.getServerSideProps) {
1311
1322
  try {
@@ -1399,7 +1410,11 @@ var moduleRouteHandler = async (request2, response) => {
1399
1410
  } = await renderModule_default(
1400
1411
  viteServer,
1401
1412
  modulePath,
1402
- { fieldValues: fieldOverrides, hublParameters: {} },
1413
+ {
1414
+ fieldValues: fieldOverrides,
1415
+ hublParameters: {},
1416
+ moduleName: `local-${moduleName}`
1417
+ },
1403
1418
  fullOriginalUrlFromRequest(request2),
1404
1419
  basePath,
1405
1420
  environmentConfig,
@@ -1776,14 +1791,17 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
1776
1791
  }
1777
1792
  return placeholderPath;
1778
1793
  }
1779
- var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, __jsRenderingGates) => {
1794
+ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates) => {
1780
1795
  const url3 = new URL(urlToProxy);
1781
- console.log(`Proxying request to ${url3.href}`, {
1782
- previewKey,
1783
- contentId
1784
- });
1796
+ const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
1785
1797
  let proxiedQueryParams = {};
1786
- for (const queryKey of url3.searchParams.keys()) {
1798
+ let baseUrl = url3.origin;
1799
+ let pathname = url3.pathname;
1800
+ const PARAMS_TO_IGNORE = ["renderPreviewLocally"];
1801
+ const queryKeys = Array.from(url3.searchParams.keys()).filter(
1802
+ (queryKey) => !PARAMS_TO_IGNORE.includes(queryKey)
1803
+ );
1804
+ for (const queryKey of queryKeys) {
1787
1805
  const values = url3.searchParams.getAll(queryKey);
1788
1806
  if (values.length > 1) {
1789
1807
  proxiedQueryParams[queryKey] = values;
@@ -1796,11 +1814,23 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
1796
1814
  ...proxiedQueryParams,
1797
1815
  hs_preview: `${previewKey}-${contentId}`,
1798
1816
  hsLocalProxyProject: localProxyProject,
1799
- localProxySchemaVersion: 1
1817
+ localProxySchemaVersion: "1"
1800
1818
  };
1819
+ if (renderPreviewLocally) {
1820
+ proxiedQueryParams.hsDebugOverridePublicHost = url3.host;
1821
+ baseUrl = `http://local.hubspot${environmentConfig.getInternalHSEnv() === "qa" ? "qa" : ""}.com`;
1822
+ pathname = `/cos-rendering/v1/public${url3.pathname}`;
1823
+ }
1824
+ console.log(
1825
+ `Proxying request to ${baseUrl}${pathname}?${new URLSearchParams({
1826
+ ...proxiedQueryParams,
1827
+ previewKey,
1828
+ contentId
1829
+ }).toString()}`
1830
+ );
1801
1831
  const result = hsGet3(accountId, {
1802
- baseUrl: url3.origin,
1803
- uri: url3.pathname,
1832
+ baseUrl,
1833
+ uri: pathname,
1804
1834
  query: proxiedQueryParams,
1805
1835
  json: false,
1806
1836
  useQuerystring: true
@@ -1948,19 +1978,20 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
1948
1978
  try {
1949
1979
  const previewInfo = await fetchPreviewInfo_default(accountId, portalId, contentId);
1950
1980
  const { previewKey } = previewInfo;
1981
+ const environmentConfig = buildStaticEnvConfig3(
1982
+ portalId,
1983
+ hublet,
1984
+ proxyEnv,
1985
+ false,
1986
+ jsRenderingGates
1987
+ );
1951
1988
  const pageHtml = await makeProxyPreviewRequest(
1952
1989
  accountId,
1953
1990
  urlToProxy,
1954
1991
  previewKey,
1955
1992
  contentId,
1956
1993
  projectName,
1957
- jsRenderingGates
1958
- );
1959
- const environmentConfig = buildStaticEnvConfig3(
1960
- portalId,
1961
- hublet,
1962
- proxyEnv,
1963
- false,
1994
+ environmentConfig,
1964
1995
  jsRenderingGates
1965
1996
  );
1966
1997
  const { sortIslandRootsByPriority } = await viteServer.ssrLoadModule(
@@ -2378,8 +2409,9 @@ import express from "express";
2378
2409
 
2379
2410
  // src/shadowDevServer/createShadowDevServerRoutes.ts
2380
2411
  import { Router as Router2 } from "express";
2381
- import { getAccountId as getAccountId3 } from "@hubspot/cli-lib/lib/config.js";
2412
+ import { getAccountId as getAccountId3, getEnv as getEnv2 } from "@hubspot/cli-lib/lib/config.js";
2382
2413
  import cors from "cors";
2414
+ import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
2383
2415
  function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
2384
2416
  return async function shadowDevServerCheckHandler(request2, response) {
2385
2417
  const { query } = request2;
@@ -2393,6 +2425,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
2393
2425
  } = query;
2394
2426
  const pageUrl = `${protocol}//${hostName}${pathName}`;
2395
2427
  const portalId = parseInt(portalIdString, 10);
2428
+ let proxyEnv;
2396
2429
  let accountId;
2397
2430
  let hasJSBuildingBlocks = false;
2398
2431
  let localProxyUrl;
@@ -2401,6 +2434,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
2401
2434
  if (accountId === null) {
2402
2435
  throw new Error();
2403
2436
  }
2437
+ proxyEnv = getEnv2(accountId);
2404
2438
  } catch (e) {
2405
2439
  response.status(500).end(
2406
2440
  `Unable to find account for hubid = ${portalId}. Please check your hubspot.config.yaml`
@@ -2414,12 +2448,21 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
2414
2448
  contentId
2415
2449
  );
2416
2450
  const { previewKey } = previewInfo;
2451
+ const environmentConfig = buildStaticEnvConfig4(
2452
+ portalId,
2453
+ "na1",
2454
+ // bad lazy TF (but does it really matter for this check)
2455
+ proxyEnv,
2456
+ false,
2457
+ gates
2458
+ );
2417
2459
  const pageHtml = await makeProxyPreviewRequest(
2418
2460
  accountId,
2419
2461
  pageUrl,
2420
2462
  previewKey,
2421
2463
  contentId,
2422
2464
  projectName,
2465
+ environmentConfig,
2423
2466
  gates
2424
2467
  );
2425
2468
  const localRenderPlaceholders = findLocalRenderPlaceholders(pageHtml);
@@ -2496,7 +2539,6 @@ import { createServer as createViteServer } from "vite";
2496
2539
  import { default as react } from "@vitejs/plugin-react";
2497
2540
  import { default as mkcert } from "vite-plugin-mkcert";
2498
2541
  import { viteCommonjs } from "@originjs/vite-plugin-commonjs";
2499
- import { default as Inspect } from "vite-plugin-inspect";
2500
2542
 
2501
2543
  // src/plugins/devSecretsPlugin.ts
2502
2544
  function devSecretsPlugin(secretNames) {
@@ -2570,7 +2612,6 @@ Custom origin: ${process.env.VITE_ORIGIN}
2570
2612
  clientIslandEntryPlugin(),
2571
2613
  resolveIslandPlugin(),
2572
2614
  jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
2573
- Inspect(),
2574
2615
  devSecretsPlugin(secretNames)
2575
2616
  ],
2576
2617
  css: {
@@ -2654,7 +2695,7 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
2654
2695
 
2655
2696
  // src/createDevServer.ts
2656
2697
  import {
2657
- getEnv as getEnv2,
2698
+ getEnv as getEnv3,
2658
2699
  getAccountId as getAccountId4,
2659
2700
  getAccountConfig as getAccountConfig2,
2660
2701
  loadConfig,
@@ -2758,7 +2799,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
2758
2799
  }
2759
2800
  if (validateConfig()) {
2760
2801
  authedPortalId = getAccountId4(hubspotCliAccountNameOption2);
2761
- authedEnv = getEnv2(hubspotCliAccountNameOption2);
2802
+ authedEnv = getEnv3(hubspotCliAccountNameOption2);
2762
2803
  personalAccessKey = getAccountConfig2(authedPortalId) && getAccountConfig2(authedPortalId).personalAccessKey;
2763
2804
  if (!authedPortalId && hubspotCliAccountNameOption2) {
2764
2805
  console.error(
@@ -10,7 +10,8 @@ function namespaceModulePropsShape(props) {
10
10
  hublParameters,
11
11
  fieldValues: passedFieldValues,
12
12
  hublData,
13
- experimentalHublData
13
+ experimentalHublData,
14
+ moduleName
14
15
  } = props;
15
16
  const oldPropsShape = { ...props };
16
17
  if (oldPropsShape.dataQueryResult) {
@@ -26,7 +27,8 @@ function namespaceModulePropsShape(props) {
26
27
  fieldValues,
27
28
  hublParameters,
28
29
  hublData,
29
- experimentalHublData
30
+ experimentalHublData,
31
+ moduleName
30
32
  };
31
33
  }
32
34
  function renderFieldsJSX(fieldsJSX) {
@@ -91,7 +91,7 @@ function escapeChar(unsafeChar) {
91
91
  function escapeForInlineJS(input) {
92
92
  return input.replace(badInlineJsChars, escapeChar);
93
93
  }
94
- function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
94
+ function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true } = {}) {
95
95
  const indentString = " ".repeat(baseIndent);
96
96
  jsonIndent = prettyPrint ? jsonIndent : void 0;
97
97
  return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
@@ -306,17 +306,25 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
306
306
  );
307
307
  const globals = [`window.__hsEnvConfig = ${serializedJson};`];
308
308
  if (hsServerPageUrl) {
309
- globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
309
+ globals.push(
310
+ `window.__hsServerPageUrl = ${jsonStringifyAndEscapeForInlineJS(
311
+ hsServerPageUrl
312
+ )};`
313
+ );
310
314
  }
311
315
  if (hsBasePath) {
312
- globals.push(`window.__hsBasePath = '${hsBasePath}';`);
316
+ globals.push(
317
+ `window.__hsBasePath = ${jsonStringifyAndEscapeForInlineJS(hsBasePath)};`
318
+ );
313
319
  }
314
320
  if (!environmentConfig.getIsDeployed() && (criticalDevErrors == null ? void 0 : criticalDevErrors.length)) {
315
321
  const firstCriticalDevError = criticalDevErrors[0];
316
322
  globals.push(`
317
323
  customElements.whenDefined('vite-error-overlay').then(() => {
318
324
  const ErrorOverlay = customElements.get('vite-error-overlay');
319
- const error = new Error("${firstCriticalDevError.message}");
325
+ const error = new Error(${jsonStringifyAndEscapeForInlineJS(
326
+ firstCriticalDevError.message
327
+ )});
320
328
  const overlay = new ErrorOverlay(error);
321
329
 
322
330
  document.body.appendChild(overlay);
@@ -335,7 +343,8 @@ function namespaceModulePropsShape(props) {
335
343
  hublParameters,
336
344
  fieldValues: passedFieldValues,
337
345
  hublData,
338
- experimentalHublData
346
+ experimentalHublData,
347
+ moduleName
339
348
  } = props;
340
349
  const oldPropsShape = { ...props };
341
350
  if (oldPropsShape.dataQueryResult) {
@@ -351,7 +360,8 @@ function namespaceModulePropsShape(props) {
351
360
  fieldValues,
352
361
  hublParameters,
353
362
  hublData,
354
- experimentalHublData
363
+ experimentalHublData,
364
+ moduleName
355
365
  };
356
366
  }
357
367
  function setIn(object, nestedKeysArray, value) {
@@ -514,11 +524,10 @@ var init_dist = __esm({
514
524
  sharedStateIDs.forEach(
515
525
  (id) => stateByID[id] = perServerRequestData.get(id)
516
526
  );
517
- const stringifiedState = JSON.stringify(
518
- stateByID,
519
- null,
520
- prettyPrint ? 2 : void 0
521
- );
527
+ const stringifiedState = jsonStringifyAndEscapeForInlineJS(stateByID, {
528
+ prettyPrint,
529
+ jsonIndent: 2
530
+ });
522
531
  return `
523
532
 
524
533
  var newState = ${stringifiedState};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.13.10",
3
+ "version": "0.13.11",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -25,7 +25,7 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "@hubspot/cli-lib": "^3.0.12",
28
- "@hubspot/cms-components": "^0.13.10",
28
+ "@hubspot/cms-components": "^0.13.11",
29
29
  "@originjs/vite-plugin-commonjs": "^1.0.3",
30
30
  "@storybook/addon-actions": "7.0.7",
31
31
  "@storybook/addon-essentials": "7.0.7",
@@ -101,5 +101,5 @@
101
101
  "publishConfig": {
102
102
  "access": "public"
103
103
  },
104
- "gitHead": "c8ff20a597765fb49fa33bcea9efea4dc58f2998"
104
+ "gitHead": "c4fd8b2c94dd02f14f0ec26c1d4d9ff30e937d1c"
105
105
  }
Binary file
@@ -1,5 +0,0 @@
1
- declare function ModulesList({ webRoot, moduleNames }: {
2
- webRoot: any;
3
- moduleNames: any;
4
- }): JSX.Element;
5
- export default ModulesList;
@@ -1,4 +0,0 @@
1
- export default function PartialsList({ webRoot, partialNames }: {
2
- webRoot: any;
3
- partialNames: any;
4
- }): JSX.Element;
@@ -1,2 +0,0 @@
1
- import { Alias } from 'vite';
2
- export default function generateBpmAliases(webRoot: string): Alias[];
@@ -1 +0,0 @@
1
- export declare const debug: any;
@@ -1,24 +0,0 @@
1
- declare type DataQueryPoints = {
2
- count: number;
3
- weight: number;
4
- used_points: number;
5
- };
6
- declare type DataQueryResult = {
7
- extensions: {
8
- query_complexity: {
9
- max_points: number;
10
- used_points: number;
11
- points_for_internal_api_requests: DataQueryPoints;
12
- points_for_objects_retrieved: DataQueryPoints;
13
- points_for_properties_with_value: DataQueryPoints;
14
- points_for_properties_without_value: DataQueryPoints;
15
- };
16
- };
17
- data?: {
18
- CRM?: any;
19
- HUBDB?: any;
20
- };
21
- };
22
- export declare function clearGraphQLDataCache(): void;
23
- export default function fetchModuleGraphQLData(accountId: number, query: string, requestedModulePath: string, pageUrl: string): Promise<DataQueryResult>;
24
- export {};
@@ -1,5 +0,0 @@
1
- export default function fullOriginalUrlFromRequest(request: {
2
- protocol: string;
3
- host: string;
4
- originalUrl: string;
5
- }): string;
@@ -1,10 +0,0 @@
1
- import { HSEnvironment, Hublet } from '@hubspot/cms-components';
2
- import { Gate } from '@hubspot/cms-js-internal';
3
- export declare type Locals = {
4
- authedPortalId: number;
5
- authedEnv: HSEnvironment;
6
- authedHublet: Hublet;
7
- jsRenderingGates: Gate[];
8
- projectName: string;
9
- projectComponentPath: string;
10
- };
@@ -1,6 +0,0 @@
1
- declare type ColorMap = {
2
- [key: string]: number;
3
- };
4
- export declare const ForeGroudANSIColorMap: ColorMap;
5
- export declare function wrapMessageInColor(color: string, message: string): string;
6
- export {};
@@ -1 +0,0 @@
1
- export declare const findFullPathInModuleGraph: (modulePathNoExtension: string, moduleGraph: any) => string | void;
@@ -1 +0,0 @@
1
- export default function packagePath(metaUrl: string, projectPath: string): string;
@@ -1,3 +0,0 @@
1
- import { ViteDevServer } from 'vite';
2
- export declare const getComponentPaths: (viteServer: ViteDevServer, componentPath: string) => [componentPathNoExtension: string, componentPathWithExtension: string];
3
- export declare const getEntryPointBasePath: (componentPath: string) => string;
@@ -1,20 +0,0 @@
1
- import { ModuleProps } from '@hubspot/cms-components';
2
- declare type BaseJson = {
3
- props: Record<string, any>;
4
- request: Record<string, any>;
5
- };
6
- export interface LocalRenderBlockInfo {
7
- startOffset: number;
8
- endOffset: number;
9
- path: string;
10
- json: BaseJson;
11
- }
12
- export declare type LocalModuleRenderPlaceholderProps = ModuleProps & Record<string, any>;
13
- export interface LocalModuleRenderBlockInfo extends LocalRenderBlockInfo {
14
- json: {
15
- props: LocalModuleRenderPlaceholderProps;
16
- } & BaseJson;
17
- }
18
- export declare const findLocalRenderPlaceholders: (body: string) => Array<LocalRenderBlockInfo>;
19
- export declare const getProjectNameFromHSConfig: (hsProjectConfigPath: any) => any;
20
- export {};
@@ -1,14 +0,0 @@
1
- import { ViteDevServer } from 'vite';
2
- import { ComponentType } from 'react';
3
- import { RenderToPipeableStreamOptions } from 'react-dom/server';
4
- import { ServerRenderContextValue } from '@hubspot/cms-components';
5
- import { EnvironmentConfig } from '@hubspot/cms-components/config';
6
- import { InlineAsset } from '@hubspot/cms-js-internal';
7
- export declare type RenderResult = {
8
- html: string;
9
- inlineAssets?: InlineAsset[];
10
- cssNeeded: string;
11
- renderContext: ServerRenderContextValue;
12
- };
13
- declare function renderComponentWithCSS(viteServer: ViteDevServer, componentPath: string, Component: ComponentType, props: any, pageUrl: string, entryPointBasePath: string, environmentConfig: EnvironmentConfig, renderOptions: RenderToPipeableStreamOptions): Promise<RenderResult>;
14
- export default renderComponentWithCSS;
@@ -1 +0,0 @@
1
- export declare const logPartialInfo: (partialPath: any, props: any) => void;
@@ -1,6 +0,0 @@
1
- import { ViteDevServer } from 'vite';
2
- import { RenderToPipeableStreamOptions } from 'react-dom/server';
3
- import { EnvironmentConfig } from '@hubspot/cms-components/config';
4
- import { ModuleProps } from '@hubspot/cms-components';
5
- declare function renderModule(viteServer: ViteDevServer, requestedModulePath: string, moduleProps: ModuleProps, pageUrl: string, basePath: string, environmentConfig: EnvironmentConfig, renderOptions?: RenderToPipeableStreamOptions): Promise<import("./renderComponentWithCSS.js").RenderResult>;
6
- export default renderModule;
@@ -1,5 +0,0 @@
1
- import { EnvironmentConfig } from '@hubspot/cms-components/config';
2
- import { ViteDevServer } from 'vite';
3
- import { RenderToPipeableStreamOptions } from 'react-dom/server';
4
- declare function renderPartial(viteServer: ViteDevServer, partialPath: string, props: any, pageUrl: string, basePath: string, environmentConfig: EnvironmentConfig, renderOptions?: RenderToPipeableStreamOptions): Promise<import("./renderComponentWithCSS.js").RenderResult>;
5
- export default renderPartial;
@@ -1,4 +0,0 @@
1
- import { ViteDevServer } from 'vite';
2
- import { ServerRenderContextValue } from '@hubspot/cms-components';
3
- export declare const createHtmlShellDependingOnRenderContext: (baseTemplatePath: string, url: string, title: string, renderContext: ServerRenderContextValue, viteServer: ViteDevServer, __jsRenderingGates: string[]) => Promise<string>;
4
- export declare const getIslandRuntimeAndGlobalToInject: (sortedIslandRoots: any, perServerRequestData: any, viteServer: ViteDevServer, __gates: string[], prettyPrint: boolean) => Promise<string>;
@@ -1,3 +0,0 @@
1
- import { HSEnvironment } from '@hubspot/cms-components';
2
- export declare const setTrackingInfo: (accountId: number | null, env: HSEnvironment | null) => void;
3
- export default function sendTrackingRequest(action: string): void;
@@ -1,3 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { IncomingMessage } from 'http';
3
- export default function urlFromRequest(request: IncomingMessage): URL;
@@ -1,3 +0,0 @@
1
- import { Plugin } from 'vite';
2
- declare const noNodeBuiltinsPlugin: () => Plugin;
3
- export default noNodeBuiltinsPlugin;
@@ -1,3 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- import { Locals } from '../lib/locals.js';
3
- export default function componentRoutesPlugin(locals: Locals): PluginOption;
@@ -1,2 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- export default function internalAppPlugin(): PluginOption;
@@ -1,2 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- export default function jsRenderingPlugin(webRoot: string, port: number): PluginOption;
@@ -1,3 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- import { Locals } from '../lib/locals.js';
3
- export default function localProxyPlugin(locals: Locals): PluginOption;
@@ -1,2 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- export default function sslPlugin(domainsToProxy: string[]): PluginOption;
@@ -1,6 +0,0 @@
1
- import { PluginOption } from 'vite';
2
- export default function storybookPlugin(locals: {
3
- authedPortalId: number;
4
- authedEnv: string;
5
- authedHublet: string;
6
- }): PluginOption;
@@ -1 +0,0 @@
1
- export declare const VALID_PROXY_DOMAIN_SUFFIXES: string[];
@@ -1,7 +0,0 @@
1
- import { Hublet } from '@hubspot/cms-components';
2
- export declare type PortalContentIdAndHublet = {
3
- portalId: number;
4
- contentId: string;
5
- hublet: Hublet;
6
- };
7
- export default function fetchContentMetadata(url: string, portalId: number): Promise<PortalContentIdAndHublet>;
@@ -1,6 +0,0 @@
1
- export interface PreviewInfoResponse {
2
- previewDomain: string;
3
- previewKey: string;
4
- }
5
- declare const _default: (accountId: string, portalId: number, contentId: string) => Promise<PreviewInfoResponse>;
6
- export default _default;
@@ -1,7 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { ServerResponse } from 'http';
3
- import { ViteDevServer } from 'vite';
4
- import { Gate } from '@hubspot/cms-js-internal';
5
- import { Hublet } from '@hubspot/cms-components';
6
- export declare const makeProxyPreviewRequest: (accountId: string, urlToProxy: string, previewKey: string, contentId: string, projectName: string, __jsRenderingGates: Gate[]) => any;
7
- export default function proxySpecificPage(response: ServerResponse, portalId: number, hublet: Hublet, contentId: string, webRoot: string, viteServer: ViteDevServer, projectName: string, projectComponentPath: string, jsRenderingGates: Gate[], urlToProxy?: string, fullOriginalUrl?: string): Promise<void>;
@@ -1,2 +0,0 @@
1
- declare const _default: (path: string, error: Error) => string;
2
- export default _default;
@@ -1,4 +0,0 @@
1
- import { RenderResult } from '../lib/renderComponentWithCSS.js';
2
- export declare const getSubDomainFromValidLocalDomain: (hostname: any) => any;
3
- export declare const fakeRenderJsComponent: (indexForThisRender: any) => Promise<RenderResult>;
4
- export declare const consoleWarn: (message: any) => void;
@@ -1,2 +0,0 @@
1
- import { Plugin } from 'vite';
2
- export default function resolveSharedDeps(): Plugin | null;
@@ -1,3 +0,0 @@
1
- import { ViteDevServer } from 'vite';
2
- declare function createDevServerRoutes(viteServer: ViteDevServer, __storybookPort?: number): import("express-serve-static-core").Router;
3
- export default createDevServerRoutes;
@@ -1,7 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from 'http';
2
- import { ViteDevServer } from 'vite';
3
- declare const homeRouteHandler: (locals: {
4
- storybookEnabled: boolean;
5
- viteServer: ViteDevServer;
6
- }) => (__request: IncomingMessage, response: ServerResponse) => Promise<void>;
7
- export default homeRouteHandler;
@@ -1,2 +0,0 @@
1
- declare const linksToAllModuleRouteHandler: (request: any, response: any) => Promise<void>;
2
- export default linksToAllModuleRouteHandler;
@@ -1,2 +0,0 @@
1
- declare const linksToAllPartialRouteHandler: (request: any, response: any) => Promise<void>;
2
- export default linksToAllPartialRouteHandler;
@@ -1,21 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import type { IncomingMessage, ServerResponse } from 'http';
3
- import { ViteDevServer } from 'vite';
4
- import { HSEnvironment } from '@hubspot/cms-components';
5
- import { Gate } from '@hubspot/cms-js-internal';
6
- declare type RoutedRequest = IncomingMessage & {
7
- params: {
8
- [key: string]: string;
9
- };
10
- };
11
- declare const moduleRouteHandler: (locals: {
12
- authedPortalId: number;
13
- authedEnv: HSEnvironment;
14
- authedHublet: 'na1';
15
- webRoot: string;
16
- viteServer: ViteDevServer;
17
- jsRenderingGates: Gate[];
18
- projectName: string;
19
- projectComponentPath: string;
20
- }) => (request: RoutedRequest, response: ServerResponse) => Promise<void>;
21
- export default moduleRouteHandler;
@@ -1,21 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import type { IncomingMessage, ServerResponse } from 'http';
3
- import { ViteDevServer } from 'vite';
4
- import { HSEnvironment } from '@hubspot/cms-components';
5
- import { Gate } from '@hubspot/cms-js-internal';
6
- declare type RoutedRequest = IncomingMessage & {
7
- params: {
8
- [key: string]: string;
9
- };
10
- };
11
- declare const partialRouteHandler: (locals: {
12
- authedPortalId: number;
13
- authedEnv: HSEnvironment;
14
- authedHublet: 'na1';
15
- webRoot: string;
16
- viteServer: ViteDevServer;
17
- jsRenderingGates: Gate[];
18
- projectName: string;
19
- projectComponentPath: string;
20
- }) => (request: RoutedRequest, response: ServerResponse) => Promise<void>;
21
- export default partialRouteHandler;
@@ -1,5 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { IncomingMessage, ServerResponse } from 'http';
3
- export default function proxyPageResourceRedirect(req: IncomingMessage & {
4
- body?: object | string;
5
- }, res: ServerResponse, next: Function): Promise<void>;
@@ -1,11 +0,0 @@
1
- import { IncomingMessage, ServerResponse } from 'http';
2
- import { ViteDevServer } from 'vite';
3
- import { Gate } from '@hubspot/cms-js-internal';
4
- declare const _default: (locals: {
5
- viteServer: ViteDevServer;
6
- projectName: string;
7
- projectComponentPath: string;
8
- authedPortalId: number;
9
- jsRenderingGates: Gate[];
10
- }) => (request: IncomingMessage, response: ServerResponse, next: Function) => Promise<void>;
11
- export default _default;
@@ -1,2 +0,0 @@
1
- import { NextFunction, Request, Response } from 'express';
2
- export default function proxyPathPageResourceRedirect(req: Request, res: Response, next: NextFunction): void;
@@ -1,13 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { Gate } from '@hubspot/cms-js-internal';
3
- import { IncomingMessage, ServerResponse } from 'http';
4
- import { ViteDevServer } from 'vite';
5
- declare const proxyPathPageRouteHandler: (locals: {
6
- viteServer: ViteDevServer;
7
- webRoot: string;
8
- authedPortalId: number;
9
- projectName: string;
10
- projectComponentPath: string;
11
- jsRenderingGates: Gate[];
12
- }) => (request: IncomingMessage, response: ServerResponse, next: Function) => Promise<ServerResponse<IncomingMessage>>;
13
- export default proxyPathPageRouteHandler;