@tuidom/headless-backend 0.16.1 → 0.17.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HostTerminalColors, type ITerminalBackend } from "@tuidom/core/backend/iTerminalBackend";
|
|
1
|
+
import { type HostColorScheme, type HostTerminalColors, type ITerminalBackend } from "@tuidom/core/backend/iTerminalBackend";
|
|
2
2
|
import { Point, Size } from "@tuidom/core/common/geometryPromitives";
|
|
3
3
|
import type { KeyPressEvent } from "@tuidom/core/input/keyEvent";
|
|
4
4
|
import type { MouseToken } from "@tuidom/core/input/rawTerminalToken";
|
|
@@ -54,6 +54,17 @@ export declare class HeadlessCaptureBackend implements ITerminalBackend {
|
|
|
54
54
|
hostColors: HostTerminalColors;
|
|
55
55
|
/** Answers right away with {@link hostColors} — there is no terminal round-trip. */
|
|
56
56
|
probeHostColors(onResult: (colors: HostTerminalColors) => void): void;
|
|
57
|
+
private readonly colorSchemeCallbacks;
|
|
58
|
+
/**
|
|
59
|
+
* The scheme {@link onColorSchemeChange} reports on subscription, as a terminal answers
|
|
60
|
+
* `CSI ? 996 n`. `undefined` (default) = a terminal without the protocol, nothing fires.
|
|
61
|
+
* Set it before the app subscribes; a later flip goes through {@link sendColorScheme}.
|
|
62
|
+
*/
|
|
63
|
+
colorScheme: HostColorScheme | undefined;
|
|
64
|
+
/** Answers synchronously with {@link colorScheme}, if set — no terminal round-trip to wait for. */
|
|
65
|
+
onColorSchemeChange(callback: (scheme: HostColorScheme) => void): void;
|
|
66
|
+
/** Simulate the terminal's unasked report that its scheme flipped (the OS switched appearance). */
|
|
67
|
+
sendColorScheme(scheme: HostColorScheme): void;
|
|
57
68
|
renderFrame(grid: Grid, cursorPosition: Point | null): void;
|
|
58
69
|
getSize(): Size;
|
|
59
70
|
setup(): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NO_HOST_COLORS } from "@tuidom/core/backend/iTerminalBackend";
|
|
1
|
+
import { NO_HOST_COLORS, } from "@tuidom/core/backend/iTerminalBackend";
|
|
2
2
|
import { Point, Size } from "@tuidom/core/common/geometryPromitives";
|
|
3
3
|
import { KeyInputParser } from "@tuidom/core/input/keyInputParser";
|
|
4
4
|
import { serializeKey } from "@tuidom/core/input/serializeKey";
|
|
@@ -73,6 +73,25 @@ export class HeadlessCaptureBackend {
|
|
|
73
73
|
probeHostColors(onResult) {
|
|
74
74
|
onResult(this.hostColors);
|
|
75
75
|
}
|
|
76
|
+
colorSchemeCallbacks = [];
|
|
77
|
+
/**
|
|
78
|
+
* The scheme {@link onColorSchemeChange} reports on subscription, as a terminal answers
|
|
79
|
+
* `CSI ? 996 n`. `undefined` (default) = a terminal without the protocol, nothing fires.
|
|
80
|
+
* Set it before the app subscribes; a later flip goes through {@link sendColorScheme}.
|
|
81
|
+
*/
|
|
82
|
+
colorScheme = undefined;
|
|
83
|
+
/** Answers synchronously with {@link colorScheme}, if set — no terminal round-trip to wait for. */
|
|
84
|
+
onColorSchemeChange(callback) {
|
|
85
|
+
this.colorSchemeCallbacks.push(callback);
|
|
86
|
+
if (this.colorScheme !== undefined)
|
|
87
|
+
callback(this.colorScheme);
|
|
88
|
+
}
|
|
89
|
+
/** Simulate the terminal's unasked report that its scheme flipped (the OS switched appearance). */
|
|
90
|
+
sendColorScheme(scheme) {
|
|
91
|
+
this.colorScheme = scheme;
|
|
92
|
+
for (const cb of this.colorSchemeCallbacks)
|
|
93
|
+
cb(scheme);
|
|
94
|
+
}
|
|
76
95
|
renderFrame(grid, cursorPosition) {
|
|
77
96
|
this.lastFrame = snapshotGrid(grid, cursorPosition);
|
|
78
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tuidom/headless-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.17.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Experimental terminal UI DOM — headless capture backend (in-memory frames for screenshots/e2e). API is unstable.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -28,6 +28,6 @@
|
|
|
28
28
|
"./*": "./dist/*.js"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tuidom/core": "0.
|
|
31
|
+
"@tuidom/core": "0.17.0"
|
|
32
32
|
}
|
|
33
33
|
}
|