f847e17c81
Follow-up cleanup for the 7 confirmed findings from a review of #163. The dominant theme: #163 hard-renamed the public composable useTerminalSize -> useWindowSize (no alias) but left stale references to the dead name in user-facing docs. - README.md + packages/runtime/README.md: the composable tables named the removed `useTerminalSize()` (root README even framed the sole real export `useWindowSize` as an "Ink-compat alias" — now inverted). Point both at `useWindowSize()`. - .agents/docs/ink-divergences.md: two vue-tui-side references to `useTerminalSize` (the shallowRef "object of refs" example and the "composables throw outside a render tree" list) -> `useWindowSize`. The Ink-side `useWindowSize -> WindowSize` naming example is left unchanged. - .agents/docs/accessibility-api.md: the intro cited three "blessed entries" but only aria-camelCase is one; `renderToString` layout-only and the `useWindowSize` name are now Ink parity, not divergences. Reword. - .agents/docs/api-contract.md: tighten the `/internal` wording — the test does assert one tripwire on `/internal`, so "not covered by public-api.test.ts" was imprecise. - public-api.test.ts / render-to-string.test.tsx: the public renderToString dropped the `isScreenReaderEnabled` option but (unlike the sibling `ScreenReaderOptions` type) had no compile-time guard. Replace an obscure, fmt-fragile type-indexing guard with a readable call-site `@ts-expect-error` in render-to-string.test.tsx; re-adding the option to the public RenderToStringOptions makes the directive unused and fails `tsc --noEmit`. - Rename terminal-size.test.tsx / .sequential.test.tsx -> window-size.test.tsx / .sequential.test.tsx to match the migrated symbol. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
77 lines
3.4 KiB
TypeScript
77 lines
3.4 KiB
TypeScript
import { expect, test } from "vite-plus/test";
|
|
import * as api from "@vue-tui/runtime";
|
|
import * as internalApi from "@vue-tui/runtime/internal";
|
|
|
|
// The EXACT public runtime (value) export surface of `@vue-tui/runtime`. The test below snapshots
|
|
// it exhaustively: adding, removing, or renaming ANY value export fails — so every change to the
|
|
// public surface must be a deliberate edit here. Keep grouped + alphabetical-within-group for
|
|
// readable diffs. NOTE: type-only exports are erased at runtime and cannot be enumerated this way;
|
|
// they are guarded individually with `@ts-expect-error` (see the `ScreenReaderOptions` guard
|
|
// below). The type surface is therefore not exhaustively snapshotted.
|
|
const PUBLIC_VALUE_EXPORTS = [
|
|
// Entry point
|
|
"createApp",
|
|
// Components
|
|
"Box",
|
|
"Newline",
|
|
"Spacer",
|
|
"Static",
|
|
"Text",
|
|
"Transform",
|
|
// Composables
|
|
"useAnimation",
|
|
"useApp",
|
|
"useBoxMetrics",
|
|
"useCursor",
|
|
"useFocus",
|
|
"useFocusManager",
|
|
"useInput",
|
|
"useIsScreenReaderEnabled",
|
|
"usePaste",
|
|
"useStderr",
|
|
"useStdin",
|
|
"useStdout",
|
|
"useWindowSize",
|
|
"measureElement",
|
|
// Rendering
|
|
"renderToString",
|
|
// Kitty keyboard
|
|
"kittyFlags",
|
|
"kittyModifiers",
|
|
];
|
|
|
|
test("public API surface is exactly the documented value-export set", () => {
|
|
expect(Object.keys(api).sort()).toEqual([...PUBLIC_VALUE_EXPORTS].sort());
|
|
});
|
|
|
|
// 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");
|
|
});
|
|
|
|
// `renderScreenReaderOutput` is the screen-reader linearizer — internal SR machinery,
|
|
// not a public API. Ink keeps its counterpart (`renderNodeToScreenReaderOutput`)
|
|
// module-internal and never re-exports it; we match that. It was never usefully
|
|
// callable from the public barrel anyway: its only parameter type (`TuiNode`) and the
|
|
// node-construction primitives needed to build one live only in
|
|
// `@vue-tui/runtime/internal`. It moves there. See .agents/docs/accessibility-api.md.
|
|
test("does not expose the screen-reader linearizer publicly (Ink keeps it internal)", () => {
|
|
expect(api).not.toHaveProperty("renderScreenReaderOutput");
|
|
expect(internalApi).toHaveProperty("renderScreenReaderOutput");
|
|
});
|
|
|
|
// Compile-time guard for the TYPE half of the contract (types are erased at runtime, so this
|
|
// can't be an `expect()`): `ScreenReaderOptions` is internal-only too. Importing it from the
|
|
// PUBLIC barrel must NOT type-check — if it is ever re-added there, this `@ts-expect-error` goes
|
|
// unused and `tsc --noEmit` fails. Same idiom as the prop-type fixtures in integration/pty/fixtures.
|
|
// It DOES type-check from `/internal`, which the runtime guard above already proves is the home.
|
|
// @ts-expect-error - ScreenReaderOptions is exported only from @vue-tui/runtime/internal
|
|
export type _ScreenReaderOptionsIsInternalOnly = import("@vue-tui/runtime").ScreenReaderOptions;
|
|
|
|
// The parallel guard for the public `renderToString`'s dropped `isScreenReaderEnabled` OPTION lives
|
|
// in render-to-string.test.tsx (a call-site `@ts-expect-error`), next to the renderToString tests.
|