xonecas.io
70160
Ce

cel-tui / commit 645d1ca

chore: add knip config, remove dead code and unnecessary exports

- Added knip.json configuring workspaces, test/bench/example entries,
  and ignored dependencies (mitata, workspace packages in examples)
- Removed dead code: setContainerScroll (unused after scroll fix),
  cursorToLineCol (never imported anywhere)
- Unexported internal-only symbols: getContainerScroll (used only within
  paint.ts), ScrollOffsetResolver (used only within hit-test.ts)
- Removed redundant get-east-asian-width from root devDependencies
  (already a real dependency in packages/core)
- knip now reports zero findings

xonecas2026-04-04 645d1ca1a6bbe0d47437d33259eba71f41d9a0fa parent 35f09dd

7 files changed

TODO.md+0โˆ’19
@@ -5,7 +5,6 @@ Remaining work, known bugs, and planned improvements.
55 ## Legend
66
77 - ๐Ÿ”ง Bug / spec violation
8-- โœ… Fixed
98 - โŒ Not yet implemented
109 - ๐Ÿ’ก Future enhancement
1110
@@ -13,24 +12,6 @@ Remaining work, known bugs, and planned improvements.
1312
1413 ## Bugs / Spec Violations
1514
16-- โœ… ~~**Uncontrolled container scroll is broken**~~ โ€” Fixed: changed `"onScroll" in props` to `overflow === "scroll"`, added path-based persistence for uncontrolled scroll state across re-renders.
17-
18-- โœ… ~~**Wide character (CJK/emoji) rendering broken in emitter**~~ โ€” Fixed: paint writes continuation markers (char="") for wide chars, emitter skips them.
19-
20-- โœ… ~~**Hit testing ignores scroll offsets**~~ โ€” Fixed: hitTest() accepts a scroll offset resolver and adjusts coordinates when descending into scrollable containers.
21-
22-- โœ… ~~**TextInput padding accepted but never applied**~~ โ€” Fixed: layout intrinsic size accounts for padding, paint insets content area by padding.
23-
24-- โœ… ~~**TextInput placeholder doesn't inherit styles**~~ โ€” Fixed: placeholder text inherits the TextInput's resolved style chain.
25-
26-- โœ… ~~**Key bubbling spuriously consumes keys**~~ โ€” Fixed: focused path always returns after bubbling (no double-dispatch to root), only renders when consumed.
27-
28-- โœ… ~~**`getMaxScrollOffset` doesn't account for padding**~~ โ€” Fixed: adds padding to content extent in max offset calculation.
29-
30-- โœ… ~~**Spec reference example inconsistency**~~ โ€” Fixed: changed `msg.blocks.map(...)` to `Text(msg.content)`.
31-
32-- โœ… ~~**Duplicate JSDoc in paint.ts**~~ โ€” Fixed: removed duplicate doc comment on `paintLineGraphemes`.
33-
3415 - ๐Ÿ”ง **TextInput cursor movement doesn't handle multi-codepoint graphemes** โ€” `deleteBackward`/`deleteForward` in `text-edit.ts` operate on single string indices. For multi-codepoint characters (emoji ZWJ sequences, combining marks), this leaves the cursor mid-grapheme. `moveCursor` has the same issue.
3516
3617 ---
bun.lock+0โˆ’1
@@ -7,7 +7,6 @@
77 "devDependencies": {
88 "@biomejs/biome": "^2.4.10",
99 "@types/bun": "^1.3.11",
10- "get-east-asian-width": "^1.5.0",
1110 "lefthook": "^2.1.4",
1211 "mitata": "^1.0.34",
1312 "prettier": "^3.8.1",
knip.json+23โˆ’0
@@ -0,0 +1,23 @@
1+{
2+ "$schema": "https://unpkg.com/knip@latest/schema.json",
3+ "workspaces": {
4+ ".": {
5+ "entry": ["benchmarks/{run-all,helpers}.ts", "examples/*.ts"],
6+ "ignore": ["benchmarks/*.bench.ts"],
7+ "ignoreDependencies": [
8+ "mitata",
9+ "@cel-tui/core",
10+ "@cel-tui/components",
11+ "@cel-tui/types"
12+ ]
13+ },
14+ "packages/core": {
15+ "entry": ["src/test-helpers.ts", "src/**/*.test.ts"]
16+ },
17+ "packages/types": {},
18+ "packages/components": {
19+ "entry": ["src/**/*.test.ts"]
20+ }
21+ },
22+ "ignoreUnresolved": [".bench.ts"]
23+}
package.json+0โˆ’1
@@ -16,7 +16,6 @@
1616 "devDependencies": {
1717 "@biomejs/biome": "^2.4.10",
1818 "@types/bun": "^1.3.11",
19- "get-east-asian-width": "^1.5.0",
2019 "lefthook": "^2.1.4",
2120 "mitata": "^1.0.34",
2221 "prettier": "^3.8.1",
packages/core/src/hit-test.ts+1โˆ’1
@@ -17,7 +17,7 @@ function pointInRect(x: number, y: number, rect: Rect): boolean {
1717 * Callback to resolve the current scroll offset for a scrollable container.
1818 * Used to adjust hit coordinates when testing children of scrolled containers.
1919 */
20-export type ScrollOffsetResolver = (ln: LayoutNode) => number;
20+type ScrollOffsetResolver = (ln: LayoutNode) => number;
2121
2222 /** Default resolver: reads scrollOffset from props, defaults to 0. */
2323 function defaultScrollResolver(ln: LayoutNode): number {
packages/core/src/paint.ts+1โˆ’9
@@ -572,18 +572,10 @@ import type { ContainerProps } from "@cel-tui/types";
572572 const containerScrolls = new WeakMap<ContainerProps, number>();
573573
574574 /** Get the scroll offset for an uncontrolled scrollable container. */
575-export function getContainerScroll(props: ContainerProps): number {
575+function getContainerScroll(props: ContainerProps): number {
576576 return containerScrolls.get(props) ?? 0;
577577 }
578578
579-/** Set the scroll offset for an uncontrolled scrollable container. */
580-export function setContainerScroll(
581- props: ContainerProps,
582- scroll: number,
583-): void {
584- containerScrolls.set(props, scroll);
585-}
586-
587579 /**
588580 * TextInput state is keyed on the `onChange` function reference, which is
589581 * a stable identity across re-renders (the app provides the same closure).
packages/core/src/text-edit.ts+0โˆ’23
@@ -139,26 +139,3 @@ function moveVertical(
139139
140140 return { value, cursor: newOffset };
141141 }
142-
143-/**
144- * Map a cursor offset to (line, column) in the raw text (split by \n).
145- * Used for painting the cursor.
146- */
147-export function cursorToLineCol(
148- value: string,
149- cursor: number,
150-): { line: number; col: number } {
151- const lines = value.split("\n");
152- let offset = 0;
153-
154- for (let i = 0; i < lines.length; i++) {
155- const lineLen = lines[i]!.length;
156- if (cursor <= offset + lineLen) {
157- return { line: i, col: cursor - offset };
158- }
159- offset += lineLen + 1;
160- }
161-
162- // Cursor at very end
163- return { line: lines.length - 1, col: lines[lines.length - 1]!.length };
164-}