@promptctl/rich-js 0.6.0 → 0.8.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/README.md +31 -30
- package/dist/core/box.d.ts +3 -3
- package/dist/core/box.d.ts.map +1 -1
- package/dist/core/box.js.map +1 -1
- package/dist/core/cells.d.ts +46 -1
- package/dist/core/cells.d.ts.map +1 -1
- package/dist/core/cells.js +55 -14
- package/dist/core/cells.js.map +1 -1
- package/dist/core/console.d.ts +28 -10
- package/dist/core/console.d.ts.map +1 -1
- package/dist/core/console.js +141 -80
- package/dist/core/console.js.map +1 -1
- package/dist/core/markup.d.ts +0 -2
- package/dist/core/markup.d.ts.map +1 -1
- package/dist/core/markup.js +31 -17
- package/dist/core/markup.js.map +1 -1
- package/dist/core/measure.d.ts +11 -0
- package/dist/core/measure.d.ts.map +1 -1
- package/dist/core/measure.js +15 -3
- package/dist/core/measure.js.map +1 -1
- package/dist/core/oklch.d.ts +22 -0
- package/dist/core/oklch.d.ts.map +1 -1
- package/dist/core/oklch.js +62 -18
- package/dist/core/oklch.js.map +1 -1
- package/dist/core/pretty.d.ts +87 -0
- package/dist/core/pretty.d.ts.map +1 -0
- package/dist/core/pretty.js +304 -0
- package/dist/core/pretty.js.map +1 -0
- package/dist/core/protocol.d.ts +64 -0
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/protocol.js +72 -0
- package/dist/core/protocol.js.map +1 -1
- package/dist/core/segment.d.ts +21 -0
- package/dist/core/segment.d.ts.map +1 -1
- package/dist/core/segment.js +40 -1
- package/dist/core/segment.js.map +1 -1
- package/dist/core/subscription.d.ts +13 -0
- package/dist/core/subscription.d.ts.map +1 -0
- package/dist/core/subscription.js +13 -0
- package/dist/core/subscription.js.map +1 -0
- package/dist/core/text.d.ts.map +1 -1
- package/dist/core/text.js +45 -13
- package/dist/core/text.js.map +1 -1
- package/dist/host/host-stream.d.ts +31 -0
- package/dist/host/host-stream.d.ts.map +1 -0
- package/dist/host/host-stream.js +36 -0
- package/dist/host/host-stream.js.map +1 -0
- package/dist/host/index.d.ts +4 -0
- package/dist/host/index.d.ts.map +1 -0
- package/dist/host/index.js +3 -0
- package/dist/host/index.js.map +1 -0
- package/dist/host/terminal-host.d.ts +144 -0
- package/dist/host/terminal-host.d.ts.map +1 -0
- package/dist/host/terminal-host.js +133 -0
- package/dist/host/terminal-host.js.map +1 -0
- package/dist/index.d.ts +11 -35
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +36 -22
- package/dist/index.js.map +1 -1
- package/dist/node/terminal-host.d.ts +85 -0
- package/dist/node/terminal-host.d.ts.map +1 -0
- package/dist/node/terminal-host.js +161 -0
- package/dist/node/terminal-host.js.map +1 -0
- package/dist/node/traceback.d.ts +28 -0
- package/dist/node/traceback.d.ts.map +1 -0
- package/dist/node/traceback.js +113 -0
- package/dist/node/traceback.js.map +1 -0
- package/dist/renderables/columns.d.ts +24 -2
- package/dist/renderables/columns.d.ts.map +1 -1
- package/dist/renderables/columns.js +91 -32
- package/dist/renderables/columns.js.map +1 -1
- package/dist/renderables/layout.d.ts +61 -5
- package/dist/renderables/layout.d.ts.map +1 -1
- package/dist/renderables/layout.js +191 -19
- package/dist/renderables/layout.js.map +1 -1
- package/dist/renderables/padding.d.ts +15 -2
- package/dist/renderables/padding.d.ts.map +1 -1
- package/dist/renderables/padding.js +92 -37
- package/dist/renderables/padding.js.map +1 -1
- package/dist/renderables/panel.d.ts +44 -3
- package/dist/renderables/panel.d.ts.map +1 -1
- package/dist/renderables/panel.js +149 -80
- package/dist/renderables/panel.js.map +1 -1
- package/dist/renderables/table.d.ts +40 -4
- package/dist/renderables/table.d.ts.map +1 -1
- package/dist/renderables/table.js +276 -158
- package/dist/renderables/table.js.map +1 -1
- package/dist/renderables/traceback.d.ts +6 -2
- package/dist/renderables/traceback.d.ts.map +1 -1
- package/dist/renderables/traceback.js +6 -10
- package/dist/renderables/traceback.js.map +1 -1
- package/dist/renderables/tree.d.ts +27 -2
- package/dist/renderables/tree.d.ts.map +1 -1
- package/dist/renderables/tree.js +82 -23
- package/dist/renderables/tree.js.map +1 -1
- package/dist/template-bindings/color-funcs.d.ts +78 -0
- package/dist/template-bindings/color-funcs.d.ts.map +1 -0
- package/dist/template-bindings/color-funcs.js +212 -0
- package/dist/template-bindings/color-funcs.js.map +1 -0
- package/dist/template-bindings/index.d.ts +24 -18
- package/dist/template-bindings/index.d.ts.map +1 -1
- package/dist/template-bindings/index.js +26 -19
- package/dist/template-bindings/index.js.map +1 -1
- package/dist/template-bindings/palette-funcs.d.ts +70 -51
- package/dist/template-bindings/palette-funcs.d.ts.map +1 -1
- package/dist/template-bindings/palette-funcs.js +120 -125
- package/dist/template-bindings/palette-funcs.js.map +1 -1
- package/dist/template-bindings/style-funcs.d.ts +11 -12
- package/dist/template-bindings/style-funcs.d.ts.map +1 -1
- package/dist/template-bindings/style-funcs.js +48 -74
- package/dist/template-bindings/style-funcs.js.map +1 -1
- package/dist/themes/buildPalette.d.ts +7 -1
- package/dist/themes/buildPalette.d.ts.map +1 -1
- package/dist/themes/buildPalette.js +15 -1
- package/dist/themes/buildPalette.js.map +1 -1
- package/dist/themes/colorRef.d.ts +52 -0
- package/dist/themes/colorRef.d.ts.map +1 -0
- package/dist/themes/colorRef.js +97 -0
- package/dist/themes/colorRef.js.map +1 -0
- package/dist/themes/palette.d.ts +4 -2
- package/dist/themes/palette.d.ts.map +1 -1
- package/dist/themes/palette.js +4 -2
- package/dist/themes/palette.js.map +1 -1
- package/dist/themes/ramp.d.ts +84 -0
- package/dist/themes/ramp.d.ts.map +1 -0
- package/dist/themes/ramp.js +123 -0
- package/dist/themes/ramp.js.map +1 -0
- package/dist/widgets/dropdown.d.ts +1 -1
- package/dist/widgets/dropdown.js +1 -1
- package/dist/widgets/event-router.d.ts +3 -2
- package/dist/widgets/event-router.d.ts.map +1 -1
- package/dist/widgets/focus-manager.d.ts +2 -1
- package/dist/widgets/focus-manager.d.ts.map +1 -1
- package/dist/widgets/index.d.ts +3 -6
- package/dist/widgets/index.d.ts.map +1 -1
- package/dist/widgets/index.js +4 -3
- package/dist/widgets/index.js.map +1 -1
- package/dist/widgets/screen.d.ts +1 -1
- package/dist/widgets/screen.d.ts.map +1 -1
- package/dist/widgets/terminal-host.d.ts +13 -63
- package/dist/widgets/terminal-host.d.ts.map +1 -1
- package/dist/widgets/terminal-host.js +11 -142
- package/dist/widgets/terminal-host.js.map +1 -1
- package/dist/widgets/text-input.d.ts +2 -3
- package/dist/widgets/text-input.d.ts.map +1 -1
- package/dist/widgets/text-input.js +4 -12
- package/dist/widgets/text-input.js.map +1 -1
- package/dist/widgets/types.d.ts +1 -1
- package/dist/widgets/types.d.ts.map +1 -1
- package/dist/widgets/types.js.map +1 -1
- package/dist/widgets/widget-base.d.ts +2 -1
- package/dist/widgets/widget-base.d.ts.map +1 -1
- package/package.json +20 -4
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ColorRgba } from "../core/color.js";
|
|
2
|
+
import type { Palette } from "./palette.js";
|
|
3
|
+
/**
|
|
4
|
+
* A **color reference** is the one string form an author uses to name a
|
|
5
|
+
* concrete color: a palette variable name (`"primary"`, `"surface-active"`,
|
|
6
|
+
* `"text-primary"`) or a literal `#RRGGBB` / `#RRGGBBAA`.
|
|
7
|
+
*
|
|
8
|
+
* [LAW:parse-dont-validate] `resolveColorRef` is the single checkpoint that
|
|
9
|
+
* turns an untrusted reference string into a `ColorRgba`. Everything
|
|
10
|
+
* downstream — color math, `Style` construction, serialization — takes
|
|
11
|
+
* `ColorRgba` and therefore cannot ask again whether the name existed. There
|
|
12
|
+
* is no `isValidColorRef` companion, deliberately: a validator would hand back
|
|
13
|
+
* the same `string` it was given and every consumer would re-check.
|
|
14
|
+
*
|
|
15
|
+
* [LAW:no-silent-failure] A miss throws. An unknown palette name is a broken
|
|
16
|
+
* config, and the author needs to see which name and what was available — not
|
|
17
|
+
* a silently substituted default that makes the bar merely look wrong.
|
|
18
|
+
*/
|
|
19
|
+
export declare class ColorRefError extends Error {
|
|
20
|
+
readonly ref: string;
|
|
21
|
+
constructor(ref: string, detail: string);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The literal-color shape, exported so the template bindings gate on the same
|
|
25
|
+
* pattern this module parses. [LAW:one-source-of-truth] — one regex, one
|
|
26
|
+
* parser body; the bindings add only their own error wording.
|
|
27
|
+
*/
|
|
28
|
+
export declare const HEX_COLOR_RE: RegExp;
|
|
29
|
+
/**
|
|
30
|
+
* Parse a `#RRGGBB` / `#RRGGBBAA` literal. The hex arm of
|
|
31
|
+
* {@link resolveColorRef}, separated so callers that accept *only* literal
|
|
32
|
+
* colors (color math, which cannot meaningfully operate on a palette name)
|
|
33
|
+
* share the one implementation instead of re-deriving it.
|
|
34
|
+
*
|
|
35
|
+
* @throws {ColorRefError} when `hex` is not a well-formed literal.
|
|
36
|
+
*/
|
|
37
|
+
export declare function parseHexColor(hex: string): ColorRgba;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve a color reference against `palette`.
|
|
40
|
+
*
|
|
41
|
+
* Accepting hex alongside names is what makes this **idempotent**:
|
|
42
|
+
* `resolveColorRef(p, resolveColorRef(p, r).hex)` equals
|
|
43
|
+
* `resolveColorRef(p, r)` for every `r` this function accepts. Callers
|
|
44
|
+
* therefore never branch on "is this a palette name or already a color" —
|
|
45
|
+
* they call it unconditionally on whatever the author wrote, whether that is
|
|
46
|
+
* `"surface-active"` or the output of a chain of color math.
|
|
47
|
+
* [LAW:dataflow-not-control-flow]
|
|
48
|
+
*
|
|
49
|
+
* @throws {ColorRefError} on malformed hex or an unknown palette name.
|
|
50
|
+
*/
|
|
51
|
+
export declare function resolveColorRef(palette: Palette, ref: string): ColorRgba;
|
|
52
|
+
//# sourceMappingURL=colorRef.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorRef.d.ts","sourceRoot":"","sources":["../../src/themes/colorRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA6B,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAEpC,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM;CAKjB;AAUD;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAuC,CAAC;AAIjE;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAUpD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,SAAS,CAcxE"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { parseRgbHex, parseRgbaHex } from "../core/color.js";
|
|
2
|
+
/**
|
|
3
|
+
* A **color reference** is the one string form an author uses to name a
|
|
4
|
+
* concrete color: a palette variable name (`"primary"`, `"surface-active"`,
|
|
5
|
+
* `"text-primary"`) or a literal `#RRGGBB` / `#RRGGBBAA`.
|
|
6
|
+
*
|
|
7
|
+
* [LAW:parse-dont-validate] `resolveColorRef` is the single checkpoint that
|
|
8
|
+
* turns an untrusted reference string into a `ColorRgba`. Everything
|
|
9
|
+
* downstream — color math, `Style` construction, serialization — takes
|
|
10
|
+
* `ColorRgba` and therefore cannot ask again whether the name existed. There
|
|
11
|
+
* is no `isValidColorRef` companion, deliberately: a validator would hand back
|
|
12
|
+
* the same `string` it was given and every consumer would re-check.
|
|
13
|
+
*
|
|
14
|
+
* [LAW:no-silent-failure] A miss throws. An unknown palette name is a broken
|
|
15
|
+
* config, and the author needs to see which name and what was available — not
|
|
16
|
+
* a silently substituted default that makes the bar merely look wrong.
|
|
17
|
+
*/
|
|
18
|
+
export class ColorRefError extends Error {
|
|
19
|
+
ref;
|
|
20
|
+
constructor(ref, detail) {
|
|
21
|
+
super(`color reference ${JSON.stringify(ref)} did not resolve — ${detail}`);
|
|
22
|
+
this.ref = ref;
|
|
23
|
+
this.name = "ColorRefError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// A reference *shaped* like hex is resolved as hex; anything else is a palette
|
|
27
|
+
// name. This is a lexical distinction with no overlap — palette variable names
|
|
28
|
+
// never begin with `#` — so it is a parse, not a mode. A `#`-leading string
|
|
29
|
+
// that is malformed hex fails loudly here rather than falling through to a
|
|
30
|
+
// palette lookup that would report a confusing "unknown name" instead of
|
|
31
|
+
// "malformed hex".
|
|
32
|
+
const HEX_LEAD = "#";
|
|
33
|
+
/**
|
|
34
|
+
* The literal-color shape, exported so the template bindings gate on the same
|
|
35
|
+
* pattern this module parses. [LAW:one-source-of-truth] — one regex, one
|
|
36
|
+
* parser body; the bindings add only their own error wording.
|
|
37
|
+
*/
|
|
38
|
+
export const HEX_COLOR_RE = /^#[0-9a-fA-F]{6}([0-9a-fA-F]{2})?$/;
|
|
39
|
+
const OPAQUE_HEX_LENGTH = 7; // "#RRGGBB"
|
|
40
|
+
/**
|
|
41
|
+
* Parse a `#RRGGBB` / `#RRGGBBAA` literal. The hex arm of
|
|
42
|
+
* {@link resolveColorRef}, separated so callers that accept *only* literal
|
|
43
|
+
* colors (color math, which cannot meaningfully operate on a palette name)
|
|
44
|
+
* share the one implementation instead of re-deriving it.
|
|
45
|
+
*
|
|
46
|
+
* @throws {ColorRefError} when `hex` is not a well-formed literal.
|
|
47
|
+
*/
|
|
48
|
+
export function parseHexColor(hex) {
|
|
49
|
+
const trimmed = hex.trim();
|
|
50
|
+
if (!HEX_COLOR_RE.test(trimmed)) {
|
|
51
|
+
throw new ColorRefError(hex, "expected #RRGGBB or #RRGGBBAA");
|
|
52
|
+
}
|
|
53
|
+
// Both parsers take the digits without the leading `#`.
|
|
54
|
+
const digits = trimmed.slice(1);
|
|
55
|
+
return trimmed.length > OPAQUE_HEX_LENGTH
|
|
56
|
+
? parseRgbaHex(digits)
|
|
57
|
+
: parseRgbHex(digits);
|
|
58
|
+
}
|
|
59
|
+
// Cap the "did you mean" list. Palettes carry ~150 variables; dumping all of
|
|
60
|
+
// them buries the message. Nearby names are what a mistyped reference needs.
|
|
61
|
+
const SUGGESTION_LIMIT = 8;
|
|
62
|
+
/**
|
|
63
|
+
* Resolve a color reference against `palette`.
|
|
64
|
+
*
|
|
65
|
+
* Accepting hex alongside names is what makes this **idempotent**:
|
|
66
|
+
* `resolveColorRef(p, resolveColorRef(p, r).hex)` equals
|
|
67
|
+
* `resolveColorRef(p, r)` for every `r` this function accepts. Callers
|
|
68
|
+
* therefore never branch on "is this a palette name or already a color" —
|
|
69
|
+
* they call it unconditionally on whatever the author wrote, whether that is
|
|
70
|
+
* `"surface-active"` or the output of a chain of color math.
|
|
71
|
+
* [LAW:dataflow-not-control-flow]
|
|
72
|
+
*
|
|
73
|
+
* @throws {ColorRefError} on malformed hex or an unknown palette name.
|
|
74
|
+
*/
|
|
75
|
+
export function resolveColorRef(palette, ref) {
|
|
76
|
+
const trimmed = ref.trim();
|
|
77
|
+
if (trimmed.startsWith(HEX_LEAD))
|
|
78
|
+
return parseHexColor(trimmed);
|
|
79
|
+
const hit = palette.get(trimmed);
|
|
80
|
+
if (hit === undefined) {
|
|
81
|
+
throw new ColorRefError(ref, `no such variable in palette ${JSON.stringify(palette.name)}` +
|
|
82
|
+
suggest(palette, trimmed));
|
|
83
|
+
}
|
|
84
|
+
return hit;
|
|
85
|
+
}
|
|
86
|
+
// Names sharing a prefix or suffix with the miss — enough to catch the two
|
|
87
|
+
// mistakes that actually happen (a wrong qualifier, `surface-active` vs
|
|
88
|
+
// `surface-lighten`; a wrong root, `text-primary` vs `primary-text`) without
|
|
89
|
+
// printing the whole palette.
|
|
90
|
+
function suggest(palette, miss) {
|
|
91
|
+
const parts = miss.split("-");
|
|
92
|
+
const near = [...palette.vars.keys()]
|
|
93
|
+
.filter((name) => parts.some((part) => part !== "" && name.includes(part)))
|
|
94
|
+
.slice(0, SUGGESTION_LIMIT);
|
|
95
|
+
return near.length === 0 ? "" : `; did you mean: ${near.join(", ")}`;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=colorRef.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colorRef.js","sourceRoot":"","sources":["../../src/themes/colorRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGxE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAE3B;IADX,YACW,GAAW,EACpB,MAAc;QAEd,KAAK,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,sBAAsB,MAAM,EAAE,CAAC,CAAC;QAHnE,QAAG,GAAH,GAAG,CAAQ;QAIpB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF;AAED,+EAA+E;AAC/E,+EAA+E;AAC/E,4EAA4E;AAC5E,2EAA2E;AAC3E,yEAAyE;AACzE,mBAAmB;AACnB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,oCAAoC,CAAC;AAEjE,MAAM,iBAAiB,GAAG,CAAC,CAAC,CAAC,YAAY;AAEzC;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAC3B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QAChC,MAAM,IAAI,aAAa,CAAC,GAAG,EAAE,+BAA+B,CAAC,CAAC;IAChE,CAAC;IACD,wDAAwD;IACxD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,OAAO,CAAC,MAAM,GAAG,iBAAiB;QACvC,CAAC,CAAC,YAAY,C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AC,CAAC,CAAC,mBAAmB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;AACvE,CAAC"}
|
package/dist/themes/palette.d.ts
CHANGED
|
@@ -7,8 +7,10 @@ import type { ColorRgba } from "../core/color.js";
|
|
|
7
7
|
* `accent`, `error`, etc. — and are the foundation of the theming system.
|
|
8
8
|
*
|
|
9
9
|
* Storage is uniformly ColorRgba; consumers that load from hex JSON
|
|
10
|
-
* parse to ColorRgba at load time.
|
|
11
|
-
*
|
|
10
|
+
* parse to ColorRgba at load time. `get` is a bare lookup — turning an
|
|
11
|
+
* author-written *reference* (a name, or a `#RRGGBB` literal) into a colour
|
|
12
|
+
* is `resolveColorRef`'s job in `colorRef.ts`, so a Palette never has to
|
|
13
|
+
* know about the syntax callers write.
|
|
12
14
|
*/
|
|
13
15
|
export declare class Palette {
|
|
14
16
|
readonly name: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/themes/palette.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD
|
|
1
|
+
{"version":3,"file":"palette.d.ts","sourceRoot":"","sources":["../../src/themes/palette.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;;;;;;;;;GAYG;AACH,qBAAa,OAAO;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;gBAG5C,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC;IAStC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;CAGxC"}
|
package/dist/themes/palette.js
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
* `accent`, `error`, etc. — and are the foundation of the theming system.
|
|
7
7
|
*
|
|
8
8
|
* Storage is uniformly ColorRgba; consumers that load from hex JSON
|
|
9
|
-
* parse to ColorRgba at load time.
|
|
10
|
-
*
|
|
9
|
+
* parse to ColorRgba at load time. `get` is a bare lookup — turning an
|
|
10
|
+
* author-written *reference* (a name, or a `#RRGGBB` literal) into a colour
|
|
11
|
+
* is `resolveColorRef`'s job in `colorRef.ts`, so a Palette never has to
|
|
12
|
+
* know about the syntax callers write.
|
|
11
13
|
*/
|
|
12
14
|
export class Palette {
|
|
13
15
|
name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/themes/palette.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"palette.js","sourceRoot":"","sources":["../../src/themes/palette.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,OAAO;IACT,IAAI,CAAS;IACb,IAAI,CAAU;IACd,IAAI,CAAiC;IAE9C,YACE,IAAY,EACZ,IAAa,EACb,IAAoC;QAEpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,2EAA2E;QAC3E,sEAAsE;QACtE,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A color ramp: a number mapped onto a color through ordered stops.
|
|
3
|
+
*
|
|
4
|
+
* "What does 73 % spent look like" has no answer in a vocabulary of discrete
|
|
5
|
+
* adjustments (`darken`, `mix`, `contrastOn`): each takes colors and returns a
|
|
6
|
+
* color, and none takes a *measurement*. Without a ramp the answer gets
|
|
7
|
+
* computed outside the theme system — a script emits a hex, a template
|
|
8
|
+
* branches `if ge .pct 80 … else if ge .pct 50 …` — and that color decision
|
|
9
|
+
* can no longer transpose with the palette it was meant to belong to. A ramp
|
|
10
|
+
* is the one function whose input is a number, so the decision stays inside.
|
|
11
|
+
*
|
|
12
|
+
* A threshold cascade is a ramp too: the same stops with a `step` easing hold
|
|
13
|
+
* each color until the next position, which is exactly `≥ threshold → hotter`
|
|
14
|
+
* written as data. [LAW:one-type-per-behavior] One primitive; the easing is a
|
|
15
|
+
* value, so a gradient and a cascade differ by one word, not by which function
|
|
16
|
+
* was called.
|
|
17
|
+
*
|
|
18
|
+
* Interpolation is in OKLCH (`Oklch.mix`), so a `linear` ramp between two
|
|
19
|
+
* theme colors passes through perceptually even steps rather than the muddy
|
|
20
|
+
* midpoints of an sRGB blend.
|
|
21
|
+
*
|
|
22
|
+
* [LAW:one-way-deps] Imports `core/color` and `core/oklch` only; nothing here
|
|
23
|
+
* knows what a palette is. Resolving stop *names* is the template binding's
|
|
24
|
+
* job (`paletteFuncs`), which hands this module resolved colors.
|
|
25
|
+
*/
|
|
26
|
+
import type { ColorRgba } from "../core/color.js";
|
|
27
|
+
/** One stop: the color the ramp is exactly `color` at position `at`. */
|
|
28
|
+
export interface ColorStop {
|
|
29
|
+
readonly at: number;
|
|
30
|
+
readonly color: ColorRgba;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* How a value between two stops maps to progress along them. Each easing is
|
|
34
|
+
* a function on segment progress `t ∈ [0, 1)` — `linear` keeps it, `step`
|
|
35
|
+
* holds the left stop for the whole segment.
|
|
36
|
+
*
|
|
37
|
+
* [LAW:dataflow-not-control-flow] The easing is looked up by name and applied
|
|
38
|
+
* unconditionally; `at` runs the same code for a gradient and a cascade.
|
|
39
|
+
*/
|
|
40
|
+
export declare const RAMP_EASINGS: {
|
|
41
|
+
readonly linear: (t: number) => number;
|
|
42
|
+
readonly step: () => number;
|
|
43
|
+
};
|
|
44
|
+
export type RampEasing = keyof typeof RAMP_EASINGS;
|
|
45
|
+
export declare const RAMP_EASING_NAMES: readonly RampEasing[];
|
|
46
|
+
/**
|
|
47
|
+
* The gate a spelled easing crosses. [LAW:parse-dont-validate] — returns the
|
|
48
|
+
* narrowed name, so `ColorRamp` never re-checks. Unknown names throw naming
|
|
49
|
+
* every legal one. [LAW:no-silent-failure]
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseRampEasing(name: string): RampEasing;
|
|
52
|
+
/**
|
|
53
|
+
* An immutable ramp over stops sorted by position.
|
|
54
|
+
*
|
|
55
|
+
* [LAW:single-enforcer] The constructor is the one place a ramp's shape is
|
|
56
|
+
* checked — at least one stop, every position finite, positions
|
|
57
|
+
* non-decreasing — matching the `ColorRgba`/`Oklch` pattern. Positions are
|
|
58
|
+
* required to arrive in order rather than being sorted here: a ramp whose
|
|
59
|
+
* stops are read from configuration (`warning at 80, error at 50`) is an
|
|
60
|
+
* authoring mistake, and sorting would quietly render a different ramp than
|
|
61
|
+
* the one written. [LAW:no-silent-failure]
|
|
62
|
+
*
|
|
63
|
+
* Two stops may share a position: that is a hard edge, the later color
|
|
64
|
+
* taking over at exactly that value (CSS gradients spell a hard stop the
|
|
65
|
+
* same way).
|
|
66
|
+
*/
|
|
67
|
+
export declare class ColorRamp {
|
|
68
|
+
readonly easing: RampEasing;
|
|
69
|
+
readonly stops: readonly ColorStop[];
|
|
70
|
+
constructor(easing: RampEasing, stops: readonly ColorStop[]);
|
|
71
|
+
/**
|
|
72
|
+
* The color at `value`. Below the first stop it is the first color; at or
|
|
73
|
+
* above the last stop it is the last; between two stops it is `easing`
|
|
74
|
+
* of the way from the lower to the upper, so a value exactly on a stop is
|
|
75
|
+
* that stop's color, byte for byte.
|
|
76
|
+
*
|
|
77
|
+
* The two endpoint returns are the exactness contract, not a shortcut:
|
|
78
|
+
* the sRGB → OKLCH → sRGB round-trip can land a channel one unit off, and a
|
|
79
|
+
* ramp that does not hit its own stops exactly would make a `step` ramp
|
|
80
|
+
* paint a color the author never wrote.
|
|
81
|
+
*/
|
|
82
|
+
at(value: number): ColorRgba;
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=ramp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramp.d.ts","sourceRoot":"","sources":["../../src/themes/ramp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,wEAAwE;AACxE,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY;yBACX,MAAM,KAAG,MAAM;yBACjB,MAAM;CACR,CAAC;AAEX,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,YAAY,CAAC;AAEnD,eAAO,MAAM,iBAAiB,EAAgC,SAAS,UAAU,EAAE,CAAC;AAEpF;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAQxD;AAED;;;;;;;;;;;;;;GAcG;AACH,qBAAa,SAAS;IAElB,QAAQ,CAAC,MAAM,EAAE,UAAU;IAC3B,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE;gBAD3B,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,SAAS,SAAS,EAAE;IAmBtC;;;;;;;;;;OAUG;IACH,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;CAmB7B"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A color ramp: a number mapped onto a color through ordered stops.
|
|
3
|
+
*
|
|
4
|
+
* "What does 73 % spent look like" has no answer in a vocabulary of discrete
|
|
5
|
+
* adjustments (`darken`, `mix`, `contrastOn`): each takes colors and returns a
|
|
6
|
+
* color, and none takes a *measurement*. Without a ramp the answer gets
|
|
7
|
+
* computed outside the theme system — a script emits a hex, a template
|
|
8
|
+
* branches `if ge .pct 80 … else if ge .pct 50 …` — and that color decision
|
|
9
|
+
* can no longer transpose with the palette it was meant to belong to. A ramp
|
|
10
|
+
* is the one function whose input is a number, so the decision stays inside.
|
|
11
|
+
*
|
|
12
|
+
* A threshold cascade is a ramp too: the same stops with a `step` easing hold
|
|
13
|
+
* each color until the next position, which is exactly `≥ threshold → hotter`
|
|
14
|
+
* written as data. [LAW:one-type-per-behavior] One primitive; the easing is a
|
|
15
|
+
* value, so a gradient and a cascade differ by one word, not by which function
|
|
16
|
+
* was called.
|
|
17
|
+
*
|
|
18
|
+
* Interpolation is in OKLCH (`Oklch.mix`), so a `linear` ramp between two
|
|
19
|
+
* theme colors passes through perceptually even steps rather than the muddy
|
|
20
|
+
* midpoints of an sRGB blend.
|
|
21
|
+
*
|
|
22
|
+
* [LAW:one-way-deps] Imports `core/color` and `core/oklch` only; nothing here
|
|
23
|
+
* knows what a palette is. Resolving stop *names* is the template binding's
|
|
24
|
+
* job (`paletteFuncs`), which hands this module resolved colors.
|
|
25
|
+
*/
|
|
26
|
+
import { Oklch } from "../core/oklch.js";
|
|
27
|
+
/**
|
|
28
|
+
* How a value between two stops maps to progress along them. Each easing is
|
|
29
|
+
* a function on segment progress `t ∈ [0, 1)` — `linear` keeps it, `step`
|
|
30
|
+
* holds the left stop for the whole segment.
|
|
31
|
+
*
|
|
32
|
+
* [LAW:dataflow-not-control-flow] The easing is looked up by name and applied
|
|
33
|
+
* unconditionally; `at` runs the same code for a gradient and a cascade.
|
|
34
|
+
*/
|
|
35
|
+
export const RAMP_EASINGS = {
|
|
36
|
+
linear: (t) => t,
|
|
37
|
+
step: () => 0,
|
|
38
|
+
};
|
|
39
|
+
export const RAMP_EASING_NAMES = Object.keys(RAMP_EASINGS);
|
|
40
|
+
/**
|
|
41
|
+
* The gate a spelled easing crosses. [LAW:parse-dont-validate] — returns the
|
|
42
|
+
* narrowed name, so `ColorRamp` never re-checks. Unknown names throw naming
|
|
43
|
+
* every legal one. [LAW:no-silent-failure]
|
|
44
|
+
*/
|
|
45
|
+
export function parseRampEasing(name) {
|
|
46
|
+
if (!Object.hasOwn(RAMP_EASINGS, name)) {
|
|
47
|
+
throw new RangeError(`unknown ramp easing ${JSON.stringify(name)}; expected one of ` +
|
|
48
|
+
RAMP_EASING_NAMES.map((n) => JSON.stringify(n)).join(", "));
|
|
49
|
+
}
|
|
50
|
+
return name;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* An immutable ramp over stops sorted by position.
|
|
54
|
+
*
|
|
55
|
+
* [LAW:single-enforcer] The constructor is the one place a ramp's shape is
|
|
56
|
+
* checked — at least one stop, every position finite, positions
|
|
57
|
+
* non-decreasing — matching the `ColorRgba`/`Oklch` pattern. Positions are
|
|
58
|
+
* required to arrive in order rather than being sorted here: a ramp whose
|
|
59
|
+
* stops are read from configuration (`warning at 80, error at 50`) is an
|
|
60
|
+
* authoring mistake, and sorting would quietly render a different ramp than
|
|
61
|
+
* the one written. [LAW:no-silent-failure]
|
|
62
|
+
*
|
|
63
|
+
* Two stops may share a position: that is a hard edge, the later color
|
|
64
|
+
* taking over at exactly that value (CSS gradients spell a hard stop the
|
|
65
|
+
* same way).
|
|
66
|
+
*/
|
|
67
|
+
export class ColorRamp {
|
|
68
|
+
easing;
|
|
69
|
+
stops;
|
|
70
|
+
constructor(easing, stops) {
|
|
71
|
+
this.easing = easing;
|
|
72
|
+
this.stops = stops;
|
|
73
|
+
if (stops.length === 0) {
|
|
74
|
+
throw new RangeError("a ColorRamp needs at least one stop");
|
|
75
|
+
}
|
|
76
|
+
for (const [i, stop] of stops.entries()) {
|
|
77
|
+
if (!Number.isFinite(stop.at)) {
|
|
78
|
+
throw new RangeError(`ColorRamp stop ${i} has a non-finite position ${stop.at}`);
|
|
79
|
+
}
|
|
80
|
+
const prev = stops[i - 1];
|
|
81
|
+
if (prev !== undefined && stop.at < prev.at) {
|
|
82
|
+
throw new RangeError(`ColorRamp stops must be in ascending position order; ` +
|
|
83
|
+
`stop ${i} at ${stop.at} follows stop ${i - 1} at ${prev.at}`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The color at `value`. Below the first stop it is the first color; at or
|
|
89
|
+
* above the last stop it is the last; between two stops it is `easing`
|
|
90
|
+
* of the way from the lower to the upper, so a value exactly on a stop is
|
|
91
|
+
* that stop's color, byte for byte.
|
|
92
|
+
*
|
|
93
|
+
* The two endpoint returns are the exactness contract, not a shortcut:
|
|
94
|
+
* the sRGB → OKLCH → sRGB round-trip can land a channel one unit off, and a
|
|
95
|
+
* ramp that does not hit its own stops exactly would make a `step` ramp
|
|
96
|
+
* paint a color the author never wrote.
|
|
97
|
+
*/
|
|
98
|
+
at(value) {
|
|
99
|
+
if (!Number.isFinite(value)) {
|
|
100
|
+
throw new RangeError(`ColorRamp.at needs a finite value, got ${value}`);
|
|
101
|
+
}
|
|
102
|
+
const stops = this.stops;
|
|
103
|
+
// The last stop at or below `value`; -1 when `value` is below them all.
|
|
104
|
+
let lower = -1;
|
|
105
|
+
while (lower + 1 < stops.length && stops[lower + 1].at <= value)
|
|
106
|
+
lower++;
|
|
107
|
+
if (lower < 0)
|
|
108
|
+
return stops[0].color;
|
|
109
|
+
const from = stops[lower];
|
|
110
|
+
if (lower === stops.length - 1)
|
|
111
|
+
return from.color;
|
|
112
|
+
// `to.at > value >= from.at` by construction of `lower`, so the segment
|
|
113
|
+
// has positive width and `t ∈ [0, 1)`.
|
|
114
|
+
const to = stops[lower + 1];
|
|
115
|
+
const t = RAMP_EASINGS[this.easing]((value - from.at) / (to.at - from.at));
|
|
116
|
+
if (t <= 0)
|
|
117
|
+
return from.color;
|
|
118
|
+
if (t >= 1)
|
|
119
|
+
return to.color;
|
|
120
|
+
return Oklch.fromRgba(from.color).mix(Oklch.fromRgba(to.color), t).toRgba();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=ramp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ramp.js","sourceRoot":"","sources":["../../src/themes/ramp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAQzC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,CAAC,CAAS,EAAU,EAAE,CAAC,CAAC;IAChC,IAAI,EAAE,GAAW,EAAE,CAAC,CAAC;CACb,CAAC;AAIX,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,YAAY,CAA0B,CAAC;AAEpF;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CAClB,uBAAuB,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,oBAAoB;YAC7D,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAC7D,CAAC;IACJ,CAAC;IACD,OAAO,IAAkB,CAAC;AAC5B,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,SAAS;IAET;IACA;IAFX,YACW,MAAkB,EAClB,KAA2B;QAD3B,WAAM,GAAN,MAAM,CAAY;QAClB,UAAK,GAAL,KAAK,CAAsB;QAEpC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,UAAU,CAAC,qCAAqC,CAAC,CAAC;QAC9D,CAAC;QACD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G,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QAClD,wEAAwE;QACxE,uCAAuC;QACvC,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAc,CAAC;QACzC,MAAM,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3E,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,CAAC,IAAI,CAAC;YAAE,OAAO,EAAE,CAAC,KAAK,CAAC;QAC5B,OAAO,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC9E,CAAC;CACF"}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* Width invariant: measure() always returns maxLabelLen(options) + 4
|
|
22
22
|
* regardless of filter state — the query is right-clipped, never wider
|
|
23
|
-
* than the header. See
|
|
23
|
+
* than the header. See docs/widgets.md → Dropdown.
|
|
24
24
|
*/
|
|
25
25
|
import { Segment } from "../core/segment.js";
|
|
26
26
|
import type { RenderOptions } from "../core/protocol.js";
|
package/dist/widgets/dropdown.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
*
|
|
21
21
|
* Width invariant: measure() always returns maxLabelLen(options) + 4
|
|
22
22
|
* regardless of filter state — the query is right-clipped, never wider
|
|
23
|
-
* than the header. See
|
|
23
|
+
* than the header. See docs/widgets.md → Dropdown.
|
|
24
24
|
*/
|
|
25
25
|
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
26
26
|
var useValue = arguments.length > 2;
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
* if it extends the sequence. Tests can call `flush()` to drain synchronously.
|
|
18
18
|
*/
|
|
19
19
|
import { KeyEvent } from "./types.js";
|
|
20
|
-
import type { Screen, FocusManager, InteractiveWidget, WidgetMouseEvent, KeyHandlerOptions
|
|
21
|
-
import type {
|
|
20
|
+
import type { Screen, FocusManager, InteractiveWidget, WidgetMouseEvent, KeyHandlerOptions } from "./types.js";
|
|
21
|
+
import type { Unsubscribe } from "../core/subscription.js";
|
|
22
|
+
import type { TerminalHost } from "../host/terminal-host.js";
|
|
22
23
|
type KeyHandler = (event: KeyEvent) => void;
|
|
23
24
|
type WidgetSource = {
|
|
24
25
|
focusManager: FocusManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"event-router.d.ts","sourceRoot":"","sources":["../../src/widgets/event-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"event-router.d.ts","sourceRoot":"","sources":["../../src/widgets/event-router.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EACV,MAAM,EACN,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EAElB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,KAAK,UAAU,GAAG,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC;AAM5C,KAAK,YAAY,GAAG;IAClB,YAAY,EAAE,YAAY,CAAC;IAC3B,U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U;IA2DlB,OAAO,CAAC,WAAW;IA4BnB,OAAO,CAAC,aAAa;CA+BtB"}
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* [LAW:dataflow-not-control-flow] focus transitions are observable state;
|
|
5
5
|
* widgets react to focus/blur events, the manager never skips dispatch.
|
|
6
6
|
*/
|
|
7
|
-
import type { InteractiveWidget, FocusManager, KeyEvent
|
|
7
|
+
import type { InteractiveWidget, FocusManager, KeyEvent } from "./types.js";
|
|
8
|
+
import type { Unsubscribe } from "../core/subscription.js";
|
|
8
9
|
export declare class DefaultFocusManager implements FocusManager {
|
|
9
10
|
accessor widgetList: InteractiveWidget[];
|
|
10
11
|
accessor currentWidget: InteractiveWidget | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focus-manager.d.ts","sourceRoot":"","sources":["../../src/widgets/focus-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,
|
|
1
|
+
{"version":3,"file":"focus-manager.d.ts","sourceRoot":"","sources":["../../src/widgets/focus-manager.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,QAAQ,EACT,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAE3D,qBAAa,mBAAoB,YAAW,YAAY;IAEtD,QAAQ,CAAC,UAAU,EAAE,iBAAiB,EAAE,CAAM;IAG9C,QAAQ,CAAC,aAAa,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAExD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0D;;IAMzF,IAAI,OAAO,IAAI,iBAAiB,GAAG,IAAI,CAEtC;IAED,IAAI,OAAO,IAAI,SAAS,iBAAiB,EAAE,CAE1C;IAGD,QAAQ,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAazC,UAAU,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAkB3C,IAAI,IAAI,IAAI;IAUZ,IAAI,IAAI,IAAI;IAUZ,KAAK,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAOtC,IAAI,IAAI,IAAI;IASZ,QAAQ,CAAC,OAAO,EAAE,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,KAAK,IAAI,GAAG,WAAW;IAS3E,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,IAAI;IAShC,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,UAAU;CAKnB"}
|
package/dist/widgets/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type { KeyEventInit, KeyHandlerPriority, KeyHandlerOptions, WidgetMouseEvent, WidgetFocusEvent, WidgetBounds, InteractiveWidget, OverlayRenderable, FocusManager, Screen, MountEntry, Placement,
|
|
1
|
+
export type { KeyEventInit, KeyHandlerPriority, KeyHandlerOptions, WidgetMouseEvent, WidgetFocusEvent, WidgetBounds, InteractiveWidget, OverlayRenderable, FocusManager, Screen, MountEntry, Placement, } from "./types.js";
|
|
2
2
|
export { FLOW, hasOverlay, KeyEvent } from "./types.js";
|
|
3
3
|
export { StaticItem } from "./static-item.js";
|
|
4
4
|
export type { StaticItemOptions } from "./static-item.js";
|
|
@@ -12,15 +12,12 @@ export { Checkbox } from "./checkbox.js";
|
|
|
12
12
|
export type { CheckboxOptions } from "./checkbox.js";
|
|
13
13
|
export { Toggle } from "./toggle.js";
|
|
14
14
|
export type { ToggleVariant, ToggleOptions } from "./toggle.js";
|
|
15
|
-
export { TextInput } from "./text-input.js";
|
|
16
|
-
export type { TextInputOptions } from "./text-input.js";
|
|
15
|
+
export { TextInput, charGreedyWrap } from "./text-input.js";
|
|
16
|
+
export type { TextInputOptions, WrapStrategy, WrapRow } from "./text-input.js";
|
|
17
17
|
export { Dropdown } from "./dropdown.js";
|
|
18
18
|
export type { DropdownOptions } from "./dropdown.js";
|
|
19
19
|
export { Slider } from "./slider.js";
|
|
20
20
|
export type { SliderOptions } from "./slider.js";
|
|
21
21
|
export { EventRouter } from "./event-router.js";
|
|
22
22
|
export type { EventRouterOptions } from "./event-router.js";
|
|
23
|
-
export { NodeTerminalHost, BrowserTerminalHost } from "./terminal-host.js";
|
|
24
|
-
export type { TerminalHost, TerminalSize, DataHandler, ResizeHandler, NodeTerminalHostOptions, BrowserTerminalHostOptions, XtermTerminal, XtermDisposable, XtermResizeEvent, } from "./terminal-host.js";
|
|
25
|
-
export { hostStream } from "./host-stream.js";
|
|
26
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,UAAU,EACV,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,MAAM,EACN,UAAU,EACV,SAAS,GACV,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/widgets/index.js
CHANGED
|
@@ -6,10 +6,11 @@ export { DefaultScreen } from "./screen.js";
|
|
|
6
6
|
export { Button } from "./button.js";
|
|
7
7
|
export { Checkbox } from "./checkbox.js";
|
|
8
8
|
export { Toggle } from "./toggle.js";
|
|
9
|
-
export { TextInput } from "./text-input.js";
|
|
9
|
+
export { TextInput, charGreedyWrap } from "./text-input.js";
|
|
10
10
|
export { Dropdown } from "./dropdown.js";
|
|
11
11
|
export { Slider } from "./slider.js";
|
|
12
12
|
export { EventRouter } from "./event-router.js";
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
// The terminal seam is not re-exported here. It lives on the `host` subpath,
|
|
14
|
+
// and a second path to `TerminalHost` would be the two-clocks problem the
|
|
15
|
+
// subpath split exists to remove.
|
|
15
16
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/widgets/index.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,6EAA6E;AAC7E,0EAA0E;AAC1E,kCAAkC"}
|
package/dist/widgets/screen.d.ts
CHANGED
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
*/
|
|
52
52
|
import { ColorDepth } from "../core/color.js";
|
|
53
53
|
import type { Screen, InteractiveWidget, FocusManager, MountEntry } from "./types.js";
|
|
54
|
-
import type { TerminalHost } from "
|
|
54
|
+
import type { TerminalHost } from "../host/terminal-host.js";
|
|
55
55
|
export type ColorSystemSpec = ColorDepth | "auto" | "truecolor" | "256" | "ansi" | "none" | null;
|
|
56
56
|
export interface ScreenOptions {
|
|
57
57
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/widgets/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAMH,OAAO,EAAE,UAAU,EAAsB,MAAM,kBAAkB,CAAC;AAIlE,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,UAAU,EAGX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/widgets/screen.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AAMH,OAAO,EAAE,UAAU,EAAsB,MAAM,kBAAkB,CAAC;AAIlE,OAAO,KAAK,EACV,MAAM,EACN,iBAAiB,EACjB,YAAY,EACZ,UAAU,EAGX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,MAAM,MAAM,eAAe,GACvB,UAAU,GACV,MAAM,GACN,WAAW,GACX,KAAK,GACL,MAAM,GACN,MAAM,GACN,IAAI,CAAC;AAET,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAmBD,qBAAa,aAAc,YAAW,MAAM;IAC1C,QAAQ,CAAC,YAAY,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