@hubspot/cms-dev-server 1.2.33 → 1.2.35

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.
@@ -1,4 +1,4 @@
1
- // ../cms-js-internal/dist/types-BsFs0N9P.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";
@@ -175,7 +175,7 @@ function resolveIslandPlugin(islandsSet) {
175
175
  idWithNoParam,
176
176
  componentExtension
177
177
  );
178
- const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
178
+ const modulePath = path.relative(viteRoot, idWithNoParam);
179
179
  const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
180
180
  if (islandsSet) {
181
181
  islandsSet.add(moduleId);
@@ -383,15 +383,15 @@ 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
- "CMS:JSRenderer:StripNullBytes"
388
+ "CMS:JSRenderer:StripNullBytes",
389
+ "PortalsAccessIdentity:DesignManager:UrlSigning"
390
390
  ];
391
391
  var ENABLED_FEATURES_GATE_MAP = {
392
392
  "cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
393
- "cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
394
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
393
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
394
+ "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
395
395
  };
396
396
  function isUngatedFor(gates, gate) {
397
397
  return gates.includes(gate);
@@ -107,9 +107,7 @@ function setupIdleCallbackIfNeeded() {
107
107
  }
108
108
  function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
109
109
  rootAndExtraInfo.root.hydrationStatus = "HYDRATED";
110
- hydrationQueue = hydrationQueue.filter(
111
- (x) => x.root.id !== rootAndExtraInfo.root.id
112
- );
110
+ hydrationQueue = hydrationQueue.filter((x) => x !== rootAndExtraInfo);
113
111
  const hasOtherRootsToHydrate = hydrationQueue.length > 0;
114
112
  if (hasOtherRootsToHydrate) {
115
113
  setTimeout(() => hydrateRoot(hydrationQueue[0]), 0);
@@ -136,7 +134,8 @@ function hydrateRoot(rootAndExtraInfo) {
136
134
  index: rootAndExtraInfo.islandScheduledIndex
137
135
  };
138
136
  const reactRoot = IslandModule.render(renderableIsland);
139
- rootsById.set(root.id, reactRoot);
137
+ const existingRoots = rootsById.get(root.id) || [];
138
+ rootsById.set(root.id, [...existingRoots, reactRoot]);
140
139
  }
141
140
  function pushToHydrationQueue(rootAndExtraInfo) {
142
141
  rootAndExtraInfo.root.hydrationStatus = "HYDRATION_QUEUED";
@@ -165,28 +164,42 @@ function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, root
165
164
  });
166
165
  }
167
166
  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, () => {
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
+ }
179
+ rootEls.forEach((rootEl) => {
180
+ const rootClone = { ...root };
181
+ const islandScheduledIndex = scheduledHydrationIndexCtr;
182
+ scheduledHydrationIndexCtr += 1;
183
+ if (rootClone.hydrateOn === "visible") {
184
+ onVisible(rootEl, () => {
185
+ loadThenHydrate(
186
+ rootClone,
187
+ LoadableIslandModule,
188
+ LoadableWrapperModule,
189
+ rootEl,
190
+ islandScheduledIndex
191
+ );
192
+ });
193
+ } else {
173
194
  loadThenHydrate(
174
- root,
195
+ rootClone,
175
196
  LoadableIslandModule,
176
197
  LoadableWrapperModule,
177
198
  rootEl,
178
199
  islandScheduledIndex
179
200
  );
180
- });
181
- } else {
182
- loadThenHydrate(
183
- root,
184
- LoadableIslandModule,
185
- LoadableWrapperModule,
186
- rootEl,
187
- islandScheduledIndex
188
- );
189
- }
201
+ }
202
+ });
190
203
  }
191
204
  function getLoadableModuleFor(root) {
192
205
  let url = root.url;
@@ -251,15 +264,17 @@ function unmountIsland(islandId) {
251
264
  const islandToUnmount = rootsToProcess.find(
252
265
  (island) => island.id === islandId
253
266
  );
254
- if (!islandToUnmount || !rootsById.get(islandId)) {
267
+ const reactRoots = rootsById.get(islandId);
268
+ if (!islandToUnmount || !reactRoots || reactRoots.length === 0) {
255
269
  throw new Error(`No known island: ${islandId}`);
256
270
  }
257
271
  const islandIndex = rootsToProcess.indexOf(islandToUnmount);
258
- const reactRoot = rootsById.get(islandId);
259
272
  rootsToProcess.splice(islandIndex, 1);
260
273
  rootsById.delete(islandId);
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,