@yahoo/uds-create-config 5.96.6 → 5.98.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/configs/system.js +2 -0
- package/dist/entities/system/Source.d.ts +1 -0
- package/dist/entities/system/Source.js +39 -3
- package/dist/entities/system/component-module.d.ts +15 -1
- package/dist/entities/system/component-module.js +76 -5
- package/dist/entities/system/copy-plan.js +2 -1
- package/dist/entities/system/defineComponent.d.ts +7 -1
- package/dist/entities/system/icon-library.js +9 -0
- package/dist/entities/system/vendor-conditions.d.ts +123 -0
- package/dist/entities/system/vendor-conditions.js +324 -0
- package/dist/framework/Config.d.ts +24 -2
- package/dist/framework/Config.js +44 -6
- package/dist/framework/class-names.js +7 -4
- package/dist/framework/module-views.d.ts +9 -1
- package/dist/framework/projections.js +56 -10
- package/dist/framework/prop-surface.d.ts +7 -1
- package/dist/framework/prop-surface.js +140 -37
- package/dist/framework/ref-integrity.js +1 -0
- package/dist/framework/registry.d.ts +3 -1
- package/dist/framework/render-spec.js +6 -0
- package/dist/framework/schema-version.d.ts +1 -1
- package/dist/framework/schema-version.js +5 -5
- package/dist/framework/source-integrity.js +1 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +5 -4
- package/dist/lint/rules.d.ts +6 -0
- package/dist/lint/rules.js +6 -0
- package/dist/migrations/20261112163439_vendor_link_type.d.ts +8 -0
- package/dist/migrations/20261112163439_vendor_link_type.js +10 -0
- package/dist/spec/glyph-jsx.js +4 -2
- package/dist/spec/glyph-members.js +3 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { isRef, kindOf, pathOf, ref, sourceOf } from "../../framework/utils/refs.js";
|
|
2
|
+
import { isPlainObject } from "../../framework/utils/field-path.js";
|
|
3
|
+
import { modifierCategory } from "./modifier-axis.js";
|
|
4
|
+
import { directivesOf } from "./link-declaration.js";
|
|
5
|
+
//#region src/entities/system/vendor-conditions.ts
|
|
6
|
+
/** How a modifier activates. A bound modifier takes these from ours and keeps the rest. */
|
|
7
|
+
const ACTIVATION_FIELDS = [
|
|
8
|
+
"type",
|
|
9
|
+
"value",
|
|
10
|
+
"media",
|
|
11
|
+
"declarations"
|
|
12
|
+
];
|
|
13
|
+
/** The entries of a pin's `options` that map a vendor modifier, as written. */
|
|
14
|
+
function vendorModifierMappings({ config, slug }) {
|
|
15
|
+
const accessor = config.accessorOf("modifier") ?? "modifier";
|
|
16
|
+
return directivesOf(config.storedBody("source", slug)).flatMap(([named, entries]) => named === accessor && isPlainObject(entries) ? Object.entries(entries).flatMap(([vendor, entry]) => isPlainObject(entry) && entry.override !== void 0 ? [{
|
|
17
|
+
vendor,
|
|
18
|
+
target: entry.override
|
|
19
|
+
}] : []) : []);
|
|
20
|
+
}
|
|
21
|
+
/** Whether a pin's `options` entry is a modifier mapping: a ref at a modifier, and nothing else. */
|
|
22
|
+
function isVendorModifierMapping({ config, accessor, entry }) {
|
|
23
|
+
return accessor === (config.accessorOf("modifier") ?? "modifier") && isPlainObject(entry) && entry.extend === void 0 && isRef(entry.override) && kindOf(entry.override) === "modifier";
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Why a pin's modifier mapping can't be written, one sentence per entry: what this config alone can
|
|
27
|
+
* say, so it holds as an invariant whether or not the source is attached.
|
|
28
|
+
*/
|
|
29
|
+
function vendorModifierMappingProblems({ config, slug }) {
|
|
30
|
+
const problems = [];
|
|
31
|
+
for (const mapping of modifierMappings({
|
|
32
|
+
config,
|
|
33
|
+
slug
|
|
34
|
+
})) if (!mapping.ours) problems.push(`${mapping.at} maps the vendor's modifier to "${mapping.target}", which isn't a modifier of this system.`);
|
|
35
|
+
else if (activationOf(mapping.ours).type === "composite") problems.push(`${mapping.at} maps the vendor's modifier to "${mapping.ours.path}", which asks whether an element sits on a surface. Only a selector or a query can stand in for the vendor's.`);
|
|
36
|
+
return problems;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The pin's modifier mappings that map nothing in the attached source: a path the source doesn't
|
|
40
|
+
* hold, or a modifier of another category than ours. Such a modifier keeps the vendor's own
|
|
41
|
+
* activation, which isn't what the entry asked for, so a build reports it.
|
|
42
|
+
*/
|
|
43
|
+
function unheldVendorModifierMappings({ config, slug }) {
|
|
44
|
+
const vendor = config.liveSourceFor(slug);
|
|
45
|
+
if (!vendor) return [];
|
|
46
|
+
const problems = [];
|
|
47
|
+
for (const mapping of modifierMappings({
|
|
48
|
+
config,
|
|
49
|
+
slug
|
|
50
|
+
})) {
|
|
51
|
+
if (!mapping.ours || activationOf(mapping.ours).type === "composite") continue;
|
|
52
|
+
const theirs = vendor.resolve("modifier", mapping.vendor);
|
|
53
|
+
if (!theirs) {
|
|
54
|
+
problems.push(`${mapping.at} names no modifier of the source. Its modifiers are spelled by path, as in "appearance/dark".`);
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const theirCategory = modifierCategory(vendor, theirs.path) ?? "plain";
|
|
58
|
+
const ourCategory = modifierCategory(config, mapping.ours.path) ?? "plain";
|
|
59
|
+
if (theirCategory !== ourCategory) problems.push(`${mapping.at} maps a ${theirCategory} modifier to "${mapping.ours.path}", which is a ${ourCategory} one here. A modifier maps to one of the same kind.`);
|
|
60
|
+
}
|
|
61
|
+
return problems;
|
|
62
|
+
}
|
|
63
|
+
/** Each mapping a pin writes, with the modifier of this config it names when there is one. */
|
|
64
|
+
function modifierMappings({ config, slug }) {
|
|
65
|
+
const accessor = config.accessorOf("modifier") ?? "modifier";
|
|
66
|
+
return vendorModifierMappings({
|
|
67
|
+
config,
|
|
68
|
+
slug
|
|
69
|
+
}).flatMap((mapping) => {
|
|
70
|
+
const { target } = mapping;
|
|
71
|
+
if (!isRef(target) || kindOf(target) !== "modifier") return [];
|
|
72
|
+
return [{
|
|
73
|
+
vendor: mapping.vendor,
|
|
74
|
+
at: `Link "${slug}": options.${accessor}["${mapping.vendor}"]`,
|
|
75
|
+
target: pathOf(target),
|
|
76
|
+
ours: sourceOf(target) === void 0 ? config.resolve("modifier", pathOf(target)) : void 0
|
|
77
|
+
}];
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The vendor's modifiers this config states as its own, vendor path to our path: the ones the pin
|
|
82
|
+
* maps, then the modes a selector switches that we hold at the same path. A modifier that asks
|
|
83
|
+
* about a surface (`composite`) is never bound, since the surface it asks about is the vendor's.
|
|
84
|
+
*/
|
|
85
|
+
function vendorModifierBindings({ consumer, slug }) {
|
|
86
|
+
const vendor = consumer.sourceFor(slug);
|
|
87
|
+
if (!vendor || consumer.sourceTypeOf(slug) !== "vendor") return NO_BINDINGS;
|
|
88
|
+
const held = bindings.get(consumer)?.get(slug);
|
|
89
|
+
if (held?.vendor === vendor) return held.bound;
|
|
90
|
+
const bound = /* @__PURE__ */ new Map();
|
|
91
|
+
const bind = ({ theirs, ours }) => {
|
|
92
|
+
const vendorModifier = vendor.resolve("modifier", theirs);
|
|
93
|
+
const ourModifier = consumer.resolve("modifier", ours);
|
|
94
|
+
if (!vendorModifier || !ourModifier) return;
|
|
95
|
+
if (vendor.vendorOf("modifier", vendorModifier.path)) return;
|
|
96
|
+
if (activationOf(vendorModifier).type === "composite") return;
|
|
97
|
+
if (activationOf(ourModifier).type === "composite") return;
|
|
98
|
+
if (modifierCategory(vendor, vendorModifier.path) !== modifierCategory(consumer, ourModifier.path)) return;
|
|
99
|
+
bound.set(vendorModifier.path, ourModifier.path);
|
|
100
|
+
};
|
|
101
|
+
for (const mapping of vendorModifierMappings({
|
|
102
|
+
config: consumer,
|
|
103
|
+
slug
|
|
104
|
+
})) {
|
|
105
|
+
if (!isRef(mapping.target) || kindOf(mapping.target) !== "modifier") continue;
|
|
106
|
+
if (sourceOf(mapping.target) !== void 0) continue;
|
|
107
|
+
bind({
|
|
108
|
+
theirs: mapping.vendor,
|
|
109
|
+
ours: pathOf(mapping.target)
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
const switched = (config, path) => modifierCategory(config, path) === "mode" && activationOf(config.resolve("modifier", path)).type === "selector";
|
|
113
|
+
const own = new Set(consumer.list("modifier").map(({ path }) => path));
|
|
114
|
+
for (const { path } of vendor.list("modifier")) {
|
|
115
|
+
if (bound.has(path) || !own.has(path)) continue;
|
|
116
|
+
if (!switched(vendor, path) || !switched(consumer, path)) continue;
|
|
117
|
+
bind({
|
|
118
|
+
theirs: path,
|
|
119
|
+
ours: path
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
let bySlug = bindings.get(consumer);
|
|
123
|
+
if (!bySlug) {
|
|
124
|
+
bySlug = /* @__PURE__ */ new Map();
|
|
125
|
+
bindings.set(consumer, bySlug);
|
|
126
|
+
}
|
|
127
|
+
bySlug.set(slug, {
|
|
128
|
+
vendor,
|
|
129
|
+
bound
|
|
130
|
+
});
|
|
131
|
+
return bound;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Each mode of a `vendor` pin's source that what the pin takes varies under, and that nothing in
|
|
135
|
+
* this config turns on: a selector switches it, no binding states it as one of ours
|
|
136
|
+
* ({@link vendorModifierBindings}), and none of our modifiers is switched by the same selector. It
|
|
137
|
+
* keeps the vendor's own switch, which only the app can set, so the lint reports it.
|
|
138
|
+
*
|
|
139
|
+
* A mode a query decides is left out, since the device answers it wherever the component renders.
|
|
140
|
+
*/
|
|
141
|
+
function unmappedVendorModes(config) {
|
|
142
|
+
const found = [];
|
|
143
|
+
const ours = config.list("modifier").map(({ path }) => ({
|
|
144
|
+
path,
|
|
145
|
+
mode: modifierCategory(config, path) === "mode",
|
|
146
|
+
...activationOf(config.resolve("modifier", path))
|
|
147
|
+
}));
|
|
148
|
+
const switches = new Set(ours.flatMap(({ type, value }) => type === "selector" && typeof value === "string" ? [value.trim()] : []));
|
|
149
|
+
for (const slug of config.sourceSlugs()) {
|
|
150
|
+
if (config.sourceTypeOf(slug) !== "vendor") continue;
|
|
151
|
+
const vendor = config.sourceFor(slug);
|
|
152
|
+
if (!vendor) continue;
|
|
153
|
+
const bound = vendorModifierBindings({
|
|
154
|
+
consumer: config,
|
|
155
|
+
slug
|
|
156
|
+
});
|
|
157
|
+
for (const target of config.sourceClosure(slug, "modifier")) {
|
|
158
|
+
const modifier = vendor.resolve("modifier", pathOf(target));
|
|
159
|
+
if (!modifier || bound.has(modifier.path)) continue;
|
|
160
|
+
if (modifierCategory(vendor, modifier.path) !== "mode") continue;
|
|
161
|
+
if (vendor.vendorOf("modifier", modifier.path)) continue;
|
|
162
|
+
const { type, value } = activationOf(modifier);
|
|
163
|
+
if (type !== "selector" || typeof value !== "string") continue;
|
|
164
|
+
if (switches.has(value.trim())) continue;
|
|
165
|
+
const leaf = modifier.path.split("/").pop();
|
|
166
|
+
const named = ours.filter(({ path, mode, type: ourType }) => mode && ourType !== "composite" && path.split("/").pop() === leaf);
|
|
167
|
+
found.push({
|
|
168
|
+
slug,
|
|
169
|
+
modifier: modifier.path,
|
|
170
|
+
selector: value,
|
|
171
|
+
...named.length === 1 && named[0] ? { candidate: named[0].path } : {}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return found;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The modes of a `vendor` pin's attached source that a mapping can state: each one a mode group
|
|
179
|
+
* holds, activated by a selector or a query, and not one the vendor itself takes as shipped.
|
|
180
|
+
* `undefined` for a pin that isn't `vendor`, or whose source isn't attached, since the recorded
|
|
181
|
+
* closure holds only the modes this config's refs reach.
|
|
182
|
+
*/
|
|
183
|
+
function vendorModes({ config, slug }) {
|
|
184
|
+
if (config.sourceTypeOf(slug) !== "vendor") return void 0;
|
|
185
|
+
const vendor = config.liveSourceFor(slug);
|
|
186
|
+
if (!vendor) return void 0;
|
|
187
|
+
const targets = config.list("modifier").filter(({ path }) => modifierCategory(config, path) === "mode" && activationOf(config.resolve("modifier", path)).type !== "composite").map(({ path }) => path);
|
|
188
|
+
const mapped = /* @__PURE__ */ new Map();
|
|
189
|
+
for (const mapping of vendorModifierMappings({
|
|
190
|
+
config,
|
|
191
|
+
slug
|
|
192
|
+
})) if (isRef(mapping.target) && kindOf(mapping.target) === "modifier") mapped.set(mapping.vendor, pathOf(mapping.target));
|
|
193
|
+
const bound = vendorModifierBindings({
|
|
194
|
+
consumer: config,
|
|
195
|
+
slug
|
|
196
|
+
});
|
|
197
|
+
const unmapped = new Map(unmappedVendorModes(config).filter((mode) => mode.slug === slug).map((mode) => [mode.modifier, mode.selector]));
|
|
198
|
+
return {
|
|
199
|
+
modes: vendor.list("modifier").flatMap(({ path }) => {
|
|
200
|
+
if (modifierCategory(vendor, path) !== "mode") return [];
|
|
201
|
+
if (vendor.vendorOf("modifier", path)) return [];
|
|
202
|
+
if (activationOf(vendor.resolve("modifier", path)).type === "composite") return [];
|
|
203
|
+
const ours = bound.get(path);
|
|
204
|
+
const mappedTo = mapped.get(path);
|
|
205
|
+
const selector = unmapped.get(path);
|
|
206
|
+
const leaf = path.split("/").pop();
|
|
207
|
+
const named = targets.filter((target) => target.split("/").pop() === leaf);
|
|
208
|
+
return [{
|
|
209
|
+
modifier: path,
|
|
210
|
+
...ours ? { follows: {
|
|
211
|
+
path: ours,
|
|
212
|
+
by: mappedTo === ours ? "mapping" : "path"
|
|
213
|
+
} } : {},
|
|
214
|
+
...mappedTo ? { mappedTo } : {},
|
|
215
|
+
...selector ? { unmapped: { selector } } : {},
|
|
216
|
+
...!ours && named.length === 1 && named[0] ? { candidate: named[0] } : {}
|
|
217
|
+
}];
|
|
218
|
+
}),
|
|
219
|
+
targets
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* The edit that maps one of a `vendor` pin's modifiers to one of this config's, or, with `to` as
|
|
224
|
+
* `null`, removes the mapping. Whatever else the pin's entry for it says is kept. The pin refuses an
|
|
225
|
+
* empty entry, so a removal that leaves none drops the entry, and the accessor when it was the last.
|
|
226
|
+
*/
|
|
227
|
+
function vendorModeMapping({ config, slug, modifier, to }) {
|
|
228
|
+
const accessor = config.accessorOf("modifier") ?? "modifier";
|
|
229
|
+
const entries = directivesOf(config.storedBody("source", slug)).find(([named]) => named === accessor)?.[1];
|
|
230
|
+
const held = isPlainObject(entries) ? entries : {};
|
|
231
|
+
const { override: _override, ...rest } = isPlainObject(held[modifier]) ? held[modifier] : {};
|
|
232
|
+
const at = `options.${accessor}.${modifier}`;
|
|
233
|
+
let data;
|
|
234
|
+
if (to !== null) data = { [at]: {
|
|
235
|
+
...rest,
|
|
236
|
+
override: ref("modifier", to)
|
|
237
|
+
} };
|
|
238
|
+
else if (Object.keys(rest).length > 0) data = { [at]: rest };
|
|
239
|
+
else if (Object.keys(held).some((path) => path !== modifier)) data = { [at]: null };
|
|
240
|
+
else data = { [`options.${accessor}`]: null };
|
|
241
|
+
return {
|
|
242
|
+
kind: "source",
|
|
243
|
+
operation: "update",
|
|
244
|
+
path: slug,
|
|
245
|
+
data
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* A `vendor` pin's source with its bound modifiers activating as this config's do
|
|
250
|
+
* ({@link vendorModifierBindings}). Each keeps the vendor's path, so the vendor's tokens, rules and
|
|
251
|
+
* style props read against it unchanged. `undefined` for a pin that isn't `vendor`, or whose source
|
|
252
|
+
* isn't attached.
|
|
253
|
+
*/
|
|
254
|
+
function vendorSource({ consumer, slug }) {
|
|
255
|
+
if (consumer.sourceTypeOf(slug) !== "vendor") return void 0;
|
|
256
|
+
const vendor = consumer.sourceFor(slug);
|
|
257
|
+
if (!vendor) return void 0;
|
|
258
|
+
const held = sources.get(consumer)?.get(slug);
|
|
259
|
+
if (held?.vendor === vendor) return held.stated;
|
|
260
|
+
const bound = vendorModifierBindings({
|
|
261
|
+
consumer,
|
|
262
|
+
slug
|
|
263
|
+
});
|
|
264
|
+
let stated = vendor.fork();
|
|
265
|
+
for (const [theirs, ours] of bound) {
|
|
266
|
+
const activation = activationOf(consumer.resolve("modifier", ours));
|
|
267
|
+
const current = activationOf(vendor.resolve("modifier", theirs));
|
|
268
|
+
if (ACTIVATION_FIELDS.every((field) => same(activation[field], current[field]))) continue;
|
|
269
|
+
stated = stated.apply({
|
|
270
|
+
kind: "modifier",
|
|
271
|
+
operation: "update",
|
|
272
|
+
path: theirs,
|
|
273
|
+
data: Object.fromEntries(ACTIVATION_FIELDS.flatMap((field) => {
|
|
274
|
+
if (activation[field] !== void 0) return [[field, activation[field]]];
|
|
275
|
+
return current[field] === void 0 ? [] : [[field, null]];
|
|
276
|
+
}))
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
recordStatedModifiers({
|
|
280
|
+
config: stated,
|
|
281
|
+
bound
|
|
282
|
+
});
|
|
283
|
+
let bySlug = sources.get(consumer);
|
|
284
|
+
if (!bySlug) {
|
|
285
|
+
bySlug = /* @__PURE__ */ new Map();
|
|
286
|
+
sources.set(consumer, bySlug);
|
|
287
|
+
}
|
|
288
|
+
bySlug.set(slug, {
|
|
289
|
+
vendor,
|
|
290
|
+
stated
|
|
291
|
+
});
|
|
292
|
+
return stated;
|
|
293
|
+
}
|
|
294
|
+
/** Records, on a config derived from a vendor's, which of its modifiers are stated as another's. */
|
|
295
|
+
function recordStatedModifiers({ config, bound }) {
|
|
296
|
+
if (bound.size > 0) statedAs.set(config, bound);
|
|
297
|
+
}
|
|
298
|
+
/** The modifiers a config states as another's, for a config derived from it to carry on. */
|
|
299
|
+
function statedModifiersOf(config) {
|
|
300
|
+
return statedAs.get(config) ?? NO_BINDINGS;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* The path a modifier is stated under: ours, for a vendor's modifier bound to one of ours, and its
|
|
304
|
+
* own otherwise. What names a mode outside the stylesheet's own selector reads this, as the
|
|
305
|
+
* attribute an editor forces a mode with does.
|
|
306
|
+
*/
|
|
307
|
+
function statedModifierPath(config, path) {
|
|
308
|
+
const bound = statedAs.get(config);
|
|
309
|
+
if (!bound) return path;
|
|
310
|
+
return bound.get(config.resolve("modifier", path)?.path ?? path) ?? path;
|
|
311
|
+
}
|
|
312
|
+
function activationOf(modifier) {
|
|
313
|
+
const body = modifier?.toJSON();
|
|
314
|
+
return isPlainObject(body) ? body : {};
|
|
315
|
+
}
|
|
316
|
+
function same(a, b) {
|
|
317
|
+
return JSON.stringify(a ?? null) === JSON.stringify(b ?? null);
|
|
318
|
+
}
|
|
319
|
+
const NO_BINDINGS = /* @__PURE__ */ new Map();
|
|
320
|
+
const bindings = /* @__PURE__ */ new WeakMap();
|
|
321
|
+
const sources = /* @__PURE__ */ new WeakMap();
|
|
322
|
+
const statedAs = /* @__PURE__ */ new WeakMap();
|
|
323
|
+
//#endregion
|
|
324
|
+
export { isVendorModifierMapping, recordStatedModifiers, statedModifierPath, statedModifiersOf, unheldVendorModifierMappings, unmappedVendorModes, vendorModeMapping, vendorModes, vendorModifierBindings, vendorModifierMappingProblems, vendorSource };
|
|
@@ -74,7 +74,7 @@ interface RecordedSource {
|
|
|
74
74
|
* The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
|
|
75
75
|
* that replaced it (see `detectedWireVersion`).
|
|
76
76
|
*/
|
|
77
|
-
declare const SERIALIZED_CONFIG_VERSION =
|
|
77
|
+
declare const SERIALIZED_CONFIG_VERSION = 20261112163439;
|
|
78
78
|
interface SerializedConfig {
|
|
79
79
|
/** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
|
|
80
80
|
readonly version: number;
|
|
@@ -621,6 +621,9 @@ declare class Config {
|
|
|
621
621
|
/** Bind this config's lineage to the handle that owns it — called by `ConfigSession`, so links
|
|
622
622
|
* taken off any config it produces resolve through the session rather than freezing. */
|
|
623
623
|
withOwner(owner: LiveConfig): this;
|
|
624
|
+
/** This config under an identity of its own. It answers what the receiver does, so a holder that
|
|
625
|
+
* keys a fact on the value (`registerModuleView`) can tag it and leave the receiver untagged. */
|
|
626
|
+
fork(): this;
|
|
624
627
|
/** The pending edits with their ids — what a sink persists and `merge` names. */
|
|
625
628
|
get pending(): readonly StampedPatch[];
|
|
626
629
|
/**
|
|
@@ -2460,6 +2463,9 @@ declare class Config {
|
|
|
2460
2463
|
* A path no pin declares goes to the first `linked` source when every `linked` source holding it
|
|
2461
2464
|
* reads the same entity, the `hybrid` ones yielding to them. With only `hybrid` sources it goes to
|
|
2462
2465
|
* the first on the same condition. Two pins declaring one path is a collision either way.
|
|
2466
|
+
*
|
|
2467
|
+
* A `vendor` source decides as a `linked` one does. It only ever offers what it declares, so
|
|
2468
|
+
* another link reaching a different entity at that path collides with it.
|
|
2463
2469
|
*/
|
|
2464
2470
|
private declaringClaimant;
|
|
2465
2471
|
/**
|
|
@@ -2483,6 +2489,18 @@ declare class Config {
|
|
|
2483
2489
|
/** How `slug`'s source joins this config ({@link EntityKind.sourceType}): `linked` unless its pin
|
|
2484
2490
|
* says otherwise. */
|
|
2485
2491
|
sourceTypeOf(slug: string): SourceType;
|
|
2492
|
+
/**
|
|
2493
|
+
* The `vendor` pin the item at `kind:path` is drawn through: a row its declaration derived, or a ref
|
|
2494
|
+
* this config placed under a name of its own. `undefined` for anything else, including a row of
|
|
2495
|
+
* this config's own whose fields name the source.
|
|
2496
|
+
*/
|
|
2497
|
+
/**
|
|
2498
|
+
* Refuse a write to a row a `vendor` pin draws. Its source is used as shipped, so even a write the
|
|
2499
|
+
* overlay would read as nothing (a `null` revealing the source's own value) is refused rather than
|
|
2500
|
+
* kept as an edit.
|
|
2501
|
+
*/
|
|
2502
|
+
private refuseVendorEdit;
|
|
2503
|
+
vendorOf(kind: string, path: string): string | undefined;
|
|
2486
2504
|
/**
|
|
2487
2505
|
* Whether a value `slug` brings is drawn with this config's row at `kind:path` rather than declared
|
|
2488
2506
|
* under the pin's own name: a token that something taken through `slug` names.
|
|
@@ -2490,7 +2508,8 @@ declare class Config {
|
|
|
2490
2508
|
* A `hybrid` pin binds to any row here that isn't its own, authored or held through another pin, so
|
|
2491
2509
|
* what it brings uses this config's values. A `linked` pin binds only to a row held through another
|
|
2492
2510
|
* pin that is the same entity, the way {@link heldThroughAnotherPin} reads it; a different one there
|
|
2493
|
-
* is a collision, and a row this config authored is its own entity under the same name.
|
|
2511
|
+
* is a collision, and a row this config authored is its own entity under the same name. A `vendor`
|
|
2512
|
+
* pin never binds: everything it brings is drawn from its own source.
|
|
2494
2513
|
*/
|
|
2495
2514
|
drawsWithLocalRow({
|
|
2496
2515
|
slug,
|
|
@@ -2631,6 +2650,9 @@ declare class Config {
|
|
|
2631
2650
|
* Every guard the adopted targets pass through applies to these too — a name this config already
|
|
2632
2651
|
* holds wins, an entry it cannot express is left behind — because
|
|
2633
2652
|
* they join the same loop rather than being written directly.
|
|
2653
|
+
*
|
|
2654
|
+
* A `vendor` pin has none. What it declares is all that lands, and the rest is read through the
|
|
2655
|
+
* source under the pin's names.
|
|
2634
2656
|
*/
|
|
2635
2657
|
private groupRefMembers;
|
|
2636
2658
|
adoptedFrom(slug: string): string[];
|
package/dist/framework/Config.js
CHANGED
|
@@ -241,7 +241,7 @@ function rejectCollisions(collisions) {
|
|
|
241
241
|
throw new ConfigRejection([{
|
|
242
242
|
code: "SOURCE_COLLISION",
|
|
243
243
|
collisions,
|
|
244
|
-
message: `This would leave ${collisions.length} ${one ? "path" : "paths"} offered by ${by} as different things, so neither applies: ${shown}${rest}. Take ${one ? "it" : "each"} from the system ${one ? "it" : "each"} should follow (\`source/link\` with \`onLinked: 'take'\`)
|
|
244
|
+
message: `This would leave ${collisions.length} ${one ? "path" : "paths"} offered by ${by} as different things, so neither applies: ${shown}${rest}. Take ${one ? "it" : "each"} from the system ${one ? "it" : "each"} should follow (\`source/link\` with \`onLinked: 'take'\`)${pins ? `, or make the link that only reaches ${one ? "it" : "them"} \`hybrid\`, so it uses what this system already has` : ""}.`
|
|
245
245
|
}]);
|
|
246
246
|
}
|
|
247
247
|
/** The snapshot a derived snapshot came from, while the parent holds a row derivation the child has
|
|
@@ -788,6 +788,11 @@ var Config = class Config {
|
|
|
788
788
|
withOwner(owner) {
|
|
789
789
|
return this.derive({ owner });
|
|
790
790
|
}
|
|
791
|
+
/** This config under an identity of its own. It answers what the receiver does, so a holder that
|
|
792
|
+
* keys a fact on the value (`registerModuleView`) can tag it and leave the receiver untagged. */
|
|
793
|
+
fork() {
|
|
794
|
+
return this.derive({});
|
|
795
|
+
}
|
|
791
796
|
/** The pending edits with their ids — what a sink persists and `merge` names. */
|
|
792
797
|
get pending() {
|
|
793
798
|
return this.state.pending;
|
|
@@ -2207,6 +2212,7 @@ var Config = class Config {
|
|
|
2207
2212
|
})]);
|
|
2208
2213
|
if (patch.operation === "sub-create" || patch.operation === "sub-upsert" || patch.operation === "sub-update" || patch.operation === "sub-delete" || patch.operation === "sub-rename" || patch.operation === "sub-reorder") {
|
|
2209
2214
|
if (extension) {
|
|
2215
|
+
this.at(snapshot).refuseVendorEdit(patch.kind, patch.path);
|
|
2210
2216
|
const resolved = this.at(snapshot).resolveExtension({
|
|
2211
2217
|
kind: patch.kind,
|
|
2212
2218
|
path: patch.path,
|
|
@@ -2316,6 +2322,7 @@ var Config = class Config {
|
|
|
2316
2322
|
}) : parsedDelta;
|
|
2317
2323
|
const touched = touchedFields(delta, isField);
|
|
2318
2324
|
if (extension) {
|
|
2325
|
+
this.at(snapshot).refuseVendorEdit(patch.kind, patch.path);
|
|
2319
2326
|
const resolved = this.at(snapshot).resolveExtension({
|
|
2320
2327
|
kind: patch.kind,
|
|
2321
2328
|
path: patch.path,
|
|
@@ -2890,6 +2897,7 @@ var Config = class Config {
|
|
|
2890
2897
|
...classifyOverlay(local, theirs),
|
|
2891
2898
|
...existing?.hidden ? { hidden: true } : {}
|
|
2892
2899
|
};
|
|
2900
|
+
if (view.sourceTypeOf(slug) === "vendor" && (overlay.override !== void 0 || overlay.extend !== void 0)) reject("UNSUPPORTED", `Cannot update ${kind} group "${path}" — it comes from the vendor source "${slug}", which is used as shipped.`);
|
|
2893
2901
|
const data = view.directiveWrite({
|
|
2894
2902
|
slug,
|
|
2895
2903
|
accessor,
|
|
@@ -5081,6 +5089,9 @@ var Config = class Config {
|
|
|
5081
5089
|
* A path no pin declares goes to the first `linked` source when every `linked` source holding it
|
|
5082
5090
|
* reads the same entity, the `hybrid` ones yielding to them. With only `hybrid` sources it goes to
|
|
5083
5091
|
* the first on the same condition. Two pins declaring one path is a collision either way.
|
|
5092
|
+
*
|
|
5093
|
+
* A `vendor` source decides as a `linked` one does. It only ever offers what it declares, so
|
|
5094
|
+
* another link reaching a different entity at that path collides with it.
|
|
5084
5095
|
*/
|
|
5085
5096
|
declaringClaimant({ target, slugs, declaredBy }) {
|
|
5086
5097
|
const declarers = slugs.filter((slug) => declaredBy.get(slug)?.has(target));
|
|
@@ -5093,7 +5104,7 @@ var Config = class Config {
|
|
|
5093
5104
|
kind,
|
|
5094
5105
|
path
|
|
5095
5106
|
}));
|
|
5096
|
-
const linked = slugs.filter((slug) => this.sourceTypeOf(slug)
|
|
5107
|
+
const linked = slugs.filter((slug) => this.sourceTypeOf(slug) !== "hybrid");
|
|
5097
5108
|
const [declarer] = declarers;
|
|
5098
5109
|
if (declarer !== void 0) return agree(declarer, linked) ? declarer : void 0;
|
|
5099
5110
|
const deciding = linked.length > 0 ? linked : slugs;
|
|
@@ -5184,20 +5195,44 @@ var Config = class Config {
|
|
|
5184
5195
|
return "linked";
|
|
5185
5196
|
}
|
|
5186
5197
|
/**
|
|
5198
|
+
* The `vendor` pin the item at `kind:path` is drawn through: a row its declaration derived, or a ref
|
|
5199
|
+
* this config placed under a name of its own. `undefined` for anything else, including a row of
|
|
5200
|
+
* this config's own whose fields name the source.
|
|
5201
|
+
*/
|
|
5202
|
+
/**
|
|
5203
|
+
* Refuse a write to a row a `vendor` pin draws. Its source is used as shipped, so even a write the
|
|
5204
|
+
* overlay would read as nothing (a `null` revealing the source's own value) is refused rather than
|
|
5205
|
+
* kept as an edit.
|
|
5206
|
+
*/
|
|
5207
|
+
refuseVendorEdit(kind, path) {
|
|
5208
|
+
const slug = this.vendorOf(kind, path);
|
|
5209
|
+
if (slug === void 0) return;
|
|
5210
|
+
reject("UNSUPPORTED", `Cannot edit ${kind} "${path}" — it comes from the vendor source "${slug}", which is used as shipped. To change it, wrap it in a ${kind} of your own.`);
|
|
5211
|
+
}
|
|
5212
|
+
vendorOf(kind, path) {
|
|
5213
|
+
const stored = this.storedBody(kind, path);
|
|
5214
|
+
if (!isRef(stored)) return void 0;
|
|
5215
|
+
const slug = sourceOf(stored.__ref);
|
|
5216
|
+
return slug !== void 0 && this.sourceTypeOf(slug) === "vendor" ? slug : void 0;
|
|
5217
|
+
}
|
|
5218
|
+
/**
|
|
5187
5219
|
* Whether a value `slug` brings is drawn with this config's row at `kind:path` rather than declared
|
|
5188
5220
|
* under the pin's own name: a token that something taken through `slug` names.
|
|
5189
5221
|
*
|
|
5190
5222
|
* A `hybrid` pin binds to any row here that isn't its own, authored or held through another pin, so
|
|
5191
5223
|
* what it brings uses this config's values. A `linked` pin binds only to a row held through another
|
|
5192
5224
|
* pin that is the same entity, the way {@link heldThroughAnotherPin} reads it; a different one there
|
|
5193
|
-
* is a collision, and a row this config authored is its own entity under the same name.
|
|
5225
|
+
* is a collision, and a row this config authored is its own entity under the same name. A `vendor`
|
|
5226
|
+
* pin never binds: everything it brings is drawn from its own source.
|
|
5194
5227
|
*/
|
|
5195
5228
|
drawsWithLocalRow({ slug, kind, path }) {
|
|
5196
5229
|
const stored = this.storedBody(kind, path);
|
|
5197
5230
|
if (stored === void 0) return false;
|
|
5198
5231
|
const held = isRef(stored) ? sourceOf(stored.__ref) : void 0;
|
|
5199
5232
|
if (held === slug) return false;
|
|
5200
|
-
|
|
5233
|
+
const type = this.sourceTypeOf(slug);
|
|
5234
|
+
if (type === "vendor") return false;
|
|
5235
|
+
if (type === "hybrid") return true;
|
|
5201
5236
|
if (!isMintedRow(stored) || held === void 0) return false;
|
|
5202
5237
|
return this.sameEntityThrough({
|
|
5203
5238
|
held,
|
|
@@ -5719,10 +5754,13 @@ var Config = class Config {
|
|
|
5719
5754
|
* Every guard the adopted targets pass through applies to these too — a name this config already
|
|
5720
5755
|
* holds wins, an entry it cannot express is left behind — because
|
|
5721
5756
|
* they join the same loop rather than being written directly.
|
|
5757
|
+
*
|
|
5758
|
+
* A `vendor` pin has none. What it declares is all that lands, and the rest is read through the
|
|
5759
|
+
* source under the pin's names.
|
|
5722
5760
|
*/
|
|
5723
5761
|
groupRefMembers(slug) {
|
|
5724
5762
|
const source = this.sourceFor(slug);
|
|
5725
|
-
if (!source) return [];
|
|
5763
|
+
if (!source || this.sourceTypeOf(slug) === "vendor") return [];
|
|
5726
5764
|
const members = /* @__PURE__ */ new Set();
|
|
5727
5765
|
/**
|
|
5728
5766
|
* Every entity or folder visited, and whether a linked row reached it.
|
|
@@ -6605,7 +6643,7 @@ var Config = class Config {
|
|
|
6605
6643
|
* links from the provided sources. A declared `linkedKind` with no provided source throws. */
|
|
6606
6644
|
hydrateFrom(stored, options) {
|
|
6607
6645
|
const claimed = schemaVersionOf(stored);
|
|
6608
|
-
if (claimed >
|
|
6646
|
+
if (claimed > 20261112163439) throw new SchemaVersionTooNew(claimed);
|
|
6609
6647
|
const wire = upgradeSerializedConfig(stored);
|
|
6610
6648
|
if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
|
|
6611
6649
|
const leftover = wire.options;
|
|
@@ -268,7 +268,9 @@ function compositePropRuleClasses(config, path) {
|
|
|
268
268
|
const out = [];
|
|
269
269
|
for (const [prop, groupRef, layer] of declared.groups) {
|
|
270
270
|
const group = pathOf(groupRef);
|
|
271
|
-
|
|
271
|
+
const slug = sourceOf(groupRef);
|
|
272
|
+
const holder = slug === void 0 || config.members("composite", group).length > 0 ? config : config.sourceFor(slug) ?? config;
|
|
273
|
+
for (const composite of holder.list("composite")) {
|
|
272
274
|
if (!composite.path.startsWith(`${group}/`)) continue;
|
|
273
275
|
const when = { [prop]: composite.path.slice(group.length + 1) };
|
|
274
276
|
out.push({
|
|
@@ -1171,8 +1173,8 @@ function compositeBags(entity) {
|
|
|
1171
1173
|
return [{ bag: entity.toJSON().styles }];
|
|
1172
1174
|
}
|
|
1173
1175
|
/**
|
|
1174
|
-
* A token object that changes when the class VOCABULARY does — the style properties,
|
|
1175
|
-
* their value domains reach.
|
|
1176
|
+
* A token object that changes when the class VOCABULARY does — the style properties, everything
|
|
1177
|
+
* their value domains reach, and the settings, which hold the class prefix.
|
|
1176
1178
|
*
|
|
1177
1179
|
* `splitStyleProps` names a class by asking the config what a prop's leaves are, so a scan's answer
|
|
1178
1180
|
* survives any edit that leaves those alone. Which is every edit to the entities being scanned.
|
|
@@ -1184,7 +1186,8 @@ const vocabularyToken = createSliceMemo({
|
|
|
1184
1186
|
"composite",
|
|
1185
1187
|
"motion",
|
|
1186
1188
|
"icon",
|
|
1187
|
-
"font"
|
|
1189
|
+
"font",
|
|
1190
|
+
"settings"
|
|
1188
1191
|
],
|
|
1189
1192
|
compute: (_config) => ({})
|
|
1190
1193
|
});
|
|
@@ -7,8 +7,16 @@ interface ModuleViewLink {
|
|
|
7
7
|
readonly consumer: Config;
|
|
8
8
|
readonly slug: string;
|
|
9
9
|
}
|
|
10
|
+
/** Records that `view` is an owner's config as `link.consumer` converts its files. */
|
|
11
|
+
declare function registerModuleView({
|
|
12
|
+
view,
|
|
13
|
+
link
|
|
14
|
+
}: {
|
|
15
|
+
readonly view: Config;
|
|
16
|
+
readonly link: ModuleViewLink;
|
|
17
|
+
}): void;
|
|
10
18
|
/** The consumer and pin `config` was built for, when it is a module view. A name it reads is its
|
|
11
19
|
* owner's, and what that names is drawn as the consumer draws it. */
|
|
12
20
|
declare function moduleViewOf(config: Config): ModuleViewLink | undefined;
|
|
13
21
|
//#endregion
|
|
14
|
-
export { ModuleViewLink, moduleViewOf };
|
|
22
|
+
export { ModuleViewLink, moduleViewOf, registerModuleView };
|