@cplieger/web-terminal-ui 5.0.2 → 5.1.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 +55 -15
- package/css/00-tokens.css +53 -1
- package/css/30-tabs.css +178 -76
- package/css/31-switcher.css +29 -25
- package/css/page.css +8 -4
- package/package.json +4 -3
- package/src/features/activity-monitor.ts +4 -2
- package/src/features/tabs/index.ts +245 -45
- package/src/features/tabs/model.ts +239 -1
- package/src/features/tabs/notify.ts +216 -0
- package/src/features/tabs/strip.ts +56 -14
- package/src/index.ts +2 -0
- package/src/kernel/style-contract.ts +96 -0
- package/src/kernel/types.ts +13 -6
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// The names that cross this package's boundary as STRINGS, published as data.
|
|
2
|
+
//
|
|
3
|
+
// Two surfaces of this library are addressed by name rather than by type, so no
|
|
4
|
+
// compiler on either side of the boundary checks them:
|
|
5
|
+
//
|
|
6
|
+
// - `theme` is `Readonly<Record<string, string>>`. The kernel copies every key
|
|
7
|
+
// onto the terminal root verbatim, so a consumer that names a token this
|
|
8
|
+
// library renamed or retired gets a live declaration nothing reads: no
|
|
9
|
+
// error, no warning, just the library's own defaults where the consumer's
|
|
10
|
+
// brand was meant to be.
|
|
11
|
+
// - The loading overlay is the CONSUMER's element (it must paint before this
|
|
12
|
+
// module loads), styled by `css/page.css` purely because the markup opts in
|
|
13
|
+
// by class. Those classes are usually hardcoded in a static HTML file no
|
|
14
|
+
// compiler reads at all.
|
|
15
|
+
//
|
|
16
|
+
// Both were previously prose — a doc comment on the option, a sentence in the
|
|
17
|
+
// README — which a consumer could only agree with by remembering. Published as
|
|
18
|
+
// data they can be ASSERTED against instead: web-terminal-kiro's app.test.ts
|
|
19
|
+
// checks its theme keys and its overlay markup against these exports the same
|
|
20
|
+
// way it already checks its bootstrap watchdog's wording against
|
|
21
|
+
// STARTUP_FAILURE_COPY. Same reason, same shape: this file imports nothing and
|
|
22
|
+
// touches no DOM, so a test or a Node build script can read it without loading
|
|
23
|
+
// the kernel.
|
|
24
|
+
//
|
|
25
|
+
// These lists are HAND-WRITTEN on purpose. They are the public contract — a
|
|
26
|
+
// decision about what this library promises to support — not a fact derived
|
|
27
|
+
// from the stylesheets. What IS derived from the stylesheets is the
|
|
28
|
+
// verification that the promise holds: `src/css-contract.test.ts` generates the
|
|
29
|
+
// declared/referenced token inventory from the CSS itself and fails if any
|
|
30
|
+
// token named here is not both DECLARED and READ by a rule. A token that is
|
|
31
|
+
// declared but never read is the silent-no-op case above, reached from the
|
|
32
|
+
// library's side instead of the consumer's, and no hand-maintained list can
|
|
33
|
+
// catch it.
|
|
34
|
+
|
|
35
|
+
/** CSS custom properties a consumer may set through `CreateTerminalOptions.theme`.
|
|
36
|
+
*
|
|
37
|
+
* Every entry is guaranteed to be both declared and read by the shipped
|
|
38
|
+
* stylesheets (see the inventory test), so setting any of them changes what the
|
|
39
|
+
* terminal renders. Anything NOT listed here is unsupported: it may be an
|
|
40
|
+
* internal token that is renamed without a release note, or it may not exist.
|
|
41
|
+
*
|
|
42
|
+
* Two families, and one rule about the second:
|
|
43
|
+
*
|
|
44
|
+
* - `--accent` and the `--tab-*` family recolor the chrome. `--accent` is the
|
|
45
|
+
* widest lever — the "+" glyphs, and the active-tab border via a `color-mix`
|
|
46
|
+
* derivation — so a single override themes several surfaces.
|
|
47
|
+
* - The `--status-*` family is the activity-dot palette. The three ANIMATED
|
|
48
|
+
* states (`working` / `warning` / `failed`) differ from one another only in
|
|
49
|
+
* HUE, so replacements must keep their LIGHTNESS spread: equal-lightness
|
|
50
|
+
* substitutes collapse into one indistinguishable state in greyscale and
|
|
51
|
+
* under deuteranopia. `crashed` deliberately has no token of its own — it
|
|
52
|
+
* reuses `--status-failed`, solid and static, separating from `failed` by
|
|
53
|
+
* motion rather than color.
|
|
54
|
+
*
|
|
55
|
+
* Values are arbitrary CSS, including `var()` references. A value that reaches
|
|
56
|
+
* through `var()` to an INTERNAL token couples the consumer to a name this
|
|
57
|
+
* list does not cover — assert on those separately if you write one. */
|
|
58
|
+
export const PUBLIC_THEME_TOKENS = [
|
|
59
|
+
"--accent",
|
|
60
|
+
"--tab-bg",
|
|
61
|
+
"--tab-hover-bg",
|
|
62
|
+
"--tab-active-bg",
|
|
63
|
+
"--tab-active-fg",
|
|
64
|
+
"--tab-active-border",
|
|
65
|
+
"--status-working",
|
|
66
|
+
"--status-done",
|
|
67
|
+
"--status-input",
|
|
68
|
+
"--status-warning",
|
|
69
|
+
"--status-failed",
|
|
70
|
+
] as const;
|
|
71
|
+
|
|
72
|
+
/** A CSS custom property `CreateTerminalOptions.theme` supports.
|
|
73
|
+
*
|
|
74
|
+
* `theme` itself stays an open `Record<string, string>` — narrowing it would
|
|
75
|
+
* break every consumer that builds its theme object dynamically — so this type
|
|
76
|
+
* is offered for a consumer that wants its OWN theme constant typed closed,
|
|
77
|
+
* which is where the mistake is actually made. */
|
|
78
|
+
export type PublicThemeToken = (typeof PUBLIC_THEME_TOKENS)[number];
|
|
79
|
+
|
|
80
|
+
/** The class names `css/page.css` styles the pre-JS loading overlay by.
|
|
81
|
+
*
|
|
82
|
+
* Selected by CLASS, never by the consumer's element id: the same
|
|
83
|
+
* no-element-id-contract rule the kernel follows, and an unnamespaced name
|
|
84
|
+
* would collide in a host document. Markup contract: one element carrying
|
|
85
|
+
* `overlay` plus `role="status"`, with one `bar` child. Recolor it by setting
|
|
86
|
+
* the `--wt-loading-*` custom properties on that element — it is the
|
|
87
|
+
* consumer's element, so no JS option is involved.
|
|
88
|
+
*
|
|
89
|
+
* The kernel writes its progressive startup status line into a region it
|
|
90
|
+
* CREATES inside the overlay (`kernel/loading-status.ts`), so those class
|
|
91
|
+
* names are the kernel's own and are not part of the markup a consumer
|
|
92
|
+
* writes. */
|
|
93
|
+
export const LOADING_OVERLAY_CLASSES = {
|
|
94
|
+
overlay: "wt-loading",
|
|
95
|
+
bar: "wt-loading-bar",
|
|
96
|
+
} as const;
|
package/src/kernel/types.ts
CHANGED
|
@@ -426,12 +426,19 @@ export interface CreateTerminalOptions {
|
|
|
426
426
|
// eslint-disable-next-line @typescript-eslint/no-invalid-void-type -- an observing handler returns nothing; only a literal `true` claims the recovery surface, so forcing `return undefined` on every observer is worse than the union
|
|
427
427
|
onFatalError?: (failure: TerminalStartupFailure) => boolean | void;
|
|
428
428
|
/** Theme overrides: CSS custom properties set on the terminal root so a
|
|
429
|
-
* consumer recolors the UI (accent, tab hover/active
|
|
430
|
-
* Keys must be CSS custom-property names
|
|
431
|
-
* CSS value. The library ships the defaults
|
|
432
|
-
* "template"; these are the consumer's "settings"
|
|
433
|
-
*
|
|
434
|
-
*
|
|
429
|
+
* consumer recolors the UI (accent, tab hover/active, the activity-dot
|
|
430
|
+
* palette) without shipping CSS. Keys must be CSS custom-property names
|
|
431
|
+
* (start with "--"); values are any CSS value. The library ships the defaults
|
|
432
|
+
* (css/00-tokens.css) — the "template"; these are the consumer's "settings"
|
|
433
|
+
* and override them for this instance.
|
|
434
|
+
*
|
|
435
|
+
* The supported keys are published as DATA, not prose: `PUBLIC_THEME_TOKENS`
|
|
436
|
+
* (exported at the package root and at "@cplieger/web-terminal-ui/style-contract").
|
|
437
|
+
* This type stays an open Record so a consumer may build its theme
|
|
438
|
+
* dynamically, which means nothing here rejects a key the library renamed or
|
|
439
|
+
* retired — the override would simply apply to nothing. Assert your keys
|
|
440
|
+
* against that list rather than trusting a comment; the library's own suite
|
|
441
|
+
* guarantees every token on it is both declared and read by a rule. */
|
|
435
442
|
theme?: Readonly<Record<string, string>>;
|
|
436
443
|
}
|
|
437
444
|
|