@hubspot/cms-dev-server 0.4.6 → 0.4.15
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 +20 -12
- package/dist/internalSsr.js +77 -37
- package/dist/run.js +189 -100
- package/dist/storybook/index.js +8 -11
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -3,20 +3,17 @@ import { createServer as createViteServer } from "vite";
|
|
|
3
3
|
import { default as react } from "@vitejs/plugin-react";
|
|
4
4
|
|
|
5
5
|
// ../cms-js-internal/dist/index.js
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path, { basename } from "path";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
import * as jsxRuntime from "react/jsx-runtime";
|
|
7
9
|
import stream from "stream";
|
|
8
|
-
import { renderToPipeableStream } from "react-dom/server";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
createServerRenderContext
|
|
12
|
-
} from "@hubspot/cms-components";
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
import path2 from "path";
|
|
10
|
+
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
11
|
+
import { createServerRenderContext, ServerRenderContext } from "@hubspot/cms-components";
|
|
12
|
+
import { createHash } from "crypto";
|
|
15
13
|
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
16
|
-
import { join
|
|
17
|
-
import { basename } from "path";
|
|
14
|
+
import { join } from "path/posix";
|
|
18
15
|
import { cloneElement } from "react";
|
|
19
|
-
|
|
16
|
+
var require2 = createRequire(import.meta.url);
|
|
20
17
|
function isUngatedFor(gates, gate) {
|
|
21
18
|
return gates.includes(gate);
|
|
22
19
|
}
|
|
@@ -59,15 +56,23 @@ function resolveIslandPlugin(gates) {
|
|
|
59
56
|
}
|
|
60
57
|
};
|
|
61
58
|
}
|
|
59
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } 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 } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: `island-${renderableIsland.index}-`,\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 >\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";
|
|
60
|
+
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
62
61
|
function clientIslandEntryPlugin() {
|
|
63
62
|
return {
|
|
64
63
|
enforce: "pre",
|
|
65
64
|
name: "client-island-entry-plugin",
|
|
65
|
+
resolveId(id) {
|
|
66
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
67
|
+
return virtualClientRenderIslandModuleId;
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
},
|
|
66
71
|
load(id) {
|
|
67
72
|
if (id.endsWith("?client-entry")) {
|
|
68
73
|
const [idWithNoParam] = id.split("?");
|
|
69
74
|
return `
|
|
70
|
-
import { clientRenderIsland } from '
|
|
75
|
+
import { clientRenderIsland } from '${virtualClientRenderIslandModuleId}';
|
|
71
76
|
import Component from '${idWithNoParam}';
|
|
72
77
|
|
|
73
78
|
export function render(island) {
|
|
@@ -77,6 +82,9 @@ function clientIslandEntryPlugin() {
|
|
|
77
82
|
export default Component;
|
|
78
83
|
`;
|
|
79
84
|
}
|
|
85
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
86
|
+
return clientRenderIsland;
|
|
87
|
+
}
|
|
80
88
|
return null;
|
|
81
89
|
}
|
|
82
90
|
};
|
package/dist/internalSsr.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
// ../cms-js-internal/dist/index.js
|
|
2
|
-
import path from "path";
|
|
2
|
+
import path, { basename } from "path";
|
|
3
|
+
import { createRequire } from "module";
|
|
4
|
+
import * as jsxRuntime from "react/jsx-runtime";
|
|
3
5
|
import stream from "stream";
|
|
4
|
-
import { renderToPipeableStream } from "react-dom/server";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
createServerRenderContext
|
|
8
|
-
} from "@hubspot/cms-components";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
import path2 from "path";
|
|
6
|
+
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
7
|
+
import { createServerRenderContext, ServerRenderContext } from "@hubspot/cms-components";
|
|
8
|
+
import { createHash } from "crypto";
|
|
11
9
|
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
12
|
-
import { join
|
|
13
|
-
import { basename } from "path";
|
|
10
|
+
import { join } from "path/posix";
|
|
14
11
|
import { cloneElement } from "react";
|
|
15
|
-
|
|
12
|
+
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
13
|
+
var ENTRY_POINTS_PATH = "components/partials/";
|
|
14
|
+
var MODULE_FOLDER_PATH = "components/modules/";
|
|
15
|
+
var VIRTUAL_ISLAND_RUNTIME = "virtual:island-runtime";
|
|
16
|
+
var VIRTUAL_CONFIG_SETUP = "virtual:config-setup";
|
|
17
|
+
var CSS_LANGS_RE = /\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\?)/;
|
|
16
18
|
var collectCssModules = (modulePathToStartWith, viteServer, cssModulesImported = /* @__PURE__ */ new Set()) => {
|
|
17
19
|
const appModulesForPath = viteServer.moduleGraph.fileToModulesMap.get(
|
|
18
20
|
modulePathToStartWith
|
|
@@ -31,7 +33,7 @@ var collectCssModules = (modulePathToStartWith, viteServer, cssModulesImported =
|
|
|
31
33
|
continue;
|
|
32
34
|
}
|
|
33
35
|
allServerSideModulesImported.add(importedModule.id);
|
|
34
|
-
const isCss = importedModule.file
|
|
36
|
+
const isCss = CSS_LANGS_RE.test(importedModule.file);
|
|
35
37
|
const moduleModulesToQueue = Array.from(importedModule.importedModules);
|
|
36
38
|
if (isCss && !cssModulesImported.has(importedModule)) {
|
|
37
39
|
cssModulesImported.add(importedModule);
|
|
@@ -47,7 +49,7 @@ function createPreloadLink(assetPath, basePath = "") {
|
|
|
47
49
|
}
|
|
48
50
|
if (assetPath.endsWith(".js")) {
|
|
49
51
|
return `<link rel="modulepreload" crossorigin href="${basePath}${assetPath}">`;
|
|
50
|
-
} else if (
|
|
52
|
+
} else if (CSS_LANGS_RE.test(assetPath)) {
|
|
51
53
|
return `<link rel="stylesheet" href="${basePath}${assetPath}?css">`;
|
|
52
54
|
} else if (assetPath.endsWith(".woff")) {
|
|
53
55
|
return ` <link rel="preload" href="${basePath}${assetPath}" as="font" type="font/woff" crossorigin>`;
|
|
@@ -150,13 +152,30 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
150
152
|
indent
|
|
151
153
|
)}${writeSharedStateToJsGlobal(islands, perServerRequestData, indent)}`;
|
|
152
154
|
};
|
|
155
|
+
var require2 = createRequire(import.meta.url);
|
|
153
156
|
var GATES = [
|
|
154
157
|
"CMS:JSRenderer:SharedDeps",
|
|
155
|
-
"CMS:JSRenderer:GetServerSideProps"
|
|
158
|
+
"CMS:JSRenderer:GetServerSideProps",
|
|
159
|
+
"CMS:JSRenderer:LocalProxySchemaVersion1",
|
|
160
|
+
"CMS:JSRenderer:GraphQLQueryBuild"
|
|
156
161
|
];
|
|
157
162
|
function isUngatedFor(gates, gate) {
|
|
158
163
|
return gates.includes(gate);
|
|
159
164
|
}
|
|
165
|
+
var BUILD_INFO_PATH = "/build-info.json";
|
|
166
|
+
function ungatedAtBuildTimeFor(buildDir, gate) {
|
|
167
|
+
try {
|
|
168
|
+
console.log("loading path", path.join(buildDir, BUILD_INFO_PATH));
|
|
169
|
+
const buildInfo = require2(path.join(
|
|
170
|
+
buildDir,
|
|
171
|
+
BUILD_INFO_PATH
|
|
172
|
+
));
|
|
173
|
+
return isUngatedFor(buildInfo.gates, gate);
|
|
174
|
+
} catch (e) {
|
|
175
|
+
console.error(`error loading build-info.json, path: ${BUILD_INFO_PATH}`);
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
160
179
|
var viteRoot;
|
|
161
180
|
var viteCommand;
|
|
162
181
|
function resolveIslandPlugin(gates) {
|
|
@@ -196,15 +215,23 @@ function resolveIslandPlugin(gates) {
|
|
|
196
215
|
}
|
|
197
216
|
};
|
|
198
217
|
}
|
|
218
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } 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 } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: `island-${renderableIsland.index}-`,\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 >\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";
|
|
219
|
+
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
199
220
|
function clientIslandEntryPlugin() {
|
|
200
221
|
return {
|
|
201
222
|
enforce: "pre",
|
|
202
223
|
name: "client-island-entry-plugin",
|
|
224
|
+
resolveId(id) {
|
|
225
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
226
|
+
return virtualClientRenderIslandModuleId;
|
|
227
|
+
}
|
|
228
|
+
return null;
|
|
229
|
+
},
|
|
203
230
|
load(id) {
|
|
204
231
|
if (id.endsWith("?client-entry")) {
|
|
205
232
|
const [idWithNoParam] = id.split("?");
|
|
206
233
|
return `
|
|
207
|
-
import { clientRenderIsland } from '
|
|
234
|
+
import { clientRenderIsland } from '${virtualClientRenderIslandModuleId}';
|
|
208
235
|
import Component from '${idWithNoParam}';
|
|
209
236
|
|
|
210
237
|
export function render(island) {
|
|
@@ -214,10 +241,14 @@ function clientIslandEntryPlugin() {
|
|
|
214
241
|
export default Component;
|
|
215
242
|
`;
|
|
216
243
|
}
|
|
244
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
245
|
+
return clientRenderIsland;
|
|
246
|
+
}
|
|
217
247
|
return null;
|
|
218
248
|
}
|
|
219
249
|
};
|
|
220
250
|
}
|
|
251
|
+
var jsx2 = jsxRuntime.jsx;
|
|
221
252
|
var promiseForNewWritableStream = () => {
|
|
222
253
|
const chunks = [];
|
|
223
254
|
const writableStream = new stream.Writable();
|
|
@@ -236,12 +267,13 @@ var promiseForNewWritableStream = () => {
|
|
|
236
267
|
});
|
|
237
268
|
return { streamDonePromise, writableStream };
|
|
238
269
|
};
|
|
239
|
-
var renderStreamToPromise = async (reactElements) => {
|
|
270
|
+
var renderStreamToPromise = async (reactElements, renderOptions = {}) => {
|
|
240
271
|
const { streamDonePromise, writableStream } = promiseForNewWritableStream();
|
|
241
272
|
const {
|
|
242
273
|
pipe
|
|
243
274
|
/* abort */
|
|
244
275
|
} = renderToPipeableStream(reactElements, {
|
|
276
|
+
...renderOptions,
|
|
245
277
|
onShellReady() {
|
|
246
278
|
},
|
|
247
279
|
onAllReady() {
|
|
@@ -276,19 +308,21 @@ ${consoleLines.join("\n")}
|
|
|
276
308
|
${groupEnd}</script>
|
|
277
309
|
`;
|
|
278
310
|
};
|
|
279
|
-
async function renderComponentOnServer(Component, props, pageUrl, environmentConfig) {
|
|
311
|
+
async function renderComponentOnServer(Component, props, pageUrl, environmentConfig, renderOptions) {
|
|
280
312
|
const componentDebugName = Component.displayName || Component.name;
|
|
281
313
|
return renderOnServer(
|
|
282
|
-
/* @__PURE__ */
|
|
314
|
+
/* @__PURE__ */ jsx2(Component, { ...props }),
|
|
283
315
|
pageUrl,
|
|
284
316
|
environmentConfig,
|
|
285
|
-
componentDebugName
|
|
317
|
+
componentDebugName,
|
|
318
|
+
renderOptions
|
|
286
319
|
);
|
|
287
320
|
}
|
|
288
|
-
async function renderOnServer(elements, pageUrl, environmentConfig, debugName) {
|
|
321
|
+
async function renderOnServer(elements, pageUrl, environmentConfig, debugName, renderOptions) {
|
|
289
322
|
const renderContext = createServerRenderContext(pageUrl, environmentConfig);
|
|
290
323
|
let html = await renderStreamToPromise(
|
|
291
|
-
/* @__PURE__ */
|
|
324
|
+
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
325
|
+
renderOptions
|
|
292
326
|
);
|
|
293
327
|
if (renderContext.messagesForBrowser.length > 0) {
|
|
294
328
|
html = `${html}${scriptTagToLogServerMessages(
|
|
@@ -298,11 +332,6 @@ async function renderOnServer(elements, pageUrl, environmentConfig, debugName) {
|
|
|
298
332
|
}
|
|
299
333
|
return { html, renderContext };
|
|
300
334
|
}
|
|
301
|
-
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
302
|
-
var ENTRY_POINTS_PATH = "components/partials/";
|
|
303
|
-
var MODULE_FOLDER_PATH = "components/modules/";
|
|
304
|
-
var VIRTUAL_ISLAND_RUNTIME = "virtual:island-runtime";
|
|
305
|
-
var VIRTUAL_CONFIG_SETUP = "virtual:config-setup";
|
|
306
335
|
var getComponentExtension = (componentPath) => {
|
|
307
336
|
const filteredExtensions = COMPONENT_EXTENSIONS.filter(
|
|
308
337
|
(ext) => componentPath.endsWith(ext)
|
|
@@ -316,7 +345,7 @@ var hasComponentExtension = (componentPath) => {
|
|
|
316
345
|
return !!getComponentExtension(componentPath);
|
|
317
346
|
};
|
|
318
347
|
var isStorybookStory = (componentPath) => {
|
|
319
|
-
return !!
|
|
348
|
+
return !!path.basename(componentPath, path.extname(componentPath)).endsWith(".stories");
|
|
320
349
|
};
|
|
321
350
|
var removeComponentExtension = (componentPath) => {
|
|
322
351
|
const ext = getComponentExtension(componentPath);
|
|
@@ -325,6 +354,13 @@ var removeComponentExtension = (componentPath) => {
|
|
|
325
354
|
}
|
|
326
355
|
return componentPath.slice(0, -1 * ext.length);
|
|
327
356
|
};
|
|
357
|
+
function getEntryPointHash(entryPoint) {
|
|
358
|
+
return createHash("md5").update(entryPoint).digest("hex").slice(0, 6);
|
|
359
|
+
}
|
|
360
|
+
function getEntryPointHashWithIndexSuffix(entryPoint, index) {
|
|
361
|
+
const renderIndexSuffix = index != null ? `i${index}` : "";
|
|
362
|
+
return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;
|
|
363
|
+
}
|
|
328
364
|
var COMBINED_REACT_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/react/v18";
|
|
329
365
|
var ISLAND_RUNTIME_CONFIG_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1";
|
|
330
366
|
function getCombinedReactUrl() {
|
|
@@ -338,25 +374,25 @@ function getIslandRuntimeConfigUrl() {
|
|
|
338
374
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
339
375
|
}
|
|
340
376
|
var findAllComponentsIn = (webRoot, componentsFolder, includeSubdirIndexJS) => {
|
|
341
|
-
const fullComponentsFolderPath =
|
|
377
|
+
const fullComponentsFolderPath = join(webRoot, componentsFolder);
|
|
342
378
|
const componentsByName = {};
|
|
343
379
|
if (!existsSync(fullComponentsFolderPath)) {
|
|
344
380
|
return componentsByName;
|
|
345
381
|
}
|
|
346
382
|
readdirSync(fullComponentsFolderPath).forEach((fileOrFolderName) => {
|
|
347
|
-
const fullPath =
|
|
348
|
-
const subdirPath =
|
|
383
|
+
const fullPath = join(fullComponentsFolderPath, fileOrFolderName);
|
|
384
|
+
const subdirPath = join(componentsFolder, fileOrFolderName);
|
|
349
385
|
const isDirectory = lstatSync(fullPath).isDirectory();
|
|
350
386
|
if (!isDirectory && hasComponentExtension(fileOrFolderName) && !isStorybookStory(fileOrFolderName)) {
|
|
351
387
|
const subdirPathNoExtension = removeComponentExtension(subdirPath);
|
|
352
388
|
componentsByName[subdirPathNoExtension] = subdirPath;
|
|
353
389
|
} else if (isDirectory && includeSubdirIndexJS) {
|
|
354
390
|
for (const potentialExtension of COMPONENT_EXTENSIONS) {
|
|
355
|
-
const potentialIndexModule =
|
|
391
|
+
const potentialIndexModule = join(
|
|
356
392
|
subdirPath,
|
|
357
393
|
`index${potentialExtension}`
|
|
358
394
|
);
|
|
359
|
-
const fullPotentialPath =
|
|
395
|
+
const fullPotentialPath = join(
|
|
360
396
|
fullPath,
|
|
361
397
|
`index${potentialExtension}`
|
|
362
398
|
);
|
|
@@ -370,9 +406,8 @@ var findAllComponentsIn = (webRoot, componentsFolder, includeSubdirIndexJS) => {
|
|
|
370
406
|
});
|
|
371
407
|
return componentsByName;
|
|
372
408
|
};
|
|
373
|
-
var findAllComponentsIn_default = findAllComponentsIn;
|
|
374
409
|
function findAllModulesInRoot(webRoot) {
|
|
375
|
-
const allModuleComponents =
|
|
410
|
+
const allModuleComponents = findAllComponentsIn(
|
|
376
411
|
webRoot,
|
|
377
412
|
"./components/modules",
|
|
378
413
|
true
|
|
@@ -384,7 +419,7 @@ function findAllModulesInRoot(webRoot) {
|
|
|
384
419
|
return { moduleNames, moduleSubpaths };
|
|
385
420
|
}
|
|
386
421
|
function findAllPartialsInRoot(webRoot) {
|
|
387
|
-
const allPartialComponents =
|
|
422
|
+
const allPartialComponents = findAllComponentsIn(
|
|
388
423
|
webRoot,
|
|
389
424
|
"./components/partials",
|
|
390
425
|
false
|
|
@@ -442,6 +477,7 @@ function renderFieldsToJson(fields) {
|
|
|
442
477
|
}
|
|
443
478
|
export {
|
|
444
479
|
COMPONENT_EXTENSIONS,
|
|
480
|
+
CSS_LANGS_RE,
|
|
445
481
|
ENTRY_POINTS_PATH,
|
|
446
482
|
GATES,
|
|
447
483
|
MODULE_FOLDER_PATH,
|
|
@@ -451,11 +487,13 @@ export {
|
|
|
451
487
|
collectCssInDev,
|
|
452
488
|
collectCssModules,
|
|
453
489
|
createIslandsGlobalJsForClientInDev,
|
|
454
|
-
|
|
490
|
+
findAllComponentsIn,
|
|
455
491
|
findAllModulesInRoot,
|
|
456
492
|
findAllPartialsInRoot,
|
|
457
493
|
getCombinedReactUrl,
|
|
458
494
|
getComponentExtension,
|
|
495
|
+
getEntryPointHash,
|
|
496
|
+
getEntryPointHashWithIndexSuffix,
|
|
459
497
|
getIslandRuntimeConfigUrl,
|
|
460
498
|
getIslandUrls,
|
|
461
499
|
getServerGlobalsToInject,
|
|
@@ -469,5 +507,7 @@ export {
|
|
|
469
507
|
renderStreamToPromise,
|
|
470
508
|
resolveIslandPlugin,
|
|
471
509
|
serializeIslandDataToJSON,
|
|
472
|
-
setIn
|
|
510
|
+
setIn,
|
|
511
|
+
ungatedAtBuildTimeFor,
|
|
512
|
+
virtualClientRenderIslandModuleId
|
|
473
513
|
};
|
package/dist/run.js
CHANGED
|
@@ -33,7 +33,7 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
// src/createDevServer.ts
|
|
36
|
-
import
|
|
36
|
+
import path6 from "path";
|
|
37
37
|
import url2 from "url";
|
|
38
38
|
import express2 from "express";
|
|
39
39
|
import http3 from "http";
|
|
@@ -46,7 +46,7 @@ import { Router } from "express";
|
|
|
46
46
|
import { createProxyMiddleware } from "http-proxy-middleware";
|
|
47
47
|
|
|
48
48
|
// src/routes/partial.ts
|
|
49
|
-
import
|
|
49
|
+
import path3 from "path";
|
|
50
50
|
import { normalizePath as normalizePath2 } from "vite";
|
|
51
51
|
|
|
52
52
|
// src/lib/fullOriginalUrlFromRequest.ts
|
|
@@ -55,20 +55,19 @@ function fullOriginalUrlFromRequest(request2) {
|
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
// ../cms-js-internal/dist/index.js
|
|
58
|
-
import path from "path";
|
|
58
|
+
import path, { basename } from "path";
|
|
59
|
+
import { createRequire } from "module";
|
|
60
|
+
import * as jsxRuntime from "react/jsx-runtime";
|
|
59
61
|
import stream from "stream";
|
|
60
|
-
import { renderToPipeableStream } from "react-dom/server";
|
|
61
|
-
import {
|
|
62
|
-
|
|
63
|
-
createServerRenderContext
|
|
64
|
-
} from "@hubspot/cms-components";
|
|
65
|
-
import { jsx } from "react/jsx-runtime";
|
|
66
|
-
import path2 from "path";
|
|
62
|
+
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
63
|
+
import { createServerRenderContext, ServerRenderContext } from "@hubspot/cms-components";
|
|
64
|
+
import { createHash } from "crypto";
|
|
67
65
|
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
68
|
-
import { join
|
|
69
|
-
import { basename } from "path";
|
|
66
|
+
import { join } from "path/posix";
|
|
70
67
|
import { cloneElement } from "react";
|
|
71
|
-
|
|
68
|
+
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
69
|
+
var ENTRY_POINTS_PATH = "components/partials/";
|
|
70
|
+
var MODULE_FOLDER_PATH = "components/modules/";
|
|
72
71
|
var serializeIslandDataToJSON = (tweakedIslandsArray, indent = 0) => {
|
|
73
72
|
const indentString = new Array(indent).fill(" ").join("");
|
|
74
73
|
return `${JSON.stringify(
|
|
@@ -148,6 +147,7 @@ var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevS
|
|
|
148
147
|
indent
|
|
149
148
|
)}${writeSharedStateToJsGlobal(islands, perServerRequestData, indent)}`;
|
|
150
149
|
};
|
|
150
|
+
var require2 = createRequire(import.meta.url);
|
|
151
151
|
function isUngatedFor(gates, gate) {
|
|
152
152
|
return gates.includes(gate);
|
|
153
153
|
}
|
|
@@ -190,15 +190,23 @@ function resolveIslandPlugin(gates) {
|
|
|
190
190
|
}
|
|
191
191
|
};
|
|
192
192
|
}
|
|
193
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } 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 } =\n renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: `island-${renderableIsland.index}-`,\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 >\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";
|
|
194
|
+
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
193
195
|
function clientIslandEntryPlugin() {
|
|
194
196
|
return {
|
|
195
197
|
enforce: "pre",
|
|
196
198
|
name: "client-island-entry-plugin",
|
|
199
|
+
resolveId(id) {
|
|
200
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
201
|
+
return virtualClientRenderIslandModuleId;
|
|
202
|
+
}
|
|
203
|
+
return null;
|
|
204
|
+
},
|
|
197
205
|
load(id) {
|
|
198
206
|
if (id.endsWith("?client-entry")) {
|
|
199
207
|
const [idWithNoParam] = id.split("?");
|
|
200
208
|
return `
|
|
201
|
-
import { clientRenderIsland } from '
|
|
209
|
+
import { clientRenderIsland } from '${virtualClientRenderIslandModuleId}';
|
|
202
210
|
import Component from '${idWithNoParam}';
|
|
203
211
|
|
|
204
212
|
export function render(island) {
|
|
@@ -208,10 +216,14 @@ function clientIslandEntryPlugin() {
|
|
|
208
216
|
export default Component;
|
|
209
217
|
`;
|
|
210
218
|
}
|
|
219
|
+
if (id === virtualClientRenderIslandModuleId) {
|
|
220
|
+
return clientRenderIsland;
|
|
221
|
+
}
|
|
211
222
|
return null;
|
|
212
223
|
}
|
|
213
224
|
};
|
|
214
225
|
}
|
|
226
|
+
var jsx2 = jsxRuntime.jsx;
|
|
215
227
|
var promiseForNewWritableStream = () => {
|
|
216
228
|
const chunks = [];
|
|
217
229
|
const writableStream = new stream.Writable();
|
|
@@ -230,12 +242,13 @@ var promiseForNewWritableStream = () => {
|
|
|
230
242
|
});
|
|
231
243
|
return { streamDonePromise, writableStream };
|
|
232
244
|
};
|
|
233
|
-
var renderStreamToPromise = async (reactElements) => {
|
|
245
|
+
var renderStreamToPromise = async (reactElements, renderOptions = {}) => {
|
|
234
246
|
const { streamDonePromise, writableStream } = promiseForNewWritableStream();
|
|
235
247
|
const {
|
|
236
248
|
pipe
|
|
237
249
|
/* abort */
|
|
238
250
|
} = renderToPipeableStream(reactElements, {
|
|
251
|
+
...renderOptions,
|
|
239
252
|
onShellReady() {
|
|
240
253
|
},
|
|
241
254
|
onAllReady() {
|
|
@@ -270,10 +283,11 @@ ${consoleLines.join("\n")}
|
|
|
270
283
|
${groupEnd}</script>
|
|
271
284
|
`;
|
|
272
285
|
};
|
|
273
|
-
async function renderOnServer(elements, pageUrl, environmentConfig, debugName) {
|
|
286
|
+
async function renderOnServer(elements, pageUrl, environmentConfig, debugName, renderOptions) {
|
|
274
287
|
const renderContext = createServerRenderContext(pageUrl, environmentConfig);
|
|
275
288
|
let html = await renderStreamToPromise(
|
|
276
|
-
/* @__PURE__ */
|
|
289
|
+
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
290
|
+
renderOptions
|
|
277
291
|
);
|
|
278
292
|
if (renderContext.messagesForBrowser.length > 0) {
|
|
279
293
|
html = `${html}${scriptTagToLogServerMessages(
|
|
@@ -283,9 +297,6 @@ async function renderOnServer(elements, pageUrl, environmentConfig, debugName) {
|
|
|
283
297
|
}
|
|
284
298
|
return { html, renderContext };
|
|
285
299
|
}
|
|
286
|
-
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
287
|
-
var ENTRY_POINTS_PATH = "components/partials/";
|
|
288
|
-
var MODULE_FOLDER_PATH = "components/modules/";
|
|
289
300
|
var getComponentExtension = (componentPath) => {
|
|
290
301
|
const filteredExtensions = COMPONENT_EXTENSIONS.filter(
|
|
291
302
|
(ext) => componentPath.endsWith(ext)
|
|
@@ -299,7 +310,7 @@ var hasComponentExtension = (componentPath) => {
|
|
|
299
310
|
return !!getComponentExtension(componentPath);
|
|
300
311
|
};
|
|
301
312
|
var isStorybookStory = (componentPath) => {
|
|
302
|
-
return !!
|
|
313
|
+
return !!path.basename(componentPath, path.extname(componentPath)).endsWith(".stories");
|
|
303
314
|
};
|
|
304
315
|
var removeComponentExtension = (componentPath) => {
|
|
305
316
|
const ext = getComponentExtension(componentPath);
|
|
@@ -308,26 +319,33 @@ var removeComponentExtension = (componentPath) => {
|
|
|
308
319
|
}
|
|
309
320
|
return componentPath.slice(0, -1 * ext.length);
|
|
310
321
|
};
|
|
322
|
+
function getEntryPointHash(entryPoint) {
|
|
323
|
+
return createHash("md5").update(entryPoint).digest("hex").slice(0, 6);
|
|
324
|
+
}
|
|
325
|
+
function getEntryPointHashWithIndexSuffix(entryPoint, index) {
|
|
326
|
+
const renderIndexSuffix = index != null ? `i${index}` : "";
|
|
327
|
+
return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;
|
|
328
|
+
}
|
|
311
329
|
var findAllComponentsIn = (webRoot2, componentsFolder, includeSubdirIndexJS) => {
|
|
312
|
-
const fullComponentsFolderPath =
|
|
330
|
+
const fullComponentsFolderPath = join(webRoot2, componentsFolder);
|
|
313
331
|
const componentsByName = {};
|
|
314
332
|
if (!existsSync(fullComponentsFolderPath)) {
|
|
315
333
|
return componentsByName;
|
|
316
334
|
}
|
|
317
335
|
readdirSync(fullComponentsFolderPath).forEach((fileOrFolderName) => {
|
|
318
|
-
const fullPath =
|
|
319
|
-
const subdirPath =
|
|
336
|
+
const fullPath = join(fullComponentsFolderPath, fileOrFolderName);
|
|
337
|
+
const subdirPath = join(componentsFolder, fileOrFolderName);
|
|
320
338
|
const isDirectory = lstatSync(fullPath).isDirectory();
|
|
321
339
|
if (!isDirectory && hasComponentExtension(fileOrFolderName) && !isStorybookStory(fileOrFolderName)) {
|
|
322
340
|
const subdirPathNoExtension = removeComponentExtension(subdirPath);
|
|
323
341
|
componentsByName[subdirPathNoExtension] = subdirPath;
|
|
324
342
|
} else if (isDirectory && includeSubdirIndexJS) {
|
|
325
343
|
for (const potentialExtension of COMPONENT_EXTENSIONS) {
|
|
326
|
-
const potentialIndexModule =
|
|
344
|
+
const potentialIndexModule = join(
|
|
327
345
|
subdirPath,
|
|
328
346
|
`index${potentialExtension}`
|
|
329
347
|
);
|
|
330
|
-
const fullPotentialPath =
|
|
348
|
+
const fullPotentialPath = join(
|
|
331
349
|
fullPath,
|
|
332
350
|
`index${potentialExtension}`
|
|
333
351
|
);
|
|
@@ -341,9 +359,8 @@ var findAllComponentsIn = (webRoot2, componentsFolder, includeSubdirIndexJS) =>
|
|
|
341
359
|
});
|
|
342
360
|
return componentsByName;
|
|
343
361
|
};
|
|
344
|
-
var findAllComponentsIn_default = findAllComponentsIn;
|
|
345
362
|
function findAllModulesInRoot(webRoot2) {
|
|
346
|
-
const allModuleComponents =
|
|
363
|
+
const allModuleComponents = findAllComponentsIn(
|
|
347
364
|
webRoot2,
|
|
348
365
|
"./components/modules",
|
|
349
366
|
true
|
|
@@ -355,7 +372,7 @@ function findAllModulesInRoot(webRoot2) {
|
|
|
355
372
|
return { moduleNames, moduleSubpaths };
|
|
356
373
|
}
|
|
357
374
|
function findAllPartialsInRoot(webRoot2) {
|
|
358
|
-
const allPartialComponents =
|
|
375
|
+
const allPartialComponents = findAllComponentsIn(
|
|
359
376
|
webRoot2,
|
|
360
377
|
"./components/partials",
|
|
361
378
|
false
|
|
@@ -423,24 +440,24 @@ var findFullPathInModuleGraph = (modulePathNoExtension, moduleGraph) => {
|
|
|
423
440
|
};
|
|
424
441
|
|
|
425
442
|
// src/lib/packagePath.ts
|
|
426
|
-
import
|
|
443
|
+
import path2 from "path";
|
|
427
444
|
import url from "url";
|
|
428
445
|
import { normalizePath } from "vite";
|
|
429
446
|
function packagePath(metaUrl, projectPath) {
|
|
430
447
|
if (true) {
|
|
431
|
-
return
|
|
448
|
+
return path2.resolve(path2.dirname(url.fileURLToPath(metaUrl)), projectPath);
|
|
432
449
|
}
|
|
433
|
-
const parentDirPath = normalizePath(
|
|
450
|
+
const parentDirPath = normalizePath(path2.dirname(url.fileURLToPath(metaUrl)));
|
|
434
451
|
const subPath = parentDirPath.replace(/^.+cms-dev-server\/src\//, "");
|
|
435
452
|
const subPathParentDirs = subPath.split("/").map(() => "..");
|
|
436
|
-
return
|
|
437
|
-
|
|
438
|
-
|
|
453
|
+
return path2.resolve(
|
|
454
|
+
path2.dirname(url.fileURLToPath(metaUrl)),
|
|
455
|
+
path2.join(...subPathParentDirs, projectPath)
|
|
439
456
|
);
|
|
440
457
|
}
|
|
441
458
|
|
|
442
459
|
// src/lib/renderComponentWithCSS.ts
|
|
443
|
-
async function renderComponentWithCSS(viteServer, componentPath, Component, props, pageUrl, environmentConfig) {
|
|
460
|
+
async function renderComponentWithCSS(viteServer, componentPath, Component, props, pageUrl, environmentConfig, renderOptions) {
|
|
444
461
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
445
462
|
const { renderComponentOnServer, collectCssInDev } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
446
463
|
let componentPathWithExtension;
|
|
@@ -455,7 +472,8 @@ async function renderComponentWithCSS(viteServer, componentPath, Component, prop
|
|
|
455
472
|
Component,
|
|
456
473
|
props,
|
|
457
474
|
pageUrl,
|
|
458
|
-
environmentConfig
|
|
475
|
+
environmentConfig,
|
|
476
|
+
renderOptions
|
|
459
477
|
);
|
|
460
478
|
if (!componentPathWithExtension) {
|
|
461
479
|
componentPathWithExtension = findFullPathInModuleGraph(
|
|
@@ -520,7 +538,7 @@ var Gates = {
|
|
|
520
538
|
};
|
|
521
539
|
|
|
522
540
|
// src/lib/renderPartial.ts
|
|
523
|
-
async function renderPartial(viteServer, partialPath, props, pageUrl, environmentConfig) {
|
|
541
|
+
async function renderPartial(viteServer, partialPath, props, pageUrl, environmentConfig, renderOptions) {
|
|
524
542
|
logPartialInfo(partialPath, props);
|
|
525
543
|
let serverSideProps;
|
|
526
544
|
const componentModule = await viteServer.ssrLoadModule(partialPath);
|
|
@@ -549,7 +567,8 @@ async function renderPartial(viteServer, partialPath, props, pageUrl, environmen
|
|
|
549
567
|
Component,
|
|
550
568
|
{ ...props, ...serverSideProps },
|
|
551
569
|
pageUrl,
|
|
552
|
-
environmentConfig
|
|
570
|
+
environmentConfig,
|
|
571
|
+
renderOptions
|
|
553
572
|
);
|
|
554
573
|
}
|
|
555
574
|
var renderPartial_default = renderPartial;
|
|
@@ -667,7 +686,9 @@ var partialRouteHandler = async (request2, response) => {
|
|
|
667
686
|
authedHublet,
|
|
668
687
|
webRoot: webRoot2,
|
|
669
688
|
viteServer,
|
|
670
|
-
jsRenderingGates
|
|
689
|
+
jsRenderingGates,
|
|
690
|
+
projectName,
|
|
691
|
+
projectComponentPath
|
|
671
692
|
} = request2.app.locals;
|
|
672
693
|
const partialName = request2.params.partial;
|
|
673
694
|
const baseTemplatePath = packagePath(
|
|
@@ -675,7 +696,16 @@ var partialRouteHandler = async (request2, response) => {
|
|
|
675
696
|
"html/baseTemplate.html"
|
|
676
697
|
);
|
|
677
698
|
const partialPath = normalizePath2(
|
|
678
|
-
|
|
699
|
+
path3.resolve(webRoot2, "components/partials/", partialName)
|
|
700
|
+
);
|
|
701
|
+
const entrypointPath = normalizePath2(
|
|
702
|
+
[
|
|
703
|
+
"@projects",
|
|
704
|
+
projectName,
|
|
705
|
+
projectComponentPath,
|
|
706
|
+
"components/modules/",
|
|
707
|
+
partialName
|
|
708
|
+
].join("/")
|
|
679
709
|
);
|
|
680
710
|
const environmentConfig = buildStaticEnvConfig(
|
|
681
711
|
authedPortalId,
|
|
@@ -694,7 +724,10 @@ var partialRouteHandler = async (request2, response) => {
|
|
|
694
724
|
partialPath,
|
|
695
725
|
{},
|
|
696
726
|
fullOriginalUrlFromRequest(request2),
|
|
697
|
-
environmentConfig
|
|
727
|
+
environmentConfig,
|
|
728
|
+
{
|
|
729
|
+
identifierPrefix: getEntryPointHash(entrypointPath)
|
|
730
|
+
}
|
|
698
731
|
);
|
|
699
732
|
const htmlShell = await createHtmlShellDependingOnRenderContext(
|
|
700
733
|
baseTemplatePath,
|
|
@@ -717,7 +750,7 @@ ${e.stack}`);
|
|
|
717
750
|
var partial_default = partialRouteHandler;
|
|
718
751
|
|
|
719
752
|
// src/components/PartialsList.tsx
|
|
720
|
-
import { jsx as
|
|
753
|
+
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
721
754
|
function EmptyPartialsList({ webRoot: webRoot2 }) {
|
|
722
755
|
return /* @__PURE__ */ jsxs("p", { children: [
|
|
723
756
|
"No partials in ",
|
|
@@ -728,22 +761,22 @@ function EmptyPartialsList({ webRoot: webRoot2 }) {
|
|
|
728
761
|
] });
|
|
729
762
|
}
|
|
730
763
|
function PartialLinkInLI({ partialName }) {
|
|
731
|
-
return /* @__PURE__ */
|
|
764
|
+
return /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsx3("a", { href: `/partial/${partialName}`, children: partialName }) });
|
|
732
765
|
}
|
|
733
766
|
function PartialsList({ webRoot: webRoot2, partialNames }) {
|
|
734
767
|
if (partialNames.length === 0) {
|
|
735
|
-
return /* @__PURE__ */
|
|
768
|
+
return /* @__PURE__ */ jsx3(EmptyPartialsList, { webRoot: webRoot2 });
|
|
736
769
|
}
|
|
737
|
-
return /* @__PURE__ */
|
|
770
|
+
return /* @__PURE__ */ jsx3("ul", { children: partialNames.map((partialName) => /* @__PURE__ */ jsx3(PartialLinkInLI, { partialName }, partialName)) });
|
|
738
771
|
}
|
|
739
772
|
|
|
740
773
|
// src/routes/linksToAllPartialsRouteHandler.tsx
|
|
741
|
-
import { jsx as
|
|
774
|
+
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
742
775
|
var linksToAllPartialRouteHandler = async (request2, response) => {
|
|
743
776
|
const { webRoot: webRoot2 } = request2.app.locals;
|
|
744
777
|
const { partialNames } = findAllPartialsInRoot(webRoot2);
|
|
745
778
|
const { html: responseHtml } = await renderOnServer(
|
|
746
|
-
/* @__PURE__ */
|
|
779
|
+
/* @__PURE__ */ jsx4(PartialsList, { webRoot: webRoot2, partialNames }),
|
|
747
780
|
null,
|
|
748
781
|
null
|
|
749
782
|
);
|
|
@@ -752,7 +785,7 @@ var linksToAllPartialRouteHandler = async (request2, response) => {
|
|
|
752
785
|
var linksToAllPartialsRouteHandler_default = linksToAllPartialRouteHandler;
|
|
753
786
|
|
|
754
787
|
// src/components/ModulesList.tsx
|
|
755
|
-
import { jsx as
|
|
788
|
+
import { jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
756
789
|
function EmptyModulesList({ webRoot: webRoot2 }) {
|
|
757
790
|
return /* @__PURE__ */ jsxs2("p", { children: [
|
|
758
791
|
"No modules in ",
|
|
@@ -763,23 +796,23 @@ function EmptyModulesList({ webRoot: webRoot2 }) {
|
|
|
763
796
|
] });
|
|
764
797
|
}
|
|
765
798
|
function ModuleLinkInLI({ moduleName }) {
|
|
766
|
-
return /* @__PURE__ */
|
|
799
|
+
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsx5("a", { href: `/module/${moduleName}`, children: moduleName }) });
|
|
767
800
|
}
|
|
768
801
|
function ModulesList({ webRoot: webRoot2, moduleNames }) {
|
|
769
802
|
if (moduleNames.length === 0) {
|
|
770
|
-
return /* @__PURE__ */
|
|
803
|
+
return /* @__PURE__ */ jsx5(EmptyModulesList, { webRoot: webRoot2 });
|
|
771
804
|
}
|
|
772
|
-
return /* @__PURE__ */
|
|
805
|
+
return /* @__PURE__ */ jsx5("ul", { children: moduleNames.map((moduleName) => /* @__PURE__ */ jsx5(ModuleLinkInLI, { moduleName }, moduleName)) });
|
|
773
806
|
}
|
|
774
807
|
var ModulesList_default = ModulesList;
|
|
775
808
|
|
|
776
809
|
// src/routes/linksToAllModulesRouteHandler.tsx
|
|
777
|
-
import { jsx as
|
|
810
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
778
811
|
var linksToAllModuleRouteHandler = async (request2, response) => {
|
|
779
812
|
const { webRoot: webRoot2 } = request2.app.locals;
|
|
780
813
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
781
814
|
const { html: responseHtml } = await renderOnServer(
|
|
782
|
-
/* @__PURE__ */
|
|
815
|
+
/* @__PURE__ */ jsx6(ModulesList_default, { webRoot: webRoot2, moduleNames }),
|
|
783
816
|
null,
|
|
784
817
|
null
|
|
785
818
|
);
|
|
@@ -789,15 +822,15 @@ var linksToAllModulesRouteHandler_default = linksToAllModuleRouteHandler;
|
|
|
789
822
|
|
|
790
823
|
// src/routes/module.ts
|
|
791
824
|
import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components/config";
|
|
792
|
-
import
|
|
825
|
+
import path4 from "path";
|
|
793
826
|
import { normalizePath as normalizePath3 } from "vite";
|
|
794
827
|
|
|
795
828
|
// src/lib/renderModule.ts
|
|
796
|
-
import { join as
|
|
829
|
+
import { join as joinPosix } from "path/posix";
|
|
797
830
|
import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
|
|
798
831
|
var lookForModuleInFolder = async (modulePath, viteServer) => {
|
|
799
832
|
let componentModule;
|
|
800
|
-
const insideFolderPath =
|
|
833
|
+
const insideFolderPath = joinPosix(modulePath, "index");
|
|
801
834
|
try {
|
|
802
835
|
componentModule = await viteServer.ssrLoadModule(insideFolderPath);
|
|
803
836
|
} catch (e) {
|
|
@@ -807,7 +840,7 @@ var lookForModuleInFolder = async (modulePath, viteServer) => {
|
|
|
807
840
|
}
|
|
808
841
|
return [componentModule, insideFolderPath];
|
|
809
842
|
};
|
|
810
|
-
async function renderModule(viteServer, requestedModulePath, fieldOverrides = {}, pageUrl, environmentConfig) {
|
|
843
|
+
async function renderModule(viteServer, requestedModulePath, fieldOverrides = {}, pageUrl, environmentConfig, renderOptions) {
|
|
811
844
|
console.log("Rendering module", requestedModulePath);
|
|
812
845
|
const ungatedForServerSideProps = environmentConfig.getGates().includes(Gates.GET_SERVER_SIDE_PROPS);
|
|
813
846
|
let serverSideProps;
|
|
@@ -854,7 +887,8 @@ async function renderModule(viteServer, requestedModulePath, fieldOverrides = {}
|
|
|
854
887
|
Component,
|
|
855
888
|
{ ...props, ...serverSideProps },
|
|
856
889
|
pageUrl,
|
|
857
|
-
environmentConfig
|
|
890
|
+
environmentConfig,
|
|
891
|
+
renderOptions
|
|
858
892
|
);
|
|
859
893
|
}
|
|
860
894
|
function getPropsForModule(fieldsJSON, fieldOverrides = {}) {
|
|
@@ -874,7 +908,9 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
874
908
|
authedHublet,
|
|
875
909
|
webRoot: webRoot2,
|
|
876
910
|
viteServer,
|
|
877
|
-
jsRenderingGates
|
|
911
|
+
jsRenderingGates,
|
|
912
|
+
projectName,
|
|
913
|
+
projectComponentPath
|
|
878
914
|
} = request2.app.locals;
|
|
879
915
|
const moduleName = request2.params.moduleName;
|
|
880
916
|
const baseTemplatePath = packagePath(
|
|
@@ -882,7 +918,16 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
882
918
|
"html/baseTemplate.html"
|
|
883
919
|
);
|
|
884
920
|
const modulePath = normalizePath3(
|
|
885
|
-
|
|
921
|
+
path4.resolve(webRoot2, "components/modules/", moduleName)
|
|
922
|
+
);
|
|
923
|
+
const entrypointPath = normalizePath3(
|
|
924
|
+
[
|
|
925
|
+
"@projects",
|
|
926
|
+
projectName,
|
|
927
|
+
projectComponentPath,
|
|
928
|
+
"components/modules/",
|
|
929
|
+
moduleName
|
|
930
|
+
].join("/")
|
|
886
931
|
);
|
|
887
932
|
let fieldOverrides = null;
|
|
888
933
|
if (request2.query.fields) {
|
|
@@ -913,7 +958,10 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
913
958
|
modulePath,
|
|
914
959
|
fieldOverrides,
|
|
915
960
|
fullOriginalUrlFromRequest(request2),
|
|
916
|
-
environmentConfig
|
|
961
|
+
environmentConfig,
|
|
962
|
+
{
|
|
963
|
+
identifierPrefix: getEntryPointHash(entrypointPath)
|
|
964
|
+
}
|
|
917
965
|
);
|
|
918
966
|
const htmlShell = await createHtmlShellDependingOnRenderContext(
|
|
919
967
|
baseTemplatePath,
|
|
@@ -1007,7 +1055,7 @@ async function fetchContentMetadata(url3, redirects = 0, originalUrl) {
|
|
|
1007
1055
|
}
|
|
1008
1056
|
|
|
1009
1057
|
// src/proxyPage/proxyPage.ts
|
|
1010
|
-
import
|
|
1058
|
+
import path5 from "path";
|
|
1011
1059
|
import { getAccountId, getEnv } from "@hubspot/cli-lib/lib/config.js";
|
|
1012
1060
|
import { get as hsGet2 } from "@hubspot/cli-lib/http.js";
|
|
1013
1061
|
|
|
@@ -1037,12 +1085,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1037
1085
|
);
|
|
1038
1086
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1039
1087
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1040
|
-
const
|
|
1088
|
+
const path7 = body.substring(
|
|
1041
1089
|
startOffset + localJsRenderStartString.length,
|
|
1042
1090
|
pathEndOffset
|
|
1043
1091
|
);
|
|
1044
1092
|
offsetSoFar = pathEndOffset + 1;
|
|
1045
|
-
if (startOffset >= 0 &&
|
|
1093
|
+
if (startOffset >= 0 && path7) {
|
|
1046
1094
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1047
1095
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1048
1096
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1053,7 +1101,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1053
1101
|
result.push({
|
|
1054
1102
|
startOffset,
|
|
1055
1103
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1056
|
-
path:
|
|
1104
|
+
path: path7,
|
|
1057
1105
|
json
|
|
1058
1106
|
});
|
|
1059
1107
|
offsetSoFar = endOffset + localJsRenderEndString.length;
|
|
@@ -1160,9 +1208,9 @@ var customColors = [
|
|
|
1160
1208
|
];
|
|
1161
1209
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1162
1210
|
var darkErrorStyles = `background-color: #222; color: #ccc; padding: 0.5em; font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;`;
|
|
1163
|
-
var renderLocalError_default = (
|
|
1211
|
+
var renderLocalError_default = (path7, error) => {
|
|
1164
1212
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1165
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1213
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path7}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1166
1214
|
};
|
|
1167
1215
|
|
|
1168
1216
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -1214,12 +1262,16 @@ import {
|
|
|
1214
1262
|
import {
|
|
1215
1263
|
mergeServerRequestData_internal
|
|
1216
1264
|
} from "@hubspot/cms-components";
|
|
1217
|
-
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName) => {
|
|
1265
|
+
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, jsRenderingGates) => {
|
|
1218
1266
|
const url3 = new URL(urlToProxy);
|
|
1219
1267
|
console.log(`Proxying request to ${url3.href}`, {
|
|
1220
1268
|
previewKey,
|
|
1221
1269
|
contentId
|
|
1222
1270
|
});
|
|
1271
|
+
const proxySchemaVersion = isUngatedFor(
|
|
1272
|
+
jsRenderingGates,
|
|
1273
|
+
"CMS:JSRenderer:LocalProxySchemaVersion1"
|
|
1274
|
+
) ? 1 : 0;
|
|
1223
1275
|
let proxiedQueryParams = {};
|
|
1224
1276
|
for (const queryKey of url3.searchParams.keys()) {
|
|
1225
1277
|
const values = url3.searchParams.getAll(queryKey);
|
|
@@ -1233,7 +1285,8 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1233
1285
|
...proxiedQueryParams,
|
|
1234
1286
|
hs_preview: `${previewKey}-${contentId}`,
|
|
1235
1287
|
hsLocalProxy: true,
|
|
1236
|
-
hsLocalProxyProject: `@projects/${projectName}
|
|
1288
|
+
hsLocalProxyProject: `@projects/${projectName}`,
|
|
1289
|
+
localProxySchemaVersion: proxySchemaVersion
|
|
1237
1290
|
};
|
|
1238
1291
|
const result = hsGet2(accountId, {
|
|
1239
1292
|
baseUrl: url3.origin,
|
|
@@ -1251,7 +1304,12 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1251
1304
|
});
|
|
1252
1305
|
};
|
|
1253
1306
|
var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder, webRoot2, viteServer, pageUrl, environmentConfig, hsProjectJsonProjectName, webRootProjectComponent) => {
|
|
1307
|
+
const proxySchemaVersion = isUngatedFor(
|
|
1308
|
+
environmentConfig.getGates(),
|
|
1309
|
+
"CMS:JSRenderer:LocalProxySchemaVersion1"
|
|
1310
|
+
) ? 1 : 0;
|
|
1254
1311
|
const { path: placeholderPath } = localRenderPlaceholder;
|
|
1312
|
+
const localRenderPlaceholderProps = proxySchemaVersion === 1 ? localRenderPlaceholder.json.props : localRenderPlaceholder.json;
|
|
1255
1313
|
const [
|
|
1256
1314
|
__projectIdentifier,
|
|
1257
1315
|
projectFolder,
|
|
@@ -1270,24 +1328,43 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
|
|
|
1270
1328
|
`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}.`
|
|
1271
1329
|
);
|
|
1272
1330
|
}
|
|
1273
|
-
const resolvedPath =
|
|
1331
|
+
const resolvedPath = path5.resolve(webRoot2, partialPath, componentFileName);
|
|
1332
|
+
const entryPointPath = [
|
|
1333
|
+
"@projects",
|
|
1334
|
+
webRootProjectComponent,
|
|
1335
|
+
projectComponentFolder,
|
|
1336
|
+
partialPath,
|
|
1337
|
+
componentFileName
|
|
1338
|
+
].join("/");
|
|
1274
1339
|
if (placeholderPath.startsWith("/fake/path/to/")) {
|
|
1275
1340
|
return fakeRenderJsComponent(indexForThisRender);
|
|
1276
1341
|
} else if (partialPath === ENTRY_POINTS_PATH) {
|
|
1277
1342
|
return renderPartial_default(
|
|
1278
1343
|
viteServer,
|
|
1279
1344
|
resolvedPath,
|
|
1280
|
-
|
|
1345
|
+
localRenderPlaceholderProps,
|
|
1281
1346
|
pageUrl,
|
|
1282
|
-
environmentConfig
|
|
1347
|
+
environmentConfig,
|
|
1348
|
+
{
|
|
1349
|
+
identifierPrefix: getEntryPointHashWithIndexSuffix(
|
|
1350
|
+
entryPointPath,
|
|
1351
|
+
indexForThisRender
|
|
1352
|
+
)
|
|
1353
|
+
}
|
|
1283
1354
|
);
|
|
1284
1355
|
} else if (partialPath === MODULE_FOLDER_PATH) {
|
|
1285
1356
|
return renderModule_default(
|
|
1286
1357
|
viteServer,
|
|
1287
1358
|
resolvedPath,
|
|
1288
|
-
|
|
1359
|
+
localRenderPlaceholderProps,
|
|
1289
1360
|
pageUrl,
|
|
1290
|
-
environmentConfig
|
|
1361
|
+
environmentConfig,
|
|
1362
|
+
{
|
|
1363
|
+
identifierPrefix: getEntryPointHashWithIndexSuffix(
|
|
1364
|
+
entryPointPath,
|
|
1365
|
+
indexForThisRender
|
|
1366
|
+
)
|
|
1367
|
+
}
|
|
1291
1368
|
);
|
|
1292
1369
|
} else {
|
|
1293
1370
|
throw new Error(`Unimplemented render of ${placeholderPath}.`);
|
|
@@ -1322,7 +1399,8 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
|
|
|
1322
1399
|
urlToProxy,
|
|
1323
1400
|
previewKey,
|
|
1324
1401
|
contentId,
|
|
1325
|
-
projectName
|
|
1402
|
+
projectName,
|
|
1403
|
+
jsRenderingGates
|
|
1326
1404
|
);
|
|
1327
1405
|
const environmentConfig = buildStaticEnvConfig3(
|
|
1328
1406
|
portalId,
|
|
@@ -1501,18 +1579,18 @@ function proxyPageResourceRedirect(req, res, next) {
|
|
|
1501
1579
|
}
|
|
1502
1580
|
|
|
1503
1581
|
// src/routes/homeRouteHandler.tsx
|
|
1504
|
-
import { Fragment, jsx as
|
|
1582
|
+
import { Fragment, jsx as jsx7, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1505
1583
|
var homeRouteHandler = async (request2, response) => {
|
|
1506
1584
|
const { webRoot: webRoot2, storybookEnabled, devServerPort } = request2.app.locals;
|
|
1507
1585
|
const { partialNames } = findAllPartialsInRoot(webRoot2);
|
|
1508
1586
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
1509
1587
|
const { html: responseHtml } = await renderOnServer(
|
|
1510
1588
|
/* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
1511
|
-
storybookEnabled ? /* @__PURE__ */
|
|
1512
|
-
/* @__PURE__ */
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
/* @__PURE__ */
|
|
1515
|
-
/* @__PURE__ */
|
|
1589
|
+
storybookEnabled ? /* @__PURE__ */ jsx7("h2", { children: /* @__PURE__ */ jsx7("a", { href: `//storybook.${request2.hostname}:${devServerPort}`, children: "Storybook" }) }) : null,
|
|
1590
|
+
/* @__PURE__ */ jsx7("h2", { children: "Partials" }),
|
|
1591
|
+
/* @__PURE__ */ jsx7(PartialsList, { webRoot: webRoot2, partialNames }),
|
|
1592
|
+
/* @__PURE__ */ jsx7("h2", { children: "Modules" }),
|
|
1593
|
+
/* @__PURE__ */ jsx7(ModulesList_default, { webRoot: webRoot2, moduleNames })
|
|
1516
1594
|
] }),
|
|
1517
1595
|
null,
|
|
1518
1596
|
null
|
|
@@ -1526,7 +1604,7 @@ import { default as debugFactory } from "debug";
|
|
|
1526
1604
|
var debug = debugFactory("cms-dev-server");
|
|
1527
1605
|
|
|
1528
1606
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
1529
|
-
import { jsx as
|
|
1607
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1530
1608
|
async function proxyPathPageRouteHandler(request2, response, next) {
|
|
1531
1609
|
const {
|
|
1532
1610
|
viteServer,
|
|
@@ -1541,10 +1619,10 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
1541
1619
|
if (!request2.query.page) {
|
|
1542
1620
|
const { html: responseHtml } = await renderOnServer(
|
|
1543
1621
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
1544
|
-
/* @__PURE__ */
|
|
1622
|
+
/* @__PURE__ */ jsx8("h2", { children: "Local Proxy" }),
|
|
1545
1623
|
/* @__PURE__ */ jsxs4("form", { action: "/proxy", children: [
|
|
1546
|
-
/* @__PURE__ */
|
|
1547
|
-
/* @__PURE__ */
|
|
1624
|
+
/* @__PURE__ */ jsx8("label", { htmlFor: "page", style: { display: "block" }, children: "Page URL" }),
|
|
1625
|
+
/* @__PURE__ */ jsx8(
|
|
1548
1626
|
"input",
|
|
1549
1627
|
{
|
|
1550
1628
|
style: { width: "300px" },
|
|
@@ -1553,7 +1631,7 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
1553
1631
|
placeholder: "https://somecmspage.com/path"
|
|
1554
1632
|
}
|
|
1555
1633
|
),
|
|
1556
|
-
/* @__PURE__ */
|
|
1634
|
+
/* @__PURE__ */ jsx8("button", { style: { display: "block" }, children: "Proxy" })
|
|
1557
1635
|
] })
|
|
1558
1636
|
] }),
|
|
1559
1637
|
null,
|
|
@@ -1676,7 +1754,7 @@ import express from "express";
|
|
|
1676
1754
|
import { Router as Router2 } from "express";
|
|
1677
1755
|
import { getAccountId as getAccountId2 } from "@hubspot/cli-lib/lib/config.js";
|
|
1678
1756
|
import cors from "cors";
|
|
1679
|
-
function getShadowDevServerCheckHandler(devServerPort, projectName) {
|
|
1757
|
+
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
1680
1758
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
1681
1759
|
const { query } = request2;
|
|
1682
1760
|
if (query) {
|
|
@@ -1715,7 +1793,8 @@ function getShadowDevServerCheckHandler(devServerPort, projectName) {
|
|
|
1715
1793
|
pageUrl,
|
|
1716
1794
|
previewKey,
|
|
1717
1795
|
contentId,
|
|
1718
|
-
projectName
|
|
1796
|
+
projectName,
|
|
1797
|
+
gates
|
|
1719
1798
|
);
|
|
1720
1799
|
const localRenderPlaceholders = findLocalRenderPlaceholders(pageHtml);
|
|
1721
1800
|
if (localRenderPlaceholders.length) {
|
|
@@ -1738,19 +1817,19 @@ ${error.stack}`
|
|
|
1738
1817
|
}
|
|
1739
1818
|
};
|
|
1740
1819
|
}
|
|
1741
|
-
async function createShadowDevServerRoutes(devServerPort, projectName) {
|
|
1820
|
+
async function createShadowDevServerRoutes(devServerPort, projectName, gates) {
|
|
1742
1821
|
const shadowDevServerRoutes = Router2();
|
|
1743
1822
|
shadowDevServerRoutes.get(
|
|
1744
1823
|
"/check-if-local-dev-server",
|
|
1745
1824
|
cors(),
|
|
1746
|
-
getShadowDevServerCheckHandler(devServerPort, projectName)
|
|
1825
|
+
getShadowDevServerCheckHandler(devServerPort, projectName, gates)
|
|
1747
1826
|
);
|
|
1748
1827
|
return shadowDevServerRoutes;
|
|
1749
1828
|
}
|
|
1750
1829
|
|
|
1751
1830
|
// src/shadowDevServer/startShadowDevServer.ts
|
|
1752
1831
|
var testNetServer = net.createServer();
|
|
1753
|
-
async function startShadowDevServer(devServerPort, shadowPort, projectName) {
|
|
1832
|
+
async function startShadowDevServer(devServerPort, shadowPort, projectName, jsRenderingGates) {
|
|
1754
1833
|
const portIsTaken = await new Promise((res, rej) => {
|
|
1755
1834
|
console.log(`Starting proxy link server on port ${shadowPort}`);
|
|
1756
1835
|
testNetServer.once("error", (err) => {
|
|
@@ -1778,7 +1857,11 @@ async function startShadowDevServer(devServerPort, shadowPort, projectName) {
|
|
|
1778
1857
|
shadowDevServer.listen(shadowPort);
|
|
1779
1858
|
shadowDevServer.use(
|
|
1780
1859
|
"/",
|
|
1781
|
-
await createShadowDevServerRoutes(
|
|
1860
|
+
await createShadowDevServerRoutes(
|
|
1861
|
+
devServerPort,
|
|
1862
|
+
projectName,
|
|
1863
|
+
jsRenderingGates
|
|
1864
|
+
)
|
|
1782
1865
|
);
|
|
1783
1866
|
}
|
|
1784
1867
|
|
|
@@ -1931,6 +2014,12 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
1931
2014
|
return domainNames;
|
|
1932
2015
|
}
|
|
1933
2016
|
|
|
2017
|
+
// src/lib/gates.ts
|
|
2018
|
+
function getGatesFromEnv() {
|
|
2019
|
+
const gates = process.env.GATES ? process.env.GATES.split(",") : [];
|
|
2020
|
+
return gates;
|
|
2021
|
+
}
|
|
2022
|
+
|
|
1934
2023
|
// src/createDevServer.ts
|
|
1935
2024
|
var BASE_PATH = "/";
|
|
1936
2025
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
@@ -1973,7 +2062,7 @@ If needed you can refer to another config file with --config.
|
|
|
1973
2062
|
Local proxy functionality will not work without setting up authentication.`
|
|
1974
2063
|
);
|
|
1975
2064
|
}
|
|
1976
|
-
const jsRenderingGates =
|
|
2065
|
+
const jsRenderingGates = getGatesFromEnv();
|
|
1977
2066
|
let domainsToProxy = [];
|
|
1978
2067
|
if (sslEnabledOption2 && authedPortalId) {
|
|
1979
2068
|
try {
|
|
@@ -1991,7 +2080,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
1991
2080
|
}
|
|
1992
2081
|
}
|
|
1993
2082
|
const authedHublet = "na1";
|
|
1994
|
-
const absoluteWebRoot = normalizePath4(
|
|
2083
|
+
const absoluteWebRoot = normalizePath4(path6.resolve(process.cwd(), webRoot2));
|
|
1995
2084
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
1996
2085
|
const viteServer = await createViteDevServer_default(
|
|
1997
2086
|
absoluteWebRoot,
|
|
@@ -2004,7 +2093,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2004
2093
|
const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
|
|
2005
2094
|
const httpsCert = viteHTTPSConfig ? viteHTTPSConfig.cert : null;
|
|
2006
2095
|
const projectName = getProjectNameFromHSConfig(
|
|
2007
|
-
|
|
2096
|
+
path6.join(webRoot2, "../hsproject.json")
|
|
2008
2097
|
);
|
|
2009
2098
|
const httpServers = [];
|
|
2010
2099
|
const expressServer = express2();
|
|
@@ -2044,7 +2133,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2044
2133
|
httpServer.listen(PORT);
|
|
2045
2134
|
httpServers.push(httpServer);
|
|
2046
2135
|
}
|
|
2047
|
-
startShadowDevServer(PORT, SHADOW_PORT, projectName);
|
|
2136
|
+
startShadowDevServer(PORT, SHADOW_PORT, projectName, jsRenderingGates);
|
|
2048
2137
|
let extraServerInfo = "";
|
|
2049
2138
|
const protocol = sslEnabledOption2 ? "https" : "http";
|
|
2050
2139
|
if (authedPortalId) {
|
|
@@ -2059,8 +2148,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2059
2148
|
`
|
|
2060
2149
|
);
|
|
2061
2150
|
if (storybook2) {
|
|
2062
|
-
const packageRoot =
|
|
2063
|
-
const configPath =
|
|
2151
|
+
const packageRoot = path6.dirname(url2.fileURLToPath(import.meta.url));
|
|
2152
|
+
const configPath = path6.resolve(packageRoot, "./storybook");
|
|
2064
2153
|
const storybookProcess = spawn(
|
|
2065
2154
|
"npx",
|
|
2066
2155
|
[
|
|
@@ -2077,7 +2166,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2077
2166
|
cwd: process.cwd(),
|
|
2078
2167
|
env: {
|
|
2079
2168
|
...process.env,
|
|
2080
|
-
WEB_ROOT:
|
|
2169
|
+
WEB_ROOT: path6.join(webRoot2, "components")
|
|
2081
2170
|
}
|
|
2082
2171
|
}
|
|
2083
2172
|
);
|
package/dist/storybook/index.js
CHANGED
|
@@ -3,20 +3,17 @@ import React, { useEffect } from "react";
|
|
|
3
3
|
import { renderToStaticMarkup as renderToStaticMarkup2 } from "react-dom/server";
|
|
4
4
|
|
|
5
5
|
// ../cms-js-internal/dist/index.js
|
|
6
|
-
import path from "path";
|
|
6
|
+
import path, { basename } from "path";
|
|
7
|
+
import { createRequire } from "module";
|
|
8
|
+
import * as jsxRuntime from "react/jsx-runtime";
|
|
7
9
|
import stream from "stream";
|
|
8
|
-
import { renderToPipeableStream } from "react-dom/server";
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
createServerRenderContext
|
|
12
|
-
} from "@hubspot/cms-components";
|
|
13
|
-
import { jsx } from "react/jsx-runtime";
|
|
14
|
-
import path2 from "path";
|
|
10
|
+
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
11
|
+
import { createServerRenderContext, ServerRenderContext } from "@hubspot/cms-components";
|
|
12
|
+
import { createHash } from "crypto";
|
|
15
13
|
import { existsSync, readdirSync, lstatSync } from "fs";
|
|
16
|
-
import { join
|
|
17
|
-
import { basename } from "path";
|
|
14
|
+
import { join } from "path/posix";
|
|
18
15
|
import { cloneElement } from "react";
|
|
19
|
-
|
|
16
|
+
var require2 = createRequire(import.meta.url);
|
|
20
17
|
function renderFieldsToJson(fields) {
|
|
21
18
|
let moduleJson;
|
|
22
19
|
const outputCallback = (callbackJson) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.15",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@hubspot/cli-lib": "^3.0.12",
|
|
27
|
-
"@hubspot/cms-components": "^0.4.
|
|
27
|
+
"@hubspot/cms-components": "^0.4.15",
|
|
28
28
|
"@storybook/addon-actions": "^7.0.0-beta.19",
|
|
29
29
|
"@storybook/addon-essentials": "^7.0.0-beta.19",
|
|
30
30
|
"@storybook/addon-interactions": "^7.0.0-beta.19",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"publishConfig": {
|
|
96
96
|
"access": "public"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "8fe879bdaa60e23de6af81291693d2241f23e673"
|
|
99
99
|
}
|