@yahoo/uds-create-config 1.1.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.
Files changed (130) hide show
  1. package/dist/AssetGroup.d.ts +77 -0
  2. package/dist/AssetGroup.js +125 -0
  3. package/dist/Component.d.ts +308 -0
  4. package/dist/Component.js +896 -0
  5. package/dist/ComponentGroup.d.ts +20 -0
  6. package/dist/ComponentGroup.js +46 -0
  7. package/dist/CompositeStyle.d.ts +27 -0
  8. package/dist/CompositeStyle.js +52 -0
  9. package/dist/Config.d.ts +423 -0
  10. package/dist/Config.js +1429 -0
  11. package/dist/Mode.d.ts +41 -0
  12. package/dist/Mode.js +81 -0
  13. package/dist/Modifier.d.ts +51 -0
  14. package/dist/Modifier.js +97 -0
  15. package/dist/MotionDef.d.ts +49 -0
  16. package/dist/MotionDef.js +97 -0
  17. package/dist/Props.d.ts +317 -0
  18. package/dist/Props.js +35 -0
  19. package/dist/Provider.d.ts +20 -0
  20. package/dist/Provider.js +14 -0
  21. package/dist/StyleProp.d.ts +112 -0
  22. package/dist/StyleProp.js +197 -0
  23. package/dist/Token.d.ts +55 -0
  24. package/dist/Token.js +112 -0
  25. package/dist/TokenGroup.d.ts +32 -0
  26. package/dist/TokenGroup.js +68 -0
  27. package/dist/asset-kind.d.ts +55 -0
  28. package/dist/asset-kind.js +29 -0
  29. package/dist/brands.d.ts +30 -0
  30. package/dist/brands.js +20 -0
  31. package/dist/captureCallerPath.d.ts +48 -0
  32. package/dist/captureCallerPath.js +95 -0
  33. package/dist/colorExpressions.d.ts +131 -0
  34. package/dist/colorExpressions.js +148 -0
  35. package/dist/defineAssetGroup.d.ts +166 -0
  36. package/dist/defineAssetGroup.js +264 -0
  37. package/dist/defineProvider.d.ts +29 -0
  38. package/dist/defineProvider.js +60 -0
  39. package/dist/element-marker.d.ts +54 -0
  40. package/dist/element-marker.js +113 -0
  41. package/dist/entity-utils.d.ts +56 -0
  42. package/dist/entity-utils.js +105 -0
  43. package/dist/factories.d.ts +707 -0
  44. package/dist/factories.js +393 -0
  45. package/dist/foreign-component-name.d.ts +21 -0
  46. package/dist/foreign-component-name.js +42 -0
  47. package/dist/index.d.ts +32 -0
  48. package/dist/index.js +28 -0
  49. package/dist/interpolate.d.ts +20 -0
  50. package/dist/interpolate.js +10 -0
  51. package/dist/jsx/__fixtures__/cross-component-preview.d.ts +3 -0
  52. package/dist/jsx/__fixtures__/cross-component-preview.js +15 -0
  53. package/dist/jsx/jsx-dev-runtime.d.ts +15 -0
  54. package/dist/jsx/jsx-dev-runtime.js +11 -0
  55. package/dist/jsx/jsx-runtime.d.ts +48 -0
  56. package/dist/jsx/jsx-runtime.js +305 -0
  57. package/dist/markers.d.ts +217 -0
  58. package/dist/markers.js +67 -0
  59. package/dist/refs.d.ts +158 -0
  60. package/dist/refs.js +104 -0
  61. package/dist/renderer/RendererErrorBoundary.d.ts +26 -0
  62. package/dist/renderer/RendererErrorBoundary.js +30 -0
  63. package/dist/renderer/UdsRenderer.d.ts +80 -0
  64. package/dist/renderer/UdsRenderer.js +33 -0
  65. package/dist/renderer/assetRenderable.d.ts +13 -0
  66. package/dist/renderer/assetRenderable.js +13 -0
  67. package/dist/renderer/index.d.ts +14 -0
  68. package/dist/renderer/index.js +14 -0
  69. package/dist/renderer/makeRegistry.d.ts +34 -0
  70. package/dist/renderer/makeRegistry.js +52 -0
  71. package/dist/renderer/makeUdsRenderer.d.ts +29 -0
  72. package/dist/renderer/makeUdsRenderer.js +35 -0
  73. package/dist/renderer/primitives/FragmentRenderer.d.ts +12 -0
  74. package/dist/renderer/primitives/FragmentRenderer.js +11 -0
  75. package/dist/renderer/primitives/SlotRenderer.d.ts +21 -0
  76. package/dist/renderer/primitives/SlotRenderer.js +20 -0
  77. package/dist/renderer/wrapRegistry.d.ts +64 -0
  78. package/dist/renderer/wrapRegistry.js +39 -0
  79. package/dist/renderer/wrappers/component-slots.d.ts +41 -0
  80. package/dist/renderer/wrappers/component-slots.js +66 -0
  81. package/dist/renderer/wrappers/event-bridge.d.ts +20 -0
  82. package/dist/renderer/wrappers/event-bridge.js +78 -0
  83. package/dist/renderer/wrappers/hex-normalize.d.ts +14 -0
  84. package/dist/renderer/wrappers/hex-normalize.js +35 -0
  85. package/dist/renderer/wrappers/html-aliases.d.ts +24 -0
  86. package/dist/renderer/wrappers/html-aliases.js +62 -0
  87. package/dist/renderer/wrappers/inline-styles.d.ts +16 -0
  88. package/dist/renderer/wrappers/inline-styles.js +104 -0
  89. package/dist/renderer/wrappers/slot-resolution.d.ts +25 -0
  90. package/dist/renderer/wrappers/slot-resolution.js +68 -0
  91. package/dist/renderer/wrappers/void-elements.d.ts +23 -0
  92. package/dist/renderer/wrappers/void-elements.js +28 -0
  93. package/dist/spec/apply-forced-modifiers.d.ts +19 -0
  94. package/dist/spec/apply-forced-modifiers.js +49 -0
  95. package/dist/spec/asset-jsx.d.ts +48 -0
  96. package/dist/spec/asset-jsx.js +48 -0
  97. package/dist/spec/collapse-text-labels.d.ts +44 -0
  98. package/dist/spec/collapse-text-labels.js +107 -0
  99. package/dist/spec/empty-node-slots.d.ts +51 -0
  100. package/dist/spec/empty-node-slots.js +141 -0
  101. package/dist/spec/index.d.ts +10 -0
  102. package/dist/spec/index.js +10 -0
  103. package/dist/spec/jsxToSpec.d.ts +48 -0
  104. package/dist/spec/jsxToSpec.js +506 -0
  105. package/dist/spec/layer-props.d.ts +52 -0
  106. package/dist/spec/layer-props.js +149 -0
  107. package/dist/spec/preview-controls.d.ts +44 -0
  108. package/dist/spec/preview-controls.js +139 -0
  109. package/dist/spec/slot-refs.d.ts +39 -0
  110. package/dist/spec/slot-refs.js +56 -0
  111. package/dist/spec/specToJsx.d.ts +35 -0
  112. package/dist/spec/specToJsx.js +127 -0
  113. package/dist/token-override-rows.d.ts +66 -0
  114. package/dist/token-override-rows.js +223 -0
  115. package/dist/tokenValueType.d.ts +34 -0
  116. package/dist/tokenValueType.js +138 -0
  117. package/dist/tsconfig.tsbuildinfo +1 -0
  118. package/dist/types/css-properties.d.ts +232 -0
  119. package/dist/types/css-properties.js +14 -0
  120. package/dist/types/css-property-keywords.d.ts +156 -0
  121. package/dist/types/css-property-keywords.js +616 -0
  122. package/dist/types/css-values.d.ts +63 -0
  123. package/dist/types/css-values.js +16 -0
  124. package/dist/types.d.ts +708 -0
  125. package/dist/types.js +12 -0
  126. package/dist/units.d.ts +14 -0
  127. package/dist/units.js +16 -0
  128. package/dist/utils/index.d.ts +4 -0
  129. package/dist/utils/index.js +4 -0
  130. package/package.json +81 -0
@@ -0,0 +1,20 @@
1
+ import { SerializedComponentGroup } from "./types.js";
2
+
3
+ //#region src/ComponentGroup.d.ts
4
+ declare class ComponentGroup {
5
+ readonly name: string;
6
+ readonly label: string;
7
+ readonly description?: string;
8
+ readonly components: readonly string[];
9
+ constructor(args: {
10
+ name: string;
11
+ label: string;
12
+ description?: string;
13
+ components: readonly string[];
14
+ });
15
+ toJSON(): SerializedComponentGroup & {
16
+ name: string;
17
+ };
18
+ }
19
+ //#endregion
20
+ export { ComponentGroup };
@@ -0,0 +1,46 @@
1
+ import { compact } from "./entity-utils.js";
2
+ //#region src/ComponentGroup.ts
3
+ /**
4
+ * `ComponentGroup` — a labeled bundle of registered components, surfaced
5
+ * together in the Studio palette, the codegen-emitted catalog, and the
6
+ * AI prompt.
7
+ *
8
+ * Authored shape:
9
+ *
10
+ * const primitives = defineComponentGroup({
11
+ * label: 'Primitives',
12
+ * description: 'Low-level components that map to HTML elements.',
13
+ * components: { Box, Text },
14
+ * });
15
+ *
16
+ * uds.registerComponentGroups({ primitives });
17
+ *
18
+ * After registration, `ComponentGroup.components` is a JSON-safe ref
19
+ * list (just the registration names) — the `ComponentDefinition`s
20
+ * themselves live on `Config.components`. Each member's
21
+ * `Component.derived.componentGroup` carries the group key, so
22
+ * consumers can answer "which group does X belong to?" without a
23
+ * parallel projection.
24
+ */
25
+ var ComponentGroup = class {
26
+ name;
27
+ label;
28
+ description;
29
+ components;
30
+ constructor(args) {
31
+ this.name = args.name;
32
+ this.label = args.label;
33
+ this.description = args.description;
34
+ this.components = args.components;
35
+ }
36
+ toJSON() {
37
+ return {
38
+ name: this.name,
39
+ label: this.label,
40
+ ...compact({ description: this.description }),
41
+ components: this.components
42
+ };
43
+ }
44
+ };
45
+ //#endregion
46
+ export { ComponentGroup };
@@ -0,0 +1,27 @@
1
+ import { CompositeStyleDefinition, CompositeStyleObject } from "./types.js";
2
+ import { CssClassName, CssVar } from "./brands.js";
3
+
4
+ //#region src/CompositeStyle.d.ts
5
+ declare class CompositeStyle {
6
+ #private;
7
+ readonly name: string;
8
+ readonly label: string;
9
+ readonly description?: string;
10
+ readonly styles: ReadonlyMap<string, CompositeStyleObject>;
11
+ constructor(args: {
12
+ name: string;
13
+ definition: CompositeStyleDefinition;
14
+ prefixGetter?: () => string;
15
+ });
16
+ get derived(): {
17
+ readonly cssClassNames: ReadonlyMap<string, CssClassName>;
18
+ readonly markerVarName: CssVar;
19
+ cssClassName(variant: string): CssClassName;
20
+ markerVarValue(variant: string): string;
21
+ };
22
+ toJSON(): CompositeStyleDefinition & {
23
+ name: string;
24
+ };
25
+ }
26
+ //#endregion
27
+ export { CompositeStyle };
@@ -0,0 +1,52 @@
1
+ import { buildCompositeClassName, buildCompositeMarkerVarName, compact, cssSafeSegment } from "./entity-utils.js";
2
+ //#region src/CompositeStyle.ts
3
+ var CompositeStyle = class {
4
+ name;
5
+ label;
6
+ description;
7
+ styles;
8
+ #prefixGetter;
9
+ #derived;
10
+ constructor(args) {
11
+ this.name = args.name;
12
+ this.label = args.definition.label;
13
+ this.description = args.definition.description;
14
+ this.#prefixGetter = args.prefixGetter ?? (() => "uds");
15
+ const styles = /* @__PURE__ */ new Map();
16
+ for (const [variant, bag] of Object.entries(args.definition.styles)) styles.set(variant, bag);
17
+ this.styles = styles;
18
+ }
19
+ get derived() {
20
+ if (!this.#derived) {
21
+ const name = this.name;
22
+ const prefixGetter = this.#prefixGetter;
23
+ const cssClassNames = /* @__PURE__ */ new Map();
24
+ for (const key of this.styles.keys()) cssClassNames.set(key, buildCompositeClassName(prefixGetter(), name, key));
25
+ this.#derived = {
26
+ cssClassNames,
27
+ get markerVarName() {
28
+ return buildCompositeMarkerVarName(prefixGetter(), name);
29
+ },
30
+ cssClassName(variant) {
31
+ return buildCompositeClassName(prefixGetter(), name, variant);
32
+ },
33
+ markerVarValue(variant) {
34
+ return cssSafeSegment(variant);
35
+ }
36
+ };
37
+ }
38
+ return this.#derived;
39
+ }
40
+ toJSON() {
41
+ const styles = {};
42
+ for (const [key, value] of this.styles) styles[key] = value;
43
+ return {
44
+ name: this.name,
45
+ label: this.label,
46
+ ...compact({ description: this.description }),
47
+ styles
48
+ };
49
+ }
50
+ };
51
+ //#endregion
52
+ export { CompositeStyle };
@@ -0,0 +1,423 @@
1
+ import { CssVarRef } from "./types/css-values.js";
2
+ import { AnyStylePropDefinition, BuildOptions, ComponentDefinition, ComponentGroupDefinition, CompositeStyleDefinition, GlobalStylesDef, ModeDefinition, ModifierDefinition, MotionDefinitionInput, SerializedConfig, TokenGroupDefinition, TokenModifierKey } from "./types.js";
3
+ import { AssetGroupDefinition } from "./defineAssetGroup.js";
4
+ import { AssetGroup } from "./AssetGroup.js";
5
+ import { cssVar } from "./brands.js";
6
+ import { Component } from "./Component.js";
7
+ import { ComponentGroup } from "./ComponentGroup.js";
8
+ import { CompositeStyle } from "./CompositeStyle.js";
9
+ import { kebabCase } from "./entity-utils.js";
10
+ import { ProviderComponent } from "./factories.js";
11
+ import { Mode, ModeOption } from "./Mode.js";
12
+ import { Modifier } from "./Modifier.js";
13
+ import { MotionDef } from "./MotionDef.js";
14
+ import { Provider } from "./Provider.js";
15
+ import { Token } from "./Token.js";
16
+ import { StyleProp } from "./StyleProp.js";
17
+ import { TokenGroup } from "./TokenGroup.js";
18
+
19
+ //#region src/Config.d.ts
20
+ /**
21
+ * The entity kinds the dependency graph addresses — the discriminant for both
22
+ * {@link Config.dependentsOf} (inbound) and {@link Config.dependenciesOf}
23
+ * (outbound), and the single source of truth for the surface. The query unions
24
+ * are mapped over this type, so adding a kind here automatically widens both
25
+ * queries, which makes each method's `switch` non-exhaustive — its trailing
26
+ * `assertNever(query)` then fails to compile until a `case` is added. A new
27
+ * kind therefore can't ship without logic in *both* directions.
28
+ */
29
+ type DependencyKind = 'component' | 'compositeStyle' | 'styleProp' | 'modifier' | 'token' | 'tokenGroup';
30
+ /**
31
+ * A tagged node in a dependency result. `value` is populated only for a
32
+ * style-prop *keyword* edge — `{ kind: 'styleProp', name: 'display', value:
33
+ * 'flex' }` — where the prop alone doesn't identify the dependency.
34
+ */
35
+ interface DependencyRef {
36
+ readonly kind: DependencyKind;
37
+ readonly name: string;
38
+ readonly value?: string;
39
+ }
40
+ /** Per-kind edge-narrowing options for the inbound {@link DependentsQuery}.
41
+ * Only kinds that take options appear here; the rest get none. */
42
+ interface DependentsOptionsByKind {
43
+ /** Narrow to components that use this keyword *value* of the prop
44
+ * (`display`=`flex`) for value-removal impact; omit for the components that
45
+ * expose the prop. */
46
+ styleProp: {
47
+ value?: string;
48
+ };
49
+ }
50
+ /** Inbound query for {@link Config.dependentsOf} — "what references this?".
51
+ * Mapped over {@link DependencyKind} so it always covers every kind. */
52
+ type DependentsQuery = { [K in DependencyKind]: {
53
+ kind: K;
54
+ name: string;
55
+ } & (K extends keyof DependentsOptionsByKind ? DependentsOptionsByKind[K] : unknown) }[DependencyKind];
56
+ /** Outbound query for {@link Config.dependenciesOf} — "what does this use?".
57
+ * Mapped over {@link DependencyKind} for the same exhaustiveness guarantee. */
58
+ type DependenciesQuery = { [K in DependencyKind]: {
59
+ kind: K;
60
+ name: string;
61
+ } }[DependencyKind];
62
+ declare class Config {
63
+ #private;
64
+ static readonly SCHEMA_VERSION = 1;
65
+ prefix: string;
66
+ /**
67
+ * Registry namespace — a stable, `package.json`-style identifier
68
+ * (`uds`, `@acme/system`) that namespaces every component's
69
+ * `registryKey` as `<namespace>:<ComponentName>` (the spec `type`).
70
+ * Declared in `uds.config.ts` via `configure({ namespace })` so it's
71
+ * available at build time; the push pipeline validates it for
72
+ * uniqueness / ownership. `undefined` ⇒ components keep bare-name
73
+ * registry keys. See Linear doc "RFC: Registry-namespaced component
74
+ * types".
75
+ */
76
+ namespace?: string;
77
+ preflight: boolean;
78
+ globalStyles: GlobalStylesDef;
79
+ rawCss: string[];
80
+ designPrinciples: string[];
81
+ buildOptions: BuildOptions;
82
+ readonly tokenGroups: Map<string, TokenGroup>;
83
+ readonly styleProps: Map<string, StyleProp>;
84
+ readonly modifiers: Map<`_${string}`, Modifier>;
85
+ readonly modes: Map<string, Mode>;
86
+ readonly compositeStyles: Map<string, CompositeStyle>;
87
+ readonly components: Map<string, Component>;
88
+ readonly componentGroups: Map<string, ComponentGroup>;
89
+ readonly assetGroups: Map<string, AssetGroup>;
90
+ readonly providers: Map<string, Provider>;
91
+ readonly motion: Map<string, MotionDef>;
92
+ /**
93
+ * Set top-level config metadata in one call — the single scalar-setter,
94
+ * replacing the former `withPrefix` / `withPreflight` / `withName` /
95
+ * `withDesignPrinciples` / `withBuildOptions` chain. Partial: only
96
+ * provided keys are applied, so it can run once or be merged across
97
+ * calls. `globalStyles` stays on `defineGlobalStyles` — its callback
98
+ * form needs the derived token refs, so it doesn't fit a plain bag.
99
+ *
100
+ * - `namespace` — the registry namespace (`uds`, `@acme/system`) that
101
+ * namespaces every component's `registryKey` as `<namespace>:<Component>`.
102
+ * Declared in `uds.config.ts` (the `package.json`-`name` model) so it's
103
+ * available at build time; the push pipeline additionally validates it
104
+ * for uniqueness / ownership. Throws on a structurally invalid value
105
+ * (the `:` separator, whitespace, or empty).
106
+ * - `prefix` — class-name + CSS-variable prefix (default `uds`); invalidates
107
+ * derived. Pass `''` or `false` to opt out entirely — classes and vars
108
+ * emit unprefixed (`bg-primary`, `--color-brand`). `false` is sugar for
109
+ * `''`, normalized to the empty string here so the value stays a string.
110
+ * - `preflight` — include Tailwind's reset (default `true`).
111
+ * - `designPrinciples` — freeform strings surfaced in the AI prompt.
112
+ * - `buildOptions` — shallow-merged into existing build options.
113
+ */
114
+ configure(options: {
115
+ namespace?: string;
116
+ prefix?: string | false;
117
+ preflight?: boolean;
118
+ designPrinciples?: readonly string[];
119
+ buildOptions?: BuildOptions;
120
+ }): this;
121
+ /**
122
+ * Resolve a spec element `type` (or any component identifier) to its
123
+ * {@link Component}, namespace-aware and backwards-compatible.
124
+ *
125
+ * `components` is keyed by the bare `name`, so:
126
+ * - an exact match is tried first — a bare `'Badge'` resolves directly,
127
+ * keeping every existing bare-name lookup working;
128
+ * - otherwise a namespaced registry key (`'<namespace>:<name>'`, the spec
129
+ * `type`) resolves by its bare name **only when the namespace is this
130
+ * registry's own**. A key from a different registry (`'other:Badge'`)
131
+ * deliberately does not resolve, so specs from multiple registries can
132
+ * coexist without colliding on a shared bare name.
133
+ *
134
+ * Returns `undefined` for unknown types and foreign (`foreign:`) sentinels.
135
+ * This is the single resolution path consumers should use instead of
136
+ * `config.components.get(type)` when `type` may be a spec/registry key.
137
+ */
138
+ getComponent(type: string): Component | undefined;
139
+ /**
140
+ * The bare, human-readable component name for a spec `type` — strips this
141
+ * registry's `<namespace>:` prefix (`'uds:Text'` → `'Text'`) for display, and
142
+ * the `foreign:` sentinel third-party leaves carry (`'foreign:CopyIcon'` →
143
+ * `'CopyIcon'`) — that prefix marks "not a UDS component," not a peer system,
144
+ * so the bare name is what every display surface wants. A bare type, an
145
+ * unknown type, or a key from another *peer* registry (`@acme/system:Button`)
146
+ * is returned unchanged — there the prefix is meaningful disambiguation.
147
+ */
148
+ componentDisplayName(type: string): string;
149
+ /**
150
+ * Components whose catalog `metadata.label` matches `label` (case-insensitive)
151
+ * — the display-name lookup that complements `getComponent` (registry key).
152
+ * Returns an array because labels aren't unique: a collision-dodging export
153
+ * (`StudioListItem` with `label: 'ListItem'`) can share a label with another
154
+ * component's key, so callers must handle 0, 1, or many. Empty when no label
155
+ * matches.
156
+ */
157
+ getComponentsByLabel(label: string): Component[];
158
+ /**
159
+ * Style props that emit a given CSS property — the reverse of
160
+ * `StyleProp.cssProperty`. A property can be served by more than one prop
161
+ * (e.g. `border-color` by `borderColor`, `divideColor`; `margin-top` by both
162
+ * the positive `marginTop` and the `negative` `offsetTop`). Match is exact on
163
+ * the CSS property name; a prop targeting several properties matches any.
164
+ *
165
+ * `negative` props are ordered LAST, so a caller taking the first match
166
+ * (`getStylePropsByCssProperty(css)[0]`) always gets the primary, positive
167
+ * prop — the negative variant is only the first result when it's the sole
168
+ * prop for that property. Registration order is preserved within each group.
169
+ *
170
+ * Pass `opts.negative` to filter explicitly: `{ negative: false }` for only
171
+ * positive props, `{ negative: true }` for only the negative variant(s) (e.g.
172
+ * the `offsetTop` behind `margin-top`). Omit it to get every match.
173
+ */
174
+ getStylePropsByCssProperty(cssProperty: string, opts?: {
175
+ negative?: boolean;
176
+ }): StyleProp[];
177
+ /**
178
+ * Resolve the `StyleProp` behind a component's JSX prop, following any
179
+ * re-alias. A component can expose a style prop under a different JSX name
180
+ * than the registry key — `Box`'s `backgroundColor` prop binds
181
+ * `styleProp('bg')` — so this maps the on-component name back to the
182
+ * registered `StyleProp`. Returns `undefined` if the component has no such
183
+ * style prop.
184
+ */
185
+ getComponentStyleProp(componentName: string, jsxProp: string): StyleProp | undefined;
186
+ /**
187
+ * Aggregate token-usage stats across the whole registry — how many tokens
188
+ * are referenced *somewhere* (components, other tokens, or composite styles;
189
+ * see {@link Config.#referencedTokenNames}) vs not. `usagePercent` is
190
+ * rounded; `0` total tokens reports `0%`.
191
+ */
192
+ tokenUsageStats(): {
193
+ total: number;
194
+ used: number;
195
+ unused: number;
196
+ usagePercent: number;
197
+ };
198
+ /**
199
+ * Token values ranked by how often they appear across component base styles —
200
+ * the aggregate "what's load-bearing?" companion to `dependentsOf('token')`.
201
+ * `opts.property` narrows to one CSS property. Descends into `_<modifier>`
202
+ * sub-objects so a value used only in a hover/dark state still counts.
203
+ */
204
+ tokenValueUsage(opts?: {
205
+ property?: string;
206
+ }): Array<{
207
+ value: string;
208
+ count: number;
209
+ property: string;
210
+ }>;
211
+ /**
212
+ * The reverse-dependency read surface — "what references this entity, and
213
+ * would break if I delete or rename it?" — uniform across every kind. One
214
+ * public entry point: callers dispatch by `kind` and get a single tagged
215
+ * list (the affected entities, each with its own kind), never a per-kind
216
+ * bespoke shape. The relation is always *references to the entity*; the
217
+ * per-kind walks behind it are private slices.
218
+ *
219
+ * A `token` resolves to BOTH the components that reference it AND the tokens
220
+ * that alias or mode-override it — a token's full referrer set, not split
221
+ * across two methods. A `modifier` flattens its components, composite styles,
222
+ * and token-group namespaces into the one tagged list. A token group's other
223
+ * relation — what actually *uses* its member tokens — is the separate
224
+ * {@link Config.getTokenGroupUsage} (only containers have it); ranking every
225
+ * entity of a kind at once is {@link Config.componentDependentCounts} & co.
226
+ */
227
+ dependentsOf(query: DependentsQuery): DependencyRef[];
228
+ /**
229
+ * The outbound mirror of {@link Config.dependentsOf} — "what does this entity
230
+ * *use*, and would I have to update if I delete those?". Same tagged
231
+ * `DependencyRef[]` shape, same `kind`-keyed exhaustiveness. A `component`
232
+ * reports the tokens it references, the keyword values it sets
233
+ * (`{ kind: 'styleProp', name, value }`), the composites and style props it
234
+ * binds, the components it renders as layers, and the modifiers it styles
235
+ * with; a `token` reports the tokens it aliases and the modifiers in its mode
236
+ * overrides; a `styleProp` reports the token groups it draws from. `modifier`
237
+ * and `tokenGroup` are leaves here — a selector and a container don't *use*
238
+ * other registry entities — so they report nothing.
239
+ */
240
+ dependenciesOf(query: DependenciesQuery): DependencyRef[];
241
+ /**
242
+ * The aggregate sibling of {@link Config.dependentsOf} — for *every* entity of
243
+ * a kind at once, how many dependents each has (`Map<name, count>`, ranked by
244
+ * `uds_analyze_usage`). A single entity's count is just
245
+ * `dependentsOf(query).length`; this exists for the all-at-once case, where
246
+ * calling that per entity would re-walk the component set N times
247
+ * (O(N × components)) — each private slice walks once (O(components)) and
248
+ * tallies as it goes, kept consistent with `dependentsOf` (a dependent
249
+ * counted once per entity, self-references excluded; the cross-check tests
250
+ * assert the equivalence against the live config).
251
+ */
252
+ dependentCounts(kind: DependencyKind): Map<string, number>;
253
+ /**
254
+ * A component's style-prop surface as a delta against a base set, so
255
+ * consumers can render "inherits Box (226); adds …; removes …" instead of
256
+ * re-emitting the full ~226-name list per component. The base is the
257
+ * `extendsFrom` parent's set when value-extending, else the union across the
258
+ * `primitives` group (the set every primitive shares). `baseSource` is the
259
+ * parent's name, or `undefined` when the base is the primitives union — every
260
+ * `extends:Box` primitive has an identical set today, so `adds`/`removes` are
261
+ * usually empty, which is the dedup the projection relies on.
262
+ */
263
+ stylePropSummary(component: Component): {
264
+ own: readonly string[];
265
+ base: readonly string[];
266
+ baseSource?: string;
267
+ adds: readonly string[];
268
+ removes: readonly string[];
269
+ };
270
+ /**
271
+ * Author global CSS — a selector → declarations bag. The callback
272
+ * form receives the same 2D CSS-var ref table as `derived.cssVarRefs`
273
+ * (`tokens.bg.primary` resolves to a `var(--uds-bg-primary)` brand)
274
+ * so consumers can reach for token values without re-deriving them.
275
+ * Mirrors the old `@yahoo/uds-create-config` `defineGlobalStyles` chain.
276
+ */
277
+ defineGlobalStyles(input: GlobalStylesDef | ((tokens: Readonly<Record<string, Readonly<Record<string, CssVarRef>>>>) => GlobalStylesDef)): this;
278
+ /**
279
+ * Include a raw CSS string verbatim in the generated stylesheet — for
280
+ * declarations the token/style-prop system can't express, most commonly
281
+ * `@font-face` blocks (the codegen pipeline emits none on its own) plus
282
+ * the `:root { --<prefix>-font-family-<id>: … }` definitions that font
283
+ * tokens reference. Accumulates across calls.
284
+ *
285
+ * Takes the CSS *content*, not a path, so `Config` stays free of Node
286
+ * `fs` and remains importable in the browser/runtime. Read the file in
287
+ * `uds.config.ts` (Node context) and pass the string:
288
+ *
289
+ * ```ts
290
+ * import { readFileSync } from 'node:fs';
291
+ * const fontsCss = readFileSync(new URL('./fonts.css', import.meta.url), 'utf8');
292
+ * export default defineConfig({ … }).includeCss(fontsCss);
293
+ * ```
294
+ *
295
+ * Injected after Tailwind compilation and the unused-var purge, so
296
+ * `@font-face` families and any custom properties it declares are never
297
+ * stripped as "unused".
298
+ */
299
+ includeCss(css: string): this;
300
+ registerModes(modes: Record<string, ModeDefinition>): this;
301
+ registerModifiers(modifiers: Record<string, ModifierDefinition>): this;
302
+ registerTokenGroups(groups: Record<string, TokenGroupDefinition>): this;
303
+ registerStyleProps(props: Record<string, AnyStylePropDefinition>): this;
304
+ registerComposites(composites: Record<string, CompositeStyleDefinition>): this;
305
+ registerMotion(motion: Record<string, MotionDefinitionInput>): this;
306
+ registerComponents(components: Record<string, ComponentDefinition>): this;
307
+ /**
308
+ * Build a single component from its definition with this config's context
309
+ * getters wired — `prefixGetter`, `namespaceGetter`, `componentResolver` —
310
+ * and set it on the registry, replacing any existing entry of the same name.
311
+ *
312
+ * This is the ONE sanctioned way to put a constructed component into the
313
+ * config outside `registerComponents`. Constructing a `Component` by hand and
314
+ * calling `config.components.set(...)` silently drops those getters, so the
315
+ * component's `derived.classNames` fall back to an empty prefix/namespace and
316
+ * its anatomy CSS emits unprefixed (`:where(.button-root)`) — it renders
317
+ * unstyled while the runtime applies the prefixed class. Patch-apply code that
318
+ * rebuilds a component from a mutated definition (e.g.
319
+ * `applyComponentStyleUpdatePatch`) routes through here so the wiring can't be
320
+ * forgotten.
321
+ */
322
+ upsertComponent(name: string, definition: ComponentDefinition, meta?: {
323
+ componentGroup?: string;
324
+ subcomponentOf?: string;
325
+ subcomponents?: readonly string[];
326
+ }): this;
327
+ /**
328
+ * Register one or more labeled bundles of components. Each group's
329
+ * `components` record is flattened into `this.components` (same
330
+ * surface as `registerComponents`), and every member's
331
+ * `Component.derived.componentGroup` carries the group key. The
332
+ * group entry itself lives on `this.componentGroups[key]` with a
333
+ * JSON-safe ref list (`components: readonly string[]`).
334
+ *
335
+ * Subcomponents declared on a grouped parent via
336
+ * `.subcomponents({...})` auto-register alongside their parent;
337
+ * they carry `subcomponentOf` instead of `componentGroup` (a
338
+ * subcomponent belongs to a parent, not a group).
339
+ *
340
+ * Component names are the identity (`<namespace>:<name>`, the spec
341
+ * `type`) and must be unique across the whole config — the same name
342
+ * under two groups, repeated in one group, or already registered by a
343
+ * prior `register*` call throws. Two components that should *display*
344
+ * the same use distinct names + `metadata.label`.
345
+ */
346
+ registerComponentGroups(groups: Record<string, ComponentGroupDefinition>): this;
347
+ /**
348
+ * Register one or more asset groups. The record key IS the slug —
349
+ * stamped onto the group at registration (late-bound, like
350
+ * `registerComponentGroups` deriving a group's name from its key and
351
+ * `Component.registryKey` reading the namespace getter). Each member
352
+ * then resolves to `${namespace}:asset:${slug}/${assetName}` via
353
+ * `AssetGroup.assetType()`.
354
+ *
355
+ * Trade-off (accepted, same as `registerComponentGroups`): the
356
+ * `{ icons }` shorthand ties the slug to the variable name — write
357
+ * the key out explicitly (`{ icons: phosphorIcons }`) whenever it
358
+ * shouldn't track the variable.
359
+ */
360
+ registerAssetGroups(groups: Record<string, AssetGroupDefinition>): this;
361
+ registerProviders(providers: Record<string, ProviderComponent<Record<never, never>>>): this;
362
+ get derived(): {
363
+ readonly tokens: ReadonlyMap<string, Token>;
364
+ readonly cssVarRefs: Readonly<Record<string, Readonly<Record<string, CssVarRef>>>>;
365
+ /**
366
+ * Reverse lookup: a style modifier key (`_dark`) → the mode option that
367
+ * owns it. Built from `modes`, so a modifier auto-created by a mode
368
+ * (`colorMode: { dark }` → `_dark`) is recognizable as mode-tied — used to
369
+ * group/describe such modifiers as modes rather than bare custom states.
370
+ */
371
+ readonly modeOptionsByModifier: ReadonlyMap<TokenModifierKey, ModeOption>;
372
+ };
373
+ /**
374
+ * Validate cross-references. Throws on cycles in token aliases or on
375
+ * unknown refs in markers (`token()`, `composite()`, `mode()`,
376
+ * `styleProp()`, `tokenGroup()`).
377
+ */
378
+ validate(): void;
379
+ /**
380
+ * Deep-fork for Studio drafts. Re-builds every entity from `toJSON` /
381
+ * `fromJSON` rather than sharing instances so the clone is fully
382
+ * isolated.
383
+ *
384
+ * `overlay` shallow-merges into the serialized form before re-hydration —
385
+ * lets callers swap top-level slices (`{ components, tokenGroups }`)
386
+ * without round-tripping through the chain methods. Each overlay key
387
+ * fully replaces the existing slice (no per-entry merge); pass the
388
+ * full record you want for that slice.
389
+ */
390
+ clone(overlay?: Partial<SerializedConfig>): Config;
391
+ /**
392
+ * Serialize to the wire format. Derived data is never included.
393
+ * `meta.builtAt` lands in the JSON when the caller passes it (CLI
394
+ * stamps it at write time so re-serializing in tests stays stable).
395
+ * `meta.projectRoot` relativizes per-component `sourceFilePath`
396
+ * values at the wire boundary — keeps `config.json` portable across
397
+ * machines. Omitting it leaves paths absolute.
398
+ */
399
+ toJSON(meta?: {
400
+ builtAt?: string;
401
+ projectRoot?: string;
402
+ }): SerializedConfig;
403
+ /**
404
+ * Hydrate from the wire format. Throws when `schemaVersion` doesn't
405
+ * match — the CLI's job is to translate the error into "your manifest
406
+ * is from an older build; run `uds build`."
407
+ */
408
+ static fromJSON(json: SerializedConfig): Config;
409
+ }
410
+ /**
411
+ * Split a spec element `type` / registry key into its namespace + bare name.
412
+ * `'uds:Text'` → `{ namespace: 'uds', name: 'Text' }`; a bare `'Text'` →
413
+ * `{ name: 'Text' }`. The namespace is everything before the first `:`
414
+ * (namespaces are validated to contain no `:`, see {@link validateNamespace}),
415
+ * so a scoped namespace like `'@acme/system:Button'` still splits on the right
416
+ * colon. The inverse of {@link Component.registryKey}.
417
+ */
418
+ declare function parseRegistryKey(type: string): {
419
+ namespace?: string;
420
+ name: string;
421
+ };
422
+ //#endregion
423
+ export { Config, DependenciesQuery, DependencyKind, DependencyRef, DependentsQuery, parseRegistryKey };