@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/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 = "terminal" | "static";
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
- /** ghostty-web theme overrides */
14
+ /** Terminal color theme overrides */
15
15
  theme?: Partial<GhosttyTheme>;
16
- /** Cursor blinking. Default: true */
17
- cursorBlink?: boolean;
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.1.1",
4
- "description": "React component for embedding interactive TUI apps via ghostty-web",
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": "npm run -s build:lib && node --test tests/*.test.mjs",
40
- "check": "npm run typecheck && npm run test"
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;
@@ -1,4 +0,0 @@
1
- const e = {};
2
- export {
3
- e as default
4
- };
@@ -1,2 +0,0 @@
1
- /** Load ghostty-web lazily to avoid SSR issues in host apps. */
2
- export declare function loadGhostty(): Promise<typeof import("ghostty-web")>;
@@ -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
- }