@contentstack/studio-registry 1.5.0 → 1.6.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.
@@ -76,6 +76,7 @@ const INTERNAL_COMPONENT_SECTIONS = {
76
76
  REGISTERED_COMPONENTS: "Registered Components",
77
77
  HTML_ELEMENT: "HTML Elements",
78
78
  SYMBOL: "Symbols",
79
+ SECTION_COMPOSITION: "Sections",
79
80
  };
80
81
  const INTERNAL_SECTIONS = Object.values(INTERNAL_COMPONENT_SECTIONS);
81
82
  const STYLE_SECTIONS_OPTIONS = [
@@ -130,6 +131,7 @@ const INTERNAL_COMPONENTS_NAMES = {
130
131
  JSON_RTE: "json-rte",
131
132
  COLLAPSIBLE_TEXT: "collapsible-text",
132
133
  PLAIN_TEXT: "plain-text",
134
+ RICH_TEXT: "rich-text",
133
135
  // * Media
134
136
  VIDEO: "video",
135
137
  EMBED: "embed",
@@ -143,6 +145,10 @@ const INTERNAL_COMPONENTS_NAMES = {
143
145
  CONDITION_BLOCK: "condition-block",
144
146
  SYMBOL: "symbol",
145
147
  FRAGMENT: "fragment",
148
+ // Exposed-slot placeholder authored inside a section composition. When the
149
+ // section is dropped into a page, each section-slot becomes a fill point
150
+ // the page composer can drop arbitrary components into.
151
+ SECTION_SLOT: "section-slot",
146
152
  // * HTML Elements
147
153
  HTML_ELEMENT: "html-element",
148
154
  STYLE_SHEET: "style-sheet",
@@ -185,6 +191,17 @@ const getSymbolUIDFromUID = (uid) => {
185
191
  return `${INTERNAL_COMPONENTS_NAMES.SYMBOL}-${uid}`;
186
192
  };
187
193
 
194
+ /**
195
+ * Extracts the composition UID from a section-composition node's metadata.
196
+ * Used to resolve section references to their actual composition identifiers.
197
+ *
198
+ * @param section - The section node containing metadata
199
+ * @returns The composition UID or undefined if not present
200
+ */
201
+ const getSectionUIDFromNode = (section) => {
202
+ return section.metadata?.compositionUID;
203
+ };
204
+
188
205
  /** Detect free variable `global` from Node.js. */
189
206
  var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
190
207
 
@@ -3891,6 +3908,7 @@ function getDefaultComponentSchemaInput(options) {
3891
3908
  hideFromComponentList: false,
3892
3909
  registry: "user-defined",
3893
3910
  icon: "",
3911
+ layerIcon: "",
3894
3912
  metadata: {},
3895
3913
  styles: {
3896
3914
  default: {
@@ -3953,6 +3971,16 @@ function processRegistryOptions(userConfig, options) {
3953
3971
  if ("icon" in userConfig && userConfig.icon) {
3954
3972
  defaultOptions.icon = userConfig.icon;
3955
3973
  }
3974
+ if (userConfig.layerIcon) {
3975
+ if (isValidLayerIcon(userConfig.layerIcon)) {
3976
+ defaultOptions.layerIcon = userConfig.layerIcon;
3977
+ }
3978
+ else {
3979
+ // Don't break registration over a bad icon — drop it and fall back to the default glyph.
3980
+ console.warn(`[studio] Ignoring invalid \`layerIcon\` for component "${userConfig.type}". ` +
3981
+ `Expected an inline SVG string, an absolute http(s)/data:image URL, or a servable relative path.`);
3982
+ }
3983
+ }
3956
3984
  if (userConfig.metadata) {
3957
3985
  defaultOptions.metadata = userConfig.metadata;
3958
3986
  }
@@ -3961,6 +3989,31 @@ function processRegistryOptions(userConfig, options) {
3961
3989
  propValidators,
3962
3990
  };
3963
3991
  }
3992
+ /**
3993
+ * Light, render-agnostic check that a `layerIcon` value is plausibly an inline SVG,
3994
+ * an image URL, or a servable path. This is developer feedback only — the Studio
3995
+ * builder still sanitizes/validates authoritatively at render time, since the value
3996
+ * crosses the postMessage boundary untrusted.
3997
+ */
3998
+ function isValidLayerIcon(value) {
3999
+ if (typeof value !== "string")
4000
+ return false;
4001
+ const v = value.trim();
4002
+ if (!v)
4003
+ return false;
4004
+ // Inline SVG markup (with or without an xml prolog).
4005
+ if (v.startsWith("<"))
4006
+ return v.includes("<svg");
4007
+ // Absolute http(s) URL.
4008
+ if (/^https?:\/\//i.test(v))
4009
+ return true;
4010
+ // A data URI must be an image.
4011
+ if (/^data:/i.test(v))
4012
+ return /^data:image\//i.test(v);
4013
+ // A relative/root-relative asset path. Must be explicitly path-shaped — a bare token
4014
+ // (e.g. a built-in icon NAME like "ComponentBox") is NOT a valid layerIcon.
4015
+ return v.startsWith("/") || v.startsWith("./") || v.startsWith("../");
4016
+ }
3964
4017
  function processStylesOptionsStyleSections(styleSections, defaultStyleSections) {
3965
4018
  if (typeof styleSections === "undefined" || styleSections === "all") {
3966
4019
  return defaultStyleSections;
@@ -4162,7 +4215,9 @@ class ComponentRegistry {
4162
4215
  // sync unregistered components (never remove system / built-in entries)
4163
4216
  this.componentRegistry.forEach((componentConfig) => {
4164
4217
  if (!updatedConfig.some((c) => c.type === componentConfig.type)) {
4165
- if (SYSTEM_COMPONENTS.has(componentConfig.type)) {
4218
+ if (SYSTEM_COMPONENTS.has(componentConfig.type) ||
4219
+ componentConfig.metadata?.type === "symbol" ||
4220
+ componentConfig.metadata?.type === "section-composition") {
4166
4221
  return;
4167
4222
  }
4168
4223
  this.unregisterComponent(componentConfig.type);
@@ -4236,23 +4291,64 @@ class ComponentRegistry {
4236
4291
  this.componentRegistry.set(type, processedOptions);
4237
4292
  });
4238
4293
  }
4294
+ registerSectionComponent(componentsConfigs) {
4295
+ componentsConfigs.forEach((componentConfig) => {
4296
+ const { type } = componentConfig;
4297
+ componentConfig["sections"] = [
4298
+ INTERNAL_COMPONENT_SECTIONS.SECTION_COMPOSITION,
4299
+ ];
4300
+ componentConfig["hideFromComponentList"] = true;
4301
+ const { processedOptions } = processRegistryOptions(componentConfig, {
4302
+ registry: "symbols",
4303
+ });
4304
+ this.componentRegistry.set(type, processedOptions);
4305
+ });
4306
+ }
4239
4307
  /**
4240
4308
  * Registers one or more components in the component registry.
4309
+ *
4310
+ * By default, duplicate registrations (same `type` registered twice) are
4311
+ * silently skipped — making the call **idempotent**. This is the desired
4312
+ * behaviour under:
4313
+ * - HMR re-evaluation (the same module runs twice in dev),
4314
+ * - dual-bundle scenarios (RSC + client both pull in the registration
4315
+ * module),
4316
+ * - prod build workers (each worker may re-import the module),
4317
+ * - test setup re-runs.
4318
+ *
4319
+ * The previous default — throwing on duplicate — forced every consumer to
4320
+ * wrap the call in `try/catch` to absorb the throw, which had the side
4321
+ * effect of masking real registration errors (typos in `type`, malformed
4322
+ * schemas). Real errors now surface on the first call; duplicates no longer
4323
+ * trip them up.
4324
+ *
4325
+ * Pass `{ strict: true }` to opt back into the old behaviour (throw on any
4326
+ * duplicate). This is useful in tests that want to assert a clean
4327
+ * registration boundary. `overrideDefaultComponents` on the registry config
4328
+ * still wins over both — it lets a duplicate replace the existing entry.
4329
+ *
4241
4330
  * @param components - An array of component options to register.
4331
+ * @param options - Per-call registration options. `strict: true` reinstates
4332
+ * the throw on duplicate.
4242
4333
  */
4243
- registerComponents(components) {
4334
+ registerComponents(components, options) {
4244
4335
  components.forEach((componentOption) => {
4245
4336
  const { type } = componentOption;
4246
4337
  if (!type) {
4247
4338
  throw new Error("Component type is required.");
4248
4339
  }
4249
- if (this.componentRegistry.has(type) &&
4250
- !this.config.overrideDefaultComponents) {
4251
- throw new Error(`Component with type '${type}' is already registered.`);
4252
- }
4253
4340
  if (SYSTEM_COMPONENTS.has(type)) {
4254
4341
  throw new Error(`Component with type '${type}' is a system component and cannot be overridden.`);
4255
4342
  }
4343
+ if (this.componentRegistry.has(type) &&
4344
+ !this.config.overrideDefaultComponents) {
4345
+ if (options?.strict) {
4346
+ throw new Error(`Component with type '${type}' is already registered.`);
4347
+ }
4348
+ // Idempotent default: silently skip duplicates so HMR/dual-graph/
4349
+ // worker re-evaluation does not break a working integration.
4350
+ return;
4351
+ }
4256
4352
  const { processedOptions, propValidators } = processRegistryOptions(componentOption, {
4257
4353
  registry: "user-defined",
4258
4354
  });
@@ -4369,6 +4465,10 @@ class ComponentRegistry {
4369
4465
  }
4370
4466
  return getSymbolUIDFromNode(node);
4371
4467
  }
4468
+ if (type === "section-composition") {
4469
+ const resolvedName = getSectionUIDFromNode(node) || type;
4470
+ return resolvedName;
4471
+ }
4372
4472
  return type;
4373
4473
  }
4374
4474
  /**
@@ -4516,34 +4616,72 @@ class ComponentRegistry {
4516
4616
  }
4517
4617
 
4518
4618
  /**
4519
- * Singleton instance of ComponentRegistry.
4520
- * This ensures all packages (studio-client, studio-react, etc.) use the same registry instance.
4619
+ * Cross-runtime singleton storage for SDK-owned registries.
4620
+ *
4621
+ * Why globalThis: a module-scoped `let instance` only exists within whichever
4622
+ * module-graph evaluates the file. Next.js maintains two graphs (RSC server +
4623
+ * client); Webpack/Turbopack treat them as independent realms. A registry
4624
+ * populated in one graph is invisible to the other. Prod build workers don't
4625
+ * share JS heap either — each worker has its own module-scoped state.
4521
4626
  *
4522
- * Using a singleton pattern here is appropriate because:
4523
- * 1. There should only be one component registry per application
4524
- * 2. Multiple packages need to access the same instance
4525
- * 3. Avoids circular dependencies between packages
4627
+ * globalThis is uniformly available across Node, browser, Edge runtime,
4628
+ * Cloudflare/Vercel workers, Deno, Bun, and Web Workers, and is shared by RSC
4629
+ * + client graphs within a single process. Storing SDK runtime singletons here
4630
+ * makes them visible to every consumer regardless of bundler or graph.
4631
+ *
4632
+ * The key is versioned (`_v1`) so future shape changes can land under `_v2`
4633
+ * without colliding with older SDK copies during a partial upgrade.
4526
4634
  */
4527
- let instance = null;
4635
+ const GLOBAL_STORE_KEY = "__contentstack_studio_registry_v1";
4528
4636
  /**
4529
- * Gets the singleton ComponentRegistry instance.
4530
- * Creates it if it doesn't exist yet.
4637
+ * Returns the SDK's versioned slot on globalThis, creating it on first call.
4638
+ * Always returns the same object reference within a single JS runtime.
4531
4639
  *
4532
- * @returns The singleton ComponentRegistry instance
4640
+ * Type-erased on purpose: each registry singleton casts to its own type on
4641
+ * read/write so the public API of `studio-registry` stays free of cross-
4642
+ * package import dependencies (e.g. `BreakpointManager` lives in
4643
+ * `studio-client`).
4644
+ */
4645
+ function getGlobalStudioStore() {
4646
+ const g = globalThis;
4647
+ if (!g[GLOBAL_STORE_KEY]) {
4648
+ g[GLOBAL_STORE_KEY] = {
4649
+ componentRegistry: null,
4650
+ designRegistry: null,
4651
+ breakpointManager: null,
4652
+ };
4653
+ }
4654
+ return g[GLOBAL_STORE_KEY];
4655
+ }
4656
+ /**
4657
+ * Clears the entire store. For tests only. Production code should never call
4658
+ * this — it would orphan every existing reference to the previous instances.
4659
+ */
4660
+ function resetGlobalStudioStore() {
4661
+ const g = globalThis;
4662
+ delete g[GLOBAL_STORE_KEY];
4663
+ }
4664
+
4665
+ /**
4666
+ * Singleton ComponentRegistry, backed by a versioned slot on `globalThis`.
4533
4667
  *
4534
- * @example
4535
- * ```typescript
4536
- * import { getComponentRegistryInstance } from '@contentstack/studio-registry';
4668
+ * The previous module-scoped `let instance` only existed within whichever
4669
+ * module-graph evaluated this file. Under Next.js's dual RSC/client graph or
4670
+ * across prod build workers, that meant two registries with no sharing —
4671
+ * `fetchCompositionData` (server) could see an empty registry while
4672
+ * `<StudioComponent>` (client) saw a populated one. See `common/global-store.ts`
4673
+ * for the full reasoning.
4537
4674
  *
4538
- * const registry = getComponentRegistryInstance();
4539
- * await registry.loadComponent('my-component');
4540
- * ```
4675
+ * After this change, all callers of `getComponentRegistryInstance()` resolve
4676
+ * to the same `ComponentRegistry` instance within a single JS runtime,
4677
+ * regardless of which graph or worker they were evaluated in.
4541
4678
  */
4542
4679
  function getComponentRegistryInstance() {
4543
- if (!instance) {
4544
- instance = new ComponentRegistry();
4680
+ const store = getGlobalStudioStore();
4681
+ if (!store.componentRegistry) {
4682
+ store.componentRegistry = new ComponentRegistry();
4545
4683
  }
4546
- return instance;
4684
+ return store.componentRegistry;
4547
4685
  }
4548
4686
  /**
4549
4687
  * Resets the singleton instance.
@@ -4559,7 +4697,7 @@ function getComponentRegistryInstance() {
4559
4697
  * ```
4560
4698
  */
4561
4699
  function resetComponentRegistryInstance() {
4562
- instance = null;
4700
+ getGlobalStudioStore().componentRegistry = null;
4563
4701
  }
4564
4702
  /**
4565
4703
  * Checks if the singleton instance has been created.
@@ -4567,7 +4705,7 @@ function resetComponentRegistryInstance() {
4567
4705
  * @returns true if the instance exists, false otherwise
4568
4706
  */
4569
4707
  function hasComponentRegistryInstance() {
4570
- return instance !== null;
4708
+ return getGlobalStudioStore().componentRegistry !== null;
4571
4709
  }
4572
4710
 
4573
4711
  const SIZE_TOKENS = {
@@ -5403,6 +5541,38 @@ class DesignRegistry {
5403
5541
  }
5404
5542
  }
5405
5543
 
5544
+ /**
5545
+ * Singleton DesignRegistry, backed by a versioned slot on `globalThis`.
5546
+ *
5547
+ * Previously, `studio-react/src/composable-studio/sdk.ts` did
5548
+ * `export const designRegistry = new DesignRegistry()` at module scope — which
5549
+ * means every separate module-graph (RSC vs client, build workers) got its own
5550
+ * `DesignRegistry`. Design tokens registered on one side were invisible to the
5551
+ * other. See `common/global-store.ts` for the dual-graph background.
5552
+ *
5553
+ * After this change, all callers of `getDesignRegistryInstance()` resolve to
5554
+ * the same `DesignRegistry` within a single JS runtime.
5555
+ */
5556
+ function getDesignRegistryInstance() {
5557
+ const store = getGlobalStudioStore();
5558
+ if (!store.designRegistry) {
5559
+ store.designRegistry = new DesignRegistry();
5560
+ }
5561
+ return store.designRegistry;
5562
+ }
5563
+ /**
5564
+ * Resets the singleton instance. For tests only.
5565
+ */
5566
+ function resetDesignRegistryInstance() {
5567
+ getGlobalStudioStore().designRegistry = null;
5568
+ }
5569
+ /**
5570
+ * Checks if the singleton instance has been created.
5571
+ */
5572
+ function hasDesignRegistryInstance() {
5573
+ return getGlobalStudioStore().designRegistry !== null;
5574
+ }
5575
+
5406
5576
  class JSONRTERegistry {
5407
5577
  config;
5408
5578
  constructor(config) {
@@ -5666,6 +5836,7 @@ function getDefaultPropStaticValue(args) {
5666
5836
  datestring: "",
5667
5837
  any: "",
5668
5838
  json_rte: {},
5839
+ plaintext: "",
5669
5840
  };
5670
5841
  if (args) {
5671
5842
  return defaultValues[args];
@@ -5686,6 +5857,7 @@ function isKnownType(type) {
5686
5857
  datestring: true,
5687
5858
  any: true,
5688
5859
  json_rte: true,
5860
+ plaintext: true,
5689
5861
  };
5690
5862
  return Object.keys(knownTypes).includes(type);
5691
5863
  }
@@ -5806,8 +5978,12 @@ function isDataMatchingPropType(data, type) {
5806
5978
  imageurl: dataType === "string",
5807
5979
  datestring: dataType === "string",
5808
5980
  json_rte: dataType === "object",
5981
+ // "any" accepts all data types — no validation
5982
+ any: true,
5983
+ // "plaintext" accepts singleline/multiline text, number, and boolean fields
5984
+ plaintext: dataType === "string" || dataType === "number" || dataType === "boolean",
5809
5985
  };
5810
- return map[type];
5986
+ return map[type] ?? false;
5811
5987
  }
5812
5988
  function getDataType(data) {
5813
5989
  if (typeof data === "object" && data !== null && !Array.isArray(data)) {
@@ -5827,6 +6003,48 @@ const dataSourceCapabilities = {
5827
6003
  [DATA_SOURCES.QUERY]: { supportsCslp: true }, // Verified: Query supports CSLP now
5828
6004
  };
5829
6005
 
6006
+ /**
6007
+ * Prop keys (`<nodeUid>-<field>`) for which a binding-type-mismatch error has
6008
+ * been reported to the editor and not yet retracted.
6009
+ *
6010
+ * The editor's "Data Mismatch Found" badge is driven entirely by the
6011
+ * UPDATE_BINDING_ERRORS messages we send from here — it has no other source of
6012
+ * truth. Previously we only ever SENT errors and never retracted them, so a
6013
+ * transient mismatch (e.g. a section repeater bound to scope-root that briefly
6014
+ * sees the whole entry OBJECT while a freshly-swapped schema re-scopes) left a
6015
+ * sticky error that survived even after the data resolved correctly. Tracking
6016
+ * what we've reported lets us emit a one-shot retraction the moment the data
6017
+ * matches again, so the badge reflects the live render instead of latching.
6018
+ */
6019
+ const reportedBindingErrors = new Set();
6020
+ /**
6021
+ * Retract every binding-mismatch error previously reported for `nodeUid`'s
6022
+ * props and forget them.
6023
+ *
6024
+ * The in-render retraction in `retrievePropValue` only clears the editor badge
6025
+ * when the SAME node re-renders with matching data — which never happens once
6026
+ * the node disappears (e.g. a repeater item removed, or a section swapped for a
6027
+ * different schema). Without this, such a node's badge would latch and its
6028
+ * entry would leak in `reportedBindingErrors` forever. Call this from the
6029
+ * node's unmount path so the badge reflects the live tree.
6030
+ *
6031
+ * Keys are `${nodeUid}-${field}`; the trailing `-` (and fixed-length uids)
6032
+ * makes the prefix match exact, so one node's uid can't match another's.
6033
+ */
6034
+ function clearReportedBindingErrorsForNode(nodeUid) {
6035
+ if (reportedBindingErrors.size === 0)
6036
+ return;
6037
+ const prefix = `${nodeUid}-`;
6038
+ for (const propKey of reportedBindingErrors) {
6039
+ if (!propKey.startsWith(prefix))
6040
+ continue;
6041
+ reportedBindingErrors.delete(propKey);
6042
+ studioMessenger.composableStudioEventManager?.send(studioMessenger.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
6043
+ propKey,
6044
+ errorMessage: "",
6045
+ });
6046
+ }
6047
+ }
5830
6048
  // Responsible for resolving props to values
5831
6049
  function retrievePropValue(args) {
5832
6050
  const { data, componentOptions, node, cslp, placeholders = {}, getSlots, jsonRTE, isCompositionBeingEdited, } = args;
@@ -5855,6 +6073,11 @@ function retrievePropValue(args) {
5855
6073
  return;
5856
6074
  }
5857
6075
  let resolvedData;
6076
+ // When the value is resolved via the `dataSources.page.*` fallback below,
6077
+ // the CSLP tag must come from the SAME page path (not the section-local
6078
+ // binding, which missed). Holds that page path so the cslp block points the
6079
+ // edit tag at the field the value actually came from.
6080
+ let cslpPathOverride;
5858
6081
  if (type === "slot") {
5859
6082
  resolvedData = getSlotData({
5860
6083
  nodeProps: nodeProps,
@@ -5865,6 +6088,32 @@ function retrievePropValue(args) {
5865
6088
  mappedData[field] = resolvedData;
5866
6089
  return;
5867
6090
  }
6091
+ // Section exposed-prop override: the page composer's exposed-prop binding is
6092
+ // the SOLE source of truth for an exposed field — the internal node's own
6093
+ // binding must never leak through on a page. SectionCompositionProvider emits
6094
+ // an entry for EVERY exposed prop (even when the page value is cleared/empty),
6095
+ // so we apply on key PRESENCE, not on a non-undefined value. A cleared prop
6096
+ // therefore renders the page-resolved empty value instead of falling back to
6097
+ // the section's authored binding.
6098
+ const overridesForNode = data.dataSources?.section_exposed_overrides?.[node.uid];
6099
+ if (overridesForNode && field in overridesForNode) {
6100
+ mappedData[field] = overridesForNode[field];
6101
+ // Carry the page-resolved CSLP tag for this exposed prop. This branch
6102
+ // short-circuits BEFORE the cslp block (~L430), so without re-emitting
6103
+ // here a page-overridden field (e.g. a section's root component bound via
6104
+ // a non-repeater binding) renders with no `data-cslp` and loses its
6105
+ // live-preview edit overlay — even though its value resolves fine. The
6106
+ // SectionComposition wrappers stash the page node's resolved cslp object
6107
+ // alongside the value under `$<propKey>`, so it points at the PAGE entry
6108
+ // field (the override's source of truth). Repeater-context exposed props
6109
+ // are never in this map (they fall through to their own binding + cslp).
6110
+ if (cslp.appendTags) {
6111
+ const overrideCslp = overridesForNode[`$${field}`];
6112
+ if (overrideCslp)
6113
+ mappedData[`$${field}`] = overrideCslp;
6114
+ }
6115
+ return;
6116
+ }
5868
6117
  const nodePropConfig = nodeProps[field];
5869
6118
  const { binding: bindedField, value: staticValue } = nodePropConfig || {};
5870
6119
  //TODO: Get proper data for design
@@ -5924,6 +6173,40 @@ function retrievePropValue(args) {
5924
6173
  else if (dataPath &&
5925
6174
  !(type === "choice" && bindedField?.type === "static_value")) {
5926
6175
  resolvedData = get(data, dataPath, fallbackValue);
6176
+ // TEMP — slot-child page-context fallback (PHASE 8 will remove this).
6177
+ //
6178
+ // Section-slot wraps its children's data context so that:
6179
+ // dataSources.template / .contentstack / .contentstack_queries / .repeater
6180
+ // ALL refer to the section's LOCAL surrounding context — matching what
6181
+ // the Data Picker currently writes when authoring a slot child against
6182
+ // section-local fields.
6183
+ //
6184
+ // The page's outer entries live at `dataSources.page.template`, etc., as
6185
+ // the explicit escape namespace. But until the Picker is slot-aware
6186
+ // (Phase 8), it has no way to write `dataSources.page.X` paths — so a
6187
+ // page-level binding authored on a slot child still produces a
6188
+ // `dataSources.<source>.X` path that targets the section-local view and
6189
+ // resolves to undefined.
6190
+ //
6191
+ // Bridge: if the local resolution is missing AND a `page` sibling
6192
+ // namespace exists on dataSources, retry under `dataSources.page.X`. Remove
6193
+ // this fallback when the Picker emits explicit `dataSources.page.X`
6194
+ // paths.
6195
+ if ((resolvedData === undefined ||
6196
+ resolvedData === null ||
6197
+ resolvedData === fallbackValue) &&
6198
+ typeof dataPath === "string" &&
6199
+ dataPath.startsWith("dataSources.") &&
6200
+ !dataPath.startsWith("dataSources.page.") &&
6201
+ data?.dataSources?.page) {
6202
+ const pagePath = dataPath.replace(/^dataSources\./, "dataSources.page.");
6203
+ const pageResolved = get(data, pagePath, undefined);
6204
+ if (pageResolved !== undefined && pageResolved !== null) {
6205
+ resolvedData = pageResolved;
6206
+ // Mirror the value's source so the cslp block tags the page field.
6207
+ cslpPathOverride = pagePath;
6208
+ }
6209
+ }
5927
6210
  // Handle primitive values in repeater context
5928
6211
  // When the array contains primitives (strings, numbers, etc.) instead of objects,
5929
6212
  // the binding path will be like: dataSources.repeater.{uid}.context.{fieldName}
@@ -6028,6 +6311,7 @@ function retrievePropValue(args) {
6028
6311
  });
6029
6312
  if (isCompositionBeingEdited) {
6030
6313
  // In editor mode: Send to Visual Builder
6314
+ reportedBindingErrors.add(`${node.uid}-${field}`);
6031
6315
  studioMessenger.composableStudioEventManager?.send(studioMessenger.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
6032
6316
  propKey: `${node.uid}-${field}`,
6033
6317
  errorMessage: getRegistryErrorMessage(RegistryErrorMessageKey.DATA_BINDING_TYPE_MISMATCH_EDITOR, { expectedType: type, receivedType }),
@@ -6046,6 +6330,21 @@ function retrievePropValue(args) {
6046
6330
  });
6047
6331
  }
6048
6332
  }
6333
+ else if (isCompositionBeingEdited) {
6334
+ // Data now matches the prop type. If we previously reported a mismatch for
6335
+ // this prop, retract it (empty errorMessage → the editor calls
6336
+ // removeBindingError) so a stale "Data Mismatch Found" badge doesn't
6337
+ // persist after the binding re-resolves — e.g. once a swapped section
6338
+ // schema finishes re-scoping a repeater's items to its array field.
6339
+ const propKey = `${node.uid}-${field}`;
6340
+ if (reportedBindingErrors.has(propKey)) {
6341
+ reportedBindingErrors.delete(propKey);
6342
+ studioMessenger.composableStudioEventManager?.send(studioMessenger.POST_MESSAGE_EVENTS.UPDATE_BINDING_ERRORS, {
6343
+ propKey,
6344
+ errorMessage: "",
6345
+ });
6346
+ }
6347
+ }
6049
6348
  mappedData[field] = resolvedData;
6050
6349
  if (type === "json_rte") {
6051
6350
  mappedData["jsonConfig"] = jsonRTE;
@@ -6053,7 +6352,13 @@ function retrievePropValue(args) {
6053
6352
  const isCSLPAbleType = bindedField?.type &&
6054
6353
  dataSourceCapabilities[bindedField.type]?.supportsCslp;
6055
6354
  if (cslp.appendTags && dataPath && isCSLPAbleType) {
6056
- const cslpValue = getCslpTag({ bindedField: dataPath, data });
6355
+ // Use the page-fallback path when the value came from there (cross-section
6356
+ // / slot-child page binding), so the edit tag points at the field that
6357
+ // actually supplied the value; otherwise the section-local binding path.
6358
+ const cslpValue = getCslpTag({
6359
+ bindedField: cslpPathOverride ?? dataPath,
6360
+ data,
6361
+ });
6057
6362
  if (cslpValue) {
6058
6363
  mappedData[`$${field}`] = cslpValue;
6059
6364
  }
@@ -6063,6 +6368,11 @@ function retrievePropValue(args) {
6063
6368
  mappedData["_uid"] = node.uid;
6064
6369
  mappedData["mode"] = node?.metadata?.mode;
6065
6370
  }
6371
+ if (node.type === "section-slot") {
6372
+ // Section-slot needs its own node uid at render time so it can look up
6373
+ // the page-side fill in SectionInstanceSlotsCtx.slotsMap[node.uid].
6374
+ mappedData["_uid"] = node.uid;
6375
+ }
6066
6376
  if (node.type === "condition-block") {
6067
6377
  mappedData["condition"] = node?.metadata?.condition;
6068
6378
  mappedData["mode"] = node?.metadata?.mode;
@@ -6080,6 +6390,34 @@ function retrievePropValue(args) {
6080
6390
  mappedData["symbol_props"][uid] = mappedData[field];
6081
6391
  });
6082
6392
  }
6393
+ if (node.type === "section-composition") {
6394
+ // Surface the page composer's LIVE binding type for each exposed prop so the
6395
+ // SectionComposition renderer can tell an untouched seed from a real override.
6396
+ // A repeater expose-time binding is only resolvable inside the section's own
6397
+ // Repeater scope; at page level it resolves to a placeholder, not undefined —
6398
+ // so the resolved VALUE can't distinguish "untouched" from "overridden". The
6399
+ // live binding type can: still `repeater` (or absent) ⇒ untouched, fall
6400
+ // through to the internal per-iteration binding; any page-resolvable type ⇒
6401
+ // the composer rebound it and the override must win.
6402
+ const bindingTypes = {};
6403
+ const autoSeeded = {};
6404
+ for (const field of Object.keys(nodeProps)) {
6405
+ const binding = nodeProps[field]?.binding;
6406
+ if (binding?.type)
6407
+ bindingTypes[field] = binding.type;
6408
+ // An auto-seeded binding means the page composer hasn't touched this exposed
6409
+ // prop — the renderer skips its override so the section's internal binding
6410
+ // resolves (re-scoped on schema switch / per repeater iteration).
6411
+ if (binding?.autoSeeded)
6412
+ autoSeeded[field] = true;
6413
+ }
6414
+ mappedData["section_exposed_binding_types"] = bindingTypes;
6415
+ mappedData["section_exposed_auto_seeded"] = autoSeeded;
6416
+ // Per-placement design/preview mode. The editor's SectionComposition uses
6417
+ // this to derive/override the render mode of every repeater, condition-block,
6418
+ // and section-slot inside the section. Ignored in production (renders live).
6419
+ mappedData["mode"] = node?.metadata?.mode;
6420
+ }
6083
6421
  // TODO: Add support for useData Hook for studio
6084
6422
  return mappedData;
6085
6423
  }
@@ -6165,6 +6503,7 @@ exports.JSONRTERegistry = JSONRTERegistry;
6165
6503
  exports.STYLE_SECTIONS_OPTIONS = STYLE_SECTIONS_OPTIONS;
6166
6504
  exports.STYLE_SECTION_CATEGORIES = STYLE_SECTION_CATEGORIES;
6167
6505
  exports.SYSTEM_COMPONENTS = SYSTEM_COMPONENTS;
6506
+ exports.clearReportedBindingErrorsForNode = clearReportedBindingErrorsForNode;
6168
6507
  exports.convertBindingPath = convertBindingPath;
6169
6508
  exports.getBindingString = getBindingString;
6170
6509
  exports.getComponentRegistryInstance = getComponentRegistryInstance;
@@ -6173,18 +6512,24 @@ exports.getCslpTag = getCslpTag;
6173
6512
  exports.getDataType = getDataType;
6174
6513
  exports.getDefaultPropStaticValue = getDefaultPropStaticValue;
6175
6514
  exports.getDesignClassesNames = getDesignClassesNames;
6515
+ exports.getDesignRegistryInstance = getDesignRegistryInstance;
6176
6516
  exports.getFlattenedData = getFlattenedData;
6517
+ exports.getGlobalStudioStore = getGlobalStudioStore;
6177
6518
  exports.getPlaceHolderComponent = getPlaceHolderComponent;
6178
6519
  exports.getRepeaterBinding = getRepeaterBinding;
6179
6520
  exports.getRepeaterContextPath = getRepeaterContextPath;
6521
+ exports.getSectionUIDFromNode = getSectionUIDFromNode;
6180
6522
  exports.getSlotData = getSlotData;
6181
6523
  exports.getSymbolUIDFromNode = getSymbolUIDFromNode;
6182
6524
  exports.getSymbolUIDFromUID = getSymbolUIDFromUID;
6183
6525
  exports.hasComponentRegistryInstance = hasComponentRegistryInstance;
6526
+ exports.hasDesignRegistryInstance = hasDesignRegistryInstance;
6184
6527
  exports.isDataMatchingPropType = isDataMatchingPropType;
6185
6528
  exports.isKnownType = isKnownType;
6186
6529
  exports.normalizeSingleSelectChoiceValue = normalizeSingleSelectChoiceValue;
6187
6530
  exports.resetComponentRegistryInstance = resetComponentRegistryInstance;
6531
+ exports.resetDesignRegistryInstance = resetDesignRegistryInstance;
6532
+ exports.resetGlobalStudioStore = resetGlobalStudioStore;
6188
6533
  exports.resolveMetadataBindings = resolveMetadataBindings;
6189
6534
  exports.retrievePropValue = retrievePropValue;
6190
6535
  //# sourceMappingURL=index.cjs.map