@uniformdev/canvas 19.203.0 → 19.204.1-alpha.2
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.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.esm.js +77 -50
- package/dist/index.js +77 -50
- package/dist/index.mjs +77 -50
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
@@ -11704,14 +11704,18 @@ type ComponentLocationReferenceV2 = {
|
|
11704
11704
|
type: 'slot';
|
11705
11705
|
node: ComponentInstance;
|
11706
11706
|
parentSlot: string;
|
11707
|
+
/** @deprecated invoke parentSlotIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11707
11708
|
parentSlotIndex: number;
|
11709
|
+
parentSlotIndexFn: () => number;
|
11708
11710
|
};
|
11709
11711
|
/** Ancestor location that is in a block on a parameter or field */
|
11710
11712
|
type BlockLocationReference = {
|
11711
11713
|
type: 'block';
|
11712
11714
|
node: EntryData;
|
11713
11715
|
fieldName: string;
|
11716
|
+
/** @deprecated invoke blockIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11714
11717
|
blockIndex: number;
|
11718
|
+
blockIndexFn: () => number;
|
11715
11719
|
};
|
11716
11720
|
/** Ancestor location that is the root of a composition or entry */
|
11717
11721
|
type RootLocationReference = {
|
package/dist/index.d.ts
CHANGED
@@ -11704,14 +11704,18 @@ type ComponentLocationReferenceV2 = {
|
|
11704
11704
|
type: 'slot';
|
11705
11705
|
node: ComponentInstance;
|
11706
11706
|
parentSlot: string;
|
11707
|
+
/** @deprecated invoke parentSlotIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11707
11708
|
parentSlotIndex: number;
|
11709
|
+
parentSlotIndexFn: () => number;
|
11708
11710
|
};
|
11709
11711
|
/** Ancestor location that is in a block on a parameter or field */
|
11710
11712
|
type BlockLocationReference = {
|
11711
11713
|
type: 'block';
|
11712
11714
|
node: EntryData;
|
11713
11715
|
fieldName: string;
|
11716
|
+
/** @deprecated invoke blockIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11714
11717
|
blockIndex: number;
|
11718
|
+
blockIndexFn: () => number;
|
11715
11719
|
};
|
11716
11720
|
/** Ancestor location that is the root of a composition or entry */
|
11717
11721
|
type RootLocationReference = {
|
package/dist/index.esm.js
CHANGED
@@ -910,7 +910,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
910
910
|
const parentLocation = ancestorsAndSelf[i + 1];
|
911
911
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
912
912
|
if (currentLocation.type === "block") {
|
913
|
-
const { fieldName,
|
913
|
+
const { fieldName, blockIndexFn } = currentLocation;
|
914
|
+
const blockIndex = blockIndexFn();
|
914
915
|
if (fieldName && blockIndex !== void 0) {
|
915
916
|
const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
|
916
917
|
path.push(`${noun}.${fieldName}.value[${blockIndex}]`);
|
@@ -919,7 +920,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
919
920
|
}
|
920
921
|
continue;
|
921
922
|
}
|
922
|
-
const
|
923
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
924
|
+
const { parentSlot } = currentLocation;
|
923
925
|
if (parentSlot && parentSlotIndex !== void 0) {
|
924
926
|
path.push(`${parentSlot}[${parentSlotIndex}]`);
|
925
927
|
}
|
@@ -1156,7 +1158,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1156
1158
|
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1157
1159
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1158
1160
|
if (currentComponentLocation.type === "block") {
|
1159
|
-
const { fieldName,
|
1161
|
+
const { fieldName, blockIndexFn } = currentComponentLocation;
|
1162
|
+
const blockIndex = blockIndexFn();
|
1160
1163
|
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1161
1164
|
blockValue.splice(blockIndex, 1);
|
1162
1165
|
if (blockValue.length === 0) {
|
@@ -1173,7 +1176,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1173
1176
|
if (currentNodeInfo.type !== "block") {
|
1174
1177
|
throw new Error("Unknown type");
|
1175
1178
|
}
|
1176
|
-
const { fieldName,
|
1179
|
+
const { fieldName, blockIndexFn } = currentNodeInfo;
|
1180
|
+
const blockIndex = blockIndexFn();
|
1177
1181
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1178
1182
|
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1179
1183
|
if (fieldName && typeof blockIndex !== "undefined") {
|
@@ -1183,22 +1187,28 @@ function walkNodeTree(node, visitor, options) {
|
|
1183
1187
|
...nodesToInsert
|
1184
1188
|
);
|
1185
1189
|
componentQueue.unshift(
|
1186
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1190
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1191
|
+
const blockIndexFn2 = () => {
|
1192
|
+
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1193
|
+
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1194
|
+
};
|
1195
|
+
return {
|
1196
|
+
ancestorsAndSelf: [
|
1197
|
+
{
|
1198
|
+
type: "block",
|
1199
|
+
node: enqueueingComponent,
|
1200
|
+
fieldName,
|
1201
|
+
get blockIndex() {
|
1202
|
+
return blockIndexFn2();
|
1203
|
+
},
|
1204
|
+
blockIndexFn: blockIndexFn2
|
1205
|
+
},
|
1206
|
+
// slice removes 'self' since we are inserting a peer of self
|
1207
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1208
|
+
],
|
1209
|
+
context: descendantContext
|
1210
|
+
};
|
1211
|
+
})
|
1202
1212
|
);
|
1203
1213
|
}
|
1204
1214
|
},
|
@@ -1247,7 +1257,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1247
1257
|
throw new Error("Unable to delete root node.");
|
1248
1258
|
}
|
1249
1259
|
if (currentComponentLocation.type === "slot") {
|
1250
|
-
const { parentSlot,
|
1260
|
+
const { parentSlot, parentSlotIndexFn } = currentComponentLocation;
|
1261
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1251
1262
|
parentComponent.node.slots[parentSlot].splice(parentSlotIndex, 1);
|
1252
1263
|
} else {
|
1253
1264
|
throw new Error("Unknown node type");
|
@@ -1261,7 +1272,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1261
1272
|
throw new Error("Unable to insert after root node.");
|
1262
1273
|
}
|
1263
1274
|
if (currentNodeInfo.type === "slot") {
|
1264
|
-
const { parentSlot,
|
1275
|
+
const { parentSlot, parentSlotIndexFn } = currentNodeInfo;
|
1276
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1265
1277
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1266
1278
|
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1267
1279
|
parentComponent.node.slots[parentSlot].splice(
|
@@ -1270,24 +1282,30 @@ function walkNodeTree(node, visitor, options) {
|
|
1270
1282
|
...nodesToInsert
|
1271
1283
|
);
|
1272
1284
|
componentQueue.unshift(
|
1273
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1285
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1286
|
+
const parentSlotIndexFn2 = () => {
|
1287
|
+
return parentComponent.node.slots[parentSlot].findIndex(
|
1288
|
+
(x) => x === enqueueingComponent
|
1289
|
+
);
|
1290
|
+
};
|
1291
|
+
return {
|
1292
|
+
type: "slot",
|
1293
|
+
ancestorsAndSelf: [
|
1294
|
+
{
|
1295
|
+
type: "slot",
|
1296
|
+
node: enqueueingComponent,
|
1297
|
+
parentSlot,
|
1298
|
+
get parentSlotIndex() {
|
1299
|
+
return parentSlotIndexFn2();
|
1300
|
+
},
|
1301
|
+
parentSlotIndexFn: parentSlotIndexFn2
|
1302
|
+
},
|
1303
|
+
// slice removes 'self' since we are inserting a peer of self
|
1304
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1305
|
+
],
|
1306
|
+
context: descendantContext
|
1307
|
+
};
|
1308
|
+
})
|
1291
1309
|
);
|
1292
1310
|
}
|
1293
1311
|
} else {
|
@@ -1319,6 +1337,12 @@ function walkNodeTree(node, visitor, options) {
|
|
1319
1337
|
const components = slots[slotKey];
|
1320
1338
|
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
1321
1339
|
const enqueueingComponent = components[componentIndex];
|
1340
|
+
const parentSlotIndexFn = () => {
|
1341
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
1342
|
+
(x) => x === enqueueingComponent
|
1343
|
+
);
|
1344
|
+
return result;
|
1345
|
+
};
|
1322
1346
|
componentQueue.push({
|
1323
1347
|
ancestorsAndSelf: [
|
1324
1348
|
{
|
@@ -1326,10 +1350,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1326
1350
|
node: enqueueingComponent,
|
1327
1351
|
parentSlot: slotKey,
|
1328
1352
|
get parentSlotIndex() {
|
1329
|
-
return
|
1330
|
-
|
1331
|
-
|
1332
|
-
}
|
1353
|
+
return parentSlotIndexFn();
|
1354
|
+
},
|
1355
|
+
parentSlotIndexFn
|
1333
1356
|
},
|
1334
1357
|
...currentQueueEntry.ancestorsAndSelf
|
1335
1358
|
],
|
@@ -1365,6 +1388,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1365
1388
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1366
1389
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1367
1390
|
const enqueueingBlock = blocks[blockIndex];
|
1391
|
+
const blockIndexFn = () => {
|
1392
|
+
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
1393
|
+
};
|
1368
1394
|
componentQueue.push({
|
1369
1395
|
ancestorsAndSelf: [
|
1370
1396
|
{
|
@@ -1372,10 +1398,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1372
1398
|
node: enqueueingBlock,
|
1373
1399
|
fieldName: propKey,
|
1374
1400
|
get blockIndex() {
|
1375
|
-
return
|
1376
|
-
|
1377
|
-
|
1378
|
-
}
|
1401
|
+
return blockIndexFn();
|
1402
|
+
},
|
1403
|
+
blockIndexFn
|
1379
1404
|
},
|
1380
1405
|
...currentQueueEntry.ancestorsAndSelf
|
1381
1406
|
],
|
@@ -1666,7 +1691,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1666
1691
|
const parentLocation = ancestorsAndSelf[i + 1];
|
1667
1692
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1668
1693
|
if (currentLocation.type === "block") {
|
1669
|
-
const { fieldName: parameterName,
|
1694
|
+
const { fieldName: parameterName, blockIndexFn } = currentLocation;
|
1695
|
+
const blockIndex = blockIndexFn();
|
1670
1696
|
if (parameterName && blockIndex !== void 0) {
|
1671
1697
|
const noun = getNounForLocation(parentLocation);
|
1672
1698
|
path.push(`${noun}/${parameterName}/value/${blockIndex}`);
|
@@ -1675,7 +1701,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1675
1701
|
}
|
1676
1702
|
continue;
|
1677
1703
|
}
|
1678
|
-
const
|
1704
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
1705
|
+
const { parentSlot } = currentLocation;
|
1679
1706
|
if (parentSlot && parentSlotIndex !== void 0) {
|
1680
1707
|
path.push(`slots/${parentSlot}/${parentSlotIndex}`);
|
1681
1708
|
}
|
package/dist/index.js
CHANGED
@@ -1068,7 +1068,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
1068
1068
|
const parentLocation = ancestorsAndSelf[i + 1];
|
1069
1069
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1070
1070
|
if (currentLocation.type === "block") {
|
1071
|
-
const { fieldName,
|
1071
|
+
const { fieldName, blockIndexFn } = currentLocation;
|
1072
|
+
const blockIndex = blockIndexFn();
|
1072
1073
|
if (fieldName && blockIndex !== void 0) {
|
1073
1074
|
const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
|
1074
1075
|
path.push(`${noun}.${fieldName}.value[${blockIndex}]`);
|
@@ -1077,7 +1078,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
1077
1078
|
}
|
1078
1079
|
continue;
|
1079
1080
|
}
|
1080
|
-
const
|
1081
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
1082
|
+
const { parentSlot } = currentLocation;
|
1081
1083
|
if (parentSlot && parentSlotIndex !== void 0) {
|
1082
1084
|
path.push(`${parentSlot}[${parentSlotIndex}]`);
|
1083
1085
|
}
|
@@ -1314,7 +1316,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1314
1316
|
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1315
1317
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1316
1318
|
if (currentComponentLocation.type === "block") {
|
1317
|
-
const { fieldName,
|
1319
|
+
const { fieldName, blockIndexFn } = currentComponentLocation;
|
1320
|
+
const blockIndex = blockIndexFn();
|
1318
1321
|
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1319
1322
|
blockValue.splice(blockIndex, 1);
|
1320
1323
|
if (blockValue.length === 0) {
|
@@ -1331,7 +1334,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1331
1334
|
if (currentNodeInfo.type !== "block") {
|
1332
1335
|
throw new Error("Unknown type");
|
1333
1336
|
}
|
1334
|
-
const { fieldName,
|
1337
|
+
const { fieldName, blockIndexFn } = currentNodeInfo;
|
1338
|
+
const blockIndex = blockIndexFn();
|
1335
1339
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1336
1340
|
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1337
1341
|
if (fieldName && typeof blockIndex !== "undefined") {
|
@@ -1341,22 +1345,28 @@ function walkNodeTree(node, visitor, options) {
|
|
1341
1345
|
...nodesToInsert
|
1342
1346
|
);
|
1343
1347
|
componentQueue.unshift(
|
1344
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1345
|
-
|
1346
|
-
|
1347
|
-
|
1348
|
-
|
1349
|
-
|
1350
|
-
|
1351
|
-
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
1358
|
-
|
1359
|
-
|
1348
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1349
|
+
const blockIndexFn2 = () => {
|
1350
|
+
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1351
|
+
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1352
|
+
};
|
1353
|
+
return {
|
1354
|
+
ancestorsAndSelf: [
|
1355
|
+
{
|
1356
|
+
type: "block",
|
1357
|
+
node: enqueueingComponent,
|
1358
|
+
fieldName,
|
1359
|
+
get blockIndex() {
|
1360
|
+
return blockIndexFn2();
|
1361
|
+
},
|
1362
|
+
blockIndexFn: blockIndexFn2
|
1363
|
+
},
|
1364
|
+
// slice removes 'self' since we are inserting a peer of self
|
1365
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1366
|
+
],
|
1367
|
+
context: descendantContext
|
1368
|
+
};
|
1369
|
+
})
|
1360
1370
|
);
|
1361
1371
|
}
|
1362
1372
|
},
|
@@ -1405,7 +1415,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1405
1415
|
throw new Error("Unable to delete root node.");
|
1406
1416
|
}
|
1407
1417
|
if (currentComponentLocation.type === "slot") {
|
1408
|
-
const { parentSlot,
|
1418
|
+
const { parentSlot, parentSlotIndexFn } = currentComponentLocation;
|
1419
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1409
1420
|
parentComponent.node.slots[parentSlot].splice(parentSlotIndex, 1);
|
1410
1421
|
} else {
|
1411
1422
|
throw new Error("Unknown node type");
|
@@ -1419,7 +1430,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1419
1430
|
throw new Error("Unable to insert after root node.");
|
1420
1431
|
}
|
1421
1432
|
if (currentNodeInfo.type === "slot") {
|
1422
|
-
const { parentSlot,
|
1433
|
+
const { parentSlot, parentSlotIndexFn } = currentNodeInfo;
|
1434
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1423
1435
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1424
1436
|
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1425
1437
|
parentComponent.node.slots[parentSlot].splice(
|
@@ -1428,24 +1440,30 @@ function walkNodeTree(node, visitor, options) {
|
|
1428
1440
|
...nodesToInsert
|
1429
1441
|
);
|
1430
1442
|
componentQueue.unshift(
|
1431
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1432
|
-
|
1433
|
-
|
1434
|
-
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1438
|
-
|
1439
|
-
|
1440
|
-
|
1441
|
-
|
1442
|
-
|
1443
|
-
|
1444
|
-
|
1445
|
-
|
1446
|
-
|
1447
|
-
|
1448
|
-
|
1443
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1444
|
+
const parentSlotIndexFn2 = () => {
|
1445
|
+
return parentComponent.node.slots[parentSlot].findIndex(
|
1446
|
+
(x) => x === enqueueingComponent
|
1447
|
+
);
|
1448
|
+
};
|
1449
|
+
return {
|
1450
|
+
type: "slot",
|
1451
|
+
ancestorsAndSelf: [
|
1452
|
+
{
|
1453
|
+
type: "slot",
|
1454
|
+
node: enqueueingComponent,
|
1455
|
+
parentSlot,
|
1456
|
+
get parentSlotIndex() {
|
1457
|
+
return parentSlotIndexFn2();
|
1458
|
+
},
|
1459
|
+
parentSlotIndexFn: parentSlotIndexFn2
|
1460
|
+
},
|
1461
|
+
// slice removes 'self' since we are inserting a peer of self
|
1462
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1463
|
+
],
|
1464
|
+
context: descendantContext
|
1465
|
+
};
|
1466
|
+
})
|
1449
1467
|
);
|
1450
1468
|
}
|
1451
1469
|
} else {
|
@@ -1477,6 +1495,12 @@ function walkNodeTree(node, visitor, options) {
|
|
1477
1495
|
const components = slots[slotKey];
|
1478
1496
|
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
1479
1497
|
const enqueueingComponent = components[componentIndex];
|
1498
|
+
const parentSlotIndexFn = () => {
|
1499
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
1500
|
+
(x) => x === enqueueingComponent
|
1501
|
+
);
|
1502
|
+
return result;
|
1503
|
+
};
|
1480
1504
|
componentQueue.push({
|
1481
1505
|
ancestorsAndSelf: [
|
1482
1506
|
{
|
@@ -1484,10 +1508,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1484
1508
|
node: enqueueingComponent,
|
1485
1509
|
parentSlot: slotKey,
|
1486
1510
|
get parentSlotIndex() {
|
1487
|
-
return
|
1488
|
-
|
1489
|
-
|
1490
|
-
}
|
1511
|
+
return parentSlotIndexFn();
|
1512
|
+
},
|
1513
|
+
parentSlotIndexFn
|
1491
1514
|
},
|
1492
1515
|
...currentQueueEntry.ancestorsAndSelf
|
1493
1516
|
],
|
@@ -1523,6 +1546,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1523
1546
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1524
1547
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1525
1548
|
const enqueueingBlock = blocks[blockIndex];
|
1549
|
+
const blockIndexFn = () => {
|
1550
|
+
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
1551
|
+
};
|
1526
1552
|
componentQueue.push({
|
1527
1553
|
ancestorsAndSelf: [
|
1528
1554
|
{
|
@@ -1530,10 +1556,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1530
1556
|
node: enqueueingBlock,
|
1531
1557
|
fieldName: propKey,
|
1532
1558
|
get blockIndex() {
|
1533
|
-
return
|
1534
|
-
|
1535
|
-
|
1536
|
-
}
|
1559
|
+
return blockIndexFn();
|
1560
|
+
},
|
1561
|
+
blockIndexFn
|
1537
1562
|
},
|
1538
1563
|
...currentQueueEntry.ancestorsAndSelf
|
1539
1564
|
],
|
@@ -1824,7 +1849,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1824
1849
|
const parentLocation = ancestorsAndSelf[i + 1];
|
1825
1850
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1826
1851
|
if (currentLocation.type === "block") {
|
1827
|
-
const { fieldName: parameterName,
|
1852
|
+
const { fieldName: parameterName, blockIndexFn } = currentLocation;
|
1853
|
+
const blockIndex = blockIndexFn();
|
1828
1854
|
if (parameterName && blockIndex !== void 0) {
|
1829
1855
|
const noun = getNounForLocation(parentLocation);
|
1830
1856
|
path.push(`${noun}/${parameterName}/value/${blockIndex}`);
|
@@ -1833,7 +1859,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1833
1859
|
}
|
1834
1860
|
continue;
|
1835
1861
|
}
|
1836
|
-
const
|
1862
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
1863
|
+
const { parentSlot } = currentLocation;
|
1837
1864
|
if (parentSlot && parentSlotIndex !== void 0) {
|
1838
1865
|
path.push(`slots/${parentSlot}/${parentSlotIndex}`);
|
1839
1866
|
}
|
package/dist/index.mjs
CHANGED
@@ -910,7 +910,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
910
910
|
const parentLocation = ancestorsAndSelf[i + 1];
|
911
911
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
912
912
|
if (currentLocation.type === "block") {
|
913
|
-
const { fieldName,
|
913
|
+
const { fieldName, blockIndexFn } = currentLocation;
|
914
|
+
const blockIndex = blockIndexFn();
|
914
915
|
if (fieldName && blockIndex !== void 0) {
|
915
916
|
const noun = parentLocation && "type" in parentLocation && parentLocation.type === "block" ? "fields" : "parameters";
|
916
917
|
path.push(`${noun}.${fieldName}.value[${blockIndex}]`);
|
@@ -919,7 +920,8 @@ function getComponentPath(ancestorsAndSelf) {
|
|
919
920
|
}
|
920
921
|
continue;
|
921
922
|
}
|
922
|
-
const
|
923
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
924
|
+
const { parentSlot } = currentLocation;
|
923
925
|
if (parentSlot && parentSlotIndex !== void 0) {
|
924
926
|
path.push(`${parentSlot}[${parentSlotIndex}]`);
|
925
927
|
}
|
@@ -1156,7 +1158,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1156
1158
|
const currentComponentLocation = currentQueueEntry.ancestorsAndSelf[0];
|
1157
1159
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1158
1160
|
if (currentComponentLocation.type === "block") {
|
1159
|
-
const { fieldName,
|
1161
|
+
const { fieldName, blockIndexFn } = currentComponentLocation;
|
1162
|
+
const blockIndex = blockIndexFn();
|
1160
1163
|
const blockValue = getBlockValue(parentComponent.node, fieldName);
|
1161
1164
|
blockValue.splice(blockIndex, 1);
|
1162
1165
|
if (blockValue.length === 0) {
|
@@ -1173,7 +1176,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1173
1176
|
if (currentNodeInfo.type !== "block") {
|
1174
1177
|
throw new Error("Unknown type");
|
1175
1178
|
}
|
1176
|
-
const { fieldName,
|
1179
|
+
const { fieldName, blockIndexFn } = currentNodeInfo;
|
1180
|
+
const blockIndex = blockIndexFn();
|
1177
1181
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1178
1182
|
const nodesToInsert = Array.isArray(nodes) ? nodes : [nodes];
|
1179
1183
|
if (fieldName && typeof blockIndex !== "undefined") {
|
@@ -1183,22 +1187,28 @@ function walkNodeTree(node, visitor, options) {
|
|
1183
1187
|
...nodesToInsert
|
1184
1188
|
);
|
1185
1189
|
componentQueue.unshift(
|
1186
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1190
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1191
|
+
const blockIndexFn2 = () => {
|
1192
|
+
const parentArray = getPropertiesValue(parentComponent.node)[fieldName].value;
|
1193
|
+
return parentArray.findIndex((x) => x === enqueueingComponent);
|
1194
|
+
};
|
1195
|
+
return {
|
1196
|
+
ancestorsAndSelf: [
|
1197
|
+
{
|
1198
|
+
type: "block",
|
1199
|
+
node: enqueueingComponent,
|
1200
|
+
fieldName,
|
1201
|
+
get blockIndex() {
|
1202
|
+
return blockIndexFn2();
|
1203
|
+
},
|
1204
|
+
blockIndexFn: blockIndexFn2
|
1205
|
+
},
|
1206
|
+
// slice removes 'self' since we are inserting a peer of self
|
1207
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1208
|
+
],
|
1209
|
+
context: descendantContext
|
1210
|
+
};
|
1211
|
+
})
|
1202
1212
|
);
|
1203
1213
|
}
|
1204
1214
|
},
|
@@ -1247,7 +1257,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1247
1257
|
throw new Error("Unable to delete root node.");
|
1248
1258
|
}
|
1249
1259
|
if (currentComponentLocation.type === "slot") {
|
1250
|
-
const { parentSlot,
|
1260
|
+
const { parentSlot, parentSlotIndexFn } = currentComponentLocation;
|
1261
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1251
1262
|
parentComponent.node.slots[parentSlot].splice(parentSlotIndex, 1);
|
1252
1263
|
} else {
|
1253
1264
|
throw new Error("Unknown node type");
|
@@ -1261,7 +1272,8 @@ function walkNodeTree(node, visitor, options) {
|
|
1261
1272
|
throw new Error("Unable to insert after root node.");
|
1262
1273
|
}
|
1263
1274
|
if (currentNodeInfo.type === "slot") {
|
1264
|
-
const { parentSlot,
|
1275
|
+
const { parentSlot, parentSlotIndexFn } = currentNodeInfo;
|
1276
|
+
const parentSlotIndex = parentSlotIndexFn();
|
1265
1277
|
const parentComponent = currentQueueEntry.ancestorsAndSelf[1];
|
1266
1278
|
if (parentSlot && typeof parentSlotIndex !== "undefined") {
|
1267
1279
|
parentComponent.node.slots[parentSlot].splice(
|
@@ -1270,24 +1282,30 @@ function walkNodeTree(node, visitor, options) {
|
|
1270
1282
|
...nodesToInsert
|
1271
1283
|
);
|
1272
1284
|
componentQueue.unshift(
|
1273
|
-
...nodesToInsert.map((enqueueingComponent) =>
|
1274
|
-
|
1275
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1280
|
-
|
1281
|
-
|
1282
|
-
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
1290
|
-
|
1285
|
+
...nodesToInsert.map((enqueueingComponent) => {
|
1286
|
+
const parentSlotIndexFn2 = () => {
|
1287
|
+
return parentComponent.node.slots[parentSlot].findIndex(
|
1288
|
+
(x) => x === enqueueingComponent
|
1289
|
+
);
|
1290
|
+
};
|
1291
|
+
return {
|
1292
|
+
type: "slot",
|
1293
|
+
ancestorsAndSelf: [
|
1294
|
+
{
|
1295
|
+
type: "slot",
|
1296
|
+
node: enqueueingComponent,
|
1297
|
+
parentSlot,
|
1298
|
+
get parentSlotIndex() {
|
1299
|
+
return parentSlotIndexFn2();
|
1300
|
+
},
|
1301
|
+
parentSlotIndexFn: parentSlotIndexFn2
|
1302
|
+
},
|
1303
|
+
// slice removes 'self' since we are inserting a peer of self
|
1304
|
+
...currentQueueEntry.ancestorsAndSelf.slice(1)
|
1305
|
+
],
|
1306
|
+
context: descendantContext
|
1307
|
+
};
|
1308
|
+
})
|
1291
1309
|
);
|
1292
1310
|
}
|
1293
1311
|
} else {
|
@@ -1319,6 +1337,12 @@ function walkNodeTree(node, visitor, options) {
|
|
1319
1337
|
const components = slots[slotKey];
|
1320
1338
|
for (let componentIndex = components.length - 1; componentIndex >= 0; componentIndex--) {
|
1321
1339
|
const enqueueingComponent = components[componentIndex];
|
1340
|
+
const parentSlotIndexFn = () => {
|
1341
|
+
const result = currentComponent.node.slots[slotKey].findIndex(
|
1342
|
+
(x) => x === enqueueingComponent
|
1343
|
+
);
|
1344
|
+
return result;
|
1345
|
+
};
|
1322
1346
|
componentQueue.push({
|
1323
1347
|
ancestorsAndSelf: [
|
1324
1348
|
{
|
@@ -1326,10 +1350,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1326
1350
|
node: enqueueingComponent,
|
1327
1351
|
parentSlot: slotKey,
|
1328
1352
|
get parentSlotIndex() {
|
1329
|
-
return
|
1330
|
-
|
1331
|
-
|
1332
|
-
}
|
1353
|
+
return parentSlotIndexFn();
|
1354
|
+
},
|
1355
|
+
parentSlotIndexFn
|
1333
1356
|
},
|
1334
1357
|
...currentQueueEntry.ancestorsAndSelf
|
1335
1358
|
],
|
@@ -1365,6 +1388,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1365
1388
|
const blocks = (_b = propObject.value) != null ? _b : [];
|
1366
1389
|
for (let blockIndex = blocks.length - 1; blockIndex >= 0; blockIndex--) {
|
1367
1390
|
const enqueueingBlock = blocks[blockIndex];
|
1391
|
+
const blockIndexFn = () => {
|
1392
|
+
return getBlockValue(currentComponent.node, propKey).findIndex((x) => x === enqueueingBlock);
|
1393
|
+
};
|
1368
1394
|
componentQueue.push({
|
1369
1395
|
ancestorsAndSelf: [
|
1370
1396
|
{
|
@@ -1372,10 +1398,9 @@ function walkNodeTree(node, visitor, options) {
|
|
1372
1398
|
node: enqueueingBlock,
|
1373
1399
|
fieldName: propKey,
|
1374
1400
|
get blockIndex() {
|
1375
|
-
return
|
1376
|
-
|
1377
|
-
|
1378
|
-
}
|
1401
|
+
return blockIndexFn();
|
1402
|
+
},
|
1403
|
+
blockIndexFn
|
1379
1404
|
},
|
1380
1405
|
...currentQueueEntry.ancestorsAndSelf
|
1381
1406
|
],
|
@@ -1666,7 +1691,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1666
1691
|
const parentLocation = ancestorsAndSelf[i + 1];
|
1667
1692
|
if ("type" in currentLocation && currentLocation.type !== "slot") {
|
1668
1693
|
if (currentLocation.type === "block") {
|
1669
|
-
const { fieldName: parameterName,
|
1694
|
+
const { fieldName: parameterName, blockIndexFn } = currentLocation;
|
1695
|
+
const blockIndex = blockIndexFn();
|
1670
1696
|
if (parameterName && blockIndex !== void 0) {
|
1671
1697
|
const noun = getNounForLocation(parentLocation);
|
1672
1698
|
path.push(`${noun}/${parameterName}/value/${blockIndex}`);
|
@@ -1675,7 +1701,8 @@ function getComponentJsonPointer(ancestorsAndSelf) {
|
|
1675
1701
|
}
|
1676
1702
|
continue;
|
1677
1703
|
}
|
1678
|
-
const
|
1704
|
+
const parentSlotIndex = "parentSlotIndexFn" in currentLocation ? currentLocation.parentSlotIndexFn() : currentLocation.parentSlotIndex;
|
1705
|
+
const { parentSlot } = currentLocation;
|
1679
1706
|
if (parentSlot && parentSlotIndex !== void 0) {
|
1680
1707
|
path.push(`slots/${parentSlot}/${parentSlotIndex}`);
|
1681
1708
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@uniformdev/canvas",
|
3
|
-
"version": "19.
|
3
|
+
"version": "19.204.1-alpha.2+0262cf78a6",
|
4
4
|
"description": "Common functionality and types for Uniform Canvas",
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
6
6
|
"main": "./dist/index.js",
|
@@ -38,9 +38,9 @@
|
|
38
38
|
"pusher-js": "8.2.0"
|
39
39
|
},
|
40
40
|
"dependencies": {
|
41
|
-
"@uniformdev/assets": "19.
|
42
|
-
"@uniformdev/context": "19.
|
43
|
-
"@uniformdev/richtext": "19.
|
41
|
+
"@uniformdev/assets": "19.204.1-alpha.2+0262cf78a6",
|
42
|
+
"@uniformdev/context": "19.204.1-alpha.2+0262cf78a6",
|
43
|
+
"@uniformdev/richtext": "19.204.1-alpha.2+0262cf78a6",
|
44
44
|
"immer": "10.1.1"
|
45
45
|
},
|
46
46
|
"files": [
|
@@ -49,5 +49,5 @@
|
|
49
49
|
"publishConfig": {
|
50
50
|
"access": "public"
|
51
51
|
},
|
52
|
-
"gitHead": "
|
52
|
+
"gitHead": "0262cf78a6bd7179419e2e1505c1a985fd1103de"
|
53
53
|
}
|