basalt-ui 2.17.0 → 2.18.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.
Files changed (69) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/MIGRATING.md +44 -12
  3. package/agent/skills/basalt-design/SKILL.md +1 -1
  4. package/dist/cli/help.d.ts +1 -0
  5. package/dist/cli/help.d.ts.map +1 -1
  6. package/dist/cli/help.js +8 -2
  7. package/dist/cli/shot/capture.d.ts +12 -1
  8. package/dist/cli/shot/capture.d.ts.map +1 -1
  9. package/dist/cli/shot/capture.js +72 -10
  10. package/dist/cli/shot/index.d.ts +10 -1
  11. package/dist/cli/shot/index.d.ts.map +1 -1
  12. package/dist/cli/shot/index.js +40 -5
  13. package/dist/cli/shot/real-data.d.ts +35 -0
  14. package/dist/cli/shot/real-data.d.ts.map +1 -0
  15. package/dist/cli/shot/real-data.js +120 -0
  16. package/dist/cli/shot/serve.d.ts +2 -2
  17. package/dist/cli/shot/serve.d.ts.map +1 -1
  18. package/dist/cli/shot/serve.js +16 -2
  19. package/dist/dashboard/bar-list.d.ts +29 -0
  20. package/dist/dashboard/bar-list.d.ts.map +1 -0
  21. package/dist/dashboard/bar-list.js +52 -0
  22. package/dist/dashboard/bar-list.module.css +73 -0
  23. package/dist/dashboard/bar-list.module.css.d.ts +16 -0
  24. package/dist/dashboard/index.d.ts +2 -0
  25. package/dist/dashboard/index.d.ts.map +1 -1
  26. package/dist/dashboard/index.js +4 -0
  27. package/dist/dashboard/meter-model.d.ts +78 -0
  28. package/dist/dashboard/meter-model.d.ts.map +1 -0
  29. package/dist/dashboard/meter-model.js +91 -0
  30. package/dist/dashboard/meter-parts.d.ts +42 -0
  31. package/dist/dashboard/meter-parts.d.ts.map +1 -0
  32. package/dist/dashboard/meter-parts.js +163 -0
  33. package/dist/dashboard/meter.d.ts +112 -0
  34. package/dist/dashboard/meter.d.ts.map +1 -0
  35. package/dist/dashboard/meter.js +43 -0
  36. package/dist/dashboard/meter.module.css +150 -0
  37. package/dist/dashboard/meter.module.css.d.ts +28 -0
  38. package/dist/dashboard/scale.d.ts +9 -0
  39. package/dist/dashboard/scale.d.ts.map +1 -0
  40. package/dist/dashboard/scale.js +10 -0
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +5 -1
  44. package/dist/tokens/derive.d.ts +11 -1
  45. package/dist/tokens/derive.d.ts.map +1 -1
  46. package/dist/tokens/derive.js +9 -24
  47. package/dist/tokens/status-text.d.ts +26 -0
  48. package/dist/tokens/status-text.d.ts.map +1 -0
  49. package/dist/tokens/status-text.js +68 -0
  50. package/llms.txt +32 -3
  51. package/package.json +1 -1
  52. package/src/cli/help.ts +22 -2
  53. package/src/cli/shot/capture.ts +98 -9
  54. package/src/cli/shot/index.ts +50 -4
  55. package/src/cli/shot/real-data.ts +165 -0
  56. package/src/cli/shot/serve.ts +28 -3
  57. package/src/dashboard/bar-list.module.css +73 -0
  58. package/src/dashboard/bar-list.module.css.d.ts +16 -0
  59. package/src/dashboard/bar-list.tsx +112 -0
  60. package/src/dashboard/index.ts +2 -0
  61. package/src/dashboard/meter-model.ts +161 -0
  62. package/src/dashboard/meter-parts.tsx +223 -0
  63. package/src/dashboard/meter.module.css +150 -0
  64. package/src/dashboard/meter.module.css.d.ts +28 -0
  65. package/src/dashboard/meter.tsx +162 -0
  66. package/src/dashboard/scale.ts +13 -0
  67. package/src/index.ts +4 -0
  68. package/src/tokens/derive.ts +19 -31
  69. package/src/tokens/status-text.ts +85 -0
package/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # [2.18.0](https://github.com/jkrumm/basalt-ui/compare/v2.17.0...v2.18.0) (2026-10-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * clamp surface levels and extract the status text solver ([94c2dea](https://github.com/jkrumm/basalt-ui/commit/94c2dea643c4a8d332bdf227d5b4e94f1fb311f4))
7
+ * harden Meter and BarList against negative and non-finite input ([ecbd177](https://github.com/jkrumm/basalt-ui/commit/ecbd177ba0272f7147d89587841e9be27cf2a7f7))
8
+ * scope shot's data checks to one page visit ([918129c](https://github.com/jkrumm/basalt-ui/commit/918129cf0a5f062e897eb8d4cf601e27ab49a003))
9
+ * validate surface levels and tighten the status text walk ([865e4a2](https://github.com/jkrumm/basalt-ui/commit/865e4a2c7c410810124576b4b4b48233395ddb5b))
10
+
11
+
12
+ ### Features
13
+
14
+ * add Meter and BarList to the dashboard layer ([499ffd6](https://github.com/jkrumm/basalt-ui/commit/499ffd6a269c0de0e29a1352eeebeccf551b88ef))
15
+ * add Meter zones and state the overage past a target ([d429496](https://github.com/jkrumm/basalt-ui/commit/d429496e0572743bc24ae2e91aeffcae9d1eb149))
16
+ * derive the status text stops per surface ([aceea2a](https://github.com/jkrumm/basalt-ui/commit/aceea2a62cbbdfb1f0fe408334b4f1368675648f))
17
+ * shot captures a real, authenticated app ([027a905](https://github.com/jkrumm/basalt-ui/commit/027a9050a315cc72882ff5ef2571c73e25000fa4))
18
+
1
19
  # [2.17.0](https://github.com/jkrumm/basalt-ui/compare/v2.16.0...v2.17.0) (2026-10-17)
2
20
 
3
21
 
package/MIGRATING.md CHANGED
@@ -66,18 +66,18 @@ There is one row per SURFACE, not per export, and a surface earns a row once any
66
66
  shipped lefthook preset both changed in 1.30.0 with no row that owned them — which is how a
67
67
  consumer read this index, found nothing, and diffed a KPI row that had silently gone 4-up → 2-up.
68
68
 
69
- | Surface | 1.27.0 | 1.28.0 | 1.29.0 | 1.30.0 | 1.30.1 | 1.30.2 | 1.31.0 | 1.32.0 | 1.32.1 | 1.33.0 | 1.34.0 | 1.34.1 | 1.35.0 | 1.36.0 | 1.36.1 | 1.37.0 | 1.37.1 | 1.38.0 | 1.38.1 | 1.39.0 | 1.40.0 | 1.40.1 | 1.40.2 | 1.40.3 | 1.41.0 | 2.0.0 | 2.0.1 | 2.0.2 | 2.0.3 | 2.0.4 | 2.0.5 | 2.1.0 | 2.2.0 | 2.3.0 | 2.4.0 | 2.5.0 | 2.6.0 | 2.6.1 | 2.7.0 | 2.7.1 | 2.7.2 | 2.7.3 | 2.8.0 | 2.8.1 | 2.9.0 | 2.9.1 | 2.10.0 | 2.11.0 | 2.11.1 | 2.12.0 | 2.13.0 | 2.13.1 | 2.13.2 | 2.13.3 | 2.14.0 | 2.15.0 | 2.16.0 | 2.17.0 | Unreleased |
70
- | ----------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------- | ------ | ------ | -------------------------------------------------------------------------------------------- | ------ | ------ | ------ | ------ | ------ | ----------------------------------------------- | ------ | ------ | ------ | ------ | ------------------------------------------------------------ | ---------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
71
- | **tokens** (`./tokens`) | — | `--vx-divider` → `rgba()` on both schemes (§ Shell) | `--vx-space-touch-target` added (§ Additions) | eight spacing numbers (§ Chrome) | — | — | `--vx-hit` replaces the touch vars; `SIZE_CLASSES` (§ 1.31.0) | — | `SIZE_CLASSES`/`CONTAINER_CLASSES` actually exported (§ Fixes) | `CONTAINER_GRID_BREAKPOINTS`; `raw-breakpoint` trusts it (§ 1.33.0) | `CONTAINER_KEYS` (§ 1.34.0) | — | — | — | — | — | — | — | | `appShellInset` 20 → 16 (§ 1.38.1) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | spacing, radius, type and the dense tier (§ 2.16.0) | — | — |
72
- | **charts** (`./charts`) | — | phone tier, `curve`, formatters, `state`, log axis (§ preamble) | `ChartState.empty: string`, `AxisBottomNumeric` (§ Additions) | responsive `height`, `legend.maxRows` (§ Charts) | `height` reaches the kinds; `maxRows` beats the `fill` fit (§ Charts) | — | container-class tier + `height` keys (§ 1.31.0) | — | `ResponsiveChartHeight` `sm` → key (§ Container recipes) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `BandSpan.absentFraction` + `absentState` (§ 2.8.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
73
- | **shell** (`.`) | — | scrollport, region seams, **the brand left the sidebar** (§§ scrollport, brand, Shell) | `PageTitle`, `BasaltDevDock`, `useBreakpoint` (§ Additions) | More popover, aside pill, the responsive gutter, `useBasaltSpacing` (§ Chrome) | — | — | `theme.breakpoints` derived, `useSizeClass`, `data-basalt-host`, `useBreakpoint` on notice (§ 1.31.0) | `useBreakpoint` removal → 1.33.0; `useSizeClass` is shell-only (§ 1.32.0) | shell-less `shell/` gutter, `AppShell` breakpoints, `useSizeClass` for overlays (§§ Shell-less, `useSizeClass`) | — | `useBreakpoint` removed (§ 1.34.0) | — | — | `useCoarsePointer()` (§ `useCoarsePointer()`) | — | — | — | — | | content gutter 16, block 8 from `sm` (§ 1.38.1) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `BasaltProvider` embedded mode, `spotlight` (§ 2.8.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | expanded gutter 24 (§ 2.16.0) | — | — |
74
- | **controls** (`./controls`) | `NumberFilter`, `field.number` (§ Controls) | sheet renders panel rows; `PanelRow`, `SliderControl` (§ `basalt-ui/controls`) | — | — | — | — | — | — | — | `NumberFilter clearable`; `createSearchStore` `resets` (§ State and controls) | — | — | — | `FormSection`/`FormRow`/`FormGroup`/`FormActions` move here (§ The form layout moves) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | dense 28 tier at a fine pointer (§ 2.16.0) | — | — |
75
- | **forms** (`./forms`) | — | `field` → `inputProps`, **`inputProps` drops `key`**, the layout tier (§ `inputProps`) | `field` DELETED — and the `--fix` recipe no longer works (§ Consolidation) | — | — | — | — | — | `FormGroup` row no longer stretches (§ Fixes) | — | — | — | — | the layout + `useForm`/`schemaResolver` deprecated, removed 1.37.0 (§ The form layout moves) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
76
- | **data** (`./data/table`) | — | root is a `<div>`, row selection, `getItemKey` required (§ `basalt-ui/data`) | `./data` + `./query` + `./connectivity` dropped (§ Consolidation) | — | — | — | — | — | `renderCard` documented (§ `renderCard`) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
77
- | **dashboard** (`.`) | `StatCard`: `unit`, `breakdown`, delta format (§ `StatCard`) | `StatGroup`, `WidgetGrid`, query-aware `StatCard` — additive | — | **the column law keys on the CONTAINER; `cols={4}` is 2-up at `sm`** (§ Dashboard) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | card inset 12/16, `kpi` 22 / 500 (§ 2.16.0) | — | — |
78
- | **toolchain** (`./configs/*`) | — | — | the shipped lefthook preset's `check-theme` BROKE — the CLI resolver stopped ascending (§ CLI) | the preset's default bin, and the `root:` recipe (§ Toolchain) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
79
- | **CLI** (`basalt-ui`) | — | — | **resolver stops relocating; `doctor` loses 6 of 10 checks** (§ CLI) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | the managed block moves `CLAUDE.md` → `AGENTS.md` (§ 1.41.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `doctor`: CSS + forced dropped subpaths, `oxlint-floor`, Start wiring (§ 2.8.0) | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
80
- | **guards** | five rules → `error` (§ Guards) | six new ids at `warn` (§ preamble) | `query-dual-import` retired in 1.29.1 (§ Guards) | four rules → `error` (§ Guards) | — | — | — | `raw-breakpoint`: the container-grid answer, `error` at 1.33.0 (§ 1.32.0) | `FormRow`/`FormGroup` homes in both lanes; `basalt-main` dropped (§ Fixes) | C1 + breakpoint pairs → `error`; `unknown-vx-token` `warn` (§ Guards) | — | — | — | `unknown-vx-token` → `error`; the token factories throw (§ Guards) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | `inline-spacing` steps, `card-inset` accepts both pairs (§ 2.16.0) | — | — |
69
+ | Surface | 1.27.0 | 1.28.0 | 1.29.0 | 1.30.0 | 1.30.1 | 1.30.2 | 1.31.0 | 1.32.0 | 1.32.1 | 1.33.0 | 1.34.0 | 1.34.1 | 1.35.0 | 1.36.0 | 1.36.1 | 1.37.0 | 1.37.1 | 1.38.0 | 1.38.1 | 1.39.0 | 1.40.0 | 1.40.1 | 1.40.2 | 1.40.3 | 1.41.0 | 2.0.0 | 2.0.1 | 2.0.2 | 2.0.3 | 2.0.4 | 2.0.5 | 2.1.0 | 2.2.0 | 2.3.0 | 2.4.0 | 2.5.0 | 2.6.0 | 2.6.1 | 2.7.0 | 2.7.1 | 2.7.2 | 2.7.3 | 2.8.0 | 2.8.1 | 2.9.0 | 2.9.1 | 2.10.0 | 2.11.0 | 2.11.1 | 2.12.0 | 2.13.0 | 2.13.1 | 2.13.2 | 2.13.3 | 2.14.0 | 2.15.0 | 2.16.0 | 2.17.0 | 2.18.0 | Unreleased |
70
+ | ----------------------------- | ------------------------------------------------------------ | -------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------- | ------ | ------ | -------------------------------------------------------------------------------------------- | ------ | ------ | ------ | ------ | ------ | ----------------------------------------------- | ------ | ------ | ------ | ------ | ------------------------------------------------------------ | ---------- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
71
+ | **tokens** (`./tokens`) | — | `--vx-divider` → `rgba()` on both schemes (§ Shell) | `--vx-space-touch-target` added (§ Additions) | eight spacing numbers (§ Chrome) | — | — | `--vx-hit` replaces the touch vars; `SIZE_CLASSES` (§ 1.31.0) | — | `SIZE_CLASSES`/`CONTAINER_CLASSES` actually exported (§ Fixes) | `CONTAINER_GRID_BREAKPOINTS`; `raw-breakpoint` trusts it (§ 1.33.0) | `CONTAINER_KEYS` (§ 1.34.0) | — | — | — | — | — | — | — | | `appShellInset` 20 → 16 (§ 1.38.1) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | spacing, radius, type and the dense tier (§ 2.16.0) | — | — | — |
72
+ | **charts** (`./charts`) | — | phone tier, `curve`, formatters, `state`, log axis (§ preamble) | `ChartState.empty: string`, `AxisBottomNumeric` (§ Additions) | responsive `height`, `legend.maxRows` (§ Charts) | `height` reaches the kinds; `maxRows` beats the `fill` fit (§ Charts) | — | container-class tier + `height` keys (§ 1.31.0) | — | `ResponsiveChartHeight` `sm` → key (§ Container recipes) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `BandSpan.absentFraction` + `absentState` (§ 2.8.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
73
+ | **shell** (`.`) | — | scrollport, region seams, **the brand left the sidebar** (§§ scrollport, brand, Shell) | `PageTitle`, `BasaltDevDock`, `useBreakpoint` (§ Additions) | More popover, aside pill, the responsive gutter, `useBasaltSpacing` (§ Chrome) | — | — | `theme.breakpoints` derived, `useSizeClass`, `data-basalt-host`, `useBreakpoint` on notice (§ 1.31.0) | `useBreakpoint` removal → 1.33.0; `useSizeClass` is shell-only (§ 1.32.0) | shell-less `shell/` gutter, `AppShell` breakpoints, `useSizeClass` for overlays (§§ Shell-less, `useSizeClass`) | — | `useBreakpoint` removed (§ 1.34.0) | — | — | `useCoarsePointer()` (§ `useCoarsePointer()`) | — | — | — | — | | content gutter 16, block 8 from `sm` (§ 1.38.1) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `BasaltProvider` embedded mode, `spotlight` (§ 2.8.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | expanded gutter 24 (§ 2.16.0) | — | — | — |
74
+ | **controls** (`./controls`) | `NumberFilter`, `field.number` (§ Controls) | sheet renders panel rows; `PanelRow`, `SliderControl` (§ `basalt-ui/controls`) | — | — | — | — | — | — | — | `NumberFilter clearable`; `createSearchStore` `resets` (§ State and controls) | — | — | — | `FormSection`/`FormRow`/`FormGroup`/`FormActions` move here (§ The form layout moves) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | dense 28 tier at a fine pointer (§ 2.16.0) | — | — | — |
75
+ | **forms** (`./forms`) | — | `field` → `inputProps`, **`inputProps` drops `key`**, the layout tier (§ `inputProps`) | `field` DELETED — and the `--fix` recipe no longer works (§ Consolidation) | — | — | — | — | — | `FormGroup` row no longer stretches (§ Fixes) | — | — | — | — | the layout + `useForm`/`schemaResolver` deprecated, removed 1.37.0 (§ The form layout moves) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
76
+ | **data** (`./data/table`) | — | root is a `<div>`, row selection, `getItemKey` required (§ `basalt-ui/data`) | `./data` + `./query` + `./connectivity` dropped (§ Consolidation) | — | — | — | — | — | `renderCard` documented (§ `renderCard`) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
77
+ | **dashboard** (`.`) | `StatCard`: `unit`, `breakdown`, delta format (§ `StatCard`) | `StatGroup`, `WidgetGrid`, query-aware `StatCard` — additive | — | **the column law keys on the CONTAINER; `cols={4}` is 2-up at `sm`** (§ Dashboard) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | card inset 12/16, `kpi` 22 / 500 (§ 2.16.0) | — | — | — |
78
+ | **toolchain** (`./configs/*`) | — | — | the shipped lefthook preset's `check-theme` BROKE — the CLI resolver stopped ascending (§ CLI) | the preset's default bin, and the `root:` recipe (§ Toolchain) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
79
+ | **CLI** (`basalt-ui`) | — | — | **resolver stops relocating; `doctor` loses 6 of 10 checks** (§ CLI) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | the managed block moves `CLAUDE.md` → `AGENTS.md` (§ 1.41.0) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | `doctor`: CSS + forced dropped subpaths, `oxlint-floor`, Start wiring (§ 2.8.0) | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — |
80
+ | **guards** | five rules → `error` (§ Guards) | six new ids at `warn` (§ preamble) | `query-dual-import` retired in 1.29.1 (§ Guards) | four rules → `error` (§ Guards) | — | — | — | `raw-breakpoint`: the container-grid answer, `error` at 1.33.0 (§ 1.32.0) | `FormRow`/`FormGroup` homes in both lanes; `basalt-main` dropped (§ Fixes) | C1 + breakpoint pairs → `error`; `unknown-vx-token` `warn` (§ Guards) | — | — | — | `unknown-vx-token` → `error`; the token factories throw (§ Guards) | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | — | § 1.x compatibility layer removed | — | — | — | — | — | — | — | — | — | — | — | `inline-spacing` steps, `card-inset` accepts both pairs (§ 2.16.0) | — | — | — |
81
81
 
82
82
  ---
83
83
 
@@ -1046,6 +1046,38 @@ The `basalt-ui/router-tanstack` subpath is **removed** in 2.x, not moved: an imp
1046
1046
  _Nothing yet. Author the next section under this heading as `## Unreleased — <title>`; the
1047
1047
  release renames it and opens a new one here._
1048
1048
 
1049
+ ## 2.18.0
1050
+
1051
+ ### Status text derived per surface
1052
+
1053
+ Wave 34 of the design-parity track (`docs/waves/design-parity/SPEC.md` § 12 D22). No export is
1054
+ added, removed or renamed.
1055
+
1056
+ `--vx-status-good`, `--vx-status-warn` and `--vx-status-bad` (light and dark) are painted as text
1057
+ (`DeltaBadge`, a toned row), but their tones were fixed while the surfaces move with `lightLevel`,
1058
+ `darkLevel` and `neutral`; off the defaults they read 3.2–3.9:1. Each solid is now derived from the
1059
+ surfaces the palette produced: **it shifts in lightness only when needed to restore the 4.5:1
1060
+ floor** on every text surface (`bg`, `panel`, `panelHover`, `elevated`, `subtle`, `field`). Light
1061
+ darkens, dark lightens; hue is preserved and chroma may clip at the gamut edge.
1062
+
1063
+ - **Defaults are unchanged**: at the default config every status hex is byte-identical.
1064
+ - At a non-default `lightLevel`, `darkLevel` or `neutral` the status solids shift in lightness only as far as the floor needs.
1065
+ - `lightLevel` / `darkLevel` outside -5..5 are clamped to the nearest bound (non-finite becomes 0).
1066
+ - No opt-out is needed. A consumer that pins a status hex at a non-default config passes its own
1067
+ colour and owns the contrast.
1068
+
1069
+ ### `shot` on a real app
1070
+
1071
+ - `basalt-ui shot` captures a signed-in app with live data. `--local-storage <key>=<@env:NAME|@file:path>` seeds
1072
+ localStorage on the app origin before any page script (an argo-style bearer token); `--api /api=https://app.example.com`
1073
+ makes the `--dist` server proxy GET/HEAD under that prefix (other methods get 405 unless `--api-allow-writes`);
1074
+ `--header authorization=@env:NAME` is added to every proxied request, to every `--api` origin (https required), never
1075
+ to a page navigation; `--wait <ms>` adds a settle after `networkidle` (default none); `--auto-anchors` crops every
1076
+ Card, Paper and table over 120×60 px on a page with no `data-shot`. A redirect, 401/403/404, 5xx or unreachable API fails every shot of that page; a localStorage key the app already holds is not overwritten; `--header` is refused when `--api` names more than one origin; any secret (`--header` or `--local-storage`) requires an https `--api` origin.
1077
+ Secret values are never printed or written to `board.html` or `metrics.json`. Shots of real data reach the reviewer
1078
+ subagent's model provider: point `--api` at staging or synthetic data for an app holding third parties' data. No
1079
+ action needed; every flag is opt-in.
1080
+
1049
1081
  ## 2.17.0 — the metric card and chrome
1050
1082
 
1051
1083
  Wave 33 of the design-parity track (`docs/waves/design-parity/SPEC.md` § 6.10, § 6.12). No export is
@@ -28,7 +28,7 @@ Method only; the law is `.claude/rules/basalt-*.md` and `./DESIGN.md`.
28
28
  4. Build with Mantine primitives and the composites; every color from `VX.*` or a series token. Tune by eye in the theme lab (`dev.theme` Spotlight command, dev only) in both schemes, then bake values into the `derive` knobs of `createBasaltTheme` and series colors into `src/lib/series.ts`.
29
29
  5. **Mark up for the board.** Tag each scored component `data-shot="<name>"`; hover and tooltip targets inside it get `data-shot-hover` / `data-shot-tooltip`; when the target's centre paints no readout (a donut's hole), add `data-shot-at="x,y"` (fractions of its box, e.g. `0.25,0.2`) and the shot hovers there. Declare supported states with `data-shot-states="empty loading error"` and render them when the `shot-state` URL param asks.
30
30
  6. **Rounds, at least three.** Playwright is the app's dev dependency: `bun add -d playwright && bunx playwright install chromium`. Then:
31
- - `basalt-ui shot <routes> --dist <built app>` (or `--base <url>` for a running server);
31
+ - `basalt-ui shot <routes> --dist <built app>` (or `--base <url>` for a running server); a real, signed-in app (live data, no `data-shot` yet): `basalt-ui shot /overview --dist dist --api /api=https://app.example.com --local-storage auth-token=@env:APP_TOKEN --auto-anchors` seeds the token (app origin only; `@env:`/`@file:`, never inline), proxies GET/HEAD under `/api` (writes get 405 unless `--api-allow-writes`) and crops every large Card, Paper and table. One `--header authorization=@env:NAME` goes to EVERY `--api` origin (https required for any secret), never on a navigation. A redirect, 401/403/404, 5xx or dead API fails every shot of that page; a key the app already holds is never overwritten. These shots reach the reviewer subagent's model provider, the session's own: an app holding third parties' data should point `--api` at staging or synthetic data;
32
32
  - hand the out dir (`.basalt/shots`) to the `basalt-design-reviewer` subagent by name; it reads each component's contact sheet (`png/*__sheet.png`) and every page shot;
33
33
  - revise every failing item at its source, rebuild, and shoot again.
34
34
  Boards stay local (gitignored); the scored verdict and notes are worth committing.
@@ -1,5 +1,6 @@
1
1
  export declare const COMMAND_OPTIONS: Record<string, Record<string, {
2
2
  type: 'string' | 'boolean';
3
+ multiple?: boolean;
3
4
  }>>;
4
5
  /** The first flag `cmd` does not accept, or null. Unknown commands return null — the dispatcher's
5
6
  * default branch already names those. */
@@ -1 +1 @@
1
- {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAA;CAAE,CAAC,CAqC1F,CAAA;AAED;yCACyC;AACzC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAWhF;AAED,0GAA0G;AAC1G,eAAO,MAAM,KAAK,QAwC0E,CAAA"}
1
+ {"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../src/cli/help.ts"],"names":[],"mappings":"AAcA,eAAO,MAAM,eAAe,EAAE,MAAM,CAClC,MAAM,EACN,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CA4CnE,CAAA;AAED;yCACyC;AACzC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAWhF;AAED,0GAA0G;AAC1G,eAAO,MAAM,KAAK,QAmD0E,CAAA"}
package/dist/cli/help.js CHANGED
@@ -34,7 +34,13 @@ const COMMAND_OPTIONS = {
34
34
  base: { type: "string" },
35
35
  dist: { type: "string" },
36
36
  out: { type: "string" },
37
- states: { type: "string" }
37
+ states: { type: "string" },
38
+ "local-storage": { type: "string", multiple: true },
39
+ api: { type: "string", multiple: true },
40
+ header: { type: "string", multiple: true },
41
+ wait: { type: "string" },
42
+ "auto-anchors": { type: "boolean" },
43
+ "api-allow-writes": { type: "boolean" }
38
44
  }
39
45
  };
40
46
  function unknownFlag(cmd, flags) {
@@ -49,7 +55,7 @@ function unknownFlag(cmd, flags) {
49
55
  return match?.[1] ?? flags.find((f) => f.startsWith("-")) ?? flags[0] ?? null;
50
56
  }
51
57
  }
52
- const USAGE = "Usage: basalt-ui <--version | init [--no-merge-lint] |\n sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n check-theme [--audit-allows] |\n doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n shot <route\u2026> | help>\n\ncheck-theme [--tokens-only|--framework] [--audit-allows]\n --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n `basalt.exemptRules` entry, with what each one still suppresses \u2014 proved by re-running the\n guard with that one waiver neutralized, not by reading its text. Exits 1 on a waiver that\n suppresses nothing (dead), which is what makes it usable as a CI gate.\n\ntokens:css [--out <path>] [--check] [--selector-attribute <attr> | --selector-class <class>]\n [--light-class <class>] [--dark-value <v>] [--light-value <v>]\n [--default-scheme <dark|light|none>] [--media-fallback] [--only <core|all>]\n Emit the --vx-* stylesheet (stdout unless --out). Defaults emit the stock identity; commit the output as your tokens file.\n --selector-class emits `:root.dark` instead of an attribute selector (the Tailwind convention).\n --check writes nothing and exits 1 when --out differs from what would be emitted (a CI gate).\n\nfonts:css [--out <path>] [--check]\n Emit the shipped --basalt-font-* stacks as plain CSS \u2014 the typeface half of the token layer,\n otherwise reachable only by importing styles.css.\n\nshot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]\n Render routes in Chromium (Playwright from YOUR project: bun add -d playwright) and write\n board.html, metrics.json and png/* \u2014 every data-shot anchor \xD7 light/dark \xD7 desktop/mobile \xD7\n rest, hover, focus, tooltip, empty, loading, error. --dist serves a built SPA dir itself.\n Default --out .basalt/shots (emptied each run); .basalt/shots/last.json names the last out dir.\n\ndoctor [--tokens-only|--framework]\n Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n this package.json. Profile is DECLARED, same as check-theme \u2014 never inferred.\n\nsync [--force] [--check] [--verbose] [--tokens-only|--framework]\n Refreshes an EXISTING install; it never creates one (that is init). A tokens-only consumer\n has no scaffold to reconcile, so sync reports n/a and exits 0 there \u2014 as doctor does.\n --check prints the permanent placement skips as a COUNT; --verbose spells them out again.\n\ncheck-theme / doctor / sync all resolve their project the same way: BASALT_CWD, else the\ninvocation cwd \u2014 nothing inferred, nothing ascended or descended into.\n--tokens-only and --framework are alternatives; passing both is an error.\n\nEvery subcommand accepts --help / -h to print this message and exit without running.\n--version / -v prints the resolved package version and exits 0 \u2014 the one command that proves\nWHICH basalt-ui ran, which a `bunx` cache can otherwise make a lie. An unknown command or an\nunrecognized flag exits 1 and names what it did not understand; neither is ever ignored.";
58
+ const USAGE = "Usage: basalt-ui <--version | init [--no-merge-lint] |\n sync [--force] [--check] [--verbose] [--tokens-only|--framework] |\n check-theme [--audit-allows] |\n doctor [--tokens-only|--framework] | guard-hook | tokens:css | fonts:css |\n shot <route\u2026> | help>\n\ncheck-theme [--tokens-only|--framework] [--audit-allows]\n --audit-allows reports instead of scanning: every `theme-allow` annotation and every\n `basalt.exemptRules` entry, with what each one still suppresses \u2014 proved by re-running the\n guard with that one waiver neutralized, not by reading its text. Exits 1 on a waiver that\n suppresses nothing (dead), which is what makes it usable as a CI gate.\n\ntokens:css [--out <path>] [--check] [--selector-attribute <attr> | --selector-class <class>]\n [--light-class <class>] [--dark-value <v>] [--light-value <v>]\n [--default-scheme <dark|light|none>] [--media-fallback] [--only <core|all>]\n Emit the --vx-* stylesheet (stdout unless --out). Defaults emit the stock identity; commit the output as your tokens file.\n --selector-class emits `:root.dark` instead of an attribute selector (the Tailwind convention).\n --check writes nothing and exits 1 when --out differs from what would be emitted (a CI gate).\n\nfonts:css [--out <path>] [--check]\n Emit the shipped --basalt-font-* stacks as plain CSS \u2014 the typeface half of the token layer,\n otherwise reachable only by importing styles.css.\n\nshot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]\n Render routes in Chromium (Playwright from YOUR project: bun add -d playwright) and write\n board.html, metrics.json and png/* \u2014 every data-shot anchor \xD7 light/dark \xD7 desktop/mobile \xD7\n rest, hover, focus, tooltip, empty, loading, error. --dist serves a built SPA dir itself.\n Default --out .basalt/shots (emptied each run); .basalt/shots/last.json names the last out dir.\n A real, signed-in app: [--local-storage <key>=<@env:NAME|@file:path>]\u2026 seeds localStorage (app origin\n only) before any page script; [--api <prefix>=<origin>]\u2026 (with --dist) proxies GET/HEAD under that\n prefix to the origin (other methods get 405 unless --api-allow-writes); [--header <name>=@env:NAME]\u2026 is\n added to every proxied request, to EVERY --api origin (never on a navigation; https required);\n [--wait <ms|networkidle>] adds ms of settle AFTER networkidle (default none); [--auto-anchors] crops\n each Card, Paper and table over 120\xD760 px on a page with no data-shot. Values are never printed or\n written; a redirect, 401/403/404, 5xx or dead API fails every shot of that page. Shots of real data go to the\n reviewer subagent and so to its model provider: point --api at staging or synthetic data when the\n app holds other people's data. Example:\n basalt-ui shot /overview --dist dist --api /api=https://app.example.com \\\n --local-storage auth-token=@env:APP_TOKEN --header authorization=@env:APP_BEARER --auto-anchors\n\ndoctor [--tokens-only|--framework]\n Checks THIS project only: the manifest exists, the oxlint preset is wired, the pre-commit\n hook runs check-theme (via `lefthook dump`), and the ai package major is consistent within\n this package.json. Profile is DECLARED, same as check-theme \u2014 never inferred.\n\nsync [--force] [--check] [--verbose] [--tokens-only|--framework]\n Refreshes an EXISTING install; it never creates one (that is init). A tokens-only consumer\n has no scaffold to reconcile, so sync reports n/a and exits 0 there \u2014 as doctor does.\n --check prints the permanent placement skips as a COUNT; --verbose spells them out again.\n\ncheck-theme / doctor / sync all resolve their project the same way: BASALT_CWD, else the\ninvocation cwd \u2014 nothing inferred, nothing ascended or descended into.\n--tokens-only and --framework are alternatives; passing both is an error.\n\nEvery subcommand accepts --help / -h to print this message and exit without running.\n--version / -v prints the resolved package version and exits 0 \u2014 the one command that proves\nWHICH basalt-ui ran, which a `bunx` cache can otherwise make a lie. An unknown command or an\nunrecognized flag exits 1 and names what it did not understand; neither is ever ignored.";
53
59
  export {
54
60
  COMMAND_OPTIONS,
55
61
  USAGE,
@@ -1,3 +1,4 @@
1
+ import type { Pair } from './real-data.js';
1
2
  import type { Box, PwBrowser, PwContext, PwLocator } from './playwright.js';
2
3
  import type { AnchorMetrics, Measurement, Scale, Scheme, ShotRecord, ShotState, Viewport } from './types.js';
3
4
  export type CaptureInput = {
@@ -6,6 +7,14 @@ export type CaptureInput = {
6
7
  routes: readonly string[];
7
8
  states: readonly ShotState[];
8
9
  pngDir: string;
10
+ /** Seeded before any page script runs (values may be secrets: never logged or written). */
11
+ localStorage?: readonly Pair[];
12
+ /** Extra settle in ms after `networkidle`; omitted: none. */
13
+ wait?: number;
14
+ /** Drains the proxied calls that failed since the last read (401/403, no answer). */
15
+ apiProblems?: () => string[];
16
+ /** On a page with no `data-shot`, tag each large Card, Paper and table as an anchor. */
17
+ autoAnchors?: boolean;
9
18
  /** Replaces the in-page measurer (tests). */
10
19
  measure?: (anchor: PwLocator) => Promise<Measurement>;
11
20
  log: (line: string) => void;
@@ -16,6 +25,8 @@ export declare const fileName: (route: string, name: string, scheme: Scheme, vie
16
25
  export declare function withParam(route: string, state: ShotState): string;
17
26
  /** The rect union of `boxes`, grown by `margin` and clamped to the viewport. */
18
27
  export declare function unionClip(boxes: readonly Box[], margin: number, viewport: Viewport): Box;
28
+ /** Runs in the page: numbers every Card, Paper and table in DOM order, tagging those over 120×60 px as anchors. */
29
+ export declare function tagAutoAnchors(): void;
19
30
  /**
20
31
  * Runs in the page: forgets the previous marks, then marks every tooltip that is visible now, so
21
32
  * a tooltip another component already holds open is never taken for the one a trigger opens.
@@ -62,7 +73,7 @@ export declare function readScaleInPage(steps: string[]): ScaleRead;
62
73
  /** Sorts the page's `--vx-*` readings into the three kinds; a step of 0 px (or an unresolvable one) is not a step. */
63
74
  export declare function groupScale({ mantine, vx }: ScaleRead): Steps;
64
75
  /** A fresh context for one scheme × viewport: the colour scheme is set on the context AND in storage before load. */
65
- export declare function openContext<C extends PwContext>(browser: PwBrowser<C>, scheme: Scheme, viewport: Viewport): Promise<C>;
76
+ export declare function openContext<C extends PwContext>(browser: PwBrowser<C>, scheme: Scheme, viewport: Viewport, seeded?: readonly Pair[], origin?: string): Promise<C>;
66
77
  /** `<route>-<hash>__<name>-<hash>__sheet.png`: one contact sheet per anchor, beside its crops. */
67
78
  export declare const sheetName: (route: string, name: string) => string;
68
79
  export declare function capture(input: CaptureInput): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"capture.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/capture.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAuB,MAAM,cAAc,CAAA;AAE7F,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,KAAK,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,QAAQ,EACT,MAAM,SAAS,CAAA;AAWhB,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,SAAS,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;IACzB,MAAM,EAAE,SAAS,SAAS,EAAE,CAAA;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,6CAA6C;IAC7C,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,SAAS,KAAK,OAAO,CAAC,WAAW,CAAC,CAAA;IACrD,GAAG,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5B,CAAA;AAsCD,kGAAkG;AAClG,eAAO,MAAM,QAAQ,GACnB,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,QAAQ,MAAM,EACd,UAAU,QAAQ,EAClB,OAAO,SAAS,KACf,MAC2G,CAAA;AAE9G,4DAA4D;AAC5D,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,MAAM,CAIjE;AAED,gFAAgF;AAChF,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,GAAG,CAOxF;AAoGD;;;GAGG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAQ1C;AAED,+GAA+G;AAC/G,wBAAgB,a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AG,WAAW,CAAC,CAAA;AAC5D,KAAK,SAAS,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAA;AAE/D;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAyD1D;AAED,sHAAsH;AACtH,wBAAgB,UAAU,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,SAAS,GAAG,KAAK,CAY5D;AAgED,qHAAqH;AACrH,wBAAsB,WAAW,CAAC,CAAC,SAAS,SAAS,EACnD,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EACrB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,EAClB,MAAM,GAAE,SAAS,IAAI,EAAO,EAC5B,MAAM,SAAK,GACV,OAAO,CAAC,CAAC,CAAC,CAaZ;AAID,kGAAkG;AAClG,eAAO,MAAM,SAAS,GAAI,OAAO,MAAM,EAAE,MAAM,MAAM,KAAG,MAC2B,CAAA;AAsDnF,wBAAsB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;IAC1D,OAAO,EAAE,aAAa,EAAE,CAAA;IACxB,KAAK,EAAE,UAAU,EAAE,CAAA;IACnB,KAAK,EAAE,KAAK,EAAE,CAAA;IACd,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAC,CAmDD"}
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { readFileSync } from "node:fs";
3
3
  import { basename, join } from "node:path";
4
4
  import { buildSheet } from "./board.js";
5
+ import { SEED_FLAG, seedScript } from "./real-data.js";
5
6
  import { finishMeasurement, measureAnchor } from "./measure.js";
6
7
  import { PAGE_ANCHOR, SCHEMES, URL_STATES, VIEWPORTS, VIEWPORT_SPECS } from "./types.js";
7
8
  const NAV_TIMEOUT_MS = 3e4;
@@ -49,14 +50,58 @@ function record(c, { name, state, status, file, note }) {
49
50
  if (status === "error")
50
51
  c.input.log(`[shot] ${route} ${name} ${scheme}/${viewport}/${state}: ${note}`);
51
52
  }
52
- async function load(page, url) {
53
+ async function load(page, url, settle = 0) {
53
54
  await page.goto(url, { waitUntil: "networkidle" });
54
55
  await page.evaluate("document.fonts.ready.then(() => undefined)");
56
+ if (settle > 0) await new Promise((done) => setTimeout(done, settle));
57
+ }
58
+ function tagAutoAnchors() {
59
+ const found = document.querySelectorAll(".mantine-Card-root, .mantine-Paper-root, table");
60
+ Array.from(found).forEach((el, i) => {
61
+ const { width, height } = el.getBoundingClientRect();
62
+ if (width > 120 && height > 60)
63
+ el.setAttribute("data-shot", `auto-${String(i + 1).padStart(2, "0")}`);
64
+ });
55
65
  }
56
66
  const readFacts = (page) => page.evaluate(`(() => ({
57
67
  anchors: [...new Set([...document.querySelectorAll('[data-shot]')].map((e) => e.getAttribute('data-shot')).filter(Boolean))],
58
68
  declared: [...document.querySelectorAll('[data-shot-states]')].flatMap((e) => (e.getAttribute('data-shot-states') ?? '').split(/\\s+/)).filter(Boolean),
59
69
  }))()`);
70
+ const addProblem = (c, problem) => {
71
+ if (!c.problems.includes(problem)) c.problems.push(problem);
72
+ };
73
+ const collect = (c) => {
74
+ for (const problem of c.input.apiProblems?.() ?? []) addProblem(c, problem);
75
+ };
76
+ async function visit(c, url) {
77
+ const { input, page } = c;
78
+ await load(page, url, input.wait);
79
+ let facts = await readFacts(page);
80
+ if (input.autoAnchors && facts.anchors.length === 0) {
81
+ await page.evaluate(tagAutoAnchors, void 0);
82
+ facts = await readFacts(page);
83
+ }
84
+ collect(c);
85
+ if (input.localStorage?.length) {
86
+ const failed = await page.evaluate(`globalThis.${SEED_FLAG} ?? ''`);
87
+ if (failed === "origin") {
88
+ input.log(`[shot] ${c.route}: page left the app origin; not seeded`);
89
+ } else if (typeof failed === "string" && failed !== "") {
90
+ addProblem(c, `localStorage seed failed (${failed})`);
91
+ input.log(`[shot] ${c.route}: localStorage seed failed (${failed})`);
92
+ }
93
+ }
94
+ return facts;
95
+ }
96
+ function flagProblems(c) {
97
+ if (c.problems.length === 0) return;
98
+ const note = c.problems.join("; ");
99
+ for (const shot of c.shots)
100
+ if (shot.status === "ok") Object.assign(shot, { status: "error", note });
101
+ if (!c.shots.some((s) => s.name === PAGE_ANCHOR && s.state === "rest"))
102
+ record(c, { name: PAGE_ANCHOR, state: "rest", status: "error", note });
103
+ c.input.log(`[shot] ${c.route} ${c.scheme}/${c.viewport}: ${note}`);
104
+ }
60
105
  async function reveal(anchor) {
61
106
  if (await anchor.count() === 0) throw new Error("anchor not found");
62
107
  await anchor.scrollIntoViewIfNeeded();
@@ -242,8 +287,7 @@ async function captureUrlState(c, state) {
242
287
  }
243
288
  let here;
244
289
  try {
245
- await load(c.page, c.input.base + withParam(c.route, state));
246
- here = await readFacts(c.page);
290
+ here = await visit(c, c.input.base + withParam(c.route, state));
247
291
  } catch (error) {
248
292
  for (const name of restNames)
249
293
  record(c, { name, state, status: "error", note: `load failed: ${firstLine(error)}` });
@@ -332,12 +376,13 @@ async function capturePage(args) {
332
376
  facts: { anchors: [], declared: [] },
333
377
  anchors: [],
334
378
  shots: [],
335
- measured: /* @__PURE__ */ new Set()
379
+ measured: /* @__PURE__ */ new Set(),
380
+ problems: []
336
381
  };
337
382
  const { input, route } = c;
383
+ input.apiProblems?.();
338
384
  try {
339
- await load(c.page, input.base + route);
340
- c.facts = await readFacts(c.page);
385
+ c.facts = await visit(c, input.base + route);
341
386
  } catch (error) {
342
387
  record(c, {
343
388
  name: PAGE_ANCHOR,
@@ -370,15 +415,23 @@ async function capturePage(args) {
370
415
  (path) => snap(c.page, path, { fullPage: true }).then(() => void 0)
371
416
  );
372
417
  }
418
+ flagProblems(c);
373
419
  for (const name of usable) {
374
420
  for (const [state, capture2] of Object.entries(POINTER_STATES)) {
375
- if (input.states.includes(state)) await capture2(c, name);
421
+ if (!input.states.includes(state)) continue;
422
+ await capture2(c, name);
423
+ collect(c);
376
424
  }
377
425
  }
378
- for (const state of URL_STATES) if (input.states.includes(state)) await captureUrlState(c, state);
426
+ for (const state of URL_STATES) {
427
+ if (!input.states.includes(state)) continue;
428
+ await captureUrlState(c, state);
429
+ collect(c);
430
+ }
431
+ flagProblems(c);
379
432
  return c;
380
433
  }
381
- async function openContext(browser, scheme, viewport) {
434
+ async function openContext(browser, scheme, viewport, seeded = [], origin = "") {
382
435
  const spec = VIEWPORT_SPECS[viewport];
383
436
  const context = await browser.newContext({
384
437
  viewport: { width: spec.width, height: spec.height },
@@ -389,6 +442,7 @@ async function openContext(browser, scheme, viewport) {
389
442
  reducedMotion: "reduce"
390
443
  });
391
444
  await context.addInitScript(`localStorage.setItem('mantine-color-scheme-value', '${scheme}')`);
445
+ if (seeded.length > 0) await context.addInitScript(seedScript(seeded, origin));
392
446
  return context;
393
447
  }
394
448
  const SHEET_WIDTH_PX = 2e3;
@@ -439,7 +493,14 @@ async function capture(input) {
439
493
  };
440
494
  for (const scheme of SCHEMES) {
441
495
  for (const viewport of VIEWPORTS) {
442
- const context = await openContext(input.browser, scheme, viewport);
496
+ input.apiProblems?.();
497
+ const context = await openContext(
498
+ input.browser,
499
+ scheme,
500
+ viewport,
501
+ input.localStorage,
502
+ new URL(input.base).origin
503
+ );
443
504
  try {
444
505
  const page = await context.newPage();
445
506
  page.setDefaultTimeout(NAV_TIMEOUT_MS);
@@ -487,6 +548,7 @@ export {
487
548
  parseHoverAt,
488
549
  readScaleInPage,
489
550
  sheetName,
551
+ tagAutoAnchors,
490
552
  tooltipSelector,
491
553
  unionClip,
492
554
  visibleTooltip,
@@ -1,5 +1,6 @@
1
1
  import { capture } from './capture.js';
2
2
  import type { PlaywrightResolver } from './playwright.js';
3
+ import type { ApiRoute, Pair, Source } from './real-data.js';
3
4
  import type { ShotState } from './types.js';
4
5
  export type ShotDeps = {
5
6
  resolve?: PlaywrightResolver;
@@ -14,9 +15,17 @@ export type ShotArgs = {
14
15
  dist?: string;
15
16
  out: string;
16
17
  states: ShotState[];
18
+ /** Resolved secrets: held for the browser only, never written anywhere. */
19
+ localStorage: Pair[];
20
+ api: ApiRoute[];
21
+ headers: Pair[];
22
+ /** Extra settle in ms after networkidle. */
23
+ wait: number;
24
+ allowWrites: boolean;
25
+ autoAnchors: boolean;
17
26
  };
18
27
  /** Parses argv; throws `ShotError` with the one-line reason. */
19
- export declare function parseShotArgs(flags: readonly string[]): ShotArgs;
28
+ export declare function parseShotArgs(flags: readonly string[], src?: Source): ShotArgs;
20
29
  /**
21
30
  * Validates `out` WITHOUT touching it and returns its absolute path. A shot only ever empties what
22
31
  * it wrote: the dir must be absent, empty, or hold a previous run's `metrics.json` (`version: 1`).
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/index.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,KAAK,EAAc,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGlE,OAAO,KAAK,EAAe,SAAS,EAAE,MAAM,SAAS,CAAA;AAQrD,MAAM,MAAM,QAAQ,GAAG;IACrB,OAAO,CAAC,EAAE,kBAAkB,CAAA;IAC5B,sEAAsE;IACtE,OAAO,CAAC,EAAE,OAAO,OAAO,CAAA;IACxB,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;IAChB,GAAG,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC7B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,SAAS,EAAE,CAAA;CACpB,CAAA;AAED,gEAAgE;AAChE,wBAAgB,aAAa,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,QAAQ,CAuChE;AAmCD;;;GAGG;AACH,wB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AG,IAAI,CAE5C;AAED;;;GAGG;AACH,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,GAAG,EAAE,IAAI,GACR,IAAI,CA0BN;AAkBD,wBAAsB,IAAI,CACxB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,QAAa,GAClB,OAAO,CAAC,MAAM,CAAC,CAmFjB;AAED,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC3E,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA"}
@@ -15,12 +15,13 @@ import { parseArgs } from "node:util";
15
15
  import { buildBoard } from "./board.js";
16
16
  import { capture } from "./capture.js";
17
17
  import { INSTALL_LINE, ShotError, resolvePlaywright, withBrowser } from "./playwright.js";
18
+ import { apiProxy, parseApi, parseHeaders, parseStorage } from "./real-data.js";
18
19
  import { serveDist } from "./serve.js";
19
20
  import { SCHEMES, STATES, VIEWPORTS } from "./types.js";
20
21
  const HOME = ".basalt/shots";
21
22
  const DEFAULT_OUT = `${HOME}/latest`;
22
- const USAGE_LINE = "usage: basalt-ui shot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>]";
23
- function parseShotArgs(flags) {
23
+ const USAGE_LINE = "usage: basalt-ui shot <route\u2026> (--base <url> | --dist <dir>) [--out <dir>] [--states <list>] [--local-storage k=@env:X] [--api /p=origin] [--header n=@env:X] [--api-allow-writes] [--wait ms] [--auto-anchors]";
24
+ function parseShotArgs(flags, src = { env: process.env, cwd: process.cwd() }) {
24
25
  let parsed;
25
26
  try {
26
27
  parsed = parseArgs({
@@ -30,7 +31,13 @@ function parseShotArgs(flags) {
30
31
  base: { type: "string" },
31
32
  dist: { type: "string" },
32
33
  out: { type: "string" },
33
- states: { type: "string" }
34
+ states: { type: "string" },
35
+ "local-storage": { type: "string", multiple: true },
36
+ api: { type: "string", multiple: true },
37
+ header: { type: "string", multiple: true },
38
+ wait: { type: "string" },
39
+ "auto-anchors": { type: "boolean" },
40
+ "api-allow-writes": { type: "boolean" }
34
41
  }
35
42
  });
36
43
  } catch (error) {
@@ -51,8 +58,31 @@ ${USAGE_LINE}`);
51
58
  const states = values.states ? values.states.split(",").map((s) => s.trim()).filter(Boolean) : [...STATES];
52
59
  const unknown = states.find((s) => !STATES.includes(s));
53
60
  if (unknown) throw new ShotError(`unknown state '${unknown}'. Known: ${STATES.join(", ")}`);
61
+ const secrets = (values.header?.length ?? 0) + (values["local-storage"]?.length ?? 0) > 0;
62
+ const api = parseApi(values.api ?? [], secrets);
63
+ if (api.length > 0 && !values.dist)
64
+ throw new ShotError(`--api needs --dist (it proxies the static server).
65
+ ${USAGE_LINE}`);
66
+ if ((values.header?.length ?? 0) > 0 && new Set(api.map((r) => r.origin)).size > 1)
67
+ throw new ShotError(
68
+ `--header goes to every --api origin; it is refused when --api names more than one.
69
+ ${USAGE_LINE}`
70
+ );
71
+ if ((values.header?.length ?? 0) > 0 && api.length === 0)
72
+ throw new ShotError(`--header is sent on --api requests only; pass --api.
73
+ ${USAGE_LINE}`);
74
+ const wait = values.wait ?? "networkidle";
75
+ if (wait !== "networkidle" && !/^\d+$/.test(wait))
76
+ throw new ShotError(`--wait takes milliseconds or 'networkidle'.
77
+ ${USAGE_LINE}`);
54
78
  return {
55
79
  routes: positionals,
80
+ localStorage: parseStorage(values["local-storage"] ?? [], src),
81
+ api,
82
+ headers: parseHeaders(values.header ?? [], src),
83
+ wait: wait === "networkidle" ? 0 : Number(wait),
84
+ allowWrites: values["api-allow-writes"] ?? false,
85
+ autoAnchors: values["auto-anchors"] ?? false,
56
86
  ...values.base ? { base: values.base.replace(/\/+$/, "") } : {},
57
87
  ...values.dist ? { dist: values.dist } : {},
58
88
  out: values.out ?? DEFAULT_OUT,
@@ -198,14 +228,15 @@ async function shot(flags, cwd, deps = {}) {
198
228
  const stops = [];
199
229
  const uninstall = exitOnSignal(stops);
200
230
  try {
201
- const args = parseShotArgs(flags);
231
+ const args = parseShotArgs(flags, { env: process.env, cwd });
202
232
  const outDir = planOut(cwd, args.out);
203
233
  recoverOut(outDir);
204
234
  const pw = (deps.resolve ?? resolvePlaywright)(cwd);
205
235
  if (!pw) throw new ShotError(INSTALL_LINE);
206
236
  const now = (deps.now ?? (() => /* @__PURE__ */ new Date()))();
207
237
  sweepStaleTmp(join(cwd, HOME), now);
208
- const server = args.dist ? serveDist(resolve(cwd, args.dist)) : null;
238
+ const proxy = args.api.length > 0 ? apiProxy(args.api, args.headers, { log, allowWrites: args.allowWrites }) : null;
239
+ const server = args.dist ? serveDist(resolve(cwd, args.dist), proxy?.handle) : null;
209
240
  if (server) stops.push(server.stop);
210
241
  let tmp = "";
211
242
  stops.push(() => tmp && rmSync(tmp, { recursive: true, force: true }));
@@ -226,6 +257,10 @@ async function shot(flags, cwd, deps = {}) {
226
257
  routes: args.routes,
227
258
  states: args.states,
228
259
  pngDir: join(tmp, "png"),
260
+ localStorage: args.localStorage,
261
+ wait: args.wait,
262
+ autoAnchors: args.autoAnchors,
263
+ ...proxy && { apiProblems: proxy.drain },
229
264
  log
230
265
  });
231
266
  },
@@ -0,0 +1,35 @@
1
+ export type ApiRoute = {
2
+ prefix: string;
3
+ origin: string;
4
+ };
5
+ export type Pair = readonly [name: string, value: string];
6
+ export type Source = {
7
+ env: Readonly<Record<string, string | undefined>>;
8
+ cwd: string;
9
+ };
10
+ export declare const parseStorage: (list: readonly string[], src: Source) => Pair[];
11
+ /** `--header` pairs: a valid, forwardable name and a value that cannot split the request. */
12
+ export declare const parseHeaders: (list: readonly string[], src: Source) => Pair[];
13
+ /** `--api <prefix>=<origin>`; with any secret configured (`--header`, `--local-storage`), a remote origin must be https. */
14
+ export declare function parseApi(list: readonly string[], secrets: boolean): ApiRoute[];
15
+ export type ApiProxy = {
16
+ handle: (req: Request) => Promise<Response | null>;
17
+ /** The calls since the last drain that make a board untrustworthy: a 3xx, 401, 403, 404, 5xx or no answer. */
18
+ drain: () => string[];
19
+ };
20
+ /**
21
+ * The static server's API hook: a GET/HEAD under a prefix goes to `<origin><path>?<query>` with the
22
+ * `--header` values added, except on a navigation; any other method is a 405 unless `allowWrites`.
23
+ * Anything else is null (served from `--dist`). Every non-2xx or failed call is logged by method,
24
+ * path and status or error class, never a header or a query.
25
+ */
26
+ export declare function apiProxy(api: readonly ApiRoute[], headers: readonly Pair[], opts: {
27
+ log: (line: string) => void;
28
+ allowWrites?: boolean;
29
+ timeoutMs?: number;
30
+ }): ApiProxy;
31
+ /** The page global the seed script reports through: `origin`, or the keys it could not set. */
32
+ export declare const SEED_FLAG = "__shotSeedFailed";
33
+ /** The init script that seeds localStorage, only on `origin` and only for an absent key (a token the app rotates survives), before any page script runs. */
34
+ export declare const seedScript: (entries: readonly Pair[], origin: string) => string;
35
+ //# sourceMappingURL=real-data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"real-data.d.ts","sourceRoot":"","sources":["../../../src/cli/shot/real-data.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,QAAQ,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AACzD,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;AACzD,MAAM,MAAM,MAAM,GAAG;IAAE,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAyBvF,eAAO,MAAM,YAAY,GAAI,MAAM,SAAS,MAAM,EAAE,EAAE,KAAK,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