@prismicio/types-internal 3.11.1 → 3.11.2-alpha.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/lib/customtypes/CustomType.js +8 -6
- package/lib/customtypes/Section.js +7 -3
- package/lib/customtypes/widgets/Group.js +18 -20
- package/lib/customtypes/widgets/slices/CompositeSlice.js +21 -9
- package/lib/customtypes/widgets/slices/SharedSlice.js +35 -18
- package/lib/customtypes/widgets/slices/Slices.js +15 -9
- package/package.json +1 -1
- package/src/customtypes/CustomType.ts +7 -7
- package/src/customtypes/Section.ts +7 -3
- package/src/customtypes/widgets/Group.ts +18 -20
- package/src/customtypes/widgets/slices/CompositeSlice.ts +21 -9
- package/src/customtypes/widgets/slices/SharedSlice.ts +36 -23
- package/src/customtypes/widgets/slices/Slices.ts +14 -9
|
@@ -165,17 +165,19 @@ function collectSharedSlices(customType) {
|
|
|
165
165
|
exports.collectSharedSlices = collectSharedSlices;
|
|
166
166
|
function traverseCustomType(args) {
|
|
167
167
|
const { customType, onField } = args;
|
|
168
|
-
|
|
168
|
+
let json;
|
|
169
169
|
for (const [key, section] of Object.entries(customType.json)) {
|
|
170
|
-
|
|
170
|
+
const newSection = (0, Section_1.traverseSection)({
|
|
171
171
|
path: [key],
|
|
172
172
|
section,
|
|
173
173
|
onField,
|
|
174
174
|
});
|
|
175
|
+
if (newSection !== section) {
|
|
176
|
+
if (!json)
|
|
177
|
+
json = { ...customType.json };
|
|
178
|
+
json[key] = newSection;
|
|
179
|
+
}
|
|
175
180
|
}
|
|
176
|
-
return {
|
|
177
|
-
...customType,
|
|
178
|
-
json,
|
|
179
|
-
};
|
|
181
|
+
return json ? { ...customType, json } : customType;
|
|
180
182
|
}
|
|
181
183
|
exports.traverseCustomType = traverseCustomType;
|
|
@@ -22,7 +22,7 @@ exports.Sections = {
|
|
|
22
22
|
};
|
|
23
23
|
function traverseSection(args) {
|
|
24
24
|
const { path: prevPath, section: prevSection, onField } = args;
|
|
25
|
-
|
|
25
|
+
let section;
|
|
26
26
|
for (const [key, prevModel] of Object.entries(prevSection)) {
|
|
27
27
|
const path = [...prevPath, key];
|
|
28
28
|
let model;
|
|
@@ -54,8 +54,12 @@ function traverseSection(args) {
|
|
|
54
54
|
});
|
|
55
55
|
break;
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
if (model !== prevModel) {
|
|
58
|
+
if (!section)
|
|
59
|
+
section = { ...prevSection };
|
|
60
|
+
section[key] = model;
|
|
61
|
+
}
|
|
58
62
|
}
|
|
59
|
-
return section;
|
|
63
|
+
return section !== null && section !== void 0 ? section : prevSection;
|
|
60
64
|
}
|
|
61
65
|
exports.traverseSection = traverseSection;
|
|
@@ -36,22 +36,21 @@ function traverseNestedGroup(args) {
|
|
|
36
36
|
const { path: prevPath, group, onField } = args;
|
|
37
37
|
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
38
38
|
return group;
|
|
39
|
-
|
|
40
|
-
for (const [key,
|
|
39
|
+
let fields;
|
|
40
|
+
for (const [key, field] of Object.entries(group.config.fields)) {
|
|
41
41
|
const path = [...prevPath, key];
|
|
42
|
-
|
|
42
|
+
const newField = onField({
|
|
43
43
|
path,
|
|
44
44
|
key,
|
|
45
|
-
field
|
|
45
|
+
field,
|
|
46
46
|
});
|
|
47
|
+
if (field !== newField) {
|
|
48
|
+
if (!fields)
|
|
49
|
+
fields = { ...group.config.fields };
|
|
50
|
+
fields[key] = newField;
|
|
51
|
+
}
|
|
47
52
|
}
|
|
48
|
-
return {
|
|
49
|
-
...group,
|
|
50
|
-
config: {
|
|
51
|
-
...group.config,
|
|
52
|
-
fields,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
53
|
+
return fields ? { ...group, config: { ...group.config, fields } } : group;
|
|
55
54
|
}
|
|
56
55
|
exports.traverseNestedGroup = traverseNestedGroup;
|
|
57
56
|
function traverseGroup(args) {
|
|
@@ -59,7 +58,7 @@ function traverseGroup(args) {
|
|
|
59
58
|
const { path: prevPath, group, onField } = args;
|
|
60
59
|
if (!((_a = group.config) === null || _a === void 0 ? void 0 : _a.fields))
|
|
61
60
|
return group;
|
|
62
|
-
|
|
61
|
+
let fields;
|
|
63
62
|
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
64
63
|
const path = [...prevPath, key];
|
|
65
64
|
let field;
|
|
@@ -75,18 +74,17 @@ function traverseGroup(args) {
|
|
|
75
74
|
field = prevField;
|
|
76
75
|
break;
|
|
77
76
|
}
|
|
78
|
-
|
|
77
|
+
const newField = onField({
|
|
79
78
|
path,
|
|
80
79
|
key,
|
|
81
80
|
field,
|
|
82
81
|
});
|
|
82
|
+
if (field !== newField) {
|
|
83
|
+
if (!fields)
|
|
84
|
+
fields = { ...group.config.fields };
|
|
85
|
+
fields[key] = newField;
|
|
86
|
+
}
|
|
83
87
|
}
|
|
84
|
-
return {
|
|
85
|
-
...group,
|
|
86
|
-
config: {
|
|
87
|
-
...group.config,
|
|
88
|
-
fields,
|
|
89
|
-
},
|
|
90
|
-
};
|
|
88
|
+
return fields ? { ...group, config: { ...group.config, fields } } : group;
|
|
91
89
|
}
|
|
92
90
|
exports.traverseGroup = traverseGroup;
|
|
@@ -31,20 +31,32 @@ exports.isCompositeSlice = isCompositeSlice;
|
|
|
31
31
|
function traverseCompositeSlice(args) {
|
|
32
32
|
var _a, _b;
|
|
33
33
|
const { path: prevPath, slice, onField } = args;
|
|
34
|
-
|
|
34
|
+
let nonRepeat;
|
|
35
35
|
for (const [key, field] of Object.entries((_a = slice["non-repeat"]) !== null && _a !== void 0 ? _a : {})) {
|
|
36
36
|
const path = [...prevPath, "non-repeat", key];
|
|
37
|
-
|
|
37
|
+
const newField = onField({ path, key, field });
|
|
38
|
+
if (field !== newField) {
|
|
39
|
+
if (!nonRepeat)
|
|
40
|
+
nonRepeat = { ...slice["non-repeat"] };
|
|
41
|
+
nonRepeat[key] = newField;
|
|
42
|
+
}
|
|
38
43
|
}
|
|
39
|
-
|
|
44
|
+
let repeat;
|
|
40
45
|
for (const [key, field] of Object.entries((_b = slice.repeat) !== null && _b !== void 0 ? _b : {})) {
|
|
41
46
|
const path = [...prevPath, "repeat", key];
|
|
42
|
-
|
|
47
|
+
const newField = onField({ path, key, field });
|
|
48
|
+
if (field !== newField) {
|
|
49
|
+
if (!repeat)
|
|
50
|
+
repeat = { ...slice.repeat };
|
|
51
|
+
repeat[key] = newField;
|
|
52
|
+
}
|
|
43
53
|
}
|
|
44
|
-
return
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
return repeat || nonRepeat
|
|
55
|
+
? {
|
|
56
|
+
...slice,
|
|
57
|
+
...(nonRepeat && { "non-repeat": nonRepeat }),
|
|
58
|
+
...(repeat && { repeat }),
|
|
59
|
+
}
|
|
60
|
+
: slice;
|
|
49
61
|
}
|
|
50
62
|
exports.traverseCompositeSlice = traverseCompositeSlice;
|
|
@@ -50,7 +50,7 @@ exports.isDynamicSharedSlice = isDynamicSharedSlice;
|
|
|
50
50
|
function traverseVariation(args) {
|
|
51
51
|
var _a, _b;
|
|
52
52
|
const { path: prevPath, variation, onField } = args;
|
|
53
|
-
|
|
53
|
+
let primary;
|
|
54
54
|
for (const [key, prevField] of Object.entries((_a = variation.primary) !== null && _a !== void 0 ? _a : {})) {
|
|
55
55
|
const path = [...prevPath, "primary", key];
|
|
56
56
|
let field;
|
|
@@ -66,34 +66,51 @@ function traverseVariation(args) {
|
|
|
66
66
|
field = prevField;
|
|
67
67
|
break;
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
const newField = onField({ path, key, field });
|
|
70
|
+
if (field !== newField) {
|
|
71
|
+
if (!primary)
|
|
72
|
+
primary = { ...variation.primary };
|
|
73
|
+
primary[key] = newField;
|
|
74
|
+
}
|
|
70
75
|
}
|
|
71
|
-
|
|
72
|
-
for (const [key,
|
|
76
|
+
let items;
|
|
77
|
+
for (const [key, prevField] of Object.entries((_b = variation.items) !== null && _b !== void 0 ? _b : {})) {
|
|
73
78
|
const path = [...prevPath, "items", key];
|
|
74
|
-
|
|
79
|
+
const newField = onField({
|
|
80
|
+
path,
|
|
81
|
+
key,
|
|
82
|
+
field: prevField,
|
|
83
|
+
});
|
|
84
|
+
if (prevField !== newField) {
|
|
85
|
+
if (!items)
|
|
86
|
+
items = { ...variation.items };
|
|
87
|
+
items[key] = newField;
|
|
88
|
+
}
|
|
75
89
|
}
|
|
76
|
-
return
|
|
77
|
-
...variation,
|
|
78
|
-
|
|
79
|
-
...(variation.items && { items }),
|
|
80
|
-
};
|
|
90
|
+
return primary || items
|
|
91
|
+
? { ...variation, ...(primary && { primary }), ...(items && { items }) }
|
|
92
|
+
: variation;
|
|
81
93
|
}
|
|
82
94
|
exports.traverseVariation = traverseVariation;
|
|
83
95
|
function traverseSharedSlice(args) {
|
|
84
96
|
const { path: prevPath, slice, onField } = args;
|
|
85
|
-
|
|
86
|
-
for (
|
|
97
|
+
let variations;
|
|
98
|
+
for (let i = 0; i < slice.variations.length; i++) {
|
|
99
|
+
const variation = slice.variations[i];
|
|
100
|
+
if (!variation)
|
|
101
|
+
continue;
|
|
87
102
|
const path = [...prevPath, variation.id];
|
|
88
|
-
|
|
103
|
+
const newVariation = traverseVariation({
|
|
89
104
|
path,
|
|
90
105
|
variation,
|
|
91
106
|
onField,
|
|
92
|
-
})
|
|
107
|
+
});
|
|
108
|
+
if (newVariation !== variation) {
|
|
109
|
+
if (!variations)
|
|
110
|
+
variations = [...slice.variations];
|
|
111
|
+
variations[i] = newVariation;
|
|
112
|
+
}
|
|
93
113
|
}
|
|
94
|
-
return {
|
|
95
|
-
...slice,
|
|
96
|
-
variations,
|
|
97
|
-
};
|
|
114
|
+
return variations ? { ...slice, variations } : slice;
|
|
98
115
|
}
|
|
99
116
|
exports.traverseSharedSlice = traverseSharedSlice;
|
|
@@ -84,7 +84,7 @@ function traverseSlices(args) {
|
|
|
84
84
|
const { path: prevPath, slices, onField } = args;
|
|
85
85
|
if (!((_a = slices.config) === null || _a === void 0 ? void 0 : _a.choices))
|
|
86
86
|
return slices;
|
|
87
|
-
|
|
87
|
+
let choices;
|
|
88
88
|
for (const [key, prevModel] of Object.entries(slices.config.choices)) {
|
|
89
89
|
const path = [...prevPath, key];
|
|
90
90
|
let model;
|
|
@@ -126,14 +126,20 @@ function traverseSlices(args) {
|
|
|
126
126
|
});
|
|
127
127
|
break;
|
|
128
128
|
}
|
|
129
|
-
|
|
129
|
+
if (model !== prevModel) {
|
|
130
|
+
if (!choices)
|
|
131
|
+
choices = { ...slices.config.choices };
|
|
132
|
+
choices[key] = model;
|
|
133
|
+
}
|
|
130
134
|
}
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
return choices
|
|
136
|
+
? {
|
|
137
|
+
...slices,
|
|
138
|
+
config: {
|
|
139
|
+
...slices.config,
|
|
140
|
+
choices,
|
|
141
|
+
},
|
|
142
|
+
}
|
|
143
|
+
: slices;
|
|
138
144
|
}
|
|
139
145
|
exports.traverseSlices = traverseSlices;
|
package/package.json
CHANGED
|
@@ -261,17 +261,17 @@ export function traverseCustomType<
|
|
|
261
261
|
}): T {
|
|
262
262
|
const { customType, onField } = args
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
let json: Record<string, typeof customType.json[string]> | undefined
|
|
265
265
|
for (const [key, section] of Object.entries(customType.json)) {
|
|
266
|
-
|
|
266
|
+
const newSection = traverseSection({
|
|
267
267
|
path: [key],
|
|
268
268
|
section,
|
|
269
269
|
onField,
|
|
270
270
|
})
|
|
271
|
+
if (newSection !== section) {
|
|
272
|
+
if (!json) json = { ...customType.json }
|
|
273
|
+
json[key] = newSection
|
|
274
|
+
}
|
|
271
275
|
}
|
|
272
|
-
|
|
273
|
-
return {
|
|
274
|
-
...customType,
|
|
275
|
-
json,
|
|
276
|
-
}
|
|
276
|
+
return json ? { ...customType, json } : customType
|
|
277
277
|
}
|
|
@@ -52,7 +52,7 @@ export function traverseSection<
|
|
|
52
52
|
}): T {
|
|
53
53
|
const { path: prevPath, section: prevSection, onField } = args
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
let section: T | undefined
|
|
56
56
|
for (const [key, prevModel] of Object.entries(prevSection)) {
|
|
57
57
|
const path = [...prevPath, key]
|
|
58
58
|
let model
|
|
@@ -84,7 +84,11 @@ export function traverseSection<
|
|
|
84
84
|
})
|
|
85
85
|
break
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
if (model !== prevModel) {
|
|
88
|
+
if (!section) section = { ...prevSection }
|
|
89
|
+
section[key] = model
|
|
90
|
+
}
|
|
88
91
|
}
|
|
89
|
-
|
|
92
|
+
|
|
93
|
+
return section ?? prevSection
|
|
90
94
|
}
|
|
@@ -58,23 +58,22 @@ export function traverseNestedGroup(args: {
|
|
|
58
58
|
|
|
59
59
|
if (!group.config?.fields) return group
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
for (const [key,
|
|
61
|
+
let fields: Record<string, NestableWidget> | undefined
|
|
62
|
+
for (const [key, field] of Object.entries(group.config.fields)) {
|
|
63
63
|
const path = [...prevPath, key]
|
|
64
|
-
|
|
64
|
+
const newField = onField({
|
|
65
65
|
path,
|
|
66
66
|
key,
|
|
67
|
-
field
|
|
67
|
+
field,
|
|
68
68
|
})
|
|
69
|
-
}
|
|
70
69
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
fields,
|
|
76
|
-
},
|
|
70
|
+
if (field !== newField) {
|
|
71
|
+
if (!fields) fields = { ...group.config.fields }
|
|
72
|
+
fields[key] = newField
|
|
73
|
+
}
|
|
77
74
|
}
|
|
75
|
+
|
|
76
|
+
return fields ? { ...group, config: { ...group.config, fields } } : group
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
export function traverseGroup(args: {
|
|
@@ -86,7 +85,7 @@ export function traverseGroup(args: {
|
|
|
86
85
|
|
|
87
86
|
if (!group.config?.fields) return group
|
|
88
87
|
|
|
89
|
-
|
|
88
|
+
let fields: Record<string, NestableWidget | NestedGroup> | undefined
|
|
90
89
|
for (const [key, prevField] of Object.entries(group.config.fields)) {
|
|
91
90
|
const path = [...prevPath, key]
|
|
92
91
|
let field
|
|
@@ -102,18 +101,17 @@ export function traverseGroup(args: {
|
|
|
102
101
|
field = prevField
|
|
103
102
|
break
|
|
104
103
|
}
|
|
105
|
-
|
|
104
|
+
|
|
105
|
+
const newField = onField({
|
|
106
106
|
path,
|
|
107
107
|
key,
|
|
108
108
|
field,
|
|
109
109
|
})
|
|
110
|
+
if (field !== newField) {
|
|
111
|
+
if (!fields) fields = { ...group.config.fields }
|
|
112
|
+
fields[key] = newField
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
|
|
112
|
-
return {
|
|
113
|
-
...group,
|
|
114
|
-
config: {
|
|
115
|
-
...group.config,
|
|
116
|
-
fields,
|
|
117
|
-
},
|
|
118
|
-
}
|
|
116
|
+
return fields ? { ...group, config: { ...group.config, fields } } : group
|
|
119
117
|
}
|
|
@@ -46,21 +46,33 @@ export function traverseCompositeSlice(args: {
|
|
|
46
46
|
}): CompositeSlice {
|
|
47
47
|
const { path: prevPath, slice, onField } = args
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
let nonRepeat: Record<string, NestableWidget> | undefined
|
|
50
50
|
for (const [key, field] of Object.entries(slice["non-repeat"] ?? {})) {
|
|
51
51
|
const path = [...prevPath, "non-repeat", key]
|
|
52
|
-
|
|
52
|
+
const newField = onField({ path, key, field })
|
|
53
|
+
|
|
54
|
+
if (field !== newField) {
|
|
55
|
+
if (!nonRepeat) nonRepeat = { ...slice["non-repeat"] }
|
|
56
|
+
nonRepeat[key] = newField
|
|
57
|
+
}
|
|
53
58
|
}
|
|
54
59
|
|
|
55
|
-
|
|
60
|
+
let repeat: Record<string, NestableWidget> | undefined
|
|
56
61
|
for (const [key, field] of Object.entries(slice.repeat ?? {})) {
|
|
57
62
|
const path = [...prevPath, "repeat", key]
|
|
58
|
-
|
|
59
|
-
}
|
|
63
|
+
const newField = onField({ path, key, field })
|
|
60
64
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (field !== newField) {
|
|
66
|
+
if (!repeat) repeat = { ...slice.repeat }
|
|
67
|
+
repeat[key] = newField
|
|
68
|
+
}
|
|
65
69
|
}
|
|
70
|
+
|
|
71
|
+
return repeat || nonRepeat
|
|
72
|
+
? {
|
|
73
|
+
...slice,
|
|
74
|
+
...(nonRepeat && { "non-repeat": nonRepeat }),
|
|
75
|
+
...(repeat && { repeat }),
|
|
76
|
+
}
|
|
77
|
+
: slice
|
|
66
78
|
}
|
|
@@ -79,7 +79,7 @@ export function traverseVariation(args: {
|
|
|
79
79
|
}): Variation {
|
|
80
80
|
const { path: prevPath, variation, onField } = args
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
let primary: Record<string, NestableWidget | Group> | undefined
|
|
83
83
|
for (const [key, prevField] of Object.entries(variation.primary ?? {})) {
|
|
84
84
|
const path = [...prevPath, "primary", key]
|
|
85
85
|
let field
|
|
@@ -95,20 +95,31 @@ export function traverseVariation(args: {
|
|
|
95
95
|
field = prevField
|
|
96
96
|
break
|
|
97
97
|
}
|
|
98
|
-
|
|
98
|
+
|
|
99
|
+
const newField = onField({ path, key, field })
|
|
100
|
+
if (field !== newField) {
|
|
101
|
+
if (!primary) primary = { ...variation.primary }
|
|
102
|
+
primary[key] = newField
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
|
|
101
|
-
|
|
102
|
-
for (const [key,
|
|
106
|
+
let items: Record<string, NestableWidget> | undefined
|
|
107
|
+
for (const [key, prevField] of Object.entries(variation.items ?? {})) {
|
|
103
108
|
const path = [...prevPath, "items", key]
|
|
104
|
-
|
|
109
|
+
const newField = (onField as OnFieldFn<NestableWidget>)({
|
|
110
|
+
path,
|
|
111
|
+
key,
|
|
112
|
+
field: prevField,
|
|
113
|
+
})
|
|
114
|
+
if (prevField !== newField) {
|
|
115
|
+
if (!items) items = { ...variation.items }
|
|
116
|
+
items[key] = newField
|
|
117
|
+
}
|
|
105
118
|
}
|
|
106
119
|
|
|
107
|
-
return
|
|
108
|
-
...variation,
|
|
109
|
-
|
|
110
|
-
...(variation.items && { items }),
|
|
111
|
-
}
|
|
120
|
+
return primary || items
|
|
121
|
+
? { ...variation, ...(primary && { primary }), ...(items && { items }) }
|
|
122
|
+
: variation
|
|
112
123
|
}
|
|
113
124
|
|
|
114
125
|
export function traverseSharedSlice(args: {
|
|
@@ -118,20 +129,22 @@ export function traverseSharedSlice(args: {
|
|
|
118
129
|
}): SharedSlice {
|
|
119
130
|
const { path: prevPath, slice, onField } = args
|
|
120
131
|
|
|
121
|
-
|
|
122
|
-
for (
|
|
132
|
+
let variations: Variation[] | undefined
|
|
133
|
+
for (let i = 0; i < slice.variations.length; i++) {
|
|
134
|
+
const variation = slice.variations[i]
|
|
135
|
+
if (!variation) continue
|
|
123
136
|
const path = [...prevPath, variation.id]
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
)
|
|
137
|
+
const newVariation = traverseVariation({
|
|
138
|
+
path,
|
|
139
|
+
variation,
|
|
140
|
+
onField,
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
if (newVariation !== variation) {
|
|
144
|
+
if (!variations) variations = [...slice.variations]
|
|
145
|
+
variations[i] = newVariation
|
|
146
|
+
}
|
|
131
147
|
}
|
|
132
148
|
|
|
133
|
-
return {
|
|
134
|
-
...slice,
|
|
135
|
-
variations,
|
|
136
|
-
}
|
|
149
|
+
return variations ? { ...slice, variations } : slice
|
|
137
150
|
}
|
|
@@ -123,7 +123,7 @@ export function traverseSlices<T extends DynamicSlices | StaticSlices>(args: {
|
|
|
123
123
|
|
|
124
124
|
if (!slices.config?.choices) return slices
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
let choices: Record<string, typeof slices.config.choices[string]> | undefined
|
|
127
127
|
for (const [key, prevModel] of Object.entries(slices.config.choices)) {
|
|
128
128
|
const path = [...prevPath, key]
|
|
129
129
|
let model
|
|
@@ -165,14 +165,19 @@ export function traverseSlices<T extends DynamicSlices | StaticSlices>(args: {
|
|
|
165
165
|
break
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
if (model !== prevModel) {
|
|
169
|
+
if (!choices) choices = { ...slices.config.choices }
|
|
170
|
+
choices[key] = model as typeof slices.config.choices[string]
|
|
171
|
+
}
|
|
169
172
|
}
|
|
170
173
|
|
|
171
|
-
return
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
return choices
|
|
175
|
+
? {
|
|
176
|
+
...slices,
|
|
177
|
+
config: {
|
|
178
|
+
...slices.config,
|
|
179
|
+
choices,
|
|
180
|
+
},
|
|
181
|
+
}
|
|
182
|
+
: slices
|
|
178
183
|
}
|