@sagmans/dsh-tui 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +126 -21
- package/lib/agent/model.d.ts +26 -0
- package/lib/agent/model.d.ts.map +1 -1
- package/lib/agent/model.js +41 -0
- package/lib/agent/model.js.map +1 -1
- package/lib/agent/status.d.ts +10 -0
- package/lib/agent/status.d.ts.map +1 -1
- package/lib/agent/status.js +2 -0
- package/lib/agent/status.js.map +1 -1
- package/lib/cards.d.ts +1 -1
- package/lib/cards.d.ts.map +1 -1
- package/lib/cards.js +4 -3
- package/lib/cards.js.map +1 -1
- package/lib/gates.d.ts +145 -2
- package/lib/gates.d.ts.map +1 -1
- package/lib/gates.js +335 -40
- package/lib/gates.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +383 -102
- package/lib/index.js.map +1 -1
- package/lib/input/actions.d.ts +136 -0
- package/lib/input/actions.d.ts.map +1 -0
- package/lib/input/actions.js +740 -0
- package/lib/input/actions.js.map +1 -0
- package/lib/input/keymap-settings.d.ts +21 -0
- package/lib/input/keymap-settings.d.ts.map +1 -0
- package/lib/input/keymap-settings.js +28 -0
- package/lib/input/keymap-settings.js.map +1 -0
- package/lib/input/keymap.d.ts +91 -0
- package/lib/input/keymap.d.ts.map +1 -0
- package/lib/input/keymap.js +170 -0
- package/lib/input/keymap.js.map +1 -0
- package/lib/input/match.d.ts +10 -0
- package/lib/input/match.d.ts.map +1 -0
- package/lib/input/match.js +83 -0
- package/lib/input/match.js.map +1 -0
- package/lib/input/submission.d.ts +6 -1
- package/lib/input/submission.d.ts.map +1 -1
- package/lib/input/submission.js +6 -2
- package/lib/input/submission.js.map +1 -1
- package/lib/input.d.ts +17 -0
- package/lib/input.d.ts.map +1 -0
- package/lib/input.js +27 -0
- package/lib/input.js.map +1 -0
- package/lib/keys-command.d.ts +16 -0
- package/lib/keys-command.d.ts.map +1 -0
- package/lib/keys-command.js +60 -0
- package/lib/keys-command.js.map +1 -0
- package/lib/queue.d.ts +6 -0
- package/lib/queue.d.ts.map +1 -0
- package/lib/queue.js +68 -0
- package/lib/queue.js.map +1 -0
- package/lib/settings-notice.d.ts +19 -0
- package/lib/settings-notice.d.ts.map +1 -0
- package/lib/settings-notice.js +30 -0
- package/lib/settings-notice.js.map +1 -0
- package/lib/theme-settings.d.ts +43 -8
- package/lib/theme-settings.d.ts.map +1 -1
- package/lib/theme-settings.js +66 -3
- package/lib/theme-settings.js.map +1 -1
- package/lib/theme-tokens.d.ts +4 -4
- package/lib/theme-tokens.d.ts.map +1 -1
- package/lib/theme-tokens.js +31 -5
- package/lib/theme-tokens.js.map +1 -1
- package/lib/ui/editor.d.ts +18 -1
- package/lib/ui/editor.d.ts.map +1 -1
- package/lib/ui/editor.js +80 -19
- package/lib/ui/editor.js.map +1 -1
- package/lib/ui/frame.d.ts +54 -0
- package/lib/ui/frame.d.ts.map +1 -0
- package/lib/ui/frame.js +79 -0
- package/lib/ui/frame.js.map +1 -0
- package/lib/ui/gate-input.d.ts +20 -0
- package/lib/ui/gate-input.d.ts.map +1 -0
- package/lib/ui/gate-input.js +96 -0
- package/lib/ui/gate-input.js.map +1 -0
- package/lib/ui/markdown.d.ts +11 -2
- package/lib/ui/markdown.d.ts.map +1 -1
- package/lib/ui/markdown.js +25 -6
- package/lib/ui/markdown.js.map +1 -1
- package/lib/ui/mermaid.d.ts +44 -0
- package/lib/ui/mermaid.d.ts.map +1 -0
- package/lib/ui/mermaid.js +178 -0
- package/lib/ui/mermaid.js.map +1 -0
- package/lib/ui/picker.d.ts +30 -8
- package/lib/ui/picker.d.ts.map +1 -1
- package/lib/ui/picker.js +63 -23
- package/lib/ui/picker.js.map +1 -1
- package/lib/ui/prompt.d.ts +30 -0
- package/lib/ui/prompt.d.ts.map +1 -0
- package/lib/ui/prompt.js +45 -0
- package/lib/ui/prompt.js.map +1 -0
- package/lib/ui/queue.d.ts +24 -0
- package/lib/ui/queue.d.ts.map +1 -0
- package/lib/ui/queue.js +57 -0
- package/lib/ui/queue.js.map +1 -0
- package/lib/ui/status.d.ts +4 -0
- package/lib/ui/status.d.ts.map +1 -1
- package/lib/ui/status.js +8 -0
- package/lib/ui/status.js.map +1 -1
- package/lib/ui/view.d.ts +22 -2
- package/lib/ui/view.d.ts.map +1 -1
- package/lib/ui/view.js +84 -24
- package/lib/ui/view.js.map +1 -1
- package/lib/work.d.ts +48 -0
- package/lib/work.d.ts.map +1 -1
- package/lib/work.js +44 -0
- package/lib/work.js.map +1 -1
- package/package.json +3 -2
package/lib/input.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Decoding shared by every surface that reads typed text.
|
|
3
|
+
*
|
|
4
|
+
* The terminal reports a paste as one bracketed run rather than as key presses,
|
|
5
|
+
* so a handler that only knows single characters silently drops what a reader
|
|
6
|
+
* copied; unwrapping it here keeps each surface answering for its own meaning
|
|
7
|
+
* instead of each re-deriving the same markers.
|
|
8
|
+
*/
|
|
9
|
+
/** The markers the surface wraps a paste in once the terminal reports one. */
|
|
10
|
+
const PASTE_START = '\x1b[200~';
|
|
11
|
+
const PASTE_END = '\x1b[201~';
|
|
12
|
+
/**
|
|
13
|
+
* The text a bracketed paste carries, or undefined when the input is a key press.
|
|
14
|
+
*
|
|
15
|
+
* Control bytes are the terminal's, not the reader's: a copied key arrives with
|
|
16
|
+
* the newline that copied it, and keeping that newline would confirm a question
|
|
17
|
+
* before the reader saw what landed.
|
|
18
|
+
*/
|
|
19
|
+
export function pastedText(data) {
|
|
20
|
+
const start = data.indexOf(PASTE_START);
|
|
21
|
+
if (start === -1)
|
|
22
|
+
return undefined;
|
|
23
|
+
const rest = data.slice(start + PASTE_START.length);
|
|
24
|
+
const end = rest.indexOf(PASTE_END);
|
|
25
|
+
return (end === -1 ? rest : rest.slice(0, end)).replace(/[\u0000-\u001f\u007f]/gu, '');
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=input.js.map
|
package/lib/input.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input.js","sourceRoot":"","sources":["../src/input.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,8EAA8E;AAC9E,MAAM,WAAW,GAAG,WAAW,CAAA;AAC/B,MAAM,SAAS,GAAG,WAAW,CAAA;AAE7B;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY;IACrC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IACvC,IAAI,KAAK,KAAK,CAAC,CAAC;QAAE,OAAO,SAAS,CAAA;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;IACnD,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAA;IACnC,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAA;AACxF,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type ActionLayer, type Keymap } from './input/actions.ts';
|
|
2
|
+
/** The layers a reader may ask for, in the order the table lists them. */
|
|
3
|
+
export declare const KEYMAP_LAYERS: readonly ActionLayer[];
|
|
4
|
+
/** The layer a reader named, or nothing when the name is not one of them. */
|
|
5
|
+
export declare function keymapLayer(name: string): ActionLayer | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* The effective map, one line per action.
|
|
8
|
+
*
|
|
9
|
+
* The id comes first because it is what the reader types into settings.yaml;
|
|
10
|
+
* the keys follow in the order they are read, so a list action answers its
|
|
11
|
+
* first key before its second. A mark says which rows the reader wrote, because
|
|
12
|
+
* a document that no longer matches the shipped map cannot be read off the file
|
|
13
|
+
* once the file grows.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderKeymap(map: Keymap, only?: ActionLayer): string[];
|
|
16
|
+
//# sourceMappingURL=keys-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys-command.d.ts","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6D,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAA4E,CAAA;AAuB5H,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAEjE;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,MAAM,EAAE,CAsBtE"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { ACTION_CATALOG, actionLabel, keyName, keysFor, newShadows } from "./input/actions.js";
|
|
2
|
+
/** The layers a reader may ask for, in the order the table lists them. */
|
|
3
|
+
export const KEYMAP_LAYERS = ['prompt', 'surface', 'chord', 'gate', 'question', 'picker', 'library'];
|
|
4
|
+
/** What each layer is for, so a list of ids reads as a surface rather than a dump. */
|
|
5
|
+
const LAYER_NOTES = {
|
|
6
|
+
prompt: 'the prompt bar',
|
|
7
|
+
surface: 'the surface, answered before the editor',
|
|
8
|
+
chord: 'the prefix first, then the key that follows it',
|
|
9
|
+
gate: 'an approval',
|
|
10
|
+
question: 'a question and its options',
|
|
11
|
+
picker: 'a list',
|
|
12
|
+
library: 'the editor and input pi-tui draws, read from the library',
|
|
13
|
+
};
|
|
14
|
+
/** Where the reader edits the section; the home is a variable, not a fixed path. */
|
|
15
|
+
const SETTINGS_HINT = 'edit $DSH_HOME/settings.yaml (default ~/.dsh/settings.yaml) under "dsh-tui:" · /keys shows the result';
|
|
16
|
+
/** The smallest document that says something, so the shape is never guessed at. */
|
|
17
|
+
const EXAMPLE = [
|
|
18
|
+
'keys:',
|
|
19
|
+
' prompt.submit: ctrl+enter # one key, or',
|
|
20
|
+
' prompt.newLine: [enter, shift+enter, ctrl+j] # a list of them',
|
|
21
|
+
];
|
|
22
|
+
/** The layer a reader named, or nothing when the name is not one of them. */
|
|
23
|
+
export function keymapLayer(name) {
|
|
24
|
+
return KEYMAP_LAYERS.find(layer => layer === name);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* The effective map, one line per action.
|
|
28
|
+
*
|
|
29
|
+
* The id comes first because it is what the reader types into settings.yaml;
|
|
30
|
+
* the keys follow in the order they are read, so a list action answers its
|
|
31
|
+
* first key before its second. A mark says which rows the reader wrote, because
|
|
32
|
+
* a document that no longer matches the shipped map cannot be read off the file
|
|
33
|
+
* once the file grows.
|
|
34
|
+
*/
|
|
35
|
+
export function renderKeymap(map, only) {
|
|
36
|
+
const layers = only === undefined ? KEYMAP_LAYERS : [only];
|
|
37
|
+
const actions = ACTION_CATALOG.filter(action => layers.includes(action.layer));
|
|
38
|
+
const lines = [`keys · ${actions.length} actions · ${map.written.size} of them yours`, ''];
|
|
39
|
+
for (const layer of layers) {
|
|
40
|
+
const rows = actions.filter(action => action.layer === layer);
|
|
41
|
+
if (rows.length === 0)
|
|
42
|
+
continue;
|
|
43
|
+
lines.push(`${layer} · ${LAYER_NOTES[layer]}:`);
|
|
44
|
+
for (const action of rows) {
|
|
45
|
+
const keys = keysFor(map, action.id).map(keyName).join(' · ');
|
|
46
|
+
lines.push(` ${action.id} = ${keys === '' ? 'unbound' : keys} · ${actionLabel(action.id)}${map.written.has(action.id) ? ' (yours)' : ''}`);
|
|
47
|
+
}
|
|
48
|
+
lines.push('');
|
|
49
|
+
}
|
|
50
|
+
const shadows = newShadows(map);
|
|
51
|
+
if (shadows.length > 0) {
|
|
52
|
+
lines.push('keys you took from the library:');
|
|
53
|
+
for (const shadow of shadows)
|
|
54
|
+
lines.push(` ${keyName(shadow.key)}: ${shadow.winner} over ${shadow.loser}`);
|
|
55
|
+
lines.push('');
|
|
56
|
+
}
|
|
57
|
+
lines.push(...EXAMPLE, '', SETTINGS_HINT);
|
|
58
|
+
return lines;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=keys-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys-command.js","sourceRoot":"","sources":["../src/keys-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAiC,MAAM,oBAAoB,CAAA;AAE7H,0EAA0E;AAC1E,MAAM,CAAC,MAAM,aAAa,GAA2B,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;AAE5H,sFAAsF;AACtF,MAAM,WAAW,GAA0C;IACzD,MAAM,EAAE,gBAAgB;IACxB,OAAO,EAAE,yCAAyC;IAClD,KAAK,EAAE,gDAAgD;IACvD,IAAI,EAAE,aAAa;IACnB,QAAQ,EAAE,4BAA4B;IACtC,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,0DAA0D;CACpE,CAAA;AAED,oFAAoF;AACpF,MAAM,aAAa,GAAG,uGAAuG,CAAA;AAE7H,mFAAmF;AACnF,MAAM,OAAO,GAAG;IACd,OAAO;IACP,kDAAkD;IAClD,mEAAmE;CACpE,CAAA;AAED,6EAA6E;AAC7E,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC,CAAA;AACpD,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,IAAkB;IAC1D,MAAM,MAAM,GAAG,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,aAAa,CAA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,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACvB,KAAK,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,KAAK,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC,MAAM,SAAS,MAAM,CAAC,KAAK,EAAE,CAAC,CAAA;QAC3G,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAChB,CAAC;IACD,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,EAAE,EAAE,EAAE,aAAa,CAAC,CAAA;IACzC,OAAO,KAAK,CAAA;AACd,CAAC"}
|
package/lib/queue.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Context } from '@deepseek-ai/cordis';
|
|
2
|
+
/** The reader's own prompts still waiting in one inbox projection state. */
|
|
3
|
+
export declare function promptsOf(state: unknown): readonly string[];
|
|
4
|
+
/** The prompts one session's agent has not taken yet. */
|
|
5
|
+
export declare function pendingPrompts(ctx: Context, session: unknown): readonly string[];
|
|
6
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAmDlD,4EAA4E;AAC5E,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAc3D;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS,MAAM,EAAE,CAEhF"}
|
package/lib/queue.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { projectionState } from "./agent/projections.js";
|
|
2
|
+
/**
|
|
3
|
+
* The prompts an agent has not taken yet.
|
|
4
|
+
*
|
|
5
|
+
* The harness owns pending input and records every append, claim, and
|
|
6
|
+
* cancellation as a durable splice; the `inbox` projection folds those into the
|
|
7
|
+
* two lists a claim drains. Reading that projection rather than keeping a list
|
|
8
|
+
* of our own is what makes a row disappear exactly when the message is taken —
|
|
9
|
+
* including when an interrupt discarded it — and what lets a resumed session
|
|
10
|
+
* show input that is still owed.
|
|
11
|
+
*/
|
|
12
|
+
/** What a queued prompt shows when it carries no text block, so its row is never blank. */
|
|
13
|
+
const NO_TEXT = '(no text)';
|
|
14
|
+
/**
|
|
15
|
+
* The pending lists, in the order the harness delivers them.
|
|
16
|
+
*
|
|
17
|
+
* A step boundary claims next-step first and takes a queued turn after it, so
|
|
18
|
+
* this is also the order the reader's own rows reach the transcript in.
|
|
19
|
+
*/
|
|
20
|
+
const TARGETS = ['next-step', 'next-turn'];
|
|
21
|
+
function asRecord(value) {
|
|
22
|
+
return typeof value === 'object' && value !== null ? value : undefined;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Whether a pending message is the reader's own input.
|
|
26
|
+
*
|
|
27
|
+
* Next-step also carries the contexts a tool or a plugin injects, which are
|
|
28
|
+
* machinery rather than something the reader is waiting to see delivered.
|
|
29
|
+
*/
|
|
30
|
+
function fromHuman(message) {
|
|
31
|
+
return asRecord(message.source)?.kind === 'user';
|
|
32
|
+
}
|
|
33
|
+
/** The text one pending message carries; a thought is the model's, not the reader's words. */
|
|
34
|
+
function textOf(message) {
|
|
35
|
+
const blocks = Array.isArray(message.content) ? message.content : [];
|
|
36
|
+
const texts = [];
|
|
37
|
+
for (const block of blocks) {
|
|
38
|
+
const record = asRecord(block);
|
|
39
|
+
if (record?.type !== 'text' || typeof record.text !== 'string')
|
|
40
|
+
continue;
|
|
41
|
+
texts.push(record.text);
|
|
42
|
+
}
|
|
43
|
+
return texts.length === 0 ? NO_TEXT : texts.join('\n');
|
|
44
|
+
}
|
|
45
|
+
/** The reader's own prompts still waiting in one inbox projection state. */
|
|
46
|
+
export function promptsOf(state) {
|
|
47
|
+
const inbox = asRecord(state);
|
|
48
|
+
if (inbox === undefined)
|
|
49
|
+
return [];
|
|
50
|
+
const prompts = [];
|
|
51
|
+
for (const target of TARGETS) {
|
|
52
|
+
const pending = inbox[target];
|
|
53
|
+
if (!Array.isArray(pending))
|
|
54
|
+
continue;
|
|
55
|
+
for (const entry of pending) {
|
|
56
|
+
const message = asRecord(entry);
|
|
57
|
+
if (message === undefined || !fromHuman(message))
|
|
58
|
+
continue;
|
|
59
|
+
prompts.push(textOf(message));
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return prompts;
|
|
63
|
+
}
|
|
64
|
+
/** The prompts one session's agent has not taken yet. */
|
|
65
|
+
export function pendingPrompts(ctx, session) {
|
|
66
|
+
return session === undefined ? [] : promptsOf(projectionState(ctx, session, 'inbox'));
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=queue.js.map
|
package/lib/queue.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../src/queue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAExD;;;;;;;;;GASG;AAEH,2FAA2F;AAC3F,MAAM,OAAO,GAAG,WAAW,CAAA;AAE3B;;;;;GAKG;AACH,MAAM,OAAO,GAAG,CAAC,WAAW,EAAE,WAAW,CAAU,CAAA;AAEnD,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,SAAS,CAAA;AACnG,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,OAAgC;IACjD,OAAO,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,KAAK,MAAM,CAAA;AAClD,CAAC;AAED,8FAA8F;AAC9F,SAAS,MAAM,CA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,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,yDAAyD;AACzD,MAAM,UAAU,cAAc,CAAC,GAAY,EAAE,OAAgB;IAC3D,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACvF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Where a deferred notice prints once the surface owns the screen. */
|
|
2
|
+
export type NoticeSink = (message: string) => void;
|
|
3
|
+
/** A notice that waits until the surface can show it. */
|
|
4
|
+
export interface DeferredNotice {
|
|
5
|
+
/** Print through `sink` from now on, starting with anything held back. */
|
|
6
|
+
open(sink: NoticeSink): void;
|
|
7
|
+
/** Print the notice now, or hold it until {@link DeferredNotice.open}. */
|
|
8
|
+
post(message: string): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Hold a notice found before the alternate screen exists.
|
|
12
|
+
*
|
|
13
|
+
* The settings scope applies on its own schedule, so a section refused at boot
|
|
14
|
+
* is read either before the surface owns the screen or after it: one holder,
|
|
15
|
+
* opened when the screen is taken, keeps both orders honest — and a notice
|
|
16
|
+
* written to stderr alone would have been buried under the alternate screen.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createDeferredNotice(): DeferredNotice;
|
|
19
|
+
//# sourceMappingURL=settings-notice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-notice.d.ts","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;AAElD,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAC5B,0EAA0E;IAC1E,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,IAAI,cAAc,CAmBrD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hold a notice found before the alternate screen exists.
|
|
3
|
+
*
|
|
4
|
+
* The settings scope applies on its own schedule, so a section refused at boot
|
|
5
|
+
* is read either before the surface owns the screen or after it: one holder,
|
|
6
|
+
* opened when the screen is taken, keeps both orders honest — and a notice
|
|
7
|
+
* written to stderr alone would have been buried under the alternate screen.
|
|
8
|
+
*/
|
|
9
|
+
export function createDeferredNotice() {
|
|
10
|
+
let sink;
|
|
11
|
+
let pending;
|
|
12
|
+
return {
|
|
13
|
+
open(next) {
|
|
14
|
+
sink = next;
|
|
15
|
+
if (pending === undefined)
|
|
16
|
+
return;
|
|
17
|
+
const held = pending;
|
|
18
|
+
pending = undefined;
|
|
19
|
+
next(held);
|
|
20
|
+
},
|
|
21
|
+
post(message) {
|
|
22
|
+
if (sink === undefined) {
|
|
23
|
+
pending = message;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
sink(message);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=settings-notice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings-notice.js","sourceRoot":"","sources":["../src/settings-notice.ts"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB;IAClC,IAAI,IAA4B,CAAA;IAChC,IAAI,OAA2B,CAAA;IAC/B,OAAO;QACL,IAAI,CAAC,IAAI;YACP,IAAI,GAAG,IAAI,CAAA;YACX,IAAI,OAAO,KAAK,SAAS;gBAAE,OAAM;YACjC,MAAM,IAAI,GAAG,OAAO,CAAA;YACpB,OAAO,GAAG,SAAS,CAAA;YACnB,IAAI,CAAC,IAAI,CAAC,CAAA;QACZ,CAAC;QACD,IAAI,CAAC,OAAO;YACV,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,GAAG,OAAO,CAAA;gBACjB,OAAM;YACR,CAAC;YACD,IAAI,CAAC,OAAO,CAAC,CAAA;QACf,CAAC;KACF,CAAA;AACH,CAAC"}
|