@hubspot/cms-dev-server 0.13.0 → 0.13.4
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/fsevents-72LCIACT.node +0 -0
- package/dist/index.js +2 -2
- package/dist/internalSsr.js +98 -52
- package/dist/run.js +113 -59
- package/dist/storybook/index.js +2 -0
- package/dist/storybook-main/main.js +110 -60
- package/package.json +3 -3
- package/types/components/ModulesList.d.ts +5 -0
- package/types/components/PartialsList.d.ts +4 -0
- package/types/createViteDevServer.d.ts +2 -1
- package/types/generateBpmAliases.d.ts +2 -0
- package/types/lib/debug.d.ts +1 -0
- package/types/lib/fetchModuleGraphQLData.d.ts +24 -0
- package/types/lib/fullOriginalUrlFromRequest.d.ts +5 -0
- package/types/lib/moduleGraph.d.ts +1 -0
- package/types/lib/packagePath.d.ts +1 -0
- package/types/lib/pathHelpers.d.ts +3 -0
- package/types/lib/proxyHelpers.d.ts +8 -0
- package/types/lib/renderComponentWithCSS.d.ts +14 -0
- package/types/lib/renderHelpers.d.ts +1 -0
- package/types/lib/renderModule.d.ts +8 -0
- package/types/lib/renderPartial.d.ts +5 -0
- package/types/lib/templates.d.ts +4 -0
- package/types/noNodeBuiltinsPlugin.d.ts +3 -0
- package/types/plugins/componentRoutesPlugin.d.ts +2 -0
- package/types/plugins/jsRenderingPlugin.d.ts +2 -0
- package/types/plugins/localProxyPlugin.d.ts +2 -0
- package/types/plugins/storybookPlugin.d.ts +2 -0
- package/types/proxyPage/constants.d.ts +1 -0
- package/types/proxyPage/fetchContentMetadata.d.ts +7 -0
- package/types/proxyPage/fetchPreviewInfo.d.ts +6 -0
- package/types/proxyPage/proxyPage.d.ts +6 -0
- package/types/proxyPage/renderLocalError.d.ts +2 -0
- package/types/proxyPage/utils.d.ts +4 -0
- package/types/resolveSharedDeps.d.ts +2 -0
- package/types/routes/createDevServerRoutes.d.ts +3 -0
- package/types/routes/homeRouteHandler.d.ts +3 -0
- package/types/routes/linksToAllModulesRouteHandler.d.ts +2 -0
- package/types/routes/linksToAllPartialsRouteHandler.d.ts +2 -0
- package/types/routes/module.d.ts +3 -0
- package/types/routes/partial.d.ts +2 -0
- package/types/routes/proxyPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPageRouteHandler.d.ts +2 -0
- package/types/routes/proxyPathPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPathPageRouteHandler.d.ts +2 -0
|
Binary file
|
package/dist/index.js
CHANGED
|
@@ -104,7 +104,7 @@ function devSecretsPlugin(secretNames) {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
// src/createViteDevServer.ts
|
|
107
|
-
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [],
|
|
107
|
+
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames) {
|
|
108
108
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
109
109
|
`${proxyDomain}.localhost`,
|
|
110
110
|
`${proxyDomain}.hslocal.net`
|
|
@@ -152,7 +152,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
152
152
|
}),
|
|
153
153
|
clientIslandEntryPlugin(),
|
|
154
154
|
resolveIslandPlugin(),
|
|
155
|
-
viteCommonjs(),
|
|
155
|
+
jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
|
|
156
156
|
Inspect(),
|
|
157
157
|
devSecretsPlugin(secretNames)
|
|
158
158
|
],
|
package/dist/internalSsr.js
CHANGED
|
@@ -73,51 +73,73 @@ var collectCssInDev = (modulePathToStartWith, viteServer, cssModulesImported = /
|
|
|
73
73
|
).map((cssModule) => createPreloadLink(cssModule.url)).join("\n")}
|
|
74
74
|
`;
|
|
75
75
|
};
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
var badInlineJsChars = /[\u2028\u2029<>/]/g;
|
|
77
|
+
var inlineJsEscapeChars = {
|
|
78
|
+
"\u2028": "\\u2028",
|
|
79
|
+
"\u2029": "\\u2029",
|
|
80
|
+
"<": "\\u003C",
|
|
81
|
+
">": "\\u003E",
|
|
82
|
+
"/": "\\u002F"
|
|
83
|
+
};
|
|
84
|
+
function escapeChar(unsafeChar) {
|
|
85
|
+
return inlineJsEscapeChars[unsafeChar];
|
|
86
|
+
}
|
|
87
|
+
function escapeForInlineJS(input) {
|
|
88
|
+
return input.replace(badInlineJsChars, escapeChar);
|
|
89
|
+
}
|
|
90
|
+
function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
|
|
91
|
+
const indentString = " ".repeat(baseIndent);
|
|
92
|
+
jsonIndent = prettyPrint ? jsonIndent : void 0;
|
|
93
|
+
return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
|
|
94
|
+
/\n/gm,
|
|
95
|
+
`
|
|
96
|
+
${indentString}`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
var serializeIslandDataForInlineScript = (tweakedIslandsArray, baseIndent = 0, prettyPrint) => {
|
|
100
|
+
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
101
|
+
({
|
|
102
|
+
id,
|
|
103
|
+
moduleName,
|
|
104
|
+
moduleId,
|
|
105
|
+
props,
|
|
106
|
+
hydrateOn,
|
|
107
|
+
clientOnly,
|
|
108
|
+
priority,
|
|
109
|
+
url,
|
|
110
|
+
sharedStateID,
|
|
111
|
+
wrapperModuleId,
|
|
112
|
+
wrapperUrl
|
|
113
|
+
}) => {
|
|
114
|
+
const output = {
|
|
81
115
|
id,
|
|
82
116
|
moduleName,
|
|
83
117
|
moduleId,
|
|
84
|
-
props,
|
|
85
118
|
hydrateOn,
|
|
86
119
|
clientOnly,
|
|
87
120
|
priority,
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
moduleId,
|
|
97
|
-
hydrateOn,
|
|
98
|
-
clientOnly,
|
|
99
|
-
priority,
|
|
100
|
-
props,
|
|
101
|
-
url
|
|
102
|
-
};
|
|
103
|
-
if (sharedStateID) {
|
|
104
|
-
output.sharedStateID = sharedStateID;
|
|
105
|
-
}
|
|
106
|
-
if (wrapperModuleId) {
|
|
107
|
-
output.wrapperModuleId = wrapperModuleId;
|
|
108
|
-
}
|
|
109
|
-
if (wrapperUrl) {
|
|
110
|
-
output.wrapperUrl = wrapperUrl;
|
|
111
|
-
}
|
|
112
|
-
return output;
|
|
121
|
+
props,
|
|
122
|
+
url
|
|
123
|
+
};
|
|
124
|
+
if (sharedStateID) {
|
|
125
|
+
output.sharedStateID = sharedStateID;
|
|
126
|
+
}
|
|
127
|
+
if (wrapperModuleId) {
|
|
128
|
+
output.wrapperModuleId = wrapperModuleId;
|
|
113
129
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
130
|
+
if (wrapperUrl) {
|
|
131
|
+
output.wrapperUrl = wrapperUrl;
|
|
132
|
+
}
|
|
133
|
+
return output;
|
|
134
|
+
}
|
|
135
|
+
);
|
|
136
|
+
return jsonStringifyAndEscapeForInlineJS(islandsArrayToSerialize, {
|
|
137
|
+
baseIndent,
|
|
138
|
+
jsonIndent: 2,
|
|
139
|
+
prettyPrint
|
|
140
|
+
});
|
|
119
141
|
};
|
|
120
|
-
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
142
|
+
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, prettyPrint) => {
|
|
121
143
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
122
144
|
if (sharedStateIDs.length > 0) {
|
|
123
145
|
const indentString = " ".repeat(indent);
|
|
@@ -125,7 +147,11 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
|
|
|
125
147
|
sharedStateIDs.forEach(
|
|
126
148
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
127
149
|
);
|
|
128
|
-
const stringifiedState = JSON.stringify(
|
|
150
|
+
const stringifiedState = JSON.stringify(
|
|
151
|
+
stateByID,
|
|
152
|
+
null,
|
|
153
|
+
prettyPrint ? 2 : void 0
|
|
154
|
+
);
|
|
129
155
|
return `
|
|
130
156
|
|
|
131
157
|
var newState = ${stringifiedState};
|
|
@@ -181,19 +207,23 @@ function getPerServerRequestUrls(perServerRequestData, viteDevServer) {
|
|
|
181
207
|
});
|
|
182
208
|
return perServerRequestDataWithUrls;
|
|
183
209
|
}
|
|
184
|
-
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent) => {
|
|
210
|
+
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
|
|
185
211
|
const islands = getIslandUrls(roots, viteDevServer);
|
|
186
212
|
const perServerRequestDataWithUrls = getPerServerRequestUrls(
|
|
187
213
|
perServerRequestData,
|
|
188
214
|
viteDevServer
|
|
189
215
|
);
|
|
190
|
-
return `${" ".repeat(
|
|
191
|
-
islands,
|
|
216
|
+
return `${" ".repeat(
|
|
192
217
|
indent
|
|
218
|
+
)}window.__islands = ${serializeIslandDataForInlineScript(
|
|
219
|
+
islands,
|
|
220
|
+
indent,
|
|
221
|
+
prettyPrint
|
|
193
222
|
)}${writeSharedStateToJsGlobal(
|
|
194
223
|
islands,
|
|
195
224
|
perServerRequestDataWithUrls,
|
|
196
|
-
indent
|
|
225
|
+
indent,
|
|
226
|
+
prettyPrint
|
|
197
227
|
)}`;
|
|
198
228
|
};
|
|
199
229
|
var viteRoot;
|
|
@@ -402,12 +432,18 @@ function getIslandRuntimeConfigUrl() {
|
|
|
402
432
|
const fileVersion = hsEnv === "prod" ? `island-runtime.mjs` : "island-runtime-qa.mjs";
|
|
403
433
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
404
434
|
}
|
|
435
|
+
function includesHublDataReference(templateSource) {
|
|
436
|
+
const hublDataPattern = /\{%\s+set\s+(experimentalHublData|hublData)\s*=/;
|
|
437
|
+
return !!templateSource.match(hublDataPattern);
|
|
438
|
+
}
|
|
405
439
|
var GATES = [
|
|
406
440
|
"CMS:JSRenderer:GetServerSideProps",
|
|
407
|
-
"CMS:JSRenderer:ModuleHubl"
|
|
441
|
+
"CMS:JSRenderer:ModuleHubl",
|
|
442
|
+
"CMS:JSRenderer:RemoveCjsPlugin"
|
|
408
443
|
];
|
|
409
444
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
410
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps"
|
|
445
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
446
|
+
"cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin"
|
|
411
447
|
};
|
|
412
448
|
function isUngatedFor(gates, gate) {
|
|
413
449
|
return gates.includes(gate);
|
|
@@ -480,10 +516,15 @@ function findAllPartialsInRoot(webRoot) {
|
|
|
480
516
|
const partialSubpaths = Object.keys(allPartialComponents);
|
|
481
517
|
return { partialNames, partialSubpaths };
|
|
482
518
|
}
|
|
483
|
-
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
519
|
+
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint) {
|
|
520
|
+
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
521
|
+
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
522
|
+
}
|
|
523
|
+
const serializedJson = jsonStringifyAndEscapeForInlineJS(
|
|
524
|
+
environmentConfig.toJSON(),
|
|
525
|
+
{ baseIndent: 6, prettyPrint }
|
|
526
|
+
);
|
|
527
|
+
const globals = [`window.__hsEnvConfig = ${serializedJson};`];
|
|
487
528
|
if (hsServerPageUrl) {
|
|
488
529
|
globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
|
|
489
530
|
}
|
|
@@ -491,9 +532,9 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
491
532
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
492
533
|
}
|
|
493
534
|
return `
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
535
|
+
<script type="text/javascript">
|
|
536
|
+
${globals.join("\n ")}
|
|
537
|
+
</script>
|
|
497
538
|
`;
|
|
498
539
|
}
|
|
499
540
|
function namespaceModulePropsShape(props) {
|
|
@@ -501,6 +542,7 @@ function namespaceModulePropsShape(props) {
|
|
|
501
542
|
dataQueryResult,
|
|
502
543
|
hublParameters,
|
|
503
544
|
fieldValues: passedFieldValues,
|
|
545
|
+
hublData,
|
|
504
546
|
experimentalHublData
|
|
505
547
|
} = props;
|
|
506
548
|
const oldPropsShape = { ...props };
|
|
@@ -516,6 +558,7 @@ function namespaceModulePropsShape(props) {
|
|
|
516
558
|
dataQueryResult,
|
|
517
559
|
fieldValues,
|
|
518
560
|
hublParameters,
|
|
561
|
+
hublData,
|
|
519
562
|
experimentalHublData
|
|
520
563
|
};
|
|
521
564
|
}
|
|
@@ -588,6 +631,7 @@ export {
|
|
|
588
631
|
collectCssInDev,
|
|
589
632
|
collectCssModules,
|
|
590
633
|
createIslandsGlobalJsForClientInDev,
|
|
634
|
+
escapeForInlineJS,
|
|
591
635
|
findAllComponentsIn,
|
|
592
636
|
findAllModulesInRoot,
|
|
593
637
|
findAllPartialsInRoot,
|
|
@@ -599,9 +643,11 @@ export {
|
|
|
599
643
|
getIslandUrls,
|
|
600
644
|
getServerGlobalsToInject,
|
|
601
645
|
hasComponentExtension,
|
|
646
|
+
includesHublDataReference,
|
|
602
647
|
isStorybookStory,
|
|
603
648
|
isStylesheetAsset,
|
|
604
649
|
isUngatedFor,
|
|
650
|
+
jsonStringifyAndEscapeForInlineJS,
|
|
605
651
|
namespaceModulePropsShape,
|
|
606
652
|
removeComponentExtension,
|
|
607
653
|
renderComponentOnServer,
|
|
@@ -610,7 +656,7 @@ export {
|
|
|
610
656
|
renderStreamToPromise,
|
|
611
657
|
resolveIslandPlugin,
|
|
612
658
|
scriptTagToLogServerMessages,
|
|
613
|
-
|
|
659
|
+
serializeIslandDataForInlineScript,
|
|
614
660
|
setIn,
|
|
615
661
|
ungatedAtBuildTimeFor,
|
|
616
662
|
virtualClientRenderIslandModuleId
|
package/dist/run.js
CHANGED
|
@@ -139,51 +139,73 @@ import { join } from "path/posix";
|
|
|
139
139
|
var COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
140
140
|
var ENTRY_POINTS_PATH = "components/partials/";
|
|
141
141
|
var MODULE_FOLDER_PATH = "components/modules/";
|
|
142
|
-
var
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
var badInlineJsChars = /[\u2028\u2029<>/]/g;
|
|
143
|
+
var inlineJsEscapeChars = {
|
|
144
|
+
"\u2028": "\\u2028",
|
|
145
|
+
"\u2029": "\\u2029",
|
|
146
|
+
"<": "\\u003C",
|
|
147
|
+
">": "\\u003E",
|
|
148
|
+
"/": "\\u002F"
|
|
149
|
+
};
|
|
150
|
+
function escapeChar(unsafeChar) {
|
|
151
|
+
return inlineJsEscapeChars[unsafeChar];
|
|
152
|
+
}
|
|
153
|
+
function escapeForInlineJS(input) {
|
|
154
|
+
return input.replace(badInlineJsChars, escapeChar);
|
|
155
|
+
}
|
|
156
|
+
function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
|
|
157
|
+
const indentString = " ".repeat(baseIndent);
|
|
158
|
+
jsonIndent = prettyPrint ? jsonIndent : void 0;
|
|
159
|
+
return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
|
|
160
|
+
/\n/gm,
|
|
161
|
+
`
|
|
162
|
+
${indentString}`
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
var serializeIslandDataForInlineScript = (tweakedIslandsArray, baseIndent = 0, prettyPrint) => {
|
|
166
|
+
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
167
|
+
({
|
|
168
|
+
id,
|
|
169
|
+
moduleName,
|
|
170
|
+
moduleId,
|
|
171
|
+
props,
|
|
172
|
+
hydrateOn,
|
|
173
|
+
clientOnly,
|
|
174
|
+
priority,
|
|
175
|
+
url: url3,
|
|
176
|
+
sharedStateID,
|
|
177
|
+
wrapperModuleId,
|
|
178
|
+
wrapperUrl
|
|
179
|
+
}) => {
|
|
180
|
+
const output = {
|
|
147
181
|
id,
|
|
148
182
|
moduleName,
|
|
149
183
|
moduleId,
|
|
150
|
-
props,
|
|
151
184
|
hydrateOn,
|
|
152
185
|
clientOnly,
|
|
153
186
|
priority,
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const output = {
|
|
160
|
-
id,
|
|
161
|
-
moduleName,
|
|
162
|
-
moduleId,
|
|
163
|
-
hydrateOn,
|
|
164
|
-
clientOnly,
|
|
165
|
-
priority,
|
|
166
|
-
props,
|
|
167
|
-
url: url3
|
|
168
|
-
};
|
|
169
|
-
if (sharedStateID) {
|
|
170
|
-
output.sharedStateID = sharedStateID;
|
|
171
|
-
}
|
|
172
|
-
if (wrapperModuleId) {
|
|
173
|
-
output.wrapperModuleId = wrapperModuleId;
|
|
174
|
-
}
|
|
175
|
-
if (wrapperUrl) {
|
|
176
|
-
output.wrapperUrl = wrapperUrl;
|
|
177
|
-
}
|
|
178
|
-
return output;
|
|
187
|
+
props,
|
|
188
|
+
url: url3
|
|
189
|
+
};
|
|
190
|
+
if (sharedStateID) {
|
|
191
|
+
output.sharedStateID = sharedStateID;
|
|
179
192
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
193
|
+
if (wrapperModuleId) {
|
|
194
|
+
output.wrapperModuleId = wrapperModuleId;
|
|
195
|
+
}
|
|
196
|
+
if (wrapperUrl) {
|
|
197
|
+
output.wrapperUrl = wrapperUrl;
|
|
198
|
+
}
|
|
199
|
+
return output;
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
return jsonStringifyAndEscapeForInlineJS(islandsArrayToSerialize, {
|
|
203
|
+
baseIndent,
|
|
204
|
+
jsonIndent: 2,
|
|
205
|
+
prettyPrint
|
|
206
|
+
});
|
|
185
207
|
};
|
|
186
|
-
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
208
|
+
var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, prettyPrint) => {
|
|
187
209
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
188
210
|
if (sharedStateIDs.length > 0) {
|
|
189
211
|
const indentString = " ".repeat(indent);
|
|
@@ -191,7 +213,11 @@ var writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) =>
|
|
|
191
213
|
sharedStateIDs.forEach(
|
|
192
214
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
193
215
|
);
|
|
194
|
-
const stringifiedState = JSON.stringify(
|
|
216
|
+
const stringifiedState = JSON.stringify(
|
|
217
|
+
stateByID,
|
|
218
|
+
null,
|
|
219
|
+
prettyPrint ? 2 : void 0
|
|
220
|
+
);
|
|
195
221
|
return `
|
|
196
222
|
|
|
197
223
|
var newState = ${stringifiedState};
|
|
@@ -247,19 +273,23 @@ function getPerServerRequestUrls(perServerRequestData, viteDevServer) {
|
|
|
247
273
|
});
|
|
248
274
|
return perServerRequestDataWithUrls;
|
|
249
275
|
}
|
|
250
|
-
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent) => {
|
|
276
|
+
var createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
|
|
251
277
|
const islands = getIslandUrls(roots, viteDevServer);
|
|
252
278
|
const perServerRequestDataWithUrls = getPerServerRequestUrls(
|
|
253
279
|
perServerRequestData,
|
|
254
280
|
viteDevServer
|
|
255
281
|
);
|
|
256
|
-
return `${" ".repeat(
|
|
257
|
-
islands,
|
|
282
|
+
return `${" ".repeat(
|
|
258
283
|
indent
|
|
284
|
+
)}window.__islands = ${serializeIslandDataForInlineScript(
|
|
285
|
+
islands,
|
|
286
|
+
indent,
|
|
287
|
+
prettyPrint
|
|
259
288
|
)}${writeSharedStateToJsGlobal(
|
|
260
289
|
islands,
|
|
261
290
|
perServerRequestDataWithUrls,
|
|
262
|
-
indent
|
|
291
|
+
indent,
|
|
292
|
+
prettyPrint
|
|
263
293
|
)}`;
|
|
264
294
|
};
|
|
265
295
|
var viteRoot;
|
|
@@ -446,7 +476,8 @@ function getEntryPointHashWithIndexSuffix(entryPoint, index) {
|
|
|
446
476
|
return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;
|
|
447
477
|
}
|
|
448
478
|
var ENABLED_FEATURES_GATE_MAP = {
|
|
449
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps"
|
|
479
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
480
|
+
"cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin"
|
|
450
481
|
};
|
|
451
482
|
function isUngatedFor(gates, gate) {
|
|
452
483
|
return gates.includes(gate);
|
|
@@ -506,10 +537,15 @@ function findAllPartialsInRoot(webRoot2) {
|
|
|
506
537
|
const partialSubpaths = Object.keys(allPartialComponents);
|
|
507
538
|
return { partialNames, partialSubpaths };
|
|
508
539
|
}
|
|
509
|
-
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
540
|
+
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint) {
|
|
541
|
+
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
542
|
+
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
543
|
+
}
|
|
544
|
+
const serializedJson = jsonStringifyAndEscapeForInlineJS(
|
|
545
|
+
environmentConfig.toJSON(),
|
|
546
|
+
{ baseIndent: 6, prettyPrint }
|
|
547
|
+
);
|
|
548
|
+
const globals = [`window.__hsEnvConfig = ${serializedJson};`];
|
|
513
549
|
if (hsServerPageUrl) {
|
|
514
550
|
globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
|
|
515
551
|
}
|
|
@@ -517,9 +553,9 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
517
553
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
518
554
|
}
|
|
519
555
|
return `
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
556
|
+
<script type="text/javascript">
|
|
557
|
+
${globals.join("\n ")}
|
|
558
|
+
</script>
|
|
523
559
|
`;
|
|
524
560
|
}
|
|
525
561
|
function namespaceModulePropsShape(props) {
|
|
@@ -527,6 +563,7 @@ function namespaceModulePropsShape(props) {
|
|
|
527
563
|
dataQueryResult,
|
|
528
564
|
hublParameters,
|
|
529
565
|
fieldValues: passedFieldValues,
|
|
566
|
+
hublData,
|
|
530
567
|
experimentalHublData
|
|
531
568
|
} = props;
|
|
532
569
|
const oldPropsShape = { ...props };
|
|
@@ -542,6 +579,7 @@ function namespaceModulePropsShape(props) {
|
|
|
542
579
|
dataQueryResult,
|
|
543
580
|
fieldValues,
|
|
544
581
|
hublParameters,
|
|
582
|
+
hublData,
|
|
545
583
|
experimentalHublData
|
|
546
584
|
};
|
|
547
585
|
}
|
|
@@ -737,6 +775,9 @@ var renderPartial_default = renderPartial;
|
|
|
737
775
|
|
|
738
776
|
// src/lib/templates.ts
|
|
739
777
|
import { promises as fsPromises } from "fs";
|
|
778
|
+
import {
|
|
779
|
+
isDebugUrlString as isDebugUrlString2
|
|
780
|
+
} from "@hubspot/cms-components";
|
|
740
781
|
var { readFile } = fsPromises;
|
|
741
782
|
var generateIslandSetupScriptBlock = () => {
|
|
742
783
|
return `
|
|
@@ -780,6 +821,7 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
780
821
|
};
|
|
781
822
|
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, __jsRenderingGates) => {
|
|
782
823
|
let htmlTemplate;
|
|
824
|
+
const prettyPrint = isDebugUrlString2(url3);
|
|
783
825
|
if (renderContext.islands.length) {
|
|
784
826
|
const globalScriptBlock = getServerGlobalsToInject(
|
|
785
827
|
renderContext.environmentConfig,
|
|
@@ -798,7 +840,8 @@ ${createIslandsGlobalJsForClientInDev(
|
|
|
798
840
|
renderContext.islands,
|
|
799
841
|
renderContext.perServerRequestData,
|
|
800
842
|
viteServer,
|
|
801
|
-
6
|
|
843
|
+
6,
|
|
844
|
+
prettyPrint
|
|
802
845
|
)}
|
|
803
846
|
</script>
|
|
804
847
|
`
|
|
@@ -815,7 +858,7 @@ ${createIslandsGlobalJsForClientInDev(
|
|
|
815
858
|
}
|
|
816
859
|
return viteServer.transformIndexHtml(url3, htmlTemplate);
|
|
817
860
|
};
|
|
818
|
-
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, __gates) => {
|
|
861
|
+
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, __gates, prettyPrint) => {
|
|
819
862
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
820
863
|
const { createIslandsGlobalJsForClientInDev: createIslandsGlobalJsForClientInDev2 } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
821
864
|
const islandRuntimeScript = await viteServer.transformIndexHtml(
|
|
@@ -827,7 +870,8 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
|
|
|
827
870
|
sortedIslandRoots,
|
|
828
871
|
perServerRequestData,
|
|
829
872
|
viteServer,
|
|
830
|
-
4
|
|
873
|
+
4,
|
|
874
|
+
prettyPrint
|
|
831
875
|
)}</script>
|
|
832
876
|
`;
|
|
833
877
|
};
|
|
@@ -869,7 +913,7 @@ function trackUsage(action) {
|
|
|
869
913
|
eventName: EVENT_NAME,
|
|
870
914
|
action,
|
|
871
915
|
nodeVersion: getNodeVersionData(),
|
|
872
|
-
version: "0.13.
|
|
916
|
+
version: "0.13.4",
|
|
873
917
|
os: getPlatform()
|
|
874
918
|
};
|
|
875
919
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1110,7 +1154,12 @@ var lookForModuleInFolder2 = async (modulePath, viteServer) => {
|
|
|
1110
1154
|
};
|
|
1111
1155
|
async function renderModule(viteServer, requestedModulePath, moduleProps, pageUrl, basePath, environmentConfig, renderOptions) {
|
|
1112
1156
|
console.log("Rendering module", requestedModulePath);
|
|
1113
|
-
const {
|
|
1157
|
+
const {
|
|
1158
|
+
fieldValues: fieldOverrides = {},
|
|
1159
|
+
hublParameters,
|
|
1160
|
+
experimentalHublData,
|
|
1161
|
+
hublData
|
|
1162
|
+
} = moduleProps;
|
|
1114
1163
|
const ungatedForServerSideProps = isUngatedFor(
|
|
1115
1164
|
environmentConfig.getGates(),
|
|
1116
1165
|
"CMS:JSRenderer:GetServerSideProps"
|
|
@@ -1174,7 +1223,9 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1174
1223
|
const namespacedModuleProps = namespaceModulePropsShape({
|
|
1175
1224
|
fieldValues,
|
|
1176
1225
|
hublParameters,
|
|
1177
|
-
dataQueryResult
|
|
1226
|
+
dataQueryResult,
|
|
1227
|
+
experimentalHublData,
|
|
1228
|
+
hublData
|
|
1178
1229
|
});
|
|
1179
1230
|
if (ungatedForServerSideProps && componentModule.getServerSideProps) {
|
|
1180
1231
|
try {
|
|
@@ -1621,6 +1672,7 @@ ${error.error.message}`);
|
|
|
1621
1672
|
// src/proxyPage/proxyPage.ts
|
|
1622
1673
|
import {
|
|
1623
1674
|
buildStaticEnvConfig as buildStaticEnvConfig3,
|
|
1675
|
+
isDebugUrlString as isDebugUrlString3,
|
|
1624
1676
|
mergeServerRequestData_internal
|
|
1625
1677
|
} from "@hubspot/cms-components";
|
|
1626
1678
|
var getEntryPointBasePathFromProxyRequest = (request2) => {
|
|
@@ -1793,6 +1845,7 @@ function renderComponentForPlaceholderModule(viteServer, resolvedPath, localModu
|
|
|
1793
1845
|
async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
|
|
1794
1846
|
let accountId;
|
|
1795
1847
|
let proxyEnv;
|
|
1848
|
+
const prettyPrint = isDebugUrlString3(urlToProxy);
|
|
1796
1849
|
try {
|
|
1797
1850
|
accountId = getAccountId2(portalId);
|
|
1798
1851
|
if (accountId === null) {
|
|
@@ -1918,7 +1971,8 @@ ${result}`;
|
|
|
1918
1971
|
sortedIslandRoots,
|
|
1919
1972
|
mergedPerRequestState,
|
|
1920
1973
|
viteServer,
|
|
1921
|
-
jsRenderingGates
|
|
1974
|
+
jsRenderingGates,
|
|
1975
|
+
prettyPrint
|
|
1922
1976
|
);
|
|
1923
1977
|
response.write(islandRuntimeAndGlobalScriptHtml);
|
|
1924
1978
|
}
|
|
@@ -2362,7 +2416,7 @@ function devSecretsPlugin(secretNames) {
|
|
|
2362
2416
|
}
|
|
2363
2417
|
|
|
2364
2418
|
// src/createViteDevServer.ts
|
|
2365
|
-
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [],
|
|
2419
|
+
async function createViteDevServer(webRoot2, port, sslEnabled, domainsToProxy = [], jsRenderingGates, secretNames) {
|
|
2366
2420
|
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
2367
2421
|
`${proxyDomain}.localhost`,
|
|
2368
2422
|
`${proxyDomain}.hslocal.net`
|
|
@@ -2410,7 +2464,7 @@ Custom origin: ${process.env.VITE_ORIGIN}
|
|
|
2410
2464
|
}),
|
|
2411
2465
|
clientIslandEntryPlugin(),
|
|
2412
2466
|
resolveIslandPlugin(),
|
|
2413
|
-
viteCommonjs(),
|
|
2467
|
+
jsRenderingGates.includes("CMS:JSRenderer:RemoveCjsPlugin") ? null : viteCommonjs(),
|
|
2414
2468
|
Inspect(),
|
|
2415
2469
|
devSecretsPlugin(secretNames)
|
|
2416
2470
|
],
|
package/dist/storybook/index.js
CHANGED
|
@@ -9,6 +9,7 @@ function namespaceModulePropsShape(props) {
|
|
|
9
9
|
dataQueryResult,
|
|
10
10
|
hublParameters,
|
|
11
11
|
fieldValues: passedFieldValues,
|
|
12
|
+
hublData,
|
|
12
13
|
experimentalHublData
|
|
13
14
|
} = props;
|
|
14
15
|
const oldPropsShape = { ...props };
|
|
@@ -24,6 +25,7 @@ function namespaceModulePropsShape(props) {
|
|
|
24
25
|
dataQueryResult,
|
|
25
26
|
fieldValues,
|
|
26
27
|
hublParameters,
|
|
28
|
+
hublData,
|
|
27
29
|
experimentalHublData
|
|
28
30
|
};
|
|
29
31
|
}
|
|
@@ -23,6 +23,7 @@ __export(dist_exports, {
|
|
|
23
23
|
collectCssInDev: () => collectCssInDev,
|
|
24
24
|
collectCssModules: () => collectCssModules,
|
|
25
25
|
createIslandsGlobalJsForClientInDev: () => createIslandsGlobalJsForClientInDev,
|
|
26
|
+
escapeForInlineJS: () => escapeForInlineJS,
|
|
26
27
|
findAllComponentsIn: () => findAllComponentsIn,
|
|
27
28
|
findAllModulesInRoot: () => findAllModulesInRoot,
|
|
28
29
|
findAllPartialsInRoot: () => findAllPartialsInRoot,
|
|
@@ -34,9 +35,11 @@ __export(dist_exports, {
|
|
|
34
35
|
getIslandUrls: () => getIslandUrls,
|
|
35
36
|
getServerGlobalsToInject: () => getServerGlobalsToInject,
|
|
36
37
|
hasComponentExtension: () => hasComponentExtension,
|
|
38
|
+
includesHublDataReference: () => includesHublDataReference,
|
|
37
39
|
isStorybookStory: () => isStorybookStory,
|
|
38
40
|
isStylesheetAsset: () => isStylesheetAsset,
|
|
39
41
|
isUngatedFor: () => isUngatedFor,
|
|
42
|
+
jsonStringifyAndEscapeForInlineJS: () => jsonStringifyAndEscapeForInlineJS,
|
|
40
43
|
namespaceModulePropsShape: () => namespaceModulePropsShape,
|
|
41
44
|
removeComponentExtension: () => removeComponentExtension,
|
|
42
45
|
renderComponentOnServer: () => renderComponentOnServer,
|
|
@@ -45,7 +48,7 @@ __export(dist_exports, {
|
|
|
45
48
|
renderStreamToPromise: () => renderStreamToPromise,
|
|
46
49
|
resolveIslandPlugin: () => resolveIslandPlugin,
|
|
47
50
|
scriptTagToLogServerMessages: () => scriptTagToLogServerMessages,
|
|
48
|
-
|
|
51
|
+
serializeIslandDataForInlineScript: () => serializeIslandDataForInlineScript,
|
|
49
52
|
setIn: () => setIn,
|
|
50
53
|
ungatedAtBuildTimeFor: () => ungatedAtBuildTimeFor,
|
|
51
54
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
@@ -82,6 +85,21 @@ function createPreloadLink(assetPath, basePath = "") {
|
|
|
82
85
|
throw new Error(`Unknown preload type for ${assetPath}`);
|
|
83
86
|
}
|
|
84
87
|
}
|
|
88
|
+
function escapeChar(unsafeChar) {
|
|
89
|
+
return inlineJsEscapeChars[unsafeChar];
|
|
90
|
+
}
|
|
91
|
+
function escapeForInlineJS(input) {
|
|
92
|
+
return input.replace(badInlineJsChars, escapeChar);
|
|
93
|
+
}
|
|
94
|
+
function jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true }) {
|
|
95
|
+
const indentString = " ".repeat(baseIndent);
|
|
96
|
+
jsonIndent = prettyPrint ? jsonIndent : void 0;
|
|
97
|
+
return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(
|
|
98
|
+
/\n/gm,
|
|
99
|
+
`
|
|
100
|
+
${indentString}`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
85
103
|
function getIslandUrls(roots, viteDevServer) {
|
|
86
104
|
return roots.map((island) => {
|
|
87
105
|
const islandModule = viteDevServer.moduleGraph.getModuleById(
|
|
@@ -237,6 +255,10 @@ function getIslandRuntimeConfigUrl() {
|
|
|
237
255
|
const fileVersion = hsEnv === "prod" ? `island-runtime.mjs` : "island-runtime-qa.mjs";
|
|
238
256
|
return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;
|
|
239
257
|
}
|
|
258
|
+
function includesHublDataReference(templateSource) {
|
|
259
|
+
const hublDataPattern = /\{%\s+set\s+(experimentalHublData|hublData)\s*=/;
|
|
260
|
+
return !!templateSource.match(hublDataPattern);
|
|
261
|
+
}
|
|
240
262
|
function isUngatedFor(gates, gate) {
|
|
241
263
|
return gates.includes(gate);
|
|
242
264
|
}
|
|
@@ -274,10 +296,15 @@ function findAllPartialsInRoot(webRoot2) {
|
|
|
274
296
|
const partialSubpaths = Object.keys(allPartialComponents);
|
|
275
297
|
return { partialNames, partialSubpaths };
|
|
276
298
|
}
|
|
277
|
-
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath) {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
299
|
+
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint) {
|
|
300
|
+
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
301
|
+
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
302
|
+
}
|
|
303
|
+
const serializedJson = jsonStringifyAndEscapeForInlineJS(
|
|
304
|
+
environmentConfig.toJSON(),
|
|
305
|
+
{ baseIndent: 6, prettyPrint }
|
|
306
|
+
);
|
|
307
|
+
const globals = [`window.__hsEnvConfig = ${serializedJson};`];
|
|
281
308
|
if (hsServerPageUrl) {
|
|
282
309
|
globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
|
|
283
310
|
}
|
|
@@ -285,9 +312,9 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
285
312
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
286
313
|
}
|
|
287
314
|
return `
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
315
|
+
<script type="text/javascript">
|
|
316
|
+
${globals.join("\n ")}
|
|
317
|
+
</script>
|
|
291
318
|
`;
|
|
292
319
|
}
|
|
293
320
|
function namespaceModulePropsShape(props) {
|
|
@@ -295,6 +322,7 @@ function namespaceModulePropsShape(props) {
|
|
|
295
322
|
dataQueryResult,
|
|
296
323
|
hublParameters,
|
|
297
324
|
fieldValues: passedFieldValues,
|
|
325
|
+
hublData,
|
|
298
326
|
experimentalHublData
|
|
299
327
|
} = props;
|
|
300
328
|
const oldPropsShape = { ...props };
|
|
@@ -310,6 +338,7 @@ function namespaceModulePropsShape(props) {
|
|
|
310
338
|
dataQueryResult,
|
|
311
339
|
fieldValues,
|
|
312
340
|
hublParameters,
|
|
341
|
+
hublData,
|
|
313
342
|
experimentalHublData
|
|
314
343
|
};
|
|
315
344
|
}
|
|
@@ -369,7 +398,7 @@ function renderFieldsToJson(fields, moduleName) {
|
|
|
369
398
|
function isStylesheetAsset(staticAsset) {
|
|
370
399
|
return staticAsset.type === "stylesheet";
|
|
371
400
|
}
|
|
372
|
-
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev,
|
|
401
|
+
var COMPONENT_EXTENSIONS, ENTRY_POINTS_PATH, MODULE_FOLDER_PATH, VIRTUAL_ISLAND_RUNTIME, VIRTUAL_CONFIG_SETUP, CSS_LANGS_RE, collectCssModules, collectCssInDev, badInlineJsChars, inlineJsEscapeChars, serializeIslandDataForInlineScript, 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;
|
|
373
402
|
var init_dist = __esm({
|
|
374
403
|
"../cms-js-internal/dist/index.js"() {
|
|
375
404
|
COMPONENT_EXTENSIONS = [".jsx", ".tsx", ".js", ".ts"];
|
|
@@ -414,51 +443,58 @@ var init_dist = __esm({
|
|
|
414
443
|
).map((cssModule) => createPreloadLink(cssModule.url)).join("\n")}
|
|
415
444
|
`;
|
|
416
445
|
};
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
446
|
+
badInlineJsChars = /[\u2028\u2029<>/]/g;
|
|
447
|
+
inlineJsEscapeChars = {
|
|
448
|
+
"\u2028": "\\u2028",
|
|
449
|
+
"\u2029": "\\u2029",
|
|
450
|
+
"<": "\\u003C",
|
|
451
|
+
">": "\\u003E",
|
|
452
|
+
"/": "\\u002F"
|
|
453
|
+
};
|
|
454
|
+
serializeIslandDataForInlineScript = (tweakedIslandsArray, baseIndent = 0, prettyPrint) => {
|
|
455
|
+
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
456
|
+
({
|
|
457
|
+
id,
|
|
458
|
+
moduleName,
|
|
459
|
+
moduleId,
|
|
460
|
+
props,
|
|
461
|
+
hydrateOn,
|
|
462
|
+
clientOnly,
|
|
463
|
+
priority,
|
|
464
|
+
url,
|
|
465
|
+
sharedStateID,
|
|
466
|
+
wrapperModuleId,
|
|
467
|
+
wrapperUrl
|
|
468
|
+
}) => {
|
|
469
|
+
const output = {
|
|
422
470
|
id,
|
|
423
471
|
moduleName,
|
|
424
472
|
moduleId,
|
|
425
|
-
props,
|
|
426
473
|
hydrateOn,
|
|
427
474
|
clientOnly,
|
|
428
475
|
priority,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
moduleId,
|
|
438
|
-
hydrateOn,
|
|
439
|
-
clientOnly,
|
|
440
|
-
priority,
|
|
441
|
-
props,
|
|
442
|
-
url
|
|
443
|
-
};
|
|
444
|
-
if (sharedStateID) {
|
|
445
|
-
output.sharedStateID = sharedStateID;
|
|
446
|
-
}
|
|
447
|
-
if (wrapperModuleId) {
|
|
448
|
-
output.wrapperModuleId = wrapperModuleId;
|
|
449
|
-
}
|
|
450
|
-
if (wrapperUrl) {
|
|
451
|
-
output.wrapperUrl = wrapperUrl;
|
|
452
|
-
}
|
|
453
|
-
return output;
|
|
476
|
+
props,
|
|
477
|
+
url
|
|
478
|
+
};
|
|
479
|
+
if (sharedStateID) {
|
|
480
|
+
output.sharedStateID = sharedStateID;
|
|
481
|
+
}
|
|
482
|
+
if (wrapperModuleId) {
|
|
483
|
+
output.wrapperModuleId = wrapperModuleId;
|
|
454
484
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
485
|
+
if (wrapperUrl) {
|
|
486
|
+
output.wrapperUrl = wrapperUrl;
|
|
487
|
+
}
|
|
488
|
+
return output;
|
|
489
|
+
}
|
|
490
|
+
);
|
|
491
|
+
return jsonStringifyAndEscapeForInlineJS(islandsArrayToSerialize, {
|
|
492
|
+
baseIndent,
|
|
493
|
+
jsonIndent: 2,
|
|
494
|
+
prettyPrint
|
|
495
|
+
});
|
|
460
496
|
};
|
|
461
|
-
writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0) => {
|
|
497
|
+
writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, prettyPrint) => {
|
|
462
498
|
const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);
|
|
463
499
|
if (sharedStateIDs.length > 0) {
|
|
464
500
|
const indentString = " ".repeat(indent);
|
|
@@ -466,7 +502,11 @@ ${indentString}`)}`;
|
|
|
466
502
|
sharedStateIDs.forEach(
|
|
467
503
|
(id) => stateByID[id] = perServerRequestData.get(id)
|
|
468
504
|
);
|
|
469
|
-
const stringifiedState = JSON.stringify(
|
|
505
|
+
const stringifiedState = JSON.stringify(
|
|
506
|
+
stateByID,
|
|
507
|
+
null,
|
|
508
|
+
prettyPrint ? 2 : void 0
|
|
509
|
+
);
|
|
470
510
|
return `
|
|
471
511
|
|
|
472
512
|
var newState = ${stringifiedState};
|
|
@@ -479,19 +519,23 @@ ${indentString}`);
|
|
|
479
519
|
}
|
|
480
520
|
return "";
|
|
481
521
|
};
|
|
482
|
-
createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent) => {
|
|
522
|
+
createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
|
|
483
523
|
const islands = getIslandUrls(roots, viteDevServer);
|
|
484
524
|
const perServerRequestDataWithUrls = getPerServerRequestUrls(
|
|
485
525
|
perServerRequestData,
|
|
486
526
|
viteDevServer
|
|
487
527
|
);
|
|
488
|
-
return `${" ".repeat(
|
|
489
|
-
islands,
|
|
528
|
+
return `${" ".repeat(
|
|
490
529
|
indent
|
|
530
|
+
)}window.__islands = ${serializeIslandDataForInlineScript(
|
|
531
|
+
islands,
|
|
532
|
+
indent,
|
|
533
|
+
prettyPrint
|
|
491
534
|
)}${writeSharedStateToJsGlobal(
|
|
492
535
|
islands,
|
|
493
536
|
perServerRequestDataWithUrls,
|
|
494
|
-
indent
|
|
537
|
+
indent,
|
|
538
|
+
prettyPrint
|
|
495
539
|
)}`;
|
|
496
540
|
};
|
|
497
541
|
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: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\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 let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\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 {innerComponent}\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";
|
|
@@ -588,10 +632,12 @@ ${groupEnd}</script>
|
|
|
588
632
|
ISLAND_RUNTIME_CONFIG_BASE_PATH = "https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1";
|
|
589
633
|
GATES = [
|
|
590
634
|
"CMS:JSRenderer:GetServerSideProps",
|
|
591
|
-
"CMS:JSRenderer:ModuleHubl"
|
|
635
|
+
"CMS:JSRenderer:ModuleHubl",
|
|
636
|
+
"CMS:JSRenderer:RemoveCjsPlugin"
|
|
592
637
|
];
|
|
593
638
|
ENABLED_FEATURES_GATE_MAP = {
|
|
594
|
-
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps"
|
|
639
|
+
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
640
|
+
"cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin"
|
|
595
641
|
};
|
|
596
642
|
BUILD_INFO_PATH = "/build-info.json";
|
|
597
643
|
findAllComponentsIn = (webRoot2, componentsFolder) => {
|
|
@@ -631,6 +677,7 @@ ${groupEnd}</script>
|
|
|
631
677
|
});
|
|
632
678
|
|
|
633
679
|
// src/storybook-main/main.ts
|
|
680
|
+
init_dist();
|
|
634
681
|
import path2 from "path";
|
|
635
682
|
import { mergeConfig } from "vite";
|
|
636
683
|
import { withoutVitePlugins } from "@storybook/builder-vite";
|
|
@@ -649,13 +696,16 @@ var main_default = {
|
|
|
649
696
|
<script type="module">
|
|
650
697
|
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
651
698
|
|
|
652
|
-
initConfigSingletonFromJSON(${
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
699
|
+
initConfigSingletonFromJSON(${jsonStringifyAndEscapeForInlineJS(
|
|
700
|
+
{
|
|
701
|
+
portalId: process.env.portalId,
|
|
702
|
+
hublet: process.env.hublet,
|
|
703
|
+
hsEnv: process.env.hsEnv,
|
|
704
|
+
hsDeployed: false,
|
|
705
|
+
hsJSRGates: jsRenderingGates
|
|
706
|
+
},
|
|
707
|
+
{ prettyPrint: false }
|
|
708
|
+
)})
|
|
659
709
|
</script>
|
|
660
710
|
|
|
661
711
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.4",
|
|
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.13.
|
|
28
|
+
"@hubspot/cms-components": "^0.13.4",
|
|
29
29
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
30
30
|
"@storybook/addon-actions": "7.0.7",
|
|
31
31
|
"@storybook/addon-essentials": "7.0.7",
|
|
@@ -101,5 +101,5 @@
|
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public"
|
|
103
103
|
},
|
|
104
|
-
"gitHead": "
|
|
104
|
+
"gitHead": "c71b01b2c1a58fa3446621a3aa866ff5284dea19"
|
|
105
105
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import { Gate } from '@hubspot/cms-js-internal';
|
|
2
|
+
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[], jsRenderingGates: Gate[], secretNames: string[]): Promise<import("vite").ViteDevServer>;
|
|
2
3
|
export default createViteDevServer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debug: any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare type DataQueryPoints = {
|
|
2
|
+
count: number;
|
|
3
|
+
weight: number;
|
|
4
|
+
used_points: number;
|
|
5
|
+
};
|
|
6
|
+
declare type DataQueryResult = {
|
|
7
|
+
extensions: {
|
|
8
|
+
query_complexity: {
|
|
9
|
+
max_points: number;
|
|
10
|
+
used_points: number;
|
|
11
|
+
points_for_internal_api_requests: DataQueryPoints;
|
|
12
|
+
points_for_objects_retrieved: DataQueryPoints;
|
|
13
|
+
points_for_properties_with_value: DataQueryPoints;
|
|
14
|
+
points_for_properties_without_value: DataQueryPoints;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
data?: {
|
|
18
|
+
CRM?: any;
|
|
19
|
+
HUBDB?: any;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export declare function clearGraphQLDataCache(): void;
|
|
23
|
+
export default function fetchModuleGraphQLData(accountId: number, query: string, requestedModulePath: string, pageUrl: string): Promise<DataQueryResult>;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const findFullPathInModuleGraph: (modulePathNoExtension: string, moduleGraph: any) => string | void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function packagePath(metaUrl: string, projectPath: string): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
export declare const getComponentPaths: (viteServer: ViteDevServer, componentPath: string) => [componentPathNoExtension: string, componentPathWithExtension: string];
|
|
3
|
+
export declare const getEntryPointBasePath: (componentPath: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface LocalRenderBlockInfo {
|
|
2
|
+
startOffset: number;
|
|
3
|
+
endOffset: number;
|
|
4
|
+
path: string;
|
|
5
|
+
json: any;
|
|
6
|
+
}
|
|
7
|
+
export declare const findLocalRenderPlaceholders: (body: string) => Array<LocalRenderBlockInfo>;
|
|
8
|
+
export declare const getProjectNameFromHSConfig: (hsProjectConfigPath: any) => any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { RenderToPipeableStreamOptions } from 'react-dom/server';
|
|
4
|
+
import { ServerRenderContextValue } from '@hubspot/cms-components';
|
|
5
|
+
import { EnvironmentConfig } from '@hubspot/cms-components/config';
|
|
6
|
+
import { InlineAsset } from '@hubspot/cms-js-internal';
|
|
7
|
+
export declare type RenderResult = {
|
|
8
|
+
html: string;
|
|
9
|
+
inlineAssets?: InlineAsset[];
|
|
10
|
+
cssNeeded: string;
|
|
11
|
+
renderContext: ServerRenderContextValue;
|
|
12
|
+
};
|
|
13
|
+
declare function renderComponentWithCSS(viteServer: ViteDevServer, componentPath: string, Component: ComponentType, props: any, pageUrl: string, entryPointBasePath: string, environmentConfig: EnvironmentConfig, renderOptions: RenderToPipeableStreamOptions): Promise<RenderResult>;
|
|
14
|
+
export default renderComponentWithCSS;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const logPartialInfo: (partialPath: any, props: any) => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { RenderToPipeableStreamOptions } from 'react-dom/server';
|
|
3
|
+
import { EnvironmentConfig } from '@hubspot/cms-components/config';
|
|
4
|
+
declare function renderModule(viteServer: ViteDevServer, requestedModulePath: string, moduleProps: {
|
|
5
|
+
fieldValues: any;
|
|
6
|
+
hublParameters?: any;
|
|
7
|
+
}, pageUrl: string, basePath: string, environmentConfig: EnvironmentConfig, renderOptions?: RenderToPipeableStreamOptions): Promise<import("./renderComponentWithCSS.js").RenderResult>;
|
|
8
|
+
export default renderModule;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EnvironmentConfig } from '@hubspot/cms-components/config';
|
|
2
|
+
import { ViteDevServer } from 'vite';
|
|
3
|
+
import { RenderToPipeableStreamOptions } from 'react-dom/server';
|
|
4
|
+
declare function renderPartial(viteServer: ViteDevServer, partialPath: string, props: any, pageUrl: string, basePath: string, environmentConfig: EnvironmentConfig, renderOptions?: RenderToPipeableStreamOptions): Promise<import("./renderComponentWithCSS.js").RenderResult>;
|
|
5
|
+
export default renderPartial;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
import { ServerRenderContextValue } from '@hubspot/cms-components';
|
|
3
|
+
export declare const createHtmlShellDependingOnRenderContext: (baseTemplatePath: string, url: string, title: string, renderContext: ServerRenderContextValue, viteServer: ViteDevServer, __jsRenderingGates: string[]) => Promise<string>;
|
|
4
|
+
export declare const getIslandRuntimeAndGlobalToInject: (sortedIslandRoots: any, perServerRequestData: any, viteServer: ViteDevServer, __gates: string[]) => Promise<string>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const VALID_PROXY_DOMAIN_SUFFIXES: string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Hublet } from '@hubspot/cms-components';
|
|
2
|
+
export declare type PortalContentIdAndHublet = {
|
|
3
|
+
portalId: number;
|
|
4
|
+
contentId: string;
|
|
5
|
+
hublet: Hublet;
|
|
6
|
+
};
|
|
7
|
+
export default function fetchContentMetadata(url: string, portalId: number): Promise<PortalContentIdAndHublet>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { ViteDevServer } from 'vite';
|
|
3
|
+
import { Gate } from '@hubspot/cms-js-internal';
|
|
4
|
+
import { Hublet } from '@hubspot/cms-components';
|
|
5
|
+
export declare const makeProxyPreviewRequest: (accountId: string, urlToProxy: string, previewKey: string, contentId: string, projectName: string, __jsRenderingGates: Gate[]) => any;
|
|
6
|
+
export default function proxySpecificPage(response: Response, portalId: number, hublet: Hublet, contentId: string, webRoot: string, viteServer: ViteDevServer, projectName: string, projectComponentPath: string, jsRenderingGates: Gate[], urlToProxy?: string, fullOriginalUrl?: string): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RenderResult } from '../lib/renderComponentWithCSS.js';
|
|
2
|
+
export declare const getSubDomainFromValidLocalDomain: (hostname: any) => any;
|
|
3
|
+
export declare const fakeRenderJsComponent: (indexForThisRender: any) => Promise<RenderResult>;
|
|
4
|
+
export declare const consoleWarn: (message: any) => void;
|