@contentful/experiences-core 1.42.3 → 2.0.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.
- package/dist/constants.js +0 -8
- package/dist/constants.js.map +1 -1
- package/dist/deep-binding/DeepReference.d.ts +2 -2
- package/dist/entity/EditorModeEntityStore.d.ts +0 -1
- package/dist/entity/EntityStoreBase.d.ts +8 -3
- package/dist/entity/InMemoryEntitiesPublicApi.d.ts +32 -0
- package/dist/entity/InMemoryEntitiesStore.d.ts +17 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +374 -129
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +4 -10
- package/dist/utils/breakpoints.d.ts +5 -2
- package/dist/utils/isLinkToAsset.d.ts +1 -1
- package/dist/utils/isLinkToEntry.d.ts +5 -0
- package/dist/utils/schema/experienceSchema.d.ts +23 -0
- package/dist/utils/schema/references.d.ts +18 -0
- package/dist/utils/typeguards.d.ts +11 -2
- package/dist/utils/utils.d.ts +1 -6
- package/package.json +3 -3
- package/dist/utils/entityTypeChecks.d.ts +0 -6
package/dist/types.d.ts
CHANGED
|
@@ -84,8 +84,6 @@ type ComponentRegistration = {
|
|
|
84
84
|
*/
|
|
85
85
|
enableCustomEditorView?: boolean;
|
|
86
86
|
wrapComponent?: boolean;
|
|
87
|
-
/** @deprecated use wrapContainer instead */
|
|
88
|
-
wrapContainerTag?: keyof JSX.IntrinsicElements;
|
|
89
87
|
wrapContainer?: keyof JSX.IntrinsicElements | React.ReactElement;
|
|
90
88
|
wrapContainerWidth?: React.CSSProperties['width'];
|
|
91
89
|
};
|
|
@@ -109,7 +107,7 @@ type BindingMapByBlockId = Record<string, BindingMap>;
|
|
|
109
107
|
type DataSourceEntryValueType = Link<'Entry' | 'Asset'>;
|
|
110
108
|
/** Type of a single node of the experience tree exchanged via postMessage between the SDK and Contentful Web app */
|
|
111
109
|
type ExperienceTreeNode = {
|
|
112
|
-
type: 'block' | 'root' | '
|
|
110
|
+
type: 'block' | 'root' | 'assembly' | 'assemblyBlock';
|
|
113
111
|
data: {
|
|
114
112
|
id: string;
|
|
115
113
|
blockId?: string;
|
|
@@ -310,7 +308,7 @@ type RequestedEntitiesMessage = {
|
|
|
310
308
|
entities: Array<Entry | Asset>;
|
|
311
309
|
missingEntityIds?: string[];
|
|
312
310
|
};
|
|
313
|
-
type BoundComponentPropertyTypes = string | number | boolean | AssetFile | Record<string, AssetFile | undefined> | Document | OptimizedBackgroundImageAsset | OptimizedImageAsset | Link<'Asset'> | Entry | Asset | (string | Entry | Asset<ChainModifiers, string> | undefined)[] | undefined;
|
|
311
|
+
type BoundComponentPropertyTypes = string | number | boolean | AssetFile | Record<string, AssetFile | undefined> | Document | OptimizedBackgroundImageAsset | OptimizedImageAsset | Link<'Asset'> | Link<'Entry'> | Array<Link<'Asset' | 'Entry'>> | Entry | Asset | (string | Entry | Asset<ChainModifiers, string> | undefined)[] | undefined;
|
|
314
312
|
type OptimizedImageAsset = {
|
|
315
313
|
url: string;
|
|
316
314
|
srcSet?: string[];
|
|
@@ -326,7 +324,7 @@ type OptimizedBackgroundImageAsset = {
|
|
|
326
324
|
file: AssetFile;
|
|
327
325
|
};
|
|
328
326
|
type ImageObjectFitOption = 'contain' | 'cover' | 'none';
|
|
329
|
-
type ImageObjectPositionOption = 'left
|
|
327
|
+
type ImageObjectPositionOption = 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
|
|
330
328
|
type ImageLoadingOption = 'lazy' | 'eager';
|
|
331
329
|
type ImageOptions = {
|
|
332
330
|
format?: string;
|
|
@@ -339,7 +337,7 @@ type ImageOptions = {
|
|
|
339
337
|
targetSize: string;
|
|
340
338
|
};
|
|
341
339
|
type BackgroundImageScalingOption = 'fit' | 'fill' | 'tile';
|
|
342
|
-
type BackgroundImageAlignmentOption = 'left
|
|
340
|
+
type BackgroundImageAlignmentOption = 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
|
|
343
341
|
type BackgroundImageOptions = {
|
|
344
342
|
format?: string;
|
|
345
343
|
scaling: BackgroundImageScalingOption;
|
|
@@ -472,12 +470,8 @@ type RequestReadOnlyModePayload = undefined;
|
|
|
472
470
|
type RequestEditorModePayload = undefined;
|
|
473
471
|
type ExperienceUpdatedPayload = {
|
|
474
472
|
tree: ExperienceTree;
|
|
475
|
-
/** @deprecated in favor of assemblies */
|
|
476
|
-
designComponents?: ExperienceUsedComponents;
|
|
477
473
|
assemblies?: ExperienceUsedComponents;
|
|
478
474
|
locale: string;
|
|
479
|
-
/** @deprecated maybe? */
|
|
480
|
-
defaultLocaleCode?: string;
|
|
481
475
|
changedNode?: ExperienceTreeNode;
|
|
482
476
|
changedValueType?: SelectedValueTypes;
|
|
483
477
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Breakpoint, PrimitiveValue, ValuesByBreakpoint } from '@contentful/experiences-validators';
|
|
1
|
+
import { Breakpoint, PrimitiveValue, ValuesByBreakpoint, DesignValue } from '@contentful/experiences-validators';
|
|
2
2
|
|
|
3
3
|
declare const MEDIA_QUERY_REGEXP: RegExp;
|
|
4
4
|
declare const mediaQueryMatcher: (breakpoints: Breakpoint[]) => [{
|
|
@@ -9,5 +9,8 @@ declare const getActiveBreakpointIndex: (breakpoints: Breakpoint[], mediaQueryMa
|
|
|
9
9
|
declare const getFallbackBreakpointIndex: (breakpoints: Breakpoint[]) => number;
|
|
10
10
|
declare const isValidBreakpointValue: (value: PrimitiveValue) => value is Exclude<PrimitiveValue, undefined>;
|
|
11
11
|
declare const getValueForBreakpoint: (valuesByBreakpoint: ValuesByBreakpoint | undefined, breakpoints: Breakpoint[], activeBreakpointIndex: number, fallbackBreakpointIndex: number, propertyName?: string, resolveDesignTokens?: boolean) => string | number | boolean | Record<any, any> | undefined;
|
|
12
|
+
declare function mergeDesignValuesByBreakpoint(defaultValue: DesignValue, overwriteValue: DesignValue | undefined): DesignValue;
|
|
13
|
+
declare function mergeDesignValuesByBreakpoint(defaultValue: DesignValue | undefined, overwriteValue: DesignValue): DesignValue;
|
|
14
|
+
declare function mergeDesignValuesByBreakpoint(defaultValue: DesignValue | undefined, overwriteValue: DesignValue | undefined): DesignValue | undefined;
|
|
12
15
|
|
|
13
|
-
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher };
|
|
16
|
+
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Experience, Link } from '../../types.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parses experience and extracts all leaf links that are referenced from the experience.
|
|
5
|
+
* PRECONDITION: Relies on the fact that entityStore is preloaded with all dataSource
|
|
6
|
+
* entries using include=2 (meaning that up to L3 entries are already preloaded into EntitStore).
|
|
7
|
+
*
|
|
8
|
+
* The function iterates over all entries in the entityStore (assuming they can be L1, L2, L3) and
|
|
9
|
+
* over all of their references. Any references that are NOT available in the entityStore are considered
|
|
10
|
+
* "leaf references" aka "leaf links" and are returned.
|
|
11
|
+
*
|
|
12
|
+
* The EntityStore happens to contain also entities representing patterns, which we do NOT consider
|
|
13
|
+
* as entries that point to leaf links. So we don't iterate over patterns only over entries which
|
|
14
|
+
* can be used for binding.
|
|
15
|
+
*/
|
|
16
|
+
declare const extractLeafLinksReferencedFromExperience: (experience: Experience) => {
|
|
17
|
+
assetLinks: Link<"Asset">[];
|
|
18
|
+
entryLinks: Link<"Entry">[];
|
|
19
|
+
assetIds: string[];
|
|
20
|
+
entryIds: string[];
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export { extractLeafLinksReferencedFromExperience };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Entry, UnresolvedLink } from 'contentful';
|
|
2
|
+
|
|
3
|
+
type FnShouldFollowReferencesOfEntryField = (fieldName: string, entry: Entry) => boolean;
|
|
4
|
+
declare const uniqueById: <T extends {
|
|
5
|
+
sys: {
|
|
6
|
+
id: string;
|
|
7
|
+
};
|
|
8
|
+
}>(arr: Array<T>) => T[];
|
|
9
|
+
/**
|
|
10
|
+
* Extracts all references from an entry.
|
|
11
|
+
* Handles both: reference and multi-reference fields.
|
|
12
|
+
* Returns unique array of references (even if they repeat within the entry).
|
|
13
|
+
*/
|
|
14
|
+
declare const referencesOf: (entry: Entry, fnShouldFollowReferencesOfEntryField?: FnShouldFollowReferencesOfEntryField) => UnresolvedLink<"Asset" | "Entry">[];
|
|
15
|
+
declare function extractReferencesFromEntriesAsIds(entries: Array<Entry>): [string[], string[], string[]];
|
|
16
|
+
declare function extractReferencesFromEntries(entries: Array<Entry>): [UnresolvedLink<'Entry'>[], UnresolvedLink<'Asset'>[], UnresolvedLink<'Entry' | 'Asset'>[]];
|
|
17
|
+
|
|
18
|
+
export { type FnShouldFollowReferencesOfEntryField, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, referencesOf, uniqueById };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ExperienceEntry } from '../types.js';
|
|
2
|
-
import { Entry } from 'contentful';
|
|
2
|
+
import { Entry, Asset, UnresolvedLink } from 'contentful';
|
|
3
3
|
|
|
4
4
|
declare const isExperienceEntry: (entry: ExperienceEntry | Entry) => entry is ExperienceEntry;
|
|
5
|
+
declare const isPatternEntry: (entry: Entry | ExperienceEntry) => entry is ExperienceEntry;
|
|
6
|
+
declare const isEntry: (value: unknown) => value is Entry;
|
|
7
|
+
declare const isAsset: (value: unknown) => value is Asset;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the values is an array of links.
|
|
10
|
+
* Note: we use convention where empty arrays are considered valid "arrays of links"
|
|
11
|
+
* as they don't contradict the type definition.
|
|
12
|
+
*/
|
|
13
|
+
declare const isArrayOfLinks: (value: unknown) => value is Array<UnresolvedLink<"Asset"> | UnresolvedLink<"Entry">>;
|
|
5
14
|
|
|
6
|
-
export { isExperienceEntry };
|
|
15
|
+
export { isArrayOfLinks, isAsset, isEntry, isExperienceEntry, isPatternEntry };
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -31,11 +31,6 @@ declare const checkIsAssemblyNode: ({ componentId, usedComponents, }: {
|
|
|
31
31
|
componentId: string;
|
|
32
32
|
usedComponents: ExperienceEntry["fields"]["usedComponents"];
|
|
33
33
|
}) => boolean;
|
|
34
|
-
/** @deprecated use `checkIsAssemblyNode` instead. Will be removed with SDK v5. */
|
|
35
|
-
declare const checkIsAssembly: ({ componentId, usedComponents, }: {
|
|
36
|
-
componentId: string;
|
|
37
|
-
usedComponents: ExperienceEntry["fields"]["usedComponents"];
|
|
38
|
-
}) => boolean;
|
|
39
34
|
/**
|
|
40
35
|
* This check assumes that the entry is already ensured to be an experience, i.e. the
|
|
41
36
|
* content type of the entry is an experience type with the necessary annotations.
|
|
@@ -49,4 +44,4 @@ interface ParsedValue {
|
|
|
49
44
|
declare function parseCSSValue(input: string): ParsedValue | null;
|
|
50
45
|
declare function getTargetValueInPixels(targetWidthObject: ParsedValue): number;
|
|
51
46
|
|
|
52
|
-
export {
|
|
47
|
+
export { checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentful/experiences-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"vitest": "^2.1.1"
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"@contentful/experiences-validators": "
|
|
73
|
+
"@contentful/experiences-validators": "2.0.0-beta.0",
|
|
74
74
|
"@contentful/rich-text-types": "^17.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"contentful": ">=10.6.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a7120e1a627761937b699afea0a5b6c4961cfa00"
|
|
80
80
|
}
|