@hubspot/cms-dev-server 0.14.11 → 0.14.13

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.
@@ -720,7 +720,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
720
720
  })
721
721
  `);
722
722
  }
723
- const nonceAttr = includeNonces && cmsComponents.STYLE_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.STYLE_NONCE_PLACEHOLDER}"` : "";
723
+ const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
724
724
  return `
725
725
  <script type="text/javascript"${nonceAttr}>
726
726
  ${globals.join("\n ")}
@@ -133,7 +133,15 @@ function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrap
133
133
  }
134
134
  }
135
135
  function getLoadableModuleFor(root) {
136
- let url = root.url.startsWith("https://") || root.url.startsWith("http://") || root.url.startsWith("//") ? root.url : `${window.location.origin}${root.url}`;
136
+ let url = root.url;
137
+ if (root.url.startsWith("/") && !root.url.startsWith("//") && window.location.search.includes("hsDebugOverridePublicHost=")) {
138
+ const currentUrl = new URL(window.location.toString());
139
+ url = `${currentUrl.protocol}//${currentUrl.searchParams.get(
140
+ "hsDebugOverridePublicHost"
141
+ )}${root.url}`;
142
+ } else if (!root.url.startsWith("https://") && !root.url.startsWith("http://") && !root.url.startsWith("//")) {
143
+ url = `${window.location.origin}${root.url}`;
144
+ }
137
145
  if (shouldForceSeparateJsForAllIslands) {
138
146
  url = `${root.url}?cacheBust=${Date.now()}-${root.id}`;
139
147
  }
package/dist/run.js CHANGED
@@ -680,7 +680,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
680
680
  })
681
681
  `);
682
682
  }
683
- const nonceAttr = includeNonces && cmsComponents.STYLE_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.STYLE_NONCE_PLACEHOLDER}"` : "";
683
+ const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
684
684
  return `
685
685
  <script type="text/javascript"${nonceAttr}>
686
686
  ${globals.join("\n ")}
@@ -1029,7 +1029,7 @@ function trackUsage(action) {
1029
1029
  eventName: EVENT_NAME,
1030
1030
  action,
1031
1031
  nodeVersion: getNodeVersionData(),
1032
- version: "0.14.11",
1032
+ version: "0.14.13",
1033
1033
  os: getPlatform()
1034
1034
  };
1035
1035
  const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1195,7 +1195,11 @@ function EmptyModulesList({ webRoot: webRoot2 }) {
1195
1195
  ] });
1196
1196
  }
1197
1197
  function ModuleLinkInLI({ moduleName }) {
1198
- return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5("a", { href: `/module/${moduleName}`, children: moduleName }) });
1198
+ return /* @__PURE__ */ jsxs2("li", { children: [
1199
+ /* @__PURE__ */ jsx5("a", { href: `/preview/module/${moduleName}`, children: moduleName }),
1200
+ " / ",
1201
+ /* @__PURE__ */ jsx5("a", { href: `/module/${moduleName}`, children: "Local Version" })
1202
+ ] });
1199
1203
  }
1200
1204
  function ModulesList({ webRoot: webRoot2, moduleNames }) {
1201
1205
  if (moduleNames.length === 0) {
@@ -2435,7 +2439,8 @@ function proxyPathPageResourceRedirect(req, res, next) {
2435
2439
  import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
2436
2440
  import path6 from "path";
2437
2441
  import { normalizePath as normalizePath5 } from "vite";
2438
- import fetch2 from "node-fetch";
2442
+ import hsHttp from "@hubspot/cli-lib/http.js";
2443
+ var { post: hsPost } = hsHttp;
2439
2444
  async function modulePreviewRouteHandler(request2, response) {
2440
2445
  sendTrackingRequest("view-module-preview-route");
2441
2446
  const {
@@ -2460,7 +2465,6 @@ async function modulePreviewRouteHandler(request2, response) {
2460
2465
  false,
2461
2466
  jsRenderingGates
2462
2467
  );
2463
- const baseUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}${authedHublet === "eu1" ? "-eu1" : ""}.com/api`;
2464
2468
  let templatePreview;
2465
2469
  try {
2466
2470
  let componentModule;
@@ -2511,19 +2515,15 @@ async function modulePreviewRouteHandler(request2, response) {
2511
2515
  hsLocalProxy: `${true}`,
2512
2516
  localProxySchemaVersion: "1"
2513
2517
  });
2514
- const templatePreviewResponse = await fetch2(
2515
- `${baseUrl}/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
2516
- {
2517
- method: "POST",
2518
- headers: {
2519
- ["content-type"]: "application/x-www-form-urlencoded",
2520
- ["Accept"]: "text/html",
2521
- referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`
2522
- },
2523
- body: `module=${encodeURIComponent(JSON.stringify(localModule))}`
2524
- }
2525
- );
2526
- templatePreview = await templatePreviewResponse.text();
2518
+ templatePreview = await hsPost(authedPortalId, {
2519
+ uri: `/api/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
2520
+ headers: {
2521
+ ["content-type"]: "application/x-www-form-urlencoded",
2522
+ ["Accept"]: "text/html",
2523
+ referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`
2524
+ },
2525
+ body: `module=${encodeURIComponent(JSON.stringify(localModule))}`
2526
+ });
2527
2527
  } catch (e) {
2528
2528
  return response.status(500).end(`Error fetching module preview for (${moduleName}).
2529
2529
 
@@ -2570,9 +2570,10 @@ async function modulePreviewRouteHandler(request2, response) {
2570
2570
  );
2571
2571
  const html = htmlShell.replace(
2572
2572
  "<!--headend-->",
2573
- [cssNeeded, ...inlineAssets.map((inlineAsset) => inlineAsset.html)].join(
2574
- "\n"
2575
- )
2573
+ [
2574
+ cssNeeded,
2575
+ ...inlineAssets.map((inlineAsset) => inlineAsset.html)
2576
+ ].join("\n")
2576
2577
  ).replace(`<!--ssr-outlet-->`, renderedHtml);
2577
2578
  response.status(200).set({ "Content-Type": "text/html" }).end(html);
2578
2579
  } catch (e) {
@@ -3142,7 +3143,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
3142
3143
  `Couldn't find an account to use, make sure there is hubspot.config.yaml in this folder (or a parent).
3143
3144
  If needed you can refer to another config file with --config.
3144
3145
 
3145
- Local proxy functionality will not work without setting up authentication.`
3146
+ Local proxy functionality and module preview routes will not work without setting up authentication. You can work purely on modules locally at "/module/[module_name]", however the experience may be degraded do to missing account data.`
3146
3147
  );
3147
3148
  }
3148
3149
  setTrackingInfo(authedPortalId, authedEnv);
@@ -654,7 +654,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
654
654
  })
655
655
  `);
656
656
  }
657
- const nonceAttr = includeNonces && cmsComponents.STYLE_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.STYLE_NONCE_PLACEHOLDER}"` : "";
657
+ const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
658
658
  return `
659
659
  <script type="text/javascript"${nonceAttr}>
660
660
  ${globals.join("\n ")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "0.14.11",
3
+ "version": "0.14.13",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@hubspot/cli-lib": "^3.0.12",
29
- "@hubspot/cms-components": "^0.14.11",
29
+ "@hubspot/cms-components": "^0.14.13",
30
30
  "@inquirer/select": "^2.0.0",
31
31
  "@originjs/vite-plugin-commonjs": "^1.0.3",
32
32
  "@storybook/addon-actions": "7.0.7",
@@ -107,5 +107,5 @@
107
107
  "publishConfig": {
108
108
  "access": "public"
109
109
  },
110
- "gitHead": "3a9e5b591890e251389ef2f13689ad6db96f159a"
110
+ "gitHead": "640f49b28c725a80b695ad0bed184a74edaddcdb"
111
111
  }