Files
vue-tui/packages/runtime-tests/integration/public-api.test.ts
T
Yunfei He bfd680490f refactor(runtime)!: rename useAppContext() to useApp() (full Ink alignment) (#73)
#69 added `useAppContext()` as a Vue-native rename of Ink's `useApp()`,
qualified to avoid reading as the Vue application instance. On reflection the
"Context" suffix borrowed the name of an internal grab-bag context and slightly
mislabels the hook — it returns app lifecycle controls, not that context. The
collision worry doesn't hold up: Vue has no `useApp()`, the returned
`{ exit, waitUntilRenderFlush }` is clearly not the Vue app instance, and "App"
in vue-tui already means the `TuiApp` from `createApp()`.

Rename to `useApp()` for full Ink fidelity (same name + same shape), and drop
the now-defunct "App composable" entry from ink-divergences.md — it ceases to
be a divergence.

Internal context cleanup (the grab-bag `AppContext` + the `StdinContext`
duplication) is intentionally out of scope here, tracked separately.

BREAKING CHANGE: `useAppContext()` is renamed to `useApp()`. Replace
`const { exit } = useAppContext()` with `const { exit } = useApp()`.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-05-30 23:32:22 +08:00

54 lines
1.4 KiB
TypeScript

import { expect, test } from "vite-plus/test";
import * as api from "@vue-tui/runtime";
test("public API exposes documented members", () => {
for (const k of [
// Entry point
"createApp",
// Components
"Box",
"Text",
"Newline",
"Spacer",
"Static",
"Transform",
// Composables
"useApp",
"useInput",
"useFocus",
"useFocusManager",
"useStdin",
"useStdout",
"useStderr",
"useTerminalSize",
"useWindowSize",
"useCursor",
"useIsScreenReaderEnabled",
"useAnimation",
"useBoxMetrics",
"measureElement",
"usePaste",
// Rendering
"renderToString",
"renderScreenReaderOutput",
// Kitty keyboard
"kittyFlags",
"kittyModifiers",
]) {
expect(api).toHaveProperty(k);
}
});
test("useWindowSize is an alias for useTerminalSize", () => {
expect(api.useWindowSize).toBe(api.useTerminalSize);
});
// Ink keeps its `measure-text` module internal and does not re-export it. vue-tui
// once exported `measureText`/`measureTextNatural` under the (incorrect) belief it
// "matched Ink's public API" — it does not. These stay internal; this guards the
// alignment against re-introduction. See .agents/docs/ink-divergences.md.
test("does not expose internal text-measurement helpers (Ink keeps them internal)", () => {
expect(api).not.toHaveProperty("measureText");
expect(api).not.toHaveProperty("measureTextNatural");
});