@yahoo/uds-v5-wip 1.61.0 → 1.62.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.
Files changed (117) hide show
  1. package/dist/config/dist/AssetGroup.d.ts +75 -0
  2. package/dist/config/dist/AssetGroup.js +114 -0
  3. package/dist/config/dist/Component.d.ts +309 -0
  4. package/dist/config/dist/Component.js +897 -0
  5. package/dist/config/dist/ComponentGroup.d.ts +21 -0
  6. package/dist/config/dist/ComponentGroup.js +46 -0
  7. package/dist/config/dist/CompositeStyle.d.ts +28 -0
  8. package/dist/config/dist/CompositeStyle.js +52 -0
  9. package/dist/config/dist/Config.d.ts +422 -0
  10. package/dist/config/dist/Config.js +1426 -0
  11. package/dist/config/dist/Mode.d.ts +42 -0
  12. package/dist/config/dist/Mode.js +81 -0
  13. package/dist/config/dist/Modifier.d.ts +52 -0
  14. package/dist/config/dist/Modifier.js +97 -0
  15. package/dist/config/dist/MotionDef.d.ts +50 -0
  16. package/dist/config/dist/MotionDef.js +97 -0
  17. package/dist/config/dist/Props.d.ts +235 -126
  18. package/dist/config/dist/Provider.d.ts +21 -0
  19. package/dist/config/dist/Provider.js +14 -0
  20. package/dist/config/dist/StyleProp.d.ts +113 -0
  21. package/dist/config/dist/StyleProp.js +197 -0
  22. package/dist/config/dist/Token.d.ts +56 -0
  23. package/dist/config/dist/Token.js +112 -0
  24. package/dist/config/dist/TokenGroup.d.ts +33 -0
  25. package/dist/config/dist/TokenGroup.js +68 -0
  26. package/dist/config/dist/asset-kind.d.ts +56 -0
  27. package/dist/config/dist/asset-kind.js +29 -0
  28. package/dist/config/dist/brands.d.ts +31 -0
  29. package/dist/config/dist/brands.js +20 -0
  30. package/dist/config/dist/captureCallerPath.d.ts +49 -0
  31. package/dist/config/dist/captureCallerPath.js +95 -0
  32. package/dist/config/dist/colorExpressions.d.ts +132 -0
  33. package/dist/config/dist/colorExpressions.js +148 -0
  34. package/dist/config/dist/defineAssetGroup.d.ts +158 -0
  35. package/dist/config/dist/defineAssetGroup.js +263 -0
  36. package/dist/config/dist/defineProvider.d.ts +30 -0
  37. package/dist/config/dist/defineProvider.js +60 -0
  38. package/dist/config/dist/element-marker.d.ts +55 -0
  39. package/dist/config/dist/element-marker.js +113 -0
  40. package/dist/config/dist/entity-utils.d.ts +27 -0
  41. package/dist/config/dist/entity-utils.js +105 -0
  42. package/dist/config/dist/factories.d.ts +707 -0
  43. package/dist/config/dist/factories.js +393 -0
  44. package/dist/config/dist/foreign-component-name.js +42 -0
  45. package/dist/config/dist/index.d.ts +30 -21
  46. package/dist/config/dist/index.js +26 -14
  47. package/dist/config/dist/interpolate.d.ts +21 -0
  48. package/dist/config/dist/interpolate.js +10 -0
  49. package/dist/config/dist/markers.d.ts +218 -0
  50. package/dist/config/dist/markers.js +67 -0
  51. package/dist/config/dist/refs.d.ts +143 -69
  52. package/dist/config/dist/refs.js +95 -113
  53. package/dist/config/dist/token-override-rows.d.ts +67 -0
  54. package/dist/config/dist/token-override-rows.js +223 -0
  55. package/dist/config/dist/tokenValueType.js +138 -0
  56. package/dist/config/dist/types/css-properties.d.ts +132 -122
  57. package/dist/config/dist/types/css-property-keywords.d.ts +157 -0
  58. package/dist/config/dist/types/css-property-keywords.js +616 -0
  59. package/dist/config/dist/types/css-values.d.ts +18 -16
  60. package/dist/config/dist/types.d.ts +688 -66
  61. package/dist/config/dist/units.d.ts +15 -0
  62. package/dist/config/dist/units.js +16 -0
  63. package/dist/config.d.ts +31 -22
  64. package/dist/config.js +28 -16
  65. package/dist/loader/dist/loader/artifacts.js +26 -9
  66. package/dist/loader/dist/loader.d.ts +11 -23
  67. package/dist/loader/dist/loader.js +54 -99
  68. package/dist/loader/dist/next.js +3 -3
  69. package/dist/loader/dist/transform-runner.js +1 -8
  70. package/dist/loader/dist/unplugin.d.ts +2 -2
  71. package/dist/loader/dist/unplugin.js +2 -2
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/dist/utils/dist/index.js +1 -0
  74. package/dist/utils/dist/motion-utils/resolveMotionState.d.ts +35 -0
  75. package/dist/utils/dist/motion-utils/resolveMotionState.js +33 -0
  76. package/dist/utils/dist/string-utils/componentClassName.d.ts +41 -8
  77. package/dist/utils/dist/string-utils/componentClassName.js +48 -11
  78. package/dist/utils.d.ts +3 -2
  79. package/dist/utils.js +3 -2
  80. package/package.json +3 -3
  81. package/dist/codegen/dist/loader/getLoaderArtifacts.js +0 -2
  82. package/dist/config/dist/bindRender.d.ts +0 -16
  83. package/dist/config/dist/bindRender.js +0 -310
  84. package/dist/config/dist/className.d.ts +0 -54
  85. package/dist/config/dist/className.js +0 -77
  86. package/dist/config/dist/component-config.d.ts +0 -862
  87. package/dist/config/dist/component-config.js +0 -163
  88. package/dist/config/dist/component-refs.d.ts +0 -121
  89. package/dist/config/dist/createConfig.d.ts +0 -456
  90. package/dist/config/dist/createConfig.js +0 -503
  91. package/dist/config/dist/createStyler.d.ts +0 -35
  92. package/dist/config/dist/createStyler.js +0 -93
  93. package/dist/config/dist/defineComponent.d.ts +0 -317
  94. package/dist/config/dist/defineComponent.js +0 -264
  95. package/dist/config/dist/defineCompositeStyle.d.ts +0 -93
  96. package/dist/config/dist/defineCompositeStyle.js +0 -18
  97. package/dist/config/dist/defineMotionConfig.d.ts +0 -152
  98. package/dist/config/dist/definePreview.d.ts +0 -45
  99. package/dist/config/dist/definePreview.js +0 -35
  100. package/dist/config/dist/defineStyleProp.d.ts +0 -289
  101. package/dist/config/dist/defineStyleProp.js +0 -61
  102. package/dist/config/dist/merge-utils.js +0 -51
  103. package/dist/config/dist/propertyAcceptedTypes.d.ts +0 -19
  104. package/dist/config/dist/propertyAcceptedTypes.js +0 -220
  105. package/dist/config/dist/resolveCompoundProps.d.ts +0 -65
  106. package/dist/config/dist/resolveCompoundProps.js +0 -120
  107. package/dist/config/dist/resolveStyleProp.d.ts +0 -157
  108. package/dist/config/dist/resolveStyleProp.js +0 -260
  109. package/dist/config/dist/runtime-registry.js +0 -37
  110. package/dist/config/dist/serialize.d.ts +0 -47
  111. package/dist/config/dist/serialize.js +0 -111
  112. package/dist/config/dist/sniffTokenType.d.ts +0 -7
  113. package/dist/config/dist/sniffTokenType.js +0 -67
  114. package/dist/config/dist/style-prop-runtime.d.ts +0 -75
  115. package/dist/config/dist/style-prop-runtime.js +0 -390
  116. package/dist/loader/dist/loader/internal-meta.js +0 -59
  117. package/dist/loader/dist/loader/lower-new-api-primitive.js +0 -252
@@ -0,0 +1,218 @@
1
+ import { AssetGroupRef } from "./refs.js";
2
+ import { ComponentDefinition } from "./types.js";
3
+
4
+ //#region ../config/dist/markers.d.ts
5
+ //#region src/markers.d.ts
6
+ /**
7
+ * A slot's `.accepts(...)` argument: a registered component definition, or a
8
+ * placeable asset group returned by `defineAssetGroup(...).config(...)` (it
9
+ * carries the `AssetGroupRef` tag). The two are kept distinct downstream —
10
+ * component names land on `SlotInfo.accepts`, the asset-group slug on
11
+ * `SlotInfo.acceptsAssetGroup` — so the designer panel can pick the right
12
+ * picker. Non-placeable groups (fonts) are admitted by the type but rejected
13
+ * at config load.
14
+ */
15
+ type SlotAccepts = ComponentDefinition | AssetGroupRef;
16
+ /**
17
+ * Brand applied to a marker by `.required()`. Lives alongside the
18
+ * marker interfaces so the slot factories (whose `.required()`
19
+ * implementation is co-located with `.accepts()` rather than going
20
+ * through `attachRequired`) can return the brand-narrowed type via
21
+ * the interface signature.
22
+ *
23
+ * `RenderPropsFromConfig` reads this brand to decide whether a render-
24
+ * fn destructure entry is optional (`T | undefined`) or non-optional
25
+ * (`T`). Distinct from `__required?: boolean` on the marker bodies —
26
+ * that field is the runtime flag codegen reads; the brand is the
27
+ * compile-time signal the render-arg type-flow keys on.
28
+ */
29
+ type RequiredBrand = {
30
+ __required: true;
31
+ };
32
+ /**
33
+ * Author-declared slot value kind. A slot holds renderable content; the only
34
+ * explicit kind is text:
35
+ *
36
+ * - `'string'` — plain text content (e.g. Button's `children` label).
37
+ *
38
+ * An open `slot()` is a node container (`ReactNode`) by default — it accepts
39
+ * dropped layers and is narrowed to specific components via `.accepts(...)`;
40
+ * `'string'` instead marks a text surface, so tools like the Studio canvas
41
+ * inline-edit it rather than treat it as a reparent target. Scalars like
42
+ * boolean and number are *not* slots — use the dedicated `bool()` / `number()`
43
+ * markers. (A `'string'` slot still *resolves* to `SlotValueKind: 'ReactNode'`,
44
+ * since a string is a valid `ReactNode`; `authoredType` records the intent.)
45
+ *
46
+ * - `'component'` — the slot resolves to a `FunctionComponent`, not rendered
47
+ * content. Used by the aliased `Icon` pattern (`name: slot({ type:
48
+ * 'component' }).accepts(icons)`), where the render fn receives the icon
49
+ * component itself (`({ name: SvgIcon }) => <SvgIcon … />`) and the saved
50
+ * value is the inline asset-name string (`"Trophy"`), not a `$slot` ref.
51
+ * A `'component'` slot *requires* an asset-group `.accepts(...)` — config
52
+ * load throws otherwise.
53
+ */
54
+ type SlotValueType = 'string' | 'component';
55
+ /**
56
+ * Open-slot marker — `slot()` with no arguments. Codegen treats it as
57
+ * `ReactNode` accepted at the component's own children. Carries no
58
+ * cross-reference; `__accepts` / `__required` may still be set via the
59
+ * chain methods to constrain the slot's children or mark it required.
60
+ * `__valueType` records an explicit `slot({ type })` override (absent ⇒
61
+ * the default `ReactNode`).
62
+ */
63
+ interface SlotMarker {
64
+ readonly __kind: 'slot';
65
+ readonly __required?: boolean;
66
+ readonly __accepts?: readonly SlotAccepts[];
67
+ readonly __valueType?: SlotValueType;
68
+ /**
69
+ * Stamp `__required: true` on the marker. Codegen reads this per-prop
70
+ * and emits the JSX prop without a trailing `?`, so the slot becomes
71
+ * mandatory at call sites. The return type also intersects
72
+ * `RequiredBrand` so `RenderPropsFromConfig` narrows the render-fn
73
+ * destructure entry to non-optional.
74
+ */
75
+ required(): SlotMarker & RequiredBrand;
76
+ /**
77
+ * Constrain the slot's accepted children to one or more registered
78
+ * components, or to a placeable asset group (`slot().accepts(icons)`).
79
+ */
80
+ accepts(component: SlotAccepts | readonly SlotAccepts[]): SlotMarker;
81
+ }
82
+ /**
83
+ * A `slot({ type: 'component' })` marker — the aliased `Icon` pattern. Carries
84
+ * the literal `__valueType: 'component'` so `ResolveMarker` resolves the prop
85
+ * to a `ComponentType` (the render fn receives the icon component itself), and
86
+ * narrows `.accepts(...)` to asset groups only (a component-typed slot must
87
+ * accept an asset group). The chained `.accepts(...)` preserves this type so
88
+ * the literal survives to the render-fn inference.
89
+ */
90
+ interface ComponentSlotMarker extends SlotMarker {
91
+ readonly __valueType: 'component';
92
+ accepts(group: AssetGroupRef | readonly AssetGroupRef[]): ComponentSlotMarker;
93
+ }
94
+ /**
95
+ * Layer-targeting slot ref — `slot('layer')`, `slot('layer/prop')`, or
96
+ * `slot('layer', { prop })`. Routes a JSX prop into the named layer's
97
+ * `layerProp` (defaults to `'children'` when only a layer is given).
98
+ * The `layer` field is the cross-reference — that's what makes this a
99
+ * Ref rather than a Marker.
100
+ */
101
+ interface SlotRef<TLayer extends string = string, TAs extends string = string> {
102
+ readonly __kind: 'slot';
103
+ readonly layer: TLayer;
104
+ readonly layerProp: TAs;
105
+ readonly __required?: boolean;
106
+ readonly __accepts?: readonly SlotAccepts[];
107
+ /** Output adapter set via `.transform(fn)` — codegen wraps the
108
+ * layer's prop so the consumer-facing handler receives `fn(arg)`
109
+ * instead of the raw layer value (e.g. an input event → its
110
+ * string value). Must be self-contained (no closure over outer
111
+ * scope) since codegen lifts it into the generated module. */
112
+ readonly __transform?: (arg: never) => unknown;
113
+ readonly __valueType?: SlotValueType;
114
+ required(): SlotRef<TLayer, TAs> & RequiredBrand;
115
+ accepts(component: SlotAccepts | readonly SlotAccepts[]): SlotRef<TLayer, TAs>;
116
+ transform<Out>(fn: (arg: unknown) => Out): SlotRef<TLayer, TAs> & {
117
+ readonly __transformOut: Out;
118
+ };
119
+ }
120
+ /**
121
+ * Runtime guard for any slot binding (open marker or layered ref).
122
+ * Callers that need to distinguish the two forms narrow further by
123
+ * checking for the `layer` field — `'layer' in value`.
124
+ */
125
+ declare function isSlotMarker(value: unknown): value is SlotMarker | SlotRef;
126
+ interface BooleanMarker {
127
+ readonly __kind: 'boolean';
128
+ readonly __required?: boolean;
129
+ readonly values?: {
130
+ true?: Record<string, Record<string, unknown>>;
131
+ false?: Record<string, Record<string, unknown>>;
132
+ };
133
+ }
134
+ declare function isBoolMarker(value: unknown): value is BooleanMarker;
135
+ interface VariantMarkerObject<V extends Record<string, Record<string, unknown>> = Record<string, Record<string, unknown>>> {
136
+ readonly __kind: 'variant';
137
+ readonly __required?: boolean;
138
+ readonly values: V;
139
+ readonly default?: keyof V & string;
140
+ }
141
+ interface VariantMarkerArray<V extends readonly (string | number)[] = readonly (string | number)[]> {
142
+ readonly __kind: 'variant';
143
+ readonly __required?: boolean;
144
+ readonly values: V;
145
+ readonly default?: V[number];
146
+ }
147
+ type VariantMarker<V = unknown> = V extends readonly (string | number)[] ? VariantMarkerArray<V> : V extends Record<string, Record<string, unknown>> ? VariantMarkerObject<V> : VariantMarkerObject | VariantMarkerArray;
148
+ declare function isVariantMarker(value: unknown): value is VariantMarker;
149
+ /**
150
+ * Distinguish the two variant forms. `Array.isArray(marker.values)` is the
151
+ * single source of truth — every downstream consumer that branches on
152
+ * the form goes through this helper rather than duplicating the check.
153
+ */
154
+ declare function isVariantArrayMarker(value: VariantMarker): value is VariantMarkerArray;
155
+ interface StringMarker {
156
+ readonly __kind: 'string';
157
+ readonly __required?: boolean;
158
+ }
159
+ interface NumberMarker {
160
+ readonly __kind: 'number';
161
+ readonly __required?: boolean;
162
+ }
163
+ declare function isStringMarker(value: unknown): value is StringMarker;
164
+ declare function isNumberMarker(value: unknown): value is NumberMarker;
165
+ interface LayerMarker {
166
+ readonly __kind: 'layer';
167
+ readonly layer: string;
168
+ readonly styles: Record<string, unknown>;
169
+ }
170
+ declare function isLayerMarker(value: unknown): value is LayerMarker;
171
+ /**
172
+ * One conditional override for a `props` axis: apply `props` to the cell
173
+ * when every key in `when` matches the cell's other-axis values. A rule
174
+ * with no `when` always applies (the base). Later matching rules win.
175
+ */
176
+ interface PreviewPropsRule {
177
+ readonly when?: Readonly<Record<string, unknown>>;
178
+ readonly props: Readonly<Record<string, unknown>>;
179
+ }
180
+ /**
181
+ * Synthetic discriminator state a `props` axis compiles to, per axis side.
182
+ * The entry's label is the value. Codegen keys the merged spec's `$cond`
183
+ * on this, and the studio seeds it per cell — both derive it here so they
184
+ * never drift. (`columns`/`rows` entries are concatenated as sibling
185
+ * values of one dimension, so one key per side suffices.)
186
+ */
187
+ declare const PREVIEW_SEED_KEY: {
188
+ readonly row: "__previewSeedRow";
189
+ readonly column: "__previewSeedCol";
190
+ };
191
+ /** True when every key in `when` equals the cell coordinate's value. */
192
+ declare function matchesPreviewWhen(when: Readonly<Record<string, unknown>> | undefined, coord: Readonly<Record<string, unknown>>): boolean;
193
+ /**
194
+ * Merge the `props` of every rule whose `when` matches `coord` (in order,
195
+ * so later matching rules win). Shared by codegen's combo enumeration and
196
+ * the studio's cell assembly so a `props` axis resolves identically.
197
+ */
198
+ declare function resolvePreviewRules(rules: readonly PreviewPropsRule[], coord: Readonly<Record<string, unknown>>): Record<string, unknown>;
199
+ interface PreviewAxisMarker {
200
+ readonly __kind: 'previewAxis';
201
+ /** Axis name — either a prop name or a `_${string}` modifier. */
202
+ readonly prop?: string;
203
+ readonly modifier?: string;
204
+ /**
205
+ * `props` axis rules — per-cell prop-override bags, optionally guarded
206
+ * by `when` against the other axes' values. Lets a preview vary
207
+ * render-extra data per cell (e.g. sample `value`) without declaring a
208
+ * config prop. Resolved against the cell coordinate by the studio and
209
+ * by codegen's combo enumeration.
210
+ */
211
+ readonly rules?: readonly PreviewPropsRule[];
212
+ readonly kind: 'prop' | 'modifier' | 'props';
213
+ readonly nested?: PreviewAxisMarker;
214
+ nest(child: PreviewAxisMarker): PreviewAxisMarker;
215
+ }
216
+ declare function isPreviewAxisMarker(value: unknown): value is PreviewAxisMarker; //#endregion
217
+ //#endregion
218
+ export { BooleanMarker, ComponentSlotMarker, LayerMarker, NumberMarker, PREVIEW_SEED_KEY, PreviewAxisMarker, PreviewPropsRule, RequiredBrand, SlotMarker, SlotRef, SlotValueType, StringMarker, VariantMarker, VariantMarkerArray, VariantMarkerObject, isBoolMarker, isLayerMarker, isNumberMarker, isPreviewAxisMarker, isSlotMarker, isStringMarker, isVariantArrayMarker, isVariantMarker, matchesPreviewWhen, resolvePreviewRules };
@@ -0,0 +1,67 @@
1
+ //#region ../config/dist/markers.js
2
+ /**
3
+ * Runtime guard for any slot binding (open marker or layered ref).
4
+ * Callers that need to distinguish the two forms narrow further by
5
+ * checking for the `layer` field — `'layer' in value`.
6
+ */
7
+ function isSlotMarker(value) {
8
+ return typeof value === "object" && value !== null && value.__kind === "slot";
9
+ }
10
+ function isBoolMarker(value) {
11
+ return typeof value === "object" && value !== null && value.__kind === "boolean";
12
+ }
13
+ function isVariantMarker(value) {
14
+ if (typeof value !== "object" || value === null) return false;
15
+ const v = value;
16
+ if (v.__kind !== "variant") return false;
17
+ return Array.isArray(v.values) || typeof v.values === "object";
18
+ }
19
+ /**
20
+ * Distinguish the two variant forms. `Array.isArray(marker.values)` is the
21
+ * single source of truth — every downstream consumer that branches on
22
+ * the form goes through this helper rather than duplicating the check.
23
+ */
24
+ function isVariantArrayMarker(value) {
25
+ return Array.isArray(value.values);
26
+ }
27
+ function isStringMarker(value) {
28
+ return typeof value === "object" && value !== null && value.__kind === "string";
29
+ }
30
+ function isNumberMarker(value) {
31
+ return typeof value === "object" && value !== null && value.__kind === "number";
32
+ }
33
+ function isLayerMarker(value) {
34
+ return typeof value === "object" && value !== null && value.__kind === "layer";
35
+ }
36
+ /**
37
+ * Synthetic discriminator state a `props` axis compiles to, per axis side.
38
+ * The entry's label is the value. Codegen keys the merged spec's `$cond`
39
+ * on this, and the studio seeds it per cell — both derive it here so they
40
+ * never drift. (`columns`/`rows` entries are concatenated as sibling
41
+ * values of one dimension, so one key per side suffices.)
42
+ */
43
+ const PREVIEW_SEED_KEY = {
44
+ row: "__previewSeedRow",
45
+ column: "__previewSeedCol"
46
+ };
47
+ /** True when every key in `when` equals the cell coordinate's value. */
48
+ function matchesPreviewWhen(when, coord) {
49
+ if (!when) return true;
50
+ for (const key of Object.keys(when)) if (coord[key] !== when[key]) return false;
51
+ return true;
52
+ }
53
+ /**
54
+ * Merge the `props` of every rule whose `when` matches `coord` (in order,
55
+ * so later matching rules win). Shared by codegen's combo enumeration and
56
+ * the studio's cell assembly so a `props` axis resolves identically.
57
+ */
58
+ function resolvePreviewRules(rules, coord) {
59
+ const out = {};
60
+ for (const rule of rules) if (matchesPreviewWhen(rule.when, coord)) Object.assign(out, rule.props);
61
+ return out;
62
+ }
63
+ function isPreviewAxisMarker(value) {
64
+ return typeof value === "object" && value !== null && value.__kind === "previewAxis";
65
+ }
66
+ //#endregion
67
+ export { PREVIEW_SEED_KEY, isBoolMarker, isLayerMarker, isNumberMarker, isPreviewAxisMarker, isSlotMarker, isStringMarker, isVariantArrayMarker, isVariantMarker, matchesPreviewWhen, resolvePreviewRules };
@@ -1,85 +1,159 @@
1
- import { TokenMarker } from "./component-config.js";
2
-
3
1
  //#region ../config/dist/refs.d.ts
4
2
  //#region src/refs.d.ts
5
3
  /**
6
- * Resolve a token value to its CSS form. `TokenMarker` from
7
- * `token('ns/name')` becomes `var(--<prefix>-<ns>-<name>)`; string
8
- * literals pass through unchanged.
4
+ * Cross-reference markers the `{ __kind, ref }` shapes that appear in
5
+ * authored values and in the wire format. Each one represents "this
6
+ * position holds a pointer to another resource, not a literal."
9
7
  *
10
- * The CSS variable name follows `defineVars`'s `:root` declaration
11
- * convention: `kebabCase` on the namespace, `safeTokenName` on the
12
- * token name.
13
- */
14
- declare function resolveTokenValue(value: string | TokenMarker, configPrefix: string | undefined): string;
15
- /**
16
- * Object marker emitted by `darken()` / `lighten()` helpers. Codegen
17
- * detects this shape on a per-value basis and resolves the inner
18
- * `$token` to `var(--<prefix>-<ns>-<name>)`, then applies the modifier.
8
+ * Naming:
9
+ *
10
+ * - `<X>Name` — the string-side identifier (`'color/brand'`, `'Box'`).
11
+ * Narrowed when the matching `Registered*` interface is augmented;
12
+ * falls open to `string` otherwise.
13
+ * - `<X>Ref` — the boxed marker shape `{ __kind, ref }` carrying an
14
+ * `<X>Name`. Distinguishes a pointer from a literal at every position
15
+ * that can hold either.
16
+ * - `<x>()` the helper that constructs an `<X>Ref` from an `<X>Name`.
17
+ * - `is<X>Ref(value)` — type guard for use by the resolver and patch
18
+ * system.
19
19
  *
20
- * Authored solely via the `darken` / `lighten` helpers — the object
21
- * shape is internal and not meant to be hand-written. Serializes
22
- * cleanly through JSON.stringify (unlike the legacy inline-string
23
- * modifier syntax which the regex parser flagged as polynomial under
24
- * adversarial input).
20
+ * # Augmented refs
21
+ *
22
+ * The `Registered*` interfaces below are augmentation seams that
23
+ * consumer codegen populates via `declare module '@uds/config' {
24
+ * interface Registered* { ... } }`. When augmented, each ref's `ref`
25
+ * field narrows to only valid references — `token('color/brand')` is OK
26
+ * but `token('color/nope')` is a compile error. When un-augmented (this
27
+ * package's own tests, fresh consumers before first build), the ref
28
+ * accepts any string — codegen narrows it later.
25
29
  */
26
- interface TokenWithModifier {
27
- /** Brace-stripped token ref, e.g. `'bg/brand'`. */
28
- readonly $token: string;
29
- readonly $modifier: {
30
- readonly type: 'darken' | 'lighten'; /** Mix percentage, e.g. `10` → `10%`. */
31
- readonly amount: number;
32
- };
33
- }
30
+ interface RegisteredTokenGroups {}
31
+ interface RegisteredModifiers<T> {}
32
+ interface RegisteredModes {}
33
+ interface RegisteredCompositeStyles {}
34
+ interface RegisteredStyleProps {}
35
+ interface RegisteredComponents {}
36
+ interface RegisteredMotionDefs {}
37
+ interface RegisteredAssetGroups {}
38
+ /** `<groupName>/<tokenName>` for every registered token. */
39
+ type TokenName = [keyof RegisteredTokenGroups] extends [never] ? string : { [G in keyof RegisteredTokenGroups & string]: `${G}/${keyof RegisteredTokenGroups[G] & string}` }[keyof RegisteredTokenGroups & string];
40
+ /** Bare group names — `'color'`, `'spacing'`. */
41
+ type TokenGroupName = [keyof RegisteredTokenGroups] extends [never] ? string : keyof RegisteredTokenGroups & string;
34
42
  /**
35
- * Type-guard: a value is a `TokenWithModifier` marker.
43
+ * Bare composite name (`'elevation'`) or `<name>/<variant>`
44
+ * (`'elevation/1'`).
45
+ *
46
+ * Indexes straight into `['styles']` rather than routing each member
47
+ * through an `extends { styles: infer V } ? … : never` conditional, for
48
+ * the same reason as `ModeName` — same resulting union, but no per-member
49
+ * conditional check + `infer`, and one consistent shape across every
50
+ * `*Name` union.
36
51
  */
37
- declare function isTokenWithModifier(value: unknown): value is TokenWithModifier;
52
+ type CompositeName = [keyof RegisteredCompositeStyles] extends [never] ? `${string}/${string}` : (keyof RegisteredCompositeStyles & string) | { [C in keyof RegisteredCompositeStyles & string]: `${C}/${keyof RegisteredCompositeStyles[C]['styles'] & string}` }[keyof RegisteredCompositeStyles & string];
38
53
  /**
39
- * Resolve a `TokenWithModifier` marker to its CSS value:
40
- * - `darken(N)` → `color-mix(in oklch, var(...), light-dark(black, white) N%)`
41
- * - `lighten(N)` → `color-mix(in oklch, var(...), light-dark(white, black) N%)`
54
+ * `<modeName>/<optionName>` for every registered mode option.
42
55
  *
43
- * Output matches the runtime helpers `darker` / `lighter` in
44
- * `createConfig.ts` byte-for-byte so mechanical conversion of legacy
45
- * callback-form components preserves compiled CSS.
56
+ * Indexes straight into `['options']` rather than routing each member
57
+ * through an `extends { options: infer O } ? … : never` conditional.
58
+ * Both yield the same union, but the indexed access skips a per-member
59
+ * conditional assignability check + `infer`, so it's cheaper for the
60
+ * checker and keeps every `*Name` union on the one shape `TokenName`
61
+ * uses.
46
62
  */
47
- declare function resolveTokenWithModifier(marker: TokenWithModifier, configPrefix: string | undefined): string;
63
+ type ModeName = [keyof RegisteredModes] extends [never] ? `${string}/${string}` : { [M in keyof RegisteredModes & string]: `${M}/${keyof RegisteredModes[M]['options'] & string}` }[keyof RegisteredModes & string];
64
+ /** Style-prop names — `'bg'`, `'padding'`. */
65
+ type StylePropName = [keyof RegisteredStyleProps] extends [never] ? string : keyof RegisteredStyleProps & string;
66
+ /** Registered component names — `'Box'`, `'Alert'`. */
67
+ type ComponentName = [keyof RegisteredComponents] extends [never] ? string : keyof RegisteredComponents & string;
68
+ /** Bare asset-group slugs — `'icons'`, `'fonts'`. */
69
+ type AssetGroupName = [keyof RegisteredAssetGroups] extends [never] ? string : keyof RegisteredAssetGroups & string;
70
+ /** HTML tag names — open string for now; could narrow against `keyof JSX.IntrinsicElements`. */
71
+ type TagName = string;
72
+ interface TokenRef<TName extends string = string> {
73
+ readonly __kind: 'token';
74
+ readonly ref: TName;
75
+ }
76
+ interface TokenGroupRef<TName extends string = string> {
77
+ readonly __kind: 'tokenGroup';
78
+ readonly ref: TName;
79
+ }
80
+ interface CompositeRef<TName extends string = string, TLayer extends string | undefined = string | undefined> {
81
+ readonly __kind: 'composite';
82
+ readonly ref: TName;
83
+ /**
84
+ * Layer the marker should land on when used as a `.config()` prop
85
+ * binding (set by `composite(ref).on(layer)`). Absent when the ref
86
+ * is used as a token value, modifier selector, or as a bare prop
87
+ * binding that defaults to the `'root'` layer downstream.
88
+ */
89
+ readonly layer?: TLayer;
90
+ }
91
+ interface ModeRef<TName extends string = string> {
92
+ readonly __kind: 'mode';
93
+ readonly ref: TName;
94
+ }
95
+ interface StylePropRef<TName extends string = string> {
96
+ readonly __kind: 'styleProp';
97
+ readonly ref: TName;
98
+ readonly layer?: string;
99
+ /**
100
+ * Bind the style-prop to a specific layer — `styleProp('bg').on('root')`
101
+ * routes the JSX prop into the named layer instead of the component's
102
+ * own layer. Codegen reads the `layer` field and emits a class on
103
+ * that layer. Mirrors the old `@uds/config` `styleProp().on()` chain.
104
+ */
105
+ on(layer: string): StylePropRef<TName>;
106
+ }
107
+ interface TagRef<TName extends string = string> {
108
+ readonly __kind: 'tag';
109
+ readonly ref: TName;
110
+ }
111
+ interface ComponentRef<TName extends string = string> {
112
+ readonly __kind: 'component';
113
+ readonly ref: TName;
114
+ }
48
115
  /**
49
- * Author-time helper that produces a darkened color-token reference for
50
- * use in component-config style blocks. Takes a `TokenMarker` (from
51
- * `token('ns/name')`) plus a mix amount, and returns a structured
52
- * marker (`{ $token, $modifier }`) that codegen resolves at build
53
- * time to:
54
- *
55
- * color-mix(in oklch, var(--<prefix>-<ns>-<name>),
56
- * light-dark(black, white) <amount>%)
57
- *
58
- * defineComponent
59
- * .layers({ root: 'div' })
60
- * .config(({ enums, token }) => ({
61
- * props: {
62
- * variant: enums({
63
- * brand: {
64
- * root: {
65
- * backgroundColor: token('bg/brand'),
66
- * _hover: { backgroundColor: darken(token('bg/brand'), 10) },
67
- * },
68
- * },
69
- * }),
70
- * },
71
- * }));
72
- *
73
- * The token reference stays portable across configs with different
74
- * prefixes because the prefix is supplied at codegen time, not at
75
- * author time.
116
+ * Asset-group pointer. The same `{ __kind, ref }` tag is *embedded* on
117
+ * the full group definition `defineAssetGroup(...)` returns (the
118
+ * definition object doubles as its own ref), so `isAssetGroupRef()` accepts
119
+ * both the bare marker and the live group object. The definition's
120
+ * `ref` is late-bound at `registerAssetGroups` and throws when read
121
+ * before registration; the guard only inspects `__kind`, so it is safe
122
+ * on unregistered groups.
76
123
  */
77
- declare function darken(ref: TokenMarker, amount: number): TokenWithModifier;
124
+ interface AssetGroupRef<TName extends string = string> {
125
+ readonly __kind: 'assetGroup';
126
+ readonly ref: TName;
127
+ }
128
+ type AnyRef = TokenRef | TokenGroupRef | CompositeRef | ModeRef | StylePropRef | TagRef | ComponentRef | AssetGroupRef;
129
+ /** Doc-alignment alias kept for ergonomic import. */
130
+ type TokenQualifiedName = TokenName;
131
+ declare function token<TName extends TokenName>(ref: TName): TokenRef<TName>;
132
+ declare function tokenGroup<TName extends TokenGroupName>(ref: TName): TokenGroupRef<TName>;
78
133
  /**
79
- * Author-time helper that produces a lightened color-token reference.
80
- * Mirror of `darken()` see its JSDoc. Resolves at codegen time to
81
- * `color-mix(in oklch, var(--<prefix>-<ns>-<name>), light-dark(white, black) N%)`.
134
+ * `composite(ref)` returns a bare `CompositeRef` plus an `.on(layer)`
135
+ * method that produces the same shape with `layer` filled in both
136
+ * forms are `CompositeRef`. Codegen's marker probe in
137
+ * `transformAuthoringSource.ts` reads `{ __kind, ref, layer? }`
138
+ * uniformly, so the on-layer marker is just a `CompositeRef` with a
139
+ * concrete `layer` field.
82
140
  */
83
- declare function lighten(ref: TokenMarker, amount: number): TokenWithModifier; //#endregion
141
+ interface CompositeRefBuilder<TName extends string> extends CompositeRef<TName, undefined> {
142
+ on<TLayer extends string>(layer: TLayer): CompositeRef<TName, TLayer>;
143
+ }
144
+ declare function composite<TName extends CompositeName>(ref: TName): CompositeRefBuilder<TName>;
145
+ declare function mode<TName extends ModeName>(ref: TName): ModeRef<TName>;
146
+ declare function styleProp<TName extends StylePropName>(ref: TName): StylePropRef<TName>;
147
+ declare function tag<TName extends TagName>(ref: TName): TagRef<TName>;
148
+ declare function component<TName extends ComponentName>(ref: TName): ComponentRef<TName>;
149
+ declare function assetGroup<TName extends AssetGroupName>(ref: TName): AssetGroupRef<TName>;
150
+ declare function isTokenRef(value: unknown): value is TokenRef;
151
+ declare function isTokenGroupRef(value: unknown): value is TokenGroupRef;
152
+ declare function isCompositeRef(value: unknown): value is CompositeRef;
153
+ declare function isModeRef(value: unknown): value is ModeRef;
154
+ declare function isStylePropRef(value: unknown): value is StylePropRef;
155
+ declare function isTagRef(value: unknown): value is TagRef;
156
+ declare function isComponentRef(value: unknown): value is ComponentRef;
157
+ declare function isAssetGroupRef(value: unknown): value is AssetGroupRef; //#endregion
84
158
  //#endregion
85
- export { TokenWithModifier, darken, isTokenWithModifier, lighten, resolveTokenValue, resolveTokenWithModifier };
159
+ export { AnyRef, AssetGroupName, AssetGroupRef, ComponentName, ComponentRef, CompositeName, CompositeRef, CompositeRefBuilder, ModeName, ModeRef, RegisteredAssetGroups, RegisteredComponents, RegisteredCompositeStyles, RegisteredModes, RegisteredModifiers, RegisteredMotionDefs, RegisteredStyleProps, RegisteredTokenGroups, StylePropName, StylePropRef, TagName, TagRef, TokenGroupName, TokenGroupRef, TokenName, TokenQualifiedName, TokenRef, assetGroup, component, composite, isAssetGroupRef, isComponentRef, isCompositeRef, isModeRef, isStylePropRef, isTagRef, isTokenGroupRef, isTokenRef, mode, styleProp, tag, token, tokenGroup };