@contentful/experiences-visual-editor-react 1.41.0-beta.0 → 1.41.0-dev-20250612T0852-ddef0ff.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/index.js +25 -39
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +25 -39
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/renderApp.js
CHANGED
|
@@ -44463,43 +44463,20 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
44463
44463
|
return asset.fields.file?.url;
|
|
44464
44464
|
};
|
|
44465
44465
|
|
|
44466
|
-
const isAsset = (value) => {
|
|
44467
|
-
return (null !== value &&
|
|
44468
|
-
typeof value === 'object' &&
|
|
44469
|
-
'sys' in value &&
|
|
44470
|
-
value.sys?.type === 'Asset');
|
|
44471
|
-
};
|
|
44472
|
-
const isEntry = (value) => {
|
|
44473
|
-
return (null !== value &&
|
|
44474
|
-
typeof value === 'object' &&
|
|
44475
|
-
'sys' in value &&
|
|
44476
|
-
value.sys?.type === 'Entry');
|
|
44477
|
-
};
|
|
44478
|
-
|
|
44479
44466
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
44480
|
-
if (
|
|
44467
|
+
if (entryOrAsset.sys.type === 'Asset') {
|
|
44481
44468
|
return entryOrAsset;
|
|
44482
44469
|
}
|
|
44483
|
-
else if (!isEntry(entryOrAsset)) {
|
|
44484
|
-
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
44485
|
-
}
|
|
44486
44470
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
44487
|
-
|
|
44488
|
-
if (isAsset(value) || isEntry(value)) {
|
|
44489
|
-
// In some cases, reference fields are already resolved
|
|
44490
|
-
resolvedEntity = value;
|
|
44491
|
-
}
|
|
44492
|
-
else if (value?.sys.type === 'Link') {
|
|
44493
|
-
// Look up the reference in the entity store
|
|
44494
|
-
resolvedEntity = entityStore.getEntityFromLink(value);
|
|
44495
|
-
if (!resolvedEntity) {
|
|
44496
|
-
return;
|
|
44497
|
-
}
|
|
44498
|
-
}
|
|
44499
|
-
else {
|
|
44471
|
+
if (value?.sys.type !== 'Link') {
|
|
44500
44472
|
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
44501
44473
|
return;
|
|
44502
44474
|
}
|
|
44475
|
+
//Look up the reference in the entity store
|
|
44476
|
+
const resolvedEntity = entityStore.getEntityFromLink(value);
|
|
44477
|
+
if (!resolvedEntity) {
|
|
44478
|
+
return;
|
|
44479
|
+
}
|
|
44503
44480
|
//resolve any embedded links - we currently only support 2 levels deep
|
|
44504
44481
|
const fields = resolvedEntity.fields || {};
|
|
44505
44482
|
Object.entries(fields).forEach(([fieldKey, field]) => {
|
|
@@ -44752,13 +44729,10 @@ class EntityStoreBase {
|
|
|
44752
44729
|
}
|
|
44753
44730
|
entity = resolvedEntity;
|
|
44754
44731
|
}
|
|
44755
|
-
else
|
|
44732
|
+
else {
|
|
44756
44733
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
44757
44734
|
entity = linkOrEntryOrAsset;
|
|
44758
44735
|
}
|
|
44759
|
-
else {
|
|
44760
|
-
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
44761
|
-
}
|
|
44762
44736
|
return entity;
|
|
44763
44737
|
}
|
|
44764
44738
|
/**
|
|
@@ -44804,14 +44778,14 @@ class EntityStoreBase {
|
|
|
44804
44778
|
};
|
|
44805
44779
|
}
|
|
44806
44780
|
addEntity(entity) {
|
|
44807
|
-
if (isAsset(entity)) {
|
|
44781
|
+
if (this.isAsset(entity)) {
|
|
44808
44782
|
this.assetMap.set(entity.sys.id, entity);
|
|
44809
44783
|
}
|
|
44810
|
-
else if (isEntry(entity)) {
|
|
44784
|
+
else if (this.isEntry(entity)) {
|
|
44811
44785
|
this.entryMap.set(entity.sys.id, entity);
|
|
44812
44786
|
}
|
|
44813
44787
|
else {
|
|
44814
|
-
|
|
44788
|
+
console.warn('Attempted to add an entity that is neither Asset nor Entry:', entity);
|
|
44815
44789
|
}
|
|
44816
44790
|
}
|
|
44817
44791
|
async fetchAsset(id) {
|
|
@@ -44881,7 +44855,7 @@ class EntityStoreBase {
|
|
|
44881
44855
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
44882
44856
|
entityToResolveFieldsFrom = entity; // we move up
|
|
44883
44857
|
}
|
|
44884
|
-
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
44858
|
+
else if (this.isAsset(fieldValue) || this.isEntry(fieldValue)) {
|
|
44885
44859
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
44886
44860
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
44887
44861
|
}
|
|
@@ -44917,6 +44891,18 @@ class EntityStoreBase {
|
|
|
44917
44891
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
44918
44892
|
return leafEntity;
|
|
44919
44893
|
}
|
|
44894
|
+
isAsset(value) {
|
|
44895
|
+
return (null !== value &&
|
|
44896
|
+
typeof value === 'object' &&
|
|
44897
|
+
'sys' in value &&
|
|
44898
|
+
value.sys?.type === 'Asset');
|
|
44899
|
+
}
|
|
44900
|
+
isEntry(value) {
|
|
44901
|
+
return (null !== value &&
|
|
44902
|
+
typeof value === 'object' &&
|
|
44903
|
+
'sys' in value &&
|
|
44904
|
+
value.sys?.type === 'Entry');
|
|
44905
|
+
}
|
|
44920
44906
|
getEntity(type, id) {
|
|
44921
44907
|
if (type === 'Asset') {
|
|
44922
44908
|
return this.assetMap.get(id);
|
|
@@ -60564,7 +60550,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
60564
60550
|
return false;
|
|
60565
60551
|
}
|
|
60566
60552
|
const { cfWrapColumns } = parentNode.data.props;
|
|
60567
|
-
if (cfWrapColumns
|
|
60553
|
+
if (cfWrapColumns.type !== 'DesignValue') {
|
|
60568
60554
|
return false;
|
|
60569
60555
|
}
|
|
60570
60556
|
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint);
|