@hubspot/cms-dev-server 1.2.36 → 1.2.39

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-CliAmBEj.js
13
+ // ../cms-js-internal/dist/types-BEz622C8.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-CliAmBEj.js
6
+ // ../cms-js-internal/dist/types-BEz622C8.js
7
7
  import path from "path";
8
8
  import { createHash } from "crypto";
9
9
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -249,7 +249,6 @@ function getCMSAssetConfigIfExists(webRoot) {
249
249
  }
250
250
  var ENABLED_FEATURES_GATE_MAP = {
251
251
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
252
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
253
252
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
254
253
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
255
254
  };
@@ -1643,7 +1642,7 @@ function trackUsage(action) {
1643
1642
  eventName: EVENT_NAME,
1644
1643
  action,
1645
1644
  nodeVersion: getNodeVersionData(),
1646
- version: "1.2.36",
1645
+ version: "1.2.39",
1647
1646
  os: getPlatform()
1648
1647
  };
1649
1648
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-CliAmBEj.js
1
+ // ../cms-js-internal/dist/types-BEz622C8.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -383,7 +383,6 @@ function getBaseAssetUrlFromBuild(buildDir) {
383
383
  var GATES = [
384
384
  "CMS:JSRenderer:GetServerSideProps",
385
385
  "CMS:JSRenderer:ModuleHubl",
386
- "CMS:JSRenderer:RemoveCjsPlugin",
387
386
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
388
387
  "CMS:JSRenderer:AnalyzeCmsModules",
389
388
  "CMS:JSRenderer:StripNullBytes",
@@ -391,14 +390,13 @@ var GATES = [
391
390
  ];
392
391
  var ENABLED_FEATURES_GATE_MAP = {
393
392
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
394
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
395
393
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
396
394
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
397
395
  };
398
396
  function isUngatedFor(gates, gate) {
399
397
  return gates.includes(gate);
400
398
  }
401
- function ungatedIAtBuildTimeFor(buildDir, gate) {
399
+ function ungatedAtBuildTimeFor(buildDir, gate) {
402
400
  try {
403
401
  const buildInfo = getBuildInfo(buildDir);
404
402
  return isUngatedFor(buildInfo.gates, gate);
@@ -1310,6 +1308,6 @@ export {
1310
1308
  scriptTagToLogServerMessages,
1311
1309
  serializeIslandDataForInlineScript,
1312
1310
  setIn,
1313
- ungatedIAtBuildTimeFor,
1311
+ ungatedAtBuildTimeFor,
1314
1312
  virtualClientRenderIslandModuleId
1315
1313
  };
@@ -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,11 +121,9 @@ function setupIdleCallbackIfNeeded() {
105
121
  );
106
122
  }
107
123
  }
108
- function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
109
- rootAndExtraInfo.root.hydrationStatus = "HYDRATED";
110
- hydrationQueue = hydrationQueue.filter(
111
- (x) => x.root.id !== rootAndExtraInfo.root.id
112
- );
124
+ function finishHydratingRootAndScheduleNext(entry) {
125
+ entry.root.hydrationStatus = "HYDRATED";
126
+ hydrationQueue = hydrationQueue.filter((x) => x !== entry);
113
127
  const hasOtherRootsToHydrate = hydrationQueue.length > 0;
114
128
  if (hasOtherRootsToHydrate) {
115
129
  setTimeout(() => hydrateRoot(hydrationQueue[0]), 0);
@@ -117,13 +131,13 @@ function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
117
131
  setupIdleCallbackIfNeeded();
118
132
  }
119
133
  }
120
- function hydrateRoot(rootAndExtraInfo) {
121
- const { rootEl, root, IslandModule, WrapperModule } = rootAndExtraInfo;
134
+ function hydrateRoot(entry) {
135
+ const { rootEl, root, IslandModule, WrapperModule } = entry;
122
136
  if (window.location.search.includes("hsDebug=")) {
123
137
  console.log("Hydrating root", root.id, root.hydrateOn);
124
138
  }
125
139
  const postHydration = () => {
126
- finishHydratingRootAndScheduleNext(rootAndExtraInfo);
140
+ finishHydratingRootAndScheduleNext(entry);
127
141
  };
128
142
  const renderableIsland = {
129
143
  rootElement: rootEl,
@@ -133,16 +147,17 @@ function hydrateRoot(rootAndExtraInfo) {
133
147
  postHydration,
134
148
  island: root,
135
149
  WrapperModule: WrapperModule ? WrapperModule.default : void 0,
136
- index: rootAndExtraInfo.islandScheduledIndex
150
+ index: entry.islandScheduledIndex
137
151
  };
138
152
  const reactRoot = IslandModule.render(renderableIsland);
139
- rootsById.set(root.id, reactRoot);
153
+ const existingRoots = rootsById.get(root.id) || [];
154
+ rootsById.set(root.id, [...existingRoots, reactRoot]);
140
155
  }
141
- function pushToHydrationQueue(rootAndExtraInfo) {
142
- rootAndExtraInfo.root.hydrationStatus = "HYDRATION_QUEUED";
143
- hydrationQueue.push(rootAndExtraInfo);
156
+ function pushToHydrationQueue(entry) {
157
+ entry.root.hydrationStatus = "HYDRATION_QUEUED";
158
+ hydrationQueue.push(entry);
144
159
  if (hydrationQueue.length === 1) {
145
- hydrateRoot(rootAndExtraInfo);
160
+ hydrateRoot(entry);
146
161
  }
147
162
  }
148
163
  function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, rootEl, islandScheduledIndex) {
@@ -162,31 +177,39 @@ function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, root
162
177
  ).catch((error) => {
163
178
  console.error(`Failed to load module for island: ${root.id}`);
164
179
  console.error(error);
180
+ scheduledElements.delete(rootEl);
165
181
  });
166
182
  }
167
183
  function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrapperModule) {
168
- const rootEl = document.getElementById(root.id);
169
- const islandScheduledIndex = scheduledHydrationIndexCtr;
170
- scheduledHydrationIndexCtr += 1;
171
- if (root.hydrateOn === "visible") {
172
- onVisible(rootEl, () => {
184
+ const rootEls = findIslandElements(root.id);
185
+ rootEls.forEach((rootEl) => {
186
+ if (scheduledElements.has(rootEl)) {
187
+ return;
188
+ }
189
+ scheduledElements.add(rootEl);
190
+ const rootClone = { ...root };
191
+ const islandScheduledIndex = scheduledHydrationIndexCtr;
192
+ scheduledHydrationIndexCtr += 1;
193
+ if (rootClone.hydrateOn === "visible") {
194
+ onVisible(rootEl, () => {
195
+ loadThenHydrate(
196
+ rootClone,
197
+ LoadableIslandModule,
198
+ LoadableWrapperModule,
199
+ rootEl,
200
+ islandScheduledIndex
201
+ );
202
+ });
203
+ } else {
173
204
  loadThenHydrate(
174
- root,
205
+ rootClone,
175
206
  LoadableIslandModule,
176
207
  LoadableWrapperModule,
177
208
  rootEl,
178
209
  islandScheduledIndex
179
210
  );
180
- });
181
- } else {
182
- loadThenHydrate(
183
- root,
184
- LoadableIslandModule,
185
- LoadableWrapperModule,
186
- rootEl,
187
- islandScheduledIndex
188
- );
189
- }
211
+ }
212
+ });
190
213
  }
191
214
  function getLoadableModuleFor(root) {
192
215
  let url = root.url;
@@ -198,14 +221,10 @@ function getLoadableModuleFor(root) {
198
221
  if (shouldForceSeparateJsForAllIslands) {
199
222
  url = `${root.url}?cacheBust=${Date.now()}-${root.id}`;
200
223
  }
201
- const LoadableIslandModule = () => import(
224
+ return () => import(
202
225
  /* @vite-ignore */
203
226
  url
204
227
  );
205
- if (!LoadableIslandModule) {
206
- throw new Error(`Missing island component for ${root.moduleName}`);
207
- }
208
- return LoadableIslandModule;
209
228
  }
210
229
  function hydrateIslandRoots() {
211
230
  if (rootsToProcess === void 0) {
@@ -220,19 +239,11 @@ function hydrateIslandRoots() {
220
239
  let encounteredAnyNonIdleIslands = false;
221
240
  for (const root of rootsToProcess) {
222
241
  if (!root.hydrationStatus) {
223
- root.hydrationStatus = root.hydrationStatus || "HYDRATION_WAITING";
224
242
  if (hydrationTypesToAccept.has(root.hydrateOn)) {
225
243
  encounteredAnyNonIdleIslands = true;
226
- root.hydrationStatus = "HYDRATION_PREPARING";
227
- waitThenLoadAndHydrateIfNeeded(
228
- root,
229
- getLoadableModuleFor(root),
230
- root.wrapperUrl ? getLoadableModuleFor({
231
- url: root.wrapperUrl,
232
- id: `${root.id}-wrapper`,
233
- moduleName: `${root.moduleName}-wrapper`
234
- }) : void 0
235
- );
244
+ prepareAndScheduleRoot(root);
245
+ } else {
246
+ root.hydrationStatus = "HYDRATION_WAITING";
236
247
  }
237
248
  }
238
249
  }
@@ -251,15 +262,19 @@ function unmountIsland(islandId) {
251
262
  const islandToUnmount = rootsToProcess.find(
252
263
  (island) => island.id === islandId
253
264
  );
254
- if (!islandToUnmount || !rootsById.get(islandId)) {
265
+ const reactRoots = rootsById.get(islandId);
266
+ if (!islandToUnmount || !reactRoots || reactRoots.length === 0) {
255
267
  throw new Error(`No known island: ${islandId}`);
256
268
  }
257
269
  const islandIndex = rootsToProcess.indexOf(islandToUnmount);
258
- const reactRoot = rootsById.get(islandId);
259
270
  rootsToProcess.splice(islandIndex, 1);
260
271
  rootsById.delete(islandId);
272
+ const islandEls = findIslandElements(islandId);
273
+ islandEls.forEach((el) => scheduledElements.delete(el));
261
274
  console.log("Unmounting island:", islandId);
262
- reactRoot.unmount();
275
+ for (const reactRoot of reactRoots) {
276
+ reactRoot.unmount();
277
+ }
263
278
  }
264
279
  export {
265
280
  setupIslandHydration,
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-CliAmBEj.js
899
+ // ../cms-js-internal/dist/types-BEz622C8.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";
@@ -1142,7 +1142,6 @@ function getCMSAssetConfigIfExists(webRoot2) {
1142
1142
  }
1143
1143
  var ENABLED_FEATURES_GATE_MAP = {
1144
1144
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
1145
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
1146
1145
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
1147
1146
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
1148
1147
  };
@@ -2250,7 +2249,7 @@ function trackUsage(action) {
2250
2249
  eventName: EVENT_NAME,
2251
2250
  action,
2252
2251
  nodeVersion: getNodeVersionData(),
2253
- version: "1.2.36",
2252
+ version: "1.2.39",
2254
2253
  os: getPlatform()
2255
2254
  };
2256
2255
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -1,7 +1,7 @@
1
1
  // src/storybook/moduleStory.tsx
2
2
  import { useEffect } from "react";
3
3
 
4
- // ../cms-js-internal/dist/types-CliAmBEj.js
4
+ // ../cms-js-internal/dist/types-BEz622C8.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-CliAmBEj.js
11
+ // ../cms-js-internal/dist/types-BEz622C8.js
12
12
  import path from "path";
13
13
  import { createHash } from "crypto";
14
14
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -276,7 +276,7 @@ function getBaseAssetUrlFromBuild(buildDir) {
276
276
  function isUngatedFor(gates, gate) {
277
277
  return gates.includes(gate);
278
278
  }
279
- function ungatedIAtBuildTimeFor(buildDir, gate) {
279
+ function ungatedAtBuildTimeFor(buildDir, gate) {
280
280
  try {
281
281
  const buildInfo = getBuildInfo(buildDir);
282
282
  return isUngatedFor(buildInfo.gates, gate);
@@ -378,8 +378,8 @@ function isStylesheetAsset(staticAsset) {
378
378
  return staticAsset.type === "stylesheet";
379
379
  }
380
380
  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_CliAmBEj = __esm({
382
- "../cms-js-internal/dist/types-CliAmBEj.js"() {
381
+ var init_types_BEz622C8 = __esm({
382
+ "../cms-js-internal/dist/types-BEz622C8.js"() {
383
383
  COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
384
384
  ENTRY_POINTS_PATH = "components/partials/";
385
385
  MODULE_FOLDER_PATH = "components/modules/";
@@ -498,7 +498,6 @@ ${groupEnd}</script>
498
498
  GATES = [
499
499
  "CMS:JSRenderer:GetServerSideProps",
500
500
  "CMS:JSRenderer:ModuleHubl",
501
- "CMS:JSRenderer:RemoveCjsPlugin",
502
501
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
503
502
  "CMS:JSRenderer:AnalyzeCmsModules",
504
503
  "CMS:JSRenderer:StripNullBytes",
@@ -506,7 +505,6 @@ ${groupEnd}</script>
506
505
  ];
507
506
  ENABLED_FEATURES_GATE_MAP = {
508
507
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
509
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
510
508
  "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
511
509
  "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
512
510
  };
@@ -605,7 +603,7 @@ __export(dist_exports, {
605
603
  scriptTagToLogServerMessages: () => scriptTagToLogServerMessages,
606
604
  serializeIslandDataForInlineScript: () => serializeIslandDataForInlineScript,
607
605
  setIn: () => setIn,
608
- ungatedIAtBuildTimeFor: () => ungatedIAtBuildTimeFor,
606
+ ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
609
607
  virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
610
608
  });
611
609
  import * as dotProp from "dot-prop";
@@ -1173,8 +1171,8 @@ function GlobalPartialSlot(props) {
1173
1171
  var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, DND_AREA_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
1174
1172
  var init_dist = __esm({
1175
1173
  "../cms-js-internal/dist/index.js"() {
1176
- init_types_CliAmBEj();
1177
- init_types_CliAmBEj();
1174
+ init_types_BEz622C8();
1175
+ init_types_BEz622C8();
1178
1176
  ({ setProperty, getProperty, hasProperty } = dotProp);
1179
1177
  serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
1180
1178
  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.36",
3
+ "version": "1.2.39",
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.36",
32
+ "@hubspot/cms-components": "^1.2.39",
33
33
  "@hubspot/local-dev-lib": "4.0.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": "84ee77b1dfdfd7fd5421260de5b91edaf48157ff"
136
+ "gitHead": "2ca803c714116540c6082ce72230784051dbc0ea"
137
137
  }