@hubspot/cms-dev-server 1.0.4 → 1.0.6

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.
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/createViteDevServer.ts", "../../cms-js-internal/dist/basicUtils.js", "../../cms-js-internal/dist/index.js", "../src/plugins/devSecretsPlugin.ts"],
4
+ "sourcesContent": ["/* hs-eslint ignored failing-rules */\n/* eslint-disable require-await */\n\nimport { createServer as createViteServer, InlineConfig } from 'vite';\nimport { default as react } from '@vitejs/plugin-react';\nimport {\n Gate,\n clientIslandEntryPlugin,\n resolveIslandPlugin,\n noncePlaceholderPlugin,\n findCmsModules,\n} from '@hubspot/cms-js-internal';\nimport { default as mkcert } from 'vite-plugin-mkcert';\nimport { viteCommonjs } from '@originjs/vite-plugin-commonjs';\nimport devSecretsPlugin from './plugins/devSecretsPlugin.js';\n\nasync function createViteDevServer(\n webRoot: string,\n port,\n sslEnabled: boolean,\n domainsToProxy = [],\n jsRenderingGates: Gate[],\n secretNames: string[]\n) {\n const additionalMkcertHosts = domainsToProxy\n .map((proxyDomain) => [\n `${proxyDomain}.localhost`,\n `${proxyDomain}.hslocal.net`,\n ])\n .flat();\n\n if (process.env.VITE_ORIGIN) {\n console.log(`\\nCustom origin: ${process.env.VITE_ORIGIN}\\n`);\n }\n\n const origin =\n process.env.VITE_ORIGIN ??\n (sslEnabled ? `https://hslocal.net:${port}` : `http://hslocal.net:${port}`);\n\n const viteConfig: InlineConfig = {\n appType: 'custom',\n server: {\n middlewareMode: true,\n host: 'hslocal.net',\n origin,\n https: sslEnabled,\n hmr: {\n protocol: sslEnabled ? 'wss' : undefined,\n },\n },\n root: webRoot,\n ssr: {\n // TODO: might need more entries here to get things to resolve through\n // resolveWebRootDepsPlugin\n noExternal: '@hubspot/cms-components',\n },\n resolve: {\n conditions: ['server'],\n dedupe: ['react', 'react-dom', '@hubspot/cms-components', 'styled-jsx'],\n },\n optimizeDeps: {\n include: ['react', 'react-dom', 'react-dom/client'],\n },\n plugins: [\n true ? findCmsModules() : null,\n sslEnabled ? mkcert({ hosts: additionalMkcertHosts }) : null,\n react({\n babel: {\n plugins: [\n 'babel-plugin-styled-components',\n 'styled-jsx/babel',\n 'macros',\n ],\n },\n }),\n clientIslandEntryPlugin(),\n resolveIslandPlugin(),\n jsRenderingGates.includes('CMS:JSRenderer:RemoveCjsPlugin')\n ? null\n : viteCommonjs(),\n devSecretsPlugin(secretNames),\n noncePlaceholderPlugin(),\n ],\n css: {\n postcss: webRoot,\n },\n envDir: webRoot,\n envPrefix: 'HS_',\n };\n\n return createViteServer(viteConfig);\n}\n\nexport default createViteDevServer;\n", "import path from \"path\";\nimport { createHash } from \"crypto\";\nimport fs, { readFileSync, existsSync, readdirSync, lstatSync } from \"fs\";\nimport { join } from \"path/posix\";\nconst COMPONENT_EXTENSIONS = [\".jsx\", \".tsx\", \".js\", \".ts\"];\nconst ENTRY_POINTS_PATH = \"components/partials/\";\nconst MODULE_FOLDER_PATH = \"components/modules/\";\nconst VIRTUAL_ISLAND_RUNTIME = \"virtual:island-runtime\";\nconst VIRTUAL_CONFIG_SETUP = \"virtual:config-setup\";\nconst CSS_LANGS_RE = /\\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\\?)/;\nconst collectCssModules = (modulePathToStartWith, viteServer, cssModulesImported = /* @__PURE__ */ new Set()) => {\n const appModulesForPath = viteServer.moduleGraph.fileToModulesMap.get(\n modulePathToStartWith\n );\n if (!appModulesForPath || appModulesForPath.size === 0) {\n throw new Error(`No modules at: ${modulePathToStartWith}`);\n } else if (appModulesForPath.size > 1) {\n throw new Error(`More than one module at: ${modulePathToStartWith}`);\n }\n const appModule = Array.from(appModulesForPath.values())[0];\n const allServerSideModulesImported = /* @__PURE__ */ new Set();\n const newCssModules = [];\n const moduleQueue = Array.from(appModule.importedModules);\n for (const importedModule of moduleQueue) {\n if (allServerSideModulesImported.has(importedModule.id)) {\n continue;\n }\n allServerSideModulesImported.add(importedModule.id);\n const isCss = CSS_LANGS_RE.test(importedModule.file);\n const moduleModulesToQueue = Array.from(importedModule.importedModules);\n if (isCss && !cssModulesImported.has(importedModule)) {\n cssModulesImported.add(importedModule);\n newCssModules.push(importedModule);\n }\n moduleQueue.push(...moduleModulesToQueue);\n }\n return newCssModules;\n};\nfunction createPreloadLink(assetPath, basePath = \"\") {\n if (assetPath && assetPath[0] !== \"/\") {\n assetPath = `/${assetPath}`;\n }\n if (assetPath.endsWith(\".js\")) {\n return `<link rel=\"modulepreload\" crossorigin href=\"${basePath}${assetPath}\">`;\n } else if (CSS_LANGS_RE.test(assetPath)) {\n return `<link rel=\"stylesheet\" href=\"${basePath}${assetPath}?css\">`;\n } else if (assetPath.endsWith(\".woff\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"font\" type=\"font/woff\" crossorigin>`;\n } else if (assetPath.endsWith(\".woff2\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"font\" type=\"font/woff2\" crossorigin>`;\n } else if (assetPath.endsWith(\".gif\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/gif\">`;\n } else if (assetPath.endsWith(\".jpg\") || assetPath.endsWith(\".jpeg\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/jpeg\">`;\n } else if (assetPath.endsWith(\".png\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/png\">`;\n } else {\n throw new Error(`Unknown preload type for ${assetPath}`);\n }\n}\nconst collectCssInDev = (modulePathToStartWith, viteServer, cssModulesImported = /* @__PURE__ */ new Set()) => {\n return `${collectCssModules(\n modulePathToStartWith,\n viteServer,\n cssModulesImported\n ).map((cssModule) => createPreloadLink(cssModule.url)).join(\"\\n\")}\n`;\n};\nconst badInlineJsChars = /[\\u2028\\u2029<>/]/g;\nconst inlineJsEscapeChars = {\n \"\\u2028\": \"\\\\u2028\",\n \"\\u2029\": \"\\\\u2029\",\n \"<\": \"\\\\u003C\",\n \">\": \"\\\\u003E\",\n \"/\": \"\\\\u002F\"\n};\nfunction escapeChar(unsafeChar) {\n return inlineJsEscapeChars[unsafeChar];\n}\nfunction escapeForInlineJS(input) {\n return input.replace(badInlineJsChars, escapeChar);\n}\nfunction jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true } = {}) {\n const indentString = \" \".repeat(baseIndent);\n jsonIndent = prettyPrint ? jsonIndent : void 0;\n return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(\n /\\n/gm,\n `\n${indentString}`\n );\n}\nlet viteRoot;\nlet viteCommand;\nfunction resolveIslandPlugin(islandsSet) {\n return {\n enforce: \"pre\",\n name: \"resolve-islands\",\n configResolved(config) {\n viteRoot = config.root;\n viteCommand = config.command;\n },\n load(id) {\n if (id.endsWith(\"?island\") || id.endsWith(\"?client\")) {\n const [idWithNoParam] = id.split(\"?\");\n const islandModuleImportPath = `${idWithNoParam}?client-entry`;\n const componentExtension = path.extname(idWithNoParam);\n const componentFilenameWithNoExtension = path.basename(\n idWithNoParam,\n componentExtension\n );\n const modulePath = idWithNoParam.replace(`${viteRoot}/`, \"\");\n const moduleId = (viteCommand === \"serve\" ? idWithNoParam : modulePath).concat(\"?client-entry\");\n if (islandsSet) {\n islandsSet.add(moduleId);\n }\n return `\n const moduleId = '${moduleId}';\n\n const lazyComponent = () => import('${islandModuleImportPath}');\n lazyComponent.moduleName = '${componentFilenameWithNoExtension}';\n lazyComponent.moduleId = moduleId;\n\n export default lazyComponent;\n `;\n }\n return null;\n }\n };\n}\nfunction resolveIslandToPlainModulePlugin(enabled = true) {\n return {\n enforce: \"pre\",\n name: \"resolve-islands-to-plain\",\n configResolved(config) {\n viteRoot = config.root;\n viteCommand = config.command;\n },\n async resolveId(id, importer, options) {\n if (enabled && (id.endsWith(\"?island\") || id.endsWith(\"?client\"))) {\n const newId = id.replace(\"?island\", \"\").replace(\"?client\", \"\");\n const resolution = await this.resolve(newId, importer, {\n skipSelf: true,\n ...options\n });\n if (resolution) {\n return resolution;\n }\n }\n return null;\n }\n };\n}\nfunction resolveIslandToPlainModuleNoopPlugin() {\n return resolveIslandToPlainModulePlugin(false);\n}\nconst 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\";\nconst virtualClientRenderIslandModuleId = \"virtual:clientRenderIsland.tsx\";\nfunction clientIslandEntryPlugin() {\n return {\n enforce: \"pre\",\n name: \"client-island-entry-plugin\",\n resolveId(id) {\n if (id === virtualClientRenderIslandModuleId) {\n return virtualClientRenderIslandModuleId;\n }\n return null;\n },\n load(id) {\n if (id.endsWith(\"?client-entry\")) {\n const [idWithNoParam] = id.split(\"?\");\n return `\n import { clientRenderIsland } from '${virtualClientRenderIslandModuleId}';\n import Component from '${idWithNoParam}';\n\n export function render(island) {\n return clientRenderIsland(island, Component)\n }\n\n export default Component;\n `;\n }\n if (id === virtualClientRenderIslandModuleId) {\n return clientRenderIsland;\n }\n return null;\n }\n };\n}\nconst scriptTagToLogServerMessages = (messagesForBrowser, groupLabel, nonceAttribute) => {\n if (!messagesForBrowser) {\n return \"\";\n }\n const consoleLines = [];\n for (const message of messagesForBrowser) {\n let funcString = \"console.log\";\n if (message.level === \"error\") {\n funcString = \"console.error\";\n }\n if (message.level === \"warn\") {\n funcString = \"console.warn\";\n }\n const argString = message.parameters.map((arg) => JSON.stringify(arg)).join(\", \");\n consoleLines.push(` ${funcString}(${argString});`);\n }\n let groupStart = \"\";\n let groupEnd = \"\";\n if (groupLabel !== void 0 && groupLabel !== null) {\n groupStart = `\n console.group(${JSON.stringify(groupLabel)});`;\n groupEnd = ` console.groupEnd()\n`;\n }\n return `<script ${nonceAttribute}>${groupStart}\n${consoleLines.join(\"\\n\")}\n${groupEnd}<\\/script>\n`;\n};\nconst getComponentExtension = (componentPath) => {\n const filteredExtensions = COMPONENT_EXTENSIONS.filter(\n (ext) => componentPath.endsWith(ext)\n );\n if (filteredExtensions.length === 1) {\n return filteredExtensions[0];\n }\n return void 0;\n};\nconst hasComponentExtension = (componentPath) => {\n return !!getComponentExtension(componentPath);\n};\nconst isStorybookStory = (componentPath) => {\n return !!path.basename(componentPath, path.extname(componentPath)).endsWith(\".stories\");\n};\nconst removeComponentExtension = (componentPath) => {\n const ext = getComponentExtension(componentPath);\n if (ext == null) {\n return componentPath;\n }\n return componentPath.slice(0, -1 * ext.length);\n};\nfunction getEntryPointHash(entryPoint) {\n return createHash(\"md5\").update(entryPoint).digest(\"hex\").slice(0, 6);\n}\nfunction getEntryPointHashWithIndexSuffix(entryPoint, index) {\n const renderIndexSuffix = index != null ? `i${index}` : \"\";\n return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;\n}\nconst COMBINED_REACT_BASE_PATH = \"https://static.hsappstatic.net/cms-js-static/ex/js/react/v18\";\nconst ISLAND_RUNTIME_CONFIG_BASE_PATH = \"https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1\";\nfunction getCombinedReactUrl() {\n const hsEnv = process.env.HS_ENV;\n const fileVersion = hsEnv === \"prod\" ? `react-combined.mjs` : \"react-combined-qa.mjs\";\n return `${COMBINED_REACT_BASE_PATH}/${fileVersion}`;\n}\nfunction getIslandRuntimeConfigUrl() {\n const hsEnv = process.env.HS_ENV;\n const fileVersion = hsEnv === \"prod\" ? `island-runtime.mjs` : \"island-runtime-qa.mjs\";\n return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;\n}\nfunction includesHublDataReference(templateSource) {\n const hublDataPattern = /\\{%\\s+set\\s+(experimentalHublData|hublData)\\s*=/;\n return !!templateSource.match(hublDataPattern);\n}\nconst removeIndexFromPath = (id) => {\n return id.replace(/\\/index\\.[jt]sx?$/, \"\");\n};\nconst removeIndexOrTrailingJsFromPath = (id) => {\n return removeIndexFromPath(id).replace(/\\.[jt]sx?$/, \"\");\n};\nconst HEALTHCHECKS_ENABLED_DEFAULT = true;\nconst HEALTHCHECKS_STRICT_DEFAULT = false;\nfunction getCMSAssetConfig(webRoot) {\n const cmsAssetsPath = path.join(webRoot, \"cms-assets.json\");\n const cmsThemePath = path.join(webRoot, \"theme.json\");\n const configPathToUse = fs.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;\n const parsedConfig = JSON.parse(\n fs.readFileSync(configPathToUse).toString()\n );\n return parsedConfig;\n}\nfunction getCMSAssetConfigIfExists(webRoot) {\n try {\n return getCMSAssetConfig(webRoot);\n } catch (e) {\n console.error(\n `Error finding or parsing cms-assets.json in ${webRoot}, but ignoring for now`\n );\n return {};\n }\n}\nfunction areBuildHealthChecksEnabled(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.healthchecks) == null ? void 0 : _b.enabled) ?? HEALTHCHECKS_ENABLED_DEFAULT;\n}\nfunction doHealthChecksFailTheBuild(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.healthchecks) == null ? void 0 : _b.strict) ?? HEALTHCHECKS_STRICT_DEFAULT;\n}\nfunction getServerIncludePrebundleDepPatterns(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.serverPrebundling) == null ? void 0 : _b.include) ?? [];\n}\nconst BUILD_INFO_PATH = \"/build-info.json\";\nfunction getBuildInfo(buildDir) {\n try {\n const buildInfo = JSON.parse(\n readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()\n );\n return buildInfo;\n } catch (e) {\n throw new Error(`Error loading build-info.json, path: ${BUILD_INFO_PATH}`);\n }\n}\nfunction getBaseAssetUrlFromBuild(buildDir) {\n return getBuildInfo(buildDir).baseAssetUrl;\n}\nconst GATES = [\n \"CMS:JSRenderer:GetServerSideProps\",\n \"CMS:JSRenderer:ModuleHubl\",\n \"CMS:JSRenderer:RemoveCjsPlugin\",\n \"CMS:JSRenderer:RemoveMockClientEntryPlugin\",\n \"CMS:JSRenderer:AnalyzeCmsModules\"\n];\nconst ENABLED_FEATURES_GATE_MAP = {\n \"cms:jsr:getServerSideProps\": \"CMS:JSRenderer:GetServerSideProps\",\n \"cms:jsr:RemoveCjsPlugin\": \"CMS:JSRenderer:RemoveCjsPlugin\",\n \"cms:jsr:analyzeCmsModules\": \"CMS:JSRenderer:AnalyzeCmsModules\"\n};\nfunction isUngatedFor(gates, gate) {\n return gates.includes(gate);\n}\nfunction ungatedAtBuildTimeFor(buildDir, gate) {\n try {\n const buildInfo = getBuildInfo(buildDir);\n return isUngatedFor(buildInfo.gates, gate);\n } catch (e) {\n return false;\n }\n}\nconst findAllComponentsIn = (webRoot, componentsFolder) => {\n const fullComponentsFolderPath = join(webRoot, componentsFolder);\n const componentsByName = {};\n if (!existsSync(fullComponentsFolderPath)) {\n return componentsByName;\n }\n readdirSync(fullComponentsFolderPath).forEach((fileOrFolderName) => {\n const fullPath = join(fullComponentsFolderPath, fileOrFolderName);\n const subdirPath = join(componentsFolder, fileOrFolderName);\n const isDirectory = lstatSync(fullPath).isDirectory();\n if (!isDirectory && hasComponentExtension(fileOrFolderName) && !isStorybookStory(fileOrFolderName)) {\n const subdirPathNoExtension = removeComponentExtension(subdirPath);\n componentsByName[subdirPathNoExtension] = subdirPath;\n } else if (isDirectory) {\n for (const potentialExtension of COMPONENT_EXTENSIONS) {\n const potentialIndexModule = join(\n subdirPath,\n `index${potentialExtension}`\n );\n const fullPotentialPath = join(\n fullPath,\n `index${potentialExtension}`\n );\n if (existsSync(fullPotentialPath)) {\n const moduleIndexPathNoExtension = removeComponentExtension(potentialIndexModule);\n componentsByName[moduleIndexPathNoExtension] = potentialIndexModule;\n break;\n }\n }\n }\n });\n return componentsByName;\n};\nfunction findAllModulesInRoot(webRoot) {\n const allModuleComponents = findAllComponentsIn(\n webRoot,\n \"./components/modules\"\n );\n const moduleNames = Object.keys(allModuleComponents).map(\n (moduleSubpath) => moduleSubpath.replace(\"components/modules/\", \"\").replace(\"/index\", \"\")\n );\n const moduleSubpaths = Object.keys(allModuleComponents);\n return { moduleNames, moduleSubpaths };\n}\nfunction findAllPartialsInRoot(webRoot) {\n const allPartialComponents = findAllComponentsIn(\n webRoot,\n \"./components/partials\"\n );\n const partialNames = Object.keys(allPartialComponents).map(\n (partialSubpath) => partialSubpath.replace(\"components/partials/\", \"\").replace(\"/index\", \"\")\n );\n const partialSubpaths = Object.keys(allPartialComponents);\n return { partialNames, partialSubpaths };\n}\nfunction namespaceModulePropsShape(props) {\n const {\n dataQueryResult,\n hublParameters,\n fieldValues: passedFieldValues,\n hublData,\n experimentalHublData,\n moduleName,\n supplementalFieldValues\n } = props;\n const oldPropsShape = { ...props };\n if (oldPropsShape.dataQueryResult) {\n delete oldPropsShape.dataQueryResult;\n }\n if (oldPropsShape.hublParameters) {\n delete oldPropsShape.hublParameters;\n }\n const fieldValues = passedFieldValues || oldPropsShape;\n return {\n ...fieldValues,\n dataQueryResult,\n fieldValues,\n hublParameters,\n hublData,\n experimentalHublData,\n moduleName,\n supplementalFieldValues\n };\n}\nfunction setIn(object, nestedKeysArray, value) {\n let curr = object;\n const finalKey = nestedKeysArray.pop();\n for (let index = 0; index < nestedKeysArray.length; index++) {\n const currentKey = nestedKeysArray[index];\n const nextKey = nestedKeysArray[index + 1];\n if (Number.isInteger(nextKey) || !nextKey && Number.isInteger(finalKey)) {\n if (curr[currentKey] === void 0) {\n curr[currentKey] = [];\n }\n }\n if (curr[currentKey] === void 0) {\n curr[currentKey] = {};\n }\n curr = curr[currentKey];\n }\n if (value !== void 0) {\n curr[finalKey] = value;\n }\n}\nfunction isStylesheetAsset(staticAsset) {\n return staticAsset.type === \"stylesheet\";\n}\nexport {\n COMPONENT_EXTENSIONS,\n CSS_LANGS_RE,\n ENABLED_FEATURES_GATE_MAP,\n ENTRY_POINTS_PATH,\n GATES,\n MODULE_FOLDER_PATH,\n VIRTUAL_CONFIG_SETUP,\n VIRTUAL_ISLAND_RUNTIME,\n getBaseAssetUrlFromBuild as a,\n areBuildHealthChecksEnabled,\n clientIslandEntryPlugin,\n collectCssInDev,\n collectCssModules,\n doHealthChecksFailTheBuild,\n escapeForInlineJS,\n findAllComponentsIn,\n findAllModulesInRoot,\n findAllPartialsInRoot,\n getBuildInfo as g,\n getCMSAssetConfig,\n getCMSAssetConfigIfExists,\n getCombinedReactUrl,\n getComponentExtension,\n getEntryPointHash,\n getEntryPointHashWithIndexSuffix,\n getIslandRuntimeConfigUrl,\n getServerIncludePrebundleDepPatterns,\n hasComponentExtension,\n includesHublDataReference,\n isStorybookStory,\n isStylesheetAsset,\n isUngatedFor,\n jsonStringifyAndEscapeForInlineJS,\n namespaceModulePropsShape,\n removeComponentExtension,\n removeIndexFromPath,\n removeIndexOrTrailingJsFromPath,\n resolveIslandPlugin,\n resolveIslandToPlainModuleNoopPlugin,\n resolveIslandToPlainModulePlugin,\n scriptTagToLogServerMessages,\n setIn,\n ungatedAtBuildTimeFor,\n virtualClientRenderIslandModuleId\n};\n", "import { jsonStringifyAndEscapeForInlineJS, scriptTagToLogServerMessages } from \"./basicUtils.js\";\nimport { COMPONENT_EXTENSIONS, CSS_LANGS_RE, ENABLED_FEATURES_GATE_MAP, ENTRY_POINTS_PATH, GATES, MODULE_FOLDER_PATH, VIRTUAL_CONFIG_SETUP, VIRTUAL_ISLAND_RUNTIME, areBuildHealthChecksEnabled, clientIslandEntryPlugin, collectCssInDev, collectCssModules, doHealthChecksFailTheBuild, escapeForInlineJS, findAllComponentsIn, findAllModulesInRoot, findAllPartialsInRoot, a, g, getCMSAssetConfig, getCMSAssetConfigIfExists, getCombinedReactUrl, getComponentExtension, getEntryPointHash, getEntryPointHashWithIndexSuffix, getIslandRuntimeConfigUrl, getServerIncludePrebundleDepPatterns, hasComponentExtension, includesHublDataReference, isStorybookStory, isStylesheetAsset, isUngatedFor, namespaceModulePropsShape, removeComponentExtension, removeIndexFromPath, removeIndexOrTrailingJsFromPath, resolveIslandPlugin, resolveIslandToPlainModuleNoopPlugin, resolveIslandToPlainModulePlugin, setIn, ungatedAtBuildTimeFor, virtualClientRenderIslandModuleId } from \"./basicUtils.js\";\nimport * as dotProp from \"dot-prop\";\nimport * as parser from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport { jsx } from \"react/jsx-runtime\";\nimport stream from \"stream\";\nimport { renderToPipeableStream, renderToStaticMarkup } from \"react-dom/server\";\nimport * as cmsComponents from \"@hubspot/cms-components\";\nimport { ServerRenderContext } from \"@hubspot/cms-components\";\nimport { isValidElement, cloneElement } from \"react\";\nimport \"path\";\nimport \"crypto\";\nimport \"fs\";\nimport \"path/posix\";\nconst { setProperty, getProperty, hasProperty } = dotProp;\nconst serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {\n const islandsArrayToSerialize = tweakedIslandsArray.map(\n ({\n id,\n moduleName,\n moduleId,\n props,\n hydrateOn,\n clientOnly,\n priority,\n url,\n sharedStateID,\n supplementalFieldValues,\n wrapperModuleId,\n wrapperUrl\n }) => {\n const output = {\n id,\n moduleName,\n moduleId,\n hydrateOn,\n clientOnly,\n priority,\n props,\n url\n };\n if (sharedStateID) {\n output.sharedStateID = sharedStateID;\n }\n if (wrapperModuleId) {\n output.wrapperModuleId = wrapperModuleId;\n }\n if (wrapperUrl) {\n output.wrapperUrl = wrapperUrl;\n }\n const filteredSupplementalFieldValues = filterOutUnreadSupplementalFieldValues(\n supplementalFieldValues,\n perServerRequestData.get(\"supplementalFieldValuesRead\")\n );\n if (filteredSupplementalFieldValues) {\n output.supplementalFieldValues = filteredSupplementalFieldValues;\n }\n return output;\n }\n );\n return jsonStringifyAndEscapeForInlineJS(islandsArrayToSerialize, {\n baseIndent,\n jsonIndent: 2,\n prettyPrint\n });\n};\nfunction filterOutUnreadSupplementalFieldValues(supplementalFieldValues, supplementalFieldValuesRead) {\n if (!supplementalFieldValues) {\n return supplementalFieldValues;\n }\n if (!supplementalFieldValuesRead) {\n return supplementalFieldValues;\n }\n const result = {};\n Array.from(supplementalFieldValuesRead).forEach((fieldPath) => {\n if (hasProperty(supplementalFieldValues, fieldPath)) {\n setProperty(\n result,\n fieldPath,\n getProperty(supplementalFieldValues, fieldPath)\n );\n }\n });\n return result;\n}\nconst writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, prettyPrint) => {\n const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);\n if (sharedStateIDs.length > 0) {\n const indentString = \" \".repeat(indent);\n const stateByID = {};\n sharedStateIDs.forEach(\n (id) => stateByID[id] = perServerRequestData.get(id)\n );\n const stringifiedState = jsonStringifyAndEscapeForInlineJS(stateByID, {\n prettyPrint,\n jsonIndent: 2\n });\n return `\n\nvar newState = ${stringifiedState};\nif(window.__hsSSInit) {\n window.__hsSSInit = Object.assign(window.__hsSSInit, newState);\n} else {\n window.__hsSSInit = newState;\n}`.replace(/\\n/gm, `\n${indentString}`);\n }\n return \"\";\n};\nfunction getIslandUrls(roots, viteDevServer) {\n return roots.map((island) => {\n const islandModule = viteDevServer.moduleGraph.getModuleById(\n island.moduleId\n );\n if (!islandModule) {\n throw new Error(`Unknown island moduleId: ${island.moduleId}`);\n }\n let wrapperModule;\n if (island.wrapperModuleId) {\n wrapperModule = viteDevServer.moduleGraph.getModuleById(\n island.wrapperModuleId\n );\n }\n const tweakedIsland = {\n ...island,\n url: islandModule.url,\n wrapperUrl: wrapperModule ? wrapperModule.url : void 0\n };\n return tweakedIsland;\n });\n}\nfunction getPerServerRequestUrls(perServerRequestData, viteDevServer) {\n if (!perServerRequestData.has(\"sharedStateIDs\")) {\n return new Map(perServerRequestData);\n }\n const perServerRequestDataWithUrls = new Map(\n perServerRequestData\n );\n perServerRequestData.get(\"sharedStateIDs\").forEach((id) => {\n const reducer = perServerRequestData.get(id);\n if (reducer.reducerFuncModuleId) {\n const reducerWithUrl = {\n ...reducer,\n reducerFuncModuleUrl: viteDevServer.moduleGraph.getModuleById(\n reducer.reducerFuncModuleId\n ).url\n };\n perServerRequestDataWithUrls.set(id, reducerWithUrl);\n }\n });\n return perServerRequestDataWithUrls;\n}\nconst createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {\n const islands = getIslandUrls(roots, viteDevServer);\n const perServerRequestDataWithUrls = getPerServerRequestUrls(\n perServerRequestData,\n viteDevServer\n );\n return `${\" \".repeat(\n indent\n )}window.__islands = ${serializeIslandDataForInlineScript(\n islands,\n perServerRequestData,\n indent,\n prettyPrint\n )}${writeSharedStateToJsGlobal(\n islands,\n perServerRequestDataWithUrls,\n indent,\n prettyPrint\n )}`;\n};\nfunction noncePlaceholderPlugin() {\n const HS_DEPLOYED = process.env.AWS_EXECUTION_ENV != null || process.env.HS_DEPLOYED === \"true\";\n return {\n name: \"hs-nonce-placeholder\",\n enforce: \"post\",\n apply() {\n return HS_DEPLOYED;\n },\n transformIndexHtml(html) {\n const regex = /<(style|script|link) (.*)>/gi;\n const replacer = (_, p1, p2) => {\n if (p1 === \"style\" || p1 === \"script\" || // if link, only nonce for stylesheet\n p1 === \"link\" && p2.includes('rel=\"stylesheet\"')) {\n const noncePlaceholderValue = p1 === \"script\" ? \"hs-random-nonce\" : \"hs-random-style-nonce\";\n p2 = `nonce=\"${noncePlaceholderValue}\" ${p2}`;\n }\n return `<${p1} ${p2}>`;\n };\n return html.replace(regex, replacer);\n }\n };\n}\nconst traverse = _traverse.default;\nconst CMS_MODULE_COMPONENT_NAME = \"UnstableModule\";\nfunction findCmsModules(cmsModules = {}) {\n let config;\n return {\n enforce: \"pre\",\n name: \"findCmsModules\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n transform(code, id) {\n const moduleInfo = this.getModuleInfo(id);\n const isExternal = config.command === \"serve\" ? false : moduleInfo.isExternal;\n if (isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME)) {\n return null;\n }\n const localCmsModules = {};\n const sourceAst = parser.parse(code, {\n sourceType: \"module\",\n plugins: [\"jsx\", \"typescript\"]\n });\n let unstableModuleLocalName = CMS_MODULE_COMPONENT_NAME;\n const pluginError = this.error.bind(this);\n traverse(sourceAst, {\n ImportDeclaration(path) {\n if (!t.isStringLiteral(path.node.source, {\n value: \"@hubspot/cms-components\"\n })) {\n return null;\n }\n for (const specifier of path.node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {\n name: CMS_MODULE_COMPONENT_NAME\n })) {\n unstableModuleLocalName = specifier.local.name;\n }\n }\n },\n JSXOpeningElement(path) {\n if (!t.isJSXIdentifier(path.node.name, {\n name: unstableModuleLocalName\n }) || path.node.attributes.length !== 2) {\n return null;\n }\n let cmsModuleName;\n let cmsModulePath;\n for (const prop of path.node.attributes) {\n if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: \"name\" }) && t.isStringLiteral(prop.value)) {\n cmsModuleName = prop.value.value;\n continue;\n }\n if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: \"path\" }) && t.isStringLiteral(prop.value)) {\n cmsModulePath = prop.value.value;\n continue;\n }\n pluginError(\n new Error(\n `Error: ${id.replace(config.root, \"\")}:${prop.loc.start.line} \"name\" and \"path\" must be primitive strings`\n )\n );\n }\n const cmsModuleProps = {\n name: cmsModuleName,\n path: cmsModulePath\n };\n if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {\n pluginError(\n new Error(\n `Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`\n )\n );\n }\n localCmsModules[cmsModuleProps.name] = cmsModuleProps;\n }\n });\n return {\n meta: {\n findCmsModules: localCmsModules\n }\n };\n },\n buildEnd(error) {\n if (error)\n throw error;\n const modulesWithCmsModuleUsage = Array.of(\n ...this.getModuleIds()\n ).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => this.getModuleInfo(moduleId)).filter(\n (moduleInfo) => Object.hasOwn(moduleInfo.meta, \"findCmsModules\")\n );\n const moduleToEntryPoints = {};\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n moduleToEntryPoints[moduleWithCmsModuleUsage.id] = findEntryPoints(\n this,\n moduleWithCmsModuleUsage\n );\n }\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const usageInModuleEntryPoint = moduleToEntryPoints[moduleWithCmsModuleUsage.id].find((entryPoint) => entryPoint.id.includes(\"/components/modules\"));\n if (usageInModuleEntryPoint) {\n this.error(`\n Error: <${CMS_MODULE_COMPONENT_NAME} /> can only be used in Partials.\n Module: ${usageInModuleEntryPoint.id === moduleWithCmsModuleUsage.id ? usageInModuleEntryPoint.id.replace(config.root, \"\") : `imports: ${moduleWithCmsModuleUsage.id.replace(\n config.root,\n \"\"\n )}, which`} contains a <${CMS_MODULE_COMPONENT_NAME} />\n `);\n }\n }\n const root = config.root;\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const islandsContainingCmsModuleUsage = checkModuleTreeForIslands(\n this,\n moduleWithCmsModuleUsage\n );\n if (islandsContainingCmsModuleUsage.length > 0) {\n throw new Error(`\n <${CMS_MODULE_COMPONENT_NAME} /> cannot be used within islands.\n ${formatIslandImporter(\n moduleWithCmsModuleUsage.id,\n root\n )} uses <${CMS_MODULE_COMPONENT_NAME} /> and is used by islands:\n ${islandsContainingCmsModuleUsage.map(\n (islandModuleInfo) => formatIslandImporter(islandModuleInfo.id, root)\n ).join(\", \")}\n `);\n }\n }\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const entryPoints = moduleToEntryPoints[moduleWithCmsModuleUsage.id];\n for (const entryPoint of entryPoints) {\n const relativeEntryPoint = entryPoint.id.replace(root, \"\");\n if (!Object.hasOwn(cmsModules, relativeEntryPoint)) {\n cmsModules[relativeEntryPoint] = {};\n }\n for (const [cmsModuleName, cmsModuleValue] of Object.entries(\n moduleWithCmsModuleUsage.meta.findCmsModules\n )) {\n if (Object.hasOwn(cmsModules[relativeEntryPoint], cmsModuleName)) {\n this.error(`Error: duplicate module name: ${cmsModuleName}`);\n }\n cmsModules[relativeEntryPoint][cmsModuleName] = cmsModuleValue;\n }\n }\n }\n }\n };\n}\nfunction findEntryPoints(ctx, moduleInfo) {\n if (moduleInfo.isEntry) {\n return [moduleInfo];\n }\n const result = [];\n for (const importer of moduleInfo.importers) {\n const importerModuleInfo = ctx.getModuleInfo(importer);\n const entryPoints = findEntryPoints(ctx, importerModuleInfo);\n result.push(...entryPoints);\n }\n return result;\n}\nfunction checkModuleTreeForIslands(ctx, module) {\n if (module.id.endsWith(\"?client-entry\")) {\n return [module];\n }\n const importerResults = [];\n for (const importer of module.importers) {\n const importerInfo = ctx.getModuleInfo(importer);\n const importerResult = checkModuleTreeForIslands(ctx, importerInfo);\n importerResults.push(importerResult);\n }\n return importerResults.flat();\n}\nfunction formatIslandImporter(id, root) {\n return id.replace(root, \"\").replace(\"?client-entry\", \"\");\n}\nconst promiseForNewWritableStream = () => {\n const chunks = [];\n const writableStream = new stream.Writable();\n writableStream._write = (chunk, encoding, done) => {\n chunks.push(Buffer.from(chunk));\n done();\n };\n const streamDonePromise = new Promise((resolve, reject) => {\n writableStream.on(\"error\", (error) => {\n reject(error);\n });\n writableStream._final = (done) => {\n resolve(Buffer.concat(chunks).toString(\"utf8\"));\n done();\n };\n });\n return { streamDonePromise, writableStream };\n};\nconst renderStreamToPromise = async (reactElements, options) => {\n const { streamDonePromise, writableStream } = promiseForNewWritableStream();\n const {\n pipe\n /* abort */\n } = renderToPipeableStream(reactElements, {\n ...options || {},\n onShellReady() {\n },\n onAllReady() {\n pipe(writableStream);\n if (options == null ? void 0 : options.onAllReady) {\n options.onAllReady();\n }\n }\n });\n return streamDonePromise;\n};\nconst {\n createServerRenderContextV2,\n createServerRenderContext,\n renderServerSidePropsWithAsyncLocalStoreContext\n} = cmsComponents;\nconst bootStrapRenderContext = () => {\n const renderContext = createServerRenderContextV2 ? createServerRenderContextV2(null, {\n environmentConfig: null,\n entryPointBasePath: \"\",\n supplementalFieldValues: {},\n messagesForBrowser: []\n }) : createServerRenderContext(\"\", null);\n return renderContext;\n};\nasync function renderComponentOnServer(Component, propsAndDeps, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions, getServerSideProps) {\n const { props } = propsAndDeps;\n const componentDebugName = Component.displayName || Component.name;\n const supplementalFieldValues = contextOptions == null ? void 0 : contextOptions.supplementalFieldValues;\n const messagesForBrowser = contextOptions == null ? void 0 : contextOptions.messagesForBrowser;\n const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {\n environmentConfig,\n entryPointBasePath,\n supplementalFieldValues,\n messagesForBrowser\n }) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);\n if (getServerSideProps !== void 0 && typeof getServerSideProps === \"function\") {\n const gSSPResult = await renderServerSidePropsWithAsyncLocalStoreContext(\n getServerSideProps,\n propsAndDeps,\n renderContext\n );\n if (gSSPResult) {\n props.serverSideProps = gSSPResult.serverSideProps;\n }\n }\n return renderOnServer(\n /* @__PURE__ */ jsx(Component, { ...props }),\n renderContext,\n componentDebugName,\n renderOptions\n );\n}\nasync function renderOnServer(elements, renderContext = bootStrapRenderContext(), debugName, renderOptions) {\n let html = await renderStreamToPromise(\n /* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: renderContext, children: elements }),\n renderOptions\n );\n if (renderContext.messagesForBrowser.length > 0) {\n html = `${html}${scriptTagToLogServerMessages(\n renderContext.messagesForBrowser,\n `Server messages rendering: ${debugName}`\n )}`;\n }\n return { html, renderContext };\n}\nfunction getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint, criticalDevErrors, includeNonces) {\n if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {\n prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);\n }\n const serializedJson = jsonStringifyAndEscapeForInlineJS(\n environmentConfig.toJSON(),\n { baseIndent: 6, prettyPrint }\n );\n const globals = [`window.__hsEnvConfig = ${serializedJson};`];\n if (hsServerPageUrl) {\n globals.push(\n `window.__hsServerPageUrl = ${jsonStringifyAndEscapeForInlineJS(\n hsServerPageUrl\n )};`\n );\n }\n if (hsBasePath) {\n globals.push(\n `window.__hsBasePath = ${jsonStringifyAndEscapeForInlineJS(hsBasePath)};`\n );\n }\n if (!environmentConfig.getIsDeployed() && (criticalDevErrors == null ? void 0 : criticalDevErrors.length)) {\n const firstCriticalDevError = criticalDevErrors[0];\n globals.push(`\n customElements.whenDefined('vite-error-overlay').then(() => {\n const ErrorOverlay = customElements.get('vite-error-overlay');\n const error = new Error(${jsonStringifyAndEscapeForInlineJS(\n firstCriticalDevError.message\n )});\n const overlay = new ErrorOverlay(error);\n\n document.body.appendChild(overlay);\n })\n `);\n }\n const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce=\"${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}\"` : \"\";\n return `\n <script type=\"text/javascript\"${nonceAttr}>\n ${globals.join(\"\\n \")}\n <\\/script>\n `;\n}\nfunction renderFieldsJSX(fieldsJSX) {\n let moduleJson;\n const outputCallback = (callbackJson) => {\n moduleJson = callbackJson;\n };\n renderToStaticMarkup(\n cloneElement(fieldsJSX, {\n outputCallback\n })\n );\n if (!moduleJson) {\n throw new Error(\"couldn't render module fields definition to fields.json\");\n }\n return moduleJson;\n}\nfunction renderFieldsToJson(fields, moduleName) {\n let fieldsJSON;\n try {\n if (isValidElement(fields)) {\n fieldsJSON = renderFieldsJSX(fields);\n } else if (Array.isArray(fields)) {\n fieldsJSON = fields;\n } else {\n throw new Error(\n `Couldn't recognize \\`fields\\` value for module ${moduleName}`\n );\n }\n return fieldsJSON;\n } catch (e) {\n e.message = `Error when rendering fields for ${moduleName}: ${e.message}`;\n throw e;\n }\n}\nexport {\n COMPONENT_EXTENSIONS,\n CSS_LANGS_RE,\n ENABLED_FEATURES_GATE_MAP,\n ENTRY_POINTS_PATH,\n GATES,\n MODULE_FOLDER_PATH,\n VIRTUAL_CONFIG_SETUP,\n VIRTUAL_ISLAND_RUNTIME,\n areBuildHealthChecksEnabled,\n clientIslandEntryPlugin,\n collectCssInDev,\n collectCssModules,\n createIslandsGlobalJsForClientInDev,\n doHealthChecksFailTheBuild,\n escapeForInlineJS,\n findAllComponentsIn,\n findAllModulesInRoot,\n findAllPartialsInRoot,\n findCmsModules,\n a as getBaseAssetUrlFromBuild,\n g as getBuildInfo,\n getCMSAssetConfig,\n getCMSAssetConfigIfExists,\n getCombinedReactUrl,\n getComponentExtension,\n getEntryPointHash,\n getEntryPointHashWithIndexSuffix,\n getIslandRuntimeConfigUrl,\n getIslandUrls,\n getServerGlobalsToInject,\n getServerIncludePrebundleDepPatterns,\n hasComponentExtension,\n includesHublDataReference,\n isStorybookStory,\n isStylesheetAsset,\n isUngatedFor,\n jsonStringifyAndEscapeForInlineJS,\n namespaceModulePropsShape,\n noncePlaceholderPlugin,\n removeComponentExtension,\n removeIndexFromPath,\n removeIndexOrTrailingJsFromPath,\n renderComponentOnServer,\n renderFieldsToJson,\n renderOnServer,\n renderStreamToPromise,\n resolveIslandPlugin,\n resolveIslandToPlainModuleNoopPlugin,\n resolveIslandToPlainModulePlugin,\n scriptTagToLogServerMessages,\n serializeIslandDataForInlineScript,\n setIn,\n ungatedAtBuildTimeFor,\n virtualClientRenderIslandModuleId\n};\n", "import { Plugin, ViteDevServer } from 'vite';\n\nexport default function devSecretsPlugin(secretNames: Array<string>): Plugin {\n return {\n name: 'dev-secrets',\n configureServer: {\n order: 'post',\n async handler(server: ViteDevServer) {\n const cmsComponents = await server.ssrLoadModule(\n '@hubspot/cms-components'\n );\n\n if (cmsComponents.setSecretsFromEnv) {\n console.log(\n `Attempting to load HS_* secrets from .env: ${secretNames}`\n );\n cmsComponents.setSecretsFromEnv(secretNames);\n } else if (secretNames.length > 0) {\n console.warn(\n 'Not loading secrets into the local environment. Make sure that your @hubspot/cms-components and @hubspot/cms-dev-server package versions match.'\n );\n }\n },\n },\n };\n}\n"],
5
+ "mappings": ";AAGA,SAAS,gBAAgB,wBAAsC;AAC/D,SAAS,WAAW,aAAa;;;ACJjC,OAAO,UAAU;AA2FjB,IAAI;AACJ,IAAI;AACJ,SAAS,oBAAoB,YAAY;AACvC,SAAO;AAAA,IACL,SAAS;AAAA,IACT,MAAM;AAAA,IACN,eAAe,QAAQ;AACrB,iBAAW,OAAO;AAClB,oBAAc,OAAO;AAAA,IACvB;AAAA,IACA,KAAK,IAAI;AACP,UAAI,GAA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AAA,IACA,SAAS;AAAA,MACP,OAAO,eAAe,IAAI;AAAA,MAC1B,aAAa,OAAO,EAAE,OAAO,sBAAsB,CAAC,IAAI;AAAA,MACxD,MAAM;AAAA,QACJ,OAAO;AAAA,UACL,SAAS;AAAA,YACP;AAAA,YACA;AAAA,YACA;AAAA,UACF;AAAA,QACF;AAAA,MACF,CAAC;AAAA,MACD,wBAAwB;AAAA,MACxB,oBAAoB;AAAA,MACpB,iBAAiB,SAAS,gCAAgC,IACtD,OACA,aAAa;AAAA,MACjB,iBAAiB,WAAW;AAAA,MAC5B,uBAAuB;AAAA,IACzB;AAAA,IACA,KAAK;AAAA,MACH,SAAS;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AAEA,SAAO,iBAAiB,UAAU;AACpC;AAEA,IAAO,8BAAQ;",
6
+ "names": ["path", "createServerRenderContextV2", "createServerRenderContext", "cmsComponents"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../cms-js-internal/dist/basicUtils.js", "../../cms-js-internal/dist/index.js"],
4
+ "sourcesContent": ["import path from \"path\";\nimport { createHash } from \"crypto\";\nimport fs, { readFileSync, existsSync, readdirSync, lstatSync } from \"fs\";\nimport { join } from \"path/posix\";\nconst COMPONENT_EXTENSIONS = [\".jsx\", \".tsx\", \".js\", \".ts\"];\nconst ENTRY_POINTS_PATH = \"components/partials/\";\nconst MODULE_FOLDER_PATH = \"components/modules/\";\nconst VIRTUAL_ISLAND_RUNTIME = \"virtual:island-runtime\";\nconst VIRTUAL_CONFIG_SETUP = \"virtual:config-setup\";\nconst CSS_LANGS_RE = /\\.(css|less|sass|scss|styl|stylus|pcss|postcss|sss)(?:$|\\?)/;\nconst collectCssModules = (modulePathToStartWith, viteServer, cssModulesImported = /* @__PURE__ */ new Set()) => {\n const appModulesForPath = viteServer.moduleGraph.fileToModulesMap.get(\n modulePathToStartWith\n );\n if (!appModulesForPath || appModulesForPath.size === 0) {\n throw new Error(`No modules at: ${modulePathToStartWith}`);\n } else if (appModulesForPath.size > 1) {\n throw new Error(`More than one module at: ${modulePathToStartWith}`);\n }\n const appModule = Array.from(appModulesForPath.values())[0];\n const allServerSideModulesImported = /* @__PURE__ */ new Set();\n const newCssModules = [];\n const moduleQueue = Array.from(appModule.importedModules);\n for (const importedModule of moduleQueue) {\n if (allServerSideModulesImported.has(importedModule.id)) {\n continue;\n }\n allServerSideModulesImported.add(importedModule.id);\n const isCss = CSS_LANGS_RE.test(importedModule.file);\n const moduleModulesToQueue = Array.from(importedModule.importedModules);\n if (isCss && !cssModulesImported.has(importedModule)) {\n cssModulesImported.add(importedModule);\n newCssModules.push(importedModule);\n }\n moduleQueue.push(...moduleModulesToQueue);\n }\n return newCssModules;\n};\nfunction createPreloadLink(assetPath, basePath = \"\") {\n if (assetPath && assetPath[0] !== \"/\") {\n assetPath = `/${assetPath}`;\n }\n if (assetPath.endsWith(\".js\")) {\n return `<link rel=\"modulepreload\" crossorigin href=\"${basePath}${assetPath}\">`;\n } else if (CSS_LANGS_RE.test(assetPath)) {\n return `<link rel=\"stylesheet\" href=\"${basePath}${assetPath}?css\">`;\n } else if (assetPath.endsWith(\".woff\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"font\" type=\"font/woff\" crossorigin>`;\n } else if (assetPath.endsWith(\".woff2\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"font\" type=\"font/woff2\" crossorigin>`;\n } else if (assetPath.endsWith(\".gif\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/gif\">`;\n } else if (assetPath.endsWith(\".jpg\") || assetPath.endsWith(\".jpeg\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/jpeg\">`;\n } else if (assetPath.endsWith(\".png\")) {\n return ` <link rel=\"preload\" href=\"${basePath}${assetPath}\" as=\"image\" type=\"image/png\">`;\n } else {\n throw new Error(`Unknown preload type for ${assetPath}`);\n }\n}\nconst collectCssInDev = (modulePathToStartWith, viteServer, cssModulesImported = /* @__PURE__ */ new Set()) => {\n return `${collectCssModules(\n modulePathToStartWith,\n viteServer,\n cssModulesImported\n ).map((cssModule) => createPreloadLink(cssModule.url)).join(\"\\n\")}\n`;\n};\nconst badInlineJsChars = /[\\u2028\\u2029<>/]/g;\nconst inlineJsEscapeChars = {\n \"\\u2028\": \"\\\\u2028\",\n \"\\u2029\": \"\\\\u2029\",\n \"<\": \"\\\\u003C\",\n \">\": \"\\\\u003E\",\n \"/\": \"\\\\u002F\"\n};\nfunction escapeChar(unsafeChar) {\n return inlineJsEscapeChars[unsafeChar];\n}\nfunction escapeForInlineJS(input) {\n return input.replace(badInlineJsChars, escapeChar);\n}\nfunction jsonStringifyAndEscapeForInlineJS(input, { baseIndent = 0, jsonIndent = 2, prettyPrint = true } = {}) {\n const indentString = \" \".repeat(baseIndent);\n jsonIndent = prettyPrint ? jsonIndent : void 0;\n return escapeForInlineJS(JSON.stringify(input, null, jsonIndent)).replace(\n /\\n/gm,\n `\n${indentString}`\n );\n}\nlet viteRoot;\nlet viteCommand;\nfunction resolveIslandPlugin(islandsSet) {\n return {\n enforce: \"pre\",\n name: \"resolve-islands\",\n configResolved(config) {\n viteRoot = config.root;\n viteCommand = config.command;\n },\n load(id) {\n if (id.endsWith(\"?island\") || id.endsWith(\"?client\")) {\n const [idWithNoParam] = id.split(\"?\");\n const islandModuleImportPath = `${idWithNoParam}?client-entry`;\n const componentExtension = path.extname(idWithNoParam);\n const componentFilenameWithNoExtension = path.basename(\n idWithNoParam,\n componentExtension\n );\n const modulePath = idWithNoParam.replace(`${viteRoot}/`, \"\");\n const moduleId = (viteCommand === \"serve\" ? idWithNoParam : modulePath).concat(\"?client-entry\");\n if (islandsSet) {\n islandsSet.add(moduleId);\n }\n return `\n const moduleId = '${moduleId}';\n\n const lazyComponent = () => import('${islandModuleImportPath}');\n lazyComponent.moduleName = '${componentFilenameWithNoExtension}';\n lazyComponent.moduleId = moduleId;\n\n export default lazyComponent;\n `;\n }\n return null;\n }\n };\n}\nfunction resolveIslandToPlainModulePlugin(enabled = true) {\n return {\n enforce: \"pre\",\n name: \"resolve-islands-to-plain\",\n configResolved(config) {\n viteRoot = config.root;\n viteCommand = config.command;\n },\n async resolveId(id, importer, options) {\n if (enabled && (id.endsWith(\"?island\") || id.endsWith(\"?client\"))) {\n const newId = id.replace(\"?island\", \"\").replace(\"?client\", \"\");\n const resolution = await this.resolve(newId, importer, {\n skipSelf: true,\n ...options\n });\n if (resolution) {\n return resolution;\n }\n }\n return null;\n }\n };\n}\nfunction resolveIslandToPlainModuleNoopPlugin() {\n return resolveIslandToPlainModulePlugin(false);\n}\nconst 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\";\nconst virtualClientRenderIslandModuleId = \"virtual:clientRenderIsland.tsx\";\nfunction clientIslandEntryPlugin() {\n return {\n enforce: \"pre\",\n name: \"client-island-entry-plugin\",\n resolveId(id) {\n if (id === virtualClientRenderIslandModuleId) {\n return virtualClientRenderIslandModuleId;\n }\n return null;\n },\n load(id) {\n if (id.endsWith(\"?client-entry\")) {\n const [idWithNoParam] = id.split(\"?\");\n return `\n import { clientRenderIsland } from '${virtualClientRenderIslandModuleId}';\n import Component from '${idWithNoParam}';\n\n export function render(island) {\n return clientRenderIsland(island, Component)\n }\n\n export default Component;\n `;\n }\n if (id === virtualClientRenderIslandModuleId) {\n return clientRenderIsland;\n }\n return null;\n }\n };\n}\nconst scriptTagToLogServerMessages = (messagesForBrowser, groupLabel, nonceAttribute) => {\n if (!messagesForBrowser) {\n return \"\";\n }\n const consoleLines = [];\n for (const message of messagesForBrowser) {\n let funcString = \"console.log\";\n if (message.level === \"error\") {\n funcString = \"console.error\";\n }\n if (message.level === \"warn\") {\n funcString = \"console.warn\";\n }\n const argString = message.parameters.map((arg) => JSON.stringify(arg)).join(\", \");\n consoleLines.push(` ${funcString}(${argString});`);\n }\n let groupStart = \"\";\n let groupEnd = \"\";\n if (groupLabel !== void 0 && groupLabel !== null) {\n groupStart = `\n console.group(${JSON.stringify(groupLabel)});`;\n groupEnd = ` console.groupEnd()\n`;\n }\n return `<script ${nonceAttribute}>${groupStart}\n${consoleLines.join(\"\\n\")}\n${groupEnd}<\\/script>\n`;\n};\nconst getComponentExtension = (componentPath) => {\n const filteredExtensions = COMPONENT_EXTENSIONS.filter(\n (ext) => componentPath.endsWith(ext)\n );\n if (filteredExtensions.length === 1) {\n return filteredExtensions[0];\n }\n return void 0;\n};\nconst hasComponentExtension = (componentPath) => {\n return !!getComponentExtension(componentPath);\n};\nconst isStorybookStory = (componentPath) => {\n return !!path.basename(componentPath, path.extname(componentPath)).endsWith(\".stories\");\n};\nconst removeComponentExtension = (componentPath) => {\n const ext = getComponentExtension(componentPath);\n if (ext == null) {\n return componentPath;\n }\n return componentPath.slice(0, -1 * ext.length);\n};\nfunction getEntryPointHash(entryPoint) {\n return createHash(\"md5\").update(entryPoint).digest(\"hex\").slice(0, 6);\n}\nfunction getEntryPointHashWithIndexSuffix(entryPoint, index) {\n const renderIndexSuffix = index != null ? `i${index}` : \"\";\n return `${getEntryPointHash(entryPoint)}${renderIndexSuffix}`;\n}\nconst COMBINED_REACT_BASE_PATH = \"https://static.hsappstatic.net/cms-js-static/ex/js/react/v18\";\nconst ISLAND_RUNTIME_CONFIG_BASE_PATH = \"https://static.hsappstatic.net/cms-js-static/ex/js/island-runtime/v1\";\nfunction getCombinedReactUrl() {\n const hsEnv = process.env.HS_ENV;\n const fileVersion = hsEnv === \"prod\" ? `react-combined.mjs` : \"react-combined-qa.mjs\";\n return `${COMBINED_REACT_BASE_PATH}/${fileVersion}`;\n}\nfunction getIslandRuntimeConfigUrl() {\n const hsEnv = process.env.HS_ENV;\n const fileVersion = hsEnv === \"prod\" ? `island-runtime.mjs` : \"island-runtime-qa.mjs\";\n return `${ISLAND_RUNTIME_CONFIG_BASE_PATH}/${fileVersion}`;\n}\nfunction includesHublDataReference(templateSource) {\n const hublDataPattern = /\\{%\\s+set\\s+(experimentalHublData|hublData)\\s*=/;\n return !!templateSource.match(hublDataPattern);\n}\nconst removeIndexFromPath = (id) => {\n return id.replace(/\\/index\\.[jt]sx?$/, \"\");\n};\nconst removeIndexOrTrailingJsFromPath = (id) => {\n return removeIndexFromPath(id).replace(/\\.[jt]sx?$/, \"\");\n};\nconst HEALTHCHECKS_ENABLED_DEFAULT = true;\nconst HEALTHCHECKS_STRICT_DEFAULT = false;\nfunction getCMSAssetConfig(webRoot) {\n const cmsAssetsPath = path.join(webRoot, \"cms-assets.json\");\n const cmsThemePath = path.join(webRoot, \"theme.json\");\n const configPathToUse = fs.existsSync(cmsAssetsPath) ? cmsAssetsPath : cmsThemePath;\n const parsedConfig = JSON.parse(\n fs.readFileSync(configPathToUse).toString()\n );\n return parsedConfig;\n}\nfunction getCMSAssetConfigIfExists(webRoot) {\n try {\n return getCMSAssetConfig(webRoot);\n } catch (e) {\n console.error(\n `Error finding or parsing cms-assets.json in ${webRoot}, but ignoring for now`\n );\n return {};\n }\n}\nfunction areBuildHealthChecksEnabled(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.healthchecks) == null ? void 0 : _b.enabled) ?? HEALTHCHECKS_ENABLED_DEFAULT;\n}\nfunction doHealthChecksFailTheBuild(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.healthchecks) == null ? void 0 : _b.strict) ?? HEALTHCHECKS_STRICT_DEFAULT;\n}\nfunction getServerIncludePrebundleDepPatterns(config) {\n var _a, _b;\n return ((_b = (_a = config.buildConfig) == null ? void 0 : _a.serverPrebundling) == null ? void 0 : _b.include) ?? [];\n}\nconst BUILD_INFO_PATH = \"/build-info.json\";\nfunction getBuildInfo(buildDir) {\n try {\n const buildInfo = JSON.parse(\n readFileSync(path.join(buildDir, BUILD_INFO_PATH)).toString()\n );\n return buildInfo;\n } catch (e) {\n throw new Error(`Error loading build-info.json, path: ${BUILD_INFO_PATH}`);\n }\n}\nfunction getBaseAssetUrlFromBuild(buildDir) {\n return getBuildInfo(buildDir).baseAssetUrl;\n}\nconst GATES = [\n \"CMS:JSRenderer:GetServerSideProps\",\n \"CMS:JSRenderer:ModuleHubl\",\n \"CMS:JSRenderer:RemoveCjsPlugin\",\n \"CMS:JSRenderer:RemoveMockClientEntryPlugin\",\n \"CMS:JSRenderer:AnalyzeCmsModules\"\n];\nconst ENABLED_FEATURES_GATE_MAP = {\n \"cms:jsr:getServerSideProps\": \"CMS:JSRenderer:GetServerSideProps\",\n \"cms:jsr:RemoveCjsPlugin\": \"CMS:JSRenderer:RemoveCjsPlugin\",\n \"cms:jsr:analyzeCmsModules\": \"CMS:JSRenderer:AnalyzeCmsModules\"\n};\nfunction isUngatedFor(gates, gate) {\n return gates.includes(gate);\n}\nfunction ungatedAtBuildTimeFor(buildDir, gate) {\n try {\n const buildInfo = getBuildInfo(buildDir);\n return isUngatedFor(buildInfo.gates, gate);\n } catch (e) {\n return false;\n }\n}\nconst findAllComponentsIn = (webRoot, componentsFolder) => {\n const fullComponentsFolderPath = join(webRoot, componentsFolder);\n const componentsByName = {};\n if (!existsSync(fullComponentsFolderPath)) {\n return componentsByName;\n }\n readdirSync(fullComponentsFolderPath).forEach((fileOrFolderName) => {\n const fullPath = join(fullComponentsFolderPath, fileOrFolderName);\n const subdirPath = join(componentsFolder, fileOrFolderName);\n const isDirectory = lstatSync(fullPath).isDirectory();\n if (!isDirectory && hasComponentExtension(fileOrFolderName) && !isStorybookStory(fileOrFolderName)) {\n const subdirPathNoExtension = removeComponentExtension(subdirPath);\n componentsByName[subdirPathNoExtension] = subdirPath;\n } else if (isDirectory) {\n for (const potentialExtension of COMPONENT_EXTENSIONS) {\n const potentialIndexModule = join(\n subdirPath,\n `index${potentialExtension}`\n );\n const fullPotentialPath = join(\n fullPath,\n `index${potentialExtension}`\n );\n if (existsSync(fullPotentialPath)) {\n const moduleIndexPathNoExtension = removeComponentExtension(potentialIndexModule);\n componentsByName[moduleIndexPathNoExtension] = potentialIndexModule;\n break;\n }\n }\n }\n });\n return componentsByName;\n};\nfunction findAllModulesInRoot(webRoot) {\n const allModuleComponents = findAllComponentsIn(\n webRoot,\n \"./components/modules\"\n );\n const moduleNames = Object.keys(allModuleComponents).map(\n (moduleSubpath) => moduleSubpath.replace(\"components/modules/\", \"\").replace(\"/index\", \"\")\n );\n const moduleSubpaths = Object.keys(allModuleComponents);\n return { moduleNames, moduleSubpaths };\n}\nfunction findAllPartialsInRoot(webRoot) {\n const allPartialComponents = findAllComponentsIn(\n webRoot,\n \"./components/partials\"\n );\n const partialNames = Object.keys(allPartialComponents).map(\n (partialSubpath) => partialSubpath.replace(\"components/partials/\", \"\").replace(\"/index\", \"\")\n );\n const partialSubpaths = Object.keys(allPartialComponents);\n return { partialNames, partialSubpaths };\n}\nfunction namespaceModulePropsShape(props) {\n const {\n dataQueryResult,\n hublParameters,\n fieldValues: passedFieldValues,\n hublData,\n experimentalHublData,\n moduleName,\n supplementalFieldValues\n } = props;\n const oldPropsShape = { ...props };\n if (oldPropsShape.dataQueryResult) {\n delete oldPropsShape.dataQueryResult;\n }\n if (oldPropsShape.hublParameters) {\n delete oldPropsShape.hublParameters;\n }\n const fieldValues = passedFieldValues || oldPropsShape;\n return {\n ...fieldValues,\n dataQueryResult,\n fieldValues,\n hublParameters,\n hublData,\n experimentalHublData,\n moduleName,\n supplementalFieldValues\n };\n}\nfunction setIn(object, nestedKeysArray, value) {\n let curr = object;\n const finalKey = nestedKeysArray.pop();\n for (let index = 0; index < nestedKeysArray.length; index++) {\n const currentKey = nestedKeysArray[index];\n const nextKey = nestedKeysArray[index + 1];\n if (Number.isInteger(nextKey) || !nextKey && Number.isInteger(finalKey)) {\n if (curr[currentKey] === void 0) {\n curr[currentKey] = [];\n }\n }\n if (curr[currentKey] === void 0) {\n curr[currentKey] = {};\n }\n curr = curr[currentKey];\n }\n if (value !== void 0) {\n curr[finalKey] = value;\n }\n}\nfunction isStylesheetAsset(staticAsset) {\n return staticAsset.type === \"stylesheet\";\n}\nexport {\n COMPONENT_EXTENSIONS,\n CSS_LANGS_RE,\n ENABLED_FEATURES_GATE_MAP,\n ENTRY_POINTS_PATH,\n GATES,\n MODULE_FOLDER_PATH,\n VIRTUAL_CONFIG_SETUP,\n VIRTUAL_ISLAND_RUNTIME,\n getBaseAssetUrlFromBuild as a,\n areBuildHealthChecksEnabled,\n clientIslandEntryPlugin,\n collectCssInDev,\n collectCssModules,\n doHealthChecksFailTheBuild,\n escapeForInlineJS,\n findAllComponentsIn,\n findAllModulesInRoot,\n findAllPartialsInRoot,\n getBuildInfo as g,\n getCMSAssetConfig,\n getCMSAssetConfigIfExists,\n getCombinedReactUrl,\n getComponentExtension,\n getEntryPointHash,\n getEntryPointHashWithIndexSuffix,\n getIslandRuntimeConfigUrl,\n getServerIncludePrebundleDepPatterns,\n hasComponentExtension,\n includesHublDataReference,\n isStorybookStory,\n isStylesheetAsset,\n isUngatedFor,\n jsonStringifyAndEscapeForInlineJS,\n namespaceModulePropsShape,\n removeComponentExtension,\n removeIndexFromPath,\n removeIndexOrTrailingJsFromPath,\n resolveIslandPlugin,\n resolveIslandToPlainModuleNoopPlugin,\n resolveIslandToPlainModulePlugin,\n scriptTagToLogServerMessages,\n setIn,\n ungatedAtBuildTimeFor,\n virtualClientRenderIslandModuleId\n};\n", "import { jsonStringifyAndEscapeForInlineJS, scriptTagToLogServerMessages } from \"./basicUtils.js\";\nimport { COMPONENT_EXTENSIONS, CSS_LANGS_RE, ENABLED_FEATURES_GATE_MAP, ENTRY_POINTS_PATH, GATES, MODULE_FOLDER_PATH, VIRTUAL_CONFIG_SETUP, VIRTUAL_ISLAND_RUNTIME, areBuildHealthChecksEnabled, clientIslandEntryPlugin, collectCssInDev, collectCssModules, doHealthChecksFailTheBuild, escapeForInlineJS, findAllComponentsIn, findAllModulesInRoot, findAllPartialsInRoot, a, g, getCMSAssetConfig, getCMSAssetConfigIfExists, getCombinedReactUrl, getComponentExtension, getEntryPointHash, getEntryPointHashWithIndexSuffix, getIslandRuntimeConfigUrl, getServerIncludePrebundleDepPatterns, hasComponentExtension, includesHublDataReference, isStorybookStory, isStylesheetAsset, isUngatedFor, namespaceModulePropsShape, removeComponentExtension, removeIndexFromPath, removeIndexOrTrailingJsFromPath, resolveIslandPlugin, resolveIslandToPlainModuleNoopPlugin, resolveIslandToPlainModulePlugin, setIn, ungatedAtBuildTimeFor, virtualClientRenderIslandModuleId } from \"./basicUtils.js\";\nimport * as dotProp from \"dot-prop\";\nimport * as parser from \"@babel/parser\";\nimport _traverse from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport { jsx } from \"react/jsx-runtime\";\nimport stream from \"stream\";\nimport { renderToPipeableStream, renderToStaticMarkup } from \"react-dom/server\";\nimport * as cmsComponents from \"@hubspot/cms-components\";\nimport { ServerRenderContext } from \"@hubspot/cms-components\";\nimport { isValidElement, cloneElement } from \"react\";\nimport \"path\";\nimport \"crypto\";\nimport \"fs\";\nimport \"path/posix\";\nconst { setProperty, getProperty, hasProperty } = dotProp;\nconst serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {\n const islandsArrayToSerialize = tweakedIslandsArray.map(\n ({\n id,\n moduleName,\n moduleId,\n props,\n hydrateOn,\n clientOnly,\n priority,\n url,\n sharedStateID,\n supplementalFieldValues,\n wrapperModuleId,\n wrapperUrl\n }) => {\n const output = {\n id,\n moduleName,\n moduleId,\n hydrateOn,\n clientOnly,\n priority,\n props,\n url\n };\n if (sharedStateID) {\n output.sharedStateID = sharedStateID;\n }\n if (wrapperModuleId) {\n output.wrapperModuleId = wrapperModuleId;\n }\n if (wrapperUrl) {\n output.wrapperUrl = wrapperUrl;\n }\n const filteredSupplementalFieldValues = filterOutUnreadSupplementalFieldValues(\n supplementalFieldValues,\n perServerRequestData.get(\"supplementalFieldValuesRead\")\n );\n if (filteredSupplementalFieldValues) {\n output.supplementalFieldValues = filteredSupplementalFieldValues;\n }\n return output;\n }\n );\n return jsonStringifyAndEscapeForInlineJS(islandsArrayToSerialize, {\n baseIndent,\n jsonIndent: 2,\n prettyPrint\n });\n};\nfunction filterOutUnreadSupplementalFieldValues(supplementalFieldValues, supplementalFieldValuesRead) {\n if (!supplementalFieldValues) {\n return supplementalFieldValues;\n }\n if (!supplementalFieldValuesRead) {\n return supplementalFieldValues;\n }\n const result = {};\n Array.from(supplementalFieldValuesRead).forEach((fieldPath) => {\n if (hasProperty(supplementalFieldValues, fieldPath)) {\n setProperty(\n result,\n fieldPath,\n getProperty(supplementalFieldValues, fieldPath)\n );\n }\n });\n return result;\n}\nconst writeSharedStateToJsGlobal = (islands, perServerRequestData, indent = 0, prettyPrint) => {\n const sharedStateIDs = islands.map((island) => island.sharedStateID).filter((x) => !!x);\n if (sharedStateIDs.length > 0) {\n const indentString = \" \".repeat(indent);\n const stateByID = {};\n sharedStateIDs.forEach(\n (id) => stateByID[id] = perServerRequestData.get(id)\n );\n const stringifiedState = jsonStringifyAndEscapeForInlineJS(stateByID, {\n prettyPrint,\n jsonIndent: 2\n });\n return `\n\nvar newState = ${stringifiedState};\nif(window.__hsSSInit) {\n window.__hsSSInit = Object.assign(window.__hsSSInit, newState);\n} else {\n window.__hsSSInit = newState;\n}`.replace(/\\n/gm, `\n${indentString}`);\n }\n return \"\";\n};\nfunction getIslandUrls(roots, viteDevServer) {\n return roots.map((island) => {\n const islandModule = viteDevServer.moduleGraph.getModuleById(\n island.moduleId\n );\n if (!islandModule) {\n throw new Error(`Unknown island moduleId: ${island.moduleId}`);\n }\n let wrapperModule;\n if (island.wrapperModuleId) {\n wrapperModule = viteDevServer.moduleGraph.getModuleById(\n island.wrapperModuleId\n );\n }\n const tweakedIsland = {\n ...island,\n url: islandModule.url,\n wrapperUrl: wrapperModule ? wrapperModule.url : void 0\n };\n return tweakedIsland;\n });\n}\nfunction getPerServerRequestUrls(perServerRequestData, viteDevServer) {\n if (!perServerRequestData.has(\"sharedStateIDs\")) {\n return new Map(perServerRequestData);\n }\n const perServerRequestDataWithUrls = new Map(\n perServerRequestData\n );\n perServerRequestData.get(\"sharedStateIDs\").forEach((id) => {\n const reducer = perServerRequestData.get(id);\n if (reducer.reducerFuncModuleId) {\n const reducerWithUrl = {\n ...reducer,\n reducerFuncModuleUrl: viteDevServer.moduleGraph.getModuleById(\n reducer.reducerFuncModuleId\n ).url\n };\n perServerRequestDataWithUrls.set(id, reducerWithUrl);\n }\n });\n return perServerRequestDataWithUrls;\n}\nconst createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {\n const islands = getIslandUrls(roots, viteDevServer);\n const perServerRequestDataWithUrls = getPerServerRequestUrls(\n perServerRequestData,\n viteDevServer\n );\n return `${\" \".repeat(\n indent\n )}window.__islands = ${serializeIslandDataForInlineScript(\n islands,\n perServerRequestData,\n indent,\n prettyPrint\n )}${writeSharedStateToJsGlobal(\n islands,\n perServerRequestDataWithUrls,\n indent,\n prettyPrint\n )}`;\n};\nfunction noncePlaceholderPlugin() {\n const HS_DEPLOYED = process.env.AWS_EXECUTION_ENV != null || process.env.HS_DEPLOYED === \"true\";\n return {\n name: \"hs-nonce-placeholder\",\n enforce: \"post\",\n apply() {\n return HS_DEPLOYED;\n },\n transformIndexHtml(html) {\n const regex = /<(style|script|link) (.*)>/gi;\n const replacer = (_, p1, p2) => {\n if (p1 === \"style\" || p1 === \"script\" || // if link, only nonce for stylesheet\n p1 === \"link\" && p2.includes('rel=\"stylesheet\"')) {\n const noncePlaceholderValue = p1 === \"script\" ? \"hs-random-nonce\" : \"hs-random-style-nonce\";\n p2 = `nonce=\"${noncePlaceholderValue}\" ${p2}`;\n }\n return `<${p1} ${p2}>`;\n };\n return html.replace(regex, replacer);\n }\n };\n}\nconst traverse = _traverse.default;\nconst CMS_MODULE_COMPONENT_NAME = \"UnstableModule\";\nfunction findCmsModules(cmsModules = {}) {\n let config;\n return {\n enforce: \"pre\",\n name: \"findCmsModules\",\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n },\n transform(code, id) {\n const moduleInfo = this.getModuleInfo(id);\n const isExternal = config.command === \"serve\" ? false : moduleInfo.isExternal;\n if (isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME)) {\n return null;\n }\n const localCmsModules = {};\n const sourceAst = parser.parse(code, {\n sourceType: \"module\",\n plugins: [\"jsx\", \"typescript\"]\n });\n let unstableModuleLocalName = CMS_MODULE_COMPONENT_NAME;\n const pluginError = this.error.bind(this);\n traverse(sourceAst, {\n ImportDeclaration(path) {\n if (!t.isStringLiteral(path.node.source, {\n value: \"@hubspot/cms-components\"\n })) {\n return null;\n }\n for (const specifier of path.node.specifiers) {\n if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {\n name: CMS_MODULE_COMPONENT_NAME\n })) {\n unstableModuleLocalName = specifier.local.name;\n }\n }\n },\n JSXOpeningElement(path) {\n if (!t.isJSXIdentifier(path.node.name, {\n name: unstableModuleLocalName\n }) || path.node.attributes.length !== 2) {\n return null;\n }\n let cmsModuleName;\n let cmsModulePath;\n for (const prop of path.node.attributes) {\n if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: \"name\" }) && t.isStringLiteral(prop.value)) {\n cmsModuleName = prop.value.value;\n continue;\n }\n if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: \"path\" }) && t.isStringLiteral(prop.value)) {\n cmsModulePath = prop.value.value;\n continue;\n }\n pluginError(\n new Error(\n `Error: ${id.replace(config.root, \"\")}:${prop.loc.start.line} \"name\" and \"path\" must be primitive strings`\n )\n );\n }\n const cmsModuleProps = {\n name: cmsModuleName,\n path: cmsModulePath\n };\n if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {\n pluginError(\n new Error(\n `Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`\n )\n );\n }\n localCmsModules[cmsModuleProps.name] = cmsModuleProps;\n }\n });\n return {\n meta: {\n findCmsModules: localCmsModules\n }\n };\n },\n buildEnd(error) {\n if (error)\n throw error;\n const modulesWithCmsModuleUsage = Array.of(\n ...this.getModuleIds()\n ).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => this.getModuleInfo(moduleId)).filter(\n (moduleInfo) => Object.hasOwn(moduleInfo.meta, \"findCmsModules\")\n );\n const moduleToEntryPoints = {};\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n moduleToEntryPoints[moduleWithCmsModuleUsage.id] = findEntryPoints(\n this,\n moduleWithCmsModuleUsage\n );\n }\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const usageInModuleEntryPoint = moduleToEntryPoints[moduleWithCmsModuleUsage.id].find((entryPoint) => entryPoint.id.includes(\"/components/modules\"));\n if (usageInModuleEntryPoint) {\n this.error(`\n Error: <${CMS_MODULE_COMPONENT_NAME} /> can only be used in Partials.\n Module: ${usageInModuleEntryPoint.id === moduleWithCmsModuleUsage.id ? usageInModuleEntryPoint.id.replace(config.root, \"\") : `imports: ${moduleWithCmsModuleUsage.id.replace(\n config.root,\n \"\"\n )}, which`} contains a <${CMS_MODULE_COMPONENT_NAME} />\n `);\n }\n }\n const root = config.root;\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const islandsContainingCmsModuleUsage = checkModuleTreeForIslands(\n this,\n moduleWithCmsModuleUsage\n );\n if (islandsContainingCmsModuleUsage.length > 0) {\n throw new Error(`\n <${CMS_MODULE_COMPONENT_NAME} /> cannot be used within islands.\n ${formatIslandImporter(\n moduleWithCmsModuleUsage.id,\n root\n )} uses <${CMS_MODULE_COMPONENT_NAME} /> and is used by islands:\n ${islandsContainingCmsModuleUsage.map(\n (islandModuleInfo) => formatIslandImporter(islandModuleInfo.id, root)\n ).join(\", \")}\n `);\n }\n }\n for (const moduleWithCmsModuleUsage of modulesWithCmsModuleUsage) {\n const entryPoints = moduleToEntryPoints[moduleWithCmsModuleUsage.id];\n for (const entryPoint of entryPoints) {\n const relativeEntryPoint = entryPoint.id.replace(root, \"\");\n if (!Object.hasOwn(cmsModules, relativeEntryPoint)) {\n cmsModules[relativeEntryPoint] = {};\n }\n for (const [cmsModuleName, cmsModuleValue] of Object.entries(\n moduleWithCmsModuleUsage.meta.findCmsModules\n )) {\n if (Object.hasOwn(cmsModules[relativeEntryPoint], cmsModuleName)) {\n this.error(`Error: duplicate module name: ${cmsModuleName}`);\n }\n cmsModules[relativeEntryPoint][cmsModuleName] = cmsModuleValue;\n }\n }\n }\n }\n };\n}\nfunction findEntryPoints(ctx, moduleInfo) {\n if (moduleInfo.isEntry) {\n return [moduleInfo];\n }\n const result = [];\n for (const importer of moduleInfo.importers) {\n const importerModuleInfo = ctx.getModuleInfo(importer);\n const entryPoints = findEntryPoints(ctx, importerModuleInfo);\n result.push(...entryPoints);\n }\n return result;\n}\nfunction checkModuleTreeForIslands(ctx, module) {\n if (module.id.endsWith(\"?client-entry\")) {\n return [module];\n }\n const importerResults = [];\n for (const importer of module.importers) {\n const importerInfo = ctx.getModuleInfo(importer);\n const importerResult = checkModuleTreeForIslands(ctx, importerInfo);\n importerResults.push(importerResult);\n }\n return importerResults.flat();\n}\nfunction formatIslandImporter(id, root) {\n return id.replace(root, \"\").replace(\"?client-entry\", \"\");\n}\nconst promiseForNewWritableStream = () => {\n const chunks = [];\n const writableStream = new stream.Writable();\n writableStream._write = (chunk, encoding, done) => {\n chunks.push(Buffer.from(chunk));\n done();\n };\n const streamDonePromise = new Promise((resolve, reject) => {\n writableStream.on(\"error\", (error) => {\n reject(error);\n });\n writableStream._final = (done) => {\n resolve(Buffer.concat(chunks).toString(\"utf8\"));\n done();\n };\n });\n return { streamDonePromise, writableStream };\n};\nconst renderStreamToPromise = async (reactElements, options) => {\n const { streamDonePromise, writableStream } = promiseForNewWritableStream();\n const {\n pipe\n /* abort */\n } = renderToPipeableStream(reactElements, {\n ...options || {},\n onShellReady() {\n },\n onAllReady() {\n pipe(writableStream);\n if (options == null ? void 0 : options.onAllReady) {\n options.onAllReady();\n }\n }\n });\n return streamDonePromise;\n};\nconst {\n createServerRenderContextV2,\n createServerRenderContext,\n renderServerSidePropsWithAsyncLocalStoreContext\n} = cmsComponents;\nconst bootStrapRenderContext = () => {\n const renderContext = createServerRenderContextV2 ? createServerRenderContextV2(null, {\n environmentConfig: null,\n entryPointBasePath: \"\",\n supplementalFieldValues: {},\n messagesForBrowser: []\n }) : createServerRenderContext(\"\", null);\n return renderContext;\n};\nasync function renderComponentOnServer(Component, propsAndDeps, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions, getServerSideProps) {\n const { props } = propsAndDeps;\n const componentDebugName = Component.displayName || Component.name;\n const supplementalFieldValues = contextOptions == null ? void 0 : contextOptions.supplementalFieldValues;\n const messagesForBrowser = contextOptions == null ? void 0 : contextOptions.messagesForBrowser;\n const renderContext = cmsComponents.createServerRenderContextV2 ? cmsComponents.createServerRenderContextV2(pageUrl, {\n environmentConfig,\n entryPointBasePath,\n supplementalFieldValues,\n messagesForBrowser\n }) : cmsComponents.createServerRenderContext(pageUrl, environmentConfig);\n if (getServerSideProps !== void 0 && typeof getServerSideProps === \"function\") {\n const gSSPResult = await renderServerSidePropsWithAsyncLocalStoreContext(\n getServerSideProps,\n propsAndDeps,\n renderContext\n );\n if (gSSPResult) {\n props.serverSideProps = gSSPResult.serverSideProps;\n }\n }\n return renderOnServer(\n /* @__PURE__ */ jsx(Component, { ...props }),\n renderContext,\n componentDebugName,\n renderOptions\n );\n}\nasync function renderOnServer(elements, renderContext = bootStrapRenderContext(), debugName, renderOptions) {\n let html = await renderStreamToPromise(\n /* @__PURE__ */ jsx(ServerRenderContext.Provider, { value: renderContext, children: elements }),\n renderOptions\n );\n if (renderContext.messagesForBrowser.length > 0) {\n html = `${html}${scriptTagToLogServerMessages(\n renderContext.messagesForBrowser,\n `Server messages rendering: ${debugName}`\n )}`;\n }\n return { html, renderContext };\n}\nfunction getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint, criticalDevErrors, includeNonces) {\n if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {\n prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);\n }\n const serializedJson = jsonStringifyAndEscapeForInlineJS(\n environmentConfig.toJSON(),\n { baseIndent: 6, prettyPrint }\n );\n const globals = [`window.__hsEnvConfig = ${serializedJson};`];\n if (hsServerPageUrl) {\n globals.push(\n `window.__hsServerPageUrl = ${jsonStringifyAndEscapeForInlineJS(\n hsServerPageUrl\n )};`\n );\n }\n if (hsBasePath) {\n globals.push(\n `window.__hsBasePath = ${jsonStringifyAndEscapeForInlineJS(hsBasePath)};`\n );\n }\n if (!environmentConfig.getIsDeployed() && (criticalDevErrors == null ? void 0 : criticalDevErrors.length)) {\n const firstCriticalDevError = criticalDevErrors[0];\n globals.push(`\n customElements.whenDefined('vite-error-overlay').then(() => {\n const ErrorOverlay = customElements.get('vite-error-overlay');\n const error = new Error(${jsonStringifyAndEscapeForInlineJS(\n firstCriticalDevError.message\n )});\n const overlay = new ErrorOverlay(error);\n\n document.body.appendChild(overlay);\n })\n `);\n }\n const nonceAttr = includeNonces && cmsComponents.SCRIPT_NONCE_PLACEHOLDER ? ` nonce=\"${cmsComponents.SCRIPT_NONCE_PLACEHOLDER}\"` : \"\";\n return `\n <script type=\"text/javascript\"${nonceAttr}>\n ${globals.join(\"\\n \")}\n <\\/script>\n `;\n}\nfunction renderFieldsJSX(fieldsJSX) {\n let moduleJson;\n const outputCallback = (callbackJson) => {\n moduleJson = callbackJson;\n };\n renderToStaticMarkup(\n cloneElement(fieldsJSX, {\n outputCallback\n })\n );\n if (!moduleJson) {\n throw new Error(\"couldn't render module fields definition to fields.json\");\n }\n return moduleJson;\n}\nfunction renderFieldsToJson(fields, moduleName) {\n let fieldsJSON;\n try {\n if (isValidElement(fields)) {\n fieldsJSON = renderFieldsJSX(fields);\n } else if (Array.isArray(fields)) {\n fieldsJSON = fields;\n } else {\n throw new Error(\n `Couldn't recognize \\`fields\\` value for module ${moduleName}`\n );\n }\n return fieldsJSON;\n } catch (e) {\n e.message = `Error when rendering fields for ${moduleName}: ${e.message}`;\n throw e;\n }\n}\nexport {\n COMPONENT_EXTENSIONS,\n CSS_LANGS_RE,\n ENABLED_FEATURES_GATE_MAP,\n ENTRY_POINTS_PATH,\n GATES,\n MODULE_FOLDER_PATH,\n VIRTUAL_CONFIG_SETUP,\n VIRTUAL_ISLAND_RUNTIME,\n areBuildHealthChecksEnabled,\n clientIslandEntryPlugin,\n collectCssInDev,\n collectCssModules,\n createIslandsGlobalJsForClientInDev,\n doHealthChecksFailTheBuild,\n escapeForInlineJS,\n findAllComponentsIn,\n findAllModulesInRoot,\n findAllPartialsInRoot,\n findCmsModules,\n a as getBaseAssetUrlFromBuild,\n g as getBuildInfo,\n getCMSAssetConfig,\n getCMSAssetConfigIfExists,\n getCombinedReactUrl,\n getComponentExtension,\n getEntryPointHash,\n getEntryPointHashWithIndexSuffix,\n getIslandRuntimeConfigUrl,\n getIslandUrls,\n getServerGlobalsToInject,\n getServerIncludePrebundleDepPatterns,\n hasComponentExtension,\n includesHublDataReference,\n isStorybookStory,\n isStylesheetAsset,\n isUngatedFor,\n jsonStringifyAndEscapeForInlineJS,\n namespaceModulePropsShape,\n noncePlaceholderPlugin,\n removeComponentExtension,\n removeIndexFromPath,\n removeIndexOrTrailingJsFromPath,\n renderComponentOnServer,\n renderFieldsToJson,\n renderOnServer,\n renderStreamToPromise,\n resolveIslandPlugin,\n resolveIslandToPlainModuleNoopPlugin,\n resolveIslandToPlainModulePlugin,\n scriptTagToLogServerMessages,\n serializeIslandDataForInlineScript,\n setIn,\n ungatedAtBuildTimeFor,\n virtualClientRenderIslandModuleId\n};\n"],
5
+ "mappings": ";AAAA,OAAO,UAAU;AACjB,SAAS,kBAAkB;AAC3B,OAAO,MAAM,cAAc,YAAY,aAAa,iBAAiB;AACrE,SAAS,YAAY;AACrB,IAAM,uBAAuB,CAAC,QAAQ,QAAQ,OAAO,KAAK;AAC1D,IAAM,oBAAoB;AAC1B,IAAM,qBAAqB;AAC3B,IAAM,yBAAyB;AAC/B,IAAM,uBAAuB;AAC7B,IAAM,eAAe;AACrB,IAAM,oBAAoB,CAAC,uBAAuB,YAAY,qBAAqC,oBAAI,IAAI,MAAM;AAC/G,QAAM,oBAAoB,WAAW,YAAY,iBAAiB;AAAA,IAChE;AAAA,EACF;AACA,MAAI,CAAC,qBAAqB,kBAAkB,SAAS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;AACA,QAAM,YAAY,iBAA+B,yCAA2B,WAAyB,4CAA8B;AACnI,SAAO;AAAA,oCAC2B;AAAA,QAC5B,QAAQ,KAAK,UAAU;AAAA;AAAA;AAG/B;AACA,SAAS,gBAAgB,WAAW;AAClC,MAAI;AACJ,QAAM,iBAAiB,CAAC,iBAAiB;AACvC,iBAAa;AAAA,EACf;AACA;AAAA,IACE,aAAa,WAAW;AAAA,MACtB;AAAA,IACF,CAAC;AAAA,EACH;AACA,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AACA,SAAO;AACT;AACA,SAAS,mBAAmB,QAAQ,YAAY;AAC9C,MAAI;AACJ,MAAI;AACF,QAAI,eAAe,MAAM,GAAG;AAC1B,mBAAa,gBAAgB,MAAM;AAAA,IACrC,WAAW,MAAM,QAAQ,MAAM,GAAG;AAChC,mBAAa;AAAA,IACf,OAAO;AACL,YAAM,IAAI;AAAA,QACR,kDAAkD;AAAA,MACpD;AAAA,IACF;AACA,WAAO;AAAA,EACT,SAAS,GAAP;AACA,MAAE,UAAU,mCAAmC,eAAe,EAAE;AAChE,UAAM;AAAA,EACR;AACF;",
6
+ "names": ["path", "createServerRenderContextV2", "createServerRenderContext"]
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../cms-js-internal/dist/island-runtime/island-runtime.js"],
4
+ "sourcesContent": ["const 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};\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(\n root,\n getLoadableModuleFor(root),\n root.wrapperUrl ? getLoadableModuleFor({\n url: root.wrapperUrl,\n id: `${root.id}-wrapper`,\n moduleName: `${root.moduleName}-wrapper`\n }) : void 0\n );\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, WrapperModule } = rootAndExtraInfo;\n if (window.location.search.includes(\"hsDebug=\")) {\n console.log(\"Hydrating root\", root.id, root.hydrateOn);\n }\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 WrapperModule: WrapperModule ? WrapperModule.default : void 0,\n index: rootAndExtraInfo.islandScheduledIndex\n };\n const reactRoot = IslandModule.render(renderableIsland);\n rootsById.set(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, LoadableWrapperModule, rootEl, islandScheduledIndex) {\n Promise.all([\n LoadableIslandModule(),\n LoadableWrapperModule ? LoadableWrapperModule() : Promise.resolve()\n ]).then(\n ([IslandModule, WrapperModule]) => {\n pushToHydrationQueue({\n rootEl,\n root,\n IslandModule,\n WrapperModule,\n islandScheduledIndex\n });\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, LoadableWrapperModule) {\n const rootEl = document.getElementById(root.id);\n const islandScheduledIndex = scheduledHydrationIndexCtr;\n scheduledHydrationIndexCtr += 1;\n if (root.hydrateOn === \"visible\") {\n onVisible(rootEl, () => {\n loadThenHydrate(\n root,\n LoadableIslandModule,\n LoadableWrapperModule,\n rootEl,\n islandScheduledIndex\n );\n });\n } else {\n loadThenHydrate(\n root,\n LoadableIslandModule,\n LoadableWrapperModule,\n rootEl,\n islandScheduledIndex\n );\n }\n}\nfunction getLoadableModuleFor(root) {\n let url = root.url;\n if (root.url.startsWith(\"/\") && !root.url.startsWith(\"//\") && window.location.search.includes(\"hsDebugOverridePublicHost=\")) {\n const currentUrl = new URL(window.location.toString());\n url = `${currentUrl.protocol}//${currentUrl.searchParams.get(\n \"hsDebugOverridePublicHost\"\n )}${root.url}`;\n } else if (!root.url.startsWith(\"https://\") && !root.url.startsWith(\"http://\") && !root.url.startsWith(\"//\")) {\n url = `${window.location.origin}${root.url}`;\n }\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 if (window.location.search.includes(\"hsDebug=\")) {\n console.log(\"Starting to hydrate\", rootsToProcess);\n }\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(\n root,\n getLoadableModuleFor(root),\n root.wrapperUrl ? getLoadableModuleFor({\n url: root.wrapperUrl,\n id: `${root.id}-wrapper`,\n moduleName: `${root.moduleName}-wrapper`\n }) : void 0\n );\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(\n (island) => island.id === islandId\n );\n if (!islandToUnmount || !rootsById.get(islandId)) {\n throw new Error(`No known island: ${islandId}`);\n }\n const islandIndex = rootsToProcess.indexOf(islandToUnmount);\n const reactRoot = rootsById.get(islandId);\n rootsToProcess.splice(islandIndex, 1);\n rootsById.delete(islandId);\n console.log(\"Unmounting island:\", islandId);\n reactRoot.unmount();\n}\nexport {\n setupIslandHydration,\n unmountIsland\n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AM,YAAY,UAAU,IAAI,QAAQ;AACxC,iBAAe,OAAO,aAAa,CAAC;AACpC,YAAU,OAAO,QAAQ;AACzB,UAAQ,IAAI,sBAAsB,QAAQ;AAC1C,YAAU,QAAQ;AACpB;",
6
+ "names": []
7
+ }
package/dist/run.js CHANGED
@@ -675,6 +675,7 @@ function getDevServerCommandLineOptions(argv) {
675
675
  const storybook2 = args.findIndex((arg) => arg === "--storybook") > 0;
676
676
  const fieldGenEnabledOption2 = args.includes("--generateFieldsTypes");
677
677
  const resetSession2 = args.includes("--resetSession");
678
+ const fieldBuilderEnabled2 = args.includes("--fieldBuilderEnabled");
678
679
  return {
679
680
  hubspotCliConfigPathOption: hubspotCliConfigPathOption2,
680
681
  hubspotCliAccountNameOption: hubspotCliAccountNameOption2,
@@ -682,7 +683,8 @@ function getDevServerCommandLineOptions(argv) {
682
683
  storybook: storybook2,
683
684
  fieldGenEnabledOption: fieldGenEnabledOption2,
684
685
  webRoot: webRoot2,
685
- resetSession: resetSession2
686
+ resetSession: resetSession2,
687
+ fieldBuilderEnabled: fieldBuilderEnabled2
686
688
  };
687
689
  }
688
690
  async function buildThemePreviewOptions(webRoot2, isUsingLocalWorkspace = false) {
@@ -762,7 +764,7 @@ import express2 from "express";
762
764
  import http3 from "http";
763
765
  import bodyParser from "body-parser";
764
766
  import { spawn as spawn2 } from "child_process";
765
- import { normalizePath as normalizePath9 } from "vite";
767
+ import { normalizePath as normalizePath10 } from "vite";
766
768
  import { Transform } from "stream";
767
769
 
768
770
  // src/routes/createDevServerRoutes.ts
@@ -775,7 +777,7 @@ import { createProxyMiddleware } from "http-proxy-middleware";
775
777
 
776
778
  // src/routes/partial.ts
777
779
  import path8 from "path";
778
- import { normalizePath as normalizePath4 } from "vite";
780
+ import { normalizePath as normalizePath5 } from "vite";
779
781
 
780
782
  // src/lib/fullOriginalUrlFromRequest.ts
781
783
  function fullOriginalUrlFromRequest(request2) {
@@ -2095,7 +2097,7 @@ function trackUsage(action) {
2095
2097
  eventName: EVENT_NAME,
2096
2098
  action,
2097
2099
  nodeVersion: getNodeVersionData(),
2098
- version: "1.0.4",
2100
+ version: "1.0.6",
2099
2101
  os: getPlatform()
2100
2102
  };
2101
2103
  const url3 = isAuthedWithPersonalAccessKey ? DEV_SERVER_USAGE_ENDPOINT_AUTHENTICATED : DEV_SERVER_USAGE_ENDPOINT;
@@ -2136,7 +2138,7 @@ function sendTrackingRequest(action) {
2136
2138
  // src/lib/renderModulePreview.ts
2137
2139
  import { buildStaticEnvConfig as buildStaticEnvConfig2 } from "@hubspot/cms-components";
2138
2140
  import path7 from "path";
2139
- import { normalizePath as normalizePath3 } from "vite";
2141
+ import { normalizePath as normalizePath4 } from "vite";
2140
2142
 
2141
2143
  // src/lib/proxyHelpers.ts
2142
2144
  import fs3 from "fs";
@@ -2237,7 +2239,7 @@ var getProjectNameFromHSConfig = (hsProjectConfigPath) => {
2237
2239
 
2238
2240
  // src/proxyPage/proxyPage.ts
2239
2241
  import path6 from "path";
2240
- import { normalizePath as normalizePath2 } from "vite";
2242
+ import { normalizePath as normalizePath3 } from "vite";
2241
2243
  import { getAccountId, getEnv } from "@hubspot/local-dev-lib/config";
2242
2244
  import { http as hsCliHttp6 } from "@hubspot/local-dev-lib/http";
2243
2245
 
@@ -2674,6 +2676,7 @@ import {
2674
2676
  convertToUnixPath,
2675
2677
  isAllowedExtension as isAllowedExtension2
2676
2678
  } from "@hubspot/local-dev-lib/path";
2679
+ import { normalizePath as normalizePath2 } from "vite";
2677
2680
  import { getExt, splitLocalPath } from "@hubspot/local-dev-lib/path";
2678
2681
  import { upload, deleteFile } from "@hubspot/local-dev-lib/api/fileMapper";
2679
2682
  import { MODULE_EXTENSION } from "@hubspot/local-dev-lib/constants/extensions";
@@ -2790,8 +2793,10 @@ function buildDeleteFileFromPreviewBufferCallback(accountId, src, dest, type) {
2790
2793
  };
2791
2794
  }
2792
2795
  function getDesignManagerPath(src, dest, file) {
2793
- const regex = new RegExp(`^${escapeRegExp2(src)}`);
2794
- const relativePath = file.replace(regex, "");
2796
+ const normalizedSrc = normalizePath2(src);
2797
+ const normalizedFile = normalizePath2(file);
2798
+ const regex = new RegExp(`^${escapeRegExp2(normalizedSrc)}`);
2799
+ const relativePath = normalizedFile.replace(regex, "");
2795
2800
  return convertToUnixPath(path4.join(dest, relativePath));
2796
2801
  }
2797
2802
  async function uploadFile(accountId, src, dest) {
@@ -3096,7 +3101,7 @@ var renderComponentForPlaceholder = (indexForThisRender, localRenderPlaceholder,
3096
3101
  `The specified component folder "${projectComponentFolder}" does not match the webroot project component folder "${webRootProjectComponent}/${projectComponentFolder}" specified to the cms-dev-server. Components must be located within the webroot project folder. Check that the specified path is correct: ${placeholderPath}.`
3097
3102
  );
3098
3103
  }
3099
- const resolvedPath = normalizePath2(
3104
+ const resolvedPath = normalizePath3(
3100
3105
  path6.resolve(webRoot2, partialPath, componentFileName)
3101
3106
  );
3102
3107
  const entryPointPath = [
@@ -3414,7 +3419,7 @@ async function renderRemoteModulePreview(modulePath, authedPortalId, authedEnv,
3414
3419
  return { html: modulePreviewContent, cssNeeded };
3415
3420
  }
3416
3421
  async function renderLocalProjectModulePreview(moduleName, authedPortalId, authedEnv, authedHublet, webRoot2, viteServer, jsRenderingGates, projectName, projectComponentPath, fullOriginalUrl, cookieValue, fieldOverrides = {}) {
3417
- const modulePath = normalizePath3(
3422
+ const modulePath = normalizePath4(
3418
3423
  path7.resolve(webRoot2, "components/modules/", moduleName)
3419
3424
  );
3420
3425
  const basePath = `preview/${getEntryPointBasePath(modulePath)}`;
@@ -3533,10 +3538,10 @@ var partialRouteHandler = async (request2, response) => {
3533
3538
  import.meta.url,
3534
3539
  "html/baseTemplate.html"
3535
3540
  );
3536
- const partialPath = normalizePath4(
3541
+ const partialPath = normalizePath5(
3537
3542
  path8.resolve(webRoot2, "components/partials/", partialName)
3538
3543
  );
3539
- const entrypointPath = normalizePath4(
3544
+ const entrypointPath = normalizePath5(
3540
3545
  [
3541
3546
  "@projects",
3542
3547
  projectName,
@@ -3759,7 +3764,7 @@ var linksToAllModulesRouteHandler_default = linksToAllModuleRouteHandler;
3759
3764
  // src/routes/module.ts
3760
3765
  import { buildStaticEnvConfig as buildStaticEnvConfig4 } from "@hubspot/cms-components";
3761
3766
  import path9 from "path";
3762
- import { normalizePath as normalizePath5 } from "vite";
3767
+ import { normalizePath as normalizePath6 } from "vite";
3763
3768
  var moduleRouteHandler = async (request2, response) => {
3764
3769
  sendTrackingRequest("view-module-route");
3765
3770
  const {
@@ -3777,10 +3782,10 @@ var moduleRouteHandler = async (request2, response) => {
3777
3782
  import.meta.url,
3778
3783
  "html/baseTemplate.html"
3779
3784
  );
3780
- const modulePath = normalizePath5(
3785
+ const modulePath = normalizePath6(
3781
3786
  path9.resolve(webRoot2, "components/modules/", moduleName)
3782
3787
  );
3783
- const entrypointPath = normalizePath5(
3788
+ const entrypointPath = normalizePath6(
3784
3789
  [
3785
3790
  "@projects",
3786
3791
  projectName,
@@ -3860,7 +3865,7 @@ var module_default = moduleRouteHandler;
3860
3865
 
3861
3866
  // src/routes/moduleFieldsJson.ts
3862
3867
  import path10 from "path";
3863
- import { normalizePath as normalizePath6 } from "vite";
3868
+ import { normalizePath as normalizePath7 } from "vite";
3864
3869
 
3865
3870
  // src/lib/renderModuleFieldsJson.ts
3866
3871
  import { join as joinPosix4 } from "path/posix";
@@ -3912,7 +3917,7 @@ var moduleFieldsJsonRouteHandler = async (request2, response) => {
3912
3917
  sendTrackingRequest("fields-json-route");
3913
3918
  const { webRoot: webRoot2, viteServer } = request2.app.locals;
3914
3919
  const { moduleName } = request2.params;
3915
- const modulePath = normalizePath6(
3920
+ const modulePath = normalizePath7(
3916
3921
  path10.resolve(webRoot2, "components/modules/", moduleName)
3917
3922
  );
3918
3923
  const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
@@ -4393,7 +4398,7 @@ function proxyServerlessRequest(req, res, next) {
4393
4398
 
4394
4399
  // src/routes/modulePreviewRouteHandler.ts
4395
4400
  import path11 from "path";
4396
- import { normalizePath as normalizePath7 } from "vite";
4401
+ import { normalizePath as normalizePath8 } from "vite";
4397
4402
  async function modulePreviewRouteHandler(request2, response) {
4398
4403
  sendTrackingRequest("view-module-preview-route");
4399
4404
  const {
@@ -4407,7 +4412,7 @@ async function modulePreviewRouteHandler(request2, response) {
4407
4412
  projectComponentPath
4408
4413
  } = request2.app.locals;
4409
4414
  const moduleName = request2.params.moduleName;
4410
- const modulePath = normalizePath7(
4415
+ const modulePath = normalizePath8(
4411
4416
  path11.resolve(webRoot2, "components/modules/", moduleName)
4412
4417
  );
4413
4418
  const PREVIEWER_APP_PARAM = "hsPreviewerApp";
@@ -4645,7 +4650,7 @@ import fs5 from "node:fs/promises";
4645
4650
 
4646
4651
  // src/lib/getDevServerUIData.ts
4647
4652
  import path12 from "path";
4648
- import { normalizePath as normalizePath8 } from "vite";
4653
+ import { normalizePath as normalizePath9 } from "vite";
4649
4654
 
4650
4655
  // src/api/project.ts
4651
4656
  import { http as hsCliHttp11 } from "@hubspot/local-dev-lib/http";
@@ -4790,7 +4795,7 @@ var templateTypeMap = {
4790
4795
  function mapReactModules(modules, themeWebRoot, viteServer) {
4791
4796
  return Promise.all(
4792
4797
  modules.moduleNames.map(async (name, index) => {
4793
- const modulePath = normalizePath8(
4798
+ const modulePath = normalizePath9(
4794
4799
  path12.resolve(themeWebRoot, "components/modules/", name)
4795
4800
  );
4796
4801
  const fieldsJson = await renderModuleFieldsJson_default(viteServer, modulePath);
@@ -4851,7 +4856,8 @@ async function getDevServerUIData(reqLocals, viteServer) {
4851
4856
  projectName,
4852
4857
  localPreviewToken,
4853
4858
  webRootProjectComponentFolder,
4854
- sslEnabled
4859
+ sslEnabled,
4860
+ fieldBuilderEnabled: fieldBuilderEnabled2
4855
4861
  } = reqLocals;
4856
4862
  const packageJson = getPackageJson(themeWebRoot);
4857
4863
  const packageManager = detectPackageManager(themeWebRoot);
@@ -4895,7 +4901,8 @@ async function getDevServerUIData(reqLocals, viteServer) {
4895
4901
  webRootProjectComponentFolder,
4896
4902
  cliCommands,
4897
4903
  sslEnabled,
4898
- projectData
4904
+ projectData,
4905
+ fieldBuilderEnabled: fieldBuilderEnabled2
4899
4906
  };
4900
4907
  }
4901
4908
  var getDevServerUIData_default = getDevServerUIData;
@@ -4953,7 +4960,7 @@ var createAppServerRoutes_default = createAppServerRoutes;
4953
4960
 
4954
4961
  // src/routes/createDevServerRoutes.ts
4955
4962
  import path13 from "path";
4956
- import { fileURLToPath } from "url";
4963
+ import { fileURLToPath, pathToFileURL } from "url";
4957
4964
  var __filename = fileURLToPath(import.meta.url);
4958
4965
  var __dirname = path13.dirname(__filename);
4959
4966
  var isProd = true;
@@ -4999,7 +5006,7 @@ var createDevServerRoutes = async (viteServer, storybookPort, appServerConfig) =
4999
5006
  let render;
5000
5007
  let template = await fs5.readFile(path13.join(templatePath), "utf-8");
5001
5008
  if (isProd) {
5002
- const { render: ssrRender } = await import(serverEntryPath);
5009
+ const { render: ssrRender } = await import(pathToFileURL(serverEntryPath).href);
5003
5010
  render = ssrRender;
5004
5011
  } else {
5005
5012
  template = await appServer.transformIndexHtml(url3, template);
@@ -5822,7 +5829,7 @@ var BASE_PATH = "/";
5822
5829
  var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
5823
5830
  var SHADOW_PORT = 1442;
5824
5831
  var STORYBOOK_PORT = process.env.STORYBOOK_PORT ? parseInt(process.env.STORYBOOK_PORT, 10) : 3123;
5825
- async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2) {
5832
+ async function createDevServer(webRoot2, storybook2, hubspotCliConfigPathOption2, hubspotCliAccountNameOption2, sslEnabledOption2, fieldGenEnabledOption2, themePreviewOptions2, fieldBuilderEnabled2) {
5826
5833
  let authedPortalId = null;
5827
5834
  let authedEnv = null;
5828
5835
  let jsRenderingGates = [];
@@ -5936,7 +5943,7 @@ Local proxy functionality and module preview routes will not work without settin
5936
5943
  } catch (e) {
5937
5944
  authedHublet = "na1";
5938
5945
  }
5939
- const absoluteWebRoot = normalizePath9(path16.resolve(process.cwd(), webRoot2));
5946
+ const absoluteWebRoot = normalizePath10(path16.resolve(process.cwd(), webRoot2));
5940
5947
  const [__webRootProjectFolder, webRootProjectComponentFolder] = absoluteWebRoot.replace(/\/$/, "").split("/").slice(-2);
5941
5948
  const projectConfigPath = findHSProjectJson(absoluteWebRoot);
5942
5949
  if (authedPortalId) {
@@ -5989,7 +5996,7 @@ Local proxy functionality and module preview routes will not work without settin
5989
5996
  expressServer.locals.localPreviewToken = _localPreviewToken;
5990
5997
  expressServer.use(bodyParser.json());
5991
5998
  const __dirname2 = path16.dirname(url2.fileURLToPath(new URL(import.meta.url)));
5992
- const appWebRoot = normalizePath9(path16.resolve(__dirname2, "../app"));
5999
+ const appWebRoot = normalizePath10(path16.resolve(__dirname2, "../app"));
5993
6000
  const reqLocals = {
5994
6001
  themeWebRoot: absoluteWebRoot,
5995
6002
  authedPortalId,
@@ -5998,7 +6005,8 @@ Local proxy functionality and module preview routes will not work without settin
5998
6005
  projectName,
5999
6006
  webRootProjectComponentFolder,
6000
6007
  localPreviewToken: _localPreviewToken,
6001
- sslEnabled: sslEnabledOption2
6008
+ sslEnabled: sslEnabledOption2,
6009
+ fieldBuilderEnabled: fieldBuilderEnabled2
6002
6010
  };
6003
6011
  const appServer = await createAppServer_default(
6004
6012
  appWebRoot,
@@ -6127,7 +6135,8 @@ var {
6127
6135
  sslEnabledOption,
6128
6136
  storybook,
6129
6137
  fieldGenEnabledOption,
6130
- resetSession
6138
+ resetSession,
6139
+ fieldBuilderEnabled
6131
6140
  } = getDevServerCommandLineOptions(process.argv);
6132
6141
  if (!webRoot) {
6133
6142
  throw new Error(`No web root path argument specified`);
@@ -6147,5 +6156,6 @@ createDevServer_default(
6147
6156
  hubspotCliAccountNameOption,
6148
6157
  sslEnabledOption,
6149
6158
  fieldGenEnabledOption,
6150
- themePreviewOptions
6159
+ themePreviewOptions,
6160
+ fieldBuilderEnabled
6151
6161
  );