@floegence/floeterm-terminal-web 0.5.18 → 0.5.20
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 +33 -0
- package/dist/core/PagedTerminalOutputCoordinator.d.ts +29 -1
- package/dist/core/PagedTerminalOutputCoordinator.d.ts.map +1 -1
- package/dist/core/PagedTerminalOutputCoordinator.js +412 -16
- package/dist/core/PagedTerminalOutputCoordinator.js.map +1 -1
- package/dist/core/TerminalCore.d.ts +6 -2
- package/dist/core/TerminalCore.d.ts.map +1 -1
- package/dist/core/TerminalCore.js +168 -36
- package/dist/core/TerminalCore.js.map +1 -1
- package/dist/fabric/BeamtermFabricRenderer.d.ts.map +1 -1
- package/dist/fabric/BeamtermFabricRenderer.js +3 -0
- package/dist/fabric/BeamtermFabricRenderer.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/TerminalInitializationScheduler.d.ts +24 -8
- package/dist/internal/TerminalInitializationScheduler.d.ts.map +1 -1
- package/dist/internal/TerminalInitializationScheduler.js +61 -28
- package/dist/internal/TerminalInitializationScheduler.js.map +1 -1
- package/dist/manager/TerminalInstanceController.d.ts +0 -2
- package/dist/manager/TerminalInstanceController.d.ts.map +1 -1
- package/dist/manager/TerminalInstanceController.js +38 -54
- package/dist/manager/TerminalInstanceController.js.map +1 -1
- package/dist/sessions/TerminalSessionsCoordinator.d.ts +6 -0
- package/dist/sessions/TerminalSessionsCoordinator.d.ts.map +1 -1
- package/dist/sessions/TerminalSessionsCoordinator.js +66 -16
- package/dist/sessions/TerminalSessionsCoordinator.js.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -51,6 +51,17 @@ const core = new TerminalCore(
|
|
|
51
51
|
await core.initialize();
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
+
Hosts can preload the dynamic Ghostty module, WASM, and renderer resources before a terminal surface is visible without creating a `TerminalCore`:
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { preloadTerminalResources } from '@floegence/floeterm-terminal-web';
|
|
58
|
+
|
|
59
|
+
await preloadTerminalResources({ signal });
|
|
60
|
+
await core.initialize({ priority: 'interactive', signal });
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Resource loading is single-flight and retryable after a real import or WASM initialization failure. Caller cancellation only stops that caller from waiting; it does not interrupt shared resource initialization. Core initialization is globally bounded, gives queued interactive work priority over background work, and shares the actual ready promise across duplicate calls.
|
|
64
|
+
|
|
54
65
|
## Notes
|
|
55
66
|
|
|
56
67
|
- You must provide a `TerminalTransport` and `TerminalEventSource` for the managed controller.
|
|
@@ -96,6 +107,26 @@ If a page reports `historyReset` or changes `historyGeneration` while catch-up i
|
|
|
96
107
|
|
|
97
108
|
Use `TerminalCore.writeHistory` for history batches. Its auto-response suppression is scoped to that parser write and ends at its completion callback, so later live output and user input use normal terminal behavior.
|
|
98
109
|
|
|
110
|
+
Running sessions can prepare bounded history before a visible terminal exists. Preparation does not create a Core, attach a session, resize a PTY, or subscribe to live output:
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
const preparedHistory = await preparePagedTerminalHistory({
|
|
114
|
+
fetchPage: request => transport.historyPage(sessionId, request),
|
|
115
|
+
maxBytes: 4 * 1024 * 1024,
|
|
116
|
+
signal,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const attachGeneration = output.beginAttach(0);
|
|
120
|
+
const attach = await transport.attachWithHistoryBoundary(sessionId, cols, rows);
|
|
121
|
+
await output.completeAttach(attachGeneration, attach.historyBoundarySequence, {
|
|
122
|
+
preparedHistory,
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Prepared history is renderer-neutral and pins `historyGeneration`, `firstRetainedSequence`, and `snapshotEndSequence`. The visible attach validates those boundaries, replays the seed once, and fetches only the missing delta. A generation reset, retention advance, stale fence, or malformed seed discards it and falls back to the normal full recovery path.
|
|
127
|
+
|
|
128
|
+
`preparePagedTerminalHistory` requires those three metadata fields on every prepared page and passes the remaining retained-byte budget as `request.maxBytes` so transports can bound each page as well. The helper always enforces its retained seed budget after a page returns; adapters should honor the request hint to keep peak response memory bounded too.
|
|
129
|
+
|
|
99
130
|
## Restorable In-Memory Snapshots
|
|
100
131
|
|
|
101
132
|
Adaptive host worksets can release inactive renderers without closing their PTY sessions:
|
|
@@ -131,6 +162,8 @@ const core = new TerminalCore(container, {
|
|
|
131
162
|
});
|
|
132
163
|
```
|
|
133
164
|
|
|
165
|
+
When a host can capture an atomic attach boundary, call `beginAttach(startSequence)` before subscribing and starting the server attach, then pass its generation token together with the returned server boundary to `completeAttach(attachGeneration, snapshotEndSequence)`. Live output arriving during the attach round trip remains retained, while a stale attach acknowledgement cannot complete a newer generation. The convenience `attach(startSequence, snapshotEndSequence)` performs both steps when no such window exists. Route only sequences after the boundary to `pushLive`: initial history is fixed at the boundary, while catch-up history is bounded before the first retained live sequence. If defensive overlap still reaches the coordinator, the raw live copy wins over history for the same sequence so terminal query/response behavior is not replaced by replay semantics.
|
|
166
|
+
|
|
134
167
|
Passive mirrors of a remote PTY can render with the session owner's current dimensions:
|
|
135
168
|
|
|
136
169
|
```ts
|
|
@@ -5,6 +5,7 @@ export interface PagedTerminalHistoryRequest {
|
|
|
5
5
|
endSequence?: number;
|
|
6
6
|
historyGeneration?: number;
|
|
7
7
|
cursor?: string | number;
|
|
8
|
+
maxBytes?: number;
|
|
8
9
|
signal: AbortSignal;
|
|
9
10
|
}
|
|
10
11
|
export interface PagedTerminalHistoryPage {
|
|
@@ -21,6 +22,27 @@ export interface PagedTerminalHistoryPage {
|
|
|
21
22
|
coveredBytes?: number;
|
|
22
23
|
totalBytes?: number;
|
|
23
24
|
}
|
|
25
|
+
export interface PreparePagedTerminalHistoryOptions {
|
|
26
|
+
fetchPage(request: PagedTerminalHistoryRequest): Promise<PagedTerminalHistoryPage>;
|
|
27
|
+
startSequence?: number;
|
|
28
|
+
maxBytes?: number;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
yieldControl?: () => void | Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export interface PreparedPagedTerminalHistory {
|
|
33
|
+
readonly chunks: readonly Readonly<TerminalOutputPipelineChunk>[];
|
|
34
|
+
readonly requestedStartSequence: number;
|
|
35
|
+
readonly firstRetainedSequence: number;
|
|
36
|
+
readonly coveredThroughSequence: number;
|
|
37
|
+
readonly snapshotEndSequence: number;
|
|
38
|
+
readonly historyGeneration: number;
|
|
39
|
+
readonly byteLength: number;
|
|
40
|
+
readonly pageCount: number;
|
|
41
|
+
readonly complete: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface PagedTerminalCompleteAttachOptions {
|
|
44
|
+
preparedHistory?: PreparedPagedTerminalHistory;
|
|
45
|
+
}
|
|
24
46
|
export type PagedTerminalHistoryTruncationReason = 'history-evicted' | 'retained-live-overflow';
|
|
25
47
|
export type PagedTerminalOutputFailureCode = 'history_fetch_failed' | 'history_coverage_incomplete' | 'history_contract_missing' | 'history_contract_invalid' | 'retained_live_overflow' | 'history_evicted';
|
|
26
48
|
export interface PagedTerminalOutputFailure {
|
|
@@ -82,6 +104,12 @@ export interface PagedTerminalOutputCoordinatorHandle {
|
|
|
82
104
|
getSnapshot(): PagedTerminalOutputSnapshot;
|
|
83
105
|
dispose(): void;
|
|
84
106
|
}
|
|
85
|
-
export
|
|
107
|
+
export interface AtomicPagedTerminalOutputCoordinatorHandle extends PagedTerminalOutputCoordinatorHandle {
|
|
108
|
+
beginAttach(startSequence?: number): number;
|
|
109
|
+
completeAttach(attachGeneration: number, snapshotEndSequence?: number, options?: PagedTerminalCompleteAttachOptions): Promise<void>;
|
|
110
|
+
attach(startSequence?: number, snapshotEndSequence?: number, options?: PagedTerminalCompleteAttachOptions): Promise<void>;
|
|
111
|
+
}
|
|
112
|
+
export declare const preparePagedTerminalHistory: (options: PreparePagedTerminalHistoryOptions) => Promise<PreparedPagedTerminalHistory>;
|
|
113
|
+
export declare const createPagedTerminalOutputCoordinator: (options: PagedTerminalOutputCoordinatorOptions) => AtomicPagedTerminalOutputCoordinatorHandle;
|
|
86
114
|
export {};
|
|
87
115
|
//# sourceMappingURL=PagedTerminalOutputCoordinator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PagedTerminalOutputCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/PagedTerminalOutputCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"PagedTerminalOutputCoordinator.d.ts","sourceRoot":"","sources":["../../src/core/PagedTerminalOutputCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAC3B,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAGlC,MAAM,MAAM,wBAAwB,GAChC,MAAM,GACN,gBAAgB,GAChB,MAAM,GACN,aAAa,GACb,YAAY,GACZ,QAAQ,GACR,UAAU,CAAC;AAEf,MAAM,WAAW,2BAA2B;IAC1C,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,SAAS,2BAA2B,EAAE,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,qBAAqB,CAAC,EAAE,MAAM,CAA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