@tomradex/pty-host 0.23.1 → 0.24.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/dist/conpty.d.ts CHANGED
@@ -3,7 +3,26 @@ import type { SpawnPty } from "./host.js";
3
3
  import type { Pane } from "./pane.js";
4
4
  /** A program on a pseudoconsole: node-pty over ConPTY with the OpenConsole it ships, the same on Windows 10 and 11 and twice as fast as the system's conhost. */
5
5
  export declare const spawnConpty: SpawnPty;
6
- /** The process table, through Windows PowerShell (always there); rejects when it fails or takes longer than `timeoutMs`. */
6
+ /** How long the reader waits for the next read; it exits after that, and the next read starts another. */
7
+ export declare const READER_IDLE_MS = 60000;
8
+ /**
9
+ * The process table through one Windows PowerShell (always there), kept for the next read: starting one costs more
10
+ * than the read. Reads go one at a time; one that fails or takes longer than its timeout ends the reader.
11
+ */
12
+ export declare class ProcessReader {
13
+ private readonly idleMs;
14
+ private child;
15
+ private idle;
16
+ private queue;
17
+ constructor(idleMs?: number);
18
+ /** The reader's pid while it runs. */
19
+ get pid(): number | null;
20
+ read(timeoutMs?: number): Promise<ProcessRow[]>;
21
+ dispose(): void;
22
+ private start;
23
+ private once;
24
+ }
25
+ /** The process table; rejects when it cannot be read or takes longer than `timeoutMs`. */
7
26
  export declare function scanProcesses(timeoutMs?: number): Promise<ProcessRow[]>;
8
27
  /**
9
28
  * Ends a pane's process and everything it started. taskkill /T walks the tree from the live root, so it goes first;
package/dist/host.d.ts CHANGED
@@ -60,6 +60,8 @@ export declare class Host {
60
60
  private readonly timing;
61
61
  /** The agent in each pane, by the table they were found in. */
62
62
  private agents;
63
+ /** Each pane's title without the activity glyph an agent animates in it, as it last had the table read again. */
64
+ private readonly named;
63
65
  private readonly screens;
64
66
  constructor(opts: HostOptions);
65
67
  /** One scan at a time, never one while no pane is open; a scan that fails keeps the table there was. */
@@ -84,6 +86,7 @@ export declare class Host {
84
86
  private pane;
85
87
  handle(method: string, params: Record<string, unknown>): Promise<unknown>;
86
88
  launch(params: LaunchParams): Pane;
89
+ /** Another title may mean another program; a working agent's spinner turning in it does not. */
87
90
  private retitled;
88
91
  private drew;
89
92
  /** Ends the pane's whole process tree; resolves once the pane is gone. */
package/dist/index.d.ts CHANGED
@@ -61,6 +61,8 @@ export declare class PtyHost extends Service implements TerminalProvider {
61
61
  [Service.init](): void;
62
62
  pipePath(): string;
63
63
  private call;
64
+ /** The host answering on the pipe; "forbidden" when one this app may not open holds it; null when none does. */
65
+ private reach;
64
66
  /** The host answering on the pipe, or null when none does. */
65
67
  server(): Promise<{
66
68
  version: string;
package/dist/pane.d.ts CHANGED
@@ -28,8 +28,12 @@ export interface ScrollState {
28
28
  }
29
29
  /** The rows a pane keeps above its screen. */
30
30
  export declare const SCROLLBACK = 5000;
31
- /** How long the frames of a burst of output wait to go as one. */
31
+ /** Paints are at least this far apart: the frames of a burst of output go as one. */
32
32
  export declare const FRAME_MS = 16;
33
+ /** A pane painting every frame for this long is a flood of output: it is painted every `BUSY_FRAME_MS` instead. */
34
+ export declare const BUSY_MS = 250;
35
+ /** How far apart a flood's paints are: a window parses half as many screens, and none falls behind. */
36
+ export declare const BUSY_FRAME_MS = 33;
33
37
  /**
34
38
  * One terminal of the host: its pseudo-terminal, the screen a headless xterm
35
39
  * keeps of it (with capped scrollback), where its view is in that scrollback,
@@ -56,7 +60,12 @@ export declare class Pane {
56
60
  private controller;
57
61
  private shown;
58
62
  private seq;
59
- private timer;
63
+ /** Cancels the paint on its way, if one is. */
64
+ private painting;
65
+ private paintedAt;
66
+ /** How far apart paints are now, and since when output has come within a frame of every paint (0 after a quiet frame). */
67
+ private frameMs;
68
+ private busySince;
60
69
  private lastScroll;
61
70
  private readonly cell;
62
71
  /** Modes the public API does not report, read off the program's own sequences. */
@@ -92,6 +101,8 @@ export declare class Pane {
92
101
  attach(attachment: Attachment, cols: number, rows: number, ready?: () => void): void;
93
102
  detach(attachment: Attachment): void;
94
103
  controls(attachment: Attachment): boolean;
104
+ /** Text as a program takes a paste: in the markers when it asked for them. */
105
+ pasted(text: string): string;
95
106
  input(data: string): void;
96
107
  resize(cols: number, rows: number): void;
97
108
  scrollTo(offset: number): void;
@@ -103,7 +114,11 @@ export declare class Pane {
103
114
  /** A click, as the program asked to hear them; nothing when it reads no mouse. */
104
115
  mouse(m: TerminalMouse): void;
105
116
  private mouseReport;
106
- /** Paints what changed, for every window at once, a moment after output: a burst goes as one. */
117
+ /**
118
+ * Paints what changed, for every window at once: right after this turn of output when the last paint is a frame
119
+ * behind (a keystroke's echo), else once it is, so a burst goes as one. Output that keeps coming within a frame of
120
+ * every paint for `BUSY_MS` is painted every `BUSY_FRAME_MS`, until a frame goes by without any.
121
+ */
107
122
  private schedule;
108
123
  private flush;
109
124
  private frame;
package/dist/render.d.ts CHANGED
@@ -13,6 +13,8 @@ export interface Screen {
13
13
  } | null;
14
14
  /** The modes the window's xterm needs to send what the program expects: arrow keys, pastes, focus, the cursor's shape. */
15
15
  modes: string;
16
+ /** On the alternate screen: a switch between the two is never taken for a scroll. */
17
+ alternate?: boolean;
16
18
  }
17
19
  /** The SGR that styles a cell, from a reset. */
18
20
  export declare function sgrOf(cell: IBufferCell): string;
@@ -23,6 +25,21 @@ export declare function renderRow(line: IBufferLine | undefined, cols: number, c
23
25
  };
24
26
  /** Paints a whole screen over whatever the window showed. */
25
27
  export declare function fullFrame(screen: Screen): string;
26
- /** Paints only what changed from `before`; empty when nothing did. A screen of another size is painted whole. */
28
+ /** Rows `top`..`bottom` (inclusive) moved up `by`: what was below comes up, blank rows come in at the bottom. */
29
+ export interface Scroll {
30
+ top: number;
31
+ bottom: number;
32
+ by: number;
33
+ }
34
+ /**
35
+ * The scroll that paints `after` over `before` in the fewest bytes, with the rows it leaves to paint; null when none
36
+ * saves any. A scroll is up by some rows, over the whole screen or one run of rows (an agent's input box stays put
37
+ * under its output). Rows are compared as they are painted, so the bytes it spares are counted exactly.
38
+ */
39
+ export declare function scrollOf(before: Screen, after: Screen): Scroll | null;
40
+ /**
41
+ * Paints only what changed from `before`; empty when nothing did. A screen of another size is painted whole. Output that
42
+ * scrolls is sent as the scroll and the rows it brings in, not as every row painted again.
43
+ */
27
44
  export declare function diffFrame(before: Screen, after: Screen): string;
28
45
  //# sourceMappingURL=render.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tomradex/pty-host",
3
- "version": "0.23.1",
3
+ "version": "0.24.0",
4
4
  "type": "module",
5
5
  "author": "Haoyuan Tang",
6
6
  "engines": {
@@ -31,7 +31,7 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@tomradex/contracts": "0.23.1",
34
+ "@tomradex/contracts": "0.24.0",
35
35
  "@tomradex/domain": "0.2.30",
36
36
  "cordis": "4.0.0-rc.8"
37
37
  },