@hex1b/web-terminal 0.170.0-alpha.1616.1.6221fe4 → 0.170.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 +98 -1
- package/dist/LICENSE +21 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +336 -73
- package/dist/index.js.map +4 -4
- package/dist/protocol.d.ts.map +1 -1
- package/dist/renderer.d.ts +5 -3
- package/dist/renderer.d.ts.map +1 -1
- package/dist/terminal-palette.d.ts +37 -0
- package/dist/terminal-palette.d.ts.map +1 -0
- package/dist/terminal-theme.d.ts.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/web-terminal.d.ts +5 -0
- package/dist/web-terminal.d.ts.map +1 -1
- package/dist/wire-types.d.ts +10 -0
- package/dist/wire-types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,101 @@ terminal.focus();
|
|
|
51
51
|
or disposes a mounted view. Disposal removes only the appended element and its
|
|
52
52
|
connection, not the container or server-side shared terminal.
|
|
53
53
|
|
|
54
|
+
### Light and dark terminal palettes
|
|
55
|
+
|
|
56
|
+
Supply JSON-compatible palettes independently for light and dark mode. Palette names
|
|
57
|
+
are not required: hosts own their presets and may derive terminal-specific colors
|
|
58
|
+
from their design system. Colors must be opaque `#RRGGBB` strings.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { WebTerminal, defaultDarkPalette, defaultLightPalette } from "@hex1b/web-terminal";
|
|
62
|
+
|
|
63
|
+
const container = document.getElementById("terminal");
|
|
64
|
+
if (!container) throw new Error("Missing terminal container");
|
|
65
|
+
const terminal = await WebTerminal.mount(container, {
|
|
66
|
+
url: "/ws/terminal",
|
|
67
|
+
colorMode: "system", // "light", "dark", or the browser's prefers-color-scheme.
|
|
68
|
+
lightModePalette: { ...defaultLightPalette, background: "#fafafa" },
|
|
69
|
+
darkModePalette: { ...defaultDarkPalette, background: "#202020" },
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
// A host such as a dashboard can drive the mode instead of following the OS.
|
|
73
|
+
terminal.setColorMode("light");
|
|
74
|
+
terminal.setPalette("dark", { ...defaultDarkPalette, foreground: "#eeeeee" });
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`TerminalPalette` requires `foreground`, `background`, and `ansi` (exactly 16
|
|
78
|
+
colors: black, red, green, yellow, blue, magenta, cyan, white, then their bright
|
|
79
|
+
variants). Optional `cursor` overrides the cursor tint. `selectionForeground`
|
|
80
|
+
and `selectionBackground` control selected text and its opaque background;
|
|
81
|
+
when omitted, they default to the palette's background and foreground,
|
|
82
|
+
respectively. Optional `extended`
|
|
83
|
+
maps indices 16–255 to custom colors. Unspecified extended entries use the xterm
|
|
84
|
+
216-color cube and gray ramp. Palettes are validated and copied on assignment.
|
|
85
|
+
|
|
86
|
+
Dark mode is the default. Omitting the palette options selects **Hex1b Dark**
|
|
87
|
+
and **Hex1b Light**, exported as `defaultDarkPalette` and `defaultLightPalette`.
|
|
88
|
+
These are the package's only built-in palettes. The
|
|
89
|
+
`colorMode` and `resolvedColorMode` getters expose the requested and effective
|
|
90
|
+
modes. Changing the active palette or mode repaints existing cells without
|
|
91
|
+
reconnecting, sending application input, resizing, or clearing selection.
|
|
92
|
+
Previously captured scrollback retains its color references and uses the active
|
|
93
|
+
palette when viewed. Explicit RGB colors and image pixels are not remapped.
|
|
94
|
+
Reverse and dim apply after color resolution; bold uses the bold font, not an
|
|
95
|
+
automatic bright-color substitution.
|
|
96
|
+
|
|
97
|
+
Selection is rendered by both GPU backends using the active palette, including
|
|
98
|
+
over explicit RGB text and image placements. It swaps the terminal's default
|
|
99
|
+
colors, not each cell's colors. Selected text decorations use the selection
|
|
100
|
+
foreground; colored emoji retain their colors and concealed text stays hidden.
|
|
101
|
+
Changing palettes recolors an existing selection without changing its text or
|
|
102
|
+
range. This replaces the translucent UI-accent overlay; selection colors no
|
|
103
|
+
longer depend on the embedding page's `--cp-accent`.
|
|
104
|
+
|
|
105
|
+
The client opts into `indexed-v1` colors only after the matching HWT server
|
|
106
|
+
advertises support, then receives a full reference-colored frame. Older clients
|
|
107
|
+
continue receiving resolved RGBA; this client can still display older RGBA
|
|
108
|
+
frames, but cannot recolor their already-resolved text. The wire extension uses
|
|
109
|
+
the existing cell color fields, not extra per-cell JSON. This spike does not add
|
|
110
|
+
application-driven OSC palette mutation or change server color-query responses.
|
|
111
|
+
Use matching client/server builds for the palette feature.
|
|
112
|
+
|
|
113
|
+
#### Hex1b's default color pair
|
|
114
|
+
|
|
115
|
+
The defaults adapt Chris Kempson's **Tomorrow Night Eighties**, not Ghostty's
|
|
116
|
+
Tomorrow Night-like palette. They use a neutral-charcoal/warm-stone pair,
|
|
117
|
+
with the default foreground and background exchanged between modes:
|
|
118
|
+
|
|
119
|
+
| Mode | Background | Foreground |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| Hex1b Dark | `#323232` | `#d4d0c8` |
|
|
122
|
+
| Hex1b Light | `#d4d0c8` | `#323232` |
|
|
123
|
+
|
|
124
|
+
The named chromatic slots are retuned in **OKLCH**, rather than RGB-inverted.
|
|
125
|
+
Starting from Eighties red, green, yellow, blue, purple, and aqua, the hue
|
|
126
|
+
adjustments are respectively -4, -7, +4, -5, -7, and +4 degrees. Dark-mode normal
|
|
127
|
+
slots use 81% of the original chroma and bright slots 89%; light mode uses 95%
|
|
128
|
+
and 100% for richer accents. Chroma is reduced when necessary to stay in the
|
|
129
|
+
sRGB gamut. Lightness is solved independently for each background: dark mode
|
|
130
|
+
targets approximately **5.2:1** normal and **6.3:1** bright contrast; light mode
|
|
131
|
+
targets **4.6:1** and **5.2:1**, allowing lighter colors that remain readable.
|
|
132
|
+
The resulting rounded hex values are shipped as constants; no color
|
|
133
|
+
conversion or palette-generation dependency runs in the browser.
|
|
134
|
+
|
|
135
|
+
This preserves each slot's hue across modes while softening Eighties' stronger
|
|
136
|
+
accents. Default text contrast is **8.34:1** in both modes (original Eighties:
|
|
137
|
+
approximately 8.58:1). Bright chromatic slots are *darker* in light mode, giving
|
|
138
|
+
them more emphasis rather than washing them out. Bright black is a readable
|
|
139
|
+
mid-gray in each mode; the remaining ANSI black/white slots retain their
|
|
140
|
+
conventional neutral roles for applications that explicitly choose them.
|
|
141
|
+
|
|
142
|
+
These contrast targets apply to opaque, non-dim chromatic text against the
|
|
143
|
+
default background, not every foreground/background combination, selection,
|
|
144
|
+
image overlay, or explicit RGB color.
|
|
145
|
+
|
|
146
|
+
The npm package and `dist/` include Hex1b's `LICENSE`. Preserve it and the bundled
|
|
147
|
+
font license when vendoring.
|
|
148
|
+
|
|
54
149
|
### Connection closure and workload completion
|
|
55
150
|
|
|
56
151
|
Use `onClose(details)` to observe the browser's actual WebSocket close event.
|
|
@@ -1360,7 +1455,9 @@ cancel the default UI.
|
|
|
1360
1455
|
|
|
1361
1456
|
Inspection UI inherits the embedding page's `--cp-*` theme tokens and otherwise
|
|
1362
1457
|
uses its own light/dark defaults. Shadow parts include `selection-highlights`,
|
|
1363
|
-
`selection-highlight`, and `selection-copy-button`.
|
|
1458
|
+
`selection-highlight`, and `selection-copy-button`. The first two retain
|
|
1459
|
+
transparent geometry for host adornments; use the terminal palette to control
|
|
1460
|
+
the rendered selection colors rather than CSS background/opacity on those parts.
|
|
1364
1461
|
|
|
1365
1462
|
## Fonts and licenses
|
|
1366
1463
|
|
package/dist/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Mitch Denny
|
|
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/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { WebTerminal } from "./web-terminal.js";
|
|
2
|
+
export { defaultLightPalette, defaultDarkPalette } from "./terminal-palette.js";
|
|
2
3
|
export { InputRoute, TerminalAction, defaultInputBindings } from "./input-policy.js";
|
|
3
4
|
export { MIN_FONT_SIZE, MAX_FONT_SIZE } from "./terminal-sizing.js";
|
|
4
5
|
export { parseCommandMarkParameters, getCmdlineUrl } from "./command-mark.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,mBAAmB,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjG,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,mBAAmB,YAAY,CAAC"}
|