@hubspot/cms-dev-server 1.2.79 → 1.2.82

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-Dvw_fW6p.js
1
+ // ../cms-js-internal/dist/types-C8bPIEz4.js
2
2
  import path from "path";
3
3
  import { createHash } from "crypto";
4
4
  import fs, { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
@@ -397,12 +397,10 @@ function getBaseAssetUrlFromBuild(buildDir) {
397
397
  var GATES = [
398
398
  "CMS:JSRenderer:RemoveMockClientEntryPlugin",
399
399
  "CMS:JSRenderer:AnalyzeCmsModules",
400
- "CMS:JSRenderer:StripNullBytes",
401
- "PortalsAccessIdentity:DesignManager:UrlSigning"
400
+ "CMS:JSRenderer:StripNullBytes"
402
401
  ];
403
402
  var ENABLED_FEATURES_GATE_MAP = {
404
- "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
405
- "PortalsAccessIdentity:DesignManager:UrlSigning": "PortalsAccessIdentity:DesignManager:UrlSigning"
403
+ "cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
406
404
  };
407
405
  function isUngatedFor(gates, gate) {
408
406
  return gates.includes(gate);
@@ -80,6 +80,7 @@ var rootsById = /* @__PURE__ */ new Map();
80
80
  var rootsByElement = /* @__PURE__ */ new WeakMap();
81
81
  var scheduledElements = /* @__PURE__ */ new WeakSet();
82
82
  var unmountedElements = /* @__PURE__ */ new WeakSet();
83
+ var pendingElementsByRoot = /* @__PURE__ */ new WeakMap();
83
84
  var typedWindow = window;
84
85
  function findIslandElements(islandId) {
85
86
  if (typeof CSS !== "undefined" && CSS.escape) {
@@ -140,7 +141,11 @@ function setupIdleCallbackIfNeeded() {
140
141
  }
141
142
  }
142
143
  function finishHydratingRootAndScheduleNext(entry) {
143
- entry.root.hydrationStatus = "HYDRATED";
144
+ const pendingElements = pendingElementsByRoot.get(entry.root);
145
+ pendingElements == null ? void 0 : pendingElements.delete(entry.rootEl);
146
+ if (!(pendingElements == null ? void 0 : pendingElements.size)) {
147
+ entry.root.hydrationStatus = "HYDRATED";
148
+ }
144
149
  hydrationQueue = hydrationQueue.filter((x) => x !== entry);
145
150
  const hasOtherRootsToHydrate = hydrationQueue.length > 0;
146
151
  if (hasOtherRootsToHydrate) {
@@ -208,17 +213,21 @@ function loadThenHydrate(root, LoadableIslandModule, LoadableWrapperModule, root
208
213
  function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrapperModule) {
209
214
  const rootEls = findIslandElements(root.id);
210
215
  rootEls.forEach((rootEl) => {
216
+ var _a;
211
217
  if (scheduledElements.has(rootEl)) {
212
218
  return;
213
219
  }
214
220
  scheduledElements.add(rootEl);
215
- const rootClone = { ...root };
221
+ if (!pendingElementsByRoot.has(root)) {
222
+ pendingElementsByRoot.set(root, /* @__PURE__ */ new Set());
223
+ }
224
+ (_a = pendingElementsByRoot.get(root)) == null ? void 0 : _a.add(rootEl);
216
225
  const islandScheduledIndex = scheduledHydrationIndexCtr;
217
226
  scheduledHydrationIndexCtr += 1;
218
- if (rootClone.hydrateOn === "visible") {
227
+ if (root.hydrateOn === "visible") {
219
228
  onVisible(rootEl, () => {
220
229
  loadThenHydrate(
221
- rootClone,
230
+ root,
222
231
  LoadableIslandModule,
223
232
  LoadableWrapperModule,
224
233
  rootEl,
@@ -227,7 +236,7 @@ function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrap
227
236
  });
228
237
  } else {
229
238
  loadThenHydrate(
230
- rootClone,
239
+ root,
231
240
  LoadableIslandModule,
232
241
  LoadableWrapperModule,
233
242
  rootEl,
@@ -316,6 +325,13 @@ function unmountIslandsForModule(moduleId) {
316
325
  console.log("Unmounting islands for module:", moduleId);
317
326
  for (const el of islandEls) {
318
327
  hydrationQueue = hydrationQueue.filter((entry) => entry.rootEl !== el);
328
+ const root = rootsToProcess.find((r) => r.id === el.id);
329
+ if (root) {
330
+ const pendingElements = pendingElementsByRoot.get(root);
331
+ if ((pendingElements == null ? void 0 : pendingElements.delete(el)) && pendingElements.size === 0 && rootsById.has(el.id)) {
332
+ root.hydrationStatus = "HYDRATED";
333
+ }
334
+ }
319
335
  scheduledElements.add(el);
320
336
  unmountedElements.add(el);
321
337
  const reactRoot = rootsByElement.get(el);
@@ -324,7 +340,7 @@ function unmountIslandsForModule(moduleId) {
324
340
  }
325
341
  rootsByElement.delete(el);
326
342
  const remainingRoots = (rootsById.get(el.id) || []).filter(
327
- (root) => root !== reactRoot
343
+ (root2) => root2 !== reactRoot
328
344
  );
329
345
  if (remainingRoots.length > 0) {
330
346
  rootsById.set(el.id, remainingRoots);