@contentful/experiences-core 1.40.3-dev-20250611T0948-7389339.0 → 1.41.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/entity/EntityStoreBase.d.ts +0 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -27
- package/dist/index.js.map +1 -1
- package/dist/utils/entityTypeChecks.d.ts +6 -0
- package/package.json +3 -3
|
@@ -33,8 +33,6 @@ declare abstract class EntityStoreBase {
|
|
|
33
33
|
fetchEntry(id: string): Promise<Entry | undefined>;
|
|
34
34
|
fetchEntries(ids: string[]): Promise<Entry[]>;
|
|
35
35
|
private getDeepEntry;
|
|
36
|
-
private isAsset;
|
|
37
|
-
private isEntry;
|
|
38
36
|
private getEntity;
|
|
39
37
|
toJSON(): {
|
|
40
38
|
entryMap: {
|
package/dist/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export { treeMap, treeVisit } from './utils/treeTraversal.js';
|
|
|
17
17
|
export { isExperienceEntry } from './utils/typeguards.js';
|
|
18
18
|
export { checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, generateRandomId, getDataFromTree, getInsertionData, getTargetValueInPixels, parseCSSValue } from './utils/utils.js';
|
|
19
19
|
export { doesMismatchMessageSchema, tryParseMessage, validateExperienceBuilderConfig } from './utils/validations.js';
|
|
20
|
+
export { isAsset, isEntry } from './utils/entityTypeChecks.js';
|
|
20
21
|
export { builtInStyles, columnsBuiltInStyles, containerBuiltInStyles, dividerBuiltInStyles, optionalBuiltInStyles, sectionBuiltInStyles, singleColumnBuiltInStyles } from './definitions/styles.js';
|
|
21
22
|
export { EditorModeEntityStore } from './entity/EditorModeEntityStore.js';
|
|
22
23
|
export { EntityStore } from './entity/EntityStore.js';
|
package/dist/index.js
CHANGED
|
@@ -953,7 +953,6 @@ const ComponentPropertyValueSchema = z.discriminatedUnion('type', [
|
|
|
953
953
|
const PatternPropertySchema = z.object({
|
|
954
954
|
type: z.literal('BoundValue'),
|
|
955
955
|
path: z.string(),
|
|
956
|
-
contentType: z.string(),
|
|
957
956
|
});
|
|
958
957
|
const PatternPropertiesSchema = z.record(propertyKeySchema, PatternPropertySchema);
|
|
959
958
|
const BreakpointSchema = z
|
|
@@ -1976,7 +1975,6 @@ const buildStyleTag = ({ styles, nodeId }) => {
|
|
|
1976
1975
|
*/
|
|
1977
1976
|
const buildCfStyles = (values) => {
|
|
1978
1977
|
const cssProperties = {
|
|
1979
|
-
boxSizing: 'border-box',
|
|
1980
1978
|
margin: values.cfMargin,
|
|
1981
1979
|
padding: values.cfPadding,
|
|
1982
1980
|
backgroundColor: values.cfBackgroundColor,
|
|
@@ -2283,6 +2281,10 @@ const detachExperienceStyles = (experience) => {
|
|
|
2283
2281
|
* }
|
|
2284
2282
|
*/
|
|
2285
2283
|
const generatedCss = stringifyCssProperties(cfStyles);
|
|
2284
|
+
if (!generatedCss && !isAnyVisibilityValueHidden) {
|
|
2285
|
+
// If there are no styles to apply, skip this breakpoint completely including the class name
|
|
2286
|
+
continue;
|
|
2287
|
+
}
|
|
2286
2288
|
/* [Data format] `generatedCss` is the minimized CSS string that will be added to the DOM:
|
|
2287
2289
|
* generatedCss = "margin: 1px;width: 100%;..."
|
|
2288
2290
|
*/
|
|
@@ -2870,18 +2872,41 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
2870
2872
|
return asset.fields.file?.url;
|
|
2871
2873
|
};
|
|
2872
2874
|
|
|
2875
|
+
const isAsset = (value) => {
|
|
2876
|
+
return (null !== value &&
|
|
2877
|
+
typeof value === 'object' &&
|
|
2878
|
+
'sys' in value &&
|
|
2879
|
+
value.sys?.type === 'Asset');
|
|
2880
|
+
};
|
|
2881
|
+
const isEntry = (value) => {
|
|
2882
|
+
return (null !== value &&
|
|
2883
|
+
typeof value === 'object' &&
|
|
2884
|
+
'sys' in value &&
|
|
2885
|
+
value.sys?.type === 'Entry');
|
|
2886
|
+
};
|
|
2887
|
+
|
|
2873
2888
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
2874
|
-
if (entryOrAsset
|
|
2889
|
+
if (isAsset(entryOrAsset)) {
|
|
2875
2890
|
return entryOrAsset;
|
|
2876
2891
|
}
|
|
2892
|
+
else if (!isEntry(entryOrAsset)) {
|
|
2893
|
+
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
2894
|
+
}
|
|
2877
2895
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
2878
|
-
|
|
2879
|
-
|
|
2880
|
-
|
|
2896
|
+
let resolvedEntity;
|
|
2897
|
+
if (isAsset(value) || isEntry(value)) {
|
|
2898
|
+
// In some cases, reference fields are already resolved
|
|
2899
|
+
resolvedEntity = value;
|
|
2900
|
+
}
|
|
2901
|
+
else if (value?.sys.type === 'Link') {
|
|
2902
|
+
// Look up the reference in the entity store
|
|
2903
|
+
resolvedEntity = entityStore.getEntityFromLink(value);
|
|
2904
|
+
if (!resolvedEntity) {
|
|
2905
|
+
return;
|
|
2906
|
+
}
|
|
2881
2907
|
}
|
|
2882
|
-
|
|
2883
|
-
|
|
2884
|
-
if (!resolvedEntity) {
|
|
2908
|
+
else {
|
|
2909
|
+
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
2885
2910
|
return;
|
|
2886
2911
|
}
|
|
2887
2912
|
//resolve any embedded links - we currently only support 2 levels deep
|
|
@@ -3237,10 +3262,13 @@ class EntityStoreBase {
|
|
|
3237
3262
|
}
|
|
3238
3263
|
entity = resolvedEntity;
|
|
3239
3264
|
}
|
|
3240
|
-
else {
|
|
3265
|
+
else if (isAsset(linkOrEntryOrAsset) || isEntry(linkOrEntryOrAsset)) {
|
|
3241
3266
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
3242
3267
|
entity = linkOrEntryOrAsset;
|
|
3243
3268
|
}
|
|
3269
|
+
else {
|
|
3270
|
+
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
3271
|
+
}
|
|
3244
3272
|
return entity;
|
|
3245
3273
|
}
|
|
3246
3274
|
/**
|
|
@@ -3286,14 +3314,14 @@ class EntityStoreBase {
|
|
|
3286
3314
|
};
|
|
3287
3315
|
}
|
|
3288
3316
|
addEntity(entity) {
|
|
3289
|
-
if (
|
|
3317
|
+
if (isAsset(entity)) {
|
|
3290
3318
|
this.assetMap.set(entity.sys.id, entity);
|
|
3291
3319
|
}
|
|
3292
|
-
else if (
|
|
3320
|
+
else if (isEntry(entity)) {
|
|
3293
3321
|
this.entryMap.set(entity.sys.id, entity);
|
|
3294
3322
|
}
|
|
3295
3323
|
else {
|
|
3296
|
-
|
|
3324
|
+
throw new Error(`Attempted to add an entity to the store that is neither Asset nor Entry: '${JSON.stringify(entity)}'`);
|
|
3297
3325
|
}
|
|
3298
3326
|
}
|
|
3299
3327
|
async fetchAsset(id) {
|
|
@@ -3363,7 +3391,7 @@ class EntityStoreBase {
|
|
|
3363
3391
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3364
3392
|
entityToResolveFieldsFrom = entity; // we move up
|
|
3365
3393
|
}
|
|
3366
|
-
else if (
|
|
3394
|
+
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
3367
3395
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
3368
3396
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
3369
3397
|
}
|
|
@@ -3399,18 +3427,6 @@ class EntityStoreBase {
|
|
|
3399
3427
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
3400
3428
|
return leafEntity;
|
|
3401
3429
|
}
|
|
3402
|
-
isAsset(value) {
|
|
3403
|
-
return (null !== value &&
|
|
3404
|
-
typeof value === 'object' &&
|
|
3405
|
-
'sys' in value &&
|
|
3406
|
-
value.sys?.type === 'Asset');
|
|
3407
|
-
}
|
|
3408
|
-
isEntry(value) {
|
|
3409
|
-
return (null !== value &&
|
|
3410
|
-
typeof value === 'object' &&
|
|
3411
|
-
'sys' in value &&
|
|
3412
|
-
value.sys?.type === 'Entry');
|
|
3413
|
-
}
|
|
3414
3430
|
getEntity(type, id) {
|
|
3415
3431
|
if (type === 'Asset') {
|
|
3416
3432
|
return this.assetMap.get(id);
|
|
@@ -4245,5 +4261,5 @@ async function fetchById({ client, experienceTypeId, id, localeCode, isEditorMod
|
|
|
4245
4261
|
}
|
|
4246
4262
|
}
|
|
4247
4263
|
|
|
4248
|
-
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4264
|
+
export { DebugLogger, DeepReference, EditorModeEntityStore, EntityStore, EntityStoreBase, MEDIA_QUERY_REGEXP, VisualEditorMode, addLocale, addMinHeightForEmptyStructures, breakpointsRegistry, buildCfStyles, buildStyleTag, buildTemplate, builtInStyles, calculateNodeDefaultHeight, checkIsAssembly, checkIsAssemblyDefinition, checkIsAssemblyEntry, checkIsAssemblyNode, columnsBuiltInStyles, containerBuiltInStyles, createExperience, debug, defineBreakpoints, defineDesignTokens, designTokensRegistry, detachExperienceStyles, disableDebug, dividerBuiltInStyles, doesMismatchMessageSchema, enableDebug, fetchAllAssets, fetchAllEntries, fetchById, fetchBySlug, fetchExperienceEntry, fetchReferencedEntities, findOutermostCoordinates, flattenDesignTokenRegistry, gatherDeepReferencesFromExperienceEntry, gatherDeepReferencesFromTree, generateRandomId, getActiveBreakpointIndex, getBreakpointRegistration, getDataFromTree, getDesignTokenRegistration, getElementCoordinates, getFallbackBreakpointIndex, getInsertionData, getTargetValueInPixels, getTemplateValue, getValueForBreakpoint, indexByBreakpoint, isAsset, isCfStyleAttribute, isComponentAllowedOnRoot, isContentfulComponent, isContentfulStructureComponent, isDeepPath, isEntry, isExperienceEntry, isLink, isLinkToAsset, isPatternComponent, isStructureWithRelativeHeight, isValidBreakpointValue, lastPathNamedSegmentEq, localizeEntity, maybePopulateDesignTokenValue, mediaQueryMatcher, optionalBuiltInStyles, parseCSSValue, parseDataSourcePathIntoFieldset, parseDataSourcePathWithL1DeepBindings, resetBreakpointsRegistry, resetDesignTokenRegistry, resolveBackgroundImageBinding, resolveHyperlinkPattern, runBreakpointsValidation, sanitizeNodeProps, sectionBuiltInStyles, sendMessage, singleColumnBuiltInStyles, stringifyCssProperties, toCSSAttribute, toMediaQuery, transformBoundContentValue, transformVisibility, treeMap, treeVisit, tryParseMessage, validateExperienceBuilderConfig };
|
|
4249
4265
|
//# sourceMappingURL=index.js.map
|