@orkestrel/terminal 0.0.12 → 0.0.14
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 +3 -7
- package/dist/src/core/index.cjs +408 -258
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +544 -297
- package/dist/src/core/index.d.ts +544 -297
- package/dist/src/core/index.js +393 -241
- package/dist/src/core/index.js.map +1 -1
- package/dist/src/server/index.cjs +187 -201
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.d.cts +129 -143
- package/dist/src/server/index.d.ts +129 -143
- package/dist/src/server/index.js +176 -185
- package/dist/src/server/index.js.map +1 -1
- package/package.json +23 -19
|
@@ -20,11 +20,11 @@ import { StylerInterface } from '@orkestrel/console';
|
|
|
20
20
|
import { TableInterface } from '@orkestrel/database';
|
|
21
21
|
import { TextField } from '@orkestrel/form';
|
|
22
22
|
|
|
23
|
-
/**
|
|
23
|
+
/** Names the `Accept` header value that opens the broker's SSE stream. */
|
|
24
24
|
export declare const ACCEPT_EVENT_STREAM = "text/event-stream";
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Explains why {@link PromptInterface.answer} refused. Names its axis with `reason`.
|
|
28
28
|
*
|
|
29
29
|
* @remarks
|
|
30
30
|
* - `unknown` — no form is parked under that id, or the one that was has already settled.
|
|
@@ -41,42 +41,57 @@ export declare type AnswerError = {
|
|
|
41
41
|
readonly errors: readonly FieldError[];
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
/**
|
|
44
|
+
/** Names the backspace byte (BS, U+0008) — Ctrl+H / some terminals' Backspace. */
|
|
45
45
|
export declare const BACKSPACE: string;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
48
|
+
* Represents the immutable state a checkbox field's reducer carries — the select state plus the ticked set.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* - `message` — the sanitized label the header renders.
|
|
52
|
+
* - `choices` — the choices the list offers, in declared order.
|
|
53
|
+
* - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
|
|
54
|
+
* - `focused` — the index the cursor sits on.
|
|
55
|
+
* - `checked` — the ticked indices, in the order they were ticked; the reducer sorts them into
|
|
56
|
+
* choice order when it submits.
|
|
57
|
+
*/
|
|
58
|
+
export declare interface CheckboxState {
|
|
59
|
+
readonly message: string;
|
|
60
|
+
readonly choices: readonly FieldChoice[];
|
|
61
|
+
readonly styler: StylerInterface;
|
|
62
|
+
readonly theme: PromptTheme;
|
|
63
|
+
readonly focused: number;
|
|
64
|
+
readonly checked: readonly number[];
|
|
65
|
+
}
|
|
64
66
|
|
|
65
67
|
/**
|
|
66
|
-
*
|
|
67
|
-
|
|
68
|
-
|
|
68
|
+
* Represents the immutable state a confirm field's reducer carries. It holds no typed value, because the
|
|
69
|
+
* answer is the key itself.
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* - `message` — the sanitized label the header renders.
|
|
73
|
+
* - `default` — the answer a bare return submits, and the letter the view capitalizes.
|
|
74
|
+
* - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
|
|
75
|
+
*/
|
|
76
|
+
export declare interface ConfirmState {
|
|
77
|
+
readonly message: string;
|
|
78
|
+
readonly default: boolean;
|
|
79
|
+
readonly styler: StylerInterface;
|
|
80
|
+
readonly theme: PromptTheme;
|
|
81
|
+
}
|
|
69
82
|
|
|
70
83
|
/**
|
|
71
|
-
*
|
|
72
|
-
* consults for the one-byte keys
|
|
73
|
-
* `ctrl` combination. The source of truth for
|
|
84
|
+
* Holds the control BYTE (or CRLF pair) → key descriptor table {@link import('./helpers.js').parseKey}
|
|
85
|
+
* consults for the one-byte keys and the two-byte CRLF Enter chunk. Each entry carries the
|
|
86
|
+
* canonical `name` and whether it is a `ctrl` combination. The source of truth for that decode;
|
|
87
|
+
* frozen.
|
|
74
88
|
*
|
|
75
89
|
* @remarks
|
|
76
|
-
* `return` / `newline` map to `return` (one canonical Enter name)
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
* `
|
|
90
|
+
* `return` / `newline` / `return + newline` all map to `return` (one canonical Enter name) — a
|
|
91
|
+
* terminal or a paste can deliver Enter as `\r`, `\n`, or the `\r\n` pair in one chunk;
|
|
92
|
+
* `delete` / `backspace` both map to `backspace` (the Backspace bytes); the Ctrl combos
|
|
93
|
+
* (`c` / `d` / `u` / `a` / `e`) carry `ctrl: true` so a reducer can match
|
|
94
|
+
* `key.ctrl && key.name === 'c'`. `escape` / `tab` / `space` are plain named keys.
|
|
80
95
|
*/
|
|
81
96
|
export declare const CONTROL_NAMES: Readonly<Record<string, {
|
|
82
97
|
readonly name: string;
|
|
@@ -84,39 +99,27 @@ export declare const CONTROL_NAMES: Readonly<Record<string, {
|
|
|
84
99
|
}>>;
|
|
85
100
|
|
|
86
101
|
/**
|
|
87
|
-
*
|
|
102
|
+
* Builds the initial checkbox-field key state.
|
|
88
103
|
*
|
|
89
104
|
* @param field - The checkbox field to render
|
|
90
105
|
* @param styler - The styler used to render the view
|
|
91
106
|
* @param theme - The optional terminal theme
|
|
92
107
|
* @returns The initial immutable key state
|
|
93
108
|
*/
|
|
94
|
-
export declare function createCheckboxState(field: CheckboxField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
95
|
-
message: string;
|
|
96
|
-
choices: FieldChoice[];
|
|
97
|
-
styler: StylerInterface;
|
|
98
|
-
theme: PromptTheme;
|
|
99
|
-
focused: number;
|
|
100
|
-
checked: readonly number[];
|
|
101
|
-
};
|
|
109
|
+
export declare function createCheckboxState(field: CheckboxField, styler?: StylerInterface, theme?: PromptThemeOptions): CheckboxState;
|
|
102
110
|
|
|
103
111
|
/**
|
|
104
|
-
*
|
|
112
|
+
* Builds the initial confirm-field key state.
|
|
105
113
|
*
|
|
106
114
|
* @param field - The confirm field to render
|
|
107
115
|
* @param styler - The styler used to render the view
|
|
108
116
|
* @param theme - The optional terminal theme
|
|
109
117
|
* @returns The initial immutable key state
|
|
110
118
|
*/
|
|
111
|
-
export declare function createConfirmState(field: ConfirmField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
112
|
-
message: string;
|
|
113
|
-
default: boolean;
|
|
114
|
-
styler: StylerInterface;
|
|
115
|
-
theme: PromptTheme;
|
|
116
|
-
};
|
|
119
|
+
export declare function createConfirmState(field: ConfirmField, styler?: StylerInterface, theme?: PromptThemeOptions): ConfirmState;
|
|
117
120
|
|
|
118
121
|
/**
|
|
119
|
-
*
|
|
122
|
+
* Creates a {@link TerminalStoreInterface} backed by one table of the `databases` layer — the
|
|
120
123
|
* driver-pluggable twin of {@link createMemoryTerminalStore}, storing each endpoint's config
|
|
121
124
|
* snapshot as one opaque JSON column.
|
|
122
125
|
*
|
|
@@ -125,7 +128,7 @@ export declare function createConfirmState(field: ConfirmField, styler?: StylerI
|
|
|
125
128
|
*
|
|
126
129
|
* @example
|
|
127
130
|
* ```ts
|
|
128
|
-
* import { createDatabaseTerminalStore } from '@
|
|
131
|
+
* import { createDatabaseTerminalStore } from '@orkestrel/terminal'
|
|
129
132
|
*
|
|
130
133
|
* const store = createDatabaseTerminalStore() // in-memory by default
|
|
131
134
|
* ```
|
|
@@ -133,47 +136,34 @@ export declare function createConfirmState(field: ConfirmField, styler?: StylerI
|
|
|
133
136
|
export declare function createDatabaseTerminalStore(driver?: DriverInterface): TerminalStoreInterface;
|
|
134
137
|
|
|
135
138
|
/**
|
|
136
|
-
*
|
|
139
|
+
* Builds the initial editor-field key state.
|
|
137
140
|
*
|
|
138
141
|
* @param field - The editor field to render
|
|
139
142
|
* @param styler - The styler used to render the view
|
|
140
143
|
* @param theme - The optional terminal theme
|
|
141
144
|
* @returns The initial immutable key state
|
|
142
145
|
*/
|
|
143
|
-
export declare function createEditorState(field: EditorField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
144
|
-
message: string;
|
|
145
|
-
default: string;
|
|
146
|
-
styler: StylerInterface;
|
|
147
|
-
theme: PromptTheme;
|
|
148
|
-
lines: readonly string[];
|
|
149
|
-
current: string;
|
|
150
|
-
};
|
|
146
|
+
export declare function createEditorState(field: EditorField, styler?: StylerInterface, theme?: PromptThemeOptions): EditorState;
|
|
151
147
|
|
|
152
148
|
/**
|
|
153
|
-
*
|
|
149
|
+
* Builds the initial text-field key state.
|
|
154
150
|
*
|
|
155
151
|
* @param field - The text field to render
|
|
156
152
|
* @param styler - The styler used to render the view
|
|
157
153
|
* @param theme - The optional terminal theme
|
|
158
154
|
* @returns The initial immutable key state
|
|
159
155
|
*/
|
|
160
|
-
export declare function createInputState(field: TextField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
161
|
-
message: string;
|
|
162
|
-
default: string;
|
|
163
|
-
styler: StylerInterface;
|
|
164
|
-
theme: PromptTheme;
|
|
165
|
-
value: string;
|
|
166
|
-
};
|
|
156
|
+
export declare function createInputState(field: TextField, styler?: StylerInterface, theme?: PromptThemeOptions): InputState;
|
|
167
157
|
|
|
168
158
|
/**
|
|
169
|
-
*
|
|
159
|
+
* Creates the in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of endpoint
|
|
170
160
|
* config snapshots, the default store backing a {@link TerminalManagerInterface}'s `open` / `save`.
|
|
171
161
|
*
|
|
172
162
|
* @returns A {@link TerminalStoreInterface}
|
|
173
163
|
*
|
|
174
164
|
* @example
|
|
175
165
|
* ```ts
|
|
176
|
-
* import { createMemoryTerminalStore } from '@
|
|
166
|
+
* import { createMemoryTerminalStore } from '@orkestrel/terminal'
|
|
177
167
|
*
|
|
178
168
|
* const store = createMemoryTerminalStore()
|
|
179
169
|
* ```
|
|
@@ -181,23 +171,17 @@ export declare function createInputState(field: TextField, styler?: StylerInterf
|
|
|
181
171
|
export declare function createMemoryTerminalStore(): TerminalStoreInterface;
|
|
182
172
|
|
|
183
173
|
/**
|
|
184
|
-
*
|
|
174
|
+
* Builds the initial password-field key state.
|
|
185
175
|
*
|
|
186
176
|
* @param field - The password field to render
|
|
187
177
|
* @param styler - The styler used to render the view
|
|
188
178
|
* @param theme - The optional terminal theme
|
|
189
179
|
* @returns The initial immutable key state
|
|
190
180
|
*/
|
|
191
|
-
export declare function createPasswordState(field: PasswordField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
192
|
-
message: string;
|
|
193
|
-
mask: string;
|
|
194
|
-
styler: StylerInterface;
|
|
195
|
-
theme: PromptTheme;
|
|
196
|
-
value: string;
|
|
197
|
-
};
|
|
181
|
+
export declare function createPasswordState(field: PasswordField, styler?: StylerInterface, theme?: PromptThemeOptions): PasswordState;
|
|
198
182
|
|
|
199
183
|
/**
|
|
200
|
-
*
|
|
184
|
+
* Creates the headless {@link PromptInterface} broker. It parks live forms and applies remote
|
|
201
185
|
* answers to the authoritative instances.
|
|
202
186
|
*
|
|
203
187
|
* @param options - See {@link PromptOptions}
|
|
@@ -210,7 +194,7 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
|
|
|
210
194
|
*
|
|
211
195
|
* @example
|
|
212
196
|
* ```ts
|
|
213
|
-
* import { createPrompt } from '@
|
|
197
|
+
* import { createPrompt } from '@orkestrel/terminal'
|
|
214
198
|
* import { createForm } from '@orkestrel/form'
|
|
215
199
|
*
|
|
216
200
|
* const prompt = createPrompt()
|
|
@@ -222,7 +206,7 @@ export declare function createPasswordState(field: PasswordField, styler?: Style
|
|
|
222
206
|
export declare function createPrompt(options?: PromptOptions): PromptInterface;
|
|
223
207
|
|
|
224
208
|
/**
|
|
225
|
-
*
|
|
209
|
+
* Creates the SSE prompt {@link PromptClientInterface} BRIDGE — it connects to a remote broker's SSE
|
|
226
210
|
* endpoint, dispatches each received form to a local {@link import('./types.js').TerminalInterface},
|
|
227
211
|
* and POSTs the answer back. Universal — `fetch` / SSE are web-standard.
|
|
228
212
|
*
|
|
@@ -234,11 +218,11 @@ export declare function createPrompt(options?: PromptOptions): PromptInterface;
|
|
|
234
218
|
* ends; it reconnects with the `delay` backoff unless `reconnect` is `false` / the client was
|
|
235
219
|
* `destroy`ed. Inject `options.fetch` (a scripted `fetch`) and `options.timer` to drive it
|
|
236
220
|
* deterministically in tests — no real network.
|
|
237
|
-
* -
|
|
221
|
+
* - **Wire narrowing.** Every decoded prompt is guard-narrowed before dispatch (never an `as`).
|
|
238
222
|
*
|
|
239
223
|
* @example
|
|
240
224
|
* ```ts
|
|
241
|
-
* import { createPromptClient } from '@
|
|
225
|
+
* import { createPromptClient } from '@orkestrel/terminal'
|
|
242
226
|
*
|
|
243
227
|
* const client = createPromptClient({ url: 'http://host/prompts', terminal })
|
|
244
228
|
* await client.connect()
|
|
@@ -247,7 +231,7 @@ export declare function createPrompt(options?: PromptOptions): PromptInterface;
|
|
|
247
231
|
export declare function createPromptClient(options: PromptClientOptions): PromptClientInterface;
|
|
248
232
|
|
|
249
233
|
/**
|
|
250
|
-
*
|
|
234
|
+
* Builds a complete {@link PromptTheme} by merging a partial one over
|
|
251
235
|
* {@link DEFAULT_PROMPT_THEME}, leaf by leaf — each supplied icon replaces that glyph, each
|
|
252
236
|
* supplied role replaces that {@link Style}, and everything else keeps its default. Each supplied
|
|
253
237
|
* style is snapshotted through the console module's own
|
|
@@ -269,23 +253,17 @@ export declare function createPromptClient(options: PromptClientOptions): Prompt
|
|
|
269
253
|
export declare function createPromptTheme(options?: PromptThemeOptions): PromptTheme;
|
|
270
254
|
|
|
271
255
|
/**
|
|
272
|
-
*
|
|
256
|
+
* Builds the initial select-field key state.
|
|
273
257
|
*
|
|
274
258
|
* @param field - The select field to render
|
|
275
259
|
* @param styler - The styler used to render the view
|
|
276
260
|
* @param theme - The optional terminal theme
|
|
277
261
|
* @returns The initial immutable key state
|
|
278
262
|
*/
|
|
279
|
-
export declare function createSelectState(field: SelectField, styler?: StylerInterface, theme?: PromptThemeOptions):
|
|
280
|
-
message: string;
|
|
281
|
-
choices: FieldChoice[];
|
|
282
|
-
styler: StylerInterface;
|
|
283
|
-
theme: PromptTheme;
|
|
284
|
-
focused: number;
|
|
285
|
-
};
|
|
263
|
+
export declare function createSelectState(field: SelectField, styler?: StylerInterface, theme?: PromptThemeOptions): SelectState;
|
|
286
264
|
|
|
287
265
|
/**
|
|
288
|
-
*
|
|
266
|
+
* Creates the multi-endpoint {@link TerminalManager} — a named registry of
|
|
289
267
|
* {@link PromptInterface} brokers so several parties can `ask` prompts of each other by name,
|
|
290
268
|
* with a transitive DEADLOCK check across every in-flight ask.
|
|
291
269
|
*
|
|
@@ -294,7 +272,7 @@ export declare function createSelectState(field: SelectField, styler?: StylerInt
|
|
|
294
272
|
*
|
|
295
273
|
* @example
|
|
296
274
|
* ```ts
|
|
297
|
-
* import { createTerminalManager } from '@
|
|
275
|
+
* import { createTerminalManager } from '@orkestrel/terminal'
|
|
298
276
|
*
|
|
299
277
|
* const manager = createTerminalManager()
|
|
300
278
|
* manager.add('agent')
|
|
@@ -302,23 +280,23 @@ export declare function createSelectState(field: SelectField, styler?: StylerInt
|
|
|
302
280
|
*/
|
|
303
281
|
export declare function createTerminalManager(options?: TerminalManagerOptions): TerminalManagerInterface;
|
|
304
282
|
|
|
305
|
-
/** Ctrl+A (SOH, U+0001) — move to start of line. */
|
|
283
|
+
/** Names the Ctrl+A byte (SOH, U+0001) — move to start of line. */
|
|
306
284
|
export declare const CTRL_A: string;
|
|
307
285
|
|
|
308
|
-
/** Ctrl+C (ETX, U+0003) — interrupt / cancel. */
|
|
286
|
+
/** Names the Ctrl+C byte (ETX, U+0003) — interrupt / cancel. */
|
|
309
287
|
export declare const CTRL_C: string;
|
|
310
288
|
|
|
311
|
-
/** Ctrl+D (EOT, U+0004) — end-of-transmission / finish (the editor's commit key). */
|
|
289
|
+
/** Names the Ctrl+D byte (EOT, U+0004) — end-of-transmission / finish (the editor's commit key). */
|
|
312
290
|
export declare const CTRL_D: string;
|
|
313
291
|
|
|
314
|
-
/** Ctrl+E (ENQ, U+0005) — move to end of line. */
|
|
292
|
+
/** Names the Ctrl+E byte (ENQ, U+0005) — move to end of line. */
|
|
315
293
|
export declare const CTRL_E: string;
|
|
316
294
|
|
|
317
|
-
/** Ctrl+U (NAK, U+0015) — clear the current line. */
|
|
295
|
+
/** Names the Ctrl+U byte (NAK, U+0015) — clear the current line. */
|
|
318
296
|
export declare const CTRL_U: string;
|
|
319
297
|
|
|
320
298
|
/**
|
|
321
|
-
*
|
|
299
|
+
* Implements a {@link TerminalStoreInterface} backed by one table of the `databases` layer — an endpoint's
|
|
322
300
|
* durable CONFIG state IS a row, so persistence reduces to keyed point-access (`get` / `set` /
|
|
323
301
|
* `delete`) over a {@link TableInterface}, the driver-pluggable twin of the plain-`Map`
|
|
324
302
|
* {@link import('./MemoryTerminalStore.js').MemoryTerminalStore}.
|
|
@@ -328,7 +306,7 @@ export declare const CTRL_U: string;
|
|
|
328
306
|
* JSON, SQLite, IndexedDB) is chosen by whoever builds it (the factories), so a JSON / SQLite /
|
|
329
307
|
* IndexedDB backend swaps in WITHOUT touching the manager — the same seam as
|
|
330
308
|
* {@link import('./MemoryTerminalStore.js').MemoryTerminalStore}. The driver defaults to memory
|
|
331
|
-
* ({@link import('
|
|
309
|
+
* ({@link import('../factories.js').createDatabaseTerminalStore} passes `createMemoryDriver()`), so
|
|
332
310
|
* it ALSO works in memory out of the box; you opt into the durable plumbing by passing a JSON /
|
|
333
311
|
* SQLite / IndexedDB driver.
|
|
334
312
|
*
|
|
@@ -340,18 +318,19 @@ export declare const CTRL_U: string;
|
|
|
340
318
|
* - **`set(snapshot)` upserts under the snapshot's OWN `id`** (no separate id param) — it writes
|
|
341
319
|
* the row `{ id: snapshot.id, snapshot }`.
|
|
342
320
|
* - **`get(id)` resolves the stored snapshot for an id**, narrowing the opaque JSON column back to
|
|
343
|
-
* a {@link TerminalSnapshot} ({@link import('
|
|
344
|
-
*
|
|
321
|
+
* a {@link TerminalSnapshot} ({@link import('../validators.js').isTerminalSnapshot} — the total
|
|
322
|
+
* guard that narrows an untrusted storage read), or `undefined` if none is stored.
|
|
345
323
|
* - **`delete(id)` drops a snapshot by id**; an absent id is a no-op (no throw).
|
|
346
324
|
*
|
|
347
325
|
* There is NO idle-TTL / eviction — a persisted config lives until an explicit `delete`. The public
|
|
348
|
-
* surface is EXACTLY `get` / `set` / `delete` — no extra members
|
|
349
|
-
* {@link TerminalStoreInterface}
|
|
326
|
+
* surface is EXACTLY `get` / `set` / `delete` — no extra members, so the class and
|
|
327
|
+
* {@link TerminalStoreInterface} carry the same methods. Hydration stays a caller concern: `open` always restores an EMPTY
|
|
350
328
|
* broker — parked Promises are process-bound and never resurrected.
|
|
351
329
|
*
|
|
352
330
|
* @example
|
|
353
331
|
* ```ts
|
|
354
|
-
* import { createDatabaseTerminalStore
|
|
332
|
+
* import { createDatabaseTerminalStore } from '@orkestrel/terminal'
|
|
333
|
+
* import { createMemoryDriver } from '@orkestrel/database'
|
|
355
334
|
*
|
|
356
335
|
* const store = createDatabaseTerminalStore(createMemoryDriver()) // a durable driver swaps in here
|
|
357
336
|
* await store.set({ id: 'shell', timeout: 5000 }) // persist the config (one JSON column)
|
|
@@ -362,25 +341,42 @@ export declare const CTRL_U: string;
|
|
|
362
341
|
export declare class DatabaseTerminalStore implements TerminalStoreInterface {
|
|
363
342
|
#private;
|
|
364
343
|
/**
|
|
365
|
-
*
|
|
344
|
+
* Wraps a table as a terminal store.
|
|
366
345
|
*
|
|
367
346
|
* @param table - The {@link TableInterface} holding the snapshots — its row is the
|
|
368
347
|
* {@link TerminalSnapshotRow} `{ id; snapshot }` shape (the snapshot one opaque JSON column)
|
|
369
348
|
*/
|
|
370
349
|
constructor(table: TableInterface<TerminalSnapshotRow>);
|
|
371
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Resolves the persisted snapshot for `id`, narrowing the opaque JSON column back to a
|
|
352
|
+
* `TerminalSnapshot`.
|
|
353
|
+
*
|
|
354
|
+
* @param id - The endpoint name the row is keyed by
|
|
355
|
+
* @returns The stored snapshot, or `undefined` when none is held or the column is off-shape
|
|
356
|
+
*/
|
|
372
357
|
get(id: string): Promise<TerminalSnapshot | undefined>;
|
|
373
|
-
/**
|
|
358
|
+
/**
|
|
359
|
+
* Inserts or replaces under the snapshot's OWN `id` (no separate id param) — the row is
|
|
360
|
+
* `{ id, snapshot }`.
|
|
361
|
+
*
|
|
362
|
+
* @param snapshot - The config snapshot to persist, carrying its own `id`
|
|
363
|
+
* @returns A promise that settles once the row is written
|
|
364
|
+
*/
|
|
374
365
|
set(snapshot: TerminalSnapshot): Promise<void>;
|
|
375
|
-
/**
|
|
366
|
+
/**
|
|
367
|
+
* Drops a snapshot by id; an absent id is a no-op (no throw).
|
|
368
|
+
*
|
|
369
|
+
* @param id - The endpoint name to drop
|
|
370
|
+
* @returns A promise that settles once the row is gone
|
|
371
|
+
*/
|
|
376
372
|
delete(id: string): Promise<void>;
|
|
377
373
|
}
|
|
378
374
|
|
|
379
|
-
/**
|
|
375
|
+
/** Names the default mask glyph {@link import('./helpers.js').createPasswordState} uses — `*`. */
|
|
380
376
|
export declare const DEFAULT_MASK = "*";
|
|
381
377
|
|
|
382
378
|
/**
|
|
383
|
-
*
|
|
379
|
+
* Holds the {@link import('./types.js').PromptTheme} every prompt renders with unless its options supply
|
|
384
380
|
* another — the glyph set assembled from {@link PROMPT_ICONS} plus the console
|
|
385
381
|
* {@link import('@orkestrel/console').STATUS_ICONS} `success` / `error` marks, and the console
|
|
386
382
|
* {@link import('@orkestrel/console').Style} each role is painted with. Deeply frozen through the
|
|
@@ -396,60 +392,69 @@ export declare const DEFAULT_MASK = "*";
|
|
|
396
392
|
*/
|
|
397
393
|
export declare const DEFAULT_PROMPT_THEME: PromptTheme;
|
|
398
394
|
|
|
399
|
-
/**
|
|
395
|
+
/** Holds how long (ms) the {@link import('./types.js').PromptInterface} broker parks an unanswered prompt before it expires — 5 minutes. */
|
|
400
396
|
export declare const DEFAULT_PROMPT_TIMEOUT_MS = 300000;
|
|
401
397
|
|
|
402
|
-
/**
|
|
398
|
+
/** Holds how long (ms) the {@link import('./types.js').PromptClientInterface} waits before each reconnect attempt — 2 seconds. */
|
|
403
399
|
export declare const DEFAULT_RECONNECT_DELAY_MS = 2000;
|
|
404
400
|
|
|
405
401
|
/**
|
|
406
|
-
*
|
|
407
|
-
* wrapper that arms `callback` after `ms` and returns a {@link
|
|
402
|
+
* Implements the default {@link import('./types.js').TimerHandler} — a thin host `setTimeout` / `clearTimeout`
|
|
403
|
+
* wrapper that arms `callback` after `ms` and returns a {@link TimerCancelFunction}. The deadline seam
|
|
408
404
|
* behind both the {@link import('./Prompt.js').Prompt} broker (its expiry) and the
|
|
409
405
|
* {@link import('./PromptClient.js').PromptClient} (its reconnect backoff); a test injects a
|
|
410
406
|
* deterministic timer instead, so neither entity touches real time.
|
|
407
|
+
*
|
|
408
|
+
* @param callback - The deadline callback to arm
|
|
409
|
+
* @param ms - How long to wait before firing it, in milliseconds
|
|
410
|
+
* @returns The {@link TimerCancelFunction} that clears the armed deadline
|
|
411
411
|
*/
|
|
412
|
-
export declare function defaultTimer(callback: () => void, ms: number):
|
|
412
|
+
export declare function defaultTimer(callback: () => void, ms: number): TimerCancelFunction;
|
|
413
413
|
|
|
414
|
-
/**
|
|
414
|
+
/** Names the delete byte (DEL, U+007F) — the usual Backspace byte on a Unix TTY. */
|
|
415
415
|
export declare const DELETE: string;
|
|
416
416
|
|
|
417
417
|
/**
|
|
418
|
-
*
|
|
418
|
+
* Applies a single line-editing {@link KeyEvent} to a text buffer — the editing shared by input /
|
|
419
419
|
* password / editor. A printable key appends its character; `backspace` drops the last character;
|
|
420
|
-
* `space` appends a space; ctrl-u clears the line.
|
|
421
|
-
*
|
|
420
|
+
* `space` appends a space; ctrl-u clears the line.
|
|
421
|
+
*
|
|
422
|
+
* @param value - The buffer the field holds so far
|
|
423
|
+
* @param key - The decoded keypress to apply
|
|
424
|
+
* @returns The new buffer, or `undefined` when the key does not edit the line, so the caller can
|
|
425
|
+
* leave the state untouched
|
|
422
426
|
*/
|
|
423
427
|
export declare function editLine(value: string, key: KeyEvent): string | undefined;
|
|
424
428
|
|
|
425
429
|
/**
|
|
426
|
-
*
|
|
427
|
-
*
|
|
428
|
-
*
|
|
429
|
-
*
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
*
|
|
435
|
-
*/
|
|
436
|
-
export declare
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
430
|
+
* Represents the immutable state an editor field's reducer carries — the committed lines and the line still
|
|
431
|
+
* being typed, kept apart so a return commits one without ending the field.
|
|
432
|
+
*
|
|
433
|
+
* @remarks
|
|
434
|
+
* - `message` — the sanitized label the header renders.
|
|
435
|
+
* - `default` — the text an empty finish falls back to.
|
|
436
|
+
* - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
|
|
437
|
+
* - `lines` — the lines already committed with a return.
|
|
438
|
+
* - `current` — the line in progress.
|
|
439
|
+
*/
|
|
440
|
+
export declare interface EditorState {
|
|
441
|
+
readonly message: string;
|
|
442
|
+
readonly default: string;
|
|
443
|
+
readonly styler: StylerInterface;
|
|
444
|
+
readonly theme: PromptTheme;
|
|
445
|
+
readonly lines: readonly string[];
|
|
446
|
+
readonly current: string;
|
|
447
|
+
}
|
|
443
448
|
|
|
444
449
|
/**
|
|
445
|
-
*
|
|
450
|
+
* Represents a minimal `fetch` — the subset of the global `fetch` a {@link PromptClientInterface} uses: open
|
|
446
451
|
* the SSE stream, POST an answer. Injected so a test drives the client with a scripted `Response`
|
|
447
452
|
* instead of a real network.
|
|
448
453
|
*/
|
|
449
454
|
export declare type FetchHandler = (input: string, init?: FetchInit) => Promise<Response>;
|
|
450
455
|
|
|
451
456
|
/**
|
|
452
|
-
*
|
|
457
|
+
* Represents the request init a {@link PromptClientInterface} passes to its {@link FetchHandler} — the
|
|
453
458
|
* `RequestInit` fields it actually sets.
|
|
454
459
|
*/
|
|
455
460
|
export declare interface FetchInit {
|
|
@@ -459,43 +464,52 @@ export declare interface FetchInit {
|
|
|
459
464
|
readonly signal?: AbortSignal;
|
|
460
465
|
}
|
|
461
466
|
|
|
462
|
-
/**
|
|
467
|
+
/**
|
|
468
|
+
* Implements the default {@link import('./types.js').FetchHandler} — the global `fetch`, adapted to
|
|
469
|
+
* the minimal injected shape the {@link import('./PromptClient.js').PromptClient} uses.
|
|
470
|
+
*
|
|
471
|
+
* @param input - The request URL
|
|
472
|
+
* @param init - The request init the client sets — method, headers, body, and abort signal
|
|
473
|
+
* @returns The host `fetch` promise for that request
|
|
474
|
+
*/
|
|
463
475
|
export declare function globalFetch(input: string, init?: FetchInit): Promise<Response>;
|
|
464
476
|
|
|
465
|
-
/**
|
|
477
|
+
/** Names the auth-token request header the {@link import('./types.js').PromptClientInterface} sends. */
|
|
466
478
|
export declare const HEADER_TOKEN = "x-orkestrel-token";
|
|
467
479
|
|
|
468
480
|
/**
|
|
469
|
-
*
|
|
470
|
-
*
|
|
481
|
+
* Represents the immutable state a text field's reducer carries — built by
|
|
482
|
+
* {@link import('./helpers.js').createInputState}, rendered by
|
|
483
|
+
* {@link import('./helpers.js').renderInputView}, and advanced by
|
|
484
|
+
* {@link import('./helpers.js').reduceInput}.
|
|
471
485
|
*
|
|
472
|
-
* @
|
|
473
|
-
*
|
|
474
|
-
*
|
|
475
|
-
*
|
|
476
|
-
*
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
/** Render a text-field key state as a styled view. */
|
|
488
|
-
export declare function inputView(state: ReturnType<typeof createInputState>): string;
|
|
486
|
+
* @remarks
|
|
487
|
+
* - `message` — the sanitized label the header renders.
|
|
488
|
+
* - `default` — the declared default a bare return submits.
|
|
489
|
+
* - `styler` — the console styler every role is painted through.
|
|
490
|
+
* - `theme` — the resolved {@link PromptTheme}.
|
|
491
|
+
* - `value` — the characters typed so far.
|
|
492
|
+
*/
|
|
493
|
+
export declare interface InputState {
|
|
494
|
+
readonly message: string;
|
|
495
|
+
readonly default: string;
|
|
496
|
+
readonly styler: StylerInterface;
|
|
497
|
+
readonly theme: PromptTheme;
|
|
498
|
+
readonly value: string;
|
|
499
|
+
}
|
|
489
500
|
|
|
490
501
|
/**
|
|
491
|
-
*
|
|
502
|
+
* Checks whether a caught value is an `AbortError` — the {@link import('./PromptClient.js').PromptClient}
|
|
492
503
|
* distinguishes a deliberate `disconnect` / teardown (an aborted `fetch`) from a real fault, so it
|
|
493
504
|
* exits its connect loop quietly instead of emitting `error` / reconnecting.
|
|
505
|
+
*
|
|
506
|
+
* @param error - The caught value to test
|
|
507
|
+
* @returns True if the value is a host `Error` or `DOMException` named `AbortError`; false otherwise
|
|
494
508
|
*/
|
|
495
509
|
export declare function isAbortError(error: unknown): boolean;
|
|
496
510
|
|
|
497
511
|
/**
|
|
498
|
-
*
|
|
512
|
+
* Checks whether `url` is an INSECURE remote endpoint — a plain `http://` URL whose host is NOT a
|
|
499
513
|
* loopback address. Pure string parsing (no `URL` global), so it stays total on malformed input.
|
|
500
514
|
*
|
|
501
515
|
* @remarks
|
|
@@ -504,7 +518,7 @@ export declare function isAbortError(error: unknown): boolean;
|
|
|
504
518
|
* An `https://` URL (or any non-`http://` scheme) is never flagged.
|
|
505
519
|
*
|
|
506
520
|
* @param url - The candidate endpoint URL
|
|
507
|
-
* @returns
|
|
521
|
+
* @returns True if `url` is a non-loopback `http://` endpoint; false otherwise
|
|
508
522
|
*
|
|
509
523
|
* @example
|
|
510
524
|
* ```ts
|
|
@@ -516,28 +530,39 @@ export declare function isAbortError(error: unknown): boolean;
|
|
|
516
530
|
export declare function isInsecureRemote(url: string): boolean;
|
|
517
531
|
|
|
518
532
|
/**
|
|
519
|
-
*
|
|
533
|
+
* Narrows an unknown wire value to a {@link PendingForm} envelope.
|
|
520
534
|
*
|
|
521
535
|
* @remarks
|
|
522
536
|
* This guard checks the transport record and proves only that `schema` is a record. The Form
|
|
523
537
|
* package's `parseForm` owns the schema payload and its semantic audit.
|
|
524
538
|
*
|
|
525
539
|
* @param value - The decoded wire value to inspect
|
|
526
|
-
* @returns
|
|
540
|
+
* @returns True if the value is a complete pending-form envelope; false otherwise
|
|
527
541
|
*/
|
|
528
542
|
export declare function isPendingForm(value: unknown): value is PendingForm;
|
|
529
543
|
|
|
530
|
-
/**
|
|
544
|
+
/**
|
|
545
|
+
* Narrows an unknown value to a {@link PendingFormStatus}.
|
|
546
|
+
*
|
|
547
|
+
* @param value - The candidate ticket status
|
|
548
|
+
* @returns True if the value is one of the declared ticket statuses; false otherwise
|
|
549
|
+
*/
|
|
531
550
|
export declare const isPendingFormStatus: Guard<PendingFormStatus>;
|
|
532
551
|
|
|
533
|
-
/**
|
|
552
|
+
/**
|
|
553
|
+
* Checks whether a single character is a printable (non-control) character — used by
|
|
554
|
+
* {@link parseKey}'s char fallback.
|
|
555
|
+
*
|
|
556
|
+
* @param character - The single character to test
|
|
557
|
+
* @returns True if the character is at or above space and is not DEL; false otherwise
|
|
558
|
+
*/
|
|
534
559
|
export declare function isPrintable(character: string): boolean;
|
|
535
560
|
|
|
536
561
|
/**
|
|
537
|
-
*
|
|
562
|
+
* Narrows an unknown caught value to a {@link TerminalError}.
|
|
538
563
|
*
|
|
539
564
|
* @param value - The value to test (typically a `catch` binding or a rejected prompt call)
|
|
540
|
-
* @returns
|
|
565
|
+
* @returns True if `value` is a {@link TerminalError}; false otherwise
|
|
541
566
|
*
|
|
542
567
|
* @example
|
|
543
568
|
* ```ts
|
|
@@ -552,30 +577,33 @@ export declare function isPrintable(character: string): boolean;
|
|
|
552
577
|
*/
|
|
553
578
|
export declare function isTerminalError(value: unknown): value is TerminalError;
|
|
554
579
|
|
|
555
|
-
/**
|
|
580
|
+
/**
|
|
581
|
+
* Narrows an unknown value to a {@link TerminalSnapshot} — the read boundary a store applies to an
|
|
582
|
+
* untrusted persisted row.
|
|
583
|
+
*
|
|
584
|
+
* @param value - The candidate snapshot read back from storage
|
|
585
|
+
* @returns True if the value carries a non-empty `id` and an optional numeric `timeout`; false otherwise
|
|
586
|
+
*/
|
|
556
587
|
export declare const isTerminalSnapshot: Guard<TerminalSnapshot>;
|
|
557
588
|
|
|
558
589
|
/**
|
|
559
|
-
*
|
|
590
|
+
* Narrows an unknown value to a transport-neutral {@link WireEvent}.
|
|
560
591
|
*
|
|
561
592
|
* @param value - The candidate wire event
|
|
562
|
-
* @returns
|
|
593
|
+
* @returns True if the value carries an event name, serialized data, and an optional id; false otherwise
|
|
563
594
|
*/
|
|
564
595
|
export declare const isWireEvent: Guard<WireEvent>;
|
|
565
596
|
|
|
566
597
|
/**
|
|
567
|
-
*
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
-
*
|
|
598
|
+
* Names the Single Shift Three lead (`ESCO`) — the alternate arrow-key prefix some terminals emit
|
|
599
|
+
* (`ESC O A`). Built from the console module's own {@link import('@orkestrel/console').ESC}; the
|
|
600
|
+
* navigation keys' CSI lead is that module's {@link import('@orkestrel/console').CSI}, which this
|
|
601
|
+
* package reuses rather than redeclaring.
|
|
571
602
|
*/
|
|
572
|
-
export declare const KEY_CSI: string;
|
|
573
|
-
|
|
574
|
-
/** The Single Shift Three lead (`ESCO`) — the alternate arrow-key prefix some terminals emit (`ESC O A`). */
|
|
575
603
|
export declare const KEY_SS3: string;
|
|
576
604
|
|
|
577
605
|
/**
|
|
578
|
-
*
|
|
606
|
+
* Represents one decoded keypress — the TTY-agnostic representation of a single key, the output of
|
|
579
607
|
* {@link import('./helpers.js').parseKey}. A driver reads `name` and the modifier flags to decide
|
|
580
608
|
* its transition; `sequence` is preserved so a printable character round-trips and an unknown
|
|
581
609
|
* escape is never lost.
|
|
@@ -584,15 +612,15 @@ export declare const KEY_SS3: string;
|
|
|
584
612
|
* - `name` — the canonical key name: a control or navigation key (`return`, `backspace`, `tab`,
|
|
585
613
|
* `escape`, `up` / `down` / `left` / `right`, `space`, `home`, `end`, `delete`), a named ctrl
|
|
586
614
|
* combo (`c` with `ctrl` true for ctrl-c, likewise `d` / `u` / `a` / `e`), or the printable
|
|
587
|
-
* character itself (`'a'`, `'7'`, `'?'`). An unrecognized sequence
|
|
588
|
-
*
|
|
615
|
+
* character itself (`'a'`, `'7'`, `'?'`). An unrecognized sequence carries NO `name` — absence,
|
|
616
|
+
* never an empty string — and the decoder stays total and never throws.
|
|
589
617
|
* - `sequence` — the exact input bytes as a string (a `Uint8Array` is decoded UTF-8). The driver
|
|
590
618
|
* writes this verbatim for a printable key.
|
|
591
619
|
* - `ctrl` / `meta` / `shift` — the modifier flags. `ctrl` is true for a C0 control byte, `meta`
|
|
592
620
|
* for an ESC-prefixed (Alt) sequence, `shift` for an uppercase-letter printable.
|
|
593
621
|
*/
|
|
594
622
|
export declare interface KeyEvent {
|
|
595
|
-
readonly name
|
|
623
|
+
readonly name?: string;
|
|
596
624
|
readonly sequence: string;
|
|
597
625
|
readonly ctrl: boolean;
|
|
598
626
|
readonly meta: boolean;
|
|
@@ -600,14 +628,14 @@ export declare interface KeyEvent {
|
|
|
600
628
|
}
|
|
601
629
|
|
|
602
630
|
/**
|
|
603
|
-
*
|
|
631
|
+
* Implements the in-memory {@link TerminalStoreInterface} — a process-lifetime `Map` of
|
|
604
632
|
* {@link TerminalSnapshot}s keyed by endpoint id, the DEFAULT store
|
|
605
|
-
* {@link import('
|
|
633
|
+
* {@link import('../factories.js').createMemoryTerminalStore} builds. The EXACT twin of
|
|
606
634
|
* {@link import('./DatabaseTerminalStore.js').DatabaseTerminalStore}.
|
|
607
635
|
*
|
|
608
636
|
* @remarks
|
|
609
|
-
* A plain `Map<string, TerminalSnapshot>`
|
|
610
|
-
*
|
|
637
|
+
* A plain `Map<string, TerminalSnapshot>` — the snapshot is already pure, self-contained CONFIG-only
|
|
638
|
+
* JSON, so the memory tier needs no encoding. There is NO idle-TTL and NO
|
|
611
639
|
* eviction: a persisted config lives until an explicit `delete`. A durable backend (JSON / SQLite /
|
|
612
640
|
* IndexedDB) swaps in through the SAME interface without touching the manager — its
|
|
613
641
|
* driver-pluggable twin is {@link import('./DatabaseTerminalStore.js').DatabaseTerminalStore} (the
|
|
@@ -617,13 +645,13 @@ export declare interface KeyEvent {
|
|
|
617
645
|
* - **`set` inserts / replaces under the snapshot's OWN `id`** (no separate id param).
|
|
618
646
|
* - **`delete` drops a snapshot by id**; an absent id is a no-op (no throw).
|
|
619
647
|
*
|
|
620
|
-
* The public surface is EXACTLY `get` / `set` / `delete` — no extra members
|
|
621
|
-
*
|
|
648
|
+
* The public surface is EXACTLY `get` / `set` / `delete` — no extra members, so the class and
|
|
649
|
+
* {@link TerminalStoreInterface} carry the same methods. Hydration is a caller concern: `open` always
|
|
622
650
|
* restores an EMPTY broker — parked Promises are process-bound and never resurrected.
|
|
623
651
|
*
|
|
624
652
|
* @example
|
|
625
653
|
* ```ts
|
|
626
|
-
* import { createMemoryTerminalStore } from '@
|
|
654
|
+
* import { createMemoryTerminalStore } from '@orkestrel/terminal'
|
|
627
655
|
*
|
|
628
656
|
* const store = createMemoryTerminalStore()
|
|
629
657
|
* await store.set({ id: 'shell', timeout: 5000 }) // persist a config
|
|
@@ -633,16 +661,34 @@ export declare interface KeyEvent {
|
|
|
633
661
|
*/
|
|
634
662
|
export declare class MemoryTerminalStore implements TerminalStoreInterface {
|
|
635
663
|
#private;
|
|
664
|
+
/**
|
|
665
|
+
* Resolves the persisted snapshot for `id`.
|
|
666
|
+
*
|
|
667
|
+
* @param id - The endpoint name the snapshot is keyed by
|
|
668
|
+
* @returns The stored snapshot, or `undefined` when none is held
|
|
669
|
+
*/
|
|
636
670
|
get(id: string): Promise<TerminalSnapshot | undefined>;
|
|
671
|
+
/**
|
|
672
|
+
* Inserts or replaces under the snapshot's OWN `id` (no separate id param).
|
|
673
|
+
*
|
|
674
|
+
* @param snapshot - The config snapshot to persist, carrying its own `id`
|
|
675
|
+
* @returns A promise that settles once the snapshot is held
|
|
676
|
+
*/
|
|
637
677
|
set(snapshot: TerminalSnapshot): Promise<void>;
|
|
678
|
+
/**
|
|
679
|
+
* Drops a snapshot by id; an absent id is a no-op (no throw).
|
|
680
|
+
*
|
|
681
|
+
* @param id - The endpoint name to drop
|
|
682
|
+
* @returns A promise that settles once the snapshot is gone
|
|
683
|
+
*/
|
|
638
684
|
delete(id: string): Promise<void>;
|
|
639
685
|
}
|
|
640
686
|
|
|
641
|
-
/**
|
|
687
|
+
/** Names the line feed byte (`\n`, U+000A) — Enter on some terminals / pasted input. */
|
|
642
688
|
export declare const NEWLINE: string;
|
|
643
689
|
|
|
644
690
|
/**
|
|
645
|
-
*
|
|
691
|
+
* Represents one parked form's runtime state inside the broker — the live form, the wire-safe record the
|
|
646
692
|
* broker exposes, and the cancel for its expiry timer.
|
|
647
693
|
*
|
|
648
694
|
* @remarks
|
|
@@ -651,14 +697,14 @@ export declare const NEWLINE: string;
|
|
|
651
697
|
* abandons it and settles the caller's promise through the form's own lifecycle. `pending` is the
|
|
652
698
|
* wire record, whose `status` tracks the ticket.
|
|
653
699
|
*/
|
|
654
|
-
export declare interface
|
|
700
|
+
export declare interface ParkedForm {
|
|
655
701
|
readonly form: FormInterface;
|
|
656
702
|
readonly pending: PendingForm;
|
|
657
|
-
readonly cancel:
|
|
703
|
+
readonly cancel: TimerCancelFunction;
|
|
658
704
|
}
|
|
659
705
|
|
|
660
706
|
/**
|
|
661
|
-
*
|
|
707
|
+
* Represents the parking envelope — everything the broker needs about a park that the form itself does not
|
|
662
708
|
* say.
|
|
663
709
|
*
|
|
664
710
|
* @remarks
|
|
@@ -671,24 +717,24 @@ export declare interface ParkRequest {
|
|
|
671
717
|
}
|
|
672
718
|
|
|
673
719
|
/**
|
|
674
|
-
*
|
|
675
|
-
* read as UTF-8; the resulting string is matched against the known control bytes
|
|
676
|
-
* ({@link CONTROL_NAMES}) and escape sequences ({@link SEQUENCE_NAMES}), falling back to a
|
|
677
|
-
* single printable character. An unrecognized sequence
|
|
720
|
+
* Decodes one keypress's bytes into a {@link KeyEvent} — total, never throws. A `Uint8Array` is
|
|
721
|
+
* read as UTF-8; the resulting string is matched against the known control bytes and the CRLF
|
|
722
|
+
* pair ({@link CONTROL_NAMES}) and escape sequences ({@link SEQUENCE_NAMES}), falling back to a
|
|
723
|
+
* single printable character. An unrecognized sequence carries NO `name`, with the raw `sequence`
|
|
678
724
|
* preserved.
|
|
679
725
|
*
|
|
680
726
|
* @remarks
|
|
681
727
|
* - **Single control byte.** A one-character control input (`return` / `backspace` / `tab` /
|
|
682
|
-
* `escape` / `space`, or a Ctrl combo `c` / `d` / `u` / `a` / `e`)
|
|
683
|
-
* {@link CONTROL_NAMES}, carrying its `ctrl` flag.
|
|
728
|
+
* `escape` / `space`, or a Ctrl combo `c` / `d` / `u` / `a` / `e`), or the two-byte `\r\n`
|
|
729
|
+
* CRLF pair, is looked up in {@link CONTROL_NAMES}, carrying its `ctrl` flag.
|
|
684
730
|
* - **Escape sequence.** A multi-byte ESC sequence (`up` / `down` / `left` / `right` in BOTH the
|
|
685
731
|
* `ESC[A` and `ESCOA` forms, plus `home` / `end` / `delete`) is looked up in
|
|
686
732
|
* {@link SEQUENCE_NAMES} and flagged `meta`.
|
|
687
733
|
* - **Printable character.** A single printable character becomes `name` = that character, with
|
|
688
734
|
* `shift` set when it is an uppercase letter. A multi-code-point printable (an emoji, a pasted
|
|
689
735
|
* run) keeps its first code point as the name and the whole input as `sequence`.
|
|
690
|
-
* - **Unknown.** Anything else (an unrecognized escape, an empty input) yields
|
|
691
|
-
* total, so the driver never crashes on a stray byte.
|
|
736
|
+
* - **Unknown.** Anything else (an unrecognized escape, an empty input) yields an event with NO
|
|
737
|
+
* `name` — absence, never an empty string — total, so the driver never crashes on a stray byte.
|
|
692
738
|
*
|
|
693
739
|
* @param input - The raw keypress bytes, as a string or `Uint8Array`
|
|
694
740
|
* @returns The decoded {@link KeyEvent}
|
|
@@ -696,6 +742,7 @@ export declare interface ParkRequest {
|
|
|
696
742
|
* @example
|
|
697
743
|
* ```ts
|
|
698
744
|
* parseKey('\r') // { name: 'return', sequence: '\r', ctrl: false, meta: false, shift: false }
|
|
745
|
+
* parseKey('\r\n') // { name: 'return', sequence: '\r\n', ctrl: false, meta: false, shift: false }
|
|
699
746
|
* parseKey('\x1b[A') // { name: 'up', sequence: '\x1b[A', ctrl: false, meta: true, shift: false }
|
|
700
747
|
* parseKey('A') // { name: 'A', sequence: 'A', ctrl: false, meta: false, shift: true }
|
|
701
748
|
* parseKey('\x03') // { name: 'c', sequence: '\x03', ctrl: true, meta: false, shift: false }
|
|
@@ -704,17 +751,25 @@ export declare interface ParkRequest {
|
|
|
704
751
|
export declare function parseKey(input: string | Uint8Array): KeyEvent;
|
|
705
752
|
|
|
706
753
|
/**
|
|
707
|
-
*
|
|
708
|
-
*
|
|
709
|
-
*
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
754
|
+
* Represents the immutable state a password field's reducer carries — the text state with the mask glyph in
|
|
755
|
+
* place of a default, because a secret is never seeded from the schema.
|
|
756
|
+
*
|
|
757
|
+
* @remarks
|
|
758
|
+
* - `message` — the sanitized label the header renders.
|
|
759
|
+
* - `mask` — the glyph each typed character renders as.
|
|
760
|
+
* - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
|
|
761
|
+
* - `value` — the characters typed so far, rendered only as the mask repeated.
|
|
762
|
+
*/
|
|
763
|
+
export declare interface PasswordState {
|
|
764
|
+
readonly message: string;
|
|
765
|
+
readonly mask: string;
|
|
766
|
+
readonly styler: StylerInterface;
|
|
767
|
+
readonly theme: PromptTheme;
|
|
768
|
+
readonly value: string;
|
|
769
|
+
}
|
|
715
770
|
|
|
716
771
|
/**
|
|
717
|
-
*
|
|
772
|
+
* Represents one form PARKED by the broker — an id-keyed, wire-safe record of a live form awaiting a remote
|
|
718
773
|
* answer. The value a `pending` listener receives and the broker serializes over SSE to a
|
|
719
774
|
* {@link PromptClientInterface}.
|
|
720
775
|
*
|
|
@@ -740,7 +795,7 @@ export declare interface PendingForm {
|
|
|
740
795
|
}
|
|
741
796
|
|
|
742
797
|
/**
|
|
743
|
-
*
|
|
798
|
+
* Names the lifecycle status of a parked {@link PendingForm} — where the TICKET stands, which is not
|
|
744
799
|
* where the form stands. A ticket is `pending` until somebody answers it; the form it carries has
|
|
745
800
|
* its own status, and the two are separate facts about separate entities.
|
|
746
801
|
*
|
|
@@ -752,7 +807,7 @@ export declare interface PendingForm {
|
|
|
752
807
|
export declare type PendingFormStatus = 'pending' | 'answered' | 'expired';
|
|
753
808
|
|
|
754
809
|
/**
|
|
755
|
-
*
|
|
810
|
+
* Implements the headless form broker. It parks live forms, exposes their serialized schemas, and applies
|
|
756
811
|
* remote answers to the authoritative form.
|
|
757
812
|
*
|
|
758
813
|
* @remarks
|
|
@@ -786,7 +841,7 @@ export declare class Prompt implements PromptInterface {
|
|
|
786
841
|
}
|
|
787
842
|
|
|
788
843
|
/**
|
|
789
|
-
*
|
|
844
|
+
* Holds the default glyphs {@link DEFAULT_PROMPT_THEME} assembles its `icons` from. Read only when
|
|
790
845
|
* the default theme is assembled; a view reads its resolved theme and never this constant. Frozen.
|
|
791
846
|
*
|
|
792
847
|
* @remarks
|
|
@@ -805,14 +860,14 @@ export declare const PROMPT_ICONS: Readonly<{
|
|
|
805
860
|
}>;
|
|
806
861
|
|
|
807
862
|
/**
|
|
808
|
-
*
|
|
863
|
+
* Holds every {@link import('./types.js').PromptRole}, in one frozen list — the role axis's source of
|
|
809
864
|
* truth. {@link import('./helpers.js').createPromptTheme} walks it to merge a partial theme, and
|
|
810
865
|
* a consumer building a complete role map reads it rather than retyping every name.
|
|
811
866
|
*/
|
|
812
867
|
export declare const PROMPT_ROLES: readonly PromptRole[];
|
|
813
868
|
|
|
814
869
|
/**
|
|
815
|
-
*
|
|
870
|
+
* Implements the SSE form bridge. It ingests serialized forms from a remote broker, renders them through a
|
|
816
871
|
* local terminal, and posts answers back without blocking the event stream.
|
|
817
872
|
*
|
|
818
873
|
* @remarks
|
|
@@ -821,12 +876,12 @@ export declare const PROMPT_ROLES: readonly PromptRole[];
|
|
|
821
876
|
* {@link disconnect} deliberately stopped it.
|
|
822
877
|
* - **Ingest + render.** Each `pending` envelope passes through `isPendingForm`, Form's `parseForm`,
|
|
823
878
|
* and terminal's `sanitizeSchema`, then enters a serial render queue. The SSE reader never awaits
|
|
824
|
-
* that queue, so `expire` and `
|
|
879
|
+
* that queue, so `expire` and `destroy` remain live while a person is answering.
|
|
825
880
|
* - **Safe local form.** The rendering copy omits every wire `pattern`, because Form compiles a
|
|
826
881
|
* pattern during local evaluation. The broker's parked form retains it and remains authoritative.
|
|
827
882
|
* - **Refusal retry.** A structured `rejected` response seeds a new rendering form with the values
|
|
828
883
|
* just submitted, applies every {@link FieldError} through `invalidate`, and asks again. No retry
|
|
829
|
-
* counter truncates the loop; acceptance, expiry, and
|
|
884
|
+
* counter truncates the loop; acceptance, expiry, and the broker's own teardown are its bounds.
|
|
830
885
|
* - **Replay safety.** A replayed id is skipped while it is queued, rendering, or posting. Once an
|
|
831
886
|
* attempt ends, a later delivery of that id may be rendered again.
|
|
832
887
|
*
|
|
@@ -851,7 +906,7 @@ export declare class PromptClient implements PromptClientInterface {
|
|
|
851
906
|
}
|
|
852
907
|
|
|
853
908
|
/**
|
|
854
|
-
*
|
|
909
|
+
* Declares the client's event map — lean, errors `unknown`, no listener-error event.
|
|
855
910
|
*
|
|
856
911
|
* @remarks
|
|
857
912
|
* - `connect` — the SSE stream opened.
|
|
@@ -869,7 +924,7 @@ export declare type PromptClientEventMap = {
|
|
|
869
924
|
};
|
|
870
925
|
|
|
871
926
|
/**
|
|
872
|
-
*
|
|
927
|
+
* Declares the SSE form BRIDGE — the client-side counterpart to {@link PromptInterface}. It receives
|
|
873
928
|
* serialized {@link PendingForm} records from a remote broker, rebuilds each schema locally, drives
|
|
874
929
|
* it through a {@link TerminalInterface}, and POSTs the answer back, so a human at this machine
|
|
875
930
|
* answers forms a broker parked elsewhere.
|
|
@@ -897,7 +952,7 @@ export declare interface PromptClientInterface {
|
|
|
897
952
|
}
|
|
898
953
|
|
|
899
954
|
/**
|
|
900
|
-
*
|
|
955
|
+
* Configures {@link import('./factories.js').createPromptClient} and the
|
|
901
956
|
* {@link PromptClientInterface}.
|
|
902
957
|
*
|
|
903
958
|
* @remarks
|
|
@@ -928,7 +983,7 @@ export declare interface PromptClientOptions {
|
|
|
928
983
|
}
|
|
929
984
|
|
|
930
985
|
/**
|
|
931
|
-
*
|
|
986
|
+
* Declares the broker's event map — lean, errors `unknown`, no listener-error event.
|
|
932
987
|
*
|
|
933
988
|
* @remarks
|
|
934
989
|
* - `pending` — a form was parked; a transport forwards the wire record to remote clients.
|
|
@@ -941,11 +996,8 @@ export declare type PromptEventMap = {
|
|
|
941
996
|
readonly expire: readonly [id: string];
|
|
942
997
|
};
|
|
943
998
|
|
|
944
|
-
/** The styled prompt-message header (`? message`) — the leading line every active prompt view shares, themed by the `question` + `message` roles. */
|
|
945
|
-
export declare function promptHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
|
|
946
|
-
|
|
947
999
|
/**
|
|
948
|
-
*
|
|
1000
|
+
* Names one glyph slot a rendered field draws — the icon axis of a {@link PromptTheme}. A named value
|
|
949
1001
|
* set, not a toggle, so it stays a union.
|
|
950
1002
|
*
|
|
951
1003
|
* @remarks
|
|
@@ -958,7 +1010,7 @@ export declare function promptHeader(styler: StylerInterface, theme: PromptTheme
|
|
|
958
1010
|
export declare type PromptIcon = 'question' | 'pointer' | 'dot' | 'selected' | 'checked' | 'unchecked' | 'success' | 'error';
|
|
959
1011
|
|
|
960
1012
|
/**
|
|
961
|
-
*
|
|
1013
|
+
* Declares the headless form BROKER — parks a live form until somebody elsewhere answers it. The headless
|
|
962
1014
|
* arm of the local-TTY / headless / remote trio: there is no terminal here, so a transport forwards
|
|
963
1015
|
* each `pending` record to whoever can answer, and {@link answer} drives the parked form to
|
|
964
1016
|
* settlement.
|
|
@@ -1001,7 +1053,7 @@ export declare interface PromptInterface {
|
|
|
1001
1053
|
}
|
|
1002
1054
|
|
|
1003
1055
|
/**
|
|
1004
|
-
*
|
|
1056
|
+
* Configures {@link import('./factories.js').createPrompt} and every {@link PromptInterface}
|
|
1005
1057
|
* broker, including one a {@link TerminalManagerInterface} mounts per endpoint.
|
|
1006
1058
|
*
|
|
1007
1059
|
* @remarks
|
|
@@ -1025,7 +1077,7 @@ export declare interface PromptOptions {
|
|
|
1025
1077
|
}
|
|
1026
1078
|
|
|
1027
1079
|
/**
|
|
1028
|
-
*
|
|
1080
|
+
* Names one styling slot a rendered field paints through — the semantic axis of a {@link PromptTheme}. A
|
|
1029
1081
|
* role says what a fragment MEANS; the theme decides what that meaning looks like, so a consumer
|
|
1030
1082
|
* re-maps styled output by naming roles rather than reimplementing a renderer.
|
|
1031
1083
|
*
|
|
@@ -1048,14 +1100,14 @@ export declare interface PromptOptions {
|
|
|
1048
1100
|
export declare type PromptRole = 'question' | 'pointer' | 'message' | 'content' | 'success' | 'error' | 'selected' | 'focus' | 'hint' | 'muted' | 'description';
|
|
1049
1101
|
|
|
1050
1102
|
/**
|
|
1051
|
-
*
|
|
1103
|
+
* Names where one field's reducer stands after a key. `active`: keep asking, because the key was
|
|
1052
1104
|
* consumed or the answer was refused. `submit`: the field resolved with its `value`. `cancel`: the
|
|
1053
1105
|
* user aborted with ctrl-c. Names its axis, never `kind`.
|
|
1054
1106
|
*/
|
|
1055
1107
|
export declare type PromptStatus = 'active' | 'submit' | 'cancel';
|
|
1056
1108
|
|
|
1057
1109
|
/**
|
|
1058
|
-
*
|
|
1110
|
+
* Represents the result of one reducer step — the next `state`, the rendered `view`, the `status`, and, on
|
|
1059
1111
|
* `submit`, the resolved `value`. The whole contract between a pure reducer and the impure driver:
|
|
1060
1112
|
* the driver applies the next `state`, writes the `view`, and reads `value` on `submit`.
|
|
1061
1113
|
*
|
|
@@ -1078,7 +1130,7 @@ export declare interface PromptStep<T, S> {
|
|
|
1078
1130
|
}
|
|
1079
1131
|
|
|
1080
1132
|
/**
|
|
1081
|
-
*
|
|
1133
|
+
* Represents a resolved PRESENTATION — the glyph for every {@link PromptIcon} and the console {@link Style}
|
|
1082
1134
|
* for every {@link PromptRole}. Plain JSON data with no functions, so it crosses the wire with the
|
|
1083
1135
|
* form it decorates. Built by {@link import('./helpers.js').createPromptTheme}.
|
|
1084
1136
|
*
|
|
@@ -1095,7 +1147,7 @@ export declare interface PromptTheme {
|
|
|
1095
1147
|
}
|
|
1096
1148
|
|
|
1097
1149
|
/**
|
|
1098
|
-
*
|
|
1150
|
+
* Represents the PARTIAL {@link PromptTheme} an option bag carries — every icon and every role is optional,
|
|
1099
1151
|
* and {@link import('./helpers.js').createPromptTheme} merges what is supplied over
|
|
1100
1152
|
* {@link import('./constants.js').DEFAULT_PROMPT_THEME} leaf by leaf. Supplying one icon or one
|
|
1101
1153
|
* role leaves every other slot at its default.
|
|
@@ -1105,11 +1157,172 @@ export declare interface PromptThemeOptions {
|
|
|
1105
1157
|
readonly roles?: Readonly<Partial<Record<PromptRole, Style>>>;
|
|
1106
1158
|
}
|
|
1107
1159
|
|
|
1108
|
-
/**
|
|
1160
|
+
/**
|
|
1161
|
+
* Advances a checkbox prompt by one {@link KeyEvent} — the pure
|
|
1162
|
+
* `(state, key) → PromptStep<readonly string[]>` reducer. `up` / `down` (and `k` / `j`) move the
|
|
1163
|
+
* focus (wrapping); `space` toggles the focused index in the checked set; return submits the
|
|
1164
|
+
* checked values in choice order; ctrl-c cancels. The form applies selection-count rules.
|
|
1165
|
+
*
|
|
1166
|
+
* @param state - The checkbox field's current reducer state
|
|
1167
|
+
* @param key - The decoded keypress to apply
|
|
1168
|
+
* @returns The next step — the state, the rendered view, the status, and the ticked values on submit
|
|
1169
|
+
*/
|
|
1170
|
+
export declare function reduceCheckbox(state: CheckboxState, key: KeyEvent): PromptStep<readonly string[], CheckboxState>;
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Advances a confirm prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<boolean>`
|
|
1174
|
+
* reducer. `y` / `Y` submits `true`, `n` / `N` submits `false`, return on an empty line submits
|
|
1175
|
+
* the `default`, ctrl-c cancels; any other key is ignored (stays active).
|
|
1176
|
+
*
|
|
1177
|
+
* @param state - The confirm field's current reducer state
|
|
1178
|
+
* @param key - The decoded keypress to apply
|
|
1179
|
+
* @returns The next step — the state, the rendered view, the status, and the answer on submit
|
|
1180
|
+
*/
|
|
1181
|
+
export declare function reduceConfirm(state: ConfirmState, key: KeyEvent): PromptStep<boolean, ConfirmState>;
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Advances an editor prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
|
|
1185
|
+
* reducer. Printable characters extend the current line; backspace shrinks it; return commits the
|
|
1186
|
+
* current line and starts a fresh one; ctrl-d FINISHES (joining all lines, falling back to the
|
|
1187
|
+
* default when empty); ctrl-c cancels. The form validates the candidate after the driver fills it.
|
|
1188
|
+
*
|
|
1189
|
+
* @param state - The editor field's current reducer state
|
|
1190
|
+
* @param key - The decoded keypress to apply
|
|
1191
|
+
* @returns The next step — the state, the rendered view, the status, and the joined text on submit
|
|
1192
|
+
*/
|
|
1193
|
+
export declare function reduceEditor(state: EditorState, key: KeyEvent): PromptStep<string, EditorState>;
|
|
1194
|
+
|
|
1195
|
+
/**
|
|
1196
|
+
* Advances an input prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
|
|
1197
|
+
* reducer. Printable characters extend the value; backspace shrinks it; ctrl-u clears it; ctrl-c
|
|
1198
|
+
* cancels; return produces the candidate value, with an empty line falling back to the default.
|
|
1199
|
+
*
|
|
1200
|
+
* @param state - The text field's current reducer state
|
|
1201
|
+
* @param key - The decoded keypress to apply
|
|
1202
|
+
* @returns The next step — the new state, the rendered view, the status, and the value on submit
|
|
1203
|
+
*/
|
|
1204
|
+
export declare function reduceInput(state: InputState, key: KeyEvent): PromptStep<string, InputState>;
|
|
1205
|
+
|
|
1206
|
+
/**
|
|
1207
|
+
* Advances a password prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
|
|
1208
|
+
* reducer. Identical line-editing to {@link reduceInput} (printable extends, backspace shrinks,
|
|
1209
|
+
* ctrl-u clears, ctrl-c cancels) but the view masks the value. Return produces the candidate value.
|
|
1210
|
+
*
|
|
1211
|
+
* @param state - The password field's current reducer state
|
|
1212
|
+
* @param key - The decoded keypress to apply
|
|
1213
|
+
* @returns The next step — the new state, the masked view, the status, and the value on submit
|
|
1214
|
+
*/
|
|
1215
|
+
export declare function reducePassword(state: PasswordState, key: KeyEvent): PromptStep<string, PasswordState>;
|
|
1216
|
+
|
|
1217
|
+
/**
|
|
1218
|
+
* Advances a select prompt by one {@link KeyEvent} — the pure `(state, key) → PromptStep<string>`
|
|
1219
|
+
* reducer. `up` / `down` (and `k` / `j`) move the focus, WRAPPING at the ends; return submits the
|
|
1220
|
+
* focused choice's `value`; ctrl-c cancels. An empty choice list can never submit (a higher layer
|
|
1221
|
+
* guards against it); any other key is ignored.
|
|
1222
|
+
*
|
|
1223
|
+
* @param state - The select field's current reducer state
|
|
1224
|
+
* @param key - The decoded keypress to apply
|
|
1225
|
+
* @returns The next step — the state, the rendered view, the status, and the chosen value on submit
|
|
1226
|
+
*/
|
|
1227
|
+
export declare function reduceSelect(state: SelectState, key: KeyEvent): PromptStep<string, SelectState>;
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Renders a checkbox-field key state as a multi-line styled view.
|
|
1231
|
+
*
|
|
1232
|
+
* @param state - The checkbox field's current reducer state
|
|
1233
|
+
* @returns The rendered view — the header, one box per choice, and the selected count
|
|
1234
|
+
*/
|
|
1235
|
+
export declare function renderCheckboxView(state: CheckboxState): string;
|
|
1236
|
+
|
|
1237
|
+
/**
|
|
1238
|
+
* Renders a confirm-field key state as a styled view. The selected role paints the default letter.
|
|
1239
|
+
*
|
|
1240
|
+
* @param state - The confirm field's current reducer state
|
|
1241
|
+
* @returns The rendered view — the header and the yes/no group with the default capitalized
|
|
1242
|
+
*/
|
|
1243
|
+
export declare function renderConfirmView(state: ConfirmState): string;
|
|
1244
|
+
|
|
1245
|
+
/**
|
|
1246
|
+
* Renders an editor-field key state as a multi-line styled view with its finish hint.
|
|
1247
|
+
*
|
|
1248
|
+
* @param state - The editor field's current reducer state
|
|
1249
|
+
* @returns The rendered view — the hinted header, the committed lines, and the line in progress
|
|
1250
|
+
*/
|
|
1251
|
+
export declare function renderEditorView(state: EditorState): string;
|
|
1252
|
+
|
|
1253
|
+
/**
|
|
1254
|
+
* Renders the styled failure line (`✖ message`) a form driver appends for a refused field.
|
|
1255
|
+
*
|
|
1256
|
+
* @param styler - The console styler that renders each role
|
|
1257
|
+
* @param theme - The resolved prompt theme
|
|
1258
|
+
* @param message - The failure text, normally the field's label and the reason
|
|
1259
|
+
* @returns The rendered failure line
|
|
1260
|
+
*/
|
|
1261
|
+
export declare function renderErrorLine(styler: StylerInterface, theme: PromptTheme, message: string): string;
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Renders a question header followed by a key hint painted with the `hint` role, or the header
|
|
1265
|
+
* alone when no hint is supplied.
|
|
1266
|
+
*
|
|
1267
|
+
* @param styler - The console styler that renders each role
|
|
1268
|
+
* @param theme - The resolved prompt theme
|
|
1269
|
+
* @param message - The prompt's question text
|
|
1270
|
+
* @param hint - The optional key hint to append
|
|
1271
|
+
* @returns The rendered header with the optional hint
|
|
1272
|
+
*/
|
|
1273
|
+
export declare function renderHintedHeader(styler: StylerInterface, theme: PromptTheme, message: string, hint?: string): string;
|
|
1274
|
+
|
|
1275
|
+
/**
|
|
1276
|
+
* Renders a text-field key state as a styled view.
|
|
1277
|
+
*
|
|
1278
|
+
* @param state - The text field's current reducer state
|
|
1279
|
+
* @returns The rendered single-line view — header, pointer, and the typed value or the default
|
|
1280
|
+
*/
|
|
1281
|
+
export declare function renderInputView(state: InputState): string;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Renders a password-field key state as a styled view.
|
|
1285
|
+
*
|
|
1286
|
+
* @param state - The password field's current reducer state
|
|
1287
|
+
* @returns The rendered view, with the mask repeated in place of the typed value
|
|
1288
|
+
*/
|
|
1289
|
+
export declare function renderPasswordView(state: PasswordState): string;
|
|
1290
|
+
|
|
1291
|
+
/**
|
|
1292
|
+
* Renders the styled question header (`? message`) — the leading line every active prompt view
|
|
1293
|
+
* shares, themed by the `question` + `message` roles.
|
|
1294
|
+
*
|
|
1295
|
+
* @param styler - The console styler that renders each role
|
|
1296
|
+
* @param theme - The resolved prompt theme
|
|
1297
|
+
* @param message - The prompt's question text
|
|
1298
|
+
* @returns The rendered question header
|
|
1299
|
+
*/
|
|
1300
|
+
export declare function renderPromptHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
|
|
1301
|
+
|
|
1302
|
+
/**
|
|
1303
|
+
* Renders a select-field key state as a multi-line styled view.
|
|
1304
|
+
*
|
|
1305
|
+
* @param state - The select field's current reducer state
|
|
1306
|
+
* @returns The rendered view — the header, then one row per choice with the focused row marked
|
|
1307
|
+
*/
|
|
1308
|
+
export declare function renderSelectView(state: SelectState): string;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Renders the styled submit line (`✔ message`) — the committed header an interactive prompt shows
|
|
1312
|
+
* after it resolves, themed by the `success` + `message` roles.
|
|
1313
|
+
*
|
|
1314
|
+
* @param styler - The console styler that renders each role
|
|
1315
|
+
* @param theme - The resolved prompt theme
|
|
1316
|
+
* @param message - The settled prompt's question text
|
|
1317
|
+
* @returns The rendered committed header
|
|
1318
|
+
*/
|
|
1319
|
+
export declare function renderSubmitHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
|
|
1320
|
+
|
|
1321
|
+
/** Names the carriage return byte (`\r`, U+000D) — Enter on most terminals. */
|
|
1109
1322
|
export declare const RETURN: string;
|
|
1110
1323
|
|
|
1111
1324
|
/**
|
|
1112
|
-
*
|
|
1325
|
+
* Sanitizes text for one single-line display slot. Composes console's ANSI {@link strip} and C0
|
|
1113
1326
|
* {@link stripControls} passes with removal of tab, line feed, and carriage return.
|
|
1114
1327
|
*
|
|
1115
1328
|
* @param text - The text to sanitize for a glyph or hint slot
|
|
@@ -1123,7 +1336,7 @@ export declare const RETURN: string;
|
|
|
1123
1336
|
export declare function sanitizeDisplayText(text: string): string;
|
|
1124
1337
|
|
|
1125
1338
|
/**
|
|
1126
|
-
*
|
|
1339
|
+
* Sanitizes every terminal-readable string in a parsed form schema.
|
|
1127
1340
|
*
|
|
1128
1341
|
* @remarks
|
|
1129
1342
|
* Display strings pass through {@link sanitizeDisplayText}: labels, help, placeholders, masks,
|
|
@@ -1145,7 +1358,7 @@ export declare function sanitizeDisplayText(text: string): string;
|
|
|
1145
1358
|
export declare function sanitizeSchema(schema: FormSchema): FormSchema;
|
|
1146
1359
|
|
|
1147
1360
|
/**
|
|
1148
|
-
*
|
|
1361
|
+
* Sanitizes every glyph a wire-supplied {@link PromptThemeOptions} carries for a single-line display
|
|
1149
1362
|
* slot. Only the icons need it: a role is guard-narrowed to a console {@link Style}, whose colors
|
|
1150
1363
|
* and attributes are fixed name sets, so no role can carry a byte a terminal would act on.
|
|
1151
1364
|
*
|
|
@@ -1155,20 +1368,26 @@ export declare function sanitizeSchema(schema: FormSchema): FormSchema;
|
|
|
1155
1368
|
export declare function sanitizeThemeIcons(theme: PromptThemeOptions): PromptThemeOptions;
|
|
1156
1369
|
|
|
1157
1370
|
/**
|
|
1158
|
-
*
|
|
1159
|
-
*
|
|
1160
|
-
*
|
|
1161
|
-
*
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
export declare
|
|
1371
|
+
* Represents the immutable state a select field's reducer carries.
|
|
1372
|
+
*
|
|
1373
|
+
* @remarks
|
|
1374
|
+
* - `message` — the sanitized label the header renders.
|
|
1375
|
+
* - `choices` — the choices the list offers, in declared order.
|
|
1376
|
+
* - `styler` / `theme` — the console styler and the resolved {@link PromptTheme}.
|
|
1377
|
+
* - `focused` — the index the cursor sits on, pre-placed on the declared default.
|
|
1378
|
+
*/
|
|
1379
|
+
export declare interface SelectState {
|
|
1380
|
+
readonly message: string;
|
|
1381
|
+
readonly choices: readonly FieldChoice[];
|
|
1382
|
+
readonly styler: StylerInterface;
|
|
1383
|
+
readonly theme: PromptTheme;
|
|
1384
|
+
readonly focused: number;
|
|
1385
|
+
}
|
|
1167
1386
|
|
|
1168
1387
|
/**
|
|
1169
|
-
*
|
|
1388
|
+
* Holds the exact escape SEQUENCE → canonical key NAME table {@link import('./helpers.js').parseKey}
|
|
1170
1389
|
* consults for the navigation / editing keys. Covers BOTH the CSI form (`ESC[A`…) and the SS3
|
|
1171
|
-
* form (`ESCOA`…) of the
|
|
1390
|
+
* form (`ESCOA`…) of the arrows, plus the `home` / `end` / `delete` CSI sequences (with
|
|
1172
1391
|
* their numeric-tilde variants). The source of truth for the multi-byte key decode; frozen.
|
|
1173
1392
|
*
|
|
1174
1393
|
* @remarks
|
|
@@ -1179,20 +1398,34 @@ export declare function selectView(state: ReturnType<typeof createSelectState>):
|
|
|
1179
1398
|
*/
|
|
1180
1399
|
export declare const SEQUENCE_NAMES: Readonly<Record<string, string>>;
|
|
1181
1400
|
|
|
1182
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Serializes the {@link WireEvent} a broker or manager sends when it is going away.
|
|
1403
|
+
*
|
|
1404
|
+
* @returns The `destroy` frame, whose `data` is empty because the signal carries no payload
|
|
1405
|
+
*/
|
|
1406
|
+
export declare function serializeDestroy(): WireEvent;
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Serializes a parked prompt's expiry or release into a {@link WireEvent}.
|
|
1410
|
+
*
|
|
1411
|
+
* @param id - The id of the parked form that expired or was released
|
|
1412
|
+
* @returns The `expire` frame, carrying the JSON-stringified `{ id }` payload as `data`
|
|
1413
|
+
*/
|
|
1183
1414
|
export declare function serializeExpire(id: string): WireEvent;
|
|
1184
1415
|
|
|
1185
|
-
/**
|
|
1416
|
+
/**
|
|
1417
|
+
* Serializes a parked {@link PendingForm} into a {@link WireEvent}.
|
|
1418
|
+
*
|
|
1419
|
+
* @param form - The parked form's wire-safe record
|
|
1420
|
+
* @returns The `pending` frame — the JSON-stringified record as `data`, and the form's own `id`
|
|
1421
|
+
*/
|
|
1186
1422
|
export declare function serializePending(form: PendingForm): WireEvent;
|
|
1187
1423
|
|
|
1188
|
-
/**
|
|
1189
|
-
export declare function serializeShutdown(): WireEvent;
|
|
1190
|
-
|
|
1191
|
-
/** Space (U+0020). */
|
|
1424
|
+
/** Names the space byte (U+0020). */
|
|
1192
1425
|
export declare const SPACE = " ";
|
|
1193
1426
|
|
|
1194
1427
|
/**
|
|
1195
|
-
*
|
|
1428
|
+
* Sets the maximum number of characters the {@link import('./types.js').PromptClientInterface} lets its
|
|
1196
1429
|
* SSE parser buffer before treating the stream as hostile — 1 MiB, comfortably above any
|
|
1197
1430
|
* legitimate prompt payload. Passed as the `limit` to `createSSEParser` so an unterminated
|
|
1198
1431
|
* or oversized `data:` field cannot grow the buffer without bound (a memory-exhaustion guard).
|
|
@@ -1200,37 +1433,35 @@ export declare const SPACE = " ";
|
|
|
1200
1433
|
export declare const SSE_BUFFER_LIMIT = 1048576;
|
|
1201
1434
|
|
|
1202
1435
|
/**
|
|
1203
|
-
*
|
|
1436
|
+
* Holds the SSE `event:` names the broker emits and the {@link import('./types.js').PromptClientInterface}
|
|
1204
1437
|
* dispatches on. Frozen; the source of truth for the wire event vocabulary.
|
|
1205
1438
|
*
|
|
1206
1439
|
* @remarks
|
|
1207
1440
|
* - `pending` — a serialized {@link import('./types.js').PendingForm} to dispatch and answer.
|
|
1208
1441
|
* - `expire` — an `{ id }` payload: the broker expired or released a parked prompt (the client drops it).
|
|
1209
|
-
* - `
|
|
1442
|
+
* - `destroy` — the broker is going away; the client disconnects (no auto-reconnect) but stays reusable.
|
|
1210
1443
|
*/
|
|
1211
1444
|
export declare const SSE_EVENTS: Readonly<{
|
|
1212
1445
|
pending: "pending";
|
|
1213
1446
|
expire: "expire";
|
|
1214
|
-
|
|
1447
|
+
destroy: "destroy";
|
|
1215
1448
|
}>;
|
|
1216
1449
|
|
|
1217
|
-
/**
|
|
1218
|
-
export declare function submitHeader(styler: StylerInterface, theme: PromptTheme, message: string): string;
|
|
1219
|
-
|
|
1220
|
-
/** Tab (`\t`, U+0009). */
|
|
1450
|
+
/** Names the tab byte (`\t`, U+0009). */
|
|
1221
1451
|
export declare const TAB: string;
|
|
1222
1452
|
|
|
1223
1453
|
/**
|
|
1224
|
-
*
|
|
1225
|
-
* endpoint's own broker, or `
|
|
1226
|
-
*
|
|
1454
|
+
* Explains why a {@link TerminalManagerInterface.answer} call refused — an {@link AnswerError} from the
|
|
1455
|
+
* endpoint's own broker, or `target` when no endpoint is mounted under that name. That is the same
|
|
1456
|
+
* condition {@link TerminalErrorCode}'s `TARGET` names for {@link TerminalManagerInterface.ask}, so
|
|
1457
|
+
* one word carries it on both doors. One discriminant, `reason`, across every member.
|
|
1227
1458
|
*/
|
|
1228
1459
|
export declare type TerminalAnswerError = AnswerError | {
|
|
1229
|
-
readonly reason: '
|
|
1460
|
+
readonly reason: 'target';
|
|
1230
1461
|
};
|
|
1231
1462
|
|
|
1232
1463
|
/**
|
|
1233
|
-
*
|
|
1464
|
+
* Represents the error the terminal surfaces for its own refusals: parking on a destroyed or full broker, an
|
|
1234
1465
|
* unusable driver stream, a manager routing fault, or a ctrl-c cancellation. A parked form's own
|
|
1235
1466
|
* lifecycle failures reject through the form's `answer` with the form package's error, never with
|
|
1236
1467
|
* this one.
|
|
@@ -1241,15 +1472,22 @@ export declare type TerminalAnswerError = AnswerError | {
|
|
|
1241
1472
|
* a caught value with {@link isTerminalError} and branch on `error.code`.
|
|
1242
1473
|
*/
|
|
1243
1474
|
export declare class TerminalError extends Error {
|
|
1244
|
-
/**
|
|
1475
|
+
/** Holds the machine-readable condition — see {@link TerminalErrorCode}. */
|
|
1245
1476
|
readonly code: TerminalErrorCode;
|
|
1246
|
-
/**
|
|
1477
|
+
/** Holds an optional context bag naming the offending values — see the class {@link TerminalError remarks}. */
|
|
1247
1478
|
readonly context?: Readonly<Record<string, unknown>>;
|
|
1479
|
+
/**
|
|
1480
|
+
* Builds one terminal refusal.
|
|
1481
|
+
*
|
|
1482
|
+
* @param code - The machine-readable {@link TerminalErrorCode} a caller branches on
|
|
1483
|
+
* @param message - The human-readable reason
|
|
1484
|
+
* @param context - The optional bag naming the offending values — see the class {@link TerminalError remarks}
|
|
1485
|
+
*/
|
|
1248
1486
|
constructor(code: TerminalErrorCode, message: string, context?: Readonly<Record<string, unknown>>);
|
|
1249
1487
|
}
|
|
1250
1488
|
|
|
1251
1489
|
/**
|
|
1252
|
-
*
|
|
1490
|
+
* Names the machine-readable condition carried by a {@link import('./errors.js').TerminalError} — the
|
|
1253
1491
|
* axis a `catch` branches on. Names its axis (the failure condition), never `kind`.
|
|
1254
1492
|
*
|
|
1255
1493
|
* @remarks
|
|
@@ -1272,7 +1510,7 @@ export declare class TerminalError extends Error {
|
|
|
1272
1510
|
export declare type TerminalErrorCode = 'EXPIRE' | 'CANCEL' | 'DRIVER' | 'DEADLOCK' | 'TARGET' | 'LIMIT' | 'DESTROYED';
|
|
1273
1511
|
|
|
1274
1512
|
/**
|
|
1275
|
-
*
|
|
1513
|
+
* Declares the contract for asking a form of a human at a keyboard — one method, because a form is one
|
|
1276
1514
|
* question however many fields it holds. The server `Terminal` implements it against a real TTY;
|
|
1277
1515
|
* a {@link PromptClientInterface} holds one to answer forms parked elsewhere.
|
|
1278
1516
|
*
|
|
@@ -1292,10 +1530,9 @@ export declare interface TerminalInterface {
|
|
|
1292
1530
|
}
|
|
1293
1531
|
|
|
1294
1532
|
/**
|
|
1295
|
-
*
|
|
1296
|
-
*
|
|
1297
|
-
*
|
|
1298
|
-
* asks.
|
|
1533
|
+
* Registers named {@link PromptInterface} brokers (one per endpoint), so several parties can
|
|
1534
|
+
* `ask` forms of each other by NAME with a `from` → `to` attribution edge on every parked form,
|
|
1535
|
+
* and a transitive DEADLOCK check across all in-flight asks.
|
|
1299
1536
|
*
|
|
1300
1537
|
* @remarks
|
|
1301
1538
|
* - **Registry.** `add(name, options?)` mints (or, if `name` is already mounted, returns the
|
|
@@ -1310,7 +1547,7 @@ export declare interface TerminalInterface {
|
|
|
1310
1547
|
* - **Durable open / save.** `open(name)` restores an EMPTY broker from the `store` (parked
|
|
1311
1548
|
* Promises are process-bound and never resurrected); `save(name)` persists the endpoint's
|
|
1312
1549
|
* configured `timeout`.
|
|
1313
|
-
* - **Removal.** `remove` drops one endpoint, a batch (
|
|
1550
|
+
* - **Removal.** `remove` drops one endpoint, a batch (the array overload declared FIRST), or every
|
|
1314
1551
|
* endpoint when called without an argument. It destroys each broker, which expires every form
|
|
1315
1552
|
* still parked on it. `destroy` is idempotent.
|
|
1316
1553
|
*
|
|
@@ -1330,7 +1567,7 @@ export declare class TerminalManager implements TerminalManagerInterface {
|
|
|
1330
1567
|
get emitter(): EmitterInterface<TerminalManagerEventMap>;
|
|
1331
1568
|
get count(): number;
|
|
1332
1569
|
terminal(name: string): PromptInterface | undefined;
|
|
1333
|
-
terminals(): readonly
|
|
1570
|
+
terminals(): readonly PromptInterface[];
|
|
1334
1571
|
add(name: string, options?: PromptOptions): PromptInterface;
|
|
1335
1572
|
ask(from: string, to: string, form: FormInterface): Promise<FormValues>;
|
|
1336
1573
|
pending(): readonly PendingForm[];
|
|
@@ -1345,7 +1582,7 @@ export declare class TerminalManager implements TerminalManagerInterface {
|
|
|
1345
1582
|
}
|
|
1346
1583
|
|
|
1347
1584
|
/**
|
|
1348
|
-
*
|
|
1585
|
+
* Declares the manager's event map — the name-attributed re-emission of every mounted broker's events, so a
|
|
1349
1586
|
* caller subscribes once for ALL endpoints instead of once per broker.
|
|
1350
1587
|
*
|
|
1351
1588
|
* @remarks
|
|
@@ -1360,24 +1597,27 @@ export declare type TerminalManagerEventMap = {
|
|
|
1360
1597
|
};
|
|
1361
1598
|
|
|
1362
1599
|
/**
|
|
1363
|
-
*
|
|
1364
|
-
*
|
|
1365
|
-
*
|
|
1600
|
+
* Declares a registry of named {@link PromptInterface} brokers, one per endpoint, so several
|
|
1601
|
+
* parties (agents, tools, humans) can ask forms of each other BY NAME, attributed with a
|
|
1602
|
+
* `from` → `to` edge on every parked record.
|
|
1366
1603
|
*
|
|
1367
1604
|
* @remarks
|
|
1368
1605
|
* - **Accessors.** `terminal(name)` looks up one endpoint's broker; `terminals()` lists every
|
|
1369
|
-
* mounted
|
|
1606
|
+
* mounted broker, in insertion order. `terminals()` returns brokers, not keys; a name is an
|
|
1607
|
+
* argument the `terminal`, `add`, `ask`, `pending`, `answer`, `open`, `save`, and `remove`
|
|
1608
|
+
* methods take.
|
|
1370
1609
|
* - **`add`** mints, or returns, the broker for `name`. Idempotent; it never clobbers a live
|
|
1371
1610
|
* endpoint.
|
|
1372
|
-
* - **`ask`** is the attributed convenience: it parks `form` from `from` to `to
|
|
1373
|
-
*
|
|
1611
|
+
* - **`ask`** is the attributed convenience: it parks `form` from `from` to `to` and resolves with
|
|
1612
|
+
* the settled values. It never mounts `to` — an unmounted target rejects with a
|
|
1613
|
+
* {@link import('./errors.js').TerminalError} coded `TARGET`, so `add` the endpoint first.
|
|
1374
1614
|
* - **`pending()`** lists every endpoint's parked records; `pending(to)` scopes to one endpoint.
|
|
1375
1615
|
* - **`answer`** routes to the named endpoint's broker.
|
|
1376
1616
|
* - **`open`** restores, or returns the live, broker for `name` from the `store`.
|
|
1377
1617
|
* - **`save`** persists an endpoint's config snapshot; false when there is no store, or `name` is
|
|
1378
1618
|
* unknown.
|
|
1379
|
-
* - **Batch `remove`.** The array overload is declared FIRST: `remove(names)` removes
|
|
1380
|
-
* endpoint and reports
|
|
1619
|
+
* - **Batch `remove`.** The array overload is declared FIRST: `remove(names)` removes every listed
|
|
1620
|
+
* endpoint and reports true only when all of them were mounted; `remove(name)` removes one;
|
|
1381
1621
|
* `remove()` removes every endpoint without destroying the manager.
|
|
1382
1622
|
* - **`destroy`** tears down every broker, then the manager's own emitter.
|
|
1383
1623
|
*/
|
|
@@ -1385,7 +1625,7 @@ export declare interface TerminalManagerInterface {
|
|
|
1385
1625
|
readonly emitter: EmitterInterface<TerminalManagerEventMap>;
|
|
1386
1626
|
readonly count: number;
|
|
1387
1627
|
terminal(name: string): PromptInterface | undefined;
|
|
1388
|
-
terminals(): readonly
|
|
1628
|
+
terminals(): readonly PromptInterface[];
|
|
1389
1629
|
add(name: string, options?: PromptOptions): PromptInterface;
|
|
1390
1630
|
ask(from: string, to: string, form: FormInterface): Promise<FormValues>;
|
|
1391
1631
|
pending(): readonly PendingForm[];
|
|
@@ -1400,7 +1640,7 @@ export declare interface TerminalManagerInterface {
|
|
|
1400
1640
|
}
|
|
1401
1641
|
|
|
1402
1642
|
/**
|
|
1403
|
-
*
|
|
1643
|
+
* Configures {@link import('./factories.js').createTerminalManager} and the
|
|
1404
1644
|
* {@link TerminalManagerInterface}.
|
|
1405
1645
|
*
|
|
1406
1646
|
* @remarks
|
|
@@ -1419,7 +1659,7 @@ export declare interface TerminalManagerOptions {
|
|
|
1419
1659
|
}
|
|
1420
1660
|
|
|
1421
1661
|
/**
|
|
1422
|
-
*
|
|
1662
|
+
* Represents one endpoint's persisted CONFIG snapshot — `id` is the endpoint name and `timeout` its configured
|
|
1423
1663
|
* default. Parked forms are process-bound and are never resurrected, so `open` always restores an
|
|
1424
1664
|
* EMPTY broker.
|
|
1425
1665
|
*/
|
|
@@ -1429,7 +1669,7 @@ export declare interface TerminalSnapshot {
|
|
|
1429
1669
|
}
|
|
1430
1670
|
|
|
1431
1671
|
/**
|
|
1432
|
-
*
|
|
1672
|
+
* Represents one opaque persisted row — the shape a `TableInterface<TerminalSnapshotRow>`-backed store reads
|
|
1433
1673
|
* and writes. `snapshot` is narrowed with {@link import('./validators.js').isTerminalSnapshot} on
|
|
1434
1674
|
* read.
|
|
1435
1675
|
*/
|
|
@@ -1439,7 +1679,7 @@ export declare interface TerminalSnapshotRow {
|
|
|
1439
1679
|
}
|
|
1440
1680
|
|
|
1441
1681
|
/**
|
|
1442
|
-
*
|
|
1682
|
+
* Declares the point-access persistence seam for a {@link TerminalManagerInterface}'s endpoint configs.
|
|
1443
1683
|
* Every primitive is async; deleting an absent id is a no-op.
|
|
1444
1684
|
*/
|
|
1445
1685
|
export declare interface TerminalStoreInterface {
|
|
@@ -1448,26 +1688,33 @@ export declare interface TerminalStoreInterface {
|
|
|
1448
1688
|
delete(id: string): Promise<void>;
|
|
1449
1689
|
}
|
|
1450
1690
|
|
|
1451
|
-
/**
|
|
1452
|
-
export declare type
|
|
1691
|
+
/** Cancels a pending {@link TimerHandler} deadline — idempotent, safe to call after the timer fired. */
|
|
1692
|
+
export declare type TimerCancelFunction = () => void;
|
|
1453
1693
|
|
|
1454
1694
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
* {@link
|
|
1695
|
+
* Represents one injected timer — arms a deadline `callback` to fire after `ms`, returning a
|
|
1696
|
+
* {@link TimerCancelFunction} that cancels it. The broker's timeout seam: the default wraps the host
|
|
1457
1697
|
* `setTimeout` and `clearTimeout`; a test injects a deterministic timer that captures the callback
|
|
1458
1698
|
* and fires it on demand, with no real time and no global patching.
|
|
1459
1699
|
*/
|
|
1460
|
-
declare type TimerHandler_2 = (callback: () => void, ms: number) =>
|
|
1700
|
+
declare type TimerHandler_2 = (callback: () => void, ms: number) => TimerCancelFunction;
|
|
1461
1701
|
export { TimerHandler_2 as TimerHandler }
|
|
1462
1702
|
|
|
1463
|
-
/**
|
|
1703
|
+
/**
|
|
1704
|
+
* Toggles `index` in a readonly index list — copy-on-write, returning the new sorted-by-insertion
|
|
1705
|
+
* list.
|
|
1706
|
+
*
|
|
1707
|
+
* @param indices - The ticked indices, in tick order
|
|
1708
|
+
* @param index - The index to add when absent, or drop when present
|
|
1709
|
+
* @returns A new list carrying the toggled membership; the input is never mutated
|
|
1710
|
+
*/
|
|
1464
1711
|
export declare function toggleIndex(indices: readonly number[], index: number): readonly number[];
|
|
1465
1712
|
|
|
1466
1713
|
/**
|
|
1467
|
-
*
|
|
1714
|
+
* Represents one SSE-shaped wire frame — the `event` name, its already-stringified `data` payload, and an
|
|
1468
1715
|
* optional `id`. The transport-neutral shape {@link import('./helpers.js').serializePending},
|
|
1469
1716
|
* {@link import('./helpers.js').serializeExpire}, and
|
|
1470
|
-
* {@link import('./helpers.js').
|
|
1717
|
+
* {@link import('./helpers.js').serializeDestroy} build, with no `http` dependency.
|
|
1471
1718
|
*/
|
|
1472
1719
|
export declare interface WireEvent {
|
|
1473
1720
|
readonly event: string;
|