688da13872
Ink keeps its `measure-text` module internal and never re-exports it. vue-tui exported `measureText` / `measureTextNatural` from the public index under the mistaken belief — stated verbatim in commit 0e7d775's own message — that doing so "matched Ink's public API". It does not; Ink keeps that module internal. A later design doc then rationalized the leak post-hoc as an intentional divergence. It was neither intentional nor a divergence — it was a mistake. Align with Ink: - Drop both from the public index. `measureTextNatural` stays as an internal helper (yoga.ts uses it). `measureText` had zero production callers (yoga uses `wrapText` + `measureTextNatural`, never `measureText`) and is removed. - Integration tests that used `measureText(stripAnsi(x), 9999).width` as a line-width helper now use `stringWidth(stripAnsi(x))` directly. - public-api.test.ts gains a regression test asserting neither is exported. - Remove the now-obsolete entry from .agents/docs/ink-divergences.md. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
54 lines
1.4 KiB
TypeScript
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
|
|
"useExit",
|
|
"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");
|
|
});
|