@contentful/experiences-core 0.0.1-alpha.10
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/LICENSE +21 -0
- package/dist/communication/sendMessage.d.ts +6 -0
- package/dist/constants.d.ts +106 -0
- package/dist/constants.js +144 -0
- package/dist/constants.js.map +1 -0
- package/dist/deep-binding/DeepReference.d.ts +28 -0
- package/dist/definitions/components.d.ts +8 -0
- package/dist/definitions/styles.d.ts +11 -0
- package/dist/entity/EditorEntityStore.d.ts +34 -0
- package/dist/entity/EditorModeEntityStore.d.ts +29 -0
- package/dist/entity/EntityStore.d.ts +68 -0
- package/dist/entity/EntityStoreBase.d.ts +49 -0
- package/dist/enums.d.ts +6 -0
- package/dist/exports.d.ts +3 -0
- package/dist/exports.js +2 -0
- package/dist/exports.js.map +1 -0
- package/dist/fetchers/createExperience.d.ts +20 -0
- package/dist/fetchers/fetchById.d.ts +20 -0
- package/dist/fetchers/fetchBySlug.d.ts +20 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +2359 -0
- package/dist/index.js.map +1 -0
- package/dist/registries/designTokenRegistry.d.ts +12 -0
- package/dist/types.d.ts +244 -0
- package/dist/utils/breakpoints.d.ts +12 -0
- package/dist/utils/components.d.ts +4 -0
- package/dist/utils/domValues.d.ts +15 -0
- package/dist/utils/isLink.d.ts +5 -0
- package/dist/utils/isLinkToAsset.d.ts +5 -0
- package/dist/utils/pathSchema.d.ts +30 -0
- package/dist/utils/styleUtils/stylesUtils.d.ts +20 -0
- package/dist/utils/supportedModes.d.ts +5 -0
- package/dist/utils/transformers/transformBoundContentValue.d.ts +8 -0
- package/dist/utils/typeguards.d.ts +6 -0
- package/dist/utils/utils.d.ts +46 -0
- package/dist/utils/validations.d.ts +15 -0
- package/package.json +75 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { Entry, Asset, AssetFile } from 'contentful';
|
|
2
|
+
import { SCROLL_STATES, OUTGOING_EVENTS, INCOMING_EVENTS, INTERNAL_EVENTS } from './constants.js';
|
|
3
|
+
import { EntityStore } from './entity/EntityStore.js';
|
|
4
|
+
import { Document } from '@contentful/rich-text-types';
|
|
5
|
+
import { ComponentDefinitionPropertyType, ComponentPropertyValue, ExperienceDataSource, ExperienceUnboundValues, Breakpoint, ExperienceComponentTree, ExperienceUsedComponents, ExperienceComponentSettings, ValuesByBreakpoint, PrimitiveValue } from '@contentful/experiences-validators';
|
|
6
|
+
export { BoundValue, Breakpoint, ComponentDefinitionPropertyType as ComponentDefinitionVariableType, ComponentPropertyValue, ComponentTreeNode, ComponentValue, DesignValue, ExperienceComponentSettings, ExperienceDataSource, ExperienceUnboundValues, PrimitiveValue, SchemaVersions, UnboundValue, ValuesByBreakpoint } from '@contentful/experiences-validators';
|
|
7
|
+
|
|
8
|
+
type ScrollStateKey = keyof typeof SCROLL_STATES;
|
|
9
|
+
type ScrollState = (typeof SCROLL_STATES)[ScrollStateKey];
|
|
10
|
+
type OutgoingEventKey = keyof typeof OUTGOING_EVENTS;
|
|
11
|
+
type OutgoingEvent = (typeof OUTGOING_EVENTS)[OutgoingEventKey];
|
|
12
|
+
type IncomingEventKey = keyof typeof INCOMING_EVENTS;
|
|
13
|
+
type IncomingEvent = (typeof INCOMING_EVENTS)[IncomingEventKey];
|
|
14
|
+
type InternalEventKey = keyof typeof INTERNAL_EVENTS;
|
|
15
|
+
type InternalEvent = (typeof INTERNAL_EVENTS)[InternalEventKey];
|
|
16
|
+
interface Link<T extends string> {
|
|
17
|
+
sys: {
|
|
18
|
+
type: 'Link';
|
|
19
|
+
linkType: T;
|
|
20
|
+
id: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
type VariableFormats = 'URL';
|
|
24
|
+
type ValidationOption<T extends ComponentDefinitionPropertyType> = {
|
|
25
|
+
value: T extends 'Text' ? string : T extends 'Number' ? number : never;
|
|
26
|
+
displayName?: string;
|
|
27
|
+
};
|
|
28
|
+
type ComponentDefinitionVariableValidation<T extends ComponentDefinitionPropertyType> = {
|
|
29
|
+
required?: boolean;
|
|
30
|
+
in?: ValidationOption<T>[];
|
|
31
|
+
format?: VariableFormats;
|
|
32
|
+
};
|
|
33
|
+
interface ComponentDefinitionVariableBase<T extends ComponentDefinitionPropertyType> {
|
|
34
|
+
type: T;
|
|
35
|
+
validations?: ComponentDefinitionVariableValidation<T>;
|
|
36
|
+
group?: 'style' | 'content';
|
|
37
|
+
description?: string;
|
|
38
|
+
displayName?: string;
|
|
39
|
+
defaultValue?: string | boolean | number | Record<any, any>;
|
|
40
|
+
}
|
|
41
|
+
type ComponentDefinitionVariable<T extends ComponentDefinitionPropertyType = ComponentDefinitionPropertyType> = ComponentDefinitionVariableBase<T>;
|
|
42
|
+
type ComponentDefinition<T extends ComponentDefinitionPropertyType = ComponentDefinitionPropertyType> = {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
category?: string;
|
|
46
|
+
thumbnailUrl?: string;
|
|
47
|
+
variables: Partial<Record<ContainerStyleVariableName, ComponentDefinitionVariable<T>>> & Record<string, ComponentDefinitionVariable<T>>;
|
|
48
|
+
builtInStyles?: Array<keyof Omit<StyleProps, 'cfHyperlink' | 'cfOpenInNewTab'>>;
|
|
49
|
+
children?: boolean;
|
|
50
|
+
tooltip?: {
|
|
51
|
+
imageUrl?: string;
|
|
52
|
+
description: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
type ComponentRegistration = {
|
|
56
|
+
component: React.ElementType;
|
|
57
|
+
definition: ComponentDefinition;
|
|
58
|
+
options?: {
|
|
59
|
+
wrapComponent?: boolean;
|
|
60
|
+
wrapContainerTag?: keyof JSX.IntrinsicElements;
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
type ComponentRegistrationOptions = {
|
|
64
|
+
enabledBuiltInComponents?: string[];
|
|
65
|
+
};
|
|
66
|
+
type Binding = {
|
|
67
|
+
spaceId: string;
|
|
68
|
+
environmentId: string;
|
|
69
|
+
entityId: string;
|
|
70
|
+
entityType: 'Entry' | 'Asset' | 'ContentType';
|
|
71
|
+
path: string[];
|
|
72
|
+
};
|
|
73
|
+
type ComponentBinding = Record<string, Binding>;
|
|
74
|
+
type BindingMap = Record<string, ComponentBinding>;
|
|
75
|
+
type BindingMapByBlockId = Record<string, BindingMap>;
|
|
76
|
+
type DataSourceEntryValueType = Link<'Entry' | 'Asset'>;
|
|
77
|
+
/** Type of a single node of the experience tree exchanged via postMessage between the SDK and Contentful Web app */
|
|
78
|
+
type ExperienceTreeNode = {
|
|
79
|
+
type: 'block' | 'root' | 'editorRoot' | 'designComponent' | 'designComponentBlock' | 'assembly' | 'assemblyBlock';
|
|
80
|
+
data: {
|
|
81
|
+
id: string;
|
|
82
|
+
blockId?: string;
|
|
83
|
+
assembly?: {
|
|
84
|
+
id: string;
|
|
85
|
+
componentId: string;
|
|
86
|
+
nodeLocation: string | null;
|
|
87
|
+
};
|
|
88
|
+
props: Record<string, ComponentPropertyValue>;
|
|
89
|
+
dataSource: ExperienceDataSource;
|
|
90
|
+
unboundValues: ExperienceUnboundValues;
|
|
91
|
+
breakpoints: Breakpoint[];
|
|
92
|
+
};
|
|
93
|
+
children: ExperienceTreeNode[];
|
|
94
|
+
parentId?: string;
|
|
95
|
+
};
|
|
96
|
+
/** Type of the tree data structure exchanged via postMessage between the SDK and Contentful Web app */
|
|
97
|
+
type ExperienceTree = {
|
|
98
|
+
root: ExperienceTreeNode;
|
|
99
|
+
};
|
|
100
|
+
type ExternalSDKMode = 'preview' | 'delivery';
|
|
101
|
+
type InternalSDKMode = ExternalSDKMode | 'editor';
|
|
102
|
+
/**
|
|
103
|
+
* Internally defined style variables are prefix with `cf` to avoid
|
|
104
|
+
* collisions with user defined variables.
|
|
105
|
+
*/
|
|
106
|
+
type StyleProps = {
|
|
107
|
+
cfHorizontalAlignment: 'start' | 'end' | 'center';
|
|
108
|
+
cfVerticalAlignment: 'start' | 'end' | 'center';
|
|
109
|
+
cfMargin: string;
|
|
110
|
+
cfPadding: string;
|
|
111
|
+
cfBackgroundColor: string;
|
|
112
|
+
cfWidth: string;
|
|
113
|
+
cfMaxWidth: string;
|
|
114
|
+
cfHeight: string;
|
|
115
|
+
cfFlexDirection: 'row' | 'column';
|
|
116
|
+
cfFlexWrap: 'nowrap' | 'wrap';
|
|
117
|
+
cfBorder: string;
|
|
118
|
+
cfBorderRadius: string;
|
|
119
|
+
cfGap: string;
|
|
120
|
+
cfHyperlink: string;
|
|
121
|
+
cfImageAsset: OptimizedImageAsset | string;
|
|
122
|
+
cfImageOptions: ImageOptions;
|
|
123
|
+
cfBackgroundImageUrl: OptimizedBackgroundImageAsset | string;
|
|
124
|
+
cfBackgroundImageOptions: BackgroundImageOptions;
|
|
125
|
+
cfOpenInNewTab: boolean;
|
|
126
|
+
cfFontSize: string;
|
|
127
|
+
cfFontWeight: string;
|
|
128
|
+
cfLineHeight: string;
|
|
129
|
+
cfLetterSpacing: string;
|
|
130
|
+
cfTextColor: string;
|
|
131
|
+
cfTextAlign: 'left' | 'center' | 'right';
|
|
132
|
+
cfTextTransform: 'none' | 'capitalize' | 'uppercase' | 'lowercase';
|
|
133
|
+
cfTextBold: boolean;
|
|
134
|
+
cfTextItalic: boolean;
|
|
135
|
+
cfTextUnderline: boolean;
|
|
136
|
+
cfColumns: string;
|
|
137
|
+
cfColumnSpan: string;
|
|
138
|
+
cfColumnSpanLock: boolean;
|
|
139
|
+
cfWrapColumns: boolean;
|
|
140
|
+
cfWrapColumnsCount: string;
|
|
141
|
+
};
|
|
142
|
+
type CSSProperties = React.CSSProperties;
|
|
143
|
+
type ContainerStyleVariableName = keyof StyleProps;
|
|
144
|
+
type ExperienceFields = {
|
|
145
|
+
title: string;
|
|
146
|
+
slug: string;
|
|
147
|
+
componentTree: ExperienceComponentTree;
|
|
148
|
+
dataSource: ExperienceDataSource;
|
|
149
|
+
unboundValues: ExperienceUnboundValues;
|
|
150
|
+
usedComponents?: ExperienceUsedComponents | Array<ExperienceEntry>;
|
|
151
|
+
componentSettings?: ExperienceComponentSettings;
|
|
152
|
+
};
|
|
153
|
+
type RecursiveDesignTokenDefinition = {
|
|
154
|
+
[key: string]: string | RecursiveDesignTokenDefinition;
|
|
155
|
+
};
|
|
156
|
+
type DesignTokensDefinition = {
|
|
157
|
+
spacing?: Record<string, string>;
|
|
158
|
+
sizing?: Record<string, string>;
|
|
159
|
+
color?: Record<string, string>;
|
|
160
|
+
border?: Record<string, {
|
|
161
|
+
width: string;
|
|
162
|
+
style: 'solid' | 'dashed' | 'dotted';
|
|
163
|
+
color: string;
|
|
164
|
+
}>;
|
|
165
|
+
borderRadius?: Record<string, string>;
|
|
166
|
+
fontSize?: Record<string, string>;
|
|
167
|
+
lineHeight?: Record<string, string>;
|
|
168
|
+
letterSpacing?: Record<string, string>;
|
|
169
|
+
textColor?: Record<string, string>;
|
|
170
|
+
} & RecursiveDesignTokenDefinition;
|
|
171
|
+
/** Type of experience entry JSON data structure as returned by CPA/CDA */
|
|
172
|
+
type ExperienceEntry = {
|
|
173
|
+
sys: Entry['sys'];
|
|
174
|
+
fields: ExperienceFields;
|
|
175
|
+
metadata: Entry['metadata'];
|
|
176
|
+
};
|
|
177
|
+
interface RawCoordinates {
|
|
178
|
+
left: number;
|
|
179
|
+
top: number;
|
|
180
|
+
width: number;
|
|
181
|
+
height: number;
|
|
182
|
+
}
|
|
183
|
+
interface Coordinates extends RawCoordinates {
|
|
184
|
+
childrenCoordinates: RawCoordinates[];
|
|
185
|
+
}
|
|
186
|
+
interface HoveredElement {
|
|
187
|
+
blockType: string | undefined;
|
|
188
|
+
nodeId: string | undefined;
|
|
189
|
+
blockId: string | undefined;
|
|
190
|
+
}
|
|
191
|
+
interface Experience<T extends EntityStore = EntityStore> {
|
|
192
|
+
entityStore?: T;
|
|
193
|
+
}
|
|
194
|
+
type ResolveDesignValueType = (valuesByBreakpoint: ValuesByBreakpoint, variableName: string) => PrimitiveValue;
|
|
195
|
+
type ManagementEntity = (Entry | Asset) & {
|
|
196
|
+
sys: {
|
|
197
|
+
version: number;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
type RequestEntitiesMessage = {
|
|
201
|
+
entityIds: string[];
|
|
202
|
+
entityType: 'Asset' | 'Entry';
|
|
203
|
+
locale: string;
|
|
204
|
+
};
|
|
205
|
+
type RequestedEntitiesMessage = {
|
|
206
|
+
entities: Array<Entry | Asset>;
|
|
207
|
+
missingEntityIds?: string[];
|
|
208
|
+
};
|
|
209
|
+
type BoundComponentPropertyTypes = string | number | boolean | AssetFile | Record<string, AssetFile | undefined> | Document | OptimizedBackgroundImageAsset | OptimizedImageAsset | Link<'Asset'> | undefined;
|
|
210
|
+
type OptimizedImageAsset = {
|
|
211
|
+
url: string;
|
|
212
|
+
srcSet?: string[];
|
|
213
|
+
sizes?: string;
|
|
214
|
+
quality?: number;
|
|
215
|
+
format?: string;
|
|
216
|
+
file: AssetFile;
|
|
217
|
+
};
|
|
218
|
+
type OptimizedBackgroundImageAsset = {
|
|
219
|
+
url: string;
|
|
220
|
+
srcSet?: string[];
|
|
221
|
+
file: AssetFile;
|
|
222
|
+
};
|
|
223
|
+
type ImageObjectFitOption = 'contain' | 'cover' | 'none';
|
|
224
|
+
type ImageObjectPositionOption = 'left' | 'right' | 'top' | 'bottom' | 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
|
|
225
|
+
type ImageOptions = {
|
|
226
|
+
format?: string;
|
|
227
|
+
width: string;
|
|
228
|
+
height: string;
|
|
229
|
+
objectFit?: ImageObjectFitOption;
|
|
230
|
+
objectPosition?: ImageObjectPositionOption;
|
|
231
|
+
quality?: string;
|
|
232
|
+
targetSize: string;
|
|
233
|
+
};
|
|
234
|
+
type BackgroundImageScalingOption = 'fit' | 'fill' | 'tile';
|
|
235
|
+
type BackgroundImageAlignmentOption = 'left' | 'right' | 'top' | 'bottom' | 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
|
|
236
|
+
type BackgroundImageOptions = {
|
|
237
|
+
format?: string;
|
|
238
|
+
scaling: BackgroundImageScalingOption;
|
|
239
|
+
alignment: BackgroundImageAlignmentOption;
|
|
240
|
+
quality?: string;
|
|
241
|
+
targetSize: string;
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
export type { BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableValidation, ComponentRegistration, ComponentRegistrationOptions, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExternalSDKMode, HoveredElement, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingEvent, InternalEvent, InternalSDKMode, Link, ManagementEntity, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, RawCoordinates, RecursiveDesignTokenDefinition, RequestEntitiesMessage, RequestedEntitiesMessage, ResolveDesignValueType, ScrollState, StyleProps, ValidationOption, VariableFormats };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Breakpoint, ValuesByBreakpoint } from '@contentful/experiences-validators';
|
|
2
|
+
|
|
3
|
+
declare const MEDIA_QUERY_REGEXP: RegExp;
|
|
4
|
+
declare const mediaQueryMatcher: (breakpoints: Breakpoint[]) => [{
|
|
5
|
+
id: string;
|
|
6
|
+
signal: MediaQueryList;
|
|
7
|
+
}[], Record<string, boolean>];
|
|
8
|
+
declare const getActiveBreakpointIndex: (breakpoints: Breakpoint[], mediaQueryMatches: Record<string, boolean>, fallbackBreakpointIndex: number) => number;
|
|
9
|
+
declare const getFallbackBreakpointIndex: (breakpoints: Breakpoint[]) => number;
|
|
10
|
+
declare const getValueForBreakpoint: (valuesByBreakpoint: ValuesByBreakpoint, breakpoints: Breakpoint[], activeBreakpointIndex: number, variableName: string) => string | number | boolean | Record<any, any> | undefined;
|
|
11
|
+
|
|
12
|
+
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, mediaQueryMatcher };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
declare const isContentfulStructureComponent: (componentId?: string) => boolean;
|
|
2
|
+
declare const isEmptyStructureWithRelativeHeight: (children: number, componentId?: string, height?: string | number) => boolean;
|
|
3
|
+
|
|
4
|
+
export { isContentfulStructureComponent, isEmptyStructureWithRelativeHeight };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type Rect = {
|
|
2
|
+
top: number;
|
|
3
|
+
right: number;
|
|
4
|
+
bottom: number;
|
|
5
|
+
left: number;
|
|
6
|
+
};
|
|
7
|
+
declare const findOutermostCoordinates: (first: Rect, second: Rect) => {
|
|
8
|
+
top: number;
|
|
9
|
+
right: number;
|
|
10
|
+
bottom: number;
|
|
11
|
+
left: number;
|
|
12
|
+
};
|
|
13
|
+
declare const getElementCoordinates: (element: Element) => DOMRect;
|
|
14
|
+
|
|
15
|
+
export { findOutermostCoordinates, getElementCoordinates };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Entry, Asset } from 'contentful';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This module encapsulates format of the path to a deep reference.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
type UnresolvedFieldset = Array<[null, string, string?]>;
|
|
8
|
+
type Fieldset = Array<[Entry | Asset, string, string?]>;
|
|
9
|
+
declare const parseDataSourcePathIntoFieldset: (path: string) => UnresolvedFieldset;
|
|
10
|
+
/**
|
|
11
|
+
* Parse path into components, supports L1 references (one reference follow) atm.
|
|
12
|
+
* @param path from data source. eg. `/uuid123/fields/image/~locale/fields/file/~locale`
|
|
13
|
+
* eg. `/uuid123/fields/file/~locale/fields/title/~locale`
|
|
14
|
+
* @returns
|
|
15
|
+
*/
|
|
16
|
+
declare const parseDataSourcePathWithL1DeepBindings: (path: string) => {
|
|
17
|
+
key: string;
|
|
18
|
+
field: string;
|
|
19
|
+
referentField: string;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Detects if paths is valid deep-path, like:
|
|
23
|
+
* - /gV6yKXp61hfYrR7rEyKxY/fields/mainStory/~locale/fields/cover/~locale/fields/title/~locale
|
|
24
|
+
* or regular, like:
|
|
25
|
+
* - /6J8eA60yXwdm5eyUh9fX6/fields/mainStory/~locale
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
declare const isDeepPath: (deepPathCandidate: string) => boolean;
|
|
29
|
+
|
|
30
|
+
export { type Fieldset, type UnresolvedFieldset, isDeepPath, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { CSSProperties, StyleProps, ExperienceTreeNode } from '../../types.js';
|
|
2
|
+
import { PrimitiveValue } from '@contentful/experiences-validators';
|
|
3
|
+
|
|
4
|
+
declare const buildStyleTag: ({ styles, nodeId }: {
|
|
5
|
+
styles: CSSProperties;
|
|
6
|
+
nodeId?: string | undefined;
|
|
7
|
+
}) => string[];
|
|
8
|
+
declare const buildCfStyles: ({ cfHorizontalAlignment, cfVerticalAlignment, cfFlexDirection, cfFlexWrap, cfMargin, cfPadding, cfBackgroundColor, cfWidth, cfHeight, cfMaxWidth, cfBorder, cfBorderRadius, cfGap, cfBackgroundImageUrl, cfBackgroundImageOptions, cfFontSize, cfFontWeight, cfImageOptions, cfLineHeight, cfLetterSpacing, cfTextColor, cfTextAlign, cfTextTransform, cfTextBold, cfTextItalic, cfTextUnderline, cfColumnSpan, }: Partial<StyleProps>) => CSSProperties;
|
|
9
|
+
/**
|
|
10
|
+
* Container/section default behavior:
|
|
11
|
+
* Default height => height: EMPTY_CONTAINER_HEIGHT (120px)
|
|
12
|
+
* If a container component has children => height: 'fit-content'
|
|
13
|
+
*/
|
|
14
|
+
declare const calculateNodeDefaultHeight: ({ blockId, children, value, }: {
|
|
15
|
+
blockId?: string | undefined;
|
|
16
|
+
children: ExperienceTreeNode['children'];
|
|
17
|
+
value: PrimitiveValue;
|
|
18
|
+
}) => string | number | boolean | Record<any, any> | undefined;
|
|
19
|
+
|
|
20
|
+
export { buildCfStyles, buildStyleTag, calculateNodeDefaultHeight };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ResolveDesignValueType, ComponentDefinitionVariable, BoundComponentPropertyTypes } from '../../types.js';
|
|
2
|
+
import { UnresolvedLink } from 'contentful';
|
|
3
|
+
import { EntityStoreBase } from '../../entity/EntityStoreBase.js';
|
|
4
|
+
import { ComponentTreeNode } from '@contentful/experiences-validators';
|
|
5
|
+
|
|
6
|
+
declare const transformBoundContentValue: (variables: ComponentTreeNode['variables'], entityStore: EntityStoreBase, binding: UnresolvedLink<'Entry' | 'Asset'>, resolveDesignValue: ResolveDesignValueType, variableName: string, variableDefinition: ComponentDefinitionVariable, path: string) => BoundComponentPropertyTypes;
|
|
7
|
+
|
|
8
|
+
export { transformBoundContentValue };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ExperienceTree, ExperienceEntry, ComponentDefinition, ExperienceTreeNode, StyleProps } from '../types.js';
|
|
2
|
+
import { Entry } from 'contentful';
|
|
3
|
+
import { ExperienceDataSource, ExperienceUnboundValues } from '@contentful/experiences-validators';
|
|
4
|
+
|
|
5
|
+
declare const getDataFromTree: (tree: ExperienceTree) => {
|
|
6
|
+
dataSource: ExperienceDataSource;
|
|
7
|
+
unboundValues: ExperienceUnboundValues;
|
|
8
|
+
};
|
|
9
|
+
type GetInsertionDataParams = {
|
|
10
|
+
dropReceiverNode: ExperienceTreeNode;
|
|
11
|
+
dropReceiverParentNode: ExperienceTreeNode;
|
|
12
|
+
flexDirection?: StyleProps['cfFlexDirection'];
|
|
13
|
+
isMouseAtTopBorder: boolean;
|
|
14
|
+
isMouseAtBottomBorder: boolean;
|
|
15
|
+
isMouseInLeftHalf: boolean;
|
|
16
|
+
isMouseInUpperHalf: boolean;
|
|
17
|
+
isOverTopIndicator: boolean;
|
|
18
|
+
isOverBottomIndicator: boolean;
|
|
19
|
+
};
|
|
20
|
+
type InsertionData = {
|
|
21
|
+
node: ExperienceTreeNode;
|
|
22
|
+
index: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Gets calculates the index to drop the dragged component based on the mouse position
|
|
26
|
+
* @returns {InsertionData} a object containing a node that will become a parent for dragged component and index at which it must be inserted
|
|
27
|
+
*/
|
|
28
|
+
declare const getInsertionData: ({ dropReceiverParentNode, dropReceiverNode, flexDirection, isMouseAtTopBorder, isMouseAtBottomBorder, isMouseInLeftHalf, isMouseInUpperHalf, isOverTopIndicator, isOverBottomIndicator, }: GetInsertionDataParams) => InsertionData;
|
|
29
|
+
declare const generateRandomId: (letterCount: number) => string;
|
|
30
|
+
declare const checkIsAssemblyNode: ({ componentId, usedComponents, }: {
|
|
31
|
+
componentId: string;
|
|
32
|
+
usedComponents: ExperienceEntry['fields']['usedComponents'];
|
|
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
|
+
/**
|
|
40
|
+
* This check assumes that the entry is already ensured to be an experience, i.e. the
|
|
41
|
+
* content type of the entry is an experience type with the necessary annotations.
|
|
42
|
+
**/
|
|
43
|
+
declare const checkIsAssemblyEntry: (entry: Entry) => boolean;
|
|
44
|
+
declare const checkIsAssemblyDefinition: (component?: ComponentDefinition) => boolean;
|
|
45
|
+
|
|
46
|
+
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IncomingEvent } from '../types.js';
|
|
2
|
+
|
|
3
|
+
type VisualEditorMessagePayload = {
|
|
4
|
+
source: string;
|
|
5
|
+
eventType: IncomingEvent;
|
|
6
|
+
payload: any;
|
|
7
|
+
};
|
|
8
|
+
declare const doesMismatchMessageSchema: (event: MessageEvent) => false | string;
|
|
9
|
+
declare const tryParseMessage: (event: MessageEvent) => VisualEditorMessagePayload;
|
|
10
|
+
declare const validateExperienceBuilderConfig: ({ locale, isEditorMode, }: {
|
|
11
|
+
locale: string;
|
|
12
|
+
isEditorMode: boolean;
|
|
13
|
+
}) => void;
|
|
14
|
+
|
|
15
|
+
export { type VisualEditorMessagePayload, doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig };
|
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@contentful/experiences-core",
|
|
3
|
+
"version": "0.0.1-alpha.10",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/contentful/experience-builder.git"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"readme.md",
|
|
15
|
+
"package.json",
|
|
16
|
+
"dist/**/*.*"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./dist/index.js",
|
|
20
|
+
"./constants": "./dist/constants.js"
|
|
21
|
+
},
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"registry": "https://npm.pkg.github.com/"
|
|
24
|
+
},
|
|
25
|
+
"typesVersions": {
|
|
26
|
+
"*": {
|
|
27
|
+
"types": [
|
|
28
|
+
"./dist/types.d.ts"
|
|
29
|
+
],
|
|
30
|
+
"constants": [
|
|
31
|
+
"./dist/constants.d.ts"
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"clean": "rimraf dist",
|
|
37
|
+
"prebuild": "npm run clean",
|
|
38
|
+
"build": "rollup -c ./rollup.config.mjs",
|
|
39
|
+
"predev": "npm run clean",
|
|
40
|
+
"dev": "rollup -c ./rollup.config.mjs --watch --environment DEV",
|
|
41
|
+
"lint": "eslint src --ext '.ts,.tsx,.js,.jsx' --max-warnings 0 --ignore-path ../../.eslintignore",
|
|
42
|
+
"lint:fix": "eslint src --ext '.ts,.tsx,.js,.jsx' --fix",
|
|
43
|
+
"test": "vitest",
|
|
44
|
+
"test:coverage": "vitest run --coverage",
|
|
45
|
+
"depcruise": "depcruise src"
|
|
46
|
+
},
|
|
47
|
+
"author": "",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
51
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
52
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
53
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
54
|
+
"@types/lodash-es": "^4.17.12",
|
|
55
|
+
"@typescript-eslint/eslint-plugin": "^7.0.2",
|
|
56
|
+
"@typescript-eslint/parser": "^7.0.2",
|
|
57
|
+
"@vitest/coverage-v8": "^1.0.4",
|
|
58
|
+
"contentful": "^10.6.4",
|
|
59
|
+
"eslint": "^8.54.0",
|
|
60
|
+
"happy-dom": "^13.3.8",
|
|
61
|
+
"rimraf": "^5.0.5",
|
|
62
|
+
"rollup-plugin-dts": "^6.1.0",
|
|
63
|
+
"rollup-plugin-ts": "^3.4.5",
|
|
64
|
+
"vite-tsconfig-paths": "^4.2.2",
|
|
65
|
+
"vitest": "^1.0.4"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {
|
|
68
|
+
"@contentful/experiences-validators": "0.0.1-alpha.6",
|
|
69
|
+
"@contentful/rich-text-types": "^16.3.0"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"contentful": ">=10.6.0"
|
|
73
|
+
},
|
|
74
|
+
"gitHead": "0ceb98b028d0d11f3c76c6c48e016fe8a10e9339"
|
|
75
|
+
}
|