@contentful/experiences-sdk-react 1.32.0 → 1.33.0-beta.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.
@@ -1,19 +1,39 @@
1
1
  import { checkIsAssemblyNode } from '@contentful/experiences-core';
2
+ import { shouldUsePrebinding, resolvePrebindingPath } from '../../utils/prebindingUtils.js';
2
3
 
3
4
  /** While unfolding the assembly definition on the instance, this function will replace all
4
5
  * ComponentValue in the definitions tree with the actual value on the instance. */
5
- const deserializeAssemblyNode = ({ node, componentInstanceVariables, assemblyVariableDefinitions, }) => {
6
+ const deserializeAssemblyNode = ({ node, componentInstanceVariables, componentSettings, patternProperties, }) => {
6
7
  const variables = {};
7
8
  for (const [variableName, variable] of Object.entries(node.variables)) {
8
9
  variables[variableName] = variable;
9
10
  if (variable.type === 'ComponentValue') {
10
11
  const componentValueKey = variable.key;
11
12
  const instanceProperty = componentInstanceVariables[componentValueKey];
12
- const variableDefinition = assemblyVariableDefinitions?.[componentValueKey];
13
+ const variableDefinition = componentSettings.variableDefinitions?.[componentValueKey];
13
14
  const defaultValue = variableDefinition?.defaultValue;
14
- // For assembly, we look up the variable in the assembly instance and
15
- // replace the ComponentValue with that one.
16
- if (instanceProperty?.type === 'UnboundValue') {
15
+ const usePrebinding = shouldUsePrebinding({
16
+ componentSettings,
17
+ componentValueKey,
18
+ patternProperties,
19
+ variable: instanceProperty,
20
+ });
21
+ if (usePrebinding) {
22
+ const path = resolvePrebindingPath({
23
+ componentSettings,
24
+ componentValueKey,
25
+ patternProperties,
26
+ });
27
+ if (path) {
28
+ variables[variableName] = {
29
+ type: 'BoundValue',
30
+ path,
31
+ };
32
+ }
33
+ // For assembly, we look up the variable in the assembly instance and
34
+ // replace the ComponentValue with that one.
35
+ }
36
+ else if (instanceProperty?.type === 'UnboundValue') {
17
37
  variables[variableName] = {
18
38
  type: 'UnboundValue',
19
39
  key: instanceProperty.key,
@@ -51,7 +71,8 @@ const deserializeAssemblyNode = ({ node, componentInstanceVariables, assemblyVar
51
71
  const children = node.children.map((child) => deserializeAssemblyNode({
52
72
  node: child,
53
73
  componentInstanceVariables,
54
- assemblyVariableDefinitions,
74
+ componentSettings,
75
+ patternProperties,
55
76
  }));
56
77
  return {
57
78
  definitionId: node.definitionId,
@@ -84,7 +105,8 @@ const resolveAssembly = ({ node, entityStore, }) => {
84
105
  children: componentFields.componentTree.children,
85
106
  },
86
107
  componentInstanceVariables: node.variables,
87
- assemblyVariableDefinitions: componentFields.componentSettings.variableDefinitions,
108
+ componentSettings: componentFields.componentSettings,
109
+ patternProperties: node.patternProperties || {},
88
110
  });
89
111
  entityStore.addAssemblyUnboundValues(componentFields.unboundValues);
90
112
  return deserializedNode;
@@ -1 +1 @@
1
- {"version":3,"file":"assemblyUtils.js","sources":["../../../../src/core/preview/assemblyUtils.ts"],"sourcesContent":["import { checkIsAssemblyNode, EntityStore } from '@contentful/experiences-core';\nimport type {\n ComponentPropertyValue,\n ComponentTreeNode,\n DesignValue,\n ExperienceComponentSettings,\n} from '@contentful/experiences-core/types';\n\n/** While unfolding the assembly definition on the instance, this function will replace all\n * ComponentValue in the definitions tree with the actual value on the instance. */\nexport const deserializeAssemblyNode = ({\n node,\n componentInstanceVariables,\n assemblyVariableDefinitions,\n}: {\n node: ComponentTreeNode;\n componentInstanceVariables: ComponentTreeNode['variables'];\n assemblyVariableDefinitions: ExperienceComponentSettings['variableDefinitions'];\n}): ComponentTreeNode => {\n const variables: Record<string, ComponentPropertyValue> = {};\n\n for (const [variableName, variable] of Object.entries(node.variables)) {\n variables[variableName] = variable;\n if (variable.type === 'ComponentValue') {\n const componentValueKey = variable.key;\n const instanceProperty = componentInstanceVariables[componentValueKey];\n const variableDefinition = assemblyVariableDefinitions?.[componentValueKey];\n const defaultValue = variableDefinition?.defaultValue;\n\n // For assembly, we look up the variable in the assembly instance and\n // replace the ComponentValue with that one.\n if (instanceProperty?.type === 'UnboundValue') {\n variables[variableName] = {\n type: 'UnboundValue',\n key: instanceProperty.key,\n };\n } else if (instanceProperty?.type === 'BoundValue') {\n variables[variableName] = {\n type: 'BoundValue',\n path: instanceProperty.path,\n };\n } else if (instanceProperty?.type === 'HyperlinkValue') {\n variables[variableName] = {\n type: 'HyperlinkValue',\n linkTargetKey: instanceProperty.linkTargetKey,\n };\n } else if (instanceProperty?.type === 'DesignValue') {\n variables[variableName] = {\n type: 'DesignValue',\n valuesByBreakpoint: instanceProperty.valuesByBreakpoint,\n };\n } else if (!instanceProperty && defaultValue) {\n // So far, we only automatically fallback to the defaultValue for design properties\n if (variableDefinition.group === 'style') {\n variables[variableName] = {\n type: 'DesignValue',\n valuesByBreakpoint: (defaultValue as DesignValue).valuesByBreakpoint,\n };\n }\n }\n }\n }\n\n const children: ComponentTreeNode[] = node.children.map((child) =>\n deserializeAssemblyNode({\n node: child,\n componentInstanceVariables,\n assemblyVariableDefinitions,\n }),\n );\n\n return {\n definitionId: node.definitionId,\n id: node.id,\n variables,\n children,\n slotId: node.slotId,\n displayName: node.displayName,\n };\n};\n\nexport const resolveAssembly = ({\n node,\n entityStore,\n}: {\n node: ComponentTreeNode;\n entityStore: EntityStore;\n}) => {\n const isAssembly = checkIsAssemblyNode({\n componentId: node.definitionId,\n usedComponents: entityStore.usedComponents,\n });\n\n if (!isAssembly) {\n return node;\n }\n\n const componentId = node.definitionId as string;\n const assembly = entityStore.usedComponents?.find(\n (component) => component.sys.id === componentId,\n );\n\n if (!assembly || !('fields' in assembly)) {\n return node;\n }\n\n const componentFields = assembly.fields;\n\n const deserializedNode = deserializeAssemblyNode({\n node: {\n definitionId: node.definitionId,\n id: node.id,\n variables: node.variables,\n children: componentFields.componentTree.children,\n },\n componentInstanceVariables: node.variables,\n assemblyVariableDefinitions: componentFields.componentSettings!.variableDefinitions,\n });\n\n entityStore.addAssemblyUnboundValues(componentFields.unboundValues);\n\n return deserializedNode;\n};\n"],"names":[],"mappings":";;AAQA;AACmF;AAC5E,MAAM,uBAAuB,GAAG,CAAC,EAC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EAAE,QAAQ,IAAI,QAAQ,CAAC,EAAE;AACxC,QAAA,OAAO,IAAI,CAAC;KACb;AAED,IAAA,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC;IAExC,MAAM,gBAAgB,GAAG,uBAAuB,CAAC;AAC/C,QAAA,IAAI,EAAE;YACJ,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,SAAS,EAAE,IAAI,CAAC,SAAS;AACzB,YAAA,QAAQ,EAAE,eAAe,CAAC,aAAa,CAAC,QAAQ;AACjD,SAAA;QACD,0BAA0B,EAAE,IAAI,CAAC,SAAS;AAC1C,QAAA,2BAA2B,EAAE,eAAe,CAAC,iBAAkB,CAAC,mBAAmB;AACpF,KAAA,CAAC,CAAC;AAEH,IAAA,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;AAEpE,IAAA,OAAO,gBAAgB,CAAC;AAC1B;;;;"}
1
+ {"version":3,"file":"assemblyUtils.js","sources":["../../../../src/core/preview/assemblyUtils.ts"],"sourcesContent":["import { checkIsAssemblyNode, EntityStore } from '@contentful/experiences-core';\nimport type {\n ComponentPropertyValue,\n ComponentTreeNode,\n DesignValue,\n ExperienceComponentSettings,\n PatternProperty,\n} from '@contentful/experiences-core/types';\nimport { resolvePrebindingPath, shouldUsePrebinding } from '../../utils/prebindingUtils';\n\n/** While unfolding the assembly definition on the instance, this function will replace all\n * ComponentValue in the definitions tree with the actual value on the instance. */\nexport const deserializeAssemblyNode = ({\n node,\n componentInstanceVariables,\n componentSettings,\n patternProperties,\n}: {\n node: ComponentTreeNode;\n componentInstanceVariables: ComponentTreeNode['variables'];\n componentSettings: ExperienceComponentSettings;\n patternProperties: Record<string, PatternProperty>;\n}): ComponentTreeNode => {\n const variables: Record<string, ComponentPropertyValue> = {};\n\n for (const [variableName, variable] of Object.entries(node.variables)) {\n variables[variableName] = variable;\n if (variable.type === 'ComponentValue') {\n const componentValueKey = variable.key;\n const instanceProperty = componentInstanceVariables[componentValueKey];\n const variableDefinition = componentSettings.variableDefinitions?.[componentValueKey];\n const defaultValue = variableDefinition?.defaultValue;\n\n const usePrebinding = shouldUsePrebinding({\n componentSettings,\n componentValueKey,\n patternProperties,\n variable: instanceProperty,\n });\n\n if (usePrebinding) {\n const path = resolvePrebindingPath({\n componentSettings,\n componentValueKey,\n patternProperties,\n });\n\n if (path) {\n variables[variableName] = {\n type: 'BoundValue',\n path,\n };\n }\n\n // For assembly, we look up the variable in the assembly instance and\n // replace the ComponentValue with that one.\n } else if (instanceProperty?.type === 'UnboundValue') {\n variables[variableName] = {\n type: 'UnboundValue',\n key: instanceProperty.key,\n };\n } else if (instanceProperty?.type === 'BoundValue') {\n variables[variableName] = {\n type: 'BoundValue',\n path: instanceProperty.path,\n };\n } else if (instanceProperty?.type === 'HyperlinkValue') {\n variables[variableName] = {\n type: 'HyperlinkValue',\n linkTargetKey: instanceProperty.linkTargetKey,\n };\n } else if (instanceProperty?.type === 'DesignValue') {\n variables[variableName] = {\n type: 'DesignValue',\n valuesByBreakpoint: instanceProperty.valuesByBreakpoint,\n };\n } else if (!instanceProperty && defaultValue) {\n // So far, we only automatically fallback to the defaultValue for design properties\n if (variableDefinition.group === 'style') {\n variables[variableName] = {\n type: 'DesignValue',\n valuesByBreakpoint: (defaultValue as DesignValue).valuesByBreakpoint,\n };\n }\n }\n }\n }\n\n const children: ComponentTreeNode[] = node.children.map((child) =>\n deserializeAssemblyNode({\n node: child,\n componentInstanceVariables,\n componentSettings,\n patternProperties,\n }),\n );\n\n return {\n definitionId: node.definitionId,\n id: node.id,\n variables,\n children,\n slotId: node.slotId,\n displayName: node.displayName,\n };\n};\n\nexport const resolveAssembly = ({\n node,\n entityStore,\n}: {\n node: ComponentTreeNode;\n entityStore: EntityStore;\n}) => {\n const isAssembly = checkIsAssemblyNode({\n componentId: node.definitionId,\n usedComponents: entityStore.usedComponents,\n });\n\n if (!isAssembly) {\n return node;\n }\n\n const componentId = node.definitionId as string;\n const assembly = entityStore.usedComponents?.find(\n (component) => component.sys.id === componentId,\n );\n\n if (!assembly || !('fields' in assembly)) {\n return node;\n }\n\n const componentFields = assembly.fields;\n\n const deserializedNode = deserializeAssemblyNode({\n node: {\n definitionId: node.definitionId,\n id: node.id,\n variables: node.variables,\n children: componentFields.componentTree.children,\n },\n componentInstanceVariables: node.variables,\n componentSettings: componentFields.componentSettings!,\n patternProperties: node.patternProperties || {},\n });\n\n entityStore.addAssemblyUnboundValues(componentFields.unboundValues);\n\n return deserializedNode;\n};\n"],"names":[],"mappings":";;;AAUA;AACmF;AAC5E,MAAM,uBAAuB,GAAG,CAAC,EACtC,IAAI,EACJ,0BAA0B,EAC1B,iBAAiB,EACjB,iBAAiB,GAMlB,KAAuB;IACtB,MAAM,SAAS,GAA2C,EAAE,CAAC;AAE7D,IAAA,KAAK,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;AACrE,QAAA,SAAS,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC;AACnC,QAAA,IAAI,QAAQ,CAAC,IAAI,KAAK,gBAAgB,EAAE;AACtC,YAAA,MAAM,iBAAiB,GAAG,QAAQ,CAAC,GAAG,CAAC;AACvC,YAAA,MAAM,gBAAgB,GAAG,0BAA0B,CAAC,iBAAiB,CAAC,CAAC;YACvE,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,CAAC;AACtF,YAAA,MAAM,YAAY,GAAG,kBAAkB,EAAE,YAAY,CAAC;YAEtD,MAAM,aAAa,GAAG,mBAAmB,CAAC;gBACxC,iBAAiB;gBACjB,iBAAiB;gBACjB,iBAAiB;AACjB,gBAAA,QAAQ,EAAE,gBAAgB;AAC3B,aAAA,CAAC,CAAC;YAEH,IAAI,aAAa,EAAE;gBACjB,MAAM,IAAI,GAAG,qBAAqB,CAAC;oBACjC,iBA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AA;QACD,0BAA0B,EAAE,IAAI,CAAC,SAAS;QAC1C,iBAAiB,EAAE,eAAe,CAAC,iBAAkB;AACrD,QAAA,iBAAiB,EAAE,IAAI,CAAC,iBAAiB,IAAI,EAAE;AAChD,KAAA,CAAC,CAAC;AAEH,IAAA,WAAW,CAAC,wBAAwB,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC;AAEpE,IAAA,OAAO,gBAAgB,CAAC;AAC1B;;;;"}
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import * as _contentful_experiences_core_constants from '@contentful/experiences
8
8
  export { CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, LATEST_SCHEMA_VERSION } from '@contentful/experiences-core/constants';
9
9
  import { ContentfulClientApi } from 'contentful';
10
10
 
11
- declare const SDK_VERSION = "1.32.0";
11
+ declare const SDK_VERSION = "1.33.0-beta.0";
12
12
 
13
13
  type ExperienceRootProps = {
14
14
  experience?: Experience<EntityStore> | string | null;
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = '1.32.0';
1
+ const SDK_VERSION = '1.33.0-beta.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 = '1.32.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
1
+ {"version":3,"file":"sdkVersion.js","sources":["../../src/sdkVersion.ts"],"sourcesContent":["export const SDK_VERSION = '1.33.0-beta.0';\n"],"names":[],"mappings":"AAAO,MAAM,WAAW,GAAG;;;;"}
@@ -1,11 +1,12 @@
1
1
  import { EntityStore } from '@contentful/experiences-core';
2
- import type { ComponentTreeNode, ExperienceComponentSettings } from '@contentful/experiences-core/types';
2
+ import type { ComponentTreeNode, ExperienceComponentSettings, PatternProperty } from '@contentful/experiences-core/types';
3
3
  /** While unfolding the assembly definition on the instance, this function will replace all
4
4
  * ComponentValue in the definitions tree with the actual value on the instance. */
5
- export declare const deserializeAssemblyNode: ({ node, componentInstanceVariables, assemblyVariableDefinitions, }: {
5
+ export declare const deserializeAssemblyNode: ({ node, componentInstanceVariables, componentSettings, patternProperties, }: {
6
6
  node: ComponentTreeNode;
7
7
  componentInstanceVariables: ComponentTreeNode["variables"];
8
- assemblyVariableDefinitions: ExperienceComponentSettings["variableDefinitions"];
8
+ componentSettings: ExperienceComponentSettings;
9
+ patternProperties: Record<string, PatternProperty>;
9
10
  }) => ComponentTreeNode;
10
11
  export declare const resolveAssembly: ({ node, entityStore, }: {
11
12
  node: ComponentTreeNode;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "1.32.0";
1
+ export declare const SDK_VERSION = "1.33.0-beta.0";
@@ -0,0 +1,12 @@
1
+ import { ComponentPropertyValue, ExperienceComponentSettings, PatternProperty } from '@contentful/experiences-validators';
2
+ export declare const shouldUsePrebinding: ({ componentValueKey, componentSettings, patternProperties, variable, }: {
3
+ componentValueKey: string;
4
+ componentSettings: ExperienceComponentSettings;
5
+ patternProperties: Record<string, PatternProperty>;
6
+ variable: ComponentPropertyValue;
7
+ }) => boolean;
8
+ export declare const resolvePrebindingPath: ({ componentValueKey, componentSettings, patternProperties, }: {
9
+ componentValueKey: string;
10
+ componentSettings: ExperienceComponentSettings;
11
+ patternProperties: Record<string, PatternProperty>;
12
+ }) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,24 @@
1
+ const shouldUsePrebinding = ({ componentValueKey, componentSettings, patternProperties, variable, }) => {
2
+ const { patternPropertyDefinitions, variableMappings } = componentSettings;
3
+ const variableMapping = variableMappings?.[componentValueKey];
4
+ const patternPropertyDefinition = patternPropertyDefinitions?.[variableMapping?.patternPropertyDefinitionId || ''];
5
+ const patternProperty = patternProperties?.[variableMapping?.patternPropertyDefinitionId || ''];
6
+ const isValidForPrebinding = !!patternPropertyDefinition && !!patternProperty && !!variableMapping;
7
+ return isValidForPrebinding && variable?.type === 'NoValue';
8
+ };
9
+ const resolvePrebindingPath = ({ componentValueKey, componentSettings, patternProperties, }) => {
10
+ const variableMapping = componentSettings.variableMappings?.[componentValueKey];
11
+ if (!variableMapping)
12
+ return '';
13
+ const patternProperty = patternProperties?.[variableMapping.patternPropertyDefinitionId];
14
+ if (!patternProperty)
15
+ return '';
16
+ const contentType = patternProperty.contentType;
17
+ const fieldPath = variableMapping?.pathsByContentType?.[contentType]?.path;
18
+ if (!fieldPath)
19
+ return '';
20
+ return patternProperty.path + fieldPath;
21
+ };
22
+
23
+ export { resolvePrebindingPath, shouldUsePrebinding };
24
+ //# sourceMappingURL=prebindingUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prebindingUtils.js","sources":["../../../src/utils/prebindingUtils.ts"],"sourcesContent":["import {\n ComponentPropertyValue,\n ExperienceComponentSettings,\n PatternProperty,\n} from '@contentful/experiences-validators';\n\nexport const shouldUsePrebinding = ({\n componentValueKey,\n componentSettings,\n patternProperties,\n variable,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n patternProperties: Record<string, PatternProperty>;\n variable: ComponentPropertyValue;\n}) => {\n const { patternPropertyDefinitions, variableMappings } = componentSettings;\n\n const variableMapping = variableMappings?.[componentValueKey];\n\n const patternPropertyDefinition =\n patternPropertyDefinitions?.[variableMapping?.patternPropertyDefinitionId || ''];\n const patternProperty = patternProperties?.[variableMapping?.patternPropertyDefinitionId || ''];\n\n const isValidForPrebinding =\n !!patternPropertyDefinition && !!patternProperty && !!variableMapping;\n\n return isValidForPrebinding && variable?.type === 'NoValue';\n};\n\nexport const resolvePrebindingPath = ({\n componentValueKey,\n componentSettings,\n patternProperties,\n}: {\n componentValueKey: string;\n componentSettings: ExperienceComponentSettings;\n patternProperties: Record<string, PatternProperty>;\n}) => {\n const variableMapping = componentSettings.variableMappings?.[componentValueKey];\n\n if (!variableMapping) return '';\n\n const patternProperty = patternProperties?.[variableMapping.patternPropertyDefinitionId];\n\n if (!patternProperty) return '';\n\n const contentType = patternProperty.contentType;\n\n const fieldPath = variableMapping?.pathsByContentType?.[contentType]?.path;\n\n if (!fieldPath) return '';\n\n return patternProperty.path + fieldPath;\n};\n"],"names":[],"mappings":"AAMO,MAAM,mBAAmB,GAAG,CAAC,EAClC,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,QAAQ,GAMT,KAAI;AACH,IAAA,MAAM,EAAE,0BAA0B,EAAE,gBAAgB,EAAE,GAAG,iBAAiB,CAAC;AAE3E,IAAA,MAAM,eAAe,GAAG,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;IAE9D,MAAM,yBAAyB,GAC7B,0BAA0B,GAAG,eAAe,EAAE,2BAA2B,IAAI,EAAE,CAAC,CAAC;IACnF,MAAM,eAAe,GAAG,iBAAiB,GAAG,eAAe,EAAE,2BAA2B,IAAI,EAAE,CAAC,CAAC;AAEhG,IAAA,MAAM,oBAAoB,GACxB,CAAC,CAAC,yBAAyB,IAAI,CAAC,CAAC,eAAe,IAAI,CAAC,CAAC,eAAe,CAAC;AAExE,IAAA,OAAO,oBAAoB,IAAI,QAAQ,EAAE,IAAI,KAAK,SAAS,CAAC;AAC9D,EAAE;AAEK,MAAM,qBAAqB,GAAG,CAAC,EACpC,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAKlB,KAAI;IACH,MAAM,eAAe,GAAG,iBAAiB,CAAC,gBAAgB,GAAG,iBAAiB,CAAC,CAAC;AAEhF,IAAA,IAAI,CAAC,eAAe;AAAE,QAAA,OAAO,EAAE,CAAC;IAEhC,MAAM,eAAe,GAAG,iBAAiB,GAAG,eAAe,CAAC,2BAA2B,CAAC,CAAC;AAEzF,IAAA,IAAI,CAAC,eAAe;AAAE,QAAA,OAAO,EAAE,CAAC;AAEhC,IAAA,MAAM,WAAW,GAAG,eAAe,CAAC,WAAW,CAAC;IAEhD,MAAM,SAAS,GAAG,eAAe,EAAE,kBAAkB,GAAG,WAAW,CAAC,EAAE,IAAI,CAAC;AAE3E,IAAA,IAAI,CAAC,SAAS;AAAE,QAAA,OAAO,EAAE,CAAC;AAE1B,IAAA,OAAO,eAAe,CAAC,IAAI,GAAG,SAAS,CAAC;AAC1C;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-sdk-react",
3
- "version": "1.32.0",
3
+ "version": "1.33.0-beta.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "typings": "./dist/src/index.d.ts",
@@ -41,10 +41,10 @@
41
41
  "depcruise": "depcruise src"
42
42
  },
43
43
  "dependencies": {
44
- "@contentful/experiences-components-react": "1.32.0",
45
- "@contentful/experiences-core": "1.32.0",
46
- "@contentful/experiences-validators": "1.32.0",
47
- "@contentful/experiences-visual-editor-react": "1.32.0",
44
+ "@contentful/experiences-components-react": "1.33.0-beta.0",
45
+ "@contentful/experiences-core": "1.33.0-beta.0",
46
+ "@contentful/experiences-validators": "1.33.0-beta.0",
47
+ "@contentful/experiences-visual-editor-react": "1.33.0-beta.0",
48
48
  "@contentful/rich-text-types": "^17.0.0",
49
49
  "classnames": "^2.3.2",
50
50
  "csstype": "^3.1.2",
@@ -102,5 +102,5 @@
102
102
  "dist",
103
103
  "package.json"
104
104
  ],
105
- "gitHead": "36a479f782ec0bf0ede6cc7d587594c9e1e0656a"
105
+ "gitHead": "4d0797291584eddd057dd3e6c9991ffb1ef37bd5"
106
106
  }