@hubspot/cms-dev-server 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/generateJsonFromJsx.js +297 -171
- package/dist/index.js +4766 -175
- package/dist/internalSsr.js +260 -151
- package/dist/run.js +1989 -502
- package/dist/storybook-main/main.js +261 -152
- package/package.json +8 -4
- package/types/api/designmanager.d.ts +31 -0
- package/types/api/session.d.ts +2 -0
- package/types/components/HubLModulesList.d.ts +4 -0
- package/types/components/HubLTemplatesList.d.ts +4 -0
- package/types/components/ModulesList.d.ts +5 -0
- package/types/components/PartialsList.d.ts +4 -0
- package/types/createAppServer.d.ts +2 -0
- package/types/createDevServer.d.ts +5 -0
- package/types/createViteDevServer.d.ts +3 -0
- package/types/fileManager.d.ts +4 -0
- package/types/index.d.ts +1 -0
- package/types/lib/configHelpers.d.ts +2 -0
- package/types/lib/criticalDevErrorsToServerMessages.d.ts +4 -0
- package/types/lib/debug.d.ts +1 -0
- package/types/lib/errors.d.ts +6 -0
- package/types/lib/fetchModuleGraphQLData.d.ts +24 -0
- package/types/lib/fullOriginalUrlFromRequest.d.ts +2 -0
- package/types/lib/gates.d.ts +2 -0
- package/types/lib/getJSRenderingGates.d.ts +8 -0
- package/types/lib/httpsRedirectingServer.d.ts +11 -0
- package/types/lib/logColors.d.ts +6 -0
- package/types/lib/moduleGraph.d.ts +1 -0
- package/types/lib/packagePath.d.ts +1 -0
- package/types/lib/pathHelpers.d.ts +3 -0
- package/types/lib/previewUtils.d.ts +22 -0
- package/types/lib/proxyHelpers.d.ts +29 -0
- package/types/lib/renderComponentWithCSS.d.ts +14 -0
- package/types/lib/renderHelpers.d.ts +1 -0
- package/types/lib/renderModule.d.ts +11 -0
- package/types/lib/renderModulePreview.d.ts +5 -0
- package/types/lib/renderPartial.d.ts +5 -0
- package/types/lib/templates.d.ts +4 -0
- package/types/lib/trackUsage.d.ts +3 -0
- package/types/lib/validateHSPlatform.d.ts +3 -0
- package/types/lib/watchFieldsUpdates.d.ts +22 -0
- package/types/proxyPage/constants.d.ts +1 -0
- package/types/proxyPage/fetchContentMetadata.d.ts +7 -0
- package/types/proxyPage/fetchDomains.d.ts +9 -0
- package/types/proxyPage/fetchPreviewInfo.d.ts +6 -0
- package/types/proxyPage/proxyPage.d.ts +11 -0
- package/types/proxyPage/renderLocalError.d.ts +2 -0
- package/types/proxyPage/utils.d.ts +4 -0
- package/types/routes/createDevServerRoutes.d.ts +3 -0
- package/types/routes/homeRouteHandler.d.ts +3 -0
- package/types/routes/hublModuleRouteHandler.d.ts +2 -0
- package/types/routes/hublTemplateRouteHandler.d.ts +2 -0
- package/types/routes/linksToAllModulesRouteHandler.d.ts +2 -0
- package/types/routes/linksToAllPartialsRouteHandler.d.ts +2 -0
- package/types/routes/meta.d.ts +2 -0
- package/types/routes/module.d.ts +3 -0
- package/types/routes/modulePreviewRouteHandler.d.ts +3 -0
- package/types/routes/partial.d.ts +2 -0
- package/types/routes/proxyPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPageRouteHandler.d.ts +2 -0
- package/types/routes/proxyPathPageResourceRedirect.d.ts +2 -0
- package/types/routes/proxyPathPageRouteHandler.d.ts +2 -0
- package/types/routes/proxyServerlessHandler.d.ts +2 -0
- package/types/routes/remoteFsDirtyHandler.d.ts +2 -0
- package/types/shadowDevServer/createShadowDevServerRoutes.d.ts +2 -0
- package/types/shadowDevServer/startShadowDevServer.d.ts +2 -0
|
@@ -415,12 +415,16 @@ ${groupEnd}</script>
|
|
|
415
415
|
"CMS:JSRenderer:ModuleHubl",
|
|
416
416
|
"CMS:JSRenderer:RemoveCjsPlugin",
|
|
417
417
|
"CMS:JSRenderer:RemoveMockClientEntryPlugin",
|
|
418
|
-
"CMS:JSRenderer:AnalyzeCmsModules"
|
|
418
|
+
"CMS:JSRenderer:AnalyzeCmsModules",
|
|
419
|
+
"CMS:JSRenderer:ClientOnlySupplementalFieldSerialization",
|
|
420
|
+
"CMS:React:UnifiedThemePreview"
|
|
419
421
|
];
|
|
420
422
|
ENABLED_FEATURES_GATE_MAP = {
|
|
421
423
|
"cms:jsr:getServerSideProps": "CMS:JSRenderer:GetServerSideProps",
|
|
422
424
|
"cms:jsr:RemoveCjsPlugin": "CMS:JSRenderer:RemoveCjsPlugin",
|
|
423
|
-
"cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules"
|
|
425
|
+
"cms:jsr:analyzeCmsModules": "CMS:JSRenderer:AnalyzeCmsModules",
|
|
426
|
+
"cms:jsr:clientOnlySupplementalFieldSerialization": "CMS:JSRenderer:ClientOnlySupplementalFieldSerialization",
|
|
427
|
+
"cms:react:unifiedThemePreview": "CMS:React:UnifiedThemePreview"
|
|
424
428
|
};
|
|
425
429
|
findAllComponentsIn = (webRoot2, componentsFolder) => {
|
|
426
430
|
const fullComponentsFolderPath = join(webRoot2, componentsFolder);
|
|
@@ -620,80 +624,14 @@ function findCmsModules(cmsModules = {}) {
|
|
|
620
624
|
},
|
|
621
625
|
transform(code, id) {
|
|
622
626
|
const moduleInfo = this.getModuleInfo(id);
|
|
623
|
-
|
|
624
|
-
if (isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME)) {
|
|
627
|
+
if (shouldSkipModule(config, moduleInfo, code))
|
|
625
628
|
return null;
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
let moduleLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
633
|
-
let moduleUsed = false;
|
|
634
|
-
const pluginError = this.error.bind(this);
|
|
635
|
-
traverse(sourceAst, {
|
|
636
|
-
ImportDeclaration(path3) {
|
|
637
|
-
if (!t.isStringLiteral(path3.node.source, {
|
|
638
|
-
value: "@hubspot/cms-components"
|
|
639
|
-
})) {
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
for (const specifier of path3.node.specifiers) {
|
|
643
|
-
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
644
|
-
name: CMS_MODULE_COMPONENT_NAME
|
|
645
|
-
})) {
|
|
646
|
-
moduleLocalImportName = specifier.local.name;
|
|
647
|
-
}
|
|
648
|
-
}
|
|
649
|
-
},
|
|
650
|
-
JSXOpeningElement(path3) {
|
|
651
|
-
if (!t.isJSXIdentifier(path3.node.name, {
|
|
652
|
-
name: moduleLocalImportName
|
|
653
|
-
})) {
|
|
654
|
-
return null;
|
|
655
|
-
}
|
|
656
|
-
moduleUsed = true;
|
|
657
|
-
let cmsModuleName;
|
|
658
|
-
let cmsModulePath;
|
|
659
|
-
let cmsModuleLabel;
|
|
660
|
-
for (const prop of path3.node.attributes) {
|
|
661
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
662
|
-
cmsModuleName = prop.value.value;
|
|
663
|
-
continue;
|
|
664
|
-
}
|
|
665
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "path" }) && t.isStringLiteral(prop.value)) {
|
|
666
|
-
cmsModulePath = prop.value.value;
|
|
667
|
-
continue;
|
|
668
|
-
}
|
|
669
|
-
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "label" }) && t.isStringLiteral(prop.value)) {
|
|
670
|
-
cmsModuleLabel = prop.value.value;
|
|
671
|
-
continue;
|
|
672
|
-
}
|
|
673
|
-
pluginError(
|
|
674
|
-
new Error(
|
|
675
|
-
`Error: ${id.replace(config.root, "")}:${prop.loc.start.line} "name" and "path" must be primitive strings`
|
|
676
|
-
)
|
|
677
|
-
);
|
|
678
|
-
return null;
|
|
679
|
-
}
|
|
680
|
-
const cmsModuleProps = {
|
|
681
|
-
name: cmsModuleName,
|
|
682
|
-
path: cmsModulePath
|
|
683
|
-
};
|
|
684
|
-
if (cmsModuleLabel) {
|
|
685
|
-
cmsModuleProps.label = cmsModuleLabel;
|
|
686
|
-
}
|
|
687
|
-
if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {
|
|
688
|
-
pluginError(
|
|
689
|
-
new Error(
|
|
690
|
-
`Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`
|
|
691
|
-
)
|
|
692
|
-
);
|
|
693
|
-
}
|
|
694
|
-
localCmsModules[cmsModuleProps.name] = cmsModuleProps;
|
|
695
|
-
}
|
|
696
|
-
});
|
|
629
|
+
const { localCmsModules, moduleUsed } = analyzeSourceCodeUsages(
|
|
630
|
+
this,
|
|
631
|
+
moduleInfo,
|
|
632
|
+
config,
|
|
633
|
+
code
|
|
634
|
+
);
|
|
697
635
|
if (!moduleUsed) {
|
|
698
636
|
return null;
|
|
699
637
|
}
|
|
@@ -706,95 +644,261 @@ function findCmsModules(cmsModules = {}) {
|
|
|
706
644
|
buildEnd(error) {
|
|
707
645
|
if (error)
|
|
708
646
|
throw error;
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
647
|
+
const entryPoints = getEntryPoints(this, config);
|
|
648
|
+
const entryPointCmsModuleMap = buildEntryPointsCmsModuleMap(
|
|
649
|
+
this,
|
|
650
|
+
entryPoints
|
|
713
651
|
);
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
652
|
+
const relativeEntryPointCmsModuleMap = convertEntryPointPathsToRelative(
|
|
653
|
+
config,
|
|
654
|
+
entryPointCmsModuleMap
|
|
655
|
+
);
|
|
656
|
+
const entryPointIslandCmsModuleMap = buildEntryPointIslandsCmsModuleMap(
|
|
657
|
+
this,
|
|
658
|
+
entryPoints
|
|
659
|
+
);
|
|
660
|
+
const relativeEntryPointIslandCmsModuleMap = convertEntryPointIslandPathsToRelative(
|
|
661
|
+
config,
|
|
662
|
+
entryPointIslandCmsModuleMap
|
|
663
|
+
);
|
|
664
|
+
if (Object.keys(relativeEntryPointIslandCmsModuleMap).length > 0) {
|
|
665
|
+
this.error(`
|
|
666
|
+
Error: <Module /> cannot be used within <Island />
|
|
667
|
+
Found invalid usages:
|
|
668
|
+
${JSON.stringify(relativeEntryPointIslandCmsModuleMap, null, 2)}
|
|
730
669
|
`);
|
|
731
|
-
}
|
|
732
670
|
}
|
|
733
|
-
const
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
${formatIslandImporter(
|
|
743
|
-
moduleWithCmsModuleUsage.id,
|
|
744
|
-
root
|
|
745
|
-
)} uses <${CMS_MODULE_COMPONENT_NAME} /> and is used by islands:
|
|
746
|
-
${islandsContainingCmsModuleUsage.map(
|
|
747
|
-
(islandModuleInfo) => formatIslandImporter(islandModuleInfo.id, root)
|
|
748
|
-
).join(", ")}
|
|
749
|
-
`);
|
|
750
|
-
}
|
|
671
|
+
const modulesWithinModules = filterEntryPointsToModules(
|
|
672
|
+
relativeEntryPointCmsModuleMap
|
|
673
|
+
);
|
|
674
|
+
if (Object.keys(modulesWithinModules).length > 0) {
|
|
675
|
+
this.error(`
|
|
676
|
+
Error: <Module /> can only be used in React Partials
|
|
677
|
+
Found invalid usages:
|
|
678
|
+
${JSON.stringify(modulesWithinModules, null, 2)}
|
|
679
|
+
`);
|
|
751
680
|
}
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
681
|
+
Object.assign(cmsModules, relativeEntryPointCmsModuleMap);
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
}
|
|
685
|
+
function convertEntryPointPathsToRelative(config, entryPointsCmsModuleMap) {
|
|
686
|
+
const relativeEntries = Object.entries(entryPointsCmsModuleMap).map(
|
|
687
|
+
([entryPointPath, cmsModules]) => {
|
|
688
|
+
return [toRelativePath(config, entryPointPath), cmsModules];
|
|
689
|
+
}
|
|
690
|
+
);
|
|
691
|
+
return Object.fromEntries(relativeEntries);
|
|
692
|
+
}
|
|
693
|
+
function convertEntryPointIslandPathsToRelative(config, entryPointsCmsModuleMap) {
|
|
694
|
+
const relativeEntries = Object.entries(entryPointsCmsModuleMap).map(
|
|
695
|
+
([entryPointPath, islandCmsModules]) => {
|
|
696
|
+
const islandCmsModuleUsage = Object.fromEntries(
|
|
697
|
+
Object.entries(islandCmsModules).map(([islandPath, cmsModule]) => {
|
|
698
|
+
return [
|
|
699
|
+
toRelativePath(config, islandPath).replace("?client-entry", ""),
|
|
700
|
+
cmsModule
|
|
701
|
+
];
|
|
702
|
+
})
|
|
703
|
+
);
|
|
704
|
+
return [toRelativePath(config, entryPointPath), islandCmsModuleUsage];
|
|
705
|
+
}
|
|
706
|
+
);
|
|
707
|
+
return Object.fromEntries(relativeEntries);
|
|
708
|
+
}
|
|
709
|
+
function toRelativePath(config, path3) {
|
|
710
|
+
return path3.replace(config.root, "");
|
|
711
|
+
}
|
|
712
|
+
function shouldSkipModule(config, moduleInfo, code) {
|
|
713
|
+
const isExternal = config.command !== "serve" && moduleInfo.isExternal;
|
|
714
|
+
return isExternal || !moduleInfo.id.startsWith(config.root) || !code.includes(CMS_MODULE_COMPONENT_NAME);
|
|
715
|
+
}
|
|
716
|
+
function getEntryPoints(ctx, config) {
|
|
717
|
+
return Array.from(ctx.getModuleIds()).filter((moduleId) => moduleId.startsWith(config.root)).map((moduleId) => ctx.getModuleInfo(moduleId)).filter((moduleInfo) => moduleInfo.isEntry);
|
|
718
|
+
}
|
|
719
|
+
function buildEntryPointsCmsModuleMap(ctx, entryPoints) {
|
|
720
|
+
const entryPointCmsModuleUsage = {};
|
|
721
|
+
for (const entryPoint of entryPoints) {
|
|
722
|
+
const result = findCmsModuleUsages(ctx, entryPoint.id);
|
|
723
|
+
if (result) {
|
|
724
|
+
entryPointCmsModuleUsage[entryPoint.id] = result;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
return entryPointCmsModuleUsage;
|
|
728
|
+
}
|
|
729
|
+
function buildEntryPointIslandsCmsModuleMap(ctx, entryPoints) {
|
|
730
|
+
const entryPointIslandsCmsModuleMap = {};
|
|
731
|
+
for (const entryPoint of entryPoints) {
|
|
732
|
+
const result = findIslandCmsModuleUsage(ctx, entryPoint.id);
|
|
733
|
+
if (result) {
|
|
734
|
+
entryPointIslandsCmsModuleMap[entryPoint.id] = result;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return entryPointIslandsCmsModuleMap;
|
|
738
|
+
}
|
|
739
|
+
function analyzeSourceCodeUsages(ctx, moduleInfo, config, code) {
|
|
740
|
+
const sourceAst = parser.parse(code, {
|
|
741
|
+
sourceType: "module",
|
|
742
|
+
plugins: ["jsx", "typescript"]
|
|
743
|
+
});
|
|
744
|
+
const localCmsModules = {};
|
|
745
|
+
let moduleUsed = false;
|
|
746
|
+
let moduleComponentLocalImportName = CMS_MODULE_COMPONENT_NAME;
|
|
747
|
+
traverse(sourceAst, {
|
|
748
|
+
ImportDeclaration(path3) {
|
|
749
|
+
if (t.isStringLiteral(path3.node.source, {
|
|
750
|
+
value: "@hubspot/cms-components"
|
|
751
|
+
})) {
|
|
752
|
+
for (const specifier of path3.node.specifiers) {
|
|
753
|
+
if (t.isImportSpecifier(specifier) && t.isIdentifier(specifier.imported, {
|
|
754
|
+
name: CMS_MODULE_COMPONENT_NAME
|
|
755
|
+
})) {
|
|
756
|
+
moduleComponentLocalImportName = specifier.local.name;
|
|
766
757
|
}
|
|
767
758
|
}
|
|
768
759
|
}
|
|
760
|
+
},
|
|
761
|
+
JSXOpeningElement(path3) {
|
|
762
|
+
if (!t.isJSXIdentifier(path3.node.name, {
|
|
763
|
+
name: moduleComponentLocalImportName
|
|
764
|
+
})) {
|
|
765
|
+
return null;
|
|
766
|
+
}
|
|
767
|
+
moduleUsed = true;
|
|
768
|
+
let cmsModuleName;
|
|
769
|
+
let cmsModulePath;
|
|
770
|
+
let cmsModuleLabel;
|
|
771
|
+
for (const prop of path3.node.attributes) {
|
|
772
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "name" }) && t.isStringLiteral(prop.value)) {
|
|
773
|
+
cmsModuleName = prop.value.value;
|
|
774
|
+
continue;
|
|
775
|
+
}
|
|
776
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "path" }) && t.isStringLiteral(prop.value)) {
|
|
777
|
+
cmsModulePath = prop.value.value;
|
|
778
|
+
continue;
|
|
779
|
+
}
|
|
780
|
+
if (t.isJSXAttribute(prop) && t.isJSXIdentifier(prop.name, { name: "label" }) && t.isStringLiteral(prop.value)) {
|
|
781
|
+
cmsModuleLabel = prop.value.value;
|
|
782
|
+
continue;
|
|
783
|
+
}
|
|
784
|
+
ctx.error(
|
|
785
|
+
new Error(
|
|
786
|
+
`Error: ${moduleInfo.id.replace(config.root, "")}:${prop.loc.start.line} "name" and "path" must be primitive strings`
|
|
787
|
+
)
|
|
788
|
+
);
|
|
789
|
+
}
|
|
790
|
+
const cmsModuleProps = {
|
|
791
|
+
name: cmsModuleName,
|
|
792
|
+
path: cmsModulePath
|
|
793
|
+
};
|
|
794
|
+
if (cmsModuleLabel) {
|
|
795
|
+
cmsModuleProps.label = cmsModuleLabel;
|
|
796
|
+
}
|
|
797
|
+
if (Object.hasOwn(localCmsModules, cmsModuleProps.name)) {
|
|
798
|
+
ctx.error(
|
|
799
|
+
new Error(
|
|
800
|
+
`Error: multiple <${CMS_MODULE_COMPONENT_NAME} /> with duplicate name: ${cmsModuleProps.name}`
|
|
801
|
+
)
|
|
802
|
+
);
|
|
803
|
+
}
|
|
804
|
+
localCmsModules[cmsModuleProps.name] = cmsModuleProps;
|
|
769
805
|
}
|
|
806
|
+
});
|
|
807
|
+
return {
|
|
808
|
+
moduleUsed,
|
|
809
|
+
localCmsModules
|
|
770
810
|
};
|
|
771
811
|
}
|
|
772
|
-
function
|
|
773
|
-
if (
|
|
774
|
-
return [
|
|
812
|
+
function findCmsModuleUsages(ctx, moduleId, processed = /* @__PURE__ */ new Set(), result = {}) {
|
|
813
|
+
if (Object.hasOwn(result, moduleId)) {
|
|
814
|
+
return result[moduleId];
|
|
775
815
|
}
|
|
776
|
-
const
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
816
|
+
const moduleInfo = ctx.getModuleInfo(moduleId);
|
|
817
|
+
let entryPointModules = null;
|
|
818
|
+
if (Object.hasOwn(moduleInfo.meta, PLUGIN_NAME)) {
|
|
819
|
+
entryPointModules = {
|
|
820
|
+
...entryPointModules,
|
|
821
|
+
...moduleInfo.meta[PLUGIN_NAME]
|
|
822
|
+
};
|
|
781
823
|
}
|
|
782
|
-
|
|
824
|
+
for (const importedId of [
|
|
825
|
+
...moduleInfo.importedIds,
|
|
826
|
+
...moduleInfo.dynamicallyImportedIds
|
|
827
|
+
]) {
|
|
828
|
+
if (processed.has(importedId)) {
|
|
829
|
+
continue;
|
|
830
|
+
}
|
|
831
|
+
const importedResult = findCmsModuleUsages(
|
|
832
|
+
ctx,
|
|
833
|
+
importedId,
|
|
834
|
+
processed,
|
|
835
|
+
result
|
|
836
|
+
);
|
|
837
|
+
if (importedResult) {
|
|
838
|
+
entryPointModules = {
|
|
839
|
+
...entryPointModules,
|
|
840
|
+
...importedResult
|
|
841
|
+
};
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
if (entryPointModules) {
|
|
845
|
+
result[moduleId] = entryPointModules;
|
|
846
|
+
}
|
|
847
|
+
processed.add(moduleId);
|
|
848
|
+
return entryPointModules;
|
|
783
849
|
}
|
|
784
|
-
function
|
|
785
|
-
|
|
786
|
-
|
|
850
|
+
function findIslandCmsModuleUsage(ctx, moduleId, processedIslands = /* @__PURE__ */ new Set(), islandModuleResults = {}, processed = /* @__PURE__ */ new Set(), results = {}) {
|
|
851
|
+
processedIslands.add(moduleId);
|
|
852
|
+
if (Object.hasOwn(islandModuleResults, moduleId)) {
|
|
853
|
+
return islandModuleResults[moduleId];
|
|
787
854
|
}
|
|
788
|
-
const
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
const
|
|
792
|
-
|
|
855
|
+
const moduleInfo = ctx.getModuleInfo(moduleId);
|
|
856
|
+
let resultForModuleId = {};
|
|
857
|
+
if (moduleInfo.id.endsWith("?client-entry")) {
|
|
858
|
+
const mergedDataDependencies = findCmsModuleUsages(
|
|
859
|
+
ctx,
|
|
860
|
+
moduleInfo.id,
|
|
861
|
+
processed,
|
|
862
|
+
results
|
|
863
|
+
);
|
|
864
|
+
if (mergedDataDependencies) {
|
|
865
|
+
resultForModuleId[moduleInfo.id] = mergedDataDependencies;
|
|
866
|
+
}
|
|
793
867
|
}
|
|
794
|
-
|
|
868
|
+
for (const importedId of [
|
|
869
|
+
...moduleInfo.importedIds,
|
|
870
|
+
...moduleInfo.dynamicallyImportedIds
|
|
871
|
+
]) {
|
|
872
|
+
if (processedIslands.has(importedId)) {
|
|
873
|
+
continue;
|
|
874
|
+
}
|
|
875
|
+
const importerCmsModuleUsageResult = findIslandCmsModuleUsage(
|
|
876
|
+
ctx,
|
|
877
|
+
importedId,
|
|
878
|
+
processedIslands,
|
|
879
|
+
islandModuleResults,
|
|
880
|
+
processed,
|
|
881
|
+
results
|
|
882
|
+
);
|
|
883
|
+
if (importerCmsModuleUsageResult) {
|
|
884
|
+
resultForModuleId = {
|
|
885
|
+
...resultForModuleId,
|
|
886
|
+
...importerCmsModuleUsageResult
|
|
887
|
+
};
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
if (Object.keys(resultForModuleId).length > 0) {
|
|
891
|
+
islandModuleResults[moduleId] = resultForModuleId;
|
|
892
|
+
return resultForModuleId;
|
|
893
|
+
}
|
|
894
|
+
return null;
|
|
795
895
|
}
|
|
796
|
-
function
|
|
797
|
-
return
|
|
896
|
+
function filterEntryPointsToModules(entryPointCmsModuleMap) {
|
|
897
|
+
return Object.fromEntries(
|
|
898
|
+
Object.entries(entryPointCmsModuleMap).filter(
|
|
899
|
+
([entryPoint]) => entryPoint.startsWith("/components/modules/")
|
|
900
|
+
)
|
|
901
|
+
);
|
|
798
902
|
}
|
|
799
903
|
async function renderComponentOnServer(Component, propsAndDeps, pageUrl, environmentConfig, entryPointBasePath, contextOptions, renderOptions, getServerSideProps) {
|
|
800
904
|
const { props } = propsAndDeps;
|
|
@@ -912,13 +1016,13 @@ function renderFieldsToJson(fields, moduleName) {
|
|
|
912
1016
|
throw e;
|
|
913
1017
|
}
|
|
914
1018
|
}
|
|
915
|
-
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
|
|
1019
|
+
var setProperty, getProperty, hasProperty, serializeIslandDataForInlineScript, writeSharedStateToJsGlobal, createIslandsGlobalJsForClientInDev, traverse, CMS_MODULE_COMPONENT_NAME, PLUGIN_NAME, promiseForNewWritableStream, renderStreamToPromise, createServerRenderContextV22, createServerRenderContext2, renderServerSidePropsWithAsyncLocalStoreContext, bootStrapRenderContext;
|
|
916
1020
|
var init_dist = __esm({
|
|
917
1021
|
"../cms-js-internal/dist/index.js"() {
|
|
918
1022
|
init_basicUtils();
|
|
919
1023
|
init_basicUtils();
|
|
920
1024
|
({ setProperty, getProperty, hasProperty } = dotProp);
|
|
921
|
-
serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
|
|
1025
|
+
serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
|
|
922
1026
|
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
923
1027
|
({
|
|
924
1028
|
id,
|
|
@@ -960,6 +1064,9 @@ var init_dist = __esm({
|
|
|
960
1064
|
if (filteredSupplementalFieldValues) {
|
|
961
1065
|
output.supplementalFieldValues = filteredSupplementalFieldValues;
|
|
962
1066
|
}
|
|
1067
|
+
if (isUngatedForClientOnlySupplementalFieldSerialization && output.clientOnly) {
|
|
1068
|
+
output.supplementalFieldValues = supplementalFieldValues;
|
|
1069
|
+
}
|
|
963
1070
|
return output;
|
|
964
1071
|
}
|
|
965
1072
|
);
|
|
@@ -993,7 +1100,7 @@ ${indentString}`);
|
|
|
993
1100
|
}
|
|
994
1101
|
return "";
|
|
995
1102
|
};
|
|
996
|
-
createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint) => {
|
|
1103
|
+
createIslandsGlobalJsForClientInDev = (roots, perServerRequestData, viteDevServer, indent, prettyPrint, isUngatedForClientOnlySupplementalFieldSerialization = false) => {
|
|
997
1104
|
const islands = getIslandUrls(roots, viteDevServer);
|
|
998
1105
|
const perServerRequestDataWithUrls = getPerServerRequestUrls(
|
|
999
1106
|
perServerRequestData,
|
|
@@ -1005,7 +1112,8 @@ ${indentString}`);
|
|
|
1005
1112
|
islands,
|
|
1006
1113
|
perServerRequestData,
|
|
1007
1114
|
indent,
|
|
1008
|
-
prettyPrint
|
|
1115
|
+
prettyPrint,
|
|
1116
|
+
isUngatedForClientOnlySupplementalFieldSerialization
|
|
1009
1117
|
)}${writeSharedStateToJsGlobal(
|
|
1010
1118
|
islands,
|
|
1011
1119
|
perServerRequestDataWithUrls,
|
|
@@ -1015,6 +1123,7 @@ ${indentString}`);
|
|
|
1015
1123
|
};
|
|
1016
1124
|
traverse = _traverse.default;
|
|
1017
1125
|
CMS_MODULE_COMPONENT_NAME = "Module";
|
|
1126
|
+
PLUGIN_NAME = "findCmsModules";
|
|
1018
1127
|
promiseForNewWritableStream = () => {
|
|
1019
1128
|
const chunks = [];
|
|
1020
1129
|
const writableStream = new stream.Writable();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/cms-dev-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"@babel/parser": "^7.25.3",
|
|
30
30
|
"@babel/traverse": "^7.25.3",
|
|
31
31
|
"@babel/types": "^7.25.2",
|
|
32
|
-
"@hubspot/cms-components": "^0.
|
|
33
|
-
"@hubspot/local-dev-lib": "
|
|
32
|
+
"@hubspot/cms-components": "^0.18.0",
|
|
33
|
+
"@hubspot/local-dev-lib": "2.0.1",
|
|
34
34
|
"@inquirer/select": "^2.0.0",
|
|
35
35
|
"@originjs/vite-plugin-commonjs": "^1.0.3",
|
|
36
36
|
"@storybook/addon-actions": "7.1.1",
|
|
@@ -45,6 +45,8 @@
|
|
|
45
45
|
"ansi-to-html": "0.7.x",
|
|
46
46
|
"babel-plugin-macros": "^3.1.0",
|
|
47
47
|
"babel-plugin-styled-components": "^2.1.4",
|
|
48
|
+
"chalk": "^5.3.0",
|
|
49
|
+
"cli-progress": "^3.12.0",
|
|
48
50
|
"cors": "^2.8.5",
|
|
49
51
|
"debug": "^4.3.4",
|
|
50
52
|
"express": "^4.17.3",
|
|
@@ -68,7 +70,9 @@
|
|
|
68
70
|
"@types/react": "^18.0.0",
|
|
69
71
|
"@types/react-dom": "^18.0.0",
|
|
70
72
|
"copyfiles": "^2.4.1",
|
|
73
|
+
"dot-prop": "^9.0.0",
|
|
71
74
|
"esbuild": "^0.16.17",
|
|
75
|
+
"fs-extra": "^11.2.0",
|
|
72
76
|
"nodemon": "^2.0.15",
|
|
73
77
|
"publint": "^0.2.7",
|
|
74
78
|
"tsx": "^4.19.1",
|
|
@@ -114,5 +118,5 @@
|
|
|
114
118
|
"publishConfig": {
|
|
115
119
|
"access": "public"
|
|
116
120
|
},
|
|
117
|
-
"gitHead": "
|
|
121
|
+
"gitHead": "116c5a3243ad1afcfc684a7d0ac99bb9345782cc"
|
|
118
122
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
interface PaginatedApiResponse<T> {
|
|
2
|
+
limit: number;
|
|
3
|
+
objects: T[];
|
|
4
|
+
offset: number;
|
|
5
|
+
total: number;
|
|
6
|
+
totalCount: number;
|
|
7
|
+
}
|
|
8
|
+
export interface HubLModule {
|
|
9
|
+
moduleId: number;
|
|
10
|
+
name: string;
|
|
11
|
+
path: string;
|
|
12
|
+
previewKey: string;
|
|
13
|
+
}
|
|
14
|
+
export interface HubLTemplate {
|
|
15
|
+
path: string;
|
|
16
|
+
label: string;
|
|
17
|
+
previewKey: string;
|
|
18
|
+
filename: string;
|
|
19
|
+
}
|
|
20
|
+
export interface HubLTemplateData {
|
|
21
|
+
previewKey: string;
|
|
22
|
+
}
|
|
23
|
+
export interface HubLModuleData {
|
|
24
|
+
previewKey: string;
|
|
25
|
+
moduleId: string;
|
|
26
|
+
}
|
|
27
|
+
export declare function fetchHubLModules(accountId: any, previewToken: any): Promise<PaginatedApiResponse<HubLModule>>;
|
|
28
|
+
export declare function fetchPreviewTemplates(accountId: any, previewToken: any): Promise<PaginatedApiResponse<HubLTemplate>>;
|
|
29
|
+
export declare function fetchModuleByPath(accountId: number, path: string): Promise<any>;
|
|
30
|
+
export declare function fetchTemplateByPath(accountId: number, path: string): Promise<HubLTemplateData>;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ThemePreviewOptions } from './lib/previewUtils.js';
|
|
2
|
+
declare function createDevServer(webRoot: string, storybook: boolean, hubspotCliConfigPathOption?: string, hubspotCliAccountNameOption?: string, sslEnabledOption?: boolean, fieldGenEnabledOption?: boolean, themePreviewOptions?: ThemePreviewOptions, showUI?: boolean): Promise<{
|
|
3
|
+
close: () => Promise<[...PromiseSettledResult<unknown>[], PromiseSettledResult<unknown>]>;
|
|
4
|
+
}>;
|
|
5
|
+
export default createDevServer;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { Gate } from '@hubspot/cms-js-internal';
|
|
2
|
+
export declare function getPackageJson(packagePath: string): any;
|
|
3
|
+
export declare function getDepsForPackage(packagePath: string): string[];
|
|
4
|
+
export declare function getDepsForPackageIfExists(packagePath: string): string[];
|
|
2
5
|
declare function createViteDevServer(webRoot: string, port: any, sslEnabled: boolean, domainsToProxy: any[], jsRenderingGates: Gate[], secretNames: string[]): Promise<import("vite").ViteDevServer>;
|
|
3
6
|
export default createViteDevServer;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import chokidar from 'chokidar';
|
|
2
|
+
export declare function initialPreviewBufferUpload(accountId: any, src: any, dest: any, filePaths: any, uploadOptions: any): Promise<void>;
|
|
3
|
+
export declare const startPreviewWatcher: (accountId: any, src: string, dest: string) => Promise<chokidar.FSWatcher>;
|
|
4
|
+
export declare function isModuleFolderChild(filePath: string): boolean;
|
package/types/index.d.ts
CHANGED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { LogMessage } from '@hubspot/cms-components';
|
|
2
|
+
import { CriticalDevError } from '@hubspot/cms-components';
|
|
3
|
+
declare const criticalDevErrorsToServerMessages: (criticalDevErrors: Array<CriticalDevError>) => Array<LogMessage>;
|
|
4
|
+
export default criticalDevErrorsToServerMessages;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const debug: any;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare class MissingScopeError extends Error {
|
|
2
|
+
constructor(error: any);
|
|
3
|
+
}
|
|
4
|
+
export declare function logMissingScopeWarning(error: MissingScopeError): void;
|
|
5
|
+
export declare function isMissingScopeError(error: any): any;
|
|
6
|
+
export declare function handleSecretsError(error: any): void;
|