@vyaz/core 0.1.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,174 @@
1
+ /**
2
+ * TableLayoutEngine.ts — TableFrame → positioned grid.
3
+ *
4
+ * Column widths and row heights are *measured*, not required from the caller
5
+ * (unlike svg-table-core, whose `calculateRows` takes them as input — see
6
+ * TableTypes.ts header): each cell's `TextFrame` content is laid out twice —
7
+ * once unconstrained to get its natural width, once at the final column width
8
+ * to get its wrapped height.
9
+ *
10
+ * Pipeline:
11
+ * 1. placeCells — colSpan/rowSpan → each cell's (startRow, startCol),
12
+ * borrowing svg-table-core's "occupied slot" idea
13
+ * (calculateRows' insertIgnoredCell), done natively.
14
+ * 2. column widths — span-1 cells set the per-column max; span>N cells only
15
+ * *widen* their spanned columns, evenly, if their own
16
+ * natural width doesn't already fit (never shrink).
17
+ * 3. per-cell content — laid out once at its final (possibly multi-column)
18
+ * width, inset by padding *and* border width (border-box
19
+ * model — a border never overlaps the text); same
20
+ * deficit-widen rule for row heights and rowSpan cells.
21
+ * 4. position — column/row offsets accumulated from final sizes.
22
+ *
23
+ * `table.width`/`table.height` (both optional) scale the *final* colWidths/
24
+ * rowHeights arrays proportionally to fit, applied after whichever source
25
+ * produced them (measured or an explicit `columnWidths`/`rowHeights`
26
+ * override) — symmetric, but width-shrink reflows text via wrapping while
27
+ * height-shrink has no equivalent and simply overflows the row.
28
+ *
29
+ * Border dash patterns (`borderPatterns`) and per-side `stroke-linecap`
30
+ * (`borderShapes`) resolve here (`resolveBorder`) but paint in
31
+ * `@vyaz/renderer`'s `TableRenderer.ts` (`borderMarkup`) — this engine only
32
+ * produces the resolved per-side values. Asymmetric corner radii (only a
33
+ * uniform `rx`/`ry` today) remain a possible future addition.
34
+ *
35
+ * Nested tables: `TableCell.content` can be a `TableFrame` instead of a
36
+ * `TextFrame` (`isNestedTable`). Both the natural-width pass and the final
37
+ * layout pass then call `layoutTableFrame` recursively instead of
38
+ * `layoutTextFrame` — meaning a nested cell's own two-pass layout happens
39
+ * *twice* (once per outer pass), so cost roughly doubles per nesting depth.
40
+ * The nested `TableLayoutResult` is exposed as `TableCellLayoutResult.
41
+ * nestedTable`; `content` still gets a placeholder `TextFrameLayoutResult`
42
+ * (zero lines, sized to the nested table) so every existing consumer that
43
+ * reads cell dimensions off `content.content.{width,height}` keeps working
44
+ * unchanged — `TableRenderer.ts` checks `nestedTable` first and renders that
45
+ * instead of `content` when present. `_depth` is an internal recursion
46
+ * counter (not meant to be set by callers) — past 50 levels this throws
47
+ * instead of hanging, on the assumption that's a cyclic/pathological input,
48
+ * not a real document.
49
+ */
50
+ import type { TableFrame, BorderLineCap } from '../types/TableTypes.js';
51
+ import type { TextFrameLayoutResult } from './TextFrameLayoutEngine.js';
52
+ import { type Side } from '../utils/sides.js';
53
+ /** A resolved, ready-to-paint border. Absent when every side's width is `0`. */
54
+ export interface ResolvedBorder {
55
+ widths: Record<Side, number>;
56
+ colors: Record<Side, string>;
57
+ /** Present only when at least one side has a non-empty dash pattern. */
58
+ patterns?: Record<Side, number[] | undefined>;
59
+ /** Present only when `borderShapes` was set anywhere in the style cascade. */
60
+ shapes?: Record<Side, BorderLineCap>;
61
+ /** Present only when `rx`/`ry` was set anywhere in the style cascade. */
62
+ rx?: number;
63
+ ry?: number;
64
+ }
65
+ export interface TableCellLayoutResult {
66
+ /** Absolute X of the cell box (border-box) within the table. */
67
+ x: number;
68
+ /** Absolute Y of the cell box within the table. */
69
+ y: number;
70
+ /** Full box width — sums every spanned column + the gaps between them. */
71
+ width: number;
72
+ /** Full box height — sums every spanned row + the gaps between them. */
73
+ height: number;
74
+ /** Resolved padding box (inside the border, if any). */
75
+ padding: {
76
+ top: number;
77
+ right: number;
78
+ bottom: number;
79
+ left: number;
80
+ };
81
+ /** Extra Y offset inside the padding box from `verticalAlign` (0 for `'top'`). */
82
+ verticalOffset: number;
83
+ /** `TableCellStyle.cx`/`cy` — an additional px nudge on top of padding/alignment. Default `0`. */
84
+ cx: number;
85
+ /** @see cx */
86
+ cy: number;
87
+ /** `TableCellStyle.allowOverflow` — let content paint past the cell's padding box. Default `false`. */
88
+ allowOverflow: boolean;
89
+ bgColor?: string;
90
+ border?: ResolvedBorder;
91
+ /**
92
+ * The cell's laid-out content — same shape a lone `TextFrame` produces.
93
+ * When `TableCell.content` was a `TableFrame` (see `nestedTable`), this is
94
+ * a zero-line placeholder sized to match it — a renderer should check
95
+ * `nestedTable` first and use that instead of painting `content` as text.
96
+ */
97
+ content: TextFrameLayoutResult;
98
+ /**
99
+ * Present when `TableCell.content` was a `TableFrame` — a table nested
100
+ * inside this cell, already laid out at the cell's own content width.
101
+ * `content` (above) is a same-sized placeholder in this case, not real
102
+ * text — paint this instead.
103
+ */
104
+ nestedTable?: TableLayoutResult;
105
+ /**
106
+ * `TableCell.before`, laid out unwrapped at its own natural size and
107
+ * positioned absolute-within-the-table, already vertically centered.
108
+ * Absent when the cell has no `before`.
109
+ */
110
+ before?: {
111
+ content: TextFrameLayoutResult;
112
+ x: number;
113
+ y: number;
114
+ };
115
+ /** @see before — from `TableCell.after`, right-anchored instead. */
116
+ after?: {
117
+ content: TextFrameLayoutResult;
118
+ x: number;
119
+ y: number;
120
+ };
121
+ /** Columns this cell occupies (>1 for `colSpan`). */
122
+ colSpan: number;
123
+ /** Rows this cell occupies (>1 for `rowSpan`). */
124
+ rowSpan: number;
125
+ }
126
+ export interface TableRowLayoutResult {
127
+ y: number;
128
+ height: number;
129
+ bgColor?: string;
130
+ border?: ResolvedBorder;
131
+ /** Only cells that *start* in this row (a rowSpan cell from above is not repeated here). */
132
+ cells: TableCellLayoutResult[];
133
+ }
134
+ export interface TableLayoutResult {
135
+ /** Full outer box width, margins included. */
136
+ width: number;
137
+ /** Full outer box height, margins included. */
138
+ height: number;
139
+ bgColor?: string;
140
+ /** The table's own outer border (`TableStyle`), distinct from row/cell borders. */
141
+ border?: ResolvedBorder;
142
+ /**
143
+ * The border-box — the outer box with `TableStyle.margins` excluded. Rows
144
+ * span its full width; `border` (above) is drawn at this box. A renderer
145
+ * uses it directly instead of re-deriving margins from row/cell positions.
146
+ */
147
+ contentBox: {
148
+ x: number;
149
+ y: number;
150
+ width: number;
151
+ height: number;
152
+ };
153
+ rows: TableRowLayoutResult[];
154
+ }
155
+ export interface TableLayoutOptions {
156
+ mode?: 'browser' | 'office';
157
+ /**
158
+ * What to do when a cell's `fontFamily` isn't registered — forwarded to
159
+ * every cell's own `layoutTextFrame` call. `'throw'` (default) raises
160
+ * `FontNotFoundError`; `'substitute'` uses any registered family and folds
161
+ * the cell's own warnings into the table's (none surfaced directly here —
162
+ * a caller wanting them should lay out a cell's `TextFrame` itself).
163
+ */
164
+ onMissingFont?: 'throw' | 'substitute';
165
+ /**
166
+ * Internal nested-table recursion counter — do not set this yourself.
167
+ * `layoutTableFrame` increments it on every recursive call (a `TableCell`
168
+ * whose `content` is itself a `TableFrame`) and throws past 50 levels.
169
+ * @internal
170
+ */
171
+ _depth?: number;
172
+ }
173
+ export declare function layoutTableFrame(table: TableFrame, options?: TableLayoutOptions): TableLayoutResult;
174
+ //# sourceMappingURL=TableLayoutEngine.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableLayoutEngine.d.ts","sourceRoot":"","sources":["../../src/layout/TableLayoutEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,OAAO,KAAK,EAAE,UAAU,EAA2F,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjK,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGxE,OAAO,EAAgE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAI5G,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,EAAE,MAAM,CAA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C;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACjE,qDAAqD;IACrD,OAAO,EAAE,MAAM,CAAC;IAChB,kDAAkD;IAClD,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB,4FAA4F;IAC5F,KAAK,EAAE,qBAAqB,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,iBAAiB;IAChC,8CAA8C;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mFAAmF;IACnF,MAAM,CAAC,EAAE,cAAc,CAAC;IACxB;;;;OAIG;IACH,UAAU,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,IAAI,EAAE,oBAAoB,EAAE,CAAC;CAC9B;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IACvC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAwMD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,GAAE,kBAAuB,GAAG,iBAAiB,CA+MvG"}
@@ -20,7 +20,7 @@
20
20
  * 4. If frame.height is set, lines overflow to next column when colHeight exceeded
21
21
  * 5. If no frame.height, columns are infinite (all lines stay in column 0)
22
22
  */
23
- import type { TextFrame } from '../types/Document.js';
23
+ import type { TextFrame, WritingMode } from '../types/Document.js';
24
24
  import type { Line, LayoutWarning } from '../types/LayoutTypes.js';
25
25
  import { ParagraphLayoutEngine } from './ParagraphLayoutEngine.js';
26
26
  /**
@@ -60,9 +60,39 @@ export interface TextFrameLayoutResult {
60
60
  };
61
61
  /** Present when autofit ran — the scale applied and whether it bottomed out. */
62
62
  autofit?: AutofitOutcome;
63
+ /**
64
+ * Block flow direction this layout was produced for — echoes
65
+ * `TextFrame.writingMode`, defaulting to `'horizontal-tb'`.
66
+ */
67
+ writingMode: WritingMode;
68
+ /**
69
+ * Post-layout rigid transform to realise `writingMode: 'sideways-*'` and/or
70
+ * `TextFrame.rotation`. Omitted when the net rotation is a multiple of 360°
71
+ * (nothing to apply). `lines`, `content` bbox aside, live in pre-rotation
72
+ * layout space; `content` / `overflow` are reported in **visual** space.
73
+ */
74
+ transform?: FrameTransform;
63
75
  /** Non-fatal issues (font fallback / substitution). Omitted when empty. */
64
76
  warnings?: LayoutWarning[];
65
77
  }
78
+ /**
79
+ * Rigid transform a renderer applies to {@link TextFrameLayoutResult.lines} so a
80
+ * `sideways-*` writing mode or an explicit `rotation` takes visual effect. The
81
+ * layout math itself (line breaking, measuring, positioning) is unchanged.
82
+ */
83
+ export interface FrameTransform {
84
+ /** Net clockwise rotation in degrees, normalised to `[0, 360)`. */
85
+ rotate: number;
86
+ /**
87
+ * The box `lines` occupy in their own pre-rotation coordinate space. The
88
+ * renderer rotates this box about its centre; for `rotate` of 90 / 270 the
89
+ * visible canvas is this box with width and height swapped.
90
+ */
91
+ layoutBox: {
92
+ width: number;
93
+ height: number;
94
+ };
95
+ }
66
96
  /** Options for {@link layoutTextFrame}. */
67
97
  export interface LayoutOptions {
68
98
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"TextFrameLayoutEngine.d.ts","sourceRoot":"","sources":["../../src/layout/TextFrameLayoutEngine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,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AAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;OAGG;IACH,WAAW,EAAE,WAAW,CAAC;IACzB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC;CAC5B;AAED;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,SAAS,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9C;AAyED,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC7C;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,GAAG,YAAY,CAAC;IACvC;;;;;OAKG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yFAAyF;AACzF,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,wEAAwE;IACxE,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,GAAE,aAAkB,GAAG,qBAAqB,CAEpG;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,EAChB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,qBAAqB,GAC5B,qBAAqB,CAoVvB"}
@@ -18,17 +18,29 @@
18
18
  *
19
19
  * Determines how lines stack relative to each other:
20
20
  * - `horizontal-tb`: lines flow horizontally top-to-bottom (Latin, Cyrillic, default).
21
- * - `vertical-rl`: lines flow vertically right-to-left (traditional CJK).
21
+ * - `vertical-rl`: lines flow vertically right-to-left (traditional CJK, per-glyph
22
+ * upright/rotated via {@link TextOrientation}).
22
23
  * - `vertical-lr`: lines flow vertically left-to-right (Mongolian, some UI scenarios).
24
+ * - `sideways-rl`: the whole text block is laid out horizontally, then rotated
25
+ * 90° **clockwise** as a rigid unit; wrapped lines stack right-to-left. A single
26
+ * line reads top-to-bottom. Matches PowerPoint `bodyPr vert="vert"`.
27
+ * - `sideways-lr`: same, rotated 90° **counter-clockwise**; wrapped lines stack
28
+ * left-to-right, a line reads bottom-to-top. Matches PowerPoint `vert="vert270"`.
23
29
  *
24
30
  * **Layout impact:**
25
31
  * Under `horizontal-tb`, `wrap` clips by **width**, `autofit` shrinks by **height**.
26
- * Under `vertical-*`, `wrap` clips by **height**, `autofit` shrinks by **width**
27
- * (width and height swap roles).
32
+ * Under `vertical-*` / `sideways-*`, `wrap` clips by **height**, `autofit` shrinks
33
+ * by **width** (width and height swap roles).
28
34
  *
29
- * @see {@link https://www.w3.org/TR/css-writing-modes-3/#block-flow | CSS Writing Modes: block flow}
35
+ * **Implementation status:** `sideways-rl` / `sideways-lr` are implemented as a
36
+ * post-layout affine transform (the engine reports it on
37
+ * `TextFrameLayoutResult.transform`; the renderer applies it). `vertical-rl` /
38
+ * `vertical-lr` with per-glyph orientation are **not yet implemented** — they are
39
+ * accepted by the type but currently laid out as `horizontal-tb`.
40
+ *
41
+ * @see {@link https://www.w3.org/TR/css-writing-modes-4/#block-flow | CSS Writing Modes: block flow}
30
42
  */
31
- export type WritingMode = 'horizontal-tb' | 'vertical-rl' | 'vertical-lr';
43
+ export type WritingMode = 'horizontal-tb' | 'vertical-rl' | 'vertical-lr' | 'sideways-rl' | 'sideways-lr';
32
44
  /**
33
45
  * Character orientation inside a vertical line.
34
46
  *
@@ -263,6 +275,18 @@ export interface TextRun {
263
275
  fullWidth?: boolean;
264
276
  /** Convert small kana to full-size kana. @experimental Accepted in the type but ignored by the layout engine (no-op until implemented). */
265
277
  fullSizeKana?: boolean;
278
+ /**
279
+ * Free-form metadata for features the layout engine itself never
280
+ * interprets — e.g. `@vyaz/converters` carrying an `<a>`'s `href` through
281
+ * to `@vyaz/renderer`, which wraps the run's painted output in `<a
282
+ * href="…">` for the `browser`/`preserve` presets. A key's meaning is a
283
+ * contract between whichever writer sets it and whichever reader consumes
284
+ * it; layout treats this purely as opaque pass-through (no effect on
285
+ * measurement, wrapping, or positioning). Modelled on unist's `data` node
286
+ * field (the remark/rehype AST spec) for the same reason: keep the base
287
+ * type lean instead of growing a named field per cross-cutting feature.
288
+ */
289
+ data?: Record<string, string>;
266
290
  }
267
291
  /**
268
292
  * A `TextRun` after the layout engine has resolved its `fontFamily` fallback
@@ -295,6 +319,12 @@ export interface InlineWidget {
295
319
  * Negative = widget ascends above the baseline.
296
320
  */
297
321
  baselineOffset?: number;
322
+ /**
323
+ * Opaque key a renderer can use to look up the widget's actual content
324
+ * (e.g. `renderToSVG`'s `inlineBoxes[id]` SVG fragment). The layout engine
325
+ * only reserves the `width` × `height` box; it never reads this.
326
+ */
327
+ id?: string;
298
328
  }
299
329
  /**
300
330
  * Configuration for list markers (bullet or numbered).
@@ -556,6 +586,20 @@ export interface TextFrame {
556
586
  * Ignored when `writingMode === 'horizontal-tb'`.
557
587
  */
558
588
  textOrientation?: TextOrientation;
589
+ /**
590
+ * Rigid clockwise rotation of the **whole** text block, in degrees, applied
591
+ * after layout as an affine transform about the frame-box centre. This does
592
+ * **not** affect line breaking, measurement or positioning — only the final
593
+ * render transform. Mirrors PowerPoint's shape rotation (`<a:xfrm rot>`).
594
+ *
595
+ * Composes with `writingMode: 'sideways-*'` (which contributes its own ±90°).
596
+ * `0`, `90`, `180`, `270` are the exercised values; other angles are accepted
597
+ * and rotate about the centre without expanding the canvas bounding box.
598
+ *
599
+ * The engine folds this together with the writing-mode rotation and reports
600
+ * the result on `TextFrameLayoutResult.transform`.
601
+ */
602
+ rotation?: number;
559
603
  /**
560
604
  * Base text direction (important for bidi).
561
605
  * `'ltr'` = left-to-right, `'rtl'` = right-to-left.
@@ -1 +1 @@
1
- {"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/types/Document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GAAG,aAAa,GAAG,aAAa,CAAC;AAE1E;;;;;;;;;GASG;AACH,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,UAAU,CAAC;AAE/D;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,SAAS,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAE/F;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE5E;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,GAAG,UAAU,CAAC;AAEhE;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEpF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,GAAG,WAAW,GAAG,YAAY,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,aAAa,GAAG,YAAY,GAAG,aAAa,GAAG,QAAQ,GAAG,SAAS,GAAG,c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C;IACxB;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,SAAS,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC;IAC1B,gEAAgE;IAChE,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC;;;OAGG;IACH,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR,yBAAyB;QACzB,GAAG,EAAE,MAAM,CAAC;QACZ,2BAA2B;QAC3B,KAAK,EAAE,MAAM,CAAC;QACd,4BAA4B;QAC5B,MAAM,EAAE,MAAM,CAAC;QACf,0BAA0B;QAC1B,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF;;;;OAIG;IACH,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,2CAA2C;IAC3C,UAAU,EAAE,SAAS,EAAE,CAAC;IACxB;;;OAGG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,cAAc,CAAC,CAAC,CAAC;CACzE;AAID;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,cAMpC,CAAC;AAEH;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,OAAO,CAM9C,CAAC"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * TableTypes.ts — TableFrame input types (Logical level), alongside TextFrame.
3
+ *
4
+ * Hierarchy: TableFrame → TableRow[] → TableCell[] → TextFrame (recursive —
5
+ * a cell's content is laid out and rendered exactly like a normal text box).
6
+ *
7
+ * The style surface (per-side widths/colors/patterns, CSS-style 1/2/4-value
8
+ * shorthand) is deliberately modelled on `svg-table-core`'s `common-types.ts` /
9
+ * `private-types.ts` (github.com/wootra/svg-table) — a well-shaped API for this
10
+ * exact problem — adapted so cell content is a `TextFrame` instead of a render
11
+ * callback, and column/row sizing is measured from that content rather than
12
+ * required from the caller.
13
+ *
14
+ * T0/T1 (this file + TableLayoutEngine.ts): grid sizing + colSpan/rowSpan.
15
+ * T2: solid per-side borders + uniform corner radius. T3 (this update): dash
16
+ * patterns + per-side stroke-linecap. Asymmetric corner radii remain a
17
+ * possible future addition.
18
+ */
19
+ import type { TextFrame, VerticalAlignment } from './Document.js';
20
+ /**
21
+ * CSS-style shorthand for a per-side value of type `T`.
22
+ * `v` = all four sides; `[tb, lr]` = top/bottom, left/right; `[t, r, b, l]` =
23
+ * one per side (CSS clockwise order).
24
+ */
25
+ export type Sides<T> = T | [T, T] | [T, T, T, T];
26
+ /** `Sides<number>` — paddings, margins, border widths. */
27
+ export type Widths = Sides<number>;
28
+ /** `Sides<string>` — border colors. */
29
+ export type ColorsOnWidth = Sides<string>;
30
+ /** SVG `stroke-linecap` for a border's dash pattern (or its solid ends). */
31
+ export type BorderLineCap = 'butt' | 'round' | 'square';
32
+ /**
33
+ * Per-side SVG `stroke-dasharray`. Not a `Sides<number[]>` — a flat
34
+ * `number[]` (one pattern for every side) is structurally indistinguishable
35
+ * from a 2- or 4-element `Sides` tuple once the element type is itself an
36
+ * array, so this is its own explicit union (same shape svg-table-core's
37
+ * `PatternArrays` uses, for the same reason): `[a, b]` = one pattern on all
38
+ * four sides; `[[tb], [lr]]` = top/bottom, left/right; `[[t], [r], [b], [l]]`
39
+ * = one per side (CSS clockwise order). `undefined` (or an absent side) =
40
+ * solid.
41
+ */
42
+ export type BorderPatterns = number[] | [number[], number[]] | [number[], number[], number[], number[]];
43
+ /**
44
+ * Solid per-side border + a uniform corner radius. Shared by `TableStyle`
45
+ * (the table's own outer border), `TableRowStyle` and `TableCellStyle`.
46
+ *
47
+ * @see TableTypes.ts header — modelled on svg-table-core's `BorderStyles`.
48
+ * Asymmetric corner radii are a possible future addition; everything
49
+ * else in svg-table-core's `BorderStyles` is covered.
50
+ */
51
+ export interface BorderStyles {
52
+ /** Per-side border width, CSS shorthand. `0` (absent) = no border on that side. */
53
+ borderWidths?: Widths;
54
+ /** Per-side border color, CSS shorthand. Default `'#000'` when a width is set. */
55
+ borderColors?: ColorsOnWidth;
56
+ /**
57
+ * Per-side SVG `stroke-dasharray`. A side with no pattern (or the whole
58
+ * property absent) is a solid line. `[4, 2]` = 4px dash, 2px gap, repeating.
59
+ */
60
+ borderPatterns?: BorderPatterns;
61
+ /** Per-side `stroke-linecap` for that side's (dashed or solid) line. Default `'butt'`. */
62
+ borderShapes?: Sides<BorderLineCap>;
63
+ /** Uniform corner radius (all four corners). Asymmetric radii are a future addition. */
64
+ rx?: number;
65
+ /** Uniform corner radius; defaults to `rx` when only one is given. */
66
+ ry?: number;
67
+ }
68
+ /** Style for a single `TableCell`. Falls back to `TableFrame.defaultCellStyle`. */
69
+ export interface TableCellStyle extends BorderStyles {
70
+ /** Cell background fill. */
71
+ bgColor?: string;
72
+ /** Inner padding, CSS shorthand. Default `8` on all sides. */
73
+ paddings?: Widths;
74
+ /** Vertical alignment of the cell's content within its row height. Default `'top'`. */
75
+ verticalAlign?: VerticalAlignment;
76
+ /**
77
+ * Fine-tuning nudge applied to the cell's content position, in px, on top of
78
+ * padding/alignment/`verticalAlign`. Positive `cx` moves right, positive
79
+ * `cy` moves down. Default `0`.
80
+ */
81
+ cx?: number;
82
+ /** @see cx */
83
+ cy?: number;
84
+ /**
85
+ * Let content wider/taller than the cell's padding box paint past its
86
+ * edges instead of being clipped. Default `false` (clipped) — matches
87
+ * `svg-table-core`'s default.
88
+ */
89
+ allowOverflow?: boolean;
90
+ }
91
+ /**
92
+ * One table cell. `content` is usually a full `TextFrame` — the same
93
+ * recursive shape as everywhere else in vyaz, laid out and rendered like any
94
+ * other text box — but can also be a `TableFrame`, nesting a table inside
95
+ * this cell (distinguished by shape: a `TableFrame` has `rows`, a `TextFrame`
96
+ * has `paragraphs` — see `isNestedTable` in `TableLayoutEngine.ts`).
97
+ *
98
+ * `content.width` and `content.wrap` (`TextFrame`) / `content.width`
99
+ * (`TableFrame`) are overridden by the table layout (the column width
100
+ * decides them); set everything else as usual.
101
+ *
102
+ * Nesting depth is unbounded here (a `TableFrame` cell can itself contain a
103
+ * cell with a `TableFrame`, and so on) but `layoutTableFrame` throws past a
104
+ * hard ceiling (50) as a guard against a pathological/cyclic structure — see
105
+ * `TableLayoutOptions._depth`. `@vyaz/converters`'s own HTML `<table>`-in-`<table>`
106
+ * conversion does not yet build this shape (still a follow-up); this is the
107
+ * `TableFrame`-level primitive it would build on.
108
+ */
109
+ export interface TableCell {
110
+ content: TextFrame | TableFrame;
111
+ /**
112
+ * Columns this cell spans. Default `1`. `'auto'` — only honoured on the
113
+ * *last* cell of a row — stretches it to fill every remaining column, so a
114
+ * ragged/short row lines its trailing border up with the widest row
115
+ * instead of leaving a gap. Unlike svg-table-core (where the last cell of
116
+ * *every* row does this implicitly), this is opt-in: a genuinely short
117
+ * last cell keeps `colSpan: 1` unless you ask for `'auto'`. Elsewhere in a
118
+ * row (not the last cell) `'auto'` is a no-op (`colSpan: 1`) — expanding a
119
+ * non-trailing cell would overlap the cells after it.
120
+ */
121
+ colSpan?: number | 'auto';
122
+ /** Rows this cell spans. Default `1`. */
123
+ rowSpan?: number;
124
+ style?: Partial<TableCellStyle>;
125
+ /**
126
+ * Decorative content anchored to the cell's left edge, vertically centered
127
+ * in the cell's full height — independent of `content`'s own alignment
128
+ * (an icon glyph, a status marker, a leading label). Laid out unwrapped at
129
+ * its own natural size and does *not* contribute to column-width
130
+ * measurement — a narrow column can make `before`/`after` overlap
131
+ * `content`, same tradeoff as `allowOverflow`. svg-table-core's `before`
132
+ * accepts arbitrary render callbacks; this is a `TextFrame` like every
133
+ * other content slot in vyaz, not an arbitrary-content callback.
134
+ */
135
+ before?: TextFrame;
136
+ /** @see before — anchored to the right edge instead. */
137
+ after?: TextFrame;
138
+ }
139
+ /** Style for a `TableRow`. Falls back to `TableFrame.defaultRowStyle`. */
140
+ export interface TableRowStyle extends BorderStyles {
141
+ /** Explicit row height override, in px. Auto (tallest cell) when absent. */
142
+ height?: number;
143
+ /** Row background fill, painted under `TableCellStyle.bgColor`. */
144
+ bgColor?: string;
145
+ }
146
+ export interface TableRow {
147
+ cells: TableCell[];
148
+ style?: Partial<TableRowStyle>;
149
+ /** Informational — a header row (`<thead>`/`<th>`). No layout effect yet. */
150
+ isHeader?: boolean;
151
+ }
152
+ /** Table-wide style. */
153
+ export interface TableStyle extends BorderStyles {
154
+ /** Outer margin around the whole table, CSS shorthand. Default `0`. */
155
+ margins?: Widths;
156
+ /** Table background fill, painted under row/cell backgrounds. */
157
+ bgColor?: string;
158
+ /** Gap between columns, in px. Default `0`. */
159
+ colGaps?: number;
160
+ /** Gap between rows, in px. Default `0`. */
161
+ rowGaps?: number;
162
+ }
163
+ /**
164
+ * Root table container — sibling of `TextFrame`.
165
+ *
166
+ * Column widths are measured from cell content (each cell's natural,
167
+ * unwrapped width) unless `columnWidths` is given; row heights are measured
168
+ * from the laid-out cell content unless `rowHeights` is given.
169
+ */
170
+ export interface TableFrame {
171
+ rows: TableRow[];
172
+ /**
173
+ * Total table width in px. When set and narrower than the natural column
174
+ * widths, columns shrink proportionally and cell text wraps; when wider,
175
+ * the extra space is distributed across columns. Auto (sum of natural
176
+ * column widths) when absent.
177
+ */
178
+ width?: number;
179
+ /**
180
+ * Total table height in px. When set, row heights (whichever way they
181
+ * were determined — measured or `rowHeights` below) scale proportionally
182
+ * to fit it: taller gives every row extra room; shorter shrinks them,
183
+ * which (unlike `width`) can't be absorbed by reflowing text — content
184
+ * simply overflows its row past a certain point (see `TableCellStyle.
185
+ * allowOverflow`). Auto (sum of row heights) when absent.
186
+ */
187
+ height?: number;
188
+ /** Explicit per-column width override, in px. Overrides measurement. */
189
+ columnWidths?: number[];
190
+ /** Explicit per-row height override, in px. Overrides measurement. */
191
+ rowHeights?: number[];
192
+ style?: Partial<TableStyle>;
193
+ /** Default style merged under every `TableCell.style`. */
194
+ defaultCellStyle?: Partial<TableCellStyle>;
195
+ /** Default style merged under every `TableRow.style`. */
196
+ defaultRowStyle?: Partial<TableRowStyle>;
197
+ }
198
+ //# sourceMappingURL=TableTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TableTypes.d.ts","sourceRoot":"","sources":["../../src/types/TableTypes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIlE;;;;GAIG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjD,0DAA0D;AAC1D,MAAM,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAEnC,uCAAuC;AACvC,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAE1C,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;AAExD;;;;;;;;;GASG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;AAExG;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,mFAAmF;IACnF,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,YAAY,CAAC,EAAE,aAAa,CAAC;IAC7B;;;OAGG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,0FAA0F;IAC1F,YAAY,CAAC,EAAE,KAAK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M,WAAW,UAAW,SAAQ,YAAY;IAC9C,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IAC5B,0DAA0D;IAC1D,gBAAgB,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3C,yDAAyD;IACzD,eAAe,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1C"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * sides.ts — resolve the CSS-style 1/2/4-value `Sides<T>` shorthand used by
3
+ * `TableTypes.ts` (`v` | `[tb, lr]` | `[t, r, b, l]`, CSS clockwise order).
4
+ * `Widths` (numbers — paddings/margins/border widths) and `ColorsOnWidth`
5
+ * (strings — border colors) are both instances of `Sides<T>`.
6
+ */
7
+ import type { Sides, Widths, ColorsOnWidth, BorderLineCap, BorderPatterns } from '../types/TableTypes.js';
8
+ export type Side = 'top' | 'right' | 'bottom' | 'left';
9
+ /** Resolve one side of a `Sides<T>` shorthand. `undefined` → `fallback`. */
10
+ export declare function resolveSide<T>(v: Sides<T> | undefined, side: Side, fallback: T): T;
11
+ /** Resolve all four sides of a `Sides<T>` shorthand at once. */
12
+ export declare function resolveAllSides<T>(v: Sides<T> | undefined, fallback: T): Record<Side, T>;
13
+ /** `resolveAllSides` for `Widths` (numbers). Default fallback `0`. */
14
+ export declare function resolveWidths(w: Widths | undefined, fallback?: number): Record<Side, number>;
15
+ /** `resolveAllSides` for `ColorsOnWidth` (strings). Default fallback `'#000'`. */
16
+ export declare function resolveColors(c: ColorsOnWidth | undefined, fallback?: string): Record<Side, string>;
17
+ /**
18
+ * Resolve `borderPatterns` per side. Not `resolveAllSides` — `BorderPatterns`
19
+ * isn't a `Sides<number[]>` (see its doc comment): a flat `number[]` (one
20
+ * pattern for every side) is disambiguated from a 2/4-element tuple of
21
+ * patterns by inspecting the element type instead.
22
+ */
23
+ export declare function resolvePatterns(p: BorderPatterns | undefined): Record<Side, number[] | undefined>;
24
+ /** `resolveAllSides` for `borderShapes` (stroke-linecap). Default fallback `'butt'`. */
25
+ export declare function resolveShapes(s: Sides<BorderLineCap> | undefined, fallback?: BorderLineCap): Record<Side, BorderLineCap>;
26
+ //# sourceMappingURL=sides.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sides.d.ts","sourceRoot":"","sources":["../../src/utils/sides.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAE1G,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,GAAG,CAAC,CASlF;AAED,gEAAgE;AAChE,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAOxF;AAED,sEAAsE;AACtE,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAI,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAEvF;AAED,kFAAkF;AAClF,wBAAgB,aAAa,CAAC,CAAC,EAAE,aAAa,GAAG,SAAS,EAAE,QAAQ,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAEnG;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,GAAG,SAAS,GAAG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC,CAajG;AAED,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,SAAS,EAAE,QAAQ,GAAE,aAAsB,GAAG,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,CAEhI"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * widths.ts — resolve the CSS-style 1/2/4-value `Widths` shorthand used by
3
+ * `TableTypes.ts` (`n` | `[tb, lr]` | `[t, r, b, l]`, CSS clockwise order).
4
+ */
5
+ import type { Widths } from '../types/TableTypes.js';
6
+ export type Side = 'top' | 'right' | 'bottom' | 'left';
7
+ /** Resolve one side of a `Widths` shorthand. `undefined` → `fallback` (default `0`). */
8
+ export declare function resolveWidth(w: Widths | undefined, side: Side, fallback?: number): number;
9
+ /** Resolve all four sides at once. */
10
+ export declare function resolveWidths(w: Widths | undefined, fallback?: number): {
11
+ top: number;
12
+ right: number;
13
+ bottom: number;
14
+ left: number;
15
+ };
16
+ //# sourceMappingURL=widths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"widths.d.ts","sourceRoot":"","sources":["../../src/utils/widths.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEvD,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,SAAI,GAAG,MAAM,CASpF;AAED,sCAAsC;AACtC,wBAAgB,aAAa,CAAC,CAAC,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,SAAI,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAO/H"}
package/package.json CHANGED
@@ -1,6 +1,15 @@
1
1
  {
2
2
  "name": "@vyaz/core",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
+ "description": "Rich-text layout engine — TypeScript, isomorphic (browser + Bun/Node.js), pixel-perfect typography. TextFrame/paragraph layout plus a TableFrame grid layout (colSpan/rowSpan, borders, nested tables).",
5
+ "keywords": ["text-layout", "typography", "svg", "table-layout", "rich-text", "font-metrics", "canvas-text"],
6
+ "license": "MIT",
7
+ "homepage": "https://sedrew.github.io/vyaz/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/sedrew/vyaz.git",
11
+ "directory": "packages/core"
12
+ },
4
13
  "type": "module",
5
14
  "main": "./dist/index.js",
6
15
  "types": "./dist/index.d.ts",