@dkkoval/tui-preview 0.1.1 → 0.2.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 +24 -16
- package/dist/TuiPreview.js +62 -54
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/libghostty.d.ts +86 -0
- package/dist/core/libghostty.js +678 -0
- package/dist/core/normalize.d.ts +0 -1
- package/dist/core/normalize.js +20 -67
- package/dist/core/wasi.d.ts +1 -1
- package/dist/core/wasi.js +16 -3
- package/dist/ghostty-vt.wasm +0 -0
- package/dist/index.cjs +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +613 -227
- package/dist/types.d.ts +8 -26
- package/package.json +6 -7
- package/dist/__vite-browser-external-2447137e-BcPniuRQ.cjs +0 -1
- package/dist/__vite-browser-external-2447137e-DYxpcVy9.js +0 -4
- package/dist/core/ghostty.d.ts +0 -2
- package/dist/core/ghostty.js +0 -11
- package/dist/ghostty-web-BfBVpf8G.js +0 -2962
- package/dist/ghostty-web-DkOZu5AZ.cjs +0 -13
- package/dist/wasi.d.ts +0 -1
- package/dist/wasi.js +0 -2
package/dist/types.d.ts
CHANGED
|
@@ -4,17 +4,17 @@ export interface TuiRuntimeSize {
|
|
|
4
4
|
}
|
|
5
5
|
export type TuiArgv = string[] | ((size: TuiRuntimeSize) => string[]);
|
|
6
6
|
export type TuiFitMode = "container" | "none";
|
|
7
|
-
export type TuiRenderMode = "
|
|
7
|
+
export type TuiRenderMode = "interactive" | "static";
|
|
8
8
|
export type TuiPreviewStatus = "loading" | "running" | "exited" | "error";
|
|
9
9
|
export interface TuiTerminalOptions {
|
|
10
10
|
/** Font size in pixels. Default: 14 */
|
|
11
11
|
fontSize?: number;
|
|
12
12
|
/** CSS font family. Default: monospace */
|
|
13
13
|
fontFamily?: string;
|
|
14
|
-
/**
|
|
14
|
+
/** Terminal color theme overrides */
|
|
15
15
|
theme?: Partial<GhosttyTheme>;
|
|
16
|
-
/**
|
|
17
|
-
|
|
16
|
+
/** URL to libghostty-vt wasm. Default: "/ghostty-vt.wasm" */
|
|
17
|
+
wasmUrl?: string | URL;
|
|
18
18
|
/** Convert LF to CRLF. Default: true */
|
|
19
19
|
convertEol?: boolean;
|
|
20
20
|
}
|
|
@@ -37,12 +37,7 @@ export interface TuiPreviewModernProps extends TuiPreviewCommonProps {
|
|
|
37
37
|
wasm: string | URL;
|
|
38
38
|
/** CLI argv (without argv[0]), static or size-aware */
|
|
39
39
|
argv?: TuiArgv;
|
|
40
|
-
/**
|
|
41
|
-
* Render mode.
|
|
42
|
-
* - `"terminal"` (default): full ghostty-web terminal, supports interactive apps.
|
|
43
|
-
* - `"static"`: runs the app once, captures stdout, renders ANSI output as HTML.
|
|
44
|
-
* No cursor, no input. Ideal for non-interactive previews in docs.
|
|
45
|
-
*/
|
|
40
|
+
/** Render mode. Default: "interactive" */
|
|
46
41
|
mode?: TuiRenderMode;
|
|
47
42
|
/** "container" auto-fit or "none" fixed size. Default: "container" */
|
|
48
43
|
fit?: TuiFitMode;
|
|
@@ -51,20 +46,7 @@ export interface TuiPreviewModernProps extends TuiPreviewCommonProps {
|
|
|
51
46
|
/** Terminal renderer options */
|
|
52
47
|
terminal?: TuiTerminalOptions;
|
|
53
48
|
}
|
|
54
|
-
|
|
55
|
-
* Legacy API retained for backwards compatibility.
|
|
56
|
-
* Prefer `TuiPreviewModernProps`.
|
|
57
|
-
*/
|
|
58
|
-
export interface TuiPreviewLegacyProps extends TuiPreviewCommonProps {
|
|
59
|
-
app: string | URL;
|
|
60
|
-
args?: TuiArgv;
|
|
61
|
-
cols?: number;
|
|
62
|
-
rows?: number;
|
|
63
|
-
fontSize?: number;
|
|
64
|
-
fontFamily?: string;
|
|
65
|
-
theme?: Partial<GhosttyTheme>;
|
|
66
|
-
}
|
|
67
|
-
export type TuiPreviewProps = TuiPreviewModernProps | TuiPreviewLegacyProps;
|
|
49
|
+
export type TuiPreviewProps = TuiPreviewModernProps;
|
|
68
50
|
export interface GhosttyTheme {
|
|
69
51
|
background: string;
|
|
70
52
|
foreground: string;
|
|
@@ -102,12 +84,12 @@ export interface ResolvedTuiPreviewOptions {
|
|
|
102
84
|
mode: TuiRenderMode;
|
|
103
85
|
fit: TuiFitMode;
|
|
104
86
|
size: TuiRuntimeSize;
|
|
105
|
-
terminal: Required<Omit<TuiTerminalOptions, "theme">> & {
|
|
87
|
+
terminal: Required<Omit<TuiTerminalOptions, "theme" | "wasmUrl">> & {
|
|
106
88
|
theme?: Partial<GhosttyTheme>;
|
|
89
|
+
wasmUrl?: string | URL;
|
|
107
90
|
};
|
|
108
91
|
resolveArgv: (size: TuiRuntimeSize) => string[];
|
|
109
92
|
onExit?: (code: number) => void;
|
|
110
93
|
onError?: (error: unknown) => void;
|
|
111
94
|
onStatusChange?: (status: TuiPreviewStatus) => void;
|
|
112
|
-
usedLegacyProps: boolean;
|
|
113
95
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dkkoval/tui-preview",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "React component for embedding interactive TUI apps via
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "React component for embedding interactive TUI apps via libghostty",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/dmk/tui-preview"
|
|
@@ -32,20 +32,19 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"clean": "rm -rf dist dist-example",
|
|
35
|
+
"build:ghostty-wasm": "./scripts/build-libghostty-wasm.sh",
|
|
35
36
|
"dev": "vite example",
|
|
36
37
|
"build": "vite build",
|
|
37
38
|
"build:lib": "tsc -p tsconfig.json && vite build --mode lib",
|
|
39
|
+
"prepack": "tsc -p tsconfig.json && vite build --mode lib && ./scripts/build-libghostty-wasm.sh dist/ghostty-vt.wasm",
|
|
38
40
|
"typecheck": "tsc --noEmit",
|
|
39
|
-
"test": "
|
|
40
|
-
"check": "
|
|
41
|
+
"test": "tsc -p tsconfig.json && vite build --mode lib && node --test tests/*.test.mjs",
|
|
42
|
+
"check": "tsc --noEmit && tsc -p tsconfig.json && vite build --mode lib && node --test tests/*.test.mjs"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"react": ">=18",
|
|
44
46
|
"react-dom": ">=18"
|
|
45
47
|
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"ghostty-web": "^0.4.0"
|
|
48
|
-
},
|
|
49
48
|
"devDependencies": {
|
|
50
49
|
"@types/react": "^18",
|
|
51
50
|
"@types/react-dom": "^18",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={};exports.default=e;
|
package/dist/core/ghostty.d.ts
DELETED
package/dist/core/ghostty.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
let ghosttyReady = null;
|
|
2
|
-
/** Load ghostty-web lazily to avoid SSR issues in host apps. */
|
|
3
|
-
export function loadGhostty() {
|
|
4
|
-
if (!ghosttyReady) {
|
|
5
|
-
ghosttyReady = import("ghostty-web").then(async (mod) => {
|
|
6
|
-
await mod.init();
|
|
7
|
-
return mod;
|
|
8
|
-
});
|
|
9
|
-
}
|
|
10
|
-
return ghosttyReady;
|
|
11
|
-
}
|