@sigx/terminal-zero 0.5.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/LICENSE +21 -0
- package/dist/contract.d.ts +75 -0
- package/dist/contract.js +32 -0
- package/dist/contract.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +6 -0
- package/dist/layout/Box.d.ts +25 -0
- package/dist/layout/Col.d.ts +15 -0
- package/dist/layout/Divider.d.ts +9 -0
- package/dist/layout/Row.d.ts +18 -0
- package/dist/layout/Spacer.d.ts +5 -0
- package/dist/layout/Text.d.ts +50 -0
- package/dist/layout/index.d.ts +6 -0
- package/dist/layout/index.js +2 -0
- package/dist/layout-BRHtLdVH.js +71 -0
- package/dist/layout-BRHtLdVH.js.map +1 -0
- package/dist/prompts/cancel.d.ts +7 -0
- package/dist/prompts/index.d.ts +11 -0
- package/dist/prompts/index.js +53 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/keys.d.ts +12 -0
- package/dist/prompts/runPrompt.d.ts +36 -0
- package/dist/shared/colorMath.d.ts +14 -0
- package/dist/shared/index.d.ts +54 -0
- package/dist/shared/index.js +2 -0
- package/dist/shared/qr.d.ts +12 -0
- package/dist/shared/textBuffer.d.ts +59 -0
- package/dist/shared/ticker.d.ts +9 -0
- package/dist/shared/viewStack.d.ts +12 -0
- package/dist/shared-h5p-EcZV.js +732 -0
- package/dist/shared-h5p-EcZV.js.map +1 -0
- package/dist/theme/index.d.ts +34 -0
- package/dist/theme/index.js +71 -0
- package/dist/theme/index.js.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, G as o, H as s, I as c, J as l, K as u, L as d, M as f, N as p, O as m, P as h, R as g, S as _, T as v, U as y, V as b, W as x, _ as S, a as C, b as w, c as T, d as E, f as D, g as O, h as k, i as A, j, k as M, l as N, m as P, n as F, o as I, p as L, q as R, r as z, s as B, t as V, u as H, v as U, w as W, x as G, y as K, z as q } from "../shared-h5p-EcZV.js";
|
|
2
|
+
export { V as GLYPHS, F as PRESS_MS, z as READY_DELAY_MS, A as SPINNERS, b as TICK_MS, C as charWidth, M as createViewStack, e as cursorToRowCol, j as deleteAt, f as deleteBefore, I as dispatchKey, B as displayWidth, T as focus, N as focusNext, H as focusPrev, E as focusState, m as generateQR, D as getColorDepth, L as getOutputTarget, P as getTerminalSize, s as getTick, x as gradient, k as hexToSGR, o as hueShift, p as insertAt, h as layoutText, u as mixHex, a as moveLeft, c as moveLineEnd, d as moveLineStart, g as moveRight, q as moveVertical, O as onKey, R as parseHex, S as printStatic, U as registerFocusable, K as renderTerminal, w as resolveBg, G as resolveFg, l as rgbToHex, t as rowColToCursor, _ as setScreenBackground, n as setScreenForeground, y as subscribeTicker, W as syncTerminalSize, v as truncateToWidth, i as unregisterFocusable, r as writeStatic };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate a QR code string for terminal display.
|
|
3
|
+
* Uses Unicode half-block characters (▀▄█ ) to render 2 rows per line.
|
|
4
|
+
*
|
|
5
|
+
* @param text - The text/URL to encode
|
|
6
|
+
* @param opts - Options: quiet zone width, colors
|
|
7
|
+
* @returns Multi-line string ready for console.log()
|
|
8
|
+
*/
|
|
9
|
+
export declare function generateQR(text: string, opts?: {
|
|
10
|
+
quiet?: number;
|
|
11
|
+
invert?: boolean;
|
|
12
|
+
}): string;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export interface TextBufferState {
|
|
2
|
+
text: string;
|
|
3
|
+
/** Code-point index, 0..codePointLength(text). */
|
|
4
|
+
cursor: number;
|
|
5
|
+
}
|
|
6
|
+
export interface TextRow {
|
|
7
|
+
text: string;
|
|
8
|
+
/** Code-point offset of the row's first character in the full text. */
|
|
9
|
+
start: number;
|
|
10
|
+
/** Exclusive end offset; excludes the `\n` on hard rows. */
|
|
11
|
+
end: number;
|
|
12
|
+
/** True when the row ends at an explicit newline (or end of text). */
|
|
13
|
+
hard: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface TextLayout {
|
|
16
|
+
rows: TextRow[];
|
|
17
|
+
width: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Soft-wrap `text` at `width` display cells. Explicit `\n` always breaks a
|
|
21
|
+
* row (hard). Overlong rows break at the last space when one exists in the
|
|
22
|
+
* row, otherwise hard-break mid-word. Empty text yields one empty row.
|
|
23
|
+
*/
|
|
24
|
+
export declare function layoutText(text: string, width: number): TextLayout;
|
|
25
|
+
/**
|
|
26
|
+
* Map a cursor (code-point index) to its visual row and column (cells).
|
|
27
|
+
* A cursor sitting exactly on a soft-wrap boundary maps to the start of the
|
|
28
|
+
* NEXT row — except at the very end of the text, where it stays on the last.
|
|
29
|
+
*/
|
|
30
|
+
export declare function cursorToRowCol(layout: TextLayout, cursor: number): {
|
|
31
|
+
row: number;
|
|
32
|
+
col: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Map a visual (row, goalCol) back to a cursor index. A goal column landing
|
|
36
|
+
* inside a wide glyph snaps to the glyph start; beyond the row end clamps to
|
|
37
|
+
* the row end.
|
|
38
|
+
*/
|
|
39
|
+
export declare function rowColToCursor(layout: TextLayout, row: number, goalCol: number): number;
|
|
40
|
+
export declare function insertAt(state: TextBufferState, chunk: string): TextBufferState;
|
|
41
|
+
/** Backspace: delete the code point before the cursor. */
|
|
42
|
+
export declare function deleteBefore(state: TextBufferState): TextBufferState;
|
|
43
|
+
/** Forward delete: delete the code point under the cursor. */
|
|
44
|
+
export declare function deleteAt(state: TextBufferState): TextBufferState;
|
|
45
|
+
export declare function moveLeft(state: TextBufferState): TextBufferState;
|
|
46
|
+
export declare function moveRight(state: TextBufferState): TextBufferState;
|
|
47
|
+
/**
|
|
48
|
+
* Move the cursor a visual row up (-1) or down (+1), keeping a sticky goal
|
|
49
|
+
* column: pass the previous call's `goalCol` back in while the user keeps
|
|
50
|
+
* moving vertically (any horizontal move/edit resets it — caller's job).
|
|
51
|
+
*/
|
|
52
|
+
export declare function moveVertical(state: TextBufferState, width: number, dir: -1 | 1, goalCol?: number): {
|
|
53
|
+
state: TextBufferState;
|
|
54
|
+
goalCol: number;
|
|
55
|
+
};
|
|
56
|
+
/** Jump to the start of the cursor's visual row. */
|
|
57
|
+
export declare function moveLineStart(state: TextBufferState, width: number): TextBufferState;
|
|
58
|
+
/** Jump to the end of the cursor's visual row. */
|
|
59
|
+
export declare function moveLineEnd(state: TextBufferState, width: number): TextBufferState;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Global animation granularity, ms. Components derive slower rates from it. */
|
|
2
|
+
export declare const TICK_MS = 80;
|
|
3
|
+
/** Reactive frame counter — read it in a render function to re-render per tick. */
|
|
4
|
+
export declare function getTick(): number;
|
|
5
|
+
/**
|
|
6
|
+
* Refcounted subscription: the first subscriber starts the interval, the last
|
|
7
|
+
* unsubscribe stops it. Returns an idempotent unsubscribe function.
|
|
8
|
+
*/
|
|
9
|
+
export declare function subscribeTicker(): () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface ViewStack<T> {
|
|
2
|
+
push(view: T): void;
|
|
3
|
+
/** Pop the current view. Returns false (and stays) at the root. */
|
|
4
|
+
pop(): boolean;
|
|
5
|
+
/** Swap the current view without growing the stack. */
|
|
6
|
+
replace(view: T): void;
|
|
7
|
+
/** The top of the stack. Reactive. */
|
|
8
|
+
current(): T;
|
|
9
|
+
/** Stack size (root = 1). Reactive. */
|
|
10
|
+
depth(): number;
|
|
11
|
+
}
|
|
12
|
+
export declare function createViewStack<T>(root: T): ViewStack<T>;
|