@contentstack/studio-react-editor 1.7.0-alpha-20260721T1325-1838437.0 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/components/EditableRenderer.js +6 -19
  2. package/dist/components/EditableRenderer.js.map +1 -1
  3. package/dist/components/Element.js +36 -21
  4. package/dist/components/Element.js.map +1 -1
  5. package/dist/components/PreviewRenderer.js +0 -19
  6. package/dist/components/PreviewRenderer.js.map +1 -1
  7. package/dist/components/WelcomeState.js +1 -17
  8. package/dist/components/WelcomeState.js.map +1 -1
  9. package/dist/components/elements/ConditionBlock.js +2 -15
  10. package/dist/components/elements/ConditionBlock.js.map +1 -1
  11. package/dist/components/elements/Repeater.js +1 -15
  12. package/dist/components/elements/Repeater.js.map +1 -1
  13. package/dist/components/elements/SectionSlot.js +59 -2
  14. package/dist/components/elements/SectionSlot.js.map +1 -1
  15. package/dist/components/styles.js +69 -0
  16. package/dist/components/styles.js.map +1 -1
  17. package/dist/hooks/use-active-node-path.hook.js +0 -19
  18. package/dist/hooks/use-active-node-path.hook.js.map +1 -1
  19. package/dist/hooks/use-condition-block-context.js +0 -20
  20. package/dist/hooks/use-condition-block-context.js.map +1 -1
  21. package/dist/hooks/use-design-preview.hook.js +0 -20
  22. package/dist/hooks/use-design-preview.hook.js.map +1 -1
  23. package/dist/hooks/use-preview-mode.hook.js +0 -20
  24. package/dist/hooks/use-preview-mode.hook.js.map +1 -1
  25. package/dist/hooks/use-register-section.hook.js +0 -1
  26. package/dist/hooks/use-register-section.hook.js.map +1 -1
  27. package/dist/hooks/use-renderer.hook.js +0 -20
  28. package/dist/hooks/use-renderer.hook.js.map +1 -1
  29. package/dist/hooks/use-repeater.hook.js +0 -20
  30. package/dist/hooks/use-repeater.hook.js.map +1 -1
  31. package/dist/hooks/use-should-show-design.hook.js +1 -20
  32. package/dist/hooks/use-should-show-design.hook.js.map +1 -1
  33. package/dist/hooks/use-spec-data-listener.hook.js +55 -10
  34. package/dist/hooks/use-spec-data-listener.hook.js.map +1 -1
  35. package/package.json +12 -13
  36. package/dist/components/elements/Symbol.js +0 -65
  37. package/dist/components/elements/Symbol.js.map +0 -1
  38. package/dist/contexts/providers/symbol-ui.provider.js +0 -88
  39. package/dist/contexts/providers/symbol-ui.provider.js.map +0 -1
  40. package/dist/hooks/use-register-symbol.hook.js +0 -54
  41. package/dist/hooks/use-register-symbol.hook.js.map +0 -1
  42. package/dist/hooks/use-symbol-events.hook.js +0 -45
  43. package/dist/hooks/use-symbol-events.hook.js.map +0 -1
  44. package/dist/hooks/use-symbol-ui-listener.hook.js +0 -17
  45. package/dist/hooks/use-symbol-ui-listener.hook.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-repeater.hook.js","sources":["../../src/hooks/use-repeater.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { RepeaterContext } from \"../contexts/providers\";\n\nexport const useRepeaterContext = () => useContext(RepeaterContext);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAGO,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,eAAe;;;;"}
1
+ {"version":3,"file":"use-repeater.hook.js","sources":["../../src/hooks/use-repeater.hook.ts"],"sourcesContent":["import { useContext } from \"react\";\nimport { RepeaterContext } from \"../contexts/providers/use-repeater.provider\";\n\nexport const useRepeaterContext = () => useContext(RepeaterContext);\n"],"names":[],"mappings":";;;AAGO,MAAM,kBAAkB,GAAG,MAAM,UAAU,CAAC,eAAe;;;;"}
@@ -1,29 +1,10 @@
1
1
  import { clientRendererModeUtil } from '@contentstack/studio-client';
2
2
  import { useContext } from 'react';
3
- import '../contexts/providers/renderer.provider.js';
4
- import '../contexts/providers/edit-context.provider.js';
5
- import '../contexts/providers/active-node.provider.js';
6
- import 'react/jsx-runtime';
7
- import '@contentstack/studio-messenger';
8
- import '@contentstack/studio-react-components/contexts';
9
- import 'immer';
10
- import './use-edit-context-listener.hook.js';
11
- import '@contentstack/studio-internal';
12
- import '@contentstack/studio-core';
13
- import '@contentstack/studio-react-components/basic-components';
14
- import '@contentstack/studio-react-components/hooks';
15
- import 'goober';
16
- import '../components/Element.js';
17
3
  import { SectionModeContext } from '../contexts/providers/section-mode.provider.js';
4
+ import { useConditionBlockContext } from './use-condition-block-context.js';
18
5
  import { useDesignPreviewContext } from './use-design-preview.hook.js';
19
6
  import { useRenderer } from './use-renderer.hook.js';
20
- import '@contentstack/studio-registry';
21
7
  import { useRepeaterContext } from './use-repeater.hook.js';
22
- import { useConditionBlockContext } from './use-condition-block-context.js';
23
- import '../contexts/providers/use-design-preview.provider.js';
24
- import '../contexts/providers/use-repeater.provider.js';
25
- import '../contexts/providers/use-condition-block.provider.js';
26
- import '../contexts/providers/preview-mode.provider.js';
27
8
 
28
9
  function useShouldShowDesign(mode) {
29
10
  const { isCompositionBeingEdited } = useRenderer();
@@ -1 +1 @@
1
- {"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport { SectionModeContext } from \"../contexts/providers\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\nexport function useShouldShowDesign(mode: \"design\" | \"preview\") {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAQM,SAAU,mBAAmB,CAAC,IAA0B,EAAA;AAC5D,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE;AACjD,IAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE;AAC7D,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;;;;;;AAMlD,IAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,EAAE;AACnE,IAAA,IAAI,CAAC,wBAAwB,IAAI,CAAC,cAAc;AAAE,QAAA,OAAO,KAAK;;;;;;;;;;;;;;IAe9D,IAAI,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,WAAW,KAAK,QAAQ;QAAE,OAAO,oBAAoB,KAAK,SAAS;AAEvE,IAAA,IAAI,gBAAgB,IAAI,sBAAsB,EAAE;;;AAG9C,QAAA,IAAI,CAAC,oBAAoB;AAAE,YAAA,OAAO,IAAI;;;QAGtC,OAAO,oBAAoB,KAAK,QAAQ;IAC1C;;IAEA,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,IAAI;IACb;;IAEA,OAAO,IAAI,KAAK,QAAQ;AAC1B;;;;"}
1
+ {"version":3,"file":"use-should-show-design.hook.js","sources":["../../src/hooks/use-should-show-design.hook.ts"],"sourcesContent":["import { clientRendererModeUtil } from \"@contentstack/studio-client\";\nimport { useContext } from \"react\";\nimport { SectionModeContext } from \"../contexts/providers/section-mode.provider\";\nimport { useConditionBlockContext } from \"./use-condition-block-context\";\nimport { useDesignPreviewContext } from \"./use-design-preview.hook\";\nimport { useRenderer } from \"./use-renderer.hook\";\nimport { useRepeaterContext } from \"./use-repeater.hook\";\n\nexport function useShouldShowDesign(mode: \"design\" | \"preview\") {\n const { isCompositionBeingEdited } = useRenderer();\n const { isInsideRepeater } = useRepeaterContext();\n const { isInsideConditionBlock } = useConditionBlockContext();\n const designPreviewContext = useDesignPreviewContext();\n const sectionMode = useContext(SectionModeContext);\n // Treat the Studio editor frame as design-mode-eligible from the very first\n // render — even before `isCompositionBeingEdited` has resolved — to avoid a\n // one-frame preview render that would inject items[0] context. Use\n // `isInsideStudioFrame()` (URL-param-gated) so Visual Builder's iframe\n // (which should render preview) is correctly excluded.\n const isInsideStudio = clientRendererModeUtil.isInsideStudioFrame();\n if (!isCompositionBeingEdited && !isInsideStudio) return false;\n\n // A placed section forces the mode of everything inside it — a single\n // per-placement switch that overrides each inner node's own `mode`. Only set\n // inside a section placement in the editor; null everywhere else.\n // - PREVIEW always wins → render preview.\n // - DESIGN keeps the section's own drop-zones visible, BUT when the section\n // is itself nested inside an enclosing PREVIEW repeater its internal data\n // repeaters must still iterate — otherwise a data-bound slot child can\n // never resolve its per-iteration context (SP7.1: a slot-bearing section\n // defaults to design via COMS-1595, which froze its inner repeaters). So\n // defer to the enclosing preview context in that case. At the page root\n // designPreviewContext is \"none\", so design is preserved (the slot's own\n // drop-zone-vs-collapsed rendering reads SectionModeContext directly and\n // is unaffected either way).\n if (sectionMode === \"preview\") return false;\n if (sectionMode === \"design\") return designPreviewContext !== \"preview\";\n\n if (isInsideRepeater || isInsideConditionBlock) {\n // If composition is being edited and current node(Repeater or Condition Block) inside another repeater or condition block,\n // and no designPreviewContext is provided, then show design\n if (!designPreviewContext) return true;\n // If designPreviewContext is provided,\n // then show design based on designPreviewContext\n return designPreviewContext === \"design\";\n }\n // if no mode is provided, then show design\n if (!mode) {\n return true;\n }\n // If mode is provided, then show design based on mode\n return mode === \"design\";\n}\n"],"names":[],"mappings":";;;;;;;;AAQM,SAAU,mBAAmB,CAAC,IAA0B,EAAA;AAC5D,IAAA,MAAM,EAAE,wBAAwB,EAAE,GAAG,WAAW,EAAE;AAClD,IAAA,MAAM,EAAE,gBAAgB,EAAE,GAAG,kBAAkB,EAAE;AACjD,IAAA,MAAM,EAAE,sBAAsB,EAAE,GAAG,wBAAwB,EAAE;AAC7D,IAAA,MAAM,oBAAoB,GAAG,uBAAuB,EAAE;AACtD,IAAA,MAAM,WAAW,GAAG,UAAU,CAAC,kBAAkB,CAAC;;;;;;AAMlD,IAAA,MAAM,cAAc,GAAG,sBAAsB,CAAC,mBAAmB,EAAE;AACnE,IAAA,IAAI,CAAC,wBAAwB,IAAI,CAAC,cAAc;AAAE,QAAA,OAAO,KAAK;;;;;;;;;;;;;;IAe9D,IAAI,WAAW,KAAK,SAAS;AAAE,QAAA,OAAO,KAAK;IAC3C,IAAI,WAAW,KAAK,QAAQ;QAAE,OAAO,oBAAoB,KAAK,SAAS;AAEvE,IAAA,IAAI,gBAAgB,IAAI,sBAAsB,EAAE;;;AAG9C,QAAA,IAAI,CAAC,oBAAoB;AAAE,YAAA,OAAO,IAAI;;;QAGtC,OAAO,oBAAoB,KAAK,QAAQ;IAC1C;;IAEA,IAAI,CAAC,IAAI,EAAE;AACT,QAAA,OAAO,IAAI;IACb;;IAEA,OAAO,IAAI,KAAK,QAAQ;AAC1B;;;;"}
@@ -128,7 +128,17 @@ state, composableUid) => {
128
128
  if (binding && "context" in binding && !("selectedField" in binding)) {
129
129
  continue;
130
130
  }
131
- const scopedTemplate = applyUidRemapping(getScopedData(pageTemplate, binding?.selectedField), binding?.uidRemapping);
131
+ let scopedTemplate = applyUidRemapping(getScopedData(pageTemplate, binding?.selectedField), binding?.uidRemapping);
132
+ // Single-element section: `selectedField` stays index-free, so an
133
+ // un-indexed terminal array resolves to the WHOLE array. Collapse to the
134
+ // first element (the deploy default — the preview instance is session-only)
135
+ // so the bound field resolves live, without depending on a save+reload
136
+ // running the cold-load scoper. Mirrors build-scoped-data.ts. When the
137
+ // path is already indexed (`menu_items[0]`, from Studio's push),
138
+ // getScopedData returns the element and this is a no-op.
139
+ if (binding?.cardinality === "single" && Array.isArray(scopedTemplate)) {
140
+ scopedTemplate = scopedTemplate[0] ?? null;
141
+ }
132
142
  let repeater;
133
143
  if (binding?.parentRepeaterUID) {
134
144
  const ctx = dataSources.repeater?.[binding.parentRepeaterUID];
@@ -166,6 +176,7 @@ state, composableUid) => {
166
176
  parentRepeaterUID: binding?.parentRepeaterUID ?? null,
167
177
  selectedField: binding?.selectedField,
168
178
  uidRemapping: binding?.uidRemapping,
179
+ cardinality: binding?.cardinality,
169
180
  componentPropsFallback: binding?.componentPropsFallback,
170
181
  };
171
182
  if (prev.template !== next.template ||
@@ -263,13 +274,27 @@ state, composableUid) => {
263
274
  const incomingSections = data?.dataSources?.[SECTION_COMPOSITIONS_KEY] || {};
264
275
  const existingSections = state.data?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||
265
276
  {};
277
+ // Per-uid merge preserves `cardinality` when the incoming entry
278
+ // lacks it — cardinality is a stable schema property, and a stale
279
+ // push dropping it would disable the single-element array→element
280
+ // collapse in rebuildScopedFromBindings (section blanks out).
281
+ const mergedSections = {
282
+ ...existingSections,
283
+ };
284
+ for (const [uid, incoming] of Object.entries(incomingSections)) {
285
+ const prev = existingSections[uid];
286
+ mergedSections[uid] =
287
+ incoming &&
288
+ typeof incoming === "object" &&
289
+ incoming.cardinality === undefined &&
290
+ prev?.cardinality !== undefined
291
+ ? { ...incoming, cardinality: prev.cardinality }
292
+ : incoming;
293
+ }
266
294
  const mergedDataSources = {
267
295
  ...(state.data?.dataSources || {}),
268
296
  ...(data?.dataSources || {}),
269
- [SECTION_COMPOSITIONS_KEY]: {
270
- ...existingSections,
271
- ...incomingSections,
272
- },
297
+ [SECTION_COMPOSITIONS_KEY]: mergedSections,
273
298
  };
274
299
  const mergedData = {
275
300
  ...state.data,
@@ -407,17 +432,37 @@ state, composableUid) => {
407
432
  return prevState;
408
433
  const existing = prevState.data?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||
409
434
  {};
435
+ // Per-uid merge preserves `cardinality` when an incoming entry lacks
436
+ // it (mirrors the UPDATE_SPEC_DATA merge below). Cardinality is a
437
+ // stable schema property; a push dropping it disables the
438
+ // single-element item-identity scoping for repeater-nested sections
439
+ // and the array→element collapse — the section blanks out.
440
+ const merged = { ...existing };
441
+ for (const [uid, incoming] of Object.entries(data.sectionCompositions)) {
442
+ const prev = existing[uid];
443
+ merged[uid] =
444
+ incoming &&
445
+ typeof incoming === "object" &&
446
+ incoming.cardinality === undefined &&
447
+ prev?.cardinality !== undefined
448
+ ? { ...incoming, cardinality: prev.cardinality }
449
+ : incoming;
450
+ }
410
451
  const mergedData = {
411
452
  ...prevState.data,
412
453
  dataSources: {
413
454
  ...prevState.data?.dataSources,
414
- [SECTION_COMPOSITIONS_KEY]: {
415
- ...existing,
416
- ...data.sectionCompositions,
417
- },
455
+ [SECTION_COMPOSITIONS_KEY]: merged,
418
456
  },
419
457
  };
420
- const finalData = rebuildScopedFromBindings(mergedData, data.sectionCompositions);
458
+ // Pass the MERGED entries for the incoming uids (not the raw incoming)
459
+ // — rebuildScopedFromBindings spreads incomingBindings over the slice,
460
+ // so raw entries would reintroduce the dropped cardinality.
461
+ const incomingMerged = Object.fromEntries(Object.keys(data.sectionCompositions).map((uid) => [
462
+ uid,
463
+ merged[uid],
464
+ ]));
465
+ const finalData = rebuildScopedFromBindings(mergedData, incomingMerged);
421
466
  return {
422
467
  ...prevState,
423
468
  data: finalData,
@@ -1 +1 @@
1
- {"version":3,"file":"use-spec-data-listener.hook.js","sources":["../../src/hooks/use-spec-data-listener.hook.ts"],"sourcesContent":["import {\n isCompositionBeingEdited,\n StudioSpec,\n applyOperation,\n SECTION_COMPOSITIONS_KEY,\n clientRendererModeUtil,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n SectionCompositionEntry,\n} from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport {\n StudioSpecData,\n DataSourceItem,\n DATA_SOURCES_PREFIX,\n} from \"@contentstack/studio-registry\";\nimport { seedSectionInstanceBindings } from \"@contentstack/studio-react-components/utils\";\nimport { useEffect, useRef } from \"react\";\nimport { produce, setAutoFreeze } from \"immer\";\n\n// NOTE: Immer (produce) automatically freezes the state to prevent mutations.\n// However, while resolving metadata bindings (which currently only include styles),\n// we need to add binding values directly to the node object.\n// Since the state is frozen by default, this throws an error.\n// To work around this, we disable auto-freezing here.\nsetAutoFreeze(false);\n\n/**\n * Walk a fresh UI tree (post-Immer-produce) and populate the NODE_TO_PARENT\n * and NODE_TO_PATH_NODE WeakMaps for every node. These maps are normally\n * populated during React render (in Element.tsx). After APPLY_OPERATION\n * produces a brand-new tree via Immer, the maps still hold entries for\n * stale node refs — `findPath` (used to compute hover/highlight paths sent\n * back to Studio) returns stale paths until the next React commit. Calling\n * this immediately after applyOperation closes that window.\n */\nfunction refreshNodeWeakMaps(root: any): void {\n if (!root || typeof root !== \"object\") return;\n NODE_TO_PARENT.set(root, undefined);\n const visit = (parent: any) => {\n const slots = parent?.slots || {};\n for (const slotUid of Object.keys(slots)) {\n const children = slots[slotUid] || [];\n for (let idx = 0; idx < children.length; idx++) {\n const child = children[idx];\n if (!child || typeof child !== \"object\") continue;\n NODE_TO_PARENT.set(child, parent);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx] as any);\n visit(child);\n }\n }\n };\n visit(root);\n}\n\nexport const useSpecDataListener = (\n setState: React.Dispatch<React.SetStateAction<StudioSpec>>,\n // Read into `stateRef` only — listener bodies use `stateRef.current` (not\n // `state` directly) so the effect's deps don't include `state.data`, which\n // would force re-register on every data change and create a window with\n // zero handlers between unregister/re-register (the original\n // `NO_REQUEST_LISTENER_FOUND` cause).\n state?: StudioSpec,\n composableUid?: string,\n) => {\n // Keep a ref to the latest state so the listener registrations don't have\n // to depend on state.data — they can read latest via stateRef.current\n // synchronously. Without this, every state.data change tore down + re-registered\n // the listeners, creating a window where Studio's UPDATE_SECTION_CONTEXTS\n // message was dropped with NO_REQUEST_LISTENER_FOUND.\n const stateRef = useRef(state);\n stateRef.current = state;\n\n // Rebuild section_scoped_data entries for instances whose binding metadata\n // (selectedField / uidRemapping / parentRepeaterUID) is present in the\n // legacy section_compositions slice. Mirrors build-scoped-data.ts logic\n // inline so the hook can rebuild without re-running the full fetchSpec\n // pipeline. Needed because Studio's fresh per-instance bindings arrive via\n // UPDATE_SPEC_DATA (and UPDATE_SECTION_CONTEXTS), while the provider only\n // reads from section_scoped_data — without this rebuild, sections render\n // the stale pre-computed scope from the initial fetchSpec (selectedField\n // missing from UI metadata on cold load → scoped template = whole page\n // template → placeholder text).\n const rebuildScopedFromBindings = (\n prevData: any,\n incomingBindings?: Record<string, unknown>,\n ): any => {\n const dataSources = prevData?.dataSources || {};\n const sectionBindings: Record<string, any> =\n incomingBindings && Object.keys(incomingBindings).length\n ? {\n ...(dataSources[SECTION_COMPOSITIONS_KEY] || {}),\n ...incomingBindings,\n }\n : dataSources[SECTION_COMPOSITIONS_KEY] || {};\n\n const pageTemplate = dataSources.template;\n const prevScoped = prevData?.section_scoped_data || {};\n const nextScoped: Record<string, any> = { ...prevScoped };\n\n const getScopedData = (obj: any, selectedField?: string): any => {\n if (!selectedField) return obj;\n return (\n selectedField.split(\".\").reduce((val: any, seg: string) => {\n if (val == null) return val;\n const arrayMatch = seg.match(/^(.*?)\\[(\\d+)\\]$/);\n if (arrayMatch) {\n const [, name, idxStr] = arrayMatch;\n const next = name ? val[name] : val;\n return next == null ? next : next[Number(idxStr)];\n }\n // Non-indexed field access landing on an ARRAY → default to the first\n // element so an un-indexed array-ancestor path (e.g.\n // \"navigation_menu_3.menu_subitems\", where navigation_menu_3 is a\n // multiple group) still resolves instead of `array[field]` →\n // undefined → null. Indexed pushes (`navigation_menu_3[1]…`) override\n // this with the picked instance.\n if (Array.isArray(val)) {\n const first = val[0];\n return first == null ? null : first[seg];\n }\n return val[seg];\n }, obj) ?? null\n );\n };\n\n const applyUidRemapping = (\n scoped: any,\n uidRemapping: Record<string, string> = {},\n ): any => {\n if (\n !scoped ||\n typeof scoped !== \"object\" ||\n Object.keys(uidRemapping).length === 0\n ) {\n return scoped;\n }\n if (Array.isArray(scoped)) {\n return scoped.map((item: any) => applyUidRemapping(item, uidRemapping));\n }\n const remapped: Record<string, unknown> = {};\n const pageKeyValues = new Set(Object.values(uidRemapping));\n for (const [sectionKey, pageKey] of Object.entries(uidRemapping)) {\n remapped[sectionKey] = applyUidRemapping(scoped[pageKey], uidRemapping);\n }\n for (const key of Object.keys(scoped)) {\n if (!pageKeyValues.has(key) && !(key in uidRemapping)) {\n remapped[key] = applyUidRemapping(scoped[key], uidRemapping);\n }\n }\n return remapped;\n };\n\n let changed = false;\n for (const [instanceUid, bindingUnknown] of Object.entries(\n sectionBindings,\n )) {\n const binding = bindingUnknown as {\n selectedField?: string;\n uidRemapping?: Record<string, string>;\n parentRepeaterUID?: string | null;\n context?: unknown;\n componentPropsFallback?: Record<string, unknown>;\n };\n // Skip context-only legacy shape — no selectedField to re-scope from.\n if (binding && \"context\" in binding && !(\"selectedField\" in binding)) {\n continue;\n }\n const scopedTemplate = applyUidRemapping(\n getScopedData(pageTemplate, binding?.selectedField),\n binding?.uidRemapping,\n );\n let repeater: Record<string, { context: unknown }> | undefined;\n if (binding?.parentRepeaterUID) {\n const ctx = dataSources.repeater?.[binding.parentRepeaterUID];\n if (ctx !== undefined) {\n repeater = { [binding.parentRepeaterUID]: ctx };\n }\n }\n const prev = prevScoped[instanceUid] || {};\n // Refresh contentstack / contentstack_queries from the live page\n // dataSources every time we rebuild. The initial scoped data built\n // during fetchSpec may have stale (or empty) entries because the\n // iframe loaded with getSpecFromParent and never fetched the section's\n // data sources itself — the studio pushes them later via\n // UPDATE_SPEC_DATA. Pool-keyed maps would be ideal but the listener\n // doesn't have access to them; copying the full page slice is a safe\n // superset (same composite-key format the resolver expects).\n const refreshedContentstack =\n dataSources.contentstack && typeof dataSources.contentstack === \"object\"\n ? { ...dataSources.contentstack }\n : prev.contentstack || {};\n const refreshedQueries =\n dataSources.contentstack_queries &&\n typeof dataSources.contentstack_queries === \"object\"\n ? { ...dataSources.contentstack_queries }\n : prev.contentstack_queries || {};\n\n const next = {\n ...prev,\n template: scopedTemplate,\n contentstack: refreshedContentstack,\n contentstack_queries: refreshedQueries,\n page: dataSources,\n repeater: repeater ?? prev.repeater,\n // Carry binding metadata so SectionCompositionProvider can re-scope the\n // template from the LIVE per-iteration repeater item. The scopedTemplate\n // above is page-root-scoped and shared across every iteration of this\n // instance, so it can't represent per-iteration values on its own.\n parentRepeaterUID: binding?.parentRepeaterUID ?? null,\n selectedField: binding?.selectedField,\n uidRemapping: binding?.uidRemapping,\n componentPropsFallback: binding?.componentPropsFallback,\n };\n if (\n prev.template !== next.template ||\n prev.page !== next.page ||\n prev.repeater !== next.repeater ||\n prev.contentstack !== next.contentstack ||\n prev.contentstack_queries !== next.contentstack_queries ||\n prev.componentPropsFallback !== next.componentPropsFallback\n ) {\n nextScoped[instanceUid] = next;\n changed = true;\n }\n }\n if (!changed) return prevData;\n return { ...prevData, section_scoped_data: nextScoped };\n };\n\n // Self-heal when the section catalog arrives after the initial seed.\n // `sectionCompositions` (each section's `linked_schemas` + authored UI) is\n // fetched asynchronously (GET_SECTIONS / UPDATE_SECTIONS_CATALOG) and can land\n // AFTER the first `seedSectionInstanceBindings` run (on GET_COMPOSITION_SPEC).\n // A root section seeded without the catalog gets `selectedField=\"\"` → its\n // scoped template resolves to the whole page (renders the page root, e.g. the\n // page title, instead of its bound field) and stays wedged unless Studio's\n // UPDATE_SECTION_CONTEXTS push wins the race. This is especially visible after\n // a preview-entry switch, which re-navigates the canvas iframe (a fresh cold\n // load). Re-run the seeder — which now heals empty root scopes from the\n // freshly-available `linked_schemas` — and rebuild `section_scoped_data` so the\n // render picks up the corrected scope without depending on the timing of\n // Studio's push. No-op when the seeder heals nothing (`seeded === prev`), so\n // working specs are unaffected and this can't loop.\n useEffect(() => {\n // Editor-only heal — mirror every other effect in this hook, which\n // early-returns outside the Studio frame. No reason to re-seed/commit in a\n // standalone or published render.\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n if (!state?.sectionCompositions?.length) return;\n setState((prev: StudioSpec) => {\n if (!prev?.ui || !prev?.data) return prev;\n const seeded = seedSectionInstanceBindings(prev);\n // Gate the rebuild + commit on the seeder's own no-op signal.\n // `rebuildScopedFromBindings` re-spreads the live `contentstack` /\n // `contentstack_queries` slices on every call, so for a page that has\n // sections it never returns its input unchanged — testing its result\n // would commit a fresh state (extra render + full scoped rebuild) on\n // every `sectionCompositions` ref change (Studio re-pushes the catalog on\n // refetch/refocus), not just when a cold-load scope actually heals.\n if (seeded === prev) return prev;\n return { ...seeded, data: rebuildScopedFromBindings(seeded.data) };\n });\n // Re-run whenever EITHER input the root-scope heal depends on lands:\n // • `sectionCompositions` — the section catalog (`linked_schemas`), and\n // • `connected_content_type` — the page CT that selects which linked\n // schema supplies the anchor field.\n // Both arrive asynchronously after a (re)load and in either order; keying on\n // only one leaves a race where the heal runs before the other is present,\n // computes an empty scope, and never retries — re-wedging the section.\n // The setState above changes neither dep, so this can't self-trigger.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state?.sectionCompositions,\n (state?.compositionEntry as any)?.connected_content_type,\n ]);\n\n // HOOK TO UPDATE THE STATE WITH THE LATEST SPEC DATA\n // Listeners are registered as soon as we're inside the Studio frame, before\n // spec has been fetched. Studio decides when to push UPDATE_SECTION_CONTEXTS\n // and UPDATE_SPEC_DATA based on its own readiness signal; the SDK can't\n // gate on `isCompositionBeingEdited(composableUid)` because that requires the\n // spec — and the parent reaches \"ready\" before the SDK's setState effect\n // has propagated, producing NO_REQUEST_LISTENER_FOUND.\n // The handlers themselves still defensively check `stateRef.current?.data`\n // before acting, so registering early is safe.\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n const specDataChangeListener =\n composableStudioEventManager?.on<StudioSpecData>(\n POST_MESSAGE_EVENTS.UPDATE_SPEC_DATA,\n async (event) => {\n const { data } = event;\n if (!data || !stateRef.current?.data) return;\n\n setState((state: StudioSpec) => {\n if (!state) return state;\n // Merge incoming over existing — never replace dataSources\n // wholesale. Studio's UPDATE_SPEC_DATA pushes can carry only\n // a subset of slices (e.g., only `template` + `section_compositions`),\n // and a naive overwrite would wipe slices the SDK relied on\n // (e.g., the `repeater` item context populated earlier from\n // preview data resolution). Result was a visible flicker as\n // sections inside a Repeater suddenly lost their item context.\n // Also merge section_compositions key-by-key so SDK-seeded\n // per-instance bindings survive when Studio's push is partial.\n const incomingSections =\n (data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] || {};\n const existingSections =\n (state.data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||\n {};\n const mergedDataSources = {\n ...((state.data as any)?.dataSources || {}),\n ...((data as any)?.dataSources || {}),\n [SECTION_COMPOSITIONS_KEY]: {\n ...existingSections,\n ...incomingSections,\n },\n };\n const mergedData = {\n ...state.data,\n ...data,\n dataSources: mergedDataSources,\n };\n const rebuilt = rebuildScopedFromBindings(mergedData);\n return {\n ...state,\n data: rebuilt,\n };\n });\n },\n );\n\n const previewEntryChangeListener = composableStudioEventManager?.on<{\n dataSources: DataSourceItem[];\n }>(POST_MESSAGE_EVENTS.REPLACE_PREVIEW_ENTRY, async (event) => {\n const { data } = event;\n if (!data?.dataSources || !stateRef.current?.data) return;\n\n setState((prevState: StudioSpec) => {\n if (!prevState) return prevState;\n // REPLACE_PREVIEW_ENTRY pushes dataSources for the preview-entry change\n // (typically just `template`/`contentstack` slices). Merge into existing\n // dataSources — don't wipe sibling slices like `repeater` or\n // `section_compositions`, which would cause a flicker for sections\n // inside a Repeater (their item context would disappear).\n const mergedData = {\n ...prevState?.data,\n [DATA_SOURCES_PREFIX]: {\n ...((prevState?.data as any)?.[DATA_SOURCES_PREFIX] || {}),\n ...(data?.dataSources as any),\n },\n };\n // The merge updates dataSources.template, but each section's SCOPED\n // template in section_scoped_data is derived from it — re-scope here,\n // else a section keeps its stale (often null) scope and renders the\n // empty placeholder after the preview entry is set/switched. (The\n // UPDATE_SPEC_DATA handler already rebuilds; this is the equivalent for\n // the preview-entry change path that EntryPickerBtn sends.)\n const rebuilt = rebuildScopedFromBindings(mergedData);\n return { ...prevState, data: rebuilt };\n });\n });\n\n const applyOperationListener = composableStudioEventManager?.on<{\n operations: Operation[];\n }>(POST_MESSAGE_EVENTS.APPLY_OPERATION, (event) => {\n const { data } = event;\n\n // Self-heal section catalog: if any op inserts a section-composition\n // node whose compositionUID isn't in the locally-known catalog\n // (race between Studio's section store hydration and the iframe's\n // initial GET_SECTIONS reply), re-fetch the catalog and merge.\n // Without this the section renders with \"Component … is not\n // registered\" until the page is saved + reloaded.\n const newSectionUids = new Set<string>();\n for (const op of data?.operations || []) {\n const node = (op as any)?.node;\n if (\n op &&\n (op as any).type === \"insert_node\" &&\n node &&\n typeof node === \"object\" &&\n node.type === \"section-composition\" &&\n typeof node.metadata?.compositionUID === \"string\"\n ) {\n newSectionUids.add(node.metadata.compositionUID as string);\n }\n }\n const known = new Set(\n (stateRef.current?.sectionCompositions || []).map(\n (s: SectionCompositionEntry) => s.uid,\n ),\n );\n const unknown = [...newSectionUids].filter((u) => !known.has(u));\n if (unknown.length > 0) {\n composableStudioEventManager\n ?.send<{ sectionCompositions: SectionCompositionEntry[] }>(\n POST_MESSAGE_EVENTS.GET_SECTIONS,\n {},\n )\n .then((resp) => {\n if (!resp?.sectionCompositions) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: resp.sectionCompositions,\n }));\n })\n .catch(() => {});\n }\n\n setState((prevState: StudioSpec) => {\n if (!prevState?.ui || !data?.operations) return prevState;\n const newUI = produce(prevState.ui, (ui) => {\n const operations = data.operations;\n return applyOperation(ui, operations);\n });\n // Eagerly refresh the NODE_TO_PARENT / NODE_TO_PATH_NODE WeakMaps for\n // the new tree. These WeakMaps are otherwise only populated during\n // React render (Element.tsx) and `findPath` (used by hover/highlight\n // postMessages back to Studio) reads from them. Without this refresh\n // there is a window between APPLY_OPERATION and the next React commit\n // where mouse-move events emit paths derived from old node refs —\n // those paths don't exist in Studio's now-updated slate editor and\n // surface as \"Cannot find a descendant at path\" errors.\n refreshNodeWeakMaps(newUI as any);\n // Re-seed per-instance section bindings ONLY when the slate op might\n // have moved/inserted/removed a section-composition node. Property /\n // style / text-content ops can't change the section-instance graph,\n // so the seeder's full UI walk on those is wasted work. The seeder\n // itself is idempotent (it short-circuits when nothing mutated), but\n // skipping the walk altogether keeps interactive ops (typing, style\n // edits) cheap on large pages.\n const ops = data.operations as any[];\n const opAffectsSectionInstances = ops.some(\n (op) =>\n op?.type === \"insert_node\" ||\n op?.type === \"remove_node\" ||\n op?.type === \"move_node\" ||\n op?.type === \"merge_node\" ||\n op?.type === \"split_node\",\n );\n if (!opAffectsSectionInstances) {\n return { ...prevState, ui: newUI };\n }\n return seedSectionInstanceBindings({ ...prevState, ui: newUI });\n });\n });\n\n // Studio pushes only the section_compositions slice when section contexts\n // are recomputed (e.g. after a section node is added/moved/removed). We\n // patch just that slice on top of existing dataSources so other data\n // (template, contentstack, query results) isn't clobbered.\n //\n // We ALSO rebuild the matching `section_scoped_data[instanceUid].template`\n // (and repeater slot) using the fresh selectedField / uidRemapping /\n // parentRepeaterUID Studio just sent. Without this, SectionCompositionProvider\n // would keep rendering the stale pre-computed scoped data from fetchSpec\n // (which can be wrong on cold load if the UI node lacked\n // metadata.selectedField), because the provider prefers section_scoped_data\n // and never falls back to the legacy section_compositions slot when it\n // exists.\n const sectionContextsListener = composableStudioEventManager?.on<{\n sectionCompositions: Record<string, unknown>;\n }>(POST_MESSAGE_EVENTS.UPDATE_SECTION_CONTEXTS, (event) => {\n const { data } = event;\n if (!data?.sectionCompositions) return;\n // Merge key-by-key on top of SDK-seeded defaults. Studio only pushes\n // user-driven overrides for specific instance nodes; replacing the whole\n // slice would wipe the SDK's seeded baseline for all other instances.\n setState((prevState: StudioSpec) => {\n if (!prevState?.data) return prevState;\n const existing =\n (prevState.data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||\n {};\n const mergedData = {\n ...prevState.data,\n dataSources: {\n ...prevState.data?.dataSources,\n [SECTION_COMPOSITIONS_KEY]: {\n ...existing,\n ...data.sectionCompositions,\n },\n },\n } as any;\n const finalData = rebuildScopedFromBindings(\n mergedData,\n data.sectionCompositions,\n );\n return {\n ...prevState,\n data: finalData,\n };\n });\n });\n\n // Signal to Studio that our editor→iframe post-message listeners are now\n // in the handler map. Studio gates UPDATE_SPEC_DATA (and similar) on this\n // event because earlier readiness signals (SDK_SPEC_RESOLVED, INIT_STUDIO)\n // fire before EditableRenderer commits its first render and race against\n // the .on(...) calls above.\n composableStudioEventManager\n ?.send(POST_MESSAGE_EVENTS.LISTENERS_READY, { composableUid })\n .then(() => {})\n .catch(() => {\n // Studio may not have its LISTENERS_READY handler registered yet on\n // very first paint — the bridge resolves this via its message queue,\n // so a dropped first emit is harmless. Not an error worth surfacing.\n });\n\n return () => {\n applyOperationListener?.unregister();\n specDataChangeListener?.unregister();\n previewEntryChangeListener?.unregister();\n sectionContextsListener?.unregister();\n };\n // Deps deliberately exclude state.data — see stateRef above. Re-registering\n // on every data change creates a window where Studio's pushes are dropped\n // with NO_REQUEST_LISTENER_FOUND. We do re-register on composableUid change\n // (e.g. switching to a different composition without unmount); the\n // LISTENERS_READY emit above re-signals Studio after each rebind.\n }, [composableUid]);\n};\n"],"names":[],"mappings":";;;;;;;AAwBA;AACA;AACA;AACA;AACA;AACA,aAAa,CAAC,KAAK,CAAC;AAEpB;;;;;;;;AAQG;AACH,SAAS,mBAAmB,CAAC,IAAS,EAAA;AACpC,IAAA,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ;QAAE;AACvC,IAAA,cAAc,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC;AACnC,IAAA,MAAM,KAAK,GAAG,CAAC,MAAW,KAAI;AAC5B,QAAA,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,IAAI,EAAE;QACjC,KAAK,MAAM,OAAO,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YACxC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE;AACrC,YAAA,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE;AAC9C,gBAAA,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC;AAC3B,gBAAA,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;oBAAE;AACzC,gBAAA,cAAc,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC;gBACjC,iBAAiB,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,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E,CAAC,aAAa,CAAC,CAAC;AACrB;;;;"}
1
+ {"version":3,"file":"use-spec-data-listener.hook.js","sources":["../../src/hooks/use-spec-data-listener.hook.ts"],"sourcesContent":["import {\n isCompositionBeingEdited,\n StudioSpec,\n applyOperation,\n SECTION_COMPOSITIONS_KEY,\n clientRendererModeUtil,\n NODE_TO_PARENT,\n NODE_TO_PATH_NODE,\n SectionCompositionEntry,\n} from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport {\n StudioSpecData,\n DataSourceItem,\n DATA_SOURCES_PREFIX,\n} from \"@contentstack/studio-registry\";\nimport { seedSectionInstanceBindings } from \"@contentstack/studio-react-components/utils\";\nimport { useEffect, useRef } from \"react\";\nimport { produce, setAutoFreeze } from \"immer\";\n\n// NOTE: Immer (produce) automatically freezes the state to prevent mutations.\n// However, while resolving metadata bindings (which currently only include styles),\n// we need to add binding values directly to the node object.\n// Since the state is frozen by default, this throws an error.\n// To work around this, we disable auto-freezing here.\nsetAutoFreeze(false);\n\n/**\n * Walk a fresh UI tree (post-Immer-produce) and populate the NODE_TO_PARENT\n * and NODE_TO_PATH_NODE WeakMaps for every node. These maps are normally\n * populated during React render (in Element.tsx). After APPLY_OPERATION\n * produces a brand-new tree via Immer, the maps still hold entries for\n * stale node refs — `findPath` (used to compute hover/highlight paths sent\n * back to Studio) returns stale paths until the next React commit. Calling\n * this immediately after applyOperation closes that window.\n */\nfunction refreshNodeWeakMaps(root: any): void {\n if (!root || typeof root !== \"object\") return;\n NODE_TO_PARENT.set(root, undefined);\n const visit = (parent: any) => {\n const slots = parent?.slots || {};\n for (const slotUid of Object.keys(slots)) {\n const children = slots[slotUid] || [];\n for (let idx = 0; idx < children.length; idx++) {\n const child = children[idx];\n if (!child || typeof child !== \"object\") continue;\n NODE_TO_PARENT.set(child, parent);\n NODE_TO_PATH_NODE.set(child, [slotUid, idx] as any);\n visit(child);\n }\n }\n };\n visit(root);\n}\n\nexport const useSpecDataListener = (\n setState: React.Dispatch<React.SetStateAction<StudioSpec>>,\n // Read into `stateRef` only — listener bodies use `stateRef.current` (not\n // `state` directly) so the effect's deps don't include `state.data`, which\n // would force re-register on every data change and create a window with\n // zero handlers between unregister/re-register (the original\n // `NO_REQUEST_LISTENER_FOUND` cause).\n state?: StudioSpec,\n composableUid?: string,\n) => {\n // Keep a ref to the latest state so the listener registrations don't have\n // to depend on state.data — they can read latest via stateRef.current\n // synchronously. Without this, every state.data change tore down + re-registered\n // the listeners, creating a window where Studio's UPDATE_SECTION_CONTEXTS\n // message was dropped with NO_REQUEST_LISTENER_FOUND.\n const stateRef = useRef(state);\n stateRef.current = state;\n\n // Rebuild section_scoped_data entries for instances whose binding metadata\n // (selectedField / uidRemapping / parentRepeaterUID) is present in the\n // legacy section_compositions slice. Mirrors build-scoped-data.ts logic\n // inline so the hook can rebuild without re-running the full fetchSpec\n // pipeline. Needed because Studio's fresh per-instance bindings arrive via\n // UPDATE_SPEC_DATA (and UPDATE_SECTION_CONTEXTS), while the provider only\n // reads from section_scoped_data — without this rebuild, sections render\n // the stale pre-computed scope from the initial fetchSpec (selectedField\n // missing from UI metadata on cold load → scoped template = whole page\n // template → placeholder text).\n const rebuildScopedFromBindings = (\n prevData: any,\n incomingBindings?: Record<string, unknown>,\n ): any => {\n const dataSources = prevData?.dataSources || {};\n const sectionBindings: Record<string, any> =\n incomingBindings && Object.keys(incomingBindings).length\n ? {\n ...(dataSources[SECTION_COMPOSITIONS_KEY] || {}),\n ...incomingBindings,\n }\n : dataSources[SECTION_COMPOSITIONS_KEY] || {};\n\n const pageTemplate = dataSources.template;\n const prevScoped = prevData?.section_scoped_data || {};\n const nextScoped: Record<string, any> = { ...prevScoped };\n\n const getScopedData = (obj: any, selectedField?: string): any => {\n if (!selectedField) return obj;\n return (\n selectedField.split(\".\").reduce((val: any, seg: string) => {\n if (val == null) return val;\n const arrayMatch = seg.match(/^(.*?)\\[(\\d+)\\]$/);\n if (arrayMatch) {\n const [, name, idxStr] = arrayMatch;\n const next = name ? val[name] : val;\n return next == null ? next : next[Number(idxStr)];\n }\n // Non-indexed field access landing on an ARRAY → default to the first\n // element so an un-indexed array-ancestor path (e.g.\n // \"navigation_menu_3.menu_subitems\", where navigation_menu_3 is a\n // multiple group) still resolves instead of `array[field]` →\n // undefined → null. Indexed pushes (`navigation_menu_3[1]…`) override\n // this with the picked instance.\n if (Array.isArray(val)) {\n const first = val[0];\n return first == null ? null : first[seg];\n }\n return val[seg];\n }, obj) ?? null\n );\n };\n\n const applyUidRemapping = (\n scoped: any,\n uidRemapping: Record<string, string> = {},\n ): any => {\n if (\n !scoped ||\n typeof scoped !== \"object\" ||\n Object.keys(uidRemapping).length === 0\n ) {\n return scoped;\n }\n if (Array.isArray(scoped)) {\n return scoped.map((item: any) => applyUidRemapping(item, uidRemapping));\n }\n const remapped: Record<string, unknown> = {};\n const pageKeyValues = new Set(Object.values(uidRemapping));\n for (const [sectionKey, pageKey] of Object.entries(uidRemapping)) {\n remapped[sectionKey] = applyUidRemapping(scoped[pageKey], uidRemapping);\n }\n for (const key of Object.keys(scoped)) {\n if (!pageKeyValues.has(key) && !(key in uidRemapping)) {\n remapped[key] = applyUidRemapping(scoped[key], uidRemapping);\n }\n }\n return remapped;\n };\n\n let changed = false;\n for (const [instanceUid, bindingUnknown] of Object.entries(\n sectionBindings,\n )) {\n const binding = bindingUnknown as {\n selectedField?: string;\n uidRemapping?: Record<string, string>;\n parentRepeaterUID?: string | null;\n context?: unknown;\n componentPropsFallback?: Record<string, unknown>;\n cardinality?: \"collection\" | \"single\";\n };\n // Skip context-only legacy shape — no selectedField to re-scope from.\n if (binding && \"context\" in binding && !(\"selectedField\" in binding)) {\n continue;\n }\n let scopedTemplate = applyUidRemapping(\n getScopedData(pageTemplate, binding?.selectedField),\n binding?.uidRemapping,\n );\n // Single-element section: `selectedField` stays index-free, so an\n // un-indexed terminal array resolves to the WHOLE array. Collapse to the\n // first element (the deploy default — the preview instance is session-only)\n // so the bound field resolves live, without depending on a save+reload\n // running the cold-load scoper. Mirrors build-scoped-data.ts. When the\n // path is already indexed (`menu_items[0]`, from Studio's push),\n // getScopedData returns the element and this is a no-op.\n if (binding?.cardinality === \"single\" && Array.isArray(scopedTemplate)) {\n scopedTemplate = scopedTemplate[0] ?? null;\n }\n let repeater: Record<string, { context: unknown }> | undefined;\n if (binding?.parentRepeaterUID) {\n const ctx = dataSources.repeater?.[binding.parentRepeaterUID];\n if (ctx !== undefined) {\n repeater = { [binding.parentRepeaterUID]: ctx };\n }\n }\n const prev = prevScoped[instanceUid] || {};\n // Refresh contentstack / contentstack_queries from the live page\n // dataSources every time we rebuild. The initial scoped data built\n // during fetchSpec may have stale (or empty) entries because the\n // iframe loaded with getSpecFromParent and never fetched the section's\n // data sources itself — the studio pushes them later via\n // UPDATE_SPEC_DATA. Pool-keyed maps would be ideal but the listener\n // doesn't have access to them; copying the full page slice is a safe\n // superset (same composite-key format the resolver expects).\n const refreshedContentstack =\n dataSources.contentstack && typeof dataSources.contentstack === \"object\"\n ? { ...dataSources.contentstack }\n : prev.contentstack || {};\n const refreshedQueries =\n dataSources.contentstack_queries &&\n typeof dataSources.contentstack_queries === \"object\"\n ? { ...dataSources.contentstack_queries }\n : prev.contentstack_queries || {};\n\n const next = {\n ...prev,\n template: scopedTemplate,\n contentstack: refreshedContentstack,\n contentstack_queries: refreshedQueries,\n page: dataSources,\n repeater: repeater ?? prev.repeater,\n // Carry binding metadata so SectionCompositionProvider can re-scope the\n // template from the LIVE per-iteration repeater item. The scopedTemplate\n // above is page-root-scoped and shared across every iteration of this\n // instance, so it can't represent per-iteration values on its own.\n parentRepeaterUID: binding?.parentRepeaterUID ?? null,\n selectedField: binding?.selectedField,\n uidRemapping: binding?.uidRemapping,\n cardinality: binding?.cardinality,\n componentPropsFallback: binding?.componentPropsFallback,\n };\n if (\n prev.template !== next.template ||\n prev.page !== next.page ||\n prev.repeater !== next.repeater ||\n prev.contentstack !== next.contentstack ||\n prev.contentstack_queries !== next.contentstack_queries ||\n prev.componentPropsFallback !== next.componentPropsFallback\n ) {\n nextScoped[instanceUid] = next;\n changed = true;\n }\n }\n if (!changed) return prevData;\n return { ...prevData, section_scoped_data: nextScoped };\n };\n\n // Self-heal when the section catalog arrives after the initial seed.\n // `sectionCompositions` (each section's `linked_schemas` + authored UI) is\n // fetched asynchronously (GET_SECTIONS / UPDATE_SECTIONS_CATALOG) and can land\n // AFTER the first `seedSectionInstanceBindings` run (on GET_COMPOSITION_SPEC).\n // A root section seeded without the catalog gets `selectedField=\"\"` → its\n // scoped template resolves to the whole page (renders the page root, e.g. the\n // page title, instead of its bound field) and stays wedged unless Studio's\n // UPDATE_SECTION_CONTEXTS push wins the race. This is especially visible after\n // a preview-entry switch, which re-navigates the canvas iframe (a fresh cold\n // load). Re-run the seeder — which now heals empty root scopes from the\n // freshly-available `linked_schemas` — and rebuild `section_scoped_data` so the\n // render picks up the corrected scope without depending on the timing of\n // Studio's push. No-op when the seeder heals nothing (`seeded === prev`), so\n // working specs are unaffected and this can't loop.\n useEffect(() => {\n // Editor-only heal — mirror every other effect in this hook, which\n // early-returns outside the Studio frame. No reason to re-seed/commit in a\n // standalone or published render.\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n if (!state?.sectionCompositions?.length) return;\n setState((prev: StudioSpec) => {\n if (!prev?.ui || !prev?.data) return prev;\n const seeded = seedSectionInstanceBindings(prev);\n // Gate the rebuild + commit on the seeder's own no-op signal.\n // `rebuildScopedFromBindings` re-spreads the live `contentstack` /\n // `contentstack_queries` slices on every call, so for a page that has\n // sections it never returns its input unchanged — testing its result\n // would commit a fresh state (extra render + full scoped rebuild) on\n // every `sectionCompositions` ref change (Studio re-pushes the catalog on\n // refetch/refocus), not just when a cold-load scope actually heals.\n if (seeded === prev) return prev;\n return { ...seeded, data: rebuildScopedFromBindings(seeded.data) };\n });\n // Re-run whenever EITHER input the root-scope heal depends on lands:\n // • `sectionCompositions` — the section catalog (`linked_schemas`), and\n // • `connected_content_type` — the page CT that selects which linked\n // schema supplies the anchor field.\n // Both arrive asynchronously after a (re)load and in either order; keying on\n // only one leaves a race where the heal runs before the other is present,\n // computes an empty scope, and never retries — re-wedging the section.\n // The setState above changes neither dep, so this can't self-trigger.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n state?.sectionCompositions,\n (state?.compositionEntry as any)?.connected_content_type,\n ]);\n\n // HOOK TO UPDATE THE STATE WITH THE LATEST SPEC DATA\n // Listeners are registered as soon as we're inside the Studio frame, before\n // spec has been fetched. Studio decides when to push UPDATE_SECTION_CONTEXTS\n // and UPDATE_SPEC_DATA based on its own readiness signal; the SDK can't\n // gate on `isCompositionBeingEdited(composableUid)` because that requires the\n // spec — and the parent reaches \"ready\" before the SDK's setState effect\n // has propagated, producing NO_REQUEST_LISTENER_FOUND.\n // The handlers themselves still defensively check `stateRef.current?.data`\n // before acting, so registering early is safe.\n useEffect(() => {\n if (!clientRendererModeUtil.isInsideStudioFrame()) return;\n const specDataChangeListener =\n composableStudioEventManager?.on<StudioSpecData>(\n POST_MESSAGE_EVENTS.UPDATE_SPEC_DATA,\n async (event) => {\n const { data } = event;\n if (!data || !stateRef.current?.data) return;\n\n setState((state: StudioSpec) => {\n if (!state) return state;\n // Merge incoming over existing — never replace dataSources\n // wholesale. Studio's UPDATE_SPEC_DATA pushes can carry only\n // a subset of slices (e.g., only `template` + `section_compositions`),\n // and a naive overwrite would wipe slices the SDK relied on\n // (e.g., the `repeater` item context populated earlier from\n // preview data resolution). Result was a visible flicker as\n // sections inside a Repeater suddenly lost their item context.\n // Also merge section_compositions key-by-key so SDK-seeded\n // per-instance bindings survive when Studio's push is partial.\n const incomingSections =\n (data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] || {};\n const existingSections =\n (state.data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||\n {};\n // Per-uid merge preserves `cardinality` when the incoming entry\n // lacks it — cardinality is a stable schema property, and a stale\n // push dropping it would disable the single-element array→element\n // collapse in rebuildScopedFromBindings (section blanks out).\n const mergedSections: Record<string, any> = {\n ...existingSections,\n };\n for (const [uid, incoming] of Object.entries(incomingSections)) {\n const prev = existingSections[uid];\n mergedSections[uid] =\n incoming &&\n typeof incoming === \"object\" &&\n (incoming as any).cardinality === undefined &&\n prev?.cardinality !== undefined\n ? { ...(incoming as any), cardinality: prev.cardinality }\n : incoming;\n }\n const mergedDataSources = {\n ...((state.data as any)?.dataSources || {}),\n ...((data as any)?.dataSources || {}),\n [SECTION_COMPOSITIONS_KEY]: mergedSections,\n };\n const mergedData = {\n ...state.data,\n ...data,\n dataSources: mergedDataSources,\n };\n const rebuilt = rebuildScopedFromBindings(mergedData);\n return {\n ...state,\n data: rebuilt,\n };\n });\n },\n );\n\n const previewEntryChangeListener = composableStudioEventManager?.on<{\n dataSources: DataSourceItem[];\n }>(POST_MESSAGE_EVENTS.REPLACE_PREVIEW_ENTRY, async (event) => {\n const { data } = event;\n if (!data?.dataSources || !stateRef.current?.data) return;\n\n setState((prevState: StudioSpec) => {\n if (!prevState) return prevState;\n // REPLACE_PREVIEW_ENTRY pushes dataSources for the preview-entry change\n // (typically just `template`/`contentstack` slices). Merge into existing\n // dataSources — don't wipe sibling slices like `repeater` or\n // `section_compositions`, which would cause a flicker for sections\n // inside a Repeater (their item context would disappear).\n const mergedData = {\n ...prevState?.data,\n [DATA_SOURCES_PREFIX]: {\n ...((prevState?.data as any)?.[DATA_SOURCES_PREFIX] || {}),\n ...(data?.dataSources as any),\n },\n };\n // The merge updates dataSources.template, but each section's SCOPED\n // template in section_scoped_data is derived from it — re-scope here,\n // else a section keeps its stale (often null) scope and renders the\n // empty placeholder after the preview entry is set/switched. (The\n // UPDATE_SPEC_DATA handler already rebuilds; this is the equivalent for\n // the preview-entry change path that EntryPickerBtn sends.)\n const rebuilt = rebuildScopedFromBindings(mergedData);\n return { ...prevState, data: rebuilt };\n });\n });\n\n const applyOperationListener = composableStudioEventManager?.on<{\n operations: Operation[];\n }>(POST_MESSAGE_EVENTS.APPLY_OPERATION, (event) => {\n const { data } = event;\n\n // Self-heal section catalog: if any op inserts a section-composition\n // node whose compositionUID isn't in the locally-known catalog\n // (race between Studio's section store hydration and the iframe's\n // initial GET_SECTIONS reply), re-fetch the catalog and merge.\n // Without this the section renders with \"Component … is not\n // registered\" until the page is saved + reloaded.\n const newSectionUids = new Set<string>();\n for (const op of data?.operations || []) {\n const node = (op as any)?.node;\n if (\n op &&\n (op as any).type === \"insert_node\" &&\n node &&\n typeof node === \"object\" &&\n node.type === \"section-composition\" &&\n typeof node.metadata?.compositionUID === \"string\"\n ) {\n newSectionUids.add(node.metadata.compositionUID as string);\n }\n }\n const known = new Set(\n (stateRef.current?.sectionCompositions || []).map(\n (s: SectionCompositionEntry) => s.uid,\n ),\n );\n const unknown = [...newSectionUids].filter((u) => !known.has(u));\n if (unknown.length > 0) {\n composableStudioEventManager\n ?.send<{ sectionCompositions: SectionCompositionEntry[] }>(\n POST_MESSAGE_EVENTS.GET_SECTIONS,\n {},\n )\n .then((resp) => {\n if (!resp?.sectionCompositions) return;\n setState((prevState: StudioSpec) => ({\n ...prevState,\n sectionCompositions: resp.sectionCompositions,\n }));\n })\n .catch(() => {});\n }\n\n setState((prevState: StudioSpec) => {\n if (!prevState?.ui || !data?.operations) return prevState;\n const newUI = produce(prevState.ui, (ui) => {\n const operations = data.operations;\n return applyOperation(ui, operations);\n });\n // Eagerly refresh the NODE_TO_PARENT / NODE_TO_PATH_NODE WeakMaps for\n // the new tree. These WeakMaps are otherwise only populated during\n // React render (Element.tsx) and `findPath` (used by hover/highlight\n // postMessages back to Studio) reads from them. Without this refresh\n // there is a window between APPLY_OPERATION and the next React commit\n // where mouse-move events emit paths derived from old node refs —\n // those paths don't exist in Studio's now-updated slate editor and\n // surface as \"Cannot find a descendant at path\" errors.\n refreshNodeWeakMaps(newUI as any);\n // Re-seed per-instance section bindings ONLY when the slate op might\n // have moved/inserted/removed a section-composition node. Property /\n // style / text-content ops can't change the section-instance graph,\n // so the seeder's full UI walk on those is wasted work. The seeder\n // itself is idempotent (it short-circuits when nothing mutated), but\n // skipping the walk altogether keeps interactive ops (typing, style\n // edits) cheap on large pages.\n const ops = data.operations as any[];\n const opAffectsSectionInstances = ops.some(\n (op) =>\n op?.type === \"insert_node\" ||\n op?.type === \"remove_node\" ||\n op?.type === \"move_node\" ||\n op?.type === \"merge_node\" ||\n op?.type === \"split_node\",\n );\n if (!opAffectsSectionInstances) {\n return { ...prevState, ui: newUI };\n }\n return seedSectionInstanceBindings({ ...prevState, ui: newUI });\n });\n });\n\n // Studio pushes only the section_compositions slice when section contexts\n // are recomputed (e.g. after a section node is added/moved/removed). We\n // patch just that slice on top of existing dataSources so other data\n // (template, contentstack, query results) isn't clobbered.\n //\n // We ALSO rebuild the matching `section_scoped_data[instanceUid].template`\n // (and repeater slot) using the fresh selectedField / uidRemapping /\n // parentRepeaterUID Studio just sent. Without this, SectionCompositionProvider\n // would keep rendering the stale pre-computed scoped data from fetchSpec\n // (which can be wrong on cold load if the UI node lacked\n // metadata.selectedField), because the provider prefers section_scoped_data\n // and never falls back to the legacy section_compositions slot when it\n // exists.\n const sectionContextsListener = composableStudioEventManager?.on<{\n sectionCompositions: Record<string, unknown>;\n }>(POST_MESSAGE_EVENTS.UPDATE_SECTION_CONTEXTS, (event) => {\n const { data } = event;\n if (!data?.sectionCompositions) return;\n // Merge key-by-key on top of SDK-seeded defaults. Studio only pushes\n // user-driven overrides for specific instance nodes; replacing the whole\n // slice would wipe the SDK's seeded baseline for all other instances.\n setState((prevState: StudioSpec) => {\n if (!prevState?.data) return prevState;\n const existing =\n (prevState.data as any)?.dataSources?.[SECTION_COMPOSITIONS_KEY] ||\n {};\n // Per-uid merge preserves `cardinality` when an incoming entry lacks\n // it (mirrors the UPDATE_SPEC_DATA merge below). Cardinality is a\n // stable schema property; a push dropping it disables the\n // single-element item-identity scoping for repeater-nested sections\n // and the array→element collapse — the section blanks out.\n const merged: Record<string, any> = { ...existing };\n for (const [uid, incoming] of Object.entries(\n data.sectionCompositions,\n )) {\n const prev = existing[uid];\n merged[uid] =\n incoming &&\n typeof incoming === \"object\" &&\n (incoming as any).cardinality === undefined &&\n prev?.cardinality !== undefined\n ? { ...(incoming as any), cardinality: prev.cardinality }\n : incoming;\n }\n const mergedData = {\n ...prevState.data,\n dataSources: {\n ...prevState.data?.dataSources,\n [SECTION_COMPOSITIONS_KEY]: merged,\n },\n } as any;\n // Pass the MERGED entries for the incoming uids (not the raw incoming)\n // — rebuildScopedFromBindings spreads incomingBindings over the slice,\n // so raw entries would reintroduce the dropped cardinality.\n const incomingMerged = Object.fromEntries(\n Object.keys(data.sectionCompositions).map((uid) => [\n uid,\n merged[uid],\n ]),\n );\n const finalData = rebuildScopedFromBindings(mergedData, incomingMerged);\n return {\n ...prevState,\n data: finalData,\n };\n });\n });\n\n // Signal to Studio that our editor→iframe post-message listeners are now\n // in the handler map. Studio gates UPDATE_SPEC_DATA (and similar) on this\n // event because earlier readiness signals (SDK_SPEC_RESOLVED, INIT_STUDIO)\n // fire before EditableRenderer commits its first render and race against\n // the .on(...) calls above.\n composableStudioEventManager\n ?.send(POST_MESSAGE_EVENTS.LISTENERS_READY, { composableUid })\n .then(() => {})\n .catch(() => {\n // Studio may not have its LISTENERS_READY handler registered yet on\n // very first paint — the bridge resolves this via its message queue,\n // so a dropped first emit is harmless. Not an error worth surfacing.\n });\n\n return () => {\n applyOperationListener?.unregister();\n specDataChangeListener?.unregister();\n previewEntryChangeListener?.unregister();\n sectionContextsListener?.unregister();\n };\n // Deps deliberately exclude state.data — see stateRef above. Re-registering\n // on every data change creates a window where Studio's pushes are dropped\n // with NO_REQUEST_LISTENER_FOUND. We do re-register on composableUid change\n // (e.g. switching to a different composition without unmount); the\n // LISTENERS_READY emit above re-signals Studio after each rebind.\n }, [composableUid]);\n};\n"],"names":[],"mappings":";;;;;;;AAwBA;AACA;AACA;AACA;AACA;AACA,aAAa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,MAAM;AACnC,qBAAA;iBACK;;;;gBAIR,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,CACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,KAAK;oBACjD,GAAG;oBACH,MAAM,CAAC,GAAG,CAAC;AACZ,iBAAA,CAAC,CACH;gBACD,MAAM,SAAS,GAAG,yBAAyB,CAAC,UAAU,EAAE,cAAc,CAAC;gBACvE,OAAO;AACL,oBAAA,GAAG,SAAS;AACZ,oBAAA,IAAI,EAAE,SAAS;iBAChB;AACH,YAAA,CAAC,CAAC;AACJ,QAAA,CAAC,CAAC;;;;;;QAOF;cACI,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,EAAE,aAAa,EAAE;AAC5D,aAAA,IAAI,CAAC,MAAK,EAAE,CAAC;aACb,KAAK,CAAC,MAAK;;;;AAIZ,QAAA,CAAC,CAAC;AAEJ,QAAA,OAAO,MAAK;YACV,sBAAsB,EAAE,UAAU,EAAE;YACpC,sBAAsB,EAAE,UAAU,EAAE;YACpC,0BAA0B,EAAE,UAAU,EAAE;YACxC,uBAAuB,EAAE,UAAU,EAAE;AACvC,QAAA,CAAC;;;;;;AAMH,IAAA,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;AACrB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/studio-react-editor",
3
- "version": "1.7.0-alpha-20260721T1325-1838437.0",
3
+ "version": "1.8.0",
4
4
  "description": "Contains all logic of editing for react based environment",
5
5
  "author": "RavenColEvol <ravilamkoti@gmail.com>",
6
6
  "homepage": "https://github.com/contentstack/composable-studio-sdk#readme",
@@ -14,10 +14,9 @@
14
14
  ],
15
15
  "exports": {
16
16
  ".": {
17
- "import": {
18
- "types": "./dist/index.d.ts",
19
- "default": "./dist/index.js"
20
- }
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/index.js",
19
+ "default": "./dist/index.js"
21
20
  }
22
21
  },
23
22
  "repository": {
@@ -39,7 +38,7 @@
39
38
  "react-dom": "^18.0.0 || ^19.0.0"
40
39
  },
41
40
  "devDependencies": {
42
- "@contentstack/common-config": "^1.2.2-alpha-20260721T1325-1838437.0",
41
+ "@contentstack/common-config": "^1.2.3",
43
42
  "@rollup/plugin-commonjs": "^28.0.6",
44
43
  "@rollup/plugin-node-resolve": "^16.0.1",
45
44
  "@rollup/plugin-terser": "^1.0.0",
@@ -59,17 +58,17 @@
59
58
  "typescript": "^5.2.2"
60
59
  },
61
60
  "dependencies": {
62
- "@contentstack/studio-client": "^3.0.0-alpha-20260721T1325-1838437.0",
63
- "@contentstack/studio-core": "^1.4.0-alpha-20260721T1325-1838437.0",
64
- "@contentstack/studio-internal": "^1.5.0-alpha-20260721T1325-1838437.0",
65
- "@contentstack/studio-messenger": "^3.0.0-alpha-20260721T1325-1838437.0",
66
- "@contentstack/studio-react-components": "^1.9.0-alpha-20260721T1325-1838437.0",
67
- "@contentstack/studio-registry": "^1.8.0-alpha-20260721T1325-1838437.0",
61
+ "@contentstack/studio-client": "^3.1.0",
62
+ "@contentstack/studio-core": "^1.4.1",
63
+ "@contentstack/studio-internal": "^1.6.0",
64
+ "@contentstack/studio-messenger": "^3.1.0",
65
+ "@contentstack/studio-react-components": "^1.10.0",
66
+ "@contentstack/studio-registry": "^1.9.0",
68
67
  "classnames": "^2.5.1",
69
68
  "goober": "^2.1.16",
70
69
  "immer": "^10.1.1",
71
70
  "lodash-es": "^4.18.1",
72
71
  "react-error-boundary": "^6.0.0"
73
72
  },
74
- "gitHead": "53aad4129b8169dcbe52b2674b541ca491c2b624"
73
+ "gitHead": "1e35733997b7c0e030296d3ebcf053aee69151a3"
75
74
  }
@@ -1,65 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { DataCtxProvider } from '@contentstack/studio-react-components/contexts';
3
- import { useData } from '@contentstack/studio-react-components/hooks';
4
- import { DATA_SOURCES } from '@contentstack/studio-registry';
5
- import { useMemo } from 'react';
6
- import '@contentstack/studio-client';
7
- import '../../hooks/use-edit-context-listener.hook.js';
8
- import '@contentstack/studio-messenger';
9
- import '@contentstack/studio-internal';
10
- import '@contentstack/studio-core';
11
- import '@contentstack/studio-react-components/basic-components';
12
- import 'goober';
13
- import { PreviewRenderer } from '../PreviewRenderer.js';
14
- import '../../contexts/providers/section-mode.provider.js';
15
- import '../../contexts/providers/renderer.provider.js';
16
- import '../../contexts/providers/edit-context.provider.js';
17
- import '../../contexts/providers/active-node.provider.js';
18
- import 'immer';
19
- import '../../contexts/providers/use-design-preview.provider.js';
20
- import '../../contexts/providers/use-repeater.provider.js';
21
- import '../../contexts/providers/use-condition-block.provider.js';
22
- import '../../contexts/providers/preview-mode.provider.js';
23
- import { useSymbolUIListener } from '../../hooks/use-symbol-ui-listener.hook.js';
24
-
25
- function EditSymbolRenderer({ ui, studioAttributes, }) {
26
- return (jsx("div", { ...studioAttributes, style: { display: "contents" }, children: ui }));
27
- }
28
- function ViewOnlySymbolRenderer({ symbolUID, spec, studioAttributes, }) {
29
- const activeSpec = useSymbolUIListener(spec, symbolUID);
30
- const data = useData();
31
- // This was required as two nested symbols were added because of this this component itself was rendered for type symbol and again it was rendering it for same json
32
- const activeSpecWithoutSymbolWrapper = useMemo(() => {
33
- const ui = activeSpec.ui;
34
- const uiWithFragment = {
35
- ...ui,
36
- type: "fragment",
37
- slots: ui.slots,
38
- };
39
- return {
40
- ...activeSpec,
41
- data,
42
- ui: uiWithFragment,
43
- };
44
- }, [activeSpec, data]);
45
- return (jsx("div", { ...studioAttributes, style: { display: "contents" }, children: jsx(PreviewRenderer, { spec: activeSpecWithoutSymbolWrapper }) }));
46
- }
47
- function WithSymbolPropsData(props) {
48
- const data = useData();
49
- // Can't memoize it because data doesn't change when symbol changes
50
- const dataWithSymbol = {
51
- ...data,
52
- [DATA_SOURCES.SYMBOL_PROPS]: {
53
- ...(data[DATA_SOURCES.SYMBOL_PROPS] || {}),
54
- ...(props.symbol_props || {}),
55
- },
56
- };
57
- return (jsx(DataCtxProvider, { value: dataWithSymbol, children: props.children }));
58
- }
59
- function Symbol(props) {
60
- const isEditing = props.symbol_internal_props?.isEditing;
61
- return (jsx(WithSymbolPropsData, { ...props, children: !isEditing ? (jsx(ViewOnlySymbolRenderer, { ...props })) : (jsx(EditSymbolRenderer, { ...props })) }));
62
- }
63
-
64
- export { EditSymbolRenderer, Symbol, ViewOnlySymbolRenderer };
65
- //# sourceMappingURL=Symbol.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Symbol.js","sources":["../../../src/components/elements/Symbol.tsx"],"sourcesContent":["/**\n * Symbol component will be used to render when a symbol is in edit mode.\n * @param props:\n * @returns\n */\n\nimport { StudioSpec } from \"@contentstack/studio-client\";\nimport { DataCtxProvider } from \"@contentstack/studio-react-components/contexts\";\nimport { useData } from \"@contentstack/studio-react-components/hooks\";\nimport { DATA_SOURCES } from \"@contentstack/studio-registry\";\nimport { useMemo } from \"react\";\nimport { useSymbolUIListener } from \"../../hooks\";\nimport { PreviewRenderer } from \"../PreviewRenderer\";\n\n/*\n * SymbolEditRenderer is used by the renderer when symbol is in edit mode\n */\ninterface EditSymbolRendererProps {\n ui: React.ReactElement;\n [key: string]: any;\n}\n\nexport function EditSymbolRenderer({\n ui,\n studioAttributes,\n}: EditSymbolRendererProps) {\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n {ui}\n </div>\n );\n}\n\n/*\n * SymbolRenderer is used by the renderer when symbol is in view mode\n */\ninterface ViewOnlySymbolRendererProps {\n ui: null;\n spec: Omit<StudioSpec, \"compositionEntry\">;\n symbolUID: string;\n studioAttributes: Record<string, any>;\n [key: string]: any;\n}\n\nexport function ViewOnlySymbolRenderer({\n symbolUID,\n spec,\n studioAttributes,\n}: ViewOnlySymbolRendererProps) {\n const activeSpec = useSymbolUIListener(spec, symbolUID);\n const data = useData();\n // This was required as two nested symbols were added because of this this component itself was rendered for type symbol and again it was rendering it for same json\n const activeSpecWithoutSymbolWrapper = useMemo(() => {\n const ui = activeSpec.ui;\n const uiWithFragment = {\n ...ui,\n type: \"fragment\",\n slots: ui.slots,\n };\n return {\n ...activeSpec,\n data,\n ui: uiWithFragment,\n };\n }, [activeSpec, data]);\n return (\n <div {...studioAttributes} style={{ display: \"contents\" }}>\n <PreviewRenderer spec={activeSpecWithoutSymbolWrapper} />\n </div>\n );\n}\n\ntype SymbolProps = ViewOnlySymbolRendererProps | EditSymbolRendererProps;\n\nfunction WithSymbolPropsData(props: SymbolProps) {\n const data = useData();\n // Can't memoize it because data doesn't change when symbol changes\n const dataWithSymbol = {\n ...data,\n [DATA_SOURCES.SYMBOL_PROPS]: {\n ...(data[DATA_SOURCES.SYMBOL_PROPS] || {}),\n ...(props.symbol_props || {}),\n },\n };\n return (\n <DataCtxProvider value={dataWithSymbol}>{props.children}</DataCtxProvider>\n );\n}\nexport function Symbol(props: SymbolProps) {\n const isEditing = props.symbol_internal_props?.isEditing;\n return (\n <WithSymbolPropsData {...props}>\n {!isEditing ? (\n <ViewOnlySymbolRenderer {...(props as ViewOnlySymbolRendererProps)} />\n ) : (\n <EditSymbolRenderer {...(props as EditSymbolRendererProps)} />\n )}\n </WithSymbolPropsData>\n );\n}\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;SAsBgB,kBAAkB,CAAC,EACjC,EAAE,EACF,gBAAgB,GACQ,EAAA;AACxB,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAA,GAAS,gBAAgB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,EAAA,QAAA,EACtD,EAAE,EAAA,CACC;AAEV;AAaM,SAAU,sBAAsB,CAAC,EACrC,SAAS,EACT,IAAI,EACJ,gBAAgB,GACY,EAAA;IAC5B,MAAM,UAAU,GAAG,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC;AACvD,IAAA,MAAM,IAAI,GAAG,OAAO,EAAE;;AAEtB,IAAA,MAAM,8B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,kBAAkB,EAAA,EAAA,GAAM,KAAiC,EAAA,CAAI,CAC/D,EAAA,CACmB;AAE1B;;;;"}
@@ -1,88 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { applyOperation } from '@contentstack/studio-client';
3
- import { composableStudioEventManager, POST_MESSAGE_EVENTS } from '@contentstack/studio-messenger';
4
- import { SymbolUICtx } from '@contentstack/studio-react-components/contexts';
5
- import { produce } from 'immer';
6
- import { useState, useEffect } from 'react';
7
- import '../../hooks/use-edit-context-listener.hook.js';
8
- import '@contentstack/studio-internal';
9
- import '@contentstack/studio-core';
10
- import '@contentstack/studio-react-components/basic-components';
11
- import '@contentstack/studio-react-components/hooks';
12
- import 'goober';
13
- import '../../components/Element.js';
14
- import './renderer.provider.js';
15
- import './edit-context.provider.js';
16
- import './active-node.provider.js';
17
- import './use-design-preview.provider.js';
18
- import './use-repeater.provider.js';
19
- import './use-condition-block.provider.js';
20
- import './preview-mode.provider.js';
21
- import './section-mode.provider.js';
22
- import { useRenderer } from '../../hooks/use-renderer.hook.js';
23
- import { registerSymbolComponent } from '../../hooks/use-register-symbol.hook.js';
24
-
25
- const SymbolUIProvider = ({ symbols, children, }) => {
26
- const { componentRegistry } = useRenderer();
27
- const [symbolUIs, setSymbolUIs] = useState(symbols.reduce((acc, symbol) => {
28
- acc[symbol.uid] = symbol;
29
- return acc;
30
- }, {}));
31
- useEffect(() => {
32
- if (symbols.length > 0) {
33
- setSymbolUIs(symbols.reduce((acc, symbol) => {
34
- acc[symbol.uid] = symbol;
35
- return acc;
36
- }, {}));
37
- }
38
- }, [symbols]);
39
- // UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,
40
- // which updates `state.symbols` — that flows down here as the `symbols`
41
- // prop and is picked up by the useEffect above. Registering another
42
- // listener here just produced a duplicate-registration warning.
43
- useEffect(() => {
44
- const handleApplySymbolOperation = (data) => {
45
- const { uid, operations } = data;
46
- setSymbolUIs((symbolUIs) => {
47
- if (!symbolUIs[uid])
48
- return symbolUIs;
49
- const newSymbolUIs = produce(symbolUIs, (draft) => {
50
- const symbol = draft[uid];
51
- if (!symbol)
52
- return;
53
- const newSymbol = applyOperation(symbol.ui, operations);
54
- symbol.ui = newSymbol;
55
- draft[uid] = {
56
- ...symbol,
57
- };
58
- });
59
- registerSymbolComponent([newSymbolUIs[uid]], componentRegistry);
60
- return newSymbolUIs;
61
- });
62
- };
63
- const applySymbolOperationListener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.APPLY_SYMBOL_OPERATION, (event) => {
64
- handleApplySymbolOperation(event.data);
65
- });
66
- return () => {
67
- applySymbolOperationListener?.unregister();
68
- };
69
- }, []);
70
- useEffect(() => {
71
- const newSymbolListener = composableStudioEventManager?.on(POST_MESSAGE_EVENTS.ADD_NEW_SYMBOL, (event) => {
72
- const { symbol } = event.data;
73
- registerSymbolComponent([symbol], componentRegistry);
74
- setSymbolUIs((symbolUIs) => {
75
- return produce(symbolUIs, (draft) => {
76
- draft[symbol.uid] = symbol;
77
- });
78
- });
79
- });
80
- return () => {
81
- newSymbolListener?.unregister();
82
- };
83
- }, []);
84
- return (jsx(SymbolUICtx.Provider, { value: symbolUIs, children: children }));
85
- };
86
-
87
- export { SymbolUIProvider };
88
- //# sourceMappingURL=symbol-ui.provider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"symbol-ui.provider.js","sources":["../../../src/contexts/providers/symbol-ui.provider.tsx"],"sourcesContent":["import { applyOperation, SymbolEntry } from \"@contentstack/studio-client\";\nimport { Operation } from \"@contentstack/studio-internal\";\nimport {\n composableStudioEventManager,\n POST_MESSAGE_EVENTS,\n} from \"@contentstack/studio-messenger\";\nimport { SymbolUICtx } from \"@contentstack/studio-react-components/contexts\";\nimport { produce } from \"immer\";\nimport { useEffect, useState } from \"react\";\nimport { registerSymbolComponent, useRenderer } from \"../../hooks\";\n\nexport interface SymbolUIProvider {\n [uid: string]: SymbolEntry;\n}\ninterface SymbolUIProviderProps {\n children: React.ReactNode;\n symbols: SymbolEntry[];\n}\nexport const SymbolUIProvider = ({\n symbols,\n children,\n}: SymbolUIProviderProps) => {\n const { componentRegistry } = useRenderer();\n const [symbolUIs, setSymbolUIs] = useState<SymbolUIProvider>(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n\n useEffect(() => {\n if (symbols.length > 0) {\n setSymbolUIs(\n symbols.reduce((acc, symbol) => {\n acc[symbol.uid] = symbol;\n return acc;\n }, {} as SymbolUIProvider),\n );\n }\n }, [symbols]);\n\n // UPDATE_SYMBOLS / GET_SYMBOLS are handled by use-symbol-events.hook.ts,\n // which updates `state.symbols` — that flows down here as the `symbols`\n // prop and is picked up by the useEffect above. Registering another\n // listener here just produced a duplicate-registration warning.\n\n useEffect(() => {\n const handleApplySymbolOperation = (data: {\n operations: Operation[];\n uid: string;\n }) => {\n const { uid, operations } = data;\n setSymbolUIs((symbolUIs) => {\n if (!symbolUIs[uid]) return symbolUIs;\n const newSymbolUIs = produce(symbolUIs, (draft) => {\n const symbol = draft[uid];\n if (!symbol) return;\n const newSymbol = applyOperation(symbol.ui, operations);\n symbol.ui = newSymbol;\n draft[uid] = {\n ...symbol,\n };\n });\n registerSymbolComponent([newSymbolUIs[uid]], componentRegistry);\n return newSymbolUIs;\n });\n };\n\n const applySymbolOperationListener = composableStudioEventManager?.on<{\n operations: Operation[];\n uid: string;\n }>(POST_MESSAGE_EVENTS.APPLY_SYMBOL_OPERATION, (event) => {\n handleApplySymbolOperation(event.data);\n });\n return () => {\n applySymbolOperationListener?.unregister();\n };\n }, []);\n\n useEffect(() => {\n const newSymbolListener = composableStudioEventManager?.on<{\n symbol: SymbolEntry;\n }>(POST_MESSAGE_EVENTS.ADD_NEW_SYMBOL, (event) => {\n const { symbol } = event.data;\n registerSymbolComponent([symbol], componentRegistry);\n setSymbolUIs((symbolUIs) => {\n return produce(symbolUIs, (draft) => {\n draft[symbol.uid] = symbol;\n });\n });\n });\n return () => {\n newSymbolListener?.unregister();\n };\n }, []);\n return (\n <SymbolUICtx.Provider value={symbolUIs}>{children}</SymbolUICtx.Provider>\n );\n};\n"],"names":["_jsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,gBAAgB,GAAG,CAAC,EAC/B,OAAO,EACP,QAAQ,GACc,KAAI;AAC1B,IAAA,MAAM,EAAE,iBAAiB,EAAE,GAAG,WAAW,EAAE;AAC3C,IAAA,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CACxC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAI;AAC7B,QAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AACxB,QAAA,OAAO,GAAG;AACZ,IAAA,CAAC,EAAE,EAAsB,CAAC,CAC3B;IAED,SAAS,CAAC,MAAK;AACb,QAAA,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YACtB,YAAY,CACV,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,MAAM,KAAI;AAC7B,gBAAA,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM;AACxB,gBAAA,OAAO,GAAG;AACZ,YAAA,CAAC,EAAE,EAAsB,CAAC,CAC3B;QACH;AACF,IAAA,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;;;;;IAOb,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,0BAA0B,GAAG,CAAC,IAGnC,KAAI;AACH,YAAA,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,GAAG,IAAI;AAChC,YAAA,YAAY,CAAC,CAAC,SAAS,KAAI;AACzB,gBAAA,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC;AAAE,oBAAA,OAAO,SAAS;gBACrC,MAAM,YAAY,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,KAAK,KAAI;AAChD,oBAAA,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,C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