@hubspot/cms-dev-server 1.2.75 → 1.2.76
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/index.js +8 -4
- package/dist/island-runtime.js +56 -1
- package/dist/run.js +8 -4
- package/package.json +2 -2
- package/types/lib/renderModulePreview.d.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -1650,7 +1650,7 @@ function trackUsage(action) {
|
|
|
1650
1650
|
eventName: EVENT_NAME,
|
|
1651
1651
|
action,
|
|
1652
1652
|
nodeVersion: getNodeVersionData(),
|
|
1653
|
-
version: "1.2.
|
|
1653
|
+
version: "1.2.76",
|
|
1654
1654
|
os: getPlatform()
|
|
1655
1655
|
};
|
|
1656
1656
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -3092,6 +3092,7 @@ function extractRelevantCss(cssText) {
|
|
|
3092
3092
|
|
|
3093
3093
|
// src/lib/renderModulePreview.ts
|
|
3094
3094
|
import jsdom from "jsdom";
|
|
3095
|
+
var DEFAULT_SECTION_VARIANT = "section1";
|
|
3095
3096
|
var _webDefaultStylesCss = null;
|
|
3096
3097
|
function getWebDefaultStylesCss(metaUrl) {
|
|
3097
3098
|
if (_webDefaultStylesCss === null) {
|
|
@@ -3344,6 +3345,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3344
3345
|
const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
|
|
3345
3346
|
const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
|
|
3346
3347
|
const globalStylesCss = [themeVariablesCss, webDefaultStylesCss].filter(Boolean).join("\n");
|
|
3348
|
+
const sectionVariant = filteredCss ? DEFAULT_SECTION_VARIANT : void 0;
|
|
3347
3349
|
const renderResult = await renderComponentForPlaceholder(
|
|
3348
3350
|
0,
|
|
3349
3351
|
localRenderPlaceholders[0],
|
|
@@ -3355,7 +3357,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3355
3357
|
projectName,
|
|
3356
3358
|
projectComponentPath
|
|
3357
3359
|
);
|
|
3358
|
-
return { ...renderResult, globalStylesCss };
|
|
3360
|
+
return { ...renderResult, globalStylesCss, sectionVariant };
|
|
3359
3361
|
}
|
|
3360
3362
|
|
|
3361
3363
|
// src/routes/partial.ts
|
|
@@ -4296,7 +4298,8 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4296
4298
|
cssNeeded,
|
|
4297
4299
|
renderContext,
|
|
4298
4300
|
inlineAssets,
|
|
4299
|
-
globalStylesCss
|
|
4301
|
+
globalStylesCss,
|
|
4302
|
+
sectionVariant
|
|
4300
4303
|
} = await renderLocalProjectModulePreview(
|
|
4301
4304
|
moduleName,
|
|
4302
4305
|
authedPortalId,
|
|
@@ -4324,6 +4327,7 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4324
4327
|
jsRenderingGates
|
|
4325
4328
|
);
|
|
4326
4329
|
const fullHeightCss = fullHeightPreview ? `<style>html,body{height:100%;width:100%;margin:0}#root{height:100%;width:100%}</style>` : "";
|
|
4330
|
+
const bodyHtml = sectionVariant ? `<div data-section-variant="${sectionVariant}">${renderedHtml}</div>` : renderedHtml;
|
|
4327
4331
|
const html = addScriptInjectionBootstrapper(
|
|
4328
4332
|
htmlShell.replace(
|
|
4329
4333
|
"<!--headend-->",
|
|
@@ -4333,7 +4337,7 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4333
4337
|
cssNeeded,
|
|
4334
4338
|
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
4335
4339
|
].join("\n")
|
|
4336
|
-
).replace(`<!--ssr-outlet-->`,
|
|
4340
|
+
).replace(`<!--ssr-outlet-->`, bodyHtml),
|
|
4337
4341
|
request.query
|
|
4338
4342
|
);
|
|
4339
4343
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
package/dist/island-runtime.js
CHANGED
|
@@ -73,7 +73,9 @@ 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 rootsByElement = /* @__PURE__ */ new WeakMap();
|
|
76
77
|
var scheduledElements = /* @__PURE__ */ new WeakSet();
|
|
78
|
+
var unmountedElements = /* @__PURE__ */ new WeakSet();
|
|
77
79
|
var typedWindow = window;
|
|
78
80
|
function findIslandElements(islandId) {
|
|
79
81
|
if (typeof CSS !== "undefined" && CSS.escape) {
|
|
@@ -87,6 +89,18 @@ function findIslandElements(islandId) {
|
|
|
87
89
|
document.querySelectorAll("[data-hs-island]")
|
|
88
90
|
).filter((el) => el.id === islandId);
|
|
89
91
|
}
|
|
92
|
+
function findModuleWrapperElements(moduleId) {
|
|
93
|
+
if (typeof CSS !== "undefined" && CSS.escape) {
|
|
94
|
+
return Array.from(
|
|
95
|
+
document.querySelectorAll(
|
|
96
|
+
`[data-hs-module-id="${CSS.escape(moduleId)}"]`
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return Array.from(
|
|
101
|
+
document.querySelectorAll("[data-hs-module-id]")
|
|
102
|
+
).filter((el) => el.getAttribute("data-hs-module-id") === moduleId);
|
|
103
|
+
}
|
|
90
104
|
function prepareAndScheduleRoot(root) {
|
|
91
105
|
root.hydrationStatus = "HYDRATION_PREPARING";
|
|
92
106
|
waitThenLoadAndHydrateIfNeeded(
|
|
@@ -150,8 +164,15 @@ function hydrateRoot(entry) {
|
|
|
150
164
|
index: entry.islandScheduledIndex
|
|
151
165
|
};
|
|
152
166
|
const reactRoot = IslandModule.render(renderableIsland);
|
|
167
|
+
if (unmountedElements.has(rootEl)) {
|
|
168
|
+
unmountedElements.delete(rootEl);
|
|
169
|
+
reactRoot == null ? void 0 : reactRoot.unmount();
|
|
170
|
+
finishHydratingRootAndScheduleNext(entry);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
153
173
|
const existingRoots = rootsById.get(root.id) || [];
|
|
154
174
|
rootsById.set(root.id, [...existingRoots, reactRoot]);
|
|
175
|
+
rootsByElement.set(rootEl, reactRoot);
|
|
155
176
|
}
|
|
156
177
|
function pushToHydrationQueue(entry) {
|
|
157
178
|
entry.root.hydrationStatus = "HYDRATION_QUEUED";
|
|
@@ -276,7 +297,41 @@ function unmountIsland(islandId) {
|
|
|
276
297
|
reactRoot.unmount();
|
|
277
298
|
}
|
|
278
299
|
}
|
|
300
|
+
function unmountIslandsForModule(moduleId) {
|
|
301
|
+
const moduleEls = findModuleWrapperElements(moduleId);
|
|
302
|
+
if (moduleEls.length === 0) {
|
|
303
|
+
console.warn(`unmountIslandsForModule: No known module: ${moduleId}`);
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const islandEls = moduleEls.flatMap(
|
|
307
|
+
(moduleEl) => Array.from(moduleEl.querySelectorAll("[data-hs-island]"))
|
|
308
|
+
);
|
|
309
|
+
if (islandEls.length === 0) {
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
console.log("Unmounting islands for module:", moduleId);
|
|
313
|
+
for (const el of islandEls) {
|
|
314
|
+
hydrationQueue = hydrationQueue.filter((entry) => entry.rootEl !== el);
|
|
315
|
+
scheduledElements.add(el);
|
|
316
|
+
unmountedElements.add(el);
|
|
317
|
+
const reactRoot = rootsByElement.get(el);
|
|
318
|
+
if (!reactRoot) {
|
|
319
|
+
continue;
|
|
320
|
+
}
|
|
321
|
+
rootsByElement.delete(el);
|
|
322
|
+
const remainingRoots = (rootsById.get(el.id) || []).filter(
|
|
323
|
+
(root) => root !== reactRoot
|
|
324
|
+
);
|
|
325
|
+
if (remainingRoots.length > 0) {
|
|
326
|
+
rootsById.set(el.id, remainingRoots);
|
|
327
|
+
} else {
|
|
328
|
+
rootsById.delete(el.id);
|
|
329
|
+
}
|
|
330
|
+
reactRoot.unmount();
|
|
331
|
+
}
|
|
332
|
+
}
|
|
279
333
|
export {
|
|
280
334
|
setupIslandHydration,
|
|
281
|
-
unmountIsland
|
|
335
|
+
unmountIsland,
|
|
336
|
+
unmountIslandsForModule
|
|
282
337
|
};
|
package/dist/run.js
CHANGED
|
@@ -2255,7 +2255,7 @@ function trackUsage(action) {
|
|
|
2255
2255
|
eventName: EVENT_NAME,
|
|
2256
2256
|
action,
|
|
2257
2257
|
nodeVersion: getNodeVersionData(),
|
|
2258
|
-
version: "1.2.
|
|
2258
|
+
version: "1.2.76",
|
|
2259
2259
|
os: getPlatform()
|
|
2260
2260
|
};
|
|
2261
2261
|
const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -3697,6 +3697,7 @@ function extractRelevantCss(cssText) {
|
|
|
3697
3697
|
|
|
3698
3698
|
// src/lib/renderModulePreview.ts
|
|
3699
3699
|
import jsdom from "jsdom";
|
|
3700
|
+
var DEFAULT_SECTION_VARIANT = "section1";
|
|
3700
3701
|
var _webDefaultStylesCss = null;
|
|
3701
3702
|
function getWebDefaultStylesCss(metaUrl) {
|
|
3702
3703
|
if (_webDefaultStylesCss === null) {
|
|
@@ -3949,6 +3950,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3949
3950
|
const themeVariablesCss = filteredCss ? `<style data-hs-styles="theme-variables">${filteredCss}</style>` : "";
|
|
3950
3951
|
const webDefaultStylesCss = meta.editor_version === "2.0" ? getWebDefaultStylesCss(import.meta.url) : "";
|
|
3951
3952
|
const globalStylesCss = [themeVariablesCss, webDefaultStylesCss].filter(Boolean).join("\n");
|
|
3953
|
+
const sectionVariant = filteredCss ? DEFAULT_SECTION_VARIANT : void 0;
|
|
3952
3954
|
const renderResult = await renderComponentForPlaceholder(
|
|
3953
3955
|
0,
|
|
3954
3956
|
localRenderPlaceholders[0],
|
|
@@ -3960,7 +3962,7 @@ async function renderLocalProjectModulePreview(moduleName, authedPortalId, authe
|
|
|
3960
3962
|
projectName,
|
|
3961
3963
|
projectComponentPath
|
|
3962
3964
|
);
|
|
3963
|
-
return { ...renderResult, globalStylesCss };
|
|
3965
|
+
return { ...renderResult, globalStylesCss, sectionVariant };
|
|
3964
3966
|
}
|
|
3965
3967
|
|
|
3966
3968
|
// src/routes/partial.ts
|
|
@@ -4901,7 +4903,8 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4901
4903
|
cssNeeded,
|
|
4902
4904
|
renderContext,
|
|
4903
4905
|
inlineAssets,
|
|
4904
|
-
globalStylesCss
|
|
4906
|
+
globalStylesCss,
|
|
4907
|
+
sectionVariant
|
|
4905
4908
|
} = await renderLocalProjectModulePreview(
|
|
4906
4909
|
moduleName,
|
|
4907
4910
|
authedPortalId,
|
|
@@ -4929,6 +4932,7 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4929
4932
|
jsRenderingGates
|
|
4930
4933
|
);
|
|
4931
4934
|
const fullHeightCss = fullHeightPreview ? `<style>html,body{height:100%;width:100%;margin:0}#root{height:100%;width:100%}</style>` : "";
|
|
4935
|
+
const bodyHtml = sectionVariant ? `<div data-section-variant="${sectionVariant}">${renderedHtml}</div>` : renderedHtml;
|
|
4932
4936
|
const html = addScriptInjectionBootstrapper(
|
|
4933
4937
|
htmlShell.replace(
|
|
4934
4938
|
"<!--headend-->",
|
|
@@ -4938,7 +4942,7 @@ async function modulePreviewRouteHandler(request, response) {
|
|
|
4938
4942
|
cssNeeded,
|
|
4939
4943
|
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
4940
4944
|
].join("\n")
|
|
4941
|
-
).replace(`<!--ssr-outlet-->`,
|
|
4945
|
+
).replace(`<!--ssr-outlet-->`, bodyHtml),
|
|
4942
4946
|
request.query
|
|
4943
4947
|
);
|
|
4944
4948
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.76",
|
|
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.
|
|
32
|
+
"@hubspot/cms-components": "^1.2.76",
|
|
33
33
|
"@hubspot/local-dev-lib": "5.10.1",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Gate } from '@hubspot/cms-js-internal';
|
|
2
|
+
export declare const DEFAULT_SECTION_VARIANT = "section1";
|
|
2
3
|
export declare function signGetUrl(authedPortalId: number, unsignedUrl: string): Promise<string>;
|
|
3
4
|
export declare function signedGet(authedPortalId: number, unsignedUrl: string, headers: Record<string, string>, gates: Gate[]): Promise<string>;
|
|
4
5
|
export declare function renderRemoteModulePreview(modulePath: string, authedPortalId: any, authedEnv: any, cookieValue: any, gates: Gate[]): Promise<{
|
|
@@ -8,6 +9,7 @@ export declare function renderRemoteModulePreview(modulePath: string, authedPort
|
|
|
8
9
|
export declare function signUrl(authedPortalId: number, unsignedUrl: string, requestBody: any): Promise<string>;
|
|
9
10
|
export declare function renderLocalProjectModulePreview(moduleName: string, authedPortalId: any, authedEnv: any, authedHublet: any, webRoot: any, viteServer: any, jsRenderingGates: any, projectName: any, projectComponentPath: any, fullOriginalUrl: any, cookieValue: any, fieldOverrides?: {}): Promise<{
|
|
10
11
|
globalStylesCss: string;
|
|
12
|
+
sectionVariant: string;
|
|
11
13
|
html: string;
|
|
12
14
|
inlineAssets?: import("@hubspot/cms-js-internal").InlineAsset[];
|
|
13
15
|
cssNeeded: string;
|