@contentful/experiences-sdk-react 3.1.1-dev-20250808T0933-3a55c60.0 → 3.1.1-dev-20250811T1516-ddc6cd6.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.
@@ -18,7 +18,7 @@ const ExperienceRoot = ({ locale, experience, visualEditorMode = VisualEditorMod
18
18
  mode,
19
19
  });
20
20
  if (mode === StudioCanvasMode.EDITOR || mode === StudioCanvasMode.READ_ONLY) {
21
- return (jsx(VisualEditorRoot, { experience: experienceObject, visualEditorMode: visualEditorMode, initialLocale: locale }));
21
+ return (jsx(VisualEditorRoot, { experience: experienceObject, visualEditorMode: visualEditorMode, initialLocale: locale, canvasMode: mode }));
22
22
  }
23
23
  if (!experienceObject)
24
24
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"ExperienceRoot.js","sources":["../../src/ExperienceRoot.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport {\n VisualEditorMode,\n createExperience,\n validateExperienceBuilderConfig,\n debug as cfDebug,\n} from '@contentful/experiences-core';\nimport { EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { PreviewDeliveryRoot } from './blocks/preview/PreviewDeliveryRoot';\nimport VisualEditorRoot from './blocks/editor/VisualEditorRoot';\nimport { useDetectCanvasMode } from './hooks/useDetectCanvasMode';\nimport { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\ntype ExperienceRootProps = {\n experience?: Experience<EntityStore> | string | null;\n locale: string;\n visualEditorMode?: VisualEditorMode;\n /** Enables extra logging in the SDK to support troubleshooting.\n * This option is not recommended for production environments as it\n * will result in too many unnecessary logs being produced during runtime.\n * Default: false\n */\n debug?: boolean;\n};\n\nexport const ExperienceRoot = ({\n locale,\n experience,\n visualEditorMode = VisualEditorMode.LazyLoad,\n debug,\n}: ExperienceRootProps) => {\n const mode = useDetectCanvasMode();\n\n if (typeof debug === 'boolean') {\n cfDebug.setEnabled(debug);\n }\n\n //If experience is passed in as a JSON string, recreate it to an experience object\n const experienceObject =\n typeof experience === 'string' ? createExperience(experience) : experience;\n\n validateExperienceBuilderConfig({\n locale,\n mode,\n });\n\n if (mode === StudioCanvasMode.EDITOR || mode === StudioCanvasMode.READ_ONLY) {\n return (\n <VisualEditorRoot\n experience={experienceObject as Experience<EntityStore> | undefined}\n visualEditorMode={visualEditorMode}\n initialLocale={locale}\n />\n );\n }\n\n if (!experienceObject) return null;\n\n return <PreviewDeliveryRoot locale={locale} experience={experienceObject} />;\n};\n"],"names":[],"mappings":";;;;;;;;AA2Ba;AAMX;AAEA;AACE;;;AAIF;AAGA;;;AAGC;AAED;AACE;;AASF;AAAuB;;AAGzB;;"}
1
+ {"version":3,"file":"ExperienceRoot.js","sources":["../../src/ExperienceRoot.tsx"],"sourcesContent":["'use client';\nimport React from 'react';\nimport {\n VisualEditorMode,\n createExperience,\n validateExperienceBuilderConfig,\n debug as cfDebug,\n} from '@contentful/experiences-core';\nimport { EntityStore } from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport { PreviewDeliveryRoot } from './blocks/preview/PreviewDeliveryRoot';\nimport VisualEditorRoot from './blocks/editor/VisualEditorRoot';\nimport { useDetectCanvasMode } from './hooks/useDetectCanvasMode';\nimport { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\ntype ExperienceRootProps = {\n experience?: Experience<EntityStore> | string | null;\n locale: string;\n visualEditorMode?: VisualEditorMode;\n /** Enables extra logging in the SDK to support troubleshooting.\n * This option is not recommended for production environments as it\n * will result in too many unnecessary logs being produced during runtime.\n * Default: false\n */\n debug?: boolean;\n};\n\nexport const ExperienceRoot = ({\n locale,\n experience,\n visualEditorMode = VisualEditorMode.LazyLoad,\n debug,\n}: ExperienceRootProps) => {\n const mode = useDetectCanvasMode();\n\n if (typeof debug === 'boolean') {\n cfDebug.setEnabled(debug);\n }\n\n //If experience is passed in as a JSON string, recreate it to an experience object\n const experienceObject =\n typeof experience === 'string' ? createExperience(experience) : experience;\n\n validateExperienceBuilderConfig({\n locale,\n mode,\n });\n\n if (mode === StudioCanvasMode.EDITOR || mode === StudioCanvasMode.READ_ONLY) {\n return (\n <VisualEditorRoot\n experience={experienceObject as Experience<EntityStore> | undefined}\n visualEditorMode={visualEditorMode}\n initialLocale={locale}\n canvasMode={mode}\n />\n );\n }\n\n if (!experienceObject) return null;\n\n return <PreviewDeliveryRoot locale={locale} experience={experienceObject} />;\n};\n"],"names":[],"mappings":";;;;;;;;AA2Ba;AAMX;AAEA;AACE;;;AAIF;AAGA;;;AAGC;AAED;;;AAWA;AAAuB;;AAGzB;;"}
@@ -2,7 +2,7 @@ import { jsx } from 'react/jsx-runtime';
2
2
  import { useState, useEffect } from 'react';
3
3
  import { VisualEditorMode, inMemoryEntitiesStore } from '@contentful/experiences-core';
4
4
 
5
- const VisualEditorLoader = ({ visualEditorMode, experience, }) => {
5
+ const VisualEditorLoader = ({ visualEditorMode, experience, canvasMode, }) => {
6
6
  const [VisualEditor, setVisualEditor] = useState(null);
7
7
  useEffect(() => {
8
8
  // Dynamically import the visual editor based on the configured mode
@@ -21,7 +21,7 @@ const VisualEditorLoader = ({ visualEditorMode, experience, }) => {
21
21
  }, [visualEditorMode]);
22
22
  if (!VisualEditor)
23
23
  return null;
24
- return jsx(VisualEditor, { experience: experience, inMemoryEntitiesStore: inMemoryEntitiesStore });
24
+ return (jsx(VisualEditor, { experience: experience, inMemoryEntitiesStore: inMemoryEntitiesStore, canvasMode: canvasMode }));
25
25
  };
26
26
 
27
27
  export { VisualEditorLoader, VisualEditorLoader as default };
@@ -1 +1 @@
1
- {"version":3,"file":"VisualEditorLoader.js","sources":["../../../../src/blocks/editor/VisualEditorLoader.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport {\n type InMemoryEntitiesStore,\n type EntityStore,\n inMemoryEntitiesStore,\n VisualEditorMode,\n} from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\n\ntype VisualEditorLoaderProps = {\n visualEditorMode: VisualEditorMode;\n experience?: Experience<EntityStore>;\n};\n\nexport const VisualEditorLoader: React.FC<VisualEditorLoaderProps> = ({\n visualEditorMode,\n experience,\n}) => {\n const [VisualEditor, setVisualEditor] = useState<React.ComponentType<{\n experience?: Experience<EntityStore>;\n inMemoryEntitiesStore?: InMemoryEntitiesStore;\n }> | null>(null);\n\n useEffect(() => {\n // Dynamically import the visual editor based on the configured mode\n switch (visualEditorMode) {\n case VisualEditorMode.InjectScript:\n import('./VisualEditorInjectScript').then((module) => {\n setVisualEditor(() => module.default);\n });\n break;\n\n // VisualEditorMode.LazyLoad:\n default:\n import('@contentful/experiences-visual-editor-react').then((module) => {\n setVisualEditor(() => module.default);\n });\n }\n }, [visualEditorMode]);\n\n if (!VisualEditor) return null;\n\n return <VisualEditor experience={experience} inMemoryEntitiesStore={inMemoryEntitiesStore} />;\n};\n\nexport default VisualEditorLoader;\n"],"names":["_jsx"],"mappings":";;;;AAca,MAAA,kBAAkB,GAAsC,CAAC,EACpE,gBAAgB,EAChB,UAAU,GACX,KAAI;IACH,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAGrC,IAAI,CAAC,CAAC;IAEjB,SAAS,CAAC,MAAK;;QAEb,QAAQ,gBAAgB;YACtB,KAAK,gBAAgB,CAAC,YAAY;gBAChC,OAAO,+BAA4B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACnD,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;gBACH,MAAM;;AAGR,YAAA;gBACE,OAAO,6CAA6C,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACpE,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;SACN;AACH,KAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,CAAC,YAAY;AAAE,QAAA,OAAO,IAAI,CAAC;IAE/B,OAAOA,GAAA,CAAC,YAAY,EAAA,EAAC,UAAU,EAAE,UAAU,EAAE,qBAAqB,EAAE,qBAAqB,EAAA,CAAI,CAAC;AAChG;;;;"}
1
+ {"version":3,"file":"VisualEditorLoader.js","sources":["../../../../src/blocks/editor/VisualEditorLoader.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport {\n type InMemoryEntitiesStore,\n type EntityStore,\n inMemoryEntitiesStore,\n VisualEditorMode,\n} from '@contentful/experiences-core';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport type { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\ntype VisualEditorLoaderProps = {\n visualEditorMode: VisualEditorMode;\n canvasMode?: StudioCanvasMode;\n experience?: Experience<EntityStore>;\n};\n\nexport const VisualEditorLoader: React.FC<VisualEditorLoaderProps> = ({\n visualEditorMode,\n experience,\n canvasMode,\n}) => {\n const [VisualEditor, setVisualEditor] = useState<React.ComponentType<{\n experience?: Experience<EntityStore>;\n inMemoryEntitiesStore?: InMemoryEntitiesStore;\n canvasMode?: StudioCanvasMode;\n }> | null>(null);\n\n useEffect(() => {\n // Dynamically import the visual editor based on the configured mode\n switch (visualEditorMode) {\n case VisualEditorMode.InjectScript:\n import('./VisualEditorInjectScript').then((module) => {\n setVisualEditor(() => module.default);\n });\n break;\n\n // VisualEditorMode.LazyLoad:\n default:\n import('@contentful/experiences-visual-editor-react').then((module) => {\n setVisualEditor(() => module.default);\n });\n }\n }, [visualEditorMode]);\n\n if (!VisualEditor) return null;\n\n return (\n <VisualEditor\n experience={experience}\n inMemoryEntitiesStore={inMemoryEntitiesStore}\n canvasMode={canvasMode}\n />\n );\n};\n\nexport default VisualEditorLoader;\n"],"names":["_jsx"],"mappings":";;;;AAgBO,MAAM,kBAAkB,GAAsC,CAAC,EACpE,gBAAgB,EAChB,UAAU,EACV,UAAU,GACX,KAAI;IACH,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAIrC,IAAI,CAAC,CAAC;IAEjB,SAAS,CAAC,MAAK;;QAEb,QAAQ,gBAAgB;YACtB,KAAK,gBAAgB,CAAC,YAAY;gBAChC,OAAO,+BAA4B,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACnD,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;gBACH,MAAM;;AAGR,YAAA;gBACE,OAAO,6CAA6C,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAI;oBACpE,eAAe,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC;AACxC,iBAAC,CAAC,CAAC;SACN;AACH,KAAC,EAAE,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAEvB,IAAA,IAAI,CAAC,YAAY;AAAE,QAAA,OAAO,IAAI,CAAC;AAE/B,IAAA,QACEA,GAAC,CAAA,YAAY,EACX,EAAA,UAAU,EAAE,UAAU,EACtB,qBAAqB,EAAE,qBAAqB,EAC5C,UAAU,EAAE,UAAU,EAAA,CACtB,EACF;AACJ;;;;"}
@@ -4,13 +4,13 @@ import { ErrorBoundary } from '../../components/ErrorBoundary.js';
4
4
  import { useInitializeVisualEditor } from '../../hooks/useInitializeVisualEditor.js';
5
5
 
6
6
  const VisualEditorLoader = React.lazy(() => import('./VisualEditorLoader.js'));
7
- const VisualEditorRoot = ({ visualEditorMode, experience, initialLocale, }) => {
7
+ const VisualEditorRoot = ({ visualEditorMode, canvasMode, experience, initialLocale, }) => {
8
8
  const initialEntities = experience?.entityStore?.entities || [];
9
9
  useInitializeVisualEditor({
10
10
  initialLocale,
11
11
  initialEntities,
12
12
  });
13
- return (jsx(ErrorBoundary, { children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(VisualEditorLoader, { experience: experience, visualEditorMode: visualEditorMode }) }) }));
13
+ return (jsx(ErrorBoundary, { children: jsx(Suspense, { fallback: jsx("div", { children: "Loading..." }), children: jsx(VisualEditorLoader, { experience: experience, visualEditorMode: visualEditorMode, canvasMode: canvasMode }) }) }));
14
14
  };
15
15
 
16
16
  export { VisualEditorRoot, VisualEditorRoot as default };
@@ -1 +1 @@
1
- {"version":3,"file":"VisualEditorRoot.js","sources":["../../../../src/blocks/editor/VisualEditorRoot.tsx"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { EntityStore, VisualEditorMode } from '@contentful/experiences-core';\nimport { ErrorBoundary } from '../../components/ErrorBoundary';\nimport { useInitializeVisualEditor } from '../../hooks/useInitializeVisualEditor';\nimport type { Experience } from '@contentful/experiences-core/types';\n\nconst VisualEditorLoader = React.lazy(() => import('./VisualEditorLoader'));\n\ntype VisualEditorRootProps = {\n visualEditorMode: VisualEditorMode;\n experience?: Experience<EntityStore>;\n initialLocale: string;\n};\n\nexport const VisualEditorRoot: React.FC<VisualEditorRootProps> = ({\n visualEditorMode,\n experience,\n initialLocale,\n}) => {\n const initialEntities = experience?.entityStore?.entities || [];\n\n useInitializeVisualEditor({\n initialLocale,\n initialEntities,\n });\n\n return (\n <ErrorBoundary>\n <Suspense fallback={<div>Loading...</div>}>\n <VisualEditorLoader experience={experience} visualEditorMode={visualEditorMode} />\n </Suspense>\n </ErrorBoundary>\n );\n};\n\nexport default VisualEditorRoot;\n"],"names":["_jsx"],"mappings":";;;;;AAMA,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,OAAO,yBAAsB,CAAC,CAAC,CAAC;AAQrE,MAAM,gBAAgB,GAAoC,CAAC,EAChE,gBAAgB,EAChB,UAAU,EACV,aAAa,GACd,KAAI;IACH,MAAM,eAAe,GAAG,UAAU,EAAE,WAAW,EAAE,QAAQ,IAAI,EAAE,CAAC;AAEhE,IAAA,yBAAyB,CAAC;QACxB,aAAa;QACb,eAAe;AAChB,KAAA,CAAC,CAAC;IAEH,QACEA,GAAC,CAAA,aAAa,EACZ,EAAA,QAAA,EAAAA,GAAA,CAAC,QAAQ,EAAC,EAAA,QAAQ,EAAEA,GAAA,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,YAAA,EAAA,CAAqB,EACvC,QAAA,EAAAA,GAAA,CAAC,kBAAkB,EAAC,EAAA,UAAU,EAAE,UAAU,EAAE,gBAAgB,EAAE,gBAAgB,EAAI,CAAA,EAAA,CACzE,EACG,CAAA,EAChB;AACJ;;;;"}
1
+ {"version":3,"file":"VisualEditorRoot.js","sources":["../../../../src/blocks/editor/VisualEditorRoot.tsx"],"sourcesContent":["import React, { Suspense } from 'react';\nimport { EntityStore, VisualEditorMode } from '@contentful/experiences-core';\nimport { ErrorBoundary } from '../../components/ErrorBoundary';\nimport { useInitializeVisualEditor } from '../../hooks/useInitializeVisualEditor';\nimport type { Experience } from '@contentful/experiences-core/types';\nimport type { StudioCanvasMode } from '@contentful/experiences-core/constants';\n\nconst VisualEditorLoader = React.lazy(() => import('./VisualEditorLoader'));\n\ntype VisualEditorRootProps = {\n visualEditorMode: VisualEditorMode;\n canvasMode?: StudioCanvasMode;\n experience?: Experience<EntityStore>;\n initialLocale: string;\n};\n\nexport const VisualEditorRoot: React.FC<VisualEditorRootProps> = ({\n visualEditorMode,\n canvasMode,\n experience,\n initialLocale,\n}) => {\n const initialEntities = experience?.entityStore?.entities || [];\n\n useInitializeVisualEditor({\n initialLocale,\n initialEntities,\n });\n\n return (\n <ErrorBoundary>\n <Suspense fallback={<div>Loading...</div>}>\n <VisualEditorLoader\n experience={experience}\n visualEditorMode={visualEditorMode}\n canvasMode={canvasMode}\n />\n </Suspense>\n </ErrorBoundary>\n );\n};\n\nexport default VisualEditorRoot;\n"],"names":["_jsx"],"mappings":";;;;;AAOA,MAAM,kBAAkB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,OAAO,yBAAsB,CAAC,CAAC,CAAC;AASrE,MAAM,gBAAgB,GAAoC,CAAC,EAChE,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,aAAa,GACd,KAAI;IACH,MAAM,eAAe,GAAG,UAAU,EAAE,WAAW,EAAE,QAAQ,IAAI,EAAE,CAAC;AAEhE,IAAA,yBAAyB,CAAC;QACxB,aAAa;QACb,eAAe;AAChB,KAAA,CAAC,CAAC;AAEH,IAAA,QACEA,GAAA,CAAC,aAAa,EAAA,EAAA,QAAA,EACZA,GAAC,CAAA,QAAQ,EAAC,EAAA,QAAQ,EAAEA,GAAA,CAAA,KAAA,EAAA,EAAA,QAAA,EAAA,YAAA,EAAA,CAAqB,EACvC,QAAA,EAAAA,GAAA,CAAC,kBAAkB,EAAA,EACjB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,UAAU,EAAA,CACtB,EACO,CAAA,EAAA,CACG,EAChB;AACJ;;;;"}
@@ -21,9 +21,6 @@ const applyComponentDefinitionFallbacks = (componentDefinition) => {
21
21
  return clone;
22
22
  };
23
23
  const applyBuiltInStyleDefinitions = (componentDefinition) => {
24
- if (componentDefinition.id === CONTENTFUL_COMPONENTS.container.id) {
25
- return componentDefinition;
26
- }
27
24
  const clone = cloneObject(componentDefinition);
28
25
  // set margin built-in style by default
29
26
  if (!clone.builtInStyles) {
@@ -103,14 +100,13 @@ const DEFAULT_COMPONENT_REGISTRATIONS = {
103
100
  wrapComponent: false,
104
101
  },
105
102
  }),
106
- divider: {
107
- // Don't wrap this component `withComponentWrapper`. Need to explicitly ignore dragProps
103
+ divider: enrichComponentDefinition({
108
104
  component: Components.ContentfulDivider,
109
105
  definition: dividerDefinition,
110
106
  options: {
111
107
  wrapComponent: false,
112
108
  },
113
- },
109
+ }),
114
110
  carousel: enrichComponentDefinition({
115
111
  component: Components.Carousel,
116
112
  definition: Components.carouselDefinition,
@@ -1 +1 @@
1
- {"version":3,"file":"componentRegistry.js","sources":["../../../src/core/componentRegistry.ts"],"sourcesContent":["import * as Components from '@contentful/experiences-components-react';\nimport type {\n ComponentRegistration,\n ComponentDefinition,\n ComponentRegistrationOptions,\n DesignTokensDefinition,\n} from '@contentful/experiences-core/types';\nimport {\n OUTGOING_EVENTS,\n INTERNAL_EVENTS,\n CONTENTFUL_COMPONENTS,\n ASSEMBLY_DEFAULT_CATEGORY,\n} from '@contentful/experiences-core/constants';\nimport {\n builtInStyles as builtInStyleDefinitions,\n designTokensRegistry,\n breakpointsRegistry,\n optionalBuiltInStyles,\n sendMessage,\n} from '@contentful/experiences-core';\nimport { validateComponentDefinition } from '@contentful/experiences-validators';\nimport { withComponentWrapper } from '../utils/withComponentWrapper';\nimport { SDK_VERSION } from '../constants';\nimport {\n sectionDefinition,\n containerDefinition,\n columnsDefinition,\n singleColumnDefinition,\n dividerDefinition,\n} from '@contentful/experiences-components-react';\n\nconst CssVarRegex = /var\\(--[\\w-]+\\)/;\n\nconst cloneObject = <T>(targetObject: T): T => {\n if (typeof structuredClone !== 'undefined') {\n return structuredClone(targetObject);\n }\n\n return JSON.parse(JSON.stringify(targetObject));\n};\n\nconst applyComponentDefinitionFallbacks = (componentDefinition: ComponentDefinition) => {\n const clone = cloneObject(componentDefinition);\n for (const variable of Object.values(clone.variables)) {\n variable.group = variable.group ?? 'content';\n }\n return clone;\n};\n\nconst applyBuiltInStyleDefinitions = (componentDefinition: ComponentDefinition) => {\n if (componentDefinition.id === CONTENTFUL_COMPONENTS.container.id) {\n return componentDefinition;\n }\n\n const clone = cloneObject(componentDefinition);\n\n // set margin built-in style by default\n if (!clone.builtInStyles) {\n clone.builtInStyles = ['cfMargin'];\n }\n\n if (!clone.variables) {\n clone.variables = {};\n }\n\n // Enforce the presence of this property for toggling visibility on any node\n clone.variables['cfVisibility'] = builtInStyleDefinitions['cfVisibility'];\n\n for (const style of clone.builtInStyles || []) {\n if (builtInStyleDefinitions[style]) {\n clone.variables[style] = builtInStyleDefinitions[style] as any; // TODO: fix type\n }\n if (optionalBuiltInStyles[style]) {\n clone.variables[style] = optionalBuiltInStyles[style] as any; // TODO: fix type\n }\n }\n return clone;\n};\n\nexport const enrichComponentDefinition = ({\n component,\n definition,\n options,\n}: ComponentRegistration): ComponentRegistration => {\n const definitionWithFallbacks = applyComponentDefinitionFallbacks(definition);\n const definitionWithBuiltInStyles = applyBuiltInStyleDefinitions(definitionWithFallbacks);\n return {\n component: withComponentWrapper(component, options),\n definition: definitionWithBuiltInStyles,\n options,\n };\n};\n\nconst DEFAULT_COMPONENT_REGISTRATIONS = {\n container: {\n component: Components.ContentfulContainer,\n definition: containerDefinition,\n },\n section: {\n component: Components.ContentfulContainer,\n definition: sectionDefinition,\n },\n columns: {\n component: Components.Columns,\n definition: columnsDefinition,\n },\n singleColumn: {\n component: Components.SingleColumn,\n definition: singleColumnDefinition,\n },\n button: enrichComponentDefinition({\n component: Components.Button,\n definition: Components.ButtonComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n heading: enrichComponentDefinition({\n component: Components.Heading,\n definition: Components.HeadingComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n image: enrichComponentDefinition({\n component: Components.Image,\n definition: Components.ImageComponentDefinition,\n options: { wrapComponent: false },\n }),\n richText: enrichComponentDefinition({\n component: Components.RichText,\n definition: Components.RichTextComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n text: enrichComponentDefinition({\n component: Components.Text,\n definition: Components.TextComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n divider: {\n // Don't wrap this component `withComponentWrapper`. Need to explicitly ignore dragProps\n component: Components.ContentfulDivider,\n definition: dividerDefinition,\n options: {\n wrapComponent: false,\n },\n },\n carousel: enrichComponentDefinition({\n component: Components.Carousel,\n definition: Components.carouselDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n} satisfies Record<string, ComponentRegistration>;\n\n// pre-filling with the default component registrations\nexport const componentRegistry = new Map<string, ComponentRegistration>([\n [DEFAULT_COMPONENT_REGISTRATIONS.section.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.section],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.container.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.container,\n ],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.singleColumn.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.singleColumn,\n ],\n [DEFAULT_COMPONENT_REGISTRATIONS.columns.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.columns],\n [DEFAULT_COMPONENT_REGISTRATIONS.button.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.button],\n [DEFAULT_COMPONENT_REGISTRATIONS.heading.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.heading],\n [DEFAULT_COMPONENT_REGISTRATIONS.image.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.image],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.richText.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.richText,\n ],\n [DEFAULT_COMPONENT_REGISTRATIONS.text.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.text],\n [DEFAULT_COMPONENT_REGISTRATIONS.divider.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.divider],\n]);\n\nexport const optionalBuiltInComponents = [\n DEFAULT_COMPONENT_REGISTRATIONS.button.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.heading.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.image.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.richText.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.text.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.divider.definition.id,\n];\n\nexport const sendRegisteredComponentsMessage = () => {\n // Send the definitions (without components) via the connection message to the experience builder\n const registeredDefinitions = Array.from(componentRegistry.values())\n .map(({ definition }) => definition)\n // Pattern definitions are empty placeholder within the SDK without variables\n // We don't send those to the editor as they would overwrite the actual correct definitions.\n .filter((definition) => definition.category !== ASSEMBLY_DEFAULT_CATEGORY);\n\n sendMessage(OUTGOING_EVENTS.RegisteredComponents, {\n definitions: registeredDefinitions,\n });\n};\n\nexport const runRegisteredComponentValidations = () => {\n Array.from(componentRegistry.values()).map(({ definition }) => {\n const validation = validateComponentDefinition(definition);\n if (!validation.success) {\n throw new Error(\n `Invalid component definition for component '${definition.name}'. Failed with errors: \\n${JSON.stringify(validation.errors, null, 2)}`,\n );\n }\n });\n};\n\nconst getSingleCssVariableValue = (\n element: HTMLDivElement,\n cssVariableValue: string,\n cssAttribute: any,\n) => {\n element.style[cssAttribute] = cssVariableValue;\n const styles = getComputedStyle(element);\n const resolvedValue = styles.getPropertyValue(cssAttribute);\n return resolvedValue;\n};\n\nconst getAllCssVariableValues = (\n element: HTMLDivElement,\n cssVariable: Record<string, string>,\n cssAttribute: any,\n) => {\n const resolvedCssVariables = {} as Record<string, string>;\n\n Object.keys(cssVariable).forEach((key) => {\n const cssVariableValue = cssVariable[key];\n if (CssVarRegex.test(cssVariableValue)) {\n const resolvedValue = getSingleCssVariableValue(element, cssVariableValue, cssAttribute);\n resolvedCssVariables[cssVariableValue] = resolvedValue;\n }\n });\n return resolvedCssVariables;\n};\n\ntype CssMapType = {\n variable?: Record<string, string>;\n property: string;\n};\n\nconst resolveCssVariables = (designTokensDefinition: DesignTokensDefinition) => {\n const {\n spacing,\n sizing,\n color,\n borderRadius,\n fontSize,\n lineHeight,\n letterSpacing,\n textColor,\n border,\n } = designTokensDefinition;\n const resolvedCssVariables = {} as Record<string, string>;\n\n // Create an element\n const element = document.createElement('div');\n document.body.appendChild(element);\n\n const cssProperties: CssMapType[] = [\n { variable: spacing, property: 'margin' },\n { variable: sizing, property: 'width' },\n { variable: color, property: 'background-color' },\n { variable: borderRadius, property: 'border-radius' },\n { variable: fontSize, property: 'font-size' },\n { variable: lineHeight, property: 'line-height' },\n { variable: letterSpacing, property: 'letter-spacing' },\n { variable: textColor, property: 'color' },\n ];\n\n cssProperties.forEach(({ variable, property }) => {\n if (variable) {\n const rawResolvedValues = getAllCssVariableValues(element, variable, property);\n Object.assign(resolvedCssVariables, rawResolvedValues);\n }\n });\n\n if (border) {\n const tempResolvedValue = {} as Record<string, string>;\n Object.keys(border).forEach((borderKey) => {\n const { width, style, color } = border[borderKey];\n\n if (width && CssVarRegex.test(width)) {\n const resolvedValue = getSingleCssVariableValue(element, width, 'border-width');\n tempResolvedValue[width] = resolvedValue;\n }\n if (style && CssVarRegex.test(style)) {\n const resolvedValue = getSingleCssVariableValue(element, style, 'border-style');\n tempResolvedValue[style] = resolvedValue;\n }\n if (color && CssVarRegex.test(color)) {\n const resolvedValue = getSingleCssVariableValue(element, color, 'border-color');\n tempResolvedValue[color] = resolvedValue;\n }\n Object.assign(resolvedCssVariables, tempResolvedValue);\n });\n }\n\n document.body.removeChild(element);\n return resolvedCssVariables;\n};\n\nexport const sendConnectedEventWithRegisteredComponents = () => {\n // Send the definitions (without components) via the connection message to the experience builder\n const registeredDefinitions = Array.from(componentRegistry.values()).map(\n ({ definition }) => definition,\n );\n\n sendMessage(OUTGOING_EVENTS.Connected, {\n sdkVersion: SDK_VERSION,\n definitions: registeredDefinitions,\n });\n\n sendMessage(OUTGOING_EVENTS.RegisteredBreakpoints, {\n breakpoints: breakpointsRegistry,\n });\n\n sendMessage(OUTGOING_EVENTS.DesignTokens, {\n designTokens: designTokensRegistry,\n resolvedCssVariables: resolveCssVariables(designTokensRegistry),\n });\n};\n\n/**\n * Registers multiple components and their component definitions at once\n * @param componentRegistrations - ComponentRegistration[]\n * @returns void\n */\nexport const defineComponents = (\n componentRegistrations: ComponentRegistration[],\n options?: ComponentRegistrationOptions,\n) => {\n if (options?.experimentalComponents?.carousel) {\n componentRegistry.set(\n CONTENTFUL_COMPONENTS.carousel.id,\n DEFAULT_COMPONENT_REGISTRATIONS.carousel,\n );\n }\n\n if (options?.enabledBuiltInComponents) {\n for (const id of optionalBuiltInComponents) {\n if (!options.enabledBuiltInComponents.includes(id)) {\n componentRegistry.delete(id);\n }\n }\n }\n\n for (const registration of componentRegistrations) {\n // Fill definitions with fallbacks values\n const enrichedComponentRegistration = enrichComponentDefinition(registration);\n\n componentRegistry.set(\n enrichedComponentRegistration.definition.id,\n enrichedComponentRegistration,\n );\n }\n\n if (typeof window !== 'undefined') {\n window.dispatchEvent(new CustomEvent(INTERNAL_EVENTS.ComponentsRegistered));\n }\n};\n\n/**\n * use this function only in tests\n */\nexport const resetComponentRegistry = () => {\n componentRegistry.clear();\n for (const registration of Object.values(DEFAULT_COMPONENT_REGISTRATIONS)) {\n componentRegistry.set(registration.definition.id, registration);\n }\n};\n\nexport const getComponentRegistration = (id: string) => componentRegistry.get(id);\n\nexport const addComponentRegistration = (componentRegistration: ComponentRegistration) => {\n componentRegistry.set(componentRegistration.definition.id, componentRegistration);\n};\n\nexport const createAssemblyRegistration = ({\n definitionId,\n definitionName,\n component,\n}: {\n definitionId: string;\n definitionName?: string;\n component: ComponentRegistration['component'];\n}) => {\n const componentRegistration = componentRegistry.get(definitionId);\n\n if (componentRegistration) {\n return componentRegistration;\n }\n\n const definition = {\n id: definitionId,\n name: definitionName || 'Component',\n variables: {},\n children: true,\n category: ASSEMBLY_DEFAULT_CATEGORY,\n };\n\n addComponentRegistration({ component, definition });\n\n return componentRegistry.get(definitionId);\n};\n"],"names":["builtInStyleDefinitions"],"mappings":";;;;;;;;AA+BA,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,MAAM,WAAW,GAAG,CAAI,YAAe,KAAO;AAC5C,IAAA,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;AAC1C,QAAA,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC;KACtC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,iCAAiC,GAAG,CAAC,mBAAwC,KAAI;AACrF,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;AAC/C,IAAA,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;QACrD,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,SAAS,CAAC;KAC9C;AACD,IAAA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I,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,MAAM,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,eAAe,CAAC,oBAAoB,CAAC,CAAC,CAAC;KAC7E;AACH,EAAE;AAYK,MAAM,wBAAwB,GAAG,CAAC,EAAU,KAAK,iBAAiB,CAAC,GAAG,CAAC,EAAE,EAAE;AAErE,MAAA,wBAAwB,GAAG,CAAC,qBAA4C,KAAI;IACvF,iBAAiB,CAAC,GAAG,CAAC,qBAAqB,CAAC,UAAU,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;AACpF,EAAE;AAEK,MAAM,0BAA0B,GAAG,CAAC,EACzC,YAAY,EACZ,cAAc,EACd,SAAS,GAKV,KAAI;IACH,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAElE,IAAI,qBAAqB,EAAE;AACzB,QAAA,OAAO,qBAAqB,CAAC;KAC9B;AAED,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,cAAc,IAAI,WAAW;AACnC,QAAA,SAAS,EAAE,EAAE;AACb,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,QAAQ,EAAE,yBAAyB;KACpC,CAAC;AAEF,IAAA,wBAAwB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;AAEpD,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAC7C;;;;"}
1
+ {"version":3,"file":"componentRegistry.js","sources":["../../../src/core/componentRegistry.ts"],"sourcesContent":["import * as Components from '@contentful/experiences-components-react';\nimport type {\n ComponentRegistration,\n ComponentDefinition,\n ComponentRegistrationOptions,\n DesignTokensDefinition,\n} from '@contentful/experiences-core/types';\nimport {\n OUTGOING_EVENTS,\n INTERNAL_EVENTS,\n CONTENTFUL_COMPONENTS,\n ASSEMBLY_DEFAULT_CATEGORY,\n} from '@contentful/experiences-core/constants';\nimport {\n builtInStyles as builtInStyleDefinitions,\n designTokensRegistry,\n breakpointsRegistry,\n optionalBuiltInStyles,\n sendMessage,\n} from '@contentful/experiences-core';\nimport { validateComponentDefinition } from '@contentful/experiences-validators';\nimport { withComponentWrapper } from '../utils/withComponentWrapper';\nimport { SDK_VERSION } from '../constants';\nimport {\n sectionDefinition,\n containerDefinition,\n columnsDefinition,\n singleColumnDefinition,\n dividerDefinition,\n} from '@contentful/experiences-components-react';\n\nconst CssVarRegex = /var\\(--[\\w-]+\\)/;\n\nconst cloneObject = <T>(targetObject: T): T => {\n if (typeof structuredClone !== 'undefined') {\n return structuredClone(targetObject);\n }\n\n return JSON.parse(JSON.stringify(targetObject));\n};\n\nconst applyComponentDefinitionFallbacks = (componentDefinition: ComponentDefinition) => {\n const clone = cloneObject(componentDefinition);\n for (const variable of Object.values(clone.variables)) {\n variable.group = variable.group ?? 'content';\n }\n return clone;\n};\n\nconst applyBuiltInStyleDefinitions = (componentDefinition: ComponentDefinition) => {\n const clone = cloneObject(componentDefinition);\n\n // set margin built-in style by default\n if (!clone.builtInStyles) {\n clone.builtInStyles = ['cfMargin'];\n }\n\n if (!clone.variables) {\n clone.variables = {};\n }\n\n // Enforce the presence of this property for toggling visibility on any node\n clone.variables['cfVisibility'] = builtInStyleDefinitions['cfVisibility'];\n\n for (const style of clone.builtInStyles || []) {\n if (builtInStyleDefinitions[style]) {\n clone.variables[style] = builtInStyleDefinitions[style] as any; // TODO: fix type\n }\n if (optionalBuiltInStyles[style]) {\n clone.variables[style] = optionalBuiltInStyles[style] as any; // TODO: fix type\n }\n }\n return clone;\n};\n\nexport const enrichComponentDefinition = ({\n component,\n definition,\n options,\n}: ComponentRegistration): ComponentRegistration => {\n const definitionWithFallbacks = applyComponentDefinitionFallbacks(definition);\n const definitionWithBuiltInStyles = applyBuiltInStyleDefinitions(definitionWithFallbacks);\n return {\n component: withComponentWrapper(component, options),\n definition: definitionWithBuiltInStyles,\n options,\n };\n};\n\nconst DEFAULT_COMPONENT_REGISTRATIONS = {\n container: {\n component: Components.ContentfulContainer,\n definition: containerDefinition,\n },\n section: {\n component: Components.ContentfulContainer,\n definition: sectionDefinition,\n },\n columns: {\n component: Components.Columns,\n definition: columnsDefinition,\n },\n singleColumn: {\n component: Components.SingleColumn,\n definition: singleColumnDefinition,\n },\n button: enrichComponentDefinition({\n component: Components.Button,\n definition: Components.ButtonComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n heading: enrichComponentDefinition({\n component: Components.Heading,\n definition: Components.HeadingComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n image: enrichComponentDefinition({\n component: Components.Image,\n definition: Components.ImageComponentDefinition,\n options: { wrapComponent: false },\n }),\n richText: enrichComponentDefinition({\n component: Components.RichText,\n definition: Components.RichTextComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n text: enrichComponentDefinition({\n component: Components.Text,\n definition: Components.TextComponentDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n divider: enrichComponentDefinition({\n component: Components.ContentfulDivider,\n definition: dividerDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n carousel: enrichComponentDefinition({\n component: Components.Carousel,\n definition: Components.carouselDefinition,\n options: {\n wrapComponent: false,\n },\n }),\n} satisfies Record<string, ComponentRegistration>;\n\n// pre-filling with the default component registrations\nexport const componentRegistry = new Map<string, ComponentRegistration>([\n [DEFAULT_COMPONENT_REGISTRATIONS.section.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.section],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.container.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.container,\n ],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.singleColumn.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.singleColumn,\n ],\n [DEFAULT_COMPONENT_REGISTRATIONS.columns.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.columns],\n [DEFAULT_COMPONENT_REGISTRATIONS.button.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.button],\n [DEFAULT_COMPONENT_REGISTRATIONS.heading.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.heading],\n [DEFAULT_COMPONENT_REGISTRATIONS.image.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.image],\n [\n DEFAULT_COMPONENT_REGISTRATIONS.richText.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.richText,\n ],\n [DEFAULT_COMPONENT_REGISTRATIONS.text.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.text],\n [DEFAULT_COMPONENT_REGISTRATIONS.divider.definition.id, DEFAULT_COMPONENT_REGISTRATIONS.divider],\n]);\n\nexport const optionalBuiltInComponents = [\n DEFAULT_COMPONENT_REGISTRATIONS.button.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.heading.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.image.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.richText.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.text.definition.id,\n DEFAULT_COMPONENT_REGISTRATIONS.divider.definition.id,\n];\n\nexport const sendRegisteredComponentsMessage = () => {\n // Send the definitions (without components) via the connection message to the experience builder\n const registeredDefinitions = Array.from(componentRegistry.values())\n .map(({ definition }) => definition)\n // Pattern definitions are empty placeholder within the SDK without variables\n // We don't send those to the editor as they would overwrite the actual correct definitions.\n .filter((definition) => definition.category !== ASSEMBLY_DEFAULT_CATEGORY);\n\n sendMessage(OUTGOING_EVENTS.RegisteredComponents, {\n definitions: registeredDefinitions,\n });\n};\n\nexport const runRegisteredComponentValidations = () => {\n Array.from(componentRegistry.values()).map(({ definition }) => {\n const validation = validateComponentDefinition(definition);\n if (!validation.success) {\n throw new Error(\n `Invalid component definition for component '${definition.name}'. Failed with errors: \\n${JSON.stringify(validation.errors, null, 2)}`,\n );\n }\n });\n};\n\nconst getSingleCssVariableValue = (\n element: HTMLDivElement,\n cssVariableValue: string,\n cssAttribute: any,\n) => {\n element.style[cssAttribute] = cssVariableValue;\n const styles = getComputedStyle(element);\n const resolvedValue = styles.getPropertyValue(cssAttribute);\n return resolvedValue;\n};\n\nconst getAllCssVariableValues = (\n element: HTMLDivElement,\n cssVariable: Record<string, string>,\n cssAttribute: any,\n) => {\n const resolvedCssVariables = {} as Record<string, string>;\n\n Object.keys(cssVariable).forEach((key) => {\n const cssVariableValue = cssVariable[key];\n if (CssVarRegex.test(cssVariableValue)) {\n const resolvedValue = getSingleCssVariableValue(element, cssVariableValue, cssAttribute);\n resolvedCssVariables[cssVariableValue] = resolvedValue;\n }\n });\n return resolvedCssVariables;\n};\n\ntype CssMapType = {\n variable?: Record<string, string>;\n property: string;\n};\n\nconst resolveCssVariables = (designTokensDefinition: DesignTokensDefinition) => {\n const {\n spacing,\n sizing,\n color,\n borderRadius,\n fontSize,\n lineHeight,\n letterSpacing,\n textColor,\n border,\n } = designTokensDefinition;\n const resolvedCssVariables = {} as Record<string, string>;\n\n // Create an element\n const element = document.createElement('div');\n document.body.appendChild(element);\n\n const cssProperties: CssMapType[] = [\n { variable: spacing, property: 'margin' },\n { variable: sizing, property: 'width' },\n { variable: color, property: 'background-color' },\n { variable: borderRadius, property: 'border-radius' },\n { variable: fontSize, property: 'font-size' },\n { variable: lineHeight, property: 'line-height' },\n { variable: letterSpacing, property: 'letter-spacing' },\n { variable: textColor, property: 'color' },\n ];\n\n cssProperties.forEach(({ variable, property }) => {\n if (variable) {\n const rawResolvedValues = getAllCssVariableValues(element, variable, property);\n Object.assign(resolvedCssVariables, rawResolvedValues);\n }\n });\n\n if (border) {\n const tempResolvedValue = {} as Record<string, string>;\n Object.keys(border).forEach((borderKey) => {\n const { width, style, color } = border[borderKey];\n\n if (width && CssVarRegex.test(width)) {\n const resolvedValue = getSingleCssVariableValue(element, width, 'border-width');\n tempResolvedValue[width] = resolvedValue;\n }\n if (style && CssVarRegex.test(style)) {\n const resolvedValue = getSingleCssVariableValue(element, style, 'border-style');\n tempResolvedValue[style] = resolvedValue;\n }\n if (color && CssVarRegex.test(color)) {\n const resolvedValue = getSingleCssVariableValue(element, color, 'border-color');\n tempResolvedValue[color] = resolvedValue;\n }\n Object.assign(resolvedCssVariables, tempResolvedValue);\n });\n }\n\n document.body.removeChild(element);\n return resolvedCssVariables;\n};\n\nexport const sendConnectedEventWithRegisteredComponents = () => {\n // Send the definitions (without components) via the connection message to the experience builder\n const registeredDefinitions = Array.from(componentRegistry.values()).map(\n ({ definition }) => definition,\n );\n\n sendMessage(OUTGOING_EVENTS.Connected, {\n sdkVersion: SDK_VERSION,\n definitions: registeredDefinitions,\n });\n\n sendMessage(OUTGOING_EVENTS.RegisteredBreakpoints, {\n breakpoints: breakpointsRegistry,\n });\n\n sendMessage(OUTGOING_EVENTS.DesignTokens, {\n designTokens: designTokensRegistry,\n resolvedCssVariables: resolveCssVariables(designTokensRegistry),\n });\n};\n\n/**\n * Registers multiple components and their component definitions at once\n * @param componentRegistrations - ComponentRegistration[]\n * @returns void\n */\nexport const defineComponents = (\n componentRegistrations: ComponentRegistration[],\n options?: ComponentRegistrationOptions,\n) => {\n if (options?.experimentalComponents?.carousel) {\n componentRegistry.set(\n CONTENTFUL_COMPONENTS.carousel.id,\n DEFAULT_COMPONENT_REGISTRATIONS.carousel,\n );\n }\n\n if (options?.enabledBuiltInComponents) {\n for (const id of optionalBuiltInComponents) {\n if (!options.enabledBuiltInComponents.includes(id)) {\n componentRegistry.delete(id);\n }\n }\n }\n\n for (const registration of componentRegistrations) {\n // Fill definitions with fallbacks values\n const enrichedComponentRegistration = enrichComponentDefinition(registration);\n\n componentRegistry.set(\n enrichedComponentRegistration.definition.id,\n enrichedComponentRegistration,\n );\n }\n\n if (typeof window !== 'undefined') {\n window.dispatchEvent(new CustomEvent(INTERNAL_EVENTS.ComponentsRegistered));\n }\n};\n\n/**\n * use this function only in tests\n */\nexport const resetComponentRegistry = () => {\n componentRegistry.clear();\n for (const registration of Object.values(DEFAULT_COMPONENT_REGISTRATIONS)) {\n componentRegistry.set(registration.definition.id, registration);\n }\n};\n\nexport const getComponentRegistration = (id: string) => componentRegistry.get(id);\n\nexport const addComponentRegistration = (componentRegistration: ComponentRegistration) => {\n componentRegistry.set(componentRegistration.definition.id, componentRegistration);\n};\n\nexport const createAssemblyRegistration = ({\n definitionId,\n definitionName,\n component,\n}: {\n definitionId: string;\n definitionName?: string;\n component: ComponentRegistration['component'];\n}) => {\n const componentRegistration = componentRegistry.get(definitionId);\n\n if (componentRegistration) {\n return componentRegistration;\n }\n\n const definition = {\n id: definitionId,\n name: definitionName || 'Component',\n variables: {},\n children: true,\n category: ASSEMBLY_DEFAULT_CATEGORY,\n };\n\n addComponentRegistration({ component, definition });\n\n return componentRegistry.get(definitionId);\n};\n"],"names":["builtInStyleDefinitions"],"mappings":";;;;;;;;AA+BA,MAAM,WAAW,GAAG,iBAAiB,CAAC;AAEtC,MAAM,WAAW,GAAG,CAAI,YAAe,KAAO;AAC5C,IAAA,IAAI,OAAO,eAAe,KAAK,WAAW,EAAE;AAC1C,QAAA,OAAO,eAAe,CAAC,YAAY,CAAC,CAAC;KACtC;IAED,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC;AAClD,CAAC,CAAC;AAEF,MAAM,iCAAiC,GAAG,CAAC,mBAAwC,KAAI;AACrF,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;AAC/C,IAAA,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE;QACrD,QAAQ,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,IAAI,SAAS,CAAC;KAC9C;AACD,IAAA,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,4BAA4B,GAAG,CAAC,mBAAwC,KAAI;AAChF,IAAA,MAAM,KAAK,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC;;AAG/C,IAAA,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE;AACx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CAAC,UAAU,CAAC,EAAE,EAAE,qBAAqB,CAAC,CAAC;AACpF,EAAE;AAEK,MAAM,0BAA0B,GAAG,CAAC,EACzC,YAAY,EACZ,cAAc,EACd,SAAS,GAKV,KAAI;IACH,MAAM,qBAAqB,GAAG,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IAElE,IAAI,qBAAqB,EAAE;AACzB,QAAA,OAAO,qBAAqB,CAAC;KAC9B;AAED,IAAA,MAAM,UAAU,GAAG;AACjB,QAAA,EAAE,EAAE,YAAY;QAChB,IAAI,EAAE,cAAc,IAAI,WAAW;AACnC,QAAA,SAAS,EAAE,EAAE;AACb,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,QAAQ,EAAE,yBAAyB;KACpC,CAAC;AAEF,IAAA,wBAAwB,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,CAAC,CAAC;AAEpD,IAAA,OAAO,iBAAiB,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;AAC7C;;;;"}
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
9
9
  export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
10
10
  import { ContentfulClientApi } from 'contentful';
11
11
 
12
- declare const SDK_VERSION = "3.1.1-dev-20250808T0933-3a55c60.0";
12
+ declare const SDK_VERSION = "3.1.1-dev-20250811T1516-ddc6cd6.0";
13
13
 
14
14
  type ExperienceRootProps = {
15
15
  experience?: Experience<EntityStore> | string | null;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = '3.1.1-dev-20250808T0933-3a55c60.0';
1
+ const SDK_VERSION = '3.1.1-dev-20250811T1516-ddc6cd6.0';
2
2
 
3
3
  export { SDK_VERSION };
4
4
  //# sourceMappingURL=sdkVersion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '3.1.1-dev-20250808T0933-3a55c60.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
1
+ {"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '3.1.1-dev-20250811T1516-ddc6cd6.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { type EntityStore, VisualEditorMode } from '@contentful/experiences-core';
3
3
  import type { Experience } from '@contentful/experiences-core/types';
4
+ import type { StudioCanvasMode } from '@contentful/experiences-core/constants';
4
5
  type VisualEditorLoaderProps = {
5
6
  visualEditorMode: VisualEditorMode;
7
+ canvasMode?: StudioCanvasMode;
6
8
  experience?: Experience<EntityStore>;
7
9
  };
8
10
  export declare const VisualEditorLoader: React.FC<VisualEditorLoaderProps>;
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
  import { EntityStore, VisualEditorMode } from '@contentful/experiences-core';
3
3
  import type { Experience } from '@contentful/experiences-core/types';
4
+ import type { StudioCanvasMode } from '@contentful/experiences-core/constants';
4
5
  type VisualEditorRootProps = {
5
6
  visualEditorMode: VisualEditorMode;
7
+ canvasMode?: StudioCanvasMode;
6
8
  experience?: Experience<EntityStore>;
7
9
  initialLocale: string;
8
10
  };
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "3.1.1-dev-20250808T0933-3a55c60.0";
1
+ export declare const SDK_VERSION = "3.1.1-dev-20250811T1516-ddc6cd6.0";
@@ -5,11 +5,9 @@ interface CFProps extends React.HtmlHTMLAttributes<HTMLElement> {
5
5
  * Classes to be applied to the container component if `wrapComponent` is true, or directly to the child component if false.
6
6
  */
7
7
  className?: string;
8
- /**
9
- * Classes to be applied to the child component if `wrapComponent` is true, or directly to the child component if false.
10
- */
11
- classes?: string;
12
- dragProps?: any;
8
+ 'data-cf-node-id': string;
9
+ 'data-cf-node-block-id': string;
10
+ 'data-cf-node-block-type': string;
13
11
  }
14
12
  /**
15
13
  * Sets up a component to be consumed by Experience Builder. This function can be used to wrap a component with a container component, or to pass props to the component directly.
@@ -1,5 +1,4 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
2
- import classNames from 'classnames';
1
+ import { jsx } from 'react/jsx-runtime';
3
2
  import React from 'react';
4
3
 
5
4
  /**
@@ -9,19 +8,17 @@ import React from 'react';
9
8
  * @default { wrapComponent: true, wrapContainer: 'div' }
10
9
  * @returns A component that can be passed to `defineComponents`.
11
10
  */
12
- function withComponentWrapper(Component, options = {
13
- wrapComponent: true,
14
- wrapContainer: 'div',
15
- }) {
16
- const Wrapped = ({ classes = '', className = '', dragProps = {}, ...props }) => {
17
- const { innerRef, className: dragClassName, ToolTipAndPlaceholder, ...restOfDragProps } = dragProps;
18
- const component = options.wrapComponent ? (jsxs("div", { "data-component-wrapper": true, className: classNames(classes, className, dragClassName), ...restOfDragProps, ref: (refNode) => {
19
- if (innerRef && refNode)
20
- innerRef(refNode);
21
- }, children: [ToolTipAndPlaceholder, jsx(Component, { className: classNames(classes), ...props })] })) : (React.createElement(Component, {
22
- className: classNames(classes, className),
23
- ...props,
24
- }));
11
+ function withComponentWrapper(Component, options = {}) {
12
+ const mergedOptions = {
13
+ // Merge default values with overwriting options
14
+ wrapComponent: true,
15
+ wrapContainer: 'div',
16
+ ...options,
17
+ };
18
+ const Wrapped = (props) => {
19
+ const Tag = mergedOptions.wrapContainer;
20
+ const { className = '', 'data-cf-node-id': dataCfNodeId, 'data-cf-node-block-id': dataCfNodeBlockId, 'data-cf-node-block-type': dataCfNodeBlockType, ...componentProps } = props;
21
+ const component = mergedOptions.wrapComponent ? (jsx(Tag, { "data-component-wrapper": true, className: className, "data-cf-node-id": dataCfNodeId, "data-cf-node-block-id": dataCfNodeBlockId, "data-cf-node-block-type": dataCfNodeBlockType, children: jsx(Component, { ...componentProps }) })) : (React.createElement(Component, props));
25
22
  return component;
26
23
  };
27
24
  return Wrapped;
@@ -1 +1 @@
1
- {"version":3,"file":"withComponentWrapper.js","sources":["../../../src/utils/withComponentWrapper.tsx"],"sourcesContent":["import { ComponentRegistration } from '@contentful/experiences-core/types';\nimport classNames from 'classnames';\nimport React from 'react';\ninterface CFProps extends React.HtmlHTMLAttributes<HTMLElement> {\n /**\n * Classes to be applied to the container component if `wrapComponent` is true, or directly to the child component if false.\n */\n className?: string;\n /**\n * Classes to be applied to the child component if `wrapComponent` is true, or directly to the child component if false.\n */\n classes?: string;\n dragProps?: any;\n}\n\n/**\n * Sets up a component to be consumed by Experience Builder. This function can be used to wrap a component with a container component, or to pass props to the component directly.\n * @param Component Component to be used by Experience Builder.\n * @param options Options for the `withComponentWrapper` function.\n * @default { wrapComponent: true, wrapContainer: 'div' }\n * @returns A component that can be passed to `defineComponents`.\n */\nexport function withComponentWrapper<T>(\n Component: React.ElementType,\n options: ComponentRegistration['options'] = {\n wrapComponent: true,\n wrapContainer: 'div',\n },\n) {\n const Wrapped: React.FC<CFProps & T> = ({\n classes = '',\n className = '',\n dragProps = {},\n ...props\n }) => {\n const {\n innerRef,\n className: dragClassName,\n ToolTipAndPlaceholder,\n ...restOfDragProps\n } = dragProps;\n const component = options.wrapComponent ? (\n <div\n data-component-wrapper\n className={classNames(classes, className, dragClassName)}\n {...restOfDragProps}\n ref={(refNode: HTMLElement | null) => {\n if (innerRef && refNode) innerRef(refNode);\n }}>\n {ToolTipAndPlaceholder}\n <Component className={classNames(classes)} {...(props as T)} />\n </div>\n ) : (\n React.createElement(Component, {\n className: classNames(classes, className),\n ...(props as T),\n })\n );\n return component;\n };\n\n return Wrapped;\n}\n"],"names":["_jsxs","_jsx"],"mappings":";;;;AAeA;;;;;;AAMG;AACa,SAAA,oBAAoB,CAClC,SAA4B,EAC5B,OAA4C,GAAA;AAC1C,IAAA,aAAa,EAAE,IAAI;AACnB,IAAA,aAAa,EAAE,KAAK;AACrB,CAAA,EAAA;IAED,MAAM,OAAO,GAA0B,CAAC,EACtC,OAAO,GAAG,EAAE,EACZ,SAAS,GAAG,EAAE,EACd,SAAS,GAAG,EAAE,EACd,GAAG,KAAK,EACT,KAAI;AACH,QAAA,MAAM,EACJ,QAAQ,EACR,SAAS,EAAE,aAAa,EACxB,qBAAqB,EACrB,GAAG,eAAe,EACnB,GAAG,SAAS,CAAC;AACd,QAAA,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,IACrCA,IAAA,CAAA,KAAA,EAAA,EAAA,wBAAA,EAAA,IAAA,EAEE,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,aAAa,CAAC,EACpD,GAAA,eAAe,EACnB,GAAG,EAAE,CAAC,OAA2B,KAAI;gBACnC,IAAI,QAAQ,IAAI,OAAO;oBAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;aAC5C,EAAA,QAAA,EAAA,CACA,qBAAqB,EACtBC,GAAC,CAAA,SAAS,EAAC,EAAA,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,EAAA,GAAO,KAAW,EAAI,CAAA,CAAA,EAAA,CAC3D,KAEN,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AAC7B,YAAA,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC;AACzC,YAAA,GAAI,KAAW;AAChB,SAAA,CAAC,CACH,CAAC;AACF,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
1
+ {"version":3,"file":"withComponentWrapper.js","sources":["../../../src/utils/withComponentWrapper.tsx"],"sourcesContent":["import { ComponentRegistration } from '@contentful/experiences-core/types';\nimport React from 'react';\ninterface CFProps extends React.HtmlHTMLAttributes<HTMLElement> {\n /**\n * Classes to be applied to the container component if `wrapComponent` is true, or directly to the child component if false.\n */\n className?: string;\n 'data-cf-node-id': string;\n 'data-cf-node-block-id': string;\n 'data-cf-node-block-type': string;\n}\n\n/**\n * Sets up a component to be consumed by Experience Builder. This function can be used to wrap a component with a container component, or to pass props to the component directly.\n * @param Component Component to be used by Experience Builder.\n * @param options Options for the `withComponentWrapper` function.\n * @default { wrapComponent: true, wrapContainer: 'div' }\n * @returns A component that can be passed to `defineComponents`.\n */\nexport function withComponentWrapper<T>(\n Component: React.ElementType,\n options: ComponentRegistration['options'] = {},\n) {\n const mergedOptions = {\n // Merge default values with overwriting options\n wrapComponent: true,\n wrapContainer: 'div' as keyof JSX.IntrinsicElements,\n ...options,\n };\n const Wrapped: React.FC<CFProps & T> = (props) => {\n const Tag = mergedOptions.wrapContainer;\n const {\n className = '',\n 'data-cf-node-id': dataCfNodeId,\n 'data-cf-node-block-id': dataCfNodeBlockId,\n 'data-cf-node-block-type': dataCfNodeBlockType,\n ...componentProps\n } = props;\n const component = mergedOptions.wrapComponent ? (\n <Tag\n data-component-wrapper\n className={className}\n data-cf-node-id={dataCfNodeId}\n data-cf-node-block-id={dataCfNodeBlockId}\n data-cf-node-block-type={dataCfNodeBlockType}>\n <Component {...componentProps} />\n </Tag>\n ) : (\n React.createElement(Component, props)\n );\n return component;\n };\n\n return Wrapped;\n}\n"],"names":["_jsx"],"mappings":";;;AAYA;;;;;;AAMG;SACa,oBAAoB,CAClC,SAA4B,EAC5B,UAA4C,EAAE,EAAA;AAE9C,IAAA,MAAM,aAAa,GAAG;;AAEpB,QAAA,aAAa,EAAE,IAAI;AACnB,QAAA,aAAa,EAAE,KAAoC;AACnD,QAAA,GAAG,OAAO;KACX,CAAC;AACF,IAAA,MAAM,OAAO,GAA0B,CAAC,KAAK,KAAI;AAC/C,QAAA,MAAM,GAAG,GAAG,aAAa,CAAC,aAAa,CAAC;QACxC,MAAM,EACJ,SAAS,GAAG,EAAE,EACd,iBAAiB,EAAE,YAAY,EAC/B,uBAAuB,EAAE,iBAAiB,EAC1C,yBAAyB,EAAE,mBAAmB,EAC9C,GAAG,cAAc,EAClB,GAAG,KAAK,CAAC;AACV,QAAA,MAAM,SAAS,GAAG,aAAa,CAAC,aAAa,IAC3CA,IAAC,GAAG,EAAA,EAAA,wBAAA,EAAA,IAAA,EAEF,SAAS,EAAE,SAAS,qBACH,YAAY,EAAA,uBAAA,EACN,iBAAiB,EACf,yBAAA,EAAA,mBAAmB,EAC5C,QAAA,EAAAA,GAAA,CAAC,SAAS,EAAK,EAAA,GAAA,cAAc,GAAI,EAC7B,CAAA,KAEN,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CACtC,CAAC;AACF,QAAA,OAAO,SAAS,CAAC;AACnB,KAAC,CAAC;AAEF,IAAA,OAAO,OAAO,CAAC;AACjB;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-sdk-react",
3
- "version": "3.1.1-dev-20250808T0933-3a55c60.0",
3
+ "version": "3.1.1-dev-20250811T1516-ddc6cd6.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -41,12 +41,11 @@
41
41
  "depcruise": "depcruise src"
42
42
  },
43
43
  "dependencies": {
44
- "@contentful/experiences-components-react": "3.1.1-dev-20250808T0933-3a55c60.0",
45
- "@contentful/experiences-core": "3.1.1-dev-20250808T0933-3a55c60.0",
46
- "@contentful/experiences-validators": "3.1.1-dev-20250808T0933-3a55c60.0",
47
- "@contentful/experiences-visual-editor-react": "3.1.1-dev-20250808T0933-3a55c60.0",
44
+ "@contentful/experiences-components-react": "3.1.1-dev-20250811T1516-ddc6cd6.0",
45
+ "@contentful/experiences-core": "3.1.1-dev-20250811T1516-ddc6cd6.0",
46
+ "@contentful/experiences-validators": "3.1.1-dev-20250811T1516-ddc6cd6.0",
47
+ "@contentful/experiences-visual-editor-react": "3.1.1-dev-20250811T1516-ddc6cd6.0",
48
48
  "@contentful/rich-text-types": "^17.0.0",
49
- "classnames": "^2.3.2",
50
49
  "csstype": "^3.1.2",
51
50
  "immer": "^10.0.3",
52
51
  "lodash-es": "^4.17.21",
@@ -99,5 +98,5 @@
99
98
  "dist",
100
99
  "package.json"
101
100
  ],
102
- "gitHead": "b2810cd3fb3cf8787eb6c8e2ba11e0ab90161925"
101
+ "gitHead": "34edcfd8de3fe99a0d1184edfcb755df8ec40cea"
103
102
  }