@contentful/experiences-core 1.42.4-prerelease-20250702T1207-37b3bfc.0 → 2.0.0-beta.1
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/constants.js
CHANGED
|
@@ -148,14 +148,6 @@ const CF_STYLE_ATTRIBUTES = [
|
|
|
148
148
|
'cfTextBold',
|
|
149
149
|
'cfTextItalic',
|
|
150
150
|
'cfTextUnderline',
|
|
151
|
-
// For backwards compatibility
|
|
152
|
-
// we need to keep those in this constant array
|
|
153
|
-
// so that omit() in <VisualEditorBlock> and <CompositionBlock>
|
|
154
|
-
// can filter them out and not pass as props
|
|
155
|
-
'cfBackgroundImageScaling',
|
|
156
|
-
'cfBackgroundImageAlignment',
|
|
157
|
-
'cfBackgroundImageAlignmentVertical',
|
|
158
|
-
'cfBackgroundImageAlignmentHorizontal',
|
|
159
151
|
];
|
|
160
152
|
const EMPTY_CONTAINER_HEIGHT = '80px';
|
|
161
153
|
const HYPERLINK_DEFAULT_PATTERN = `/{locale}/{entry.fields.slug}/`;
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const SCROLL_STATES = {\n Start: 'scrollStart',\n IsScrolling: 'isScrolling',\n End: 'scrollEnd',\n} as const;\n\nexport const OUTGOING_EVENTS = {\n Connected: 'connected',\n DesignTokens: 'registerDesignTokens',\n RegisteredBreakpoints: 'registeredBreakpoints',\n MouseMove: 'mouseMove',\n NewHoveredElement: 'newHoveredElement',\n ComponentSelected: 'componentSelected',\n RegisteredComponents: 'registeredComponents',\n RequestComponentTreeUpdate: 'requestComponentTreeUpdate',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDropped: 'componentDropped',\n ComponentMoved: 'componentMoved',\n CanvasReload: 'canvasReload',\n UpdateSelectedComponentCoordinates: 'updateSelectedComponentCoordinates',\n CanvasScroll: 'canvasScrolling',\n CanvasError: 'canvasError',\n ComponentMoveStarted: 'componentMoveStarted',\n ComponentMoveEnded: 'componentMoveEnded',\n OutsideCanvasClick: 'outsideCanvasClick',\n SDKFeatures: 'sdkFeatures',\n RequestEntities: 'REQUEST_ENTITIES',\n} as const;\n\nexport const INCOMING_EVENTS = {\n RequestEditorMode: 'requestEditorMode',\n RequestReadOnlyMode: 'requestReadOnlyMode',\n ExperienceUpdated: 'componentTreeUpdated',\n ComponentDraggingChanged: 'componentDraggingChanged',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDragStarted: 'componentDragStarted',\n ComponentDragEnded: 'componentDragEnded',\n ComponentMoveEnded: 'componentMoveEnded',\n CanvasResized: 'canvasResized',\n SelectComponent: 'selectComponent',\n HoverComponent: 'hoverComponent',\n UpdatedEntity: 'updatedEntity',\n AssembliesAdded: 'assembliesAdded',\n AssembliesRegistered: 'assembliesRegistered',\n MouseMove: 'mouseMove',\n RequestedEntities: 'REQUESTED_ENTITIES',\n} as const;\n\nexport const INTERNAL_EVENTS = {\n ComponentsRegistered: 'cfComponentsRegistered',\n VisualEditorInitialize: 'cfVisualEditorInitialize',\n} as const;\n\nexport const VISUAL_EDITOR_EVENTS = {\n Ready: 'cfVisualEditorReady',\n};\n\n/**\n * These modes are ONLY intended to be internally used within the context of\n * editing an experience inside of Contentful Studio. i.e. these modes\n * intentionally do not include preview/delivery modes.\n */\nexport enum StudioCanvasMode {\n READ_ONLY = 'readOnlyMode',\n EDITOR = 'editorMode',\n NONE = 'none',\n}\n\nexport const VISUAL_EDITOR_CONTAINER_ID = 'cf-visual-editor';\nexport const CONTENTFUL_COMPONENT_CATEGORY = 'contentful-component';\nexport const CONTENTFUL_DEFAULT_CATEGORY = 'Contentful';\n\nexport const CONTENTFUL_COMPONENTS = {\n section: {\n id: 'contentful-section',\n name: 'Section',\n },\n container: {\n id: 'contentful-container',\n name: 'Container',\n },\n columns: {\n id: 'contentful-columns',\n name: 'Columns',\n },\n singleColumn: {\n id: 'contentful-single-column',\n name: 'Column',\n },\n button: {\n id: 'contentful-button',\n name: 'Button',\n },\n heading: {\n id: 'contentful-heading',\n name: 'Heading',\n },\n image: {\n id: 'contentful-image',\n name: 'Image',\n },\n richText: {\n id: 'contentful-richText',\n name: 'Rich Text',\n },\n text: {\n id: 'contentful-text',\n name: 'Text',\n },\n divider: {\n id: 'contentful-divider',\n name: 'Divider',\n },\n carousel: {\n id: 'contentful-carousel',\n name: 'Carousel',\n },\n} as const;\n\nexport const ASSEMBLY_NODE_TYPE = 'assembly';\nexport const ASSEMBLY_DEFAULT_CATEGORY = 'Assemblies';\nexport const ASSEMBLY_BLOCK_NODE_TYPE = 'assemblyBlock';\nexport const ASSEMBLY_NODE_TYPES = [ASSEMBLY_NODE_TYPE, ASSEMBLY_BLOCK_NODE_TYPE];\nexport const LATEST_SCHEMA_VERSION = '2023-09-28';\nexport const CF_STYLE_ATTRIBUTES = [\n 'cfVisibility',\n 'cfHorizontalAlignment',\n 'cfVerticalAlignment',\n 'cfMargin',\n 'cfPadding',\n 'cfBackgroundColor',\n 'cfWidth',\n 'cfMaxWidth',\n 'cfHeight',\n 'cfImageAsset',\n 'cfImageOptions',\n 'cfBackgroundImageUrl',\n 'cfBackgroundImageOptions',\n 'cfFlexDirection',\n 'cfFlexWrap',\n 'cfFlexReverse',\n 'cfBorder',\n 'cfBorderRadius',\n 'cfGap',\n 'cfColumnSpan',\n 'cfColumnSpanLock',\n 'cfColumns',\n 'cfFontSize',\n 'cfFontWeight',\n 'cfLineHeight',\n 'cfLetterSpacing',\n 'cfTextColor',\n 'cfTextAlign',\n 'cfTextTransform',\n 'cfTextBold',\n 'cfTextItalic',\n 'cfTextUnderline',\n
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":["export const SCROLL_STATES = {\n Start: 'scrollStart',\n IsScrolling: 'isScrolling',\n End: 'scrollEnd',\n} as const;\n\nexport const OUTGOING_EVENTS = {\n Connected: 'connected',\n DesignTokens: 'registerDesignTokens',\n RegisteredBreakpoints: 'registeredBreakpoints',\n MouseMove: 'mouseMove',\n NewHoveredElement: 'newHoveredElement',\n ComponentSelected: 'componentSelected',\n RegisteredComponents: 'registeredComponents',\n RequestComponentTreeUpdate: 'requestComponentTreeUpdate',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDropped: 'componentDropped',\n ComponentMoved: 'componentMoved',\n CanvasReload: 'canvasReload',\n UpdateSelectedComponentCoordinates: 'updateSelectedComponentCoordinates',\n CanvasScroll: 'canvasScrolling',\n CanvasError: 'canvasError',\n ComponentMoveStarted: 'componentMoveStarted',\n ComponentMoveEnded: 'componentMoveEnded',\n OutsideCanvasClick: 'outsideCanvasClick',\n SDKFeatures: 'sdkFeatures',\n RequestEntities: 'REQUEST_ENTITIES',\n} as const;\n\nexport const INCOMING_EVENTS = {\n RequestEditorMode: 'requestEditorMode',\n RequestReadOnlyMode: 'requestReadOnlyMode',\n ExperienceUpdated: 'componentTreeUpdated',\n ComponentDraggingChanged: 'componentDraggingChanged',\n ComponentDragCanceled: 'componentDragCanceled',\n ComponentDragStarted: 'componentDragStarted',\n ComponentDragEnded: 'componentDragEnded',\n ComponentMoveEnded: 'componentMoveEnded',\n CanvasResized: 'canvasResized',\n SelectComponent: 'selectComponent',\n HoverComponent: 'hoverComponent',\n UpdatedEntity: 'updatedEntity',\n AssembliesAdded: 'assembliesAdded',\n AssembliesRegistered: 'assembliesRegistered',\n MouseMove: 'mouseMove',\n RequestedEntities: 'REQUESTED_ENTITIES',\n} as const;\n\nexport const INTERNAL_EVENTS = {\n ComponentsRegistered: 'cfComponentsRegistered',\n VisualEditorInitialize: 'cfVisualEditorInitialize',\n} as const;\n\nexport const VISUAL_EDITOR_EVENTS = {\n Ready: 'cfVisualEditorReady',\n};\n\n/**\n * These modes are ONLY intended to be internally used within the context of\n * editing an experience inside of Contentful Studio. i.e. these modes\n * intentionally do not include preview/delivery modes.\n */\nexport enum StudioCanvasMode {\n READ_ONLY = 'readOnlyMode',\n EDITOR = 'editorMode',\n NONE = 'none',\n}\n\nexport const VISUAL_EDITOR_CONTAINER_ID = 'cf-visual-editor';\nexport const CONTENTFUL_COMPONENT_CATEGORY = 'contentful-component';\nexport const CONTENTFUL_DEFAULT_CATEGORY = 'Contentful';\n\nexport const CONTENTFUL_COMPONENTS = {\n section: {\n id: 'contentful-section',\n name: 'Section',\n },\n container: {\n id: 'contentful-container',\n name: 'Container',\n },\n columns: {\n id: 'contentful-columns',\n name: 'Columns',\n },\n singleColumn: {\n id: 'contentful-single-column',\n name: 'Column',\n },\n button: {\n id: 'contentful-button',\n name: 'Button',\n },\n heading: {\n id: 'contentful-heading',\n name: 'Heading',\n },\n image: {\n id: 'contentful-image',\n name: 'Image',\n },\n richText: {\n id: 'contentful-richText',\n name: 'Rich Text',\n },\n text: {\n id: 'contentful-text',\n name: 'Text',\n },\n divider: {\n id: 'contentful-divider',\n name: 'Divider',\n },\n carousel: {\n id: 'contentful-carousel',\n name: 'Carousel',\n },\n} as const;\n\nexport const ASSEMBLY_NODE_TYPE = 'assembly';\nexport const ASSEMBLY_DEFAULT_CATEGORY = 'Assemblies';\nexport const ASSEMBLY_BLOCK_NODE_TYPE = 'assemblyBlock';\nexport const ASSEMBLY_NODE_TYPES = [ASSEMBLY_NODE_TYPE, ASSEMBLY_BLOCK_NODE_TYPE];\nexport const LATEST_SCHEMA_VERSION = '2023-09-28';\nexport const CF_STYLE_ATTRIBUTES = [\n 'cfVisibility',\n 'cfHorizontalAlignment',\n 'cfVerticalAlignment',\n 'cfMargin',\n 'cfPadding',\n 'cfBackgroundColor',\n 'cfWidth',\n 'cfMaxWidth',\n 'cfHeight',\n 'cfImageAsset',\n 'cfImageOptions',\n 'cfBackgroundImageUrl',\n 'cfBackgroundImageOptions',\n 'cfFlexDirection',\n 'cfFlexWrap',\n 'cfFlexReverse',\n 'cfBorder',\n 'cfBorderRadius',\n 'cfGap',\n 'cfColumnSpan',\n 'cfColumnSpanLock',\n 'cfColumns',\n 'cfFontSize',\n 'cfFontWeight',\n 'cfLineHeight',\n 'cfLetterSpacing',\n 'cfTextColor',\n 'cfTextAlign',\n 'cfTextTransform',\n 'cfTextBold',\n 'cfTextItalic',\n 'cfTextUnderline',\n];\n\nexport const EMPTY_CONTAINER_HEIGHT = '80px';\n\nexport const HYPERLINK_DEFAULT_PATTERN = `/{locale}/{entry.fields.slug}/`;\n\nexport const DEFAULT_IMAGE_WIDTH = '500px';\n\nexport enum PostMessageMethods {\n REQUEST_ENTITIES = 'REQUEST_ENTITIES',\n REQUESTED_ENTITIES = 'REQUESTED_ENTITIES',\n}\n\nexport const SUPPORTED_IMAGE_FORMATS = ['jpg', 'png', 'webp', 'gif', 'avif'] as const;\n\nexport const PATTERN_PROPERTY_DIVIDER = '-----';\n\nexport const SIDELOADED_PREFIX = 'sideloaded_';\n"],"names":[],"mappings":"AAAa,MAAA,aAAa,GAAG;AAC3B,IAAA,KAAK,EAAE,aAAa;AACpB,IAAA,WAAW,EAAE,aAAa;AAC1B,IAAA,GAAG,EAAE,WAAW;EACP;AAEE,MAAA,eAAe,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BAAkB,EAAA;AAC5B,IAAA,kBAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC,CAAA;AACrC,IAAA,kBAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC,CAAA;AAC3C,CAAC,EAHW,kBAAkB,KAAlB,kBAAkB,GAG7B,EAAA,CAAA,CAAA,CAAA;AAEM,MAAM,uBAAuB,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAW;AAE/E,MAAM,wBAAwB,GAAG,QAAQ;AAEzC,MAAM,iBAAiB,GAAG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DataSourceEntryValueType, Link, ExperienceEntry, ExperienceTreeNode } from '../types.js';
|
|
2
|
-
import {
|
|
2
|
+
import { EntityFromLink } from '../entity/EntityStoreBase.js';
|
|
3
3
|
import { ExperienceDataSource } from '@contentful/experiences-validators';
|
|
4
4
|
|
|
5
5
|
type DeepReferenceOpts = {
|
|
@@ -18,7 +18,7 @@ declare class DeepReference {
|
|
|
18
18
|
* Extracts referent from the path, using EntityStore as source of
|
|
19
19
|
* entities during the resolution path.
|
|
20
20
|
*/
|
|
21
|
-
extractReferent(entityStore:
|
|
21
|
+
extractReferent(entityStore: EntityFromLink): Link<'Asset' | 'Entry'> | undefined;
|
|
22
22
|
static from(opt: DeepReferenceOpts): DeepReference;
|
|
23
23
|
}
|
|
24
24
|
declare function gatherDeepReferencesFromExperienceEntry(experienceEntry: ExperienceEntry): DeepReference[];
|
|
@@ -2,7 +2,6 @@ import { Asset, Entry, UnresolvedLink } from 'contentful';
|
|
|
2
2
|
import { EditorEntityStore } from './EditorEntityStore.js';
|
|
3
3
|
|
|
4
4
|
declare class EditorModeEntityStore extends EditorEntityStore {
|
|
5
|
-
locale: string;
|
|
6
5
|
constructor({ entities, locale }: {
|
|
7
6
|
entities: Array<Asset | Entry>;
|
|
8
7
|
locale: string;
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { Entry, Asset, ChainModifiers, UnresolvedLink } from 'contentful';
|
|
2
2
|
|
|
3
|
+
interface EntityFromLink {
|
|
4
|
+
getEntityFromLink(link: UnresolvedLink<'Entry' | 'Asset'>): Asset | Entry | undefined;
|
|
5
|
+
}
|
|
3
6
|
/**
|
|
4
7
|
* Base Store for entities
|
|
5
8
|
* Can be extended for the different loading behaviours (editor, production, ..)
|
|
6
9
|
*/
|
|
7
|
-
declare abstract class EntityStoreBase {
|
|
8
|
-
|
|
10
|
+
declare abstract class EntityStoreBase implements EntityFromLink {
|
|
11
|
+
locale: string;
|
|
9
12
|
protected entryMap: Map<string, Entry>;
|
|
10
13
|
protected assetMap: Map<string, Asset<ChainModifiers, string>>;
|
|
11
14
|
constructor({ entities, locale }: {
|
|
@@ -23,6 +26,8 @@ declare abstract class EntityStoreBase {
|
|
|
23
26
|
*/
|
|
24
27
|
getValue(entityLink: UnresolvedLink<'Entry' | 'Asset'>, path: string[]): string | undefined;
|
|
25
28
|
getEntityFromLink(link: UnresolvedLink<'Entry' | 'Asset'>): Asset | Entry | undefined;
|
|
29
|
+
getAssetById(assetId: string): Asset | undefined;
|
|
30
|
+
getEntryById(entryId: string): Entry | undefined;
|
|
26
31
|
protected getEntitiesFromMap(type: 'Entry' | 'Asset', ids: string[]): {
|
|
27
32
|
resolved: (Entry | Asset<ChainModifiers, string>)[];
|
|
28
33
|
missing: string[];
|
|
@@ -45,4 +50,4 @@ declare abstract class EntityStoreBase {
|
|
|
45
50
|
};
|
|
46
51
|
}
|
|
47
52
|
|
|
48
|
-
export { EntityStoreBase };
|
|
53
|
+
export { type EntityFromLink, EntityStoreBase };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { UnresolvedLink, Entry, Asset } from 'contentful';
|
|
2
|
+
|
|
3
|
+
declare function maybeResolveLink(maybeLink: UnresolvedLink<'Entry'>): Entry | undefined;
|
|
4
|
+
declare function maybeResolveLink(maybeLink: UnresolvedLink<'Asset'>): Asset | undefined;
|
|
5
|
+
declare function maybeResolveLink(maybeLink: UnresolvedLink<'Asset' | 'Entry'>): Asset | Entry | undefined;
|
|
6
|
+
declare function maybeResolveLink(maybeLink: unknown): Entry | Asset | undefined;
|
|
7
|
+
declare function maybeResolveByAssetId(assetId: string): Asset | undefined;
|
|
8
|
+
declare function maybeResolveByEntryId(entryId: string): Entry | undefined;
|
|
9
|
+
declare function hasEntry(entryId: string): boolean;
|
|
10
|
+
declare function hasAsset(assetId: string): boolean;
|
|
11
|
+
declare function addEntities(entities: Array<Entry>): void;
|
|
12
|
+
declare function addEntities(entities: Array<Asset>): void;
|
|
13
|
+
declare function addEntities(entities: Array<Entry | Asset>): void;
|
|
14
|
+
declare const inMemoryEntities: {
|
|
15
|
+
maybeResolveLink: typeof maybeResolveLink;
|
|
16
|
+
maybeResolveByAssetId: typeof maybeResolveByAssetId;
|
|
17
|
+
maybeResolveByEntryId: typeof maybeResolveByEntryId;
|
|
18
|
+
hasEntry: typeof hasEntry;
|
|
19
|
+
hasAsset: typeof hasAsset;
|
|
20
|
+
addEntities: typeof addEntities;
|
|
21
|
+
};
|
|
22
|
+
type InMemoryEntitiesPublicApi = typeof inMemoryEntities;
|
|
23
|
+
declare const useInMemoryEntities: () => {
|
|
24
|
+
maybeResolveLink: typeof maybeResolveLink;
|
|
25
|
+
maybeResolveByAssetId: typeof maybeResolveByAssetId;
|
|
26
|
+
maybeResolveByEntryId: typeof maybeResolveByEntryId;
|
|
27
|
+
hasEntry: typeof hasEntry;
|
|
28
|
+
hasAsset: typeof hasAsset;
|
|
29
|
+
addEntities: typeof addEntities;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { type InMemoryEntitiesPublicApi, inMemoryEntities, useInMemoryEntities };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as zustand from 'zustand';
|
|
2
|
+
import { EntityStoreBase } from './EntityStoreBase.js';
|
|
3
|
+
import { UnresolvedLink, Entry, Asset } from 'contentful';
|
|
4
|
+
|
|
5
|
+
interface InMemoryEntitiesState {
|
|
6
|
+
entityStore: EntityStoreBase;
|
|
7
|
+
areEntitiesFetched: boolean;
|
|
8
|
+
setEntitiesFetched: (fetched: boolean) => void;
|
|
9
|
+
resolveEntity: <T extends 'Entry' | 'Asset'>(link?: UnresolvedLink<T>) => Entry | Asset | undefined;
|
|
10
|
+
resolveAssetById: (assetId?: string) => Asset | undefined;
|
|
11
|
+
resolveEntryById: (entryId?: string) => Entry | undefined;
|
|
12
|
+
resetEntityStore: (entityStore: EntityStoreBase) => void;
|
|
13
|
+
}
|
|
14
|
+
declare const inMemoryEntitiesStore: zustand.UseBoundStore<zustand.StoreApi<InMemoryEntitiesState>>;
|
|
15
|
+
type InMemoryEntitiesStore = typeof inMemoryEntitiesStore;
|
|
16
|
+
|
|
17
|
+
export { type InMemoryEntitiesState, type InMemoryEntitiesStore, inMemoryEntitiesStore };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isPatternComponent, isStructureWithRelativeHeight } from './utils/components.js';
|
|
2
|
-
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher } from './utils/breakpoints.js';
|
|
2
|
+
export { MEDIA_QUERY_REGEXP, getActiveBreakpointIndex, getFallbackBreakpointIndex, getValueForBreakpoint, isValidBreakpointValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint } from './utils/breakpoints.js';
|
|
3
3
|
export { DebugLogger, debug, disableDebug, enableDebug } from './utils/debugLogger.js';
|
|
4
4
|
export { findOutermostCoordinates, getElementCoordinates } from './utils/domValues.js';
|
|
5
5
|
export { isLinkToAsset } from './utils/isLinkToAsset.js';
|
|
6
|
+
export { isLinkToEntry } from './utils/isLinkToEntry.js';
|
|
6
7
|
export { isLink } from './utils/isLink.js';
|
|
7
8
|
export { localizeEntity } from './utils/localizeEntity.js';
|
|
8
9
|
export { Fieldset, UnresolvedFieldset, isDeepPath, lastPathNamedSegmentEq, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings } from './utils/pathSchema.js';
|
|
@@ -14,14 +15,17 @@ export { toMediaQuery } from './utils/styleUtils/toMediaQuery.js';
|
|
|
14
15
|
export { transformVisibility } from './utils/styleUtils/styleTransformers.js';
|
|
15
16
|
export { transformBoundContentValue } from './utils/transformers/transformBoundContentValue.js';
|
|
16
17
|
export { treeMap, treeVisit } from './utils/treeTraversal.js';
|
|
17
|
-
export { isExperienceEntry } from './utils/typeguards.js';
|
|
18
|
-
export {
|
|
18
|
+
export { isArrayOfLinks, isAsset, isEntry, isExperienceEntry, isPatternEntry } from './utils/typeguards.js';
|
|
19
|
+
export { checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
19
20
|
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
20
|
-
export {
|
|
21
|
+
export { extractLeafLinksReferencedFromExperience } from './utils/schema/experienceSchema.js';
|
|
22
|
+
export { FnShouldFollowReferencesOfEntryField, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, referencesOf, uniqueById } from './utils/schema/references.js';
|
|
21
23
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
22
24
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
|
23
25
|
export { EntityStore } from './entity/EntityStore.js';
|
|
24
|
-
export { EntityStoreBase } from './entity/EntityStoreBase.js';
|
|
26
|
+
export { EntityFromLink, EntityStoreBase } from './entity/EntityStoreBase.js';
|
|
27
|
+
export { InMemoryEntitiesStore, inMemoryEntitiesStore } from './entity/InMemoryEntitiesStore.js';
|
|
28
|
+
export { InMemoryEntitiesPublicApi as InMemoryEntitiesService, inMemoryEntities, useInMemoryEntities } from './entity/InMemoryEntitiesPublicApi.js';
|
|
25
29
|
export { sendMessage } from './communication/sendMessage.js';
|
|
26
30
|
export { VisualEditorMode } from './enums.js';
|
|
27
31
|
export { fetchBySlug } from './fetchers/fetchBySlug.js';
|