@hubspot/cms-dev-server 0.14.15 → 0.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +9 -3
- package/dist/internalSsr.js +37 -17
- package/dist/run.js +98 -88
- package/dist/storybook/index.js +6 -0
- package/dist/storybook-main/main.js +38 -18
- package/package.json +6 -6
- package/dist/createViteDevServer-5624911d.js +0 -69
- package/dist/index-de34229d.js +0 -525
- package/dist/index-e4860c0f.js +0 -150
- package/dist/index2.js +0 -178
- package/dist/main.js +0 -52
- package/dist/preview.js +0 -18
- package/types/island-runtime.d.ts +0 -2
package/dist/index.js
CHANGED
|
@@ -78,6 +78,7 @@ function clientIslandEntryPlugin() {
|
|
|
78
78
|
|
|
79
79
|
// ../cms-js-internal/dist/index.js
|
|
80
80
|
import * as dotProp from "dot-prop";
|
|
81
|
+
import * as cmsComponents from "@hubspot/cms-components";
|
|
81
82
|
var { setProperty, getProperty, hasProperty } = dotProp;
|
|
82
83
|
function noncePlaceholderPlugin() {
|
|
83
84
|
const HS_DEPLOYED = process.env.AWS_EXECUTION_ENV != null || process.env.HS_DEPLOYED === "true";
|
|
@@ -101,6 +102,11 @@ function noncePlaceholderPlugin() {
|
|
|
101
102
|
}
|
|
102
103
|
};
|
|
103
104
|
}
|
|
105
|
+
var {
|
|
106
|
+
createServerRenderContextV2: createServerRenderContextV22,
|
|
107
|
+
createServerRenderContext: createServerRenderContext2,
|
|
108
|
+
renderSuspendedServerSidePropsWithContext
|
|
109
|
+
} = cmsComponents;
|
|
104
110
|
|
|
105
111
|
// src/createViteDevServer.ts
|
|
106
112
|
import { default as mkcert } from "vite-plugin-mkcert";
|
|
@@ -113,11 +119,11 @@ function devSecretsPlugin(secretNames) {
|
|
|
113
119
|
configureServer: {
|
|
114
120
|
order: "post",
|
|
115
121
|
async handler(server) {
|
|
116
|
-
const
|
|
122
|
+
const cmsComponents2 = await server.ssrLoadModule(
|
|
117
123
|
"@hubspot/cms-components"
|
|
118
124
|
);
|
|
119
|
-
if (
|
|
120
|
-
|
|
125
|
+
if (cmsComponents2.setSecretsFromEnv) {
|
|
126
|
+
cmsComponents2.setSecretsFromEnv(secretNames);
|
|
121
127
|
} else if (secretNames.length > 0) {
|
|
122
128
|
console.warn(
|
|
123
129
|
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
package/dist/internalSsr.js
CHANGED
|
@@ -431,7 +431,7 @@ function isStylesheetAsset(staticAsset) {
|
|
|
431
431
|
|
|
432
432
|
// ../cms-js-internal/dist/index.js
|
|
433
433
|
import * as dotProp from "dot-prop";
|
|
434
|
-
import
|
|
434
|
+
import { jsx } from "react/jsx-runtime";
|
|
435
435
|
import stream from "stream";
|
|
436
436
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
437
437
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
@@ -617,7 +617,6 @@ function noncePlaceholderPlugin() {
|
|
|
617
617
|
}
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
-
var jsx2 = jsxRuntime.jsx;
|
|
621
620
|
var promiseForNewWritableStream = () => {
|
|
622
621
|
const chunks = [];
|
|
623
622
|
const writableStream = new stream.Writable();
|
|
@@ -654,29 +653,50 @@ var renderStreamToPromise = async (reactElements, options) => {
|
|
|
654
653
|
});
|
|
655
654
|
return streamDonePromise;
|
|
656
655
|
};
|
|
657
|
-
|
|
656
|
+
var {
|
|
657
|
+
createServerRenderContextV2: createServerRenderContextV22,
|
|
658
|
+
createServerRenderContext: createServerRenderContext2,
|
|
659
|
+
renderSuspendedServerSidePropsWithContext
|
|
660
|
+
} = cmsComponents;
|
|
661
|
+
var bootStrapRenderContext = () => {
|
|
662
|
+
const renderContext = createServerRenderContextV22 ? createServerRenderContextV22(null, {
|
|
663
|
+
environmentConfig: null,
|
|
664
|
+
entryPointBasePath: "",
|
|
665
|
+
supplementalFieldValues: {},
|
|
666
|
+
messagesForBrowser: []
|
|
667
|
+
}) : createServerRenderContext2("", null);
|
|
668
|
+
return renderContext;
|
|
669
|
+
};
|
|
670
|
+
async function renderComponentOnServer(Component, propsAndDeps, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions, getServerSideProps) {
|
|
671
|
+
const { props } = propsAndDeps;
|
|
658
672
|
const componentDebugName = Component.displayName || Component.name;
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
pageUrl,
|
|
662
|
-
environmentConfig,
|
|
663
|
-
entryPointBasePath,
|
|
664
|
-
contextOptions,
|
|
665
|
-
componentDebugName,
|
|
666
|
-
renderOptions
|
|
667
|
-
);
|
|
668
|
-
}
|
|
669
|
-
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
670
|
-
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
671
|
-
const messagesForBrowser = contextOptions ? contextOptions.messagesForBrowser : void 0;
|
|
673
|
+
const supplementalFieldValues = contextOptions == null ? void 0 : contextOptions.supplementalFieldValues;
|
|
674
|
+
const messagesForBrowser = contextOptions == null ? void 0 : contextOptions.messagesForBrowser;
|
|
672
675
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
673
676
|
environmentConfig,
|
|
674
677
|
entryPointBasePath,
|
|
675
678
|
supplementalFieldValues,
|
|
676
679
|
messagesForBrowser
|
|
677
680
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
681
|
+
if (renderSuspendedServerSidePropsWithContext !== void 0 && getServerSideProps !== void 0 && typeof getServerSideProps === "function") {
|
|
682
|
+
await renderSuspendedServerSidePropsWithContext(
|
|
683
|
+
getServerSideProps,
|
|
684
|
+
propsAndDeps,
|
|
685
|
+
renderContext
|
|
686
|
+
);
|
|
687
|
+
const serverSideProps = renderContext.perServerRequestData.get("serverSideProps");
|
|
688
|
+
props.serverSideProps = serverSideProps;
|
|
689
|
+
}
|
|
690
|
+
return renderOnServer(
|
|
691
|
+
/* @__PURE__ */ jsx(Component, { ...props }),
|
|
692
|
+
renderContext,
|
|
693
|
+
componentDebugName,
|
|
694
|
+
renderOptions
|
|
695
|
+
);
|
|
696
|
+
}
|
|
697
|
+
async function renderOnServer(elements, renderContext = bootStrapRenderContext(), debugName, renderOptions) {
|
|
678
698
|
let html = await renderStreamToPromise(
|
|
679
|
-
/* @__PURE__ */
|
|
699
|
+
/* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
680
700
|
renderOptions
|
|
681
701
|
);
|
|
682
702
|
if (renderContext.messagesForBrowser.length > 0) {
|
package/dist/run.js
CHANGED
|
@@ -404,7 +404,7 @@ function setIn(object, nestedKeysArray, value) {
|
|
|
404
404
|
|
|
405
405
|
// ../cms-js-internal/dist/index.js
|
|
406
406
|
import * as dotProp from "dot-prop";
|
|
407
|
-
import
|
|
407
|
+
import { jsx } from "react/jsx-runtime";
|
|
408
408
|
import stream from "stream";
|
|
409
409
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
410
410
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
@@ -589,7 +589,6 @@ function noncePlaceholderPlugin() {
|
|
|
589
589
|
}
|
|
590
590
|
};
|
|
591
591
|
}
|
|
592
|
-
var jsx2 = jsxRuntime.jsx;
|
|
593
592
|
var promiseForNewWritableStream = () => {
|
|
594
593
|
const chunks = [];
|
|
595
594
|
const writableStream = new stream.Writable();
|
|
@@ -626,17 +625,23 @@ var renderStreamToPromise = async (reactElements, options) => {
|
|
|
626
625
|
});
|
|
627
626
|
return streamDonePromise;
|
|
628
627
|
};
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
628
|
+
var {
|
|
629
|
+
createServerRenderContextV2: createServerRenderContextV22,
|
|
630
|
+
createServerRenderContext: createServerRenderContext2,
|
|
631
|
+
renderSuspendedServerSidePropsWithContext
|
|
632
|
+
} = cmsComponents;
|
|
633
|
+
var bootStrapRenderContext = () => {
|
|
634
|
+
const renderContext = createServerRenderContextV22 ? createServerRenderContextV22(null, {
|
|
635
|
+
environmentConfig: null,
|
|
636
|
+
entryPointBasePath: "",
|
|
637
|
+
supplementalFieldValues: {},
|
|
638
|
+
messagesForBrowser: []
|
|
639
|
+
}) : createServerRenderContext2("", null);
|
|
640
|
+
return renderContext;
|
|
641
|
+
};
|
|
642
|
+
async function renderOnServer(elements, renderContext = bootStrapRenderContext(), debugName, renderOptions) {
|
|
638
643
|
let html = await renderStreamToPromise(
|
|
639
|
-
/* @__PURE__ */
|
|
644
|
+
/* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
640
645
|
renderOptions
|
|
641
646
|
);
|
|
642
647
|
if (renderContext.messagesForBrowser.length > 0) {
|
|
@@ -734,25 +739,33 @@ var getEntryPointBasePath = (componentPath) => {
|
|
|
734
739
|
};
|
|
735
740
|
|
|
736
741
|
// src/lib/renderComponentWithCSS.ts
|
|
737
|
-
async function renderComponentWithCSS(viteServer, componentPath, Component,
|
|
742
|
+
async function renderComponentWithCSS(viteServer, componentPath, Component, propsAndExtraDeps, pageUrl, entryPointBasePath, contextOptions, environmentConfig, renderOptions, getServerSideProps, modifyHtmlCallback) {
|
|
738
743
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
739
744
|
const { renderComponentOnServer, collectCssInDev: collectCssInDev2 } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
740
745
|
const [, componentPathWithExtension] = getComponentPaths(
|
|
741
746
|
viteServer,
|
|
742
747
|
componentPath
|
|
743
748
|
);
|
|
744
|
-
const
|
|
745
|
-
html,
|
|
746
|
-
renderContext
|
|
747
|
-
} = await renderComponentOnServer(
|
|
749
|
+
const renderResult = await renderComponentOnServer(
|
|
748
750
|
Component,
|
|
749
|
-
|
|
751
|
+
propsAndExtraDeps,
|
|
750
752
|
pageUrl,
|
|
751
753
|
environmentConfig,
|
|
752
754
|
entryPointBasePath,
|
|
753
755
|
contextOptions,
|
|
754
|
-
renderOptions
|
|
756
|
+
renderOptions,
|
|
757
|
+
getServerSideProps
|
|
755
758
|
);
|
|
759
|
+
let html = renderResult.html;
|
|
760
|
+
const renderContext = renderResult.renderContext;
|
|
761
|
+
if (modifyHtmlCallback) {
|
|
762
|
+
html = modifyHtmlCallback(
|
|
763
|
+
html,
|
|
764
|
+
renderContext,
|
|
765
|
+
[]
|
|
766
|
+
// Build-time generated static asset arracy is only available when deployed
|
|
767
|
+
);
|
|
768
|
+
}
|
|
756
769
|
const cssNeeded = collectCssInDev2(componentPathWithExtension, viteServer);
|
|
757
770
|
let inlineAssets = [];
|
|
758
771
|
if (renderContext.inlineAssets && Array.isArray(renderContext.inlineAssets)) {
|
|
@@ -851,7 +864,7 @@ async function renderPartial(viteServer, partialPath, props, pageUrl, basePath,
|
|
|
851
864
|
viteServer,
|
|
852
865
|
resolvedPath,
|
|
853
866
|
Component,
|
|
854
|
-
props,
|
|
867
|
+
{ props },
|
|
855
868
|
pageUrl,
|
|
856
869
|
basePath,
|
|
857
870
|
void 0,
|
|
@@ -1031,7 +1044,7 @@ function trackUsage(action) {
|
|
|
1031
1044
|
eventName: EVENT_NAME,
|
|
1032
1045
|
action,
|
|
1033
1046
|
nodeVersion: getNodeVersionData(),
|
|
1034
|
-
version: "0.
|
|
1047
|
+
version: "0.15.0",
|
|
1035
1048
|
os: getPlatform()
|
|
1036
1049
|
};
|
|
1037
1050
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1150,7 +1163,7 @@ ${e.stack}`);
|
|
|
1150
1163
|
var partial_default = partialRouteHandler;
|
|
1151
1164
|
|
|
1152
1165
|
// src/components/PartialsList.tsx
|
|
1153
|
-
import { jsx as
|
|
1166
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
1154
1167
|
function EmptyPartialsList({ webRoot: webRoot2 }) {
|
|
1155
1168
|
return /* @__PURE__ */ jsxs("p", { children: [
|
|
1156
1169
|
"No partials in ",
|
|
@@ -1161,32 +1174,29 @@ function EmptyPartialsList({ webRoot: webRoot2 }) {
|
|
|
1161
1174
|
] });
|
|
1162
1175
|
}
|
|
1163
1176
|
function PartialLinkInLI({ partialName }) {
|
|
1164
|
-
return /* @__PURE__ */
|
|
1177
|
+
return /* @__PURE__ */ jsx2("li", { children: /* @__PURE__ */ jsx2("a", { href: `/partial/${partialName}`, children: partialName }) });
|
|
1165
1178
|
}
|
|
1166
1179
|
function PartialsList({ webRoot: webRoot2, partialNames }) {
|
|
1167
1180
|
if (partialNames.length === 0) {
|
|
1168
|
-
return /* @__PURE__ */
|
|
1181
|
+
return /* @__PURE__ */ jsx2(EmptyPartialsList, { webRoot: webRoot2 });
|
|
1169
1182
|
}
|
|
1170
|
-
return /* @__PURE__ */
|
|
1183
|
+
return /* @__PURE__ */ jsx2("ul", { children: partialNames.map((partialName) => /* @__PURE__ */ jsx2(PartialLinkInLI, { partialName }, partialName)) });
|
|
1171
1184
|
}
|
|
1172
1185
|
|
|
1173
1186
|
// src/routes/linksToAllPartialsRouteHandler.tsx
|
|
1174
|
-
import { jsx as
|
|
1187
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
1175
1188
|
var linksToAllPartialRouteHandler = async (request2, response) => {
|
|
1176
1189
|
const { webRoot: webRoot2 } = request2.app.locals;
|
|
1177
1190
|
const { partialNames } = findAllPartialsInRoot(webRoot2);
|
|
1178
1191
|
const { html: responseHtml } = await renderOnServer(
|
|
1179
|
-
/* @__PURE__ */
|
|
1180
|
-
null,
|
|
1181
|
-
null,
|
|
1182
|
-
""
|
|
1192
|
+
/* @__PURE__ */ jsx3(PartialsList, { webRoot: webRoot2, partialNames })
|
|
1183
1193
|
);
|
|
1184
1194
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
1185
1195
|
};
|
|
1186
1196
|
var linksToAllPartialsRouteHandler_default = linksToAllPartialRouteHandler;
|
|
1187
1197
|
|
|
1188
1198
|
// src/components/ModulesList.tsx
|
|
1189
|
-
import { jsx as
|
|
1199
|
+
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1190
1200
|
function EmptyModulesList({ webRoot: webRoot2 }) {
|
|
1191
1201
|
return /* @__PURE__ */ jsxs2("p", { children: [
|
|
1192
1202
|
"No modules in ",
|
|
@@ -1198,29 +1208,26 @@ function EmptyModulesList({ webRoot: webRoot2 }) {
|
|
|
1198
1208
|
}
|
|
1199
1209
|
function ModuleLinkInLI({ moduleName }) {
|
|
1200
1210
|
return /* @__PURE__ */ jsxs2("li", { children: [
|
|
1201
|
-
/* @__PURE__ */
|
|
1211
|
+
/* @__PURE__ */ jsx4("a", { href: `/preview/module/${moduleName}`, children: moduleName }),
|
|
1202
1212
|
" / ",
|
|
1203
|
-
/* @__PURE__ */
|
|
1213
|
+
/* @__PURE__ */ jsx4("a", { href: `/module/${moduleName}`, children: "Local Version" })
|
|
1204
1214
|
] });
|
|
1205
1215
|
}
|
|
1206
1216
|
function ModulesList({ webRoot: webRoot2, moduleNames }) {
|
|
1207
1217
|
if (moduleNames.length === 0) {
|
|
1208
|
-
return /* @__PURE__ */
|
|
1218
|
+
return /* @__PURE__ */ jsx4(EmptyModulesList, { webRoot: webRoot2 });
|
|
1209
1219
|
}
|
|
1210
|
-
return /* @__PURE__ */
|
|
1220
|
+
return /* @__PURE__ */ jsx4("ul", { children: moduleNames.map((moduleName) => /* @__PURE__ */ jsx4(ModuleLinkInLI, { moduleName }, moduleName)) });
|
|
1211
1221
|
}
|
|
1212
1222
|
var ModulesList_default = ModulesList;
|
|
1213
1223
|
|
|
1214
1224
|
// src/routes/linksToAllModulesRouteHandler.tsx
|
|
1215
|
-
import { jsx as
|
|
1225
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
1216
1226
|
var linksToAllModuleRouteHandler = async (request2, response) => {
|
|
1217
1227
|
const { webRoot: webRoot2 } = request2.app.locals;
|
|
1218
1228
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
1219
1229
|
const { html: responseHtml } = await renderOnServer(
|
|
1220
|
-
/* @__PURE__ */
|
|
1221
|
-
null,
|
|
1222
|
-
null,
|
|
1223
|
-
""
|
|
1230
|
+
/* @__PURE__ */ jsx5(ModulesList_default, { webRoot: webRoot2, moduleNames })
|
|
1224
1231
|
);
|
|
1225
1232
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
1226
1233
|
};
|
|
@@ -1234,6 +1241,7 @@ import { normalizePath as normalizePath3 } from "vite";
|
|
|
1234
1241
|
// src/lib/renderModule.ts
|
|
1235
1242
|
import { join as joinPosix2 } from "path/posix";
|
|
1236
1243
|
import { traverseFieldsJSON } from "@hubspot/cms-components/fields";
|
|
1244
|
+
import * as cmsComponents2 from "@hubspot/cms-components";
|
|
1237
1245
|
import cliHttp3 from "@hubspot/cli-lib/http.js";
|
|
1238
1246
|
|
|
1239
1247
|
// src/lib/fetchModuleGraphQLData.ts
|
|
@@ -1263,6 +1271,7 @@ async function fetchModuleGraphQLData(accountId, query, requestedModulePath, pag
|
|
|
1263
1271
|
}
|
|
1264
1272
|
|
|
1265
1273
|
// src/lib/renderModule.ts
|
|
1274
|
+
var { filterToModuleDataDepsIncludedIn, getModuleDataDependecyTypeFrom } = cmsComponents2;
|
|
1266
1275
|
var getApplyFieldsValidationToRenderContext = (portalId, fieldsJSON, requestedModulePath) => {
|
|
1267
1276
|
return async (renderResult) => {
|
|
1268
1277
|
const { renderContext } = renderResult;
|
|
@@ -1323,10 +1332,11 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1323
1332
|
"CMS:JSRenderer:GetServerSideProps"
|
|
1324
1333
|
);
|
|
1325
1334
|
const messagesForBrowser = [];
|
|
1326
|
-
let serverSideProps;
|
|
1327
1335
|
let componentModule;
|
|
1328
1336
|
let dataQueryResult;
|
|
1329
1337
|
let foundPath;
|
|
1338
|
+
let getServerSideProps;
|
|
1339
|
+
let extraDeps;
|
|
1330
1340
|
if (!hasComponentExtension(requestedModulePath)) {
|
|
1331
1341
|
[componentModule, foundPath] = await lookForModuleInFolder2(
|
|
1332
1342
|
requestedModulePath,
|
|
@@ -1405,40 +1415,35 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1405
1415
|
moduleName
|
|
1406
1416
|
});
|
|
1407
1417
|
if (ungatedForServerSideProps && componentModule.getServerSideProps) {
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
new URL(pageUrl)
|
|
1412
|
-
);
|
|
1413
|
-
if (serverSideProps.constructor !== {}.constructor) {
|
|
1414
|
-
throw new Error("getServerSideProps must return an object");
|
|
1415
|
-
}
|
|
1416
|
-
} catch (error) {
|
|
1417
|
-
const errorString = `Error resolving server side props ${requestedModulePath}`;
|
|
1418
|
-
console.log(errorString);
|
|
1419
|
-
console.error(error);
|
|
1420
|
-
messagesForBrowser.push(
|
|
1421
|
-
{
|
|
1422
|
-
level: "error",
|
|
1423
|
-
parameters: [errorString]
|
|
1424
|
-
},
|
|
1425
|
-
{
|
|
1426
|
-
level: "error",
|
|
1427
|
-
parameters: [error.message]
|
|
1428
|
-
}
|
|
1418
|
+
if (!getModuleDataDependecyTypeFrom || !filterToModuleDataDepsIncludedIn) {
|
|
1419
|
+
throw new Error(
|
|
1420
|
+
`Need to upgrade to @hubspot/cms-components 0.15.x or higher to use getServerSideProps`
|
|
1429
1421
|
);
|
|
1430
1422
|
}
|
|
1423
|
+
getServerSideProps = componentModule.getServerSideProps;
|
|
1424
|
+
const depType = getModuleDataDependecyTypeFrom(
|
|
1425
|
+
componentModule.getServerSideProps
|
|
1426
|
+
);
|
|
1427
|
+
extraDeps = filterToModuleDataDepsIncludedIn(depType, {
|
|
1428
|
+
url: new URL(pageUrl),
|
|
1429
|
+
contact: void 0,
|
|
1430
|
+
// TODO
|
|
1431
|
+
request: void 0
|
|
1432
|
+
// TODO
|
|
1433
|
+
});
|
|
1431
1434
|
}
|
|
1432
1435
|
return renderComponentWithCSS_default(
|
|
1433
1436
|
viteServer,
|
|
1434
1437
|
foundPath,
|
|
1435
1438
|
Component,
|
|
1436
|
-
{
|
|
1439
|
+
{ props: namespacedModuleProps, extraDeps },
|
|
1437
1440
|
pageUrl,
|
|
1438
1441
|
basePath,
|
|
1439
1442
|
{ supplementalFieldValues, messagesForBrowser },
|
|
1440
1443
|
environmentConfig,
|
|
1441
|
-
renderOptions
|
|
1444
|
+
renderOptions,
|
|
1445
|
+
getServerSideProps,
|
|
1446
|
+
componentModule.unstable_modifyHtml
|
|
1442
1447
|
).then(applyFieldsValidationToRenderContext);
|
|
1443
1448
|
}
|
|
1444
1449
|
function getFieldValuesForModule(fieldsJSON, fieldOverrides = {}) {
|
|
@@ -1484,7 +1489,9 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
1484
1489
|
if (request2.query.fields) {
|
|
1485
1490
|
try {
|
|
1486
1491
|
if (typeof request2.query.fields === "string") {
|
|
1487
|
-
fieldOverrides = JSON.parse(
|
|
1492
|
+
fieldOverrides = JSON.parse(
|
|
1493
|
+
decodeURIComponent(request2.query.fields.replace(/\+/g, "%20"))
|
|
1494
|
+
);
|
|
1488
1495
|
}
|
|
1489
1496
|
} catch (e) {
|
|
1490
1497
|
console.error(
|
|
@@ -2334,7 +2341,7 @@ function proxyPageResourceRedirect(req, res, next) {
|
|
|
2334
2341
|
}
|
|
2335
2342
|
|
|
2336
2343
|
// src/routes/homeRouteHandler.tsx
|
|
2337
|
-
import { Fragment, jsx as
|
|
2344
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2338
2345
|
var homeRouteHandler = async (request2, response, next) => {
|
|
2339
2346
|
const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
|
|
2340
2347
|
if (domainToProxy) {
|
|
@@ -2347,22 +2354,19 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
2347
2354
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
2348
2355
|
const { html: responseHtml } = await renderOnServer(
|
|
2349
2356
|
/* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
2350
|
-
storybookEnabled ? /* @__PURE__ */
|
|
2351
|
-
/* @__PURE__ */
|
|
2352
|
-
/* @__PURE__ */
|
|
2353
|
-
/* @__PURE__ */
|
|
2354
|
-
/* @__PURE__ */
|
|
2355
|
-
] })
|
|
2356
|
-
null,
|
|
2357
|
-
null,
|
|
2358
|
-
""
|
|
2357
|
+
storybookEnabled ? /* @__PURE__ */ jsx6("h2", { children: /* @__PURE__ */ jsx6("a", { href: `//storybook.${request2.hostname}:${devServerPort}`, children: "Storybook" }) }) : null,
|
|
2358
|
+
/* @__PURE__ */ jsx6("h2", { children: "Partials" }),
|
|
2359
|
+
/* @__PURE__ */ jsx6(PartialsList, { webRoot: webRoot2, partialNames }),
|
|
2360
|
+
/* @__PURE__ */ jsx6("h2", { children: "Modules" }),
|
|
2361
|
+
/* @__PURE__ */ jsx6(ModulesList_default, { webRoot: webRoot2, moduleNames })
|
|
2362
|
+
] })
|
|
2359
2363
|
);
|
|
2360
2364
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
2361
2365
|
};
|
|
2362
2366
|
var homeRouteHandler_default = homeRouteHandler;
|
|
2363
2367
|
|
|
2364
2368
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
2365
|
-
import { jsx as
|
|
2369
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2366
2370
|
async function proxyPathPageRouteHandler(request2, response, next) {
|
|
2367
2371
|
sendTrackingRequest("view-proxy-path-route");
|
|
2368
2372
|
const {
|
|
@@ -2378,10 +2382,10 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2378
2382
|
if (!request2.query.page) {
|
|
2379
2383
|
const { html: responseHtml } = await renderOnServer(
|
|
2380
2384
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2381
|
-
/* @__PURE__ */
|
|
2385
|
+
/* @__PURE__ */ jsx7("h2", { children: "Local Proxy" }),
|
|
2382
2386
|
/* @__PURE__ */ jsxs4("form", { action: "/proxy", children: [
|
|
2383
|
-
/* @__PURE__ */
|
|
2384
|
-
/* @__PURE__ */
|
|
2387
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: "page", style: { display: "block" }, children: "Page URL" }),
|
|
2388
|
+
/* @__PURE__ */ jsx7(
|
|
2385
2389
|
"input",
|
|
2386
2390
|
{
|
|
2387
2391
|
style: { width: "300px" },
|
|
@@ -2390,12 +2394,9 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2390
2394
|
placeholder: "https://somecmspage.com/path"
|
|
2391
2395
|
}
|
|
2392
2396
|
),
|
|
2393
|
-
/* @__PURE__ */
|
|
2397
|
+
/* @__PURE__ */ jsx7("button", { style: { display: "block" }, children: "Proxy" })
|
|
2394
2398
|
] })
|
|
2395
|
-
] })
|
|
2396
|
-
null,
|
|
2397
|
-
null,
|
|
2398
|
-
""
|
|
2399
|
+
] })
|
|
2399
2400
|
);
|
|
2400
2401
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
2401
2402
|
return;
|
|
@@ -2820,11 +2821,11 @@ function devSecretsPlugin(secretNames) {
|
|
|
2820
2821
|
configureServer: {
|
|
2821
2822
|
order: "post",
|
|
2822
2823
|
async handler(server) {
|
|
2823
|
-
const
|
|
2824
|
+
const cmsComponents3 = await server.ssrLoadModule(
|
|
2824
2825
|
"@hubspot/cms-components"
|
|
2825
2826
|
);
|
|
2826
|
-
if (
|
|
2827
|
-
|
|
2827
|
+
if (cmsComponents3.setSecretsFromEnv) {
|
|
2828
|
+
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
2828
2829
|
} else if (secretNames.length > 0) {
|
|
2829
2830
|
console.warn(
|
|
2830
2831
|
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
@@ -3108,6 +3109,7 @@ async function validateHSPlatform(webroot, portalId) {
|
|
|
3108
3109
|
}
|
|
3109
3110
|
|
|
3110
3111
|
// src/createDevServer.ts
|
|
3112
|
+
import { get as hsGet6 } from "@hubspot/cli-lib/http.js";
|
|
3111
3113
|
var BASE_PATH = "/";
|
|
3112
3114
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
3113
3115
|
var SHADOW_PORT = 1442;
|
|
@@ -3210,7 +3212,15 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
3210
3212
|
}
|
|
3211
3213
|
}
|
|
3212
3214
|
}
|
|
3213
|
-
|
|
3215
|
+
let authedHublet;
|
|
3216
|
+
try {
|
|
3217
|
+
const accountInformation = await hsGet6(authedPortalId, {
|
|
3218
|
+
uri: "/account-info/v3/details"
|
|
3219
|
+
});
|
|
3220
|
+
authedHublet = accountInformation.dataHostingLocation;
|
|
3221
|
+
} catch (e) {
|
|
3222
|
+
authedHublet = "na1";
|
|
3223
|
+
}
|
|
3214
3224
|
const absoluteWebRoot = normalizePath6(path8.resolve(process.cwd(), webRoot2));
|
|
3215
3225
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
3216
3226
|
if (authedPortalId) {
|
package/dist/storybook/index.js
CHANGED
|
@@ -35,8 +35,14 @@ function namespaceModulePropsShape(props) {
|
|
|
35
35
|
// ../cms-js-internal/dist/index.js
|
|
36
36
|
import * as dotProp from "dot-prop";
|
|
37
37
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
38
|
+
import * as cmsComponents from "@hubspot/cms-components";
|
|
38
39
|
import { isValidElement, cloneElement } from "react";
|
|
39
40
|
var { setProperty, getProperty, hasProperty } = dotProp;
|
|
41
|
+
var {
|
|
42
|
+
createServerRenderContextV2: createServerRenderContextV22,
|
|
43
|
+
createServerRenderContext: createServerRenderContext2,
|
|
44
|
+
renderSuspendedServerSidePropsWithContext
|
|
45
|
+
} = cmsComponents;
|
|
40
46
|
function renderFieldsJSX(fieldsJSX) {
|
|
41
47
|
let moduleJson;
|
|
42
48
|
const outputCallback = (callbackJson) => {
|
|
@@ -498,7 +498,7 @@ __export(dist_exports, {
|
|
|
498
498
|
virtualClientRenderIslandModuleId: () => virtualClientRenderIslandModuleId
|
|
499
499
|
});
|
|
500
500
|
import * as dotProp from "dot-prop";
|
|
501
|
-
import
|
|
501
|
+
import { jsx } from "react/jsx-runtime";
|
|
502
502
|
import stream from "stream";
|
|
503
503
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
504
504
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
@@ -588,29 +588,36 @@ function noncePlaceholderPlugin() {
|
|
|
588
588
|
}
|
|
589
589
|
};
|
|
590
590
|
}
|
|
591
|
-
async function renderComponentOnServer(Component,
|
|
591
|
+
async function renderComponentOnServer(Component, propsAndDeps, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions, getServerSideProps) {
|
|
592
|
+
const { props } = propsAndDeps;
|
|
592
593
|
const componentDebugName = Component.displayName || Component.name;
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
pageUrl,
|
|
596
|
-
environmentConfig,
|
|
597
|
-
entryPointBasePath,
|
|
598
|
-
contextOptions,
|
|
599
|
-
componentDebugName,
|
|
600
|
-
renderOptions
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
604
|
-
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
605
|
-
const messagesForBrowser = contextOptions ? contextOptions.messagesForBrowser : void 0;
|
|
594
|
+
const supplementalFieldValues = contextOptions == null ? void 0 : contextOptions.supplementalFieldValues;
|
|
595
|
+
const messagesForBrowser = contextOptions == null ? void 0 : contextOptions.messagesForBrowser;
|
|
606
596
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
607
597
|
environmentConfig,
|
|
608
598
|
entryPointBasePath,
|
|
609
599
|
supplementalFieldValues,
|
|
610
600
|
messagesForBrowser
|
|
611
601
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
602
|
+
if (renderSuspendedServerSidePropsWithContext !== void 0 && getServerSideProps !== void 0 && typeof getServerSideProps === "function") {
|
|
603
|
+
await renderSuspendedServerSidePropsWithContext(
|
|
604
|
+
getServerSideProps,
|
|
605
|
+
propsAndDeps,
|
|
606
|
+
renderContext
|
|
607
|
+
);
|
|
608
|
+
const serverSideProps = renderContext.perServerRequestData.get("serverSideProps");
|
|
609
|
+
props.serverSideProps = serverSideProps;
|
|
610
|
+
}
|
|
611
|
+
return renderOnServer(
|
|
612
|
+
/* @__PURE__ */ jsx(Component, { ...props }),
|
|
613
|
+
renderContext,
|
|
614
|
+
componentDebugName,
|
|
615
|
+
renderOptions
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
async function renderOnServer(elements, renderContext = bootStrapRenderContext(), debugName, renderOptions) {
|
|
612
619
|
let html = await renderStreamToPromise(
|
|
613
|
-
/* @__PURE__ */
|
|
620
|
+
/* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
614
621
|
renderOptions
|
|
615
622
|
);
|
|
616
623
|
if (renderContext.messagesForBrowser.length > 0) {
|
|
@@ -696,7 +703,7 @@ function renderFieldsToJson(fields, moduleName) {
|
|
|
696
703
|
throw e;
|
|
697
704
|
}
|
|
698
705
|
}
|
|
699
|
-
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev,
|
|
706
|
+
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderSuspendedServerSidePropsWithContext, bootStrapRenderContext;
|
|
700
707
|
var init_dist = __esm({
|
|
701
708
|
"../cms-js-internal/dist/index.js"() {
|
|
702
709
|
init_basicUtils();
|
|
@@ -797,7 +804,6 @@ ${indentString}`);
|
|
|
797
804
|
prettyPrint
|
|
798
805
|
)}`;
|
|
799
806
|
};
|
|
800
|
-
jsx2 = jsxRuntime.jsx;
|
|
801
807
|
promiseForNewWritableStream = () => {
|
|
802
808
|
const chunks = [];
|
|
803
809
|
const writableStream = new stream.Writable();
|
|
@@ -834,6 +840,20 @@ ${indentString}`);
|
|
|
834
840
|
});
|
|
835
841
|
return streamDonePromise;
|
|
836
842
|
};
|
|
843
|
+
({
|
|
844
|
+
createServerRenderContextV2: createServerRenderContextV22,
|
|
845
|
+
createServerRenderContext: createServerRenderContext2,
|
|
846
|
+
renderSuspendedServerSidePropsWithContext
|
|
847
|
+
} = cmsComponents);
|
|
848
|
+
bootStrapRenderContext = () => {
|
|
849
|
+
const renderContext = createServerRenderContextV22 ? createServerRenderContextV22(null, {
|
|
850
|
+
environmentConfig: null,
|
|
851
|
+
entryPointBasePath: "",
|
|
852
|
+
supplementalFieldValues: {},
|
|
853
|
+
messagesForBrowser: []
|
|
854
|
+
}) : createServerRenderContext2("", null);
|
|
855
|
+
return renderContext;
|
|
856
|
+
};
|
|
837
857
|
}
|
|
838
858
|
});
|
|
839
859
|
|