@contentful/experiences-visual-editor-react 1.41.0-dev-20250612T0852-ddef0ff.0 → 1.41.0-dev-20250612T1212-618fdd9.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 +26 -19
- package/dist/index.js.map +1 -1
- package/dist/renderApp.js +26 -19
- package/dist/renderApp.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1842,10 +1842,26 @@ const transformMedia = (asset, variables, resolveDesignValue, variableName, path
|
|
|
1842
1842
|
return asset.fields.file?.url;
|
|
1843
1843
|
};
|
|
1844
1844
|
|
|
1845
|
+
const isAsset = (value) => {
|
|
1846
|
+
return (null !== value &&
|
|
1847
|
+
typeof value === 'object' &&
|
|
1848
|
+
'sys' in value &&
|
|
1849
|
+
value.sys?.type === 'Asset');
|
|
1850
|
+
};
|
|
1851
|
+
const isEntry = (value) => {
|
|
1852
|
+
return (null !== value &&
|
|
1853
|
+
typeof value === 'object' &&
|
|
1854
|
+
'sys' in value &&
|
|
1855
|
+
value.sys?.type === 'Entry');
|
|
1856
|
+
};
|
|
1857
|
+
|
|
1845
1858
|
function getResolvedEntryFromLink(entryOrAsset, path, entityStore) {
|
|
1846
|
-
if (entryOrAsset
|
|
1859
|
+
if (isAsset(entryOrAsset)) {
|
|
1847
1860
|
return entryOrAsset;
|
|
1848
1861
|
}
|
|
1862
|
+
else if (!isEntry(entryOrAsset)) {
|
|
1863
|
+
throw new Error(`Expected an Entry or Asset, but got: ${JSON.stringify(entryOrAsset)}`);
|
|
1864
|
+
}
|
|
1849
1865
|
const value = get(entryOrAsset, path.split('/').slice(2, -1));
|
|
1850
1866
|
if (value?.sys.type !== 'Link') {
|
|
1851
1867
|
console.warn(`Expected a link to a reference, but got: ${JSON.stringify(value)}`);
|
|
@@ -2108,10 +2124,13 @@ class EntityStoreBase {
|
|
|
2108
2124
|
}
|
|
2109
2125
|
entity = resolvedEntity;
|
|
2110
2126
|
}
|
|
2111
|
-
else {
|
|
2127
|
+
else if (isAsset(linkOrEntryOrAsset) || isEntry(linkOrEntryOrAsset)) {
|
|
2112
2128
|
// We already have the complete entity in preview & delivery (resolved by the CMA client)
|
|
2113
2129
|
entity = linkOrEntryOrAsset;
|
|
2114
2130
|
}
|
|
2131
|
+
else {
|
|
2132
|
+
throw new Error(`Unexpected object when resolving entity: ${JSON.stringify(linkOrEntryOrAsset)}`);
|
|
2133
|
+
}
|
|
2115
2134
|
return entity;
|
|
2116
2135
|
}
|
|
2117
2136
|
/**
|
|
@@ -2157,14 +2176,14 @@ class EntityStoreBase {
|
|
|
2157
2176
|
};
|
|
2158
2177
|
}
|
|
2159
2178
|
addEntity(entity) {
|
|
2160
|
-
if (
|
|
2179
|
+
if (isAsset(entity)) {
|
|
2161
2180
|
this.assetMap.set(entity.sys.id, entity);
|
|
2162
2181
|
}
|
|
2163
|
-
else if (
|
|
2182
|
+
else if (isEntry(entity)) {
|
|
2164
2183
|
this.entryMap.set(entity.sys.id, entity);
|
|
2165
2184
|
}
|
|
2166
2185
|
else {
|
|
2167
|
-
|
|
2186
|
+
throw new Error(`Attempted to add an entity to the store that is neither Asset nor Entry: '${JSON.stringify(entity)}'`);
|
|
2168
2187
|
}
|
|
2169
2188
|
}
|
|
2170
2189
|
async fetchAsset(id) {
|
|
@@ -2234,7 +2253,7 @@ class EntityStoreBase {
|
|
|
2234
2253
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
2235
2254
|
entityToResolveFieldsFrom = entity; // we move up
|
|
2236
2255
|
}
|
|
2237
|
-
else if (
|
|
2256
|
+
else if (isAsset(fieldValue) || isEntry(fieldValue)) {
|
|
2238
2257
|
resolvedFieldset.push([entityToResolveFieldsFrom, field, _localeQualifier]);
|
|
2239
2258
|
entityToResolveFieldsFrom = fieldValue; // we move up
|
|
2240
2259
|
}
|
|
@@ -2270,18 +2289,6 @@ class EntityStoreBase {
|
|
|
2270
2289
|
const [leafEntity] = resolvedFieldset[resolvedFieldset.length - 1];
|
|
2271
2290
|
return leafEntity;
|
|
2272
2291
|
}
|
|
2273
|
-
isAsset(value) {
|
|
2274
|
-
return (null !== value &&
|
|
2275
|
-
typeof value === 'object' &&
|
|
2276
|
-
'sys' in value &&
|
|
2277
|
-
value.sys?.type === 'Asset');
|
|
2278
|
-
}
|
|
2279
|
-
isEntry(value) {
|
|
2280
|
-
return (null !== value &&
|
|
2281
|
-
typeof value === 'object' &&
|
|
2282
|
-
'sys' in value &&
|
|
2283
|
-
value.sys?.type === 'Entry');
|
|
2284
|
-
}
|
|
2285
2292
|
getEntity(type, id) {
|
|
2286
2293
|
if (type === 'Asset') {
|
|
2287
2294
|
return this.assetMap.get(id);
|
|
@@ -5507,7 +5514,7 @@ function useSingleColumn(node, resolveDesignValue) {
|
|
|
5507
5514
|
return false;
|
|
5508
5515
|
}
|
|
5509
5516
|
const { cfWrapColumns } = parentNode.data.props;
|
|
5510
|
-
if (cfWrapColumns
|
|
5517
|
+
if (cfWrapColumns?.type !== 'DesignValue') {
|
|
5511
5518
|
return false;
|
|
5512
5519
|
}
|
|
5513
5520
|
return resolveDesignValue(cfWrapColumns.valuesByBreakpoint);
|