@contentstack/studio-registry 1.3.0 → 1.5.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/cjs/index.cjs +529 -84
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/component-registry/registry-options-processor.js +27 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.constant.js +3 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +171 -4
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/component-registry/singleton.js +59 -0
- package/dist/esm/component-registry/singleton.js.map +1 -0
- package/dist/esm/data-binder/cslp.js +4 -1
- package/dist/esm/data-binder/cslp.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +107 -30
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +70 -52
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- package/dist/esm/data-binder/strategies/contentstack.js +19 -0
- package/dist/esm/data-binder/strategies/contentstack.js.map +1 -0
- package/dist/esm/data-binder/strategies/dataSourceCapabilities.js +12 -0
- package/dist/esm/data-binder/strategies/dataSourceCapabilities.js.map +1 -0
- package/dist/esm/data-binder/strategies/query.js +17 -0
- package/dist/esm/data-binder/strategies/query.js.map +1 -0
- package/dist/esm/data-binder/strategies/repeater.js +18 -0
- package/dist/esm/data-binder/strategies/repeater.js.map +1 -0
- package/dist/esm/data-binder/strategies/template.js +16 -0
- package/dist/esm/data-binder/strategies/template.js.map +1 -0
- package/dist/esm/data-binder/strategies/utils.js +20 -0
- package/dist/esm/data-binder/strategies/utils.js.map +1 -0
- package/dist/esm/data-binder/strategy-registry.js +20 -0
- package/dist/esm/data-binder/strategy-registry.js.map +1 -0
- package/dist/esm/index.d.ts +132 -3
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/package.json +13 -10
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NodePropType, NodePropTypes, Node, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot
|
|
1
|
+
import { NodePropType, NodePropTypes, Node, BindingType, NodePropStaticValueTypes, BindableNodePropType, NodePropsWithSlot } from '@contentstack/studio-internal';
|
|
2
2
|
import { Properties } from 'csstype';
|
|
3
3
|
import { IJsonToHtmlOptions } from '@contentstack/json-rte-serializer';
|
|
4
4
|
import * as React from 'react';
|
|
@@ -50,7 +50,24 @@ type ImageUrlProp = PropBase<NodePropTypes["imageurl"], string>;
|
|
|
50
50
|
type ObjectProp = PropBase<NodePropTypes["object"], Record<string, unknown>> & {
|
|
51
51
|
properties: Props;
|
|
52
52
|
};
|
|
53
|
-
type SlotProp = PropBase<NodePropTypes["slot"], Node[]
|
|
53
|
+
type SlotProp = PropBase<NodePropTypes["slot"], Node[]> & {
|
|
54
|
+
/**
|
|
55
|
+
* References a `NumberProp` by name that controls how many children this slot holds.
|
|
56
|
+
* When the linked number prop value changes, slot children are automatically
|
|
57
|
+
* added or removed to match the count.
|
|
58
|
+
*/
|
|
59
|
+
countProp?: string;
|
|
60
|
+
/**
|
|
61
|
+
* Factory function that creates a new child node when the slot needs to grow.
|
|
62
|
+
* Required when `countProp` is specified.
|
|
63
|
+
*/
|
|
64
|
+
itemFactory?: () => Node;
|
|
65
|
+
/**
|
|
66
|
+
* Pre-computed serializable node template, generated from `itemFactory` during registration.
|
|
67
|
+
* Used by composable-studio to create new slot children across the postMessage boundary.
|
|
68
|
+
*/
|
|
69
|
+
itemTemplate?: Node;
|
|
70
|
+
};
|
|
54
71
|
type ChoiceProp = PropBase<NodePropTypes["choice"], string[]> & {
|
|
55
72
|
options: string[] | {
|
|
56
73
|
value: string | number | boolean;
|
|
@@ -97,6 +114,7 @@ declare const DATA_SOURCES: {
|
|
|
97
114
|
readonly TEMPLATE: "template";
|
|
98
115
|
readonly CONTENTSTACK: "contentstack";
|
|
99
116
|
readonly REPEATER: "repeater";
|
|
117
|
+
readonly QUERY: "contentstack_queries";
|
|
100
118
|
readonly SYMBOL_PROPS: "symbol_props";
|
|
101
119
|
};
|
|
102
120
|
declare const INTERNAL_COMPONENT_SECTIONS: {
|
|
@@ -126,6 +144,7 @@ declare const INTERNAL_COMPONENTS_NAMES: {
|
|
|
126
144
|
readonly LINK: "link";
|
|
127
145
|
readonly LINK_CONTAINER: "link-container";
|
|
128
146
|
readonly TEXT: "text";
|
|
147
|
+
readonly NUMBER: "number";
|
|
129
148
|
readonly BUTTON: "button";
|
|
130
149
|
readonly JSON_RTE: "json-rte";
|
|
131
150
|
readonly COLLAPSIBLE_TEXT: "collapsible-text";
|
|
@@ -158,6 +177,7 @@ declare const BUILT_IN_COMPONENTS: {
|
|
|
158
177
|
readonly LINK: "link";
|
|
159
178
|
readonly LINK_CONTAINER: "link-container";
|
|
160
179
|
readonly TEXT: "text";
|
|
180
|
+
readonly NUMBER: "number";
|
|
161
181
|
readonly BUTTON: "button";
|
|
162
182
|
readonly JSON_RTE: "json-rte";
|
|
163
183
|
readonly COLLAPSIBLE_TEXT: "collapsible-text";
|
|
@@ -289,6 +309,9 @@ declare class ComponentRegistry<C> {
|
|
|
289
309
|
private componentRegistry;
|
|
290
310
|
private propValidatorRegistry;
|
|
291
311
|
private config;
|
|
312
|
+
private componentLoaders;
|
|
313
|
+
private loadedComponents;
|
|
314
|
+
private loadingPromises;
|
|
292
315
|
constructor(config?: ComponentRegistryOptions);
|
|
293
316
|
setConfig(config?: Partial<ComponentRegistryOptions>): void;
|
|
294
317
|
/**
|
|
@@ -354,8 +377,105 @@ declare class ComponentRegistry<C> {
|
|
|
354
377
|
unregisterComponent(node: Node | string): void;
|
|
355
378
|
validateProp<V>(componentName: string, propName: string, value: V): ReturnType<PropValidator<V>>;
|
|
356
379
|
getComponentName(node: Node): string;
|
|
380
|
+
/**
|
|
381
|
+
* Registers a lazy-loadable component with a loader function.
|
|
382
|
+
* The component will be loaded on-demand when needed.
|
|
383
|
+
*
|
|
384
|
+
* @param config - Component configuration without the component itself
|
|
385
|
+
* @param loader - Function that returns a Promise resolving to the component
|
|
386
|
+
* @param registryType - Type of registry (internal or user-defined), defaults to user-defined
|
|
387
|
+
*/
|
|
388
|
+
registerLazyComponent(config: Omit<RegisterComponentOptionsInput<C>, "component">, loader: () => Promise<C>, registryType?: Registry): void;
|
|
389
|
+
/**
|
|
390
|
+
* Loads a single component if it's registered as lazy and not yet loaded.
|
|
391
|
+
* Returns immediately if already loaded or not a lazy component.
|
|
392
|
+
*
|
|
393
|
+
* @param componentType - The type of component to load
|
|
394
|
+
* @returns Promise that resolves when the component is loaded
|
|
395
|
+
*/
|
|
396
|
+
loadComponent(componentType: string): Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Loads multiple components in parallel.
|
|
399
|
+
* Deduplicates requests and uses caching.
|
|
400
|
+
*
|
|
401
|
+
* @param componentTypes - Array of component types to load
|
|
402
|
+
* @returns Promise that resolves when all components are loaded
|
|
403
|
+
*/
|
|
404
|
+
loadComponents(componentTypes: string[]): Promise<void>;
|
|
405
|
+
/**
|
|
406
|
+
* Checks if a component is registered as lazy-loadable.
|
|
407
|
+
*
|
|
408
|
+
* @param componentType - The type of component to check
|
|
409
|
+
* @returns true if the component is lazy-loadable
|
|
410
|
+
*/
|
|
411
|
+
isLazyComponent(componentType: string): boolean;
|
|
412
|
+
/**
|
|
413
|
+
* Checks if a lazy component has been loaded.
|
|
414
|
+
*
|
|
415
|
+
* @param componentType - The type of component to check
|
|
416
|
+
* @returns true if the component has been loaded
|
|
417
|
+
*/
|
|
418
|
+
isComponentLoaded(componentType: string): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Checks if a component has a loader registered (lazy) or is already registered (eager).
|
|
421
|
+
* This is useful for SSR validation to ensure components are available before rendering.
|
|
422
|
+
*
|
|
423
|
+
* @param componentType - The type of component to check
|
|
424
|
+
* @returns true if the component has a loader or is registered
|
|
425
|
+
*/
|
|
426
|
+
hasComponentLoader(componentType: string): boolean;
|
|
427
|
+
/**
|
|
428
|
+
* Gets all component types that have loaders registered (lazy components).
|
|
429
|
+
* Useful for debugging and SSR setup validation.
|
|
430
|
+
*
|
|
431
|
+
* @returns Array of component types with lazy loaders
|
|
432
|
+
*/
|
|
433
|
+
getLazyComponentTypes(): string[];
|
|
434
|
+
/**
|
|
435
|
+
* Gets all registered component types (both lazy and eager).
|
|
436
|
+
* Useful for debugging and validation.
|
|
437
|
+
*
|
|
438
|
+
* @returns Array of all registered component types
|
|
439
|
+
*/
|
|
440
|
+
getAllComponentTypes(): string[];
|
|
357
441
|
}
|
|
358
442
|
|
|
443
|
+
/**
|
|
444
|
+
* Gets the singleton ComponentRegistry instance.
|
|
445
|
+
* Creates it if it doesn't exist yet.
|
|
446
|
+
*
|
|
447
|
+
* @returns The singleton ComponentRegistry instance
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
* ```typescript
|
|
451
|
+
* import { getComponentRegistryInstance } from '@contentstack/studio-registry';
|
|
452
|
+
*
|
|
453
|
+
* const registry = getComponentRegistryInstance();
|
|
454
|
+
* await registry.loadComponent('my-component');
|
|
455
|
+
* ```
|
|
456
|
+
*/
|
|
457
|
+
declare function getComponentRegistryInstance(): ComponentRegistry<any>;
|
|
458
|
+
/**
|
|
459
|
+
* Resets the singleton instance.
|
|
460
|
+
* Primarily useful for testing to ensure a clean state between tests.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
* ```typescript
|
|
464
|
+
* import { resetComponentRegistryInstance } from '@contentstack/studio-registry';
|
|
465
|
+
*
|
|
466
|
+
* beforeEach(() => {
|
|
467
|
+
* resetComponentRegistryInstance();
|
|
468
|
+
* });
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
declare function resetComponentRegistryInstance(): void;
|
|
472
|
+
/**
|
|
473
|
+
* Checks if the singleton instance has been created.
|
|
474
|
+
*
|
|
475
|
+
* @returns true if the instance exists, false otherwise
|
|
476
|
+
*/
|
|
477
|
+
declare function hasComponentRegistryInstance(): boolean;
|
|
478
|
+
|
|
359
479
|
type DesignTokensInput = Partial<SectionDesignTokens> & Partial<GlobalDesignTokens>;
|
|
360
480
|
type DesignTokensInputKeys = keyof DesignTokensInput;
|
|
361
481
|
type GlobalDesignTokens = {
|
|
@@ -1144,7 +1264,16 @@ declare function getDefaultPropStaticValue<K extends BindableNodePropType>(args:
|
|
|
1144
1264
|
declare function isKnownType(type: string): type is PropType;
|
|
1145
1265
|
declare function getSlotData<T>({ nodeProps, field, node, getSlots, }: GetSlotDataArgs<T>): T | null;
|
|
1146
1266
|
declare function getPlaceHolderComponent<T>(placeholders: PlaceHolders<T>, prop: PropInput, type: BindableNodePropType): any;
|
|
1267
|
+
|
|
1147
1268
|
declare const getBindingString: (binding: BindingType) => string;
|
|
1269
|
+
declare const convertBindingPath: (bindingType: string, path: string) => string | string[];
|
|
1270
|
+
declare const getFlattenedData: (data: any) => any;
|
|
1271
|
+
/**
|
|
1272
|
+
* Composition/static data often stores single-select choice as `string[]` (one element).
|
|
1273
|
+
* `isDataMatchingPropType` treats `choice` as a `string` or `string[]` (multi-select);
|
|
1274
|
+
* single-select stored as `string[]` must still be unwrapped here before the type-mismatch fallback.
|
|
1275
|
+
*/
|
|
1276
|
+
declare function normalizeSingleSelectChoiceValue(resolvedData: unknown, prop: PropInput): unknown;
|
|
1148
1277
|
declare const resolveMetadataBindings: (node: Node, data: ComposableStudioData) => void;
|
|
1149
1278
|
declare const getRepeaterContextPath: (binding: RepeaterBindingValue) => string;
|
|
1150
1279
|
declare function isDataMatchingPropType(data: unknown, type: BindableNodePropType): boolean;
|
|
@@ -1193,5 +1322,5 @@ declare class BreakpointRegistry {
|
|
|
1193
1322
|
declare const getSymbolUIDFromNode: (symbol: Node) => string;
|
|
1194
1323
|
declare const getSymbolUIDFromUID: (uid: string) => string;
|
|
1195
1324
|
|
|
1196
|
-
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, getBindingString, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSlotData, getSymbolUIDFromNode, getSymbolUIDFromUID, isDataMatchingPropType, isKnownType, resolveMetadataBindings, retrievePropValue };
|
|
1325
|
+
export { ALLOWED_DESIGN_VALUES_LEVELS, BUILT_IN_COMPONENTS, BreakpointRegistry, ComponentRegistry, DATA_SOURCES, DATA_SOURCES_PREFIX, DEFAULT_DESIGN_TOKENS, DesignRegistry, INTERNAL_COMPONENTS_NAMES, INTERNAL_COMPONENT_SECTIONS, INTERNAL_SECTIONS, JSONRTERegistry, STYLE_SECTIONS_OPTIONS, STYLE_SECTION_CATEGORIES, SYSTEM_COMPONENTS, convertBindingPath, getBindingString, getComponentRegistryInstance, getCslpPath, getCslpTag, getDataType, getDefaultPropStaticValue, getDesignClassesNames, getFlattenedData, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSlotData, getSymbolUIDFromNode, getSymbolUIDFromUID, hasComponentRegistryInstance, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resetComponentRegistryInstance, resolveMetadataBindings, retrievePropValue };
|
|
1197
1326
|
export type { AllowedDesignValues, AllowedDesignValuesLevel, AnyProp, ArrayProp, BooleanProp, Breakpoint, BreakpointInput, CSBindingPath, CSDataSources, ChoiceProp, ComponentRegistryOptions, ComponentType, ComposableStudioData, ContentstackBindingValue, CssVariablesToDesignTokens, CssVariablesToValue, DataSourceItem, DataSources, DateStringProp, DefaultBreakpoint, DesignClassValue, DesignClasses, DesignClassesInput, DesignClassesNames, DesignTokenCssVariable, DesignTokens, DesignTokensInput, DesignTokensInputKeys, DesignTokensOptions, DesignTokensOptionsInput, GetSlots, GetSlotsParams, GlobalDesignTokens, HrefProp, ICSEntryReference, ImageUrlProp, InternalComponentRegistryOptions, JSONRTERegistryOptions, JsonRTEProp, LengthToken, NodeProps, NumberProp, ObjectInput, ObjectProp, PlaceHolders, PreProcessedBreakpoint, PreProcessedDesignTokenInput, PropBase, PropInput, PropType, PropTypeOfNoOptionsRequired, PropValidator, Props, PropsWithNoOptionsRequired, RawStaticValue, RegisterComponentOptionsInput, RegisterComponentSchema, RegisterComponentSchemaInput, RegisterInternalComponentOptionsInput, Registry, RepeaterBindingValue, SectionDesignTokens, SlotProp, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioSpecData, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
export { ComponentRegistry } from './component-registry/registry.js';
|
|
2
2
|
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 } from './component-registry/registry.constant.js';
|
|
3
|
+
export { getComponentRegistryInstance, hasComponentRegistryInstance, resetComponentRegistryInstance } from './component-registry/singleton.js';
|
|
3
4
|
export { DesignRegistry } from './design-registry/design-registry.js';
|
|
4
5
|
export { getDesignClassesNames } from './design-registry/design-classes.js';
|
|
5
6
|
export { ALLOWED_DESIGN_VALUES_LEVELS, DEFAULT_DESIGN_TOKENS } from './design-registry/constants.js';
|
|
6
7
|
export { JSONRTERegistry } from './json-rte-registry/index.js';
|
|
7
8
|
export { retrievePropValue } from './data-binder/retrieve-data.js';
|
|
8
|
-
export { getBindingString, getDataType, getDefaultPropStaticValue, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, resolveMetadataBindings } from './data-binder/retrieve-data.util.js';
|
|
9
|
+
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resolveMetadataBindings } from './data-binder/retrieve-data.util.js';
|
|
9
10
|
export { getCslpPath, getCslpTag, getRepeaterBinding } from './data-binder/cslp.js';
|
|
10
11
|
export { BreakpointRegistry } from './breakpoint-registry/index.js';
|
|
11
12
|
export { getSymbolUIDFromNode, getSymbolUIDFromUID } from './utils/symbols.js';
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-registry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "This package houses all the registry related to the visual builder",
|
|
5
5
|
"main": "dist/cjs/index.cjs",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"dist"
|
|
16
16
|
],
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@contentstack/common-config": "^1.1.
|
|
19
|
-
"@contentstack/studio-internal": "^1.
|
|
18
|
+
"@contentstack/common-config": "^1.1.8",
|
|
19
|
+
"@contentstack/studio-internal": "^1.2.2",
|
|
20
20
|
"@rollup/plugin-commonjs": "^28.0.6",
|
|
21
21
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
22
|
-
"@rollup/plugin-terser": "^0.
|
|
22
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
23
23
|
"@rollup/plugin-typescript": "^12.1.4",
|
|
24
|
-
"happy-dom": "^20.
|
|
24
|
+
"happy-dom": "^20.8.9",
|
|
25
25
|
"rollup": "^4.46.2",
|
|
26
26
|
"rollup-plugin-dts": "^6.2.1",
|
|
27
27
|
"rollup-plugin-node-externals": "^8.0.1",
|
|
@@ -52,11 +52,14 @@
|
|
|
52
52
|
"author": "Contentstack",
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"@contentstack/json-rte-serializer": "^3.0.
|
|
56
|
-
"@contentstack/studio-message-types": "^1.
|
|
57
|
-
"@contentstack/studio-messenger": "^1.
|
|
55
|
+
"@contentstack/json-rte-serializer": "^3.0.5",
|
|
56
|
+
"@contentstack/studio-message-types": "^1.2.2",
|
|
57
|
+
"@contentstack/studio-messenger": "^1.4.0",
|
|
58
58
|
"csstype": "^3.1.3",
|
|
59
|
-
"lodash-es": "^4.
|
|
59
|
+
"lodash-es": "^4.18.1"
|
|
60
60
|
},
|
|
61
|
-
"
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public"
|
|
63
|
+
},
|
|
64
|
+
"gitHead": "1877b45f4a73ffb0c570ea06c197ba95504c014a"
|
|
62
65
|
}
|