@hubspot/cms-dev-server 1.2.42 → 1.2.46

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.
@@ -10,7 +10,7 @@ import { createServer as createViteServer } from "vite";
10
10
  import { createRequire } from "module";
11
11
  import { default as react } from "@vitejs/plugin-react";
12
12
 
13
- // ../cms-js-internal/dist/types-BEz622C8.js
13
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
14
14
  import path from "path";
15
15
  var viteRoot;
16
16
  var viteCommand;
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { createServer as createViteServer } from "vite";
3
3
  import { createRequire } from "module";
4
4
  import { default as react } from "@vitejs/plugin-react";
5
5
 
6
- // ../cms-js-internal/dist/types-BEz622C8.js
6
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -247,6 +247,13 @@ function getCMSAssetConfigIfExists(webRoot) {
247
247
  return {};
248
248
  }
249
249
  }
250
+ function isFullHeightPreviewEnabled(config) {
251
+ var _a;
252
+ if ("devServer" in config) {
253
+ return ((_a = config.devServer) == null ? void 0 : _a.fullHeightPreview) ?? false;
254
+ }
255
+ return false;
256
+ }
250
257
  var ENABLED_FEATURES_GATE_MAP = {
251
258
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
252
259
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
@@ -1642,7 +1649,7 @@ function trackUsage(action) {
1642
1649
  eventName: EVENT_NAME,
1643
1650
  action,
1644
1651
  nodeVersion: getNodeVersionData(),
1645
- version: "1.2.42",
1652
+ version: "1.2.46",
1646
1653
  os: getPlatform()
1647
1654
  };
1648
1655
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2920,8 +2927,35 @@ ${result}`;
2920
2927
 
2921
2928
  // src/lib/renderModulePreview.ts
2922
2929
  import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
2930
+ import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
2931
+ import { accessTokenForPersonalAccessKey as accessTokenForPersonalAccessKey2 } from "@hubspot/local-dev-lib/personalAccessKey";
2932
+
2933
+ // src/lib/fetchSignedModulePreview.ts
2923
2934
  import { getConfigAccountIfExists as getConfigAccountIfExists3 } from "@hubspot/local-dev-lib/config";
2924
2935
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
2936
+ async function fetchSignedModulePreview(signedUrl, authedEnv, cookieValue, postBody, authedPortalId) {
2937
+ const authHeaders = {};
2938
+ const accountConfig = getConfigAccountIfExists3(authedPortalId);
2939
+ if (accountConfig && accountConfig.authType === "personalaccesskey") {
2940
+ const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
2941
+ authHeaders["Authorization"] = `Bearer ${accessToken}`;
2942
+ }
2943
+ const response = await fetch(signedUrl, {
2944
+ method: "POST",
2945
+ headers: {
2946
+ "content-type": "application/x-www-form-urlencoded",
2947
+ Accept: "text/html",
2948
+ referer: `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
2949
+ cookie: cookieValue,
2950
+ "User-Agent": "HubSpot CMS Dev Server",
2951
+ ...authHeaders
2952
+ },
2953
+ body: postBody
2954
+ });
2955
+ return response.text();
2956
+ }
2957
+
2958
+ // src/lib/renderModulePreview.ts
2925
2959
  import jsdom from "jsdom";
2926
2960
  var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
2927
2961
  async function signGetUrl(authedPortalId, unsignedUrl) {
@@ -2950,9 +2984,9 @@ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
2950
2984
  }
2951
2985
  const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
2952
2986
  const authHeaders = {};
2953
- const accountConfig = getConfigAccountIfExists3(authedPortalId);
2987
+ const accountConfig = getConfigAccountIfExists4(authedPortalId);
2954
2988
  if (accountConfig && accountConfig.authType === "personalaccesskey") {
2955
- const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
2989
+ const accessToken = await accessTokenForPersonalAccessKey2(authedPortalId);
2956
2990
  authHeaders["Authorization"] = `Bearer ${accessToken}`;
2957
2991
  }
2958
2992
  const response = await fetch(signedUrl, {
@@ -3118,25 +3152,13 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
3118
3152
  const postBody = `module=${encodeURIComponent(JSON.stringify(localModule))}`;
3119
3153
  let templatePreview;
3120
3154
  try {
3121
- const authHeaders = {};
3122
- const accountConfig = getConfigAccountIfExists3(authedPortalId);
3123
- if (accountConfig && accountConfig.authType === "personalaccesskey") {
3124
- const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3125
- authHeaders["Authorization"] = `Bearer ${accessToken}`;
3126
- }
3127
- const response = await fetch(signedUrl, {
3128
- method: "POST",
3129
- headers: {
3130
- "content-type": "application/x-www-form-urlencoded",
3131
- Accept: "text/html",
3132
- referer: `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3133
- cookie: cookieValue,
3134
- "User-Agent": "HubSpot CMS Dev Server",
3135
- ...authHeaders
3136
- },
3137
- body: postBody
3138
- });
3139
- templatePreview = await response.text();
3155
+ templatePreview = await fetchSignedModulePreview(
3156
+ signedUrl,
3157
+ authedEnv,
3158
+ cookieValue,
3159
+ postBody,
3160
+ authedPortalId
3161
+ );
3140
3162
  } catch (error) {
3141
3163
  console.error("Preview request failed:", error);
3142
3164
  throw error;
@@ -3584,7 +3606,7 @@ var moduleFieldsJson_default = moduleFieldsJsonRouteHandler;
3584
3606
  // src/proxyPage/fetchContentMetadata.ts
3585
3607
  import http from "http";
3586
3608
  import https from "https";
3587
- import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
3609
+ import { getConfigAccountIfExists as getConfigAccountIfExists5 } from "@hubspot/local-dev-lib/config";
3588
3610
  async function requestPage(url3, redirects = 0, originalUrl) {
3589
3611
  if (redirects > 5) {
3590
3612
  throw new Error(
@@ -3652,7 +3674,7 @@ async function fetchContentMetadata(url3, portalId) {
3652
3674
  );
3653
3675
  } else {
3654
3676
  const portalIdFromResponse = parseInt(portalIdHeader, 10);
3655
- const pageAccount = await getConfigAccountIfExists4(portalIdFromResponse);
3677
+ const pageAccount = await getConfigAccountIfExists5(portalIdFromResponse);
3656
3678
  if (!pageAccount) {
3657
3679
  throw new Error(
3658
3680
  `No CLI auth for portal ${portalIdFromResponse} found, please run \`hs auth\``
@@ -4053,7 +4075,8 @@ async function modulePreviewRouteHandler(request, response) {
4053
4075
  viteServer,
4054
4076
  jsRenderingGates,
4055
4077
  projectName,
4056
- projectComponentPath
4078
+ projectComponentPath,
4079
+ fullHeightPreview
4057
4080
  } = request.app.locals;
4058
4081
  const moduleName = request.params.moduleName;
4059
4082
  const modulePath = normalizePath8(
@@ -4128,9 +4151,11 @@ async function modulePreviewRouteHandler(request, response) {
4128
4151
  viteServer,
4129
4152
  jsRenderingGates
4130
4153
  );
4154
+ const fullHeightCss = fullHeightPreview ? `<style>html,body{height:100%;width:100%;margin:0}#root{height:100%;width:100%}</style>` : "";
4131
4155
  const html = htmlShell.replace(
4132
4156
  "<!--headend-->",
4133
4157
  [
4158
+ fullHeightCss,
4134
4159
  cssNeeded,
4135
4160
  ...inlineAssets.map((inlineAsset) => inlineAsset.html)
4136
4161
  ].join("\n")
@@ -4626,7 +4651,7 @@ import express from "express";
4626
4651
 
4627
4652
  // src/shadowDevServer/createShadowDevServerRoutes.ts
4628
4653
  import { Router as Router3 } from "express";
4629
- import { getConfigAccountIfExists as getConfigAccountIfExists5 } from "@hubspot/local-dev-lib/config";
4654
+ import { getConfigAccountIfExists as getConfigAccountIfExists6 } from "@hubspot/local-dev-lib/config";
4630
4655
  import cors2 from "cors";
4631
4656
  function getShadowDevServerCheckHandler(devServerPort, themePath) {
4632
4657
  return async function shadowDevServerCheckHandler(request, response) {
@@ -4643,7 +4668,7 @@ function getShadowDevServerCheckHandler(devServerPort, themePath) {
4643
4668
  let isTemplateFromDevTheme = false;
4644
4669
  let localProxyUrl;
4645
4670
  try {
4646
- account = getConfigAccountIfExists5(portalId);
4671
+ account = getConfigAccountIfExists6(portalId);
4647
4672
  if (!account) {
4648
4673
  throw new Error();
4649
4674
  }
@@ -5011,7 +5036,7 @@ function hasFlag(flag, argv = process2.argv) {
5011
5036
 
5012
5037
  // src/createDevServer.ts
5013
5038
  import {
5014
- getConfigAccountIfExists as getConfigAccountIfExists6,
5039
+ getConfigAccountIfExists as getConfigAccountIfExists7,
5015
5040
  getConfigDefaultAccountIfExists,
5016
5041
  validateConfig
5017
5042
  } from "@hubspot/local-dev-lib/config";
@@ -5598,9 +5623,10 @@ async function createDevServer(webRoot, storybook, hubspotCliConfigPathOption, h
5598
5623
  }
5599
5624
  const cmsAssetConfig = getCMSAssetConfigIfExists(webRoot);
5600
5625
  secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
5626
+ const fullHeightPreview = isFullHeightPreviewEnabled(cmsAssetConfig);
5601
5627
  const { isValid } = validateConfig();
5602
5628
  if (isValid) {
5603
- const account = hubspotCliAccountNameOption ? getConfigAccountIfExists6(hubspotCliAccountNameOption) : getConfigDefaultAccountIfExists();
5629
+ const account = hubspotCliAccountNameOption ? getConfigAccountIfExists7(hubspotCliAccountNameOption) : getConfigDefaultAccountIfExists();
5604
5630
  if (!account) {
5605
5631
  console.error(
5606
5632
  hubspotCliAccountNameOption ? `Couldn't find ${hubspotCliAccountNameOption} in your hubspot.config.yaml` : `No default account found. Run 'hs auth' first.`
@@ -5744,6 +5770,7 @@ Local proxy functionality and module preview routes will not work without settin
5744
5770
  expressServer.locals.domainsToProxy = domainsToProxy;
5745
5771
  expressServer.locals.localPreviewToken = _localPreviewToken;
5746
5772
  expressServer.locals.sslEnabled = sslEnabledOption;
5773
+ expressServer.locals.fullHeightPreview = fullHeightPreview;
5747
5774
  expressServer.use(bodyParser.json());
5748
5775
  const __dirname = path17.dirname(url2.fileURLToPath(new URL(import.meta.url)));
5749
5776
  let appWebRoot = normalizePath10(path17.resolve(__dirname, "../app"));
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-BEz622C8.js
1
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -366,6 +366,13 @@ function getServerIncludePrebundleDepPatterns(config) {
366
366
  var _a, _b;
367
367
  return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.serverPrebundling) == null ? void 0 : _b.include) ?? [];
368
368
  }
369
+ function isFullHeightPreviewEnabled(config) {
370
+ var _a;
371
+ if ("devServer" in config) {
372
+ return ((_a = config.devServer) == null ? void 0 : _a.fullHeightPreview) ?? false;
373
+ }
374
+ return false;
375
+ }
369
376
  var BUILD_INFO_PATH = "/build-info.json";
370
377
  function getBuildInfo(buildDir) {
371
378
  try {
@@ -1289,6 +1296,7 @@ export {
1289
1296
  getServerIncludePrebundleDepPatterns,
1290
1297
  hasComponentExtension,
1291
1298
  includesHublDataReference,
1299
+ isFullHeightPreviewEnabled,
1292
1300
  isStorybookStory,
1293
1301
  isStylesheetAsset,
1294
1302
  isUngatedFor,
@@ -73,24 +73,40 @@ var startHydratingIdleRootsTimeout;
73
73
  var shouldForceSeparateJsForAllIslands = /(&|\?)forceSeparateIslandJs=true/.test(window.location.search);
74
74
  var scheduledHydrationIndexCtr = 1;
75
75
  var rootsById = /* @__PURE__ */ new Map();
76
+ var scheduledElements = /* @__PURE__ */ new WeakSet();
76
77
  var typedWindow = window;
77
- var startHydratingIdleRoots = () => {
78
+ function findIslandElements(islandId) {
79
+ if (typeof CSS !== "undefined" && CSS.escape) {
80
+ return Array.from(
81
+ document.querySelectorAll(
82
+ `[data-hs-island][id="${CSS.escape(islandId)}"]`
83
+ )
84
+ );
85
+ }
86
+ return Array.from(
87
+ document.querySelectorAll("[data-hs-island]")
88
+ ).filter((el) => el.id === islandId);
89
+ }
90
+ function prepareAndScheduleRoot(root) {
91
+ root.hydrationStatus = "HYDRATION_PREPARING";
92
+ waitThenLoadAndHydrateIfNeeded(
93
+ root,
94
+ getLoadableModuleFor(root),
95
+ root.wrapperUrl ? getLoadableModuleFor({
96
+ url: root.wrapperUrl,
97
+ id: `${root.id}-wrapper`,
98
+ moduleName: `${root.moduleName}-wrapper`
99
+ }) : void 0
100
+ );
101
+ }
102
+ function startHydratingIdleRoots() {
78
103
  hydrationTypesToAccept.add("idle");
79
104
  for (const root of rootsToProcess) {
80
105
  if (root.hydrationStatus === "HYDRATION_WAITING" && hydrationTypesToAccept.has(root.hydrateOn)) {
81
- root.hydrationStatus = "HYDRATION_PREPARING";
82
- waitThenLoadAndHydrateIfNeeded(
83
- root,
84
- getLoadableModuleFor(root),
85
- root.wrapperUrl ? getLoadableModuleFor({
86
- url: root.wrapperUrl,
87
- id: `${root.id}-wrapper`,
88
- moduleName: `${root.moduleName}-wrapper`
89
- }) : void 0
90
- );
106
+ prepareAndScheduleRoot(root);
91
107
  }
92
108
  }
93
- };
109
+ }
94
110
  function setupIdleCallbackIfNeeded() {
95
111
  if (!startHydratingIdleRootsTimeout) {
96
112
  if (!window.requestIdleCallback) {
@@ -105,9 +121,9 @@ function setupIdleCallbackIfNeeded() {
105
121
  );
106
122
  }
107
123
  }
108
- function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
109
- rootAndExtraInfo.root.hydrationStatus = "HYDRATED";
110
- hydrationQueue = hydrationQueue.filter((x) => x !== rootAndExtraInfo);
124
+ function finishHydratingRootAndScheduleNext(entry) {
125
+ entry.root.hydrationStatus = "HYDRATED";
126
+ hydrationQueue = hydrationQueue.filter((x) => x !== entry);
111
127
  const hasOtherRootsToHydrate = hydrationQueue.length > 0;
112
128
  if (hasOtherRootsToHydrate) {
113
129
  setTimeout(() => hydrateRoot(hydrationQueue[0]), 0);
@@ -115,13 +131,13 @@ function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
115
131
  setupIdleCallbackIfNeeded();
116
132
  }
117
133
  }
118
- function hydrateRoot(rootAndExtraInfo) {
119
- const { rootEl, root, IslandModule, WrapperModule } = rootAndExtraInfo;
134
+ function hydrateRoot(entry) {
135
+ const { rootEl, root, IslandModule, WrapperModule } = entry;
120
136
  if (window.location.search.includes("hsDebug=")) {
121
137
  console.log("Hydrating root", root.id, root.hydrateOn);
122
138
  }
123
139
  const postHydration = () => {
124
- finishHydratingRootAndScheduleNext(rootAndExtraInfo);
140
+ finishHydratingRootAndScheduleNext(entry);
125
141
  };
126
142
  const renderableIsland = {
127
143
  rootElement: rootEl,
@@ -131,17 +147,17 @@ function hydrateRoot(rootAndExtraInfo) {
131
147
  postHydration,
132
148
  island: root,
133
149
  WrapperModule: WrapperModule ? WrapperModule.default : void 0,
134
- index: rootAndExtraInfo.islandScheduledIndex
150
+ index: entry.islandScheduledIndex
135
151
  };
136
152
  const reactRoot = IslandModule.render(renderableIsland);
137
153
  const existingRoots = rootsById.get(root.id) || [];
138
154
  rootsById.set(root.id, [...existingRoots, reactRoot]);
139
155
  }
140
- function pushToHydrationQueue(rootAndExtraInfo) {
141
- rootAndExtraInfo.root.hydrationStatus = "HYDRATION_QUEUED";
142
- hydrationQueue.push(rootAndExtraInfo);
156
+ function pushToHydrationQueue(entry) {
157
+ entry.root.hydrationStatus = "HYDRATION_QUEUED";
158
+ hydrationQueue.push(entry);
143
159
  if (hydrationQueue.length === 1) {
144
- hydrateRoot(rootAndExtraInfo);
160
+ hydrateRoot(entry);
145
161
  }
146
162
  }
147
163
  function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, rootEl, islandScheduledIndex) {
@@ -161,22 +177,16 @@ function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, root
161
177
  ).catch((error) => {
162
178
  console.error(`Failed to load module for island: ${root.id}`);
163
179
  console.error(error);
180
+ scheduledElements.delete(rootEl);
164
181
  });
165
182
  }
166
183
  function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrapperModule) {
167
- let rootEls;
168
- if (typeof CSS !== "undefined" && CSS.escape) {
169
- rootEls = Array.from(
170
- document.querySelectorAll(
171
- `[data-hs-island][id="${CSS.escape(root.id)}"]`
172
- )
173
- );
174
- } else {
175
- rootEls = Array.from(
176
- document.querySelectorAll("[data-hs-island]")
177
- ).filter((el) => el.id === root.id);
178
- }
184
+ const rootEls = findIslandElements(root.id);
179
185
  rootEls.forEach((rootEl) => {
186
+ if (scheduledElements.has(rootEl)) {
187
+ return;
188
+ }
189
+ scheduledElements.add(rootEl);
180
190
  const rootClone = { ...root };
181
191
  const islandScheduledIndex = scheduledHydrationIndexCtr;
182
192
  scheduledHydrationIndexCtr += 1;
@@ -211,14 +221,10 @@ function getLoadableModuleFor(root) {
211
221
  if (shouldForceSeparateJsForAllIslands) {
212
222
  url = `${root.url}?cacheBust=${Date.now()}-${root.id}`;
213
223
  }
214
- const LoadableIslandModule = () => import(
224
+ return () => import(
215
225
  /* @vite-ignore */
216
226
  url
217
227
  );
218
- if (!LoadableIslandModule) {
219
- throw new Error(`Missing island component for ${root.moduleName}`);
220
- }
221
- return LoadableIslandModule;
222
228
  }
223
229
  function hydrateIslandRoots() {
224
230
  if (rootsToProcess === void 0) {
@@ -233,19 +239,11 @@ function hydrateIslandRoots() {
233
239
  let encounteredAnyNonIdleIslands = false;
234
240
  for (const root of rootsToProcess) {
235
241
  if (!root.hydrationStatus) {
236
- root.hydrationStatus = root.hydrationStatus || "HYDRATION_WAITING";
237
242
  if (hydrationTypesToAccept.has(root.hydrateOn)) {
238
243
  encounteredAnyNonIdleIslands = true;
239
- root.hydrationStatus = "HYDRATION_PREPARING";
240
- waitThenLoadAndHydrateIfNeeded(
241
- root,
242
- getLoadableModuleFor(root),
243
- root.wrapperUrl ? getLoadableModuleFor({
244
- url: root.wrapperUrl,
245
- id: `${root.id}-wrapper`,
246
- moduleName: `${root.moduleName}-wrapper`
247
- }) : void 0
248
- );
244
+ prepareAndScheduleRoot(root);
245
+ } else {
246
+ root.hydrationStatus = "HYDRATION_WAITING";
249
247
  }
250
248
  }
251
249
  }
@@ -271,6 +269,8 @@ function unmountIsland(islandId) {
271
269
  const islandIndex = rootsToProcess.indexOf(islandToUnmount);
272
270
  rootsToProcess.splice(islandIndex, 1);
273
271
  rootsById.delete(islandId);
272
+ const islandEls = findIslandElements(islandId);
273
+ islandEls.forEach((el) => scheduledElements.delete(el));
274
274
  console.log("Unmounting island:", islandId);
275
275
  for (const reactRoot of reactRoots) {
276
276
  reactRoot.unmount();
package/dist/run.js CHANGED
@@ -896,7 +896,7 @@ function packagePath(metaUrl, projectPath) {
896
896
  );
897
897
  }
898
898
 
899
- // ../cms-js-internal/dist/types-BEz622C8.js
899
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
900
900
  import path4 from "path";
901
901
  import { createHash } from "crypto";
902
902
  import fs3, { readFileSync, existsSync as existsSync2, readdirSync, lstatSync } from "fs";
@@ -1140,6 +1140,13 @@ function getCMSAssetConfigIfExists(webRoot2) {
1140
1140
  return {};
1141
1141
  }
1142
1142
  }
1143
+ function isFullHeightPreviewEnabled(config) {
1144
+ var _a;
1145
+ if ("devServer" in config) {
1146
+ return ((_a = config.devServer) == null ? void 0 : _a.fullHeightPreview) ?? false;
1147
+ }
1148
+ return false;
1149
+ }
1143
1150
  var ENABLED_FEATURES_GATE_MAP = {
1144
1151
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1145
1152
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
@@ -2249,7 +2256,7 @@ function trackUsage(action) {
2249
2256
  eventName: EVENT_NAME,
2250
2257
  action,
2251
2258
  nodeVersion: getNodeVersionData(),
2252
- version: "1.2.42",
2259
+ version: "1.2.46",
2253
2260
  os: getPlatform()
2254
2261
  };
2255
2262
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -3527,8 +3534,35 @@ ${result}`;
3527
3534
 
3528
3535
  // src/lib/renderModulePreview.ts
3529
3536
  import { http as hsCliHttp7 } from "@hubspot/local-dev-lib/http";
3537
+ import { getConfigAccountIfExists as getConfigAccountIfExists5 } from "@hubspot/local-dev-lib/config";
3538
+ import { accessTokenForPersonalAccessKey as accessTokenForPersonalAccessKey2 } from "@hubspot/local-dev-lib/personalAccessKey";
3539
+
3540
+ // src/lib/fetchSignedModulePreview.ts
3530
3541
  import { getConfigAccountIfExists as getConfigAccountIfExists4 } from "@hubspot/local-dev-lib/config";
3531
3542
  import { accessTokenForPersonalAccessKey } from "@hubspot/local-dev-lib/personalAccessKey";
3543
+ async function fetchSignedModulePreview(signedUrl, authedEnv, cookieValue, postBody, authedPortalId) {
3544
+ const authHeaders = {};
3545
+ const accountConfig = getConfigAccountIfExists4(authedPortalId);
3546
+ if (accountConfig && accountConfig.authType === "personalaccesskey") {
3547
+ const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3548
+ authHeaders["Authorization"] = `Bearer ${accessToken}`;
3549
+ }
3550
+ const response = await fetch(signedUrl, {
3551
+ method: "POST",
3552
+ headers: {
3553
+ "content-type": "application/x-www-form-urlencoded",
3554
+ Accept: "text/html",
3555
+ referer: `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3556
+ cookie: cookieValue,
3557
+ "User-Agent": "HubSpot CMS Dev Server",
3558
+ ...authHeaders
3559
+ },
3560
+ body: postBody
3561
+ });
3562
+ return response.text();
3563
+ }
3564
+
3565
+ // src/lib/renderModulePreview.ts
3532
3566
  import jsdom from "jsdom";
3533
3567
  var URL_SIGNING_GATE = "PortalsAccessIdentity:DesignManager:UrlSigning";
3534
3568
  async function signGetUrl(authedPortalId, unsignedUrl) {
@@ -3557,9 +3591,9 @@ async function signedGet(authedPortalId, unsignedUrl, headers, gates) {
3557
3591
  }
3558
3592
  const signedUrl = await signGetUrl(authedPortalId, unsignedUrl);
3559
3593
  const authHeaders = {};
3560
- const accountConfig = getConfigAccountIfExists4(authedPortalId);
3594
+ const accountConfig = getConfigAccountIfExists5(authedPortalId);
3561
3595
  if (accountConfig && accountConfig.authType === "personalaccesskey") {
3562
- const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3596
+ const accessToken = await accessTokenForPersonalAccessKey2(authedPortalId);
3563
3597
  authHeaders["Authorization"] = `Bearer ${accessToken}`;
3564
3598
  }
3565
3599
  const response = await fetch(signedUrl, {
@@ -3725,25 +3759,13 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
3725
3759
  const postBody = `module=${encodeURIComponent(JSON.stringify(localModule))}`;
3726
3760
  let templatePreview;
3727
3761
  try {
3728
- const authHeaders = {};
3729
- const accountConfig = getConfigAccountIfExists4(authedPortalId);
3730
- if (accountConfig && accountConfig.authType === "personalaccesskey") {
3731
- const accessToken = await accessTokenForPersonalAccessKey(authedPortalId);
3732
- authHeaders["Authorization"] = `Bearer ${accessToken}`;
3733
- }
3734
- const response = await fetch(signedUrl, {
3735
- method: "POST",
3736
- headers: {
3737
- "content-type": "application/x-www-form-urlencoded",
3738
- Accept: "text/html",
3739
- referer: `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
3740
- cookie: cookieValue,
3741
- "User-Agent": "HubSpot CMS Dev Server",
3742
- ...authHeaders
3743
- },
3744
- body: postBody
3745
- });
3746
- templatePreview = await response.text();
3762
+ templatePreview = await fetchSignedModulePreview(
3763
+ signedUrl,
3764
+ authedEnv,
3765
+ cookieValue,
3766
+ postBody,
3767
+ authedPortalId
3768
+ );
3747
3769
  } catch (error) {
3748
3770
  console.error("Preview request failed:", error);
3749
3771
  throw error;
@@ -4191,7 +4213,7 @@ var moduleFieldsJson_default = moduleFieldsJsonRouteHandler;
4191
4213
  // src/proxyPage/fetchContentMetadata.ts
4192
4214
  import http from "http";
4193
4215
  import https from "https";
4194
- import { getConfigAccountIfExists as getConfigAccountIfExists5 } from "@hubspot/local-dev-lib/config";
4216
+ import { getConfigAccountIfExists as getConfigAccountIfExists6 } from "@hubspot/local-dev-lib/config";
4195
4217
  async function requestPage(url3, redirects = 0, originalUrl) {
4196
4218
  if (redirects > 5) {
4197
4219
  throw new Error(
@@ -4259,7 +4281,7 @@ async function fetchContentMetadata(url3, portalId) {
4259
4281
  );
4260
4282
  } else {
4261
4283
  const portalIdFromResponse = parseInt(portalIdHeader, 10);
4262
- const pageAccount = await getConfigAccountIfExists5(portalIdFromResponse);
4284
+ const pageAccount = await getConfigAccountIfExists6(portalIdFromResponse);
4263
4285
  if (!pageAccount) {
4264
4286
  throw new Error(
4265
4287
  `No CLI auth for portal ${portalIdFromResponse} found, please run \`hs auth\``
@@ -4660,7 +4682,8 @@ async function modulePreviewRouteHandler(request, response) {
4660
4682
  viteServer,
4661
4683
  jsRenderingGates,
4662
4684
  projectName,
4663
- projectComponentPath
4685
+ projectComponentPath,
4686
+ fullHeightPreview
4664
4687
  } = request.app.locals;
4665
4688
  const moduleName = request.params.moduleName;
4666
4689
  const modulePath = normalizePath8(
@@ -4735,9 +4758,11 @@ async function modulePreviewRouteHandler(request, response) {
4735
4758
  viteServer,
4736
4759
  jsRenderingGates
4737
4760
  );
4761
+ const fullHeightCss = fullHeightPreview ? `<style>html,body{height:100%;width:100%;margin:0}#root{height:100%;width:100%}</style>` : "";
4738
4762
  const html = htmlShell.replace(
4739
4763
  "<!--headend-->",
4740
4764
  [
4765
+ fullHeightCss,
4741
4766
  cssNeeded,
4742
4767
  ...inlineAssets.map((inlineAsset) => inlineAsset.html)
4743
4768
  ].join("\n")
@@ -5450,7 +5475,7 @@ import express from "express";
5450
5475
 
5451
5476
  // src/shadowDevServer/createShadowDevServerRoutes.ts
5452
5477
  import { Router as Router3 } from "express";
5453
- import { getConfigAccountIfExists as getConfigAccountIfExists6 } from "@hubspot/local-dev-lib/config";
5478
+ import { getConfigAccountIfExists as getConfigAccountIfExists7 } from "@hubspot/local-dev-lib/config";
5454
5479
  import cors2 from "cors";
5455
5480
  function getShadowDevServerCheckHandler(devServerPort, themePath) {
5456
5481
  return async function shadowDevServerCheckHandler(request, response) {
@@ -5467,7 +5492,7 @@ function getShadowDevServerCheckHandler(devServerPort, themePath) {
5467
5492
  let isTemplateFromDevTheme = false;
5468
5493
  let localProxyUrl;
5469
5494
  try {
5470
- account = getConfigAccountIfExists6(portalId);
5495
+ account = getConfigAccountIfExists7(portalId);
5471
5496
  if (!account) {
5472
5497
  throw new Error();
5473
5498
  }
@@ -5680,7 +5705,7 @@ async function getJsRenderingGates(portalId, env2, personalAccessKey) {
5680
5705
 
5681
5706
  // src/createDevServer.ts
5682
5707
  import {
5683
- getConfigAccountIfExists as getConfigAccountIfExists7,
5708
+ getConfigAccountIfExists as getConfigAccountIfExists8,
5684
5709
  getConfigDefaultAccountIfExists,
5685
5710
  validateConfig
5686
5711
  } from "@hubspot/local-dev-lib/config";
@@ -6267,9 +6292,10 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
6267
6292
  }
6268
6293
  const cmsAssetConfig = getCMSAssetConfigIfExists(webRoot2);
6269
6294
  secretNamesFromConfig = getSecretNamesFromConfig(cmsAssetConfig);
6295
+ const fullHeightPreview = isFullHeightPreviewEnabled(cmsAssetConfig);
6270
6296
  const { isValid } = validateConfig();
6271
6297
  if (isValid) {
6272
- const account = hubspotCliAccountNameOption2 ? getConfigAccountIfExists7(hubspotCliAccountNameOption2) : getConfigDefaultAccountIfExists();
6298
+ const account = hubspotCliAccountNameOption2 ? getConfigAccountIfExists8(hubspotCliAccountNameOption2) : getConfigDefaultAccountIfExists();
6273
6299
  if (!account) {
6274
6300
  console.error(
6275
6301
  hubspotCliAccountNameOption2 ? `Couldn't find ${hubspotCliAccountNameOption2} in your hubspot.config.yaml` : `No default account found. Run 'hs auth' first.`
@@ -6413,6 +6439,7 @@ Local proxy functionality and module preview routes will not work without settin
6413
6439
  expressServer.locals.domainsToProxy = domainsToProxy;
6414
6440
  expressServer.locals.localPreviewToken = _localPreviewToken;
6415
6441
  expressServer.locals.sslEnabled = sslEnabledOption2;
6442
+ expressServer.locals.fullHeightPreview = fullHeightPreview;
6416
6443
  expressServer.use(bodyParser.json());
6417
6444
  const __dirname = path18.dirname(url2.fileURLToPath(new URL(import.meta.url)));
6418
6445
  let appWebRoot = normalizePath10(path18.resolve(__dirname, "../app"));
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-BEz622C8.js
4
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
5
5
  function namespaceModulePropsShape(props) {
6
6
  const {
7
7
  dataQueryResult,
@@ -8,7 +8,7 @@ var __export = (target, all) => {
8
8
  __defProp(target, name, { get: all[name], enumerable: true });
9
9
  };
10
10
 
11
- // ../cms-js-internal/dist/types-BEz622C8.js
11
+ // ../cms-js-internal/dist/types-CBGC9bBc.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -260,6 +260,13 @@ function getServerIncludePrebundleDepPatterns(config) {
260
260
  var _a, _b;
261
261
  return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.serverPrebundling) == null ? void 0 : _b.include) ?? [];
262
262
  }
263
+ function isFullHeightPreviewEnabled(config) {
264
+ var _a;
265
+ if ("devServer" in config) {
266
+ return ((_a = config.devServer) == null ? void 0 : _a.fullHeightPreview) ?? false;
267
+ }
268
+ return false;
269
+ }
263
270
  function getBuildInfo(buildDir) {
264
271
  try {
265
272
  const buildInfo = JSON.parse(
@@ -378,8 +385,8 @@ function isStylesheetAsset(staticAsset) {
378
385
  return staticAsset.type === "stylesheet";
379
386
  }
380
387
  var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, TEMPLATE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, badInlineJsChars, inlineJsEscapeChars, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, removeIndexFromPath, removeIndexOrTrailingJsFromPath, HEALTHCHECKS_ENABLED_DEFAULT, HEALTHCHECKS_STRICT_DEFAULT, BUILD_INFO_PATH, GATES, ENABLED_FEATURES_GATE_MAP, findAllComponentsIn;
381
- var init_types_BEz622C8 = __esm({
382
- "../cms-js-internal/dist/types-BEz622C8.js"() {
388
+ var init_types_CBGC9bBc = __esm({
389
+ "../cms-js-internal/dist/types-CBGC9bBc.js"() {
383
390
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
384
391
  ENTRY_POINTS_PATH = "components/partials/";
385
392
  MODULE_FOLDER_PATH = "components/modules/";
@@ -584,6 +591,7 @@ __export(dist_exports, {
584
591
  getServerIncludePrebundleDepPatterns: () => getServerIncludePrebundleDepPatterns,
585
592
  hasComponentExtension: () => hasComponentExtension,
586
593
  includesHublDataReference: () => includesHublDataReference,
594
+ isFullHeightPreviewEnabled: () => isFullHeightPreviewEnabled,
587
595
  isStorybookStory: () => isStorybookStory,
588
596
  isStylesheetAsset: () => isStylesheetAsset,
589
597
  isUngatedFor: () => isUngatedFor,
@@ -1171,8 +1179,8 @@ function GlobalPartialSlot(props) {
1171
1179
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1172
1180
  var init_dist = __esm({
1173
1181
  "../cms-js-internal/dist/index.js"() {
1174
- init_types_BEz622C8();
1175
- init_types_BEz622C8();
1182
+ init_types_CBGC9bBc();
1183
+ init_types_CBGC9bBc();
1176
1184
  ({ setProperty, getProperty, hasProperty } = dotProp);
1177
1185
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1178
1186
  const islandsArrayToSerialize = tweakedIslandsArray.map(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hubspot/cms-dev-server",
3
- "version": "1.2.42",
3
+ "version": "1.2.46",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "engines": {
@@ -29,7 +29,7 @@
29
29
  "@babel/parser": "^7.25.3",
30
30
  "@babel/traverse": "^7.25.3",
31
31
  "@babel/types": "^7.25.2",
32
- "@hubspot/cms-components": "^1.2.42",
32
+ "@hubspot/cms-components": "^1.2.46",
33
33
  "@hubspot/local-dev-lib": "5.8.2",
34
34
  "@inquirer/select": "^2.0.0",
35
35
  "@originjs/vite-plugin-commonjs": "^1.0.3",
@@ -133,5 +133,5 @@
133
133
  "publishConfig": {
134
134
  "access": "public"
135
135
  },
136
- "gitHead": "41c0d54621457b4b7937a35bcbe045da4e4ced95"
136
+ "gitHead": "5d1f0a93de7baa5df065f5bc35bbb7f40e4d9b4b"
137
137
  }
@@ -0,0 +1 @@
1
+ export declare function fetchSignedModulePreview(signedUrl: string, authedEnv: string, cookieValue: string | undefined, postBody: string, authedPortalId: number): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import { Request, Response } from 'express';
2
+ declare const homeRouteHandler: (request: Request, response: Response, next: Function) => Promise<void>;
3
+ export default homeRouteHandler;
@@ -0,0 +1,2 @@
1
+ export declare const metaRouteHandler: (req: any, res: any) => void;
2
+ export declare const markRemoteFsDirty: () => void;