@contentstack/studio-registry 1.5.0 → 1.6.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 +425 -37
- 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 +51 -0
- package/dist/esm/component-registry/registry-options-processor.js.map +1 -1
- package/dist/esm/component-registry/registry.constant.js +6 -0
- package/dist/esm/component-registry/registry.constant.js.map +1 -1
- package/dist/esm/component-registry/registry.js +81 -8
- package/dist/esm/component-registry/registry.js.map +1 -1
- package/dist/esm/component-registry/singleton.js +17 -25
- package/dist/esm/component-registry/singleton.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.js +167 -2
- package/dist/esm/data-binder/retrieve-data.js.map +1 -1
- package/dist/esm/data-binder/retrieve-data.util.js +7 -1
- package/dist/esm/data-binder/retrieve-data.util.js.map +1 -1
- 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 +228 -22
- package/dist/esm/index.js +4 -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 +7 -10
|
@@ -7,6 +7,48 @@ import { dataSourceCapabilities } from './strategies/dataSourceCapabilities.js';
|
|
|
7
7
|
import { getRegistryErrorMessage } from '../utils/registry-error-messages.js';
|
|
8
8
|
import { RegistryErrorMessageKey } from '../utils/registry-error-messages.default.js';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Prop keys (`<nodeUid>-<field>`) for which a binding-type-mismatch error has
|
|
12
|
+
* been reported to the editor and not yet retracted.
|
|
13
|
+
*
|
|
14
|
+
* The editor's "Data Mismatch Found" badge is driven entirely by the
|
|
15
|
+
* UPDATE_BINDING_ERRORS messages we send from here — it has no other source of
|
|
16
|
+
* truth. Previously we only ever SENT errors and never retracted them, so a
|
|
17
|
+
* transient mismatch (e.g. a section repeater bound to scope-root that briefly
|
|
18
|
+
* sees the whole entry OBJECT while a freshly-swapped schema re-scopes) left a
|
|
19
|
+
* sticky error that survived even after the data resolved correctly. Tracking
|
|
20
|
+
* what we've reported lets us emit a one-shot retraction the moment the data
|
|
21
|
+
* matches again, so the badge reflects the live render instead of latching.
|
|
22
|
+
*/
|
|
23
|
+
const reportedBindingErrors = new Set();
|
|
24
|
+
/**
|
|
25
|
+
* Retract every binding-mismatch error previously reported for `nodeUid`'s
|
|
26
|
+
* props and forget them.
|
|
27
|
+
*
|
|
28
|
+
* The in-render retraction in `retrievePropValue` only clears the editor badge
|
|
29
|
+
* when the SAME node re-renders with matching data — which never happens once
|
|
30
|
+
* the node disappears (e.g. a repeater item removed, or a section swapped for a
|
|
31
|
+
* different schema). Without this, such a node's badge would latch and its
|
|
32
|
+
* entry would leak in `reportedBindingErrors` forever. Call this from the
|
|
33
|
+
* node's unmount path so the badge reflects the live tree.
|
|
34
|
+
*
|
|
35
|
+
* Keys are `${nodeUid}-${field}`; the trailing `-` (and fixed-length uids)
|
|
36
|
+
* makes the prefix match exact, so one node's uid can't match another's.
|
|
37
|
+
*/
|
|
38
|
+
function clearReportedBindingErrorsForNode(nodeUid) {
|
|
39
|
+
if (reportedBindingErrors.size === 0)
|
|
40
|
+
return;
|
|
41
|
+
const prefix = `${nodeUid}-`;
|
|
42
|
+
for (const propKey of reportedBindingErrors) {
|
|
43
|
+
if (!propKey.startsWith(prefix))
|
|
44
|
+
continue;
|
|
45
|
+
reportedBindingErrors.delete(propKey);
|
|
46
|
+
composableStudioEventManager?.send(POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
|
|
47
|
+
propKey,
|
|
48
|
+
errorMessage: "",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
10
52
|
// Responsible for resolving props to values
|
|
11
53
|
function retrievePropValue(args) {
|
|
12
54
|
const { data, componentOptions, node, cslp, placeholders = {}, getSlots, jsonRTE, isCompositionBeingEdited, } = args;
|
|
@@ -35,6 +77,11 @@ function retrievePropValue(args) {
|
|
|
35
77
|
return;
|
|
36
78
|
}
|
|
37
79
|
let resolvedData;
|
|
80
|
+
// When the value is resolved via the `dataSources.page.*` fallback below,
|
|
81
|
+
// the CSLP tag must come from the SAME page path (not the section-local
|
|
82
|
+
// binding, which missed). Holds that page path so the cslp block points the
|
|
83
|
+
// edit tag at the field the value actually came from.
|
|
84
|
+
let cslpPathOverride;
|
|
38
85
|
if (type === "slot") {
|
|
39
86
|
resolvedData = getSlotData({
|
|
40
87
|
nodeProps: nodeProps,
|
|
@@ -45,6 +92,32 @@ function retrievePropValue(args) {
|
|
|
45
92
|
mappedData[field] = resolvedData;
|
|
46
93
|
return;
|
|
47
94
|
}
|
|
95
|
+
// Section exposed-prop override: the page composer's exposed-prop binding is
|
|
96
|
+
// the SOLE source of truth for an exposed field — the internal node's own
|
|
97
|
+
// binding must never leak through on a page. SectionCompositionProvider emits
|
|
98
|
+
// an entry for EVERY exposed prop (even when the page value is cleared/empty),
|
|
99
|
+
// so we apply on key PRESENCE, not on a non-undefined value. A cleared prop
|
|
100
|
+
// therefore renders the page-resolved empty value instead of falling back to
|
|
101
|
+
// the section's authored binding.
|
|
102
|
+
const overridesForNode = data.dataSources?.section_exposed_overrides?.[node.uid];
|
|
103
|
+
if (overridesForNode && field in overridesForNode) {
|
|
104
|
+
mappedData[field] = overridesForNode[field];
|
|
105
|
+
// Carry the page-resolved CSLP tag for this exposed prop. This branch
|
|
106
|
+
// short-circuits BEFORE the cslp block (~L430), so without re-emitting
|
|
107
|
+
// here a page-overridden field (e.g. a section's root component bound via
|
|
108
|
+
// a non-repeater binding) renders with no `data-cslp` and loses its
|
|
109
|
+
// live-preview edit overlay — even though its value resolves fine. The
|
|
110
|
+
// SectionComposition wrappers stash the page node's resolved cslp object
|
|
111
|
+
// alongside the value under `$<propKey>`, so it points at the PAGE entry
|
|
112
|
+
// field (the override's source of truth). Repeater-context exposed props
|
|
113
|
+
// are never in this map (they fall through to their own binding + cslp).
|
|
114
|
+
if (cslp.appendTags) {
|
|
115
|
+
const overrideCslp = overridesForNode[`$${field}`];
|
|
116
|
+
if (overrideCslp)
|
|
117
|
+
mappedData[`$${field}`] = overrideCslp;
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
48
121
|
const nodePropConfig = nodeProps[field];
|
|
49
122
|
const { binding: bindedField, value: staticValue } = nodePropConfig || {};
|
|
50
123
|
//TODO: Get proper data for design
|
|
@@ -104,6 +177,40 @@ function retrievePropValue(args) {
|
|
|
104
177
|
else if (dataPath &&
|
|
105
178
|
!(type === "choice" && bindedField?.type === "static_value")) {
|
|
106
179
|
resolvedData = get(data, dataPath, fallbackValue);
|
|
180
|
+
// TEMP — slot-child page-context fallback (PHASE 8 will remove this).
|
|
181
|
+
//
|
|
182
|
+
// Section-slot wraps its children's data context so that:
|
|
183
|
+
// dataSources.template / .contentstack / .contentstack_queries / .repeater
|
|
184
|
+
// ALL refer to the section's LOCAL surrounding context — matching what
|
|
185
|
+
// the Data Picker currently writes when authoring a slot child against
|
|
186
|
+
// section-local fields.
|
|
187
|
+
//
|
|
188
|
+
// The page's outer entries live at `dataSources.page.template`, etc., as
|
|
189
|
+
// the explicit escape namespace. But until the Picker is slot-aware
|
|
190
|
+
// (Phase 8), it has no way to write `dataSources.page.X` paths — so a
|
|
191
|
+
// page-level binding authored on a slot child still produces a
|
|
192
|
+
// `dataSources.<source>.X` path that targets the section-local view and
|
|
193
|
+
// resolves to undefined.
|
|
194
|
+
//
|
|
195
|
+
// Bridge: if the local resolution is missing AND a `page` sibling
|
|
196
|
+
// namespace exists on dataSources, retry under `dataSources.page.X`. Remove
|
|
197
|
+
// this fallback when the Picker emits explicit `dataSources.page.X`
|
|
198
|
+
// paths.
|
|
199
|
+
if ((resolvedData === undefined ||
|
|
200
|
+
resolvedData === null ||
|
|
201
|
+
resolvedData === fallbackValue) &&
|
|
202
|
+
typeof dataPath === "string" &&
|
|
203
|
+
dataPath.startsWith("dataSources.") &&
|
|
204
|
+
!dataPath.startsWith("dataSources.page.") &&
|
|
205
|
+
data?.dataSources?.page) {
|
|
206
|
+
const pagePath = dataPath.replace(/^dataSources\./, "dataSources.page.");
|
|
207
|
+
const pageResolved = get(data, pagePath, undefined);
|
|
208
|
+
if (pageResolved !== undefined && pageResolved !== null) {
|
|
209
|
+
resolvedData = pageResolved;
|
|
210
|
+
// Mirror the value's source so the cslp block tags the page field.
|
|
211
|
+
cslpPathOverride = pagePath;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
107
214
|
// Handle primitive values in repeater context
|
|
108
215
|
// When the array contains primitives (strings, numbers, etc.) instead of objects,
|
|
109
216
|
// the binding path will be like: dataSources.repeater.{uid}.context.{fieldName}
|
|
@@ -208,6 +315,7 @@ function retrievePropValue(args) {
|
|
|
208
315
|
});
|
|
209
316
|
if (isCompositionBeingEdited) {
|
|
210
317
|
// In editor mode: Send to Visual Builder
|
|
318
|
+
reportedBindingErrors.add(`${node.uid}-${field}`);
|
|
211
319
|
composableStudioEventManager?.send(POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
|
|
212
320
|
propKey: `${node.uid}-${field}`,
|
|
213
321
|
errorMessage: getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR, { expectedType: type, receivedType }),
|
|
@@ -226,6 +334,21 @@ function retrievePropValue(args) {
|
|
|
226
334
|
});
|
|
227
335
|
}
|
|
228
336
|
}
|
|
337
|
+
else if (isCompositionBeingEdited) {
|
|
338
|
+
// Data now matches the prop type. If we previously reported a mismatch for
|
|
339
|
+
// this prop, retract it (empty errorMessage → the editor calls
|
|
340
|
+
// removeBindingError) so a stale "Data Mismatch Found" badge doesn't
|
|
341
|
+
// persist after the binding re-resolves — e.g. once a swapped section
|
|
342
|
+
// schema finishes re-scoping a repeater's items to its array field.
|
|
343
|
+
const propKey = `${node.uid}-${field}`;
|
|
344
|
+
if (reportedBindingErrors.has(propKey)) {
|
|
345
|
+
reportedBindingErrors.delete(propKey);
|
|
346
|
+
composableStudioEventManager?.send(POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
|
|
347
|
+
propKey,
|
|
348
|
+
errorMessage: "",
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
}
|
|
229
352
|
mappedData[field] = resolvedData;
|
|
230
353
|
if (type === "json_rte") {
|
|
231
354
|
mappedData["jsonConfig"] = jsonRTE;
|
|
@@ -233,7 +356,13 @@ function retrievePropValue(args) {
|
|
|
233
356
|
const isCSLPAbleType = bindedField?.type &&
|
|
234
357
|
dataSourceCapabilities[bindedField.type]?.supportsCslp;
|
|
235
358
|
if (cslp.appendTags && dataPath && isCSLPAbleType) {
|
|
236
|
-
|
|
359
|
+
// Use the page-fallback path when the value came from there (cross-section
|
|
360
|
+
// / slot-child page binding), so the edit tag points at the field that
|
|
361
|
+
// actually supplied the value; otherwise the section-local binding path.
|
|
362
|
+
const cslpValue = getCslpTag({
|
|
363
|
+
bindedField: cslpPathOverride ?? dataPath,
|
|
364
|
+
data,
|
|
365
|
+
});
|
|
237
366
|
if (cslpValue) {
|
|
238
367
|
mappedData[`$${field}`] = cslpValue;
|
|
239
368
|
}
|
|
@@ -243,6 +372,14 @@ function retrievePropValue(args) {
|
|
|
243
372
|
mappedData["_uid"] = node.uid;
|
|
244
373
|
mappedData["mode"] = node?.metadata?.mode;
|
|
245
374
|
}
|
|
375
|
+
if (node.type === "section-slot") {
|
|
376
|
+
// Section-slot needs its own node uid at render time so it can look up
|
|
377
|
+
// the page-side fill in SectionInstanceSlotsCtx.slotsMap[node.uid].
|
|
378
|
+
mappedData["_uid"] = node.uid;
|
|
379
|
+
// The authored Slot default (COMS-1659): rendered when a placement leaves
|
|
380
|
+
// the slot empty (editor preview only; design keeps the dropzone).
|
|
381
|
+
mappedData["defaultSection"] = node?.metadata?.defaultSection?.uid;
|
|
382
|
+
}
|
|
246
383
|
if (node.type === "condition-block") {
|
|
247
384
|
mappedData["condition"] = node?.metadata?.condition;
|
|
248
385
|
mappedData["mode"] = node?.metadata?.mode;
|
|
@@ -260,9 +397,37 @@ function retrievePropValue(args) {
|
|
|
260
397
|
mappedData["symbol_props"][uid] = mappedData[field];
|
|
261
398
|
});
|
|
262
399
|
}
|
|
400
|
+
if (node.type === "section-composition") {
|
|
401
|
+
// Surface the page composer's LIVE binding type for each exposed prop so the
|
|
402
|
+
// SectionComposition renderer can tell an untouched seed from a real override.
|
|
403
|
+
// A repeater expose-time binding is only resolvable inside the section's own
|
|
404
|
+
// Repeater scope; at page level it resolves to a placeholder, not undefined —
|
|
405
|
+
// so the resolved VALUE can't distinguish "untouched" from "overridden". The
|
|
406
|
+
// live binding type can: still `repeater` (or absent) ⇒ untouched, fall
|
|
407
|
+
// through to the internal per-iteration binding; any page-resolvable type ⇒
|
|
408
|
+
// the composer rebound it and the override must win.
|
|
409
|
+
const bindingTypes = {};
|
|
410
|
+
const autoSeeded = {};
|
|
411
|
+
for (const field of Object.keys(nodeProps)) {
|
|
412
|
+
const binding = nodeProps[field]?.binding;
|
|
413
|
+
if (binding?.type)
|
|
414
|
+
bindingTypes[field] = binding.type;
|
|
415
|
+
// An auto-seeded binding means the page composer hasn't touched this exposed
|
|
416
|
+
// prop — the renderer skips its override so the section's internal binding
|
|
417
|
+
// resolves (re-scoped on schema switch / per repeater iteration).
|
|
418
|
+
if (binding?.autoSeeded)
|
|
419
|
+
autoSeeded[field] = true;
|
|
420
|
+
}
|
|
421
|
+
mappedData["section_exposed_binding_types"] = bindingTypes;
|
|
422
|
+
mappedData["section_exposed_auto_seeded"] = autoSeeded;
|
|
423
|
+
// Per-placement design/preview mode. The editor's SectionComposition uses
|
|
424
|
+
// this to derive/override the render mode of every repeater, condition-block,
|
|
425
|
+
// and section-slot inside the section. Ignored in production (renders live).
|
|
426
|
+
mappedData["mode"] = node?.metadata?.mode;
|
|
427
|
+
}
|
|
263
428
|
// TODO: Add support for useData Hook for studio
|
|
264
429
|
return mappedData;
|
|
265
430
|
}
|
|
266
431
|
|
|
267
|
-
export { retrievePropValue };
|
|
432
|
+
export { clearReportedBindingErrorsForNode, retrievePropValue };
|
|
268
433
|
//# sourceMappingURL=retrieve-data.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve-data.js","sources":["../../../src/data-binder/retrieve-data.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"retrieve-data.js","sources":["../../../src/data-binder/retrieve-data.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;AAuDA;;;;;;;;;;;;AAYG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAU;AAE/C;;;;;;;;;;;;;AAaG;AACG,SAAU,iCAAiC,CAAC,OAAe,EAAA;AAC/D,IAAA,IAAI,qBAAqB,CAAC,IAAI,KAAK,CAAC;QAAE;AACtC,IAAA,MAAM,MAAM,GAAG,CAAA,EAAG,OAAO,GAAG;AAC5B,IAAA,KAAK,MAAM,OAAO,IAAI,qBAAqB,EAAE;AAC3C,QAAA,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;YAAE;AACjC,QAAA,qBAAqB,CAAC,MAAM,CAAC,OAAO,CAAC;AACrC,QAAA,4BAA4B,EAAE,IAAI,CAChC,mBAAmB,CAAC,qBAAqB,EACzC;YACE,OAAO;AACP,YAAA,YAAY,EAAE,EAAE;AACjB,SAAA,CACF;IACH;AACF;AA2BA;AACM,SAAU,iBAAiB,CAC/B,IAAiC,EAAA;IAEjC,MAAM,EACJ,IAAI,EACJ,gBAAgB,EAChB,IAAI,EACJ,IAAI,EACJ,YAAY,GAAG,EAAE,EACjB,QAAQ,EACR,OAAO,EACP,wBAAwB,GACzB,GAAG,IAAI;AAER,IAAA,MAAM,cAAc,GAAG,CAAC,SAAS,iBAAiB,GAAA;;AAEhD,QAAA,IA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EAAE;gBACR;YACF;YACA,UAAU,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC;AACrD,QAAA,CAAC,CAAC;IACJ;AACA,IAAA,IAAI,IAAI,CAAC,IAAI,KAAK,qBAAqB,EAAE;;;;;;;;;QASvC,MAAM,YAAY,GAA2B,EAAE;QAC/C,MAAM,UAAU,GAA4B,EAAE;QAC9C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YAC1C,MAAM,OAAO,GACX,SAAS,CAAC,KAAK,CAGhB,EAAE,OAAO;YACV,IAAI,OAAO,EAAE,IAAI;AAAE,gBAAA,YAAY,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI;;;;YAIrD,IAAI,OAAO,EAAE,UAAU;AAAE,gBAAA,UAAU,CAAC,KAAK,CAAC,GAAG,IAAI;QACnD;AACA,QAAA,UAAU,CAAC,+BAA+B,CAAC,GAAG,YAAY;AAC1D,QAAA,UAAU,CAAC,6BAA6B,CAAC,GAAG,UAAU;;;;QAItD,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,EAAE,QAAQ,EAAE,IAAI;IAC3C;;AAEA,IAAA,OAAO,UAAU;AACnB;;;;"}
|
|
@@ -38,6 +38,7 @@ function getDefaultPropStaticValue(args) {
|
|
|
38
38
|
datestring: "",
|
|
39
39
|
any: "",
|
|
40
40
|
json_rte: {},
|
|
41
|
+
plaintext: "",
|
|
41
42
|
};
|
|
42
43
|
if (args) {
|
|
43
44
|
return defaultValues[args];
|
|
@@ -58,6 +59,7 @@ function isKnownType(type) {
|
|
|
58
59
|
datestring: true,
|
|
59
60
|
any: true,
|
|
60
61
|
json_rte: true,
|
|
62
|
+
plaintext: true,
|
|
61
63
|
};
|
|
62
64
|
return Object.keys(knownTypes).includes(type);
|
|
63
65
|
}
|
|
@@ -178,8 +180,12 @@ function isDataMatchingPropType(data, type) {
|
|
|
178
180
|
imageurl: dataType === "string",
|
|
179
181
|
datestring: dataType === "string",
|
|
180
182
|
json_rte: dataType === "object",
|
|
183
|
+
// "any" accepts all data types — no validation
|
|
184
|
+
any: true,
|
|
185
|
+
// "plaintext" accepts singleline/multiline text, number, and boolean fields
|
|
186
|
+
plaintext: dataType === "string" || dataType === "number" || dataType === "boolean",
|
|
181
187
|
};
|
|
182
|
-
return map[type];
|
|
188
|
+
return map[type] ?? false;
|
|
183
189
|
}
|
|
184
190
|
function getDataType(data) {
|
|
185
191
|
if (typeof data === "object" && data !== null && !Array.isArray(data)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retrieve-data.util.js","sources":["../../../src/data-binder/retrieve-data.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AA6BA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,yBAAyB,CACvC,IAAQ,EAAA;AAER,IAAA,MAAM,aAAa,GAAG;AACpB,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,MAAM,EAAE,CAAC;;AAET,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,KAAK,EAAE,EAAE;AACT,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,IAAI,EAAE,EAAE;AACR,QAAA,QAAQ,EAAE,EAAE;AACZ,QAAA,UAAU,EAAE,EAAE;AACd,QAAA,GAAG,EAAE,EAAE;AACP,QAAA,QAAQ,EAAE,EAAE;
|
|
1
|
+
{"version":3,"file":"retrieve-data.util.js","sources":["../../../src/data-binder/retrieve-data.util.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;AA6BA;;;;;;;;;;;;;;;;;AAiBG;AACG,SAAU,yBAAyB,CACvC,IAAQ,EAAA;AAER,IAAA,MAAM,aAAa,GAAG;AACpB,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,OAAO,EAAE,KAAK;AACd,QAAA,MAAM,EAAE,CAAC;;AAET,QAAA,MAAM,EAAE,EAAE;AACV,QAAA,K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AK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACrE,QAAA,OAAO,QAAQ;IACjB;AACA,IAAA,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACvB,QAAA,OAAO,OAAO;IAChB;IACA,OAAO,OAAO,IAAI;AACpB;;;;"}
|
|
@@ -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;;;;"}
|