@contentful/experiences-core 1.9.0-dev-20240628T2235-7a4f71f.0 → 1.9.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.
Files changed (39) hide show
  1. package/dist/communication/sendMessage.d.ts +5 -0
  2. package/dist/constants.d.ts +112 -0
  3. package/dist/constants.js +150 -0
  4. package/dist/constants.js.map +1 -0
  5. package/dist/deep-binding/DeepReference.d.ts +27 -0
  6. package/dist/definitions/components.d.ts +9 -0
  7. package/dist/definitions/styles.d.ts +12 -0
  8. package/dist/entity/EditorEntityStore.d.ts +34 -0
  9. package/dist/entity/EditorModeEntityStore.d.ts +29 -0
  10. package/dist/entity/EntityStore.d.ts +69 -0
  11. package/dist/entity/EntityStoreBase.d.ts +49 -0
  12. package/dist/enums.d.ts +6 -0
  13. package/dist/exports.d.ts +3 -0
  14. package/dist/exports.js +2 -0
  15. package/dist/exports.js.map +1 -0
  16. package/dist/fetchers/createExperience.d.ts +20 -0
  17. package/dist/fetchers/fetchById.d.ts +20 -0
  18. package/dist/fetchers/fetchBySlug.d.ts +20 -0
  19. package/dist/index.d.ts +27 -0
  20. package/dist/index.js +3370 -0
  21. package/dist/index.js.map +1 -0
  22. package/dist/registries/breakpointsRegistry.d.ts +20 -0
  23. package/dist/registries/designTokenRegistry.d.ts +13 -0
  24. package/dist/types.d.ts +451 -0
  25. package/dist/utils/breakpoints.d.ts +12 -0
  26. package/dist/utils/components.d.ts +5 -0
  27. package/dist/utils/domValues.d.ts +15 -0
  28. package/dist/utils/isLink.d.ts +5 -0
  29. package/dist/utils/isLinkToAsset.d.ts +5 -0
  30. package/dist/utils/pathSchema.d.ts +31 -0
  31. package/dist/utils/resolveHyperlinkPattern.d.ts +17 -0
  32. package/dist/utils/styleUtils/ssrStyles.d.ts +51 -0
  33. package/dist/utils/styleUtils/stylesUtils.d.ts +21 -0
  34. package/dist/utils/supportedModes.d.ts +5 -0
  35. package/dist/utils/transformers/transformBoundContentValue.d.ts +8 -0
  36. package/dist/utils/typeguards.d.ts +6 -0
  37. package/dist/utils/utils.d.ts +46 -0
  38. package/dist/utils/validations.d.ts +10 -0
  39. package/package.json +3 -3
@@ -0,0 +1,20 @@
1
+ import { Breakpoint } from '@contentful/experiences-validators';
2
+
3
+ declare let breakpointsRegistry: Breakpoint[];
4
+ /**
5
+ * Register custom breakpoints
6
+ * @param breakpoints - [{[key:string]: string}]
7
+ * @returns void
8
+ */
9
+ declare const defineBreakpoints: (breakpoints: Breakpoint[]) => void;
10
+ declare const runBreakpointsValidation: () => void;
11
+ declare const getBreakpointRegistration: (id: string) => {
12
+ id: string;
13
+ displayName: string;
14
+ query: string;
15
+ previewSize: string;
16
+ displayIcon?: "desktop" | "tablet" | "mobile" | undefined;
17
+ } | undefined;
18
+ declare const resetBreakpointsRegistry: () => void;
19
+
20
+ export { breakpointsRegistry, defineBreakpoints, getBreakpointRegistration, resetBreakpointsRegistry, runBreakpointsValidation };
@@ -0,0 +1,13 @@
1
+ import { DesignTokensDefinition } from '../types.js';
2
+
3
+ declare let designTokensRegistry: DesignTokensDefinition;
4
+ /**
5
+ * Register design tokens styling
6
+ * @param designTokenDefinition - {[key:string]: Record<string, string>}
7
+ * @returns void
8
+ */
9
+ declare const defineDesignTokens: (designTokenDefinition: DesignTokensDefinition) => void;
10
+ declare const getDesignTokenRegistration: (breakpointValue: string, variableName: string) => string;
11
+ declare const resetDesignTokenRegistry: () => void;
12
+
13
+ export { defineDesignTokens, designTokensRegistry, getDesignTokenRegistration, resetDesignTokenRegistry };
@@ -0,0 +1,451 @@
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
+ hyperlinkPattern?: string;
48
+ variables: Partial<Record<ContainerStyleVariableName, ComponentDefinitionVariable<T>>> & Record<string, ComponentDefinitionVariable<T>>;
49
+ slots?: Record<string, {
50
+ displayName: string;
51
+ }>;
52
+ builtInStyles?: Array<keyof Omit<StyleProps, 'cfHyperlink' | 'cfOpenInNewTab'>>;
53
+ children?: boolean;
54
+ tooltip?: {
55
+ imageUrl?: string;
56
+ description: string;
57
+ };
58
+ };
59
+ type ComponentRegistration = {
60
+ component: React.ElementType;
61
+ definition: ComponentDefinition;
62
+ options?: {
63
+ wrapComponent?: boolean;
64
+ /** @deprecated use wrapContainer instead */
65
+ wrapContainerTag?: keyof JSX.IntrinsicElements;
66
+ wrapContainer?: keyof JSX.IntrinsicElements | React.ReactElement;
67
+ };
68
+ };
69
+ type ComponentRegistrationOptions = {
70
+ enabledBuiltInComponents?: string[];
71
+ };
72
+ type Binding = {
73
+ spaceId: string;
74
+ environmentId: string;
75
+ entityId: string;
76
+ entityType: 'Entry' | 'Asset' | 'ContentType';
77
+ path: string[];
78
+ };
79
+ type ComponentBinding = Record<string, Binding>;
80
+ type BindingMap = Record<string, ComponentBinding>;
81
+ type BindingMapByBlockId = Record<string, BindingMap>;
82
+ type DataSourceEntryValueType = Link<'Entry' | 'Asset'>;
83
+ /** Type of a single node of the experience tree exchanged via postMessage between the SDK and Contentful Web app */
84
+ type ExperienceTreeNode = {
85
+ type: 'block' | 'root' | 'editorRoot' | 'designComponent' | 'designComponentBlock' | 'assembly' | 'assemblyBlock';
86
+ data: {
87
+ id: string;
88
+ blockId?: string;
89
+ slotId?: string;
90
+ assembly?: {
91
+ id: string;
92
+ componentId: string;
93
+ nodeLocation: string | null;
94
+ };
95
+ displayName?: string;
96
+ props: Record<string, ComponentPropertyValue>;
97
+ dataSource: ExperienceDataSource;
98
+ unboundValues: ExperienceUnboundValues;
99
+ breakpoints: Breakpoint[];
100
+ };
101
+ children: ExperienceTreeNode[];
102
+ parentId?: string;
103
+ };
104
+ /** Type of the tree data structure exchanged via postMessage between the SDK and Contentful Web app */
105
+ type ExperienceTree = {
106
+ root: ExperienceTreeNode;
107
+ };
108
+ type ExternalSDKMode = 'preview' | 'delivery';
109
+ type InternalSDKMode = ExternalSDKMode | 'editor';
110
+ /**
111
+ * Internally defined style variables are prefix with `cf` to avoid
112
+ * collisions with user defined variables.
113
+ */
114
+ type StyleProps = {
115
+ cfHorizontalAlignment: 'start' | 'end' | 'center';
116
+ cfVerticalAlignment: 'start' | 'end' | 'center';
117
+ cfMargin: string;
118
+ cfPadding: string;
119
+ cfBackgroundColor: string;
120
+ cfWidth: string;
121
+ cfMaxWidth: string;
122
+ cfHeight: string;
123
+ cfFlexDirection: 'row' | 'column';
124
+ cfFlexWrap: 'nowrap' | 'wrap';
125
+ cfBorder: string;
126
+ cfBorderRadius: string;
127
+ cfGap: string;
128
+ cfHyperlink: string;
129
+ cfImageAsset: OptimizedImageAsset | string;
130
+ cfImageOptions: ImageOptions;
131
+ cfBackgroundImageUrl: OptimizedBackgroundImageAsset | string;
132
+ cfBackgroundImageOptions: BackgroundImageOptions;
133
+ cfOpenInNewTab: boolean;
134
+ cfFontSize: string;
135
+ cfFontWeight: string;
136
+ cfLineHeight: string;
137
+ cfLetterSpacing: string;
138
+ cfTextColor: string;
139
+ cfTextAlign: 'left' | 'center' | 'right';
140
+ cfTextTransform: 'none' | 'capitalize' | 'uppercase' | 'lowercase';
141
+ cfTextBold: boolean;
142
+ cfTextItalic: boolean;
143
+ cfTextUnderline: boolean;
144
+ cfColumns: string;
145
+ cfColumnSpan: string;
146
+ cfColumnSpanLock: boolean;
147
+ cfWrapColumns: boolean;
148
+ cfWrapColumnsCount: string;
149
+ };
150
+ type CSSProperties = React.CSSProperties;
151
+ type ContainerStyleVariableName = keyof StyleProps;
152
+ type ExperienceFields = {
153
+ title: string;
154
+ slug: string;
155
+ componentTree: ExperienceComponentTree;
156
+ dataSource: ExperienceDataSource;
157
+ unboundValues: ExperienceUnboundValues;
158
+ usedComponents?: ExperienceUsedComponents | Array<ExperienceEntry>;
159
+ componentSettings?: ExperienceComponentSettings;
160
+ };
161
+ type RecursiveDesignTokenDefinition = {
162
+ [key: string]: string | RecursiveDesignTokenDefinition;
163
+ };
164
+ type DesignTokensDefinition = {
165
+ spacing?: Record<string, string>;
166
+ sizing?: Record<string, string>;
167
+ color?: Record<string, string>;
168
+ border?: Record<string, {
169
+ width?: string;
170
+ style?: 'solid' | 'dashed' | 'dotted';
171
+ color?: string;
172
+ }>;
173
+ borderRadius?: Record<string, string>;
174
+ fontSize?: Record<string, string>;
175
+ lineHeight?: Record<string, string>;
176
+ letterSpacing?: Record<string, string>;
177
+ textColor?: Record<string, string>;
178
+ } & RecursiveDesignTokenDefinition;
179
+ /** Type of experience entry JSON data structure as returned by CPA/CDA */
180
+ type ExperienceEntry = {
181
+ sys: Entry['sys'];
182
+ fields: ExperienceFields;
183
+ metadata: Entry['metadata'];
184
+ };
185
+ interface RawCoordinates {
186
+ left: number;
187
+ top: number;
188
+ width: number;
189
+ height: number;
190
+ }
191
+ interface Coordinates extends RawCoordinates {
192
+ childrenCoordinates: RawCoordinates[];
193
+ }
194
+ interface HoveredElement {
195
+ blockType: string | undefined;
196
+ nodeId: string | undefined;
197
+ blockId: string | undefined;
198
+ }
199
+ interface Experience<T extends EntityStore = EntityStore> {
200
+ hyperlinkPattern?: string;
201
+ entityStore?: T;
202
+ }
203
+ type ResolveDesignValueType = (valuesByBreakpoint: ValuesByBreakpoint, variableName: string) => PrimitiveValue;
204
+ type ManagementEntity = (Entry | Asset) & {
205
+ sys: {
206
+ version: number;
207
+ };
208
+ };
209
+ type RequestEntitiesMessage = {
210
+ entityIds: string[];
211
+ entityType: 'Asset' | 'Entry';
212
+ locale: string;
213
+ };
214
+ type RequestedEntitiesMessage = {
215
+ entities: Array<Entry | Asset>;
216
+ missingEntityIds?: string[];
217
+ };
218
+ type BoundComponentPropertyTypes = string | number | boolean | AssetFile | Record<string, AssetFile | undefined> | Document | OptimizedBackgroundImageAsset | OptimizedImageAsset | Link<'Asset'> | undefined;
219
+ type OptimizedImageAsset = {
220
+ url: string;
221
+ srcSet?: string[];
222
+ sizes?: string;
223
+ quality?: number;
224
+ format?: string;
225
+ file: AssetFile;
226
+ loading?: ImageLoadingOption;
227
+ };
228
+ type OptimizedBackgroundImageAsset = {
229
+ url: string;
230
+ srcSet?: string[];
231
+ file: AssetFile;
232
+ };
233
+ type ImageObjectFitOption = 'contain' | 'cover' | 'none';
234
+ type ImageObjectPositionOption = 'left' | 'right' | 'top' | 'bottom' | 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
235
+ type ImageLoadingOption = 'lazy' | 'eager';
236
+ type ImageOptions = {
237
+ format?: string;
238
+ width: string;
239
+ height: string;
240
+ loading?: ImageLoadingOption;
241
+ objectFit?: ImageObjectFitOption;
242
+ objectPosition?: ImageObjectPositionOption;
243
+ quality?: string;
244
+ targetSize: string;
245
+ };
246
+ type BackgroundImageScalingOption = 'fit' | 'fill' | 'tile';
247
+ type BackgroundImageAlignmentOption = 'left' | 'right' | 'top' | 'bottom' | 'left top' | 'left center' | 'left bottom' | 'right top' | 'right center' | 'right bottom' | 'center top' | 'center center' | 'center bottom';
248
+ type BackgroundImageOptions = {
249
+ format?: string;
250
+ scaling: BackgroundImageScalingOption;
251
+ alignment: BackgroundImageAlignmentOption;
252
+ quality?: string;
253
+ targetSize: string;
254
+ };
255
+ interface DraggableProvidedDraggableProps {
256
+ 'data-rfd-draggable-context-id'?: string;
257
+ 'data-rfd-draggable-id'?: string;
258
+ }
259
+ interface DraggableProvidedDragHandleProps {
260
+ 'data-rfd-drag-handle-draggable-id'?: string;
261
+ 'data-rfd-drag-handle-context-id'?: string;
262
+ }
263
+ type WrapperTags = keyof Pick<JSX.IntrinsicElements, 'div' | 'span' | 'section' | 'article' | 'aside' | 'p' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'header' | 'footer' | 'nav' | 'main'>;
264
+ interface DragWrapperProps extends DraggableProvidedDragHandleProps, DraggableProvidedDraggableProps, React.HTMLAttributes<HTMLElement>, React.PropsWithChildren {
265
+ 'data-cf-node-id'?: string;
266
+ 'data-ctfl-draggable-id'?: string;
267
+ 'data-test-id'?: string;
268
+ 'data-cf-node-block-id'?: string;
269
+ 'data-cf-node-block-type'?: string;
270
+ 'data-ctfl-dragging-element'?: string;
271
+ innerRef?: (refNode: HTMLElement) => void;
272
+ wrapComponent?: boolean;
273
+ Tag?: WrapperTags;
274
+ ToolTipAndPlaceholder?: React.ReactNode;
275
+ }
276
+ type ConnectedPayload = undefined | {
277
+ sdkVersion: string;
278
+ definitions: ComponentDefinition[];
279
+ };
280
+ type DesignTokensPayload = {
281
+ designTokens: DesignTokensDefinition;
282
+ resolvedCssVariables: Record<string, string>;
283
+ };
284
+ type RegisteredBreakpointsPayload = {
285
+ breakpoints: Breakpoint[];
286
+ };
287
+ type MouseMovePayload = {
288
+ clientX: number;
289
+ clientY: number;
290
+ };
291
+ type NewHoveredElementPayload = {
292
+ nodeId?: string;
293
+ };
294
+ type ComponentSelectedPayload = {
295
+ nodeId: string;
296
+ assembly?: {
297
+ id: string;
298
+ componentId: string;
299
+ nodeLocation: string | null;
300
+ };
301
+ };
302
+ type RegisteredComponentsPayload = {
303
+ definitions: ComponentDefinition[];
304
+ };
305
+ type RequestComponentTreeUpdatePayload = undefined;
306
+ type ComponentDragCanceledPayload = undefined;
307
+ type ComponentDroppedPayload = {
308
+ node: ExperienceTreeNode;
309
+ index: number;
310
+ parentNode: {
311
+ type?: ExperienceTreeNode['type'] | 'root';
312
+ data: {
313
+ blockId?: string;
314
+ id?: string;
315
+ };
316
+ };
317
+ };
318
+ type ComponentMovedPayload = {
319
+ nodeId: string;
320
+ sourceParentId: string;
321
+ destinationParentId: string;
322
+ sourceIndex: number;
323
+ destinationIndex: number;
324
+ };
325
+ type CanvasReloadPayload = undefined;
326
+ type CanvasErrorPayload = Error;
327
+ type UpdateSelectedComponentCoordinatesPayload = {
328
+ selectedNodeCoordinates: DOMRect;
329
+ selectedAssemblyChildCoordinates?: DOMRect;
330
+ parentCoordinates?: DOMRect;
331
+ };
332
+ type CanvasScrollPayload = (typeof SCROLL_STATES)[keyof typeof SCROLL_STATES];
333
+ type ComponentMoveStartedPayload = undefined;
334
+ type ComponentMoveEndedPayload = undefined;
335
+ type OutsideCanvasClickPayload = {
336
+ outsideCanvasClick: boolean;
337
+ };
338
+ type SDKFeaturesPayload = Record<string, unknown>;
339
+ type RequestEntitiesPayload = {
340
+ entityIds: string[];
341
+ entityType: 'Entry' | 'Asset';
342
+ locale: string;
343
+ };
344
+ type OUTGOING_EVENT_PAYLOADS = {
345
+ connected: ConnectedPayload;
346
+ registerDesignTokens: DesignTokensPayload;
347
+ registeredBreakpoints: RegisteredBreakpointsPayload;
348
+ mouseMove: MouseMovePayload;
349
+ newHoveredElement: NewHoveredElementPayload;
350
+ componentSelected: ComponentSelectedPayload;
351
+ registeredComponents: RegisteredComponentsPayload;
352
+ requestComponentTreeUpdate: RequestComponentTreeUpdatePayload;
353
+ componentDragCanceled: ComponentDragCanceledPayload;
354
+ componentDropped: ComponentDroppedPayload;
355
+ componentMoved: ComponentMovedPayload;
356
+ canvasReload: CanvasReloadPayload;
357
+ canvasError: CanvasErrorPayload;
358
+ updateSelectedComponentCoordinates: UpdateSelectedComponentCoordinatesPayload;
359
+ canvasScrolling: CanvasScrollPayload;
360
+ componentMoveStarted: ComponentMoveStartedPayload;
361
+ componentMoveEnded: ComponentMoveEndedPayload;
362
+ outsideCanvasClick: OutsideCanvasClickPayload;
363
+ sdkFeatures: SDKFeaturesPayload;
364
+ REQUEST_ENTITIES: RequestEntitiesPayload;
365
+ };
366
+ type SendMessageParams = <T extends OutgoingEvent>(eventType: T, data: OUTGOING_EVENT_PAYLOADS[T]) => void;
367
+ type OutgoingMessage = {
368
+ [K in keyof OUTGOING_EVENT_PAYLOADS]: {
369
+ source: 'customer-app';
370
+ eventType: K;
371
+ payload: OUTGOING_EVENT_PAYLOADS[K];
372
+ };
373
+ }[keyof OUTGOING_EVENT_PAYLOADS];
374
+ type Filter<T, U> = T extends U ? T : never;
375
+ type SelectedValueTypes = Filter<ComponentPropertyValue['type'], 'UnboundValue' | 'BoundValue'>;
376
+ type RequestEditorModePayload = undefined;
377
+ type ExperienceUpdatedPayload = {
378
+ tree: ExperienceTree;
379
+ /** @deprecated in favor of assemblies */
380
+ designComponents?: ExperienceUsedComponents;
381
+ assemblies?: ExperienceUsedComponents;
382
+ locale: string;
383
+ /** @deprecated maybe? */
384
+ defaultLocaleCode?: string;
385
+ changedNode?: ExperienceTreeNode;
386
+ changedValueType?: SelectedValueTypes;
387
+ };
388
+ type ComponentDraggingChangedPayload = {
389
+ isDragging: boolean;
390
+ };
391
+ type IncomingComponentDragCanceledPayload = undefined;
392
+ type ComponentDragStartedPayload = {
393
+ id: string;
394
+ };
395
+ type ComponentDragEndedPayload = undefined;
396
+ type IncomingComponentMoveEndedPayload = {
397
+ mouseX: number;
398
+ mouseY: number;
399
+ };
400
+ type CanvasResizedPayload = {
401
+ selectedNodeId: string;
402
+ };
403
+ type SelectComponentPayload = {
404
+ selectedNodeId: string;
405
+ };
406
+ type HoverComponentPayload = {
407
+ hoveredNodeId: string;
408
+ };
409
+ type UpdatedEntityPayload = {
410
+ entity: ManagementEntity;
411
+ shouldRerender?: boolean;
412
+ };
413
+ type AssembliesAddedPayload = {
414
+ assembly: ManagementEntity;
415
+ assemblyDefinition: ComponentDefinition;
416
+ };
417
+ type AssembliesRegisteredPayload = {
418
+ assemblies: ComponentDefinition[];
419
+ };
420
+ type IncomingMouseMovePayload = {
421
+ mouseX: number;
422
+ mouseY: number;
423
+ };
424
+ type RequestedEntitiesPayload = {
425
+ entities: ManagementEntity[];
426
+ };
427
+ type INCOMING_EVENT_PAYLOADS = {
428
+ requestEditorMode: RequestEditorModePayload;
429
+ componentTreeUpdated: ExperienceUpdatedPayload;
430
+ componentDraggingChanged: ComponentDraggingChangedPayload;
431
+ componentDragCanceled: IncomingComponentDragCanceledPayload;
432
+ componentDragStarted: ComponentDragStartedPayload;
433
+ componentDragEnded: ComponentDragEndedPayload;
434
+ componentMoveEnded: IncomingComponentMoveEndedPayload;
435
+ canvasResized: CanvasResizedPayload;
436
+ selectComponent: SelectComponentPayload;
437
+ hoverComponent: HoverComponentPayload;
438
+ updatedEntity: UpdatedEntityPayload;
439
+ assembliesAdded: AssembliesAddedPayload;
440
+ assembliesRegistered: AssembliesRegisteredPayload;
441
+ mouseMove: IncomingMouseMovePayload;
442
+ REQUESTED_ENTITIES: RequestedEntitiesPayload;
443
+ };
444
+ type IncomingMessage = {
445
+ [K in keyof INCOMING_EVENT_PAYLOADS]: {
446
+ eventType: K;
447
+ payload: INCOMING_EVENT_PAYLOADS[K];
448
+ };
449
+ }[keyof INCOMING_EVENT_PAYLOADS];
450
+
451
+ export type { AssembliesAddedPayload, AssembliesRegisteredPayload, BackgroundImageAlignmentOption, BackgroundImageOptions, BackgroundImageScalingOption, Binding, BindingMap, BindingMapByBlockId, BoundComponentPropertyTypes, CSSProperties, CanvasErrorPayload, CanvasReloadPayload, CanvasResizedPayload, CanvasScrollPayload, ComponentBinding, ComponentDefinition, ComponentDefinitionVariable, ComponentDefinitionVariableBase, ComponentDefinitionVariableValidation, ComponentDragCanceledPayload, ComponentDragEndedPayload, ComponentDragStartedPayload, ComponentDraggingChangedPayload, ComponentDroppedPayload, ComponentMoveEndedPayload, ComponentMoveStartedPayload, ComponentMovedPayload, ComponentRegistration, ComponentRegistrationOptions, ComponentSelectedPayload, ConnectedPayload, ContainerStyleVariableName, Coordinates, DataSourceEntryValueType, DesignTokensDefinition, DesignTokensPayload, DragWrapperProps, Experience, ExperienceEntry, ExperienceFields, ExperienceTree, ExperienceTreeNode, ExperienceUpdatedPayload, ExternalSDKMode, HoverComponentPayload, HoveredElement, ImageLoadingOption, ImageObjectFitOption, ImageObjectPositionOption, ImageOptions, IncomingComponentDragCanceledPayload, IncomingComponentMoveEndedPayload, IncomingEvent, IncomingMessage, IncomingMouseMovePayload, InternalEvent, InternalSDKMode, Link, ManagementEntity, MouseMovePayload, NewHoveredElementPayload, OptimizedBackgroundImageAsset, OptimizedImageAsset, OutgoingEvent, OutgoingMessage, OutsideCanvasClickPayload, RawCoordinates, RecursiveDesignTokenDefinition, RegisteredBreakpointsPayload, RegisteredComponentsPayload, RequestComponentTreeUpdatePayload, RequestEditorModePayload, RequestEntitiesMessage, RequestEntitiesPayload, RequestedEntitiesMessage, RequestedEntitiesPayload, ResolveDesignValueType, SDKFeaturesPayload, ScrollState, SelectComponentPayload, SendMessageParams, StyleProps, UpdateSelectedComponentCoordinatesPayload, UpdatedEntityPayload, ValidationOption, VariableFormats, WrapperTags };
@@ -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,5 @@
1
+ declare const isContentfulStructureComponent: (componentId?: string) => boolean;
2
+ declare const isComponentAllowedOnRoot: (componentId?: string) => boolean;
3
+ declare const isStructureWithRelativeHeight: (componentId?: string, height?: string | number) => boolean;
4
+
5
+ export { isComponentAllowedOnRoot, isContentfulStructureComponent, isStructureWithRelativeHeight };
@@ -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,5 @@
1
+ import { UnresolvedLink, Entry, Asset } from 'contentful';
2
+
3
+ declare const isLink: (maybeLink: UnresolvedLink<"Entry" | "Asset"> | Entry | Asset | string | unknown) => maybeLink is UnresolvedLink<"Entry" | "Asset">;
4
+
5
+ export { isLink };
@@ -0,0 +1,5 @@
1
+ import { Link } from '../types.js';
2
+
3
+ declare const isLinkToAsset: (variable: any) => variable is Link<"Asset">;
4
+
5
+ export { isLinkToAsset };
@@ -0,0 +1,31 @@
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
+ declare const lastPathNamedSegmentEq: (path: string, expectedName: string) => boolean;
30
+
31
+ export { type Fieldset, type UnresolvedFieldset, isDeepPath, lastPathNamedSegmentEq, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings };
@@ -0,0 +1,17 @@
1
+ import { Entry } from 'contentful';
2
+
3
+ declare const resolveHyperlinkPattern: (pattern: string, entry: Entry | null, locale: string | null) => string | null;
4
+ declare function addLocale(str: string, locale: string): string;
5
+ declare function getTemplateValue(ctx: {
6
+ entry: Entry;
7
+ locale: string;
8
+ }, path: string): string | (() => string);
9
+ declare function buildTemplate({ template, context, }: {
10
+ template: string;
11
+ context: {
12
+ entry: Entry;
13
+ locale: string;
14
+ };
15
+ }): string;
16
+
17
+ export { addLocale, buildTemplate, getTemplateValue, resolveHyperlinkPattern };
@@ -0,0 +1,51 @@
1
+ import { Entry, Asset } from 'contentful/dist/types/types';
2
+ import { ComponentPropertyValue, ExperienceUnboundValues, ExperienceDataSource, ExperienceComponentSettings } from '@contentful/experiences-validators';
3
+ import { Experience, StyleProps, DesignTokensDefinition } from '../../types.js';
4
+
5
+ type FlattenedDesignTokens = Record<string, string | {
6
+ width?: string;
7
+ style?: string;
8
+ color?: string;
9
+ }>;
10
+ declare const detachExperienceStyles: (experience: Experience) => string | undefined;
11
+ declare const isCfStyleAttribute: (variableName: string) => variableName is keyof StyleProps;
12
+ declare const maybePopulateDesignTokenValue: (variableName: string, variableValue: unknown, mapOfDesignVariableKeys: FlattenedDesignTokens) => unknown;
13
+ declare const resolveBackgroundImageBinding: ({ variableData, getBoundEntityById, dataSource, unboundValues, componentVariablesOverwrites, componentSettings, }: {
14
+ variableData: ComponentPropertyValue;
15
+ getBoundEntityById: (id: string) => Entry | Asset | undefined;
16
+ unboundValues?: ExperienceUnboundValues;
17
+ dataSource?: ExperienceDataSource;
18
+ componentSettings?: ExperienceComponentSettings;
19
+ componentVariablesOverwrites?: Record<string, ComponentPropertyValue>;
20
+ }) => string | undefined;
21
+ declare const indexByBreakpoint: ({ variables, breakpointIds, getBoundEntityById, unboundValues, dataSource, componentVariablesOverwrites, componentSettings, }: {
22
+ variables: Record<string, ComponentPropertyValue>;
23
+ breakpointIds: string[];
24
+ getBoundEntityById: (id: string) => Entry | Asset | undefined;
25
+ unboundValues?: ExperienceUnboundValues;
26
+ dataSource?: ExperienceDataSource;
27
+ componentVariablesOverwrites?: Record<string, ComponentPropertyValue>;
28
+ componentSettings?: ExperienceComponentSettings;
29
+ }) => Record<string, Record<string, unknown>>;
30
+ /**
31
+ * Flattens the object from
32
+ * {
33
+ * color: {
34
+ * [key]: [value]
35
+ * }
36
+ * }
37
+ *
38
+ * to
39
+ *
40
+ * {
41
+ * 'color.key': [value]
42
+ * }
43
+ */
44
+ declare const flattenDesignTokenRegistry: (designTokenRegistry: DesignTokensDefinition) => FlattenedDesignTokens;
45
+ declare const toCSSString: (breakpointStyles: Record<string, string>) => string;
46
+ declare const toMediaQuery: (breakpointPayload: {
47
+ condition: string;
48
+ cssByClassName: Record<string, string>;
49
+ }) => string;
50
+
51
+ export { detachExperienceStyles, flattenDesignTokenRegistry, indexByBreakpoint, isCfStyleAttribute, maybePopulateDesignTokenValue, resolveBackgroundImageBinding, toCSSString, toMediaQuery };
@@ -0,0 +1,21 @@
1
+ import { CSSProperties, StyleProps, ExperienceTreeNode } from '../../types.js';
2
+ import { PrimitiveValue } from '@contentful/experiences-validators';
3
+
4
+ declare const toCSSAttribute: (key: string) => string;
5
+ declare const buildStyleTag: ({ styles, nodeId }: {
6
+ styles: CSSProperties;
7
+ nodeId?: string;
8
+ }) => string[];
9
+ 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;
10
+ /**
11
+ * Container/section default behavior:
12
+ * Default height => height: EMPTY_CONTAINER_HEIGHT
13
+ * If a container component has children => height: 'fit-content'
14
+ */
15
+ declare const calculateNodeDefaultHeight: ({ blockId, children, value, }: {
16
+ blockId?: string;
17
+ children: ExperienceTreeNode["children"];
18
+ value: PrimitiveValue;
19
+ }) => string | number | boolean | Record<any, any> | undefined;
20
+
21
+ export { buildCfStyles, buildStyleTag, calculateNodeDefaultHeight, toCSSAttribute };
@@ -0,0 +1,5 @@
1
+ import { InternalSDKMode } from '../types.js';
2
+
3
+ declare const supportedModes: InternalSDKMode[];
4
+
5
+ export { supportedModes };
@@ -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 };