@contentful/experiences-core 3.7.0-dev-20250917T1515-4c340b9.0 → 3.7.0-dev-20250918T1653-d735f6f.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.cjs +196 -0
- package/dist/constants.cjs.map +1 -0
- package/dist/entity/EntityStore.d.ts +1 -1
- package/dist/index.cjs +5396 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +44 -17
- package/dist/index.js.map +1 -1
- package/dist/registries/breakpointsRegistry.d.ts +36 -13
- package/dist/utils/sanitizeNodeProps.d.ts +3 -2
- package/package.json +21 -8
- package/dist/exports.js +0 -2
- package/dist/exports.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -37,6 +37,6 @@ export { createExperience } from './fetchers/createExperience.js';
|
|
|
37
37
|
export { fetchReferencedEntities } from './fetchers/fetchReferencedEntities.js';
|
|
38
38
|
export { fetchExperienceEntry } from './fetchers/fetchExperienceEntry.js';
|
|
39
39
|
export { defineDesignTokens, designTokensRegistry, getDesignTokenRegistration, resetDesignTokenRegistry } from './registries/designTokenRegistry.js';
|
|
40
|
-
export { breakpointsRegistry, defineBreakpoints,
|
|
40
|
+
export { breakpointsRegistry, defineBreakpoints, runBreakpointsValidation } from './registries/breakpointsRegistry.js';
|
|
41
41
|
export { defineSdkOptions, getSdkOptions, sdkOptionsRegistry } from './registries/sdkOptionsRegistry.js';
|
|
42
42
|
export { DeepReference, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree } from './deep-binding/DeepReference.js';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z, ZodIssueCode } from 'zod';
|
|
2
|
-
import
|
|
2
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
3
3
|
import md5 from 'md5';
|
|
4
4
|
import { BLOCKS } from '@contentful/rich-text-types';
|
|
5
5
|
import { create } from 'zustand';
|
|
@@ -998,7 +998,7 @@ const BreakpointSchema = z
|
|
|
998
998
|
id: propertyKeySchema,
|
|
999
999
|
// Can be replace with z.templateLiteral when upgrading to zod v4
|
|
1000
1000
|
query: z.string().refine((s) => BREAKPOINT_QUERY_REGEX.test(s)),
|
|
1001
|
-
previewSize: z.string(),
|
|
1001
|
+
previewSize: z.string().optional(),
|
|
1002
1002
|
displayName: z.string(),
|
|
1003
1003
|
displayIcon: z.enum(['desktop', 'tablet', 'mobile']).optional(),
|
|
1004
1004
|
})
|
|
@@ -1519,11 +1519,42 @@ const validateBreakpointsDefinition = (breakpoints) => {
|
|
|
1519
1519
|
return { success: true };
|
|
1520
1520
|
};
|
|
1521
1521
|
|
|
1522
|
-
|
|
1522
|
+
const breakpointsRegistry = [];
|
|
1523
1523
|
/**
|
|
1524
|
-
*
|
|
1525
|
-
*
|
|
1526
|
-
*
|
|
1524
|
+
* Define custom breakpoints that should be used for all your experiences.
|
|
1525
|
+
* A breakpoint consists of:
|
|
1526
|
+
* - id: a unique identifier for this breakpoint
|
|
1527
|
+
* - query: a media query string that defines when this breakpoint is active
|
|
1528
|
+
* - previewSize: an optional fixed preview size to be used in the Studio editor when selecting this breakpoint
|
|
1529
|
+
* - displayName: the name to be displayed in the Studio editor for this breakpoint
|
|
1530
|
+
* - displayIcon: an optional icon to be displayed in the Studio editor for this breakpoint
|
|
1531
|
+
*
|
|
1532
|
+
* The first breakpoint must use a wildcard query (`*`) to match all sizes.
|
|
1533
|
+
*
|
|
1534
|
+
* Every subsequent breakpoint inherits the designs of the previous ones by default.
|
|
1535
|
+
*
|
|
1536
|
+
* The order of breakpoints must be either:
|
|
1537
|
+
* - desktop first: from largest to smallest, using `<` operators
|
|
1538
|
+
* - mobile first: from smallest to largest, using `>` operators
|
|
1539
|
+
*
|
|
1540
|
+
* @note changing breakpoints after you have created experiences may break those experiences
|
|
1541
|
+
* @example
|
|
1542
|
+
* defineBreakpoints([{
|
|
1543
|
+
* id: 'desktop',
|
|
1544
|
+
* query: '*',
|
|
1545
|
+
* displayName: 'Desktop',
|
|
1546
|
+
* displayIcon: 'desktop',
|
|
1547
|
+
* }, {
|
|
1548
|
+
* id: 'tablet',
|
|
1549
|
+
* query: '<992px',
|
|
1550
|
+
* displayName: 'Tablet',
|
|
1551
|
+
* displayIcon: 'tablet',
|
|
1552
|
+
* }, {
|
|
1553
|
+
* id: 'mobile',
|
|
1554
|
+
* query: '<576px',
|
|
1555
|
+
* displayName: 'Mobile',
|
|
1556
|
+
* displayIcon: 'mobile',
|
|
1557
|
+
* }]);
|
|
1527
1558
|
*/
|
|
1528
1559
|
const defineBreakpoints = (breakpoints) => {
|
|
1529
1560
|
Object.assign(breakpointsRegistry, breakpoints);
|
|
@@ -1536,12 +1567,6 @@ const runBreakpointsValidation = () => {
|
|
|
1536
1567
|
throw new Error(`Invalid breakpoints definition. Failed with errors: \n${JSON.stringify(validation.errors, null, 2)}`);
|
|
1537
1568
|
}
|
|
1538
1569
|
};
|
|
1539
|
-
// Used in the tests to get a breakpoint registration
|
|
1540
|
-
const getBreakpointRegistration = (id) => breakpointsRegistry.find((breakpoint) => breakpoint.id === id);
|
|
1541
|
-
// Used in the tests to reset the registry
|
|
1542
|
-
const resetBreakpointsRegistry = () => {
|
|
1543
|
-
breakpointsRegistry = [];
|
|
1544
|
-
};
|
|
1545
1570
|
|
|
1546
1571
|
const sdkOptionsRegistry = {};
|
|
1547
1572
|
/**
|
|
@@ -2148,7 +2173,9 @@ const stylesToRemove = CF_STYLE_ATTRIBUTES.filter((style) => !stylesToKeep.inclu
|
|
|
2148
2173
|
// cfWrapColumns & cfWrapColumnsCount are no real style attributes as they are handled on the editor side
|
|
2149
2174
|
const propsToRemove = ['cfSsrClassName', 'cfWrapColumns', 'cfWrapColumnsCount'];
|
|
2150
2175
|
const sanitizeNodeProps = (nodeProps) => {
|
|
2151
|
-
|
|
2176
|
+
const keysToRemove = [...stylesToRemove, ...propsToRemove];
|
|
2177
|
+
const sanitizedProps = Object.fromEntries(Object.entries(nodeProps).filter(([key]) => !keysToRemove.includes(key)));
|
|
2178
|
+
return sanitizedProps;
|
|
2152
2179
|
};
|
|
2153
2180
|
|
|
2154
2181
|
/** Turn the visibility value into a style object that can be used for inline styles in React */
|
|
@@ -3279,7 +3306,7 @@ function getArrayValue(entryOrAsset, path, entityStore) {
|
|
|
3279
3306
|
}
|
|
3280
3307
|
const fieldName = path.split('/').slice(2, -1);
|
|
3281
3308
|
const arrayValue = get(entryOrAsset, fieldName);
|
|
3282
|
-
if (!isArray(arrayValue)) {
|
|
3309
|
+
if (!Array.isArray(arrayValue)) {
|
|
3283
3310
|
debug.warn(`[experiences-core::getArrayValue] A field '${fieldName}' of an entity was bound to an Array variable. Expected value of that field to be an array, but got: ${JSON.stringify(arrayValue)}`, { entity: entryOrAsset });
|
|
3284
3311
|
return;
|
|
3285
3312
|
}
|
|
@@ -4806,8 +4833,8 @@ const fetchAllEntries = async ({ client, ids, locale, skip = 0, limit = 100, res
|
|
|
4806
4833
|
responseIncludes,
|
|
4807
4834
|
});
|
|
4808
4835
|
}
|
|
4809
|
-
const dedupedEntries =
|
|
4810
|
-
const dedupedAssets =
|
|
4836
|
+
const dedupedEntries = uniqueById(responseIncludes?.Entry);
|
|
4837
|
+
const dedupedAssets = uniqueById(responseIncludes?.Asset);
|
|
4811
4838
|
return {
|
|
4812
4839
|
items: responseItems,
|
|
4813
4840
|
includes: {
|
|
@@ -5248,5 +5275,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
5248
5275
|
}
|
|
5249
5276
|
}
|
|
5250
5277
|
|
|
5251
|
-
export { BREAKPOINTS_STRATEGY_DESKTOP_FIRST, BREAKPOINTS_STRATEGY_MOBILE_FIRST, DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, defineSdkOptions, designTokensRegistry, detachExperienceStyles, detectBreakpointsStrategy, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, extractLeafLinksReferencedFromExperience, extractPrebindingDataByPatternId, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, flattenNestedPatterns, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateDefaultDataSourceForPrebindingDefinition, generateRandomId, getActiveBreakpointIndex,
|
|
5278
|
+
export { BREAKPOINTS_STRATEGY_DESKTOP_FIRST, BREAKPOINTS_STRATEGY_MOBILE_FIRST, DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, defineSdkOptions, designTokensRegistry, detachExperienceStyles, detectBreakpointsStrategy, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, extractLeafLinksReferencedFromExperience, extractPrebindingDataByPatternId, extractReferencesFromEntries, extractReferencesFromEntriesAsIds, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, flattenNestedPatterns, gatherDeepPrebindingReferencesFromExperienceEntry, gatherDeepPrebindingReferencesFromPatternEntry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateDefaultDataSourceForPrebindingDefinition, generateRandomId, getActiveBreakpointIndex, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getPrebindingPathBySourceEntry, getSdkOptions, getTargetPatternMappingsForParameter, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, inMemoryEntities, inMemoryEntitiesStore, indexByBreakpoint, isArrayOfLinks, isAsset, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isDeepPrebinding, isElementHidden, isEntry, isExperienceEntry, isLink, isLinkToAsset, isLinkToEntry, isPatternComponent, isPatternEntry, isPreboundProp, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, mergeDesignValuesByBreakpoint, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, referencesOf, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sdkOptionsRegistry, sectionBuiltInStyles, sendMessage, setDebugLevel, singleColumnBuiltInStyles, splitDirectAndSlotChildren, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, uniqueById, useInMemoryEntities, validateExperienceBuilderConfig };
|
|
5252
5279
|
//# sourceMappingURL=index.js.map
|