@hubspot/cms-dev-server 0.15.8 → 0.15.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -2
- package/dist/internalSsr.js +2 -268
- package/dist/run.js +359 -354
- package/dist/storybook/index.js +1 -3
- package/dist/storybook-main/main.js +3 -269
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -107,8 +107,6 @@ var {
|
|
|
107
107
|
createServerRenderContext: createServerRenderContext2,
|
|
108
108
|
renderServerSidePropsWithAsyncLocalStoreContext
|
|
109
109
|
} = cmsComponents;
|
|
110
|
-
var CMS_COMPONENTS = "@hubspot/cms-components";
|
|
111
|
-
var CMS_COMPONENTS_FIELD_TYPES = `${CMS_COMPONENTS}/fields`;
|
|
112
110
|
|
|
113
111
|
// src/createViteDevServer.ts
|
|
114
112
|
import { default as mkcert } from "vite-plugin-mkcert";
|
package/dist/internalSsr.js
CHANGED
|
@@ -445,9 +445,7 @@ import stream from "stream";
|
|
|
445
445
|
import { renderToPipeableStream, renderToStaticMarkup } from "react-dom/server";
|
|
446
446
|
import * as cmsComponents from "@hubspot/cms-components";
|
|
447
447
|
import { ServerRenderContext } from "@hubspot/cms-components";
|
|
448
|
-
import {
|
|
449
|
-
import ts from "typescript";
|
|
450
|
-
import React, { isValidElement, cloneElement } from "react";
|
|
448
|
+
import { isValidElement, cloneElement } from "react";
|
|
451
449
|
var { setProperty, getProperty, hasProperty } = dotProp;
|
|
452
450
|
var serializeIslandDataForInlineScript = (tweakedIslandsArray, perServerRequestData, baseIndent = 0, prettyPrint) => {
|
|
453
451
|
const islandsArrayToSerialize = tweakedIslandsArray.map(
|
|
@@ -719,265 +717,6 @@ async function renderOnServer(elements, renderContext = bootStrapRenderContext()
|
|
|
719
717
|
}
|
|
720
718
|
return { html, renderContext };
|
|
721
719
|
}
|
|
722
|
-
var fieldTypeNameByType = {
|
|
723
|
-
alignment: "AlignmentFieldType",
|
|
724
|
-
audioplayer: "AudioFieldType",
|
|
725
|
-
backgroundimage: "BackgroundImageFieldType",
|
|
726
|
-
blog: "BlogFieldType",
|
|
727
|
-
boolean: "BooleanFieldType",
|
|
728
|
-
border: "BorderFieldType",
|
|
729
|
-
choice: "ChoiceFieldType",
|
|
730
|
-
color: "ColorFieldType",
|
|
731
|
-
crmobject: "CrmObjectFieldType",
|
|
732
|
-
cta: "CtaFieldType",
|
|
733
|
-
date: "DateFieldType",
|
|
734
|
-
datetime: "DateTimeFieldType",
|
|
735
|
-
email: "EmailFieldType",
|
|
736
|
-
embed: "EmbedFieldType",
|
|
737
|
-
file: "FileFieldType",
|
|
738
|
-
followupemail: "FollowUpEmailFieldType",
|
|
739
|
-
font: "FontFieldType",
|
|
740
|
-
form: "FormFieldType",
|
|
741
|
-
gradient: "GradientFieldType",
|
|
742
|
-
group: "GroupFieldType",
|
|
743
|
-
html: "HtmlFieldType",
|
|
744
|
-
hubdbrow: "HubDbRowFieldType",
|
|
745
|
-
hubdbtable: "HubDbTableFieldType",
|
|
746
|
-
hubl: "HublFieldType",
|
|
747
|
-
icon: "IconFieldType",
|
|
748
|
-
image: "ImageFieldType",
|
|
749
|
-
link: "LinkFieldType",
|
|
750
|
-
logo: "LogoFieldType",
|
|
751
|
-
meeting: "MeetingFieldType",
|
|
752
|
-
menu: "MenuFieldType",
|
|
753
|
-
number: "NumberFieldType",
|
|
754
|
-
page: "PageFieldType",
|
|
755
|
-
payment: "PaymentFieldType",
|
|
756
|
-
podcast: "PodcastFieldType",
|
|
757
|
-
richtext: "RichTextFieldType",
|
|
758
|
-
salesforcecampaign: "SfdcCamapaignFieldType",
|
|
759
|
-
simplemenu: "SimpleMenuFieldType",
|
|
760
|
-
spacing: "SpacingFieldType",
|
|
761
|
-
survey: "SurveyFieldType",
|
|
762
|
-
tag: "TagFieldType",
|
|
763
|
-
textalignment: "TextAlignmentFieldType",
|
|
764
|
-
text: "TextFieldType",
|
|
765
|
-
url: "UrlFieldType",
|
|
766
|
-
video: "VideoFieldType",
|
|
767
|
-
workflow: "WorkflowFieldType"
|
|
768
|
-
};
|
|
769
|
-
var getChildrenAsArray = (element) => React.Children.toArray(element.props.children);
|
|
770
|
-
function getFieldEntries(fields) {
|
|
771
|
-
if (isValidElement(fields)) {
|
|
772
|
-
const fieldsJSX = getChildrenAsArray(fields);
|
|
773
|
-
return getReactFieldEntries(fieldsJSX);
|
|
774
|
-
} else if (Array.isArray(fields)) {
|
|
775
|
-
return getJSONFieldEntries(fields);
|
|
776
|
-
}
|
|
777
|
-
return void 0;
|
|
778
|
-
}
|
|
779
|
-
var getJSXFieldType = (fieldFunctionName) => {
|
|
780
|
-
switch (fieldFunctionName) {
|
|
781
|
-
case "RepeatedFieldGroup":
|
|
782
|
-
case "FieldGroup":
|
|
783
|
-
return "GroupFieldType";
|
|
784
|
-
default:
|
|
785
|
-
return `${fieldFunctionName}Type`;
|
|
786
|
-
}
|
|
787
|
-
};
|
|
788
|
-
var getElementName = (element) => typeof element.type === "string" ? element.type : element.type.name || null;
|
|
789
|
-
function getReactFieldEntries(fields) {
|
|
790
|
-
const validTypeNames = Object.values(fieldTypeNameByType);
|
|
791
|
-
if (!Array.isArray(fields)) {
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
return fields.filter((field) => field.props && field.props.name).map((field) => {
|
|
795
|
-
const elName = getElementName(field);
|
|
796
|
-
const fieldType = getJSXFieldType(getElementName(field));
|
|
797
|
-
if (!validTypeNames.includes(fieldType)) {
|
|
798
|
-
return void 0;
|
|
799
|
-
}
|
|
800
|
-
const { name, default: hasDefault } = field.props;
|
|
801
|
-
const isRepeater = elName === "RepeatedFieldGroup";
|
|
802
|
-
const entry = {
|
|
803
|
-
type: fieldType,
|
|
804
|
-
name,
|
|
805
|
-
hasDefault: !!hasDefault,
|
|
806
|
-
isRepeater,
|
|
807
|
-
children: []
|
|
808
|
-
};
|
|
809
|
-
if (fieldType === "GroupFieldType") {
|
|
810
|
-
const childrenArray = getChildrenAsArray(field);
|
|
811
|
-
const children = getReactFieldEntries(childrenArray);
|
|
812
|
-
return {
|
|
813
|
-
...entry,
|
|
814
|
-
children
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
return entry;
|
|
818
|
-
}).filter((entry) => entry !== void 0);
|
|
819
|
-
}
|
|
820
|
-
function getJSONFieldEntries(fields) {
|
|
821
|
-
if (!Array.isArray(fields)) {
|
|
822
|
-
return;
|
|
823
|
-
}
|
|
824
|
-
return fields.filter((field) => field.name && field.type).map((field) => {
|
|
825
|
-
const { name, type } = field;
|
|
826
|
-
const fieldType = fieldTypeNameByType[type];
|
|
827
|
-
if (!fieldType) {
|
|
828
|
-
return void 0;
|
|
829
|
-
}
|
|
830
|
-
const entry = {
|
|
831
|
-
type: fieldType,
|
|
832
|
-
name,
|
|
833
|
-
isRepeater: "occurrence" in field,
|
|
834
|
-
hasDefault: !!field.default,
|
|
835
|
-
children: []
|
|
836
|
-
};
|
|
837
|
-
if (fieldType === "GroupFieldType" && "children" in field) {
|
|
838
|
-
const children = getJSONFieldEntries(field.children);
|
|
839
|
-
return { ...entry, children };
|
|
840
|
-
}
|
|
841
|
-
return entry;
|
|
842
|
-
}).filter((entry) => entry !== void 0);
|
|
843
|
-
}
|
|
844
|
-
var OVERRIDE_TYPE = "Override";
|
|
845
|
-
var REQUIRED_TYPE = "Required";
|
|
846
|
-
var REPEATED_VAR = "_repeater";
|
|
847
|
-
var DEFAULT_VALUES_TYPE = "DefaultValues";
|
|
848
|
-
var CMS_COMPONENTS = "@hubspot/cms-components";
|
|
849
|
-
var CMS_COMPONENTS_FIELD_TYPES = `${CMS_COMPONENTS}/fields`;
|
|
850
|
-
var AUTO_GEN_COMMENT = "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.";
|
|
851
|
-
var createPropertySignature = (identifier, type) => ts.factory.createPropertySignature([], identifier, void 0, type);
|
|
852
|
-
var buildTypeFromField = (field, additionalNode) => {
|
|
853
|
-
const imports = [field.type];
|
|
854
|
-
const identifier = ts.factory.createIdentifier(field.name);
|
|
855
|
-
const baseType = ts.factory.createTypeReferenceNode(field.type);
|
|
856
|
-
const requiredType = ts.factory.createTypeReferenceNode(REQUIRED_TYPE, [
|
|
857
|
-
baseType
|
|
858
|
-
]);
|
|
859
|
-
let finalType = field.hasDefault ? requiredType : baseType;
|
|
860
|
-
if (additionalNode) {
|
|
861
|
-
const typeLiteral = ts.isTypeLiteralNode(additionalNode) ? additionalNode : ts.factory.createTypeLiteralNode([additionalNode]);
|
|
862
|
-
const repeaterName = ts.factory.createLiteralTypeNode(
|
|
863
|
-
ts.factory.createStringLiteral(REPEATED_VAR)
|
|
864
|
-
);
|
|
865
|
-
if (!field.isRepeater) {
|
|
866
|
-
imports.push(OVERRIDE_TYPE);
|
|
867
|
-
}
|
|
868
|
-
finalType = field.isRepeater ? ts.factory.createTypeReferenceNode("Array", [
|
|
869
|
-
ts.factory.createTypeReferenceNode("Record", [
|
|
870
|
-
repeaterName,
|
|
871
|
-
typeLiteral
|
|
872
|
-
])
|
|
873
|
-
]) : ts.factory.createTypeReferenceNode(OVERRIDE_TYPE, [
|
|
874
|
-
finalType,
|
|
875
|
-
typeLiteral
|
|
876
|
-
]);
|
|
877
|
-
}
|
|
878
|
-
return { type: createPropertySignature(identifier, finalType), imports };
|
|
879
|
-
};
|
|
880
|
-
function getImportDeclaration(imports, moduleSpecifier) {
|
|
881
|
-
const importSpecifiers = Array.from(imports).map(
|
|
882
|
-
(importName) => ts.factory.createImportSpecifier(
|
|
883
|
-
true,
|
|
884
|
-
void 0,
|
|
885
|
-
ts.factory.createIdentifier(importName)
|
|
886
|
-
)
|
|
887
|
-
);
|
|
888
|
-
const namedImports = ts.factory.createNamedImports(importSpecifiers);
|
|
889
|
-
return ts.factory.createImportDeclaration(
|
|
890
|
-
[],
|
|
891
|
-
[],
|
|
892
|
-
ts.factory.createImportClause(false, void 0, namedImports),
|
|
893
|
-
ts.factory.createStringLiteral(moduleSpecifier)
|
|
894
|
-
);
|
|
895
|
-
}
|
|
896
|
-
function getFieldTypes(fields) {
|
|
897
|
-
const imports = ["DefaultValues"];
|
|
898
|
-
const types = fields.map((field) => {
|
|
899
|
-
if (field.children) {
|
|
900
|
-
const childrenResult = getFieldTypes(field.children);
|
|
901
|
-
imports.push(...childrenResult.imports);
|
|
902
|
-
if (childrenResult.types.length) {
|
|
903
|
-
const subType = ts.factory.createTypeLiteralNode(childrenResult.types);
|
|
904
|
-
const childrenPropertySignature = createPropertySignature(
|
|
905
|
-
"children",
|
|
906
|
-
subType
|
|
907
|
-
);
|
|
908
|
-
const { type: type2, imports: newImports2 } = buildTypeFromField(
|
|
909
|
-
field,
|
|
910
|
-
field.isRepeater ? subType : childrenPropertySignature
|
|
911
|
-
);
|
|
912
|
-
imports.push(...newImports2);
|
|
913
|
-
return type2;
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
const { type, imports: newImports } = buildTypeFromField(field);
|
|
917
|
-
imports.push(...newImports);
|
|
918
|
-
return type;
|
|
919
|
-
});
|
|
920
|
-
return { types, imports: Array.from(new Set(imports)) };
|
|
921
|
-
}
|
|
922
|
-
function constructFinalType(fields, typeName) {
|
|
923
|
-
const { types, imports } = getFieldTypes(fields);
|
|
924
|
-
const importDeclaration = getImportDeclaration(
|
|
925
|
-
imports,
|
|
926
|
-
CMS_COMPONENTS_FIELD_TYPES
|
|
927
|
-
);
|
|
928
|
-
const baseType = ts.factory.createTypeAliasDeclaration(
|
|
929
|
-
[],
|
|
930
|
-
[],
|
|
931
|
-
"",
|
|
932
|
-
void 0,
|
|
933
|
-
ts.factory.createTypeLiteralNode(types)
|
|
934
|
-
);
|
|
935
|
-
const wrappedType = ts.factory.createTypeReferenceNode(DEFAULT_VALUES_TYPE, [
|
|
936
|
-
baseType.type
|
|
937
|
-
]);
|
|
938
|
-
const finalType = ts.factory.createTypeAliasDeclaration(
|
|
939
|
-
[],
|
|
940
|
-
[],
|
|
941
|
-
typeName,
|
|
942
|
-
void 0,
|
|
943
|
-
wrappedType
|
|
944
|
-
);
|
|
945
|
-
const defaultExport = ts.factory.createExportDefault(
|
|
946
|
-
ts.factory.createIdentifier(typeName)
|
|
947
|
-
);
|
|
948
|
-
return [importDeclaration, finalType, defaultExport];
|
|
949
|
-
}
|
|
950
|
-
function writeFieldsType(fields, fileName, typeName) {
|
|
951
|
-
const entries = getFieldEntries(fields);
|
|
952
|
-
if (!entries) {
|
|
953
|
-
return false;
|
|
954
|
-
}
|
|
955
|
-
try {
|
|
956
|
-
const file = ts.createSourceFile(
|
|
957
|
-
fileName,
|
|
958
|
-
"",
|
|
959
|
-
ts.ScriptTarget.ESNext,
|
|
960
|
-
false,
|
|
961
|
-
ts.ScriptKind.TS
|
|
962
|
-
);
|
|
963
|
-
const printer = ts.createPrinter();
|
|
964
|
-
const nodes = constructFinalType(entries, typeName);
|
|
965
|
-
const comments = [
|
|
966
|
-
AUTO_GEN_COMMENT,
|
|
967
|
-
"Removing the above comment will disable type generation for this module",
|
|
968
|
-
"This file was created by @hubspot/cms-dev-server, for more information see https://github.hubspot.com/cms-react/reference/js-modules.html#module-fields"
|
|
969
|
-
].map((comment) => `// ${comment}`);
|
|
970
|
-
const typeResult = nodes.map(
|
|
971
|
-
(node) => printer.printNode(ts.EmitHint.Unspecified, node, file)
|
|
972
|
-
);
|
|
973
|
-
const result = [...comments, ...typeResult].join("\n");
|
|
974
|
-
writeFileSync(fileName, result);
|
|
975
|
-
return true;
|
|
976
|
-
} catch (e) {
|
|
977
|
-
console.error(e);
|
|
978
|
-
return false;
|
|
979
|
-
}
|
|
980
|
-
}
|
|
981
720
|
function getServerGlobalsToInject(environmentConfig, hsServerPageUrl, hsBasePath, prettyPrint, criticalDevErrors, includeNonces) {
|
|
982
721
|
if (prettyPrint === void 0 && hsServerPageUrl && cmsComponents.isDebugUrlString) {
|
|
983
722
|
prettyPrint = cmsComponents.isDebugUrlString(hsServerPageUrl);
|
|
@@ -1054,7 +793,6 @@ function renderFieldsToJson(fields, moduleName) {
|
|
|
1054
793
|
}
|
|
1055
794
|
}
|
|
1056
795
|
export {
|
|
1057
|
-
AUTO_GEN_COMMENT,
|
|
1058
796
|
COMPONENT_EXTENSIONS,
|
|
1059
797
|
CSS_LANGS_RE,
|
|
1060
798
|
ENABLED_FEATURES_GATE_MAP,
|
|
@@ -1064,11 +802,9 @@ export {
|
|
|
1064
802
|
VIRTUAL_CONFIG_SETUP,
|
|
1065
803
|
VIRTUAL_ISLAND_RUNTIME,
|
|
1066
804
|
areBuildHealthChecksEnabled,
|
|
1067
|
-
buildTypeFromField,
|
|
1068
805
|
clientIslandEntryPlugin,
|
|
1069
806
|
collectCssInDev,
|
|
1070
807
|
collectCssModules,
|
|
1071
|
-
constructFinalType,
|
|
1072
808
|
createIslandsGlobalJsForClientInDev,
|
|
1073
809
|
doHealthChecksFailTheBuild,
|
|
1074
810
|
escapeForInlineJS,
|
|
@@ -1083,7 +819,6 @@ export {
|
|
|
1083
819
|
getComponentExtension,
|
|
1084
820
|
getEntryPointHash,
|
|
1085
821
|
getEntryPointHashWithIndexSuffix,
|
|
1086
|
-
getFieldTypes,
|
|
1087
822
|
getIslandRuntimeConfigUrl,
|
|
1088
823
|
getIslandUrls,
|
|
1089
824
|
getServerGlobalsToInject,
|
|
@@ -1110,6 +845,5 @@ export {
|
|
|
1110
845
|
serializeIslandDataForInlineScript,
|
|
1111
846
|
setIn,
|
|
1112
847
|
ungatedAtBuildTimeFor,
|
|
1113
|
-
virtualClientRenderIslandModuleId
|
|
1114
|
-
writeFieldsType
|
|
848
|
+
virtualClientRenderIslandModuleId
|
|
1115
849
|
};
|