fix(runtime): keep text-measure helpers internal, matching Ink (#68)
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>
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { defineComponent, shallowRef, nextTick } from "vue";
|
||||
import { test } from "vite-plus/test";
|
||||
import { render } from "@vue-tui/testing";
|
||||
import { Box, Text, measureText } from "@vue-tui/runtime";
|
||||
import { Box, Text } from "@vue-tui/runtime";
|
||||
import stripAnsi from "strip-ansi";
|
||||
import stringWidth from "string-width";
|
||||
|
||||
// single node — full width box
|
||||
test("single node - full width box", async ({ expect }) => {
|
||||
@@ -977,7 +978,7 @@ test("arrow border on narrow box does not overflow", async ({ expect }) => {
|
||||
);
|
||||
const frame = lastFrame()!;
|
||||
for (const line of frame.split("\n")) {
|
||||
expect(measureText(stripAnsi(line), 9999).width).toBeLessThanOrEqual(3);
|
||||
expect(stringWidth(stripAnsi(line))).toBeLessThanOrEqual(3);
|
||||
}
|
||||
const stripped = stripAnsi(frame);
|
||||
expect(stripped.split("\n")[0]).toContain("↘");
|
||||
|
||||
Reference in New Issue
Block a user