@hubspot/cms-dev-server 0.12.1 → 0.13.3
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/internalSsr.js +94 -50
- package/dist/run.js +109 -56
- package/dist/storybook/index.js +2 -0
- package/dist/storybook-main/main.js +106 -58
- package/package.json +3 -3
- package/types/components/ModulesList.d.ts +5 -0
- package/types/components/PartialsList.d.ts +4 -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/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/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
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,6 +432,10 @@ 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
441
|
"CMS:JSRenderer:ModuleHubl"
|
|
@@ -480,10 +514,15 @@ function findAllPartialsInRoot(webRoot) {
|
|
|
480
514
|
const partialSubpaths = Object.keys(allPartialComponents);
|
|
481
515
|
return { partialNames, partialSubpaths };
|
|
482
516
|
}
|
|
483
|
-
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath) {
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
517
|
+
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint) {
|
|
518
|
+
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
519
|
+
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
520
|
+
}
|
|
521
|
+
const serializedJson = jsonStringifyAndEscapeForInlineJS(
|
|
522
|
+
environmentConfig.toJSON(),
|
|
523
|
+
{ baseIndent: 6, prettyPrint }
|
|
524
|
+
);
|
|
525
|
+
const globals = [`window.__hsEnvConfig = ${serializedJson};`];
|
|
487
526
|
if (hsServerPageUrl) {
|
|
488
527
|
globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
|
|
489
528
|
}
|
|
@@ -491,9 +530,9 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
491
530
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
492
531
|
}
|
|
493
532
|
return `
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
533
|
+
<script type="text/javascript">
|
|
534
|
+
${globals.join("\n ")}
|
|
535
|
+
</script>
|
|
497
536
|
`;
|
|
498
537
|
}
|
|
499
538
|
function namespaceModulePropsShape(props) {
|
|
@@ -501,6 +540,7 @@ function namespaceModulePropsShape(props) {
|
|
|
501
540
|
dataQueryResult,
|
|
502
541
|
hublParameters,
|
|
503
542
|
fieldValues: passedFieldValues,
|
|
543
|
+
hublData,
|
|
504
544
|
experimentalHublData
|
|
505
545
|
} = props;
|
|
506
546
|
const oldPropsShape = { ...props };
|
|
@@ -516,6 +556,7 @@ function namespaceModulePropsShape(props) {
|
|
|
516
556
|
dataQueryResult,
|
|
517
557
|
fieldValues,
|
|
518
558
|
hublParameters,
|
|
559
|
+
hublData,
|
|
519
560
|
experimentalHublData
|
|
520
561
|
};
|
|
521
562
|
}
|
|
@@ -588,6 +629,7 @@ export {
|
|
|
588
629
|
collectCssInDev,
|
|
589
630
|
collectCssModules,
|
|
590
631
|
createIslandsGlobalJsForClientInDev,
|
|
632
|
+
escapeForInlineJS,
|
|
591
633
|
findAllComponentsIn,
|
|
592
634
|
findAllModulesInRoot,
|
|
593
635
|
findAllPartialsInRoot,
|
|
@@ -599,9 +641,11 @@ export {
|
|
|
599
641
|
getIslandUrls,
|
|
600
642
|
getServerGlobalsToInject,
|
|
601
643
|
hasComponentExtension,
|
|
644
|
+
includesHublDataReference,
|
|
602
645
|
isStorybookStory,
|
|
603
646
|
isStylesheetAsset,
|
|
604
647
|
isUngatedFor,
|
|
648
|
+
jsonStringifyAndEscapeForInlineJS,
|
|
605
649
|
namespaceModulePropsShape,
|
|
606
650
|
removeComponentExtension,
|
|
607
651
|
renderComponentOnServer,
|
|
@@ -610,7 +654,7 @@ export {
|
|
|
610
654
|
renderStreamToPromise,
|
|
611
655
|
resolveIslandPlugin,
|
|
612
656
|
scriptTagToLogServerMessages,
|
|
613
|
-
|
|
657
|
+
serializeIslandDataForInlineScript,
|
|
614
658
|
setIn,
|
|
615
659
|
ungatedAtBuildTimeFor,
|
|
616
660
|
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;
|
|
@@ -506,10 +536,15 @@ function findAllPartialsInRoot(webRoot2) {
|
|
|
506
536
|
const partialSubpaths = Object.keys(allPartialComponents);
|
|
507
537
|
return { partialNames, partialSubpaths };
|
|
508
538
|
}
|
|
509
|
-
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath) {
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
539
|
+
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint) {
|
|
540
|
+
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
541
|
+
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
542
|
+
}
|
|
543
|
+
const serializedJson = jsonStringifyAndEscapeForInlineJS(
|
|
544
|
+
environmentConfig.toJSON(),
|
|
545
|
+
{ baseIndent: 6, prettyPrint }
|
|
546
|
+
);
|
|
547
|
+
const globals = [`window.__hsEnvConfig = ${serializedJson};`];
|
|
513
548
|
if (hsServerPageUrl) {
|
|
514
549
|
globals.push(`window.__hsServerPageUrl = '${hsServerPageUrl}';`);
|
|
515
550
|
}
|
|
@@ -517,9 +552,9 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
517
552
|
globals.push(`window.__hsBasePath = '${hsBasePath}';`);
|
|
518
553
|
}
|
|
519
554
|
return `
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
555
|
+
<script type="text/javascript">
|
|
556
|
+
${globals.join("\n ")}
|
|
557
|
+
</script>
|
|
523
558
|
`;
|
|
524
559
|
}
|
|
525
560
|
function namespaceModulePropsShape(props) {
|
|
@@ -527,6 +562,7 @@ function namespaceModulePropsShape(props) {
|
|
|
527
562
|
dataQueryResult,
|
|
528
563
|
hublParameters,
|
|
529
564
|
fieldValues: passedFieldValues,
|
|
565
|
+
hublData,
|
|
530
566
|
experimentalHublData
|
|
531
567
|
} = props;
|
|
532
568
|
const oldPropsShape = { ...props };
|
|
@@ -542,6 +578,7 @@ function namespaceModulePropsShape(props) {
|
|
|
542
578
|
dataQueryResult,
|
|
543
579
|
fieldValues,
|
|
544
580
|
hublParameters,
|
|
581
|
+
hublData,
|
|
545
582
|
experimentalHublData
|
|
546
583
|
};
|
|
547
584
|
}
|
|
@@ -737,6 +774,9 @@ var renderPartial_default = renderPartial;
|
|
|
737
774
|
|
|
738
775
|
// src/lib/templates.ts
|
|
739
776
|
import { promises as fsPromises } from "fs";
|
|
777
|
+
import {
|
|
778
|
+
isDebugUrlString as isDebugUrlString2
|
|
779
|
+
} from "@hubspot/cms-components";
|
|
740
780
|
var { readFile } = fsPromises;
|
|
741
781
|
var generateIslandSetupScriptBlock = () => {
|
|
742
782
|
return `
|
|
@@ -780,6 +820,7 @@ var createIslandHtmlTemplate = async (baseTemplatePath, title, globalScriptBlock
|
|
|
780
820
|
};
|
|
781
821
|
var createHtmlShellDependingOnRenderContext = async (baseTemplatePath, url3, title, renderContext, viteServer, __jsRenderingGates) => {
|
|
782
822
|
let htmlTemplate;
|
|
823
|
+
const prettyPrint = isDebugUrlString2(url3);
|
|
783
824
|
if (renderContext.islands.length) {
|
|
784
825
|
const globalScriptBlock = getServerGlobalsToInject(
|
|
785
826
|
renderContext.environmentConfig,
|
|
@@ -798,7 +839,8 @@ ${createIslandsGlobalJsForClientInDev(
|
|
|
798
839
|
renderContext.islands,
|
|
799
840
|
renderContext.perServerRequestData,
|
|
800
841
|
viteServer,
|
|
801
|
-
6
|
|
842
|
+
6,
|
|
843
|
+
prettyPrint
|
|
802
844
|
)}
|
|
803
845
|
</script>
|
|
804
846
|
`
|
|
@@ -815,7 +857,7 @@ ${createIslandsGlobalJsForClientInDev(
|
|
|
815
857
|
}
|
|
816
858
|
return viteServer.transformIndexHtml(url3, htmlTemplate);
|
|
817
859
|
};
|
|
818
|
-
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, __gates) => {
|
|
860
|
+
var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerRequestData, viteServer, __gates, prettyPrint) => {
|
|
819
861
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
820
862
|
const { createIslandsGlobalJsForClientInDev: createIslandsGlobalJsForClientInDev2 } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
821
863
|
const islandRuntimeScript = await viteServer.transformIndexHtml(
|
|
@@ -827,7 +869,8 @@ var getIslandRuntimeAndGlobalToInject = async (sortedIslandRoots, perServerReque
|
|
|
827
869
|
sortedIslandRoots,
|
|
828
870
|
perServerRequestData,
|
|
829
871
|
viteServer,
|
|
830
|
-
4
|
|
872
|
+
4,
|
|
873
|
+
prettyPrint
|
|
831
874
|
)}</script>
|
|
832
875
|
`;
|
|
833
876
|
};
|
|
@@ -869,7 +912,7 @@ function trackUsage(action) {
|
|
|
869
912
|
eventName: EVENT_NAME,
|
|
870
913
|
action,
|
|
871
914
|
nodeVersion: getNodeVersionData(),
|
|
872
|
-
version: "0.
|
|
915
|
+
version: "0.13.3",
|
|
873
916
|
os: getPlatform()
|
|
874
917
|
};
|
|
875
918
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1110,7 +1153,12 @@ var lookForModuleInFolder2 = async (modulePath, viteServer) => {
|
|
|
1110
1153
|
};
|
|
1111
1154
|
async function renderModule(viteServer, requestedModulePath, moduleProps, pageUrl, basePath, environmentConfig, renderOptions) {
|
|
1112
1155
|
console.log("Rendering module", requestedModulePath);
|
|
1113
|
-
const {
|
|
1156
|
+
const {
|
|
1157
|
+
fieldValues: fieldOverrides = {},
|
|
1158
|
+
hublParameters,
|
|
1159
|
+
experimentalHublData,
|
|
1160
|
+
hublData
|
|
1161
|
+
} = moduleProps;
|
|
1114
1162
|
const ungatedForServerSideProps = isUngatedFor(
|
|
1115
1163
|
environmentConfig.getGates(),
|
|
1116
1164
|
"CMS:JSRenderer:GetServerSideProps"
|
|
@@ -1174,7 +1222,9 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1174
1222
|
const namespacedModuleProps = namespaceModulePropsShape({
|
|
1175
1223
|
fieldValues,
|
|
1176
1224
|
hublParameters,
|
|
1177
|
-
dataQueryResult
|
|
1225
|
+
dataQueryResult,
|
|
1226
|
+
experimentalHublData,
|
|
1227
|
+
hublData
|
|
1178
1228
|
});
|
|
1179
1229
|
if (ungatedForServerSideProps && componentModule.getServerSideProps) {
|
|
1180
1230
|
try {
|
|
@@ -1621,6 +1671,7 @@ ${error.error.message}`);
|
|
|
1621
1671
|
// src/proxyPage/proxyPage.ts
|
|
1622
1672
|
import {
|
|
1623
1673
|
buildStaticEnvConfig as buildStaticEnvConfig3,
|
|
1674
|
+
isDebugUrlString as isDebugUrlString3,
|
|
1624
1675
|
mergeServerRequestData_internal
|
|
1625
1676
|
} from "@hubspot/cms-components";
|
|
1626
1677
|
var getEntryPointBasePathFromProxyRequest = (request2) => {
|
|
@@ -1793,6 +1844,7 @@ function renderComponentForPlaceholderModule(viteServer, resolvedPath, localModu
|
|
|
1793
1844
|
async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
|
|
1794
1845
|
let accountId;
|
|
1795
1846
|
let proxyEnv;
|
|
1847
|
+
const prettyPrint = isDebugUrlString3(urlToProxy);
|
|
1796
1848
|
try {
|
|
1797
1849
|
accountId = getAccountId2(portalId);
|
|
1798
1850
|
if (accountId === null) {
|
|
@@ -1918,7 +1970,8 @@ ${result}`;
|
|
|
1918
1970
|
sortedIslandRoots,
|
|
1919
1971
|
mergedPerRequestState,
|
|
1920
1972
|
viteServer,
|
|
1921
|
-
jsRenderingGates
|
|
1973
|
+
jsRenderingGates,
|
|
1974
|
+
prettyPrint
|
|
1922
1975
|
);
|
|
1923
1976
|
response.write(islandRuntimeAndGlobalScriptHtml);
|
|
1924
1977
|
}
|
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";
|
|
@@ -631,6 +675,7 @@ ${groupEnd}</script>
|
|
|
631
675
|
});
|
|
632
676
|
|
|
633
677
|
// src/storybook-main/main.ts
|
|
678
|
+
init_dist();
|
|
634
679
|
import path2 from "path";
|
|
635
680
|
import { mergeConfig } from "vite";
|
|
636
681
|
import { withoutVitePlugins } from "@storybook/builder-vite";
|
|
@@ -649,13 +694,16 @@ var main_default = {
|
|
|
649
694
|
<script type="module">
|
|
650
695
|
import { initConfigSingletonFromJSON } from '@hubspot/cms-components/config';
|
|
651
696
|
|
|
652
|
-
initConfigSingletonFromJSON(${
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
697
|
+
initConfigSingletonFromJSON(${jsonStringifyAndEscapeForInlineJS(
|
|
698
|
+
{
|
|
699
|
+
portalId: process.env.portalId,
|
|
700
|
+
hublet: process.env.hublet,
|
|
701
|
+
hsEnv: process.env.hsEnv,
|
|
702
|
+
hsDeployed: false,
|
|
703
|
+
hsJSRGates: jsRenderingGates
|
|
704
|
+
},
|
|
705
|
+
{ prettyPrint: false }
|
|
706
|
+
)})
|
|
659
707
|
</script>
|
|
660
708
|
|
|
661
709
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.3",
|
|
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.
|
|
28
|
+
"@hubspot/cms-components": "^0.13.3",
|
|
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": "551b9121af85a18c200fc8714ee8192541b02169"
|
|
105
105
|
}
|
|
@@ -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;
|