@animus-ui/system 0.1.1 → 0.1.2

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 (42) hide show
  1. package/README.md +125 -4
  2. package/dist/Animus.d.ts +2 -3
  3. package/dist/Animus.d.ts.map +1 -1
  4. package/dist/AnimusExtended.d.ts +2 -3
  5. package/dist/AnimusExtended.d.ts.map +1 -1
  6. package/dist/SystemBuilder.d.ts +27 -8
  7. package/dist/SystemBuilder.d.ts.map +1 -1
  8. package/dist/appearance/index.d.ts +75 -0
  9. package/dist/appearance/index.d.ts.map +1 -0
  10. package/dist/appearance/index.js +179 -0
  11. package/dist/bootstrap/createAppearanceBootstrap.d.ts +71 -0
  12. package/dist/bootstrap/createAppearanceBootstrap.d.ts.map +1 -0
  13. package/dist/bootstrap/index.d.ts +2 -0
  14. package/dist/bootstrap/index.d.ts.map +1 -0
  15. package/dist/bootstrap/index.js +98 -0
  16. package/dist/composeWithContext.d.ts.map +1 -1
  17. package/dist/composeWithContext.js +43 -22
  18. package/dist/conditions.d.ts +163 -0
  19. package/dist/conditions.d.ts.map +1 -0
  20. package/dist/{createComposedFamily-DSE2ZuRE.js → createComposedFamily-DJ2aqfqN.js} +141 -67
  21. package/dist/index.d.ts +4 -3
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +645 -23
  24. package/dist/runtime/index.d.ts +2 -0
  25. package/dist/runtime/index.d.ts.map +1 -1
  26. package/dist/runtime/resolveClasses.d.ts.map +1 -1
  27. package/dist/runtime-entry.js +1 -1
  28. package/dist/selectors.d.ts +22 -0
  29. package/dist/selectors.d.ts.map +1 -1
  30. package/dist/theme/createTheme.d.ts +47 -4
  31. package/dist/theme/createTheme.d.ts.map +1 -1
  32. package/dist/types/component.d.ts +27 -10
  33. package/dist/types/component.d.ts.map +1 -1
  34. package/dist/types/config.d.ts +124 -11
  35. package/dist/types/config.d.ts.map +1 -1
  36. package/dist/types/props.d.ts +0 -4
  37. package/dist/types/props.d.ts.map +1 -1
  38. package/dist/types/theme.d.ts +132 -0
  39. package/dist/types/theme.d.ts.map +1 -1
  40. package/dist/utils/deepMerge.d.ts +0 -3
  41. package/dist/utils/deepMerge.d.ts.map +1 -1
  42. package/package.json +12 -4
package/README.md CHANGED
@@ -136,12 +136,133 @@ ds.styles() → @layer base
136
136
 
137
137
  The type system prevents calling methods out of order. `.variant()` after `.states()` is a type error.
138
138
 
139
+ ## Color Modes
140
+
141
+ `addColorModes(initialMode, modeConfig)` emits a `[data-color-mode="…"]` block
142
+ per mode. An optional third argument opts the theme into OS participation:
143
+
144
+ ```tsx
145
+ const tokens = createTheme()
146
+ .addColors({ gray: { 100: '#f0f0f0', 800: '#1a1a1a' } })
147
+ .addColorModes(
148
+ 'dark',
149
+ {
150
+ dark: { bg: 'gray.800', text: 'gray.100' },
151
+ light: { bg: 'gray.100', text: 'gray.800' },
152
+ },
153
+ {
154
+ // OS preference → declared mode name.
155
+ systemPreference: { light: 'light', dark: 'dark' },
156
+ // CSS `color-scheme` per mode. The two mapped modes default to
157
+ // 'light'/'dark' (the mapping forces them), so `{}` is the whole
158
+ // opt-in here; classify any ADDITIONAL modes explicitly.
159
+ browserColorScheme: {},
160
+ }
161
+ )
162
+ .build();
163
+ ```
164
+
165
+ **`systemPreference`** enables guarded fallback emission:
166
+
167
+ ```css
168
+ @media (prefers-color-scheme: dark) {
169
+ :root:not([data-color-mode]) {
170
+ /* the dark mode's declarations */
171
+ }
172
+ }
173
+ ```
174
+
175
+ The `:not([data-color-mode])` guard is what makes an explicit attribute win — in
176
+ CSS alone, with no script. Both values must name declared modes.
177
+
178
+ **`browserColorScheme`** adds the CSS `color-scheme` property so native
179
+ scrollbars, form controls, and UA styling track the active mode. When supplied it
180
+ must classify _every_ declared mode, otherwise a mode would silently inherit the
181
+ previous one's native scheme — with one carve-out: the two modes named by
182
+ `systemPreference` are forced to `light`/`dark` by validation anyway, so they
183
+ default and may be omitted. An explicit entry on a mapped mode is honored and
184
+ still conflict-checked.
185
+
186
+ A theme that opts into neither emits exactly the bytes it emitted before.
187
+
188
+ ### "System" is the absence of the attribute
189
+
190
+ There is no `data-color-mode="system"` — the OS-following state is the attribute
191
+ being **absent**, which is the only value the media guard above can fall through.
192
+ `system` is a reserved mode name and is rejected.
193
+
194
+ ### The appearance record
195
+
196
+ Persisted appearance lives under one versioned key, `animus:appearance`:
197
+
198
+ ```
199
+ { "v": 1, "mode": "system" | "<mode name>", "theme": "default" }
200
+ ```
201
+
202
+ The `theme` axis is reserved and currently ignored — a writer that owns only the
203
+ mode axis must preserve the fields it does not own. The package ships that
204
+ write discipline so you don't hand-roll it: `@animus-ui/system/appearance` is a
205
+ tiny, storage-only runtime subpath (no React, no listeners, no DOM — applying
206
+ `data-color-mode` stays yours):
207
+
208
+ ```ts
209
+ import {
210
+ SYSTEM_MODE,
211
+ migrateLegacyModeKey,
212
+ persistColorMode,
213
+ } from '@animus-ui/system/appearance';
214
+
215
+ persistColorMode('midnight'); // read-modify-write; unowned fields survive
216
+ persistColorMode(SYSTEM_MODE); // "follow the OS" — bootstrap restores absence
217
+
218
+ // One-shot: move YOUR app's old key into the record, then delete it.
219
+ migrateLegacyModeKey('my-app-color-mode', ['midnight', 'paper']);
220
+ ```
221
+
222
+ It refuses to downgrade a record written by a newer version, and refuses to
223
+ migrate the shared `color-mode` key (that one may belong to another app on your
224
+ origin; the bootstrap already reads it, read-only).
225
+
226
+ To restore it before first paint, generate an inline snippet from the **built**
227
+ theme:
228
+
229
+ ```ts
230
+ import { createAppearanceBootstrap } from '@animus-ui/system/bootstrap';
231
+
232
+ const { code, cspHash } = createAppearanceBootstrap(tokens, {
233
+ storageKey: 'animus:appearance', // default
234
+ });
235
+ ```
236
+
237
+ `code` is a dependency-free IIFE for the document head: it reads the record,
238
+ validates `mode` against the theme's declared names, sets `data-color-mode` for a
239
+ valid explicit mode, and **removes** the attribute for `"system"`, a missing
240
+ record, or an unrecognized value — handing control back to the media query. It
241
+ never writes storage and never calls `matchMedia` (materializing the OS answer
242
+ into the attribute would freeze it against later OS changes). The pre-record
243
+ plain-string `color-mode` key is read once, only when the record is absent, and
244
+ is never written.
245
+
246
+ `cspHash` authorizes that exact script. Derive the header from the artifact at
247
+ build time and **single-quote** the value — `script-src 'sha256-…'`. Unquoted it
248
+ parses as a host source and silently blocks the script; hand-copied, it goes
249
+ stale the moment a mode is renamed.
250
+
251
+ This subpath is build tooling. It is never imported by the component or runtime
252
+ entries, so it cannot reach an extracted application bundle — generate the
253
+ artifact in your bundler config and hand it to the plugin
254
+ ([`@animus-ui/vite-plugin`](https://github.com/codecaaron/animus/tree/main/packages/vite-plugin)
255
+ accepts `appearanceBootstrap`; in Next.js the application places `code` itself,
256
+ so it can control CSP nonce and ordering).
257
+
139
258
  ## Exports
140
259
 
141
- | Path | What's in it |
142
- | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
143
- | `@animus-ui/system` | Full API — builder, theme, runtime, types |
144
- | `@animus-ui/system/groups` | Pre-built prop groups: `space`, `color`, `typography`, `layout`, `flex`, `grid`, `border`, `shadows`, `background`, `positioning`, `transitions` |
260
+ | Path | What's in it |
261
+ | ------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
262
+ | `@animus-ui/system` | Full API — builder, theme, runtime, types |
263
+ | `@animus-ui/system/groups` | Pre-built prop groups: `space`, `color`, `typography`, `layout`, `flex`, `grid`, `border`, `shadows`, `background`, `positioning`, `transitions` |
264
+ | `@animus-ui/system/bootstrap` | `createAppearanceBootstrap` — build-time only, never imported by application code |
265
+ | `@animus-ui/system/appearance` | `persistColorMode`, `migrateLegacyModeKey`, `SYSTEM_MODE` — storage-only appearance record write path (runtime, client-safe) |
145
266
 
146
267
  ## License
147
268
 
package/dist/Animus.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ComponentType } from 'react';
1
2
  import { AnimusExtended } from './AnimusExtended';
2
3
  import { AbstractParser, CompoundEntry, CSSPropMap, CSSProps, CustomPropConfig, Prop, SystemProps, ThemedCSSPropMap, ThemedCSSProps, VariantConfig } from './types/config';
3
4
  import { AbstractProps } from './types/props';
@@ -14,9 +15,7 @@ export declare class AnimusWithAll<PropRegistry extends Record<string, Prop>, Gr
14
15
  constructor(props: PropRegistry, groups: GroupRegistry, base: BaseStyles, variants: Variants, states: States, activeGroups: ActiveGroups, custom: CustomProps, compounds?: CompoundEntry[]);
15
16
  extend(): AnimusExtended<PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
16
17
  asElement<El extends keyof JSX.IntrinsicElements>(component: El): AnimusComponent<El, PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
17
- asComponent<C extends (props: {
18
- className?: string;
19
- }) => any>(AsComponent: C): AnimusWrappedComponent<PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
18
+ asComponent<C extends ComponentType<any>>(AsComponent: C): AnimusWrappedComponent<C, PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
20
19
  asClass(): (props?: Record<string, unknown>) => string;
21
20
  _buildComponentConfig(): {
22
21
  variants: Record<string, {
@@ -1 +1 @@
1
- {"version":3,"file":"Animus.d.ts","sourceRoot":"","sources":["../src/Animus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,EACL,cAAc,EACd,aAAa,EACb,UAAU,EACV,QAAQ,EACR,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,KAAK,EACV,eAAe,EACf,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAE3B,qBAAa,aAAa,CACxB,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,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hD;CACF;AAED,qBAAa,MAAM,CACjB,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,YAAY,CAAC,EAAE,CAAC,CAC5D,SAAQ,cAAc,CAAC,YAAY,EAAE,aAAa,EAAE,EAAE,CAAC;IACvD,YAAY,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAErD;IACD,MAAM,CAAC,KAAK,SAAS,aAAa,EAChC,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,oFAO5C;CACF"}
@@ -1,3 +1,4 @@
1
+ import type { ComponentType } from 'react';
1
2
  import { AbstractParser, CompoundEntry, CSSPropMap, CSSProps, CustomPropConfig, Prop, SystemProps, ThemedCSSPropMap, ThemedCSSProps, VariantConfig } from './types/config';
2
3
  import { AbstractProps } from './types/props';
3
4
  import type { AnimusComponent, AnimusWrappedComponent } from './types/component';
@@ -13,9 +14,7 @@ export declare class AnimusExtendedWithAll<PropRegistry extends Record<string, P
13
14
  constructor(props: PropRegistry, groups: GroupRegistry, base: BaseStyles, variants: Variants, states: States, activeGroups: ActiveGroups, custom: CustomProps, compounds?: CompoundEntry[]);
14
15
  extend(): AnimusExtended<PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
15
16
  asElement<El extends keyof JSX.IntrinsicElements>(component: El): AnimusComponent<El, PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
16
- asComponent<C extends (props: {
17
- className?: string;
18
- }) => any>(AsComponent: C): AnimusWrappedComponent<PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
17
+ asComponent<C extends ComponentType<any>>(AsComponent: C): AnimusWrappedComponent<C, PropRegistry, GroupRegistry, BaseStyles, Variants, States, ActiveGroups, CustomProps>;
19
18
  asClass(): (props?: Record<string, unknown>) => string;
20
19
  _buildComponentConfig(): {
21
20
  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AAgB,CAAC,KAAK,EAAE,YAAY,CAAC;2CAsBhD;CACF;AAED,qBAAa,cAAc,CACzB,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACzC,aAAa,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,YAAY,CAAC,EAAE,CAAC,EAC5D,UAAU,SAAS,QAAQ,CAAC,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,EACvE,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,EAC9C,MAAM,SAAS,UAAU,CAAC,aAAa,EAAE,WAAW,CAAC,cAAc,CAAC,CAAC,EACrE,YAAY,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACzC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CACxC,SAAQ,sBAAsB,CAC9B,YAAY,EACZ,aAAa,EACb,UAAU,EACV,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,WAAW,CACZ;IACC,MAAM,CAAC,KAAK,SAAS,aAAa,EAChC,MAAM,EAAE,cAAc,CAAC,KAAK,EAAE,YAAY,CAAC,sJAoB5C;CACF"}
@@ -1,4 +1,5 @@
1
1
  import { Animus } from './Animus';
2
+ import { type ConditionAliasMap, type RegistryBrand } from './conditions';
2
3
  import { type KeyframeFrameMap, type Keyframes } from './keyframes';
3
4
  import { type SelectorAliasMap } from './selectors';
4
5
  import { NamedTransform } from './transforms/createTransform';
@@ -25,26 +26,44 @@ type IncludableSystem = {
25
26
  export interface CreateSystemConfig {
26
27
  includes?: readonly IncludableSystem[];
27
28
  }
28
- export declare class SystemBuilder<PropReg extends Record<string, Prop> = {}, GroupReg extends Record<string, (keyof PropReg)[]> = {}> {
29
+ export declare class SystemBuilder<PropReg extends Record<string, Prop> = {}, GroupReg extends Record<string, (keyof PropReg)[]> = {}, Conds extends string = never, Sels extends string = never> {
29
30
  #private;
30
- constructor(propRegistry?: PropReg, groupRegistry?: GroupReg, selectorRegistry?: SelectorAliasMap, includesRegistry?: readonly IncludableSystem[]);
31
- addSelectors(selectors: Record<string, string>): SystemBuilder<PropReg, GroupReg>;
32
- addGroup<Name extends string, Conf extends Record<string, Prop>>(name: Name extends keyof PropReg ? never : Name, config: Conf): SystemBuilder<PropReg & Conf, GroupReg & Record<Name, (keyof Conf)[]>>;
33
- addProps<Conf extends Record<string, Prop> & Partial<Record<Extract<keyof GroupReg, string>, never>>>(config: Conf): SystemBuilder<PropReg & Conf, GroupReg>;
31
+ constructor(propRegistry?: PropReg, groupRegistry?: GroupReg, selectorRegistry?: SelectorAliasMap, includesRegistry?: readonly IncludableSystem[], conditionRegistry?: ConditionAliasMap);
32
+ addSelectors<S extends Record<`_${string}`, string>>(selectors: S): SystemBuilder<PropReg, GroupReg, Conds, Sels | Extract<keyof S, string>>;
33
+ /**
34
+ * Register condition aliases (`_motionReduce`, `_cardSm`, …) → at-rule
35
+ * condition strings (`@media …` / `@container …` / `@supports …`).
36
+ * Recognized as block keys in style objects; user aliases override built-ins
37
+ * of the same name (design D3). Keys are constrained to `_`-prefixed aliases
38
+ * and values to `@`-prefixed at-rule strings — a value that does not begin
39
+ * with an at-rule name is a compile-time type error (design D9; the runtime
40
+ * `inferConditionKind` throw is defense-in-depth). The registered keys are
41
+ * accumulated into the phantom `Conds` union and surfaced on `build()`.
42
+ */
43
+ addConditions<C extends Record<`_${string}`, `@media${string}` | `@container${string}` | `@supports${string}`>>(conditions: C): SystemBuilder<PropReg, GroupReg, Conds | Extract<keyof C, string>, Sels>;
44
+ addGroup<Name extends string, Conf extends Record<string, Prop>>(name: Name extends keyof PropReg ? never : Name, config: Conf): SystemBuilder<PropReg & Conf, GroupReg & Record<Name, (keyof Conf)[]>, Conds, Sels>;
45
+ addProps<Conf extends Record<string, Prop> & Partial<Record<Extract<keyof GroupReg, string>, never>>>(config: Conf): SystemBuilder<PropReg & Conf, GroupReg, Conds, Sels>;
34
46
  build(): {
35
- system: SystemInstance<PropReg, GroupReg>;
47
+ system: SystemInstance<PropReg, GroupReg, Conds, Sels>;
36
48
  createGlobalStyles: GlobalStylesFactory<PropReg>;
37
49
  createKeyframes: CreateKeyframesFactory<PropReg>;
38
50
  };
39
51
  }
40
- export type SystemInstance<PropReg extends Record<string, Prop>, GroupReg extends Record<string, (keyof PropReg)[]>> = Animus<PropReg, GroupReg> & {
52
+ export type SystemInstance<PropReg extends Record<string, Prop>, GroupReg extends Record<string, (keyof PropReg)[]>, Conds extends string = never, Sels extends string = never> = Animus<PropReg, GroupReg> & {
41
53
  toConfig(): SerializedConfig;
42
- };
54
+ } & RegistryBrand<Conds, Sels>;
43
55
  export interface SerializedConfig {
44
56
  propConfig: string;
45
57
  groupRegistry: string;
46
58
  transforms: Record<string, NamedTransform>;
47
59
  selectorAliases: string;
60
+ /**
61
+ * Condition alias map JSON (inc 03 — NEW field): `alias → { value, order,
62
+ * kind }`. `"{}"` when the system registers no conditions (built-ins are
63
+ * empty this increment). Distinct from `selectorAliases`, which stays
64
+ * byte-for-byte unchanged.
65
+ */
66
+ conditionAliases: string;
48
67
  }
49
68
  export declare function createSystem(config?: CreateSystemConfig): SystemBuilder;
50
69
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"SystemBuilder.d.ts","sourceRoot":"","sources":["../src/SystemBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,SAAS,EAEf,MAAM,aAAa,CAAC;AACrB,OAAO,EAGL,KAAK,gBAAgB,EAEtB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAW9C,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EA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;IAED,KAAK,IAAI;QACP,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;QACvD,kBAAkB,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACjD,eAAe,EAAE,sBAAsB,CAAC,OAAO,CAAC,CAAC;KAClD,CA+BA;CACF;AAED,MAAM,MAAM,cAAc,CACxB,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,EACpC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,EAAE,CAAC,EAClD,KAAK,SAAS,MAAM,GAAG,KAAK,EAC5B,IAAI,SAAS,MAAM,GAAG,KAAK,IACzB,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG;IAC9B,QAAQ,IAAI,gBAAgB,CAAC;CAC9B,GAAG,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;AAE/B,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AA4DD,wBAAgB,YAAY,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,aAAa,CAOvE"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Appearance record write path — the CLIENT half of the contract the generated
3
+ * bootstrap reads (openspec: color-mode-bootstrap, "Appearance record
4
+ * contract").
5
+ *
6
+ * This module is runtime application code: it ships in client bundles and owns
7
+ * only the record WRITE path. It deliberately imports nothing from
8
+ * `@animus-ui/system/bootstrap` — that subpath is build tooling, reaches
9
+ * `node:crypto`, and must never enter an application bundle — so the two
10
+ * modules re-state the key and shape they agree on, and the round-trip tests
11
+ * pin the agreement (a record written here is restored by the generated
12
+ * snippet).
13
+ *
14
+ * Record: `animus:appearance` → `{"v":1,"mode":…,"theme":…}`.
15
+ *
16
+ * Two axes share one record. A writer that changes ONE axis reads, modifies
17
+ * and writes back, so fields it does not own (`theme`, plus anything a future
18
+ * version adds) survive untouched.
19
+ */
20
+ /**
21
+ * Mode value meaning "follow the OS". It is never a declared mode and never
22
+ * reaches `data-color-mode` — the OS is followed by the attribute's ABSENCE,
23
+ * which the generated bootstrap restores when it reads this value.
24
+ */
25
+ export declare const SYSTEM_MODE = "system";
26
+ export interface AppearanceStorageOptions {
27
+ /**
28
+ * Overrides the record key. MUST match the `storageKey` the bootstrap
29
+ * artifact was generated with, or the snippet restores from a key this
30
+ * module never writes. Defaults to `animus:appearance`.
31
+ */
32
+ storageKey?: string;
33
+ }
34
+ /**
35
+ * Persists the mode axis, preserving every field this call does not own
36
+ * (`v`, `theme`, and any additional keys already in the record).
37
+ *
38
+ * Pass {@link SYSTEM_MODE} to persist "follow the OS" — the generated
39
+ * bootstrap restores it as attribute absence. Applying the mode to the
40
+ * document (setting or removing `data-color-mode`) stays the caller's job:
41
+ * this module is storage-only and never touches the DOM.
42
+ *
43
+ * REFUSAL RULE: when the stored record carries a version this code does not
44
+ * understand, NOTHING is written. Downgrading it to a v1 shape would drop
45
+ * whatever fields the newer writer keeps there, and this axis is not worth
46
+ * that. A caller that has already updated the attribute keeps the user's
47
+ * choice for the session — only its persistence is skipped.
48
+ *
49
+ * Storage failures are likewise swallowed: persistence is a convenience, and
50
+ * the attribute write that accompanies it has already taken effect.
51
+ */
52
+ export declare function persistColorMode(mode: string, options?: AppearanceStorageOptions): void;
53
+ /**
54
+ * One-shot migration of an application's OWN historical mode key into the
55
+ * record.
56
+ *
57
+ * The generated bootstrap only knows the record and the contract's `color-mode`
58
+ * key — an app that persisted under its own key before adopting the record
59
+ * would silently drop every returning visitor's mode without this. Run it
60
+ * post-paint from the app entry: the visit on which it migrates still paints
61
+ * in the OS-resolved mode before correcting itself — one accepted flash, once
62
+ * — and every later load restores pre-paint through the bootstrap.
63
+ *
64
+ * It writes only when there is nothing to lose (no record) and something worth
65
+ * keeping (a value in `declaredModes`), then DELETES the old key so the
66
+ * migration cannot run twice or resurrect a stale value. Deleting is
67
+ * legitimate precisely because the key is the application's own; the
68
+ * contract's `color-mode` key may belong to another app on this origin and is
69
+ * refused, as is the record key itself.
70
+ *
71
+ * @returns the migrated mode name, so the caller can apply it to the document
72
+ * for this one visit, or `null` when nothing was migrated.
73
+ */
74
+ export declare function migrateLegacyModeKey(legacyKey: string, declaredModes: readonly string[], options?: AppearanceStorageOptions): string | null;
75
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/appearance/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAgBH;;;;GAIG;AACH,eAAO,MAAM,WAAW,WAAW,CAAC;AASpC,MAAM,WAAW,wBAAwB;IACvC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAkFD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,wBAAwB,GACjC,IAAI,CAWN;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,SAAS,MAAM,EAAE,EAChC,OAAO,CAAC,EAAE,wBAAwB,GACjC,MAAM,GAAG,IAAI,CAmDf"}
@@ -0,0 +1,179 @@
1
+ //#region src/appearance/index.ts
2
+ /**
3
+ * Appearance record write path — the CLIENT half of the contract the generated
4
+ * bootstrap reads (openspec: color-mode-bootstrap, "Appearance record
5
+ * contract").
6
+ *
7
+ * This module is runtime application code: it ships in client bundles and owns
8
+ * only the record WRITE path. It deliberately imports nothing from
9
+ * `@animus-ui/system/bootstrap` — that subpath is build tooling, reaches
10
+ * `node:crypto`, and must never enter an application bundle — so the two
11
+ * modules re-state the key and shape they agree on, and the round-trip tests
12
+ * pin the agreement (a record written here is restored by the generated
13
+ * snippet).
14
+ *
15
+ * Record: `animus:appearance` → `{"v":1,"mode":…,"theme":…}`.
16
+ *
17
+ * Two axes share one record. A writer that changes ONE axis reads, modifies
18
+ * and writes back, so fields it does not own (`theme`, plus anything a future
19
+ * version adds) survive untouched.
20
+ */
21
+ /** The single versioned appearance record key. */
22
+ const DEFAULT_STORAGE_KEY = "animus:appearance";
23
+ /**
24
+ * The CONTRACT's pre-record key. The generated bootstrap reads it once, only
25
+ * when the record is absent, and never writes it — it may belong to another
26
+ * app on this origin, so this module refuses to migrate (and therefore
27
+ * delete) it. See {@link migrateLegacyModeKey}.
28
+ */
29
+ const CONTRACT_LEGACY_KEY = "color-mode";
30
+ /** The only appearance-record version this module writes or read-modify-writes. */
31
+ const RECORD_VERSION = 1;
32
+ /**
33
+ * Mode value meaning "follow the OS". It is never a declared mode and never
34
+ * reaches `data-color-mode` — the OS is followed by the attribute's ABSENCE,
35
+ * which the generated bootstrap restores when it reads this value.
36
+ */
37
+ const SYSTEM_MODE = "system";
38
+ /** Applied when nothing is stored: OS-driven mode, default theme. */
39
+ const DEFAULT_RECORD = {
40
+ v: RECORD_VERSION,
41
+ mode: SYSTEM_MODE,
42
+ theme: "default"
43
+ };
44
+ function storageOf() {
45
+ return globalThis.localStorage;
46
+ }
47
+ function keyOf(options) {
48
+ const key = options?.storageKey ?? DEFAULT_STORAGE_KEY;
49
+ if (typeof key !== "string" || key === "") throw new Error("appearance: storageKey must be a non-empty string.");
50
+ return key;
51
+ }
52
+ /**
53
+ * Reads the stored record.
54
+ *
55
+ * READ FAILURE vs. ABSENT: a `getItem` that THROWS (blocked or partitioned
56
+ * storage) — or no storage object at all — is reported as `absent`, not
57
+ * `foreign`, deliberately. "Absent" here means "this code has no knowledge of
58
+ * a stored record", and a store we cannot read at all is indistinguishable
59
+ * from an empty one. The asymmetry is safe because the accompanying write is
60
+ * wrapped in its own try/catch: a store that throws on read throws on write
61
+ * too, so the `absent` classification can never actually clobber anything.
62
+ * Only a store we CAN read and whose content we cannot interpret yields
63
+ * `foreign`.
64
+ *
65
+ * A present-but-corrupt value (not JSON, not an object) is `absent`: it is
66
+ * nobody's live state, so replacing it with a clean record is a repair. A
67
+ * present record carrying an unrecognized `v` is `foreign`: that is a future
68
+ * writer's data, and v1-shaped fields written over it would destroy fields
69
+ * this version does not know exist.
70
+ */
71
+ function readRecord(storageKey) {
72
+ let raw = null;
73
+ try {
74
+ raw = storageOf()?.getItem(storageKey) ?? null;
75
+ } catch {
76
+ return { kind: "absent" };
77
+ }
78
+ if (typeof raw !== "string" || raw === "") return { kind: "absent" };
79
+ let parsed;
80
+ try {
81
+ parsed = JSON.parse(raw);
82
+ } catch {
83
+ return { kind: "absent" };
84
+ }
85
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return { kind: "absent" };
86
+ const record = parsed;
87
+ if (record.v !== RECORD_VERSION) return { kind: "foreign" };
88
+ return {
89
+ kind: "record",
90
+ record
91
+ };
92
+ }
93
+ /**
94
+ * Persists the mode axis, preserving every field this call does not own
95
+ * (`v`, `theme`, and any additional keys already in the record).
96
+ *
97
+ * Pass {@link SYSTEM_MODE} to persist "follow the OS" — the generated
98
+ * bootstrap restores it as attribute absence. Applying the mode to the
99
+ * document (setting or removing `data-color-mode`) stays the caller's job:
100
+ * this module is storage-only and never touches the DOM.
101
+ *
102
+ * REFUSAL RULE: when the stored record carries a version this code does not
103
+ * understand, NOTHING is written. Downgrading it to a v1 shape would drop
104
+ * whatever fields the newer writer keeps there, and this axis is not worth
105
+ * that. A caller that has already updated the attribute keeps the user's
106
+ * choice for the session — only its persistence is skipped.
107
+ *
108
+ * Storage failures are likewise swallowed: persistence is a convenience, and
109
+ * the attribute write that accompanies it has already taken effect.
110
+ */
111
+ function persistColorMode(mode, options) {
112
+ const storageKey = keyOf(options);
113
+ const outcome = readRecord(storageKey);
114
+ if (outcome.kind === "foreign") return;
115
+ const base = outcome.kind === "record" ? outcome.record : DEFAULT_RECORD;
116
+ try {
117
+ storageOf()?.setItem(storageKey, JSON.stringify({
118
+ ...base,
119
+ mode
120
+ }));
121
+ } catch {}
122
+ }
123
+ /**
124
+ * One-shot migration of an application's OWN historical mode key into the
125
+ * record.
126
+ *
127
+ * The generated bootstrap only knows the record and the contract's `color-mode`
128
+ * key — an app that persisted under its own key before adopting the record
129
+ * would silently drop every returning visitor's mode without this. Run it
130
+ * post-paint from the app entry: the visit on which it migrates still paints
131
+ * in the OS-resolved mode before correcting itself — one accepted flash, once
132
+ * — and every later load restores pre-paint through the bootstrap.
133
+ *
134
+ * It writes only when there is nothing to lose (no record) and something worth
135
+ * keeping (a value in `declaredModes`), then DELETES the old key so the
136
+ * migration cannot run twice or resurrect a stale value. Deleting is
137
+ * legitimate precisely because the key is the application's own; the
138
+ * contract's `color-mode` key may belong to another app on this origin and is
139
+ * refused, as is the record key itself.
140
+ *
141
+ * @returns the migrated mode name, so the caller can apply it to the document
142
+ * for this one visit, or `null` when nothing was migrated.
143
+ */
144
+ function migrateLegacyModeKey(legacyKey, declaredModes, options) {
145
+ const storageKey = keyOf(options);
146
+ if (legacyKey === CONTRACT_LEGACY_KEY) throw new Error(`appearance: '${CONTRACT_LEGACY_KEY}' is the contract's shared legacy key — the generated bootstrap reads it read-only and it may belong to another app on this origin. Migrate only keys your application owns.`);
147
+ if (legacyKey === storageKey) throw new Error(`appearance: legacyKey '${legacyKey}' is the record key itself — nothing to migrate.`);
148
+ const forget = () => {
149
+ try {
150
+ storageOf()?.removeItem(legacyKey);
151
+ } catch {}
152
+ };
153
+ if (readRecord(storageKey).kind !== "absent") {
154
+ forget();
155
+ return null;
156
+ }
157
+ let legacy = null;
158
+ try {
159
+ legacy = storageOf()?.getItem(legacyKey) ?? null;
160
+ } catch {
161
+ return null;
162
+ }
163
+ if (typeof legacy !== "string" || !declaredModes.includes(legacy)) {
164
+ if (legacy !== null) forget();
165
+ return null;
166
+ }
167
+ try {
168
+ storageOf()?.setItem(storageKey, JSON.stringify({
169
+ ...DEFAULT_RECORD,
170
+ mode: legacy
171
+ }));
172
+ } catch {
173
+ return null;
174
+ }
175
+ forget();
176
+ return legacy;
177
+ }
178
+ //#endregion
179
+ export { SYSTEM_MODE, migrateLegacyModeKey, persistColorMode };
@@ -0,0 +1,71 @@
1
+ /**
2
+ * The slice of a built theme the generator reads: the declared mode names.
3
+ * Structural on purpose — the generator reads mode KEYS only and never touches
4
+ * the theme's pipeline wire (guardrail G5).
5
+ */
6
+ export interface AppearanceBootstrapTheme {
7
+ manifest: {
8
+ /** Mode name → resolved tokens. Only the KEYS are read. */
9
+ modes?: Record<string, unknown>;
10
+ };
11
+ }
12
+ export interface AppearanceBootstrapOptions {
13
+ /** Overrides the record key. Defaults to `animus:appearance`. */
14
+ storageKey?: string;
15
+ }
16
+ export interface AppearanceBootstrapArtifact {
17
+ /** Dependency-free inline IIFE, safe to embed in a document head. */
18
+ code: string;
19
+ /**
20
+ * `sha256-<base64>` — the CSP hash of `code`, ready for a `script-src`
21
+ * source list.
22
+ *
23
+ * The source expression MUST be SINGLE-QUOTED in the header, exactly as
24
+ * returned:
25
+ *
26
+ * ```
27
+ * Content-Security-Policy: script-src 'sha256-<the artifact hash>'
28
+ * ```
29
+ *
30
+ * Unquoted, it is parsed as a host source and silently fails to authorize
31
+ * the script.
32
+ *
33
+ * Always derive the header from this field at build time — never hand-copy
34
+ * it. Any theme edit that changes the declared mode names (or a changed
35
+ * `storageKey`) changes `code` and therefore this hash; a stale literal in a
36
+ * config file turns into a blocked script and a flash of the wrong mode.
37
+ */
38
+ cspHash: string;
39
+ }
40
+ /**
41
+ * Builds the inline appearance-restoration script for a built theme.
42
+ *
43
+ * The generated snippet, before first paint:
44
+ * 1. reads the appearance record from `storageKey`, falling back to the legacy
45
+ * `color-mode` key ONLY when the record is absent (missing key, or an empty
46
+ * string, which is not a record);
47
+ * 2. accepts the record only at version `1` — a future or absent version is
48
+ * treated as NO record, because an older snippet cannot interpret a newer
49
+ * record and absence is the neutral fail-safe;
50
+ * 3. sets `data-color-mode` when the resulting name is a declared mode;
51
+ * 4. removes the attribute for `system`, no record, an unreadable store, or an
52
+ * unknown mode — absence is how "follow the OS" is represented, so later OS
53
+ * changes apply with no script running.
54
+ *
55
+ * The failure semantics are deliberately asymmetric:
56
+ * - storage that THROWS on read (private browsing, blocked storage) means "no
57
+ * knowledge", so the attribute is REMOVED and the media-query fallback takes
58
+ * over; freezing a server-rendered mode would defeat that fallback;
59
+ * - a record that is PRESENT but unparseable means "storage is telling us
60
+ * something we cannot read", so the snippet exits leaving the server-rendered
61
+ * markup exactly as it was.
62
+ *
63
+ * It never writes storage, never calls `matchMedia`, and ignores the record's
64
+ * `theme` axis. Identical inputs always yield byte-identical output.
65
+ *
66
+ * @throws if the theme declares no color modes (a bootstrap without a mode
67
+ * allowlist could not validate anything), declares the reserved name
68
+ * `system`, or declares a blank mode name.
69
+ */
70
+ export declare function createAppearanceBootstrap(theme: AppearanceBootstrapTheme, options?: AppearanceBootstrapOptions): AppearanceBootstrapArtifact;
71
+ //# sourceMappingURL=createAppearanceBootstrap.d.ts.map