@codefast/theme 0.5.0 → 0.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/CHANGELOG.md +32 -0
- package/README.md +24 -9
- package/dist/appearance-context.d.ts +2 -1
- package/dist/appearance-context.d.ts.map +1 -1
- package/dist/appearance-context.js +1 -3
- package/dist/appearance-context.js.map +1 -1
- package/dist/appearance-provider.d.ts.map +1 -1
- package/dist/appearance-provider.js +2 -4
- package/dist/appearance-provider.js.map +1 -1
- package/dist/appearance-script.d.ts.map +1 -1
- package/dist/appearance-script.js +1 -3
- package/dist/appearance-script.js.map +1 -1
- package/dist/appearance.d.ts +3 -3
- package/dist/appearance.d.ts.map +1 -1
- package/dist/appearance.js +5 -1
- package/dist/appearance.js.map +1 -1
- package/dist/color-scheme.d.ts +2 -2
- package/dist/color-scheme.d.ts.map +1 -1
- package/dist/color-scheme.js +3 -5
- package/dist/color-scheme.js.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +2 -6
- package/dist/constants.js.map +1 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +2 -4
- package/dist/dom.js.map +1 -1
- package/dist/use-appearance.d.ts.map +1 -1
- package/dist/use-appearance.js +1 -3
- package/dist/use-appearance.js.map +1 -1
- package/package.json +6 -6
- package/src/appearance-context.ts +5 -4
- package/src/appearance-provider.tsx +3 -7
- package/src/appearance-script.tsx +2 -6
- package/src/appearance.ts +6 -2
- package/src/color-scheme.ts +3 -5
- package/src/constants.ts +2 -6
- package/src/dom.ts +2 -4
- package/src/use-appearance.ts +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @codefast/theme
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#690](https://github.com/codefastlabs/codefast/pull/690) [`f4b1aa6`](https://github.com/codefastlabs/codefast/commit/f4b1aa6335f535574eae5cf559b81a568f5a7a30) Thanks [@thevuong](https://github.com/thevuong)! - Report the failures that were being swallowed or mislabelled, and derive the types the build emits.
|
|
8
|
+
|
|
9
|
+
`@codefast/di`:
|
|
10
|
+
|
|
11
|
+
- `@inject`, `@postConstruct` and `@preDestroy` on a static member now throw `StaticMemberDecoratorError` instead of
|
|
12
|
+
`InternalError`. All three act on one instance, so this is caller misuse — and `InternalError` means the library
|
|
13
|
+
broke, which sent anyone catching it to file a bug against their own mistake. SPEC §10 already recorded that mistake
|
|
14
|
+
for predicate ambiguity.
|
|
15
|
+
- `AsyncResolutionError` names the token the caller asked for and the token whose factory is async, which is what SPEC
|
|
16
|
+
has always specified. Every throw site passed the same token twice, so the message read "Token 'X' requires async
|
|
17
|
+
resolution because 'X' in its dependency chain has an async factory"; a `resolve(App)` that fails on an async
|
|
18
|
+
`Database` now says so. `asyncSourceToken` defaults to `tokenName` for the case where the requested binding is itself
|
|
19
|
+
the source.
|
|
20
|
+
- A `MetadataReader` that names a `@postConstruct`/`@preDestroy` method the instance does not have raises
|
|
21
|
+
`InvalidMetadataError` instead of skipping the hook — a hook that silently never runs is the failure a caller cannot
|
|
22
|
+
see. `InvalidMetadataError`'s message no longer says "constructor", since it now covers both answers; the specifics
|
|
23
|
+
moved into `reason`.
|
|
24
|
+
- `MissingScopeContextError` from `ScopeManager` names its token instead of `"(unknown)"`, and the scoped read takes one
|
|
25
|
+
map lookup where it took two.
|
|
26
|
+
- `Token`, `Constructor` and `InjectionDescriptor` declare `out Value`, so the compiler checks the covariance the engine
|
|
27
|
+
already relied on.
|
|
28
|
+
|
|
29
|
+
Repo-wide: `isolatedDeclarations` is on for every package that emits declarations, so a public type can always be
|
|
30
|
+
written down from the source file alone. `allowJs` is gone from the shared base config — no package has JavaScript
|
|
31
|
+
sources. `@codefast/theme` and `@codefast/tracking` gained explicit annotations on four exported constants to satisfy
|
|
32
|
+
it; the emitted types are unchanged. `@codefast/ui` and `@codefast/benchmark-viewer` opt out for reasons recorded in
|
|
33
|
+
their configs.
|
|
34
|
+
|
|
3
35
|
## 0.5.0
|
|
4
36
|
|
|
5
37
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# @codefast/theme
|
|
2
2
|
|
|
3
|
-
Appearance management for React 19 — optimistic updates, cross-tab sync, and FOUC-free SSR, with vocabulary borrowed
|
|
3
|
+
Appearance management for React 19 — optimistic updates, cross-tab sync, and FOUC-free SSR, with vocabulary borrowed
|
|
4
|
+
from Apple's Human Interface Guidelines.
|
|
4
5
|
|
|
5
6
|
[](https://www.npmjs.com/package/@codefast/theme)
|
|
6
7
|
[](https://github.com/codefastlabs/codefast/blob/main/LICENSE)
|
|
@@ -12,7 +13,8 @@ Two words, two meanings, kept apart throughout the API:
|
|
|
12
13
|
| `Appearance` | `"light" \| "dark" \| "automatic"` | The user's preference — think macOS System Settings: Light / Dark / Auto. |
|
|
13
14
|
| `ColorScheme` | `"light" \| "dark"` | The resolved value actually applied to the page, after `automatic` is resolved. |
|
|
14
15
|
|
|
15
|
-
The preference lives entirely on the client in `localStorage` — no cookies, loaders, or server functions. Built on React
|
|
16
|
+
The preference lives entirely on the client in `localStorage` — no cookies, loaders, or server functions. Built on React
|
|
17
|
+
19's `useOptimistic`, `useSyncExternalStore`, and `useEffectEvent`.
|
|
16
18
|
|
|
17
19
|
## Installation
|
|
18
20
|
|
|
@@ -22,7 +24,8 @@ pnpm add @codefast/theme
|
|
|
22
24
|
# yarn add @codefast/theme
|
|
23
25
|
```
|
|
24
26
|
|
|
25
|
-
Requires `react` and `react-dom` version 19 or later as peer dependencies. Published
|
|
27
|
+
Requires `react` and `react-dom` version 19 or later as peer dependencies. Published on `0.x` with no 1.0 planned —
|
|
28
|
+
breaking changes ship as minor versions.
|
|
26
29
|
|
|
27
30
|
## Quick Start
|
|
28
31
|
|
|
@@ -50,7 +53,9 @@ function Page() {
|
|
|
50
53
|
}
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
`setAppearance` updates the UI immediately (optimistic), persists to `localStorage`, and reverts automatically if
|
|
56
|
+
`setAppearance` updates the UI immediately (optimistic), persists to `localStorage`, and reverts automatically if
|
|
57
|
+
persistence fails. The resolved color scheme is applied to `<html>` as a `light` / `dark` class plus the CSS
|
|
58
|
+
`color-scheme` property, so Tailwind `dark:` variants and native controls both follow along.
|
|
54
59
|
|
|
55
60
|
A three-state selector needs no hard-coded list — `appearances` is `["light", "dark", "automatic"]`:
|
|
56
61
|
|
|
@@ -78,7 +83,10 @@ function AppearanceSelect() {
|
|
|
78
83
|
|
|
79
84
|
## FOUC-free SSR
|
|
80
85
|
|
|
81
|
-
React hydrates after first paint, so server-rendered HTML alone would flash the wrong colors for returning visitors.
|
|
86
|
+
React hydrates after first paint, so server-rendered HTML alone would flash the wrong colors for returning visitors.
|
|
87
|
+
`<AppearanceScript>` fixes this: a tiny inline script in `<head>` that reads `localStorage`, resolves `automatic` via
|
|
88
|
+
`matchMedia`, and applies the correct class before anything paints — including on statically prerendered, CDN-served
|
|
89
|
+
pages.
|
|
82
90
|
|
|
83
91
|
A TanStack Start root shell (works the same in any framework that lets you render into the document head):
|
|
84
92
|
|
|
@@ -113,7 +121,9 @@ function RootDocument({ children }: { children: ReactNode }) {
|
|
|
113
121
|
}
|
|
114
122
|
```
|
|
115
123
|
|
|
116
|
-
The server renders the defaults; the script corrects `<html>` before first paint and `suppressHydrationWarning` absorbs
|
|
124
|
+
The server renders the defaults; the script corrects `<html>` before first paint and `suppressHydrationWarning` absorbs
|
|
125
|
+
the mismatch. The script also mirrors the preference (not the resolved value) to a `data-appearance` attribute, so
|
|
126
|
+
preference-aware UI can render correctly from pure CSS on the very first frame:
|
|
117
127
|
|
|
118
128
|
```css
|
|
119
129
|
/* highlight the "Auto" option when the stored preference is automatic */
|
|
@@ -122,11 +132,15 @@ html[data-appearance="automatic"] .option-auto {
|
|
|
122
132
|
}
|
|
123
133
|
```
|
|
124
134
|
|
|
125
|
-
If your Content Security Policy requires nonces for inline scripts, pass one: `<AppearanceScript nonce={cspNonce} />`.
|
|
135
|
+
If your Content Security Policy requires nonces for inline scripts, pass one: `<AppearanceScript nonce={cspNonce} />`.
|
|
136
|
+
The same prop exists on `<AppearanceProvider>` for the temporary inline style used by `disableTransition`.
|
|
126
137
|
|
|
127
138
|
## Cross-tab sync
|
|
128
139
|
|
|
129
|
-
Appearance changes propagate to every open tab: the provider broadcasts over a `BroadcastChannel` and falls back to the
|
|
140
|
+
Appearance changes propagate to every open tab: the provider broadcasts over a `BroadcastChannel` and falls back to the
|
|
141
|
+
`storage` event where the channel is unavailable. Incoming messages are schema-validated before being applied, and each
|
|
142
|
+
tab re-resolves `automatic` against its own OS preference. No configuration needed — it works out of the box with the
|
|
143
|
+
default `localStorage` persistence.
|
|
130
144
|
|
|
131
145
|
## API
|
|
132
146
|
|
|
@@ -149,7 +163,8 @@ Everything below ships from the root entry unless a subpath is noted.
|
|
|
149
163
|
| `applyColorScheme()`, `suppressTransitions()` (`@codefast/theme/dom`) | functions | DOM helpers for custom integrations. |
|
|
150
164
|
| `AppearanceContext` (`@codefast/theme/appearance-context`) | context | Raw context for custom providers. |
|
|
151
165
|
|
|
152
|
-
Granular subpaths (`./appearance`, `./appearance-provider`, `./use-appearance`, ...) mirror the source modules for
|
|
166
|
+
Granular subpaths (`./appearance`, `./appearance-provider`, `./use-appearance`, ...) mirror the source modules for
|
|
167
|
+
bundler-aware imports — see the `exports` field in `package.json` for the full list.
|
|
153
168
|
|
|
154
169
|
### AppearanceProvider props
|
|
155
170
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Context } from "react";
|
|
1
2
|
import type { AppearanceContextValue } from "#/appearance";
|
|
2
3
|
/**
|
|
3
4
|
* React context for appearance state management.
|
|
@@ -10,5 +11,5 @@ import type { AppearanceContextValue } from "#/appearance";
|
|
|
10
11
|
*
|
|
11
12
|
* @since 0.5.0-canary.2
|
|
12
13
|
*/
|
|
13
|
-
export declare const AppearanceContext:
|
|
14
|
+
export declare const AppearanceContext: Context<null | AppearanceContextValue>;
|
|
14
15
|
//# sourceMappingURL=appearance-context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-context.d.ts","sourceRoot":"","sources":["../src/appearance-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appearance-context.d.ts","sourceRoot":"","sources":["../src/appearance-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAGrC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAI3D;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,EAAE,OAAO,CAAC,IAAI,GAAG,sBAAsB,CAEpE,CAAC"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { createContext } from "react";
|
|
2
|
-
|
|
3
|
-
* Context
|
|
4
|
-
* -------------------------------------------------------------------------- */
|
|
2
|
+
// ── Context ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
5
3
|
/**
|
|
6
4
|
* React context for appearance state management.
|
|
7
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-context.js","sourceRoot":"","sources":["../src/appearance-context.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"appearance-context.js","sourceRoot":"","sources":["../src/appearance-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAItC,wHAAwH;AAExH;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAA2C,aAAa,CACpF,IAAI,CACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-provider.d.ts","sourceRoot":"","sources":["../src/appearance-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAa5C,OAAO,KAAK,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"appearance-provider.d.ts","sourceRoot":"","sources":["../src/appearance-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAa5C,OAAO,KAAK,EAAE,UAAU,EAAuC,MAAM,cAAc,CAAC;AAsEpF;;GAEG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;OAEG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClE;;OAEG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE,UAAU,KAAK,IAAI,CAAC;IACpF;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAIF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,iBAAyB,EACzB,KAAK,EACL,cAAc,EACd,iBAAiB,EACjB,UAAwB,EACxB,UAAU,EAAE,iBAAsC,GACnD,EAAE,uBAAuB,GAAG,GAAG,CAAC,OAAO,CA6MvC"}
|
|
@@ -43,7 +43,7 @@ function createAppearanceChannel() {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* Reads and validates the persisted preference from localStorage. Returns null when unavailable
|
|
47
47
|
* (SSR, private mode) or when the stored value is not a recognised appearance.
|
|
48
48
|
*/
|
|
49
49
|
function readAppearanceFromStorage(storageKey) {
|
|
@@ -58,9 +58,7 @@ function readAppearanceFromStorage(storageKey) {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
* Component
|
|
63
|
-
* -------------------------------------------------------------------------- */
|
|
61
|
+
// ── Component ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
64
62
|
/**
|
|
65
63
|
* Provider component for appearance state management.
|
|
66
64
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-provider.js","sourceRoot":"","sources":["../src/appearance-provider.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,WAAW,EACX,SAAS,EACT,cAAc,EACd,OAAO,EACP,aAAa,EACb,MAAM,EACN,QAAQ,EACR,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AAE9D;;;;;gFAKgF;AAEhF;;;;;GAKG;AACH,SAAS,4BAA4B,CAAC,QAAoB;IACxD,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;IAE5C,UAAU,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAEhD,OAAO,GAAG,EAAE;QACV,UAAU,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC,CAAC;AACJ,CAAC;AAED,8FAA8F;AAC9F,SAAS,iBAAiB;IACxB,OAAO,oBAAoB,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,SAAS,uBAAuB;IAC9B,IAAI,OAAO,gBAAgB,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,OAAO,IAAI,gBAAgB,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,yBAAyB,CAAC,UAAkB;IACnD,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,gBAAgB,CAAC,SAAS,CAAC,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;QAE9F,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;
|
|
1
|
+
{"version":3,"file":"appearance-provider.js","sourceRoot":"","sources":["../src/appearance-provider.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,eAAe,EACf,WAAW,EACX,SAAS,EACT,cAAc,EACd,OAAO,EACP,aAAa,EACb,MAAM,EACN,QAAQ,EACR,oBAAoB,GACrB,MAAM,OAAO,CAAC;AAGf,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,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AAC,4CAA4C,EAAE,aAAa,CAAC,CAAC;oBAC7E,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAC;gBACpD,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,oFAAoF;gBACpF,yFAAyF;gBACzF,2BAA2B;gBAC3B,MAAM,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC;gBAE5C,IAAI,MAAM,EAAE,CAAC;oBACX,oBAAoB,CAAC,OAAO,GAAG,IAAI,CAAC;oBACpC,MAAM,EAAE,CAAC;gBACX,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,iBAAiB,EAAE,KAAK,EAAE,uBAAuB,EAAE,OAAO,EAAE,cAAc,CAAC,CAC7E,CAAC;IAEF,sEAAsE;IACtE,MAAM,KAAK,GAAG,OAAO,CACnB,GAAG,EAAE,CAAC,CAAC;QACL,SAAS;QACT,WAAW;QACX,aAAa;QACb,UAAU,EAAE,oBAAoB;KACjC,CAAC,EACF,CAAC,oBAAoB,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,CAAC,CAC9D,CAAC;IAEF,OAAO,KAAC,iBAAiB,IAAC,KAAK,EAAE,KAAK,YAAG,QAAQ,GAAqB,CAAC;AACzE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-script.d.ts","sourceRoot":"","sources":["../src/appearance-script.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"appearance-script.d.ts","sourceRoot":"","sources":["../src/appearance-script.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAGjC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAe/C;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;IACjC;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,KAAK,EACL,UAAwB,EACxB,UAA+B,GAChC,EAAE,qBAAqB,GAAG,GAAG,CAAC,OAAO,CAQrC"}
|
|
@@ -9,9 +9,7 @@ function toScriptSafe(value) {
|
|
|
9
9
|
/* Derived once from schema + constants — the inline script uses these to stay in sync */
|
|
10
10
|
const APPEARANCE_REMOVE_ARGS = appearances.map((s) => toScriptSafe(s)).join(",");
|
|
11
11
|
const APPEARANCE_VALID_CHECK = appearances.map((s) => `s===${toScriptSafe(s)}`).join("||");
|
|
12
|
-
|
|
13
|
-
* Component
|
|
14
|
-
* -------------------------------------------------------------------------- */
|
|
12
|
+
// ── Component ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
15
13
|
/**
|
|
16
14
|
* Inline script that prevents Flash of Unstyled Content (FOUC).
|
|
17
15
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance-script.js","sourceRoot":"","sources":["../src/appearance-script.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,kBAAkB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErE;mFACmF;AACnF,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,SAAS,CAA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,EAC/B,KAAK,EACL,UAAU,GAAG,WAAW,EACxB,UAAU,GAAG,kBAAkB,GACT;IACtB,wFAAwF;IACxF,oFAAoF;IACpF,6DAA6D;IAC7D,MAAM,gBAAgB,GAAG,0BAA0B,YAAY,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,UAAU,CAAC,2CAA2C,sBAAsB,0FAA0F,YAAY,CAAC,KAAK,CAAC,uEAAuE,sBAAsB,oLAAoL,CAAC;IAC1iB,MAAM,UAAU,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;IAExD,OAAO,iBAAQ,uBAAuB,EAAE,EAAE,MAAM,EAAE,gBAAgB,EAAE,EAAE,wBAAwB,WAAK,UAAU,GAAI,CAAC;AACpH,CAAC"}
|
package/dist/appearance.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ import { z } from "zod";
|
|
|
8
8
|
* @since 0.5.0-canary.2
|
|
9
9
|
*/
|
|
10
10
|
export declare const appearanceSchema: z.ZodEnum<{
|
|
11
|
-
automatic: "automatic";
|
|
12
|
-
dark: "dark";
|
|
13
11
|
light: "light";
|
|
12
|
+
dark: "dark";
|
|
13
|
+
automatic: "automatic";
|
|
14
14
|
}>;
|
|
15
15
|
/**
|
|
16
16
|
* User's appearance preference.
|
|
@@ -37,7 +37,7 @@ export type ColorScheme = Exclude<Appearance, "automatic">;
|
|
|
37
37
|
*
|
|
38
38
|
* @since 0.5.0-canary.2
|
|
39
39
|
*/
|
|
40
|
-
export declare const appearances:
|
|
40
|
+
export declare const appearances: Array<Appearance>;
|
|
41
41
|
/**
|
|
42
42
|
* Shape of the context value provided by AppearanceProvider.
|
|
43
43
|
*
|
package/dist/appearance.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"appearance.d.ts","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAWxB;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAAC,CAAC,OAAO,CAAC;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,WAAW,CAAA;CAAE,CAI/F,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,UAAU,CAA4B,CAAC;AAEvE;;;;;;;;;GASG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACnC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7D,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;CACjC,CAAC"}
|
package/dist/appearance.js
CHANGED
|
@@ -15,7 +15,11 @@ import { z } from "zod";
|
|
|
15
15
|
*
|
|
16
16
|
* @since 0.5.0-canary.2
|
|
17
17
|
*/
|
|
18
|
-
export const appearanceSchema = z.enum([
|
|
18
|
+
export const appearanceSchema = z.enum([
|
|
19
|
+
"light",
|
|
20
|
+
"dark",
|
|
21
|
+
"automatic",
|
|
22
|
+
]);
|
|
19
23
|
/**
|
|
20
24
|
* Array of all available appearance options: `['light', 'dark', 'automatic']`.
|
|
21
25
|
*
|
package/dist/appearance.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appearance.js","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;gFAOgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"appearance.js","sourceRoot":"","sources":["../src/appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;gFAOgF;AAEhF;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAwE,CAAC,CAAC,IAAI,CAAC;IAC1G,OAAO;IACP,MAAM;IACN,WAAW;CACZ,CAAC,CAAC;AAsBH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAsB,gBAAgB,CAAC,OAAO,CAAC"}
|
package/dist/color-scheme.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Appearance, ColorScheme } from "#/appearance";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Detects the OS color scheme preference.
|
|
4
4
|
*
|
|
5
5
|
* Uses `matchMedia()` to query the `prefers-color-scheme` media feature.
|
|
6
6
|
* Returns {@link DEFAULT_COLOR_SCHEME} during SSR since `window` is unavailable.
|
|
@@ -11,7 +11,7 @@ import type { Appearance, ColorScheme } from "#/appearance";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function getSystemColorScheme(): ColorScheme;
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Resolves an appearance preference to the color scheme to apply.
|
|
15
15
|
*
|
|
16
16
|
* - 'light' → 'light'
|
|
17
17
|
* - 'dark' → 'dark'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"color-scheme.d.ts","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAK5D;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,IAAI,WAAW,CAMlD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,GAAG,WAAW,CAMtE"}
|
package/dist/color-scheme.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { DEFAULT_COLOR_SCHEME, MEDIA } from "#/constants";
|
|
2
|
-
|
|
3
|
-
* Color Scheme Resolution
|
|
4
|
-
* -------------------------------------------------------------------------- */
|
|
2
|
+
// ── Color Scheme Resolution ──────────────────────────────────────────────────────────────────────────────────────────
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
4
|
+
* Detects the OS color scheme preference.
|
|
7
5
|
*
|
|
8
6
|
* Uses `matchMedia()` to query the `prefers-color-scheme` media feature.
|
|
9
7
|
* Returns {@link DEFAULT_COLOR_SCHEME} during SSR since `window` is unavailable.
|
|
@@ -19,7 +17,7 @@ export function getSystemColorScheme() {
|
|
|
19
17
|
return globalThis.window.matchMedia(MEDIA).matches ? "dark" : "light";
|
|
20
18
|
}
|
|
21
19
|
/**
|
|
22
|
-
*
|
|
20
|
+
* Resolves an appearance preference to the color scheme to apply.
|
|
23
21
|
*
|
|
24
22
|
* - 'light' → 'light'
|
|
25
23
|
* - 'dark' → 'dark'
|
package/dist/color-scheme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-scheme.js","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D
|
|
1
|
+
{"version":3,"file":"color-scheme.js","sourceRoot":"","sources":["../src/color-scheme.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE1D,wHAAwH;AAExH;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,OAAO,UAAU,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;QAC7C,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,OAAO,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;AACxE,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB;IACvD,IAAI,UAAU,KAAK,WAAW,EAAE,CAAC;QAC/B,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,OAAO,oBAAoB,EAAE,CAAC;AAChC,CAAC"}
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAI5D;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAAwB,CAAC;AAE1D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,EAAE,WAAoB,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,kBAAkB,CAAC;AAI3C;;;;;GAKG;AACH,eAAO,MAAM,KAAK,iCAAiC,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,YAAY,oBAAoB,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Public Constants
|
|
3
|
-
* -------------------------------------------------------------------------- */
|
|
1
|
+
// ── Public Constants ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
4
2
|
/**
|
|
5
3
|
* Default appearance preference when no stored value exists.
|
|
6
4
|
*
|
|
@@ -26,9 +24,7 @@ export const DEFAULT_COLOR_SCHEME = "dark";
|
|
|
26
24
|
* @since 0.3.16-canary.0
|
|
27
25
|
*/
|
|
28
26
|
export const STORAGE_KEY = "ui-appearance";
|
|
29
|
-
|
|
30
|
-
* Internal Constants
|
|
31
|
-
* -------------------------------------------------------------------------- */
|
|
27
|
+
// ── Internal Constants ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
32
28
|
/**
|
|
33
29
|
* CSS media query for detecting dark mode preference.
|
|
34
30
|
* @internal
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,wHAAwH;AAExH;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe,WAAW,CAAC;AAE1D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAgB,MAAM,CAAC;AAExD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAC;AAE3C,wHAAwH;AAExH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,8BAA8B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAC"}
|
package/dist/dom.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ColorScheme } from "#/appearance";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Applies a color scheme to the DOM by updating the `<html>` element.
|
|
4
4
|
*
|
|
5
5
|
* Updates both:
|
|
6
6
|
* - CSS class (for Tailwind's `dark:` variants)
|
package/dist/dom.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAM/D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,IAAI,CAyC9D"}
|
package/dist/dom.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
* DOM Utilities
|
|
3
|
-
* -------------------------------------------------------------------------- */
|
|
1
|
+
// ── DOM Utilities ────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
4
2
|
/**
|
|
5
|
-
*
|
|
3
|
+
* Applies a color scheme to the DOM by updating the `<html>` element.
|
|
6
4
|
*
|
|
7
5
|
* Updates both:
|
|
8
6
|
* - CSS class (for Tailwind's `dark:` variants)
|
package/dist/dom.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"dom.js","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAEA,wHAAwH;AAExH;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAAC,WAA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CAAC,UAAU,EAAE,CAAC;oBACnB,GAAG,CAAC,MAAM,EAAE,CAAC;gBACf,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-appearance.d.ts","sourceRoot":"","sources":["../src/use-appearance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"use-appearance.d.ts","sourceRoot":"","sources":["../src/use-appearance.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAK3D;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,IAAI,sBAAsB,CAQtD"}
|
package/dist/use-appearance.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { use } from "react";
|
|
2
2
|
import { AppearanceContext } from "#/appearance-context";
|
|
3
|
-
|
|
4
|
-
* Hook
|
|
5
|
-
* -------------------------------------------------------------------------- */
|
|
3
|
+
// ── Hook ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
6
4
|
/**
|
|
7
5
|
* Hook to access appearance context.
|
|
8
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-appearance.js","sourceRoot":"","sources":["../src/use-appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"use-appearance.js","sourceRoot":"","sources":["../src/use-appearance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAG5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,wHAAwH;AAExH;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,KAAK,GAAG,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAErC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;IAC7E,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codefast/theme",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Appearance management for React 19 with HIG-inspired vocabulary - optimistic updates, cross-tab sync, and FOUC-free SSR",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dark-mode",
|
|
@@ -110,17 +110,17 @@
|
|
|
110
110
|
},
|
|
111
111
|
"devDependencies": {
|
|
112
112
|
"@testing-library/dom": "^10.4.1",
|
|
113
|
-
"@testing-library/jest-dom": "^7.0.
|
|
113
|
+
"@testing-library/jest-dom": "^7.0.1",
|
|
114
114
|
"@testing-library/react": "^16.3.2",
|
|
115
|
-
"@testing-library/user-event": "^14.6.
|
|
116
|
-
"@types/node": "^26.
|
|
115
|
+
"@testing-library/user-event": "^14.6.4",
|
|
116
|
+
"@types/node": "^26.2.0",
|
|
117
117
|
"@vitejs/plugin-react": "^6.0.5",
|
|
118
118
|
"@vitest/coverage-v8": "^4.1.10",
|
|
119
119
|
"jsdom": "^30.0.1",
|
|
120
120
|
"typescript": "^7.0.2",
|
|
121
|
-
"vite": "^8.2.
|
|
121
|
+
"vite": "^8.2.1",
|
|
122
122
|
"vitest": "^4.1.10",
|
|
123
|
-
"@codefast/typescript-config": "0.
|
|
123
|
+
"@codefast/typescript-config": "0.6.0"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
126
|
"@types/react": ">=19.0.0",
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import type { Context } from "react";
|
|
1
2
|
import { createContext } from "react";
|
|
2
3
|
|
|
3
4
|
import type { AppearanceContextValue } from "#/appearance";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
* Context
|
|
7
|
-
* -------------------------------------------------------------------------- */
|
|
6
|
+
// ── Context ──────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* React context for appearance state management.
|
|
@@ -17,4 +16,6 @@ import type { AppearanceContextValue } from "#/appearance";
|
|
|
17
16
|
*
|
|
18
17
|
* @since 0.5.0-canary.2
|
|
19
18
|
*/
|
|
20
|
-
export const AppearanceContext = createContext<null | AppearanceContextValue>(
|
|
19
|
+
export const AppearanceContext: Context<null | AppearanceContextValue> = createContext<null | AppearanceContextValue>(
|
|
20
|
+
null,
|
|
21
|
+
);
|
|
@@ -62,7 +62,7 @@ function createAppearanceChannel(): BroadcastChannel | null {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Reads and validates the persisted preference from localStorage. Returns null when unavailable
|
|
66
66
|
* (SSR, private mode) or when the stored value is not a recognised appearance.
|
|
67
67
|
*/
|
|
68
68
|
function readAppearanceFromStorage(storageKey: string): Appearance | null {
|
|
@@ -79,9 +79,7 @@ function readAppearanceFromStorage(storageKey: string): Appearance | null {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
* Props
|
|
84
|
-
* -------------------------------------------------------------------------- */
|
|
82
|
+
// ── Props ────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
85
83
|
|
|
86
84
|
/**
|
|
87
85
|
* @since 0.5.0-canary.2
|
|
@@ -127,9 +125,7 @@ export type AppearanceProviderProps = {
|
|
|
127
125
|
readonly storageKey?: string;
|
|
128
126
|
};
|
|
129
127
|
|
|
130
|
-
|
|
131
|
-
* Component
|
|
132
|
-
* -------------------------------------------------------------------------- */
|
|
128
|
+
// ── Component ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
133
129
|
|
|
134
130
|
/**
|
|
135
131
|
* Provider component for appearance state management.
|
|
@@ -14,9 +14,7 @@ function toScriptSafe(value: unknown): string {
|
|
|
14
14
|
const APPEARANCE_REMOVE_ARGS = appearances.map((s) => toScriptSafe(s)).join(",");
|
|
15
15
|
const APPEARANCE_VALID_CHECK = appearances.map((s) => `s===${toScriptSafe(s)}`).join("||");
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
* Props
|
|
19
|
-
* -------------------------------------------------------------------------- */
|
|
17
|
+
// ── Props ────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
20
18
|
|
|
21
19
|
/**
|
|
22
20
|
* @since 0.5.0-canary.2
|
|
@@ -39,9 +37,7 @@ export type AppearanceScriptProps = {
|
|
|
39
37
|
readonly storageKey?: string;
|
|
40
38
|
};
|
|
41
39
|
|
|
42
|
-
|
|
43
|
-
* Component
|
|
44
|
-
* -------------------------------------------------------------------------- */
|
|
40
|
+
// ── Component ────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
45
41
|
|
|
46
42
|
/**
|
|
47
43
|
* Inline script that prevents Flash of Unstyled Content (FOUC).
|
package/src/appearance.ts
CHANGED
|
@@ -17,7 +17,11 @@ import { z } from "zod";
|
|
|
17
17
|
*
|
|
18
18
|
* @since 0.5.0-canary.2
|
|
19
19
|
*/
|
|
20
|
-
export const appearanceSchema
|
|
20
|
+
export const appearanceSchema: z.ZodEnum<{ light: "light"; dark: "dark"; automatic: "automatic" }> = z.enum([
|
|
21
|
+
"light",
|
|
22
|
+
"dark",
|
|
23
|
+
"automatic",
|
|
24
|
+
]);
|
|
21
25
|
|
|
22
26
|
/**
|
|
23
27
|
* User's appearance preference.
|
|
@@ -46,7 +50,7 @@ export type ColorScheme = Exclude<Appearance, "automatic">;
|
|
|
46
50
|
*
|
|
47
51
|
* @since 0.5.0-canary.2
|
|
48
52
|
*/
|
|
49
|
-
export const appearances = appearanceSchema.options;
|
|
53
|
+
export const appearances: Array<Appearance> = appearanceSchema.options;
|
|
50
54
|
|
|
51
55
|
/**
|
|
52
56
|
* Shape of the context value provided by AppearanceProvider.
|
package/src/color-scheme.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { Appearance, ColorScheme } from "#/appearance";
|
|
2
2
|
import { DEFAULT_COLOR_SCHEME, MEDIA } from "#/constants";
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
* Color Scheme Resolution
|
|
6
|
-
* -------------------------------------------------------------------------- */
|
|
4
|
+
// ── Color Scheme Resolution ──────────────────────────────────────────────────────────────────────────────────────────
|
|
7
5
|
|
|
8
6
|
/**
|
|
9
|
-
*
|
|
7
|
+
* Detects the OS color scheme preference.
|
|
10
8
|
*
|
|
11
9
|
* Uses `matchMedia()` to query the `prefers-color-scheme` media feature.
|
|
12
10
|
* Returns {@link DEFAULT_COLOR_SCHEME} during SSR since `window` is unavailable.
|
|
@@ -24,7 +22,7 @@ export function getSystemColorScheme(): ColorScheme {
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
/**
|
|
27
|
-
*
|
|
25
|
+
* Resolves an appearance preference to the color scheme to apply.
|
|
28
26
|
*
|
|
29
27
|
* - 'light' → 'light'
|
|
30
28
|
* - 'dark' → 'dark'
|
package/src/constants.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { Appearance, ColorScheme } from "#/appearance";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* Public Constants
|
|
5
|
-
* -------------------------------------------------------------------------- */
|
|
3
|
+
// ── Public Constants ─────────────────────────────────────────────────────────────────────────────────────────────────
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
6
|
* Default appearance preference when no stored value exists.
|
|
@@ -32,9 +30,7 @@ export const DEFAULT_COLOR_SCHEME: ColorScheme = "dark";
|
|
|
32
30
|
*/
|
|
33
31
|
export const STORAGE_KEY = "ui-appearance";
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
* Internal Constants
|
|
37
|
-
* -------------------------------------------------------------------------- */
|
|
33
|
+
// ── Internal Constants ───────────────────────────────────────────────────────────────────────────────────────────────
|
|
38
34
|
|
|
39
35
|
/**
|
|
40
36
|
* CSS media query for detecting dark mode preference.
|
package/src/dom.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { ColorScheme } from "#/appearance";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
* DOM Utilities
|
|
5
|
-
* -------------------------------------------------------------------------- */
|
|
3
|
+
// ── DOM Utilities ────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
6
4
|
|
|
7
5
|
/**
|
|
8
|
-
*
|
|
6
|
+
* Applies a color scheme to the DOM by updating the `<html>` element.
|
|
9
7
|
*
|
|
10
8
|
* Updates both:
|
|
11
9
|
* - CSS class (for Tailwind's `dark:` variants)
|
package/src/use-appearance.ts
CHANGED
|
@@ -3,9 +3,7 @@ import { use } from "react";
|
|
|
3
3
|
import type { AppearanceContextValue } from "#/appearance";
|
|
4
4
|
import { AppearanceContext } from "#/appearance-context";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
* Hook
|
|
8
|
-
* -------------------------------------------------------------------------- */
|
|
6
|
+
// ── Hook ─────────────────────────────────────────────────────────────────────────────────────────────────────────────
|
|
9
7
|
|
|
10
8
|
/**
|
|
11
9
|
* Hook to access appearance context.
|