@yahoo/uds-create-config 4.55.1 → 4.56.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.
@@ -1,7 +1,7 @@
1
1
  import { GraftableElement, GraftableSpec, PreviewElement, PreviewRef, PreviewSpecNode, PreviewValue, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, isComponentRef, isPreviewElement, isPreviewRef, previewElementNodes, previewElementType } from "./preview-elements.js";
2
2
  import { Slot, SlotCell } from "./slot.js";
3
3
  import { Cell, CellSlot } from "./cell.js";
4
- import { DocumentRename, RewritableSpec, SpecRewrite, documentRenamesFromPatches, rewriteSpecRefs } from "./rewrite-refs.js";
4
+ import { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs } from "./rewrite-refs.js";
5
5
  import { applyForcedModifiers, collectForcedModifierProps } from "./apply-forced-modifiers.js";
6
6
  import { AcceptsChildNodes, ChildNodesClassification, ClassifyChildNodes, buildAcceptsChildNodes, buildClassifyChildNodes, stripInjectedSlots, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots } from "./empty-node-slots.js";
7
7
  import { CollapseTextLabelsResult, CollapsedTextLabel, collapseWrappedTextLabels } from "./collapse-text-labels.js";
@@ -28,4 +28,4 @@ import { SpecToJsxOptions, SpecToJsxResult, specToJsx } from "./specToJsx.js";
28
28
  * element, without changing the rendered layer hierarchy. */
29
29
  declare const SYNTHETIC_TEXT_SLOT_PROP = "data-uds-synthetic-text-slot";
30
30
  //#endregion
31
- export { type AcceptsChildNodes, type Cell, type CellSlot, type ChildNodesClassification, type ClassifyChildNodes, type CollapseTextLabelsResult, type CollapsedTextLabel, type DocumentRename, type GlyphJsxForm, type GlyphNodeResolver, type GraftableElement, type GraftableSpec, type JsxToSpecOptions, type PreviewElement, type PreviewRef, type PreviewSpecNode, type PreviewValue, type RewritableSpec, SYNTHETIC_TEXT_SLOT_PROP, type Slot, type SlotCell, type SpecRewrite, type SpecToJsxOptions, type SpecToJsxResult, UNRESOLVED, applyForcedModifiers, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, documentRenamesFromPatches, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, parseGlyphType, previewElementNodes, previewElementType, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
31
+ export { type AcceptsChildNodes, type Cell, type CellSlot, type ChildNodesClassification, type ClassifyChildNodes, type CollapseTextLabelsResult, type CollapsedTextLabel, type DocumentRename, type GlyphJsxForm, type GlyphNodeResolver, type GraftableElement, type GraftableSpec, type JsxToSpecOptions, type PreviewElement, type PreviewRef, type PreviewSpecNode, type PreviewValue, type RewritableElement, type RewritableSpec, SYNTHETIC_TEXT_SLOT_PROP, type Slot, type SlotCell, type SpecRewrite, type SpecToJsxOptions, type SpecToJsxResult, UNRESOLVED, applyForcedModifiers, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, parseGlyphType, previewElementNodes, previewElementType, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
@@ -4,7 +4,7 @@ import { applyForcedModifiers, collectForcedModifierProps } from "./apply-forced
4
4
  import { collapseWrappedTextLabels } from "./collapse-text-labels.js";
5
5
  import { buildAcceptsChildNodes, buildClassifyChildNodes, stripInjectedSlots, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots } from "./empty-node-slots.js";
6
6
  import { UNRESOLVED, hasUnresolvedProps, jsxToSpec, stripUnresolvedProps } from "./jsxToSpec.js";
7
- import { documentRenamesFromPatches, rewriteSpecRefs } from "./rewrite-refs.js";
7
+ import { composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs } from "./rewrite-refs.js";
8
8
  import { specToJsx } from "./specToJsx.js";
9
9
  //#region src/spec/index.ts
10
10
  /**
@@ -25,4 +25,4 @@ import { specToJsx } from "./specToJsx.js";
25
25
  * element, without changing the rendered layer hierarchy. */
26
26
  const SYNTHETIC_TEXT_SLOT_PROP = "data-uds-synthetic-text-slot";
27
27
  //#endregion
28
- export { SYNTHETIC_TEXT_SLOT_PROP, UNRESOLVED, applyForcedModifiers, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, documentRenamesFromPatches, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, parseGlyphType, previewElementNodes, previewElementType, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
28
+ export { SYNTHETIC_TEXT_SLOT_PROP, UNRESOLVED, applyForcedModifiers, buildAcceptsChildNodes, buildClassifyChildNodes, collapseWrappedTextLabels, collectForcedModifierProps, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, glyphJsxForm, glyphMemberOf, graftPreviewElements, graftSlotContent, hasPreviewElementDeep, hasUnresolvedProps, isComponentRef, isPreviewElement, isPreviewRef, jsxIdentifier, jsxToSpec, parseGlyphType, previewElementNodes, previewElementType, rewriteSpecRefs, specToJsx, stripInjectedSlots, stripUnresolvedProps, withContainerChildSlots, withEmptyNodeSlots, withRenderSlots };
@@ -47,12 +47,39 @@ type DocumentRename = /** A component's path — `element.type` and a node's own
47
47
  * last name if the pairs are applied in the order they were made.
48
48
  */
49
49
  declare function documentRenamesFromPatches(patches: readonly Record<string, unknown>[]): DocumentRename[];
50
+ /**
51
+ * A source's renames as a consumer's documents see them, once a pin moves from the source `before`
52
+ * was built against to the one `after` is.
53
+ *
54
+ * Only a rename of a row `before` inherited through `slug` comes through: a local row at the same
55
+ * path shadows the source and keeps its name, and a hand-written alias is a pointer of this config's
56
+ * own. A component-scoped rename follows its component, since the consumer's row for it is a pointer
57
+ * whose props and layers are the source's. The inherited set is tracked through the list, so a chain
58
+ * or a swap lands where the source did. A destination `after` does not hold as a row inherited through
59
+ * `slug` is refused: written into documents, it would name nothing they can resolve.
60
+ */
61
+ declare function documentRenamesFromSource({
62
+ before,
63
+ after,
64
+ slug,
65
+ renames
66
+ }: {
67
+ before: Config;
68
+ after: Config;
69
+ slug: string;
70
+ renames: readonly DocumentRename[];
71
+ }): DocumentRename[];
72
+ /** Fold adjacent rename steps without moving them past operations that can depend on intermediate names. */
73
+ declare function composeRenames(renames: readonly DocumentRename[]): DocumentRename[];
50
74
  /** A spec as this reads it: the structural subset, loose because the rows are whatever was written months ago. */
51
75
  interface RewritableSpec {
52
- elements?: Record<string, {
53
- type?: unknown;
54
- props?: Record<string, unknown>;
55
- } | undefined>;
76
+ elements?: Record<string, RewritableElement | undefined>;
77
+ }
78
+ /** One element's rewritable positions: its type, its props bag, and the slot fills keyed by slot prop. */
79
+ interface RewritableElement {
80
+ type?: unknown;
81
+ props?: Record<string, unknown>;
82
+ slots?: Record<string, unknown>;
56
83
  }
57
84
  interface SpecRewrite {
58
85
  readonly spec: RewritableSpec;
@@ -67,4 +94,4 @@ interface SpecRewrite {
67
94
  */
68
95
  declare function rewriteSpecRefs(config: Config, spec: RewritableSpec, renames: readonly DocumentRename[]): SpecRewrite;
69
96
  //#endregion
70
- export { DocumentRename, RewritableSpec, SpecRewrite, documentRenamesFromPatches, rewriteSpecRefs };
97
+ export { DocumentRename, RewritableElement, RewritableSpec, SpecRewrite, composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs };
@@ -1,6 +1,5 @@
1
- import { isRef, kindOf, pathOf } from "../framework/utils/refs.js";
2
- import { StyleProperty } from "../entities/system/StyleProperty.js";
3
- import { propOwner, resolveComponentProps } from "../framework/projections.js";
1
+ import { isMintedRow, isRef, kindOf, pathOf, sourceOf } from "../framework/utils/refs.js";
2
+ import { propOwner, resolveComponentProps, stylePropLeafForToken, stylePropTokenPath } from "../framework/projections.js";
4
3
  import { Component } from "../entities/system/Component.js";
5
4
  //#region src/spec/rewrite-refs.ts
6
5
  /**
@@ -105,6 +104,69 @@ function documentRenamesFromPatches(patches) {
105
104
  }
106
105
  return renames;
107
106
  }
107
+ /**
108
+ * A source's renames as a consumer's documents see them, once a pin moves from the source `before`
109
+ * was built against to the one `after` is.
110
+ *
111
+ * Only a rename of a row `before` inherited through `slug` comes through: a local row at the same
112
+ * path shadows the source and keeps its name, and a hand-written alias is a pointer of this config's
113
+ * own. A component-scoped rename follows its component, since the consumer's row for it is a pointer
114
+ * whose props and layers are the source's. The inherited set is tracked through the list, so a chain
115
+ * or a swap lands where the source did. A destination `after` does not hold as a row inherited through
116
+ * `slug` is refused: written into documents, it would name nothing they can resolve.
117
+ */
118
+ function documentRenamesFromSource({ before, after, slug, renames }) {
119
+ const inherited = /* @__PURE__ */ new Set();
120
+ for (const kind of before.ownedKinds()) for (const entity of before.list(kind)) {
121
+ const body = before.storedBody(kind, entity.path);
122
+ if (isMintedRow(body) && isRef(body) && sourceOf(body) === slug) inherited.add(`${kind}:${entity.path}`);
123
+ }
124
+ const projected = [];
125
+ const moved = /* @__PURE__ */ new Set();
126
+ for (const rename of renames) {
127
+ if ("component" in rename) {
128
+ if (inherited.has(`component:${rename.component}`)) projected.push(rename);
129
+ continue;
130
+ }
131
+ const from = `${rename.kind}:${rename.from}`;
132
+ const to = `${rename.kind}:${rename.to}`;
133
+ if (!inherited.has(from)) continue;
134
+ inherited.delete(from);
135
+ inherited.add(to);
136
+ moved.delete(from);
137
+ moved.add(to);
138
+ projected.push(rename);
139
+ }
140
+ for (const target of moved) {
141
+ const body = after.storedBody(kindOf(target), pathOf(target));
142
+ if (!isMintedRow(body) || !isRef(body) || sourceOf(body) !== slug || pathOf(body) !== pathOf(target)) throw new Error(`The linked rename destination ${target} is not inherited from ${slug}.`);
143
+ }
144
+ return projected;
145
+ }
146
+ /** Fold adjacent rename steps without moving them past operations that can depend on intermediate names. */
147
+ function composeRenames(renames) {
148
+ const out = [];
149
+ for (const rename of renames) {
150
+ const prior = out.at(-1);
151
+ if (!prior || !sameScope(prior, rename) || prior.to !== rename.from) {
152
+ out.push(rename);
153
+ continue;
154
+ }
155
+ out.pop();
156
+ if (prior.from !== rename.to) out.push({
157
+ ...prior,
158
+ to: rename.to
159
+ });
160
+ }
161
+ return out;
162
+ }
163
+ /** Whether two renames move names in the same namespace, so one's `to` can be the other's `from`. */
164
+ function sameScope(a, b) {
165
+ if (a.kind !== b.kind) return false;
166
+ if ("component" in a && "component" in b && a.component !== b.component) return false;
167
+ if ("prop" in a && "prop" in b && a.prop !== b.prop) return false;
168
+ return true;
169
+ }
108
170
  /** Whether a stored `type` names this component path, in either form it may be written in. */
109
171
  function namesComponent(type, path) {
110
172
  if (typeof type !== "string") return false;
@@ -122,12 +184,14 @@ function boundStylePropPath(declaration) {
122
184
  const decl = declaration;
123
185
  return decl?.type === "styleProperty" && isRef(decl.value) ? pathOf(decl.value.__ref) : void 0;
124
186
  }
125
- /** The token GROUP a prop declaration draws its values from, if it draws from one. */
126
- function tokenGroupOf(config, declaration) {
127
- const decl = declaration;
128
- if (decl?.type !== "styleProperty" || !isRef(decl.value)) return;
129
- const styleProp = StyleProperty.get(config, pathOf(decl.value.__ref));
130
- for (const value of styleProp?.values ?? []) if (isRef(value) && kindOf(value.__ref) === "token") return pathOf(value.__ref);
187
+ /**
188
+ * The style property a bag key reaches on this scope: the one its declaration binds, or the key itself
189
+ * when the scope declares nothing under it (an intrinsic tag, or a style prop set directly).
190
+ */
191
+ function stylePropFor(config, scope, key) {
192
+ const declaration = scope.declared[key];
193
+ if (declaration === void 0) return config.resolve("style-property", key) ? key : void 0;
194
+ return boundStylePropPath(declaration);
131
195
  }
132
196
  /** The prop a call site overrides a component's inner layers through — see `deriveSpec`, which spreads each of
133
197
  * its bags onto the node whose layer the key names. */
@@ -139,13 +203,17 @@ function nestedBag(value) {
139
203
  /**
140
204
  * The nested props bag a modifier block holds — `undefined` for anything else in the bag.
141
205
  *
142
- * The `_` prefix is the whole test, which is the same test `styleDeclarations` and the prop validator make. A
143
- * key naming a modifier the config no longer holds still reads as a block: an unresolvable one is a document
144
- * that needs repairing, not a reason to leave the props inside it un-renamed.
206
+ * The key is `_` plus the modifier's leaf (`state/hover` is `_hover`; leaves are unique by declaration),
207
+ * and only a key the config knows as a modifier is a block: authored bags carry other `_`-prefixed
208
+ * members (`_TOKENS`) that hold no props. A modifier this batch is renaming resolves under either name,
209
+ * since the config may be on either side of the rename.
145
210
  */
146
- function modifierBlock(key, value) {
147
- return key.startsWith("_") ? nestedBag(value) : void 0;
211
+ function modifierBlock(config, key, value, renames) {
212
+ if (!key.startsWith("_")) return void 0;
213
+ const leaf = key.slice(1);
214
+ return config.resolve("modifier", leaf) !== void 0 || renames.some((rename) => rename.kind === "modifier" && (leafOf(rename.from) === leaf || leafOf(rename.to) === leaf)) ? nestedBag(value) : void 0;
148
215
  }
216
+ const leafOf = (path) => path.slice(path.lastIndexOf("/") + 1);
149
217
  const INTRINSIC = {
150
218
  component: void 0,
151
219
  declared: {}
@@ -169,6 +237,22 @@ function withRenamedKey(props, from, to) {
169
237
  return out;
170
238
  }
171
239
  /**
240
+ * Whether a component-scoped rename reaches a bag on `scope`.
241
+ *
242
+ * It reaches every component that EXPOSES the renamed prop, not only the one that DECLARES it. `HStack`
243
+ * exposes `Box`'s props through `inherits`, so `<HStack gap="2">` is a position a rename of `Box.gap`
244
+ * has to move — and scoping by `element.type` walked past all of them (7,375 such positions across 32
245
+ * components on the real system). The owner's own elements take the original path untouched, so this
246
+ * only ever ADDS matches.
247
+ */
248
+ function reachesScope(config, scope, rename) {
249
+ if (!scope.component) return false;
250
+ if (scope.component === rename.component) return true;
251
+ const target = rename.kind === "component-prop" ? rename.to : rename.prop;
252
+ if (!(propOwner(config, scope.component, target) === rename.component || rename.kind === "component-prop" && propOwner(config, scope.component, rename.from) === rename.component)) return false;
253
+ return !(rename.kind === "component-prop" && propOwner(config, scope.component, rename.from) === scope.component);
254
+ }
255
+ /**
172
256
  * One rename applied to the keys and values of ONE bag — `undefined` when it matched nothing there.
173
257
  *
174
258
  * Everything scoped to a component is scoped to THIS bag's component, which is the element's for its own props
@@ -176,18 +260,11 @@ function withRenamedKey(props, from, to) {
176
260
  */
177
261
  function rewriteOwnEntries(config, scope, props, rename) {
178
262
  if (rename.kind === "layer") return void 0;
179
- if (rename.kind === "component-prop" || rename.kind === "variant-value") {
180
- if (!scope.component) return void 0;
181
- if (scope.component !== rename.component) {
182
- const target = rename.kind === "component-prop" ? rename.to : rename.prop;
183
- if (!(propOwner(config, scope.component, target) === rename.component || rename.kind === "component-prop" && propOwner(config, scope.component, rename.from) === rename.component)) return void 0;
184
- if (rename.kind === "component-prop" && propOwner(config, scope.component, rename.from) === scope.component) return;
185
- }
186
- }
263
+ if ((rename.kind === "component-prop" || rename.kind === "variant-value") && !reachesScope(config, scope, rename)) return;
187
264
  const declared = scope.declared;
188
265
  if (rename.kind === "modifier") {
189
- const from = `_${rename.from}`;
190
- return from in props ? withRenamedKey(props, from, `_${rename.to}`) : void 0;
266
+ const from = `_${leafOf(rename.from)}`;
267
+ return from in props ? withRenamedKey(props, from, `_${leafOf(rename.to)}`) : void 0;
191
268
  }
192
269
  if (rename.kind === "component-prop") return rename.from in props ? withRenamedKey(props, rename.from, rename.to) : void 0;
193
270
  if (rename.kind === "variant-value") return props[rename.prop] === rename.from ? {
@@ -200,33 +277,51 @@ function rewriteOwnEntries(config, scope, props, rename) {
200
277
  if (declaration !== void 0 && boundStylePropPath(declaration) !== rename.from) return;
201
278
  return withRenamedKey(props, rename.from, rename.to);
202
279
  }
203
- const group = rename.from.slice(0, rename.from.lastIndexOf("/"));
204
- const leaf = rename.from.slice(rename.from.lastIndexOf("/") + 1);
205
- const toLeaf = rename.to.slice(rename.to.lastIndexOf("/") + 1);
206
- if (!group) return void 0;
207
280
  let next;
208
281
  for (const [prop, value] of Object.entries(props)) {
209
- if (value !== leaf) continue;
210
- if (tokenGroupOf(config, declared[prop]) !== group) continue;
282
+ if (typeof value !== "string") continue;
283
+ const styleProp = stylePropFor(config, scope, prop);
284
+ if (!styleProp) continue;
285
+ const names = stylePropTokenPath(config, styleProp, value);
286
+ if (names !== rename.from && names !== rename.to) {
287
+ if (!spellsUnderDomain(config, styleProp, value, rename.from)) continue;
288
+ } else if (names === rename.to) continue;
289
+ const toLeaf = stylePropLeafForToken(config, styleProp, rename.to) ?? relativeSpelling(value, rename.from, rename.to);
290
+ if (toLeaf === void 0 || toLeaf === value) continue;
211
291
  next ??= { ...props };
212
292
  next[prop] = toLeaf;
213
293
  }
214
294
  return next;
215
295
  }
216
296
  /**
297
+ * Whether `value` is how `tokenPath` would be spelled under one of `styleProp`'s token groups, asked
298
+ * when the property no longer lists that token (the config is already past the rename).
299
+ */
300
+ function spellsUnderDomain(config, styleProp, value, tokenPath) {
301
+ if (!tokenPath.endsWith(`/${value}`) && tokenPath !== value) return false;
302
+ const group = tokenPath.slice(0, tokenPath.length - value.length - 1);
303
+ return ((config.resolve("style-property", styleProp)?.toJSON())?.values ?? []).some((entry) => isRef(entry) && kindOf(entry.__ref) === "token" && pathOf(entry.__ref) === group);
304
+ }
305
+ /** `to` spelled the way `value` spelled `from`: the same group prefix removed. */
306
+ function relativeSpelling(value, from, to) {
307
+ if (!from.endsWith(`/${value}`) && from !== value) return void 0;
308
+ const group = from.slice(0, from.length - value.length);
309
+ return to.startsWith(group) ? to.slice(group.length) : void 0;
310
+ }
311
+ /**
217
312
  * One rename applied to a props bag, to every modifier block nested inside it, and to every layer override under
218
313
  * its `layerProps` — at any depth.
219
314
  *
220
315
  * `undefined` when nothing matched, so a caller can leave the element it came from untouched.
221
316
  */
222
- function rewriteProps(config, scope, props, rename) {
317
+ function rewriteProps(config, scope, props, rename, batch) {
223
318
  let next = rewriteOwnEntries(config, scope, props, rename);
224
319
  for (const [key, value] of Object.entries(next ?? props)) {
225
320
  let rewritten;
226
- if (key === LAYER_PROPS) rewritten = rewriteLayerProps(config, scope, value, rename);
321
+ if (key === LAYER_PROPS) rewritten = rewriteLayerProps(config, scope, value, rename, batch);
227
322
  else {
228
- const block = modifierBlock(key, value);
229
- rewritten = block ? rewriteProps(config, scope, block, rename) : void 0;
323
+ const block = modifierBlock(config, key, value, batch);
324
+ rewritten = block ? rewriteProps(config, scope, block, rename, batch) : void 0;
230
325
  }
231
326
  if (!rewritten) continue;
232
327
  next ??= { ...props };
@@ -241,7 +336,7 @@ function rewriteProps(config, scope, props, rename) {
241
336
  * The key rename is the only thing here scoped to the enclosing component rather than to the bag's own — a layer
242
337
  * name means nothing on its own, and two components' `text` layers are unrelated.
243
338
  */
244
- function rewriteLayerProps(config, scope, layerProps, rename) {
339
+ function rewriteLayerProps(config, scope, layerProps, rename, batch) {
245
340
  const bags = nestedBag(layerProps);
246
341
  if (!bags) return void 0;
247
342
  let next;
@@ -249,7 +344,7 @@ function rewriteLayerProps(config, scope, layerProps, rename) {
249
344
  for (const [layer, value] of Object.entries(next ?? bags)) {
250
345
  const bag = nestedBag(value);
251
346
  if (!bag) continue;
252
- const rewritten = rewriteProps(config, layerScope(config, scope, layer), bag, rename);
347
+ const rewritten = rewriteProps(config, layerScope(config, scope, layer), bag, rename, batch);
253
348
  if (!rewritten) continue;
254
349
  next ??= { ...bags };
255
350
  next[layer] = rewritten;
@@ -273,18 +368,32 @@ function rewriteSpecRefs(config, spec, renames) {
273
368
  if (!element) continue;
274
369
  let type = element.type;
275
370
  let props = element.props;
371
+ let slots = element.slots;
276
372
  let touched = 0;
277
- const scope = scopeFor(config, componentOf(element.type));
373
+ let current = componentOf(element.type);
374
+ const declaredFor = (path) => {
375
+ const own = scopeFor(config, path);
376
+ if (Object.keys(own.declared).length > 0 || !path) return own;
377
+ return {
378
+ component: path,
379
+ declared: scopeFor(config, renames.filter((r) => r.kind === "component").reduce((at, r) => r.from === at ? r.to : at, path)).declared
380
+ };
381
+ };
278
382
  for (const rename of renames) {
279
383
  if (rename.from === rename.to) continue;
280
384
  if (rename.kind === "component") {
281
385
  if (!namesComponent(type, rename.from)) continue;
282
386
  type = typeof type === "string" && type.includes(":") ? `component:${rename.to}` : rename.to;
387
+ current = rename.to;
283
388
  touched++;
284
389
  continue;
285
390
  }
391
+ if (rename.kind === "component-prop" && slots && rename.from in slots && reachesScope(config, declaredFor(current), rename)) {
392
+ slots = withRenamedKey(slots, rename.from, rename.to);
393
+ touched++;
394
+ }
286
395
  if (!props) continue;
287
- const next = rewriteProps(config, scope, props, rename);
396
+ const next = rewriteProps(config, declaredFor(current), props, rename, renames);
288
397
  if (!next) continue;
289
398
  props = next;
290
399
  touched++;
@@ -294,7 +403,8 @@ function rewriteSpecRefs(config, spec, renames) {
294
403
  elements[key] = {
295
404
  ...element,
296
405
  ...type !== void 0 ? { type } : {},
297
- ...props ? { props } : {}
406
+ ...props ? { props } : {},
407
+ ...slots ? { slots } : {}
298
408
  };
299
409
  changed += touched;
300
410
  }
@@ -310,4 +420,4 @@ function rewriteSpecRefs(config, spec, renames) {
310
420
  };
311
421
  }
312
422
  //#endregion
313
- export { documentRenamesFromPatches, rewriteSpecRefs };
423
+ export { composeRenames, documentRenamesFromPatches, documentRenamesFromSource, rewriteSpecRefs };