refactor(words): extract table types to extensions/table/types.ts (F2.3a)

First atomic checkpoint of F2.3 (table migration to extension). Moves
the type declarations only — interfaces and unions for the table node
tree (WordsTableBlock, WordsTableRow, WordsTableCell, WordsTableOptions,
WordsTableCellOptions, WordsTableCellVerticalAlign, WordsTableCellTone)
go from engine/document.ts to extensions/table/types.ts.

engine/document.ts re-exports the moved types via `export type { ... }
from '../extensions/table/types'` so every existing consumer keeps
compiling without changes. Internal usages within document.ts use a
separate `import type` to keep the types in local scope for factory
function signatures.

The rest of F2.3 (factories + serializers + render + normalize + path
+ operations + registry wire-up) requires deeper dependency analysis
across the engine's ~990 LoC of table code spread over 10 files. That
work is deferred to a dedicated session to avoid mid-refactor breakage.

Verification:
- 143/143 tests pass in src/uix/soma/components/words
- 0 new TypeScript errors
- No engine behaviour change (types-only move)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
active-uix
dev 4 months ago
parent 1805b0817d
commit 088d31ec5d

@ -5,8 +5,29 @@ export type WordsBlockType = 'paragraph' | 'heading' | 'quote' | 'code' | 'list'
export type WordsListKind = 'ordered' | 'unordered' | 'check'; export type WordsListKind = 'ordered' | 'unordered' | 'check';
export type WordsHeadingLevel = 1 | 2 | 3; export type WordsHeadingLevel = 1 | 2 | 3;
export type WordsTextAlign = 'left' | 'center' | 'right' | 'justify'; export type WordsTextAlign = 'left' | 'center' | 'right' | 'justify';
export type WordsTableCellVerticalAlign = 'top' | 'middle' | 'bottom';
export type WordsTableCellTone = 'default' | 'muted' | 'accent'; // Table types live in the table extension since F2.3 (extension system
// migration). Re-exported here so existing consumers that import table
// types from `engine/document` keep compiling. New code SHOULD import
// from `extensions/table` directly.
import type {
WordsTableCellVerticalAlign,
WordsTableCellTone,
WordsTableBlock,
WordsTableRow,
WordsTableCell,
WordsTableOptions,
WordsTableCellOptions
} from '../extensions/table/types';
export type {
WordsTableCellVerticalAlign,
WordsTableCellTone,
WordsTableBlock,
WordsTableRow,
WordsTableCell,
WordsTableOptions,
WordsTableCellOptions
};
export interface WordsDocument { export interface WordsDocument {
readonly version: typeof WORDS_DOCUMENT_VERSION; readonly version: typeof WORDS_DOCUMENT_VERSION;
@ -52,13 +73,6 @@ export interface WordsListBlock {
readonly children: readonly WordsListItem[]; readonly children: readonly WordsListItem[];
} }
export interface WordsTableBlock {
readonly type: 'table';
readonly striped?: boolean;
readonly compact?: boolean;
readonly children: readonly WordsTableRow[];
}
export interface WordsListItem { export interface WordsListItem {
readonly type: 'list-item'; readonly type: 'list-item';
readonly checked?: boolean; readonly checked?: boolean;
@ -66,31 +80,11 @@ export interface WordsListItem {
readonly children: readonly WordsInline[]; readonly children: readonly WordsInline[];
} }
export interface WordsTableRow { // Table interface declarations live in `extensions/table/types.ts` since
readonly type: 'table-row'; // F2.3. The interfaces (WordsTableBlock, WordsTableRow, WordsTableCell,
readonly children: readonly WordsTableCell[]; // WordsTableOptions, WordsTableCellOptions) are re-exported from this
} // module via the `export type { ... } from '../extensions/table/types'`
// statement near the top of the file.
export interface WordsTableCell {
readonly type: 'table-cell';
readonly header?: boolean;
readonly textAlign?: WordsTextAlign;
readonly verticalAlign?: WordsTableCellVerticalAlign;
readonly tone?: WordsTableCellTone;
readonly children: readonly WordsInline[];
}
export interface WordsTableOptions {
readonly striped?: boolean;
readonly compact?: boolean;
}
export interface WordsTableCellOptions {
readonly header?: boolean;
readonly textAlign?: WordsTextAlign;
readonly verticalAlign?: WordsTableCellVerticalAlign;
readonly tone?: WordsTableCellTone;
}
export type WordsInline = WordsText | WordsLink; export type WordsInline = WordsText | WordsLink;

@ -0,0 +1,47 @@
/**
* Table extension types — canonical types for the table node tree
* (`table` → `table-row` → `table-cell` → inline content).
*
* Owned by the table extension. The engine's `document.ts` re-exports
* these for backward compatibility with consumers that import table
* types from there directly. New code should import from the table
* extension barrel (`extensions/table`) instead.
*/
import type { WordsInline, WordsTextAlign } from '../../engine/document';
export type WordsTableCellVerticalAlign = 'top' | 'middle' | 'bottom';
export type WordsTableCellTone = 'default' | 'muted' | 'accent';
export interface WordsTableBlock {
readonly type: 'table';
readonly striped?: boolean;
readonly compact?: boolean;
readonly children: readonly WordsTableRow[];
}
export interface WordsTableRow {
readonly type: 'table-row';
readonly children: readonly WordsTableCell[];
}
export interface WordsTableCell {
readonly type: 'table-cell';
readonly header?: boolean;
readonly textAlign?: WordsTextAlign;
readonly verticalAlign?: WordsTableCellVerticalAlign;
readonly tone?: WordsTableCellTone;
readonly children: readonly WordsInline[];
}
export interface WordsTableOptions {
readonly striped?: boolean;
readonly compact?: boolean;
}
export interface WordsTableCellOptions {
readonly header?: boolean;
readonly textAlign?: WordsTextAlign;
readonly verticalAlign?: WordsTableCellVerticalAlign;
readonly tone?: WordsTableCellTone;
}
Loading…
Cancel
Save

Powered by TurnKey Linux.