@animus-ui/system 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -6
- package/dist/SystemBuilder.d.ts +168 -6
- package/dist/SystemBuilder.d.ts.map +1 -1
- package/dist/asset.d.ts +25 -0
- package/dist/asset.d.ts.map +1 -0
- package/dist/groups/index.js +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +858 -148
- package/dist/selectors.d.ts +5 -1
- package/dist/selectors.d.ts.map +1 -1
- package/dist/{size-CusLCguT.js → size-CDBRRzkb.js} +35 -8
- package/dist/theme/createTheme.d.ts +125 -13
- package/dist/theme/createTheme.d.ts.map +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/resolveReferences.d.ts +49 -0
- package/dist/theme/resolveReferences.d.ts.map +1 -0
- package/dist/transforms/createTransform.d.ts +22 -0
- package/dist/transforms/createTransform.d.ts.map +1 -1
- package/dist/types/theme.d.ts +28 -4
- package/dist/types/theme.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/selectors.d.ts
CHANGED
|
@@ -45,7 +45,11 @@ export declare const BUILT_IN_SELECTORS: SelectorAliasMap;
|
|
|
45
45
|
/**
|
|
46
46
|
* Merge user-provided selectors with built-in defaults.
|
|
47
47
|
* User selectors override built-in aliases of the same name.
|
|
48
|
-
* New aliases
|
|
48
|
+
* New aliases allocate orders CONTINUING from the highest existing order
|
|
49
|
+
* (floored at 490, so the first user alias lands at 500) rather than
|
|
50
|
+
* restarting at 500 each call (mirrors `mergeConditions`) — aliases from
|
|
51
|
+
* successive `.addSelectors()`/`extend()` merges must not collide on
|
|
52
|
+
* order 500.
|
|
49
53
|
*/
|
|
50
54
|
export declare function mergeSelectors(base: SelectorAliasMap, custom: Record<string, string>): SelectorAliasMap;
|
|
51
55
|
/** Get the sorted alias keys for deterministic cascade ordering. */
|
package/dist/selectors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,SAAS;CAAG;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAyDhC,CAAC;AAEF
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../src/selectors.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,WAAW,aAAa;IAC5B,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE7D;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,MAAM,WAAW,SAAS;CAAG;AAE7B;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,gBAyDhC,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,gBAAgB,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,gBAAgB,CAmBlB;AAED,oEAAoE;AACpE,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,GAAG,MAAM,EAAE,CAElE;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,gBAAgB,GAAG;IAC3D,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB,CAOA"}
|
|
@@ -1,15 +1,42 @@
|
|
|
1
|
-
//#region src/scales/createScale.ts
|
|
2
|
-
const createScale = () => [];
|
|
3
|
-
const numericScale = [];
|
|
4
|
-
const stringScale = [];
|
|
5
|
-
const numericOrStringScale = [];
|
|
6
|
-
//#endregion
|
|
7
1
|
//#region src/transforms/createTransform.ts
|
|
8
2
|
function createTransform(name, fn) {
|
|
9
3
|
const wrapper = (value, property, props) => fn(value, property, props);
|
|
10
4
|
Object.defineProperty(wrapper, "name", { value: name });
|
|
11
|
-
|
|
5
|
+
const inherited = fn.transformSource;
|
|
6
|
+
return Object.assign(wrapper, {
|
|
7
|
+
transformName: name,
|
|
8
|
+
transformSource: inherited ?? fn.toString()
|
|
9
|
+
});
|
|
12
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Cross-system transform equality (design D12): identity fast path, then —
|
|
13
|
+
* when both carry `transformName` — equal names AND equal captured
|
|
14
|
+
* `transformSource`. A name match with the captured source missing on either
|
|
15
|
+
* side is a loud conflict (older-instance safety), as is a named/bare mix.
|
|
16
|
+
* Bare-function pairs compare by their own `toString()` (their body IS their
|
|
17
|
+
* source; only `createTransform` wrappers hide it). Known accepted residual:
|
|
18
|
+
* two functions with byte-identical source can close over different values
|
|
19
|
+
* and would coalesce — the loud-conflict alternative (identity-only) was
|
|
20
|
+
* measured to false-conflict every transform-bearing prop under duplicate
|
|
21
|
+
* module instances (inc-01 spike) and to forbid re-registering kit props.
|
|
22
|
+
*/
|
|
23
|
+
function areTransformsEqual(a, b) {
|
|
24
|
+
if (a === b) return true;
|
|
25
|
+
if (a === void 0 || b === void 0) return false;
|
|
26
|
+
const aNamed = a;
|
|
27
|
+
const bNamed = b;
|
|
28
|
+
const aName = aNamed.transformName;
|
|
29
|
+
const bName = bNamed.transformName;
|
|
30
|
+
if (aName !== void 0 && bName !== void 0) return aName === bName && aNamed.transformSource !== void 0 && aNamed.transformSource === bNamed.transformSource;
|
|
31
|
+
if (aName === void 0 && bName === void 0) return a.toString() === b.toString();
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/scales/createScale.ts
|
|
36
|
+
const createScale = () => [];
|
|
37
|
+
const numericScale = [];
|
|
38
|
+
const stringScale = [];
|
|
39
|
+
const numericOrStringScale = [];
|
|
13
40
|
//#endregion
|
|
14
41
|
//#region src/transforms/border.ts
|
|
15
42
|
/**
|
|
@@ -94,4 +121,4 @@ const size = createTransform("size", (value) => {
|
|
|
94
121
|
return !unit ? toSize(numericValue) : `${numericValue}${unit}`;
|
|
95
122
|
});
|
|
96
123
|
//#endregion
|
|
97
|
-
export { borderShorthand as a,
|
|
124
|
+
export { borderShorthand as a, numericScale as c, createTransform as d, gridItemRatio as i, stringScale as l, size as n, createScale as o, gridItem as r, numericOrStringScale as s, percentageOrAbsolute as t, areTransformsEqual as u };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { ColorModeOptions, ContextualVarRegistration, CSSColorValue, ModeAliasDefinition, SerializedTheme, ThemeCssFragment, ThemeManifest, TokenDefinition } from '../types/theme';
|
|
1
|
+
import { ColorModeOptions, ContextualVarRegistration, CSSColorValue, ModeAliasDefinition, SerializedTheme, ThemeCssFragment, ThemeManifest, ThemeStructuralKey, TokenDefinition } from '../types/theme';
|
|
2
2
|
import { LiteralPaths } from './flattenScale';
|
|
3
3
|
/** Flatten a type to prevent MergeTheme depth accumulation (TS2589). Exported for use in consumer themes. */
|
|
4
4
|
export type Flatten<T> = {
|
|
5
5
|
[K in keyof T]: T[K];
|
|
6
6
|
};
|
|
7
|
+
/** Right-biased object merge used where runtime composition is also right-biased. */
|
|
8
|
+
type MergeRecord<Base, Incoming> = Omit<Base, keyof Incoming> & Incoming;
|
|
7
9
|
/**
|
|
8
10
|
* The union of contextual var NAMES declared across all scales in a
|
|
9
11
|
* `declareContextualVars` config. Read only for the optional registration
|
|
@@ -13,6 +15,7 @@ export type Flatten<T> = {
|
|
|
13
15
|
type ContextualVarNames<Vars> = {
|
|
14
16
|
[K in keyof Vars]: Vars[K] extends readonly (infer N extends string)[] ? N : never;
|
|
15
17
|
}[keyof Vars];
|
|
18
|
+
type ThemeScaleKeys<T> = Exclude<keyof T & string, ThemeStructuralKey>;
|
|
16
19
|
/** The built theme: nested raw data + non-enumerable boundary methods */
|
|
17
20
|
type BuiltTheme<T, Emitted extends string> = {
|
|
18
21
|
[K in keyof T]: T[K];
|
|
@@ -35,6 +38,7 @@ type BuiltTheme<T, Emitted extends string> = {
|
|
|
35
38
|
*/
|
|
36
39
|
interface CarriedManifestV2 {
|
|
37
40
|
tokenDefinitions?: Record<string, TokenDefinition>;
|
|
41
|
+
emittedScales?: string[];
|
|
38
42
|
modeAliasDefinitions?: ModeAliasDefinition;
|
|
39
43
|
registrations?: Record<string, ContextualVarRegistration>;
|
|
40
44
|
emitterVersion?: number;
|
|
@@ -63,31 +67,139 @@ interface BuilderState {
|
|
|
63
67
|
* `createThemeVariants` rejection keys off exactly that absence.
|
|
64
68
|
*/
|
|
65
69
|
hasLegacyManifestSource: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Per-leaf-path provenance of `extend()` sources: flattened dot-path →
|
|
72
|
+
* 1-based index of the extend call that first defined it (D3/G4 — sibling
|
|
73
|
+
* conflicts error naming both sources positionally; positional labels are
|
|
74
|
+
* the accepted form until DEF-4's provenance artifact).
|
|
75
|
+
*/
|
|
76
|
+
extendProvenance: Map<string, number>;
|
|
77
|
+
/** Number of `extend()` calls made so far — the next source's label index. */
|
|
78
|
+
extendCount: number;
|
|
79
|
+
/**
|
|
80
|
+
* Mode names carried in by `extend()` sources (D6). Inherited modes are
|
|
81
|
+
* EXEMPT from the coverage gate — a kit's own alias asymmetry is
|
|
82
|
+
* pre-existing behavior, not consumer breakage, and must round-trip.
|
|
83
|
+
*/
|
|
84
|
+
inheritedModes: Set<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Alias dot-paths declared by any extended source's modes (D6). A
|
|
87
|
+
* consumer-declared mode leaving any of these uncovered needs a `basedOn`
|
|
88
|
+
* entry or the build fails listing the uncovered set.
|
|
89
|
+
*/
|
|
90
|
+
inheritedModeAliases: Set<string>;
|
|
91
|
+
/**
|
|
92
|
+
* Token paths dropped by an explicit `addScale({ replace: true })` →
|
|
93
|
+
* replaced scale name (D5). Consulted at `build()`: a reference whose
|
|
94
|
+
* target is absent from the merged map AND present here is a hard error;
|
|
95
|
+
* a later re-add simply makes the target known again.
|
|
96
|
+
*/
|
|
97
|
+
droppedTokenPaths: Map<string, string>;
|
|
66
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* What `from()` actually inherits from its argument: a library bundle
|
|
101
|
+
* contributes its theme half — `theme ?? tokens` (D9 naming; `tokens`
|
|
102
|
+
* accepted until DEF-8 resolves) — anything else is treated as a built
|
|
103
|
+
* theme and contributes itself. Mirrors the runtime bundle detection inside
|
|
104
|
+
* `from()`.
|
|
105
|
+
*/
|
|
106
|
+
type ThemeSourceOf<Source> = Source extends {
|
|
107
|
+
system: {
|
|
108
|
+
toConfig(...args: never[]): unknown;
|
|
109
|
+
};
|
|
110
|
+
theme?: infer ThemeHalf;
|
|
111
|
+
tokens?: infer TokensHalf;
|
|
112
|
+
} ? ThemeHalf extends Record<string, unknown> ? ThemeHalf : TokensHalf extends Record<string, unknown> ? TokensHalf : Record<never, never> : Source;
|
|
113
|
+
type ThemeBoundaryKey = '__emitted' | 'manifest' | 'serialize' | 'varRef';
|
|
114
|
+
/** Runtime composition copies enumerable data and deliberately skips methods. */
|
|
115
|
+
type ThemeDataOf<Source> = {
|
|
116
|
+
[Key in keyof Source as Key extends ThemeBoundaryKey ? never : Extract<Source[Key], (...args: never[]) => unknown> extends never ? Key : never]: Source[Key];
|
|
117
|
+
};
|
|
118
|
+
type MergeThemeData<Base, Source> = Flatten<MergeRecord<Base, ThemeDataOf<Source>>>;
|
|
119
|
+
/** Preserve the built source's exact emitted-scale phantom without exposing it as data. */
|
|
120
|
+
type EmittedThemeScalesOf<Source> = Source extends {
|
|
121
|
+
readonly __emitted: [infer Emitted extends string];
|
|
122
|
+
} ? Emitted : never;
|
|
123
|
+
/**
|
|
124
|
+
* What `extend()` inherits from its argument: a library bundle contributes
|
|
125
|
+
* its THEME half — `theme ?? tokens` (D9 naming; `tokens` accepted until
|
|
126
|
+
* DEF-8 resolves) — anything else is treated as a built theme and
|
|
127
|
+
* contributes itself. Mirrors the runtime bundle-half resolution inside
|
|
128
|
+
* `extend()`.
|
|
129
|
+
*/
|
|
130
|
+
type ExtendedThemeSourceOf<Source> = Source extends {
|
|
131
|
+
system: {
|
|
132
|
+
toConfig(...args: never[]): unknown;
|
|
133
|
+
};
|
|
134
|
+
theme?: infer ThemeHalf;
|
|
135
|
+
tokens?: infer TokensHalf;
|
|
136
|
+
} ? ThemeHalf extends Record<string, unknown> ? ThemeHalf : TokensHalf extends Record<string, unknown> ? TokensHalf : Record<never, never> : Source;
|
|
137
|
+
declare const THEME_STAGE_BRAND: unique symbol;
|
|
138
|
+
/**
|
|
139
|
+
* Builder type-state for the inherit-first rule (D2), mirroring the system
|
|
140
|
+
* builder's `SystemBuilderStage`: `extend()` is only callable while the
|
|
141
|
+
* builder is in the `'inherit'` stage; every augmentation method advances to
|
|
142
|
+
* `'extend'`, making "inherit first, then extend" a compile error rather
|
|
143
|
+
* than a lint. `from()` is deliberately NOT stage-gated — its call-anywhere
|
|
144
|
+
* semantics are frozen for the deprecation window, so it passes the stage
|
|
145
|
+
* through unchanged. Phantom — never present at runtime.
|
|
146
|
+
*/
|
|
147
|
+
export type ThemeBuilderStage = 'inherit' | 'extend';
|
|
67
148
|
/**
|
|
68
149
|
* ThemeScales — the final phase. Has addScale, extendScale, declareContextualVars, build.
|
|
69
150
|
* Also allows addColors and addColorModes for augmentation.
|
|
70
151
|
*/
|
|
71
|
-
export declare class ThemeBuilder<T extends Record<string, unknown> = Record<string, unknown>, Emitted extends string = never> {
|
|
152
|
+
export declare class ThemeBuilder<T extends Record<string, unknown> = Record<string, unknown>, Emitted extends string = never, Stage extends ThemeBuilderStage = 'inherit'> {
|
|
153
|
+
readonly [THEME_STAGE_BRAND]?: Stage;
|
|
72
154
|
/** @internal */ _state: BuilderState;
|
|
73
155
|
constructor(state: BuilderState);
|
|
74
|
-
addBreakpoints<BP extends Record<string, number>>(breakpoints: BP): ThemeBuilder<{ [K in keyof (Omit<T, "breakpoints"> & Record<"breakpoints", { [K in keyof BP]: BP[K]; }>)]: (Omit<T, "breakpoints"> & Record<"breakpoints", { [K in keyof BP]: BP[K]; }>)[K]; }, Emitted>;
|
|
75
|
-
|
|
76
|
-
|
|
156
|
+
addBreakpoints<BP extends Record<string, number>>(breakpoints: BP): ThemeBuilder<{ [K in keyof (Omit<T, "breakpoints"> & Record<"breakpoints", { [K in keyof BP]: BP[K]; }>)]: (Omit<T, "breakpoints"> & Record<"breakpoints", { [K in keyof BP]: BP[K]; }>)[K]; }, Emitted, "extend">;
|
|
157
|
+
/**
|
|
158
|
+
* FROZEN for the deprecation window (D1/G6): source-WINS precedence over
|
|
159
|
+
* prior builder state, callable at ANY stage — the phantom Stage passes
|
|
160
|
+
* through unchanged. Do not add a stage gate; do not flip the merge
|
|
161
|
+
* direction. Those semantics ship under the new verb only.
|
|
162
|
+
*
|
|
163
|
+
* @deprecated Use `extend(source)` — the single extension verb on both
|
|
164
|
+
* builders: the extended source seeds the base and later local calls win.
|
|
165
|
+
* `from()` keeps these frozen source-wins semantics for at least one minor
|
|
166
|
+
* release after `extend()` ships.
|
|
167
|
+
*/
|
|
168
|
+
from<Source extends object>(builtTheme: Source): ThemeBuilder<Flatten<MergeRecord<T, ThemeDataOf<ThemeSourceOf<Source>>>>, Emitted | EmittedThemeScalesOf<ThemeSourceOf<Source>>, Stage>;
|
|
169
|
+
/**
|
|
170
|
+
* Extend this theme from a consumed library (D1/D2): the source's complete
|
|
171
|
+
* configuration — tokens, modes, preferences, registrations, emitted-scale
|
|
172
|
+
* set — seeds the builder as the BASE, and local calls made after
|
|
173
|
+
* `extend()` win on conflict (the mirror of `from()`'s source-wins).
|
|
174
|
+
* Chainable and repeatable, but only before augmentation methods ("inherit
|
|
175
|
+
* first, then extend" — enforced by the phantom builder stage). Accepts a
|
|
176
|
+
* built theme or a library bundle, consuming the bundle's theme half
|
|
177
|
+
* (`theme ?? tokens`, D9) and ignoring the rest.
|
|
178
|
+
*
|
|
179
|
+
* Sibling conflicts fail loud (D3/G4): a leaf path defined divergently by
|
|
180
|
+
* two extended sources throws naming the path and both sources
|
|
181
|
+
* positionally; equal values coalesce silently, and the consumer's own
|
|
182
|
+
* post-extend `add*` calls override silently (NS-4).
|
|
183
|
+
*/
|
|
184
|
+
extend<Source extends object>(this: ThemeBuilder<T, Emitted, 'inherit'>, source: Source): ThemeBuilder<MergeThemeData<T, ExtendedThemeSourceOf<Source>>, Emitted | EmittedThemeScalesOf<ExtendedThemeSourceOf<Source>>, 'inherit'>;
|
|
185
|
+
addColors<Colors extends Record<string, CSSColorValue | Record<string, CSSColorValue>>, NextColors extends LiteralPaths<Colors, '.'> = LiteralPaths<Colors, '.'>>(colors: Colors): ThemeBuilder<Flatten<Omit<T, "colors"> & Record<"colors", Flatten<MergeRecord<T extends {
|
|
186
|
+
colors: infer Existing;
|
|
187
|
+
} ? Existing : {}, NextColors>>>>, "colors" | Emitted, "extend">;
|
|
77
188
|
addColorModes<Config extends Record<string, Record<string, unknown>>, AliasKeys extends LiteralPaths<Config[keyof Config], '.', '_'> = LiteralPaths<Config[keyof Config], '.', '_'>>(initialMode: string, modeConfig: Config, options?: ColorModeOptions<Config>): ThemeBuilder<{ [K in keyof (Omit<T, "colors"> & Record<"colors", (T extends {
|
|
78
189
|
colors: infer C;
|
|
79
190
|
} ? C : unknown) & AliasKeys>)]: (Omit<T, "colors"> & Record<"colors", (T extends {
|
|
80
191
|
colors: infer C;
|
|
81
|
-
} ? C : unknown) & AliasKeys>)[K]; }, Emitted>;
|
|
82
|
-
addScale<Key extends string, Values extends Record<string | number, string | number | Record<string, string | number>>, Emit extends boolean = false, NewScale extends LiteralPaths<Values, '.'> = LiteralPaths<Values, '.'>>(config: {
|
|
83
|
-
name: Key;
|
|
192
|
+
} ? C : unknown) & AliasKeys>)[K]; }, Emitted, "extend">;
|
|
193
|
+
addScale<Key extends string, Values extends Record<string | number, string | number | Record<string, string | number>>, Emit extends boolean = false, Replace extends boolean = false, NewScale extends LiteralPaths<Values, '.'> = LiteralPaths<Values, '.'>>(config: {
|
|
194
|
+
name: Key & (Key extends ThemeStructuralKey ? never : unknown);
|
|
84
195
|
values: Values;
|
|
85
196
|
emit?: Emit;
|
|
86
|
-
|
|
197
|
+
replace?: Replace;
|
|
198
|
+
}): ThemeBuilder<Flatten<Omit<T, Key> & Record<Key, Replace extends true ? NewScale : Flatten<MergeRecord<Key extends keyof T ? T[Key] : {}, NewScale>>>>, Emit extends true ? Emitted | Key : Emitted, "extend">;
|
|
87
199
|
declareContextualVars<const Vars extends Partial<{
|
|
88
|
-
[K in
|
|
89
|
-
}>>(vars: Vars, registrations?: Partial<Record<ContextualVarNames<Vars>, ContextualVarRegistration>>): ThemeBuilder<{ [K in keyof T]: K extends keyof Vars ? Vars[K] extends readonly string[] ? T[K] & Record<Vars[K][number], `var(--${string})`> : T[K] : T[K]; }, Emitted>;
|
|
90
|
-
extendScale<Key extends keyof T, Fn extends (tokens: T[Key]) => Record<string | number, unknown>>(key: Key, updateFn: Fn): ThemeBuilder<
|
|
200
|
+
[K in ThemeScaleKeys<T>]: readonly string[];
|
|
201
|
+
}>>(vars: Vars & Record<Exclude<keyof Vars, ThemeScaleKeys<T>>, never>, registrations?: Partial<Record<ContextualVarNames<Vars>, ContextualVarRegistration>>): ThemeBuilder<{ [K in keyof T]: K extends keyof Vars ? Vars[K] extends readonly string[] ? T[K] & Record<Vars[K][number], `var(--${string})`> : T[K] : T[K]; }, Emitted, "extend">;
|
|
202
|
+
extendScale<Key extends Exclude<keyof T, ThemeStructuralKey>, Fn extends (tokens: T[Key]) => Record<string | number, unknown>>(key: Key, updateFn: Fn): ThemeBuilder<Flatten<Omit<T, Key> & Record<Key, Flatten<MergeRecord<T[Key], ReturnType<Fn>>>>>, Emitted, "extend">;
|
|
91
203
|
/**
|
|
92
204
|
* Finalize the theme build.
|
|
93
205
|
* Flattens nested data at the boundary — produces manifest and serialize().
|
|
@@ -97,6 +209,6 @@ export declare class ThemeBuilder<T extends Record<string, unknown> = Record<str
|
|
|
97
209
|
type EmptyTheme = {
|
|
98
210
|
breakpoints: Record<string, number>;
|
|
99
211
|
};
|
|
100
|
-
export declare function createTheme(): ThemeBuilder<EmptyTheme, never>;
|
|
212
|
+
export declare function createTheme(): ThemeBuilder<EmptyTheme, never, "inherit">;
|
|
101
213
|
export {};
|
|
102
214
|
//# sourceMappingURL=createTheme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createTheme.d.ts","sourceRoot":"","sources":["../../src/theme/createTheme.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,gBAAgB,EAChB,yBAAyB,EACzB,aAAa,EACb,mBAAmB,EACnB,eAAe,EAEf,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,eAAe,EAEhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuV9C,6GAA6G;AAC7G,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAElD,qFAAqF;AACrF,KAAK,WAAW,CAAC,IAAI,EAAE,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,MAAM,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAEzE;;;;;GAKG;AACH,KAAK,kBAAkB,CAAC,IAA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,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,EAAE,sHASvB;IAED;;;OAGG;IACH,KAAK,IAAI,UAAU,CAAC,CAAC,EAAE,OAAO,CAAC,CA0S9B;CACF;AAED,KAAK,UAAU,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC;AAE1D,wBAAgB,WAAW,+CAE1B"}
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { createTheme, ThemeBuilder } from './createTheme';
|
|
1
|
+
export { createTheme, type Flatten, ThemeBuilder, type ThemeBuilderStage, } from './createTheme';
|
|
2
2
|
export type { FindPath, LiteralPaths, Path, PathToLiteral, PathValue, } from './flattenScale';
|
|
3
3
|
export type { KeyAsVariable, SanitizeKey } from './serializeTokens';
|
|
4
4
|
export type { Assign, AssignValueIfUnmergable, ColorModeConfig, Mergable, Merge, MergeTheme, PrivateThemeKeys, } from './types';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,KAAK,OAAO,EACZ,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,aAAa,EACb,SAAS,GACV,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,YAAY,EACV,MAAM,EACN,uBAAuB,EACvB,eAAe,EACf,QAAQ,EACR,KAAK,EACL,UAAU,EACV,gBAAgB,GACjB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Late-binding token-reference resolution over the flattened theme (D4,
|
|
3
|
+
* openspec change first-class-extension).
|
|
4
|
+
*
|
|
5
|
+
* Replaces the old single-pass, insertion-order-dependent rewrite: references
|
|
6
|
+
* resolve against the COMPLETE flattened map via depth-first traversal of the
|
|
7
|
+
* reference DAG, so declaration order is never observable (G3), references
|
|
8
|
+
* inside emitted scales resolve into the emitted variable declarations
|
|
9
|
+
* instead of leaking literally into CSS (G2), and a token resolves to the
|
|
10
|
+
* same value whether its scale is emitted or inlined (G1 — an emitted target
|
|
11
|
+
* substitutes as `var()`, which the cascade late-binds to exactly the value
|
|
12
|
+
* the inlined form substitutes directly).
|
|
13
|
+
*
|
|
14
|
+
* Pure module: consumes the flatten pass's maps, returns fresh maps, mutates
|
|
15
|
+
* nothing. Runs in QuickJS — ES built-ins only, no Node/WHATWG APIs.
|
|
16
|
+
*/
|
|
17
|
+
export interface ResolvedReferences {
|
|
18
|
+
/**
|
|
19
|
+
* Token path → resolved value: emitted paths keep their `var()`
|
|
20
|
+
* indirection; every other path carries its fully resolved literal.
|
|
21
|
+
* Keys are in sorted token-path order (deterministic serialization).
|
|
22
|
+
*/
|
|
23
|
+
tokenMap: Record<string, string>;
|
|
24
|
+
/**
|
|
25
|
+
* CSS var name → resolved declaration value for every emitted path, in
|
|
26
|
+
* sorted token-path order — `buildVariableCss` emits in iteration order,
|
|
27
|
+
* so reversed-declaration builds produce byte-identical CSS.
|
|
28
|
+
*/
|
|
29
|
+
variables: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Resolve token references over the complete flattened maps.
|
|
33
|
+
*
|
|
34
|
+
* - `tokenMap`/`variableMap`/`variables` are `flattenTheme`'s outputs: an
|
|
35
|
+
* emitted path's tokenMap entry is its `var()` indirection and its RAW
|
|
36
|
+
* authored value is parked in `variables`; a non-emitted path's tokenMap
|
|
37
|
+
* entry IS its raw value.
|
|
38
|
+
* - Substitution per reference: emitted target → `var(--target)`; non-emitted
|
|
39
|
+
* target → its resolved literal; `{path/NN}` keeps the existing
|
|
40
|
+
* `color-mix` output shape (`/0` → `transparent`, `/100` → the base).
|
|
41
|
+
* - Unresolvable target: warn once per missing path, keep the literal — a
|
|
42
|
+
* SUPPORTED pattern (a kit theme may reference tokens its consumer
|
|
43
|
+
* provides later). Dangling-reference errors arrive with the explicit
|
|
44
|
+
* replacement form (D5, increment 04).
|
|
45
|
+
* - Reference cycle: hard error naming the cycle's token paths in traversal
|
|
46
|
+
* order, regardless of emission flags (emission-invariant failure, G1).
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveReferences(tokenMap: Record<string, string>, variableMap: Record<string, string>, variables: Record<string, string>): ResolvedReferences;
|
|
49
|
+
//# sourceMappingURL=resolveReferences.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveReferences.d.ts","sourceRoot":"","sources":["../../src/theme/resolveReferences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAuCH,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC;;;;OAIG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAChC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,kBAAkB,CAiIpB"}
|
|
@@ -3,6 +3,28 @@ import type { CSSObject } from '../types/shared';
|
|
|
3
3
|
export type TransformFn = (value: string | number, property?: string, props?: AbstractProps) => string | number | CSSObject;
|
|
4
4
|
export type NamedTransform = TransformFn & {
|
|
5
5
|
transformName: string;
|
|
6
|
+
/**
|
|
7
|
+
* The user function's source text, captured at creation (design D12).
|
|
8
|
+
* The wrapper's own `toString()` is byte-identical for every transform
|
|
9
|
+
* (the body is closure-captured), so cross-system equality must compare
|
|
10
|
+
* the original source. Optional in the type: instances built by an older
|
|
11
|
+
* @animus-ui/system lack it, and a name match with a missing source is a
|
|
12
|
+
* loud conflict, never a silent coalesce.
|
|
13
|
+
*/
|
|
14
|
+
transformSource?: string;
|
|
6
15
|
};
|
|
7
16
|
export declare function createTransform(name: string, fn: TransformFn): NamedTransform;
|
|
17
|
+
/**
|
|
18
|
+
* Cross-system transform equality (design D12): identity fast path, then —
|
|
19
|
+
* when both carry `transformName` — equal names AND equal captured
|
|
20
|
+
* `transformSource`. A name match with the captured source missing on either
|
|
21
|
+
* side is a loud conflict (older-instance safety), as is a named/bare mix.
|
|
22
|
+
* Bare-function pairs compare by their own `toString()` (their body IS their
|
|
23
|
+
* source; only `createTransform` wrappers hide it). Known accepted residual:
|
|
24
|
+
* two functions with byte-identical source can close over different values
|
|
25
|
+
* and would coalesce — the loud-conflict alternative (identity-only) was
|
|
26
|
+
* measured to false-conflict every transform-bearing prop under duplicate
|
|
27
|
+
* module instances (inc-01 spike) and to forbid re-registering kit props.
|
|
28
|
+
*/
|
|
29
|
+
export declare function areTransformsEqual(a: TransformFn | undefined, b: TransformFn | undefined): boolean;
|
|
8
30
|
//# sourceMappingURL=createTransform.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTransform.d.ts","sourceRoot":"","sources":["../../src/transforms/createTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,aAAa,KAClB,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;
|
|
1
|
+
{"version":3,"file":"createTransform.d.ts","sourceRoot":"","sources":["../../src/transforms/createTransform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,CACxB,KAAK,EAAE,MAAM,GAAG,MAAM,EACtB,QAAQ,CAAC,EAAE,MAAM,EACjB,KAAK,CAAC,EAAE,aAAa,KAClB,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;AAEjC,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG;IACzC,aAAa,EAAE,MAAM,CAAC;IACtB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,WAAW,GAAG,cAAc,CAa7E;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,CAAC,EAAE,WAAW,GAAG,SAAS,EAC1B,CAAC,EAAE,WAAW,GAAG,SAAS,GACzB,OAAO,CAkBT"}
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -8,9 +8,11 @@ export interface AbstractTheme extends BaseTheme {
|
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Filter non-scale keys from T so only user-defined scales appear.
|
|
11
|
-
*
|
|
11
|
+
* Builder/runtime metadata and color-mode options are structural — not token
|
|
12
|
+
* scales.
|
|
12
13
|
*/
|
|
13
|
-
export type
|
|
14
|
+
export type ThemeStructuralKey = 'breakpoints' | 'modes' | 'mode' | 'systemPreference' | 'browserColorScheme' | 'modeBases' | '__emitted' | 'manifest' | 'serialize' | 'varRef';
|
|
15
|
+
export type TokenScales<T> = Omit<T, ThemeStructuralKey>;
|
|
14
16
|
/**
|
|
15
17
|
* Augmentable Theme interface. Consumers extend this via module augmentation
|
|
16
18
|
* to get type-safe scale lookups in .styles(), .variant(), and .states():
|
|
@@ -132,6 +134,20 @@ export interface ColorModeOptions<Config> {
|
|
|
132
134
|
* type applying.
|
|
133
135
|
*/
|
|
134
136
|
browserColorScheme?: Partial<Record<keyof Config & string, 'light' | 'dark' | 'normal'>>;
|
|
137
|
+
/**
|
|
138
|
+
* NEW mode → the declared mode its uncovered INHERITED aliases resolve
|
|
139
|
+
* through (D6, first-class-extension). A consumer-declared mode over an
|
|
140
|
+
* extended theme that leaves inherited aliases uncovered must name a base
|
|
141
|
+
* here — the build fails otherwise, listing the uncovered set; with a
|
|
142
|
+
* base, uncovered aliases resolve through the declared chain and the
|
|
143
|
+
* build reports ONE aggregated inherited-alias count per mode.
|
|
144
|
+
*
|
|
145
|
+
* The base value is a plain `string` (not `keyof Config`) on purpose: the
|
|
146
|
+
* base is typically a mode declared by the EXTENDED source, which this
|
|
147
|
+
* call's local config type cannot see. Runtime validation covers both
|
|
148
|
+
* sides against the merged mode set.
|
|
149
|
+
*/
|
|
150
|
+
basedOn?: Partial<Record<keyof Config & string, string>>;
|
|
135
151
|
}
|
|
136
152
|
/** Pipeline-ready JSON strings returned by `.serialize()` on a built theme. */
|
|
137
153
|
export interface SerializedTheme {
|
|
@@ -146,7 +162,7 @@ export interface SerializedTheme {
|
|
|
146
162
|
}
|
|
147
163
|
/**
|
|
148
164
|
* One authored `{scale.key}` reference occurrence inside a token value
|
|
149
|
-
* (manifest v2, D6). Captured BEFORE `
|
|
165
|
+
* (manifest v2, D6). Captured BEFORE `resolveReferences` rewrites the value —
|
|
150
166
|
* the authored graph is unrecoverable from resolved CSS (D8).
|
|
151
167
|
*/
|
|
152
168
|
export interface TokenReference {
|
|
@@ -202,7 +218,13 @@ export interface ThemeManifest {
|
|
|
202
218
|
tokenMap: Record<string, string>;
|
|
203
219
|
/** Flat token key → CSS variable name without var() wrapper (e.g. 'colors.ember' → '--color-ember') */
|
|
204
220
|
variableMap: Record<string, string>;
|
|
205
|
-
/**
|
|
221
|
+
/**
|
|
222
|
+
* Mode name → flat key → RESOLVED value (e.g. { dark: { 'colors.primary':
|
|
223
|
+
* '#FF2800' } }). Since first-class-extension inc 04 the values pass
|
|
224
|
+
* through the reference resolver (a reference-valued color contributes its
|
|
225
|
+
* resolved value, never a raw `{…}` string), and both mode keys and inner
|
|
226
|
+
* keys are in sorted order (G3).
|
|
227
|
+
*/
|
|
206
228
|
modes: Record<string, Record<string, string>>;
|
|
207
229
|
/** Pre-built CSS string with :root and [data-color-mode] blocks */
|
|
208
230
|
variableCss: string;
|
|
@@ -216,6 +238,8 @@ export interface ThemeManifest {
|
|
|
216
238
|
manifestVersion?: 2;
|
|
217
239
|
/** Authored literal-vs-reference structure per flattened token path. */
|
|
218
240
|
tokenDefinitions?: Record<string, TokenDefinition>;
|
|
241
|
+
/** Exact scale names configured for CSS-variable emission, including empty scales. */
|
|
242
|
+
emittedScales?: string[];
|
|
219
243
|
/** Mode name → alias dot-path → AUTHORED color dot-path (pre-resolution). */
|
|
220
244
|
modeAliasDefinitions?: ModeAliasDefinition;
|
|
221
245
|
/** `@property` registrations by contextual var name, in declaration order. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAE1D,YAAY,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,WAAW,SAAS;CAAG;AAE7B,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CAC7B;AAED
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../src/types/theme.ts"],"names":[],"mappings":"AAA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
|
"description": "Animus design system builder — tokens, prop groups, global styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"css",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"compile": "tsc --noEmit"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@animus-ui/properties": "0.1.
|
|
74
|
+
"@animus-ui/properties": "0.1.4",
|
|
75
75
|
"csstype": "^3.1.3"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|