@celestia-island/hikari 0.55.486 → 0.55.488

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.
@@ -111,24 +111,17 @@ export declare function saveCustomThemes(list: CustomThemePreset[]): void;
111
111
  export declare function addCustomTheme(theme: CustomThemePreset): void;
112
112
  export declare function removeCustomTheme(id: string): void;
113
113
  /**
114
- * The stock preset table holds exactly ONE theme.
114
+ * The stock preset table holds exactly ONE theme, and its VALUES are no
115
+ * longer written here: they live in the Rust palette crate
116
+ * (`packages/palette/src/stock.rs`, hikari#1546 Phase 2) and arrive as the
117
+ * checked-in JSON artifact above. Editing a color means editing Rust and
118
+ * regenerating (`REGEN_STOCK_JSON=1 cargo test -p hikari-palette --test
119
+ * stock_snapshot`) — the artifact snapshot test in that crate keeps the
120
+ * two sides locked.
115
121
  *
116
- * `default` carries the pair the library has always fallen back to: its
117
- * light scheme is the historical pink/paper palette and its dark scheme the
118
- * black-blue one. The four editor-derived looks (Synthwave '84, Nord,
119
- * Gruvbox, Tokyo Night) were collapsed into this single pair on user
120
- * direction — the library stops shipping competing aesthetics. A consumer
121
- * that wants a distinct brand registers its own preset (chest's `sc` is the
122
- * reference), and a user who wants another look edits this one through the
123
- * theme dialog and keeps it as a custom scheme.
124
- *
125
- * Values are carried over VERBATIM from the entries this collapse retired —
126
- * `synthwave84.light` into the light scheme, `nord.dark` into the dark one.
127
- * Nothing was restyled: the dark scheme therefore keeps Nord's pale Polar
128
- * Water primary (#88C0D0) and, with it, the near-black on-solid ink slots
129
- * that pale primary requires (white on it is ~1.9:1). A stored id from the
130
- * retired set is no longer a known theme, so `storedThemeId()` drops it and
131
- * the engine resolves this default instead.
122
+ * A consumer that wants a distinct brand still registers its own preset
123
+ * (chest's `sc` is the reference), and a user who wants another look edits
124
+ * the default through the theme dialog and keeps it as a custom scheme.
132
125
  */
133
126
  export declare const themePresets: Record<ThemeId, ThemePreset>;
134
127
  export type ThemeTokens = ThemeSchemeTokens;
@@ -1 +1,43 @@
1
+ /**
2
+ * The PRE-RENDERED static form of the stock theme table (hikari#1546).
3
+ *
4
+ * `applyTheme()` injects the whole cssvar set from JS, which is why a
5
+ * phone's first paint used to flash the unthemed default: no JS, no vars.
6
+ * This module composes the SAME `tokensToCSSVars` output the runtime uses
7
+ * into plain CSS blocks keyed on the `data-mode` attribute — the SSR
8
+ * template ships it in `<head>`, and a tiny inline bootstrap only sets
9
+ * `data-theme`/`data-mode` (attribute writes, no computation) before body
10
+ * paint. The cascade picks the block instantly.
11
+ *
12
+ * Selectors are mode-keyed and deliberately NOT theme-keyed: a stored
13
+ * CUSTOM theme id cannot be pre-rendered (user-authored, lives in
14
+ * localStorage), so pre-hydration those users see the stock colors in the
15
+ * right MODE — strictly better than the previous unthemed flash — and
16
+ * `applyTheme()` replaces them the moment the bundle lands. Override
17
+ * mechanics: the runtime writes a managed `<style data-hikari-theme-vars>`
18
+ * block whose selector (`html:root`, 0-1-1) TIES with these `html[data-mode]`
19
+ * blocks — the runtime wins by head ORDER (its block is appended after the
20
+ * SSR sheet), so the static sheet must stay in the SSR head; a late/async
21
+ * -loaded copy would re-tie and could snap the theme back.
22
+ *
23
+ * Phase 2 (de-Vue): the table itself moves to the Rust palette crate
24
+ * (tairitsu lane) and this module consumes generated JSON — the CSS form
25
+ * and the bootstrap contract stay exactly as they are here.
26
+ *
27
+ * Group tokens (shape/radius) are intentionally NOT included: every
28
+ * component reads them with its own CSS fallback (e.g.
29
+ * `var(--hk-radius-sm, 4px)` in HkSkeleton, `var(--hk-z-*)`,
30
+ * `var(--hk-picker-*)`), so the pre-hydration window degrades to identical
31
+ * geometry, and the runtime emission covers them anyway.
32
+ */
33
+ /** The typed view of the Rust artifact: the serde BTreeMap arrives as two
34
+ * string-keyed maps. Declared explicitly because the JSON import's literal
35
+ * type defeats `stockVarsJson[mode]` under the strict build (vue-tsc
36
+ * TS7053 — the release lane caught it, the esbuild test transform did not). */
37
+ export interface StockVarsArtifact {
38
+ dark: Record<string, string>;
39
+ light: Record<string, string>;
40
+ }
41
+ declare const stockVars: StockVarsArtifact;
1
42
  export declare function buildThemeVarsCss(): string;
43
+ export { stockVars };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celestia-island/hikari",
3
- "version": "0.55.486",
3
+ "version": "0.55.488",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Hikari UI library, Vue 3 runtime — one design system for Vue 3 and Rust/WASM applications",
@@ -1,117 +1,119 @@
1
- /* GENERATED by themeVarsCss.contract.test.ts (REGEN_THEME_VARS=1) —
2
- * do not edit by hand. Source: the stock `default` preset in
3
- * presets.ts; the regen command is in the contract test doc block. */
1
+ /* GENERATED from the Rust palette crate's derivation (packages/palette/
2
+ * src/derivation.rs) via the stock-vars.json artifact — do not edit by
3
+ * hand. The drift contract pins the TypeScript derivation to these
4
+ * values key-for-key; regen is REGEN_STOCK_JSON=1 cargo test
5
+ * -p hikari-palette --test stock_snapshot. */
4
6
  html[data-mode="dark"] {
5
- --color-primary: 136 192 208;
7
+ --color-accent: 94 129 172;
8
+ --color-background: 22 27 38;
9
+ --color-border: 128 128 128;
10
+ --color-error: 166 41 55;
11
+ --color-focused-border: 136 192 208;
12
+ --color-info: 0 98 116;
13
+ --color-muted: 180 180 180;
14
+ --color-on-danger: 255 255 255;
15
+ --color-on-info: 255 255 255;
6
16
  --color-on-primary: 0 0 0;
7
- --color-on-solid-text: 46 52 64;
8
- --color-on-solid-icon: 46 52 64;
9
17
  --color-on-solid: 46 52 64;
10
- --color-on-danger: 255 255 255;
18
+ --color-on-solid-icon: 46 52 64;
19
+ --color-on-solid-text: 46 52 64;
11
20
  --color-on-success: 255 255 255;
12
21
  --color-on-warning: 255 255 255;
13
- --color-on-info: 255 255 255;
22
+ --color-primary: 136 192 208;
14
23
  --color-secondary: 143 188 187;
15
- --color-accent: 94 129 172;
16
- --color-text: 247 249 252;
17
- --color-text-secondary: 230 232 234;
18
- --color-text-tertiary: 214 215 216;
19
- --color-muted: 180 180 180;
20
- --color-border: 128 128 128;
21
- --color-focused-border: 136 192 208;
22
- --color-background: 22 27 38;
23
- --color-surface: 34 40 54;
24
24
  --color-selected-bg: 70 70 85;
25
25
  --color-selected-text: 248 248 250;
26
26
  --color-status-bar-bg: 34 40 54;
27
27
  --color-success: 31 101 48;
28
- --color-error: 166 41 55;
28
+ --color-surface: 34 40 54;
29
+ --color-text: 247 249 252;
30
+ --color-text-secondary: 230 232 234;
31
+ --color-text-tertiary: 214 215 216;
29
32
  --color-warning: 137 72 0;
30
- --color-info: 0 98 116;
31
- --hi-color-primary: rgb(var(--color-primary));
32
- --hi-color-secondary: rgb(var(--color-secondary));
33
- --hi-color-surface: rgb(var(--color-surface));
34
33
  --hi-color-background: rgb(var(--color-background));
34
+ --hi-color-bg-canvas: rgb(var(--color-background));
35
+ --hi-color-bg-container: rgb(var(--color-surface));
36
+ --hi-color-bg-elevated: rgb(var(--color-surface));
37
+ --hi-color-bg-subtle: rgb(var(--color-surface) / 0.5);
35
38
  --hi-color-border: rgb(var(--color-border) / 15%);
36
- --hi-color-text-primary: rgb(var(--color-text));
37
- --hi-color-text-secondary: rgb(var(--color-text-secondary));
39
+ --hi-color-danger-fg: rgb(233 104 109);
40
+ --hi-color-error: rgb(var(--color-error));
41
+ --hi-color-icon-on-solid: rgb(var(--color-on-solid-icon, 255 255 255));
42
+ --hi-color-info: rgb(var(--color-info));
43
+ --hi-color-info-fg: rgb(81 158 177);
38
44
  --hi-color-muted: rgb(var(--color-muted));
39
45
  --hi-color-on-primary: rgb(var(--color-on-primary));
40
- --hi-color-text-on-primary: rgb(var(--color-on-primary));
41
- --hi-color-text-on-solid: rgb(var(--color-on-solid-text, 255 255 255));
42
- --hi-color-icon-on-solid: rgb(var(--color-on-solid-icon, 255 255 255));
46
+ --hi-color-primary: rgb(var(--color-primary));
47
+ --hi-color-secondary: rgb(var(--color-secondary));
43
48
  --hi-color-success: rgb(var(--color-success));
44
- --hi-color-error: rgb(var(--color-error));
45
- --hi-color-warning: rgb(var(--color-warning));
46
- --hi-color-info: rgb(var(--color-info));
49
+ --hi-color-success-fg: rgb(94 162 105);
50
+ --hi-color-surface: rgb(var(--color-surface));
47
51
  --hi-color-text-on-danger: rgb(var(--color-on-danger));
52
+ --hi-color-text-on-info: rgb(var(--color-on-info));
53
+ --hi-color-text-on-primary: rgb(var(--color-on-primary));
54
+ --hi-color-text-on-solid: rgb(var(--color-on-solid-text, 255 255 255));
48
55
  --hi-color-text-on-success: rgb(var(--color-on-success));
49
56
  --hi-color-text-on-warning: rgb(var(--color-on-warning));
50
- --hi-color-text-on-info: rgb(var(--color-on-info));
51
- --hi-color-success-fg: rgb(94 162 105);
52
- --hi-color-danger-fg: rgb(233 104 109);
57
+ --hi-color-text-primary: rgb(var(--color-text));
58
+ --hi-color-text-secondary: rgb(var(--color-text-secondary));
59
+ --hi-color-warning: rgb(var(--color-warning));
53
60
  --hi-color-warning-fg: rgb(200 130 73);
54
- --hi-color-info-fg: rgb(81 158 177);
55
- --hi-color-bg-subtle: rgb(var(--color-surface) / 0.5);
56
- --hi-color-bg-elevated: rgb(var(--color-surface));
57
- --hi-color-bg-container: rgb(var(--color-surface));
58
- --hi-color-bg-canvas: rgb(var(--color-background));
59
61
  --hi-secondary-bg: rgb(var(--color-surface) / 0.5);
60
62
  }
61
63
  html[data-mode="light"] {
62
- --color-primary: 214 51 132;
64
+ --color-accent: 230 167 0;
65
+ --color-background: 245 245 240;
66
+ --color-border: 128 128 128;
67
+ --color-error: 166 41 55;
68
+ --color-focused-border: 214 51 132;
69
+ --color-info: 0 98 116;
70
+ --color-muted: 80 80 80;
71
+ --color-on-danger: 255 255 255;
72
+ --color-on-info: 255 255 255;
63
73
  --color-on-primary: 255 255 255;
64
- --color-on-solid-text: 255 255 255;
65
- --color-on-solid-icon: 255 255 255;
66
74
  --color-on-solid: 255 255 255;
67
- --color-on-danger: 255 255 255;
75
+ --color-on-solid-icon: 255 255 255;
76
+ --color-on-solid-text: 255 255 255;
68
77
  --color-on-success: 255 255 255;
69
78
  --color-on-warning: 255 255 255;
70
- --color-on-info: 255 255 255;
79
+ --color-primary: 214 51 132;
71
80
  --color-secondary: 156 106 222;
72
- --color-accent: 230 167 0;
73
- --color-text: 30 30 30;
74
- --color-text-secondary: 43 43 43;
75
- --color-text-tertiary: 55 55 55;
76
- --color-muted: 80 80 80;
77
- --color-border: 128 128 128;
78
- --color-focused-border: 214 51 132;
79
- --color-background: 245 245 240;
80
- --color-surface: 255 255 255;
81
81
  --color-selected-bg: 200 200 205;
82
82
  --color-selected-text: 40 40 45;
83
83
  --color-status-bar-bg: 230 230 225;
84
84
  --color-success: 31 101 48;
85
- --color-error: 166 41 55;
85
+ --color-surface: 255 255 255;
86
+ --color-text: 30 30 30;
87
+ --color-text-secondary: 43 43 43;
88
+ --color-text-tertiary: 55 55 55;
86
89
  --color-warning: 137 72 0;
87
- --color-info: 0 98 116;
88
- --hi-color-primary: rgb(var(--color-primary));
89
- --hi-color-secondary: rgb(var(--color-secondary));
90
- --hi-color-surface: rgb(var(--color-surface));
91
90
  --hi-color-background: rgb(var(--color-background));
91
+ --hi-color-bg-canvas: rgb(var(--color-background));
92
+ --hi-color-bg-container: rgb(var(--color-surface));
93
+ --hi-color-bg-elevated: rgb(var(--color-surface));
94
+ --hi-color-bg-subtle: rgb(var(--color-surface) / 0.5);
92
95
  --hi-color-border: rgb(var(--color-border) / 15%);
93
- --hi-color-text-primary: rgb(var(--color-text));
94
- --hi-color-text-secondary: rgb(var(--color-text-secondary));
96
+ --hi-color-danger-fg: rgb(166 41 55);
97
+ --hi-color-error: rgb(var(--color-error));
98
+ --hi-color-icon-on-solid: rgb(var(--color-on-solid-icon, 255 255 255));
99
+ --hi-color-info: rgb(var(--color-info));
100
+ --hi-color-info-fg: rgb(0 98 116);
95
101
  --hi-color-muted: rgb(var(--color-muted));
96
102
  --hi-color-on-primary: rgb(var(--color-on-primary));
97
- --hi-color-text-on-primary: rgb(var(--color-on-primary));
98
- --hi-color-text-on-solid: rgb(var(--color-on-solid-text, 255 255 255));
99
- --hi-color-icon-on-solid: rgb(var(--color-on-solid-icon, 255 255 255));
103
+ --hi-color-primary: rgb(var(--color-primary));
104
+ --hi-color-secondary: rgb(var(--color-secondary));
100
105
  --hi-color-success: rgb(var(--color-success));
101
- --hi-color-error: rgb(var(--color-error));
102
- --hi-color-warning: rgb(var(--color-warning));
103
- --hi-color-info: rgb(var(--color-info));
106
+ --hi-color-success-fg: rgb(31 101 48);
107
+ --hi-color-surface: rgb(var(--color-surface));
104
108
  --hi-color-text-on-danger: rgb(var(--color-on-danger));
109
+ --hi-color-text-on-info: rgb(var(--color-on-info));
110
+ --hi-color-text-on-primary: rgb(var(--color-on-primary));
111
+ --hi-color-text-on-solid: rgb(var(--color-on-solid-text, 255 255 255));
105
112
  --hi-color-text-on-success: rgb(var(--color-on-success));
106
113
  --hi-color-text-on-warning: rgb(var(--color-on-warning));
107
- --hi-color-text-on-info: rgb(var(--color-on-info));
108
- --hi-color-success-fg: rgb(31 101 48);
109
- --hi-color-danger-fg: rgb(166 41 55);
114
+ --hi-color-text-primary: rgb(var(--color-text));
115
+ --hi-color-text-secondary: rgb(var(--color-text-secondary));
116
+ --hi-color-warning: rgb(var(--color-warning));
110
117
  --hi-color-warning-fg: rgb(137 72 0);
111
- --hi-color-info-fg: rgb(0 98 116);
112
- --hi-color-bg-subtle: rgb(var(--color-surface) / 0.5);
113
- --hi-color-bg-elevated: rgb(var(--color-surface));
114
- --hi-color-bg-container: rgb(var(--color-surface));
115
- --hi-color-bg-canvas: rgb(var(--color-background));
116
118
  --hi-secondary-bg: rgb(var(--color-surface) / 0.5);
117
119
  }
@@ -1,3 +1,8 @@
1
+ // The stock `default` theme's VALUES live in the Rust palette crate
2
+ // (packages/palette/src/stock.rs — hikari#1546 Phase 2); this JSON is the
3
+ // serde artifact a snapshot test keeps byte-locked to that crate. This file
4
+ // no longer hand-writes the slot table.
5
+ import stockThemeJson from "./stock-preset.json";
1
6
  import { readStorageItem, writeStorageItem } from "./safeStorage";
2
7
  import { rgbToOklch, oklchToRgb, contrastRatio } from "../theme/semanticPalette";
3
8
 
@@ -149,79 +154,21 @@ export function removeCustomTheme(id: string) {
149
154
  saveCustomThemes(list);
150
155
  }
151
156
 
152
- const rgb = (r: number, g: number, b: number): ThemeTokenRGB => ({ r, g, b });
153
-
154
157
  /**
155
- * The stock preset table holds exactly ONE theme.
156
- *
157
- * `default` carries the pair the library has always fallen back to: its
158
- * light scheme is the historical pink/paper palette and its dark scheme the
159
- * black-blue one. The four editor-derived looks (Synthwave '84, Nord,
160
- * Gruvbox, Tokyo Night) were collapsed into this single pair on user
161
- * direction — the library stops shipping competing aesthetics. A consumer
162
- * that wants a distinct brand registers its own preset (chest's `sc` is the
163
- * reference), and a user who wants another look edits this one through the
164
- * theme dialog and keeps it as a custom scheme.
158
+ * The stock preset table holds exactly ONE theme, and its VALUES are no
159
+ * longer written here: they live in the Rust palette crate
160
+ * (`packages/palette/src/stock.rs`, hikari#1546 Phase 2) and arrive as the
161
+ * checked-in JSON artifact above. Editing a color means editing Rust and
162
+ * regenerating (`REGEN_STOCK_JSON=1 cargo test -p hikari-palette --test
163
+ * stock_snapshot`) — the artifact snapshot test in that crate keeps the
164
+ * two sides locked.
165
165
  *
166
- * Values are carried over VERBATIM from the entries this collapse retired —
167
- * `synthwave84.light` into the light scheme, `nord.dark` into the dark one.
168
- * Nothing was restyled: the dark scheme therefore keeps Nord's pale Polar
169
- * Water primary (#88C0D0) and, with it, the near-black on-solid ink slots
170
- * that pale primary requires (white on it is ~1.9:1). A stored id from the
171
- * retired set is no longer a known theme, so `storedThemeId()` drops it and
172
- * the engine resolves this default instead.
166
+ * A consumer that wants a distinct brand still registers its own preset
167
+ * (chest's `sc` is the reference), and a user who wants another look edits
168
+ * the default through the theme dialog and keeps it as a custom scheme.
173
169
  */
174
170
  export const themePresets: Record<ThemeId, ThemePreset> = {
175
- default: {
176
- id: "default",
177
- name: "Default",
178
- dark: {
179
- primary: rgb(136, 192, 208),
180
- secondary: rgb(143, 188, 187),
181
- accent: rgb(94, 129, 172),
182
- text: rgb(247, 249, 252),
183
- muted: rgb(180, 180, 180),
184
- border: rgb(128, 128, 128),
185
- focusedBorder: rgb(136, 192, 208),
186
- background: rgb(22, 27, 38),
187
- surface: rgb(34, 40, 54),
188
- selectedBackground: rgb(70, 70, 85),
189
- selectedText: rgb(248, 248, 250),
190
- statusBarBackground: rgb(34, 40, 54),
191
- // Same canonical family as light — solid fills ignore the mode.
192
- success: rgb(31, 101, 48),
193
- error: rgb(166, 41, 55),
194
- warning: rgb(137, 72, 0),
195
- info: rgb(0, 98, 116),
196
- // The pale primary puts dark ink on solid fills (white is ~1.9:1).
197
- onSolidText: rgb(46, 52, 64),
198
- onSolidIcon: rgb(46, 52, 64),
199
- },
200
- light: {
201
- primary: rgb(214, 51, 132),
202
- secondary: rgb(156, 106, 222),
203
- accent: rgb(230, 167, 0),
204
- text: rgb(30, 30, 30),
205
- muted: rgb(80, 80, 80),
206
- border: rgb(128, 128, 128),
207
- focusedBorder: rgb(214, 51, 132),
208
- background: rgb(245, 245, 240),
209
- surface: rgb(255, 255, 255),
210
- selectedBackground: rgb(200, 200, 205),
211
- selectedText: rgb(40, 40, 45),
212
- statusBarBackground: rgb(230, 230, 225),
213
- // Semantic quartet — the SHARED canonical family (solid fills ignore
214
- // the light/dark config, user direction), lightness derived so the
215
- // house white ink clears 7:1. See hikari-palette themes.rs for the
216
- // same trio on the components side.
217
- success: rgb(31, 101, 48),
218
- error: rgb(166, 41, 55),
219
- warning: rgb(137, 72, 0),
220
- info: rgb(0, 98, 116),
221
- onSolidText: rgb(255, 255, 255),
222
- onSolidIcon: rgb(255, 255, 255),
223
- },
224
- },
171
+ default: stockThemeJson as unknown as ThemePreset,
225
172
  };
226
173
 
227
174
  export type ThemeTokens = ThemeSchemeTokens;
@@ -246,26 +193,6 @@ export function getThemeTokens(
246
193
  if (preset) return mode === "dark" ? preset.dark : preset.light;
247
194
  return null;
248
195
  }
249
-
250
- /**
251
- * The white-or-black ink for ONE solid fill. Deliberately NOT "whichever
252
- * side wins the WCAG ratio": on saturated fills the ratio winner is the
253
- * black ink far more often than design systems ship it (a 32-colour sweep
254
- * of shipped brand/semantic solids picked white only 19% of the time by
255
- * ratio, while Radix, Bootstrap and Material all ship white on them).
256
- * The house rule (user direction, 2026-11-12) is perception-first:
257
- *
258
- * solid fill → WHITE by default; BLACK only when the fill is light
259
- * enough to need it (perceptual luminance above 0.65,
260
- * which lands on Radix's "designed for dark foreground"
261
- * set: Sky, Mint, Lime, Yellow, Amber, plus the pale
262
- * Nord tones; see the threshold note in solidInk);
263
- * translucent → ride the theme's text channel (never computed here).
264
- *
265
- * Per-fill, not per-theme: one global on-solid slot cannot be right for a
266
- * dark red AND a pale amber at once, which is exactly how the toast
267
- * copy/close glyphs went near-black on themed bands (2026-11-12 report).
268
- */
269
196
  /**
270
197
  * This colour as TEXT on `bg`: itself when it already clears `target`,
271
198
  * otherwise the nearest OKLCH-lightness step that does. Hue is preserved;
@@ -0,0 +1 @@
1
+ {"id":"default","name":"Default","dark":{"primary":{"r":136,"g":192,"b":208},"secondary":{"r":143,"g":188,"b":187},"accent":{"r":94,"g":129,"b":172},"text":{"r":247,"g":249,"b":252},"muted":{"r":180,"g":180,"b":180},"border":{"r":128,"g":128,"b":128},"focusedBorder":{"r":136,"g":192,"b":208},"background":{"r":22,"g":27,"b":38},"surface":{"r":34,"g":40,"b":54},"selectedBackground":{"r":70,"g":70,"b":85},"selectedText":{"r":248,"g":248,"b":250},"statusBarBackground":{"r":34,"g":40,"b":54},"success":{"r":31,"g":101,"b":48},"error":{"r":166,"g":41,"b":55},"warning":{"r":137,"g":72,"b":0},"info":{"r":0,"g":98,"b":116},"onSolidText":{"r":46,"g":52,"b":64},"onSolidIcon":{"r":46,"g":52,"b":64}},"light":{"primary":{"r":214,"g":51,"b":132},"secondary":{"r":156,"g":106,"b":222},"accent":{"r":230,"g":167,"b":0},"text":{"r":30,"g":30,"b":30},"muted":{"r":80,"g":80,"b":80},"border":{"r":128,"g":128,"b":128},"focusedBorder":{"r":214,"g":51,"b":132},"background":{"r":245,"g":245,"b":240},"surface":{"r":255,"g":255,"b":255},"selectedBackground":{"r":200,"g":200,"b":205},"selectedText":{"r":40,"g":40,"b":45},"statusBarBackground":{"r":230,"g":230,"b":225},"success":{"r":31,"g":101,"b":48},"error":{"r":166,"g":41,"b":55},"warning":{"r":137,"g":72,"b":0},"info":{"r":0,"g":98,"b":116},"onSolidText":{"r":255,"g":255,"b":255},"onSolidIcon":{"r":255,"g":255,"b":255}}}
@@ -0,0 +1 @@
1
+ {"dark":{"--color-accent":"94 129 172","--color-background":"22 27 38","--color-border":"128 128 128","--color-error":"166 41 55","--color-focused-border":"136 192 208","--color-info":"0 98 116","--color-muted":"180 180 180","--color-on-danger":"255 255 255","--color-on-info":"255 255 255","--color-on-primary":"0 0 0","--color-on-solid":"46 52 64","--color-on-solid-icon":"46 52 64","--color-on-solid-text":"46 52 64","--color-on-success":"255 255 255","--color-on-warning":"255 255 255","--color-primary":"136 192 208","--color-secondary":"143 188 187","--color-selected-bg":"70 70 85","--color-selected-text":"248 248 250","--color-status-bar-bg":"34 40 54","--color-success":"31 101 48","--color-surface":"34 40 54","--color-text":"247 249 252","--color-text-secondary":"230 232 234","--color-text-tertiary":"214 215 216","--color-warning":"137 72 0","--hi-color-background":"rgb(var(--color-background))","--hi-color-bg-canvas":"rgb(var(--color-background))","--hi-color-bg-container":"rgb(var(--color-surface))","--hi-color-bg-elevated":"rgb(var(--color-surface))","--hi-color-bg-subtle":"rgb(var(--color-surface) / 0.5)","--hi-color-border":"rgb(var(--color-border) / 15%)","--hi-color-danger-fg":"rgb(233 104 109)","--hi-color-error":"rgb(var(--color-error))","--hi-color-icon-on-solid":"rgb(var(--color-on-solid-icon, 255 255 255))","--hi-color-info":"rgb(var(--color-info))","--hi-color-info-fg":"rgb(81 158 177)","--hi-color-muted":"rgb(var(--color-muted))","--hi-color-on-primary":"rgb(var(--color-on-primary))","--hi-color-primary":"rgb(var(--color-primary))","--hi-color-secondary":"rgb(var(--color-secondary))","--hi-color-success":"rgb(var(--color-success))","--hi-color-success-fg":"rgb(94 162 105)","--hi-color-surface":"rgb(var(--color-surface))","--hi-color-text-on-danger":"rgb(var(--color-on-danger))","--hi-color-text-on-info":"rgb(var(--color-on-info))","--hi-color-text-on-primary":"rgb(var(--color-on-primary))","--hi-color-text-on-solid":"rgb(var(--color-on-solid-text, 255 255 255))","--hi-color-text-on-success":"rgb(var(--color-on-success))","--hi-color-text-on-warning":"rgb(var(--color-on-warning))","--hi-color-text-primary":"rgb(var(--color-text))","--hi-color-text-secondary":"rgb(var(--color-text-secondary))","--hi-color-warning":"rgb(var(--color-warning))","--hi-color-warning-fg":"rgb(200 130 73)","--hi-secondary-bg":"rgb(var(--color-surface) / 0.5)"},"light":{"--color-accent":"230 167 0","--color-background":"245 245 240","--color-border":"128 128 128","--color-error":"166 41 55","--color-focused-border":"214 51 132","--color-info":"0 98 116","--color-muted":"80 80 80","--color-on-danger":"255 255 255","--color-on-info":"255 255 255","--color-on-primary":"255 255 255","--color-on-solid":"255 255 255","--color-on-solid-icon":"255 255 255","--color-on-solid-text":"255 255 255","--color-on-success":"255 255 255","--color-on-warning":"255 255 255","--color-primary":"214 51 132","--color-secondary":"156 106 222","--color-selected-bg":"200 200 205","--color-selected-text":"40 40 45","--color-status-bar-bg":"230 230 225","--color-success":"31 101 48","--color-surface":"255 255 255","--color-text":"30 30 30","--color-text-secondary":"43 43 43","--color-text-tertiary":"55 55 55","--color-warning":"137 72 0","--hi-color-background":"rgb(var(--color-background))","--hi-color-bg-canvas":"rgb(var(--color-background))","--hi-color-bg-container":"rgb(var(--color-surface))","--hi-color-bg-elevated":"rgb(var(--color-surface))","--hi-color-bg-subtle":"rgb(var(--color-surface) / 0.5)","--hi-color-border":"rgb(var(--color-border) / 15%)","--hi-color-danger-fg":"rgb(166 41 55)","--hi-color-error":"rgb(var(--color-error))","--hi-color-icon-on-solid":"rgb(var(--color-on-solid-icon, 255 255 255))","--hi-color-info":"rgb(var(--color-info))","--hi-color-info-fg":"rgb(0 98 116)","--hi-color-muted":"rgb(var(--color-muted))","--hi-color-on-primary":"rgb(var(--color-on-primary))","--hi-color-primary":"rgb(var(--color-primary))","--hi-color-secondary":"rgb(var(--color-secondary))","--hi-color-success":"rgb(var(--color-success))","--hi-color-success-fg":"rgb(31 101 48)","--hi-color-surface":"rgb(var(--color-surface))","--hi-color-text-on-danger":"rgb(var(--color-on-danger))","--hi-color-text-on-info":"rgb(var(--color-on-info))","--hi-color-text-on-primary":"rgb(var(--color-on-primary))","--hi-color-text-on-solid":"rgb(var(--color-on-solid-text, 255 255 255))","--hi-color-text-on-success":"rgb(var(--color-on-success))","--hi-color-text-on-warning":"rgb(var(--color-on-warning))","--hi-color-text-primary":"rgb(var(--color-text))","--hi-color-text-secondary":"rgb(var(--color-text-secondary))","--hi-color-warning":"rgb(var(--color-warning))","--hi-color-warning-fg":"rgb(137 72 0)","--hi-secondary-bg":"rgb(var(--color-surface) / 0.5)"}}
@@ -3,7 +3,8 @@ import { dirname, join } from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { describe, expect, it } from "vitest";
5
5
 
6
- import { buildThemeVarsCss } from "./themeVarsCss";
6
+ import { tokensToCSSVars, getThemeTokens } from "./presets";
7
+ import { buildThemeVarsCss, stockVars } from "./themeVarsCss";
7
8
 
8
9
  /**
9
10
  * Drift contract for the PRE-RENDERED theme CSS (hikari#1546): the checked
@@ -46,7 +47,40 @@ describe("pre-rendered theme vars CSS (hikari#1546)", () => {
46
47
  expect(checkedIn).toBe(css);
47
48
  });
48
49
 
50
+ it("CROSS-LANGUAGE LOCK: the TS derivation equals the Rust derivation, key-for-key", () => {
51
+ // hikari#1546 Phase 2 endgame: the shipped sheet now comes from the
52
+ // Rust palette crate's derivation (via stock-vars.json). The same
53
+ // derivation ALSO lives here for runtime-authored custom themes. Two
54
+ // implementations of one algorithm drift silently — this compare
55
+ // VERIFIED the lock on first run (55 keys x 2 modes byte-identical)
56
+ // and always catches a divergence: any value edit on either side
57
+ // REDS the named key and mode. MUT:mut-derivation-lock. `tokensToCSSVars` is the runtime
58
+ // authority for custom themes; this file's CSS composition is the
59
+ // boot-time authority for the stock preset.
60
+ for (const mode of ["dark", "light"] as const) {
61
+ const tokens = getThemeTokens("default", mode);
62
+ const tsVars = tokensToCSSVars(tokens!);
63
+ const rustVars = stockVars[mode];
64
+ const tsKeys = Object.keys(tsVars).sort();
65
+ const rustKeys = Object.keys(rustVars).sort();
66
+ expect(tsKeys, `TS/Rust key sets must match (${mode})`).toEqual(rustKeys);
67
+ for (const key of tsKeys) {
68
+ expect(
69
+ tsVars[key]?.replace(/\s+/g, " ").trim(),
70
+ `${key} (${mode})`,
71
+ ).toBe(rustVars[key]?.replace(/\s+/g, " ").trim());
72
+ }
73
+ }
74
+ });
75
+
49
76
  it("covers both modes with the core color tokens", () => {
77
+ expect(css).toContain('html[data-mode="dark"]');
78
+ expect(css).toContain('html[data-mode="light"]');
79
+ // Load-bearing for hikari#1546 Phase 2: the values now originate in the
80
+ // Rust palette crate (stock.rs) and reach this composition through the
81
+ // JSON artifact presets.ts imports. A migration typo would change one
82
+ // of these channel triples — the comparison against the checked-in CSS
83
+ // is what proves the migration changed no color.
50
84
  expect(css).toContain('html[data-mode="dark"]');
51
85
  expect(css).toContain('html[data-mode="light"]');
52
86
  // The slots with no per-component CSS fallback — a missing one leaves
@@ -1,4 +1,9 @@
1
- import { themePresets, tokensToCSSVars, getThemeTokens } from "./presets";
1
+ // The vars are the RUST DERIVATION's output (packages/palette/src/
2
+ // derivation.rs), shipped as this JSON artifact — hikari#1546 Phase 2
3
+ // endgame. The TypeScript tokensToCSSVars remains ONLY for runtime-authored
4
+ // custom themes, and the drift contract below pins it, key-for-key, to this
5
+ // artifact so the two implementations cannot diverge.
6
+ import stockVarsJson from "./stock-vars.json";
2
7
 
3
8
  /**
4
9
  * The PRE-RENDERED static form of the stock theme table (hikari#1546).
@@ -32,20 +37,29 @@ import { themePresets, tokensToCSSVars, getThemeTokens } from "./presets";
32
37
  * `var(--hk-picker-*)`), so the pre-hydration window degrades to identical
33
38
  * geometry, and the runtime emission covers them anyway.
34
39
  */
40
+ /** The typed view of the Rust artifact: the serde BTreeMap arrives as two
41
+ * string-keyed maps. Declared explicitly because the JSON import's literal
42
+ * type defeats `stockVarsJson[mode]` under the strict build (vue-tsc
43
+ * TS7053 — the release lane caught it, the esbuild test transform did not). */
44
+ export interface StockVarsArtifact {
45
+ dark: Record<string, string>;
46
+ light: Record<string, string>;
47
+ }
48
+
49
+ const stockVars: StockVarsArtifact = stockVarsJson as StockVarsArtifact;
50
+
35
51
  const MODES = ["dark", "light"] as const;
36
52
 
37
53
  export function buildThemeVarsCss(): string {
38
- const preset = themePresets.default;
39
- if (!preset) return "/* stock preset table is empty — nothing to pre-render */\n";
40
54
  const chunks: string[] = [
41
- "/* GENERATED by themeVarsCss.contract.test.ts (REGEN_THEME_VARS=1) —",
42
- " * do not edit by hand. Source: the stock `default` preset in",
43
- " * presets.ts; the regen command is in the contract test doc block. */",
55
+ "/* GENERATED from the Rust palette crate's derivation (packages/palette/",
56
+ " * src/derivation.rs) via the stock-vars.json artifact — do not edit by",
57
+ " * hand. The drift contract pins the TypeScript derivation to these",
58
+ " * values key-for-key; regen is REGEN_STOCK_JSON=1 cargo test",
59
+ " * -p hikari-palette --test stock_snapshot. */",
44
60
  ];
45
61
  for (const mode of MODES) {
46
- const tokens = getThemeTokens("default", mode);
47
- if (!tokens) continue;
48
- const vars = tokensToCSSVars(tokens);
62
+ const vars = stockVars[mode];
49
63
  chunks.push(`html[data-mode="${mode}"] {`);
50
64
  for (const name of Object.keys(vars)) {
51
65
  chunks.push(` ${name}: ${vars[name]};`);
@@ -54,3 +68,5 @@ export function buildThemeVarsCss(): string {
54
68
  }
55
69
  return chunks.join("\n") + "\n";
56
70
  }
71
+
72
+ export { stockVars };