@sltsh/aion-tokens 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +48 -0
- package/dist/flatten.d.ts +2 -0
- package/dist/flatten.d.ts.map +1 -0
- package/dist/flatten.js +18 -0
- package/dist/flatten.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/light.d.ts +21 -0
- package/dist/light.d.ts.map +1 -0
- package/dist/light.js +72 -0
- package/dist/light.js.map +1 -0
- package/dist/oklch.d.ts +14 -0
- package/dist/oklch.d.ts.map +1 -0
- package/dist/oklch.js +86 -0
- package/dist/oklch.js.map +1 -0
- package/dist/palette.d.ts +155 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +179 -0
- package/dist/palette.js.map +1 -0
- package/dist/preview.d.ts +29 -0
- package/dist/preview.d.ts.map +1 -0
- package/dist/preview.js +72 -0
- package/dist/preview.js.map +1 -0
- package/dist/report.d.ts +17 -0
- package/dist/report.d.ts.map +1 -0
- package/dist/report.js +279 -0
- package/dist/report.js.map +1 -0
- package/dist/rivals.d.ts +22 -0
- package/dist/rivals.d.ts.map +1 -0
- package/dist/rivals.js +83 -0
- package/dist/rivals.js.map +1 -0
- package/dist/semantic.d.ts +203 -0
- package/dist/semantic.d.ts.map +1 -0
- package/dist/semantic.js +99 -0
- package/dist/semantic.js.map +1 -0
- package/dist/solve.d.ts +44 -0
- package/dist/solve.d.ts.map +1 -0
- package/dist/solve.js +59 -0
- package/dist/solve.js.map +1 -0
- package/dist/states.d.ts +28 -0
- package/dist/states.d.ts.map +1 -0
- package/dist/states.js +89 -0
- package/dist/states.js.map +1 -0
- package/dist/status.d.ts +12 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +12 -0
- package/dist/status.js.map +1 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -0
- package/dist/util.js +2 -0
- package/dist/util.js.map +1 -0
- package/dist/verify.d.ts +2 -0
- package/dist/verify.d.ts.map +1 -0
- package/dist/verify.js +42 -0
- package/dist/verify.js.map +1 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sltsh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @sltsh/aion-tokens
|
|
2
|
+
|
|
3
|
+
The Aion colour system. OKLCH definitions, contrast invariants and sRGB emitters.
|
|
4
|
+
|
|
5
|
+
Every other Aion package reads this one. Nothing downstream defines a colour.
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { hex, bg, fg, accent, contrastEmitted, flatten, semantic } from '@sltsh/aion-tokens';
|
|
9
|
+
|
|
10
|
+
hex(bg.editor); // '#11151c'
|
|
11
|
+
hex(accent.gold.solid); // '#e4c058'
|
|
12
|
+
contrastEmitted(fg.primary, bg.editor); // 14.87
|
|
13
|
+
flatten(semantic); // { 'bg.editor': '#11151c', ... }
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Two contrast functions, on purpose
|
|
17
|
+
|
|
18
|
+
`contrast` reads the ideal OKLCH. `contrastEmitted` reads the rounded 8-bit hex that
|
|
19
|
+
actually ships. They differ by up to 0.06, which matters at a 4.5:1 floor.
|
|
20
|
+
|
|
21
|
+
Use `contrastEmitted` for any gate or report; a user measures the hex. `solveLightness`
|
|
22
|
+
uses the continuous form, because bisection needs one.
|
|
23
|
+
|
|
24
|
+
## Layers
|
|
25
|
+
|
|
26
|
+
- **Literal** — `neutral`, `ACCENTS`, `accentScale`, `ansi`, `lightNeutral`. What the
|
|
27
|
+
colour is.
|
|
28
|
+
- **Semantic** — `bg`, `fg`, `border`, `syntax`, `accent`, `status`, and the `*Light`
|
|
29
|
+
counterparts. What the colour is for. Consumers use this layer.
|
|
30
|
+
- **Preview** — `buildPalette(overrides)` recomputes the whole palette from six
|
|
31
|
+
parameters. With no overrides it equals the shipped palette exactly, and a test asserts
|
|
32
|
+
that.
|
|
33
|
+
|
|
34
|
+
## The gate
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npm run verify # every token, its surface and its ratio; non-zero on any failure
|
|
38
|
+
npm run tables # the same data as the markdown tables in DESIGN.md
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Rules it enforces
|
|
42
|
+
|
|
43
|
+
Text 4.5:1, non-text 3:1, chroma inside its per-hue band, hue within ±15° of the One Dark
|
|
44
|
+
Pro role map, a 0.06 lightness gap on meaning pairs, and every colour inside sRGB.
|
|
45
|
+
|
|
46
|
+
## Licence
|
|
47
|
+
|
|
48
|
+
MIT.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../src/flatten.ts"],"names":[],"mappings":"AAUA,wBAAgB,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,SAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAS1E"}
|
package/dist/flatten.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { hex, hexAlpha } from './oklch.js';
|
|
2
|
+
const isOklch = (value) => Array.isArray(value) && value.length === 3 && value.every((v) => typeof v === 'number');
|
|
3
|
+
const isOverlay = (value) => typeof value === 'object' && value !== null && 'color' in value && 'alpha' in value &&
|
|
4
|
+
isOklch(value.color);
|
|
5
|
+
export function flatten(tree, prefix = '') {
|
|
6
|
+
if (isOklch(tree))
|
|
7
|
+
return { [prefix]: hex(tree) };
|
|
8
|
+
if (isOverlay(tree))
|
|
9
|
+
return { [prefix]: hexAlpha(tree.color, tree.alpha) };
|
|
10
|
+
if (typeof tree !== 'object' || tree === null)
|
|
11
|
+
return {};
|
|
12
|
+
const out = {};
|
|
13
|
+
for (const [key, value] of Object.entries(tree)) {
|
|
14
|
+
Object.assign(out, flatten(value, prefix ? `${prefix}.${key}` : key));
|
|
15
|
+
}
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.js","sourceRoot":"","sources":["../src/flatten.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,MAAM,OAAO,GAAG,CAAC,KAAc,EAAkB,EAAE,CACjD,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC;AAE1F,MAAM,SAAS,GAAG,CAAC,KAAc,EAA4C,EAAE,CAC7E,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,KAAK,IAAI,OAAO,IAAI,KAAK;IACnF,OAAO,CAAE,KAA4B,CAAC,KAAK,CAAC,CAAC;AAE/C,MAAM,UAAU,OAAO,CAAC,IAAa,EAAE,MAAM,GAAG,EAAE;IAChD,IAAI,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;IAClD,IAAI,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,EAAE,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;IAC3E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IACzD,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChD,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type { Oklch, LinearSrgb, SolveDirection } from './oklch.js';
|
|
2
|
+
export { oklchToLinearSrgb, inGamut, hex, hexAlpha, luminance, contrast, contrastEmitted, compositeEmitted, hexToOklch, solveLightness, } from './oklch.js';
|
|
3
|
+
export type { NeutralName, AccentName, AccentScale, SyntaxRole, StatusName, DiffName, Overlay, OverlayName, AnsiSlot, TerminalBackgroundName, DiffWashName, } from './palette.js';
|
|
4
|
+
export { BASE_HUE, BASE_CHROMA, NEUTRAL_LIGHTNESS, neutral, ACCENTS, ACCENT_NAMES, accentScale, scaleOf, SYNTAX, ONE_DARK_PRO_HUE, comment, dimText, STATUS, diff, diffWash, overlay, findMatch, bracketPairs, cursor, ansi, ANSI_ORDER, ANSI_BLACK_TEXT, terminalBackground, terminalSelection, TERMINAL_BACKGROUNDS, CHROMA_CEILING, CHROMA_DEFAULT, HUE_DRIFT_LIMIT, CONTRAST_FLOOR, NON_TEXT_FLOOR, MEANING_PAIR_GAP, CONTRAST_EXEMPT, } from './palette.js';
|
|
5
|
+
export type { LightNeutralName } from './light.js';
|
|
6
|
+
export { LIGHT_LIGHTNESS, lightNeutral, lightAccent, lightAccents, lightAccentScale, } from './light.js';
|
|
7
|
+
export type { StatusScale } from './status.js';
|
|
8
|
+
export { status, statusLight } from './status.js';
|
|
9
|
+
export { bg, fg, border, syntax, accent, brackets, semantic, BOUNDARY_PAIRS, bgLight, fgLight, borderLight, accentLight, semanticLight, BOUNDARY_PAIRS_LIGHT, } from './semantic.js';
|
|
10
|
+
export type { Marker, Solution } from './solve.js';
|
|
11
|
+
export { solveMarker, binding, distanceEmitted } from './solve.js';
|
|
12
|
+
export type { ReadingState, StateSource, SurfaceName } from './states.js';
|
|
13
|
+
export { readingStates, readingForegrounds, SHIPPED } from './states.js';
|
|
14
|
+
export { flatten } from './flatten.js';
|
|
15
|
+
export type { Check, CheckState } from './report.js';
|
|
16
|
+
export { checks, failures, designTables, NEUTRAL_ROLE } from './report.js';
|
|
17
|
+
export type { Palette, PreviewOptions } from './preview.js';
|
|
18
|
+
export { buildPalette, PREVIEW_DEFAULTS } from './preview.js';
|
|
19
|
+
export type { Rival, RivalResult, SurfaceOrder } from './rivals.js';
|
|
20
|
+
export { RIVALS, SYNTAX_ROLES_COMPARED, contrastHex, measure, surfaceOrder } from './rivals.js';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACpE,OAAO,EACL,iBAAiB,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAC/E,gBAAgB,EAAE,UAAU,EAAE,cAAc,GAC7C,MAAM,YAAY,CAAC;AAEpB,YAAY,EACV,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAC5F,QAAQ,EAAE,sBAAsB,EAAE,YAAY,GAC/C,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,OAAO,EAC9F,MAAM,EAAE,gBAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EACtF,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,eAAe,EAAE,kBAAkB,EAC3E,iBAAiB,EAAE,oBAAoB,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EACxF,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,GAClE,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EACL,eAAe,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,gBAAgB,GAC3E,MAAM,YAAY,CAAC;AAEpB,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,EACL,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAClE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,oBAAoB,GAChF,MAAM,eAAe,CAAC;AAEvB,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnE,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,YAAY,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3E,YAAY,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAE9D,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,qBAAqB,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { oklchToLinearSrgb, inGamut, hex, hexAlpha, luminance, contrast, contrastEmitted, compositeEmitted, hexToOklch, solveLightness, } from './oklch.js';
|
|
2
|
+
export { BASE_HUE, BASE_CHROMA, NEUTRAL_LIGHTNESS, neutral, ACCENTS, ACCENT_NAMES, accentScale, scaleOf, SYNTAX, ONE_DARK_PRO_HUE, comment, dimText, STATUS, diff, diffWash, overlay, findMatch, bracketPairs, cursor, ansi, ANSI_ORDER, ANSI_BLACK_TEXT, terminalBackground, terminalSelection, TERMINAL_BACKGROUNDS, CHROMA_CEILING, CHROMA_DEFAULT, HUE_DRIFT_LIMIT, CONTRAST_FLOOR, NON_TEXT_FLOOR, MEANING_PAIR_GAP, CONTRAST_EXEMPT, } from './palette.js';
|
|
3
|
+
export { LIGHT_LIGHTNESS, lightNeutral, lightAccent, lightAccents, lightAccentScale, } from './light.js';
|
|
4
|
+
export { status, statusLight } from './status.js';
|
|
5
|
+
export { bg, fg, border, syntax, accent, brackets, semantic, BOUNDARY_PAIRS, bgLight, fgLight, borderLight, accentLight, semanticLight, BOUNDARY_PAIRS_LIGHT, } from './semantic.js';
|
|
6
|
+
export { solveMarker, binding, distanceEmitted } from './solve.js';
|
|
7
|
+
export { readingStates, readingForegrounds, SHIPPED } from './states.js';
|
|
8
|
+
export { flatten } from './flatten.js';
|
|
9
|
+
export { checks, failures, designTables, NEUTRAL_ROLE } from './report.js';
|
|
10
|
+
export { buildPalette, PREVIEW_DEFAULTS } from './preview.js';
|
|
11
|
+
export { RIVALS, SYNTAX_ROLES_COMPARED, contrastHex, measure, surfaceOrder } from './rivals.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAAE,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,eAAe,EAC/E,gBAAgB,EAAE,UAAU,EAAE,cAAc,GAC7C,MAAM,YAAY,CAAC;AAMpB,OAAO,EACL,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE,OAAO,EAAE,OAAO,EA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|
1
|
+
import type { Oklch } from './oklch.js';
|
|
2
|
+
import type { AccentName, AccentScale } from './palette.js';
|
|
3
|
+
export declare const LIGHT_LIGHTNESS: {
|
|
4
|
+
readonly page: 0.99;
|
|
5
|
+
readonly surface: 0.97;
|
|
6
|
+
readonly raised: 0.945;
|
|
7
|
+
readonly input: 0.92;
|
|
8
|
+
readonly hover: 0.89;
|
|
9
|
+
readonly hairline: 0.86;
|
|
10
|
+
readonly divider: 0.81;
|
|
11
|
+
readonly border: 0.605;
|
|
12
|
+
readonly muted: 0.56;
|
|
13
|
+
readonly textSecondary: 0.45;
|
|
14
|
+
readonly textPrimary: 0.22;
|
|
15
|
+
};
|
|
16
|
+
export type LightNeutralName = keyof typeof LIGHT_LIGHTNESS;
|
|
17
|
+
export declare const lightNeutral: Record<LightNeutralName, Oklch>;
|
|
18
|
+
export declare const lightAccent: (name: AccentName) => Oklch;
|
|
19
|
+
export declare const lightAccents: Record<AccentName, Oklch>;
|
|
20
|
+
export declare const lightAccentScale: (name: AccentName) => AccentScale;
|
|
21
|
+
//# sourceMappingURL=light.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.d.ts","sourceRoot":"","sources":["../src/light.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAQ5D,eAAO,MAAM,eAAe;;;;;;;;;;;;CAIlB,CAAC;AAEX,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,eAAe,CAAC;AAK5D,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,gBAAgB,EAAE,KAAK,CAGxD,CAAC;AAiCF,eAAO,MAAM,WAAW,GAAI,MAAM,UAAU,KAAG,KAG9C,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,CAElD,CAAC;AAgBF,eAAO,MAAM,gBAAgB,GAAI,MAAM,UAAU,KAAG,WAOnD,CAAC"}
|
package/dist/light.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { solveLightness, inGamut, contrastEmitted } from './oklch.js';
|
|
2
|
+
import { ACCENTS, BASE_CHROMA, BASE_HUE, CONTRAST_FLOOR, NON_TEXT_FLOOR } from './palette.js';
|
|
3
|
+
import { mapValues } from './util.js';
|
|
4
|
+
// `border` is solved against `input`, the darkest surface a control edge encloses, not
|
|
5
|
+
// against `page`. A light border is darker than every surface it touches, so the darkest
|
|
6
|
+
// surface is the one that binds: at 0.650 it read 3.15:1 on the page and 2.56:1 on the
|
|
7
|
+
// field it was supposed to delimit.
|
|
8
|
+
export const LIGHT_LIGHTNESS = {
|
|
9
|
+
page: 0.990, surface: 0.970, raised: 0.945, input: 0.920, hover: 0.890,
|
|
10
|
+
hairline: 0.860, divider: 0.810, border: 0.605, muted: 0.560,
|
|
11
|
+
textSecondary: 0.450, textPrimary: 0.220,
|
|
12
|
+
};
|
|
13
|
+
// sRGB cannot hold chroma next to white, so the tint tapers as lightness approaches 1.
|
|
14
|
+
const tint = (L) => Math.min(BASE_CHROMA * 0.5, (1 - L) * 0.35);
|
|
15
|
+
export const lightNeutral = mapValues(LIGHT_LIGHTNESS, (L) => [L, tint(L), BASE_HUE]);
|
|
16
|
+
const CHROMA_BOOST = 1.35;
|
|
17
|
+
const CHROMA_STEP = 0.98;
|
|
18
|
+
const LIGHTNESS_STEP = 0.001;
|
|
19
|
+
const floorTo = (value, places) => Math.floor(value * 10 ** places) / 10 ** places;
|
|
20
|
+
// Dark accents lose contrast on a light page, so lightness drops and chroma rises.
|
|
21
|
+
// The two constraints fight: more chroma leaves the sRGB gamut at the lightness the
|
|
22
|
+
// floor demands. Walk chroma down until a colour satisfies both, then verify against
|
|
23
|
+
// the emitted hex, because rounding to 8 bits can cost up to 0.06 of the ratio.
|
|
24
|
+
//
|
|
25
|
+
// The reference surface is `raised`, not `page`: an accent that only clears the floor on
|
|
26
|
+
// the lightest surface fails the moment it lands on a card or a subtle fill. Accent text
|
|
27
|
+
// on the `hover` surface is outside this guarantee; hover rows use neutral text.
|
|
28
|
+
const solveOnLightSurface = (name, hue, startChroma, floor) => {
|
|
29
|
+
let chroma = startChroma;
|
|
30
|
+
for (let i = 0; i < 60; i += 1) {
|
|
31
|
+
const rounded = Math.round(chroma * 10000) / 10000;
|
|
32
|
+
// Lower lightness means more contrast here, so rounding down never breaks the floor.
|
|
33
|
+
let L = floorTo(solveLightness(rounded, hue, lightNeutral.raised, floor, 'down'), 3);
|
|
34
|
+
for (let step = 0; step < 10; step += 1) {
|
|
35
|
+
const colour = [L, rounded, hue];
|
|
36
|
+
if (!inGamut(colour))
|
|
37
|
+
break;
|
|
38
|
+
if (contrastEmitted(colour, lightNeutral.raised) >= floor)
|
|
39
|
+
return colour;
|
|
40
|
+
L -= LIGHTNESS_STEP;
|
|
41
|
+
}
|
|
42
|
+
chroma *= CHROMA_STEP;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`no in-gamut light colour for ${name} at ${floor}:1`);
|
|
45
|
+
};
|
|
46
|
+
export const lightAccent = (name) => {
|
|
47
|
+
const [, chroma, hue] = ACCENTS[name];
|
|
48
|
+
return solveOnLightSurface(name, hue, Math.min(chroma * CHROMA_BOOST, 0.19), CONTRAST_FLOOR);
|
|
49
|
+
};
|
|
50
|
+
export const lightAccents = mapValues(ACCENTS, (_value, name) => lightAccent(name));
|
|
51
|
+
const LIGHT_SUBTLE_LIGHTNESS = 0.955;
|
|
52
|
+
// A subtle fill carries no text of its own, so only the gamut constrains it.
|
|
53
|
+
const lightSubtle = (name) => {
|
|
54
|
+
const [, chroma, hue] = ACCENTS[name];
|
|
55
|
+
let candidate = Math.min(chroma * 0.35, (1 - LIGHT_SUBTLE_LIGHTNESS) * 0.6);
|
|
56
|
+
for (let i = 0; i < 60; i += 1) {
|
|
57
|
+
const colour = [LIGHT_SUBTLE_LIGHTNESS, Math.round(candidate * 10000) / 10000, hue];
|
|
58
|
+
if (inGamut(colour))
|
|
59
|
+
return colour;
|
|
60
|
+
candidate *= CHROMA_STEP;
|
|
61
|
+
}
|
|
62
|
+
throw new Error(`no in-gamut light subtle fill for ${name}`);
|
|
63
|
+
};
|
|
64
|
+
export const lightAccentScale = (name) => {
|
|
65
|
+
const [, chroma, hue] = ACCENTS[name];
|
|
66
|
+
return {
|
|
67
|
+
subtle: lightSubtle(name),
|
|
68
|
+
border: solveOnLightSurface(name, hue, Math.min(chroma * 0.5, 0.09), NON_TEXT_FLOOR),
|
|
69
|
+
solid: lightAccent(name),
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=light.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"light.js","sourceRoot":"","sources":["../src/light.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9F,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,uFAAuF;AACvF,yFAAyF;AACzF,uFAAuF;AACvF,oCAAoC;AACpC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IACtE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK;IAC5D,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK;CAChC,CAAC;AAIX,uFAAuF;AACvF,MAAM,IAAI,GAAG,CAAC,CAAS,EAAU,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,GAA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AsB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,EAAE,GAAG,CAAC,CAAC;QAC3F,IAAI,OAAO,CAAC,MAAM,CAAC;YAAE,OAAO,MAAM,CAAC;QACnC,SAAS,IAAI,WAAW,CAAC;IAC3B,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,qCAAqC,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAgB,EAAe,EAAE;IAChE,MAAM,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,OAAO;QACL,MAAM,EAAE,WAAW,CAAC,IAAI,CAAC;QACzB,MAAM,EAAE,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,EAAE,cAAc,CAAC;QACpF,KAAK,EAAE,WAAW,CAAC,IAAI,CAAC;KACzB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/oklch.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type Oklch = readonly [lightness: number, chroma: number, hue: number];
|
|
2
|
+
export type LinearSrgb = readonly [red: number, green: number, blue: number];
|
|
3
|
+
export type SolveDirection = 'up' | 'down';
|
|
4
|
+
export declare function oklchToLinearSrgb(L: number, C: number, H: number): LinearSrgb;
|
|
5
|
+
export declare const inGamut: (c: Oklch) => boolean;
|
|
6
|
+
export declare function hex(c: Oklch): string;
|
|
7
|
+
export declare function hexAlpha(c: Oklch, alpha: number): string;
|
|
8
|
+
export declare const luminance: (c: Oklch) => number;
|
|
9
|
+
export declare function contrast(a: Oklch, b: Oklch): number;
|
|
10
|
+
export declare function contrastEmitted(a: Oklch, b: Oklch): number;
|
|
11
|
+
export declare function compositeEmitted(over: Oklch, alpha: number, under: Oklch): Oklch;
|
|
12
|
+
export declare function hexToOklch(value: string): Oklch;
|
|
13
|
+
export declare function solveLightness(chroma: number, hue: number, background: Oklch, target: number, direction: SolveDirection): number;
|
|
14
|
+
//# sourceMappingURL=oklch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oklch.d.ts","sourceRoot":"","sources":["../src/oklch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAC9E,MAAM,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC7E,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,MAAM,CAAC;AAE3C,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU,CAa7E;AAGD,eAAO,MAAM,OAAO,GAAI,GAAG,KAAK,KAAG,OACkD,CAAC;AAMtF,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,CAGpC;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED,eAAO,MAAM,SAAS,GAAI,GAAG,KAAK,KAAG,MAGpC,CAAC;AAEF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAGnD;AASD,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,MAAM,CAK1D;AAUD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,KAAK,CAMhF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAa/C;AAED,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,UAAU,EAAE,KAAK,EACjB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,cAAc,GACxB,MAAM,CASR"}
|
package/dist/oklch.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
export function oklchToLinearSrgb(L, C, H) {
|
|
2
|
+
const h = (H * Math.PI) / 180;
|
|
3
|
+
const a = C * Math.cos(h);
|
|
4
|
+
const b = C * Math.sin(h);
|
|
5
|
+
const l_ = L + 0.3963377774 * a + 0.2158037573 * b;
|
|
6
|
+
const m_ = L - 0.1055613458 * a - 0.0638541728 * b;
|
|
7
|
+
const s_ = L - 0.0894841775 * a - 1.2914855480 * b;
|
|
8
|
+
const l = l_ ** 3, m = m_ ** 3, s = s_ ** 3;
|
|
9
|
+
return [
|
|
10
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
11
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
12
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s,
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
const GAMUT_EPSILON = 0.002;
|
|
16
|
+
export const inGamut = (c) => oklchToLinearSrgb(...c).every((v) => v >= -GAMUT_EPSILON && v <= 1 + GAMUT_EPSILON);
|
|
17
|
+
const clamp = (v) => Math.min(1, Math.max(0, v));
|
|
18
|
+
const encode = (u) => (u <= 0.0031308 ? 12.92 * u : 1.055 * u ** (1 / 2.4) - 0.055);
|
|
19
|
+
const byte = (v) => Math.round(clamp(v) * 255).toString(16).padStart(2, '0');
|
|
20
|
+
export function hex(c) {
|
|
21
|
+
const channels = oklchToLinearSrgb(...c).map(clamp).map(encode);
|
|
22
|
+
return '#' + channels.map(byte).join('');
|
|
23
|
+
}
|
|
24
|
+
export function hexAlpha(c, alpha) {
|
|
25
|
+
return hex(c) + byte(alpha);
|
|
26
|
+
}
|
|
27
|
+
export const luminance = (c) => {
|
|
28
|
+
const [r, g, b] = oklchToLinearSrgb(...c).map(clamp);
|
|
29
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
30
|
+
};
|
|
31
|
+
export function contrast(a, b) {
|
|
32
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
33
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
34
|
+
}
|
|
35
|
+
const srgbLuminance = (channels) => {
|
|
36
|
+
const [r, g, b] = channels.map((v) => (v <= 0.04045 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4));
|
|
37
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
38
|
+
};
|
|
39
|
+
// A user measures the 8-bit hex that ships, not the ideal OKLCH. Rounding moves the ratio
|
|
40
|
+
// by up to 0.06, so the build gate uses this and the solvers use the continuous form.
|
|
41
|
+
export function contrastEmitted(a, b) {
|
|
42
|
+
const quantise = (c) => oklchToLinearSrgb(...c).map(clamp).map(encode).map((v) => Math.round(clamp(v) * 255) / 255);
|
|
43
|
+
const [hi, lo] = [srgbLuminance(quantise(a)), srgbLuminance(quantise(b))].sort((x, y) => y - x);
|
|
44
|
+
return (hi + 0.05) / (lo + 0.05);
|
|
45
|
+
}
|
|
46
|
+
const emittedChannels = (c) => {
|
|
47
|
+
const [r, g, b] = oklchToLinearSrgb(...c).map(clamp).map(encode)
|
|
48
|
+
.map((v) => Math.round(clamp(v) * 255));
|
|
49
|
+
return [r, g, b];
|
|
50
|
+
};
|
|
51
|
+
// A decoration ships as an 8-bit colour and an 8-bit alpha byte, and the renderer blends
|
|
52
|
+
// those bytes. Compositing in OKLCH instead would miss the rounding on both operands.
|
|
53
|
+
export function compositeEmitted(over, alpha, under) {
|
|
54
|
+
const a = Math.round(clamp(alpha) * 255) / 255;
|
|
55
|
+
const front = emittedChannels(over);
|
|
56
|
+
const back = emittedChannels(under);
|
|
57
|
+
const blend = front.map((v, i) => Math.round(v * a + back[i] * (1 - a)));
|
|
58
|
+
return hexToOklch('#' + blend.map((v) => v.toString(16).padStart(2, '0')).join(''));
|
|
59
|
+
}
|
|
60
|
+
export function hexToOklch(value) {
|
|
61
|
+
const n = parseInt(value.slice(1), 16);
|
|
62
|
+
const [r, g, b] = [(n >> 16) & 255, (n >> 8) & 255, n & 255]
|
|
63
|
+
.map((v) => v / 255)
|
|
64
|
+
.map((u) => (u <= 0.04045 ? u / 12.92 : ((u + 0.055) / 1.055) ** 2.4));
|
|
65
|
+
const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
|
|
66
|
+
const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
|
|
67
|
+
const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
|
|
68
|
+
const L = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s;
|
|
69
|
+
const A = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s;
|
|
70
|
+
const B = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s;
|
|
71
|
+
const H = (Math.atan2(B, A) * 180) / Math.PI;
|
|
72
|
+
return [L, Math.hypot(A, B), H < 0 ? H + 360 : H];
|
|
73
|
+
}
|
|
74
|
+
export function solveLightness(chroma, hue, background, target, direction) {
|
|
75
|
+
let lo = 0, hi = 1;
|
|
76
|
+
for (let i = 0; i < 40; i += 1) {
|
|
77
|
+
const mid = (lo + hi) / 2;
|
|
78
|
+
const ok = contrast([mid, chroma, hue], background) >= target;
|
|
79
|
+
if (direction === 'up' ? ok : !ok)
|
|
80
|
+
hi = mid;
|
|
81
|
+
else
|
|
82
|
+
lo = mid;
|
|
83
|
+
}
|
|
84
|
+
return direction === 'up' ? hi : lo;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=oklch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import type { Oklch } from './oklch.js';
|
|
2
|
+
export declare const BASE_HUE = 264;
|
|
3
|
+
export declare const BASE_CHROMA = 0.016;
|
|
4
|
+
export declare const NEUTRAL_LIGHTNESS: {
|
|
5
|
+
readonly editor: 0.195;
|
|
6
|
+
readonly terminal: 0.207;
|
|
7
|
+
readonly sidebar: 0.22;
|
|
8
|
+
readonly widget: 0.25;
|
|
9
|
+
readonly input: 0.285;
|
|
10
|
+
readonly hover: 0.32;
|
|
11
|
+
readonly hairline: 0.375;
|
|
12
|
+
readonly divider: 0.44;
|
|
13
|
+
readonly border: 0.56;
|
|
14
|
+
readonly muted: 0.58;
|
|
15
|
+
readonly textSecondary: 0.745;
|
|
16
|
+
readonly textPrimary: 0.93;
|
|
17
|
+
};
|
|
18
|
+
export type NeutralName = keyof typeof NEUTRAL_LIGHTNESS;
|
|
19
|
+
export declare const neutral: Record<NeutralName, Oklch>;
|
|
20
|
+
export declare const ACCENTS: {
|
|
21
|
+
readonly coral: readonly [0.72, 0.1337, 22];
|
|
22
|
+
readonly copper: readonly [0.745, 0.1238, 52];
|
|
23
|
+
readonly gold: readonly [0.82, 0.1287, 90];
|
|
24
|
+
readonly green: readonly [0.78, 0.1287, 148];
|
|
25
|
+
readonly teal: readonly [0.78, 0.104, 192];
|
|
26
|
+
readonly blue: readonly [0.755, 0.1139, 255];
|
|
27
|
+
readonly violet: readonly [0.74, 0.1238, 305];
|
|
28
|
+
};
|
|
29
|
+
export type AccentName = keyof typeof ACCENTS;
|
|
30
|
+
export declare const ACCENT_NAMES: AccentName[];
|
|
31
|
+
export interface AccentScale {
|
|
32
|
+
readonly subtle: Oklch;
|
|
33
|
+
readonly border: Oklch;
|
|
34
|
+
readonly solid: Oklch;
|
|
35
|
+
}
|
|
36
|
+
export declare const ACCENT_SUBTLE_LIGHTNESS = 0.255;
|
|
37
|
+
export declare const ACCENT_BORDER_LIGHTNESS = 0.52;
|
|
38
|
+
export declare const scaleOf: ([L, C, H]: Oklch) => AccentScale;
|
|
39
|
+
export declare const accentScale: (name: AccentName) => AccentScale;
|
|
40
|
+
export declare const SYNTAX: {
|
|
41
|
+
readonly variable: "coral";
|
|
42
|
+
readonly number: "copper";
|
|
43
|
+
readonly constant: "copper";
|
|
44
|
+
readonly type: "gold";
|
|
45
|
+
readonly string: "green";
|
|
46
|
+
readonly operator: "teal";
|
|
47
|
+
readonly escape: "teal";
|
|
48
|
+
readonly function: "blue";
|
|
49
|
+
readonly keyword: "violet";
|
|
50
|
+
};
|
|
51
|
+
export type SyntaxRole = keyof typeof SYNTAX;
|
|
52
|
+
export declare const ONE_DARK_PRO_HUE: {
|
|
53
|
+
readonly variable: 17;
|
|
54
|
+
readonly number: 63.8;
|
|
55
|
+
readonly constant: 63.8;
|
|
56
|
+
readonly type: 82.3;
|
|
57
|
+
readonly string: 133;
|
|
58
|
+
readonly operator: 206.3;
|
|
59
|
+
readonly escape: 206.3;
|
|
60
|
+
readonly function: 245.3;
|
|
61
|
+
readonly keyword: 318.2;
|
|
62
|
+
};
|
|
63
|
+
export declare const comment: Oklch;
|
|
64
|
+
export declare const dimText: Oklch;
|
|
65
|
+
export declare const STATUS: {
|
|
66
|
+
readonly success: "green";
|
|
67
|
+
readonly warning: "copper";
|
|
68
|
+
readonly error: "coral";
|
|
69
|
+
readonly info: "blue";
|
|
70
|
+
};
|
|
71
|
+
export type StatusName = keyof typeof STATUS;
|
|
72
|
+
export declare const diffWash: {
|
|
73
|
+
readonly addedLine: {
|
|
74
|
+
readonly color: Oklch;
|
|
75
|
+
readonly alpha: 0.12;
|
|
76
|
+
};
|
|
77
|
+
readonly addedWord: {
|
|
78
|
+
readonly color: Oklch;
|
|
79
|
+
readonly alpha: 0.16;
|
|
80
|
+
};
|
|
81
|
+
readonly removedLine: {
|
|
82
|
+
readonly color: Oklch;
|
|
83
|
+
readonly alpha: 0.16;
|
|
84
|
+
};
|
|
85
|
+
readonly removedWord: {
|
|
86
|
+
readonly color: Oklch;
|
|
87
|
+
readonly alpha: 0.17;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
export type DiffWashName = keyof typeof diffWash;
|
|
91
|
+
export declare const diff: {
|
|
92
|
+
readonly addedStrip: readonly [0.308, 0.05, 148];
|
|
93
|
+
readonly removedStrip: readonly [0.248, 0.11, 22];
|
|
94
|
+
readonly addedGutter: readonly [0.78, 0.1287, 148];
|
|
95
|
+
readonly removedGutter: readonly [0.72, 0.1337, 22];
|
|
96
|
+
};
|
|
97
|
+
export type DiffName = keyof typeof diff;
|
|
98
|
+
export interface Overlay {
|
|
99
|
+
readonly color: Oklch;
|
|
100
|
+
readonly alpha: number;
|
|
101
|
+
}
|
|
102
|
+
export declare const overlay: {
|
|
103
|
+
readonly selection: {
|
|
104
|
+
readonly color: readonly [0.48, 0.195, 260];
|
|
105
|
+
readonly alpha: 0.39;
|
|
106
|
+
};
|
|
107
|
+
readonly findMatchOther: {
|
|
108
|
+
readonly color: readonly [0.4, 0.075, 90];
|
|
109
|
+
readonly alpha: 0.4;
|
|
110
|
+
};
|
|
111
|
+
readonly wordHighlight: {
|
|
112
|
+
readonly color: Oklch;
|
|
113
|
+
readonly alpha: 0.28;
|
|
114
|
+
};
|
|
115
|
+
readonly lineHighlight: {
|
|
116
|
+
readonly color: Oklch;
|
|
117
|
+
readonly alpha: 0.36;
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
export type OverlayName = keyof typeof overlay;
|
|
121
|
+
export declare const findMatch: {
|
|
122
|
+
readonly current: readonly [0.338, 0.072, 90];
|
|
123
|
+
};
|
|
124
|
+
export declare const bracketPairs: readonly ["gold", "teal", "violet"];
|
|
125
|
+
export declare const cursor: Oklch;
|
|
126
|
+
export declare const BRIGHT_TO_NORMAL = 0.06;
|
|
127
|
+
export declare const ANSI_HUE: {
|
|
128
|
+
readonly red: "coral";
|
|
129
|
+
readonly green: "green";
|
|
130
|
+
readonly yellow: "gold";
|
|
131
|
+
readonly blue: "blue";
|
|
132
|
+
readonly magenta: "violet";
|
|
133
|
+
readonly cyan: "teal";
|
|
134
|
+
};
|
|
135
|
+
export type AnsiChromaticSlot = keyof typeof ANSI_HUE;
|
|
136
|
+
export declare const capitalise: <S extends string>(value: S) => Capitalize<S>;
|
|
137
|
+
export type AnsiSlot = AnsiChromaticSlot | `bright${Capitalize<AnsiChromaticSlot>}` | 'black' | 'brightBlack' | 'white' | 'brightWhite';
|
|
138
|
+
export declare const ansi: Record<AnsiSlot, Oklch>;
|
|
139
|
+
export declare const ANSI_ORDER: readonly ["black", "red", "green", "yellow", "blue", "magenta", "cyan", "white", "brightBlack", "brightRed", "brightGreen", "brightYellow", "brightBlue", "brightMagenta", "brightCyan", "brightWhite"];
|
|
140
|
+
export declare const TERMINAL_BACKGROUNDS: {
|
|
141
|
+
readonly standalone: Oklch;
|
|
142
|
+
readonly vscodePanel: Oklch;
|
|
143
|
+
};
|
|
144
|
+
export type TerminalBackgroundName = keyof typeof TERMINAL_BACKGROUNDS;
|
|
145
|
+
export declare const terminalBackground: Oklch;
|
|
146
|
+
export declare const terminalSelection: Oklch;
|
|
147
|
+
export declare const ANSI_BLACK_TEXT: readonly ["white", "brightWhite"];
|
|
148
|
+
export declare const CHROMA_CEILING: Partial<Record<AccentName, number>>;
|
|
149
|
+
export declare const CHROMA_DEFAULT: readonly [number, number];
|
|
150
|
+
export declare const HUE_DRIFT_LIMIT = 15;
|
|
151
|
+
export declare const CONTRAST_FLOOR = 4.5;
|
|
152
|
+
export declare const NON_TEXT_FLOOR = 3;
|
|
153
|
+
export declare const MEANING_PAIR_GAP = 0.06;
|
|
154
|
+
export declare const CONTRAST_EXEMPT: Set<string>;
|
|
155
|
+
//# sourceMappingURL=palette.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../src/palette.ts"],"names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