@weasel-js/theme 1.5.1 → 1.6.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.
- package/README.md +39 -1
- package/dist/chunk-6R3FTRRJ.js +3255 -0
- package/dist/chunk-6R3FTRRJ.js.map +1 -0
- package/dist/chunk-GI7ZAXIB.js +12 -0
- package/dist/chunk-GI7ZAXIB.js.map +1 -0
- package/dist/chunk-QKRFHBRB.js +557 -0
- package/dist/chunk-QKRFHBRB.js.map +1 -0
- package/dist/colorMode-CoklZomJ.d.ts +12 -0
- package/dist/engine.d.ts +84 -16
- package/dist/engine.js +215 -431
- package/dist/engine.js.map +1 -1
- package/dist/faces.css +19 -0
- package/dist/fonts.css +4 -18
- package/dist/index.d.ts +49 -5
- package/dist/index.js +200 -35
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +50 -6
- package/dist/react.js +68 -6
- package/dist/react.js.map +1 -1
- package/dist/themes-bTfTZjCh.d.ts +1299 -0
- package/dist/tokens.css +186 -16
- package/fonts/README.md +5 -6
- package/package.json +4 -3
- package/dist/chunk-LL2ERJPZ.js +0 -175
- package/dist/chunk-LL2ERJPZ.js.map +0 -1
- package/dist/chunk-PJMTWM34.js +0 -6
- package/dist/chunk-PJMTWM34.js.map +0 -1
- package/dist/chunk-YBHW5LZM.js +0 -1582
- package/dist/chunk-YBHW5LZM.js.map +0 -1
- package/dist/resolveTheme-CHnPdh8W.d.ts +0 -266
- package/dist/theme-BtpBHcUg.d.ts +0 -189
package/dist/theme-BtpBHcUg.d.ts
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/** One value of an axis. `scheme` becomes `color-scheme` in that value's CSS blocks. */
|
|
2
|
-
interface AxisValue {
|
|
3
|
-
readonly scheme?: 'dark' | 'light';
|
|
4
|
-
}
|
|
5
|
-
interface AxisDef {
|
|
6
|
-
readonly default: string;
|
|
7
|
-
readonly values: Readonly<Record<string, AxisValue>>;
|
|
8
|
-
}
|
|
9
|
-
/** Key order is declaration order, which selectors and selection keys follow. */
|
|
10
|
-
type AxisDefs = Readonly<Record<string, AxisDef>>;
|
|
11
|
-
/** A partial choice of axis values, e.g. `{ mode: 'light' }`. */
|
|
12
|
-
type Selection = Readonly<Record<string, string>>;
|
|
13
|
-
/** `{ by: 'mode', dark: …, light: … }`: a value that differs per axis value. */
|
|
14
|
-
interface ByAxis<T> {
|
|
15
|
-
readonly by: string;
|
|
16
|
-
readonly [axisValue: string]: Varying<T> | string;
|
|
17
|
-
}
|
|
18
|
-
type Varying<T> = T | ByAxis<T>;
|
|
19
|
-
declare function isByAxis(v: unknown): v is ByAxis<unknown>;
|
|
20
|
-
/** Every axis given a known value; anything missing or unknown takes its default. */
|
|
21
|
-
declare function fullSelection(axes: AxisDefs, selection?: Selection): Selection;
|
|
22
|
-
declare function enumerateSelections(axes: AxisDefs): Selection[];
|
|
23
|
-
/** `mode=dark,density=compact`, axes in declaration order. */
|
|
24
|
-
declare function selectionKey(axes: AxisDefs, selection: Selection): string;
|
|
25
|
-
|
|
26
|
-
type TokenValue = string | number | readonly (string | number)[];
|
|
27
|
-
/**
|
|
28
|
-
* A single design token as authored, before aliases are resolved: a DTCG-shaped
|
|
29
|
-
* `{ type, value }` pair where `value` may still be a `{ref}` to another token.
|
|
30
|
-
*/
|
|
31
|
-
interface RawToken {
|
|
32
|
-
readonly type: string;
|
|
33
|
-
readonly value: TokenValue;
|
|
34
|
-
/** Render the referenced color at this alpha, 0–1. */
|
|
35
|
-
readonly alpha?: number | undefined;
|
|
36
|
-
readonly description?: string | undefined;
|
|
37
|
-
}
|
|
38
|
-
/** A token graph flattened to one level, keyed by token name (no `--wzl-`
|
|
39
|
-
* prefix). Still unresolved — see `ResolvedTokenMap` for the output side. */
|
|
40
|
-
type FlatTokens = Record<string, RawToken>;
|
|
41
|
-
|
|
42
|
-
/** A number, or `{seeds.name}`. */
|
|
43
|
-
type NumberParam = Varying<number | string>;
|
|
44
|
-
interface PinObject {
|
|
45
|
-
readonly value: TokenValue;
|
|
46
|
-
readonly type?: string;
|
|
47
|
-
readonly description?: string;
|
|
48
|
-
readonly alpha?: number;
|
|
49
|
-
}
|
|
50
|
-
/** A bare value or `{ value, type?, description?, alpha? }`. The value may be a `{token}` reference. */
|
|
51
|
-
type PinValue = TokenValue | PinObject;
|
|
52
|
-
interface LightnessRampDef {
|
|
53
|
-
readonly kind: 'lightness';
|
|
54
|
-
readonly steps: Varying<readonly string[]>;
|
|
55
|
-
/** First and last step's OKLCH lightness. */
|
|
56
|
-
readonly lightness: Varying<readonly [NumberParam, NumberParam]>;
|
|
57
|
-
/** 0 walks evenly; 1 follows a smoothstep S. */
|
|
58
|
-
readonly curve?: NumberParam;
|
|
59
|
-
/** Degrees. Ignored when an anchor is given. */
|
|
60
|
-
readonly hue?: NumberParam;
|
|
61
|
-
readonly chroma?: Varying<{
|
|
62
|
-
readonly peak: NumberParam;
|
|
63
|
-
readonly lightBias?: NumberParam;
|
|
64
|
-
readonly darkBias?: NumberParam;
|
|
65
|
-
}>;
|
|
66
|
-
/** Step name → exact hex (or `{seeds.name}`). The first anchor supplies hue and chroma. */
|
|
67
|
-
readonly anchor?: Varying<Readonly<Record<string, Varying<string>>>>;
|
|
68
|
-
readonly description?: string;
|
|
69
|
-
readonly describe?: Readonly<Record<string, string>>;
|
|
70
|
-
}
|
|
71
|
-
interface CategoricalRampDef {
|
|
72
|
-
readonly kind: 'categorical';
|
|
73
|
-
readonly steps: Varying<readonly string[]>;
|
|
74
|
-
/** Any of the palette generator's `Constraints` except `count` and `anchors`. */
|
|
75
|
-
readonly gates?: Varying<Readonly<Record<string, Varying<number | string>>>>;
|
|
76
|
-
readonly anchors?: readonly {
|
|
77
|
-
readonly name: string;
|
|
78
|
-
readonly hue: number;
|
|
79
|
-
readonly lightness: number;
|
|
80
|
-
readonly chroma?: number;
|
|
81
|
-
}[];
|
|
82
|
-
readonly description?: string;
|
|
83
|
-
readonly describe?: Readonly<Record<string, string>>;
|
|
84
|
-
}
|
|
85
|
-
type RampDef = LightnessRampDef | CategoricalRampDef;
|
|
86
|
-
interface ScaleDef {
|
|
87
|
-
readonly steps: Varying<readonly string[]>;
|
|
88
|
-
readonly base: NumberParam;
|
|
89
|
-
/** Linear: `base + step × i`. */
|
|
90
|
-
readonly step?: NumberParam;
|
|
91
|
-
/** Geometric: `base × ratio^i`. */
|
|
92
|
-
readonly ratio?: NumberParam;
|
|
93
|
-
readonly description?: string;
|
|
94
|
-
readonly describe?: Readonly<Record<string, string>>;
|
|
95
|
-
}
|
|
96
|
-
interface SemanticCommon {
|
|
97
|
-
readonly type?: string;
|
|
98
|
-
readonly description?: string;
|
|
99
|
-
/** Audited, never applied. */
|
|
100
|
-
readonly check?: {
|
|
101
|
-
readonly contrast: number;
|
|
102
|
-
readonly against: readonly string[];
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
type StepRule = SemanticCommon & {
|
|
106
|
-
readonly ramp: string;
|
|
107
|
-
readonly step: Varying<string>;
|
|
108
|
-
};
|
|
109
|
-
type OffsetRule = SemanticCommon & {
|
|
110
|
-
readonly from: string;
|
|
111
|
-
readonly offset: number;
|
|
112
|
-
readonly dir: 'lighter' | 'darker' | 'away';
|
|
113
|
-
};
|
|
114
|
-
type ContrastRule = SemanticCommon & {
|
|
115
|
-
readonly ramp: string;
|
|
116
|
-
readonly contrast: {
|
|
117
|
-
readonly min: number;
|
|
118
|
-
readonly against: readonly string[];
|
|
119
|
-
};
|
|
120
|
-
};
|
|
121
|
-
type RefRule = SemanticCommon & {
|
|
122
|
-
readonly ref: string;
|
|
123
|
-
readonly alpha?: number;
|
|
124
|
-
};
|
|
125
|
-
type LiteralRule = SemanticCommon & {
|
|
126
|
-
readonly value: TokenValue;
|
|
127
|
-
};
|
|
128
|
-
type SemanticRule = StepRule | OffsetRule | ContrastRule | RefRule | LiteralRule;
|
|
129
|
-
interface ThemeDefinition {
|
|
130
|
-
readonly name: string;
|
|
131
|
-
/** Another definition's name. Absent or null: extends nothing. */
|
|
132
|
-
readonly extends?: string | null;
|
|
133
|
-
readonly description?: string;
|
|
134
|
-
readonly axes?: AxisDefs;
|
|
135
|
-
readonly seeds?: Readonly<Record<string, Varying<number | string>>>;
|
|
136
|
-
readonly ramps?: Readonly<Record<string, RampDef>>;
|
|
137
|
-
readonly scales?: Readonly<Record<string, ScaleDef>>;
|
|
138
|
-
readonly semantics?: Readonly<Record<string, Varying<SemanticRule>>>;
|
|
139
|
-
readonly components?: Readonly<Record<string, Varying<PinValue>>>;
|
|
140
|
-
readonly pins?: Readonly<Record<string, Varying<PinValue>>>;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
type Lookup = (name: string) => ThemeDefinition | undefined;
|
|
144
|
-
/** The definition with its whole `extends` chain folded in, child entries winning. */
|
|
145
|
-
declare function mergeChain(def: ThemeDefinition, lookup?: Lookup, seen?: ReadonlySet<string>): ThemeDefinition;
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* A definition with every rule run: plain or `by`-varying tokens, references intact.
|
|
149
|
-
* A branch `derive` could not produce is left out, so at runtime it falls through to the parent; definitions with
|
|
150
|
-
* issues still bake, because the editor bakes mid-edit and the build refuses them before baking. Cycles and dangling
|
|
151
|
-
* references still throw, as they do in `derive`.
|
|
152
|
-
*/
|
|
153
|
-
interface BakedTheme {
|
|
154
|
-
readonly name: string;
|
|
155
|
-
readonly extends: string | null;
|
|
156
|
-
readonly axes: AxisDefs;
|
|
157
|
-
/** In layer order, then definition order. */
|
|
158
|
-
readonly tokens: Readonly<Record<string, Varying<RawToken>>>;
|
|
159
|
-
}
|
|
160
|
-
/** Derive `definition` at every selection and fold the results into one record of tokens with no rules left. */
|
|
161
|
-
declare function bake(definition: ThemeDefinition, lookup?: Lookup): BakedTheme;
|
|
162
|
-
/** `definition` and every theme it extends, baked, root first. */
|
|
163
|
-
declare function bakeChain(definition: ThemeDefinition, lookup?: Lookup): BakedTheme[];
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* A theme ready to resolve: its axes and its tokens, each plain or varying by
|
|
167
|
-
* axis, references intact. A `by` that leaves a value out contributes nothing
|
|
168
|
-
* for that selection, so the theme it extends supplies it.
|
|
169
|
-
*/
|
|
170
|
-
interface Theme {
|
|
171
|
-
readonly name: string;
|
|
172
|
-
readonly extends: Theme | null;
|
|
173
|
-
readonly axes: AxisDefs;
|
|
174
|
-
readonly tokens: Readonly<Record<string, Varying<RawToken>>>;
|
|
175
|
-
}
|
|
176
|
-
/** What `defineTheme` accepts: a definition whose `extends` is a `Theme`, holding pins and components only. */
|
|
177
|
-
type ThemeInput = Omit<ThemeDefinition, 'extends'> & {
|
|
178
|
-
readonly extends?: Theme | null;
|
|
179
|
-
};
|
|
180
|
-
/** The built-in theme, from the baked output of themes/weasel.json. */
|
|
181
|
-
declare const weaselTheme: Theme;
|
|
182
|
-
/**
|
|
183
|
-
* Build a theme from pins. Unless `extends` says otherwise the result layers
|
|
184
|
-
* onto `weaselTheme`, so a theme only names what it changes. A definition with
|
|
185
|
-
* seeds, ramps, scales or semantics needs deriving first.
|
|
186
|
-
*/
|
|
187
|
-
declare function defineTheme(input: ThemeInput): Theme;
|
|
188
|
-
|
|
189
|
-
export { type AxisDef as A, type BakedTheme as B, type CategoricalRampDef as C, type FlatTokens as F, type Lookup as L, type NumberParam as N, type OffsetRule as O, type PinObject as P, type RawToken as R, type Selection as S, type Theme as T, type Varying as V, type TokenValue as a, type AxisDefs as b, type AxisValue as c, type ByAxis as d, type PinValue as e, type ThemeDefinition as f, type ThemeInput as g, defineTheme as h, enumerateSelections as i, fullSelection as j, isByAxis as k, type ContrastRule as l, type LightnessRampDef as m, type LiteralRule as n, type RampDef as o, type RefRule as p, type ScaleDef as q, type SemanticRule as r, selectionKey as s, type StepRule as t, bake as u, bakeChain as v, weaselTheme as w, mergeChain as x };
|