@omerdlw/base-framework 3.2.2 → 3.4.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/MIGRATION.md +11 -0
- package/dist/ambient/index.js +1 -1
- package/dist/ambient/server/index.js +2 -2
- package/dist/ambient/worker/index.js +1 -1
- package/dist/{chunk-MMVVHQ7V.js → chunk-67MOKJFZ.js} +174 -75
- package/dist/chunk-67MOKJFZ.js.map +1 -0
- package/dist/{chunk-FXO4QJQ4.js → chunk-AZ2ZDFNP.js} +6 -6
- package/dist/{chunk-FXO4QJQ4.js.map → chunk-AZ2ZDFNP.js.map} +1 -1
- package/dist/{chunk-2EFQJITY.js → chunk-FFJWJ4OB.js} +1341 -1133
- package/dist/chunk-FFJWJ4OB.js.map +1 -0
- package/dist/{chunk-2LGI33JP.js → chunk-GKAJ4EM2.js} +169 -73
- package/dist/chunk-GKAJ4EM2.js.map +1 -0
- package/dist/{chunk-TKOGBAW3.js → chunk-QGPRTUED.js} +3 -3
- package/dist/{chunk-TKOGBAW3.js.map → chunk-QGPRTUED.js.map} +1 -1
- package/dist/{chunk-7XUAYJOA.js → chunk-VNSMNGWP.js} +3 -3
- package/dist/{chunk-7XUAYJOA.js.map → chunk-VNSMNGWP.js.map} +1 -1
- package/dist/{chunk-FS2R34VD.js → chunk-XGAYTDSI.js} +36 -36
- package/dist/chunk-XGAYTDSI.js.map +1 -0
- package/dist/context-menu/index.js +3 -3
- package/dist/dock/index.js +2 -2
- package/dist/index.js +6 -6
- package/dist/modules/ambient/analyze-ground.d.ts +42 -0
- package/dist/modules/ambient/analyze-ground.d.ts.map +1 -0
- package/dist/modules/ambient/analyze.d.ts +1 -1
- package/dist/modules/ambient/analyze.d.ts.map +1 -1
- package/dist/modules/ambient/dom.d.ts.map +1 -1
- package/dist/modules/ambient/hooks.d.ts.map +1 -1
- package/dist/modules/ambient/settings.d.ts.map +1 -1
- package/dist/modules/ambient/types.d.ts +16 -4
- package/dist/modules/ambient/types.d.ts.map +1 -1
- package/dist/modules/dock/components/card-header.d.ts +1 -1
- package/dist/modules/dock/components/card-header.d.ts.map +1 -1
- package/dist/modules/dock/components/card-item.d.ts +1 -1
- package/dist/modules/dock/components/card-item.d.ts.map +1 -1
- package/dist/modules/dock/components/command-bar.d.ts.map +1 -1
- package/dist/modules/dock/components/compact.d.ts +9 -0
- package/dist/modules/dock/components/compact.d.ts.map +1 -0
- package/dist/modules/dock/components/item-content.d.ts.map +1 -1
- package/dist/modules/dock/context.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-action-slot.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-card-item-model.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts +1 -1
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-dock-viewport.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-pending-skeleton.d.ts +7 -0
- package/dist/modules/dock/hooks/use-pending-skeleton.d.ts.map +1 -0
- package/dist/modules/dock/lib/card-item.d.ts +7 -0
- package/dist/modules/dock/lib/card-item.d.ts.map +1 -1
- package/dist/modules/dock/model/layout.d.ts +19 -4
- package/dist/modules/dock/model/layout.d.ts.map +1 -1
- package/dist/modules/dock/model/paths.d.ts +7 -0
- package/dist/modules/dock/model/paths.d.ts.map +1 -1
- package/dist/modules/dock/motion.d.ts.map +1 -1
- package/dist/modules/dock/provider.d.ts.map +1 -1
- package/dist/modules/dock/runtime/display.d.ts.map +1 -1
- package/dist/modules/dock/runtime/dock.d.ts +2 -0
- package/dist/modules/dock/runtime/dock.d.ts.map +1 -1
- package/dist/modules/dock/runtime/hooks/use-dock.d.ts.map +1 -1
- package/dist/modules/dock/runtime/model/cards.d.ts +5 -2
- package/dist/modules/dock/runtime/model/cards.d.ts.map +1 -1
- package/dist/modules/dock/runtime/pipeline.d.ts.map +1 -1
- package/dist/modules/dock/types/card.d.ts +17 -0
- package/dist/modules/dock/types/card.d.ts.map +1 -1
- package/dist/modules/dock/types/compact.d.ts +13 -0
- package/dist/modules/dock/types/compact.d.ts.map +1 -0
- package/dist/modules/dock/types/index.d.ts +1 -0
- package/dist/modules/dock/types/index.d.ts.map +1 -1
- package/dist/modules/dock/types/theme.d.ts +30 -1
- package/dist/modules/dock/types/theme.d.ts.map +1 -1
- package/dist/modules/index.js +6 -6
- package/dist/navigation/index.js +4 -4
- package/docs/modules/ambient.md +79 -58
- package/docs/modules/dock.md +25 -15
- package/package.json +1 -1
- package/dist/chunk-2EFQJITY.js.map +0 -1
- package/dist/chunk-2LGI33JP.js.map +0 -1
- package/dist/chunk-FS2R34VD.js.map +0 -1
- package/dist/chunk-MMVVHQ7V.js.map +0 -1
package/docs/modules/ambient.md
CHANGED
|
@@ -28,12 +28,14 @@ client image URL ─fetch─▶ createImageBitmap ─────┤ (w
|
|
|
28
28
|
▼
|
|
29
29
|
roles: dominant · vibrant · muted · accent (each: colour, `on`, 11-tone ramp)
|
|
30
30
|
regions: top · bottom · left · right · center
|
|
31
|
-
|
|
31
|
+
page: the page tone for the ground (dark or light) · presence: how colourful
|
|
32
32
|
▼
|
|
33
33
|
CSS variables on the target element ─▶ everything that reads them re-tints
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
Ambient is a **colour pipeline**, not a component: pick an image (or pass colors directly), and the `--ambient-*` variables change. The app maps its own tokens onto them, e.g. `:root { --primary: var(--ambient-vibrant, #101010); --
|
|
36
|
+
Ambient is a **colour pipeline**, not a component: pick an image (or pass colors directly), and the `--ambient-*` variables change. The app maps its own tokens onto them, e.g. `:root { --primary: var(--ambient-vibrant, #101010); --bg: var(--ambient-page, #0b0b0b) }`; Tailwind classes such as `bg-primary` and anything using `var(--bg)` then follow automatically, and the fallbacks apply whenever no palette is set.
|
|
37
|
+
|
|
38
|
+
A palette is made for one **ground**, the kind of page it lies on: `"dark"` (default) or `"light"`. The app says which once (`configureAmbient({ analysis: { ground: "light" } })`, and the same `analysis` on the server); the framework then makes the page tone, the region glows and the roles for that ground, and stays out of everything else. See §6.1.
|
|
37
39
|
|
|
38
40
|
A palette is plain JSON (~2.7 KB), so it can be computed once on the server, cached, and passed down as `initialPalette`. When its `source` is the same image URL, the client does not extract again. Client extraction is the fallback.
|
|
39
41
|
|
|
@@ -53,7 +55,7 @@ useAmbientTheme({ image: backdropUrl || account?.avatarUrl || null });
|
|
|
53
55
|
// 4. Explicit colors, scoped to one element
|
|
54
56
|
const cardRef = useRef<HTMLDivElement>(null);
|
|
55
57
|
useAmbientTheme({
|
|
56
|
-
colors: { "--ambient-vibrant": "#e5d3ff", "--ambient-
|
|
58
|
+
colors: { "--ambient-vibrant": "#e5d3ff", "--ambient-page": "#140d1f" },
|
|
57
59
|
scope: cardRef,
|
|
58
60
|
});
|
|
59
61
|
```
|
|
@@ -110,14 +112,15 @@ The app builds the `Worker` itself because only its bundler can turn `new URL(".
|
|
|
110
112
|
|
|
111
113
|
Default names; see §5.2 to rename them or turn groups off. Nothing is written until a palette exists.
|
|
112
114
|
|
|
113
|
-
| Variable | Value
|
|
114
|
-
| :----------------------------- |
|
|
115
|
-
| `--ambient-
|
|
116
|
-
| `--ambient-
|
|
117
|
-
| `--ambient-
|
|
118
|
-
| `--ambient-{role}
|
|
119
|
-
| `--ambient-{
|
|
120
|
-
|
|
|
115
|
+
| Variable | Value |
|
|
116
|
+
| :----------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------- |
|
|
117
|
+
| `--ambient-page` | the page tone for the ground (§6.1): dark L ≈ 0.16 in the shadows' hue; light L 0.9–0.955 in the image's mood (chroma 0 for grey images) |
|
|
118
|
+
| `--ambient-presence` | how colourful the image is, `0` (grey) … `1`: e.g. the opacity of a wash |
|
|
119
|
+
| `--ambient-{role}` | the role's colour; roles: `dominant`, `vibrant`, `muted`, `accent` |
|
|
120
|
+
| `--ambient-on-{role}` | text colour on that role, ≥ 4.5:1 (WCAG 2) by default |
|
|
121
|
+
| `--ambient-{role}-{tone}` | ramp tones `10 15 20 30 40 50 60 70 80 90 95` (= OKLCH L × 100) |
|
|
122
|
+
| `--ambient-{region}` | regions: `top`, `bottom`, `left`, `right`, `center` |
|
|
123
|
+
| any variable named in `colors` | the literal value |
|
|
121
124
|
|
|
122
125
|
`colors` keys are custom property names: a key starting with `--` is used verbatim; anything else becomes `--color-<key>`. `colors` always wins over extracted values.
|
|
123
126
|
|
|
@@ -164,23 +167,25 @@ Until a palette exists the shared state's `palette` is `null` and no variable is
|
|
|
164
167
|
|
|
165
168
|
Settings live on `globalThis`, so every bundled copy of the module (one per package entry) shares them. Call it once at start-up, in a client module (and on the server too if you change `analysis`).
|
|
166
169
|
|
|
167
|
-
| Setting | Default
|
|
168
|
-
| :----------- |
|
|
169
|
-
| `proxy` | `"/api/ambient/proxy?url="`
|
|
170
|
-
| `strategy` | `"auto"`
|
|
171
|
-
| `worker` | `null`
|
|
172
|
-
| `cssVars` | `--ambient-
|
|
173
|
-
| `analysis` | `DEFAULT_ANALYSIS`
|
|
174
|
-
| `cacheLimit` | `100`
|
|
175
|
-
| `linger` | `3000` (`DEFAULT_LINGER_MS`)
|
|
170
|
+
| Setting | Default | Meaning |
|
|
171
|
+
| :----------- | :----------------------------------------------------------------------------------------------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
172
|
+
| `proxy` | `"/api/ambient/proxy?url="` | Tried last, only for cross-origin images whose direct request (and its one cache-bypassing retry) failed. A string is a prefix the encoded URL is appended to, or a template with `{url}`; a function returns the URL; `null` turns it off. |
|
|
173
|
+
| `strategy` | `"auto"` | `"auto"`: the worker if one is configured, else the main thread. `"worker"`: worker only (no main-thread extraction). `"main"`: main thread only. `"none"`: never extract on the client (server palettes only). |
|
|
174
|
+
| `worker` | `null` | `() => Worker` running `serveAmbientWorker()` (§3.2). If it fails to start or errors, extraction falls back to the main thread (except under `"worker"`). |
|
|
175
|
+
| `cssVars` | `--ambient-page`, `--ambient-presence`, `--ambient-{role}`, `--ambient-on-{role}`, `--ambient-{role}-{tone}`, `--ambient-{region}`, all 11 tones | Rename any variable; `null` turns that variable or group off; `tones: [10, 20, 90]` or `false` limits the ramp variables. |
|
|
176
|
+
| `analysis` | `DEFAULT_ANALYSIS` | `sampleSize` 128, `clusters` 7, `centerWeight` 0.5, `letterbox` true, `minHueDistance` 40, `minContrast` 4.5, `ground` `"dark"`. |
|
|
177
|
+
| `cacheLimit` | `100` | Client palettes kept (oldest evicted). |
|
|
178
|
+
| `linger` | `3000` (`DEFAULT_LINGER_MS`) | How long (ms) a page-wide theme's variables stay after it goes, so the next page takes over from them. `0` removes them at once. |
|
|
176
179
|
|
|
177
180
|
### 5.3 `AmbientPalette`
|
|
178
181
|
|
|
179
182
|
```ts
|
|
180
183
|
{
|
|
181
184
|
source?: string | null; // the image URL it was made from
|
|
185
|
+
ground: "dark" | "light"; // the ground it was made for
|
|
182
186
|
neutral: boolean; // the image has (almost) no colour
|
|
183
|
-
|
|
187
|
+
presence: number; // 0 grey … 1 fully coloured
|
|
188
|
+
page: string; // the page tone for the ground (oklch())
|
|
184
189
|
roles: Record<"dominant" | "vibrant" | "muted" | "accent", {
|
|
185
190
|
color: string; on: string; // oklch() strings
|
|
186
191
|
l: number; c: number; h: number;
|
|
@@ -217,29 +222,44 @@ Before every request, redirects included, the host is resolved (`resolve`, defau
|
|
|
217
222
|
- **Clustering.** Pixels are binned by 15-bit RGB (OKLab averaged per bin). Coloured bins (chroma ≥ 0.022) and grey bins are clustered **apart** with weighted, deterministically seeded k-means in OKLab (ΔL counts 0.45×, so hue beats lightness; vivid bins pull up to ~2.5× harder), 5 + 2 clusters by default. Splitting them keeps the greys of a dark poster from using up every cluster and swallowing its one coloured detail. The vivid pull only shapes the clusters: a cluster's colour is the plain mean of its pixels, so a face is not tinted toward the red title it shares a cluster with.
|
|
218
223
|
- **Roles.** A hue's share is that of its family (clusters within 20°). `dominant` = max share × chroma; `vibrant` = max chroma² × share^0.3; `accent` = the best hue at least `minHueDistance` (40°) from `dominant`, or `vibrant` marked `fromImage: false` when the image has one hue; `muted` = the largest low-chroma (≤ 0.09) colour, or a quiet tone of the dominant hue. Skin, hair, wood and tungsten-lit walls (hues near 54°, chroma 0.03–0.12, see `skinLikeness`) count up to 65% less in every pick, roles and regions alike: film frames are full of them, and they are what a frame shows, rarely its mood. Hue trust fades below L 0.28 and above L 0.9.
|
|
219
224
|
- **Tones.** A role keeps about its source's **chroma**, not its share of the gamut: × 1.15 (`dominant`, regions), × 1.3 (`accent`), × 1.35 (`vibrant`), × 1 (`muted`); a faint tint is raised to at most 0.05 so it still reads as a colour; skin is held back up to 30%; and reds and oranges get a 30% lower ceiling, since they read louder than blues at the same chroma. Carrying the gamut share instead (as before `AMBIENT_ANALYSIS_VERSION` 2) turned pale faces and beige rooms into loud orange: at mid lightness orange has twice the room teal has. The ramp keeps the role's share of the gamut at each L (`toneOf`, × 0.96 of `maxChroma`), so a dark tone of blue stays blue; nothing is ever out of gamut.
|
|
220
|
-
- **`
|
|
225
|
+
- **`page`.** Dark ground: the hue of the shadows (clusters at L ≤ 0.5, scored by share × relative chroma) or, without coloured shadows, of `dominant`; at L 0.16 ± 0.02 and up to 0.1 chroma. Light ground: paper in the hue of `dominant` (the image's mood, not its shadows), 35% of its chroma held to 0.01–0.05 (warm and skin hues 30% less, scaled down for faint images), at L 0.955 ± 0.008, stepping down (no lower than 0.9) until the hue has the gamut room for that chroma: near white, sRGB holds five times more yellow than violet, so a yellow film's paper stays near white and a violet one's turns lilac.
|
|
226
|
+
- **`presence`.** The coloured share of the image (weighted by colourfulness and hue trust), 1 from 25% up; 0 for a neutral image.
|
|
221
227
|
- **`on`.** A near-white or near-black carrying a hint of the role's hue, pushed toward pure white / black until it reaches `minContrast`.
|
|
222
|
-
- **Regions.** Each region (thirds of the content box; `center` is the middle half) takes its most chromatic-and-present cluster, coloured by that cluster's own pixels **in the region** (not its frame-wide mean), at
|
|
223
|
-
- **Neutral images.** If coloured pixels make up under 3% (weighted), the palette is grey: `neutral: true`, `dominant`, `vibrant`, `muted`, `
|
|
228
|
+
- **Regions.** Each region (thirds of the content box; `center` is the middle half) takes its most chromatic-and-present cluster, coloured by that cluster's own pixels **in the region** (not its frame-wide mean), at the ground's region lightness (§6.1) and × 1.15 its chroma; `strength` is how coloured the region is.
|
|
229
|
+
- **Neutral images.** If coloured pixels make up under 3% (weighted), the palette is grey: `neutral: true`, `dominant`, `vibrant`, `muted`, `page` and regions have chroma 0, `presence` is 0. A vivid detail (≥ 0.6% of the image, chroma ≥ 0.06) still becomes `accent`, e.g. the red coat in _Schindler's List_.
|
|
224
230
|
- **Cost.** About 3–8 ms per image for the analysis (Node, warm); in Chromium, ~13 ms for a cached image end to end on the main thread, ~20 ms through the worker (off the main thread). ~2.7 KB of JSON per palette.
|
|
225
231
|
- **Cache.** Client: `cacheLimit` palettes (oldest evicted), keyed by URL (+ analysis overrides); concurrent requests share one promise. Server: 500 per process. A cache that outlives a deploy (`unstable_cache`, a database) should carry `AMBIENT_ANALYSIS_VERSION` in its key, so palettes are computed again when the analysis changes.
|
|
226
232
|
- **Stability.** `colors`, `cssVars`, `options` and `initialPalette` are stabilized with `shallowEqual`, so fresh object literals each render do **not** re-apply the theme (keep `cssVars.tones` a constant array). The same pixels always give the same palette.
|
|
227
233
|
- **Failure.** Client: `extractPaletteFromImage` resolves `null` and the hooks keep `initialPalette` (or nothing); it never throws. Server: `null`, except a missing decoder.
|
|
228
234
|
|
|
235
|
+
### 6.1 Grounds
|
|
236
|
+
|
|
237
|
+
Everything else in the analysis (clusters, role picks, skin, ramps, `on`) is the same on both grounds; the ground moves only these:
|
|
238
|
+
|
|
239
|
+
| | `dark` (default) | `light` |
|
|
240
|
+
| :---------------------- | :------------------------------------------------------------------------- | :----------------------------------------------------------------------------------------------- |
|
|
241
|
+
| `page` | L 0.16, the shadows' hue | L 0.9–0.955, the mood's (dominant) hue; lower where the hue needs room for its colour |
|
|
242
|
+
| Role lightness bands | dominant 0.42–0.74 · vibrant 0.62–0.84 · muted 0.38–0.66 · accent 0.55–0.8 | dominant 0.42–0.6 · vibrant 0.5–0.64 · muted 0.42–0.58 · accent 0.46–0.62 |
|
|
243
|
+
| Role contrast on `page` | ≥ 3:1 (lifted if needed) | ≥ 4.5:1 (deepened if needed): a role reads as text on paper |
|
|
244
|
+
| Regions | L 0.42–0.72 (glows on dark); colourless 0.3–0.7 | L 0.8–0.9 (pale light on paper); colourless at the page's lightness, so they leave no grey stain |
|
|
245
|
+
|
|
246
|
+
A palette carries its `ground`; an `initialPalette` made for another ground than the one configured is not shown (its page and roles would sit at the wrong lightness), so set the same `analysis.ground` on the server and the client.
|
|
247
|
+
|
|
229
248
|
## 7. Recipes and gotchas
|
|
230
249
|
|
|
231
|
-
| I want to…
|
|
232
|
-
|
|
|
233
|
-
| Tint a page from its hero image
|
|
234
|
-
| No flash, no client work
|
|
235
|
-
| Glows that follow the picture
|
|
236
|
-
| Text on a role colour
|
|
237
|
-
| A surface a few steps
|
|
238
|
-
|
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
|
242
|
-
|
|
|
250
|
+
| I want to… | Do this |
|
|
251
|
+
| :---------------------------------- | :---------------------------------------------------------------------------------------------------- |
|
|
252
|
+
| Tint a page from its hero image | `usePage({ ambient: heroUrl })` |
|
|
253
|
+
| No flash, no client work | Compute on the server (§3.1); add `configureAmbient({ strategy: "none" })` if every image has one |
|
|
254
|
+
| Glows that follow the picture | `radial-gradient(at 20% 0%, color-mix(in oklab, var(--ambient-top) 30%, transparent), transparent)` … |
|
|
255
|
+
| Text on a role colour | `background: var(--ambient-accent); color: var(--ambient-on-accent)` |
|
|
256
|
+
| A surface a few steps off the page | dark: `var(--ambient-dominant-20)` / `-30`; light: `-90` / `-95` |
|
|
257
|
+
| Fade a wash with the image's colour | `opacity: var(--ambient-presence, 0)` |
|
|
258
|
+
| Tint only one section | `useAmbientTheme({ image, scope: "#section" })` |
|
|
259
|
+
| Rename the variables | `configureAmbient({ cssVars: { page: "--bg", role: "--tint-{role}" } })` |
|
|
260
|
+
| Fewer variables on `<html>` | `configureAmbient({ cssVars: { tones: [20, 80], region: null } })` |
|
|
261
|
+
| Own proxy / no proxy | `configureAmbient({ proxy: "/img?u={url}" })` / `{ proxy: null }` |
|
|
262
|
+
| Disable tint on one page | `usePage({ ambient: false })` |
|
|
243
263
|
|
|
244
264
|
- The theme is global by default: two components calling `useAmbientTheme` without `scope` fight over the `--ambient-*` variables; the last effect wins.
|
|
245
265
|
- Cross-origin images that block CORS **and** the proxy cannot be sampled on the client; `initialPalette` (or the app's CSS fallbacks) stays. The server has no CORS limits.
|
|
@@ -248,28 +268,29 @@ Before every request, redirects included, the host is resolved (`resolve`, defau
|
|
|
248
268
|
|
|
249
269
|
## 8. File map
|
|
250
270
|
|
|
251
|
-
| File | Responsibility
|
|
252
|
-
| :-------------------- |
|
|
253
|
-
| `index.ts` | Public barrel export (client entry).
|
|
254
|
-
| `constants.ts` | `ambientTheme` spec.
|
|
255
|
-
| `types.ts` | Palette, swatch, region, settings, config, descriptor, page contracts.
|
|
256
|
-
| `settings.ts` | Defaults, `configureAmbient` (on `globalThis`), proxy resolution. Pure.
|
|
257
|
-
| `oklab.ts` | OKLab/OKLCH math, gamut room (`maxChroma`), tones, WCAG contrast, `on` colours. Pure.
|
|
258
|
-
| `quantize.ts` | Deterministic weighted k-means. Pure.
|
|
259
|
-
| `analyze.ts` | `analyzeAmbientPixels`: roles, ramps, regions, `
|
|
260
|
-
| `analyze-
|
|
261
|
-
| `analyze-
|
|
262
|
-
| `analyze-
|
|
263
|
-
| `analyze-
|
|
264
|
-
| `
|
|
265
|
-
| `
|
|
266
|
-
| `
|
|
267
|
-
| `
|
|
268
|
-
| `server/
|
|
269
|
-
| `
|
|
270
|
-
| `
|
|
271
|
-
| `
|
|
272
|
-
| `
|
|
271
|
+
| File | Responsibility |
|
|
272
|
+
| :-------------------- | :--------------------------------------------------------------------------------------------- |
|
|
273
|
+
| `index.ts` | Public barrel export (client entry). |
|
|
274
|
+
| `constants.ts` | `ambientTheme` spec. |
|
|
275
|
+
| `types.ts` | Palette, swatch, region, settings, config, descriptor, page contracts. |
|
|
276
|
+
| `settings.ts` | Defaults, `configureAmbient` (on `globalThis`), proxy resolution. Pure. |
|
|
277
|
+
| `oklab.ts` | OKLab/OKLCH math, gamut room (`maxChroma`), tones, WCAG contrast, `on` colours. Pure. |
|
|
278
|
+
| `quantize.ts` | Deterministic weighted k-means. Pure. |
|
|
279
|
+
| `analyze.ts` | `analyzeAmbientPixels`: roles, ramps, regions, `page`, `presence`, from the parts below. Pure. |
|
|
280
|
+
| `analyze-ground.ts` | Per-ground lightness bands, the page tone and role readability. Pure. |
|
|
281
|
+
| `analyze-bounds.ts` | Letterbox cut (`findContentBounds`). Pure. |
|
|
282
|
+
| `analyze-clusters.ts` | Binning and clustering of pixels. Pure. |
|
|
283
|
+
| `analyze-measures.ts` | Thresholds, cluster reliability and colorfulness measures. Pure. |
|
|
284
|
+
| `analyze-swatches.ts` | Role chroma and tone fitting, swatch building. Pure. |
|
|
285
|
+
| `pipeline.ts` | fetch → `createImageBitmap` → canvas pixels → analysis; runs in a window or a worker. |
|
|
286
|
+
| `extractor.ts` | Client cache, strategy, worker dispatch with main-thread fallback. |
|
|
287
|
+
| `worker/index.ts` | `serveAmbientWorker` (the `ambient/worker` entry). |
|
|
288
|
+
| `server/index.ts` | `extractAmbientPalette`, sharp decoder, URL guard, server cache (the `ambient/server` entry). |
|
|
289
|
+
| `server/address.ts` | Host normalization and private-address checks for the URL guard. |
|
|
290
|
+
| `dom.ts` | Target resolution, CSS variable maps, scoped style restoration. |
|
|
291
|
+
| `hooks.ts` | `useAmbientColor`, `useAmbientTheme`, `useAmbient`, `useStableObject`. |
|
|
292
|
+
| `context.tsx` | `AmbientContext` and `AmbientProvider` store. |
|
|
293
|
+
| `module.tsx` | `ambientModule`, `resolvePageAmbientTheme`, `defineAmbient`, kernel type augmentation. |
|
|
273
294
|
|
|
274
295
|
## 9. Dependencies
|
|
275
296
|
|
package/docs/modules/dock.md
CHANGED
|
@@ -655,15 +655,25 @@ See [media.md](./media.md) for how sources are registered (`usePage({ media })`,
|
|
|
655
655
|
|
|
656
656
|
## 16. Layout and geometry
|
|
657
657
|
|
|
658
|
-
| What | Value
|
|
659
|
-
| :--------------- |
|
|
660
|
-
| Card
|
|
661
|
-
| Card width | 460 px
|
|
662
|
-
| Published height | `--dock-h` on `<html>` and `dockHeight` in state (card height + 16 px buffer)
|
|
658
|
+
| What | Value |
|
|
659
|
+
| :--------------- | :--------------------------------------------------------------------------------------------------------------- |
|
|
660
|
+
| Card height | content + `motion.deck.padding` × 2 (default 10 px); at least 48 px / HUD 32 px + padding; viewport margin 24 px |
|
|
661
|
+
| Card width | `motion.deck.width` (default 460 px), or the card/surface `width`; clamped to `viewport − 16/32 px` |
|
|
662
|
+
| Published height | `--dock-h` on `<html>` and `dockHeight` in state (card height + 16 px buffer) |
|
|
663
663
|
|
|
664
664
|
These are what the layout **measures**, so they stay in the module. Where the cards _rest_ is yours: `motion.deck.stacking` holds the offsets, scales, depth fade and how many cards stay in view ([§17](#17-theming)). If you change a card's height, change `stacking.expanded.offsetY` with it (the starter spaces expanded cards by the card height plus a 4 px gap).
|
|
665
665
|
|
|
666
|
-
Reserve space with `useDockHeight().padding` or `padding-bottom: var(--dock-h)`. Height changes are measured with a `ResizeObserver` and ignored below 0.5 px; during surface close phases the height is locked to the base height.
|
|
666
|
+
Reserve space with `useDockHeight().padding` or `padding-bottom: var(--dock-h)`. The variable sits on `<html>`, so each write restyles the whole page; set `deck.heightVar: false` in the dock theme to skip it and size only the elements that need the height from `dockHeight`. Height changes are measured with a `ResizeObserver` and ignored below 0.5 px; during surface close phases the height is locked to the base height.
|
|
667
|
+
|
|
668
|
+
### 16.1 Compact layout
|
|
669
|
+
|
|
670
|
+
`setCompact(true)` asks the dock to shrink its front card to one row (the app decides when, e.g. on scroll down); `state.compact` reports the request. The row shows only while nothing needs the full card (no HUD, notification or expanded stack) and draws the card's action small beside the commands, split by a divider. The card fits the row's measured width plus `deck.padding`, with no base min-height. Back cards step away.
|
|
671
|
+
|
|
672
|
+
- A command or the card's action works in place; only a tap elsewhere on the card asks for the full card again.
|
|
673
|
+
- A surface opened from the compact row grows out of it and, on close, folds straight back into it (the row stays through the page-facing phases).
|
|
674
|
+
- A status other than 404 stays in the row as its icon plus one line (description, else title).
|
|
675
|
+
|
|
676
|
+
Slots: `compact`, `compactFrame`, `compactView`, `compactActions`, `compactDivider`, `compactStatus`, `compactStatusIcon`, `compactStatusText`. Motion: `variants.compact` (keep its `exit` shorter than the `dismissAction` timing so the row clears before a surface grows). The card carries `data-compact`.
|
|
667
677
|
|
|
668
678
|
## 17. Theming
|
|
669
679
|
|
|
@@ -671,15 +681,15 @@ The module contains **no design classes**. Every slot comes from `dockTheme` (`s
|
|
|
671
681
|
|
|
672
682
|
The theme also carries the dock's **motion** (`motion: DockMotion`, [theming §5](../theming.md#5-motion-your-app-owns-every-animation)). Everything the dock animates, and every number that shapes it, is yours:
|
|
673
683
|
|
|
674
|
-
| Key | What you decide
|
|
675
|
-
| :------------------------ |
|
|
676
|
-
| `transitions`, `variants` | Every transition and variant, including `transitions.layout` for parts that slide when their neighbours change (the surface close control, the breadcrumbs).
|
|
677
|
-
| `phases` | What the deck, header and body play in each surface phase (`idle`, `dismissAction`, `expandBody`, `open`, `anticipation`, `collapseBody`, `restoreHeader`): the deck's size/shadow transition (`null` follows its resting one, a function gets the resize distance), its transform transition and `scale` (below 1 compresses it), the body's and header's transitions, and `headerReturn`.
|
|
678
|
-
| `timings` | How long each phase holds (`dismissAction`, `anticipation`, `expandBody`, `collapseBody`, `restoreHeader`) plus the card staggers, in seconds. The surface state machine schedules its phases from these, so they follow the app's tempo. `restoreHeader: 0` skips that phase.
|
|
679
|
-
| `deck` | `elevation`, `peek`, `exit`, `tapScale`; `stacking` (where cards rest: collapsed/expanded offsets, scale, depth fade, the shelf, and how many cards stay in view normally, with an extension shelf and under a status); `breadcrumbOffset`; `fullscreenOpacity`; `origin`; `resizeFallback
|
|
680
|
-
| `opacity` | The resting opacity of the card **banner** and **description**. A page's own `bannerOpacity` or description `style.opacity` still wins.
|
|
681
|
-
| `drag` | The swipe-to-dismiss feel (`elastic`, `range`, `opacity`, `scale`) and `dismiss: { offset, velocity }`, the distance (px) or speed (px/s) past which a swipe closes the surface.
|
|
682
|
-
| `skeleton` | The class of the loading skeletons.
|
|
684
|
+
| Key | What you decide |
|
|
685
|
+
| :------------------------ | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
686
|
+
| `transitions`, `variants` | Every transition and variant, including `transitions.layout` for parts that slide when their neighbours change (the surface close control, the breadcrumbs). |
|
|
687
|
+
| `phases` | What the deck, header and body play in each surface phase (`idle`, `dismissAction`, `expandBody`, `open`, `anticipation`, `collapseBody`, `restoreHeader`): the deck's size/shadow transition (`null` follows its resting one, a function gets the resize distance), its transform transition and `scale` (below 1 compresses it), the body's and header's transitions, and `headerReturn`. |
|
|
688
|
+
| `timings` | How long each phase holds (`dismissAction`, `anticipation`, `expandBody`, `collapseBody`, `restoreHeader`) plus the card staggers, in seconds. The surface state machine schedules its phases from these, so they follow the app's tempo. `restoreHeader: 0` skips that phase. |
|
|
689
|
+
| `deck` | `elevation`, `peek`, `exit`, `tapScale`; `stacking` (where cards rest: collapsed/expanded offsets, scale, depth fade, the shelf, and how many cards stay in view normally, with an extension shelf and under a status); `breadcrumbOffset`; `fullscreenOpacity`; `origin`; `resizeFallback`; `width` (optional resting card width in px, default 460); `padding` (the card's vertical padding per side, px, default 10: match your CSS). |
|
|
690
|
+
| `opacity` | The resting opacity of the card **banner** and **description**. A page's own `bannerOpacity` or description `style.opacity` still wins. |
|
|
691
|
+
| `drag` | The swipe-to-dismiss feel (`elastic`, `range`, `opacity`, `scale`) and `dismiss: { offset, velocity }`, the distance (px) or speed (px/s) past which a swipe closes the surface. |
|
|
692
|
+
| `skeleton` | The class of the loading skeletons. |
|
|
683
693
|
|
|
684
694
|
The framework ships no dock motion: write `DockMotion` in your app. Geometry and opacities are not times, so tempo and reduced motion leave them alone; only transitions and `timings` are stretched or collapsed.
|
|
685
695
|
|