@hubspot/cms-dev-server 1.2.42 → 1.2.44

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.
package/dist/.DS_Store ADDED
Binary file
package/dist/index.js CHANGED
@@ -1642,7 +1642,7 @@ function trackUsage(action) {
1642
1642
  eventName: EVENT_NAME,
1643
1643
  action,
1644
1644
  nodeVersion: getNodeVersionData(),
1645
- version: "1.2.42",
1645
+ version: "1.2.44",
1646
1646
  os: getPlatform()
1647
1647
  };
1648
1648
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -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
@@ -2249,7 +2249,7 @@ function trackUsage(action) {
2249
2249
  eventName: EVENT_NAME,
2250
2250
  action,
2251
2251
  nodeVersion: getNodeVersionData(),
2252
- version: "1.2.42",
2252
+ version: "1.2.44",
2253
2253
  os: getPlatform()
2254
2254
  };
2255
2255
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
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.44",
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.44",
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": "910c6333475c2840fa3053bf558d45963d12a4f2"
137
137
  }
@@ -0,0 +1,2 @@
1
+ export declare function debugAuthContext(authedPortalId: number, cookieValue: string): Promise<void>;
2
+ export declare function compareUrls(originalUrl: string, signedUrl: string): void;
@@ -0,0 +1,2 @@
1
+ export declare function getLocalComponentsPath(): string;
2
+ export declare function shouldUseLocalComponents(): boolean;
@@ -0,0 +1,15 @@
1
+ import { ViteDevServer } from 'vite';
2
+ /**
3
+ * Processes HTML to find remote assets and replace with Vite-managed URLs
4
+ */
5
+ export declare function processRemoteAssets(html: string, viteServer: ViteDevServer): Promise<string>;
6
+ /**
7
+ * Vite plugin to handle remote assets
8
+ */
9
+ export declare function remoteAssetsPlugin(): {
10
+ name: string;
11
+ apply: "serve";
12
+ configResolved(config: any): void;
13
+ resolveId(id: string): string;
14
+ load(id: string): Promise<string>;
15
+ };
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function hubspotStaticAssetsPlugin(): Plugin;
@@ -0,0 +1,7 @@
1
+ import { ViteDevServer, Plugin } from 'vite';
2
+ /**
3
+ * Create a self-contained plugin with proper caching
4
+ */
5
+ export declare function remoteAssetsPlugin(): Plugin & {
6
+ processRemoteAssets: (html: string, viteServer: ViteDevServer) => Promise<string>;
7
+ };
@@ -0,0 +1,6 @@
1
+ import type { Plugin } from 'vite';
2
+ /**
3
+ * Plugin that provides URL signing capabilities
4
+ * Uses internal signing mechanisms when available, with fallback for public environments
5
+ */
6
+ export default function requestSigningPlugin(): Plugin;
@@ -0,0 +1,5 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+ export declare function handleGetModulePages(req: Request, res: Response, next: NextFunction): Promise<Response<any, Record<string, any>>>;
3
+ export declare function handleOpenFile(req: Request, res: Response, next: NextFunction): Response<any, Record<string, any>>;
4
+ export declare function createAppServerRoutes(): import("express-serve-static-core").Router;
5
+ export default createAppServerRoutes;
@@ -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;