@xtyle/core 0.6.0 → 0.7.1
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/README.md +43 -10
- package/dist/algorithms/factory.d.ts +37 -1
- package/dist/algorithms/factory.d.ts.map +1 -1
- package/dist/algorithms/factory.js +407 -60
- package/dist/algorithms/factory.js.map +1 -1
- package/dist/audit.d.ts +36 -0
- package/dist/audit.d.ts.map +1 -1
- package/dist/audit.js +22 -0
- package/dist/audit.js.map +1 -1
- package/dist/authoring.d.ts +10 -1
- package/dist/authoring.d.ts.map +1 -1
- package/dist/authoring.js +6 -1
- package/dist/authoring.js.map +1 -1
- package/dist/baked.d.ts +14 -1
- package/dist/baked.d.ts.map +1 -1
- package/dist/baked.js +17 -0
- package/dist/baked.js.map +1 -1
- package/dist/batteries.js +11 -2
- package/dist/cli.js +58 -19
- package/dist/cli.js.map +1 -1
- package/dist/color.d.ts +6 -0
- package/dist/color.d.ts.map +1 -1
- package/dist/color.js +20 -0
- package/dist/color.js.map +1 -1
- package/dist/css/components/app-shell.d.ts.map +1 -1
- package/dist/css/components/app-shell.js +10 -0
- package/dist/css/components/app-shell.js.map +1 -1
- package/dist/css/components/avatar.d.ts.map +1 -1
- package/dist/css/components/avatar.js +8 -19
- package/dist/css/components/avatar.js.map +1 -1
- package/dist/css/components/badge.d.ts.map +1 -1
- package/dist/css/components/badge.js +3 -87
- package/dist/css/components/badge.js.map +1 -1
- package/dist/css/components/bottom-nav.d.ts +2 -0
- package/dist/css/components/bottom-nav.d.ts.map +1 -0
- package/dist/css/components/bottom-nav.js +72 -0
- package/dist/css/components/bottom-nav.js.map +1 -0
- package/dist/css/components/carousel.d.ts.map +1 -1
- package/dist/css/components/carousel.js +144 -1
- package/dist/css/components/carousel.js.map +1 -1
- package/dist/css/components/dialog.d.ts.map +1 -1
- package/dist/css/components/dialog.js +10 -4
- package/dist/css/components/dialog.js.map +1 -1
- package/dist/css/components/dot.d.ts +2 -0
- package/dist/css/components/dot.d.ts.map +1 -0
- package/dist/css/components/dot.js +72 -0
- package/dist/css/components/dot.js.map +1 -0
- package/dist/css/components/heatmap.d.ts.map +1 -1
- package/dist/css/components/heatmap.js +23 -0
- package/dist/css/components/heatmap.js.map +1 -1
- package/dist/css/components/image.d.ts.map +1 -1
- package/dist/css/components/image.js +41 -0
- package/dist/css/components/image.js.map +1 -1
- package/dist/css/components/mobile-shell.d.ts +2 -0
- package/dist/css/components/mobile-shell.d.ts.map +1 -0
- package/dist/css/components/mobile-shell.js +63 -0
- package/dist/css/components/mobile-shell.js.map +1 -0
- package/dist/css/components/panel.js +1 -1
- package/dist/css/components/qr.d.ts +2 -0
- package/dist/css/components/qr.d.ts.map +1 -0
- package/dist/css/components/qr.js +134 -0
- package/dist/css/components/qr.js.map +1 -0
- package/dist/css/components/radio.d.ts.map +1 -1
- package/dist/css/components/radio.js +49 -0
- package/dist/css/components/radio.js.map +1 -1
- package/dist/css/components/ribbon.d.ts +2 -0
- package/dist/css/components/ribbon.d.ts.map +1 -0
- package/dist/css/components/ribbon.js +65 -0
- package/dist/css/components/ribbon.js.map +1 -0
- package/dist/css/components/tree.d.ts.map +1 -1
- package/dist/css/components/tree.js +4 -1
- package/dist/css/components/tree.js.map +1 -1
- package/dist/css/components.d.ts.map +1 -1
- package/dist/css/components.js +14 -1
- package/dist/css/components.js.map +1 -1
- package/dist/css/index.d.ts +2 -0
- package/dist/css/index.d.ts.map +1 -1
- package/dist/css/index.js +2 -0
- package/dist/css/index.js.map +1 -1
- package/dist/elements/avatar.d.ts +18 -3
- package/dist/elements/avatar.d.ts.map +1 -1
- package/dist/elements/avatar.js +35 -6
- package/dist/elements/avatar.js.map +1 -1
- package/dist/elements/bottom-nav.d.ts +30 -0
- package/dist/elements/bottom-nav.d.ts.map +1 -0
- package/dist/elements/bottom-nav.js +114 -0
- package/dist/elements/bottom-nav.js.map +1 -0
- package/dist/elements/carousel.d.ts +61 -0
- package/dist/elements/carousel.d.ts.map +1 -1
- package/dist/elements/carousel.js +282 -22
- package/dist/elements/carousel.js.map +1 -1
- package/dist/elements/dialog.d.ts +3 -3
- package/dist/elements/dialog.d.ts.map +1 -1
- package/dist/elements/dialog.js.map +1 -1
- package/dist/elements/dot.d.ts +37 -0
- package/dist/elements/dot.d.ts.map +1 -0
- package/dist/elements/dot.js +104 -0
- package/dist/elements/dot.js.map +1 -0
- package/dist/elements/fragment-ssr.d.ts.map +1 -1
- package/dist/elements/fragment-ssr.js +10 -0
- package/dist/elements/fragment-ssr.js.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/avatar/source.generated.js +1 -1
- package/dist/elements/fragments/avatar/source.generated.js.map +1 -1
- package/dist/elements/fragments/badge/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/badge/source.generated.js +1 -1
- package/dist/elements/fragments/badge/source.generated.js.map +1 -1
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts +25 -0
- package/dist/elements/fragments/bottom-nav/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js +4 -0
- package/dist/elements/fragments/bottom-nav/source.generated.js.map +1 -0
- package/dist/elements/fragments/component-host.json +147 -77
- package/dist/elements/fragments/dot/source.generated.d.ts +25 -0
- package/dist/elements/fragments/dot/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/dot/source.generated.js +4 -0
- package/dist/elements/fragments/dot/source.generated.js.map +1 -0
- package/dist/elements/fragments/heatmap/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js +1 -1
- package/dist/elements/fragments/heatmap/source.generated.js.map +1 -1
- package/dist/elements/fragments/icon/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/icon/source.generated.js +1 -1
- package/dist/elements/fragments/icon/source.generated.js.map +1 -1
- package/dist/elements/fragments/image/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/image/source.generated.js +1 -1
- package/dist/elements/fragments/image/source.generated.js.map +1 -1
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts +25 -0
- package/dist/elements/fragments/mobile-shell/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js +4 -0
- package/dist/elements/fragments/mobile-shell/source.generated.js.map +1 -0
- package/dist/elements/fragments/qr/source.generated.d.ts +25 -0
- package/dist/elements/fragments/qr/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/qr/source.generated.js +4 -0
- package/dist/elements/fragments/qr/source.generated.js.map +1 -0
- package/dist/elements/fragments/radio/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/radio/source.generated.js +1 -1
- package/dist/elements/fragments/radio/source.generated.js.map +1 -1
- package/dist/elements/fragments/ribbon/source.generated.d.ts +25 -0
- package/dist/elements/fragments/ribbon/source.generated.d.ts.map +1 -0
- package/dist/elements/fragments/ribbon/source.generated.js +4 -0
- package/dist/elements/fragments/ribbon/source.generated.js.map +1 -0
- package/dist/elements/fragments/segmented/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/segmented/source.generated.js +1 -1
- package/dist/elements/fragments/segmented/source.generated.js.map +1 -1
- package/dist/elements/fragments/slider/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/slider/source.generated.js +1 -1
- package/dist/elements/fragments/slider/source.generated.js.map +1 -1
- package/dist/elements/fragments/tree/source.generated.d.ts.map +1 -1
- package/dist/elements/fragments/tree/source.generated.js +1 -1
- package/dist/elements/fragments/tree/source.generated.js.map +1 -1
- package/dist/elements/heatmap.d.ts +14 -3
- package/dist/elements/heatmap.d.ts.map +1 -1
- package/dist/elements/heatmap.js +49 -18
- package/dist/elements/heatmap.js.map +1 -1
- package/dist/elements/image.d.ts +20 -1
- package/dist/elements/image.d.ts.map +1 -1
- package/dist/elements/image.js +171 -1
- package/dist/elements/image.js.map +1 -1
- package/dist/elements/index.d.ts +10 -0
- package/dist/elements/index.d.ts.map +1 -1
- package/dist/elements/index.js +10 -0
- package/dist/elements/index.js.map +1 -1
- package/dist/elements/mobile-shell.d.ts +24 -0
- package/dist/elements/mobile-shell.d.ts.map +1 -0
- package/dist/elements/mobile-shell.js +53 -0
- package/dist/elements/mobile-shell.js.map +1 -0
- package/dist/elements/qr.d.ts +65 -0
- package/dist/elements/qr.d.ts.map +1 -0
- package/dist/elements/qr.js +244 -0
- package/dist/elements/qr.js.map +1 -0
- package/dist/elements/radio.d.ts +1 -0
- package/dist/elements/radio.d.ts.map +1 -1
- package/dist/elements/radio.js +7 -1
- package/dist/elements/radio.js.map +1 -1
- package/dist/elements/ribbon.d.ts +36 -0
- package/dist/elements/ribbon.d.ts.map +1 -0
- package/dist/elements/ribbon.js +91 -0
- package/dist/elements/ribbon.js.map +1 -0
- package/dist/elements/segmented.d.ts.map +1 -1
- package/dist/elements/segmented.js +3 -0
- package/dist/elements/segmented.js.map +1 -1
- package/dist/elements/slider.d.ts +25 -1
- package/dist/elements/slider.d.ts.map +1 -1
- package/dist/elements/slider.js +122 -16
- package/dist/elements/slider.js.map +1 -1
- package/dist/elements/sparkline.d.ts +3 -1
- package/dist/elements/sparkline.d.ts.map +1 -1
- package/dist/elements/sparkline.js +13 -3
- package/dist/elements/sparkline.js.map +1 -1
- package/dist/emit/css.d.ts.map +1 -1
- package/dist/emit/css.js +5 -1
- package/dist/emit/css.js.map +1 -1
- package/dist/emit/index.d.ts +2 -1
- package/dist/emit/index.d.ts.map +1 -1
- package/dist/emit/index.js +3 -1
- package/dist/emit/index.js.map +1 -1
- package/dist/emit/monaco.d.ts.map +1 -1
- package/dist/emit/monaco.js +2 -18
- package/dist/emit/monaco.js.map +1 -1
- package/dist/emit/terminal.d.ts +9 -0
- package/dist/emit/terminal.d.ts.map +1 -0
- package/dist/emit/terminal.js +32 -0
- package/dist/emit/terminal.js.map +1 -0
- package/dist/gauntlet.d.ts.map +1 -1
- package/dist/gauntlet.js +26 -0
- package/dist/gauntlet.js.map +1 -1
- package/dist/host/algorithms-bundle.generated.d.ts.map +1 -1
- package/dist/host/algorithms-bundle.generated.js +1 -1
- package/dist/host/algorithms-bundle.generated.js.map +1 -1
- package/dist/host/authoring-prelude.generated.d.ts +1 -1
- package/dist/host/authoring-prelude.generated.d.ts.map +1 -1
- package/dist/host/authoring-prelude.generated.js +1 -1
- package/dist/host/authoring-prelude.generated.js.map +1 -1
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +12 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/registry.d.ts +34 -7
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.js +45 -11
- package/dist/host/registry.js.map +1 -1
- package/dist/icon-builder.d.ts +41 -0
- package/dist/icon-builder.d.ts.map +1 -1
- package/dist/icon-builder.js +129 -8
- package/dist/icon-builder.js.map +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/icons.js +2 -0
- package/dist/icons.js.map +1 -1
- package/dist/index.d.ts +12 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/knobs.d.ts +22 -0
- package/dist/knobs.d.ts.map +1 -0
- package/dist/knobs.js +63 -0
- package/dist/knobs.js.map +1 -0
- package/dist/manifest/avatar.manifest.d.ts.map +1 -1
- package/dist/manifest/avatar.manifest.js +37 -17
- package/dist/manifest/avatar.manifest.js.map +1 -1
- package/dist/manifest/badge.manifest.js +1 -1
- package/dist/manifest/badge.manifest.js.map +1 -1
- package/dist/manifest/bottom-nav.manifest.d.ts +3 -0
- package/dist/manifest/bottom-nav.manifest.d.ts.map +1 -0
- package/dist/manifest/bottom-nav.manifest.js +149 -0
- package/dist/manifest/bottom-nav.manifest.js.map +1 -0
- package/dist/manifest/carousel.manifest.d.ts.map +1 -1
- package/dist/manifest/carousel.manifest.js +58 -4
- package/dist/manifest/carousel.manifest.js.map +1 -1
- package/dist/manifest/dialog.manifest.d.ts.map +1 -1
- package/dist/manifest/dialog.manifest.js +7 -4
- package/dist/manifest/dialog.manifest.js.map +1 -1
- package/dist/manifest/dot.manifest.d.ts +3 -0
- package/dist/manifest/dot.manifest.d.ts.map +1 -0
- package/dist/manifest/dot.manifest.js +172 -0
- package/dist/manifest/dot.manifest.js.map +1 -0
- package/dist/manifest/heatmap.manifest.d.ts.map +1 -1
- package/dist/manifest/heatmap.manifest.js +60 -2
- package/dist/manifest/heatmap.manifest.js.map +1 -1
- package/dist/manifest/icon.manifest.d.ts.map +1 -1
- package/dist/manifest/icon.manifest.js +28 -1
- package/dist/manifest/icon.manifest.js.map +1 -1
- package/dist/manifest/image.manifest.d.ts.map +1 -1
- package/dist/manifest/image.manifest.js +100 -1
- package/dist/manifest/image.manifest.js.map +1 -1
- package/dist/manifest/mobile-shell.manifest.d.ts +3 -0
- package/dist/manifest/mobile-shell.manifest.d.ts.map +1 -0
- package/dist/manifest/mobile-shell.manifest.js +177 -0
- package/dist/manifest/mobile-shell.manifest.js.map +1 -0
- package/dist/manifest/panel.manifest.d.ts.map +1 -1
- package/dist/manifest/panel.manifest.js +2 -1
- package/dist/manifest/panel.manifest.js.map +1 -1
- package/dist/manifest/qr.manifest.d.ts +3 -0
- package/dist/manifest/qr.manifest.d.ts.map +1 -0
- package/dist/manifest/qr.manifest.js +314 -0
- package/dist/manifest/qr.manifest.js.map +1 -0
- package/dist/manifest/radio.manifest.d.ts.map +1 -1
- package/dist/manifest/radio.manifest.js +54 -1
- package/dist/manifest/radio.manifest.js.map +1 -1
- package/dist/manifest/registry.d.ts.map +1 -1
- package/dist/manifest/registry.js +10 -0
- package/dist/manifest/registry.js.map +1 -1
- package/dist/manifest/ribbon.manifest.d.ts +3 -0
- package/dist/manifest/ribbon.manifest.d.ts.map +1 -0
- package/dist/manifest/ribbon.manifest.js +173 -0
- package/dist/manifest/ribbon.manifest.js.map +1 -0
- package/dist/manifest/segmented.manifest.js +5 -5
- package/dist/manifest/segmented.manifest.js.map +1 -1
- package/dist/manifest/slider.manifest.d.ts.map +1 -1
- package/dist/manifest/slider.manifest.js +62 -4
- package/dist/manifest/slider.manifest.js.map +1 -1
- package/dist/manifest/sparkline.manifest.d.ts.map +1 -1
- package/dist/manifest/sparkline.manifest.js +27 -1
- package/dist/manifest/sparkline.manifest.js.map +1 -1
- package/dist/manifest/tree.manifest.d.ts.map +1 -1
- package/dist/manifest/tree.manifest.js +24 -10
- package/dist/manifest/tree.manifest.js.map +1 -1
- package/dist/markup/avatar.d.ts +33 -0
- package/dist/markup/avatar.d.ts.map +1 -1
- package/dist/markup/avatar.js +55 -5
- package/dist/markup/avatar.js.map +1 -1
- package/dist/markup/bottom-nav.d.ts +11 -0
- package/dist/markup/bottom-nav.d.ts.map +1 -0
- package/dist/markup/bottom-nav.js +3 -0
- package/dist/markup/bottom-nav.js.map +1 -0
- package/dist/markup/dialog.d.ts +3 -0
- package/dist/markup/dialog.d.ts.map +1 -1
- package/dist/markup/dialog.js.map +1 -1
- package/dist/markup/dot.d.ts +27 -0
- package/dist/markup/dot.d.ts.map +1 -0
- package/dist/markup/dot.js +27 -0
- package/dist/markup/dot.js.map +1 -0
- package/dist/markup/heatmap.d.ts +2 -2
- package/dist/markup/heatmap.d.ts.map +1 -1
- package/dist/markup/heatmap.js.map +1 -1
- package/dist/markup/image.d.ts +9 -0
- package/dist/markup/image.d.ts.map +1 -1
- package/dist/markup/image.js +24 -0
- package/dist/markup/image.js.map +1 -1
- package/dist/markup/index.d.ts +17 -7
- package/dist/markup/index.d.ts.map +1 -1
- package/dist/markup/index.js +9 -4
- package/dist/markup/index.js.map +1 -1
- package/dist/markup/mobile-shell.d.ts +3 -0
- package/dist/markup/mobile-shell.d.ts.map +1 -0
- package/dist/markup/mobile-shell.js +3 -0
- package/dist/markup/mobile-shell.js.map +1 -0
- package/dist/markup/qr.d.ts +77 -0
- package/dist/markup/qr.d.ts.map +1 -0
- package/dist/markup/qr.js +37 -0
- package/dist/markup/qr.js.map +1 -0
- package/dist/markup/radio.d.ts +1 -1
- package/dist/markup/radio.d.ts.map +1 -1
- package/dist/markup/radio.js +1 -1
- package/dist/markup/radio.js.map +1 -1
- package/dist/markup/ribbon.d.ts +23 -0
- package/dist/markup/ribbon.d.ts.map +1 -0
- package/dist/markup/ribbon.js +23 -0
- package/dist/markup/ribbon.js.map +1 -0
- package/dist/markup/segmented.d.ts +2 -0
- package/dist/markup/segmented.d.ts.map +1 -1
- package/dist/markup/segmented.js +2 -0
- package/dist/markup/segmented.js.map +1 -1
- package/dist/markup/sparkline.d.ts +8 -0
- package/dist/markup/sparkline.d.ts.map +1 -1
- package/dist/markup/sparkline.js +37 -0
- package/dist/markup/sparkline.js.map +1 -1
- package/dist/markup/tree.d.ts +15 -4
- package/dist/markup/tree.d.ts.map +1 -1
- package/dist/markup/tree.js +16 -4
- package/dist/markup/tree.js.map +1 -1
- package/dist/mcp/tools.d.ts +7 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +65 -29
- package/dist/mcp/tools.js.map +1 -1
- package/dist/qr.d.ts +84 -0
- package/dist/qr.d.ts.map +1 -0
- package/dist/qr.js +596 -0
- package/dist/qr.js.map +1 -0
- package/dist/series.d.ts +29 -0
- package/dist/series.d.ts.map +1 -1
- package/dist/series.js +36 -0
- package/dist/series.js.map +1 -1
- package/dist/theme-file.d.ts +21 -0
- package/dist/theme-file.d.ts.map +1 -1
- package/dist/theme-file.js +42 -0
- package/dist/theme-file.js.map +1 -1
- package/dist/token-meta.d.ts.map +1 -1
- package/dist/token-meta.js +6 -0
- package/dist/token-meta.js.map +1 -1
- package/dist/types.d.ts +99 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/vocab.d.ts +5 -0
- package/dist/vocab.d.ts.map +1 -1
- package/dist/vocab.js.map +1 -1
- package/manifest.json +25 -2
- package/package.json +1 -1
|
@@ -9,14 +9,43 @@ export const BORDER_SEPARATION = 1.5;
|
|
|
9
9
|
export const DIVIDER_SEPARATION = 1.8;
|
|
10
10
|
const DEFAULT_SHIFT_STEP = 90;
|
|
11
11
|
const DEFAULT_ACCENT_SPLIT = 45;
|
|
12
|
+
/**
|
|
13
|
+
* The magnitude of one step on the surface stack. The *sign* is scheme-derived rather than constant
|
|
14
|
+
* (see {@link defaultSurfaceRamp}), so this is a magnitude and never a `surfaceRamp` value on its own.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_SURFACE_STEP = 0.045;
|
|
17
|
+
/** The `surfaceRamp` a scheme resolves to when the knob is unset: dark ascends the stack, light descends it. */
|
|
18
|
+
function defaultSurfaceRamp(scheme) {
|
|
19
|
+
return scheme === "dark" ? DEFAULT_SURFACE_STEP : -DEFAULT_SURFACE_STEP;
|
|
20
|
+
}
|
|
12
21
|
// Chroma of the faint accent-hue wash on a surface synthesized from an accent (the "keep the tone"
|
|
13
22
|
// derivation); kept low enough that any hue stays a neutral-reading surface rather than a muddy fill.
|
|
14
23
|
const DERIVED_SURFACE_TINT_C = 0.02;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
24
|
+
const DEFAULT_ACCENT_STRATEGY = "fan";
|
|
25
|
+
const ACCENT_STRATEGIES = ["fan", "step", "shade", "duo"];
|
|
26
|
+
/**
|
|
27
|
+
* The accent strategy in force for one derivation. It is both an algorithm's taste (a preset picks
|
|
28
|
+
* the posture it ships with) and a knob (a theme overrides it), so the knob wins where it is set and
|
|
29
|
+
* the preset's own choice is the default — the same layering anchors and every other knob follow.
|
|
30
|
+
*/
|
|
31
|
+
function accentStrategyOf(preset, knobs) {
|
|
32
|
+
const knob = knobs.accentStrategy;
|
|
33
|
+
if (typeof knob === "string" && ACCENT_STRATEGIES.includes(knob))
|
|
34
|
+
return knob;
|
|
35
|
+
return preset.accentStrategy ?? DEFAULT_ACCENT_STRATEGY;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Everything the accent family is built from, resolved in one place. The derivation and the
|
|
39
|
+
* invariant that grades it must read these identically — if they drift, the gauntlet grades a fan
|
|
40
|
+
* the engine never built.
|
|
41
|
+
*/
|
|
42
|
+
function resolveAccentKnobs(preset, knobs) {
|
|
43
|
+
return {
|
|
44
|
+
strategy: accentStrategyOf(preset, knobs),
|
|
45
|
+
split: typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT,
|
|
46
|
+
shiftStep: typeof knobs.accentShiftStep === "number" ? knobs.accentShiftStep : DEFAULT_SHIFT_STEP,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
20
49
|
const ACHROMATIC_CHROMA = 0.02;
|
|
21
50
|
const DERIVED_ACCENT_HUE_ROTATION = 150;
|
|
22
51
|
const DERIVED_ACCENT_FALLBACK_HUE = 250;
|
|
@@ -24,6 +53,12 @@ const DERIVED_ACCENT_L = 0.62;
|
|
|
24
53
|
const DERIVED_ACCENT_C = 0.16;
|
|
25
54
|
const ACCENT_RAMP_L_MIN = 0.1;
|
|
26
55
|
const ACCENT_RAMP_L_MAX = 0.95;
|
|
56
|
+
// The `shade` strategy steps lightness (not hue) by this much per rung: `accent-2` a tint one step
|
|
57
|
+
// up, `accent-3`/`-4` one and two steps down, so the four read as distinct shades of the one brand hue.
|
|
58
|
+
const SHADE_LADDER_L_STEP = 0.12;
|
|
59
|
+
// How far `duo`'s two derived shades sit from the mean lightness of its two brand anchors. Larger than
|
|
60
|
+
// a single `shade` rung: the shades must clear *both* anchors, not just step away from one.
|
|
61
|
+
const DUO_L_STEP = 0.16;
|
|
27
62
|
const HUE_STABLE_CHROMA = 0.1;
|
|
28
63
|
// The fan (accent-2/3/4) varies hue at the accent's L/C, which collapses to identical grays when the
|
|
29
64
|
// accent has near-zero chroma. Floor the fan's *base* chroma (not the primary accent) so a near-gray
|
|
@@ -102,6 +137,23 @@ const CODE_HUE_RANK = [0, 4, 2, 6, 1, 5, 3, 7];
|
|
|
102
137
|
const CODE_STRUCTURAL_ROLES = ["comment", "operator", "punctuation", "variable"];
|
|
103
138
|
const CODE_SCOPES = [...CODE_VIVID_ROLES, ...CODE_STRUCTURAL_ROLES];
|
|
104
139
|
const CODE_SURFACES = ["--code-bg", "--code-fg", "--code-line-highlight", "--code-selection"];
|
|
140
|
+
// The ANSI palette. The four chrome roles map to xterm.js's ITheme
|
|
141
|
+
// (background / foreground / cursor / cursorAccent), and the sixteen colors are the
|
|
142
|
+
// standard 8 + 8-bright set. The six chromatic slots take fixed hue angles (aligned
|
|
143
|
+
// with the named `--color-*` palette) so a terminal skin re-colours with the chrome
|
|
144
|
+
// while staying recognisably red/green/yellow/blue/magenta/cyan; `black` and `white`
|
|
145
|
+
// are the achromatic endpoints (bg-fill / text) that a terminal uses regardless of scheme.
|
|
146
|
+
const TERMINAL_CHROME = ["bg", "fg", "cursor", "cursor-accent"];
|
|
147
|
+
const ANSI_ORDER = ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white"];
|
|
148
|
+
const ANSI_HUES = {
|
|
149
|
+
red: 25,
|
|
150
|
+
green: 145,
|
|
151
|
+
yellow: 95,
|
|
152
|
+
blue: 250,
|
|
153
|
+
magenta: 330,
|
|
154
|
+
cyan: 200,
|
|
155
|
+
};
|
|
156
|
+
const ANSI_CHROMATIC = ["red", "green", "yellow", "blue", "magenta", "cyan"];
|
|
105
157
|
const SURFACES = ["--body-bg", "--bg-0", "--bg-1", "--bg-2", "--bg-3"];
|
|
106
158
|
const PANEL_REF_INDEX = SURFACES.indexOf("--bg-2");
|
|
107
159
|
const PANEL_SURFACES = ["--bg-1", "--bg-2"];
|
|
@@ -150,6 +202,9 @@ function buildProduces() {
|
|
|
150
202
|
add("--placeholder", "color");
|
|
151
203
|
add("--line", "color");
|
|
152
204
|
add("--line-2", "color");
|
|
205
|
+
add("--scrollbar-track", "color");
|
|
206
|
+
add("--scrollbar-thumb", "color");
|
|
207
|
+
add("--scrollbar-thumb-hover", "color");
|
|
153
208
|
add("--ring", "color");
|
|
154
209
|
add("--ring-bg", "color");
|
|
155
210
|
add("--accent", "color");
|
|
@@ -204,6 +259,12 @@ function buildProduces() {
|
|
|
204
259
|
add(t, "color");
|
|
205
260
|
for (const role of CODE_SCOPES)
|
|
206
261
|
add(`--code-${role}`, "color");
|
|
262
|
+
for (const role of TERMINAL_CHROME)
|
|
263
|
+
add(`--terminal-${role}`, "color");
|
|
264
|
+
for (const name of ANSI_ORDER) {
|
|
265
|
+
add(`--terminal-${name}`, "color");
|
|
266
|
+
add(`--terminal-bright-${name}`, "color");
|
|
267
|
+
}
|
|
207
268
|
add("--font-sans", "font");
|
|
208
269
|
add("--font-mono", "font");
|
|
209
270
|
add("--font-display", "font");
|
|
@@ -237,10 +298,6 @@ const { produces: PRODUCES, categories: CATEGORIES } = buildProduces();
|
|
|
237
298
|
export const KEYWORD_DOMAINS = {
|
|
238
299
|
"--selection-cue": ["tint", "marker"],
|
|
239
300
|
};
|
|
240
|
-
function stepLightness(base, scheme, step, index) {
|
|
241
|
-
const direction = scheme === "dark" ? 1 : -1;
|
|
242
|
-
return base + direction * step * index;
|
|
243
|
-
}
|
|
244
301
|
function contrastBandFloor(knobs) {
|
|
245
302
|
const band = knobs.contrastBand;
|
|
246
303
|
if (typeof band === "number")
|
|
@@ -737,7 +794,32 @@ function resolveStatusHue(role, pinned) {
|
|
|
737
794
|
const pin = parseChromaticPin(pinned[`--${name}`] ?? pinned[`--color-${name}-base`] ?? pinned[`--color-${name}`]);
|
|
738
795
|
return pin ? pin.h : paletteHueAngle(name);
|
|
739
796
|
}
|
|
797
|
+
/**
|
|
798
|
+
* A single derivation is pure in `(preset, opts)`, and a live editor asks for the same one
|
|
799
|
+
* several ways at once: `derive` resolves the graph, `lineage` reads its edges, an inspector
|
|
800
|
+
* reads it again. Without this they each pay a full OKLCH pass over the whole register. The
|
|
801
|
+
* cache is per-preset and bounded — a slider drag mints a new key per settled value, so it
|
|
802
|
+
* evicts oldest-first rather than growing for the life of the page.
|
|
803
|
+
*/
|
|
804
|
+
const GRAPH_CACHE_LIMIT = 16;
|
|
805
|
+
const graphCaches = new WeakMap();
|
|
740
806
|
export function buildGraph(preset, opts) {
|
|
807
|
+
let cache = graphCaches.get(preset);
|
|
808
|
+
if (!cache)
|
|
809
|
+
graphCaches.set(preset, (cache = new Map()));
|
|
810
|
+
const key = JSON.stringify(opts ?? {});
|
|
811
|
+
const hit = cache.get(key);
|
|
812
|
+
if (hit)
|
|
813
|
+
return hit;
|
|
814
|
+
const nodes = buildGraphUncached(preset, opts);
|
|
815
|
+
cache.set(key, nodes);
|
|
816
|
+
if (cache.size > GRAPH_CACHE_LIMIT) {
|
|
817
|
+
const oldest = cache.keys().next().value;
|
|
818
|
+
cache.delete(oldest);
|
|
819
|
+
}
|
|
820
|
+
return nodes;
|
|
821
|
+
}
|
|
822
|
+
function buildGraphUncached(preset, opts) {
|
|
741
823
|
const completed = completeAnchors(preset, opts);
|
|
742
824
|
const bg = completed.bg;
|
|
743
825
|
const fgAnchor = completed.fg;
|
|
@@ -745,8 +827,7 @@ export function buildGraph(preset, opts) {
|
|
|
745
827
|
const accent = pinned["--accent"] ? toOklchColor(pinned["--accent"]) : completed.accent;
|
|
746
828
|
const scheme = completed.scheme;
|
|
747
829
|
const knobs = opts.knobs ?? {};
|
|
748
|
-
const
|
|
749
|
-
const accentSplit = typeof knobs.accentSplit === "number" ? knobs.accentSplit : DEFAULT_ACCENT_SPLIT;
|
|
830
|
+
const { strategy, split: accentSplit, shiftStep } = resolveAccentKnobs(preset, knobs);
|
|
750
831
|
const band = contrastBandFloor(knobs);
|
|
751
832
|
const floor = Math.max(ENFORCE, preset.contrastFloor, (band ?? 0) + 0.2);
|
|
752
833
|
const extreme = preset.extreme === true;
|
|
@@ -757,7 +838,11 @@ export function buildGraph(preset, opts) {
|
|
|
757
838
|
const radiusScale = radiusScaleOf(knobs);
|
|
758
839
|
const density = densityOf(knobs);
|
|
759
840
|
const fonts = fontsOf(knobs);
|
|
760
|
-
|
|
841
|
+
// The signed lightness delta the surface stack walks from `--bg-0`. Unset, it resolves to the
|
|
842
|
+
// scheme-derived direction (dark ascends, light descends) at the default magnitude, so output is
|
|
843
|
+
// unchanged; set, the author's sign wins and the whole stack (body-bg, bg-1/2/3, bg-sunken)
|
|
844
|
+
// follows the one number instead of six hand-pinned surfaces.
|
|
845
|
+
const surfaceRamp = typeof knobs.surfaceRamp === "number" ? knobs.surfaceRamp : defaultSurfaceRamp(scheme);
|
|
761
846
|
const nodes = [];
|
|
762
847
|
const lit = (name, value, refs) => {
|
|
763
848
|
nodes.push(refs && refs.length ? { name, value, refs } : { name, value });
|
|
@@ -769,14 +854,13 @@ export function buildGraph(preset, opts) {
|
|
|
769
854
|
? toOklchColor(pinned["--bg-0"])
|
|
770
855
|
: extreme
|
|
771
856
|
? oklch(scheme === "dark" ? 0 : 1, 0, 0)
|
|
772
|
-
: ensureTextHeadroom(withLightness(bg,
|
|
857
|
+
: ensureTextHeadroom(withLightness(bg, bg.l + surfaceRamp), scheme, floor);
|
|
773
858
|
const pageFloor = (fill) => separateFillFromSurface(fill, bg0, SURFACE_SEPARATION, floor);
|
|
774
|
-
const
|
|
775
|
-
const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + direction * surfaceStep * (index - 1)));
|
|
859
|
+
const surfaceColors = SURFACES.map((_, index) => withLightness(bg0, bg0.l + surfaceRamp * (index - 1)));
|
|
776
860
|
SURFACES.forEach((name, index) => {
|
|
777
861
|
lit(name, formatCss(surfaceColors[index]), refIfPinned("--bg-0"));
|
|
778
862
|
});
|
|
779
|
-
lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l -
|
|
863
|
+
lit("--bg-sunken", formatCss(withLightness(bg0, bg0.l - surfaceRamp * 2)), refIfPinned("--bg-0"));
|
|
780
864
|
lit("--scrim", formatCss(oklch(scheme === "dark" ? 0 : 0.1, 0, 0, 0.6)));
|
|
781
865
|
const overlayBase = withLightness(bg0, scheme === "dark" ? bg0.l + 0.07 : bg0.l + 0.03);
|
|
782
866
|
lit("--surface-overlay", formatCss(overlayBase), refIfPinned("--bg-0"));
|
|
@@ -897,7 +981,11 @@ export function buildGraph(preset, opts) {
|
|
|
897
981
|
const line2Seed = extreme
|
|
898
982
|
? oklch(scheme === "dark" ? 0.85 : 0.15, 0, 0)
|
|
899
983
|
: withLightness(bg0, scheme === "dark" ? bg0.l + 0.2 : bg0.l - 0.2);
|
|
900
|
-
|
|
984
|
+
const line2Color = borderForContrast(line2Seed, bg0, DIVIDER_SEPARATION);
|
|
985
|
+
lit("--line-2", formatCss(line2Color), refIfPinned("--bg-0"));
|
|
986
|
+
lit("--scrollbar-track", "transparent");
|
|
987
|
+
lit("--scrollbar-thumb", formatCss(line2Color), ["--line-2", ...refIfPinned("--bg-0")]);
|
|
988
|
+
lit("--scrollbar-thumb-hover", formatCss(withLightness(line2Color, line2Color.l + (scheme === "dark" ? 0.12 : -0.12))), ["--scrollbar-thumb"]);
|
|
901
989
|
lit("--ring", formatCss(withAlpha(accentFill, 0.7)), ["--accent"]);
|
|
902
990
|
lit("--ring-bg", formatCss(withAlpha(accentFill, 0.18)), ["--accent"]);
|
|
903
991
|
const fieldBg = withLightness(bg0, scheme === "dark" ? bg0.l - 0.03 : bg0.l + 0.02);
|
|
@@ -937,13 +1025,14 @@ export function buildGraph(preset, opts) {
|
|
|
937
1025
|
let a2;
|
|
938
1026
|
let a3;
|
|
939
1027
|
let a4;
|
|
940
|
-
// The lineage edges differ per
|
|
941
|
-
//
|
|
942
|
-
//
|
|
1028
|
+
// The lineage edges differ per strategy: a `fan`'s 2/3 flank the accent and 4 is its complement
|
|
1029
|
+
// (all off `--accent`, so a pinned flank pulls its mirror in), a `step` chains 3 off 2 and 4 off 3,
|
|
1030
|
+
// and a `duo` reads *both* anchors into each shade. Declared per-branch so `lineage()` names what
|
|
1031
|
+
// each token actually reads.
|
|
943
1032
|
let a2Refs;
|
|
944
1033
|
let a3Refs;
|
|
945
1034
|
let a4Refs;
|
|
946
|
-
if (
|
|
1035
|
+
if (strategy === "fan") {
|
|
947
1036
|
// The two flanks are symmetric either way: pin either wing and the other mirrors its hue
|
|
948
1037
|
// across the accent, so the fan stays balanced around the author's choice. With neither
|
|
949
1038
|
// pinned it's the default ∓split; with both pinned each holds its own value. Lightness and
|
|
@@ -964,10 +1053,56 @@ export function buildGraph(preset, opts) {
|
|
|
964
1053
|
a3Refs = a2Pin && !a3Pin ? ["--accent", "--accent-2"] : ["--accent"];
|
|
965
1054
|
a4Refs = ["--accent"];
|
|
966
1055
|
}
|
|
1056
|
+
else if (strategy === "shade") {
|
|
1057
|
+
// 2/3/4 hold the accent's hue and step its lightness: a tint one step up, two shades down, so
|
|
1058
|
+
// the fan reads as one brand color in four depths. The separation is on lightness, so a
|
|
1059
|
+
// near-gray accent still fans into four distinguishable rungs where a hue rotation is a no-op.
|
|
1060
|
+
// Each rung reads off `--accent` and is independently pinnable.
|
|
1061
|
+
a2 = fanned("2", applyAccentDelta(fanBase, { dL: SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1062
|
+
a3 = fanned("3", applyAccentDelta(fanBase, { dL: -SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1063
|
+
a4 = fanned("4", applyAccentDelta(fanBase, { dL: -2 * SHADE_LADDER_L_STEP, dC: 0, dH: 0 }));
|
|
1064
|
+
a2Refs = ["--accent"];
|
|
1065
|
+
a3Refs = ["--accent"];
|
|
1066
|
+
a4Refs = ["--accent"];
|
|
1067
|
+
}
|
|
1068
|
+
else if (strategy === "duo") {
|
|
1069
|
+
// Two brand colors, not one. `--accent` and `--accent-2` are both *inputs* — the only strategy
|
|
1070
|
+
// where a fan slot is an anchor rather than an output — and 3/4 are their shades. Unpinned,
|
|
1071
|
+
// `--accent-2` still has to come from somewhere, so it falls out of `--accent` by the same fan
|
|
1072
|
+
// distance the split uses; a duo theme that never sets a second color is just a fan that kept
|
|
1073
|
+
// two of its wings.
|
|
1074
|
+
//
|
|
1075
|
+
// The shades are placed against the *pair's* mean lightness rather than each anchor's own, which
|
|
1076
|
+
// is what makes this more than two ladders side by side: both land on one common lightness, so
|
|
1077
|
+
// they read as a matched secondary pair belonging to the same system. They step away from the
|
|
1078
|
+
// surface (up from a dark scheme, down from a light one) and flip if that pole has no headroom
|
|
1079
|
+
// left, so a pair of already-light brand colors on a light theme still yields separable rungs.
|
|
1080
|
+
a2 = fanned("2", applyAccentDelta(fanBase, rotate(accentSplit)));
|
|
1081
|
+
const midL = (a1.l + a2.l) / 2;
|
|
1082
|
+
const away = scheme === "dark" ? 1 : -1;
|
|
1083
|
+
const room = (dir) => {
|
|
1084
|
+
const target = midL + dir * DUO_L_STEP;
|
|
1085
|
+
return target <= ACCENT_RAMP_L_MAX && target >= ACCENT_RAMP_L_MIN;
|
|
1086
|
+
};
|
|
1087
|
+
const dir = room(away) ? away : -away;
|
|
1088
|
+
const shadeL = Math.min(ACCENT_RAMP_L_MAX, Math.max(ACCENT_RAMP_L_MIN, midL + dir * DUO_L_STEP));
|
|
1089
|
+
const shadeOf = (brand) => ({
|
|
1090
|
+
l: shadeL,
|
|
1091
|
+
c: Math.max(brand.c, FAN_MIN_CHROMA),
|
|
1092
|
+
h: brand.h,
|
|
1093
|
+
alpha: 1,
|
|
1094
|
+
});
|
|
1095
|
+
a3 = fanned("3", shadeOf(a1));
|
|
1096
|
+
a4 = fanned("4", shadeOf(a2));
|
|
1097
|
+
a2Refs = ["--accent"];
|
|
1098
|
+
// Both shades read both anchors: the hue is one brand's, the lightness is the pair's mean.
|
|
1099
|
+
a3Refs = ["--accent", "--accent-2"];
|
|
1100
|
+
a4Refs = ["--accent-2", "--accent"];
|
|
1101
|
+
}
|
|
967
1102
|
else {
|
|
968
|
-
//
|
|
969
|
-
//
|
|
970
|
-
// chromatic accent has `fanBase === a1`, so the step stays byte-identical.
|
|
1103
|
+
// `step`: each accent is one hue-step past the last. Chaining off `fanBase` (not `a1`) keeps the
|
|
1104
|
+
// whole walk at the floored chroma for a near-gray accent instead of escalating it down the
|
|
1105
|
+
// chain; a chromatic accent has `fanBase === a1`, so the step stays byte-identical.
|
|
971
1106
|
a2 = fanned("2", applyAccentDelta(fanBase, rotate(shiftStep)));
|
|
972
1107
|
a3 = fanned("3", applyAccentDelta(a2, accentDelta(fanBase, a2)));
|
|
973
1108
|
a4 = fanned("4", applyAccentDelta(a3, accentDelta(a2, a3)));
|
|
@@ -1098,15 +1233,15 @@ export function buildGraph(preset, opts) {
|
|
|
1098
1233
|
const codeTowardLight = contrast("#ffffff", codeBgCss) >= contrast("#000000", codeBgCss);
|
|
1099
1234
|
const codePole = codeTowardLight ? 1 : 0;
|
|
1100
1235
|
const codeFloor = AA;
|
|
1101
|
-
const
|
|
1236
|
+
const readableHuedOn = (bgCss, pole, l, c, h, fl) => {
|
|
1102
1237
|
const seed = oklch(l, c, h);
|
|
1103
1238
|
let best = seed;
|
|
1104
|
-
let bestContrast = emittedContrast(seed,
|
|
1239
|
+
let bestContrast = emittedContrast(seed, bgCss);
|
|
1105
1240
|
if (bestContrast >= fl)
|
|
1106
1241
|
return seed;
|
|
1107
1242
|
for (let i = 1; i <= 100; i++) {
|
|
1108
|
-
const cand = withLightness(seed, seed.l + (
|
|
1109
|
-
const ct = emittedContrast(cand,
|
|
1243
|
+
const cand = withLightness(seed, seed.l + (pole - seed.l) * (i / 100));
|
|
1244
|
+
const ct = emittedContrast(cand, bgCss);
|
|
1110
1245
|
if (ct >= fl)
|
|
1111
1246
|
return cand;
|
|
1112
1247
|
if (ct > bestContrast) {
|
|
@@ -1116,6 +1251,7 @@ export function buildGraph(preset, opts) {
|
|
|
1116
1251
|
}
|
|
1117
1252
|
return best;
|
|
1118
1253
|
};
|
|
1254
|
+
const readableHuedOnCode = (l, c, h, fl) => readableHuedOn(codeBgCss, codePole, l, c, h, fl);
|
|
1119
1255
|
const codeChroma = Math.max(0.08, Math.max(0.1, accent.c) * (0.7 + vibrancy * 0.7) * preset.paletteChromaMul);
|
|
1120
1256
|
// A near-gray accent has no hue to anchor the spread to, so seed the code wheel
|
|
1121
1257
|
// from the fallback hue rather than letting `NaN` collapse every scope to one ink.
|
|
@@ -1145,6 +1281,42 @@ export function buildGraph(preset, opts) {
|
|
|
1145
1281
|
lit("--code-operator", formatCss(readableHuedOnCode(codeBaseL, codeChroma * 0.5, codeBaseHue, codeFloor)), ["--accent", "--code-bg"]);
|
|
1146
1282
|
lit("--code-punctuation", formatCss(enforceContrastFloor(withLightness(codeFg, codeFg.l + (codePole - codeFg.l) * 0.18), codeBg, scheme, codeFloor)), ["--code-fg", "--code-bg"]);
|
|
1147
1283
|
lit("--code-variable", codeFgCss, ["--code-fg"]);
|
|
1284
|
+
const terminalBg = ensureTextHeadroom(withLightness(bg0, scheme === "dark" ? bg0.l - 0.035 : bg0.l + 0.02), scheme, floor);
|
|
1285
|
+
const terminalBgCss = formatCss(terminalBg);
|
|
1286
|
+
lit("--terminal-bg", terminalBgCss, refIfPinned("--bg-0"));
|
|
1287
|
+
const terminalFg = enforceContrastFloor(fg0, terminalBg, scheme, floor);
|
|
1288
|
+
lit("--terminal-fg", formatCss(terminalFg), ["--fg-0", ...refIfPinned("--bg-0")]);
|
|
1289
|
+
// A block cursor reads as the accent; the glyph under it flips to whichever pole
|
|
1290
|
+
// stays legible against that block.
|
|
1291
|
+
const terminalCursor = separateFillFromSurface(accentFill, terminalBg, SURFACE_SEPARATION, floor);
|
|
1292
|
+
lit("--terminal-cursor", formatCss(terminalCursor), ["--accent"]);
|
|
1293
|
+
lit("--terminal-cursor-accent", pickReadable(terminalCursor, TEXT_POLES, floor), ["--accent"]);
|
|
1294
|
+
// The six chromatic slots sit at a mid band that clears AA on the terminal bg; the
|
|
1295
|
+
// bright tier pushes each toward the readable pole (and up in chroma) so bright and
|
|
1296
|
+
// normal stay separable while both stay legible.
|
|
1297
|
+
const terminalTowardLight = contrast("#ffffff", terminalBgCss) >= contrast("#000000", terminalBgCss);
|
|
1298
|
+
const terminalPole = terminalTowardLight ? 1 : 0;
|
|
1299
|
+
const terminalFloor = AA;
|
|
1300
|
+
const terminalChroma = Math.max(0.07, Math.max(0.1, accent.c) * (0.55 + vibrancy * 0.7) * preset.paletteChromaMul);
|
|
1301
|
+
const terminalNormalL = terminalTowardLight ? 0.5 : 0.62;
|
|
1302
|
+
const terminalBrightL = terminalNormalL + (terminalPole - terminalNormalL) * 0.34;
|
|
1303
|
+
for (const name of ANSI_CHROMATIC) {
|
|
1304
|
+
const hue = ANSI_HUES[name];
|
|
1305
|
+
const normal = readableHuedOn(terminalBgCss, terminalPole, terminalNormalL, terminalChroma, hue, terminalFloor);
|
|
1306
|
+
const bright = readableHuedOn(terminalBgCss, terminalPole, terminalBrightL, terminalChroma * 1.08, hue, terminalFloor);
|
|
1307
|
+
lit(`--terminal-${name}`, formatCss(normal), ["--accent", "--terminal-bg"]);
|
|
1308
|
+
lit(`--terminal-bright-${name}`, formatCss(bright), ["--accent", "--terminal-bg"]);
|
|
1309
|
+
}
|
|
1310
|
+
// `black` and `white` are the achromatic endpoints — a terminal uses them as
|
|
1311
|
+
// fills / ink, not as legible-on-bg scopes, so they anchor to fixed dark / light
|
|
1312
|
+
// lightnesses (carrying a whisper of the bg hue for cohesion) rather than sweeping
|
|
1313
|
+
// for contrast like the chromatic slots.
|
|
1314
|
+
const terminalHue = Number.isFinite(bg0.h) ? bg0.h : 0;
|
|
1315
|
+
const terminalAchroma = (l) => oklch(l, 0.006, terminalHue);
|
|
1316
|
+
lit("--terminal-black", formatCss(terminalAchroma(0.2)), refIfPinned("--bg-0"));
|
|
1317
|
+
lit("--terminal-bright-black", formatCss(terminalAchroma(0.42)), refIfPinned("--bg-0"));
|
|
1318
|
+
lit("--terminal-white", formatCss(terminalAchroma(0.85)), ["--fg-0"]);
|
|
1319
|
+
lit("--terminal-bright-white", formatCss(terminalAchroma(0.97)), ["--fg-0"]);
|
|
1148
1320
|
lit("--font-sans", fonts.sans);
|
|
1149
1321
|
lit("--font-mono", fonts.mono);
|
|
1150
1322
|
lit("--font-display", fonts.display);
|
|
@@ -1778,27 +1950,32 @@ export function makeInvariants(preset) {
|
|
|
1778
1950
|
if (accent.c < HUE_STABLE_CHROMA) {
|
|
1779
1951
|
return { name, ok: true };
|
|
1780
1952
|
}
|
|
1781
|
-
const step =
|
|
1782
|
-
? ctx.knobs.accentShiftStep
|
|
1783
|
-
: DEFAULT_SHIFT_STEP;
|
|
1784
|
-
const split = typeof ctx.knobs.accentSplit === "number"
|
|
1785
|
-
? ctx.knobs.accentSplit
|
|
1786
|
-
: DEFAULT_ACCENT_SPLIT;
|
|
1953
|
+
const { strategy, split, shiftStep: step } = resolveAccentKnobs(preset, ctx.knobs);
|
|
1787
1954
|
const accent2Value = ctx.register["--accent-2"];
|
|
1788
1955
|
const accent3Value = ctx.register["--accent-3"];
|
|
1789
1956
|
const pinnedAccent2 = ctx.constraints["--accent-2"] && accent2Value ? toOklchColor(accent2Value) : null;
|
|
1790
1957
|
const pinnedAccent3 = ctx.constraints["--accent-3"] && accent3Value ? toOklchColor(accent3Value) : null;
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1958
|
+
// The hue each slot owes the accent. A `shade` holds one hue and steps lightness, so every
|
|
1959
|
+
// rung wants the accent's own. A `duo` carries two hues: 3 is brand one's (the accent's), 4 is
|
|
1960
|
+
// brand two's — whatever `--accent-2` actually landed on, pinned or derived.
|
|
1961
|
+
const duoSecondHue = () => pinnedAccent2 ? hueDelta(accent.h, pinnedAccent2.h) : split;
|
|
1962
|
+
const fanOffset = (n) => {
|
|
1963
|
+
if (strategy === "shade")
|
|
1964
|
+
return 0;
|
|
1965
|
+
if (strategy === "step")
|
|
1966
|
+
return step * (n - 1);
|
|
1967
|
+
// 3 shades brand one (the accent's own hue); 2 and 4 are brand two's.
|
|
1968
|
+
if (strategy === "duo")
|
|
1969
|
+
return n === 3 ? 0 : duoSecondHue();
|
|
1970
|
+
if (n === 2)
|
|
1971
|
+
return pinnedAccent3 ? -hueDelta(accent.h, pinnedAccent3.h) : -split;
|
|
1972
|
+
if (n === 3)
|
|
1973
|
+
return pinnedAccent2 ? -hueDelta(accent.h, pinnedAccent2.h) : split;
|
|
1974
|
+
return 180;
|
|
1975
|
+
};
|
|
1976
|
+
// `shade` and `duo` both deliberately move lightness off the accent's, so the constant-L/C
|
|
1977
|
+
// checks below belong only to the hue-rotating postures.
|
|
1978
|
+
const stepsLightness = strategy === "shade" || strategy === "duo";
|
|
1802
1979
|
for (let n = 2; n <= 4; n++) {
|
|
1803
1980
|
if (ctx.constraints[`--accent-${n}`])
|
|
1804
1981
|
continue;
|
|
@@ -1819,21 +1996,25 @@ export function makeInvariants(preset) {
|
|
|
1819
1996
|
};
|
|
1820
1997
|
}
|
|
1821
1998
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1999
|
+
// A lightness-stepping strategy gamut-clamps chroma per rung, so only the shared-hue check
|
|
2000
|
+
// above is a promise it makes; the constant-L/C pair below is the hue-fan postures' promise.
|
|
2001
|
+
if (!stepsLightness) {
|
|
2002
|
+
if (Math.abs(rotated.l - accent.l) > LIGHTNESS_TOLERANCE) {
|
|
2003
|
+
return {
|
|
2004
|
+
name,
|
|
2005
|
+
ok: false,
|
|
2006
|
+
detail: `--accent-${n} l=${rotated.l.toFixed(3)} want ${accent.l.toFixed(3)}`,
|
|
2007
|
+
};
|
|
2008
|
+
}
|
|
2009
|
+
const maxChroma = clampToGamut({ l: accent.l, c: accent.c, h: wantH, alpha: 1 }).c;
|
|
2010
|
+
const expectedChroma = Math.min(accent.c, maxChroma);
|
|
2011
|
+
if (Math.abs(rotated.c - expectedChroma) > 0.02) {
|
|
2012
|
+
return {
|
|
2013
|
+
name,
|
|
2014
|
+
ok: false,
|
|
2015
|
+
detail: `--accent-${n} chroma ${rotated.c.toFixed(3)} want max-at-hue ${expectedChroma.toFixed(3)}`,
|
|
2016
|
+
};
|
|
2017
|
+
}
|
|
1837
2018
|
}
|
|
1838
2019
|
}
|
|
1839
2020
|
return { name, ok: true };
|
|
@@ -2109,6 +2290,51 @@ export function makeInvariants(preset) {
|
|
|
2109
2290
|
}
|
|
2110
2291
|
return { name, ok: true };
|
|
2111
2292
|
},
|
|
2293
|
+
(ctx) => {
|
|
2294
|
+
const name = "terminal palette readable on --terminal-bg";
|
|
2295
|
+
const bg = ctx.register["--terminal-bg"];
|
|
2296
|
+
if (!bg)
|
|
2297
|
+
return { name, ok: false, detail: "--terminal-bg missing" };
|
|
2298
|
+
const readFloor = achievableFloor(AA, bg);
|
|
2299
|
+
const inks = [
|
|
2300
|
+
"--terminal-fg",
|
|
2301
|
+
...ANSI_CHROMATIC.map((n) => `--terminal-${n}`),
|
|
2302
|
+
...ANSI_CHROMATIC.map((n) => `--terminal-bright-${n}`),
|
|
2303
|
+
];
|
|
2304
|
+
for (const token of inks) {
|
|
2305
|
+
const v = ctx.register[token];
|
|
2306
|
+
const ratio = v ? contrast(v, bg) : 0;
|
|
2307
|
+
if (ratio < readFloor - 0.05) {
|
|
2308
|
+
return { name, ok: false, detail: `${token} on --terminal-bg = ${ratio.toFixed(2)} (floor ${readFloor.toFixed(2)})` };
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
return { name, ok: true };
|
|
2312
|
+
},
|
|
2313
|
+
(ctx) => {
|
|
2314
|
+
// OKLab distance, not WCAG contrast — two equally-light hues (a red and a green
|
|
2315
|
+
// both readable on the bg) can still be one indistinguishable colour to a reader.
|
|
2316
|
+
// Floored under the muted reality (the warm red/magenta pair converges to ~0.020
|
|
2317
|
+
// once a low-chroma seed floors the palette), so it guards a real collapse, not the
|
|
2318
|
+
// legitimate warm-family closeness a muted terminal skin is allowed.
|
|
2319
|
+
const name = "terminal ANSI hues mutually distinguishable";
|
|
2320
|
+
const MIN_DE = 0.012;
|
|
2321
|
+
const slots = ANSI_CHROMATIC.map((n) => `--terminal-${n}`);
|
|
2322
|
+
for (let i = 0; i < slots.length; i++) {
|
|
2323
|
+
for (let j = i + 1; j < slots.length; j++) {
|
|
2324
|
+
const ni = slots[i];
|
|
2325
|
+
const nj = slots[j];
|
|
2326
|
+
const a = ctx.register[ni];
|
|
2327
|
+
const b = ctx.register[nj];
|
|
2328
|
+
if (!a || !b)
|
|
2329
|
+
continue;
|
|
2330
|
+
const d = oklabDist(a, b);
|
|
2331
|
+
if (d < MIN_DE) {
|
|
2332
|
+
return { name, ok: false, detail: `${ni} vs ${nj} ΔE=${d.toFixed(4)} (min ${MIN_DE})` };
|
|
2333
|
+
}
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
return { name, ok: true };
|
|
2337
|
+
},
|
|
2112
2338
|
(ctx) => {
|
|
2113
2339
|
// Mistaking success for danger is a usability failure WCAG contrast can't see — two
|
|
2114
2340
|
// equally-light status hues read as one. Floored well under the muted reality
|
|
@@ -2154,6 +2380,7 @@ export function makeXtylePipelineAlgorithm(preset, buildPasses) {
|
|
|
2154
2380
|
id: preset.id,
|
|
2155
2381
|
produces: PRODUCES,
|
|
2156
2382
|
knobs: preset.knobs,
|
|
2383
|
+
knobSpecs: resolveKnobSpecs(preset.knobs, preset.knobSpecs),
|
|
2157
2384
|
categories: CATEGORIES,
|
|
2158
2385
|
derive: (opts = {}) => run(opts).register,
|
|
2159
2386
|
lineage: (opts = {}) => singlePass
|
|
@@ -2169,6 +2396,8 @@ export function makeXtyleAlgorithm(preset) {
|
|
|
2169
2396
|
}
|
|
2170
2397
|
export const SHARED_KNOBS = [
|
|
2171
2398
|
"scheme",
|
|
2399
|
+
"surfaceRamp",
|
|
2400
|
+
"accentStrategy",
|
|
2172
2401
|
"accentShiftStep",
|
|
2173
2402
|
"accentSplit",
|
|
2174
2403
|
"contrastBand",
|
|
@@ -2180,6 +2409,124 @@ export const SHARED_KNOBS = [
|
|
|
2180
2409
|
"fonts",
|
|
2181
2410
|
"anchors",
|
|
2182
2411
|
];
|
|
2412
|
+
/**
|
|
2413
|
+
* The rendered *domain* of every knob the shared xtyle derivation reads — the kind, range, and
|
|
2414
|
+
* accepted values a consumer needs to build a control.
|
|
2415
|
+
*
|
|
2416
|
+
* Strictly the *shared* knobs: a knob only one algorithm reads belongs to that algorithm's own
|
|
2417
|
+
* `knobSpecs`, not here (`hour` is nxi-nite's, and lives there). A shared registry carrying a
|
|
2418
|
+
* single algorithm's domain would be the same hardcoded name-keyed table `knobSpecs` exists to
|
|
2419
|
+
* delete, moved one layer down.
|
|
2420
|
+
*
|
|
2421
|
+
* `fonts` and `anchors` carry `kind: "composite"` rather than a scalar domain: they are groups a
|
|
2422
|
+
* consumer expands into multiple controls (font stacks, anchor pickers), so their orchestration stays
|
|
2423
|
+
* with the consumer. They are declared here all the same, so that "this knob is a composite" is a fact
|
|
2424
|
+
* the algorithm states rather than a list of names the engine keeps. Cosmetic concerns (localized
|
|
2425
|
+
* labels, unit suffixes, digit precision) are deliberately not here — they belong to the consumer; the
|
|
2426
|
+
* `label` hints below are just defaults a consumer may override.
|
|
2427
|
+
*/
|
|
2428
|
+
export const SHARED_KNOB_SPECS = [
|
|
2429
|
+
{
|
|
2430
|
+
name: "scheme",
|
|
2431
|
+
kind: "select",
|
|
2432
|
+
label: "Scheme",
|
|
2433
|
+
options: [
|
|
2434
|
+
{ value: "dark", label: "dark" },
|
|
2435
|
+
{ value: "light", label: "light" },
|
|
2436
|
+
],
|
|
2437
|
+
},
|
|
2438
|
+
{
|
|
2439
|
+
name: "contrastBand",
|
|
2440
|
+
kind: "select",
|
|
2441
|
+
label: "Contrast band",
|
|
2442
|
+
default: "aa",
|
|
2443
|
+
options: [
|
|
2444
|
+
{ value: "aa", label: "AA" },
|
|
2445
|
+
{ value: "aaa", label: "AAA" },
|
|
2446
|
+
],
|
|
2447
|
+
},
|
|
2448
|
+
{
|
|
2449
|
+
name: "density",
|
|
2450
|
+
kind: "select",
|
|
2451
|
+
label: "Density",
|
|
2452
|
+
default: "normal",
|
|
2453
|
+
options: [
|
|
2454
|
+
{ value: "compact", label: "compact" },
|
|
2455
|
+
{ value: "normal", label: "normal" },
|
|
2456
|
+
{ value: "comfortable", label: "comfortable" },
|
|
2457
|
+
],
|
|
2458
|
+
},
|
|
2459
|
+
{
|
|
2460
|
+
name: "cues",
|
|
2461
|
+
kind: "select",
|
|
2462
|
+
label: "Cues",
|
|
2463
|
+
default: "color",
|
|
2464
|
+
options: [
|
|
2465
|
+
{ value: "color", label: "color only" },
|
|
2466
|
+
{ value: "redundant", label: "redundant markers" },
|
|
2467
|
+
],
|
|
2468
|
+
},
|
|
2469
|
+
{
|
|
2470
|
+
name: "accentStrategy",
|
|
2471
|
+
kind: "select",
|
|
2472
|
+
label: "Accent strategy",
|
|
2473
|
+
options: [
|
|
2474
|
+
{ value: "fan", label: "fan (flanks + complement)" },
|
|
2475
|
+
{ value: "step", label: "step (even hue wheel)" },
|
|
2476
|
+
{ value: "shade", label: "shade (one hue, four depths)" },
|
|
2477
|
+
{ value: "duo", label: "duo (two brands + their shades)" },
|
|
2478
|
+
],
|
|
2479
|
+
},
|
|
2480
|
+
{ name: "vibrancy", kind: "range", label: "Vibrancy", min: 0, max: 1, step: 0.05, default: 0.5 },
|
|
2481
|
+
{ name: "typeScale", kind: "range", label: "Type scale", min: 1.05, max: 1.6, step: 0.01, default: 1.2 },
|
|
2482
|
+
{ name: "radiusScale", kind: "range", label: "Radius scale", min: 0, max: 3, step: 0.1, default: 1 },
|
|
2483
|
+
// The defaults are the engine's own constants, not a second copy of them: a slider that opens on a
|
|
2484
|
+
// value the derivation does not actually use is a lie the control surface tells about the engine.
|
|
2485
|
+
// `surfaceRamp` is signed and its sign is scheme-derived, so it declares a default per scheme; a
|
|
2486
|
+
// lone `+0.045` would open the control on an *ascending* stack under a light theme, which is the
|
|
2487
|
+
// exact inversion of what that theme derives.
|
|
2488
|
+
{
|
|
2489
|
+
name: "surfaceRamp",
|
|
2490
|
+
kind: "range",
|
|
2491
|
+
label: "Surface ramp",
|
|
2492
|
+
min: -0.06,
|
|
2493
|
+
max: 0.06,
|
|
2494
|
+
step: 0.005,
|
|
2495
|
+
default: DEFAULT_SURFACE_STEP,
|
|
2496
|
+
defaultByScheme: { dark: defaultSurfaceRamp("dark"), light: defaultSurfaceRamp("light") },
|
|
2497
|
+
},
|
|
2498
|
+
{ name: "accentSplit", kind: "range", label: "Accent split", min: 0, max: 90, step: 1, default: DEFAULT_ACCENT_SPLIT, unit: "°" },
|
|
2499
|
+
{ name: "accentShiftStep", kind: "range", label: "Accent shift step", min: 0, max: 180, step: 5, default: DEFAULT_SHIFT_STEP, unit: "°" },
|
|
2500
|
+
// Groups a consumer expands into a cluster of its own, not single scalar controls. They *declare*
|
|
2501
|
+
// that rather than being named in a list the engine keeps: an algorithm with its own composite knob
|
|
2502
|
+
// (a palette array, a per-role font map) has to be able to say so, and a name-keyed table of knob
|
|
2503
|
+
// identities held by the engine is exactly what `knobSpecs` exists to delete.
|
|
2504
|
+
{ name: "anchors", kind: "composite", label: "Anchors" },
|
|
2505
|
+
{ name: "fonts", kind: "composite", label: "Fonts" },
|
|
2506
|
+
];
|
|
2507
|
+
const SHARED_KNOB_SPEC_BY_NAME = new Map(SHARED_KNOB_SPECS.map((spec) => [spec.name, spec]));
|
|
2508
|
+
/**
|
|
2509
|
+
* Resolve a declared knob-name list to the render specs a consumer needs. A name matching the shared
|
|
2510
|
+
* registry gets its domain; a novel knob resolves from `extra` when the algorithm supplies its own
|
|
2511
|
+
* spec. This is the one place a knob name becomes a renderable domain, so both baked and hosted
|
|
2512
|
+
* facades — and a host facade rebuilding from a name list — agree.
|
|
2513
|
+
*
|
|
2514
|
+
* A name that resolves to nothing degrades to a `text` control rather than vanishing. An algorithm
|
|
2515
|
+
* that declares a knob it never described still *reads* that knob, so dropping it silently would
|
|
2516
|
+
* leave the one thing the author asked for unreachable, with nothing on screen to say why. A
|
|
2517
|
+
* permissive text field is the honest floor: the knob stays editable, and the missing domain shows up
|
|
2518
|
+
* as a crude control instead of an absent one. `undeclared` marks it, so a discovery surface can say
|
|
2519
|
+
* *why* it looks crude — a typo'd knob name surfaces as a named gap rather than a mystery text box.
|
|
2520
|
+
*/
|
|
2521
|
+
export function resolveKnobSpecs(names, extra = []) {
|
|
2522
|
+
const byName = new Map(extra.map((spec) => [spec.name, spec]));
|
|
2523
|
+
const out = [];
|
|
2524
|
+
for (const name of names) {
|
|
2525
|
+
const spec = byName.get(name) ?? SHARED_KNOB_SPEC_BY_NAME.get(name) ?? { name, kind: "text", undeclared: true };
|
|
2526
|
+
out.push(spec);
|
|
2527
|
+
}
|
|
2528
|
+
return out;
|
|
2529
|
+
}
|
|
2183
2530
|
export const DEFAULT_ANCHORS = {
|
|
2184
2531
|
bg: "#0f1115",
|
|
2185
2532
|
fg: "#e8eaed",
|