@hubspot/cms-dev-server 0.7.0 → 0.7.2
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 +7 -18
- package/dist/internalSsr.js +29 -37
- package/dist/island-runtime.js +23 -27
- package/dist/run.js +36 -53
- package/dist/storybook-main/main.js +31 -39
- package/package.json +3 -3
- package/types/createViteDevServer.d.ts +1 -1
- package/types/noNodeBuiltinsPlugin.d.ts +3 -0
package/dist/index.js
CHANGED
|
@@ -4,13 +4,9 @@ import { default as react } from "@vitejs/plugin-react";
|
|
|
4
4
|
|
|
5
5
|
// ../cms-js-internal/dist/index.js
|
|
6
6
|
import path, { basename } from "path";
|
|
7
|
-
function isUngatedFor(gates, gate) {
|
|
8
|
-
return gates.includes(gate);
|
|
9
|
-
}
|
|
10
7
|
var viteRoot;
|
|
11
8
|
var viteCommand;
|
|
12
|
-
function resolveIslandPlugin(
|
|
13
|
-
const sharedDepsEnabled = isUngatedFor(gates, "CMS:JSRenderer:SharedDeps");
|
|
9
|
+
function resolveIslandPlugin() {
|
|
14
10
|
return {
|
|
15
11
|
enforce: "pre",
|
|
16
12
|
name: "resolve-islands",
|
|
@@ -21,17 +17,14 @@ function resolveIslandPlugin(gates) {
|
|
|
21
17
|
load(id) {
|
|
22
18
|
if (id.endsWith("?island") || id.endsWith("?client")) {
|
|
23
19
|
const [idWithNoParam] = id.split("?");
|
|
24
|
-
const islandModuleImportPath =
|
|
20
|
+
const islandModuleImportPath = `${idWithNoParam}?client-entry`;
|
|
25
21
|
const componentExtension = path.extname(idWithNoParam);
|
|
26
22
|
const componentFilenameWithNoExtension = path.basename(
|
|
27
23
|
idWithNoParam,
|
|
28
24
|
componentExtension
|
|
29
25
|
);
|
|
30
26
|
const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
|
|
31
|
-
|
|
32
|
-
if (sharedDepsEnabled) {
|
|
33
|
-
moduleId = moduleId.concat("?client-entry");
|
|
34
|
-
}
|
|
27
|
+
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
35
28
|
return `
|
|
36
29
|
const moduleId = '${moduleId}';
|
|
37
30
|
|
|
@@ -46,7 +39,7 @@ function resolveIslandPlugin(gates) {
|
|
|
46
39
|
}
|
|
47
40
|
};
|
|
48
41
|
}
|
|
49
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
42
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
50
43
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
51
44
|
function clientIslandEntryPlugin() {
|
|
52
45
|
return {
|
|
@@ -82,11 +75,7 @@ function clientIslandEntryPlugin() {
|
|
|
82
75
|
|
|
83
76
|
// src/createViteDevServer.ts
|
|
84
77
|
import mkcert from "vite-plugin-mkcert";
|
|
85
|
-
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [],
|
|
86
|
-
const sharedDepsEnabled = isUngatedFor(
|
|
87
|
-
jsRenderingGates,
|
|
88
|
-
"CMS:JSRenderer:SharedDeps"
|
|
89
|
-
);
|
|
78
|
+
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], __jsRenderingGates) {
|
|
90
79
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
91
80
|
`${proxyDomain}.localhost`,
|
|
92
81
|
`${proxyDomain}.hslocal.net`
|
|
@@ -123,8 +112,8 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
123
112
|
plugins: [
|
|
124
113
|
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
125
114
|
react(),
|
|
126
|
-
|
|
127
|
-
resolveIslandPlugin(
|
|
115
|
+
clientIslandEntryPlugin(),
|
|
116
|
+
resolveIslandPlugin()
|
|
128
117
|
],
|
|
129
118
|
css: {
|
|
130
119
|
postcss: webRoot
|
package/dist/internalSsr.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// ../cms-js-internal/dist/index.js
|
|
2
2
|
import path, { basename } from "path";
|
|
3
|
-
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
4
3
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
5
4
|
import stream from "stream";
|
|
6
5
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
7
6
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
8
7
|
import { ServerRenderContext } from "@hubspot/cms-components";
|
|
9
8
|
import { createHash } from "crypto";
|
|
9
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
10
10
|
import { join } from "path/posix";
|
|
11
11
|
import { cloneElement } from "react";
|
|
12
12
|
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -181,38 +181,9 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
181
181
|
indent
|
|
182
182
|
)}`;
|
|
183
183
|
};
|
|
184
|
-
var GATES = [
|
|
185
|
-
"CMS:JSRenderer:SharedDeps",
|
|
186
|
-
"CMS:JSRenderer:GetServerSideProps",
|
|
187
|
-
"CMS:JSRenderer:GraphQLQueryBuild",
|
|
188
|
-
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
189
|
-
];
|
|
190
|
-
var ENABLED_FEATURES_GATE_MAP = {
|
|
191
|
-
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
192
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
193
|
-
"cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
|
|
194
|
-
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
195
|
-
};
|
|
196
|
-
function isUngatedFor(gates, gate) {
|
|
197
|
-
return gates.includes(gate);
|
|
198
|
-
}
|
|
199
|
-
var BUILD_INFO_PATH = "/build-info.json";
|
|
200
|
-
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
201
|
-
try {
|
|
202
|
-
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
203
|
-
const buildInfo = JSON.parse(
|
|
204
|
-
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
205
|
-
);
|
|
206
|
-
return isUngatedFor(buildInfo.gates, gate);
|
|
207
|
-
} catch (e) {
|
|
208
|
-
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
209
|
-
return false;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
184
|
var viteRoot;
|
|
213
185
|
var viteCommand;
|
|
214
|
-
function resolveIslandPlugin(
|
|
215
|
-
const sharedDepsEnabled = isUngatedFor(gates, "CMS:JSRenderer:SharedDeps");
|
|
186
|
+
function resolveIslandPlugin() {
|
|
216
187
|
return {
|
|
217
188
|
enforce: "pre",
|
|
218
189
|
name: "resolve-islands",
|
|
@@ -223,17 +194,14 @@ function resolveIslandPlugin(gates) {
|
|
|
223
194
|
load(id) {
|
|
224
195
|
if (id.endsWith("?island") || id.endsWith("?client")) {
|
|
225
196
|
const [idWithNoParam] = id.split("?");
|
|
226
|
-
const islandModuleImportPath =
|
|
197
|
+
const islandModuleImportPath = `${idWithNoParam}?client-entry`;
|
|
227
198
|
const componentExtension = path.extname(idWithNoParam);
|
|
228
199
|
const componentFilenameWithNoExtension = path.basename(
|
|
229
200
|
idWithNoParam,
|
|
230
201
|
componentExtension
|
|
231
202
|
);
|
|
232
203
|
const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
|
|
233
|
-
|
|
234
|
-
if (sharedDepsEnabled) {
|
|
235
|
-
moduleId = moduleId.concat("?client-entry");
|
|
236
|
-
}
|
|
204
|
+
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
237
205
|
return `
|
|
238
206
|
const moduleId = '${moduleId}';
|
|
239
207
|
|
|
@@ -248,7 +216,7 @@ function resolveIslandPlugin(gates) {
|
|
|
248
216
|
}
|
|
249
217
|
};
|
|
250
218
|
}
|
|
251
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
219
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
252
220
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
253
221
|
function clientIslandEntryPlugin() {
|
|
254
222
|
return {
|
|
@@ -416,6 +384,30 @@ function getIslandRuntimeConfigUrl() {
|
|
|
416
384
|
const fileVersion = hsEnv === "prod" ? `island-runtime.mjs` : "island-runtime-qa.mjs";
|
|
417
385
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
418
386
|
}
|
|
387
|
+
var GATES = [
|
|
388
|
+
"CMS:JSRenderer:GetServerSideProps",
|
|
389
|
+
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
390
|
+
];
|
|
391
|
+
var ENABLED_FEATURES_GATE_MAP = {
|
|
392
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
393
|
+
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
394
|
+
};
|
|
395
|
+
function isUngatedFor(gates, gate) {
|
|
396
|
+
return gates.includes(gate);
|
|
397
|
+
}
|
|
398
|
+
var BUILD_INFO_PATH = "/build-info.json";
|
|
399
|
+
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
400
|
+
try {
|
|
401
|
+
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
402
|
+
const buildInfo = JSON.parse(
|
|
403
|
+
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
404
|
+
);
|
|
405
|
+
return isUngatedFor(buildInfo.gates, gate);
|
|
406
|
+
} catch (e) {
|
|
407
|
+
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
408
|
+
return false;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
419
411
|
var findAllComponentsIn = (webRoot, componentsFolder, includeSubdirIndexJS) => {
|
|
420
412
|
const fullComponentsFolderPath = join(webRoot, componentsFolder);
|
|
421
413
|
const componentsByName = {};
|
package/dist/island-runtime.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
// ../cms-js-internal/dist/island-runtime/island-runtime.js
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var onVisible = (islandEl, callback) => {
|
|
3
|
+
const observer = new IntersectionObserver((entries) => {
|
|
4
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
5
|
+
observer.disconnect();
|
|
6
|
+
callback();
|
|
7
|
+
}
|
|
8
|
+
return;
|
|
9
|
+
});
|
|
10
|
+
for (let i = 0; i < islandEl.children.length; i++) {
|
|
11
|
+
const child = islandEl.children[i];
|
|
12
|
+
observer.observe(child);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
6
15
|
var rootsToProcess;
|
|
7
16
|
var hydrationQueue = [];
|
|
8
17
|
var hydrationTypesToAccept = /* @__PURE__ */ new Set(["load", "visible"]);
|
|
@@ -14,8 +23,8 @@ var typedWindow = window;
|
|
|
14
23
|
var startHydratingIdleRoots = () => {
|
|
15
24
|
hydrationTypesToAccept.add("idle");
|
|
16
25
|
for (const root of rootsToProcess) {
|
|
17
|
-
if (root.hydrationStatus === HYDRATION_WAITING && hydrationTypesToAccept.has(root.hydrateOn)) {
|
|
18
|
-
root.hydrationStatus = HYDRATION_PREPARING;
|
|
26
|
+
if (root.hydrationStatus === "HYDRATION_WAITING" && hydrationTypesToAccept.has(root.hydrateOn)) {
|
|
27
|
+
root.hydrationStatus = "HYDRATION_PREPARING";
|
|
19
28
|
waitThenLoadAndHydrateIfNeeded(root, getLoadableModuleFor(root));
|
|
20
29
|
}
|
|
21
30
|
}
|
|
@@ -35,7 +44,7 @@ function setupIdleCallbackIfNeeded() {
|
|
|
35
44
|
}
|
|
36
45
|
}
|
|
37
46
|
function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
|
|
38
|
-
rootAndExtraInfo.root.hydrationStatus = HYDRATED;
|
|
47
|
+
rootAndExtraInfo.root.hydrationStatus = "HYDRATED";
|
|
39
48
|
hydrationQueue = hydrationQueue.filter(
|
|
40
49
|
(x) => x.root.id !== rootAndExtraInfo.root.id
|
|
41
50
|
);
|
|
@@ -62,10 +71,10 @@ function hydrateRoot(rootAndExtraInfo) {
|
|
|
62
71
|
index: rootAndExtraInfo.islandScheduledIndex
|
|
63
72
|
};
|
|
64
73
|
const reactRoot = IslandModule.render(renderableIsland);
|
|
65
|
-
rootsById
|
|
74
|
+
rootsById.set(root.id, reactRoot);
|
|
66
75
|
}
|
|
67
76
|
function pushToHydrationQueue(rootAndExtraInfo) {
|
|
68
|
-
rootAndExtraInfo.root.hydrationStatus = HYDRATION_QUEUED;
|
|
77
|
+
rootAndExtraInfo.root.hydrationStatus = "HYDRATION_QUEUED";
|
|
69
78
|
hydrationQueue.push(rootAndExtraInfo);
|
|
70
79
|
if (hydrationQueue.length === 1) {
|
|
71
80
|
hydrateRoot(rootAndExtraInfo);
|
|
@@ -121,10 +130,10 @@ function hydrateIslandRoots() {
|
|
|
121
130
|
let encounteredAnyNonIdleIslands = false;
|
|
122
131
|
for (const root of rootsToProcess) {
|
|
123
132
|
if (!root.hydrationStatus) {
|
|
124
|
-
root.hydrationStatus = root.hydrationStatus || HYDRATION_WAITING;
|
|
133
|
+
root.hydrationStatus = root.hydrationStatus || "HYDRATION_WAITING";
|
|
125
134
|
if (hydrationTypesToAccept.has(root.hydrateOn)) {
|
|
126
135
|
encounteredAnyNonIdleIslands = true;
|
|
127
|
-
root.hydrationStatus = HYDRATION_PREPARING;
|
|
136
|
+
root.hydrationStatus = "HYDRATION_PREPARING";
|
|
128
137
|
waitThenLoadAndHydrateIfNeeded(root, getLoadableModuleFor(root));
|
|
129
138
|
}
|
|
130
139
|
}
|
|
@@ -142,29 +151,16 @@ function setupIslandHydration() {
|
|
|
142
151
|
}
|
|
143
152
|
function unmountIsland(islandId) {
|
|
144
153
|
const islandToUnmount = rootsToProcess.find((island) => island.id === islandId);
|
|
145
|
-
if (!islandToUnmount || !rootsById
|
|
154
|
+
if (!islandToUnmount || !rootsById.get(islandId)) {
|
|
146
155
|
throw new Error(`No known island: ${islandId}`);
|
|
147
156
|
}
|
|
148
157
|
const islandIndex = rootsToProcess.indexOf(islandToUnmount);
|
|
149
|
-
const reactRoot = rootsById
|
|
158
|
+
const reactRoot = rootsById.get(islandId);
|
|
150
159
|
rootsToProcess.splice(islandIndex, 1);
|
|
151
|
-
delete
|
|
160
|
+
rootsById.delete(islandId);
|
|
152
161
|
console.log("Unmounting island:", islandId);
|
|
153
162
|
reactRoot.unmount();
|
|
154
163
|
}
|
|
155
|
-
var onVisible = (islandEl, callback) => {
|
|
156
|
-
const observer = new IntersectionObserver((entries) => {
|
|
157
|
-
if (entries.some((entry) => entry.isIntersecting)) {
|
|
158
|
-
observer.disconnect();
|
|
159
|
-
callback();
|
|
160
|
-
}
|
|
161
|
-
return;
|
|
162
|
-
});
|
|
163
|
-
for (let i = 0; i < islandEl.children.length; i++) {
|
|
164
|
-
const child = islandEl.children[i];
|
|
165
|
-
observer.observe(child);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
164
|
export {
|
|
169
165
|
setupIslandHydration,
|
|
170
166
|
unmountIsland
|
package/dist/run.js
CHANGED
|
@@ -39,7 +39,7 @@ import express2 from "express";
|
|
|
39
39
|
import http3 from "http";
|
|
40
40
|
import bodyParser from "body-parser";
|
|
41
41
|
import { spawn } from "child_process";
|
|
42
|
-
import { normalizePath as
|
|
42
|
+
import { normalizePath as normalizePath5 } from "vite";
|
|
43
43
|
import { Transform } from "stream";
|
|
44
44
|
|
|
45
45
|
// src/routes/createDevServerRoutes.ts
|
|
@@ -57,13 +57,13 @@ function fullOriginalUrlFromRequest(request2) {
|
|
|
57
57
|
|
|
58
58
|
// ../cms-js-internal/dist/index.js
|
|
59
59
|
import path, { basename } from "path";
|
|
60
|
-
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
61
60
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
62
61
|
import stream from "stream";
|
|
63
62
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
64
63
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
65
64
|
import { ServerRenderContext } from "@hubspot/cms-components";
|
|
66
65
|
import { createHash } from "crypto";
|
|
66
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
67
67
|
import { join } from "path/posix";
|
|
68
68
|
import { cloneElement } from "react";
|
|
69
69
|
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -177,19 +177,9 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
177
177
|
indent
|
|
178
178
|
)}`;
|
|
179
179
|
};
|
|
180
|
-
var ENABLED_FEATURES_GATE_MAP = {
|
|
181
|
-
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
182
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
183
|
-
"cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
|
|
184
|
-
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
185
|
-
};
|
|
186
|
-
function isUngatedFor(gates, gate) {
|
|
187
|
-
return gates.includes(gate);
|
|
188
|
-
}
|
|
189
180
|
var viteRoot;
|
|
190
181
|
var viteCommand;
|
|
191
|
-
function resolveIslandPlugin(
|
|
192
|
-
const sharedDepsEnabled = isUngatedFor(gates, "CMS:JSRenderer:SharedDeps");
|
|
182
|
+
function resolveIslandPlugin() {
|
|
193
183
|
return {
|
|
194
184
|
enforce: "pre",
|
|
195
185
|
name: "resolve-islands",
|
|
@@ -200,17 +190,14 @@ function resolveIslandPlugin(gates) {
|
|
|
200
190
|
load(id) {
|
|
201
191
|
if (id.endsWith("?island") || id.endsWith("?client")) {
|
|
202
192
|
const [idWithNoParam] = id.split("?");
|
|
203
|
-
const islandModuleImportPath =
|
|
193
|
+
const islandModuleImportPath = `${idWithNoParam}?client-entry`;
|
|
204
194
|
const componentExtension = path.extname(idWithNoParam);
|
|
205
195
|
const componentFilenameWithNoExtension = path.basename(
|
|
206
196
|
idWithNoParam,
|
|
207
197
|
componentExtension
|
|
208
198
|
);
|
|
209
199
|
const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
|
|
210
|
-
|
|
211
|
-
if (sharedDepsEnabled) {
|
|
212
|
-
moduleId = moduleId.concat("?client-entry");
|
|
213
|
-
}
|
|
200
|
+
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
214
201
|
return `
|
|
215
202
|
const moduleId = '${moduleId}';
|
|
216
203
|
|
|
@@ -225,7 +212,7 @@ function resolveIslandPlugin(gates) {
|
|
|
225
212
|
}
|
|
226
213
|
};
|
|
227
214
|
}
|
|
228
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {
|
|
215
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
229
216
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
230
217
|
function clientIslandEntryPlugin() {
|
|
231
218
|
return {
|
|
@@ -370,6 +357,13 @@ function getEntryPointHashWithIndexSuffix(entryPoint, index) {
|
|
|
370
357
|
const renderIndexSuffix = index != null ? `i${index}` : "";
|
|
371
358
|
return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;
|
|
372
359
|
}
|
|
360
|
+
var ENABLED_FEATURES_GATE_MAP = {
|
|
361
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
362
|
+
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
363
|
+
};
|
|
364
|
+
function isUngatedFor(gates, gate) {
|
|
365
|
+
return gates.includes(gate);
|
|
366
|
+
}
|
|
373
367
|
var findAllComponentsIn = (webRoot2, componentsFolder, includeSubdirIndexJS) => {
|
|
374
368
|
const fullComponentsFolderPath = join(webRoot2, componentsFolder);
|
|
375
369
|
const componentsByName = {};
|
|
@@ -503,7 +497,9 @@ import url from "url";
|
|
|
503
497
|
import { normalizePath } from "vite";
|
|
504
498
|
function packagePath(metaUrl, projectPath) {
|
|
505
499
|
if (true) {
|
|
506
|
-
return
|
|
500
|
+
return normalizePath(
|
|
501
|
+
path2.resolve(path2.dirname(url.fileURLToPath(metaUrl)), projectPath)
|
|
502
|
+
);
|
|
507
503
|
}
|
|
508
504
|
const parentDirPath = normalizePath(path2.dirname(url.fileURLToPath(metaUrl)));
|
|
509
505
|
const subPath = parentDirPath.replace(/^.+cms-dev-server\/src\//, "");
|
|
@@ -662,30 +658,19 @@ var renderPartial_default = renderPartial;
|
|
|
662
658
|
// src/lib/templates.ts
|
|
663
659
|
import { promises as fsPromises } from "fs";
|
|
664
660
|
var { readFile } = fsPromises;
|
|
665
|
-
var generateIslandSetupScriptBlock = (
|
|
666
|
-
|
|
667
|
-
return `<script type="module">
|
|
661
|
+
var generateIslandSetupScriptBlock = () => {
|
|
662
|
+
return `<script type="module">
|
|
668
663
|
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
669
664
|
initConfigSingletonFromJSON(window.__hsEnvConfig);
|
|
670
665
|
</script>
|
|
671
666
|
<script type="module">
|
|
672
667
|
import { setupIslandHydration } from '${packagePath(
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
668
|
+
import.meta.url,
|
|
669
|
+
"island-runtime"
|
|
670
|
+
)}';
|
|
676
671
|
setupIslandHydration();
|
|
677
672
|
</script>
|
|
678
673
|
`;
|
|
679
|
-
}
|
|
680
|
-
return `<script type="module">
|
|
681
|
-
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
682
|
-
initConfigSingletonFromJSON(window.__hsEnvConfig);
|
|
683
|
-
</script>
|
|
684
|
-
<script type="module">
|
|
685
|
-
import { setupIslandHydration } from '@hubspot/cms-components/island-runtime';
|
|
686
|
-
setupIslandHydration();
|
|
687
|
-
</script>
|
|
688
|
-
`;
|
|
689
674
|
};
|
|
690
675
|
var createdPlainHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock) => {
|
|
691
676
|
const htmlTemplateBase = await readFile(baseTemplatePath, "utf-8");
|
|
@@ -696,7 +681,7 @@ var createdPlainHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
696
681
|
<!--bodyend-->`
|
|
697
682
|
);
|
|
698
683
|
};
|
|
699
|
-
var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
684
|
+
var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock) => {
|
|
700
685
|
let htmlTemplate = await createdPlainHtmlTemplate(
|
|
701
686
|
baseTemplatePath,
|
|
702
687
|
title,
|
|
@@ -705,14 +690,14 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
705
690
|
htmlTemplate = htmlTemplate.replace(
|
|
706
691
|
"<!--bodyend-->",
|
|
707
692
|
`
|
|
708
|
-
${generateIslandSetupScriptBlock(
|
|
693
|
+
${generateIslandSetupScriptBlock()}
|
|
709
694
|
<!-- ISLAND_RUNTIME_AND_SETUP_SCRIPT_BLOCK -->
|
|
710
695
|
<!--islandsglobal-->
|
|
711
696
|
`
|
|
712
697
|
);
|
|
713
698
|
return htmlTemplate;
|
|
714
699
|
};
|
|
715
|
-
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer,
|
|
700
|
+
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, __jsRenderingGates) => {
|
|
716
701
|
let htmlTemplate;
|
|
717
702
|
if (renderContext.islands.length) {
|
|
718
703
|
const globalScriptBlock = getServerGlobalsToInject(
|
|
@@ -723,8 +708,7 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
|
|
|
723
708
|
htmlTemplate = await createIslandHtmlTemplate(
|
|
724
709
|
baseTemplatePath,
|
|
725
710
|
title,
|
|
726
|
-
globalScriptBlock
|
|
727
|
-
jsRenderingGates
|
|
711
|
+
globalScriptBlock
|
|
728
712
|
);
|
|
729
713
|
htmlTemplate = htmlTemplate.replace(
|
|
730
714
|
"<!--islandsglobal-->",
|
|
@@ -750,12 +734,12 @@ var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, tit
|
|
|
750
734
|
}
|
|
751
735
|
return viteServer.transformIndexHtml(url3, htmlTemplate);
|
|
752
736
|
};
|
|
753
|
-
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer,
|
|
737
|
+
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, __gates) => {
|
|
754
738
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
755
739
|
const { createIslandsGlobalJsForClientInDev: createIslandsGlobalJsForClientInDev2 } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
756
740
|
const islandRuntimeScript = await viteServer.transformIndexHtml(
|
|
757
741
|
"/",
|
|
758
|
-
generateIslandSetupScriptBlock(
|
|
742
|
+
generateIslandSetupScriptBlock()
|
|
759
743
|
);
|
|
760
744
|
return `${islandRuntimeScript}
|
|
761
745
|
<script>${createIslandsGlobalJsForClientInDev2(
|
|
@@ -1243,6 +1227,7 @@ async function fetchContentMetadata(url3, portalId) {
|
|
|
1243
1227
|
|
|
1244
1228
|
// src/proxyPage/proxyPage.ts
|
|
1245
1229
|
import path5 from "path";
|
|
1230
|
+
import { normalizePath as normalizePath4 } from "vite";
|
|
1246
1231
|
import { getAccountId as getAccountId2, getEnv } from "@hubspot/cli-lib/lib/config.js";
|
|
1247
1232
|
import { get as hsGet3 } from "@hubspot/cli-lib/http.js";
|
|
1248
1233
|
|
|
@@ -1515,7 +1500,9 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
|
|
|
1515
1500
|
`The specified component folder "${projectComponentFolder}" does not match the webroot project component folder "${webRootProjectComponent}/${projectComponentFolder}" specified to the cms-dev-server. Components must be located within the webroot project folder. Check that the specified path is correct: ${placeholderPath}.`
|
|
1516
1501
|
);
|
|
1517
1502
|
}
|
|
1518
|
-
const resolvedPath =
|
|
1503
|
+
const resolvedPath = normalizePath4(
|
|
1504
|
+
path5.resolve(webRoot2, partialPath, componentFileName)
|
|
1505
|
+
);
|
|
1519
1506
|
const entryPointPath = [
|
|
1520
1507
|
"@projects",
|
|
1521
1508
|
webRootProjectComponent,
|
|
@@ -2101,11 +2088,7 @@ async function startShadowDevServer(devServerPort, shadowPort, projectName, jsRe
|
|
|
2101
2088
|
import { createServer as createViteServer } from "vite";
|
|
2102
2089
|
import { default as react } from "@vitejs/plugin-react";
|
|
2103
2090
|
import mkcert from "vite-plugin-mkcert";
|
|
2104
|
-
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [],
|
|
2105
|
-
const sharedDepsEnabled = isUngatedFor(
|
|
2106
|
-
jsRenderingGates,
|
|
2107
|
-
"CMS:JSRenderer:SharedDeps"
|
|
2108
|
-
);
|
|
2091
|
+
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], __jsRenderingGates) {
|
|
2109
2092
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
2110
2093
|
`${proxyDomain}.localhost`,
|
|
2111
2094
|
`${proxyDomain}.hslocal.net`
|
|
@@ -2142,8 +2125,8 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
2142
2125
|
plugins: [
|
|
2143
2126
|
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
2144
2127
|
react(),
|
|
2145
|
-
|
|
2146
|
-
resolveIslandPlugin(
|
|
2128
|
+
clientIslandEntryPlugin(),
|
|
2129
|
+
resolveIslandPlugin()
|
|
2147
2130
|
],
|
|
2148
2131
|
css: {
|
|
2149
2132
|
postcss: webRoot2
|
|
@@ -2311,7 +2294,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2311
2294
|
);
|
|
2312
2295
|
let authedPortalId = null;
|
|
2313
2296
|
let authedEnv = null;
|
|
2314
|
-
let jsRenderingGates = [
|
|
2297
|
+
let jsRenderingGates = [];
|
|
2315
2298
|
let personalAccessKey = null;
|
|
2316
2299
|
if (hubspotCliConfigPathOption2 && hubspotCliAccountNameOption2) {
|
|
2317
2300
|
console.log(
|
|
@@ -2375,7 +2358,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2375
2358
|
}
|
|
2376
2359
|
}
|
|
2377
2360
|
const authedHublet = "na1";
|
|
2378
|
-
const absoluteWebRoot =
|
|
2361
|
+
const absoluteWebRoot = normalizePath5(path6.resolve(process.cwd(), webRoot2));
|
|
2379
2362
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
2380
2363
|
const viteServer = await createViteDevServer_default(
|
|
2381
2364
|
absoluteWebRoot,
|
|
@@ -50,13 +50,13 @@ __export(dist_exports, {
|
|
|
50
50
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
51
51
|
});
|
|
52
52
|
import path, { basename } from "path";
|
|
53
|
-
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
54
53
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
55
54
|
import stream from "stream";
|
|
56
55
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
57
56
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
58
57
|
import { ServerRenderContext } from "@hubspot/cms-components";
|
|
59
58
|
import { createHash } from "crypto";
|
|
59
|
+
import { readFileSync, existsSync, readdirSync, lstatSync } from "fs";
|
|
60
60
|
import { join } from "path/posix";
|
|
61
61
|
import { cloneElement } from "react";
|
|
62
62
|
function createPreloadLink(assetPath, basePath = "") {
|
|
@@ -117,23 +117,7 @@ function getPerServerRequestUrls(perServerRequestData, viteDevServer) {
|
|
|
117
117
|
});
|
|
118
118
|
return perServerRequestDataWithUrls;
|
|
119
119
|
}
|
|
120
|
-
function
|
|
121
|
-
return gates.includes(gate);
|
|
122
|
-
}
|
|
123
|
-
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
124
|
-
try {
|
|
125
|
-
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
126
|
-
const buildInfo = JSON.parse(
|
|
127
|
-
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
128
|
-
);
|
|
129
|
-
return isUngatedFor(buildInfo.gates, gate);
|
|
130
|
-
} catch (e) {
|
|
131
|
-
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
132
|
-
return false;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
function resolveIslandPlugin(gates) {
|
|
136
|
-
const sharedDepsEnabled = isUngatedFor(gates, "CMS:JSRenderer:SharedDeps");
|
|
120
|
+
function resolveIslandPlugin() {
|
|
137
121
|
return {
|
|
138
122
|
enforce: "pre",
|
|
139
123
|
name: "resolve-islands",
|
|
@@ -144,17 +128,14 @@ function resolveIslandPlugin(gates) {
|
|
|
144
128
|
load(id) {
|
|
145
129
|
if (id.endsWith("?island") || id.endsWith("?client")) {
|
|
146
130
|
const [idWithNoParam] = id.split("?");
|
|
147
|
-
const islandModuleImportPath =
|
|
131
|
+
const islandModuleImportPath = `${idWithNoParam}?client-entry`;
|
|
148
132
|
const componentExtension = path.extname(idWithNoParam);
|
|
149
133
|
const componentFilenameWithNoExtension = path.basename(
|
|
150
134
|
idWithNoParam,
|
|
151
135
|
componentExtension
|
|
152
136
|
);
|
|
153
137
|
const modulePath = idWithNoParam.replace(`${viteRoot}/`, "");
|
|
154
|
-
|
|
155
|
-
if (sharedDepsEnabled) {
|
|
156
|
-
moduleId = moduleId.concat("?client-entry");
|
|
157
|
-
}
|
|
138
|
+
const moduleId = (viteCommand === "serve" ? idWithNoParam : modulePath).concat("?client-entry");
|
|
158
139
|
return `
|
|
159
140
|
const moduleId = '${moduleId}';
|
|
160
141
|
|
|
@@ -245,6 +226,21 @@ function getIslandRuntimeConfigUrl() {
|
|
|
245
226
|
const fileVersion = hsEnv === "prod" ? `island-runtime.mjs` : "island-runtime-qa.mjs";
|
|
246
227
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
247
228
|
}
|
|
229
|
+
function isUngatedFor(gates, gate) {
|
|
230
|
+
return gates.includes(gate);
|
|
231
|
+
}
|
|
232
|
+
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
233
|
+
try {
|
|
234
|
+
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
235
|
+
const buildInfo = JSON.parse(
|
|
236
|
+
readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()
|
|
237
|
+
);
|
|
238
|
+
return isUngatedFor(buildInfo.gates, gate);
|
|
239
|
+
} catch (e) {
|
|
240
|
+
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
248
244
|
function findAllModulesInRoot(webRoot2) {
|
|
249
245
|
const allModuleComponents = findAllComponentsIn(
|
|
250
246
|
webRoot2,
|
|
@@ -338,7 +334,7 @@ function renderFieldsToJson(fields) {
|
|
|
338
334
|
);
|
|
339
335
|
return moduleJson;
|
|
340
336
|
}
|
|
341
|
-
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, serializeIslandDataToJSON, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev,
|
|
337
|
+
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, serializeIslandDataToJSON, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, viteRoot, viteCommand, clientRenderIsland, virtualClientRenderIslandModuleId, jsx2, promiseForNewWritableStream, renderStreamToPromise, scriptTagToLogServerMessages, getComponentExtension, hasComponentExtension, isStorybookStory, removeComponentExtension, COMBINED_REACT_BASE_PATH, ISLAND_RUNTIME_CONFIG_BASE_PATH, GATES, ENABLED_FEATURES_GATE_MAP, BUILD_INFO_PATH, findAllComponentsIn;
|
|
342
338
|
var init_dist = __esm({
|
|
343
339
|
"../cms-js-internal/dist/index.js"() {
|
|
344
340
|
COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -455,20 +451,7 @@ ${indentString}`);
|
|
|
455
451
|
indent
|
|
456
452
|
)}`;
|
|
457
453
|
};
|
|
458
|
-
|
|
459
|
-
"CMS:JSRenderer:SharedDeps",
|
|
460
|
-
"CMS:JSRenderer:GetServerSideProps",
|
|
461
|
-
"CMS:JSRenderer:GraphQLQueryBuild",
|
|
462
|
-
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
463
|
-
];
|
|
464
|
-
ENABLED_FEATURES_GATE_MAP = {
|
|
465
|
-
"cms:jsr:sharedDeps": "CMS:JSRenderer:SharedDeps",
|
|
466
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
467
|
-
"cms:jsr:graphqQLQueryBuild": "CMS:JSRenderer:GraphQLQueryBuild",
|
|
468
|
-
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
469
|
-
};
|
|
470
|
-
BUILD_INFO_PATH = "/build-info.json";
|
|
471
|
-
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport {\n ClientRenderContextProvider,\n buildIslandIdentifierPrefix,\n} from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
454
|
+
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: any\n) {\n const { island, rootElement, postHydration, pageUrl, islands, basePath } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n <Component islandId={island.id} {...island.props} />\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
472
455
|
virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
473
456
|
jsx2 = jsxRuntime.jsx;
|
|
474
457
|
promiseForNewWritableStream = () => {
|
|
@@ -560,6 +543,15 @@ ${groupEnd}</script>
|
|
|
560
543
|
};
|
|
561
544
|
COMBINED_REACT_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/react/v18";
|
|
562
545
|
ISLAND_RUNTIME_CONFIG_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1";
|
|
546
|
+
GATES = [
|
|
547
|
+
"CMS:JSRenderer:GetServerSideProps",
|
|
548
|
+
"CMS:JSRenderer:SeparateIslandRenderOption"
|
|
549
|
+
];
|
|
550
|
+
ENABLED_FEATURES_GATE_MAP = {
|
|
551
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
552
|
+
"cms:jsr:separateIslandRenderOption": "CMS:JSRenderer:SeparateIslandRenderOption"
|
|
553
|
+
};
|
|
554
|
+
BUILD_INFO_PATH = "/build-info.json";
|
|
563
555
|
findAllComponentsIn = (webRoot2, componentsFolder, includeSubdirIndexJS) => {
|
|
564
556
|
const fullComponentsFolderPath = join(webRoot2, componentsFolder);
|
|
565
557
|
const componentsByName = {};
|
|
@@ -641,7 +633,7 @@ var main_default = {
|
|
|
641
633
|
css: {
|
|
642
634
|
postcss: webRoot
|
|
643
635
|
},
|
|
644
|
-
plugins: [resolveIslandPlugin2(
|
|
636
|
+
plugins: [resolveIslandPlugin2()]
|
|
645
637
|
};
|
|
646
638
|
return mergeConfig(config, viteConfig);
|
|
647
639
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@hubspot/cli-lib": "^3.0.12",
|
|
28
|
-
"@hubspot/cms-components": "^0.7.
|
|
28
|
+
"@hubspot/cms-components": "^0.7.2",
|
|
29
29
|
"@storybook/addon-actions": "7.0.7",
|
|
30
30
|
"@storybook/addon-essentials": "7.0.7",
|
|
31
31
|
"@storybook/addon-interactions": "7.0.7",
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"publishConfig": {
|
|
98
98
|
"access": "public"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "c7d8d001f21316fb22f45a9466be0ff36d824756"
|
|
101
101
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[],
|
|
1
|
+
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[], __jsRenderingGates: string[]): Promise<import("vite").ViteDevServer>;
|
|
2
2
|
export default createViteDevServer;
|