@vyaz/core 0.0.16 → 0.3.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.
- package/README.md +35 -0
- package/bin/vyaz.js +27 -0
- package/dist/cli/check.d.ts +12 -0
- package/dist/cli/check.d.ts.map +1 -0
- package/dist/cli/check.js +4077 -0
- package/dist/compile/ParagraphCompiler.d.ts +84 -0
- package/dist/compile/ParagraphCompiler.d.ts.map +1 -0
- package/dist/debug/lines-to-yaml.d.ts +14 -0
- package/dist/debug/lines-to-yaml.d.ts.map +1 -0
- package/dist/debug.d.ts +11 -0
- package/dist/debug.d.ts.map +1 -0
- package/dist/debug.js +4 -0
- package/dist/index.browser.d.ts +11 -4
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +3244 -4669
- package/dist/index.d.ts +15 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5133 -811
- package/dist/layout/AutoFitEngine.d.ts.map +1 -1
- package/dist/layout/LineBoxValidator.d.ts +5 -10
- package/dist/layout/LineBoxValidator.d.ts.map +1 -1
- package/dist/layout/ParagraphLayoutEngine.d.ts +13 -8
- package/dist/layout/ParagraphLayoutEngine.d.ts.map +1 -1
- package/dist/layout/PositioningEngine.d.ts +1 -1
- package/dist/layout/PositioningEngine.d.ts.map +1 -1
- package/dist/layout/TableLayoutEngine.d.ts +174 -0
- package/dist/layout/TableLayoutEngine.d.ts.map +1 -0
- package/dist/layout/TextFrameLayoutEngine.d.ts +115 -16
- package/dist/layout/TextFrameLayoutEngine.d.ts.map +1 -1
- package/dist/layout/create-engine.d.ts +32 -0
- package/dist/layout/create-engine.d.ts.map +1 -0
- package/dist/layout/resolve-font.d.ts +25 -0
- package/dist/layout/resolve-font.d.ts.map +1 -0
- package/dist/measure/FontEngine.d.ts +44 -1
- package/dist/measure/FontEngine.d.ts.map +1 -1
- package/dist/measure/FontMetricsProvider.d.ts +3 -10
- package/dist/measure/FontMetricsProvider.d.ts.map +1 -1
- package/dist/measure/FontkitMeasureContext.d.ts +109 -0
- package/dist/measure/FontkitMeasureContext.d.ts.map +1 -0
- package/dist/measure/canvas-polyfill.d.ts.map +1 -1
- package/dist/types/Document.d.ts +73 -28
- package/dist/types/Document.d.ts.map +1 -1
- package/dist/types/FontTypes.d.ts +1 -1
- package/dist/types/FontTypes.d.ts.map +1 -1
- package/dist/types/LayoutTypes.d.ts +19 -2
- package/dist/types/LayoutTypes.d.ts.map +1 -1
- package/dist/types/TableTypes.d.ts +198 -0
- package/dist/types/TableTypes.d.ts.map +1 -0
- package/dist/utils/sides.d.ts +26 -0
- package/dist/utils/sides.d.ts.map +1 -0
- package/dist/utils/widths.d.ts +16 -0
- package/dist/utils/widths.d.ts.map +1 -0
- package/package.json +25 -4
|
@@ -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/html`'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.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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,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vyaz/core",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.3.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",
|
|
7
16
|
"files": [
|
|
8
|
-
"dist"
|
|
17
|
+
"dist",
|
|
18
|
+
"bin"
|
|
9
19
|
],
|
|
20
|
+
"bin": {
|
|
21
|
+
"vyaz": "./bin/vyaz.js"
|
|
22
|
+
},
|
|
10
23
|
"sideEffects": false,
|
|
11
24
|
"publishConfig": {
|
|
12
25
|
"access": "public"
|
|
@@ -18,6 +31,13 @@
|
|
|
18
31
|
"browser": "./dist/index.browser.js",
|
|
19
32
|
"types": "./dist/index.d.ts",
|
|
20
33
|
"default": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./debug": {
|
|
36
|
+
"bun": "./src/debug.ts",
|
|
37
|
+
"node": "./dist/debug.js",
|
|
38
|
+
"browser": "./dist/debug.browser.js",
|
|
39
|
+
"types": "./dist/debug.d.ts",
|
|
40
|
+
"default": "./dist/debug.js"
|
|
21
41
|
}
|
|
22
42
|
},
|
|
23
43
|
"browser": {
|
|
@@ -28,12 +48,12 @@
|
|
|
28
48
|
"child_process": false
|
|
29
49
|
},
|
|
30
50
|
"scripts": {
|
|
31
|
-
"build": "bun build ./src/index.ts --outdir ./dist --target bun --external
|
|
51
|
+
"build": "bun build ./src/index.ts --outdir ./dist --target bun --external js-yaml --external @napi-rs/canvas --external fontkit --external get-system-fonts && bun build ./src/index.browser.ts --outdir ./dist --outfile ./dist/index.browser.js --target browser && bun build ./src/debug.ts --outdir ./dist --target bun --external js-yaml && bun build ./src/debug.ts --outdir ./dist --outfile ./dist/debug.browser.js --target browser && bun build ./src/cli/check.ts --outdir ./dist/cli --target bun --external @napi-rs/canvas --external fontkit --external get-system-fonts && tsc -b",
|
|
32
52
|
"prepublishOnly": "bun run build",
|
|
53
|
+
"vendor:pretext": "bun run scripts/vendor-pretext.ts",
|
|
33
54
|
"test": "bun test"
|
|
34
55
|
},
|
|
35
56
|
"dependencies": {
|
|
36
|
-
"@chenglou/pretext": "^0.0.8",
|
|
37
57
|
"js-yaml": "^5.0.0"
|
|
38
58
|
},
|
|
39
59
|
"optionalDependencies": {
|
|
@@ -42,6 +62,7 @@
|
|
|
42
62
|
"get-system-fonts": "^2.0.2"
|
|
43
63
|
},
|
|
44
64
|
"devDependencies": {
|
|
65
|
+
"@chenglou/pretext": "^0.0.8",
|
|
45
66
|
"@types/node": "^26.0.0",
|
|
46
67
|
"@clean-jsdoc-theme/typedoc": "^5.0.6",
|
|
47
68
|
"typedoc": "^0.28.19"
|