@vui-rs/core 0.1.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.
Files changed (44) hide show
  1. package/README.md +29 -0
  2. package/dist/char-width.d.ts +7 -0
  3. package/dist/char-width.js +20 -0
  4. package/dist/color-names.js +46 -0
  5. package/dist/color.d.ts +5 -0
  6. package/dist/color.js +57 -0
  7. package/dist/image-decode.d.ts +21 -0
  8. package/dist/image-decode.js +42 -0
  9. package/dist/index.d.ts +402 -0
  10. package/dist/index.js +27 -0
  11. package/dist/keys.d.ts +76 -0
  12. package/dist/keys.js +373 -0
  13. package/dist/named-colors.d.ts +7 -0
  14. package/dist/named-colors.js +20 -0
  15. package/dist/native/darwin-arm64/libvui_core.dylib +0 -0
  16. package/dist/native/darwin-x64/libvui_core.dylib +0 -0
  17. package/dist/native/ffi-symbols.d.ts +453 -0
  18. package/dist/native/ffi-symbols.js +680 -0
  19. package/dist/native/linux-arm64/libvui_core.so +0 -0
  20. package/dist/native/linux-x64/libvui_core.so +0 -0
  21. package/dist/native/load-native-lib.d.ts +384 -0
  22. package/dist/native/load-native-lib.js +63 -0
  23. package/dist/native/win32-x64/vui_core.dll +0 -0
  24. package/dist/node.d.ts +61 -0
  25. package/dist/node.js +157 -0
  26. package/dist/offscreen-buffer.d.ts +28 -0
  27. package/dist/offscreen-buffer.js +73 -0
  28. package/dist/renderer.d.ts +106 -0
  29. package/dist/renderer.js +186 -0
  30. package/dist/style.d.ts +48 -0
  31. package/dist/style.js +134 -0
  32. package/dist/terminal-session.d.ts +43 -0
  33. package/dist/terminal-session.js +82 -0
  34. package/dist/text/edit-buffer.d.ts +31 -0
  35. package/dist/text/edit-buffer.js +96 -0
  36. package/dist/text/editor-view.d.ts +22 -0
  37. package/dist/text/editor-view.js +48 -0
  38. package/dist/text/index.d.ts +5 -0
  39. package/dist/text/index.js +5 -0
  40. package/dist/text/text-buffer-view.d.ts +22 -0
  41. package/dist/text/text-buffer-view.js +49 -0
  42. package/dist/text/text-buffer.d.ts +16 -0
  43. package/dist/text/text-buffer.js +43 -0
  44. package/package.json +46 -0
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # @vui-rs/core
2
+
3
+ Native terminal rendering engine for [vui-rs](https://github.com/open-ai-sdk/vui-rs) — a Rust cell buffer (truecolor, unicode/grapheme width, borders, [taffy](https://github.com/DioxusLabs/taffy) flexbox layout, inline images) driven from **Bun** via FFI.
4
+
5
+ > **Runtime:** Bun only. This package loads a native library through `bun:ffi`; it does not run under Node.js.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ bun add @vui-rs/core
11
+ ```
12
+
13
+ Prebuilt native binaries for `darwin-arm64`, `darwin-x64`, `linux-x64`, `linux-arm64`, and `win32-x64` ship inside the package; the loader picks the right one at runtime.
14
+
15
+ ## Usage
16
+
17
+ ```ts
18
+ import { Renderer } from "@vui-rs/core";
19
+
20
+ const r = new Renderer(80, 24);
21
+ // …draw into the cell buffer, then flush.
22
+ r.free();
23
+ ```
24
+
25
+ Most apps use [`@vui-rs/vue`](https://www.npmjs.com/package/@vui-rs/vue) (a Vue custom renderer) on top of this engine rather than calling it directly.
26
+
27
+ ## License
28
+
29
+ MIT
@@ -0,0 +1,7 @@
1
+ //#region src/char-width.d.ts
2
+ /** Column width of a single codepoint: 0 (combining/control), 1, or 2. */
3
+ declare function charWidth(cp: number): number;
4
+ /** Width of a single-codepoint string's leading codepoint (`charWidth` for graphemes). */
5
+ declare function strWidth(ch: string): number;
6
+ //#endregion
7
+ export { charWidth, strWidth };
@@ -0,0 +1,20 @@
1
+ import { loadNativeLib } from "./native/load-native-lib.js";
2
+ //#region src/char-width.ts
3
+ const cache = /* @__PURE__ */ new Map();
4
+ let lib = null;
5
+ /** Column width of a single codepoint: 0 (combining/control), 1, or 2. */
6
+ function charWidth(cp) {
7
+ const hit = cache.get(cp);
8
+ if (hit !== void 0) return hit;
9
+ lib ??= loadNativeLib();
10
+ const w = lib.symbols.vui_char_width(cp >>> 0);
11
+ cache.set(cp, w);
12
+ return w;
13
+ }
14
+ /** Width of a single-codepoint string's leading codepoint (`charWidth` for graphemes). */
15
+ function strWidth(ch) {
16
+ const cp = ch.codePointAt(0);
17
+ return cp === void 0 ? 0 : charWidth(cp);
18
+ }
19
+ //#endregion
20
+ export { charWidth, strWidth };
@@ -0,0 +1,46 @@
1
+ //#region src/color-names.json
2
+ var color_names_default = {
3
+ black: "#000000",
4
+ white: "#ffffff",
5
+ red: "#ff0000",
6
+ green: "#008000",
7
+ lime: "#00ff00",
8
+ blue: "#0000ff",
9
+ yellow: "#ffff00",
10
+ cyan: "#00ffff",
11
+ aqua: "#00ffff",
12
+ magenta: "#ff00ff",
13
+ fuchsia: "#ff00ff",
14
+ gray: "#808080",
15
+ grey: "#808080",
16
+ silver: "#c0c0c0",
17
+ maroon: "#800000",
18
+ olive: "#808000",
19
+ navy: "#000080",
20
+ teal: "#008080",
21
+ purple: "#800080",
22
+ orange: "#ffa500",
23
+ gold: "#ffd700",
24
+ pink: "#ffc0cb",
25
+ brown: "#a52a2a",
26
+ coral: "#ff7f50",
27
+ salmon: "#fa8072",
28
+ tomato: "#ff6347",
29
+ crimson: "#dc143c",
30
+ indigo: "#4b0082",
31
+ violet: "#ee82ee",
32
+ turquoise: "#40e0d0",
33
+ skyblue: "#87ceeb",
34
+ royalblue: "#4169e1",
35
+ steelblue: "#4682b4",
36
+ slategray: "#708090",
37
+ slategrey: "#708090",
38
+ forestgreen: "#228b22",
39
+ seagreen: "#2e8b57",
40
+ khaki: "#f0e68c",
41
+ beige: "#f5f5dc",
42
+ ivory: "#fffff0",
43
+ transparent: "#00000000"
44
+ };
45
+ //#endregion
46
+ export { color_names_default as default };
@@ -0,0 +1,5 @@
1
+ //#region src/color.d.ts
2
+ /** Coerce a prop value to a packed `0xRRGGBBAA` color, or `undefined` for unset. */
3
+ declare function parseColor(value: unknown): number | undefined;
4
+ //#endregion
5
+ export { parseColor };
package/dist/color.js ADDED
@@ -0,0 +1,57 @@
1
+ import { NAMED_COLORS, parseHex } from "./named-colors.js";
2
+ //#region src/color.ts
3
+ let warnedColors = null;
4
+ /** Coerce a prop value to a packed `0xRRGGBBAA` color, or `undefined` for unset. */
5
+ function parseColor(value) {
6
+ if (value == null) return void 0;
7
+ if (typeof value === "number") return value >>> 0;
8
+ if (typeof value === "string") {
9
+ const parsed = parseColorString(value.trim());
10
+ if (parsed !== void 0) return parsed;
11
+ warnBadColor(value);
12
+ }
13
+ }
14
+ function parseColorString(value) {
15
+ if (value.startsWith("#")) return parseHex(value);
16
+ if (value.startsWith("rgb")) return parseRgbFunction(value);
17
+ return NAMED_COLORS.get(value.toLowerCase());
18
+ }
19
+ function parseRgbFunction(value) {
20
+ const open = value.indexOf("(");
21
+ if (open < 0 || !value.endsWith(")")) return void 0;
22
+ const parts = value.slice(open + 1, -1).split(",").map((p) => p.trim());
23
+ if (parts.length < 3 || parts.length > 4) return void 0;
24
+ const r = channel(parts[0]);
25
+ const g = channel(parts[1]);
26
+ const b = channel(parts[2]);
27
+ if (r === void 0 || g === void 0 || b === void 0) return void 0;
28
+ let a = 255;
29
+ if (parts.length === 4) {
30
+ const raw = decimal(parts[3]);
31
+ if (raw === void 0) return void 0;
32
+ a = raw <= 1 ? Math.round(raw * 255) : Math.round(raw);
33
+ }
34
+ return (r << 24 | g << 16 | b << 8 | clamp255(a)) >>> 0;
35
+ }
36
+ function channel(s) {
37
+ const n = decimal(s);
38
+ return n === void 0 ? void 0 : clamp255(Math.round(n));
39
+ }
40
+ const DECIMAL = /^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
41
+ function decimal(s) {
42
+ if (!DECIMAL.test(s)) return void 0;
43
+ const n = Number(s);
44
+ return Number.isFinite(n) ? n : void 0;
45
+ }
46
+ function clamp255(n) {
47
+ return n < 0 ? 0 : n > 255 ? 255 : n;
48
+ }
49
+ function warnBadColor(value) {
50
+ if (process.env.NODE_ENV === "production") return;
51
+ warnedColors ??= /* @__PURE__ */ new Set();
52
+ if (warnedColors.has(value)) return;
53
+ warnedColors.add(value);
54
+ console.warn(`vui: unparseable color "${value}" — expected a number, #rrggbb(aa), rgb()/rgba(), or a named color; treated as unset`);
55
+ }
56
+ //#endregion
57
+ export { parseColor };
@@ -0,0 +1,21 @@
1
+ //#region src/image-decode.d.ts
2
+ interface DecodedImage {
3
+ width: number;
4
+ height: number;
5
+ /** Tightly-packed RGBA8, `width * height * 4` bytes (JS-owned copy). */
6
+ rgba: Uint8Array;
7
+ }
8
+ /**
9
+ * Decode `path` and fit within `maxW`×`maxH` pixels (aspect preserved; 0 = no
10
+ * resize). Returns null on any decode/read error so callers render nothing. The
11
+ * native handle is freed before returning — the pixels are copied out.
12
+ */
13
+ declare function decodeImage(path: string, maxW?: number, maxH?: number): DecodedImage | null;
14
+ /**
15
+ * Decode an image from in-memory bytes (format auto-detected) and fit within
16
+ * `maxW`×`maxH` px. For remote/fetched images the host already has as a buffer.
17
+ * Returns null on any decode error.
18
+ */
19
+ declare function decodeImageBytes(bytes: Uint8Array, maxW?: number, maxH?: number): DecodedImage | null;
20
+ //#endregion
21
+ export { DecodedImage, decodeImage, decodeImageBytes };
@@ -0,0 +1,42 @@
1
+ import { loadNativeLib } from "./native/load-native-lib.js";
2
+ import { toArrayBuffer } from "bun:ffi";
3
+ //#region src/image-decode.ts
4
+ /**
5
+ * Decode `path` and fit within `maxW`×`maxH` pixels (aspect preserved; 0 = no
6
+ * resize). Returns null on any decode/read error so callers render nothing. The
7
+ * native handle is freed before returning — the pixels are copied out.
8
+ */
9
+ function decodeImage(path, maxW = 0, maxH = 0) {
10
+ const bytes = new TextEncoder().encode(path);
11
+ return readHandle((lib) => lib.symbols.vui_image_decode(bytes, bytes.byteLength, maxW, maxH));
12
+ }
13
+ /**
14
+ * Decode an image from in-memory bytes (format auto-detected) and fit within
15
+ * `maxW`×`maxH` px. For remote/fetched images the host already has as a buffer.
16
+ * Returns null on any decode error.
17
+ */
18
+ function decodeImageBytes(bytes, maxW = 0, maxH = 0) {
19
+ return readHandle((lib) => lib.symbols.vui_image_decode_bytes(bytes, bytes.byteLength, maxW, maxH));
20
+ }
21
+ /** Run a decode that yields a native handle, copy its RGBA out, and free it. */
22
+ function readHandle(decode) {
23
+ const lib = loadNativeLib();
24
+ const handle = decode(lib);
25
+ if (handle === null) return null;
26
+ try {
27
+ const width = lib.symbols.vui_image_width(handle);
28
+ const height = lib.symbols.vui_image_height(handle);
29
+ const ptr = lib.symbols.vui_image_rgba_ptr(handle);
30
+ const len = Number(lib.symbols.vui_image_rgba_len(handle));
31
+ if (ptr === null || len === 0) return null;
32
+ return {
33
+ width,
34
+ height,
35
+ rgba: new Uint8Array(toArrayBuffer(ptr, 0, len)).slice()
36
+ };
37
+ } finally {
38
+ lib.symbols.vui_image_free(handle);
39
+ }
40
+ }
41
+ //#endregion
42
+ export { decodeImage, decodeImageBytes };
@@ -0,0 +1,402 @@
1
+ import { Attr, CELL_BYTES, EXPECTED_ABI_VERSION, EditMotion, EditMotionCode, LINK_SHIFT, NativeTextWrap, NativeTextWrapCode, NodeKindCode, STYLE_FFI_BYTES, Status, symbols } from "./native/ffi-symbols.js";
2
+ import { NativeLib } from "./native/load-native-lib.js";
3
+ import { parseColor } from "./color.js";
4
+ import { NAMED_COLORS, parseHex } from "./named-colors.js";
5
+ import { AlignValue, Dim, JustifyValue, Sides, VuiStyle, packStyle } from "./style.js";
6
+ import { LayoutRect, RectEdges, TextRun, TextWrapName, VuiNode, hostTreeHash } from "./node.js";
7
+ import { OffscreenBuffer } from "./offscreen-buffer.js";
8
+ import { TextBuffer } from "./text/text-buffer.js";
9
+ import { TextBufferView, TextMeasure, TextWrapMode, wrapCode } from "./text/text-buffer-view.js";
10
+ import { EditBuffer } from "./text/edit-buffer.js";
11
+ import { EditorView } from "./text/editor-view.js";
12
+ import { ClipRect, Renderer, TextStyle, rgba } from "./renderer.js";
13
+ import { charWidth, strWidth } from "./char-width.js";
14
+ import { DecodedImage, decodeImage, decodeImageBytes } from "./image-decode.js";
15
+ import { InputEvent, Key, KeyDecoder, KeyEvent, MouseButton, MouseEvent, PasteEvent, createKeyDecoder, matchesKey, parseKeys } from "./keys.js";
16
+ import { TerminalSession, TerminalSessionOptions, createTerminalSession } from "./terminal-session.js";
17
+
18
+ //#region src/index.d.ts
19
+ /**
20
+ * Memoized handle to the loaded vui-core native library. The first call
21
+ * resolves, opens, and ABI-checks the library; subsequent calls reuse it.
22
+ */
23
+ declare function getNativeLib(): import("bun:ffi").Library<{
24
+ readonly vui_version: {
25
+ readonly args: readonly [];
26
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
27
+ };
28
+ readonly vui_abi_version: {
29
+ readonly args: readonly [];
30
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
31
+ };
32
+ readonly vui_char_width: {
33
+ readonly args: readonly [import("bun:ffi").FFIType.uint32_t];
34
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
35
+ };
36
+ readonly vui_renderer_new: {
37
+ readonly args: readonly [import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
38
+ readonly returns: import("bun:ffi").FFIType.ptr;
39
+ };
40
+ readonly vui_renderer_free: {
41
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
42
+ readonly returns: import("bun:ffi").FFIType.void;
43
+ };
44
+ readonly vui_renderer_resize: {
45
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
46
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
47
+ };
48
+ readonly vui_renderer_back_buffer_ptr: {
49
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
50
+ readonly returns: import("bun:ffi").FFIType.ptr;
51
+ };
52
+ readonly vui_renderer_buffer_len: {
53
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
54
+ readonly returns: "usize";
55
+ };
56
+ readonly vui_cell_size_bytes: {
57
+ readonly args: readonly [];
58
+ readonly returns: "usize";
59
+ };
60
+ readonly vui_buffer_draw_text: {
61
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t];
62
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
63
+ };
64
+ readonly vui_buffer_fill_rect: {
65
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
66
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
67
+ };
68
+ readonly vui_buffer_set_cell: {
69
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t];
70
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
71
+ };
72
+ readonly vui_buffer_clear: {
73
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t];
74
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
75
+ };
76
+ readonly vui_renderer_render: {
77
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
78
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
79
+ };
80
+ readonly vui_renderer_flush: {
81
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
82
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
83
+ };
84
+ readonly vui_renderer_clear_links: {
85
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
86
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
87
+ };
88
+ readonly vui_renderer_stage_link: {
89
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint16_t, import("bun:ffi").FFIType.ptr, "usize"];
90
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
91
+ };
92
+ readonly vui_renderer_stage_passthrough: {
93
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
94
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
95
+ };
96
+ readonly vui_image_decode: {
97
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
98
+ readonly returns: import("bun:ffi").FFIType.ptr;
99
+ };
100
+ readonly vui_renderer_stage_image_placement: {
101
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t];
102
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
103
+ };
104
+ readonly vui_renderer_clear_image_placements: {
105
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
106
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
107
+ };
108
+ readonly vui_image_decode_bytes: {
109
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
110
+ readonly returns: import("bun:ffi").FFIType.ptr;
111
+ };
112
+ readonly vui_image_width: {
113
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
114
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
115
+ };
116
+ readonly vui_image_height: {
117
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
118
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
119
+ };
120
+ readonly vui_image_rgba_ptr: {
121
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
122
+ readonly returns: import("bun:ffi").FFIType.ptr;
123
+ };
124
+ readonly vui_image_rgba_len: {
125
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
126
+ readonly returns: "usize";
127
+ };
128
+ readonly vui_image_free: {
129
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
130
+ readonly returns: import("bun:ffi").FFIType.void;
131
+ };
132
+ readonly vui_buffer_draw_text_clipped: {
133
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t, import("bun:ffi").FFIType.ptr];
134
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
135
+ };
136
+ readonly vui_buffer_fill_rect_clipped: {
137
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr];
138
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
139
+ };
140
+ readonly vui_buffer_set_cell_clipped: {
141
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t, import("bun:ffi").FFIType.ptr];
142
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
143
+ };
144
+ readonly vui_buffer_blit: {
145
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.ptr];
146
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
147
+ };
148
+ readonly vui_buffer_draw_textbuffer: {
149
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint8_t, import("bun:ffi").FFIType.uint16_t, import("bun:ffi").FFIType.ptr];
150
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
151
+ };
152
+ readonly vui_buffer_draw_editor: {
153
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.int32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t, import("bun:ffi").FFIType.ptr];
154
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
155
+ };
156
+ readonly vui_textbuf_new: {
157
+ readonly args: readonly [];
158
+ readonly returns: import("bun:ffi").FFIType.ptr;
159
+ };
160
+ readonly vui_textbuf_free: {
161
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
162
+ readonly returns: import("bun:ffi").FFIType.void;
163
+ };
164
+ readonly vui_textbuf_set_text: {
165
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
166
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
167
+ };
168
+ readonly vui_textbuf_set_runs: {
169
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.ptr, "usize"];
170
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
171
+ };
172
+ readonly vui_textbuf_line_count: {
173
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
174
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
175
+ };
176
+ readonly vui_textbuf_length: {
177
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
178
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
179
+ };
180
+ readonly vui_textview_new: {
181
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
182
+ readonly returns: import("bun:ffi").FFIType.ptr;
183
+ };
184
+ readonly vui_textview_free: {
185
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
186
+ readonly returns: import("bun:ffi").FFIType.void;
187
+ };
188
+ readonly vui_textview_set_wrap: {
189
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t];
190
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
191
+ };
192
+ readonly vui_textview_set_width: {
193
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t];
194
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
195
+ };
196
+ readonly vui_textview_measure: {
197
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint8_t, import("bun:ffi").FFIType.ptr];
198
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
199
+ };
200
+ readonly vui_editbuf_new: {
201
+ readonly args: readonly [];
202
+ readonly returns: import("bun:ffi").FFIType.ptr;
203
+ };
204
+ readonly vui_editbuf_free: {
205
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
206
+ readonly returns: import("bun:ffi").FFIType.void;
207
+ };
208
+ readonly vui_editbuf_set_value: {
209
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
210
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
211
+ };
212
+ readonly vui_editbuf_value_len: {
213
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
214
+ readonly returns: "usize";
215
+ };
216
+ readonly vui_editbuf_copy_value: {
217
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
218
+ readonly returns: "usize";
219
+ };
220
+ readonly vui_editbuf_insert: {
221
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
222
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
223
+ };
224
+ readonly vui_editbuf_backspace: {
225
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
226
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
227
+ };
228
+ readonly vui_editbuf_delete: {
229
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
230
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
231
+ };
232
+ readonly vui_editbuf_newline: {
233
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
234
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
235
+ };
236
+ readonly vui_editbuf_move: {
237
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t, import("bun:ffi").FFIType.uint8_t];
238
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
239
+ };
240
+ readonly vui_editbuf_select_all: {
241
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
242
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
243
+ };
244
+ readonly vui_editbuf_has_selection: {
245
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
246
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
247
+ };
248
+ readonly vui_editbuf_selected_len: {
249
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
250
+ readonly returns: "usize";
251
+ };
252
+ readonly vui_editbuf_copy_selected: {
253
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, "usize"];
254
+ readonly returns: "usize";
255
+ };
256
+ readonly vui_editbuf_delete_selection: {
257
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr];
258
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
259
+ };
260
+ readonly vui_editbuf_undo: {
261
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr];
262
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
263
+ };
264
+ readonly vui_editbuf_redo: {
265
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr];
266
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
267
+ };
268
+ readonly vui_editbuf_can_undo: {
269
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
270
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
271
+ };
272
+ readonly vui_editbuf_can_redo: {
273
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
274
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
275
+ };
276
+ readonly vui_editbuf_cursor: {
277
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.ptr];
278
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
279
+ };
280
+ readonly vui_editor_new: {
281
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
282
+ readonly returns: import("bun:ffi").FFIType.ptr;
283
+ };
284
+ readonly vui_editor_free: {
285
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
286
+ readonly returns: import("bun:ffi").FFIType.void;
287
+ };
288
+ readonly vui_editor_set_wrap: {
289
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t];
290
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
291
+ };
292
+ readonly vui_editor_set_viewport: {
293
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
294
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
295
+ };
296
+ readonly vui_editor_set_focused: {
297
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t];
298
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
299
+ };
300
+ readonly vui_editor_move: {
301
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t, import("bun:ffi").FFIType.uint8_t];
302
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
303
+ };
304
+ readonly vui_editor_measure: {
305
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint8_t, import("bun:ffi").FFIType.ptr];
306
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
307
+ };
308
+ readonly vui_cbuf_new: {
309
+ readonly args: readonly [import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
310
+ readonly returns: import("bun:ffi").FFIType.ptr;
311
+ };
312
+ readonly vui_cbuf_free: {
313
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
314
+ readonly returns: import("bun:ffi").FFIType.void;
315
+ };
316
+ readonly vui_cbuf_resize: {
317
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
318
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
319
+ };
320
+ readonly vui_cbuf_ptr: {
321
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
322
+ readonly returns: import("bun:ffi").FFIType.ptr;
323
+ };
324
+ readonly vui_cbuf_len: {
325
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
326
+ readonly returns: "usize";
327
+ };
328
+ readonly vui_cbuf_clear: {
329
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t];
330
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
331
+ };
332
+ readonly vui_cbuf_draw_text: {
333
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t];
334
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
335
+ };
336
+ readonly vui_cbuf_fill_rect: {
337
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
338
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
339
+ };
340
+ readonly vui_cbuf_set_cell: {
341
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint16_t];
342
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
343
+ };
344
+ readonly vui_renderer_set_root: {
345
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
346
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
347
+ };
348
+ readonly vui_node_new: {
349
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint8_t];
350
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
351
+ };
352
+ readonly vui_node_free: {
353
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t];
354
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
355
+ };
356
+ readonly vui_node_append_child: {
357
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
358
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
359
+ };
360
+ readonly vui_node_insert_before: {
361
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
362
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
363
+ };
364
+ readonly vui_node_remove_child: {
365
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
366
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
367
+ };
368
+ readonly vui_node_set_text: {
369
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr, "usize"];
370
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
371
+ };
372
+ readonly vui_node_set_text_runs: {
373
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr, "usize", import("bun:ffi").FFIType.ptr, "usize"];
374
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
375
+ };
376
+ readonly vui_node_set_text_wrap: {
377
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint8_t];
378
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
379
+ };
380
+ readonly vui_node_set_style: {
381
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr];
382
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
383
+ };
384
+ readonly vui_style_ffi_size: {
385
+ readonly args: readonly [];
386
+ readonly returns: "usize";
387
+ };
388
+ readonly vui_debug_tree_hash: {
389
+ readonly args: readonly [import("bun:ffi").FFIType.ptr];
390
+ readonly returns: import("bun:ffi").FFIType.uint64_t;
391
+ };
392
+ readonly vui_layout_compute: {
393
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.uint32_t];
394
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
395
+ };
396
+ readonly vui_node_rect: {
397
+ readonly args: readonly [import("bun:ffi").FFIType.ptr, import("bun:ffi").FFIType.uint32_t, import("bun:ffi").FFIType.ptr];
398
+ readonly returns: import("bun:ffi").FFIType.uint32_t;
399
+ };
400
+ }>;
401
+ //#endregion
402
+ export { type AlignValue, Attr, CELL_BYTES, type ClipRect, type DecodedImage, type Dim, EXPECTED_ABI_VERSION, EditBuffer, EditMotion, type EditMotionCode, EditorView, type InputEvent, type JustifyValue, Key, type KeyDecoder, type KeyEvent, LINK_SHIFT, type LayoutRect, type MouseButton, type MouseEvent, NAMED_COLORS, type NativeLib, NativeTextWrap, type NativeTextWrapCode, NodeKindCode, OffscreenBuffer, type PasteEvent, type RectEdges, Renderer, STYLE_FFI_BYTES, type Sides, Status, type TerminalSession, type TerminalSessionOptions, TextBuffer, TextBufferView, type TextMeasure, type TextRun, type TextStyle, type TextWrapMode, type TextWrapName, VuiNode, type VuiStyle, charWidth, createKeyDecoder, createTerminalSession, decodeImage, decodeImageBytes, getNativeLib, hostTreeHash, matchesKey, packStyle, parseColor, parseHex, parseKeys, rgba, strWidth, symbols, wrapCode };
package/dist/index.js ADDED
@@ -0,0 +1,27 @@
1
+ import { Attr, CELL_BYTES, EXPECTED_ABI_VERSION, EditMotion, LINK_SHIFT, NativeTextWrap, NodeKindCode, STYLE_FFI_BYTES, Status, symbols } from "./native/ffi-symbols.js";
2
+ import { loadNativeLib } from "./native/load-native-lib.js";
3
+ import { NAMED_COLORS, parseHex } from "./named-colors.js";
4
+ import { parseColor } from "./color.js";
5
+ import { packStyle } from "./style.js";
6
+ import { VuiNode, hostTreeHash } from "./node.js";
7
+ import { OffscreenBuffer } from "./offscreen-buffer.js";
8
+ import { Renderer, rgba } from "./renderer.js";
9
+ import { TextBuffer } from "./text/text-buffer.js";
10
+ import { TextBufferView, wrapCode } from "./text/text-buffer-view.js";
11
+ import { EditBuffer } from "./text/edit-buffer.js";
12
+ import { EditorView } from "./text/editor-view.js";
13
+ import "./text/index.js";
14
+ import { charWidth, strWidth } from "./char-width.js";
15
+ import { decodeImage, decodeImageBytes } from "./image-decode.js";
16
+ import { Key, createKeyDecoder, matchesKey, parseKeys } from "./keys.js";
17
+ import { createTerminalSession } from "./terminal-session.js";
18
+ //#region src/index.ts
19
+ /**
20
+ * Memoized handle to the loaded vui-core native library. The first call
21
+ * resolves, opens, and ABI-checks the library; subsequent calls reuse it.
22
+ */
23
+ function getNativeLib() {
24
+ return loadNativeLib();
25
+ }
26
+ //#endregion
27
+ export { Attr, CELL_BYTES, EXPECTED_ABI_VERSION, EditBuffer, EditMotion, EditorView, Key, LINK_SHIFT, NAMED_COLORS, NativeTextWrap, NodeKindCode, OffscreenBuffer, Renderer, STYLE_FFI_BYTES, Status, TextBuffer, TextBufferView, VuiNode, charWidth, createKeyDecoder, createTerminalSession, decodeImage, decodeImageBytes, getNativeLib, hostTreeHash, matchesKey, packStyle, parseColor, parseHex, parseKeys, rgba, strWidth, symbols, wrapCode };