@contentful/experiences-core 3.8.2 → 3.8.3-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.cjs → cjs/constants.cjs} +2 -0
- package/dist/cjs/constants.cjs.map +1 -0
- package/dist/{index.cjs → cjs/index.cjs} +129 -127
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/index.d.ts +1675 -0
- package/package.json +17 -21
- package/dist/communication/sendMessage.d.ts +0 -5
- package/dist/constants.cjs.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/deep-binding/DeepReference.d.ts +0 -44
- package/dist/definitions/styles.d.ts +0 -11
- package/dist/entity/EditorEntityStore.d.ts +0 -34
- package/dist/entity/EditorModeEntityStore.d.ts +0 -28
- package/dist/entity/EntityStore.d.ts +0 -99
- package/dist/entity/EntityStoreBase.d.ts +0 -53
- package/dist/entity/InMemoryEntitiesPublicApi.d.ts +0 -41
- package/dist/entity/InMemoryEntitiesStore.d.ts +0 -17
- package/dist/enums.d.ts +0 -6
- package/dist/exports.d.ts +0 -3
- package/dist/fetchers/createExperience.d.ts +0 -25
- package/dist/fetchers/fetchAllEntities.d.ts +0 -30
- package/dist/fetchers/fetchById.d.ts +0 -24
- package/dist/fetchers/fetchBySlug.d.ts +0 -24
- package/dist/fetchers/fetchExperienceEntry.d.ts +0 -30
- package/dist/fetchers/fetchReferencedEntities.d.ts +0 -28
- package/dist/fetchers/gatherAutoFetchedReferentsFromIncludes.d.ts +0 -11
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -42
- package/dist/index.js.map +0 -1
- package/dist/registries/breakpointsRegistry.d.ts +0 -43
- package/dist/registries/designTokenRegistry.d.ts +0 -13
- package/dist/registries/sdkOptionsRegistry.d.ts +0 -11
- package/dist/types.d.ts +0 -630
- package/dist/utils/breakpoints.d.ts +0 -26
- package/dist/utils/components.d.ts +0 -17
- package/dist/utils/debugLogger.d.ts +0 -36
- package/dist/utils/domValues.d.ts +0 -16
- package/dist/utils/extractPrebindingData.d.ts +0 -46
- package/dist/utils/isLink.d.ts +0 -7
- package/dist/utils/isLinkToAsset.d.ts +0 -5
- package/dist/utils/isLinkToEntry.d.ts +0 -5
- package/dist/utils/localizeEntity.d.ts +0 -24
- package/dist/utils/pathSchema.d.ts +0 -43
- package/dist/utils/resolveHyperlinkPattern.d.ts +0 -17
- package/dist/utils/sanitizeNodeProps.d.ts +0 -7
- package/dist/utils/schema/experienceSchema.d.ts +0 -23
- package/dist/utils/schema/references.d.ts +0 -18
- package/dist/utils/splitDirectAndSlotChildren.d.ts +0 -12
- package/dist/utils/styleUtils/ssrStyles.d.ts +0 -75
- package/dist/utils/styleUtils/styleTransformers.d.ts +0 -6
- package/dist/utils/styleUtils/stylesUtils.d.ts +0 -64
- package/dist/utils/styleUtils/toMediaQuery.d.ts +0 -15
- package/dist/utils/transformers/transformBoundContentValue.d.ts +0 -8
- package/dist/utils/treeTraversal.d.ts +0 -17
- package/dist/utils/typeguards.d.ts +0 -15
- package/dist/utils/utils.d.ts +0 -32
- package/dist/utils/validations.d.ts +0 -11
- package/dist/{constants.js → esm/constants.js} +0 -0
- package/dist/{index.js → esm/index.js} +127 -127
- /package/dist/{constants.d.ts → types/constants.d.ts} +0 -0
|
@@ -2354,6 +2354,133 @@ const calculateNodeDefaultHeight = ({ blockId, children, value, }) => {
|
|
|
2354
2354
|
return EMPTY_CONTAINER_SIZE;
|
|
2355
2355
|
};
|
|
2356
2356
|
|
|
2357
|
+
const getDataFromTree = (tree) => {
|
|
2358
|
+
let dataSource = {};
|
|
2359
|
+
let unboundValues = {};
|
|
2360
|
+
const queue = [...tree.root.children];
|
|
2361
|
+
while (queue.length) {
|
|
2362
|
+
const node = queue.shift();
|
|
2363
|
+
if (!node) {
|
|
2364
|
+
continue;
|
|
2365
|
+
}
|
|
2366
|
+
dataSource = { ...dataSource, ...node.data.dataSource };
|
|
2367
|
+
unboundValues = { ...unboundValues, ...node.data.unboundValues };
|
|
2368
|
+
if (node.children.length) {
|
|
2369
|
+
queue.push(...node.children);
|
|
2370
|
+
}
|
|
2371
|
+
}
|
|
2372
|
+
return {
|
|
2373
|
+
dataSource,
|
|
2374
|
+
unboundValues,
|
|
2375
|
+
};
|
|
2376
|
+
};
|
|
2377
|
+
const generateRandomId = (letterCount) => {
|
|
2378
|
+
const LETTERS = 'abcdefghijklmnopqvwxyzABCDEFGHIJKLMNOPQVWXYZ';
|
|
2379
|
+
const NUMS = '0123456789';
|
|
2380
|
+
const ALNUM = NUMS + LETTERS;
|
|
2381
|
+
const times = (n, callback) => Array.from({ length: n }, callback);
|
|
2382
|
+
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
|
2383
|
+
return times(letterCount, () => ALNUM[random(0, ALNUM.length - 1)]).join('');
|
|
2384
|
+
};
|
|
2385
|
+
const checkIsAssemblyNode = ({ componentId, usedComponents, }) => {
|
|
2386
|
+
if (!usedComponents?.length)
|
|
2387
|
+
return false;
|
|
2388
|
+
return usedComponents.some((usedComponent) => usedComponent.sys.id === componentId);
|
|
2389
|
+
};
|
|
2390
|
+
/**
|
|
2391
|
+
* This check assumes that the entry is already ensured to be an experience, i.e. the
|
|
2392
|
+
* content type of the entry is an experience type with the necessary annotations.
|
|
2393
|
+
**/
|
|
2394
|
+
const checkIsAssemblyEntry = (entry) => {
|
|
2395
|
+
return Boolean(entry.fields?.componentSettings);
|
|
2396
|
+
};
|
|
2397
|
+
const checkIsAssemblyDefinition = (component) => component?.category === ASSEMBLY_DEFAULT_CATEGORY;
|
|
2398
|
+
function parseCSSValue(input) {
|
|
2399
|
+
const regex = /^(\d+(\.\d+)?)(px|em|rem)$/;
|
|
2400
|
+
const match = input.match(regex);
|
|
2401
|
+
if (match) {
|
|
2402
|
+
return {
|
|
2403
|
+
value: parseFloat(match[1]),
|
|
2404
|
+
unit: match[3],
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
return null;
|
|
2408
|
+
}
|
|
2409
|
+
function getTargetValueInPixels(targetWidthObject) {
|
|
2410
|
+
switch (targetWidthObject.unit) {
|
|
2411
|
+
case 'px':
|
|
2412
|
+
return targetWidthObject.value;
|
|
2413
|
+
case 'em':
|
|
2414
|
+
return targetWidthObject.value * 16;
|
|
2415
|
+
case 'rem':
|
|
2416
|
+
return targetWidthObject.value * 16;
|
|
2417
|
+
default:
|
|
2418
|
+
return targetWidthObject.value;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
/**
|
|
2422
|
+
* Creates a component definition for an assembly. As all assemblies use the same definition in the SDK,
|
|
2423
|
+
* all should be registered via this function.
|
|
2424
|
+
*/
|
|
2425
|
+
const createAssemblyDefinition = (definitionId) => {
|
|
2426
|
+
return {
|
|
2427
|
+
id: definitionId,
|
|
2428
|
+
name: 'Component',
|
|
2429
|
+
variables: {},
|
|
2430
|
+
children: true,
|
|
2431
|
+
category: ASSEMBLY_DEFAULT_CATEGORY,
|
|
2432
|
+
};
|
|
2433
|
+
};
|
|
2434
|
+
|
|
2435
|
+
/**
|
|
2436
|
+
* Turns a condition like `<768px` or `>1024px` into a media query rule.
|
|
2437
|
+
* For example, `<768px` becomes `max-width:768px` and `>1024px` becomes `min-width:1024px`.
|
|
2438
|
+
*/
|
|
2439
|
+
const toMediaQueryRule = (condition) => {
|
|
2440
|
+
const [evaluation, pixelValue] = [condition[0], condition.substring(1)];
|
|
2441
|
+
const mediaQueryRule = evaluation === '<' ? 'max-width' : 'min-width';
|
|
2442
|
+
return `(${mediaQueryRule}:${pixelValue})`;
|
|
2443
|
+
};
|
|
2444
|
+
/**
|
|
2445
|
+
* Converts a map of class names to CSS strings into a single CSS string.
|
|
2446
|
+
*
|
|
2447
|
+
* @param cssByClassName map of class names to CSS strings containing all rules for each class
|
|
2448
|
+
* @returns joined string of all CSS class definitions
|
|
2449
|
+
*/
|
|
2450
|
+
const toCompoundCss = (cssByClassName) => {
|
|
2451
|
+
return Object.entries(cssByClassName).reduce((acc, [className, css]) => {
|
|
2452
|
+
if (css === '')
|
|
2453
|
+
return acc;
|
|
2454
|
+
return `${acc}.${className}{${css}}`;
|
|
2455
|
+
}, ``);
|
|
2456
|
+
};
|
|
2457
|
+
/**
|
|
2458
|
+
* Create a single CSS string containing all class definitions for a given media query.
|
|
2459
|
+
*
|
|
2460
|
+
* @param cssByClassName map of class names to CSS strings containing all rules for each class
|
|
2461
|
+
* @param condition e.g. "*", "<520px", ">520px"
|
|
2462
|
+
* @param nextCondition optional next condition to create a disjunct media query that doesn't affect the next breakpoint
|
|
2463
|
+
* @returns joined string of all CSS class definitions wrapped into media queries
|
|
2464
|
+
*/
|
|
2465
|
+
const toMediaQuery = ({ cssByClassName, condition, nextCondition, }) => {
|
|
2466
|
+
const compoundCss = toCompoundCss(cssByClassName);
|
|
2467
|
+
if (compoundCss === '') {
|
|
2468
|
+
return '';
|
|
2469
|
+
}
|
|
2470
|
+
const queryRule = toMediaQueryRule(condition);
|
|
2471
|
+
if (!nextCondition) {
|
|
2472
|
+
if (condition === '*') {
|
|
2473
|
+
return compoundCss;
|
|
2474
|
+
}
|
|
2475
|
+
return `@media${queryRule}{${compoundCss}}`;
|
|
2476
|
+
}
|
|
2477
|
+
const nextRule = toMediaQueryRule(nextCondition);
|
|
2478
|
+
if (condition === '*') {
|
|
2479
|
+
return `@media not ${nextRule}{${compoundCss}}`;
|
|
2480
|
+
}
|
|
2481
|
+
return `@media${queryRule} and (not ${nextRule}){${compoundCss}}`;
|
|
2482
|
+
};
|
|
2483
|
+
|
|
2357
2484
|
function getOptimizedImageUrl(url, width, quality, format) {
|
|
2358
2485
|
if (url.startsWith('//')) {
|
|
2359
2486
|
url = 'https:' + url;
|
|
@@ -2983,55 +3110,6 @@ function mergeDefaultAndOverwriteValues(defaultValue, overwriteValue) {
|
|
|
2983
3110
|
return overwriteValue ?? defaultValue;
|
|
2984
3111
|
}
|
|
2985
3112
|
|
|
2986
|
-
/**
|
|
2987
|
-
* Turns a condition like `<768px` or `>1024px` into a media query rule.
|
|
2988
|
-
* For example, `<768px` becomes `max-width:768px` and `>1024px` becomes `min-width:1024px`.
|
|
2989
|
-
*/
|
|
2990
|
-
const toMediaQueryRule = (condition) => {
|
|
2991
|
-
const [evaluation, pixelValue] = [condition[0], condition.substring(1)];
|
|
2992
|
-
const mediaQueryRule = evaluation === '<' ? 'max-width' : 'min-width';
|
|
2993
|
-
return `(${mediaQueryRule}:${pixelValue})`;
|
|
2994
|
-
};
|
|
2995
|
-
/**
|
|
2996
|
-
* Converts a map of class names to CSS strings into a single CSS string.
|
|
2997
|
-
*
|
|
2998
|
-
* @param cssByClassName map of class names to CSS strings containing all rules for each class
|
|
2999
|
-
* @returns joined string of all CSS class definitions
|
|
3000
|
-
*/
|
|
3001
|
-
const toCompoundCss = (cssByClassName) => {
|
|
3002
|
-
return Object.entries(cssByClassName).reduce((acc, [className, css]) => {
|
|
3003
|
-
if (css === '')
|
|
3004
|
-
return acc;
|
|
3005
|
-
return `${acc}.${className}{${css}}`;
|
|
3006
|
-
}, ``);
|
|
3007
|
-
};
|
|
3008
|
-
/**
|
|
3009
|
-
* Create a single CSS string containing all class definitions for a given media query.
|
|
3010
|
-
*
|
|
3011
|
-
* @param cssByClassName map of class names to CSS strings containing all rules for each class
|
|
3012
|
-
* @param condition e.g. "*", "<520px", ">520px"
|
|
3013
|
-
* @param nextCondition optional next condition to create a disjunct media query that doesn't affect the next breakpoint
|
|
3014
|
-
* @returns joined string of all CSS class definitions wrapped into media queries
|
|
3015
|
-
*/
|
|
3016
|
-
const toMediaQuery = ({ cssByClassName, condition, nextCondition, }) => {
|
|
3017
|
-
const compoundCss = toCompoundCss(cssByClassName);
|
|
3018
|
-
if (compoundCss === '') {
|
|
3019
|
-
return '';
|
|
3020
|
-
}
|
|
3021
|
-
const queryRule = toMediaQueryRule(condition);
|
|
3022
|
-
if (!nextCondition) {
|
|
3023
|
-
if (condition === '*') {
|
|
3024
|
-
return compoundCss;
|
|
3025
|
-
}
|
|
3026
|
-
return `@media${queryRule}{${compoundCss}}`;
|
|
3027
|
-
}
|
|
3028
|
-
const nextRule = toMediaQueryRule(nextCondition);
|
|
3029
|
-
if (condition === '*') {
|
|
3030
|
-
return `@media not ${nextRule}{${compoundCss}}`;
|
|
3031
|
-
}
|
|
3032
|
-
return `@media${queryRule} and (not ${nextRule}){${compoundCss}}`;
|
|
3033
|
-
};
|
|
3034
|
-
|
|
3035
3113
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3036
3114
|
function get(obj, path) {
|
|
3037
3115
|
if (!path.length) {
|
|
@@ -3364,84 +3442,6 @@ function treeMap(node, onNode) {
|
|
|
3364
3442
|
return newNode;
|
|
3365
3443
|
}
|
|
3366
3444
|
|
|
3367
|
-
const getDataFromTree = (tree) => {
|
|
3368
|
-
let dataSource = {};
|
|
3369
|
-
let unboundValues = {};
|
|
3370
|
-
const queue = [...tree.root.children];
|
|
3371
|
-
while (queue.length) {
|
|
3372
|
-
const node = queue.shift();
|
|
3373
|
-
if (!node) {
|
|
3374
|
-
continue;
|
|
3375
|
-
}
|
|
3376
|
-
dataSource = { ...dataSource, ...node.data.dataSource };
|
|
3377
|
-
unboundValues = { ...unboundValues, ...node.data.unboundValues };
|
|
3378
|
-
if (node.children.length) {
|
|
3379
|
-
queue.push(...node.children);
|
|
3380
|
-
}
|
|
3381
|
-
}
|
|
3382
|
-
return {
|
|
3383
|
-
dataSource,
|
|
3384
|
-
unboundValues,
|
|
3385
|
-
};
|
|
3386
|
-
};
|
|
3387
|
-
const generateRandomId = (letterCount) => {
|
|
3388
|
-
const LETTERS = 'abcdefghijklmnopqvwxyzABCDEFGHIJKLMNOPQVWXYZ';
|
|
3389
|
-
const NUMS = '0123456789';
|
|
3390
|
-
const ALNUM = NUMS + LETTERS;
|
|
3391
|
-
const times = (n, callback) => Array.from({ length: n }, callback);
|
|
3392
|
-
const random = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min;
|
|
3393
|
-
return times(letterCount, () => ALNUM[random(0, ALNUM.length - 1)]).join('');
|
|
3394
|
-
};
|
|
3395
|
-
const checkIsAssemblyNode = ({ componentId, usedComponents, }) => {
|
|
3396
|
-
if (!usedComponents?.length)
|
|
3397
|
-
return false;
|
|
3398
|
-
return usedComponents.some((usedComponent) => usedComponent.sys.id === componentId);
|
|
3399
|
-
};
|
|
3400
|
-
/**
|
|
3401
|
-
* This check assumes that the entry is already ensured to be an experience, i.e. the
|
|
3402
|
-
* content type of the entry is an experience type with the necessary annotations.
|
|
3403
|
-
**/
|
|
3404
|
-
const checkIsAssemblyEntry = (entry) => {
|
|
3405
|
-
return Boolean(entry.fields?.componentSettings);
|
|
3406
|
-
};
|
|
3407
|
-
const checkIsAssemblyDefinition = (component) => component?.category === ASSEMBLY_DEFAULT_CATEGORY;
|
|
3408
|
-
function parseCSSValue(input) {
|
|
3409
|
-
const regex = /^(\d+(\.\d+)?)(px|em|rem)$/;
|
|
3410
|
-
const match = input.match(regex);
|
|
3411
|
-
if (match) {
|
|
3412
|
-
return {
|
|
3413
|
-
value: parseFloat(match[1]),
|
|
3414
|
-
unit: match[3],
|
|
3415
|
-
};
|
|
3416
|
-
}
|
|
3417
|
-
return null;
|
|
3418
|
-
}
|
|
3419
|
-
function getTargetValueInPixels(targetWidthObject) {
|
|
3420
|
-
switch (targetWidthObject.unit) {
|
|
3421
|
-
case 'px':
|
|
3422
|
-
return targetWidthObject.value;
|
|
3423
|
-
case 'em':
|
|
3424
|
-
return targetWidthObject.value * 16;
|
|
3425
|
-
case 'rem':
|
|
3426
|
-
return targetWidthObject.value * 16;
|
|
3427
|
-
default:
|
|
3428
|
-
return targetWidthObject.value;
|
|
3429
|
-
}
|
|
3430
|
-
}
|
|
3431
|
-
/**
|
|
3432
|
-
* Creates a component definition for an assembly. As all assemblies use the same definition in the SDK,
|
|
3433
|
-
* all should be registered via this function.
|
|
3434
|
-
*/
|
|
3435
|
-
const createAssemblyDefinition = (definitionId) => {
|
|
3436
|
-
return {
|
|
3437
|
-
id: definitionId,
|
|
3438
|
-
name: 'Component',
|
|
3439
|
-
variables: {},
|
|
3440
|
-
children: true,
|
|
3441
|
-
category: ASSEMBLY_DEFAULT_CATEGORY,
|
|
3442
|
-
};
|
|
3443
|
-
};
|
|
3444
|
-
|
|
3445
3445
|
class ParseError extends Error {
|
|
3446
3446
|
constructor(message) {
|
|
3447
3447
|
super(message);
|
|
File without changes
|