feat(tui): render Mermaid diagrams as terminal images (#6320)
* feat(tui): render Mermaid diagrams as terminal images * perf(tui): streamline Mermaid rendering and resource ownership * fix(tui): clarify diagram navigation hints * fix(tui): release viewer layout leases and retain retry targets * docs(tui): keep Mermaid guide focused on usage
This commit is contained in:
1 parent
9b5d552f40
commit
9adbcc2cef
31 files changed
+1983
-21
No files matched your search
@@ -25,6 +25,10 @@ const output = join(outputDir, `nanobot-tui-${platform}-${arch}${extension}`)
|
||||
await mkdir(outputDir, { recursive: true })
|
||||
const result = await Bun.build({
|
||||
entrypoints: [join(import.meta.dir, "..", "src", "index.ts")],
|
||||
define: { NANOBOT_COMPILED: "true" },
|
||||
bytecode: true,
|
||||
format: "esm",
|
||||
minify: { whitespace: true, syntax: true, identifiers: true, keepNames: true },
|
||||
compile: {
|
||||
target: `bun-${bunPlatform}-${arch}${cpuVariant}` as Bun.Build.CompileTarget,
|
||||
outfile: output,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { join } from "node:path"
|
||||
|
||||
const packagesByTarget: Record<string, string[]> = {
|
||||
"darwin-arm64": ["@opentui/core-darwin-arm64"],
|
||||
"darwin-x64": ["@opentui/core-darwin-x64"],
|
||||
"linux-arm64": ["@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl"],
|
||||
"linux-x64": ["@opentui/core-linux-x64", "@opentui/core-linux-x64-musl"],
|
||||
"win32-x64": ["@opentui/core-win32-x64"],
|
||||
"darwin-arm64": ["@opentui/core-darwin-arm64", "@resvg/resvg-js-darwin-arm64"],
|
||||
"darwin-x64": ["@opentui/core-darwin-x64", "@resvg/resvg-js-darwin-x64"],
|
||||
"linux-arm64": ["@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@resvg/resvg-js-linux-arm64-gnu", "@resvg/resvg-js-linux-arm64-musl"],
|
||||
"linux-x64": ["@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@resvg/resvg-js-linux-x64-gnu", "@resvg/resvg-js-linux-x64-musl"],
|
||||
"win32-x64": ["@opentui/core-win32-x64", "@resvg/resvg-js-win32-x64-msvc"],
|
||||
}
|
||||
|
||||
const target = process.argv[2]
|
||||
@@ -15,9 +15,11 @@ if (!packages) throw new Error(`unsupported target: ${target}`)
|
||||
|
||||
const root = join(import.meta.dir, "..")
|
||||
const manifest = await Bun.file(join(root, "package.json")).json()
|
||||
const version = manifest.dependencies?.["@opentui/core"]
|
||||
if (typeof version !== "string" || !/^\d+\.\d+\.\d+$/.test(version)) {
|
||||
throw new Error("@opentui/core must use an exact version")
|
||||
const versions: Record<string, string> = {}
|
||||
for (const name of ["@opentui/core", "@resvg/resvg-js"]) {
|
||||
const version = manifest.dependencies?.[name]
|
||||
if (typeof version !== "string" || !/^\d+\.\d+\.\d+$/.test(version)) throw new Error(`${name} must use an exact version`)
|
||||
versions[name] = version
|
||||
}
|
||||
|
||||
const npm = process.platform === "win32" ? "npm.cmd" : "npm"
|
||||
@@ -29,7 +31,7 @@ const result = Bun.spawnSync(
|
||||
"--ignore-scripts",
|
||||
"--force",
|
||||
"--package-lock=false",
|
||||
...packages.map((name) => `${name}@${version}`),
|
||||
...packages.map((name) => `${name}@${versions[name.startsWith("@opentui/") ? "@opentui/core" : "@resvg/resvg-js"]}`),
|
||||
],
|
||||
{
|
||||
cwd: root,
|
||||
|
||||
@@ -12,11 +12,11 @@ const supportedTargets = new Set([
|
||||
])
|
||||
if (!supportedTargets.has(target)) throw new Error(`unsupported target: ${target}`)
|
||||
const nativePackagesByTarget: Record<string, string[]> = {
|
||||
"darwin-arm64": ["@opentui/core-darwin-arm64"],
|
||||
"darwin-x64": ["@opentui/core-darwin-x64"],
|
||||
"linux-arm64": ["@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl"],
|
||||
"linux-x64": ["@opentui/core-linux-x64", "@opentui/core-linux-x64-musl"],
|
||||
"win32-x64": ["@opentui/core-win32-x64"],
|
||||
"darwin-arm64": ["@opentui/core-darwin-arm64", "@resvg/resvg-js-darwin-arm64"],
|
||||
"darwin-x64": ["@opentui/core-darwin-x64", "@resvg/resvg-js-darwin-x64"],
|
||||
"linux-arm64": ["@opentui/core-linux-arm64", "@opentui/core-linux-arm64-musl", "@resvg/resvg-js-linux-arm64-gnu", "@resvg/resvg-js-linux-arm64-musl"],
|
||||
"linux-x64": ["@opentui/core-linux-x64", "@opentui/core-linux-x64-musl", "@resvg/resvg-js-linux-x64-gnu", "@resvg/resvg-js-linux-x64-musl"],
|
||||
"win32-x64": ["@opentui/core-win32-x64", "@resvg/resvg-js-win32-x64-msvc"],
|
||||
}
|
||||
|
||||
const root = join(import.meta.dir, "..")
|
||||
@@ -86,7 +86,18 @@ async function readPackageNotice(path: string): Promise<PackageNotice> {
|
||||
.filter((entry) => entry.isFile() && /^(licen[cs]e|copying|notice)([._-].*)?$/i.test(entry.name))
|
||||
.map((entry) => entry.name)
|
||||
.sort()
|
||||
if (!licenseNames.length) throw new Error(`${manifest.name ?? basename(path)} has no license file`)
|
||||
if (!licenseNames.length) {
|
||||
// These exact npm releases put their MIT declaration in the README only.
|
||||
const readme = new Map([
|
||||
["fontkit@2.0.4", "README.md"], ["dfa@1.2.0", "README.md"], ["brotli@1.3.3", "readme.md"],
|
||||
]).get(`${manifest.name}@${manifest.version}`)
|
||||
if (readme && manifest.license === "MIT") licenseNames.push(readme)
|
||||
else if (typeof manifest.name === "string" && manifest.name.startsWith("@resvg/resvg-js-") && manifest.version === "2.6.2") {
|
||||
const wrapper = JSON.parse(await readFile(join(path, "..", "resvg-js", "package.json"), "utf8")) as PackageManifest
|
||||
if (wrapper.version !== manifest.version || wrapper.license !== manifest.license) throw new Error("resvg native license version mismatch")
|
||||
licenseNames.push("../resvg-js/LICENSE")
|
||||
} else throw new Error(`${manifest.name ?? basename(path)} has no license file`)
|
||||
}
|
||||
return {
|
||||
name: String(manifest.name ?? basename(path)),
|
||||
version: String(manifest.version ?? "unknown"),
|
||||
@@ -110,6 +121,8 @@ const sections = [
|
||||
`Target: ${target}`,
|
||||
"Runtime: Bun 1.3.13",
|
||||
"The release archive also contains SOURCE_OFFER.md, RELINKING.md, and the complete TUI application source.",
|
||||
"fontkit 2.0.4, dfa 1.2.0 and brotli 1.3.3 declare MIT in their included README notices.",
|
||||
"resvg's unmodified native binding includes its upstream MPL-2.0 text; source is listed in RELINKING.md.",
|
||||
"",
|
||||
"===== nanobot project license =====",
|
||||
"",
|
||||
|
||||
Reference in new issue
Block a user