From 088d31ec5dd1ac18f7accb32883c8a3d9d714f8a Mon Sep 17 00:00:00 2001 From: dev Date: Wed, 27 May 2026 15:40:01 +0200 Subject: [PATCH] refactor(words): extract table types to extensions/table/types.ts (F2.3a) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../soma/components/words/engine/document.ts | 62 +++++++++---------- .../words/extensions/table/types.ts | 47 ++++++++++++++ 2 files changed, 75 insertions(+), 34 deletions(-) create mode 100644 src/uix/soma/components/words/extensions/table/types.ts diff --git a/src/uix/soma/components/words/engine/document.ts b/src/uix/soma/components/words/engine/document.ts index c139fed9a..83a6babf1 100644 --- a/src/uix/soma/components/words/engine/document.ts +++ b/src/uix/soma/components/words/engine/document.ts @@ -5,8 +5,29 @@ export type WordsBlockType = 'paragraph' | 'heading' | 'quote' | 'code' | 'list' export type WordsListKind = 'ordered' | 'unordered' | 'check'; export type WordsHeadingLevel = 1 | 2 | 3; 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 { readonly version: typeof WORDS_DOCUMENT_VERSION; @@ -52,13 +73,6 @@ export interface WordsListBlock { readonly children: readonly WordsListItem[]; } -export interface WordsTableBlock { - readonly type: 'table'; - readonly striped?: boolean; - readonly compact?: boolean; - readonly children: readonly WordsTableRow[]; -} - export interface WordsListItem { readonly type: 'list-item'; readonly checked?: boolean; @@ -66,31 +80,11 @@ export interface WordsListItem { readonly children: readonly WordsInline[]; } -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; -} +// Table interface declarations live in `extensions/table/types.ts` since +// F2.3. The interfaces (WordsTableBlock, WordsTableRow, 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 type WordsInline = WordsText | WordsLink; diff --git a/src/uix/soma/components/words/extensions/table/types.ts b/src/uix/soma/components/words/extensions/table/types.ts new file mode 100644 index 000000000..8a6fe4091 --- /dev/null +++ b/src/uix/soma/components/words/extensions/table/types.ts @@ -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; +}