@contentstack/studio-registry 1.3.0 → 1.4.1
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 +722 -89
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/common/global-store.js +49 -0
- package/dist/esm/common/global-store.js.map +1 -0
- 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 +8 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +224 -9
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/component-registry/singleton.js +51 -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 +156 -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/design-registry/singleton.js +37 -0
- package/dist/esm/design-registry/singleton.js.map +1 -0
- package/dist/esm/index.d.ts +236 -6
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/sections.js +13 -0
- package/dist/esm/utils/sections.js.map +1 -0
- package/package.json +9 -9
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
class DataSourceStrategyRegistry {
|
|
2
|
+
static instance;
|
|
3
|
+
strategies = new Map();
|
|
4
|
+
constructor() { }
|
|
5
|
+
static getInstance() {
|
|
6
|
+
if (!DataSourceStrategyRegistry.instance) {
|
|
7
|
+
DataSourceStrategyRegistry.instance = new DataSourceStrategyRegistry();
|
|
8
|
+
}
|
|
9
|
+
return DataSourceStrategyRegistry.instance;
|
|
10
|
+
}
|
|
11
|
+
register(type, strategy) {
|
|
12
|
+
this.strategies.set(type, strategy);
|
|
13
|
+
}
|
|
14
|
+
get(type) {
|
|
15
|
+
return this.strategies.get(type);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { DataSourceStrategyRegistry };
|
|
20
|
+
//# sourceMappingURL=strategy-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategy-registry.js","sources":["../../../src/data-binder/strategy-registry.ts"],"sourcesContent":[null],"names":[],"mappings":"MAOa,0BAA0B,CAAA;IAC7B,OAAO,QAAQ;AACf,IAAA,UAAU,GAAoC,IAAI,GAAG,EAAE;AAE/D,IAAA,WAAA,GAAA,EAAuB;AAEhB,IAAA,OAAO,WAAW,GAAA;AACvB,QAAA,IAAI,CAAC,0BAA0B,CAAC,QAAQ,EAAE;AACxC,YAAA,0BAA0B,CAAC,QAAQ,GAAG,IAAI,0BAA0B,EAAE;QACxE;QACA,OAAO,0BAA0B,CAAC,QAAQ;IAC5C;IAEO,QAAQ,CAAC,IAAY,EAAE,QAA4B,EAAA;QACxD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC;IACrC;AAEO,IAAA,GAAG,CAAC,IAAY,EAAA;QACrB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;IAClC;AACD;;;;"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getGlobalStudioStore } from '../common/global-store.js';
|
|
2
|
+
import { DesignRegistry } from './design-registry.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Singleton DesignRegistry, backed by a versioned slot on `globalThis`.
|
|
6
|
+
*
|
|
7
|
+
* Previously, `studio-react/src/composable-studio/sdk.ts` did
|
|
8
|
+
* `export const designRegistry = new DesignRegistry()` at module scope — which
|
|
9
|
+
* means every separate module-graph (RSC vs client, build workers) got its own
|
|
10
|
+
* `DesignRegistry`. Design tokens registered on one side were invisible to the
|
|
11
|
+
* other. See `common/global-store.ts` for the dual-graph background.
|
|
12
|
+
*
|
|
13
|
+
* After this change, all callers of `getDesignRegistryInstance()` resolve to
|
|
14
|
+
* the same `DesignRegistry` within a single JS runtime.
|
|
15
|
+
*/
|
|
16
|
+
function getDesignRegistryInstance() {
|
|
17
|
+
const store = getGlobalStudioStore();
|
|
18
|
+
if (!store.designRegistry) {
|
|
19
|
+
store.designRegistry = new DesignRegistry();
|
|
20
|
+
}
|
|
21
|
+
return store.designRegistry;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Resets the singleton instance. For tests only.
|
|
25
|
+
*/
|
|
26
|
+
function resetDesignRegistryInstance() {
|
|
27
|
+
getGlobalStudioStore().designRegistry = null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Checks if the singleton instance has been created.
|
|
31
|
+
*/
|
|
32
|
+
function hasDesignRegistryInstance() {
|
|
33
|
+
return getGlobalStudioStore().designRegistry !== null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { getDesignRegistryInstance, hasDesignRegistryInstance, resetDesignRegistryInstance };
|
|
37
|
+
//# sourceMappingURL=singleton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"singleton.js","sources":["../../../src/design-registry/singleton.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAGA;;;;;;;;;;;AAWG;SACa,yBAAyB,GAAA;AACvC,IAAA,MAAM,KAAK,GAAG,oBAAoB,EAAE;AACpC,IAAA,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;AACzB,QAAA,KAAK,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE;IAC7C;IACA,OAAO,KAAK,CAAC,cAAgC;AAC/C;AAEA;;AAEG;SACa,2BAA2B,GAAA;AACzC,IAAA,oBAAoB,EAAE,CAAC,cAAc,GAAG,IAAI;AAC9C;AAEA;;AAEG;SACa,yBAAyB,GAAA;AACvC,IAAA,OAAO,oBAAoB,EAAE,CAAC,cAAc,KAAK,IAAI;AACvD;;;;"}
|
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: {
|
|
@@ -108,8 +126,9 @@ declare const INTERNAL_COMPONENT_SECTIONS: {
|
|
|
108
126
|
readonly REGISTERED_COMPONENTS: "Registered Components";
|
|
109
127
|
readonly HTML_ELEMENT: "HTML Elements";
|
|
110
128
|
readonly SYMBOL: "Symbols";
|
|
129
|
+
readonly SECTION_COMPOSITION: "Sections";
|
|
111
130
|
};
|
|
112
|
-
declare const INTERNAL_SECTIONS: ("Basic" | "Media" | "Container" | "Smart Containers" | "Advanced" | "Registered Components" | "HTML Elements" | "Symbols")[];
|
|
131
|
+
declare const INTERNAL_SECTIONS: ("Basic" | "Media" | "Container" | "Smart Containers" | "Advanced" | "Registered Components" | "HTML Elements" | "Symbols" | "Sections")[];
|
|
113
132
|
declare const STYLE_SECTIONS_OPTIONS: readonly ["class", "size", "spacing", "position", "visibility", "layout", "typography", "transform", "media", "background", "shadow", "effect", "overflow", "border", "responsive"];
|
|
114
133
|
/**
|
|
115
134
|
* The style group is the group of the style sections options.
|
|
@@ -126,6 +145,7 @@ declare const INTERNAL_COMPONENTS_NAMES: {
|
|
|
126
145
|
readonly LINK: "link";
|
|
127
146
|
readonly LINK_CONTAINER: "link-container";
|
|
128
147
|
readonly TEXT: "text";
|
|
148
|
+
readonly NUMBER: "number";
|
|
129
149
|
readonly BUTTON: "button";
|
|
130
150
|
readonly JSON_RTE: "json-rte";
|
|
131
151
|
readonly COLLAPSIBLE_TEXT: "collapsible-text";
|
|
@@ -141,6 +161,7 @@ declare const INTERNAL_COMPONENTS_NAMES: {
|
|
|
141
161
|
readonly CONDITION_BLOCK: "condition-block";
|
|
142
162
|
readonly SYMBOL: "symbol";
|
|
143
163
|
readonly FRAGMENT: "fragment";
|
|
164
|
+
readonly SECTION_SLOT: "section-slot";
|
|
144
165
|
readonly HTML_ELEMENT: "html-element";
|
|
145
166
|
readonly STYLE_SHEET: "style-sheet";
|
|
146
167
|
};
|
|
@@ -158,6 +179,7 @@ declare const BUILT_IN_COMPONENTS: {
|
|
|
158
179
|
readonly LINK: "link";
|
|
159
180
|
readonly LINK_CONTAINER: "link-container";
|
|
160
181
|
readonly TEXT: "text";
|
|
182
|
+
readonly NUMBER: "number";
|
|
161
183
|
readonly BUTTON: "button";
|
|
162
184
|
readonly JSON_RTE: "json-rte";
|
|
163
185
|
readonly COLLAPSIBLE_TEXT: "collapsible-text";
|
|
@@ -289,6 +311,9 @@ declare class ComponentRegistry<C> {
|
|
|
289
311
|
private componentRegistry;
|
|
290
312
|
private propValidatorRegistry;
|
|
291
313
|
private config;
|
|
314
|
+
private componentLoaders;
|
|
315
|
+
private loadedComponents;
|
|
316
|
+
private loadingPromises;
|
|
292
317
|
constructor(config?: ComponentRegistryOptions);
|
|
293
318
|
setConfig(config?: Partial<ComponentRegistryOptions>): void;
|
|
294
319
|
/**
|
|
@@ -315,11 +340,37 @@ declare class ComponentRegistry<C> {
|
|
|
315
340
|
* @param componentsConfigs
|
|
316
341
|
*/
|
|
317
342
|
registerSymbolComponent(componentsConfigs: RegisterInternalComponentOptionsInput<C>[]): void;
|
|
343
|
+
registerSectionComponent(componentsConfigs: RegisterInternalComponentOptionsInput<C>[]): void;
|
|
318
344
|
/**
|
|
319
345
|
* Registers one or more components in the component registry.
|
|
346
|
+
*
|
|
347
|
+
* By default, duplicate registrations (same `type` registered twice) are
|
|
348
|
+
* silently skipped — making the call **idempotent**. This is the desired
|
|
349
|
+
* behaviour under:
|
|
350
|
+
* - HMR re-evaluation (the same module runs twice in dev),
|
|
351
|
+
* - dual-bundle scenarios (RSC + client both pull in the registration
|
|
352
|
+
* module),
|
|
353
|
+
* - prod build workers (each worker may re-import the module),
|
|
354
|
+
* - test setup re-runs.
|
|
355
|
+
*
|
|
356
|
+
* The previous default — throwing on duplicate — forced every consumer to
|
|
357
|
+
* wrap the call in `try/catch` to absorb the throw, which had the side
|
|
358
|
+
* effect of masking real registration errors (typos in `type`, malformed
|
|
359
|
+
* schemas). Real errors now surface on the first call; duplicates no longer
|
|
360
|
+
* trip them up.
|
|
361
|
+
*
|
|
362
|
+
* Pass `{ strict: true }` to opt back into the old behaviour (throw on any
|
|
363
|
+
* duplicate). This is useful in tests that want to assert a clean
|
|
364
|
+
* registration boundary. `overrideDefaultComponents` on the registry config
|
|
365
|
+
* still wins over both — it lets a duplicate replace the existing entry.
|
|
366
|
+
*
|
|
320
367
|
* @param components - An array of component options to register.
|
|
368
|
+
* @param options - Per-call registration options. `strict: true` reinstates
|
|
369
|
+
* the throw on duplicate.
|
|
321
370
|
*/
|
|
322
|
-
registerComponents(components: RegisterComponentOptionsInput<C>[]
|
|
371
|
+
registerComponents(components: RegisterComponentOptionsInput<C>[], options?: {
|
|
372
|
+
strict?: boolean;
|
|
373
|
+
}): void;
|
|
323
374
|
/**
|
|
324
375
|
* Retrieves an array of component registry values.
|
|
325
376
|
*
|
|
@@ -354,8 +405,105 @@ declare class ComponentRegistry<C> {
|
|
|
354
405
|
unregisterComponent(node: Node | string): void;
|
|
355
406
|
validateProp<V>(componentName: string, propName: string, value: V): ReturnType<PropValidator<V>>;
|
|
356
407
|
getComponentName(node: Node): string;
|
|
408
|
+
/**
|
|
409
|
+
* Registers a lazy-loadable component with a loader function.
|
|
410
|
+
* The component will be loaded on-demand when needed.
|
|
411
|
+
*
|
|
412
|
+
* @param config - Component configuration without the component itself
|
|
413
|
+
* @param loader - Function that returns a Promise resolving to the component
|
|
414
|
+
* @param registryType - Type of registry (internal or user-defined), defaults to user-defined
|
|
415
|
+
*/
|
|
416
|
+
registerLazyComponent(config: Omit<RegisterComponentOptionsInput<C>, "component">, loader: () => Promise<C>, registryType?: Registry): void;
|
|
417
|
+
/**
|
|
418
|
+
* Loads a single component if it's registered as lazy and not yet loaded.
|
|
419
|
+
* Returns immediately if already loaded or not a lazy component.
|
|
420
|
+
*
|
|
421
|
+
* @param componentType - The type of component to load
|
|
422
|
+
* @returns Promise that resolves when the component is loaded
|
|
423
|
+
*/
|
|
424
|
+
loadComponent(componentType: string): Promise<void>;
|
|
425
|
+
/**
|
|
426
|
+
* Loads multiple components in parallel.
|
|
427
|
+
* Deduplicates requests and uses caching.
|
|
428
|
+
*
|
|
429
|
+
* @param componentTypes - Array of component types to load
|
|
430
|
+
* @returns Promise that resolves when all components are loaded
|
|
431
|
+
*/
|
|
432
|
+
loadComponents(componentTypes: string[]): Promise<void>;
|
|
433
|
+
/**
|
|
434
|
+
* Checks if a component is registered as lazy-loadable.
|
|
435
|
+
*
|
|
436
|
+
* @param componentType - The type of component to check
|
|
437
|
+
* @returns true if the component is lazy-loadable
|
|
438
|
+
*/
|
|
439
|
+
isLazyComponent(componentType: string): boolean;
|
|
440
|
+
/**
|
|
441
|
+
* Checks if a lazy component has been loaded.
|
|
442
|
+
*
|
|
443
|
+
* @param componentType - The type of component to check
|
|
444
|
+
* @returns true if the component has been loaded
|
|
445
|
+
*/
|
|
446
|
+
isComponentLoaded(componentType: string): boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Checks if a component has a loader registered (lazy) or is already registered (eager).
|
|
449
|
+
* This is useful for SSR validation to ensure components are available before rendering.
|
|
450
|
+
*
|
|
451
|
+
* @param componentType - The type of component to check
|
|
452
|
+
* @returns true if the component has a loader or is registered
|
|
453
|
+
*/
|
|
454
|
+
hasComponentLoader(componentType: string): boolean;
|
|
455
|
+
/**
|
|
456
|
+
* Gets all component types that have loaders registered (lazy components).
|
|
457
|
+
* Useful for debugging and SSR setup validation.
|
|
458
|
+
*
|
|
459
|
+
* @returns Array of component types with lazy loaders
|
|
460
|
+
*/
|
|
461
|
+
getLazyComponentTypes(): string[];
|
|
462
|
+
/**
|
|
463
|
+
* Gets all registered component types (both lazy and eager).
|
|
464
|
+
* Useful for debugging and validation.
|
|
465
|
+
*
|
|
466
|
+
* @returns Array of all registered component types
|
|
467
|
+
*/
|
|
468
|
+
getAllComponentTypes(): string[];
|
|
357
469
|
}
|
|
358
470
|
|
|
471
|
+
/**
|
|
472
|
+
* Singleton ComponentRegistry, backed by a versioned slot on `globalThis`.
|
|
473
|
+
*
|
|
474
|
+
* The previous module-scoped `let instance` only existed within whichever
|
|
475
|
+
* module-graph evaluated this file. Under Next.js's dual RSC/client graph or
|
|
476
|
+
* across prod build workers, that meant two registries with no sharing —
|
|
477
|
+
* `fetchCompositionData` (server) could see an empty registry while
|
|
478
|
+
* `<StudioComponent>` (client) saw a populated one. See `common/global-store.ts`
|
|
479
|
+
* for the full reasoning.
|
|
480
|
+
*
|
|
481
|
+
* After this change, all callers of `getComponentRegistryInstance()` resolve
|
|
482
|
+
* to the same `ComponentRegistry` instance within a single JS runtime,
|
|
483
|
+
* regardless of which graph or worker they were evaluated in.
|
|
484
|
+
*/
|
|
485
|
+
declare function getComponentRegistryInstance(): ComponentRegistry<any>;
|
|
486
|
+
/**
|
|
487
|
+
* Resets the singleton instance.
|
|
488
|
+
* Primarily useful for testing to ensure a clean state between tests.
|
|
489
|
+
*
|
|
490
|
+
* @example
|
|
491
|
+
* ```typescript
|
|
492
|
+
* import { resetComponentRegistryInstance } from '@contentstack/studio-registry';
|
|
493
|
+
*
|
|
494
|
+
* beforeEach(() => {
|
|
495
|
+
* resetComponentRegistryInstance();
|
|
496
|
+
* });
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
declare function resetComponentRegistryInstance(): void;
|
|
500
|
+
/**
|
|
501
|
+
* Checks if the singleton instance has been created.
|
|
502
|
+
*
|
|
503
|
+
* @returns true if the instance exists, false otherwise
|
|
504
|
+
*/
|
|
505
|
+
declare function hasComponentRegistryInstance(): boolean;
|
|
506
|
+
|
|
359
507
|
type DesignTokensInput = Partial<SectionDesignTokens> & Partial<GlobalDesignTokens>;
|
|
360
508
|
type DesignTokensInputKeys = keyof DesignTokensInput;
|
|
361
509
|
type GlobalDesignTokens = {
|
|
@@ -636,6 +784,28 @@ declare class DesignRegistry {
|
|
|
636
784
|
updateClasses(classes: DesignClasses[]): void;
|
|
637
785
|
}
|
|
638
786
|
|
|
787
|
+
/**
|
|
788
|
+
* Singleton DesignRegistry, backed by a versioned slot on `globalThis`.
|
|
789
|
+
*
|
|
790
|
+
* Previously, `studio-react/src/composable-studio/sdk.ts` did
|
|
791
|
+
* `export const designRegistry = new DesignRegistry()` at module scope — which
|
|
792
|
+
* means every separate module-graph (RSC vs client, build workers) got its own
|
|
793
|
+
* `DesignRegistry`. Design tokens registered on one side were invisible to the
|
|
794
|
+
* other. See `common/global-store.ts` for the dual-graph background.
|
|
795
|
+
*
|
|
796
|
+
* After this change, all callers of `getDesignRegistryInstance()` resolve to
|
|
797
|
+
* the same `DesignRegistry` within a single JS runtime.
|
|
798
|
+
*/
|
|
799
|
+
declare function getDesignRegistryInstance(): DesignRegistry;
|
|
800
|
+
/**
|
|
801
|
+
* Resets the singleton instance. For tests only.
|
|
802
|
+
*/
|
|
803
|
+
declare function resetDesignRegistryInstance(): void;
|
|
804
|
+
/**
|
|
805
|
+
* Checks if the singleton instance has been created.
|
|
806
|
+
*/
|
|
807
|
+
declare function hasDesignRegistryInstance(): boolean;
|
|
808
|
+
|
|
639
809
|
declare function getDesignClassesNames<C extends DesignClassesInput[]>(classes: C): DesignClassesNames<C>;
|
|
640
810
|
|
|
641
811
|
declare const DEFAULT_DESIGN_TOKENS: {
|
|
@@ -1044,10 +1214,26 @@ interface DataSources {
|
|
|
1044
1214
|
contentstack?: any;
|
|
1045
1215
|
[source: string]: any;
|
|
1046
1216
|
}
|
|
1217
|
+
interface SectionScopedDataSources {
|
|
1218
|
+
template: unknown;
|
|
1219
|
+
contentstack: Record<string, any>;
|
|
1220
|
+
contentstack_queries: Record<string, any>;
|
|
1221
|
+
static_value?: Record<string, unknown>;
|
|
1222
|
+
page: DataSources;
|
|
1223
|
+
repeater?: Record<string, {
|
|
1224
|
+
context: unknown;
|
|
1225
|
+
}>;
|
|
1226
|
+
parentRepeaterUID?: string | null;
|
|
1227
|
+
selectedField?: string;
|
|
1228
|
+
uidRemapping?: Record<string, string>;
|
|
1229
|
+
componentPropsFallback?: Record<string, unknown>;
|
|
1230
|
+
}
|
|
1047
1231
|
interface StudioSpecData {
|
|
1048
1232
|
dataSources: DataSources;
|
|
1049
1233
|
static_value: StaticValue;
|
|
1050
1234
|
symbol_props?: Record<string, any>;
|
|
1235
|
+
component_props?: Record<string, any>;
|
|
1236
|
+
section_scoped_data?: Record<string, SectionScopedDataSources>;
|
|
1051
1237
|
}
|
|
1052
1238
|
interface ComposableStudioData extends StudioSpecData {
|
|
1053
1239
|
component_props: Record<string, any> | undefined;
|
|
@@ -1144,7 +1330,16 @@ declare function getDefaultPropStaticValue<K extends BindableNodePropType>(args:
|
|
|
1144
1330
|
declare function isKnownType(type: string): type is PropType;
|
|
1145
1331
|
declare function getSlotData<T>({ nodeProps, field, node, getSlots, }: GetSlotDataArgs<T>): T | null;
|
|
1146
1332
|
declare function getPlaceHolderComponent<T>(placeholders: PlaceHolders<T>, prop: PropInput, type: BindableNodePropType): any;
|
|
1333
|
+
|
|
1147
1334
|
declare const getBindingString: (binding: BindingType) => string;
|
|
1335
|
+
declare const convertBindingPath: (bindingType: string, path: string) => string | string[];
|
|
1336
|
+
declare const getFlattenedData: (data: any) => any;
|
|
1337
|
+
/**
|
|
1338
|
+
* Composition/static data often stores single-select choice as `string[]` (one element).
|
|
1339
|
+
* `isDataMatchingPropType` treats `choice` as a `string` or `string[]` (multi-select);
|
|
1340
|
+
* single-select stored as `string[]` must still be unwrapped here before the type-mismatch fallback.
|
|
1341
|
+
*/
|
|
1342
|
+
declare function normalizeSingleSelectChoiceValue(resolvedData: unknown, prop: PropInput): unknown;
|
|
1148
1343
|
declare const resolveMetadataBindings: (node: Node, data: ComposableStudioData) => void;
|
|
1149
1344
|
declare const getRepeaterContextPath: (binding: RepeaterBindingValue) => string;
|
|
1150
1345
|
declare function isDataMatchingPropType(data: unknown, type: BindableNodePropType): boolean;
|
|
@@ -1193,5 +1388,40 @@ declare class BreakpointRegistry {
|
|
|
1193
1388
|
declare const getSymbolUIDFromNode: (symbol: Node) => string;
|
|
1194
1389
|
declare const getSymbolUIDFromUID: (uid: string) => string;
|
|
1195
1390
|
|
|
1196
|
-
|
|
1197
|
-
|
|
1391
|
+
/**
|
|
1392
|
+
* Extracts the composition UID from a section-composition node's metadata.
|
|
1393
|
+
* Used to resolve section references to their actual composition identifiers.
|
|
1394
|
+
*
|
|
1395
|
+
* @param section - The section node containing metadata
|
|
1396
|
+
* @returns The composition UID or undefined if not present
|
|
1397
|
+
*/
|
|
1398
|
+
declare const getSectionUIDFromNode: (section: Node) => any;
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Shape of the slot we own on globalThis. Each field is lazily initialized by
|
|
1402
|
+
* the corresponding `get*Instance()` helper; storing `null` keeps the slot
|
|
1403
|
+
* type-stable while letting each consumer create its instance on first access.
|
|
1404
|
+
*/
|
|
1405
|
+
interface GlobalStudioStore {
|
|
1406
|
+
componentRegistry: unknown | null;
|
|
1407
|
+
designRegistry: unknown | null;
|
|
1408
|
+
breakpointManager: unknown | null;
|
|
1409
|
+
}
|
|
1410
|
+
/**
|
|
1411
|
+
* Returns the SDK's versioned slot on globalThis, creating it on first call.
|
|
1412
|
+
* Always returns the same object reference within a single JS runtime.
|
|
1413
|
+
*
|
|
1414
|
+
* Type-erased on purpose: each registry singleton casts to its own type on
|
|
1415
|
+
* read/write so the public API of `studio-registry` stays free of cross-
|
|
1416
|
+
* package import dependencies (e.g. `BreakpointManager` lives in
|
|
1417
|
+
* `studio-client`).
|
|
1418
|
+
*/
|
|
1419
|
+
declare function getGlobalStudioStore(): GlobalStudioStore;
|
|
1420
|
+
/**
|
|
1421
|
+
* Clears the entire store. For tests only. Production code should never call
|
|
1422
|
+
* this — it would orphan every existing reference to the previous instances.
|
|
1423
|
+
*/
|
|
1424
|
+
declare function resetGlobalStudioStore(): void;
|
|
1425
|
+
|
|
1426
|
+
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, getDesignRegistryInstance, getFlattenedData, getGlobalStudioStore, getPlaceHolderComponent, getRepeaterBinding, getRepeaterContextPath, getSectionUIDFromNode, getSlotData, getSymbolUIDFromNode, getSymbolUIDFromUID, hasComponentRegistryInstance, hasDesignRegistryInstance, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resetComponentRegistryInstance, resetDesignRegistryInstance, resetGlobalStudioStore, resolveMetadataBindings, retrievePropValue };
|
|
1427
|
+
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, GlobalStudioStore, 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, SectionScopedDataSources, SlotProp, StaticValue, StaticValueItem, StaticValueUid, StringProp, StudioSpecData, StyleGroupOptions, StyleSectionCategoriesOptions, StyleSectionOptions, StyleSections, TemplateBindingValue };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
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';
|
|
5
|
+
export { getDesignRegistryInstance, hasDesignRegistryInstance, resetDesignRegistryInstance } from './design-registry/singleton.js';
|
|
4
6
|
export { getDesignClassesNames } from './design-registry/design-classes.js';
|
|
5
7
|
export { ALLOWED_DESIGN_VALUES_LEVELS, DEFAULT_DESIGN_TOKENS } from './design-registry/constants.js';
|
|
6
8
|
export { JSONRTERegistry } from './json-rte-registry/index.js';
|
|
7
9
|
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';
|
|
10
|
+
export { convertBindingPath, getBindingString, getDataType, getDefaultPropStaticValue, getFlattenedData, getPlaceHolderComponent, getRepeaterContextPath, getSlotData, isDataMatchingPropType, isKnownType, normalizeSingleSelectChoiceValue, resolveMetadataBindings } from './data-binder/retrieve-data.util.js';
|
|
9
11
|
export { getCslpPath, getCslpTag, getRepeaterBinding } from './data-binder/cslp.js';
|
|
10
12
|
export { BreakpointRegistry } from './breakpoint-registry/index.js';
|
|
11
13
|
export { getSymbolUIDFromNode, getSymbolUIDFromUID } from './utils/symbols.js';
|
|
14
|
+
export { getSectionUIDFromNode } from './utils/sections.js';
|
|
15
|
+
export { getGlobalStudioStore, resetGlobalStudioStore } from './common/global-store.js';
|
|
12
16
|
//# sourceMappingURL=index.js.map
|
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":";;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts the composition UID from a section-composition node's metadata.
|
|
3
|
+
* Used to resolve section references to their actual composition identifiers.
|
|
4
|
+
*
|
|
5
|
+
* @param section - The section node containing metadata
|
|
6
|
+
* @returns The composition UID or undefined if not present
|
|
7
|
+
*/
|
|
8
|
+
const getSectionUIDFromNode = (section) => {
|
|
9
|
+
return section.metadata?.compositionUID;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { getSectionUIDFromNode };
|
|
13
|
+
//# sourceMappingURL=sections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.js","sources":["../../../src/utils/sections.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;;AAMG;AACI,MAAM,qBAAqB,GAAG,CAAC,OAAa,KAAI;AACrD,IAAA,OAAO,OAAO,CAAC,QAAQ,EAAE,cAAc;AACzC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/studio-registry",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.1",
|
|
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.1
|
|
18
|
+
"@contentstack/common-config": "^1.1.7",
|
|
19
|
+
"@contentstack/studio-internal": "^1.2.1",
|
|
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",
|
|
@@ -53,10 +53,10 @@
|
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@contentstack/json-rte-serializer": "^3.0.4",
|
|
56
|
-
"@contentstack/studio-message-types": "^1.1
|
|
57
|
-
"@contentstack/studio-messenger": "^1.
|
|
56
|
+
"@contentstack/studio-message-types": "^1.2.1",
|
|
57
|
+
"@contentstack/studio-messenger": "^1.3.1",
|
|
58
58
|
"csstype": "^3.1.3",
|
|
59
|
-
"lodash-es": "^4.
|
|
59
|
+
"lodash-es": "^4.18.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "d4e0a1d80b39a2bfa9ac12baa5d4d4a852f4b326"
|
|
62
62
|
}
|