@hubspot/cms-dev-server 0.15.11 → 0.15.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/index.js +1 -1
- package/dist/internalSsr.js +3 -3
- package/dist/island-runtime.js +9 -3
- package/dist/run.js +97 -55
- package/dist/storybook-main/main.js +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -42,7 +42,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
45
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || ((id) => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
46
46
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
47
47
|
function clientIslandEntryPlugin() {
|
|
48
48
|
return {
|
package/dist/internalSsr.js
CHANGED
|
@@ -154,7 +154,7 @@ function resolveIslandToPlainModulePlugin(enabled = true) {
|
|
|
154
154
|
function resolveIslandToPlainModuleNoopPlugin() {
|
|
155
155
|
return resolveIslandToPlainModulePlugin(false);
|
|
156
156
|
}
|
|
157
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
157
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || ((id) => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
158
158
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
159
159
|
function clientIslandEntryPlugin() {
|
|
160
160
|
return {
|
|
@@ -187,7 +187,7 @@ function clientIslandEntryPlugin() {
|
|
|
187
187
|
}
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
|
-
var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
190
|
+
var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel, nonceAttribute) => {
|
|
191
191
|
if (!messagesForBrowser) {
|
|
192
192
|
return "";
|
|
193
193
|
}
|
|
@@ -211,7 +211,7 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
|
211
211
|
groupEnd = ` console.groupEnd()
|
|
212
212
|
`;
|
|
213
213
|
}
|
|
214
|
-
return `<script>${groupStart}
|
|
214
|
+
return `<script ${nonceAttribute}>${groupStart}
|
|
215
215
|
${consoleLines.join("\n")}
|
|
216
216
|
${groupEnd}</script>
|
|
217
217
|
`;
|
package/dist/island-runtime.js
CHANGED
|
@@ -65,7 +65,9 @@ function finishHydratingRootAndScheduleNext(rootAndExtraInfo) {
|
|
|
65
65
|
}
|
|
66
66
|
function hydrateRoot(rootAndExtraInfo) {
|
|
67
67
|
const { rootEl, root, IslandModule, WrapperModule } = rootAndExtraInfo;
|
|
68
|
-
|
|
68
|
+
if (window.location.search.includes("hsDebug=")) {
|
|
69
|
+
console.log("Hydrating root", root.id, root.hydrateOn);
|
|
70
|
+
}
|
|
69
71
|
const postHydration = () => {
|
|
70
72
|
finishHydratingRootAndScheduleNext(rootAndExtraInfo);
|
|
71
73
|
};
|
|
@@ -157,7 +159,9 @@ function getLoadableModuleFor(root) {
|
|
|
157
159
|
function hydrateIslandRoots() {
|
|
158
160
|
if (rootsToProcess === void 0) {
|
|
159
161
|
rootsToProcess = typedWindow.__islands;
|
|
160
|
-
|
|
162
|
+
if (window.location.search.includes("hsDebug=")) {
|
|
163
|
+
console.log("Starting to hydrate", rootsToProcess);
|
|
164
|
+
}
|
|
161
165
|
if (shouldForceSeparateJsForAllIslands) {
|
|
162
166
|
console.log(" ... forcibly making every island refetch JS");
|
|
163
167
|
}
|
|
@@ -193,7 +197,9 @@ function setupIslandHydration() {
|
|
|
193
197
|
}
|
|
194
198
|
}
|
|
195
199
|
function unmountIsland(islandId) {
|
|
196
|
-
const islandToUnmount = rootsToProcess.find(
|
|
200
|
+
const islandToUnmount = rootsToProcess.find(
|
|
201
|
+
(island) => island.id === islandId
|
|
202
|
+
);
|
|
197
203
|
if (!islandToUnmount || !rootsById.get(islandId)) {
|
|
198
204
|
throw new Error(`No known island: ${islandId}`);
|
|
199
205
|
}
|
package/dist/run.js
CHANGED
|
@@ -198,7 +198,7 @@ function resolveIslandPlugin(islandsSet) {
|
|
|
198
198
|
}
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
201
|
+
var clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || ((id) => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
202
202
|
var virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
203
203
|
function clientIslandEntryPlugin() {
|
|
204
204
|
return {
|
|
@@ -231,7 +231,7 @@ function clientIslandEntryPlugin() {
|
|
|
231
231
|
}
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
|
-
var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
234
|
+
var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel, nonceAttribute) => {
|
|
235
235
|
if (!messagesForBrowser) {
|
|
236
236
|
return "";
|
|
237
237
|
}
|
|
@@ -255,7 +255,7 @@ var scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
|
255
255
|
groupEnd = ` console.groupEnd()
|
|
256
256
|
`;
|
|
257
257
|
}
|
|
258
|
-
return `<script>${groupStart}
|
|
258
|
+
return `<script ${nonceAttribute}>${groupStart}
|
|
259
259
|
${consoleLines.join("\n")}
|
|
260
260
|
${groupEnd}</script>
|
|
261
261
|
`;
|
|
@@ -1047,7 +1047,7 @@ function trackUsage(action) {
|
|
|
1047
1047
|
eventName: EVENT_NAME,
|
|
1048
1048
|
action,
|
|
1049
1049
|
nodeVersion: getNodeVersionData(),
|
|
1050
|
-
version: "0.15.
|
|
1050
|
+
version: "0.15.14",
|
|
1051
1051
|
os: getPlatform()
|
|
1052
1052
|
};
|
|
1053
1053
|
const uri = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
|
|
@@ -1150,9 +1150,10 @@ var partialRouteHandler = async (request2, response) => {
|
|
|
1150
1150
|
);
|
|
1151
1151
|
const html = htmlShell.replace(
|
|
1152
1152
|
"<!--headend-->",
|
|
1153
|
-
[
|
|
1154
|
-
|
|
1155
|
-
|
|
1153
|
+
[
|
|
1154
|
+
cssNeeded,
|
|
1155
|
+
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
1156
|
+
].join("\n")
|
|
1156
1157
|
).replace(`<!--ssr-outlet-->`, renderedHtml);
|
|
1157
1158
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
1158
1159
|
} catch (e) {
|
|
@@ -1366,9 +1367,7 @@ async function renderModule(viteServer, requestedModulePath, moduleProps, pageUr
|
|
|
1366
1367
|
throw new Error(`Module does not have a named meta export: ${foundPath}`);
|
|
1367
1368
|
}
|
|
1368
1369
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
1369
|
-
const { renderFieldsToJson } = await viteServer.ssrLoadModule(
|
|
1370
|
-
internalSsrPath
|
|
1371
|
-
);
|
|
1370
|
+
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
1372
1371
|
const fieldsJSON = renderFieldsToJson(fields, requestedModulePath);
|
|
1373
1372
|
const fieldValues = getFieldValuesForModule(fieldsJSON, fieldOverrides);
|
|
1374
1373
|
const applyFieldsValidationToRenderContext = getApplyFieldsValidationToRenderContext(
|
|
@@ -1541,9 +1540,10 @@ var moduleRouteHandler = async (request2, response) => {
|
|
|
1541
1540
|
);
|
|
1542
1541
|
const html = htmlShell.replace(
|
|
1543
1542
|
"<!--headend-->",
|
|
1544
|
-
[
|
|
1545
|
-
|
|
1546
|
-
|
|
1543
|
+
[
|
|
1544
|
+
cssNeeded,
|
|
1545
|
+
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
1546
|
+
].join("\n")
|
|
1547
1547
|
).replace(`<!--ssr-outlet-->`, renderedHtml);
|
|
1548
1548
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
1549
1549
|
} catch (e) {
|
|
@@ -2572,7 +2572,7 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2572
2572
|
const modulePath = normalizePath5(
|
|
2573
2573
|
path6.resolve(webRoot2, "components/modules/", moduleName)
|
|
2574
2574
|
);
|
|
2575
|
-
const basePath = getEntryPointBasePath(modulePath)
|
|
2575
|
+
const basePath = `preview/${getEntryPointBasePath(modulePath)}`;
|
|
2576
2576
|
const environmentConfig = buildStaticEnvConfig4(
|
|
2577
2577
|
authedPortalId,
|
|
2578
2578
|
authedHublet,
|
|
@@ -2613,9 +2613,7 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2613
2613
|
throw new Error(`Module does not have a named meta export: ${foundPath}`);
|
|
2614
2614
|
}
|
|
2615
2615
|
const internalSsrPath = packagePath(import.meta.url, "internalSsr");
|
|
2616
|
-
const { renderFieldsToJson } = await viteServer.ssrLoadModule(
|
|
2617
|
-
internalSsrPath
|
|
2618
|
-
);
|
|
2616
|
+
const { renderFieldsToJson } = await viteServer.ssrLoadModule(internalSsrPath);
|
|
2619
2617
|
const localFieldsJson = renderFieldsToJson(fields, modulePath);
|
|
2620
2618
|
const localModule = {
|
|
2621
2619
|
isJsModule: true,
|
|
@@ -2696,9 +2694,10 @@ async function modulePreviewRouteHandler(request2, response) {
|
|
|
2696
2694
|
);
|
|
2697
2695
|
const html = htmlShell.replace(
|
|
2698
2696
|
"<!--headend-->",
|
|
2699
|
-
[
|
|
2700
|
-
|
|
2701
|
-
|
|
2697
|
+
[
|
|
2698
|
+
cssNeeded,
|
|
2699
|
+
...inlineAssets.map((inlineAsset) => inlineAsset.html)
|
|
2700
|
+
].join("\n")
|
|
2702
2701
|
).replace(`<!--ssr-outlet-->`, renderedHtml);
|
|
2703
2702
|
response.status(200).set({ "Content-Type": "text/html" }).end(html);
|
|
2704
2703
|
} catch (e) {
|
|
@@ -3084,6 +3083,35 @@ function logMissingScopeWarning(error) {
|
|
|
3084
3083
|
function isMissingScopeError(error) {
|
|
3085
3084
|
return error.statusCode === 403 && (error.error.message.match(OAUTH_ERROR_REGEX) || error.error.message.startsWith(NOT_PUBLIC_USE_ERROR));
|
|
3086
3085
|
}
|
|
3086
|
+
function handleSecretsError(error) {
|
|
3087
|
+
if (error && error.statusCode && error.error) {
|
|
3088
|
+
const { statusCode, error: errorDetails } = error;
|
|
3089
|
+
if ((errorDetails == null ? void 0 : errorDetails.category) === "MISSING_SCOPES") {
|
|
3090
|
+
console.log(
|
|
3091
|
+
"\nMissing scopes for secrets.",
|
|
3092
|
+
"\nSecrets require Serverless functions which are scoped to Enterprise portals.\n"
|
|
3093
|
+
);
|
|
3094
|
+
} else {
|
|
3095
|
+
console.error(`Error ${statusCode}: ${errorDetails.message}`);
|
|
3096
|
+
if (errorDetails.correlationId) {
|
|
3097
|
+
console.error(`Correlation ID: ${errorDetails.correlationId}`);
|
|
3098
|
+
}
|
|
3099
|
+
if (errorDetails.category) {
|
|
3100
|
+
console.error(`Category: ${errorDetails.category}`);
|
|
3101
|
+
}
|
|
3102
|
+
if (errorDetails.links) {
|
|
3103
|
+
if (errorDetails.links.support) {
|
|
3104
|
+
console.error(`Support URL: ${errorDetails.links.support}`);
|
|
3105
|
+
}
|
|
3106
|
+
if (errorDetails.links.forum) {
|
|
3107
|
+
console.error(`Forum URL: ${errorDetails.links.forum}`);
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
} else {
|
|
3112
|
+
console.error("Unexpected error structure:", error);
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3087
3115
|
|
|
3088
3116
|
// src/proxyPage/fetchDomains.ts
|
|
3089
3117
|
async function fetchDomains(portalId) {
|
|
@@ -3254,7 +3282,7 @@ function getFieldEntries(fields) {
|
|
|
3254
3282
|
type: fieldType,
|
|
3255
3283
|
name,
|
|
3256
3284
|
isRepeater: "occurrence" in field,
|
|
3257
|
-
|
|
3285
|
+
isRequired: !!field.required,
|
|
3258
3286
|
choices: (
|
|
3259
3287
|
// Choices are pair [value, label] but only the value is printed to the page, so flatten it.
|
|
3260
3288
|
"choices" in field ? field.choices.map(([value]) => value) : void 0
|
|
@@ -3268,15 +3296,20 @@ function getFieldEntries(fields) {
|
|
|
3268
3296
|
return entry;
|
|
3269
3297
|
}).filter((entry) => entry !== void 0);
|
|
3270
3298
|
}
|
|
3271
|
-
var INVALID_IMPORTS = ["ChoiceFieldType"];
|
|
3272
|
-
var
|
|
3273
|
-
var
|
|
3274
|
-
var
|
|
3299
|
+
var INVALID_IMPORTS = ["ChoiceFieldType", "GroupFieldType"];
|
|
3300
|
+
var FIELD_GROUP_TYPE = "FieldGroupWithChildren";
|
|
3301
|
+
var REPEATER_GROUP_TYPE = "RepeaterGroup";
|
|
3302
|
+
var REQUIRED_TYPE = "RequiredField";
|
|
3275
3303
|
var DEFAULT_VALUES_TYPE = "DefaultValues";
|
|
3276
3304
|
var CMS_COMPONENTS = "@hubspot/cms-components";
|
|
3277
3305
|
var CMS_COMPONENTS_FIELD_TYPES = `${CMS_COMPONENTS}/fields`;
|
|
3278
3306
|
var AUTO_GEN_COMMENT = "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.";
|
|
3279
|
-
var createPropertySignature = (identifier, type) => ts.factory.createPropertySignature(
|
|
3307
|
+
var createPropertySignature = (identifier, type, hasQuestionToken = false) => ts.factory.createPropertySignature(
|
|
3308
|
+
[],
|
|
3309
|
+
identifier,
|
|
3310
|
+
hasQuestionToken ? ts.factory.createToken(ts.SyntaxKind.QuestionToken) : void 0,
|
|
3311
|
+
type
|
|
3312
|
+
);
|
|
3280
3313
|
var createUnionTypeFromArray = (values) => ts.factory.createUnionTypeNode(
|
|
3281
3314
|
values.map(
|
|
3282
3315
|
(value) => ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(value))
|
|
@@ -3289,29 +3322,41 @@ var buildTypeFromField = (field, additionalNode) => {
|
|
|
3289
3322
|
const requiredType = ts.factory.createTypeReferenceNode(REQUIRED_TYPE, [
|
|
3290
3323
|
baseType
|
|
3291
3324
|
]);
|
|
3292
|
-
let finalType = field.
|
|
3325
|
+
let finalType = field.isRequired ? requiredType : baseType;
|
|
3293
3326
|
if (field.choices) {
|
|
3294
3327
|
finalType = createUnionTypeFromArray(field.choices);
|
|
3295
3328
|
}
|
|
3329
|
+
if (field.isRequired) {
|
|
3330
|
+
imports.push(REQUIRED_TYPE);
|
|
3331
|
+
}
|
|
3296
3332
|
if (additionalNode) {
|
|
3297
3333
|
const typeLiteral = ts.isTypeLiteralNode(additionalNode) ? additionalNode : ts.factory.createTypeLiteralNode([additionalNode]);
|
|
3298
|
-
const
|
|
3299
|
-
|
|
3300
|
-
);
|
|
3301
|
-
if (!field.isRepeater) {
|
|
3302
|
-
imports.push(OVERRIDE_TYPE);
|
|
3303
|
-
}
|
|
3304
|
-
finalType = field.isRepeater ? ts.factory.createTypeReferenceNode("Array", [
|
|
3305
|
-
ts.factory.createTypeReferenceNode("Record", [
|
|
3306
|
-
repeaterName,
|
|
3307
|
-
typeLiteral
|
|
3308
|
-
])
|
|
3309
|
-
]) : ts.factory.createTypeReferenceNode(OVERRIDE_TYPE, [
|
|
3310
|
-
finalType,
|
|
3311
|
-
typeLiteral
|
|
3312
|
-
]);
|
|
3334
|
+
const genericType = field.isRepeater ? REPEATER_GROUP_TYPE : FIELD_GROUP_TYPE;
|
|
3335
|
+
imports.push(genericType);
|
|
3336
|
+
finalType = ts.factory.createTypeReferenceNode(genericType, [typeLiteral]);
|
|
3313
3337
|
}
|
|
3314
|
-
return {
|
|
3338
|
+
return {
|
|
3339
|
+
type: createPropertySignature(
|
|
3340
|
+
identifier,
|
|
3341
|
+
finalType,
|
|
3342
|
+
!field.isRequired && !additionalNode
|
|
3343
|
+
),
|
|
3344
|
+
imports
|
|
3345
|
+
};
|
|
3346
|
+
};
|
|
3347
|
+
var filterUnusedImports = (imports, type) => {
|
|
3348
|
+
const usedImports = /* @__PURE__ */ new Set();
|
|
3349
|
+
const visit = (node) => {
|
|
3350
|
+
if (ts.isTypeReferenceNode(node)) {
|
|
3351
|
+
const typeName = node.typeName;
|
|
3352
|
+
if ("escapedText" in typeName) {
|
|
3353
|
+
usedImports.add(typeName.escapedText.toString());
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
ts.forEachChild(node, visit);
|
|
3357
|
+
};
|
|
3358
|
+
visit(type);
|
|
3359
|
+
return imports.filter((name) => usedImports.has(name));
|
|
3315
3360
|
};
|
|
3316
3361
|
function getImportDeclaration(imports, moduleSpecifier) {
|
|
3317
3362
|
const importSpecifiers = Array.from(imports).map(
|
|
@@ -3330,20 +3375,16 @@ function getImportDeclaration(imports, moduleSpecifier) {
|
|
|
3330
3375
|
);
|
|
3331
3376
|
}
|
|
3332
3377
|
function getFieldTypes(fields) {
|
|
3333
|
-
const imports = [
|
|
3378
|
+
const imports = [];
|
|
3334
3379
|
const types = fields.map((field) => {
|
|
3335
3380
|
if (field.children) {
|
|
3336
3381
|
const childrenResult = getFieldTypes(field.children);
|
|
3337
3382
|
imports.push(...childrenResult.imports);
|
|
3338
3383
|
if (childrenResult.types.length) {
|
|
3339
3384
|
const subType = ts.factory.createTypeLiteralNode(childrenResult.types);
|
|
3340
|
-
const childrenPropertySignature = createPropertySignature(
|
|
3341
|
-
"children",
|
|
3342
|
-
subType
|
|
3343
|
-
);
|
|
3344
3385
|
const { type: type2, imports: newImports2 } = buildTypeFromField(
|
|
3345
3386
|
field,
|
|
3346
|
-
|
|
3387
|
+
subType
|
|
3347
3388
|
);
|
|
3348
3389
|
imports.push(...newImports2);
|
|
3349
3390
|
return type2;
|
|
@@ -3360,10 +3401,6 @@ function getFieldTypes(fields) {
|
|
|
3360
3401
|
}
|
|
3361
3402
|
function constructFinalType(fields, typeName) {
|
|
3362
3403
|
const { types, imports } = getFieldTypes(fields);
|
|
3363
|
-
const importDeclaration = getImportDeclaration(
|
|
3364
|
-
imports,
|
|
3365
|
-
CMS_COMPONENTS_FIELD_TYPES
|
|
3366
|
-
);
|
|
3367
3404
|
const baseType = ts.factory.createTypeAliasDeclaration(
|
|
3368
3405
|
[],
|
|
3369
3406
|
[],
|
|
@@ -3381,6 +3418,11 @@ function constructFinalType(fields, typeName) {
|
|
|
3381
3418
|
void 0,
|
|
3382
3419
|
wrappedType
|
|
3383
3420
|
);
|
|
3421
|
+
const filteredImports = filterUnusedImports(imports, finalType);
|
|
3422
|
+
const importDeclaration = getImportDeclaration(
|
|
3423
|
+
[...filteredImports, DEFAULT_VALUES_TYPE],
|
|
3424
|
+
CMS_COMPONENTS_FIELD_TYPES
|
|
3425
|
+
);
|
|
3384
3426
|
const defaultExport = ts.factory.createExportDefault(
|
|
3385
3427
|
ts.factory.createIdentifier(typeName)
|
|
3386
3428
|
);
|
|
@@ -3604,8 +3646,8 @@ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2
|
|
|
3604
3646
|
);
|
|
3605
3647
|
}
|
|
3606
3648
|
}
|
|
3607
|
-
} catch (
|
|
3608
|
-
|
|
3649
|
+
} catch (error) {
|
|
3650
|
+
handleSecretsError(error);
|
|
3609
3651
|
}
|
|
3610
3652
|
} else {
|
|
3611
3653
|
console.warn(
|
|
@@ -341,9 +341,9 @@ var init_basicUtils = __esm({
|
|
|
341
341
|
">": "\\u003E",
|
|
342
342
|
"/": "\\u002F"
|
|
343
343
|
};
|
|
344
|
-
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || (id => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
344
|
+
clientRenderIsland = "import type { RenderableIsland } from '@hubspot/cms-components';\nimport * as cmsComponents from '@hubspot/cms-components';\nimport { ClientRenderContextProvider } from '@hubspot/cms-components';\nimport { Suspense } from 'react';\nimport ReactDOMClient from 'react-dom/client';\n\nconst buildIslandIdentifierPrefix =\n cmsComponents.buildIslandIdentifierPrefix || ((id) => id);\n\nexport function clientRenderIsland(\n renderableIsland: RenderableIsland,\n Component: React.ComponentType<any>\n) {\n const {\n island,\n rootElement,\n postHydration,\n pageUrl,\n islands,\n basePath,\n WrapperModule,\n } = renderableIsland;\n let reactRoot: any;\n\n const rootOptions = {\n // Ensure useId is unique across island roots\n identifierPrefix: buildIslandIdentifierPrefix(renderableIsland.island.id),\n };\n\n let innerComponent = <Component islandId={island.id} {...island.props} />;\n if (WrapperModule) {\n innerComponent = <WrapperModule>{innerComponent}</WrapperModule>;\n }\n\n const elementsToHydrate = (\n <Suspense fallback={`client hydrate fail/waiting for ${island.id}`}>\n <ClientRenderContextProvider\n pageUrl={pageUrl}\n islands={islands}\n onTopLevelHydrationFinish={postHydration}\n island={island}\n basePath={basePath}\n >\n {innerComponent}\n </ClientRenderContextProvider>\n </Suspense>\n );\n\n if (island.clientOnly) {\n reactRoot = ReactDOMClient.createRoot(rootElement, rootOptions);\n reactRoot.render(elementsToHydrate);\n } else {\n reactRoot = ReactDOMClient.hydrateRoot(\n rootElement,\n elementsToHydrate,\n rootOptions\n );\n }\n return reactRoot;\n}\n";
|
|
345
345
|
virtualClientRenderIslandModuleId = "virtual:clientRenderIsland.tsx";
|
|
346
|
-
scriptTagToLogServerMessages = (messagesForBrowser, groupLabel) => {
|
|
346
|
+
scriptTagToLogServerMessages = (messagesForBrowser, groupLabel, nonceAttribute) => {
|
|
347
347
|
if (!messagesForBrowser) {
|
|
348
348
|
return "";
|
|
349
349
|
}
|
|
@@ -367,7 +367,7 @@ var init_basicUtils = __esm({
|
|
|
367
367
|
groupEnd = ` console.groupEnd()
|
|
368
368
|
`;
|
|
369
369
|
}
|
|
370
|
-
return `<script>${groupStart}
|
|
370
|
+
return `<script ${nonceAttribute}>${groupStart}
|
|
371
371
|
${consoleLines.join("\n")}
|
|
372
372
|
${groupEnd}</script>
|
|
373
373
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.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.15.
|
|
29
|
+
"@hubspot/cms-components": "^0.15.14",
|
|
30
30
|
"@inquirer/select": "^2.0.0",
|
|
31
31
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
32
32
|
"@storybook/addon-actions": "7.1.1",
|
|
@@ -108,5 +108,5 @@
|
|
|
108
108
|
"publishConfig": {
|
|
109
109
|
"access": "public"
|
|
110
110
|
},
|
|
111
|
-
"gitHead": "
|
|
111
|
+
"gitHead": "91d840fcf23f9b175bd8155dd1e2d2a31cb3fbef"
|
|
112
112
|
}
|