@vyaz/core 0.0.4 → 0.0.6
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.
- package/README.md +156 -0
- package/dist/compile/DocumentCompiler.d.ts +40 -0
- package/dist/index.browser.d.ts +28 -0
- package/dist/index.browser.js +18 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +11 -147930
- package/dist/layout/AutoFitEngine.d.ts +44 -0
- package/dist/layout/LineBoxValidator.d.ts +25 -0
- package/dist/layout/ParagraphLayoutEngine.d.ts +46 -0
- package/dist/layout/PositioningEngine.d.ts +68 -0
- package/dist/layout/TextFrameLayoutEngine.d.ts +50 -0
- package/dist/layout/estimateWidth.d.ts +36 -0
- package/dist/measure/FontEngine.d.ts +47 -0
- package/dist/measure/FontMetricsProvider.d.ts +49 -0
- package/dist/measure/FontNotFoundError.d.ts +6 -0
- package/dist/measure/SystemFontRegistry.d.ts +46 -0
- package/dist/measure/canvas-polyfill.d.ts +30 -0
- package/dist/types/Document.d.ts +593 -0
- package/dist/types/FontTypes.d.ts +61 -0
- package/dist/types/LayoutTypes.d.ts +128 -0
- package/dist/utils/env.d.ts +11 -0
- package/dist/utils/font.d.ts +16 -0
- package/dist/utils/groupLinesByParagraph.d.ts +44 -0
- package/dist/utils/list.d.ts +41 -0
- package/dist/utils/textTransform.d.ts +32 -0
- package/package.json +30 -13
- package/src/compile/DocumentCompiler.ts +0 -136
- package/src/index.ts +0 -80
- package/src/layout/AutoFitEngine.ts +0 -101
- package/src/layout/LineBoxValidator.ts +0 -162
- package/src/layout/ParagraphLayoutEngine.ts +0 -202
- package/src/layout/PositioningEngine.ts +0 -401
- package/src/layout/TextFrameLayoutEngine.ts +0 -91
- package/src/measure/FontMetricsProvider.ts +0 -226
- package/src/measure/FontNotFoundError.ts +0 -16
- package/src/measure/SystemFontRegistry.ts +0 -151
- package/src/measure/canvas-polyfill.d.ts +0 -6
- package/src/measure/canvas-polyfill.ts +0 -235
- package/src/measure/fontkit.d.ts +0 -44
- package/src/types/Document.ts +0 -540
- package/src/types/FontTypes.ts +0 -74
- package/src/types/LayoutTypes.ts +0 -141
package/src/types/LayoutTypes.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LayoutTypes.ts — output types (Physical Box Model).
|
|
3
|
-
*
|
|
4
|
-
* ParagraphLayoutResult → Line[] → Span[]
|
|
5
|
-
* This is the contract between layout engine and renderers.
|
|
6
|
-
*
|
|
7
|
-
* Based on plan.md §2.5 (Output — Physical Box Model / Layout Tree)
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import type { TextRun, InlineWidget, TextAlignment } from './Document.js';
|
|
11
|
-
|
|
12
|
-
// ── Span (render atom, formerly FragmentBox) ─────────────────────────────
|
|
13
|
-
|
|
14
|
-
export interface Span {
|
|
15
|
-
/** Offset from Line.x */
|
|
16
|
-
x: number;
|
|
17
|
-
/** Physical span width */
|
|
18
|
-
width: number;
|
|
19
|
-
/** Span text (or " " for justify spaces) */
|
|
20
|
-
text: string;
|
|
21
|
-
/** Index of the source run in the paragraph's `children` array. */
|
|
22
|
-
itemIndex: number;
|
|
23
|
-
/** ID of the source paragraph (for SVG grouping). */
|
|
24
|
-
paragraphId?: string;
|
|
25
|
-
|
|
26
|
-
/** Physical font metrics for this span */
|
|
27
|
-
fontMetrics: SpanFontMetrics;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* A snapshot of the source run's style at layout time.
|
|
31
|
-
* Copied from the corresponding `TextRun` in the paragraph's `children` array.
|
|
32
|
-
*/
|
|
33
|
-
style: TextRun;
|
|
34
|
-
|
|
35
|
-
/** InlineWidget data (if span is an inline-box) */
|
|
36
|
-
inlineWidget?: InlineWidget;
|
|
37
|
-
|
|
38
|
-
/** Per-character advance widths (for selection/tracking) */
|
|
39
|
-
glyphAdvances?: number[];
|
|
40
|
-
|
|
41
|
-
/** Span type: 'text' — regular text, 'space' — whitespace span */
|
|
42
|
-
type: 'text' | 'space';
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Trailing whitespace flag.
|
|
46
|
-
* - true: span is at end of line, does not participate in line advance
|
|
47
|
-
* and is not stretched during justify (zero width for calculations).
|
|
48
|
-
* - undefined/false: regular span.
|
|
49
|
-
*
|
|
50
|
-
* See CSS Text Module Level 3 §4.1.3 (Tracking and Dropping Spaces)
|
|
51
|
-
* and Parley LineItemData::has_trailing_whitespace.
|
|
52
|
-
*/
|
|
53
|
-
trailing?: boolean;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Line break mode after this span.
|
|
57
|
-
* 'soft' — soft line break (insufficient space)
|
|
58
|
-
* 'hard' — forced break (\n, explicit separator)
|
|
59
|
-
* undefined — not end of line
|
|
60
|
-
*/
|
|
61
|
-
breakType?: 'soft' | 'hard';
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export interface SpanFontMetrics {
|
|
65
|
-
ascent: number;
|
|
66
|
-
descent: number;
|
|
67
|
-
fontSize: number;
|
|
68
|
-
/** Vertical offset from baseline (px). Used for sub/superscript positioning.
|
|
69
|
-
* Negative = above baseline (superscript). Positive = below baseline (subscript).
|
|
70
|
-
* Undefined or 0 = normal baseline position. */
|
|
71
|
-
baselineOffset?: number;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// ── Line (single line, formerly LineBox) ─────────────────────────────────
|
|
75
|
-
|
|
76
|
-
export interface Line {
|
|
77
|
-
/** Absolute X within container (alignment + indent) */
|
|
78
|
-
x: number;
|
|
79
|
-
/** Absolute Y of line top edge */
|
|
80
|
-
y: number;
|
|
81
|
-
/** Line content width (without alignment) */
|
|
82
|
-
width: number;
|
|
83
|
-
/** Full line height (max spans × lineHeight) */
|
|
84
|
-
height: number;
|
|
85
|
-
|
|
86
|
-
/** Baseline offset from y */
|
|
87
|
-
baseline: number;
|
|
88
|
-
/** Maximum ascent in line */
|
|
89
|
-
ascent: number;
|
|
90
|
-
/** Maximum descent in line */
|
|
91
|
-
descent: number;
|
|
92
|
-
|
|
93
|
-
/** Index of first character in the original paragraph text */
|
|
94
|
-
startIndex: number;
|
|
95
|
-
/** Index of last character + 1 (for convenient length calculation) */
|
|
96
|
-
endIndex: number;
|
|
97
|
-
|
|
98
|
-
/** Paragraph alignment (optional, for PowerPoint render) */
|
|
99
|
-
alignment?: TextAlignment;
|
|
100
|
-
|
|
101
|
-
spans: Span[];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
// ── ParagraphLayoutResult (single paragraph) ─────────────────────────────
|
|
105
|
-
|
|
106
|
-
export interface ParagraphLayoutResult {
|
|
107
|
-
width: number; // paragraph width (maxWidth)
|
|
108
|
-
height: number; // full paragraph height including spacing
|
|
109
|
-
lines: Line[];
|
|
110
|
-
/** Actual content width (text bbox, without voids) */
|
|
111
|
-
contentWidth: number;
|
|
112
|
-
/** Actual content height (text bbox) */
|
|
113
|
-
contentHeight: number;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// ── Text region for YAML snapshots ───────────────────────────────────────
|
|
117
|
-
|
|
118
|
-
/** Semantic span for snapshots (without physical metrics) */
|
|
119
|
-
export interface SemanticFragment {
|
|
120
|
-
text: string;
|
|
121
|
-
x: number;
|
|
122
|
-
width: number;
|
|
123
|
-
style?: 'bold' | 'italic' | 'normal';
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/** Semantic line for snapshots */
|
|
127
|
-
export interface SemanticLine {
|
|
128
|
-
y: number;
|
|
129
|
-
width: number;
|
|
130
|
-
height: number;
|
|
131
|
-
baseline: number;
|
|
132
|
-
fragments: SemanticFragment[];
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/** Semantic paragraph for YAML snapshots */
|
|
136
|
-
export interface SemanticParagraph {
|
|
137
|
-
width: number;
|
|
138
|
-
height: number;
|
|
139
|
-
lines: SemanticLine[];
|
|
140
|
-
}
|
|
141
|
-
|