@contentful/experiences-react 0.13.4 β 0.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/dist/client-renderer.js +6 -6
- package/dist/client-renderer.js.map +1 -1
- package/dist/component-error.js +1 -1
- package/dist/component-error.js.map +1 -1
- package/dist/context.js.map +1 -1
- package/dist/index.js +16 -12
- package/dist/index.js.map +1 -1
- package/dist/missing-component.js +1 -1
- package/dist/missing-component.js.map +1 -1
- package/dist/nodes-renderer.js +3 -3
- package/dist/nodes-renderer.js.map +1 -1
- package/dist/server-renderer.js +5 -5
- package/dist/server-renderer.js.map +1 -1
- package/dist/use-design-values.js +1 -1
- package/dist/use-design-values.js.map +1 -1
- package/dist/use-live-preview.js +2 -2
- package/dist/use-live-preview.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## 0.13.5 (2026-10-16)
|
|
2
|
+
|
|
3
|
+
### π©Ή Fixes
|
|
4
|
+
|
|
5
|
+
- **exo:** emit ESM-compatible adapter imports [SPA-5573] ([#231](https://github.com/contentful/experiences/pull/231))
|
|
6
|
+
|
|
7
|
+
### π§± Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated design to 0.12.3
|
|
10
|
+
|
|
1
11
|
## 0.13.4 (2026-10-14)
|
|
2
12
|
|
|
3
13
|
### π Features
|
package/dist/client-renderer.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
|
-
import { ComponentError } from "./component-error";
|
|
5
|
-
import { DiagnosticReporterContext } from "./component-error-boundary";
|
|
6
|
-
import { DebugExperience } from "./debug-experience";
|
|
7
|
-
import { ExperienceProvider } from "./context";
|
|
8
|
-
import { MissingComponent } from "./missing-component";
|
|
9
|
-
import { NodesRenderer } from "./nodes-renderer";
|
|
4
|
+
import { ComponentError } from "./component-error.js";
|
|
5
|
+
import { DiagnosticReporterContext } from "./component-error-boundary.js";
|
|
6
|
+
import { DebugExperience } from "./debug-experience.js";
|
|
7
|
+
import { ExperienceProvider } from "./context.js";
|
|
8
|
+
import { MissingComponent } from "./missing-component.js";
|
|
9
|
+
import { NodesRenderer } from "./nodes-renderer.js";
|
|
10
10
|
const DEFAULT_CONTEXT = {
|
|
11
11
|
debug: false,
|
|
12
12
|
metadata: {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client-renderer.tsx"],"sourcesContent":["/*\n * Client Experience renderer. It renders the resolved plan directly, with no\n * browser-only design-property work.\n */\n\n'use client';\n\nimport { useCallback, useState, type ReactNode } from 'react';\n\nimport type { ExperienceContext, PortableRenderPlan } from '@contentful/experiences-sdk-core';\n\nimport { ComponentError } from './component-error';\nimport { DiagnosticReporterContext } from './component-error-boundary';\nimport { DebugExperience } from './debug-experience';\nimport { ExperienceProvider } from './context';\nimport { MissingComponent } from './missing-component';\nimport { NodesRenderer, type RenderError, type RenderUnknown } from './nodes-renderer';\nimport type { Config, RenderContext } from './types';\n\nconst DEFAULT_CONTEXT: ExperienceContext = {\n debug: false,\n metadata: {},\n};\n\nexport interface ClientExperienceRendererProps {\n experience: PortableRenderPlan | null | undefined;\n config: Config;\n /** Shallow-merges over the plan's `metadata`. Only needed to override it. */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: renders the visible missing-component box,\n * turns the default `renderUnknown` fallback into the debug component, and\n * auto-mounts `<DebugExperience>` after the tree. Defaults to the plan's `debug`.\n */\n debug?: boolean;\n renderUnknown?: RenderUnknown;\n /** Override the fallback rendered when a registered component throws. */\n renderError?: RenderError;\n}\n\nexport function ClientExperienceRenderer({\n experience,\n config,\n metadata,\n debug,\n renderUnknown = MissingComponent,\n renderError = ComponentError,\n}: ClientExperienceRendererProps): ReactNode {\n const [renderDiagnostics, setRenderDiagnostics] = useState<Error[]>([]);\n // A `setState` updater rather than the SSR renderer's plain-array push: this\n // tree stays mounted and interactive, so a component that throws well after\n // first paint (a later re-render, an event handler) must still make\n // `<DebugExperience>` re-render with the new diagnostic β a mutated array\n // wouldn't trigger that.\n //\n // `queueMicrotask` defers the actual `setState` call: most of these\n // diagnostics (component-not-registered, malformed-slot,\n // experience-template-not-registered) are reported synchronously from\n // *inside* NodeRenderer's own render body, i.e. while React is mid-render\n // of a descendant β calling this component's setState right there is\n // exactly React's \"Cannot update a component while rendering a different\n // component\" anti-pattern. Escaping to a microtask (same \"break the\n // synchronous call chain\" rationale as core's resolveData deferral)\n // schedules the update for after the current render/commit fully unwinds.\n // `component-render-error`, reported from `componentDidCatch`, is already\n // commit-phase-safe β deferring it too is harmless and keeps one code path.\n // This is client-only (NodeRenderer's own onDiagnostic call is unchanged\n // and stays synchronous β see nodes-renderer.tsx for why SSR needs that):\n // `ServerExperienceRenderer` threads a plain synchronous array-push\n // closure instead of this setState-backed one, so SSR is unaffected.\n const onDiagnostic = useCallback((error: Error) => {\n queueMicrotask(() => {\n // Dedup by message, the guard `NodeRenderer` used to hold in a `useRef`.\n // It lives here so that module stays hook-free and therefore usable from\n // a React Server Component. Returning `prev` unchanged also skips a\n // pointless re-render, which matters more here than on the server: every\n // ancestor re-render re-reports the same diagnostic.\n setRenderDiagnostics((prev) =>\n prev.some((seen) => seen.message === error.message) ? prev : [...prev, error]\n );\n });\n }, []);\n\n if (!experience) return null;\n // `??`, not `||`, so an explicit `debug={false}` overrides a debug-on plan.\n const resolvedDebug = debug ?? experience.debug;\n const renderContext: RenderContext = {\n ...DEFAULT_CONTEXT,\n debug: resolvedDebug,\n metadata: { ...DEFAULT_CONTEXT.metadata, ...experience.metadata, ...(metadata ?? {}) },\n };\n\n return (\n <ExperienceProvider value={renderContext}>\n {/*\n Established here, not in `ServerExperienceRenderer`: this Provider\n (and the closure it carries) never crosses a ServerβClient boundary\n because everything from `ClientExperienceRenderer` down is already\n client-rendered. `ComponentErrorBoundary` reads it via `contextType`\n to report a render-time throw without receiving a callback prop β\n see component-error-boundary.tsx for why that specifically matters.\n */}\n <DiagnosticReporterContext.Provider value={onDiagnostic}>\n <NodesRenderer\n nodes={experience.nodes}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n </DiagnosticReporterContext.Provider>\n {resolvedDebug ? (\n <DebugExperience\n experience={experience}\n errors={[...(experience.diagnostics ?? []), ...renderDiagnostics]}\n />\n ) : null}\n </ExperienceProvider>\n );\n}\n"],"mappings":";AA6FI,SAUI,KAVJ;AAtFJ,SAAS,aAAa,gBAAgC;AAItD,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,qBAA2D;AAGpE,MAAM,kBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,UAAU,CAAC;AACb;AAkBO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAChB,GAA6C;AAC3C,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAkB,CAAC,CAAC;AAsBtE,QAAM,eAAe,YAAY,CAAC,UAAiB;AACjD,mBAAe,MAAM;AAMnB;AAAA,QAAqB,CAAC,SACpB,KAAK,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,OAAO,IAAI,OAAO,CAAC,GAAG,MAAM,KAAK;AAAA,MAC9E;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC,WAAY,QAAO;AAExB,QAAM,gBAAgB,SAAS,WAAW;AAC1C,QAAM,gBAA+B;AAAA,IACnC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU,EAAE,GAAG,gBAAgB,UAAU,GAAG,WAAW,UAAU,GAAI,YAAY,CAAC,EAAG;AAAA,EACvF;AAEA,SACE,qBAAC,sBAAmB,OAAO,eASzB;AAAA,wBAAC,0BAA0B,UAA1B,EAAmC,OAAO,cACzC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,WAAW;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF;AAAA,IACC,gBACC;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,QAAQ,CAAC,GAAI,WAAW,eAAe,CAAC,GAAI,GAAG,iBAAiB;AAAA;AAAA,IAClE,IACE;AAAA,KACN;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/client-renderer.tsx"],"sourcesContent":["/*\n * Client Experience renderer. It renders the resolved plan directly, with no\n * browser-only design-property work.\n */\n\n'use client';\n\nimport { useCallback, useState, type ReactNode } from 'react';\n\nimport type { ExperienceContext, PortableRenderPlan } from '@contentful/experiences-sdk-core';\n\nimport { ComponentError } from './component-error.js';\nimport { DiagnosticReporterContext } from './component-error-boundary.js';\nimport { DebugExperience } from './debug-experience.js';\nimport { ExperienceProvider } from './context.js';\nimport { MissingComponent } from './missing-component.js';\nimport { NodesRenderer, type RenderError, type RenderUnknown } from './nodes-renderer.js';\nimport type { Config, RenderContext } from './types.js';\n\nconst DEFAULT_CONTEXT: ExperienceContext = {\n debug: false,\n metadata: {},\n};\n\nexport interface ClientExperienceRendererProps {\n experience: PortableRenderPlan | null | undefined;\n config: Config;\n /** Shallow-merges over the plan's `metadata`. Only needed to override it. */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: renders the visible missing-component box,\n * turns the default `renderUnknown` fallback into the debug component, and\n * auto-mounts `<DebugExperience>` after the tree. Defaults to the plan's `debug`.\n */\n debug?: boolean;\n renderUnknown?: RenderUnknown;\n /** Override the fallback rendered when a registered component throws. */\n renderError?: RenderError;\n}\n\nexport function ClientExperienceRenderer({\n experience,\n config,\n metadata,\n debug,\n renderUnknown = MissingComponent,\n renderError = ComponentError,\n}: ClientExperienceRendererProps): ReactNode {\n const [renderDiagnostics, setRenderDiagnostics] = useState<Error[]>([]);\n // A `setState` updater rather than the SSR renderer's plain-array push: this\n // tree stays mounted and interactive, so a component that throws well after\n // first paint (a later re-render, an event handler) must still make\n // `<DebugExperience>` re-render with the new diagnostic β a mutated array\n // wouldn't trigger that.\n //\n // `queueMicrotask` defers the actual `setState` call: most of these\n // diagnostics (component-not-registered, malformed-slot,\n // experience-template-not-registered) are reported synchronously from\n // *inside* NodeRenderer's own render body, i.e. while React is mid-render\n // of a descendant β calling this component's setState right there is\n // exactly React's \"Cannot update a component while rendering a different\n // component\" anti-pattern. Escaping to a microtask (same \"break the\n // synchronous call chain\" rationale as core's resolveData deferral)\n // schedules the update for after the current render/commit fully unwinds.\n // `component-render-error`, reported from `componentDidCatch`, is already\n // commit-phase-safe β deferring it too is harmless and keeps one code path.\n // This is client-only (NodeRenderer's own onDiagnostic call is unchanged\n // and stays synchronous β see nodes-renderer.tsx for why SSR needs that):\n // `ServerExperienceRenderer` threads a plain synchronous array-push\n // closure instead of this setState-backed one, so SSR is unaffected.\n const onDiagnostic = useCallback((error: Error) => {\n queueMicrotask(() => {\n // Dedup by message, the guard `NodeRenderer` used to hold in a `useRef`.\n // It lives here so that module stays hook-free and therefore usable from\n // a React Server Component. Returning `prev` unchanged also skips a\n // pointless re-render, which matters more here than on the server: every\n // ancestor re-render re-reports the same diagnostic.\n setRenderDiagnostics((prev) =>\n prev.some((seen) => seen.message === error.message) ? prev : [...prev, error]\n );\n });\n }, []);\n\n if (!experience) return null;\n // `??`, not `||`, so an explicit `debug={false}` overrides a debug-on plan.\n const resolvedDebug = debug ?? experience.debug;\n const renderContext: RenderContext = {\n ...DEFAULT_CONTEXT,\n debug: resolvedDebug,\n metadata: { ...DEFAULT_CONTEXT.metadata, ...experience.metadata, ...(metadata ?? {}) },\n };\n\n return (\n <ExperienceProvider value={renderContext}>\n {/*\n Established here, not in `ServerExperienceRenderer`: this Provider\n (and the closure it carries) never crosses a ServerβClient boundary\n because everything from `ClientExperienceRenderer` down is already\n client-rendered. `ComponentErrorBoundary` reads it via `contextType`\n to report a render-time throw without receiving a callback prop β\n see component-error-boundary.tsx for why that specifically matters.\n */}\n <DiagnosticReporterContext.Provider value={onDiagnostic}>\n <NodesRenderer\n nodes={experience.nodes}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n </DiagnosticReporterContext.Provider>\n {resolvedDebug ? (\n <DebugExperience\n experience={experience}\n errors={[...(experience.diagnostics ?? []), ...renderDiagnostics]}\n />\n ) : null}\n </ExperienceProvider>\n );\n}\n"],"mappings":";AA6FI,SAUI,KAVJ;AAtFJ,SAAS,aAAa,gBAAgC;AAItD,SAAS,sBAAsB;AAC/B,SAAS,iCAAiC;AAC1C,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,qBAA2D;AAGpE,MAAM,kBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,UAAU,CAAC;AACb;AAkBO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAChB,GAA6C;AAC3C,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAkB,CAAC,CAAC;AAsBtE,QAAM,eAAe,YAAY,CAAC,UAAiB;AACjD,mBAAe,MAAM;AAMnB;AAAA,QAAqB,CAAC,SACpB,KAAK,KAAK,CAAC,SAAS,KAAK,YAAY,MAAM,OAAO,IAAI,OAAO,CAAC,GAAG,MAAM,KAAK;AAAA,MAC9E;AAAA,IACF,CAAC;AAAA,EACH,GAAG,CAAC,CAAC;AAEL,MAAI,CAAC,WAAY,QAAO;AAExB,QAAM,gBAAgB,SAAS,WAAW;AAC1C,QAAM,gBAA+B;AAAA,IACnC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU,EAAE,GAAG,gBAAgB,UAAU,GAAG,WAAW,UAAU,GAAI,YAAY,CAAC,EAAG;AAAA,EACvF;AAEA,SACE,qBAAC,sBAAmB,OAAO,eASzB;AAAA,wBAAC,0BAA0B,UAA1B,EAAmC,OAAO,cACzC;AAAA,MAAC;AAAA;AAAA,QACC,OAAO,WAAW;AAAA,QAClB;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF,GACF;AAAA,IACC,gBACC;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,QAAQ,CAAC,GAAI,WAAW,eAAe,CAAC,GAAI,GAAG,iBAAiB;AAAA;AAAA,IAClE,IACE;AAAA,KACN;AAEJ;","names":[]}
|
package/dist/component-error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useExperience } from "./context";
|
|
3
|
+
import { useExperience } from "./context.js";
|
|
4
4
|
function ComponentError({ componentId, nodeId, message }) {
|
|
5
5
|
const { debug } = useExperience();
|
|
6
6
|
if (!debug) return null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/component-error.tsx"],"sourcesContent":["/*\n * Default fallback rendered when a registered component throws while\n * rendering. Sibling of `MissingComponent` β same debug-gated behavior\n * (visible box in debug mode, silent null otherwise), visually distinct\n * (different color/label) so a customer can tell \"not registered\" apart from\n * \"registered but threw\" at a glance. The diagnostic + console.warn for this\n * failure mode are recorded once, at the error-boundary call site in\n * `nodes-renderer.tsx` β not here β so they still fire even when a customer\n * overrides `renderError` with their own fallback.\n */\n'use client';\n\nimport type { ReactNode } from 'react';\n\nimport { useExperience } from './context';\n\nexport interface ComponentErrorProps {\n componentId: string;\n /** Optional β only present when the payload supplied an id for this node. */\n nodeId?: string;\n /** The caught error's message, when available. */\n message?: string;\n}\n\nexport function ComponentError({ componentId, nodeId, message }: ComponentErrorProps): ReactNode {\n const { debug } = useExperience();\n if (!debug) return null;\n return (\n <div\n style={{\n border: '2px solid #b91c1c',\n padding: '1rem',\n color: '#b91c1c',\n background: '#fff',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.8125rem',\n }}\n data-experiences-render-error={componentId}\n >\n <strong>Component ‘{componentId}’ threw while rendering</strong>\n <p style={{ margin: '0.5rem 0' }}>\n This component is registered but threw during render. Rendering this fallback instead of\n crashing the surrounding tree.\n </p>\n <pre style={{ margin: 0, whiteSpace: 'pre-wrap' }}>\n {JSON.stringify({ componentId, nodeId: nodeId ?? null, message: message ?? null }, null, 2)}\n </pre>\n </div>\n );\n}\n"],"mappings":";AAuCM,SACA,KADA;AAzBN,SAAS,qBAAqB;AAUvB,SAAS,eAAe,EAAE,aAAa,QAAQ,QAAQ,GAAmC;AAC/F,QAAM,EAAE,MAAM,IAAI,cAAc;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,iCAA+B;AAAA,MAE/B;AAAA,6BAAC,YAAO;AAAA;AAAA,UAAkB;AAAA,UAAY;AAAA,WAA6B;AAAA,QACnE,oBAAC,OAAE,OAAO,EAAE,QAAQ,WAAW,GAAG,qIAGlC;AAAA,QACA,oBAAC,SAAI,OAAO,EAAE,QAAQ,GAAG,YAAY,WAAW,GAC7C,eAAK,UAAU,EAAE,aAAa,QAAQ,UAAU,MAAM,SAAS,WAAW,KAAK,GAAG,MAAM,CAAC,GAC5F;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/component-error.tsx"],"sourcesContent":["/*\n * Default fallback rendered when a registered component throws while\n * rendering. Sibling of `MissingComponent` β same debug-gated behavior\n * (visible box in debug mode, silent null otherwise), visually distinct\n * (different color/label) so a customer can tell \"not registered\" apart from\n * \"registered but threw\" at a glance. The diagnostic + console.warn for this\n * failure mode are recorded once, at the error-boundary call site in\n * `nodes-renderer.tsx` β not here β so they still fire even when a customer\n * overrides `renderError` with their own fallback.\n */\n'use client';\n\nimport type { ReactNode } from 'react';\n\nimport { useExperience } from './context.js';\n\nexport interface ComponentErrorProps {\n componentId: string;\n /** Optional β only present when the payload supplied an id for this node. */\n nodeId?: string;\n /** The caught error's message, when available. */\n message?: string;\n}\n\nexport function ComponentError({ componentId, nodeId, message }: ComponentErrorProps): ReactNode {\n const { debug } = useExperience();\n if (!debug) return null;\n return (\n <div\n style={{\n border: '2px solid #b91c1c',\n padding: '1rem',\n color: '#b91c1c',\n background: '#fff',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.8125rem',\n }}\n data-experiences-render-error={componentId}\n >\n <strong>Component ‘{componentId}’ threw while rendering</strong>\n <p style={{ margin: '0.5rem 0' }}>\n This component is registered but threw during render. Rendering this fallback instead of\n crashing the surrounding tree.\n </p>\n <pre style={{ margin: 0, whiteSpace: 'pre-wrap' }}>\n {JSON.stringify({ componentId, nodeId: nodeId ?? null, message: message ?? null }, null, 2)}\n </pre>\n </div>\n );\n}\n"],"mappings":";AAuCM,SACA,KADA;AAzBN,SAAS,qBAAqB;AAUvB,SAAS,eAAe,EAAE,aAAa,QAAQ,QAAQ,GAAmC;AAC/F,QAAM,EAAE,MAAM,IAAI,cAAc;AAChC,MAAI,CAAC,MAAO,QAAO;AACnB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,iCAA+B;AAAA,MAE/B;AAAA,6BAAC,YAAO;AAAA;AAAA,UAAkB;AAAA,UAAY;AAAA,WAA6B;AAAA,QACnE,oBAAC,OAAE,OAAO,EAAE,QAAQ,WAAW,GAAG,qIAGlC;AAAA,QACA,oBAAC,SAAI,OAAO,EAAE,QAAQ,GAAG,YAAY,WAAW,GAC7C,eAAK,UAAU,EAAE,aAAa,QAAQ,UAAU,MAAM,SAAS,WAAW,KAAK,GAAG,MAAM,CAAC,GAC5F;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.tsx"],"sourcesContent":["/*\n * React context providers + hooks that expose runtime context and the raw\n * Contentful payload to descendants of a rendered Experience. Customer\n * components receive only their declared props via the renderer; anything\n * that needs the Experience runtime context or the underlying payload calls\n * the hook explicitly at the top of its component body.\n */\n\n'use client';\n\nimport { createContext, useContext, type ReactNode } from 'react';\n\nimport type { ContentfulComponent, ContentfulExperienceTemplate, RenderContext } from './types';\n\nconst ExperienceContext = createContext<RenderContext | null>(null);\nconst ContentfulComponentContext = createContext<ContentfulComponent | null>(null);\nconst ContentfulExperienceTemplateContext = createContext<ContentfulExperienceTemplate | null>(\n null\n);\n// Plain data only (never the Config or its functions) so it crosses RSC cleanly.\nconst ResolvedDesignContext = createContext<Record<string, unknown> | null>(null);\n\n// Wrapped as real client-component functions, not re-exported `Context.Provider`\n// objects β the server renderer imports these across the RSC boundary and\n// Next.js requires a function reference there (\"Element type is invalid\" otherwise).\n\nexport function ExperienceProvider({\n value,\n children,\n}: {\n value: RenderContext;\n children: ReactNode;\n}): ReactNode {\n return <ExperienceContext.Provider value={value}>{children}</ExperienceContext.Provider>;\n}\n\nexport function ContentfulComponentProvider({\n value,\n children,\n}: {\n value: ContentfulComponent;\n children: ReactNode;\n}): ReactNode {\n return (\n <ContentfulComponentContext.Provider value={value}>\n {children}\n </ContentfulComponentContext.Provider>\n );\n}\n\nexport function ContentfulExperienceTemplateProvider({\n value,\n children,\n}: {\n value: ContentfulExperienceTemplate;\n children: ReactNode;\n}): ReactNode {\n return (\n <ContentfulExperienceTemplateContext.Provider value={value}>\n {children}\n </ContentfulExperienceTemplateContext.Provider>\n );\n}\n\nexport function ResolvedDesignProvider({\n value,\n children,\n}: {\n value: Record<string, unknown>;\n children: ReactNode;\n}): ReactNode {\n return <ResolvedDesignContext.Provider value={value}>{children}</ResolvedDesignContext.Provider>;\n}\n\n/**\n * Read the current Experience runtime context β the `debug` flag and\n * free-form metadata. Throws when called outside any Experience renderer subtree.\n */\nexport function useExperience(): RenderContext {\n const ctx = useContext(ExperienceContext);\n if (ctx === null) {\n throw new Error(\n 'useExperience() must be called inside a <ServerExperienceRenderer> or <ClientExperienceRenderer> subtree.'\n );\n }\n return ctx;\n}\n\n/**\n * Read the raw Contentful payload for the nearest enclosing *component* node.\n * Returns `null` outside any rendered component node β including inside a coded\n * Experience Template, which publishes `useContentfulExperienceTemplate()`\n * instead.\n */\nexport function useContentfulComponent(): ContentfulComponent | null {\n return useContext(ContentfulComponentContext);\n}\n\n/**\n * Read the raw Contentful payload for the nearest enclosing Experience Template\n * node. Returns `null` outside an Experience Template's render tree.\n */\nexport function useContentfulExperienceTemplate(): ContentfulExperienceTemplate | null {\n return useContext(ContentfulExperienceTemplateContext);\n}\n\n/**\n * Read the design values the renderer already resolved for the enclosing\n * node or experience template β token-resolved, the same bag that feeds the\n * component's props. Returns `null` outside a rendered\n * node / experience template, which `useDesignValues` treats as \"nothing to read.\"\n */\nexport function useResolvedDesign(): Record<string, unknown> | null {\n return useContext(ResolvedDesignContext);\n}\n"],"mappings":";AAiCS;AAvBT,SAAS,eAAe,kBAAkC;AAI1D,MAAM,oBAAoB,cAAoC,IAAI;AAClE,MAAM,6BAA6B,cAA0C,IAAI;AACjF,MAAM,sCAAsC;AAAA,EAC1C;AACF;AAEA,MAAM,wBAAwB,cAA8C,IAAI;AAMzE,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGc;AACZ,SAAO,oBAAC,kBAAkB,UAAlB,EAA2B,OAAe,UAAS;AAC7D;AAEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGc;AACZ,SACE,oBAAC,2BAA2B,UAA3B,EAAoC,OAClC,UACH;AAEJ;AAEO,SAAS,qCAAqC;AAAA,EACnD;AAAA,EACA;AACF,GAGc;AACZ,SACE,oBAAC,oCAAoC,UAApC,EAA6C,OAC3C,UACH;AAEJ;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGc;AACZ,SAAO,oBAAC,sBAAsB,UAAtB,EAA+B,OAAe,UAAS;AACjE;AAMO,SAAS,gBAA+B;AAC7C,QAAM,MAAM,WAAW,iBAAiB;AACxC,MAAI,QAAQ,MAAM;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAQO,SAAS,yBAAqD;AACnE,SAAO,WAAW,0BAA0B;AAC9C;AAMO,SAAS,kCAAuE;AACrF,SAAO,WAAW,mCAAmC;AACvD;AAQO,SAAS,oBAAoD;AAClE,SAAO,WAAW,qBAAqB;AACzC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/context.tsx"],"sourcesContent":["/*\n * React context providers + hooks that expose runtime context and the raw\n * Contentful payload to descendants of a rendered Experience. Customer\n * components receive only their declared props via the renderer; anything\n * that needs the Experience runtime context or the underlying payload calls\n * the hook explicitly at the top of its component body.\n */\n\n'use client';\n\nimport { createContext, useContext, type ReactNode } from 'react';\n\nimport type { ContentfulComponent, ContentfulExperienceTemplate, RenderContext } from './types.js';\n\nconst ExperienceContext = createContext<RenderContext | null>(null);\nconst ContentfulComponentContext = createContext<ContentfulComponent | null>(null);\nconst ContentfulExperienceTemplateContext = createContext<ContentfulExperienceTemplate | null>(\n null\n);\n// Plain data only (never the Config or its functions) so it crosses RSC cleanly.\nconst ResolvedDesignContext = createContext<Record<string, unknown> | null>(null);\n\n// Wrapped as real client-component functions, not re-exported `Context.Provider`\n// objects β the server renderer imports these across the RSC boundary and\n// Next.js requires a function reference there (\"Element type is invalid\" otherwise).\n\nexport function ExperienceProvider({\n value,\n children,\n}: {\n value: RenderContext;\n children: ReactNode;\n}): ReactNode {\n return <ExperienceContext.Provider value={value}>{children}</ExperienceContext.Provider>;\n}\n\nexport function ContentfulComponentProvider({\n value,\n children,\n}: {\n value: ContentfulComponent;\n children: ReactNode;\n}): ReactNode {\n return (\n <ContentfulComponentContext.Provider value={value}>\n {children}\n </ContentfulComponentContext.Provider>\n );\n}\n\nexport function ContentfulExperienceTemplateProvider({\n value,\n children,\n}: {\n value: ContentfulExperienceTemplate;\n children: ReactNode;\n}): ReactNode {\n return (\n <ContentfulExperienceTemplateContext.Provider value={value}>\n {children}\n </ContentfulExperienceTemplateContext.Provider>\n );\n}\n\nexport function ResolvedDesignProvider({\n value,\n children,\n}: {\n value: Record<string, unknown>;\n children: ReactNode;\n}): ReactNode {\n return <ResolvedDesignContext.Provider value={value}>{children}</ResolvedDesignContext.Provider>;\n}\n\n/**\n * Read the current Experience runtime context β the `debug` flag and\n * free-form metadata. Throws when called outside any Experience renderer subtree.\n */\nexport function useExperience(): RenderContext {\n const ctx = useContext(ExperienceContext);\n if (ctx === null) {\n throw new Error(\n 'useExperience() must be called inside a <ServerExperienceRenderer> or <ClientExperienceRenderer> subtree.'\n );\n }\n return ctx;\n}\n\n/**\n * Read the raw Contentful payload for the nearest enclosing *component* node.\n * Returns `null` outside any rendered component node β including inside a coded\n * Experience Template, which publishes `useContentfulExperienceTemplate()`\n * instead.\n */\nexport function useContentfulComponent(): ContentfulComponent | null {\n return useContext(ContentfulComponentContext);\n}\n\n/**\n * Read the raw Contentful payload for the nearest enclosing Experience Template\n * node. Returns `null` outside an Experience Template's render tree.\n */\nexport function useContentfulExperienceTemplate(): ContentfulExperienceTemplate | null {\n return useContext(ContentfulExperienceTemplateContext);\n}\n\n/**\n * Read the design values the renderer already resolved for the enclosing\n * node or experience template β token-resolved, the same bag that feeds the\n * component's props. Returns `null` outside a rendered\n * node / experience template, which `useDesignValues` treats as \"nothing to read.\"\n */\nexport function useResolvedDesign(): Record<string, unknown> | null {\n return useContext(ResolvedDesignContext);\n}\n"],"mappings":";AAiCS;AAvBT,SAAS,eAAe,kBAAkC;AAI1D,MAAM,oBAAoB,cAAoC,IAAI;AAClE,MAAM,6BAA6B,cAA0C,IAAI;AACjF,MAAM,sCAAsC;AAAA,EAC1C;AACF;AAEA,MAAM,wBAAwB,cAA8C,IAAI;AAMzE,SAAS,mBAAmB;AAAA,EACjC;AAAA,EACA;AACF,GAGc;AACZ,SAAO,oBAAC,kBAAkB,UAAlB,EAA2B,OAAe,UAAS;AAC7D;AAEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGc;AACZ,SACE,oBAAC,2BAA2B,UAA3B,EAAoC,OAClC,UACH;AAEJ;AAEO,SAAS,qCAAqC;AAAA,EACnD;AAAA,EACA;AACF,GAGc;AACZ,SACE,oBAAC,oCAAoC,UAApC,EAA6C,OAC3C,UACH;AAEJ;AAEO,SAAS,uBAAuB;AAAA,EACrC;AAAA,EACA;AACF,GAGc;AACZ,SAAO,oBAAC,sBAAsB,UAAtB,EAA+B,OAAe,UAAS;AACjE;AAMO,SAAS,gBAA+B;AAC7C,QAAM,MAAM,WAAW,iBAAiB;AACxC,MAAI,QAAQ,MAAM;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;AAQO,SAAS,yBAAqD;AACnE,SAAO,WAAW,0BAA0B;AAC9C;AAMO,SAAS,kCAAuE;AACrF,SAAO,WAAW,mCAAmC;AACvD;AAQO,SAAS,oBAAoD;AAClE,SAAO,WAAW,qBAAqB;AACzC;","names":[]}
|
package/dist/index.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ClientExperienceRenderer,
|
|
3
3
|
ClientExperienceRenderer as ClientExperienceRenderer2
|
|
4
|
-
} from "./client-renderer";
|
|
5
|
-
import { ServerExperienceRenderer } from "./server-renderer";
|
|
6
|
-
import { MissingComponent } from "./missing-component";
|
|
7
|
-
import { ComponentError } from "./component-error";
|
|
8
|
-
import { DebugExperience } from "./debug-experience";
|
|
9
|
-
import { useLivePreviewExperience } from "./use-live-preview-experience";
|
|
10
|
-
import { useLivePreview } from "./use-live-preview";
|
|
11
|
-
import { useExperiencePlan } from "./use-experience-plan";
|
|
4
|
+
} from "./client-renderer.js";
|
|
5
|
+
import { ServerExperienceRenderer } from "./server-renderer.js";
|
|
6
|
+
import { MissingComponent } from "./missing-component.js";
|
|
7
|
+
import { ComponentError } from "./component-error.js";
|
|
8
|
+
import { DebugExperience } from "./debug-experience.js";
|
|
9
|
+
import { useLivePreviewExperience } from "./use-live-preview-experience.js";
|
|
10
|
+
import { useLivePreview } from "./use-live-preview.js";
|
|
11
|
+
import { useExperiencePlan } from "./use-experience-plan.js";
|
|
12
12
|
import {
|
|
13
13
|
fetchPreviewSession,
|
|
14
14
|
LivePreviewConnectionError,
|
|
15
15
|
PREVIEW_WEBSOCKET_HOST,
|
|
16
16
|
PreviewSessionFetchError
|
|
17
17
|
} from "@contentful/experiences-live-preview";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
import {
|
|
19
|
+
useExperience,
|
|
20
|
+
useContentfulComponent,
|
|
21
|
+
useContentfulExperienceTemplate
|
|
22
|
+
} from "./context.js";
|
|
23
|
+
import { useDesignValues } from "./use-design-values.js";
|
|
24
|
+
import { toCss } from "./design-utils.js";
|
|
21
25
|
import {
|
|
22
26
|
defineComponent,
|
|
23
27
|
defineExperienceTemplate,
|
|
24
28
|
normalizeComponentRegistration,
|
|
25
29
|
normalizeExperienceTemplateRegistration
|
|
26
|
-
} from "./types";
|
|
30
|
+
} from "./types.js";
|
|
27
31
|
import { resolveExperience } from "@contentful/experiences-sdk-core";
|
|
28
32
|
import {
|
|
29
33
|
getTrackingAttributes,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*\n * Public API surface for `@contentful/experiences-react`.\n *\n * Customers add ONLY this package to their app's dependencies. Everything\n * needed to render an Experience β types, the resolver, design utilities,\n * the renderer components, the authoring helpers β is re-exported from here.\n * The internal `@contentful/experiences-sdk-core` and\n * `@contentful/experiences-design` packages are workspace-only implementation\n * details; they are not part of the public API.\n *\n * `ExperienceRenderer` is an alias for `ClientExperienceRenderer`; SSR\n * consumers explicitly import `ServerExperienceRenderer`.\n */\n\n// βββ Renderers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\nexport {\n ClientExperienceRenderer as ExperienceRenderer,\n ClientExperienceRenderer,\n} from './client-renderer';\nexport type { ClientExperienceRendererProps as ExperienceRendererProps } from './client-renderer';\nexport type { ClientExperienceRendererProps } from './client-renderer';\n\nexport { ServerExperienceRenderer } from './server-renderer';\nexport type { ServerExperienceRendererProps } from './server-renderer';\n\nexport { MissingComponent } from './missing-component';\nexport type { MissingComponentProps } from './missing-component';\n\nexport { ComponentError } from './component-error';\nexport type { ComponentErrorProps } from './component-error';\n\nexport { DebugExperience } from './debug-experience';\nexport type { DebugExperienceProps } from './debug-experience';\n\nexport type { DiagnosticReporter, RenderError, RenderUnknown } from './nodes-renderer';\n\nexport { useLivePreviewExperience } from './use-live-preview-experience';\nexport type {\n UseLivePreviewExperienceOptions,\n UseLivePreviewExperienceResult,\n} from './use-live-preview-experience';\nexport { useLivePreview } from './use-live-preview';\nexport type { UseLivePreviewOptions, UseLivePreviewResult } from './use-live-preview';\n\nexport { useExperiencePlan } from './use-experience-plan';\nexport type {\n ExperiencePlanResolveOptions,\n UseExperiencePlanOptions,\n UseExperiencePlanResult,\n} from './use-experience-plan';\nexport type {\n LivePreviewClient,\n LivePreviewResult,\n PreviewSessionClientOptions,\n PreviewSessionExperienceOptions,\n PreviewSessionOptions,\n PreviewSessionResolveOptions,\n} from '@contentful/experiences-live-preview';\nexport {\n fetchPreviewSession,\n LivePreviewConnectionError,\n PREVIEW_WEBSOCKET_HOST,\n PreviewSessionFetchError,\n} from '@contentful/experiences-live-preview';\n\n// βββ Runtime context hooks βββββββββββββββββββββββββββββββββββββββββββββββ\nexport {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/*\n * Public API surface for `@contentful/experiences-react`.\n *\n * Customers add ONLY this package to their app's dependencies. Everything\n * needed to render an Experience β types, the resolver, design utilities,\n * the renderer components, the authoring helpers β is re-exported from here.\n * The internal `@contentful/experiences-sdk-core` and\n * `@contentful/experiences-design` packages are workspace-only implementation\n * details; they are not part of the public API.\n *\n * `ExperienceRenderer` is an alias for `ClientExperienceRenderer`; SSR\n * consumers explicitly import `ServerExperienceRenderer`.\n */\n\n// βββ Renderers βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ\nexport {\n ClientExperienceRenderer as ExperienceRenderer,\n ClientExperienceRenderer,\n} from './client-renderer.js';\nexport type { ClientExperienceRendererProps as ExperienceRendererProps } from './client-renderer.js';\nexport type { ClientExperienceRendererProps } from './client-renderer.js';\n\nexport { ServerExperienceRenderer } from './server-renderer.js';\nexport type { ServerExperienceRendererProps } from './server-renderer.js';\n\nexport { MissingComponent } from './missing-component.js';\nexport type { MissingComponentProps } from './missing-component.js';\n\nexport { ComponentError } from './component-error.js';\nexport type { ComponentErrorProps } from './component-error.js';\n\nexport { DebugExperience } from './debug-experience.js';\nexport type { DebugExperienceProps } from './debug-experience.js';\n\nexport type { DiagnosticReporter, RenderError, RenderUnknown } from './nodes-renderer.js';\n\nexport { useLivePreviewExperience } from './use-live-preview-experience.js';\nexport type {\n UseLivePreviewExperienceOptions,\n UseLivePreviewExperienceResult,\n} from './use-live-preview-experience.js';\nexport { useLivePreview } from './use-live-preview.js';\nexport type { UseLivePreviewOptions, UseLivePreviewResult } from './use-live-preview.js';\n\nexport { useExperiencePlan } from './use-experience-plan.js';\nexport type {\n ExperiencePlanResolveOptions,\n UseExperiencePlanOptions,\n UseExperiencePlanResult,\n} from './use-experience-plan.js';\nexport type {\n LivePreviewClient,\n LivePreviewResult,\n PreviewSessionClientOptions,\n PreviewSessionExperienceOptions,\n PreviewSessionOptions,\n PreviewSessionResolveOptions,\n} from '@contentful/experiences-live-preview';\nexport {\n fetchPreviewSession,\n LivePreviewConnectionError,\n PREVIEW_WEBSOCKET_HOST,\n PreviewSessionFetchError,\n} from '@contentful/experiences-live-preview';\n\n// βββ Runtime context hooks βββββββββββββββββββββββββββββββββββββββββββββββ\nexport {\n useExperience,\n useContentfulComponent,\n useContentfulExperienceTemplate,\n} from './context.js';\nexport { useDesignValues } from './use-design-values.js';\nexport { toCss } from './design-utils.js';\nexport type { ToCssOptions } from './design-utils.js';\n\n// βββ Authoring helpers + Config types βββββββββββββββββββββββββββββββββββββ\nexport {\n defineComponent,\n defineExperienceTemplate,\n normalizeComponentRegistration,\n normalizeExperienceTemplateRegistration,\n} from './types.js';\nexport type {\n ComponentConfig,\n Components,\n Config,\n ContentfulComponent,\n ContentfulExperienceTemplate,\n ExperienceTemplateConfig,\n ExperienceTemplateRegistration,\n ExperienceTemplates,\n Registration,\n RenderContext,\n ResolveToken,\n} from './types.js';\n\n// βββ Resolver (re-exported from render-core) ββββββββββββββββββββββββββββββ\nexport { resolveExperience } from '@contentful/experiences-sdk-core';\nexport {\n getTrackingAttributes,\n TRACKING_CLICKABLE_ATTRIBUTE,\n TRACKING_SCOPES_ATTRIBUTE,\n} from '@contentful/experiences-sdk-core';\nexport type { TrackingAttributes } from '@contentful/experiences-sdk-core';\nexport type { ResolverConfig, ResolveExperienceOptions } from '@contentful/experiences-sdk-core';\n\n// βββ Event builder (re-exported from runtime) βββββββββββββββββββββββββββββ\nexport { DEFAULT_PAGE_PROPERTIES, EventBuilder } from '@contentful/experiences-runtime';\nexport type {\n ClickBuilderArgs,\n EventBuilderConfig,\n FlagViewBuilderArgs,\n HoverBuilderArgs,\n IdentifyBuilderArgs,\n InteractionBuilderArgsBase,\n PageViewBuilderArgs,\n TrackBuilderArgs,\n UniversalEventBuilderArgs,\n ViewBuilderArgs,\n} from '@contentful/experiences-runtime';\n\n// βββ Core IR + payload types (re-exported from render-core) βββββββββββββββ\nexport type {\n ComponentNode,\n ComponentRef,\n DesignPropValue,\n DesignToken,\n ExperienceContext,\n ExperienceNode,\n ExperiencePayload,\n ExperienceSourceMap,\n ExperienceSys,\n ExperienceTemplateNode,\n ExperienceTemplateRef,\n ManualDesignValue,\n PortableRegistration,\n PortableRenderNode,\n PortableRenderPlan,\n ResolveContext,\n} from '@contentful/experiences-sdk-core';\n\n// βββ Design utilities (re-exported from design) βββββββββββββββββββββββββββ\nexport { CSS_PROPERTIES, isCssProperty, toCssKey } from '@contentful/experiences-design';\n\n// βββ Delivery client + fetchExperience ββββββββββββββββββββββββββββββββββββ\nexport {\n ContentfulViewDelivery,\n ContentfulViewDeliveryClient,\n DELIVERY_HOST,\n ExperienceFetchError,\n NotFoundError,\n PREVIEW_HOST,\n createClient,\n fetchExperience,\n fetchDestinationSitemap,\n readSourceMap,\n toExperiencePayload,\n toExperiencePayloadFromDestination,\n} from '@contentful/experiences-client';\nexport { ANONYMOUS_ID_COOKIE } from '@contentful/experiences-runtime';\nexport type {\n ByDestinationNodeIdExperienceOptions,\n ByDestinationPathExperienceOptions,\n ByIdExperienceOptions,\n ClientOptions,\n CreateClientOptions,\n DestinationRedirectResult,\n DestinationSitemapResult,\n ExperienceOptions,\n ExperienceResponse,\n FetchDestinationSitemapOptions,\n FetchDestinationSitemapPaginationOptions,\n ResolveOptions,\n SitemapPathItem,\n} from '@contentful/experiences-client';\n"],"mappings":"AAeA;AAAA,EAC8B;AAAA,EAC5B,4BAAAA;AAAA,OACK;AAIP,SAAS,gCAAgC;AAGzC,SAAS,wBAAwB;AAGjC,SAAS,sBAAsB;AAG/B,SAAS,uBAAuB;AAKhC,SAAS,gCAAgC;AAKzC,SAAS,sBAAsB;AAG/B,SAAS,yBAAyB;AAclC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,uBAAuB;AAChC,SAAS,aAAa;AAItB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgBP,SAAS,yBAAyB;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAKP,SAAS,yBAAyB,oBAAoB;AAmCtD,SAAS,gBAAgB,eAAe,gBAAgB;AAGxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;","names":["ClientExperienceRenderer"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useExperience } from "./context";
|
|
3
|
+
import { useExperience } from "./context.js";
|
|
4
4
|
function MissingComponent({ componentId, nodeId }) {
|
|
5
5
|
const { debug } = useExperience();
|
|
6
6
|
if (typeof console !== "undefined") {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/missing-component.tsx"],"sourcesContent":["/*\n * Default fallback rendered when an instance references a component\n * not present in the Config.\n *\n * Behavior: a visible debug box when `debug` is on, silent null otherwise.\n * The console.warn fires either way so the miss is never fully silent.\n * Customers can override per-render via <ExperienceRenderer renderUnknown=...>.\n */\n'use client';\n\nimport type { ReactNode } from 'react';\n\nimport { useExperience } from './context';\n\nexport interface MissingComponentProps {\n componentId: string;\n /** Optional β only present when the payload supplied an id for this node. */\n nodeId?: string;\n}\n\nexport function MissingComponent({ componentId, nodeId }: MissingComponentProps): ReactNode {\n const { debug } = useExperience();\n if (typeof console !== 'undefined') {\n const idLabel = nodeId ? ` (nodeId: ${nodeId})` : '';\n console.warn(\n `[@contentful/experiences] No component registered for id \"${componentId}\"${idLabel}.`\n );\n }\n if (!debug) return null;\n // In debug mode the fallback is richer than a bare red box: it surfaces the\n // exact registration the customer needs to add (componentId) and the\n // node id so a miss in a large tree is locatable.\n return (\n <div\n style={{\n border: '2px solid red',\n padding: '1rem',\n color: 'red',\n background: '#fff',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.8125rem',\n }}\n data-experiences-missing={componentId}\n >\n <strong>Missing component ‘{componentId}’</strong>\n <p style={{ margin: '0.5rem 0' }}>\n This component is referenced by the Experience payload but is not registered in the Config.\n Register it under this key in your <code>components</code> map:\n </p>\n <pre style={{ margin: 0, whiteSpace: 'pre-wrap' }}>\n {JSON.stringify({ componentId, nodeId: nodeId ?? null }, null, 2)}\n </pre>\n </div>\n );\n}\n"],"mappings":";AA4CM,SAGqC,KAHrC;AAhCN,SAAS,qBAAqB;AAQvB,SAAS,iBAAiB,EAAE,aAAa,OAAO,GAAqC;AAC1F,QAAM,EAAE,MAAM,IAAI,cAAc;AAChC,MAAI,OAAO,YAAY,aAAa;AAClC,UAAM,UAAU,SAAS,aAAa,MAAM,MAAM;AAClD,YAAQ;AAAA,MACN,6DAA6D,WAAW,IAAI,OAAO;AAAA,IACrF;AAAA,EACF;AACA,MAAI,CAAC,MAAO,QAAO;AAInB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,4BAA0B;AAAA,MAE1B;AAAA,6BAAC,YAAO;AAAA;AAAA,UAA0B;AAAA,UAAY;AAAA,WAAO;AAAA,QACrD,qBAAC,OAAE,OAAO,EAAE,QAAQ,WAAW,GAAG;AAAA;AAAA,UAEG,oBAAC,UAAK,wBAAU;AAAA,UAAO;AAAA,WAC5D;AAAA,QACA,oBAAC,SAAI,OAAO,EAAE,QAAQ,GAAG,YAAY,WAAW,GAC7C,eAAK,UAAU,EAAE,aAAa,QAAQ,UAAU,KAAK,GAAG,MAAM,CAAC,GAClE;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/missing-component.tsx"],"sourcesContent":["/*\n * Default fallback rendered when an instance references a component\n * not present in the Config.\n *\n * Behavior: a visible debug box when `debug` is on, silent null otherwise.\n * The console.warn fires either way so the miss is never fully silent.\n * Customers can override per-render via <ExperienceRenderer renderUnknown=...>.\n */\n'use client';\n\nimport type { ReactNode } from 'react';\n\nimport { useExperience } from './context.js';\n\nexport interface MissingComponentProps {\n componentId: string;\n /** Optional β only present when the payload supplied an id for this node. */\n nodeId?: string;\n}\n\nexport function MissingComponent({ componentId, nodeId }: MissingComponentProps): ReactNode {\n const { debug } = useExperience();\n if (typeof console !== 'undefined') {\n const idLabel = nodeId ? ` (nodeId: ${nodeId})` : '';\n console.warn(\n `[@contentful/experiences] No component registered for id \"${componentId}\"${idLabel}.`\n );\n }\n if (!debug) return null;\n // In debug mode the fallback is richer than a bare red box: it surfaces the\n // exact registration the customer needs to add (componentId) and the\n // node id so a miss in a large tree is locatable.\n return (\n <div\n style={{\n border: '2px solid red',\n padding: '1rem',\n color: 'red',\n background: '#fff',\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: '0.8125rem',\n }}\n data-experiences-missing={componentId}\n >\n <strong>Missing component ‘{componentId}’</strong>\n <p style={{ margin: '0.5rem 0' }}>\n This component is referenced by the Experience payload but is not registered in the Config.\n Register it under this key in your <code>components</code> map:\n </p>\n <pre style={{ margin: 0, whiteSpace: 'pre-wrap' }}>\n {JSON.stringify({ componentId, nodeId: nodeId ?? null }, null, 2)}\n </pre>\n </div>\n );\n}\n"],"mappings":";AA4CM,SAGqC,KAHrC;AAhCN,SAAS,qBAAqB;AAQvB,SAAS,iBAAiB,EAAE,aAAa,OAAO,GAAqC;AAC1F,QAAM,EAAE,MAAM,IAAI,cAAc;AAChC,MAAI,OAAO,YAAY,aAAa;AAClC,UAAM,UAAU,SAAS,aAAa,MAAM,MAAM;AAClD,YAAQ;AAAA,MACN,6DAA6D,WAAW,IAAI,OAAO;AAAA,IACrF;AAAA,EACF;AACA,MAAI,CAAC,MAAO,QAAO;AAInB,SACE;AAAA,IAAC;AAAA;AAAA,MACC,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO;AAAA,QACP,YAAY;AAAA,QACZ,YAAY;AAAA,QACZ,UAAU;AAAA,MACZ;AAAA,MACA,4BAA0B;AAAA,MAE1B;AAAA,6BAAC,YAAO;AAAA;AAAA,UAA0B;AAAA,UAAY;AAAA,WAAO;AAAA,QACrD,qBAAC,OAAE,OAAO,EAAE,QAAQ,WAAW,GAAG;AAAA;AAAA,UAEG,oBAAC,UAAK,wBAAU;AAAA,UAAO;AAAA,WAC5D;AAAA,QACA,oBAAC,SAAI,OAAO,EAAE,QAAQ,GAAG,YAAY,WAAW,GAC7C,eAAK,UAAU,EAAE,aAAa,QAAQ,UAAU,KAAK,GAAG,MAAM,CAAC,GAClE;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
package/dist/nodes-renderer.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment, createElement } from "react";
|
|
3
|
-
import { ComponentErrorBoundary } from "./component-error-boundary";
|
|
3
|
+
import { ComponentErrorBoundary } from "./component-error-boundary.js";
|
|
4
4
|
import {
|
|
5
5
|
ContentfulComponentProvider,
|
|
6
6
|
ContentfulExperienceTemplateProvider,
|
|
7
7
|
ResolvedDesignProvider
|
|
8
|
-
} from "./context";
|
|
8
|
+
} from "./context.js";
|
|
9
9
|
import {
|
|
10
10
|
normalizeComponentRegistration,
|
|
11
11
|
normalizeExperienceTemplateRegistration
|
|
12
|
-
} from "./types";
|
|
12
|
+
} from "./types.js";
|
|
13
13
|
function NodesRenderer({
|
|
14
14
|
nodes,
|
|
15
15
|
config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/nodes-renderer.tsx"],"sourcesContent":["/*\n * Recursive renderer over PortableRenderNodes. Resolved design values auto-fill\n * matching props (below content/resolveData) and are also available via\n * `useDesignValues()`.\n */\n\nimport { Fragment, createElement, type ReactNode } from 'react';\n\nimport type { PortableRenderNode } from '@contentful/experiences-sdk-core';\n\nimport { ComponentErrorBoundary } from './component-error-boundary';\nimport type { ComponentErrorProps } from './component-error';\nimport {\n ContentfulComponentProvider,\n ContentfulExperienceTemplateProvider,\n ResolvedDesignProvider,\n} from './context';\nimport type { MissingComponentProps } from './missing-component';\nimport {\n normalizeComponentRegistration,\n normalizeExperienceTemplateRegistration,\n type ContentfulComponent,\n type ContentfulExperienceTemplate,\n type Config,\n} from './types';\n\nexport type RenderUnknown = (props: MissingComponentProps) => ReactNode;\nexport type RenderError = (props: ComponentErrorProps) => ReactNode;\n\n/**\n * Reports one render-time diagnostic (unregistered id, a component that\n * threw). `ServerExperienceRenderer` passes a closure that pushes onto a\n * plain array (SSR is synchronous top-down, so the array is fully populated\n * by the time `<DebugExperience>` reads it β see the element-order note\n * there). `ClientExperienceRenderer` passes a `setState` updater instead, so\n * `<DebugExperience>` re-renders reactively when a later interaction throws.\n */\nexport type DiagnosticReporter = (error: Error) => void;\n\nexport interface NodesRendererProps {\n nodes: PortableRenderNode[];\n config: Config;\n renderUnknown: RenderUnknown;\n renderError: RenderError;\n onDiagnostic: DiagnosticReporter;\n}\n\nexport function NodesRenderer({\n nodes,\n config,\n renderUnknown,\n renderError,\n onDiagnostic,\n}: NodesRendererProps): ReactNode {\n if (!nodes.length) return null;\n return (\n <Fragment>\n {nodes.map((node, index) => (\n <NodeRenderer\n key={node.nodeId ?? index}\n node={node}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n ))}\n </Fragment>\n );\n}\n\ninterface NodeRendererProps {\n node: PortableRenderNode;\n config: Config;\n renderUnknown: RenderUnknown;\n renderError: RenderError;\n onDiagnostic: DiagnosticReporter;\n}\n\nfunction NodeRenderer({\n node,\n config,\n renderUnknown,\n renderError,\n onDiagnostic,\n}: NodeRendererProps): ReactNode {\n const { kind, id } = node.registration;\n const isExperienceTemplate = kind === 'experienceTemplate';\n\n // Diagnostics are reported straight to `onDiagnostic`, synchronously during\n // render. Deliberate: this component is shared between SSR and CSR, and\n // `useEffect` never runs during `renderToStaticMarkup`/streaming SSR β an\n // effect-deferred report would silently vanish on the server.\n //\n // Dedup lives in `onDiagnostic` (see both renderers), not here. An ancestor\n // re-render re-executes this whole function, so an unregistered id or\n // malformed slot would otherwise be re-reported every time β the collectors\n // drop a message they already hold. Keeping the guard there rather than in a\n // `useRef` is what lets this module stay hook-free, and therefore usable from\n // a React Server Component: `ServerExperienceRenderer` renders it without a\n // `'use client'` boundary, which is what keeps `config` (component\n // references, unserializable) from having to cross one.\n\n // Pre-render each slot's children as an *array* of ReactNodes (one keyed\n // element per child), not a single wrapping node. A component can drop the\n // array straight into JSX for the common \"just render them\" case (React\n // renders keyed arrays), or map/filter/wrap the children individually.\n //\n // Slot name β prop name, for both node kinds: a coded Experience Template\n // declaring a `content` slot receives a `content` prop. `children` is not a\n // special case, just the conventional default slot name.\n const slotProps: Record<string, ReactNode[]> = {};\n for (const [slotName, children] of Object.entries(node.slots)) {\n // Defensive: `node.slots[x]` is typed as an array, but a hand-built\n // PortableRenderPlan (a supported path β customers can construct one\n // directly instead of going through `resolveExperience`) is not\n // type-checked at runtime. Warn + drop rather than letting `.map` throw.\n if (!Array.isArray(children)) {\n const message =\n `Slot \"${slotName}\" on ${kind} \"${id}\"${node.nodeId ? ` (node \"${node.nodeId}\")` : ''} ` +\n `is not an array of nodes; rendering it as empty instead of throwing.`;\n if (typeof console !== 'undefined') {\n console.warn(`[@contentful/experiences-react] ${message}`);\n }\n onDiagnostic(new Error(message));\n slotProps[slotName] = [];\n continue;\n }\n slotProps[slotName] = children.map((child, index) => (\n <NodeRenderer\n key={child.nodeId ?? index}\n node={child}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n ));\n }\n\n const entry = isExperienceTemplate ? config.experienceTemplates?.[id] : config.components[id];\n if (!entry) {\n // An unregistered Experience Template would blank the page if we swapped\n // it for the missing-component box, so warn and render its slot children\n // unwrapped β the content survives, the diagnostic names what's missing.\n if (isExperienceTemplate) {\n const message = `No experience template registered for id \"${id}\". Rendering its slot children without the experience template wrapper.`;\n if (typeof console !== 'undefined') {\n console.warn(`[@contentful/experiences-react] ${message}`);\n }\n onDiagnostic(new Error(message));\n return <Fragment>{Object.values(slotProps).flat()}</Fragment>;\n }\n // `MissingComponent` (the default `renderUnknown`) does its own\n // console.warn; a custom override may not, so the diagnostic is recorded\n // here regardless of which fallback ends up rendering.\n onDiagnostic(\n new Error(\n `No component registered for id \"${id}\"${node.nodeId ? ` (nodeId: ${node.nodeId})` : ''}.`\n )\n );\n return createElement(renderUnknown, { componentId: id, nodeId: node.nodeId });\n }\n const registrationConfig = isExperienceTemplate\n ? normalizeExperienceTemplateRegistration(entry)\n : normalizeComponentRegistration(entry);\n\n const tokenResolvedDesign = node.props.design;\n\n // Merge precedence (last wins): defaults < design < content < resolveData < slots.\n const composed = {\n ...registrationConfig.defaults,\n ...tokenResolvedDesign,\n ...node.props.content,\n ...node.props.resolved,\n ...slotProps,\n };\n\n const element = (\n <ResolvedDesignProvider value={tokenResolvedDesign}>\n <ComponentErrorBoundary\n fallback={createElement(renderError, { componentId: id, nodeId: node.nodeId })}\n componentId={id}\n kind={kind}\n nodeId={node.nodeId}\n >\n {createElement(registrationConfig.component, composed)}\n </ComponentErrorBoundary>\n </ResolvedDesignProvider>\n );\n\n if (isExperienceTemplate) {\n const contentful: ContentfulExperienceTemplate = {\n experienceTemplateId: id,\n nodeId: node.nodeId,\n content: node.props.content,\n design: node.props.designRaw,\n resolved: node.props.resolved,\n attribution: node.attribution,\n };\n return (\n <ContentfulExperienceTemplateProvider value={contentful}>\n {element}\n </ContentfulExperienceTemplateProvider>\n );\n }\n\n const contentful: ContentfulComponent = {\n componentId: id,\n nodeId: node.nodeId,\n content: node.props.content,\n design: node.props.designRaw,\n resolved: node.props.resolved,\n attribution: node.attribution,\n };\n return <ContentfulComponentProvider value={contentful}>{element}</ContentfulComponentProvider>;\n}\n\n// `ComponentErrorBoundary` lives in its own `'use client'` file β see\n// component-error-boundary.tsx for why (it's a class component, which\n// Next.js's RSC bundler rejects from a directive-free file).\n"],"mappings":"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","names":["contentful"]}
|
|
1
|
+
{"version":3,"sources":["../src/nodes-renderer.tsx"],"sourcesContent":["/*\n * Recursive renderer over PortableRenderNodes. Resolved design values auto-fill\n * matching props (below content/resolveData) and are also available via\n * `useDesignValues()`.\n */\n\nimport { Fragment, createElement, type ReactNode } from 'react';\n\nimport type { PortableRenderNode } from '@contentful/experiences-sdk-core';\n\nimport { ComponentErrorBoundary } from './component-error-boundary.js';\nimport type { ComponentErrorProps } from './component-error.js';\nimport {\n ContentfulComponentProvider,\n ContentfulExperienceTemplateProvider,\n ResolvedDesignProvider,\n} from './context.js';\nimport type { MissingComponentProps } from './missing-component.js';\nimport {\n normalizeComponentRegistration,\n normalizeExperienceTemplateRegistration,\n type ContentfulComponent,\n type ContentfulExperienceTemplate,\n type Config,\n} from './types.js';\n\nexport type RenderUnknown = (props: MissingComponentProps) => ReactNode;\nexport type RenderError = (props: ComponentErrorProps) => ReactNode;\n\n/**\n * Reports one render-time diagnostic (unregistered id, a component that\n * threw). `ServerExperienceRenderer` passes a closure that pushes onto a\n * plain array (SSR is synchronous top-down, so the array is fully populated\n * by the time `<DebugExperience>` reads it β see the element-order note\n * there). `ClientExperienceRenderer` passes a `setState` updater instead, so\n * `<DebugExperience>` re-renders reactively when a later interaction throws.\n */\nexport type DiagnosticReporter = (error: Error) => void;\n\nexport interface NodesRendererProps {\n nodes: PortableRenderNode[];\n config: Config;\n renderUnknown: RenderUnknown;\n renderError: RenderError;\n onDiagnostic: DiagnosticReporter;\n}\n\nexport function NodesRenderer({\n nodes,\n config,\n renderUnknown,\n renderError,\n onDiagnostic,\n}: NodesRendererProps): ReactNode {\n if (!nodes.length) return null;\n return (\n <Fragment>\n {nodes.map((node, index) => (\n <NodeRenderer\n key={node.nodeId ?? index}\n node={node}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n ))}\n </Fragment>\n );\n}\n\ninterface NodeRendererProps {\n node: PortableRenderNode;\n config: Config;\n renderUnknown: RenderUnknown;\n renderError: RenderError;\n onDiagnostic: DiagnosticReporter;\n}\n\nfunction NodeRenderer({\n node,\n config,\n renderUnknown,\n renderError,\n onDiagnostic,\n}: NodeRendererProps): ReactNode {\n const { kind, id } = node.registration;\n const isExperienceTemplate = kind === 'experienceTemplate';\n\n // Diagnostics are reported straight to `onDiagnostic`, synchronously during\n // render. Deliberate: this component is shared between SSR and CSR, and\n // `useEffect` never runs during `renderToStaticMarkup`/streaming SSR β an\n // effect-deferred report would silently vanish on the server.\n //\n // Dedup lives in `onDiagnostic` (see both renderers), not here. An ancestor\n // re-render re-executes this whole function, so an unregistered id or\n // malformed slot would otherwise be re-reported every time β the collectors\n // drop a message they already hold. Keeping the guard there rather than in a\n // `useRef` is what lets this module stay hook-free, and therefore usable from\n // a React Server Component: `ServerExperienceRenderer` renders it without a\n // `'use client'` boundary, which is what keeps `config` (component\n // references, unserializable) from having to cross one.\n\n // Pre-render each slot's children as an *array* of ReactNodes (one keyed\n // element per child), not a single wrapping node. A component can drop the\n // array straight into JSX for the common \"just render them\" case (React\n // renders keyed arrays), or map/filter/wrap the children individually.\n //\n // Slot name β prop name, for both node kinds: a coded Experience Template\n // declaring a `content` slot receives a `content` prop. `children` is not a\n // special case, just the conventional default slot name.\n const slotProps: Record<string, ReactNode[]> = {};\n for (const [slotName, children] of Object.entries(node.slots)) {\n // Defensive: `node.slots[x]` is typed as an array, but a hand-built\n // PortableRenderPlan (a supported path β customers can construct one\n // directly instead of going through `resolveExperience`) is not\n // type-checked at runtime. Warn + drop rather than letting `.map` throw.\n if (!Array.isArray(children)) {\n const message =\n `Slot \"${slotName}\" on ${kind} \"${id}\"${node.nodeId ? ` (node \"${node.nodeId}\")` : ''} ` +\n `is not an array of nodes; rendering it as empty instead of throwing.`;\n if (typeof console !== 'undefined') {\n console.warn(`[@contentful/experiences-react] ${message}`);\n }\n onDiagnostic(new Error(message));\n slotProps[slotName] = [];\n continue;\n }\n slotProps[slotName] = children.map((child, index) => (\n <NodeRenderer\n key={child.nodeId ?? index}\n node={child}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n ));\n }\n\n const entry = isExperienceTemplate ? config.experienceTemplates?.[id] : config.components[id];\n if (!entry) {\n // An unregistered Experience Template would blank the page if we swapped\n // it for the missing-component box, so warn and render its slot children\n // unwrapped β the content survives, the diagnostic names what's missing.\n if (isExperienceTemplate) {\n const message = `No experience template registered for id \"${id}\". Rendering its slot children without the experience template wrapper.`;\n if (typeof console !== 'undefined') {\n console.warn(`[@contentful/experiences-react] ${message}`);\n }\n onDiagnostic(new Error(message));\n return <Fragment>{Object.values(slotProps).flat()}</Fragment>;\n }\n // `MissingComponent` (the default `renderUnknown`) does its own\n // console.warn; a custom override may not, so the diagnostic is recorded\n // here regardless of which fallback ends up rendering.\n onDiagnostic(\n new Error(\n `No component registered for id \"${id}\"${node.nodeId ? ` (nodeId: ${node.nodeId})` : ''}.`\n )\n );\n return createElement(renderUnknown, { componentId: id, nodeId: node.nodeId });\n }\n const registrationConfig = isExperienceTemplate\n ? normalizeExperienceTemplateRegistration(entry)\n : normalizeComponentRegistration(entry);\n\n const tokenResolvedDesign = node.props.design;\n\n // Merge precedence (last wins): defaults < design < content < resolveData < slots.\n const composed = {\n ...registrationConfig.defaults,\n ...tokenResolvedDesign,\n ...node.props.content,\n ...node.props.resolved,\n ...slotProps,\n };\n\n const element = (\n <ResolvedDesignProvider value={tokenResolvedDesign}>\n <ComponentErrorBoundary\n fallback={createElement(renderError, { componentId: id, nodeId: node.nodeId })}\n componentId={id}\n kind={kind}\n nodeId={node.nodeId}\n >\n {createElement(registrationConfig.component, composed)}\n </ComponentErrorBoundary>\n </ResolvedDesignProvider>\n );\n\n if (isExperienceTemplate) {\n const contentful: ContentfulExperienceTemplate = {\n experienceTemplateId: id,\n nodeId: node.nodeId,\n content: node.props.content,\n design: node.props.designRaw,\n resolved: node.props.resolved,\n attribution: node.attribution,\n };\n return (\n <ContentfulExperienceTemplateProvider value={contentful}>\n {element}\n </ContentfulExperienceTemplateProvider>\n );\n }\n\n const contentful: ContentfulComponent = {\n componentId: id,\n nodeId: node.nodeId,\n content: node.props.content,\n design: node.props.designRaw,\n resolved: node.props.resolved,\n attribution: node.attribution,\n };\n return <ContentfulComponentProvider value={contentful}>{element}</ContentfulComponentProvider>;\n}\n\n// `ComponentErrorBoundary` lives in its own `'use client'` file β see\n// component-error-boundary.tsx for why (it's a class component, which\n// Next.js's RSC bundler rejects from a directive-free file).\n"],"mappings":"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","names":["contentful"]}
|
package/dist/server-renderer.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { ComponentError } from "./component-error";
|
|
3
|
-
import { DebugExperience } from "./debug-experience";
|
|
4
|
-
import { ExperienceProvider } from "./context";
|
|
5
|
-
import { MissingComponent } from "./missing-component";
|
|
6
|
-
import { NodesRenderer } from "./nodes-renderer";
|
|
2
|
+
import { ComponentError } from "./component-error.js";
|
|
3
|
+
import { DebugExperience } from "./debug-experience.js";
|
|
4
|
+
import { ExperienceProvider } from "./context.js";
|
|
5
|
+
import { MissingComponent } from "./missing-component.js";
|
|
6
|
+
import { NodesRenderer } from "./nodes-renderer.js";
|
|
7
7
|
const DEFAULT_CONTEXT = {
|
|
8
8
|
debug: false,
|
|
9
9
|
metadata: {}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/server-renderer.tsx"],"sourcesContent":["/*\n * Server-safe Experience renderer. It renders the resolved plan directly.\n */\n\nimport type { ReactNode } from 'react';\n\nimport type { ExperienceContext, PortableRenderPlan } from '@contentful/experiences-sdk-core';\n\nimport { ComponentError } from './component-error';\nimport { DebugExperience } from './debug-experience';\nimport { ExperienceProvider } from './context';\nimport { MissingComponent } from './missing-component';\nimport { NodesRenderer, type RenderError, type RenderUnknown } from './nodes-renderer';\nimport type { Config, RenderContext } from './types';\n\nconst DEFAULT_CONTEXT: ExperienceContext = {\n debug: false,\n metadata: {},\n};\n\nexport interface ServerExperienceRendererProps {\n experience: PortableRenderPlan | null | undefined;\n config: Config;\n /** Shallow-merges over the plan's `metadata`. Only needed to override it. */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: renders the visible missing-component box,\n * turns the default `renderUnknown` fallback into the debug component, and\n * auto-mounts `<DebugExperience>` (the resolved-plan JSON panel) after the\n * tree. Defaults to the plan's `debug`.\n */\n debug?: boolean;\n /** Override the fallback rendered for unregistered component types. */\n renderUnknown?: RenderUnknown;\n /** Override the fallback rendered when a registered component throws. */\n renderError?: RenderError;\n}\n\nexport function ServerExperienceRenderer({\n experience,\n config,\n metadata,\n debug,\n renderUnknown = MissingComponent,\n renderError = ComponentError,\n}: ServerExperienceRendererProps): ReactNode {\n if (!experience) return null;\n\n // `??`, not `||`, so an explicit `debug={false}` overrides a debug-on plan.\n const resolvedDebug = debug ?? experience.debug;\n const renderContext: RenderContext = {\n ...DEFAULT_CONTEXT,\n debug: resolvedDebug,\n metadata: { ...DEFAULT_CONTEXT.metadata, ...experience.metadata, ...(metadata ?? {}) },\n };\n\n // Render-time diagnostics (unregistered id, a component that threw),\n // collected into a plain array rather than React state: SSR is synchronous\n // top-down, so by the time `<DebugExperience>` renders β after the tree,\n // see the element-order note below β this array is already fully populated.\n // Seeded with the resolve-time diagnostics up front rather than spreading\n // them in later: `<DebugExperience>` below reads this array by reference\n // (`errors={renderDiagnostics}`), not a spread copy β a copy would be built\n // right here, before React ever renders `tree` and gets a chance to push\n // into it.\n const renderDiagnostics: Error[] = [...(experience.diagnostics ?? [])];\n // Dedup by message, the guard `NodeRenderer` used to hold in a `useRef`. It\n // lives here so that module stays hook-free and therefore server-renderable.\n // One pass on the server, so this mostly guards a node that reports the same\n // message from several slots.\n const seenDiagnostics = new Set(renderDiagnostics.map((error) => error.message));\n const onDiagnostic = (error: Error): void => {\n if (seenDiagnostics.has(error.message)) return;\n seenDiagnostics.add(error.message);\n renderDiagnostics.push(error);\n };\n\n const tree = (\n <NodesRenderer\n nodes={experience.nodes}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n );\n\n // The node tree renders BEFORE `<DebugExperience>` β required, not\n // stylistic. React's render is synchronous top-down; if DebugExperience\n // rendered first (as it used to), it would read `renderDiagnostics` before\n // any descendant had a chance to push into it, and always see it empty.\n return (\n <ExperienceProvider value={renderContext}>\n {tree}\n {resolvedDebug ? (\n <DebugExperience experience={experience} errors={renderDiagnostics} />\n ) : null}\n </ExperienceProvider>\n );\n}\n"],"mappings":"AA8EI,cAcA,YAdA;AAtEJ,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,qBAA2D;AAGpE,MAAM,kBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,UAAU,CAAC;AACb;AAoBO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAChB,GAA6C;AAC3C,MAAI,CAAC,WAAY,QAAO;AAGxB,QAAM,gBAAgB,SAAS,WAAW;AAC1C,QAAM,gBAA+B;AAAA,IACnC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU,EAAE,GAAG,gBAAgB,UAAU,GAAG,WAAW,UAAU,GAAI,YAAY,CAAC,EAAG;AAAA,EACvF;AAWA,QAAM,oBAA6B,CAAC,GAAI,WAAW,eAAe,CAAC,CAAE;AAKrE,QAAM,kBAAkB,IAAI,IAAI,kBAAkB,IAAI,CAAC,UAAU,MAAM,OAAO,CAAC;AAC/E,QAAM,eAAe,CAAC,UAAuB;AAC3C,QAAI,gBAAgB,IAAI,MAAM,OAAO,EAAG;AACxC,oBAAgB,IAAI,MAAM,OAAO;AACjC,sBAAkB,KAAK,KAAK;AAAA,EAC9B;AAEA,QAAM,OACJ;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,WAAW;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAOF,SACE,qBAAC,sBAAmB,OAAO,eACxB;AAAA;AAAA,IACA,gBACC,oBAAC,mBAAgB,YAAwB,QAAQ,mBAAmB,IAClE;AAAA,KACN;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/server-renderer.tsx"],"sourcesContent":["/*\n * Server-safe Experience renderer. It renders the resolved plan directly.\n */\n\nimport type { ReactNode } from 'react';\n\nimport type { ExperienceContext, PortableRenderPlan } from '@contentful/experiences-sdk-core';\n\nimport { ComponentError } from './component-error.js';\nimport { DebugExperience } from './debug-experience.js';\nimport { ExperienceProvider } from './context.js';\nimport { MissingComponent } from './missing-component.js';\nimport { NodesRenderer, type RenderError, type RenderUnknown } from './nodes-renderer.js';\nimport type { Config, RenderContext } from './types.js';\n\nconst DEFAULT_CONTEXT: ExperienceContext = {\n debug: false,\n metadata: {},\n};\n\nexport interface ServerExperienceRendererProps {\n experience: PortableRenderPlan | null | undefined;\n config: Config;\n /** Shallow-merges over the plan's `metadata`. Only needed to override it. */\n metadata?: Record<string, unknown>;\n /**\n * Observability switch. When on: renders the visible missing-component box,\n * turns the default `renderUnknown` fallback into the debug component, and\n * auto-mounts `<DebugExperience>` (the resolved-plan JSON panel) after the\n * tree. Defaults to the plan's `debug`.\n */\n debug?: boolean;\n /** Override the fallback rendered for unregistered component types. */\n renderUnknown?: RenderUnknown;\n /** Override the fallback rendered when a registered component throws. */\n renderError?: RenderError;\n}\n\nexport function ServerExperienceRenderer({\n experience,\n config,\n metadata,\n debug,\n renderUnknown = MissingComponent,\n renderError = ComponentError,\n}: ServerExperienceRendererProps): ReactNode {\n if (!experience) return null;\n\n // `??`, not `||`, so an explicit `debug={false}` overrides a debug-on plan.\n const resolvedDebug = debug ?? experience.debug;\n const renderContext: RenderContext = {\n ...DEFAULT_CONTEXT,\n debug: resolvedDebug,\n metadata: { ...DEFAULT_CONTEXT.metadata, ...experience.metadata, ...(metadata ?? {}) },\n };\n\n // Render-time diagnostics (unregistered id, a component that threw),\n // collected into a plain array rather than React state: SSR is synchronous\n // top-down, so by the time `<DebugExperience>` renders β after the tree,\n // see the element-order note below β this array is already fully populated.\n // Seeded with the resolve-time diagnostics up front rather than spreading\n // them in later: `<DebugExperience>` below reads this array by reference\n // (`errors={renderDiagnostics}`), not a spread copy β a copy would be built\n // right here, before React ever renders `tree` and gets a chance to push\n // into it.\n const renderDiagnostics: Error[] = [...(experience.diagnostics ?? [])];\n // Dedup by message, the guard `NodeRenderer` used to hold in a `useRef`. It\n // lives here so that module stays hook-free and therefore server-renderable.\n // One pass on the server, so this mostly guards a node that reports the same\n // message from several slots.\n const seenDiagnostics = new Set(renderDiagnostics.map((error) => error.message));\n const onDiagnostic = (error: Error): void => {\n if (seenDiagnostics.has(error.message)) return;\n seenDiagnostics.add(error.message);\n renderDiagnostics.push(error);\n };\n\n const tree = (\n <NodesRenderer\n nodes={experience.nodes}\n config={config}\n renderUnknown={renderUnknown}\n renderError={renderError}\n onDiagnostic={onDiagnostic}\n />\n );\n\n // The node tree renders BEFORE `<DebugExperience>` β required, not\n // stylistic. React's render is synchronous top-down; if DebugExperience\n // rendered first (as it used to), it would read `renderDiagnostics` before\n // any descendant had a chance to push into it, and always see it empty.\n return (\n <ExperienceProvider value={renderContext}>\n {tree}\n {resolvedDebug ? (\n <DebugExperience experience={experience} errors={renderDiagnostics} />\n ) : null}\n </ExperienceProvider>\n );\n}\n"],"mappings":"AA8EI,cAcA,YAdA;AAtEJ,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AACjC,SAAS,qBAA2D;AAGpE,MAAM,kBAAqC;AAAA,EACzC,OAAO;AAAA,EACP,UAAU,CAAC;AACb;AAoBO,SAAS,yBAAyB;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,gBAAgB;AAAA,EAChB,cAAc;AAChB,GAA6C;AAC3C,MAAI,CAAC,WAAY,QAAO;AAGxB,QAAM,gBAAgB,SAAS,WAAW;AAC1C,QAAM,gBAA+B;AAAA,IACnC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,UAAU,EAAE,GAAG,gBAAgB,UAAU,GAAG,WAAW,UAAU,GAAI,YAAY,CAAC,EAAG;AAAA,EACvF;AAWA,QAAM,oBAA6B,CAAC,GAAI,WAAW,eAAe,CAAC,CAAE;AAKrE,QAAM,kBAAkB,IAAI,IAAI,kBAAkB,IAAI,CAAC,UAAU,MAAM,OAAO,CAAC;AAC/E,QAAM,eAAe,CAAC,UAAuB;AAC3C,QAAI,gBAAgB,IAAI,MAAM,OAAO,EAAG;AACxC,oBAAgB,IAAI,MAAM,OAAO;AACjC,sBAAkB,KAAK,KAAK;AAAA,EAC9B;AAEA,QAAM,OACJ;AAAA,IAAC;AAAA;AAAA,MACC,OAAO,WAAW;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EACF;AAOF,SACE,qBAAC,sBAAmB,OAAO,eACxB;AAAA;AAAA,IACA,gBACC,oBAAC,mBAAgB,YAAwB,QAAQ,mBAAmB,IAClE;AAAA,KACN;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-design-values.tsx"],"sourcesContent":["'use client';\n\nimport { useResolvedDesign } from './context';\n\n/**\n * Read the current node's token-resolved design values. Returns `{}` when\n * there's no design in scope.\n *\n * Pass a type argument to shape the bag, like `useState<T>()`:\n *\n * const design = useDesignValues<{ as?: 'h1' | 'h2' }>();\n *\n * `T` is a convenience assertion, not validated at runtime β treat keys as\n * possibly `undefined`.\n */\nexport function useDesignValues<T extends object = Record<string, unknown>>(): T {\n return (useResolvedDesign() ?? {}) as T;\n}\n"],"mappings":";AAEA,SAAS,yBAAyB;AAa3B,SAAS,kBAAiE;AAC/E,SAAQ,kBAAkB,KAAK,CAAC;AAClC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/use-design-values.tsx"],"sourcesContent":["'use client';\n\nimport { useResolvedDesign } from './context.js';\n\n/**\n * Read the current node's token-resolved design values. Returns `{}` when\n * there's no design in scope.\n *\n * Pass a type argument to shape the bag, like `useState<T>()`:\n *\n * const design = useDesignValues<{ as?: 'h1' | 'h2' }>();\n *\n * `T` is a convenience assertion, not validated at runtime β treat keys as\n * possibly `undefined`.\n */\nexport function useDesignValues<T extends object = Record<string, unknown>>(): T {\n return (useResolvedDesign() ?? {}) as T;\n}\n"],"mappings":";AAEA,SAAS,yBAAyB;AAa3B,SAAS,kBAAiE;AAC/E,SAAQ,kBAAkB,KAAK,CAAC;AAClC;","names":[]}
|
package/dist/use-live-preview.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useLivePreviewExperience } from "./use-live-preview-experience";
|
|
3
|
-
import { useExperiencePlan } from "./use-experience-plan";
|
|
2
|
+
import { useLivePreviewExperience } from "./use-live-preview-experience.js";
|
|
3
|
+
import { useExperiencePlan } from "./use-experience-plan.js";
|
|
4
4
|
function useLivePreview(options) {
|
|
5
5
|
const livePreview = useLivePreviewExperience({
|
|
6
6
|
previewSessionOptions: options.previewSessionOptions,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/use-live-preview.ts"],"sourcesContent":["'use client';\n\nimport type { ExperiencePayload, PortableRenderPlan } from '@contentful/experiences-sdk-core';\nimport type { PreviewSessionOptions } from '@contentful/experiences-live-preview';\n\nimport { useLivePreviewExperience } from './use-live-preview-experience';\nimport { useExperiencePlan, type ExperiencePlanResolveOptions } from './use-experience-plan';\n\nexport interface UseLivePreviewOptions {\n previewSessionOptions?: PreviewSessionOptions;\n initialPayload?: ExperiencePayload;\n initialPlan?: PortableRenderPlan;\n resolveOptions: ExperiencePlanResolveOptions;\n}\n\nexport interface UseLivePreviewResult {\n readonly data: PortableRenderPlan | undefined;\n readonly error: Error | undefined;\n}\n\nexport function useLivePreview(options: UseLivePreviewOptions): UseLivePreviewResult {\n const livePreview = useLivePreviewExperience({\n previewSessionOptions: options.previewSessionOptions,\n initialPayload: options.initialPayload,\n });\n\n const plan = useExperiencePlan({\n payload: livePreview.data,\n initialPlan: options.initialPlan,\n resolveOptions: options.resolveOptions,\n });\n\n return { data: plan.data, error: livePreview.error };\n}\n"],"mappings":";AAKA,SAAS,gCAAgC;AACzC,SAAS,yBAA4D;AAc9D,SAAS,eAAe,SAAsD;AACnF,QAAM,cAAc,yBAAyB;AAAA,IAC3C,uBAAuB,QAAQ;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,EAC1B,CAAC;AAED,QAAM,OAAO,kBAAkB;AAAA,IAC7B,SAAS,YAAY;AAAA,IACrB,aAAa,QAAQ;AAAA,IACrB,gBAAgB,QAAQ;AAAA,EAC1B,CAAC;AAED,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,YAAY,MAAM;AACrD;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/use-live-preview.ts"],"sourcesContent":["'use client';\n\nimport type { ExperiencePayload, PortableRenderPlan } from '@contentful/experiences-sdk-core';\nimport type { PreviewSessionOptions } from '@contentful/experiences-live-preview';\n\nimport { useLivePreviewExperience } from './use-live-preview-experience.js';\nimport { useExperiencePlan, type ExperiencePlanResolveOptions } from './use-experience-plan.js';\n\nexport interface UseLivePreviewOptions {\n previewSessionOptions?: PreviewSessionOptions;\n initialPayload?: ExperiencePayload;\n initialPlan?: PortableRenderPlan;\n resolveOptions: ExperiencePlanResolveOptions;\n}\n\nexport interface UseLivePreviewResult {\n readonly data: PortableRenderPlan | undefined;\n readonly error: Error | undefined;\n}\n\nexport function useLivePreview(options: UseLivePreviewOptions): UseLivePreviewResult {\n const livePreview = useLivePreviewExperience({\n previewSessionOptions: options.previewSessionOptions,\n initialPayload: options.initialPayload,\n });\n\n const plan = useExperiencePlan({\n payload: livePreview.data,\n initialPlan: options.initialPlan,\n resolveOptions: options.resolveOptions,\n });\n\n return { data: plan.data, error: livePreview.error };\n}\n"],"mappings":";AAKA,SAAS,gCAAgC;AACzC,SAAS,yBAA4D;AAc9D,SAAS,eAAe,SAAsD;AACnF,QAAM,cAAc,yBAAyB;AAAA,IAC3C,uBAAuB,QAAQ;AAAA,IAC/B,gBAAgB,QAAQ;AAAA,EAC1B,CAAC;AAED,QAAM,OAAO,kBAAkB;AAAA,IAC7B,SAAS,YAAY;AAAA,IACrB,aAAa,QAAQ;AAAA,IACrB,gBAAgB,QAAQ;AAAA,EAC1B,CAAC;AAED,SAAO,EAAE,MAAM,KAAK,MAAM,OAAO,YAAY,MAAM;AACrD;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-react",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.5",
|
|
4
4
|
"description": "React adapter for Contentful Experiences β Server and Client renderers over a PortableRenderPlan",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@contentful/experiences-client": "0.9.4",
|
|
34
34
|
"@contentful/experiences-runtime": "0.0.3",
|
|
35
35
|
"@contentful/experiences-sdk-core": "0.12.3",
|
|
36
|
-
"@contentful/experiences-design": "0.12.
|
|
36
|
+
"@contentful/experiences-design": "0.12.3",
|
|
37
37
|
"@contentful/experiences-live-preview": "0.6.4"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|