@hubspot/cms-dev-server 0.13.11 → 0.14.1
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/createViteDevServer-5624911d.js +69 -0
- package/dist/index-de34229d.js +525 -0
- package/dist/index-e4860c0f.js +150 -0
- package/dist/index2.js +178 -0
- package/dist/internalSsr.js +38 -5
- package/dist/main.js +52 -0
- package/dist/preview.js +18 -0
- package/dist/run.js +44 -6
- package/dist/storybook-main/main.js +38 -5
- package/package.json +11 -6
- package/types/island-runtime.d.ts +2 -0
|
@@ -53,6 +53,7 @@ __export(dist_exports, {
|
|
|
53
53
|
ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
|
|
54
54
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
55
55
|
});
|
|
56
|
+
import { hasProperty, setProperty, getProperty } from "dot-prop";
|
|
56
57
|
import path from "path";
|
|
57
58
|
import * as jsxRuntime from "react/jsx-runtime";
|
|
58
59
|
import stream from "stream";
|
|
@@ -100,6 +101,25 @@ function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent =
|
|
|
100
101
|
${indentString}`
|
|
101
102
|
);
|
|
102
103
|
}
|
|
104
|
+
function filterOutUnreadSupplementalFieldValues(supplementalFieldValues, supplementalFieldValuesRead) {
|
|
105
|
+
if (!supplementalFieldValues) {
|
|
106
|
+
return supplementalFieldValues;
|
|
107
|
+
}
|
|
108
|
+
if (!supplementalFieldValuesRead) {
|
|
109
|
+
return supplementalFieldValues;
|
|
110
|
+
}
|
|
111
|
+
const result = {};
|
|
112
|
+
Array.from(supplementalFieldValuesRead).forEach((fieldPath) => {
|
|
113
|
+
if (hasProperty(supplementalFieldValues, fieldPath)) {
|
|
114
|
+
setProperty(
|
|
115
|
+
result,
|
|
116
|
+
fieldPath,
|
|
117
|
+
getProperty(supplementalFieldValues, fieldPath)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
return result;
|
|
122
|
+
}
|
|
103
123
|
function getIslandUrls(roots, viteDevServer) {
|
|
104
124
|
return roots.map((island) => {
|
|
105
125
|
const islandModule = viteDevServer.moduleGraph.getModuleById(
|
|
@@ -210,21 +230,24 @@ function clientIslandEntryPlugin() {
|
|
|
210
230
|
}
|
|
211
231
|
};
|
|
212
232
|
}
|
|
213
|
-
async function renderComponentOnServer(Component, props, pageUrl, environmentConfig, entryPointBasePath, renderOptions) {
|
|
233
|
+
async function renderComponentOnServer(Component, props, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions) {
|
|
214
234
|
const componentDebugName = Component.displayName || Component.name;
|
|
215
235
|
return renderOnServer(
|
|
216
236
|
/* @__PURE__ */ jsx2(Component, { ...props }),
|
|
217
237
|
pageUrl,
|
|
218
238
|
environmentConfig,
|
|
219
239
|
entryPointBasePath,
|
|
240
|
+
contextOptions,
|
|
220
241
|
componentDebugName,
|
|
221
242
|
renderOptions
|
|
222
243
|
);
|
|
223
244
|
}
|
|
224
|
-
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, debugName, renderOptions) {
|
|
245
|
+
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
246
|
+
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
225
247
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
226
248
|
environmentConfig,
|
|
227
|
-
entryPointBasePath
|
|
249
|
+
entryPointBasePath,
|
|
250
|
+
supplementalFieldValues
|
|
228
251
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
229
252
|
let html = await renderStreamToPromise(
|
|
230
253
|
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
@@ -473,7 +496,7 @@ var init_dist = __esm({
|
|
|
473
496
|
">": "\\u003E",
|
|
474
497
|
"/": "\\u002F"
|
|
475
498
|
};
|
|
476
|
-
serializeIslandDataForInlineScript = (tweakedIslandsArray, baseIndent = 0, prettyPrint) => {
|
|
499
|
+
serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
|
|
477
500
|
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
478
501
|
({
|
|
479
502
|
id,
|
|
@@ -485,6 +508,7 @@ var init_dist = __esm({
|
|
|
485
508
|
priority,
|
|
486
509
|
url,
|
|
487
510
|
sharedStateID,
|
|
511
|
+
supplementalFieldValues,
|
|
488
512
|
wrapperModuleId,
|
|
489
513
|
wrapperUrl
|
|
490
514
|
}) => {
|
|
@@ -507,6 +531,13 @@ var init_dist = __esm({
|
|
|
507
531
|
if (wrapperUrl) {
|
|
508
532
|
output.wrapperUrl = wrapperUrl;
|
|
509
533
|
}
|
|
534
|
+
const filteredSupplementalFieldValues = filterOutUnreadSupplementalFieldValues(
|
|
535
|
+
supplementalFieldValues,
|
|
536
|
+
perServerRequestData.get("supplementalFieldValuesRead")
|
|
537
|
+
);
|
|
538
|
+
if (filteredSupplementalFieldValues) {
|
|
539
|
+
output.supplementalFieldValues = filteredSupplementalFieldValues;
|
|
540
|
+
}
|
|
510
541
|
return output;
|
|
511
542
|
}
|
|
512
543
|
);
|
|
@@ -550,6 +581,7 @@ ${indentString}`);
|
|
|
550
581
|
indent
|
|
551
582
|
)}window.__islands = ${serializeIslandDataForInlineScript(
|
|
552
583
|
islands,
|
|
584
|
+
perServerRequestData,
|
|
553
585
|
indent,
|
|
554
586
|
prettyPrint
|
|
555
587
|
)}${writeSharedStateToJsGlobal(
|
|
@@ -654,7 +686,8 @@ ${groupEnd}</script>
|
|
|
654
686
|
GATES = [
|
|
655
687
|
"CMS:JSRenderer:GetServerSideProps",
|
|
656
688
|
"CMS:JSRenderer:ModuleHubl",
|
|
657
|
-
"CMS:JSRenderer:RemoveCjsPlugin"
|
|
689
|
+
"CMS:JSRenderer:RemoveCjsPlugin",
|
|
690
|
+
"CMS:JSRenderer:RemoveMockClientEntryPlugin"
|
|
658
691
|
];
|
|
659
692
|
ENABLED_FEATURES_GATE_MAP = {
|
|
660
693
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=16.x"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"build": "tsc -noEmit && yarn run copy-html && yarn build-types && node scripts/build.mjs",
|
|
10
|
+
"build": "tsc -noEmit && yarn run copy-html && yarn build-types && node scripts/build.mjs; npm run publint",
|
|
11
11
|
"build:watch": "nodemon --exec 'yarn build'",
|
|
12
12
|
"copy-html": "copyfiles -u 1 'src/html/**' 'dist'",
|
|
13
13
|
"build-types": "tsc --project tsconfig.types.json",
|
|
@@ -21,11 +21,12 @@
|
|
|
21
21
|
"start": "ts-node-esm --transpileOnly runWhenDeveloping.ts",
|
|
22
22
|
"start-inspect": "node --loader ts-node/esm --inspect runWhenDeveloping.ts",
|
|
23
23
|
"test": "PORT=30042 NODE_ENV=test vitest run",
|
|
24
|
-
"test:watch": "PORT=30042 NODE_ENV=test vitest watch"
|
|
24
|
+
"test:watch": "PORT=30042 NODE_ENV=test vitest watch",
|
|
25
|
+
"publint": "publint --level warning --prod"
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
28
|
"@hubspot/cli-lib": "^3.0.12",
|
|
28
|
-
"@hubspot/cms-components": "^0.
|
|
29
|
+
"@hubspot/cms-components": "^0.14.1",
|
|
29
30
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
30
31
|
"@storybook/addon-actions": "7.0.7",
|
|
31
32
|
"@storybook/addon-essentials": "7.0.7",
|
|
@@ -62,12 +63,16 @@
|
|
|
62
63
|
"copyfiles": "^2.4.1",
|
|
63
64
|
"esbuild": "^0.16.17",
|
|
64
65
|
"nodemon": "^2.0.15",
|
|
66
|
+
"publint": "^0.2.7",
|
|
65
67
|
"ts-node": "^10.7.0",
|
|
66
68
|
"vitest": "0.30.1"
|
|
67
69
|
},
|
|
68
70
|
"main": "./dist/index.js",
|
|
69
71
|
"exports": {
|
|
70
|
-
".":
|
|
72
|
+
".": {
|
|
73
|
+
"types": "./types/index.d.ts",
|
|
74
|
+
"default": "./dist/index.js"
|
|
75
|
+
},
|
|
71
76
|
"./storybook": {
|
|
72
77
|
"types": "./types/storybook/index.d.ts",
|
|
73
78
|
"default": "./dist/storybook/index.js"
|
|
@@ -101,5 +106,5 @@
|
|
|
101
106
|
"publishConfig": {
|
|
102
107
|
"access": "public"
|
|
103
108
|
},
|
|
104
|
-
"gitHead": "
|
|
109
|
+
"gitHead": "ce75267044864a6d877ee25ca4cc76c4e041708b"
|
|
105
110
|
}
|