Upgrade OpenTUI to 0.8.1
The native library now comes from a package per platform, so the bundle leaves those imports to run time. A SyntaxStyle belongs to the renderer that made it, so the markdown style is kept per renderer.
This commit is contained in:
1 parent
e2d2892c52
commit
b35263b41b
6 files changed
+41
-31
No files matched your search
@@ -5,13 +5,13 @@
|
||||
"": {
|
||||
"name": "t3tui",
|
||||
"dependencies": {
|
||||
"@opentui/core": "0.2.7",
|
||||
"@opentui/react": "0.2.7",
|
||||
"@opentui/core": "0.8.1",
|
||||
"@opentui/react": "0.8.1",
|
||||
"diff": "9.0.0",
|
||||
"effect": "4.0.5",
|
||||
"mdast-util-directive": "^3.2.0",
|
||||
"micromark-extension-directive": "^4.0.0",
|
||||
"react": "19",
|
||||
"react": "^19.2.0",
|
||||
"remark-parse": "^11.0.0",
|
||||
"zustand": "5.0.11",
|
||||
},
|
||||
@@ -46,21 +46,25 @@
|
||||
|
||||
"@noble/hashes": ["@noble/hashes@1.8.0", "", {}, "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A=="],
|
||||
|
||||
"@opentui/core": ["@opentui/core@0.2.7", "", { "dependencies": { "bun-ffi-structs": "0.2.2", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0", "strip-ansi": "7.1.2", "yoga-layout": "3.2.1" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.2.7", "@opentui/core-darwin-x64": "0.2.7", "@opentui/core-linux-arm64": "0.2.7", "@opentui/core-linux-x64": "0.2.7", "@opentui/core-win32-arm64": "0.2.7", "@opentui/core-win32-x64": "0.2.7" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-cnN6JcaGC7SeQzobBy/CHzqUAQFtypazuw1CjQBo7WwoOiLMGubt9W5FXeF0zIrSxH2Ed6NLWhPYRg7SD4629Q=="],
|
||||
"@opentui/core": ["@opentui/core@0.8.1", "", { "dependencies": { "bun-ffi-structs": "0.3.1", "diff": "9.0.0", "marked": "17.0.1", "string-width": "7.2.0" }, "optionalDependencies": { "@opentui/core-darwin-arm64": "0.8.1", "@opentui/core-darwin-x64": "0.8.1", "@opentui/core-linux-arm64": "0.8.1", "@opentui/core-linux-arm64-musl": "0.8.1", "@opentui/core-linux-x64": "0.8.1", "@opentui/core-linux-x64-musl": "0.8.1", "@opentui/core-win32-arm64": "0.8.1", "@opentui/core-win32-x64": "0.8.1" }, "peerDependencies": { "web-tree-sitter": "0.25.10" } }, "sha512-WmnpnVZn2MdyYNEahQNn4k3OrIkQKfcwPVrX/DjguLtl/S2g5fPeXCqHZjCg2GLMf1N4HJap0LEkTPJEvfrDXw=="],
|
||||
|
||||
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.2.7", "", { "os": "darwin", "cpu": "arm64" }, "sha512-CAy6cL3byz2Xf6gFiJHBpcnsp/2ADEWLLOUokVypOyPLcy8GY3sPzlA4pkAjVGQMYQhDj+Y3+SXz4uTLt4AETg=="],
|
||||
"@opentui/core-darwin-arm64": ["@opentui/core-darwin-arm64@0.8.1", "", { "os": "darwin", "cpu": "arm64" }, "sha512-22jdbN55W9hCraw6k1y3TklzCvF90UJG7d1wvtUYwsn9LOEvOZn+i3fUyqkpP+kBgL31RBt+sB4RKsUmNzjWaw=="],
|
||||
|
||||
"@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.2.7", "", { "os": "darwin", "cpu": "x64" }, "sha512-K06h333rMkC9cyMJr/VvcRK3ik81Admd8ZsES5uf5YXWPdYhXGf75I1T8mKIThhUmoFLb8R5xqfuPmoocsjM7Q=="],
|
||||
"@opentui/core-darwin-x64": ["@opentui/core-darwin-x64@0.8.1", "", { "os": "darwin", "cpu": "x64" }, "sha512-rlqzXisgUl3U7WmrWySFLLZq6x9ZQiSRSGLyyULBFWTZLJY4qrs2a7y/8B0NpIFY7Ngku17qVIKcVwQZZBoLbw=="],
|
||||
|
||||
"@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.2.7", "", { "os": "linux", "cpu": "arm64" }, "sha512-iYWGTztbdG9yYSB5Alxuo0dWAmkWQR0+/paNWUyPOocjigmKgMmACDtHgYqa7sxkIcWgmXljt/f8rgXDG4wdMg=="],
|
||||
"@opentui/core-linux-arm64": ["@opentui/core-linux-arm64@0.8.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-UtJzpwvAy67RU60T1IFNBYHH3tUrmcIHsLrNI+8WFFxoOk6btwRp67NKiZd3qoDcztTz2q/yKf9KQI0yr+P6MQ=="],
|
||||
|
||||
"@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.2.7", "", { "os": "linux", "cpu": "x64" }, "sha512-tymBCfYbsDRfHQNXsolkFfaTEIDhemD4+1ZovUztQd7i+0Ggnu9WbPN1SNCiRz6PjrlaNeQzZE3Wl8FfVdw/cw=="],
|
||||
"@opentui/core-linux-arm64-musl": ["@opentui/core-linux-arm64-musl@0.8.1", "", { "os": "linux", "cpu": "arm64" }, "sha512-BzVCOuG5Vw/nB9ffLwZq82uEg0f0BE4wkd5EvrqOET9qK5D5emT4Zo8tZJFY8NG0/xBuWj6S9xVpazQWjZR17A=="],
|
||||
|
||||
"@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.2.7", "", { "os": "win32", "cpu": "arm64" }, "sha512-XLPJWdT8QOukrYDkpIng6+uNUlF66ByXcQlC3qA9JbrUTBetZhgXs8Q2jEjRfc+Ty3uh1iRSA6PgJGbbOK/f4Q=="],
|
||||
"@opentui/core-linux-x64": ["@opentui/core-linux-x64@0.8.1", "", { "os": "linux", "cpu": "x64" }, "sha512-du4V6YlGvCWs/ggc6Tj7Oc7qaoYdPpzwAeJMKUbjrg+Zv5zweNHFMN4YLbzIutTi6Ukz4KsW/hwEaQIjXHlUcA=="],
|
||||
|
||||
"@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.2.7", "", { "os": "win32", "cpu": "x64" }, "sha512-CzVGEfqysVk8Hxcj0RDv/DtXIM6iZmbmr23kW7y8CJMPtmV1gmKI4D9abVjynWJnGbaSBnDi43mgZnGMgOdyEg=="],
|
||||
"@opentui/core-linux-x64-musl": ["@opentui/core-linux-x64-musl@0.8.1", "", { "os": "linux", "cpu": "x64" }, "sha512-RB/u2G5X4KpW1/rT5iabCLYbmfMWKF3OASj2Z29+RAj38I7caRU3/TTntpX3CpHzjQrDTVWyMYzcnu+WFF8thg=="],
|
||||
|
||||
"@opentui/react": ["@opentui/react@0.2.7", "", { "dependencies": { "@opentui/core": "0.2.7", "react-reconciler": "^0.33.0" }, "peerDependencies": { "react": ">=19.2.0", "react-devtools-core": "^7.0.1", "ws": "^8.18.0" } }, "sha512-1p0TsYEgwVfJc0G0URHp9PF16JOA9aVU5PfbzH2Kx1+py3i79x47mnkUMJ9ugYxAaXLrRqbFetnq5v5L6UfI0Q=="],
|
||||
"@opentui/core-win32-arm64": ["@opentui/core-win32-arm64@0.8.1", "", { "os": "win32", "cpu": "arm64" }, "sha512-wF5AZRWDCjkfRHT1cRfyvHkf+RI/Pxjb0oMFVg2h2ayndBu8CSgyQDhtNgZd0ON+xrP4xceikCkHDhDLe5bv1w=="],
|
||||
|
||||
"@opentui/core-win32-x64": ["@opentui/core-win32-x64@0.8.1", "", { "os": "win32", "cpu": "x64" }, "sha512-+rIrkvwBJMGWdXn4GGQAmM4y+RH1Xvb9nveNyJ58SOsTOBqyWyi+63qMlxe58WVl+sVAJodEjAILcWdwrzMJ3Q=="],
|
||||
|
||||
"@opentui/react": ["@opentui/react@0.8.1", "", { "dependencies": { "@opentui/core": "0.8.1", "react-reconciler": "^0.33.0" }, "peerDependencies": { "react": ">=19.2.0", "react-devtools-core": "^7.0.1", "ws": "^8.18.0" } }, "sha512-2Suc127MY7iLkgzFjyKJVsML4PZHhtc+lOXgQhP4bP6zxgNCBlGm/FxX0fDbp5RpuogKyIix9s57YnpxQB54nw=="],
|
||||
|
||||
"@types/bun": ["@types/bun@1.4.4", "", { "dependencies": { "bun-types": "1.4.4" } }, "sha512-9wkRDXUXK124pEnAutE6n/l18j+i9GC5IAHK8TmX/2nlySETmky0OU6yL5U8pW1AoKh++AN9auDCr647BfurjQ=="],
|
||||
|
||||
@@ -80,7 +84,7 @@
|
||||
|
||||
"bail": ["bail@2.0.2", "", {}, "sha512-0xO6mYd7JB2YesxDKplafRpsiOzPt9V02ddPCLbY1xYGPOX24NTyN50qnUxgCPcSoYMhKpAuBTjQoRZCAkUDRw=="],
|
||||
|
||||
"bun-ffi-structs": ["bun-ffi-structs@0.2.2", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-N/ZWtyN0piZlrXQT7TO0V+q952orYqkfhXRXM1Hcbb+R3QSiBH4vLnib187Mrs1H7pWIYECAmPeapGYDOMCl+w=="],
|
||||
"bun-ffi-structs": ["bun-ffi-structs@0.3.1", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-3gM7PpVWLyrwxWjcilSiGuhWanhZivvo6l0u573NziPH6f/gwk6McbaYgn7oJWov6pKGRTDbrg94W5DcJsKTtQ=="],
|
||||
|
||||
"bun-types": ["bun-types@1.4.4", "", { "dependencies": { "@types/node": "*", "undici-types": "*" } }, "sha512-yjrJh5oGX7mMPKGd19YXyIjmEuj4G4zNC30bs7PM9Az7NQ3ndF3j6hbeRdvJTRQEhJ/FYQwW0a2moweEi2hMxQ=="],
|
||||
|
||||
@@ -232,8 +236,6 @@
|
||||
|
||||
"ws": ["ws@8.22.1", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g=="],
|
||||
|
||||
"yoga-layout": ["yoga-layout@3.2.1", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="],
|
||||
|
||||
"zustand": ["zustand@5.0.11", "", { "peerDependencies": { "@types/react": ">=18.0.0", "immer": ">=9.0.6", "react": ">=18.0.0", "use-sync-external-store": ">=1.2.0" }, "optionalPeers": ["@types/react", "immer", "react", "use-sync-external-store"] }, "sha512-fdZY+dk7zn/vbWNCYmzZULHRrss0jx5pPFiOuMZ/5HJN6Yv3u+1Wswy/4MpZEkEGhtNH+pwxZB8OKgUBPzYAGg=="],
|
||||
|
||||
"zwitch": ["zwitch@2.0.4", "", {}, "sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A=="],
|
||||
|
||||
+3
-3
@@ -16,13 +16,13 @@
|
||||
"postinstall": "bun run scripts/link-vendor.ts && bun run scripts/build.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@opentui/core": "0.2.7",
|
||||
"@opentui/react": "0.2.7",
|
||||
"@opentui/core": "0.8.1",
|
||||
"@opentui/react": "0.8.1",
|
||||
"diff": "9.0.0",
|
||||
"effect": "4.0.5",
|
||||
"mdast-util-directive": "^3.2.0",
|
||||
"micromark-extension-directive": "^4.0.0",
|
||||
"react": "19",
|
||||
"react": "^19.2.0",
|
||||
"remark-parse": "^11.0.0",
|
||||
"zustand": "5.0.11"
|
||||
},
|
||||
|
||||
+2
-1
@@ -13,7 +13,8 @@ const builds = [
|
||||
join(root, "node_modules/@opentui/core/parser.worker.js"),
|
||||
];
|
||||
for (const entrypoint of builds) {
|
||||
const result = await Bun.build({ entrypoints: [entrypoint], outdir, target: "bun", minify: true });
|
||||
// OpenTUI's native library comes from a package per platform, found in node_modules at run time.
|
||||
const result = await Bun.build({ entrypoints: [entrypoint], outdir, target: "bun", minify: true, external: ["@opentui/core-*"] });
|
||||
if (!result.success) {
|
||||
for (const log of result.logs) console.error(log);
|
||||
process.exit(1);
|
||||
|
||||
+3
-2
@@ -4,7 +4,7 @@ import type { MouseEvent, ScrollBoxRenderable } from "@opentui/core";
|
||||
import type { RefObject } from "react";
|
||||
|
||||
import { isLeftClick, useHover } from "./Button.tsx";
|
||||
import { colors, getMarkdownStyle } from "./theme.ts";
|
||||
import { colors, useMarkdownStyle } from "./theme.ts";
|
||||
|
||||
export interface DiffState {
|
||||
readonly cwd: string;
|
||||
@@ -21,6 +21,7 @@ export interface DiffState {
|
||||
/** Working-tree or checkpoint changes through the same unified diff renderer. */
|
||||
export function DiffView(props: { readonly diff: DiffState; readonly scrollRef: RefObject<ScrollBoxRenderable | null>; readonly selected: number; readonly expanded: Readonly<Record<string, { patch?: string; error?: string }>>; readonly onFile: (index: number) => void }) {
|
||||
const { diff } = props;
|
||||
const markdownStyle = useMarkdownStyle();
|
||||
const files = diff.patch ? splitPatch(diff.patch) : [];
|
||||
return (
|
||||
<box flexGrow={1} minHeight={0} flexDirection="column" paddingLeft={2} paddingRight={1} backgroundColor={colors.bg}>
|
||||
@@ -45,7 +46,7 @@ export function DiffView(props: { readonly diff: DiffState; readonly scrollRef:
|
||||
diff={props.expanded[file.path]?.patch ?? file.patch}
|
||||
view="unified"
|
||||
{...(filetypeOf(file.path) ? { filetype: filetypeOf(file.path)! } : {})}
|
||||
syntaxStyle={getMarkdownStyle()}
|
||||
syntaxStyle={markdownStyle}
|
||||
showLineNumbers
|
||||
wrapMode="none"
|
||||
fg={colors.text}
|
||||
|
||||
@@ -18,7 +18,7 @@ import type { T3Session, ThreadHistory } from "../client/session.ts";
|
||||
import { liveWorkEntryLabel, workEntryDisplayLabel, type MessagesTimelineRow, type Timeline, type WorkLogEntry } from "../model/timeline.ts";
|
||||
import { blockFor } from "../model/transcript.ts";
|
||||
import { firstLine, truncate } from "./text.ts";
|
||||
import { colors, getMarkdownStyle, toneColor } from "./theme.ts";
|
||||
import { colors, toneColor, useMarkdownStyle } from "./theme.ts";
|
||||
|
||||
/** What a right-click in the conversation was on. */
|
||||
export type ConversationTarget =
|
||||
@@ -165,6 +165,7 @@ const Row = memo(function Row(props: {
|
||||
readonly mouse: ConversationMouse;
|
||||
}) {
|
||||
const { row, workspaceRoot, mouse } = props;
|
||||
const markdownStyle = useMarkdownStyle();
|
||||
switch (row.kind) {
|
||||
case "message": {
|
||||
const { message } = row;
|
||||
@@ -178,7 +179,7 @@ const Row = memo(function Row(props: {
|
||||
if (message.role === "system") return <text marginTop={1} fg={colors.muted} onMouseDown={(event: MouseEvent) => isRightClick(event) && mouse.menu(menu)}>{message.text}</text>;
|
||||
return (
|
||||
<box marginTop={1} flexDirection="column" onMouseDown={(event: MouseEvent) => isRightClick(event) && mouse.menu(menu)}>
|
||||
<markdown content={message.text || "…"} syntaxStyle={getMarkdownStyle()} streaming={message.streaming} conceal />
|
||||
<markdown content={message.text || "…"} syntaxStyle={markdownStyle} streaming={message.streaming} conceal />
|
||||
{summary && summary.files.length > 0 ? <ChangedFiles summary={summary} onOpenTurnDiff={mouse.openTurnDiff} /> : null}
|
||||
{props.footer ? <text marginTop={1} fg={colors.faint}>{props.footer}</text> : null}
|
||||
</box>
|
||||
@@ -228,7 +229,7 @@ const Row = memo(function Row(props: {
|
||||
<text fg={colors.plan}>
|
||||
<strong>Plan</strong>
|
||||
</text>
|
||||
<markdown content={row.proposedPlan.planMarkdown} syntaxStyle={getMarkdownStyle()} conceal />
|
||||
<markdown content={row.proposedPlan.planMarkdown} syntaxStyle={markdownStyle} conceal />
|
||||
</box>
|
||||
);
|
||||
case "event":
|
||||
|
||||
+13
-8
@@ -1,4 +1,5 @@
|
||||
import { SyntaxStyle, type ThemeMode } from "@opentui/core";
|
||||
import { type NativeResourceOwner, SyntaxStyle, type ThemeMode } from "@opentui/core";
|
||||
import { useRenderer } from "@opentui/react";
|
||||
|
||||
import type { StatusTone } from "../model/threads.ts";
|
||||
import type { Tone } from "../model/transcript.ts";
|
||||
@@ -69,7 +70,7 @@ export const colors: Palette = { ...DARK };
|
||||
|
||||
export function applyTheme(mode: ThemeMode): void {
|
||||
Object.assign(colors, mode === "light" ? LIGHT : DARK);
|
||||
markdownStyle = undefined;
|
||||
markdownStyles = new WeakMap();
|
||||
}
|
||||
|
||||
const STATUS_COLORS: Record<StatusTone, keyof Palette> = { info: "info", muted: "muted", warn: "warn", input: "input", bad: "bad", good: "good" };
|
||||
@@ -78,11 +79,14 @@ export const statusColor = (tone: StatusTone): string => colors[STATUS_COLORS[to
|
||||
const TONE_COLORS: Record<Tone, keyof Palette> = { normal: "text", muted: "muted", good: "good", bad: "bad", warn: "warn" };
|
||||
export const toneColor = (tone: Tone): string => colors[TONE_COLORS[tone]];
|
||||
|
||||
let markdownStyle: SyntaxStyle | undefined;
|
||||
let markdownStyles = new WeakMap<NativeResourceOwner, SyntaxStyle>();
|
||||
|
||||
/** Created lazily: SyntaxStyle needs the native renderer library loaded. */
|
||||
export function getMarkdownStyle(): SyntaxStyle {
|
||||
markdownStyle ??= SyntaxStyle.fromStyles({
|
||||
/** One per renderer: a SyntaxStyle belongs to the renderer's native scene that created it. */
|
||||
export function useMarkdownStyle(): SyntaxStyle {
|
||||
const owner = useRenderer().nativeScene;
|
||||
let style = markdownStyles.get(owner);
|
||||
if (style) return style;
|
||||
style = SyntaxStyle.fromStyles({
|
||||
default: { fg: colors.text },
|
||||
"markup.heading": { fg: colors.text, bold: true },
|
||||
"markup.strong": { fg: colors.text, bold: true },
|
||||
@@ -96,6 +100,7 @@ export function getMarkdownStyle(): SyntaxStyle {
|
||||
"markup.quote": { fg: colors.muted, italic: true },
|
||||
"markup.raw": { fg: colors.plan },
|
||||
"markup.raw.block": { fg: colors.text },
|
||||
});
|
||||
return markdownStyle;
|
||||
}, owner);
|
||||
markdownStyles.set(owner, style);
|
||||
return style;
|
||||
}
|
||||
Reference in new issue
Block a user