@hubspot/cms-dev-server 0.14.12 → 0.14.14
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 +4 -2
- package/dist/island-runtime.js +9 -1
- package/dist/run.js +62 -33
- package/dist/storybook-main/main.js +4 -2
- package/package.json +3 -3
package/dist/internalSsr.js
CHANGED
|
@@ -668,10 +668,12 @@ async function renderComponentOnServer(Component, props, pageUrl, environmentCon
|
|
|
668
668
|
}
|
|
669
669
|
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
670
670
|
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
671
|
+
const messagesForBrowser = contextOptions ? contextOptions.messagesForBrowser : void 0;
|
|
671
672
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
672
673
|
environmentConfig,
|
|
673
674
|
entryPointBasePath,
|
|
674
|
-
supplementalFieldValues
|
|
675
|
+
supplementalFieldValues,
|
|
676
|
+
messagesForBrowser
|
|
675
677
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
676
678
|
let html = await renderStreamToPromise(
|
|
677
679
|
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
@@ -720,7 +722,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
720
722
|
})
|
|
721
723
|
`);
|
|
722
724
|
}
|
|
723
|
-
const nonceAttr = includeNonces && cmsComponents.
|
|
725
|
+
const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
|
|
724
726
|
return `
|
|
725
727
|
<script type="text/javascript"${nonceAttr}>
|
|
726
728
|
${globals.join("\n ")}
|
package/dist/island-runtime.js
CHANGED
|
@@ -133,7 +133,15 @@ function waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule, LoadableWrap
|
|
|
133
133
|
}
|
|
134
134
|
}
|
|
135
135
|
function getLoadableModuleFor(root) {
|
|
136
|
-
let url = root.url
|
|
136
|
+
let url = root.url;
|
|
137
|
+
if (root.url.startsWith("/") && !root.url.startsWith("//") && window.location.search.includes("hsDebugOverridePublicHost=")) {
|
|
138
|
+
const currentUrl = new URL(window.location.toString());
|
|
139
|
+
url = `${currentUrl.protocol}//${currentUrl.searchParams.get(
|
|
140
|
+
"hsDebugOverridePublicHost"
|
|
141
|
+
)}${root.url}`;
|
|
142
|
+
} else if (!root.url.startsWith("https://") && !root.url.startsWith("http://") && !root.url.startsWith("//")) {
|
|
143
|
+
url = `${window.location.origin}${root.url}`;
|
|
144
|
+
}
|
|
137
145
|
if (shouldForceSeparateJsForAllIslands) {
|
|
138
146
|
url = `${root.url}?cacheBust=${Date.now()}-${root.id}`;
|
|
139
147
|
}
|
package/dist/run.js
CHANGED
|
@@ -628,10 +628,12 @@ var renderStreamToPromise = async (reactElements, options) => {
|
|
|
628
628
|
};
|
|
629
629
|
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
630
630
|
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
631
|
+
const messagesForBrowser = contextOptions ? contextOptions.messagesForBrowser : void 0;
|
|
631
632
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
632
633
|
environmentConfig,
|
|
633
634
|
entryPointBasePath,
|
|
634
|
-
supplementalFieldValues
|
|
635
|
+
supplementalFieldValues,
|
|
636
|
+
messagesForBrowser
|
|
635
637
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
636
638
|
let html = await renderStreamToPromise(
|
|
637
639
|
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
@@ -680,7 +682,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
680
682
|
})
|
|
681
683
|
`);
|
|
682
684
|
}
|
|
683
|
-
const nonceAttr = includeNonces && cmsComponents.
|
|
685
|
+
const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
|
|
684
686
|
return `
|
|
685
687
|
<script type="text/javascript"${nonceAttr}>
|
|
686
688
|
${globals.join("\n ")}
|
|
@@ -1029,7 +1031,7 @@ function trackUsage(action) {
|
|
|
1029
1031
|
eventName: EVENT_NAME,
|
|
1030
1032
|
action,
|
|
1031
1033
|
nodeVersion: getNodeVersionData(),
|
|
1032
|
-
version: "0.14.
|
|
1034
|
+
version: "0.14.14",
|
|
1033
1035
|
os: getPlatform()
|
|
1034
1036
|
};
|
|
1035
1037
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1320,6 +1322,7 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1320
1322
|
environmentConfig.getGates(),
|
|
1321
1323
|
"CMS:JSRenderer:GetServerSideProps"
|
|
1322
1324
|
);
|
|
1325
|
+
const messagesForBrowser = [];
|
|
1323
1326
|
let serverSideProps;
|
|
1324
1327
|
let componentModule;
|
|
1325
1328
|
let dataQueryResult;
|
|
@@ -1369,16 +1372,27 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1369
1372
|
pageUrl
|
|
1370
1373
|
);
|
|
1371
1374
|
if (dataQueryResult.errors && dataQueryResult.errors.length) {
|
|
1375
|
+
const errorString = `GraphQL query for ${requestedModulePath} had errors.`;
|
|
1376
|
+
messagesForBrowser.push({
|
|
1377
|
+
level: "error",
|
|
1378
|
+
parameters: [errorString]
|
|
1379
|
+
});
|
|
1372
1380
|
dataQueryResult.errors.forEach((graphQLError) => {
|
|
1373
1381
|
console.error(graphQLError);
|
|
1382
|
+
messagesForBrowser.push({
|
|
1383
|
+
level: "error",
|
|
1384
|
+
parameters: [graphQLError.message, graphQLError]
|
|
1385
|
+
});
|
|
1374
1386
|
});
|
|
1375
|
-
console.error("Your GraphQL query resulted in the above errors");
|
|
1376
1387
|
}
|
|
1377
1388
|
} catch (error) {
|
|
1389
|
+
const errorString = `Failed to execute query for ${requestedModulePath}.`;
|
|
1390
|
+
console.error(errorString);
|
|
1378
1391
|
console.error(error.message);
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1392
|
+
messagesForBrowser.push({
|
|
1393
|
+
level: "error",
|
|
1394
|
+
parameters: [errorString, error.message]
|
|
1395
|
+
});
|
|
1382
1396
|
}
|
|
1383
1397
|
}
|
|
1384
1398
|
const namespacedModuleProps = namespaceModulePropsShape({
|
|
@@ -1399,9 +1413,20 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1399
1413
|
if (serverSideProps.constructor !== {}.constructor) {
|
|
1400
1414
|
throw new Error("getServerSideProps must return an object");
|
|
1401
1415
|
}
|
|
1402
|
-
} catch (
|
|
1403
|
-
|
|
1404
|
-
console.
|
|
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
|
+
}
|
|
1429
|
+
);
|
|
1405
1430
|
}
|
|
1406
1431
|
}
|
|
1407
1432
|
return renderComponentWithCSS_default(
|
|
@@ -1411,7 +1436,7 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1411
1436
|
{ ...namespacedModuleProps, serverSideProps },
|
|
1412
1437
|
pageUrl,
|
|
1413
1438
|
basePath,
|
|
1414
|
-
{ supplementalFieldValues },
|
|
1439
|
+
{ supplementalFieldValues, messagesForBrowser },
|
|
1415
1440
|
environmentConfig,
|
|
1416
1441
|
renderOptions
|
|
1417
1442
|
).then(applyFieldsValidationToRenderContext);
|
|
@@ -1866,7 +1891,7 @@ function resolvePlaceholderPath(placeholderPath, projectName, projectComponent)
|
|
|
1866
1891
|
}
|
|
1867
1892
|
return placeholderPath;
|
|
1868
1893
|
}
|
|
1869
|
-
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates) => {
|
|
1894
|
+
var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, projectName, environmentConfig, __jsRenderingGates, cookieHeader) => {
|
|
1870
1895
|
const url3 = new URL(urlToProxy);
|
|
1871
1896
|
const renderPreviewLocally = url3.searchParams.has("renderPreviewLocally");
|
|
1872
1897
|
let proxiedQueryParams = {};
|
|
@@ -1908,7 +1933,10 @@ var makeProxyPreviewRequest = (accountId, urlToProxy, previewKey, contentId, pro
|
|
|
1908
1933
|
uri: pathname,
|
|
1909
1934
|
query: proxiedQueryParams,
|
|
1910
1935
|
json: false,
|
|
1911
|
-
useQuerystring: true
|
|
1936
|
+
useQuerystring: true,
|
|
1937
|
+
headers: {
|
|
1938
|
+
COOKIE: cookieHeader
|
|
1939
|
+
}
|
|
1912
1940
|
});
|
|
1913
1941
|
return result.catch((error) => {
|
|
1914
1942
|
if (error.statusCode >= 400 && error.statusCode < 500 && !!error.response.body) {
|
|
@@ -2028,7 +2056,7 @@ function renderComponentForPlaceholderModule(viteServer, resolvedPath, localModu
|
|
|
2028
2056
|
}
|
|
2029
2057
|
);
|
|
2030
2058
|
}
|
|
2031
|
-
async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
|
|
2059
|
+
async function proxySpecificPage(request2, response, portalId, hublet, contentId, webRoot2, viteServer, projectName, projectComponentPath, jsRenderingGates, urlToProxy, fullOriginalUrl) {
|
|
2032
2060
|
let accountId;
|
|
2033
2061
|
let proxyEnv;
|
|
2034
2062
|
const prettyPrint = isDebugUrlString3(urlToProxy);
|
|
@@ -2067,7 +2095,8 @@ async function proxySpecificPage(response, portalId, hublet, contentId, webRoot2
|
|
|
2067
2095
|
contentId,
|
|
2068
2096
|
projectName,
|
|
2069
2097
|
environmentConfig,
|
|
2070
|
-
jsRenderingGates
|
|
2098
|
+
jsRenderingGates,
|
|
2099
|
+
request2.get("COOKIE")
|
|
2071
2100
|
);
|
|
2072
2101
|
const { sortIslandRootsByPriority } = await viteServer.ssrLoadModule(
|
|
2073
2102
|
"@hubspot/cms-components"
|
|
@@ -2232,6 +2261,7 @@ async function proxyPageRouteHandler(request2, response, next) {
|
|
|
2232
2261
|
request2.app.locals.authedPortalId
|
|
2233
2262
|
);
|
|
2234
2263
|
await proxySpecificPage(
|
|
2264
|
+
request2,
|
|
2235
2265
|
response,
|
|
2236
2266
|
portalId,
|
|
2237
2267
|
hublet,
|
|
@@ -2384,6 +2414,7 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2384
2414
|
request2.app.locals.authedPortalId
|
|
2385
2415
|
);
|
|
2386
2416
|
await proxySpecificPage(
|
|
2417
|
+
request2,
|
|
2387
2418
|
response,
|
|
2388
2419
|
portalId,
|
|
2389
2420
|
hublet,
|
|
@@ -2439,7 +2470,8 @@ function proxyPathPageResourceRedirect(req, res, next) {
|
|
|
2439
2470
|
import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
|
|
2440
2471
|
import path6 from "path";
|
|
2441
2472
|
import { normalizePath as normalizePath5 } from "vite";
|
|
2442
|
-
import
|
|
2473
|
+
import hsHttp from "@hubspot/cli-lib/http.js";
|
|
2474
|
+
var { post: hsPost } = hsHttp;
|
|
2443
2475
|
async function modulePreviewRouteHandler(request2, response) {
|
|
2444
2476
|
sendTrackingRequest("view-module-preview-route");
|
|
2445
2477
|
const {
|
|
@@ -2464,7 +2496,6 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2464
2496
|
false,
|
|
2465
2497
|
jsRenderingGates
|
|
2466
2498
|
);
|
|
2467
|
-
const baseUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}${authedHublet === "eu1" ? "-eu1" : ""}.com/api`;
|
|
2468
2499
|
let templatePreview;
|
|
2469
2500
|
try {
|
|
2470
2501
|
let componentModule;
|
|
@@ -2515,19 +2546,16 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2515
2546
|
hsLocalProxy: `${true}`,
|
|
2516
2547
|
localProxySchemaVersion: "1"
|
|
2517
2548
|
});
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
{
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
}
|
|
2529
|
-
);
|
|
2530
|
-
templatePreview = await templatePreviewResponse.text();
|
|
2549
|
+
templatePreview = await hsPost(authedPortalId, {
|
|
2550
|
+
uri: `/api/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
|
|
2551
|
+
headers: {
|
|
2552
|
+
["content-type"]: "application/x-www-form-urlencoded",
|
|
2553
|
+
["Accept"]: "text/html",
|
|
2554
|
+
referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`,
|
|
2555
|
+
cookie: request2.get("COOKIE")
|
|
2556
|
+
},
|
|
2557
|
+
body: `module=${encodeURIComponent(JSON.stringify(localModule))}`
|
|
2558
|
+
});
|
|
2531
2559
|
} catch (e) {
|
|
2532
2560
|
return response.status(500).end(`Error fetching module preview for (${moduleName}).
|
|
2533
2561
|
|
|
@@ -2574,9 +2602,10 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2574
2602
|
);
|
|
2575
2603
|
const html = htmlShell.replace(
|
|
2576
2604
|
"<!--headend-->",
|
|
2577
|
-
[
|
|
2578
|
-
|
|
2579
|
-
|
|
2605
|
+
[
|
|
2606
|
+
cssNeeded,
|
|
2607
|
+
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
2608
|
+
].join("\n")
|
|
2580
2609
|
).replace(`<!--ssr-outlet-->`, renderedHtml);
|
|
2581
2610
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
2582
2611
|
} catch (e) {
|
|
@@ -602,10 +602,12 @@ async function renderComponentOnServer(Component, props, pageUrl, environmentCon
|
|
|
602
602
|
}
|
|
603
603
|
async function renderOnServer(elements, pageUrl, environmentConfig, entryPointBasePath, contextOptions, debugName, renderOptions) {
|
|
604
604
|
const supplementalFieldValues = contextOptions ? contextOptions.supplementalFieldValues : void 0;
|
|
605
|
+
const messagesForBrowser = contextOptions ? contextOptions.messagesForBrowser : void 0;
|
|
605
606
|
const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {
|
|
606
607
|
environmentConfig,
|
|
607
608
|
entryPointBasePath,
|
|
608
|
-
supplementalFieldValues
|
|
609
|
+
supplementalFieldValues,
|
|
610
|
+
messagesForBrowser
|
|
609
611
|
}) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);
|
|
610
612
|
let html = await renderStreamToPromise(
|
|
611
613
|
/* @__PURE__ */ jsx2(ServerRenderContext.Provider, { value: renderContext, children: elements }),
|
|
@@ -654,7 +656,7 @@ function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath
|
|
|
654
656
|
})
|
|
655
657
|
`);
|
|
656
658
|
}
|
|
657
|
-
const nonceAttr = includeNonces && cmsComponents.
|
|
659
|
+
const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce="${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}"` : "";
|
|
658
660
|
return `
|
|
659
661
|
<script type="text/javascript"${nonceAttr}>
|
|
660
662
|
${globals.join("\n ")}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.14",
|
|
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.14.
|
|
29
|
+
"@hubspot/cms-components": "^0.14.14",
|
|
30
30
|
"@inquirer/select": "^2.0.0",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
32
32
|
"@storybook/addon-actions": "7.0.7",
|
|
@@ -107,5 +107,5 @@
|
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
|
109
109
|
},
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "3a5444685139558c99e7fdd8fe446ac035299d4b"
|
|
111
111
|
}
|