@hubspot/cms-dev-server 0.14.16 → 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 -89
- package/dist/storybook/index.js +6 -0
- package/dist/storybook-main/main.js +38 -18
- package/package.json +6 -6
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,41 +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
|
-
serverSideProps = serverSidePropsResponse == null ? void 0 : serverSidePropsResponse.serverSideProps;
|
|
1414
|
-
if (!!serverSideProps || serverSideProps.constructor !== {}.constructor) {
|
|
1415
|
-
throw new Error("getServerSideProps must return an object");
|
|
1416
|
-
}
|
|
1417
|
-
} catch (error) {
|
|
1418
|
-
const errorString = `Error resolving server side props ${requestedModulePath}`;
|
|
1419
|
-
console.log(errorString);
|
|
1420
|
-
console.error(error);
|
|
1421
|
-
messagesForBrowser.push(
|
|
1422
|
-
{
|
|
1423
|
-
level: "error",
|
|
1424
|
-
parameters: [errorString]
|
|
1425
|
-
},
|
|
1426
|
-
{
|
|
1427
|
-
level: "error",
|
|
1428
|
-
parameters: [error.message]
|
|
1429
|
-
}
|
|
1418
|
+
if (!getModuleDataDependecyTypeFrom || !filterToModuleDataDepsIncludedIn) {
|
|
1419
|
+
throw new Error(
|
|
1420
|
+
`Need to upgrade to @hubspot/cms-components 0.15.x or higher to use getServerSideProps`
|
|
1430
1421
|
);
|
|
1431
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
|
+
});
|
|
1432
1434
|
}
|
|
1433
1435
|
return renderComponentWithCSS_default(
|
|
1434
1436
|
viteServer,
|
|
1435
1437
|
foundPath,
|
|
1436
1438
|
Component,
|
|
1437
|
-
{
|
|
1439
|
+
{ props: namespacedModuleProps, extraDeps },
|
|
1438
1440
|
pageUrl,
|
|
1439
1441
|
basePath,
|
|
1440
1442
|
{ supplementalFieldValues, messagesForBrowser },
|
|
1441
1443
|
environmentConfig,
|
|
1442
|
-
renderOptions
|
|
1444
|
+
renderOptions,
|
|
1445
|
+
getServerSideProps,
|
|
1446
|
+
componentModule.unstable_modifyHtml
|
|
1443
1447
|
).then(applyFieldsValidationToRenderContext);
|
|
1444
1448
|
}
|
|
1445
1449
|
function getFieldValuesForModule(fieldsJSON, fieldOverrides = {}) {
|
|
@@ -1485,7 +1489,9 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
1485
1489
|
if (request2.query.fields) {
|
|
1486
1490
|
try {
|
|
1487
1491
|
if (typeof request2.query.fields === "string") {
|
|
1488
|
-
fieldOverrides = JSON.parse(
|
|
1492
|
+
fieldOverrides = JSON.parse(
|
|
1493
|
+
decodeURIComponent(request2.query.fields.replace(/\+/g, "%20"))
|
|
1494
|
+
);
|
|
1489
1495
|
}
|
|
1490
1496
|
} catch (e) {
|
|
1491
1497
|
console.error(
|
|
@@ -2335,7 +2341,7 @@ function proxyPageResourceRedirect(req, res, next) {
|
|
|
2335
2341
|
}
|
|
2336
2342
|
|
|
2337
2343
|
// src/routes/homeRouteHandler.tsx
|
|
2338
|
-
import { Fragment, jsx as
|
|
2344
|
+
import { Fragment, jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
2339
2345
|
var homeRouteHandler = async (request2, response, next) => {
|
|
2340
2346
|
const domainToProxy = getSubDomainFromValidLocalDomain(request2.hostname);
|
|
2341
2347
|
if (domainToProxy) {
|
|
@@ -2348,22 +2354,19 @@ var homeRouteHandler = async (request2, response, next) => {
|
|
|
2348
2354
|
const { moduleNames } = findAllModulesInRoot(webRoot2);
|
|
2349
2355
|
const { html: responseHtml } = await renderOnServer(
|
|
2350
2356
|
/* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
2351
|
-
storybookEnabled ? /* @__PURE__ */
|
|
2352
|
-
/* @__PURE__ */
|
|
2353
|
-
/* @__PURE__ */
|
|
2354
|
-
/* @__PURE__ */
|
|
2355
|
-
/* @__PURE__ */
|
|
2356
|
-
] })
|
|
2357
|
-
null,
|
|
2358
|
-
null,
|
|
2359
|
-
""
|
|
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
|
+
] })
|
|
2360
2363
|
);
|
|
2361
2364
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
2362
2365
|
};
|
|
2363
2366
|
var homeRouteHandler_default = homeRouteHandler;
|
|
2364
2367
|
|
|
2365
2368
|
// src/routes/proxyPathPageRouteHandler.tsx
|
|
2366
|
-
import { jsx as
|
|
2369
|
+
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2367
2370
|
async function proxyPathPageRouteHandler(request2, response, next) {
|
|
2368
2371
|
sendTrackingRequest("view-proxy-path-route");
|
|
2369
2372
|
const {
|
|
@@ -2379,10 +2382,10 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2379
2382
|
if (!request2.query.page) {
|
|
2380
2383
|
const { html: responseHtml } = await renderOnServer(
|
|
2381
2384
|
/* @__PURE__ */ jsxs4("div", { children: [
|
|
2382
|
-
/* @__PURE__ */
|
|
2385
|
+
/* @__PURE__ */ jsx7("h2", { children: "Local Proxy" }),
|
|
2383
2386
|
/* @__PURE__ */ jsxs4("form", { action: "/proxy", children: [
|
|
2384
|
-
/* @__PURE__ */
|
|
2385
|
-
/* @__PURE__ */
|
|
2387
|
+
/* @__PURE__ */ jsx7("label", { htmlFor: "page", style: { display: "block" }, children: "Page URL" }),
|
|
2388
|
+
/* @__PURE__ */ jsx7(
|
|
2386
2389
|
"input",
|
|
2387
2390
|
{
|
|
2388
2391
|
style: { width: "300px" },
|
|
@@ -2391,12 +2394,9 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2391
2394
|
placeholder: "https://somecmspage.com/path"
|
|
2392
2395
|
}
|
|
2393
2396
|
),
|
|
2394
|
-
/* @__PURE__ */
|
|
2397
|
+
/* @__PURE__ */ jsx7("button", { style: { display: "block" }, children: "Proxy" })
|
|
2395
2398
|
] })
|
|
2396
|
-
] })
|
|
2397
|
-
null,
|
|
2398
|
-
null,
|
|
2399
|
-
""
|
|
2399
|
+
] })
|
|
2400
2400
|
);
|
|
2401
2401
|
response.status(200).set({ "Content-Type": "text/html" }).end(responseHtml);
|
|
2402
2402
|
return;
|
|
@@ -2821,11 +2821,11 @@ function devSecretsPlugin(secretNames) {
|
|
|
2821
2821
|
configureServer: {
|
|
2822
2822
|
order: "post",
|
|
2823
2823
|
async handler(server) {
|
|
2824
|
-
const
|
|
2824
|
+
const cmsComponents3 = await server.ssrLoadModule(
|
|
2825
2825
|
"@hubspot/cms-components"
|
|
2826
2826
|
);
|
|
2827
|
-
if (
|
|
2828
|
-
|
|
2827
|
+
if (cmsComponents3.setSecretsFromEnv) {
|
|
2828
|
+
cmsComponents3.setSecretsFromEnv(secretNames);
|
|
2829
2829
|
} else if (secretNames.length > 0) {
|
|
2830
2830
|
console.warn(
|
|
2831
2831
|
"Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match."
|
|
@@ -3109,6 +3109,7 @@ async function validateHSPlatform(webroot, portalId) {
|
|
|
3109
3109
|
}
|
|
3110
3110
|
|
|
3111
3111
|
// src/createDevServer.ts
|
|
3112
|
+
import { get as hsGet6 } from "@hubspot/cli-lib/http.js";
|
|
3112
3113
|
var BASE_PATH = "/";
|
|
3113
3114
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
3114
3115
|
var SHADOW_PORT = 1442;
|
|
@@ -3211,7 +3212,15 @@ Local proxy functionality and module preview routes will not work without settin
|
|
|
3211
3212
|
}
|
|
3212
3213
|
}
|
|
3213
3214
|
}
|
|
3214
|
-
|
|
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
|
+
}
|
|
3215
3224
|
const absoluteWebRoot = normalizePath6(path8.resolve(process.cwd(), webRoot2));
|
|
3216
3225
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
3217
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
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@hubspot/cli-lib": "^3.0.12",
|
|
29
|
-
"@hubspot/cms-components": "^0.
|
|
29
|
+
"@hubspot/cms-components": "^0.15.0",
|
|
30
30
|
"@inquirer/select": "^2.0.0",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
32
32
|
"@storybook/addon-actions": "7.0.7",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@storybook/react": "7.0.7",
|
|
38
38
|
"@storybook/react-vite": "7.0.7",
|
|
39
39
|
"@storybook/testing-library": "^0.0.13",
|
|
40
|
-
"@vitejs/plugin-react": "^4.
|
|
40
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
41
41
|
"ansi-to-html": "0.7.x",
|
|
42
42
|
"babel-plugin-macros": "^3.1.0",
|
|
43
43
|
"babel-plugin-styled-components": "^2.1.4",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"request": "^2.88.2",
|
|
53
53
|
"styled-jsx": "5.1.2",
|
|
54
54
|
"typescript": "~4.7.0",
|
|
55
|
-
"vite": "4.5.
|
|
55
|
+
"vite": "4.5.3",
|
|
56
56
|
"vite-plugin-inspect": "^0.4.3",
|
|
57
57
|
"vite-plugin-mkcert": "1.16.0"
|
|
58
58
|
},
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"nodemon": "^2.0.15",
|
|
68
68
|
"publint": "^0.2.7",
|
|
69
69
|
"ts-node": "^10.7.0",
|
|
70
|
-
"vitest": "
|
|
70
|
+
"vitest": "1.4.0"
|
|
71
71
|
},
|
|
72
72
|
"main": "./dist/index.js",
|
|
73
73
|
"exports": {
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "8342e1dbecc81d9c0414d6592217e422acff9c3c"
|
|
112
112
|
}
|