@uniformdev/canvas 19.202.0 → 19.202.1-alpha.9
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 +66 -1
- package/dist/index.d.ts +66 -1
- 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
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ApiClient, ExceptProject, ClientOptions, ApiClientError } from '@uniformdev/context/api';
|
2
2
|
export { ApiClientError } from '@uniformdev/context/api';
|
3
|
-
import { AssetGetResponseSingle } from '@uniformdev/assets';
|
3
|
+
import { AssetGetResponseSingle, AssetDefinitionType } from '@uniformdev/assets';
|
4
4
|
import { Quirks, StorageCommands, PersonalizedVariant, TestVariant } from '@uniformdev/context';
|
5
5
|
import Pusher from 'pusher-js';
|
6
6
|
import { Options as Options$1 } from 'p-retry';
|
@@ -467,6 +467,13 @@ interface components$n {
|
|
467
467
|
[key: string]: components$n["schemas"]["ComponentInstance"][];
|
468
468
|
};
|
469
469
|
variant?: string;
|
470
|
+
/** @description Overrides data resource definitions for a pattern component.
|
471
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
472
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
473
|
+
* */
|
474
|
+
dataResources?: {
|
475
|
+
[key: string]: components$n["schemas"]["DataResourceDefinition"];
|
476
|
+
};
|
470
477
|
};
|
471
478
|
/**
|
472
479
|
* @description Whether a parameter is overridable
|
@@ -1081,6 +1088,13 @@ interface components$m {
|
|
1081
1088
|
[key: string]: components$m["schemas"]["ComponentInstance"][];
|
1082
1089
|
};
|
1083
1090
|
variant?: string;
|
1091
|
+
/** @description Overrides data resource definitions for a pattern component.
|
1092
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
1093
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
1094
|
+
* */
|
1095
|
+
dataResources?: {
|
1096
|
+
[key: string]: components$m["schemas"]["DataResourceDefinition"];
|
1097
|
+
};
|
1084
1098
|
};
|
1085
1099
|
/** @description Defines how a component on a pattern may have its values overridden.
|
1086
1100
|
* NOTE: Data resources' overridability is defined in the data resource definition, not here.
|
@@ -2231,6 +2245,13 @@ interface components$k {
|
|
2231
2245
|
[key: string]: components$k["schemas"]["ComponentInstance"][];
|
2232
2246
|
};
|
2233
2247
|
variant?: string;
|
2248
|
+
/** @description Overrides data resource definitions for a pattern component.
|
2249
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
2250
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
2251
|
+
* */
|
2252
|
+
dataResources?: {
|
2253
|
+
[key: string]: components$k["schemas"]["DataResourceDefinition"];
|
2254
|
+
};
|
2234
2255
|
};
|
2235
2256
|
/**
|
2236
2257
|
* @description Whether a parameter is overridable
|
@@ -3351,6 +3372,13 @@ interface components$i {
|
|
3351
3372
|
[key: string]: components$i["schemas"]["ComponentInstance"][];
|
3352
3373
|
};
|
3353
3374
|
variant?: string;
|
3375
|
+
/** @description Overrides data resource definitions for a pattern component.
|
3376
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
3377
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
3378
|
+
* */
|
3379
|
+
dataResources?: {
|
3380
|
+
[key: string]: components$i["schemas"]["DataResourceDefinition"];
|
3381
|
+
};
|
3354
3382
|
};
|
3355
3383
|
/**
|
3356
3384
|
* @description Whether a parameter is overridable
|
@@ -5521,6 +5549,13 @@ interface components$b {
|
|
5521
5549
|
[key: string]: components$b["schemas"]["ComponentInstance"][];
|
5522
5550
|
};
|
5523
5551
|
variant?: string;
|
5552
|
+
/** @description Overrides data resource definitions for a pattern component.
|
5553
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
5554
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
5555
|
+
* */
|
5556
|
+
dataResources?: {
|
5557
|
+
[key: string]: components$b["schemas"]["DataResourceDefinition"];
|
5558
|
+
};
|
5524
5559
|
};
|
5525
5560
|
/**
|
5526
5561
|
* @description Whether a parameter is overridable
|
@@ -6646,6 +6681,13 @@ interface components$a {
|
|
6646
6681
|
[key: string]: components$a["schemas"]["ComponentInstance"][];
|
6647
6682
|
};
|
6648
6683
|
variant?: string;
|
6684
|
+
/** @description Overrides data resource definitions for a pattern component.
|
6685
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
6686
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
6687
|
+
* */
|
6688
|
+
dataResources?: {
|
6689
|
+
[key: string]: components$a["schemas"]["DataResourceDefinition"];
|
6690
|
+
};
|
6649
6691
|
};
|
6650
6692
|
/**
|
6651
6693
|
* @description Whether a parameter is overridable
|
@@ -7625,6 +7667,13 @@ interface components$8 {
|
|
7625
7667
|
[key: string]: components$8["schemas"]["ComponentInstance"][];
|
7626
7668
|
};
|
7627
7669
|
variant?: string;
|
7670
|
+
/** @description Overrides data resource definitions for a pattern component.
|
7671
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
7672
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
7673
|
+
* */
|
7674
|
+
dataResources?: {
|
7675
|
+
[key: string]: components$8["schemas"]["DataResourceDefinition"];
|
7676
|
+
};
|
7628
7677
|
};
|
7629
7678
|
/**
|
7630
7679
|
* @description Whether a parameter is overridable
|
@@ -8905,6 +8954,13 @@ interface components$7 {
|
|
8905
8954
|
[key: string]: components$7["schemas"]["ComponentInstance"][];
|
8906
8955
|
};
|
8907
8956
|
variant?: string;
|
8957
|
+
/** @description Overrides data resource definitions for a pattern component.
|
8958
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
8959
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
8960
|
+
* */
|
8961
|
+
dataResources?: {
|
8962
|
+
[key: string]: components$7["schemas"]["DataResourceDefinition"];
|
8963
|
+
};
|
8908
8964
|
};
|
8909
8965
|
/**
|
8910
8966
|
* @description Whether a parameter is overridable
|
@@ -9930,6 +9986,11 @@ type RichTextParamConfiguration = {
|
|
9930
9986
|
elements?: {
|
9931
9987
|
builtIn?: Array<RichTextBuiltInElement>;
|
9932
9988
|
};
|
9989
|
+
elementsConfig?: {
|
9990
|
+
asset?: {
|
9991
|
+
allowedTypes?: AssetDefinitionType[];
|
9992
|
+
};
|
9993
|
+
};
|
9933
9994
|
};
|
9934
9995
|
type RichTextParamValue = ParameterRichTextValue;
|
9935
9996
|
|
@@ -11648,14 +11709,18 @@ type ComponentLocationReferenceV2 = {
|
|
11648
11709
|
type: 'slot';
|
11649
11710
|
node: ComponentInstance;
|
11650
11711
|
parentSlot: string;
|
11712
|
+
/** @deprecated invoke parentSlotIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11651
11713
|
parentSlotIndex: number;
|
11714
|
+
parentSlotIndexFn: () => number;
|
11652
11715
|
};
|
11653
11716
|
/** Ancestor location that is in a block on a parameter or field */
|
11654
11717
|
type BlockLocationReference = {
|
11655
11718
|
type: 'block';
|
11656
11719
|
node: EntryData;
|
11657
11720
|
fieldName: string;
|
11721
|
+
/** @deprecated invoke blockIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11658
11722
|
blockIndex: number;
|
11723
|
+
blockIndexFn: () => number;
|
11659
11724
|
};
|
11660
11725
|
/** Ancestor location that is the root of a composition or entry */
|
11661
11726
|
type RootLocationReference = {
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ApiClient, ExceptProject, ClientOptions, ApiClientError } from '@uniformdev/context/api';
|
2
2
|
export { ApiClientError } from '@uniformdev/context/api';
|
3
|
-
import { AssetGetResponseSingle } from '@uniformdev/assets';
|
3
|
+
import { AssetGetResponseSingle, AssetDefinitionType } from '@uniformdev/assets';
|
4
4
|
import { Quirks, StorageCommands, PersonalizedVariant, TestVariant } from '@uniformdev/context';
|
5
5
|
import Pusher from 'pusher-js';
|
6
6
|
import { Options as Options$1 } from 'p-retry';
|
@@ -467,6 +467,13 @@ interface components$n {
|
|
467
467
|
[key: string]: components$n["schemas"]["ComponentInstance"][];
|
468
468
|
};
|
469
469
|
variant?: string;
|
470
|
+
/** @description Overrides data resource definitions for a pattern component.
|
471
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
472
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
473
|
+
* */
|
474
|
+
dataResources?: {
|
475
|
+
[key: string]: components$n["schemas"]["DataResourceDefinition"];
|
476
|
+
};
|
470
477
|
};
|
471
478
|
/**
|
472
479
|
* @description Whether a parameter is overridable
|
@@ -1081,6 +1088,13 @@ interface components$m {
|
|
1081
1088
|
[key: string]: components$m["schemas"]["ComponentInstance"][];
|
1082
1089
|
};
|
1083
1090
|
variant?: string;
|
1091
|
+
/** @description Overrides data resource definitions for a pattern component.
|
1092
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
1093
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
1094
|
+
* */
|
1095
|
+
dataResources?: {
|
1096
|
+
[key: string]: components$m["schemas"]["DataResourceDefinition"];
|
1097
|
+
};
|
1084
1098
|
};
|
1085
1099
|
/** @description Defines how a component on a pattern may have its values overridden.
|
1086
1100
|
* NOTE: Data resources' overridability is defined in the data resource definition, not here.
|
@@ -2231,6 +2245,13 @@ interface components$k {
|
|
2231
2245
|
[key: string]: components$k["schemas"]["ComponentInstance"][];
|
2232
2246
|
};
|
2233
2247
|
variant?: string;
|
2248
|
+
/** @description Overrides data resource definitions for a pattern component.
|
2249
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
2250
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
2251
|
+
* */
|
2252
|
+
dataResources?: {
|
2253
|
+
[key: string]: components$k["schemas"]["DataResourceDefinition"];
|
2254
|
+
};
|
2234
2255
|
};
|
2235
2256
|
/**
|
2236
2257
|
* @description Whether a parameter is overridable
|
@@ -3351,6 +3372,13 @@ interface components$i {
|
|
3351
3372
|
[key: string]: components$i["schemas"]["ComponentInstance"][];
|
3352
3373
|
};
|
3353
3374
|
variant?: string;
|
3375
|
+
/** @description Overrides data resource definitions for a pattern component.
|
3376
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
3377
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
3378
|
+
* */
|
3379
|
+
dataResources?: {
|
3380
|
+
[key: string]: components$i["schemas"]["DataResourceDefinition"];
|
3381
|
+
};
|
3354
3382
|
};
|
3355
3383
|
/**
|
3356
3384
|
* @description Whether a parameter is overridable
|
@@ -5521,6 +5549,13 @@ interface components$b {
|
|
5521
5549
|
[key: string]: components$b["schemas"]["ComponentInstance"][];
|
5522
5550
|
};
|
5523
5551
|
variant?: string;
|
5552
|
+
/** @description Overrides data resource definitions for a pattern component.
|
5553
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
5554
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
5555
|
+
* */
|
5556
|
+
dataResources?: {
|
5557
|
+
[key: string]: components$b["schemas"]["DataResourceDefinition"];
|
5558
|
+
};
|
5524
5559
|
};
|
5525
5560
|
/**
|
5526
5561
|
* @description Whether a parameter is overridable
|
@@ -6646,6 +6681,13 @@ interface components$a {
|
|
6646
6681
|
[key: string]: components$a["schemas"]["ComponentInstance"][];
|
6647
6682
|
};
|
6648
6683
|
variant?: string;
|
6684
|
+
/** @description Overrides data resource definitions for a pattern component.
|
6685
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
6686
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
6687
|
+
* */
|
6688
|
+
dataResources?: {
|
6689
|
+
[key: string]: components$a["schemas"]["DataResourceDefinition"];
|
6690
|
+
};
|
6649
6691
|
};
|
6650
6692
|
/**
|
6651
6693
|
* @description Whether a parameter is overridable
|
@@ -7625,6 +7667,13 @@ interface components$8 {
|
|
7625
7667
|
[key: string]: components$8["schemas"]["ComponentInstance"][];
|
7626
7668
|
};
|
7627
7669
|
variant?: string;
|
7670
|
+
/** @description Overrides data resource definitions for a pattern component.
|
7671
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
7672
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
7673
|
+
* */
|
7674
|
+
dataResources?: {
|
7675
|
+
[key: string]: components$8["schemas"]["DataResourceDefinition"];
|
7676
|
+
};
|
7628
7677
|
};
|
7629
7678
|
/**
|
7630
7679
|
* @description Whether a parameter is overridable
|
@@ -8905,6 +8954,13 @@ interface components$7 {
|
|
8905
8954
|
[key: string]: components$7["schemas"]["ComponentInstance"][];
|
8906
8955
|
};
|
8907
8956
|
variant?: string;
|
8957
|
+
/** @description Overrides data resource definitions for a pattern component.
|
8958
|
+
* Object keys defined under this property override the corresponding keys in the pattern's data resources.
|
8959
|
+
* Overrides defined here replace values in either _dataResources or _patternDataResources on the target component.
|
8960
|
+
* */
|
8961
|
+
dataResources?: {
|
8962
|
+
[key: string]: components$7["schemas"]["DataResourceDefinition"];
|
8963
|
+
};
|
8908
8964
|
};
|
8909
8965
|
/**
|
8910
8966
|
* @description Whether a parameter is overridable
|
@@ -9930,6 +9986,11 @@ type RichTextParamConfiguration = {
|
|
9930
9986
|
elements?: {
|
9931
9987
|
builtIn?: Array<RichTextBuiltInElement>;
|
9932
9988
|
};
|
9989
|
+
elementsConfig?: {
|
9990
|
+
asset?: {
|
9991
|
+
allowedTypes?: AssetDefinitionType[];
|
9992
|
+
};
|
9993
|
+
};
|
9933
9994
|
};
|
9934
9995
|
type RichTextParamValue = ParameterRichTextValue;
|
9935
9996
|
|
@@ -11648,14 +11709,18 @@ type ComponentLocationReferenceV2 = {
|
|
11648
11709
|
type: 'slot';
|
11649
11710
|
node: ComponentInstance;
|
11650
11711
|
parentSlot: string;
|
11712
|
+
/** @deprecated invoke parentSlotIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11651
11713
|
parentSlotIndex: number;
|
11714
|
+
parentSlotIndexFn: () => number;
|
11652
11715
|
};
|
11653
11716
|
/** Ancestor location that is in a block on a parameter or field */
|
11654
11717
|
type BlockLocationReference = {
|
11655
11718
|
type: 'block';
|
11656
11719
|
node: EntryData;
|
11657
11720
|
fieldName: string;
|
11721
|
+
/** @deprecated invoke blockIndexFn instead, this property may be unreliable with some bundlers. This will be removed in the next major. */
|
11658
11722
|
blockIndex: number;
|
11723
|
+
blockIndexFn: () => number;
|
11659
11724
|
};
|
11660
11725
|
/** Ancestor location that is the root of a composition or entry */
|
11661
11726
|
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.202.
|
3
|
+
"version": "19.202.1-alpha.9+63c059770a",
|
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.202.
|
42
|
-
"@uniformdev/context": "19.202.
|
43
|
-
"@uniformdev/richtext": "19.202.
|
41
|
+
"@uniformdev/assets": "19.202.1-alpha.9+63c059770a",
|
42
|
+
"@uniformdev/context": "19.202.1-alpha.9+63c059770a",
|
43
|
+
"@uniformdev/richtext": "19.202.1-alpha.9+63c059770a",
|
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": "63c059770a54fc063a12af0f74eba059143e8074"
|
53
53
|
}
|