@contentful/experiences-core 3.7.0-prerelease-20250915T1724-8825648.0 → 3.7.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,20 +1,43 @@
1
1
  import { Breakpoint } from '@contentful/experiences-validators';
2
2
 
3
- declare let breakpointsRegistry: Breakpoint[];
3
+ declare const breakpointsRegistry: Breakpoint[];
4
4
  /**
5
- * Register custom breakpoints
6
- * @param breakpoints - [{[key:string]: string}]
7
- * @returns void
5
+ * Define custom breakpoints that should be used for all your experiences.
6
+ * A breakpoint consists of:
7
+ * - id: a unique identifier for this breakpoint
8
+ * - query: a media query string that defines when this breakpoint is active
9
+ * - previewSize: an optional fixed preview size to be used in the Studio editor when selecting this breakpoint
10
+ * - displayName: the name to be displayed in the Studio editor for this breakpoint
11
+ * - displayIcon: an optional icon to be displayed in the Studio editor for this breakpoint
12
+ *
13
+ * The first breakpoint must use a wildcard query (`*`) to match all sizes.
14
+ *
15
+ * Every subsequent breakpoint inherits the designs of the previous ones by default.
16
+ *
17
+ * The order of breakpoints must be either:
18
+ * - desktop first: from largest to smallest, using `<` operators
19
+ * - mobile first: from smallest to largest, using `>` operators
20
+ *
21
+ * @note changing breakpoints after you have created experiences may break those experiences
22
+ * @example
23
+ * defineBreakpoints([{
24
+ * id: 'desktop',
25
+ * query: '*',
26
+ * displayName: 'Desktop',
27
+ * displayIcon: 'desktop',
28
+ * }, {
29
+ * id: 'tablet',
30
+ * query: '<992px',
31
+ * displayName: 'Tablet',
32
+ * displayIcon: 'tablet',
33
+ * }, {
34
+ * id: 'mobile',
35
+ * query: '<576px',
36
+ * displayName: 'Mobile',
37
+ * displayIcon: 'mobile',
38
+ * }]);
8
39
  */
9
40
  declare const defineBreakpoints: (breakpoints: Breakpoint[]) => void;
10
41
  declare const runBreakpointsValidation: () => void;
11
- declare const getBreakpointRegistration: (id: string) => {
12
- id: string;
13
- query: "*" | `>${number}px` | `<${number}px`;
14
- previewSize: string;
15
- displayName: string;
16
- displayIcon?: "desktop" | "tablet" | "mobile" | undefined;
17
- } | undefined;
18
- declare const resetBreakpointsRegistry: () => void;
19
42
 
20
- export { breakpointsRegistry, defineBreakpoints, getBreakpointRegistration, resetBreakpointsRegistry, runBreakpointsValidation };
43
+ export { breakpointsRegistry, defineBreakpoints, runBreakpointsValidation };
package/dist/types.d.ts CHANGED
@@ -191,11 +191,6 @@ type ExperienceTreeNode = {
191
191
  id: string;
192
192
  blockId?: string;
193
193
  slotId?: string;
194
- assembly?: {
195
- id: string;
196
- componentId: string;
197
- nodeLocation: string | null;
198
- };
199
194
  displayName?: string;
200
195
  props: Record<string, ComponentPropertyValue>;
201
196
  dataSource: ExperienceDataSource;
@@ -552,6 +547,7 @@ type RequestReadOnlyModePayload = undefined;
552
547
  type RequestEditorModePayload = undefined;
553
548
  type ExperienceUpdatedPayload = {
554
549
  tree: ExperienceTree;
550
+ /** @deprecated not needed after `patternResolution` was introduced. Will be removed in the next major version. */
555
551
  assemblies?: ExperienceUsedComponents;
556
552
  locale: string;
557
553
  changedNode?: ExperienceTreeNode;
@@ -0,0 +1,46 @@
1
+ import { ExperienceEntry } from '../types.js';
2
+ import { ParameterDefinition, VariableMapping, ExperienceComponentSettings } from '@contentful/experiences-validators';
3
+
4
+ type PrebindingData = {
5
+ prebindingDefinitionId: string;
6
+ parameterIds: Array<string>;
7
+ nativeParameterId?: string;
8
+ parameterDefinitions: Record<string, ParameterDefinition>;
9
+ variableMappings?: Record<string, VariableMapping>;
10
+ };
11
+ declare const flattenNestedPatterns: (fetchedPatterns: Array<ExperienceEntry>) => ExperienceEntry[];
12
+ /**
13
+ * Given a list of patterns, extract the prebinding data into a more digestable format indexed by the pattern entry id
14
+ * @param patterns a list of pattern entries
15
+ * @returns a map of pattern entry ids to their prebinding data
16
+ */
17
+ declare const extractPrebindingDataByPatternId: (patterns: Array<ExperienceEntry>) => Record<string, PrebindingData>;
18
+ declare const generateDefaultDataSourceForPrebindingDefinition: (prebindingDefinitions?: ExperienceComponentSettings["prebindingDefinitions"]) => {
19
+ dataSource: Record<string, {
20
+ sys: {
21
+ type: "Link";
22
+ id: string;
23
+ linkType: "Entry" | "Asset";
24
+ };
25
+ }>;
26
+ parameters: Record<string, {
27
+ path: string;
28
+ type: "BoundValue";
29
+ }>;
30
+ };
31
+ declare function getTargetPatternMappingsForParameter({ fetchedPatterns, prebindingDataByPatternId, patternNodeDefinitionId, parameterId, }: {
32
+ fetchedPatterns: Array<ExperienceEntry>;
33
+ prebindingDataByPatternId: Record<string, PrebindingData>;
34
+ patternNodeDefinitionId: string;
35
+ parameterId: string;
36
+ }): {
37
+ [k: string]: {
38
+ type: "ContentTypeMapping";
39
+ parameterId: string;
40
+ pathsByContentType: Record<string, {
41
+ path: string;
42
+ }>;
43
+ };
44
+ } | undefined;
45
+
46
+ export { type PrebindingData, extractPrebindingDataByPatternId, flattenNestedPatterns, generateDefaultDataSourceForPrebindingDefinition, getTargetPatternMappingsForParameter };
@@ -1,6 +1,7 @@
1
- import * as lodash from 'lodash';
2
1
  import { PrimitiveValue } from '@contentful/experiences-validators';
3
2
 
4
- declare const sanitizeNodeProps: (nodeProps: Record<PropertyKey, PrimitiveValue>) => lodash.Omit<Record<PropertyKey, string | number | boolean | Record<any, any> | undefined>, string>;
3
+ declare const sanitizeNodeProps: (nodeProps: Record<PropertyKey, PrimitiveValue>) => {
4
+ [k: string]: string | number | boolean | Record<any, any> | undefined;
5
+ };
5
6
 
6
7
  export { sanitizeNodeProps };
@@ -23,5 +23,10 @@ interface ParsedValue {
23
23
  }
24
24
  declare function parseCSSValue(input: string): ParsedValue | null;
25
25
  declare function getTargetValueInPixels(targetWidthObject: ParsedValue): number;
26
+ /**
27
+ * Creates a component definition for an assembly. As all assemblies use the same definition in the SDK,
28
+ * all should be registered via this function.
29
+ */
30
+ declare const createAssemblyDefinition: (definitionId: string) => ComponentDefinition;
26
31
 
27
- export { checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getTargetValueInPixels, parseCSSValue };
32
+ export { checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, createAssemblyDefinition, generateRandomId, getDataFromTree, getTargetValueInPixels, parseCSSValue };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experiences-core",
3
- "version": "3.7.0-prerelease-20250915T1724-8825648.0",
3
+ "version": "3.7.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -20,8 +20,22 @@
20
20
  "dist/**/*.*"
21
21
  ],
22
22
  "exports": {
23
- ".": "./dist/index.js",
24
- "./constants": "./dist/constants.js",
23
+ ".": {
24
+ "import": "./dist/index.js",
25
+ "require": "./dist/index.cjs",
26
+ "default": "./dist/index.js",
27
+ "types": [
28
+ "./dist/index.d.ts"
29
+ ]
30
+ },
31
+ "./constants": {
32
+ "import": "./dist/constants.js",
33
+ "require": "./dist/constants.cjs",
34
+ "default": "./dist/constants.js",
35
+ "types": [
36
+ "./dist/constants.d.ts"
37
+ ]
38
+ },
25
39
  "./types": "./dist/types.d.ts"
26
40
  },
27
41
  "publishConfig": {
@@ -54,9 +68,8 @@
54
68
  "devDependencies": {
55
69
  "@rollup/plugin-commonjs": "^25.0.7",
56
70
  "@rollup/plugin-node-resolve": "^15.2.3",
57
- "@rollup/plugin-terser": "^0.4.4",
58
71
  "@rollup/plugin-typescript": "^11.1.5",
59
- "@types/lodash-es": "^4.17.12",
72
+ "@types/lodash.clonedeep": "^4.5.9",
60
73
  "@vitest/coverage-v8": "^2.1.1",
61
74
  "contentful": "^10.6.4",
62
75
  "happy-dom": "^13.3.8",
@@ -67,13 +80,13 @@
67
80
  "vitest": "^2.1.1"
68
81
  },
69
82
  "dependencies": {
70
- "@contentful/experiences-validators": "3.7.0-prerelease-20250915T1724-8825648.0",
83
+ "@contentful/experiences-validators": "3.7.0",
71
84
  "@contentful/rich-text-types": "^17.0.0",
72
- "lodash-es": "^4.17.21",
85
+ "lodash.clonedeep": "^4.5.0",
73
86
  "zustand": "^4.4.7"
74
87
  },
75
88
  "peerDependencies": {
76
89
  "contentful": ">=10.6.0"
77
90
  },
78
- "gitHead": "19c18e11e35b9261550f0cab3b54a9427987f084"
91
+ "gitHead": "0c47053b29fea11ad7e116e39c380c49c1387a8f"
79
92
  }
package/dist/exports.js DELETED
@@ -1,2 +0,0 @@
1
- export { ASSEMBLY_BLOCK_NODE_TYPE, ASSEMBLY_DEFAULT_CATEGORY, ASSEMBLY_NODE_TYPE, ASSEMBLY_NODE_TYPES, CF_STYLE_ATTRIBUTES, CONTENTFUL_COMPONENTS, CONTENTFUL_COMPONENT_CATEGORY, CONTENTFUL_DEFAULT_CATEGORY, EMPTY_CONTAINER_SIZE, HYPERLINK_DEFAULT_PATTERN, INCOMING_EVENTS, INTERNAL_EVENTS, LATEST_SCHEMA_VERSION, OUTGOING_EVENTS, PATTERN_PROPERTY_DIVIDER, PostMessageMethods, SCROLL_STATES, SIDELOADED_PREFIX, SUPPORTED_IMAGE_FORMATS, StudioCanvasMode, VISUAL_EDITOR_CONTAINER_ID, VISUAL_EDITOR_EVENTS } from './constants.js';
2
- //# sourceMappingURL=exports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"exports.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}