@yahoo/uds-create-config 5.95.3 → 5.96.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.
@@ -56,6 +56,11 @@ function convertLinkedTokenValue({ path, value, sourcePlatform, destinationPlatf
56
56
  if (LENGTH_GROUPS.has(group)) {
57
57
  if (typeof value === "number") return value;
58
58
  if (group === "size" && typeof value === "string" && (value === "auto" || /^-?(?:\d+(?:\.\d+)?|\.\d+)%$/.test(value))) return value;
59
+ if (group === "size" && typeof value === "string" && [
60
+ "min-content",
61
+ "max-content",
62
+ "fit-content"
63
+ ].includes(value)) throw new Error(`[uds] Linked native size token "${path}" has unsupported CSS intrinsic sizing value ${JSON.stringify(value)}. Use an explicit native layout: replacing it with auto alone can stretch a component in a column parent. Account for parent direction, label shrink, and caller width/minWidth/maxWidth.`);
59
64
  const match = typeof value === "string" ? LENGTH.exec(value) : null;
60
65
  if (!match) throw unsupported("native", path, value, "a px or rem length");
61
66
  if (match[2] === "rem" && remBase === void 0) throw new Error(`[uds] Linked native token "${path}" has value ${JSON.stringify(value)}, but its source has no fixed root font size for rem conversion.`);
@@ -21,7 +21,8 @@ type PropertySource = {
21
21
  readonly key: string;
22
22
  readonly layer: string;
23
23
  readonly when: Readonly<Record<string, unknown>>;
24
- readonly drivenBy: readonly string[];
24
+ readonly drivenBy: readonly string[]; /** The composite variant the rule applies, when the value is one of its styles. */
25
+ readonly composite?: string;
25
26
  } | {
26
27
  /** A forced modifier's block inside a rule, or a rule an interaction holds. */readonly kind: 'modifier';
27
28
  readonly modifier: string;
@@ -32,6 +33,11 @@ type PropertySource = {
32
33
  readonly prop: string;
33
34
  readonly composite: string;
34
35
  readonly variant: string;
36
+ } | {
37
+ /** The component a layer renders supplies it, through one of its own sources. */readonly kind: 'layer-component';
38
+ readonly layer: string;
39
+ readonly component: string;
40
+ readonly source: PropertySource;
35
41
  } | DefaultSource;
36
42
  /** Where a value the element can't write would change in the config. */
37
43
  type ConfigAddress = {
@@ -76,7 +82,7 @@ interface PropertyTarget {
76
82
  /**
77
83
  * A row for every property on a root element: every prop the component declares whose condition
78
84
  * holds, every key the element stores, every key the component's rules and defaults set on its root
79
- * layer, and every key in `include`.
85
+ * layer, every style value the component the root renders sets, and every key in `include`.
80
86
  */
81
87
  declare function resolveProperties({
82
88
  config,
@@ -3,8 +3,9 @@ import { rootLayerOf } from "./element.js";
3
3
  import { createSliceMemo } from "../../framework/memo.js";
4
4
  import { UDS_FORCE_STATES } from "../../framework/component-states.js";
5
5
  import { authoredBag, defaultSources, propOwner } from "../../framework/projections.js";
6
- import { propApplies, surfaceProps } from "../../framework/prop-surface.js";
6
+ import { forwardClaims, layerPropRoutes, propApplies, surfaceProps } from "../../framework/prop-surface.js";
7
7
  import { layerDeclarationStacks } from "../../framework/layer-styles.js";
8
+ import { layerRoutedProps, splitStyleProps } from "../../framework/class-names.js";
8
9
  import { Component } from "./Component.js";
9
10
  import { markerKind } from "../../framework/bindings.js";
10
11
  //#region src/entities/system/resolve-properties.ts
@@ -13,21 +14,29 @@ import { markerKind } from "../../framework/bindings.js";
13
14
  * the value that paints, where that value comes from, and whether the config lets you write it.
14
15
  *
15
16
  * The states are Donna's (Properties Panel Refactor): Set, Inherited, Default, Read-only and Not
16
- * declared. A value is the first source that sets the key, in the order the stylesheet ranks them:
17
- * the element; a rule value of more than one class of specificity (a forced block inside a
18
- * conditional rule); a composite the element names, whose class the sheet emits after every rule;
19
- * the remaining rule values by specificity and rule order, which puts a rule a prop drives over the
20
- * unconditional rule; then the default layers (`defaultSources`). The element's force-state pins
21
- * are read the way the render reads them.
17
+ * declared. The element's force-state pins are read the way the render reads them.
18
+ *
19
+ * A value is the highest-ranked source that sets the key, ranked the way the render settles it.
20
+ * Style values are CSS on the root element, so they rank as the stylesheet does: the element's own
21
+ * values are utilities, a layer above every component rule; then specificity, with `:where()` rules
22
+ * at zero; then the sheet's order, which emits every component's defaults, then every component's
23
+ * rules, then the composite classes, each with a component a root layer renders ahead of its host.
24
+ * Any other value is a prop the root receives: the element's, over the component's defaults, over
25
+ * what its rules route there, over what the component it renders sets for itself.
26
+ *
27
+ * A root layer that renders a component resolves under the props it receives, the same split
28
+ * `render-spec.ts` makes: what the rules route there (`layerRoutedProps`), what the component's own
29
+ * `forward` props send, and the element's and the defaults' values that aren't styling or the
30
+ * component's own to consume. A prop the component consumes, or forwards to another layer, reads none
31
+ * of the root's sources. A composite a rule applies to that root is written into the rule's own
32
+ * declarations, as `inlineRuleComposites` does for the stylesheet, so its styles rank as the rule's.
22
33
  *
23
34
  * OPEN: a root element only. Drilled layers, ancestors and multi-select are not read yet, so a value
24
35
  * from a parent element reads as Default or unset, as the panel shows it today.
25
- * OPEN: a root layer that is itself a component contributes none of that component's own defaults
26
- * or rules.
27
- * OPEN: a prop forwarded to another layer is read against the root layer's rules.
28
- * OPEN: a composite a rule applies isn't expanded into the style properties it sets.
29
36
  * OPEN: when two props write one style property, each row reads only the value stored under its
30
37
  * own name.
38
+ * OPEN: a root value under a name the component's own prop takes (a rule's `width` on a component
39
+ * whose own `width` is a number) has no row of its own.
31
40
  * OPEN: an element's own modifier blocks (`_hover: { … }`) aren't read as sources under `forced`.
32
41
  * OPEN: a value's token origin and a borrowed component's `system` aren't reported.
33
42
  */
@@ -44,7 +53,8 @@ const componentModels = createSliceMemo({
44
53
  ],
45
54
  compute: (_config) => /* @__PURE__ */ new Map()
46
55
  });
47
- function componentModel({ config, path, layers }) {
56
+ function componentModel({ config, component }) {
57
+ const path = component.path;
48
58
  const models = componentModels(config);
49
59
  const cached = models.get(path);
50
60
  if (cached) return cached;
@@ -54,11 +64,29 @@ function componentModel({ config, path, layers }) {
54
64
  surface.set(prop.name, prop);
55
65
  if (prop.kind === "styleProperty" && !propForStyleKey.has(prop.styleProperty)) propForStyleKey.set(prop.styleProperty, prop.name);
56
66
  }
57
- const [root] = rootLayerOf(layers);
67
+ const layers = component.layers ?? {};
68
+ const declared = component.props ?? {};
69
+ const [root, rootElement] = rootLayerOf(layers);
70
+ const forwardsIntoRoot = /* @__PURE__ */ new Map();
71
+ for (const [into, from] of layerPropRoutes(config, path, root)) if (ownEntry(declared, from)?.type === "forward") forwardsIntoRoot.set(into, from);
72
+ const intoRoot = new Set(forwardsIntoRoot.values());
73
+ const offRoot = /* @__PURE__ */ new Set();
74
+ for (const [name, decl] of Object.entries(declared)) if (decl && decl.type !== "styleProperty" && !intoRoot.has(name)) offRoot.add(name);
75
+ for (const [name, layer] of forwardClaims(config, path).forwarded) if (layer !== root) offRoot.add(name);
76
+ for (const layer of Object.keys(layers)) {
77
+ if (layer === root) continue;
78
+ for (const from of layerPropRoutes(config, path, layer).values()) offRoot.add(from);
79
+ }
80
+ const rootComponent = isRef(rootElement) ? Component.get(config, rootElement)?.path : void 0;
58
81
  const model = {
59
82
  root,
83
+ ...rootComponent ? { rootComponent } : {},
84
+ rootProps: new Map(rootComponent ? surfaceProps(config, rootComponent).map((prop) => [prop.name, prop]) : []),
60
85
  surface,
61
- propForStyleKey
86
+ propForStyleKey,
87
+ offRoot,
88
+ forwardsIntoRoot,
89
+ ruleOrder: new Map(Object.keys(component.styles ?? {}).map((key, index) => [key, index]))
62
90
  };
63
91
  models.set(path, model);
64
92
  return model;
@@ -66,79 +94,72 @@ function componentModel({ config, path, layers }) {
66
94
  /** A composite prop's class has one class of specificity, and the sheet emits it after every rule
67
95
  * (`compositePropRuleClasses`), so it beats every rule value of that specificity or less. */
68
96
  const COMPOSITE_SPECIFICITY = 1;
97
+ /** The element's own value: a utility, a layer above every component rule, or the prop itself. */
98
+ const ELEMENT_RANK = [3];
99
+ /** The sheet's blocks, in the order it emits them (`emitComponentCss`). */
100
+ const DEFAULTS_BLOCK = 0;
101
+ const RULES_BLOCK = 1;
102
+ const COMPOSITES_BLOCK = 2;
103
+ /** A style value in the components layer: specificity, then the block, then how deep the component
104
+ * sits under the element (a rendered component comes ahead of its host), then rule order. */
105
+ function cssRank({ specificity, block, depth, rule }) {
106
+ return [
107
+ 2,
108
+ specificity,
109
+ block,
110
+ -depth,
111
+ rule
112
+ ];
113
+ }
114
+ /** The tiers of a prop the root receives, as `render-spec.ts` spreads them. */
115
+ const ROUTED_TIER = 0;
116
+ const DEFAULTS_TIER = 1;
117
+ /** A prop the root receives: the nearer component's word first, and within it the tier. */
118
+ function propRank({ depth, tier }) {
119
+ return [
120
+ 1,
121
+ -depth,
122
+ tier
123
+ ];
124
+ }
125
+ function outranks(left, right) {
126
+ for (let index = 0; index < Math.max(left.length, right.length); index++) {
127
+ const difference = (right[index] ?? 0) - (left[index] ?? 0);
128
+ if (difference !== 0) return difference;
129
+ }
130
+ return 0;
131
+ }
69
132
  /**
70
133
  * A row for every property on a root element: every prop the component declares whose condition
71
134
  * holds, every key the element stores, every key the component's rules and defaults set on its root
72
- * layer, and every key in `include`.
135
+ * layer, every style value the component the root renders sets, and every key in `include`.
73
136
  */
74
137
  function resolveProperties({ config, target, forced = [], previews = false, include = [] }) {
75
- const stored = target.props;
76
- const component = Component.get(config, target.type);
77
- if (!component) return orderedKeys([storedKeys(stored), include]).map((key) => notDeclared({
78
- key,
79
- stored
80
- }));
81
- const path = component.path;
82
- const model = componentModel({
138
+ const resolved = resolveRows({
83
139
  config,
84
- path,
85
- layers: component.layers ?? {}
140
+ target,
141
+ forced,
142
+ previews,
143
+ include,
144
+ seen: /* @__PURE__ */ new Set(),
145
+ depth: 0
86
146
  });
87
- const pins = pinnedStates(stored);
88
- const defaults = defaultSources(config, path, { ...stored }, {
89
- firstVariants: previews,
90
- preview: previews
91
- });
92
- const values = {
93
- ...topValues(defaults),
94
- ...stored,
95
- ...pins.states
96
- };
97
- const rules = ownEntry(layerDeclarationStacks(config, path, values, { forced: [...forced, ...pins.forced] }), model.root) ?? {};
98
- const composites = compositeValues({
99
- config,
100
- model,
101
- values
102
- });
103
- const rowKeyOf = (styleKey) => model.propForStyleKey.get(styleKey) ?? styleKey;
104
- return orderedKeys([
105
- [...model.surface.values()].filter((prop) => propApplies(prop, values)).map((prop) => prop.name),
106
- storedKeys(stored),
107
- Object.keys(rules).filter(isPropertyKey).map(rowKeyOf),
108
- Object.keys(defaults).filter(isPropertyKey),
109
- [...composites.keys()],
110
- include
111
- ]).map((key) => {
112
- const prop = model.surface.get(key);
113
- const surfaced = !!prop && propApplies(prop, values);
114
- const styleProperty = prop?.kind === "styleProperty" ? prop.styleProperty : void 0;
115
- const styleKey = styleProperty ?? key;
116
- const ruleStack = ownEntry(rules, styleKey) ?? [];
117
- const fromRules = (declaration) => ruleValue({
118
- declaration,
119
- layer: model.root
120
- });
121
- const sources = [
122
- ...Object.hasOwn(stored, key) && stored[key] !== void 0 ? [{
123
- value: propertyValue(stored[key]),
124
- source: ELEMENT
125
- }] : [],
126
- ...ruleStack.filter(({ specificity }) => specificity > COMPOSITE_SPECIFICITY).map(fromRules),
127
- ...composites.get(key) ?? [],
128
- ...ruleStack.filter(({ specificity }) => specificity <= COMPOSITE_SPECIFICITY).map(fromRules),
129
- ...(ownEntry(defaults, key) ?? []).map((value) => defaultValue({
130
- config,
131
- styleKey,
132
- value
133
- }))
134
- ];
147
+ if (!resolved) return orderedKeys([storedKeys(target.props), include]).map((key) => notDeclared({
148
+ key,
149
+ stored: target.props
150
+ }));
151
+ const { path, rows } = resolved;
152
+ return rows.map(({ key, styleProperty, surfaced, sources }) => {
135
153
  if (!(surfaced || sources.some(({ source }) => source.kind !== "element"))) return notDeclared({
136
154
  key,
137
- stored,
155
+ stored: target.props,
138
156
  path,
139
157
  styleProperty
140
158
  });
141
- const [winner, ...beneath] = sources;
159
+ const [winner, ...beneath] = sources.map(({ value, source }) => ({
160
+ value,
161
+ source
162
+ }));
142
163
  const editable = surfaced && winner?.value.kind !== "bound";
143
164
  const owner = surfaced ? propOwner(config, path, key) : void 0;
144
165
  return {
@@ -161,6 +182,155 @@ function resolveProperties({ config, target, forced = [], previews = false, incl
161
182
  };
162
183
  });
163
184
  }
185
+ function resolveRows({ config, target, forced, previews, include, seen, depth }) {
186
+ const stored = target.props;
187
+ const component = Component.get(config, target.type);
188
+ if (!component) return void 0;
189
+ const path = component.path;
190
+ const model = componentModel({
191
+ config,
192
+ component
193
+ });
194
+ const pins = pinnedStates(stored);
195
+ const defaults = defaultSources(config, path, { ...stored }, {
196
+ firstVariants: previews,
197
+ preview: previews
198
+ });
199
+ const supplied = {
200
+ ...topValues(defaults),
201
+ ...stored
202
+ };
203
+ const values = {
204
+ ...supplied,
205
+ ...pins.states
206
+ };
207
+ const inForce = [...forced, ...pins.forced];
208
+ const rules = ownEntry(layerDeclarationStacks(config, path, values, { forced: inForce }), model.root) ?? {};
209
+ const composites = compositeValues({
210
+ config,
211
+ model,
212
+ values
213
+ });
214
+ const ruleComposites = ruleCompositeValues({
215
+ config,
216
+ model,
217
+ rules,
218
+ depth
219
+ });
220
+ const rowKeyOf = (bagKey) => {
221
+ const rootProp = model.rootProps.get(bagKey);
222
+ if (rootProp && rootProp.kind !== "styleProperty") return bagKey;
223
+ const styleKey = rootProp?.kind === "styleProperty" ? rootProp.styleProperty : bagKey;
224
+ return model.propForStyleKey.get(styleKey) ?? (rootProp ? bagKey : styleKey);
225
+ };
226
+ const inner = rootComponentRows({
227
+ config,
228
+ model,
229
+ sent: sentToRoot({
230
+ config,
231
+ model,
232
+ path,
233
+ supplied,
234
+ values,
235
+ inForce
236
+ }),
237
+ forced: inForce,
238
+ seen: new Set([...seen, path]),
239
+ depth: depth + 1
240
+ });
241
+ return {
242
+ path,
243
+ rows: orderedKeys([
244
+ [...model.surface.values()].filter((prop) => propApplies(prop, values)).map((prop) => prop.name),
245
+ storedKeys(stored),
246
+ Object.keys(rules).filter(isPropertyKey).map(rowKeyOf),
247
+ Object.keys(defaults).filter(isPropertyKey),
248
+ [...composites.keys()],
249
+ [...ruleComposites.keys()],
250
+ [...inner.keys()].filter((key) => !model.offRoot.has(key)),
251
+ include
252
+ ]).map((key) => {
253
+ const prop = model.surface.get(key);
254
+ const surfaced = !!prop && propApplies(prop, values);
255
+ const onRoot = !model.offRoot.has(key);
256
+ const innerRow = onRoot ? inner.get(key) : void 0;
257
+ const rootProp = model.rootProps.get(key);
258
+ let styleProperty;
259
+ if (prop?.kind === "styleProperty") styleProperty = prop.styleProperty;
260
+ else if (rootProp?.kind === "styleProperty") styleProperty = rootProp.styleProperty;
261
+ else styleProperty = innerRow?.styleProperty;
262
+ const styleKey = styleProperty ?? key;
263
+ const css = styleProperty !== void 0 || config.resolve("style-property", styleKey) !== void 0 || innerRow?.css === true;
264
+ const ruleRank = (declaration) => css ? cssRank({
265
+ specificity: declaration.specificity,
266
+ block: RULES_BLOCK,
267
+ depth,
268
+ rule: model.ruleOrder.get(declaration.rule) ?? 0
269
+ }) : propRank({
270
+ depth,
271
+ tier: ROUTED_TIER
272
+ });
273
+ const defaultRank = css ? cssRank({
274
+ specificity: 0,
275
+ block: DEFAULTS_BLOCK,
276
+ depth,
277
+ rule: 0
278
+ }) : propRank({
279
+ depth,
280
+ tier: DEFAULTS_TIER
281
+ });
282
+ const compositeRank = cssRank({
283
+ specificity: COMPOSITE_SPECIFICITY,
284
+ block: COMPOSITES_BLOCK,
285
+ depth,
286
+ rule: 0
287
+ });
288
+ const listed = [
289
+ ...Object.hasOwn(stored, key) && stored[key] !== void 0 ? [{
290
+ value: propertyValue(stored[key]),
291
+ source: ELEMENT,
292
+ rank: ELEMENT_RANK
293
+ }] : [],
294
+ ...(onRoot ? ruleStackOf({
295
+ rules,
296
+ model,
297
+ key,
298
+ styleKey
299
+ }) : []).map((declaration) => ({
300
+ ...ruleValue({
301
+ declaration,
302
+ layer: model.root
303
+ }),
304
+ rank: ruleRank(declaration)
305
+ })),
306
+ ...onRoot ? ruleComposites.get(key) ?? [] : [],
307
+ ...(onRoot ? composites.get(key) ?? [] : []).map((value) => ({
308
+ ...value,
309
+ rank: compositeRank
310
+ })),
311
+ ...(ownEntry(defaults, key) ?? []).map((value) => ({
312
+ ...defaultValue({
313
+ config,
314
+ styleKey,
315
+ value
316
+ }),
317
+ rank: defaultRank
318
+ })),
319
+ ...innerRow?.sources ?? []
320
+ ];
321
+ return {
322
+ key,
323
+ ...styleProperty ? { styleProperty } : {},
324
+ css,
325
+ surfaced,
326
+ sources: listed.map((value, index) => ({
327
+ value,
328
+ index
329
+ })).sort((left, right) => outranks(left.value.rank, right.value.rank) || left.index - right.index).map(({ value }) => value)
330
+ };
331
+ })
332
+ };
333
+ }
164
334
  const UNSET = { kind: "unset" };
165
335
  const ELEMENT = { kind: "element" };
166
336
  function stateOf({ winner, surfaced }) {
@@ -174,6 +344,7 @@ function stateOf({ winner, surfaced }) {
174
344
  * drives, a forced modifier block, or a composite. */
175
345
  function isInherited(source) {
176
346
  if (source.kind === "rule") return source.drivenBy.length > 0;
347
+ if (source.kind === "layer-component") return isInherited(source.source);
177
348
  return source.kind === "modifier" || source.kind === "composite";
178
349
  }
179
350
  function notDeclared({ key, stored, path, styleProperty }) {
@@ -326,8 +497,164 @@ function compositeValues({ config, model, values }) {
326
497
  }
327
498
  return out;
328
499
  }
500
+ /**
501
+ * The styles of each composite a root rule applies to a layer that renders a component, per row key,
502
+ * ranked as the rule's own declarations. They come after the rule's explicit values in the list, so a
503
+ * key the rule also states outright keeps the rule's value, as `inlineRuleComposites` merges them.
504
+ */
505
+ function ruleCompositeValues({ config, model, rules, depth }) {
506
+ const out = /* @__PURE__ */ new Map();
507
+ if (!model.rootComponent) return out;
508
+ for (const [bagKey, stack] of Object.entries(rules)) {
509
+ const prop = model.rootProps.get(bagKey);
510
+ if (prop?.kind !== "composite") continue;
511
+ for (const declaration of stack) {
512
+ const variant = compositeVariantPath({
513
+ compositeName: prop.compositeName,
514
+ chosen: declaration.value
515
+ });
516
+ const styles = variant ? (config.resolve("composite", variant)?.body)?.styles : void 0;
517
+ if (!variant || !styles) continue;
518
+ const { value: _value, source } = ruleValue({
519
+ declaration,
520
+ layer: model.root
521
+ });
522
+ const rank = cssRank({
523
+ specificity: declaration.specificity,
524
+ block: RULES_BLOCK,
525
+ depth,
526
+ rule: model.ruleOrder.get(declaration.rule) ?? 0
527
+ });
528
+ for (const [styleKey, value] of Object.entries(authoredBag(config, styles))) {
529
+ if (!isPropertyKey(styleKey)) continue;
530
+ const key = model.propForStyleKey.get(styleKey) ?? styleKey;
531
+ const list = out.get(key) ?? [];
532
+ list.push({
533
+ value: propertyValue(value),
534
+ source: source.kind === "rule" ? {
535
+ ...source,
536
+ composite: variant
537
+ } : source,
538
+ rank
539
+ });
540
+ out.set(key, list);
541
+ }
542
+ }
543
+ }
544
+ return out;
545
+ }
546
+ /**
547
+ * The root rules' values for a row, read under the bag key the root layer spells it with. On a layer
548
+ * that renders a component, a key that names one of that component's props is that prop, and any
549
+ * other key is the style property of its name.
550
+ */
551
+ function ruleStackOf({ rules, model, key, styleKey }) {
552
+ if (!model.rootComponent) return ownEntry(rules, styleKey) ?? [];
553
+ const byName = model.rootProps.has(key) ? ownEntry(rules, key) : void 0;
554
+ const byProperty = model.rootProps.has(styleKey) ? void 0 : ownEntry(rules, styleKey);
555
+ return byName ?? byProperty ?? [];
556
+ }
557
+ /**
558
+ * The props the root layer's component receives, as `render-spec.ts` assembles them: what the rules
559
+ * route there, under what the component's own `forward` props send, under the element's and the
560
+ * defaults' values that aren't styling or the component's own. Style values never travel as props;
561
+ * they are classes on the root element, ranked by the stylesheet.
562
+ */
563
+ function sentToRoot({ config, model, path, supplied, values, inForce }) {
564
+ if (!model.rootComponent) return {};
565
+ const routed = ownEntry(layerRoutedProps(config, path, {
566
+ ...values,
567
+ ...Object.fromEntries(inForce.map((name) => [`_${name.replace(/^_/, "")}`, true]))
568
+ }), model.root) ?? {};
569
+ const forwarded = {};
570
+ for (const [into, from] of model.forwardsIntoRoot) {
571
+ const value = ownEntry(values, from);
572
+ if (value !== void 0) forwarded[into] = value;
573
+ }
574
+ const bag = {};
575
+ for (const [key, value] of Object.entries(supplied)) {
576
+ if (key === "__udsForceStates" || value === void 0) continue;
577
+ if (!model.offRoot.has(key)) bag[key] = value;
578
+ }
579
+ const { rest } = splitStyleProps({
580
+ config,
581
+ bag,
582
+ through: [path]
583
+ });
584
+ const sent = authoredBag(config, {
585
+ ...routed,
586
+ ...forwarded,
587
+ ...rest
588
+ });
589
+ for (const [key, value] of Object.entries(sent)) if (isRef(value)) sent[key] = refLeaf(value);
590
+ return sent;
591
+ }
592
+ /**
593
+ * The rows of the component the root layer renders, keyed as this component reads them, with its
594
+ * sources wrapped to say where they come from. What it was sent is this component's to report, so
595
+ * its element sources drop out. It renders as its compiled module, with no preview staging.
596
+ */
597
+ function rootComponentRows({ config, model, sent, forced, seen, depth }) {
598
+ const out = /* @__PURE__ */ new Map();
599
+ const component = model.rootComponent;
600
+ if (!component || seen.has(component)) return out;
601
+ const resolved = resolveRows({
602
+ config,
603
+ target: {
604
+ type: component,
605
+ props: sent
606
+ },
607
+ forced,
608
+ previews: false,
609
+ include: [],
610
+ seen,
611
+ depth
612
+ });
613
+ for (const row of resolved?.rows ?? []) {
614
+ const key = outerKeyOf({
615
+ model,
616
+ row
617
+ });
618
+ if (key === void 0) continue;
619
+ const sources = row.sources.filter(({ source }) => source.kind !== "element").map(({ value, source, rank }) => ({
620
+ value,
621
+ source: {
622
+ kind: "layer-component",
623
+ layer: model.root,
624
+ component,
625
+ source
626
+ },
627
+ rank
628
+ }));
629
+ if (sources.length > 0) out.set(key, {
630
+ ...row,
631
+ key,
632
+ sources
633
+ });
634
+ }
635
+ return out;
636
+ }
637
+ /**
638
+ * The row of this component an inner row belongs to: the same name when this component exposes it, an
639
+ * own `forward` that lands there, or for a style value the prop of this component that writes it, else
640
+ * the style property itself. A prop of the inner component's own API that this one doesn't expose
641
+ * isn't a property here.
642
+ */
643
+ function outerKeyOf({ model, row }) {
644
+ const forwardedFrom = model.forwardsIntoRoot.get(row.key);
645
+ if (forwardedFrom !== void 0) return forwardedFrom;
646
+ if (model.surface.has(row.key)) return row.key;
647
+ if (!row.css) return void 0;
648
+ const styleKey = row.styleProperty ?? row.key;
649
+ return model.propForStyleKey.get(styleKey) ?? styleKey;
650
+ }
329
651
  function addressOf({ path, key, source }) {
330
652
  switch (source.kind) {
653
+ case "layer-component": return addressOf({
654
+ path: source.component,
655
+ key,
656
+ source: source.source
657
+ });
331
658
  case "rule": return {
332
659
  kind: "component",
333
660
  path,