@hubspot/cms-dev-server 0.14.1 → 0.14.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 +4 -2
- package/dist/run.js +153 -27
- package/dist/storybook/index.js +4 -2
- package/dist/storybook-main/main.js +4 -2
- package/package.json +5 -4
- 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/internalSsr.js
CHANGED
|
@@ -596,7 +596,8 @@ function namespaceModulePropsShape(props) {
|
|
|
596
596
|
fieldValues: passedFieldValues,
|
|
597
597
|
hublData,
|
|
598
598
|
experimentalHublData,
|
|
599
|
-
moduleName
|
|
599
|
+
moduleName,
|
|
600
|
+
supplementalFieldValues
|
|
600
601
|
} = props;
|
|
601
602
|
const oldPropsShape = { ...props };
|
|
602
603
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -613,7 +614,8 @@ function namespaceModulePropsShape(props) {
|
|
|
613
614
|
hublParameters,
|
|
614
615
|
hublData,
|
|
615
616
|
experimentalHublData,
|
|
616
|
-
moduleName
|
|
617
|
+
moduleName,
|
|
618
|
+
supplementalFieldValues
|
|
617
619
|
};
|
|
618
620
|
}
|
|
619
621
|
function setIn(object, nestedKeysArray, value) {
|
package/dist/run.js
CHANGED
|
@@ -77,13 +77,13 @@ function getDevServerCommandLineOptions(argv) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// src/createDevServer.ts
|
|
80
|
-
import
|
|
80
|
+
import path8 from "path";
|
|
81
81
|
import url2 from "url";
|
|
82
82
|
import express2 from "express";
|
|
83
83
|
import http3 from "http";
|
|
84
84
|
import bodyParser from "body-parser";
|
|
85
85
|
import { spawn } from "child_process";
|
|
86
|
-
import { normalizePath as
|
|
86
|
+
import { normalizePath as normalizePath6 } from "vite";
|
|
87
87
|
import { Transform } from "stream";
|
|
88
88
|
|
|
89
89
|
// src/routes/createDevServerRoutes.ts
|
|
@@ -615,7 +615,8 @@ function namespaceModulePropsShape(props) {
|
|
|
615
615
|
fieldValues: passedFieldValues,
|
|
616
616
|
hublData,
|
|
617
617
|
experimentalHublData,
|
|
618
|
-
moduleName
|
|
618
|
+
moduleName,
|
|
619
|
+
supplementalFieldValues
|
|
619
620
|
} = props;
|
|
620
621
|
const oldPropsShape = { ...props };
|
|
621
622
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -632,7 +633,8 @@ function namespaceModulePropsShape(props) {
|
|
|
632
633
|
hublParameters,
|
|
633
634
|
hublData,
|
|
634
635
|
experimentalHublData,
|
|
635
|
-
moduleName
|
|
636
|
+
moduleName,
|
|
637
|
+
supplementalFieldValues
|
|
636
638
|
};
|
|
637
639
|
}
|
|
638
640
|
function setIn(object, nestedKeysArray, value) {
|
|
@@ -997,7 +999,7 @@ function trackUsage(action) {
|
|
|
997
999
|
eventName: EVENT_NAME,
|
|
998
1000
|
action,
|
|
999
1001
|
nodeVersion: getNodeVersionData(),
|
|
1000
|
-
version: "0.14.
|
|
1002
|
+
version: "0.14.2",
|
|
1001
1003
|
os: getPlatform()
|
|
1002
1004
|
};
|
|
1003
1005
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1621,12 +1623,12 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1621
1623
|
);
|
|
1622
1624
|
offsetSoFar = nearestNewlineOrQuoteAfterBlockOpen;
|
|
1623
1625
|
if (pathEndOffset >= 0 && pathEndOffset < nextNewlineOffset) {
|
|
1624
|
-
const
|
|
1626
|
+
const path9 = body.substring(
|
|
1625
1627
|
startOffset + localJsRenderStartString.length,
|
|
1626
1628
|
pathEndOffset
|
|
1627
1629
|
);
|
|
1628
1630
|
offsetSoFar = pathEndOffset + 1;
|
|
1629
|
-
if (startOffset >= 0 &&
|
|
1631
|
+
if (startOffset >= 0 && path9) {
|
|
1630
1632
|
const nextCommentEndOffset = body.indexOf("-->", pathEndOffset);
|
|
1631
1633
|
const endOffset = body.indexOf(localJsRenderEndString, pathEndOffset);
|
|
1632
1634
|
offsetSoFar = Math.min(nextCommentEndOffset, endOffset);
|
|
@@ -1646,7 +1648,7 @@ var findLocalRenderPlaceholders = (body) => {
|
|
|
1646
1648
|
result.push({
|
|
1647
1649
|
startOffset,
|
|
1648
1650
|
endOffset: endOffset + localJsRenderEndString.length,
|
|
1649
|
-
path:
|
|
1651
|
+
path: path9,
|
|
1650
1652
|
json
|
|
1651
1653
|
});
|
|
1652
1654
|
}
|
|
@@ -1755,9 +1757,9 @@ var customColors = [
|
|
|
1755
1757
|
];
|
|
1756
1758
|
var Converter = new AnsiToHtmlConverter({ colors: customColors });
|
|
1757
1759
|
var darkErrorStyles = `background-color: #222; color: #ccc; padding: 0.5em; font-family: ui-monospace, Menlo, Monaco, 'Cascadia Mono', 'Segoe UI Mono', 'Roboto Mono', 'Oxygen Mono', 'Ubuntu Monospace', 'Source Code Pro', 'Fira Mono', 'Droid Sans Mono', 'Courier New', monospace;`;
|
|
1758
|
-
var renderLocalError_default = (
|
|
1760
|
+
var renderLocalError_default = (path9, error) => {
|
|
1759
1761
|
const stackWithColorClasses = Converter.toHtml(error.stack);
|
|
1760
|
-
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${
|
|
1762
|
+
return `<div data-js-rendered="error" style="${darkErrorStyles}">Error rendering ${path9}<br/><br/><code><pre>${stackWithColorClasses}</pre></code></div>`;
|
|
1761
1763
|
};
|
|
1762
1764
|
|
|
1763
1765
|
// src/proxyPage/fetchPreviewInfo.ts
|
|
@@ -2365,7 +2367,7 @@ async function proxyPathPageRouteHandler(request2, response, next) {
|
|
|
2365
2367
|
}
|
|
2366
2368
|
|
|
2367
2369
|
// src/routes/proxyPathPageResourceRedirect.ts
|
|
2368
|
-
import
|
|
2370
|
+
import fetch2 from "node-fetch";
|
|
2369
2371
|
var HCMS_PATH2 = "/_hcms/";
|
|
2370
2372
|
var HS_FS_PATH2 = "/hs-fs/";
|
|
2371
2373
|
var HUB_FS_PATH2 = "/hubfs/";
|
|
@@ -2395,8 +2397,131 @@ function proxyPathPageResourceRedirect(req, res, next) {
|
|
|
2395
2397
|
return;
|
|
2396
2398
|
}
|
|
2397
2399
|
const urlToProxy = `https://${proxyPageUrl.host}${req.url}`;
|
|
2398
|
-
|
|
2400
|
+
fetch2(urlToProxy).then((response) => response.body.pipe(res)).catch((err) => console.log(err));
|
|
2401
|
+
}
|
|
2402
|
+
|
|
2403
|
+
// src/routes/modulePreviewRouteHandler.ts
|
|
2404
|
+
import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
|
|
2405
|
+
import path6 from "path";
|
|
2406
|
+
import { normalizePath as normalizePath5 } from "vite";
|
|
2407
|
+
import { getAccountId as getAccountId3 } from "@hubspot/cli-lib/lib/config.js";
|
|
2408
|
+
import { get as hsGet4 } from "@hubspot/cli-lib/http.js";
|
|
2409
|
+
async function modulePreviewRouteHandler(request2, response) {
|
|
2410
|
+
sendTrackingRequest("view-module-preview-route");
|
|
2411
|
+
const {
|
|
2412
|
+
authedPortalId,
|
|
2413
|
+
authedEnv,
|
|
2414
|
+
authedHublet,
|
|
2415
|
+
webRoot: webRoot2,
|
|
2416
|
+
viteServer,
|
|
2417
|
+
jsRenderingGates,
|
|
2418
|
+
projectName,
|
|
2419
|
+
projectComponentPath
|
|
2420
|
+
} = request2.app.locals;
|
|
2421
|
+
const moduleName = request2.params.moduleName;
|
|
2422
|
+
const modulePath = normalizePath5(
|
|
2423
|
+
path6.resolve(webRoot2, "components/modules/", moduleName)
|
|
2424
|
+
);
|
|
2425
|
+
const basePath = getEntryPointBasePath(modulePath);
|
|
2426
|
+
const environmentConfig = buildStaticEnvConfig4(
|
|
2427
|
+
authedPortalId,
|
|
2428
|
+
authedHublet,
|
|
2429
|
+
authedEnv,
|
|
2430
|
+
false,
|
|
2431
|
+
jsRenderingGates
|
|
2432
|
+
);
|
|
2433
|
+
const baseUrl = `https://api.hubspot${authedEnv === "qa" ? "qa" : ""}${authedHublet === "eu1" ? "-eu1" : ""}.com/api`;
|
|
2434
|
+
const accountId = await getAccountId3(authedPortalId);
|
|
2435
|
+
let templatePreview;
|
|
2436
|
+
try {
|
|
2437
|
+
const moduleFetchResult = await hsGet4(accountId, {
|
|
2438
|
+
baseUrl,
|
|
2439
|
+
uri: `/designmanager/v1/modules/by-path/@projects/${projectName}/${projectComponentPath}/components/modules/${moduleName}`,
|
|
2440
|
+
query: {
|
|
2441
|
+
portalId: authedPortalId
|
|
2442
|
+
},
|
|
2443
|
+
json: true,
|
|
2444
|
+
useQuerystring: true
|
|
2445
|
+
});
|
|
2446
|
+
const queryParams = new URLSearchParams({
|
|
2447
|
+
portalId: `${authedPortalId}`,
|
|
2448
|
+
module_id: `${moduleFetchResult.moduleId}`,
|
|
2449
|
+
hsLocalProxy: `${true}`,
|
|
2450
|
+
hs_preview_key: `${moduleFetchResult.previewKey}`,
|
|
2451
|
+
localProxySchemaVersion: "1"
|
|
2452
|
+
});
|
|
2453
|
+
const templatePreviewResponse = await fetch(
|
|
2454
|
+
`${baseUrl}/cos-rendering/v1/public/_hcms/preview/template/multiform?${queryParams}`,
|
|
2455
|
+
{
|
|
2456
|
+
method: "POST",
|
|
2457
|
+
headers: {
|
|
2458
|
+
["content-type"]: "application/x-www-form-urlencoded",
|
|
2459
|
+
["Accept"]: "text/html",
|
|
2460
|
+
referer: `https://app.hubspot${authedEnv === "qa" ? "qa" : ""}.com`
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
);
|
|
2464
|
+
templatePreview = await templatePreviewResponse.text();
|
|
2465
|
+
} catch (e) {
|
|
2466
|
+
return response.status(500).end(
|
|
2467
|
+
`Error previewing module (${moduleName}). Ensure this module has been included in a successful project build.
|
|
2468
|
+
|
|
2469
|
+
`
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
try {
|
|
2473
|
+
const localRenderPlaceholders = findLocalRenderPlaceholders(templatePreview);
|
|
2474
|
+
if (localRenderPlaceholders.length !== 1) {
|
|
2475
|
+
return response.status(500).end(
|
|
2476
|
+
`Error previewing module (${moduleName}), exception in module preview HTML
|
|
2477
|
+
|
|
2478
|
+
`
|
|
2479
|
+
);
|
|
2480
|
+
}
|
|
2481
|
+
const {
|
|
2482
|
+
html: renderedHtml,
|
|
2483
|
+
cssNeeded,
|
|
2484
|
+
renderContext,
|
|
2485
|
+
inlineAssets
|
|
2486
|
+
} = await renderComponentForPlaceholder(
|
|
2487
|
+
0,
|
|
2488
|
+
localRenderPlaceholders[0],
|
|
2489
|
+
webRoot2,
|
|
2490
|
+
viteServer,
|
|
2491
|
+
fullOriginalUrlFromRequest(request2),
|
|
2492
|
+
basePath,
|
|
2493
|
+
environmentConfig,
|
|
2494
|
+
projectName,
|
|
2495
|
+
projectComponentPath
|
|
2496
|
+
);
|
|
2497
|
+
const baseTemplatePath = packagePath(
|
|
2498
|
+
import.meta.url,
|
|
2499
|
+
"html/baseTemplate.html"
|
|
2500
|
+
);
|
|
2501
|
+
const htmlShell = await createHtmlShellDependingOnRenderContext(
|
|
2502
|
+
baseTemplatePath,
|
|
2503
|
+
request2.originalUrl,
|
|
2504
|
+
`Module: ${modulePath}`,
|
|
2505
|
+
renderContext,
|
|
2506
|
+
viteServer,
|
|
2507
|
+
jsRenderingGates
|
|
2508
|
+
);
|
|
2509
|
+
const html = htmlShell.replace(
|
|
2510
|
+
"<!--headend-->",
|
|
2511
|
+
[cssNeeded, ...inlineAssets.map((inlineAsset) => inlineAsset.html)].join(
|
|
2512
|
+
"\n"
|
|
2513
|
+
)
|
|
2514
|
+
).replace(`<!--ssr-outlet-->`, renderedHtml);
|
|
2515
|
+
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
2516
|
+
} catch (e) {
|
|
2517
|
+
console.error(e);
|
|
2518
|
+
viteServer.ssrFixStacktrace(e);
|
|
2519
|
+
return response.status(500).end(`Error rendering module (${moduleName})
|
|
2520
|
+
|
|
2521
|
+
${e.stack}`);
|
|
2522
|
+
}
|
|
2399
2523
|
}
|
|
2524
|
+
var modulePreviewRouteHandler_default = modulePreviewRouteHandler;
|
|
2400
2525
|
|
|
2401
2526
|
// src/routes/createDevServerRoutes.ts
|
|
2402
2527
|
var STORYBOOK_DOMAINS = VALID_PROXY_DOMAIN_SUFFIXES.map(
|
|
@@ -2425,6 +2550,7 @@ var createDevServerRoutes = async (viteServer, storybookPort) => {
|
|
|
2425
2550
|
devServerApp.get("/partials/", linksToAllPartialsRouteHandler_default);
|
|
2426
2551
|
devServerApp.get("/partial/:partial", partial_default);
|
|
2427
2552
|
devServerApp.get("/partial/:partial/*", partial_default);
|
|
2553
|
+
devServerApp.get("/preview/module/:moduleName", modulePreviewRouteHandler_default);
|
|
2428
2554
|
devServerApp.get("/modules/", linksToAllModulesRouteHandler_default);
|
|
2429
2555
|
devServerApp.get("/module/:moduleName", module_default);
|
|
2430
2556
|
devServerApp.get("/module/:moduleName/*", module_default);
|
|
@@ -2447,9 +2573,9 @@ import express from "express";
|
|
|
2447
2573
|
|
|
2448
2574
|
// src/shadowDevServer/createShadowDevServerRoutes.ts
|
|
2449
2575
|
import { Router as Router2 } from "express";
|
|
2450
|
-
import { getAccountId as
|
|
2576
|
+
import { getAccountId as getAccountId4, getEnv as getEnv2 } from "@hubspot/cli-lib/lib/config.js";
|
|
2451
2577
|
import cors from "cors";
|
|
2452
|
-
import { buildStaticEnvConfig as
|
|
2578
|
+
import { buildStaticEnvConfig as buildStaticEnvConfig5 } from "@hubspot/cms-components";
|
|
2453
2579
|
function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
2454
2580
|
return async function shadowDevServerCheckHandler(request2, response) {
|
|
2455
2581
|
const { query } = request2;
|
|
@@ -2468,7 +2594,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
2468
2594
|
let hasJSBuildingBlocks = false;
|
|
2469
2595
|
let localProxyUrl;
|
|
2470
2596
|
try {
|
|
2471
|
-
accountId =
|
|
2597
|
+
accountId = getAccountId4(portalId);
|
|
2472
2598
|
if (accountId === null) {
|
|
2473
2599
|
throw new Error();
|
|
2474
2600
|
}
|
|
@@ -2486,7 +2612,7 @@ function getShadowDevServerCheckHandler(devServerPort, projectName, gates) {
|
|
|
2486
2612
|
contentId
|
|
2487
2613
|
);
|
|
2488
2614
|
const { previewKey } = previewInfo;
|
|
2489
|
-
const environmentConfig =
|
|
2615
|
+
const environmentConfig = buildStaticEnvConfig5(
|
|
2490
2616
|
portalId,
|
|
2491
2617
|
"na1",
|
|
2492
2618
|
// bad lazy TF (but does it really matter for this check)
|
|
@@ -2734,7 +2860,7 @@ async function getJsRenderingGates(portalId, env, personalAccessKey) {
|
|
|
2734
2860
|
// src/createDevServer.ts
|
|
2735
2861
|
import {
|
|
2736
2862
|
getEnv as getEnv3,
|
|
2737
|
-
getAccountId as
|
|
2863
|
+
getAccountId as getAccountId5,
|
|
2738
2864
|
getAccountConfig as getAccountConfig2,
|
|
2739
2865
|
loadConfig,
|
|
2740
2866
|
validateConfig
|
|
@@ -2742,7 +2868,7 @@ import {
|
|
|
2742
2868
|
import { fetchSecrets } from "@hubspot/cli-lib/api/secrets.js";
|
|
2743
2869
|
|
|
2744
2870
|
// src/proxyPage/fetchDomains.ts
|
|
2745
|
-
import { get as
|
|
2871
|
+
import { get as hsGet5 } from "@hubspot/cli-lib/http.js";
|
|
2746
2872
|
|
|
2747
2873
|
// src/lib/errors.ts
|
|
2748
2874
|
var MISSING_SCOPE_ERROR_PREFIX = `Your personal access key is missing required scopes fetch domains.
|
|
@@ -2771,7 +2897,7 @@ function isMissingScopeError(error) {
|
|
|
2771
2897
|
// src/proxyPage/fetchDomains.ts
|
|
2772
2898
|
async function fetchDomains(portalId) {
|
|
2773
2899
|
try {
|
|
2774
|
-
const result = await
|
|
2900
|
+
const result = await hsGet5(portalId, {
|
|
2775
2901
|
uri: `/cms/v3/domains`,
|
|
2776
2902
|
query: { portalId },
|
|
2777
2903
|
json: true
|
|
@@ -2795,9 +2921,9 @@ async function fetchWebsiteDomainNames(portalId) {
|
|
|
2795
2921
|
|
|
2796
2922
|
// src/lib/getCMSAssetConfig.ts
|
|
2797
2923
|
import fs2 from "fs";
|
|
2798
|
-
import
|
|
2924
|
+
import path7 from "path";
|
|
2799
2925
|
function getCMSAssetConfig(webRoot2) {
|
|
2800
|
-
const cmsAssetsPath =
|
|
2926
|
+
const cmsAssetsPath = path7.join(webRoot2, "cms-assets.json");
|
|
2801
2927
|
return JSON.parse(fs2.readFileSync(cmsAssetsPath).toString());
|
|
2802
2928
|
}
|
|
2803
2929
|
|
|
@@ -2836,7 +2962,7 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
2836
2962
|
process.exit(1);
|
|
2837
2963
|
}
|
|
2838
2964
|
if (validateConfig()) {
|
|
2839
|
-
authedPortalId =
|
|
2965
|
+
authedPortalId = getAccountId5(hubspotCliAccountNameOption2);
|
|
2840
2966
|
authedEnv = getEnv3(hubspotCliAccountNameOption2);
|
|
2841
2967
|
personalAccessKey = getAccountConfig2(authedPortalId) && getAccountConfig2(authedPortalId).personalAccessKey;
|
|
2842
2968
|
if (!authedPortalId && hubspotCliAccountNameOption2) {
|
|
@@ -2905,7 +3031,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2905
3031
|
}
|
|
2906
3032
|
}
|
|
2907
3033
|
const authedHublet = "na1";
|
|
2908
|
-
const absoluteWebRoot =
|
|
3034
|
+
const absoluteWebRoot = normalizePath6(path8.resolve(process.cwd(), webRoot2));
|
|
2909
3035
|
const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
|
|
2910
3036
|
const viteServer = await createViteDevServer_default(
|
|
2911
3037
|
absoluteWebRoot,
|
|
@@ -2919,7 +3045,7 @@ Local proxy functionality will not work without setting up authentication.`
|
|
|
2919
3045
|
const httpsKey = viteHTTPSConfig ? viteHTTPSConfig.key : null;
|
|
2920
3046
|
const httpsCert = viteHTTPSConfig ? viteHTTPSConfig.cert : null;
|
|
2921
3047
|
const projectName = getProjectNameFromHSConfig(
|
|
2922
|
-
|
|
3048
|
+
path8.join(webRoot2, "../hsproject.json")
|
|
2923
3049
|
);
|
|
2924
3050
|
const httpServers = [];
|
|
2925
3051
|
const expressServer = express2();
|
|
@@ -2976,8 +3102,8 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2976
3102
|
`
|
|
2977
3103
|
);
|
|
2978
3104
|
if (storybook2) {
|
|
2979
|
-
const packageRoot =
|
|
2980
|
-
const configPath =
|
|
3105
|
+
const packageRoot = path8.dirname(url2.fileURLToPath(import.meta.url));
|
|
3106
|
+
const configPath = path8.resolve(packageRoot, "./storybook-main");
|
|
2981
3107
|
sendTrackingRequest("start-storybook");
|
|
2982
3108
|
const storybookProcess = spawn(
|
|
2983
3109
|
"sb",
|
|
@@ -2997,7 +3123,7 @@ HubSpot CMS dev server hosting: ${projectName}/${expressServer.locals.projectCom
|
|
|
2997
3123
|
portalId: authedPortalId.toString(),
|
|
2998
3124
|
hsEnv: authedEnv,
|
|
2999
3125
|
hublet: authedHublet,
|
|
3000
|
-
WEB_ROOT:
|
|
3126
|
+
WEB_ROOT: path8.join(webRoot2, "components")
|
|
3001
3127
|
}
|
|
3002
3128
|
}
|
|
3003
3129
|
);
|
package/dist/storybook/index.js
CHANGED
|
@@ -11,7 +11,8 @@ function namespaceModulePropsShape(props) {
|
|
|
11
11
|
fieldValues: passedFieldValues,
|
|
12
12
|
hublData,
|
|
13
13
|
experimentalHublData,
|
|
14
|
-
moduleName
|
|
14
|
+
moduleName,
|
|
15
|
+
supplementalFieldValues
|
|
15
16
|
} = props;
|
|
16
17
|
const oldPropsShape = { ...props };
|
|
17
18
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -28,7 +29,8 @@ function namespaceModulePropsShape(props) {
|
|
|
28
29
|
hublParameters,
|
|
29
30
|
hublData,
|
|
30
31
|
experimentalHublData,
|
|
31
|
-
moduleName
|
|
32
|
+
moduleName,
|
|
33
|
+
supplementalFieldValues
|
|
32
34
|
};
|
|
33
35
|
}
|
|
34
36
|
function renderFieldsJSX(fieldsJSX) {
|
|
@@ -367,7 +367,8 @@ function namespaceModulePropsShape(props) {
|
|
|
367
367
|
fieldValues: passedFieldValues,
|
|
368
368
|
hublData,
|
|
369
369
|
experimentalHublData,
|
|
370
|
-
moduleName
|
|
370
|
+
moduleName,
|
|
371
|
+
supplementalFieldValues
|
|
371
372
|
} = props;
|
|
372
373
|
const oldPropsShape = { ...props };
|
|
373
374
|
if (oldPropsShape.dataQueryResult) {
|
|
@@ -384,7 +385,8 @@ function namespaceModulePropsShape(props) {
|
|
|
384
385
|
hublParameters,
|
|
385
386
|
hublData,
|
|
386
387
|
experimentalHublData,
|
|
387
|
-
moduleName
|
|
388
|
+
moduleName,
|
|
389
|
+
supplementalFieldValues
|
|
388
390
|
};
|
|
389
391
|
}
|
|
390
392
|
function setIn(object, nestedKeysArray, value) {
|
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.3",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"copy-html": "copyfiles -u 1 'src/html/**' 'dist'",
|
|
13
13
|
"build-types": "tsc --project tsconfig.types.json",
|
|
14
14
|
"clean": "tsc --build --clean",
|
|
15
|
-
"dev": "nodemon --exec 'yarn start'",
|
|
15
|
+
"dev": "nodemon --no-stdin --exec 'yarn start'",
|
|
16
16
|
"dev-inspect": "nodemon --exec 'yarn start-inspect'",
|
|
17
17
|
"es-watch": "esbuild --outfile=dist-esbuild/runWhenDeveloping.cjs --bundle --watch --platform=node --external:fsevents --external:vite --external:react-refresh runWhenDeveloping.ts",
|
|
18
18
|
"package": "npm run build && npm pack",
|
|
@@ -26,7 +26,8 @@
|
|
|
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.3",
|
|
30
|
+
"@inquirer/select": "^2.0.0",
|
|
30
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
31
32
|
"@storybook/addon-actions": "7.0.7",
|
|
32
33
|
"@storybook/addon-essentials": "7.0.7",
|
|
@@ -106,5 +107,5 @@
|
|
|
106
107
|
"publishConfig": {
|
|
107
108
|
"access": "public"
|
|
108
109
|
},
|
|
109
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "0c0426830420f96794f6b5899b645d901fa6bdd4"
|
|
110
111
|
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { createServer } from "vite";
|
|
2
|
-
import react from "@vitejs/plugin-react";
|
|
3
|
-
import { isUngatedFor, clientIslandEntryPlugin, resolveIslandPlugin } from "./index-de34229d.js";
|
|
4
|
-
import mkcert from "vite-plugin-mkcert";
|
|
5
|
-
const islandRuntime = 'const HYDRATION_WAITING = "HYDRATION_WAITING";\nconst HYDRATION_PREPARING = "HYDRATION_PREPARING";\nconst HYDRATION_QUEUED = "HYDRATION_QUEUED";\nconst HYDRATED = "HYDRATED";\nlet rootsToProcess;\nlet hydrationQueue = [];\nconst hydrationTypesToAccept = /* @__PURE__ */ new Set(["load", "visible"]);\nlet startHydratingIdleRootsTimeout;\nconst shouldForceSeparateJsForAllIslands = /(&|\\?)forceSeparateIslandJs=true/.test(window.location.search);\nlet scheduledHydrationIndexCtr = 1;\nconst rootsById = /* @__PURE__ */ new Map();\nconst typedWindow = window;\nconst startHydratingIdleRoots = () => {\n hydrationTypesToAccept.add("idle");\n for (const root of rootsToProcess) {\n if (root.hydrationStatus === HYDRATION_WAITING && hydrationTypesToAccept.has(root.hydrateOn)) {\n root.hydrationStatus = HYDRATION_PREPARING;\n waitThenLoadAndHydrateIfNeeded(root, getLoadableModuleFor(root));\n }\n }\n};\nfunction setupIdleCallbackIfNeeded() {\n if (!startHydratingIdleRootsTimeout) {\n if (!window.requestIdleCallback) {\n setTimeout(() => {\n startHydratingIdleRoots();\n }, 1);\n return;\n }\n startHydratingIdleRootsTimeout = requestIdleCallback(\n startHydratingIdleRoots,\n { timeout: 5e3 }\n );\n }\n}\nfunction finishHydratingRootAndScheduleNext(rootAndExtraInfo) {\n rootAndExtraInfo.root.hydrationStatus = HYDRATED;\n hydrationQueue = hydrationQueue.filter(\n (x) => x.root.id !== rootAndExtraInfo.root.id\n );\n const hasOtherRootsToHydrate = hydrationQueue.length > 0;\n if (hasOtherRootsToHydrate) {\n setTimeout(() => hydrateRoot(hydrationQueue[0]), 0);\n } else if (!hasOtherRootsToHydrate && !hydrationTypesToAccept.has("idle")) {\n setupIdleCallbackIfNeeded();\n }\n}\nfunction hydrateRoot(rootAndExtraInfo) {\n const { rootEl, root, IslandModule } = rootAndExtraInfo;\n console.log("Hydrating root", root.id, root.hydrateOn);\n const postHydration = () => {\n finishHydratingRootAndScheduleNext(rootAndExtraInfo);\n };\n const renderableIsland = {\n rootElement: rootEl,\n pageUrl: typedWindow.__hsServerPageUrl,\n basePath: typedWindow.__hsBasePath,\n islands: typedWindow.__islands,\n postHydration,\n island: root,\n index: rootAndExtraInfo.islandScheduledIndex\n };\n const reactRoot = IslandModule.render(renderableIsland);\n rootsById[root.id] = reactRoot;\n}\nfunction pushToHydrationQueue(rootAndExtraInfo) {\n rootAndExtraInfo.root.hydrationStatus = HYDRATION_QUEUED;\n hydrationQueue.push(rootAndExtraInfo);\n if (hydrationQueue.length === 1) {\n hydrateRoot(rootAndExtraInfo);\n }\n}\nfunction loadThenHydrate(root, LoadableIslandModule, rootEl, islandScheduledIndex) {\n LoadableIslandModule().then((IslandModule) => {\n pushToHydrationQueue({\n rootEl,\n root,\n IslandModule,\n islandScheduledIndex\n });\n }).catch((error) => {\n console.error(`Failed to load module for island: ${root.id}`);\n console.error(error);\n });\n}\nfunction waitThenLoadAndHydrateIfNeeded(root, LoadableIslandModule) {\n const rootEl = document.getElementById(root.id);\n const islandScheduledIndex = scheduledHydrationIndexCtr;\n scheduledHydrationIndexCtr += 1;\n if (root.hydrateOn === "visible") {\n onVisible(rootEl, () => {\n loadThenHydrate(root, LoadableIslandModule, rootEl, islandScheduledIndex);\n });\n } else {\n loadThenHydrate(root, LoadableIslandModule, rootEl, islandScheduledIndex);\n }\n}\nfunction getLoadableModuleFor(root) {\n let url = `${window.location.origin}${root.url}`;\n if (shouldForceSeparateJsForAllIslands) {\n url = `${root.url}?cacheBust=${Date.now()}-${root.id}`;\n }\n const LoadableIslandModule = () => import(\n /* @vite-ignore */\n url\n );\n if (!LoadableIslandModule) {\n throw new Error(`Missing island component for ${root.moduleName}`);\n }\n return LoadableIslandModule;\n}\nfunction hydrateIslandRoots() {\n if (rootsToProcess === void 0) {\n rootsToProcess = typedWindow.__islands;\n console.log("Starting to hydrate", rootsToProcess);\n if (shouldForceSeparateJsForAllIslands) {\n console.log(" ... forcibly making every island refetch JS");\n }\n }\n let encounteredAnyNonIdleIslands = false;\n for (const root of rootsToProcess) {\n if (!root.hydrationStatus) {\n root.hydrationStatus = root.hydrationStatus || HYDRATION_WAITING;\n if (hydrationTypesToAccept.has(root.hydrateOn)) {\n encounteredAnyNonIdleIslands = true;\n root.hydrationStatus = HYDRATION_PREPARING;\n waitThenLoadAndHydrateIfNeeded(root, getLoadableModuleFor(root));\n }\n }\n }\n if (rootsToProcess.length > 0 && !encounteredAnyNonIdleIslands) {\n setupIdleCallbackIfNeeded();\n }\n}\nfunction setupIslandHydration() {\n if (document.readyState === "interactive" || document.readyState === "complete") {\n hydrateIslandRoots();\n } else {\n window.addEventListener("DOMContentLoaded", hydrateIslandRoots);\n }\n}\nfunction unmountIsland(islandId) {\n const islandToUnmount = rootsToProcess.find((island) => island.id === islandId);\n if (!islandToUnmount || !rootsById[islandId]) {\n throw new Error(`No known island: ${islandId}`);\n }\n const islandIndex = rootsToProcess.indexOf(islandToUnmount);\n const reactRoot = rootsById[islandId];\n rootsToProcess.splice(islandIndex, 1);\n delete rootsById[islandId];\n console.log("Unmounting island:", islandId);\n reactRoot.unmount();\n}\nconst onVisible = (islandEl, callback) => {\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n observer.disconnect();\n callback();\n }\n return;\n });\n for (let i = 0; i < islandEl.children.length; i++) {\n const child = islandEl.children[i];\n observer.observe(child);\n }\n};\nexport {\n setupIslandHydration,\n unmountIsland\n};\n';
|
|
6
|
-
async function createViteDevServer(webRoot, port, sslEnabled, domainsToProxy = [], jsRenderingGates) {
|
|
7
|
-
const sharedDepsEnabled = isUngatedFor(
|
|
8
|
-
jsRenderingGates,
|
|
9
|
-
"CMS:JSRenderer:SharedDeps"
|
|
10
|
-
);
|
|
11
|
-
const additionalMkcertHosts = domainsToProxy.map((proxyDomain) => [
|
|
12
|
-
`${proxyDomain}.localhost`,
|
|
13
|
-
`${proxyDomain}.hslocal.net`
|
|
14
|
-
]).flat();
|
|
15
|
-
additionalMkcertHosts.push("*.hslocal.net", "hslocal.net");
|
|
16
|
-
const origin = sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`;
|
|
17
|
-
const viteConfig = {
|
|
18
|
-
appType: "custom",
|
|
19
|
-
server: {
|
|
20
|
-
middlewareMode: true,
|
|
21
|
-
host: "hslocal.net",
|
|
22
|
-
origin,
|
|
23
|
-
https: sslEnabled,
|
|
24
|
-
hmr: {
|
|
25
|
-
protocol: sslEnabled ? "wss" : void 0
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
ssr: {
|
|
29
|
-
// TODO: might need more entries here to get things to resolve through
|
|
30
|
-
// resolveWebRootDepsPlugin
|
|
31
|
-
noExternal: "@hubspot/cms-components"
|
|
32
|
-
},
|
|
33
|
-
resolve: {
|
|
34
|
-
conditions: ["server"],
|
|
35
|
-
dedupe: ["react", "react-dom", "@hubspot/cms-components"]
|
|
36
|
-
},
|
|
37
|
-
optimizeDeps: {
|
|
38
|
-
include: ["react", "react-dom", "react-dom/client"]
|
|
39
|
-
},
|
|
40
|
-
plugins: [
|
|
41
|
-
{
|
|
42
|
-
name: "island-runtime",
|
|
43
|
-
resolveId(id) {
|
|
44
|
-
if (id === "island-runtime") {
|
|
45
|
-
return id;
|
|
46
|
-
}
|
|
47
|
-
return null;
|
|
48
|
-
},
|
|
49
|
-
load(id) {
|
|
50
|
-
if (id === "island-runtime") {
|
|
51
|
-
return islandRuntime;
|
|
52
|
-
}
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,
|
|
57
|
-
react(),
|
|
58
|
-
sharedDepsEnabled && clientIslandEntryPlugin(),
|
|
59
|
-
resolveIslandPlugin(jsRenderingGates)
|
|
60
|
-
],
|
|
61
|
-
css: {
|
|
62
|
-
postcss: webRoot
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
return createServer(viteConfig);
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
createViteDevServer as c
|
|
69
|
-
};
|