@contentstack/studio-registry 0.1.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.
Files changed (35) hide show
  1. package/README.md +130 -0
  2. package/dist/cjs/index.cjs +5625 -0
  3. package/dist/cjs/index.cjs.map +1 -0
  4. package/dist/esm/breakpoint-registry/index.js +68 -0
  5. package/dist/esm/breakpoint-registry/index.js.map +1 -0
  6. package/dist/esm/component-registry/registry-options-processor.js +195 -0
  7. package/dist/esm/component-registry/registry-options-processor.js.map +1 -0
  8. package/dist/esm/component-registry/registry.constant.js +119 -0
  9. package/dist/esm/component-registry/registry.constant.js.map +1 -0
  10. package/dist/esm/component-registry/registry.js +245 -0
  11. package/dist/esm/component-registry/registry.js.map +1 -0
  12. package/dist/esm/data-binder/cslp.js +31 -0
  13. package/dist/esm/data-binder/cslp.js.map +1 -0
  14. package/dist/esm/data-binder/handle-binding-map.util.js +103 -0
  15. package/dist/esm/data-binder/handle-binding-map.util.js.map +1 -0
  16. package/dist/esm/data-binder/retrieve-data.js +146 -0
  17. package/dist/esm/data-binder/retrieve-data.js.map +1 -0
  18. package/dist/esm/data-binder/retrieve-data.util.js +177 -0
  19. package/dist/esm/data-binder/retrieve-data.util.js.map +1 -0
  20. package/dist/esm/design-registry/constants.js +386 -0
  21. package/dist/esm/design-registry/constants.js.map +1 -0
  22. package/dist/esm/design-registry/design-classes.js +36 -0
  23. package/dist/esm/design-registry/design-classes.js.map +1 -0
  24. package/dist/esm/design-registry/design-registry.js +87 -0
  25. package/dist/esm/design-registry/design-registry.js.map +1 -0
  26. package/dist/esm/design-registry/design-token.js +332 -0
  27. package/dist/esm/design-registry/design-token.js.map +1 -0
  28. package/dist/esm/index.d.ts +1196 -0
  29. package/dist/esm/index.js +12 -0
  30. package/dist/esm/index.js.map +1 -0
  31. package/dist/esm/json-rte-registry/index.js +18 -0
  32. package/dist/esm/json-rte-registry/index.js.map +1 -0
  33. package/dist/esm/utils/symbols.js +12 -0
  34. package/dist/esm/utils/symbols.js.map +1 -0
  35. package/package.json +62 -0
@@ -0,0 +1,68 @@
1
+ class BreakpointRegistry {
2
+ breakpoints = [];
3
+ requiredFields = ["id", "query", "previewSize"];
4
+ uniqueNames = new Set();
5
+ registerBreakpoints(breakpoints) {
6
+ // throw an error if first breakpoint is not default
7
+ if (breakpoints[0].id !== "default") {
8
+ throw new Error(`First breakpoint must be default`);
9
+ }
10
+ // throw an error if default breakpoint's query is present
11
+ if ("query" in breakpoints[0]) {
12
+ throw new Error(`Default breakpoint should not have a query`);
13
+ }
14
+ breakpoints.forEach((breakpoint) => {
15
+ // throw an error if breakpoints contain duplicate names
16
+ if (this.uniqueNames.has(breakpoint.id)) {
17
+ throw new Error(`Duplicate breakpoint name '${breakpoint.id}'`);
18
+ }
19
+ this.uniqueNames.add(breakpoint.id);
20
+ // throw an error if required fields are missing
21
+ this.requiredFields.forEach((field) => {
22
+ if (!(field in breakpoint)) {
23
+ if (breakpoint.id !== "default" && field !== "query") {
24
+ throw new Error(`Breakpoint '${field}' is required`);
25
+ }
26
+ }
27
+ });
28
+ });
29
+ const processedBreakpoints = this.processBreakpoints(breakpoints);
30
+ this.breakpoints = processedBreakpoints;
31
+ this.uniqueNames.clear();
32
+ }
33
+ getBreakpoints() {
34
+ return this.breakpoints;
35
+ }
36
+ getBreakpoint(id) {
37
+ // throw an error if breakpoint does not exist
38
+ const breakpoint = this.breakpoints.find((bp) => bp.id === id);
39
+ if (!breakpoint) {
40
+ throw new Error(`Breakpoint with ID '${id}' does not exist`);
41
+ }
42
+ return breakpoint;
43
+ }
44
+ setBreakpoint(breakpoints) {
45
+ this.breakpoints = breakpoints;
46
+ }
47
+ // process breakpoints
48
+ processBreakpoints(breakpoints) {
49
+ const updatedBreakpoints = [];
50
+ // add query to default breakpoint
51
+ updatedBreakpoints.push({
52
+ ...breakpoints[0],
53
+ query: "*",
54
+ displayName: breakpoints[0].displayName || breakpoints[0].id,
55
+ });
56
+ // assign name to display name if not present
57
+ breakpoints.slice(1).forEach((breakpoint) => {
58
+ updatedBreakpoints.push({
59
+ ...breakpoint,
60
+ displayName: breakpoint.displayName || breakpoint.id,
61
+ });
62
+ });
63
+ return updatedBreakpoints;
64
+ }
65
+ }
66
+
67
+ export { BreakpointRegistry };
68
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../src/breakpoint-registry/index.ts"],"sourcesContent":[null],"names":[],"mappings":"MAMa,kBAAkB,CAAA;IACrB,WAAW,GAAiB,EAAE;IAC9B,cAAc,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,aAAa,CAAU;AACxD,IAAA,WAAW,GAAG,IAAI,GAAG,EAAE;AAE/B,IAAA,mBAAmB,CAAC,WAA4B,EAAA;;QAE9C,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,SAAS,EAAE;AACnC,YAAA,MAAM,IAAI,KAAK,CAAC,CAAA,gCAAA,CAAkC,CAAC;QACrD;;AAGA,QAAA,IAAI,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;AAC7B,YAAA,MAAM,IAAI,KAAK,CAAC,CAAA,0CAAA,CAA4C,CAAC;QAC/D;AAEA,QAAA,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,KAAI;;YAEjC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE;gBACvC,MAAM,IAAI,KAAK,CAAC,CAAA,2BAAA,EAA8B,UAAU,CAAC,EAAE,CAAA,CAAA,CAAG,CAAC;YACjE;YACA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;;YAGnC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,KAAK,KAAI;AACpC,gBAAA,IAAI,EAAE,KAAK,IAAI,UAAU,CAAC,EAAE;oBAC1B,IAAI,UAAU,CAAC,EAAE,KAAK,SAAS,IAAI,KAAK,KAA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W,IAAI,UAAU,CAAC,EAAE;AACrD,aAAA,CAAC;AACJ,QAAA,CAAC,CAAC;AAEF,QAAA,OAAO,kBAAkB;IAC3B;AACD;;;;"}
@@ -0,0 +1,195 @@
1
+ import { clone } from 'lodash-es';
2
+ import { STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES } from './registry.constant.js';
3
+
4
+ function getDefaultComponentSchemaInput(options) {
5
+ return {
6
+ component: options.component,
7
+ type: options.name,
8
+ description: "",
9
+ displayName: options.name,
10
+ sections: [],
11
+ wrap: true,
12
+ thumbnailUrl: "",
13
+ hideFromContentCreators: false,
14
+ hideFromComponentList: false,
15
+ registry: "user-defined",
16
+ icon: "",
17
+ metadata: {},
18
+ styles: {
19
+ default: {
20
+ defaultClasses: [],
21
+ defaultStyles: {},
22
+ styleSections: getStyleSection(),
23
+ displayName: "default",
24
+ },
25
+ },
26
+ props: {},
27
+ };
28
+ }
29
+ function processRegistryOptions(userConfig, options) {
30
+ let propValidators = {};
31
+ if (!userConfig.type) {
32
+ throw new Error("Component type is required.");
33
+ }
34
+ if (userConfig.component !== null && !userConfig.component) {
35
+ throw new Error("Component is required.");
36
+ }
37
+ const defaultOptions = getDefaultComponentSchemaInput({
38
+ name: userConfig.type,
39
+ component: userConfig.component,
40
+ });
41
+ if (userConfig.props) {
42
+ const { props, validators } = processRegistryOptionsProps(userConfig.props);
43
+ defaultOptions.props = props;
44
+ propValidators = validators;
45
+ }
46
+ if (typeof userConfig.wrap !== "undefined") {
47
+ defaultOptions.wrap = userConfig.wrap;
48
+ }
49
+ if (userConfig.displayName) {
50
+ defaultOptions.displayName = userConfig.displayName;
51
+ }
52
+ if (userConfig.description) {
53
+ defaultOptions.description = userConfig.description;
54
+ }
55
+ if (userConfig.sections) {
56
+ if (Array.isArray(userConfig.sections)) {
57
+ defaultOptions.sections = userConfig.sections;
58
+ }
59
+ else {
60
+ defaultOptions.sections = [userConfig.sections];
61
+ }
62
+ }
63
+ defaultOptions.registry = options.registry;
64
+ if (userConfig.thumbnailUrl) {
65
+ defaultOptions.thumbnailUrl = userConfig.thumbnailUrl;
66
+ }
67
+ if (userConfig.styles) {
68
+ defaultOptions.styles = processRegistryOptionsStylesOptions(userConfig.styles);
69
+ }
70
+ if (typeof userConfig.hideFromContentCreators !== "undefined") {
71
+ defaultOptions.hideFromContentCreators = userConfig.hideFromContentCreators;
72
+ }
73
+ if (typeof userConfig.hideFromComponentList !== "undefined") {
74
+ defaultOptions.hideFromComponentList = userConfig.hideFromComponentList;
75
+ }
76
+ if ("icon" in userConfig && userConfig.icon) {
77
+ defaultOptions.icon = userConfig.icon;
78
+ }
79
+ if (userConfig.metadata) {
80
+ defaultOptions.metadata = userConfig.metadata;
81
+ }
82
+ return {
83
+ processedOptions: defaultOptions,
84
+ propValidators,
85
+ };
86
+ }
87
+ function processStylesOptionsStyleSections(styleSections, defaultStyleSections) {
88
+ if (typeof styleSections === "undefined" || styleSections === "all") {
89
+ return defaultStyleSections;
90
+ }
91
+ if (styleSections === "none") {
92
+ return [];
93
+ }
94
+ const styleSectionsOptionSet = new Set(STYLE_SECTIONS_OPTIONS);
95
+ const newStyleSections = [];
96
+ /**
97
+ * We use this for optimization to avoid adding the same style section multiple times.
98
+ */
99
+ const flags = {
100
+ block: false,
101
+ text: false,
102
+ };
103
+ for (const styleSection of styleSections) {
104
+ if (styleSection === "block") {
105
+ if (!flags.block) {
106
+ newStyleSections.push(...getBlockStyleSections());
107
+ flags.block = true;
108
+ }
109
+ }
110
+ else if (styleSection === "text") {
111
+ if (!flags.text) {
112
+ newStyleSections.push(...getTextStyleSections());
113
+ flags.text = true;
114
+ }
115
+ }
116
+ else if (styleSectionsOptionSet.has(styleSection)) {
117
+ newStyleSections.push(styleSection);
118
+ }
119
+ }
120
+ return Array.from(new Set(newStyleSections));
121
+ }
122
+ function processRegistryOptionsStylesOptions(stylesOptions) {
123
+ if (!stylesOptions) {
124
+ return {
125
+ default: {
126
+ defaultClasses: [],
127
+ defaultStyles: {},
128
+ styleSections: getStyleSection(),
129
+ displayName: "default",
130
+ },
131
+ };
132
+ }
133
+ const processedStylesOptions = {};
134
+ Object.entries(stylesOptions).forEach(([section, options]) => {
135
+ processedStylesOptions[section] = {
136
+ defaultClasses: options.defaultClasses ?? [],
137
+ defaultStyles: options.defaultStyles ?? {},
138
+ styleSections: processStylesOptionsStyleSections(options.styleSections, getStyleSection()),
139
+ displayName: options.displayName ?? section,
140
+ };
141
+ });
142
+ return processedStylesOptions;
143
+ }
144
+ function processRegistryOptionsProps(props) {
145
+ if (!props) {
146
+ return { props: {}, validators: {} };
147
+ }
148
+ const propValidators = {};
149
+ const processedProps = {};
150
+ for (const [field, prop] of Object.entries(props)) {
151
+ if (typeof prop === "string") {
152
+ processedProps[field] = getExpandedPropTypes(prop);
153
+ }
154
+ else {
155
+ if (prop.validate) {
156
+ propValidators[field] = prop.validate;
157
+ }
158
+ processedProps[field] = clone(prop);
159
+ delete processedProps[field].validate;
160
+ }
161
+ }
162
+ return { props: processedProps, validators: propValidators };
163
+ }
164
+ function getExpandedPropTypes(prop) {
165
+ const propTypeMapping = {
166
+ array: { type: "array", items: { type: "any" } },
167
+ string: { type: "string" },
168
+ number: { type: "number" },
169
+ boolean: { type: "boolean" },
170
+ object: { type: "object", properties: {} },
171
+ datestring: { type: "datestring" },
172
+ href: { type: "href" },
173
+ imageurl: { type: "imageurl" },
174
+ slot: { type: "slot" },
175
+ };
176
+ return propTypeMapping[prop];
177
+ }
178
+ function getBlockStyleSections() {
179
+ return STYLE_SECTION_CATEGORIES.block;
180
+ }
181
+ function getTextStyleSections() {
182
+ return STYLE_SECTION_CATEGORIES.text;
183
+ }
184
+ function getStyleSection() {
185
+ return [...STYLE_SECTIONS_OPTIONS];
186
+ }
187
+ function getDefaultComponentRegistryOptions() {
188
+ return {
189
+ allowedBuiltInComponents: true,
190
+ overrideDefaultComponents: false,
191
+ };
192
+ }
193
+
194
+ export { getDefaultComponentRegistryOptions, processRegistryOptions };
195
+ //# sourceMappingURL=registry-options-processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry-options-processor.js","sources":["../../../src/component-registry/registry-options-processor.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAqBA,SAAS,8BAA8B,CAAI,OAG1C,EAAA;IACC,OAAO;QACL,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,IAAI,EAAE,OAAO,CAAC,IAAI;AAClB,QAAA,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,OAAO,CAAC,IAAI;AACzB,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,IAAI,EAAE,IAAI;AACV,QAAA,YAAY,EAAE,EAAE;AAChB,QAAA,uBAAuB,EAAE,KAAK;AAC9B,QAAA,qBAAqB,EAAE,KAAK;AAC5B,QAAA,QAAQ,EAAE,cAAc;AACxB,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,MAAM,EAAE;AACN,YAAA,OAAO,EAAE;AACP,gBAAA,cAAc,EAAE,EAAE;AAClB,gBAAA,aAAa,EAAE,EAAE;gBACjB,aAAa,EAAE,eAAe,EAAE;AAChC,gBAAA,WAAW,EAAE,SAAS;AACvB,aAAA;AACF,SAAA;AACD,QAAA,KAAK,EAAE,EAAE;KACV;AACH;AAEM,SAAU,sBAAsB,CACpC,UAE4C,EAC5C,OAEC,EAAA;IAKD,IAAI,cAAc,GAAG,EAAE;AAEvB,IAAA,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE;AACpB,QAAA,MAAM,IAAI,KAAK,CAAC,6BAA6B,CAAC;IAChD;IAEA,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,SAAS,EAAE;AAC1D,QAAA,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC;IAC3C;IAEA,MAAM,cAAc,GAAG,8BAA8B,CAAC;QACpD,IAAI,EAAE,UAAU,CAAC,IAAI;QACrB,SAAS,EAAE,UAAU,CAAC,SAAS;AA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qBAAqB,GAAA;IAC5B,OAAO,wBAAwB,CAAC,KAAK;AACvC;AAEA,SAAS,oBAAoB,GAAA;IAC3B,OAAO,wBAAwB,CAAC,IAAI;AACtC;AAEA,SAAS,eAAe,GAAA;AACtB,IAAA,OAAO,CAAC,GAAG,sBAAsB,CAAC;AACpC;SAEgB,kCAAkC,GAAA;IAChD,OAAO;AACL,QAAA,wBAAwB,EAAE,IAAI;AAC9B,QAAA,yBAAyB,EAAE,KAAK;KACjC;AACH;;;;"}
@@ -0,0 +1,119 @@
1
+ const DATA_SOURCES_PREFIX = "dataSources";
2
+ const DATA_SOURCES = {
3
+ COMPONENT_PROPS: "component_props",
4
+ STATIC_VALUE: "static_value",
5
+ TEMPLATE: "template",
6
+ CONTENTSTACK: "contentstack",
7
+ REPEATER: "repeater",
8
+ SYMBOL_PROPS: "symbol_props",
9
+ };
10
+ const INTERNAL_COMPONENT_SECTIONS = {
11
+ BASIC: "Basic",
12
+ MEDIA: "Media",
13
+ CONTAINER: "Container",
14
+ SMART_CONTAINER: "Smart Containers",
15
+ ADVANCED: "Advanced",
16
+ REGISTERED_COMPONENTS: "Registered Components",
17
+ HTML_ELEMENT: "HTML Elements",
18
+ SYMBOL: "Symbols",
19
+ };
20
+ const INTERNAL_SECTIONS = Object.values(INTERNAL_COMPONENT_SECTIONS);
21
+ const STYLE_SECTIONS_OPTIONS = [
22
+ "class",
23
+ "size",
24
+ "spacing",
25
+ "position",
26
+ "visibility",
27
+ "layout",
28
+ "typography",
29
+ "transform",
30
+ "media",
31
+ "background",
32
+ "shadow",
33
+ "effect",
34
+ "overflow",
35
+ "border",
36
+ "responsive",
37
+ ];
38
+ /**
39
+ * The style group is the group of the style sections options.
40
+ * When a style group is selected, all the styles
41
+ * corresponding to it will be extracted from the
42
+ */
43
+ const STYLE_SECTION_CATEGORIES = {
44
+ block: [
45
+ "class",
46
+ "size",
47
+ "spacing",
48
+ "position",
49
+ "visibility",
50
+ "layout",
51
+ "background",
52
+ "shadow",
53
+ "effect",
54
+ "overflow",
55
+ "border",
56
+ "responsive",
57
+ ],
58
+ text: ["typography"],
59
+ };
60
+ const INTERNAL_COMPONENTS_NAMES = {
61
+ // * System
62
+ PAGE: "page",
63
+ // * Basic
64
+ HEADER: "header",
65
+ LINK: "link",
66
+ LINK_CONTAINER: "link-container",
67
+ TEXT: "text",
68
+ BUTTON: "button",
69
+ JSON_RTE: "json-rte",
70
+ COLLAPSIBLE_TEXT: "collapsible-text",
71
+ PLAIN_TEXT: "plain-text",
72
+ // * Media
73
+ VIDEO: "video",
74
+ EMBED: "embed",
75
+ IMAGE: "image",
76
+ // * Container
77
+ SECTION: "section",
78
+ BOX: "box",
79
+ COLUMNS: "hstack",
80
+ ROWS: "vstack",
81
+ REPEATER: "repeater",
82
+ CONDITION_BLOCK: "condition-block",
83
+ SYMBOL: "symbol",
84
+ FRAGMENT: "fragment",
85
+ // * HTML Elements
86
+ HTML_ELEMENT: "html-element",
87
+ STYLE_SHEET: "style-sheet",
88
+ };
89
+ /**
90
+ * System components are protected components that are not intended to be modified or removed.
91
+ */
92
+ const SYSTEM_COMPONENTS = /* #__PURE__ */ new Set(Object.values([INTERNAL_COMPONENTS_NAMES.PAGE]));
93
+ /**
94
+ * Built-in components are components that are included in the component registry by default.
95
+ * User can opt-out of including these components in the registry by setting the
96
+ * `includeBuiltInComponents` option to `false`.
97
+ */
98
+ const BUILT_IN_COMPONENTS = {
99
+ // * Basic
100
+ HEADER: "header",
101
+ LINK: "link",
102
+ LINK_CONTAINER: "link-container",
103
+ TEXT: "text",
104
+ BUTTON: "button",
105
+ JSON_RTE: "json-rte",
106
+ COLLAPSIBLE_TEXT: "collapsible-text",
107
+ // * Media
108
+ VIDEO: "video",
109
+ EMBED: "embed",
110
+ IMAGE: "image",
111
+ // * Container
112
+ SECTION: "section",
113
+ BOX: "box",
114
+ COLUMNS: "hstack",
115
+ ROWS: "vstack",
116
+ };
117
+
118
+ export { BUILT_IN_COMPONENTS, DATA_SOURCES, DATA_SOURCES_PREFIX, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS };
119
+ //# sourceMappingURL=registry.constant.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.constant.js","sources":["../../../src/component-registry/registry.constant.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,MAAM,mBAAmB,GAAG;AAE5B,MAAM,YAAY,GAAG;AAC1B,IAAA,eAAe,EAAE,iBAAiB;AAClC,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,YAAY,EAAE,cAAc;AAC5B,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,YAAY,EAAE,cAAc;;AAGvB,MAAM,2BAA2B,GAAG;AACzC,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,KAAK,EAAE,OAAO;AACd,IAAA,SAAS,EAAE,WAAW;AACtB,IAAA,eAAe,EAAE,kBAAkB;AACnC,IAAA,QAAQ,EAAE,UAAU;AACpB,IAAA,qBAAqB,EAAE,uBAAuB;AAC9C,IAAA,YAAY,EAAE,eAAe;AAC7B,IAAA,MAAM,EAAE,SAAS;;AAGZ,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC,2BAA2B;AAEnE,MAAM,sBAAsB,GAAG;IACpC,OAAO;IACP,MAAM;IACN,SAAS;IACT,UAAU;IACV,YAAY;IACZ,QAAQ;IACR,YAAY;IACZ,WAAW;IACX,OAAO;IACP,YAAY;IACZ,QAAQ;IACR,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,YAAY;;AAGd;;;;AAIG;AACI,MAAM,wBAAwB,GAAG;AACtC,IAAA,KAAK,EAAE;QACL,OAAO;QACP,MAAM;QACN,SAAS;QACT,UAAU;QACV,YAAY;QACZ,QAAQ;QACR,YAAY;QACZ,QAAQ;QACR,QAAQ;QACR,UAAU;Q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,IAAA,KAAK,EAAE,OAAO;;AAGd,IAAA,OAAO,EAAE,SAAS;AAClB,IAAA,GAAG,EAAE,KAAK;AACV,IAAA,OAAO,EAAE,QAAQ;AACjB,IAAA,IAAI,EAAE,QAAQ;;;;;"}
@@ -0,0 +1,245 @@
1
+ import { getSymbolUIDFromUID, getSymbolUIDFromNode } from '../utils/symbols.js';
2
+ import { getDefaultComponentRegistryOptions, processRegistryOptions } from './registry-options-processor.js';
3
+ import { BUILT_IN_COMPONENTS, SYSTEM_COMPONENTS, INTERNAL_COMPONENT_SECTIONS } from './registry.constant.js';
4
+
5
+ class ComponentRegistry {
6
+ componentRegistry = new Map();
7
+ propValidatorRegistry = new Map();
8
+ config;
9
+ constructor(config) {
10
+ // TODO process options
11
+ this.config = config || getDefaultComponentRegistryOptions();
12
+ this.updateRegistry = this.updateRegistry.bind(this);
13
+ this.registerInternalComponent = this.registerInternalComponent.bind(this);
14
+ this.registerComponents = this.registerComponents.bind(this);
15
+ this.getComponents = this.getComponents.bind(this);
16
+ this.getComponent = this.getComponent.bind(this);
17
+ this.hasComponent = this.hasComponent.bind(this);
18
+ }
19
+ setConfig(config = {}) {
20
+ if (config.allowedBuiltInComponents !== undefined) {
21
+ this.config.allowedBuiltInComponents = config.allowedBuiltInComponents;
22
+ // If allowedBuiltInComponents is true, we don't need to do anything as components
23
+ // will be registered when needed. If it's an array, we'll keep only the specified ones
24
+ if (Array.isArray(this.config.allowedBuiltInComponents)) {
25
+ // Filter out any component names that aren't actually built-in components
26
+ const validComponents = this.config.allowedBuiltInComponents.filter((name) => Object.values(BUILT_IN_COMPONENTS).includes(name));
27
+ if (validComponents.length !==
28
+ this.config.allowedBuiltInComponents.length &&
29
+ this.config.debug) {
30
+ console.warn("Some specified component names are not valid built-in components");
31
+ }
32
+ this.config.allowedBuiltInComponents = validComponents;
33
+ // un-register not allowed components
34
+ Object.values(BUILT_IN_COMPONENTS).forEach((componentName) => {
35
+ if (!validComponents.includes(componentName)) {
36
+ this.unregisterComponent(componentName);
37
+ }
38
+ });
39
+ }
40
+ else if (!this.config.allowedBuiltInComponents) {
41
+ // If explicitly set to false, ensure we unregister all built-in components
42
+ Object.values(BUILT_IN_COMPONENTS).forEach((componentName) => {
43
+ this.unregisterComponent(componentName);
44
+ });
45
+ }
46
+ }
47
+ if (config.overrideDefaultComponents !== undefined) {
48
+ this.config.overrideDefaultComponents = config.overrideDefaultComponents;
49
+ }
50
+ }
51
+ /**
52
+ * Updates the component registry with the provided configuration.
53
+ * This method is **UNSAFE** and should be used if the updated config is
54
+ * already processed.
55
+ * @param updatedConfig - An array of component configurations to update the registry with.
56
+ */
57
+ updateRegistry(updatedConfig) {
58
+ updatedConfig.forEach((componentConfig) => {
59
+ const { type: name } = componentConfig;
60
+ this.componentRegistry.set(name, componentConfig);
61
+ });
62
+ // sync unregistered components
63
+ this.componentRegistry.forEach((componentConfig) => {
64
+ if (!updatedConfig.some((c) => c.type === componentConfig.type)) {
65
+ this.unregisterComponent(componentConfig.type);
66
+ }
67
+ });
68
+ }
69
+ /**
70
+ * This acts like PATCH for the component registry.
71
+ * @param components - An array of component configurations to update the registry with.
72
+ */
73
+ updateComponents(components) {
74
+ components.forEach((component) => {
75
+ if (!component.type) {
76
+ throw new Error("Component type is required.");
77
+ }
78
+ const { type } = component;
79
+ const existingComponent = this.componentRegistry.get(type);
80
+ if (!existingComponent) {
81
+ throw new Error(`Component with type '${type}' is not registered.`);
82
+ }
83
+ const newComponent = {
84
+ ...existingComponent,
85
+ ...component,
86
+ };
87
+ this.componentRegistry.set(type, newComponent);
88
+ });
89
+ }
90
+ /**
91
+ * Registers internal components with the component registry.
92
+ *
93
+ * @param componentConfigs - An array of component configurations to register.
94
+ * @throws {Error} If a component name is missing.
95
+ */
96
+ registerInternalComponent(componentConfigs, options = {}) {
97
+ componentConfigs.forEach((componentConfig) => {
98
+ const { type } = componentConfig;
99
+ if (!type) {
100
+ throw new Error("Component type is required.");
101
+ }
102
+ if (!this.config.allowedBuiltInComponents &&
103
+ !SYSTEM_COMPONENTS.has(type)) {
104
+ if (this.config.debug) {
105
+ console.warn("Default components are not allowed.");
106
+ }
107
+ }
108
+ // If already have and override not allowed continue with registered version
109
+ if (this.componentRegistry.has(type) && !options.overrideComponents) {
110
+ return;
111
+ }
112
+ const { processedOptions, propValidators } = processRegistryOptions(componentConfig, {
113
+ registry: "internal",
114
+ });
115
+ this.componentRegistry.set(type, processedOptions);
116
+ this.propValidatorRegistry.set(type, propValidators);
117
+ });
118
+ }
119
+ /**
120
+ * Registers list of symbol components in the component registry
121
+ * @param componentsConfigs
122
+ */
123
+ registerSymbolComponent(componentsConfigs) {
124
+ componentsConfigs.forEach((componentConfig) => {
125
+ // ComponentConfig.name for symbols are UID we are prefixing it with INTERNAL_COMPONENTS_NAMES.SYMBOL
126
+ componentConfig["type"] = getSymbolUIDFromUID(componentConfig.type);
127
+ const { type } = componentConfig;
128
+ componentConfig["sections"] = [INTERNAL_COMPONENT_SECTIONS.SYMBOL];
129
+ // TODO: Check if this works for symbol components
130
+ const { processedOptions } = processRegistryOptions(componentConfig, {
131
+ registry: "symbols",
132
+ });
133
+ this.componentRegistry.set(type, processedOptions);
134
+ });
135
+ }
136
+ /**
137
+ * Registers one or more components in the component registry.
138
+ * @param components - An array of component options to register.
139
+ */
140
+ registerComponents(components) {
141
+ components.forEach((componentOption) => {
142
+ const { type } = componentOption;
143
+ if (!type) {
144
+ throw new Error("Component type is required.");
145
+ }
146
+ if (this.componentRegistry.has(type) &&
147
+ !this.config.overrideDefaultComponents) {
148
+ throw new Error(`Component with type '${type}' is already registered.`);
149
+ }
150
+ if (SYSTEM_COMPONENTS.has(type)) {
151
+ throw new Error(`Component with type '${type}' is a system component and cannot be overridden.`);
152
+ }
153
+ const { processedOptions, propValidators } = processRegistryOptions(componentOption, {
154
+ registry: "user-defined",
155
+ });
156
+ this.componentRegistry.set(type, processedOptions);
157
+ this.propValidatorRegistry.set(type, propValidators);
158
+ });
159
+ }
160
+ /**
161
+ * Retrieves an array of component registry values.
162
+ *
163
+ * @param options - An optional object containing the registry option.
164
+ * @returns An array of component registry values.
165
+ */
166
+ getComponents(options) {
167
+ let componentConfigs = Array.from(this.componentRegistry.values());
168
+ if (options?.registry) {
169
+ componentConfigs = componentConfigs.filter((component) => component.registry === options.registry);
170
+ }
171
+ if (options?.excludeSystemComponents) {
172
+ componentConfigs = componentConfigs.filter((component) => !SYSTEM_COMPONENTS.has(component.type));
173
+ }
174
+ return componentConfigs;
175
+ }
176
+ /**
177
+ * Retrieves a component from the component registry by its name.
178
+ *
179
+ * @param name - The name of the component to retrieve.
180
+ * @returns The component registry value for the specified component name.
181
+ * @throws Error if the component with the specified name is not registered.
182
+ */
183
+ getComponent(name) {
184
+ if (!this.componentRegistry.has(name)) {
185
+ throw new Error(`Component with type '${name}' is not registered.`);
186
+ }
187
+ return this.componentRegistry.get(name);
188
+ }
189
+ /**
190
+ * Retrieves a component from the component registry by its name.
191
+ *
192
+ * @param node - The node of the component to retrieve.
193
+ * @returns The component registry value for the specified component name.
194
+ * @throws Error if the component with the specified name is not registered.
195
+ */
196
+ getComponentByNode(node, suppressError = true) {
197
+ const name = this.getComponentName(node);
198
+ if (!this.componentRegistry.has(name) && !suppressError) {
199
+ throw new Error(`Component with name '${name}' is not registered.`);
200
+ }
201
+ if (!this.componentRegistry.has(name)) {
202
+ return;
203
+ }
204
+ return this.componentRegistry.get(name);
205
+ }
206
+ hasComponent(node) {
207
+ const name = this.getComponentName(node);
208
+ return this.componentRegistry.has(name);
209
+ }
210
+ unregisterComponent(node) {
211
+ const name = typeof node === "string" ? node : this.getComponentName(node);
212
+ if (!this.componentRegistry.has(name)) {
213
+ console.error(`Component with name '${name}' is not registered.`);
214
+ return;
215
+ }
216
+ if (SYSTEM_COMPONENTS.has(name)) {
217
+ console.error(`Component with name '${name}' is a system component and cannot be unregistered.`);
218
+ return;
219
+ }
220
+ this.componentRegistry.delete(name);
221
+ this.propValidatorRegistry.delete(name);
222
+ }
223
+ validateProp(componentName, propName, value) {
224
+ const propValidators = this.propValidatorRegistry.get(componentName);
225
+ const propValidator = propValidators?.[propName];
226
+ if (!propValidator) {
227
+ return true;
228
+ }
229
+ return propValidator(value);
230
+ }
231
+ getComponentName(node) {
232
+ const { type } = node;
233
+ if (type === "symbol") {
234
+ // If node is under editing mode return symbol to be rendered by symbol component
235
+ if (Object.keys(node.slots).length > 0) {
236
+ return type;
237
+ }
238
+ return getSymbolUIDFromNode(node);
239
+ }
240
+ return type;
241
+ }
242
+ }
243
+
244
+ export { ComponentRegistry };
245
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sources":["../../../src/component-registry/registry.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;MA4Ba,iBAAiB,CAAA;AACpB,IAAA,iBAAiB,GACvB,IAAI,GAAG,EAAE;AACH,IAAA,qBAAqB,GAGzB,IAAI,GAAG,EAAE;AACL,IAAA,MAAM;AAEd,IAAA,WAAA,CAAY,MAAiC,EAAA;;AAE3C,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,kCAAkC,EAAE;QAE5D,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC;QACpD,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;QAC1E,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC;QAClD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;QAChD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC;IAClD;IAEA,SAAS,CAAC,SAA4C,EAAE,EAAA;AACtD,QAAA,IAAI,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