@formepdf/shared 0.11.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 +7 -0
- package/dist/canvas.d.ts +6 -0
- package/dist/canvas.js +43 -0
- package/dist/charts.d.ts +100 -0
- package/dist/charts.js +98 -0
- package/dist/font.d.ts +13 -0
- package/dist/font.js +52 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +10 -0
- package/dist/semantics.d.ts +15 -0
- package/dist/semantics.js +44 -0
- package/dist/style.d.ts +7 -0
- package/dist/style.js +1024 -0
- package/dist/types.d.ts +743 -0
- package/dist/types.js +2 -0
- package/package.json +30 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,743 @@
|
|
|
1
|
+
/** Edge values for padding, margin, borderWidth */
|
|
2
|
+
export interface Edges {
|
|
3
|
+
top: number;
|
|
4
|
+
right: number;
|
|
5
|
+
bottom: number;
|
|
6
|
+
left: number;
|
|
7
|
+
}
|
|
8
|
+
/** Corner values for borderRadius */
|
|
9
|
+
export interface Corners {
|
|
10
|
+
topLeft: number;
|
|
11
|
+
topRight: number;
|
|
12
|
+
bottomRight: number;
|
|
13
|
+
bottomLeft: number;
|
|
14
|
+
}
|
|
15
|
+
/** A single CSS Grid track size */
|
|
16
|
+
export type GridTrackSize = number | `${number}fr` | 'auto' | {
|
|
17
|
+
min: GridTrackSize;
|
|
18
|
+
max: GridTrackSize;
|
|
19
|
+
};
|
|
20
|
+
/** Per-edge colors for borderColor */
|
|
21
|
+
export interface EdgeColors {
|
|
22
|
+
top: string;
|
|
23
|
+
right: string;
|
|
24
|
+
bottom: string;
|
|
25
|
+
left: string;
|
|
26
|
+
}
|
|
27
|
+
/** CSS-like style properties for Forme components */
|
|
28
|
+
export interface Style {
|
|
29
|
+
display?: 'flex' | 'grid';
|
|
30
|
+
width?: number | string;
|
|
31
|
+
height?: number | string;
|
|
32
|
+
minWidth?: number | string;
|
|
33
|
+
minHeight?: number | string;
|
|
34
|
+
maxWidth?: number | string;
|
|
35
|
+
maxHeight?: number | string;
|
|
36
|
+
flexDirection?: 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
37
|
+
flex?: number;
|
|
38
|
+
flexGrow?: number;
|
|
39
|
+
flexShrink?: number;
|
|
40
|
+
flexBasis?: number | string;
|
|
41
|
+
flexWrap?: 'nowrap' | 'wrap' | 'wrap-reverse';
|
|
42
|
+
justifyContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly';
|
|
43
|
+
alignItems?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
44
|
+
alignSelf?: 'flex-start' | 'flex-end' | 'center' | 'stretch' | 'baseline';
|
|
45
|
+
alignContent?: 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around' | 'space-evenly' | 'stretch';
|
|
46
|
+
gap?: number;
|
|
47
|
+
rowGap?: number;
|
|
48
|
+
columnGap?: number;
|
|
49
|
+
/** Column track definitions. String shorthand: `"1fr 2fr 200"` or array of track sizes. */
|
|
50
|
+
gridTemplateColumns?: string | GridTrackSize[];
|
|
51
|
+
/** Row track definitions. String shorthand: `"auto 1fr"` or array of track sizes. */
|
|
52
|
+
gridTemplateRows?: string | GridTrackSize[];
|
|
53
|
+
/** Default size for auto-generated rows. */
|
|
54
|
+
gridAutoRows?: GridTrackSize;
|
|
55
|
+
/** Default size for auto-generated columns. */
|
|
56
|
+
gridAutoColumns?: GridTrackSize;
|
|
57
|
+
/** Grid column start line (1-based). */
|
|
58
|
+
gridColumnStart?: number;
|
|
59
|
+
/** Grid column end line (1-based). */
|
|
60
|
+
gridColumnEnd?: number;
|
|
61
|
+
/** Grid row start line (1-based). */
|
|
62
|
+
gridRowStart?: number;
|
|
63
|
+
/** Grid row end line (1-based). */
|
|
64
|
+
gridRowEnd?: number;
|
|
65
|
+
/** Number of columns to span. */
|
|
66
|
+
gridColumnSpan?: number;
|
|
67
|
+
/** Number of rows to span. */
|
|
68
|
+
gridRowSpan?: number;
|
|
69
|
+
padding?: number | string | number[] | Edges;
|
|
70
|
+
paddingTop?: number;
|
|
71
|
+
paddingRight?: number;
|
|
72
|
+
paddingBottom?: number;
|
|
73
|
+
paddingLeft?: number;
|
|
74
|
+
paddingHorizontal?: number;
|
|
75
|
+
paddingVertical?: number;
|
|
76
|
+
margin?: number | string | number[] | Edges;
|
|
77
|
+
marginTop?: number | 'auto';
|
|
78
|
+
marginRight?: number | 'auto';
|
|
79
|
+
marginBottom?: number | 'auto';
|
|
80
|
+
marginLeft?: number | 'auto';
|
|
81
|
+
marginHorizontal?: number | 'auto';
|
|
82
|
+
marginVertical?: number | 'auto';
|
|
83
|
+
fontSize?: number;
|
|
84
|
+
fontFamily?: string;
|
|
85
|
+
fontWeight?: number | 'normal' | 'bold';
|
|
86
|
+
fontStyle?: 'normal' | 'italic' | 'oblique';
|
|
87
|
+
lineHeight?: number;
|
|
88
|
+
textAlign?: 'left' | 'center' | 'right' | 'justify';
|
|
89
|
+
letterSpacing?: number;
|
|
90
|
+
/** Extra width (points) added to each ASCII space — PDF Tw operator.
|
|
91
|
+
* Negative values tighten word gaps. When `textAlign: 'justify'` is
|
|
92
|
+
* set, the layout engine adds the computed slack-per-space on top. */
|
|
93
|
+
wordSpacing?: number;
|
|
94
|
+
/** Drop shadow painted behind the element. Object form is preferred;
|
|
95
|
+
* CSS-like string form `"offsetX offsetY blur color"` is also
|
|
96
|
+
* accepted. v1 paints a solid offset shadow only — `blur` is parsed
|
|
97
|
+
* for forward-compat but ignored. */
|
|
98
|
+
boxShadow?: string | {
|
|
99
|
+
offsetX: number;
|
|
100
|
+
offsetY: number;
|
|
101
|
+
blur?: number;
|
|
102
|
+
color: string;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Paint-only transform applied around the element's origin (default:
|
|
106
|
+
* center). Layout flow is NOT affected — matches CSS `transform`.
|
|
107
|
+
*
|
|
108
|
+
* Accepts a CSS-like string with one or more space-separated ops:
|
|
109
|
+
* `"rotate(45deg)"`
|
|
110
|
+
* `"rotate(-15deg) scale(1.2)"`
|
|
111
|
+
* `"translate(10, -4) rotate(30deg)"`
|
|
112
|
+
*
|
|
113
|
+
* Supported ops: `rotate(<deg>deg)`, `scale(<x>[, <y>])`,
|
|
114
|
+
* `translate(<x>[, <y>])`. Angles are degrees, lengths are points.
|
|
115
|
+
*/
|
|
116
|
+
transform?: string;
|
|
117
|
+
/**
|
|
118
|
+
* Origin of the transform as fractions of the element box.
|
|
119
|
+
* `"50% 50%"` (default) = center, `"0% 0%"` = top-left, `"100% 0%"`
|
|
120
|
+
* = top-right, etc. Also accepts a tuple `[x, y]` where each is 0–1.
|
|
121
|
+
*/
|
|
122
|
+
transformOrigin?: string | [number, number];
|
|
123
|
+
textDecoration?: 'none' | 'underline' | 'line-through';
|
|
124
|
+
textTransform?: 'none' | 'uppercase' | 'lowercase' | 'capitalize';
|
|
125
|
+
hyphens?: 'none' | 'manual' | 'auto';
|
|
126
|
+
/** Language tag (BCP 47, e.g. "en-US", "de"). Controls hyphenation dictionary. */
|
|
127
|
+
lang?: string;
|
|
128
|
+
/** Text direction for BiDi support (Arabic, Hebrew). */
|
|
129
|
+
direction?: 'ltr' | 'rtl' | 'auto';
|
|
130
|
+
/** Text overflow behavior: 'wrap' (default), 'ellipsis' (truncate with ...), 'clip' (truncate). */
|
|
131
|
+
textOverflow?: 'wrap' | 'ellipsis' | 'clip';
|
|
132
|
+
/** Line breaking algorithm: 'optimal' (Knuth-Plass, default) or 'greedy'. */
|
|
133
|
+
lineBreaking?: 'optimal' | 'greedy';
|
|
134
|
+
/** Overflow behavior: 'visible' (default) or 'hidden' (clips children to bounds). */
|
|
135
|
+
overflow?: 'visible' | 'hidden';
|
|
136
|
+
color?: string;
|
|
137
|
+
backgroundColor?: string;
|
|
138
|
+
/**
|
|
139
|
+
* CSS background. Supports:
|
|
140
|
+
* - solid colors (`"#1e293b"`, `"rgba(...)"`) — equivalent to backgroundColor
|
|
141
|
+
* - 2-stop linear gradients: `"linear-gradient(180deg, #fff 0%, #000 100%)"`
|
|
142
|
+
* - 2-stop radial gradients: `"radial-gradient(circle, #fff 0%, #000 100%)"`
|
|
143
|
+
*
|
|
144
|
+
* v1 supports exactly 2 color stops; gradients with 3+ stops fall back to
|
|
145
|
+
* the first and last stop. Multi-stop support is planned via PDF Type 3
|
|
146
|
+
* stitching functions in a follow-up.
|
|
147
|
+
*/
|
|
148
|
+
background?: string;
|
|
149
|
+
opacity?: number;
|
|
150
|
+
borderWidth?: number | Edges;
|
|
151
|
+
borderTopWidth?: number;
|
|
152
|
+
borderRightWidth?: number;
|
|
153
|
+
borderBottomWidth?: number;
|
|
154
|
+
borderLeftWidth?: number;
|
|
155
|
+
borderColor?: string | EdgeColors;
|
|
156
|
+
borderTopColor?: string;
|
|
157
|
+
borderRightColor?: string;
|
|
158
|
+
borderBottomColor?: string;
|
|
159
|
+
borderLeftColor?: string;
|
|
160
|
+
borderRadius?: number | Corners;
|
|
161
|
+
borderTopLeftRadius?: number;
|
|
162
|
+
borderTopRightRadius?: number;
|
|
163
|
+
borderBottomRightRadius?: number;
|
|
164
|
+
borderBottomLeftRadius?: number;
|
|
165
|
+
/** CSS border shorthand, e.g. `"1px solid #000"` */
|
|
166
|
+
border?: string;
|
|
167
|
+
/** Per-side border shorthand: string parses as CSS, number sets width */
|
|
168
|
+
borderTop?: string | number;
|
|
169
|
+
/** Per-side border shorthand: string parses as CSS, number sets width */
|
|
170
|
+
borderRight?: string | number;
|
|
171
|
+
/** Per-side border shorthand: string parses as CSS, number sets width */
|
|
172
|
+
borderBottom?: string | number;
|
|
173
|
+
/** Per-side border shorthand: string parses as CSS, number sets width */
|
|
174
|
+
borderLeft?: string | number;
|
|
175
|
+
position?: 'relative' | 'absolute';
|
|
176
|
+
top?: number;
|
|
177
|
+
right?: number;
|
|
178
|
+
bottom?: number;
|
|
179
|
+
left?: number;
|
|
180
|
+
wrap?: boolean;
|
|
181
|
+
breakBefore?: boolean;
|
|
182
|
+
minWidowLines?: number;
|
|
183
|
+
minOrphanLines?: number;
|
|
184
|
+
}
|
|
185
|
+
export interface CertificationConfig {
|
|
186
|
+
/** PEM-encoded X.509 certificate. */
|
|
187
|
+
certificatePem: string;
|
|
188
|
+
/** PEM-encoded RSA private key (PKCS#8). */
|
|
189
|
+
privateKeyPem: string;
|
|
190
|
+
/** Reason for certification (e.g. "Approved"). */
|
|
191
|
+
reason?: string;
|
|
192
|
+
/** Location of certification (e.g. "New York, NY"). */
|
|
193
|
+
location?: string;
|
|
194
|
+
/** Contact info for the certifier. */
|
|
195
|
+
contact?: string;
|
|
196
|
+
/** Whether to show a visible signature annotation on the page. */
|
|
197
|
+
visible?: boolean;
|
|
198
|
+
/** X coordinate in points for visible signature. */
|
|
199
|
+
x?: number;
|
|
200
|
+
/** Y coordinate in points for visible signature. */
|
|
201
|
+
y?: number;
|
|
202
|
+
/** Width in points for visible signature. */
|
|
203
|
+
width?: number;
|
|
204
|
+
/** Height in points for visible signature. */
|
|
205
|
+
height?: number;
|
|
206
|
+
}
|
|
207
|
+
/** @deprecated Use CertificationConfig */
|
|
208
|
+
export type SignatureConfig = CertificationConfig;
|
|
209
|
+
export interface ColumnDef {
|
|
210
|
+
width: {
|
|
211
|
+
fraction: number;
|
|
212
|
+
} | {
|
|
213
|
+
fixed: number;
|
|
214
|
+
} | 'auto';
|
|
215
|
+
}
|
|
216
|
+
export type BarcodeFormat = 'Code128' | 'Code39' | 'EAN13' | 'EAN8' | 'Codabar';
|
|
217
|
+
/** Data point for bar and pie charts. */
|
|
218
|
+
export interface ChartDataPoint {
|
|
219
|
+
label: string;
|
|
220
|
+
value: number;
|
|
221
|
+
/** Optional per-item color (hex string). */
|
|
222
|
+
color?: string;
|
|
223
|
+
}
|
|
224
|
+
/** @deprecated Use ChartDataPoint instead (color is now optional on ChartDataPoint). */
|
|
225
|
+
export interface PieDataPoint {
|
|
226
|
+
label: string;
|
|
227
|
+
value: number;
|
|
228
|
+
color: string;
|
|
229
|
+
}
|
|
230
|
+
/** A data series for multi-series line and area charts. */
|
|
231
|
+
export interface ChartSeries {
|
|
232
|
+
name: string;
|
|
233
|
+
data: number[];
|
|
234
|
+
/** Optional series color (hex string). */
|
|
235
|
+
color?: string;
|
|
236
|
+
}
|
|
237
|
+
/** A group of (x, y) data points for dot plots. */
|
|
238
|
+
export interface DotPlotGroup {
|
|
239
|
+
name: string;
|
|
240
|
+
/** Optional group color (hex string). */
|
|
241
|
+
color?: string;
|
|
242
|
+
data: [number, number][];
|
|
243
|
+
}
|
|
244
|
+
/** Canvas drawing context for the draw callback. */
|
|
245
|
+
export interface CanvasContext {
|
|
246
|
+
moveTo(x: number, y: number): void;
|
|
247
|
+
lineTo(x: number, y: number): void;
|
|
248
|
+
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
|
|
249
|
+
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
|
|
250
|
+
closePath(): void;
|
|
251
|
+
rect(x: number, y: number, w: number, h: number): void;
|
|
252
|
+
circle(cx: number, cy: number, r: number): void;
|
|
253
|
+
ellipse(cx: number, cy: number, rx: number, ry: number): void;
|
|
254
|
+
arc(cx: number, cy: number, r: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
|
|
255
|
+
/** Convenience: draws a stroked line from (x1,y1) to (x2,y2). */
|
|
256
|
+
line(x1: number, y1: number, x2: number, y2: number): void;
|
|
257
|
+
stroke(): void;
|
|
258
|
+
fill(): void;
|
|
259
|
+
fillAndStroke(): void;
|
|
260
|
+
setFillColor(r: number, g: number, b: number): void;
|
|
261
|
+
setStrokeColor(r: number, g: number, b: number): void;
|
|
262
|
+
setLineWidth(w: number): void;
|
|
263
|
+
setLineCap(cap: number): void;
|
|
264
|
+
setLineJoin(join: number): void;
|
|
265
|
+
save(): void;
|
|
266
|
+
restore(): void;
|
|
267
|
+
}
|
|
268
|
+
/** A single canvas drawing operation (serialized to JSON). */
|
|
269
|
+
export type CanvasOp = {
|
|
270
|
+
op: 'MoveTo';
|
|
271
|
+
x: number;
|
|
272
|
+
y: number;
|
|
273
|
+
} | {
|
|
274
|
+
op: 'LineTo';
|
|
275
|
+
x: number;
|
|
276
|
+
y: number;
|
|
277
|
+
} | {
|
|
278
|
+
op: 'BezierCurveTo';
|
|
279
|
+
cp1x: number;
|
|
280
|
+
cp1y: number;
|
|
281
|
+
cp2x: number;
|
|
282
|
+
cp2y: number;
|
|
283
|
+
x: number;
|
|
284
|
+
y: number;
|
|
285
|
+
} | {
|
|
286
|
+
op: 'QuadraticCurveTo';
|
|
287
|
+
cpx: number;
|
|
288
|
+
cpy: number;
|
|
289
|
+
x: number;
|
|
290
|
+
y: number;
|
|
291
|
+
} | {
|
|
292
|
+
op: 'ClosePath';
|
|
293
|
+
} | {
|
|
294
|
+
op: 'Rect';
|
|
295
|
+
x: number;
|
|
296
|
+
y: number;
|
|
297
|
+
width: number;
|
|
298
|
+
height: number;
|
|
299
|
+
} | {
|
|
300
|
+
op: 'Circle';
|
|
301
|
+
cx: number;
|
|
302
|
+
cy: number;
|
|
303
|
+
r: number;
|
|
304
|
+
} | {
|
|
305
|
+
op: 'Ellipse';
|
|
306
|
+
cx: number;
|
|
307
|
+
cy: number;
|
|
308
|
+
rx: number;
|
|
309
|
+
ry: number;
|
|
310
|
+
} | {
|
|
311
|
+
op: 'Arc';
|
|
312
|
+
cx: number;
|
|
313
|
+
cy: number;
|
|
314
|
+
r: number;
|
|
315
|
+
start_angle: number;
|
|
316
|
+
end_angle: number;
|
|
317
|
+
counterclockwise: boolean;
|
|
318
|
+
} | {
|
|
319
|
+
op: 'Stroke';
|
|
320
|
+
} | {
|
|
321
|
+
op: 'Fill';
|
|
322
|
+
} | {
|
|
323
|
+
op: 'FillAndStroke';
|
|
324
|
+
} | {
|
|
325
|
+
op: 'SetFillColor';
|
|
326
|
+
r: number;
|
|
327
|
+
g: number;
|
|
328
|
+
b: number;
|
|
329
|
+
} | {
|
|
330
|
+
op: 'SetStrokeColor';
|
|
331
|
+
r: number;
|
|
332
|
+
g: number;
|
|
333
|
+
b: number;
|
|
334
|
+
} | {
|
|
335
|
+
op: 'SetLineWidth';
|
|
336
|
+
width: number;
|
|
337
|
+
} | {
|
|
338
|
+
op: 'SetLineCap';
|
|
339
|
+
cap: number;
|
|
340
|
+
} | {
|
|
341
|
+
op: 'SetLineJoin';
|
|
342
|
+
join: number;
|
|
343
|
+
} | {
|
|
344
|
+
op: 'Save';
|
|
345
|
+
} | {
|
|
346
|
+
op: 'Restore';
|
|
347
|
+
};
|
|
348
|
+
/** A styled text segment within a <Text> element */
|
|
349
|
+
export interface TextRun {
|
|
350
|
+
content: string;
|
|
351
|
+
style?: FormeStyle;
|
|
352
|
+
href?: string;
|
|
353
|
+
}
|
|
354
|
+
export interface FormeFont {
|
|
355
|
+
family: string;
|
|
356
|
+
src: string | Uint8Array;
|
|
357
|
+
weight: number;
|
|
358
|
+
italic: boolean;
|
|
359
|
+
}
|
|
360
|
+
export interface FormeDocument {
|
|
361
|
+
children: FormeNode[];
|
|
362
|
+
metadata: FormeMetadata;
|
|
363
|
+
defaultPage: FormePageConfig;
|
|
364
|
+
defaultStyle?: FormeStyle;
|
|
365
|
+
fonts?: FormeFont[];
|
|
366
|
+
tagged?: boolean;
|
|
367
|
+
pdfa?: '2a' | '2b';
|
|
368
|
+
pdfUa?: boolean;
|
|
369
|
+
flattenForms?: boolean;
|
|
370
|
+
certification?: CertificationConfig;
|
|
371
|
+
}
|
|
372
|
+
export interface FormeMetadata {
|
|
373
|
+
title?: string;
|
|
374
|
+
author?: string;
|
|
375
|
+
subject?: string;
|
|
376
|
+
creator?: string;
|
|
377
|
+
lang?: string;
|
|
378
|
+
}
|
|
379
|
+
export interface FormePageConfig {
|
|
380
|
+
size: FormePageSize;
|
|
381
|
+
margin: FormeEdges;
|
|
382
|
+
wrap: boolean;
|
|
383
|
+
backgroundImage?: string;
|
|
384
|
+
backgroundOpacity?: number;
|
|
385
|
+
backgroundSize?: 'fill' | 'cover' | 'contain';
|
|
386
|
+
backgroundPosition?: 'center' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
387
|
+
}
|
|
388
|
+
export type FormePageSize = 'A4' | 'A3' | 'A5' | 'Letter' | 'Legal' | 'Tabloid' | {
|
|
389
|
+
Custom: {
|
|
390
|
+
width: number;
|
|
391
|
+
height: number;
|
|
392
|
+
};
|
|
393
|
+
};
|
|
394
|
+
export interface FormeEdges {
|
|
395
|
+
top: number;
|
|
396
|
+
right: number;
|
|
397
|
+
bottom: number;
|
|
398
|
+
left: number;
|
|
399
|
+
}
|
|
400
|
+
export interface FormeBoxShadow {
|
|
401
|
+
offsetX: number;
|
|
402
|
+
offsetY: number;
|
|
403
|
+
blur?: number;
|
|
404
|
+
color: {
|
|
405
|
+
r: number;
|
|
406
|
+
g: number;
|
|
407
|
+
b: number;
|
|
408
|
+
a: number;
|
|
409
|
+
};
|
|
410
|
+
}
|
|
411
|
+
export interface FormeGradientStop {
|
|
412
|
+
position: number;
|
|
413
|
+
color: {
|
|
414
|
+
r: number;
|
|
415
|
+
g: number;
|
|
416
|
+
b: number;
|
|
417
|
+
a: number;
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
export type FormeBackground = {
|
|
421
|
+
type: 'color';
|
|
422
|
+
value: {
|
|
423
|
+
r: number;
|
|
424
|
+
g: number;
|
|
425
|
+
b: number;
|
|
426
|
+
a: number;
|
|
427
|
+
};
|
|
428
|
+
} | {
|
|
429
|
+
type: 'linear';
|
|
430
|
+
angleDeg: number;
|
|
431
|
+
stops: FormeGradientStop[];
|
|
432
|
+
} | {
|
|
433
|
+
type: 'radial';
|
|
434
|
+
stops: FormeGradientStop[];
|
|
435
|
+
};
|
|
436
|
+
/** Margin edges that support auto values (for centering). */
|
|
437
|
+
export interface FormeMarginEdges {
|
|
438
|
+
top: number | 'auto';
|
|
439
|
+
right: number | 'auto';
|
|
440
|
+
bottom: number | 'auto';
|
|
441
|
+
left: number | 'auto';
|
|
442
|
+
}
|
|
443
|
+
export interface FormeNode {
|
|
444
|
+
kind: FormeNodeKind;
|
|
445
|
+
style: FormeStyle;
|
|
446
|
+
children: FormeNode[];
|
|
447
|
+
bookmark?: string;
|
|
448
|
+
href?: string;
|
|
449
|
+
alt?: string;
|
|
450
|
+
sourceLocation?: {
|
|
451
|
+
file: string;
|
|
452
|
+
line: number;
|
|
453
|
+
column: number;
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
export type FormeNodeKind = {
|
|
457
|
+
type: 'Page';
|
|
458
|
+
config: FormePageConfig;
|
|
459
|
+
} | {
|
|
460
|
+
type: 'View';
|
|
461
|
+
} | {
|
|
462
|
+
type: 'Text';
|
|
463
|
+
content: string;
|
|
464
|
+
href?: string;
|
|
465
|
+
runs?: TextRun[];
|
|
466
|
+
} | {
|
|
467
|
+
type: 'Heading';
|
|
468
|
+
level: number;
|
|
469
|
+
content: string;
|
|
470
|
+
href?: string;
|
|
471
|
+
runs?: TextRun[];
|
|
472
|
+
} | {
|
|
473
|
+
type: 'List';
|
|
474
|
+
ordered: boolean;
|
|
475
|
+
marker_type: FormeListMarkerType;
|
|
476
|
+
start: number;
|
|
477
|
+
} | {
|
|
478
|
+
type: 'ListItem';
|
|
479
|
+
} | {
|
|
480
|
+
type: 'Image';
|
|
481
|
+
src: string;
|
|
482
|
+
width?: number;
|
|
483
|
+
height?: number;
|
|
484
|
+
} | {
|
|
485
|
+
type: 'Table';
|
|
486
|
+
columns: FormeColumnDef[];
|
|
487
|
+
} | {
|
|
488
|
+
type: 'TableRow';
|
|
489
|
+
is_header: boolean;
|
|
490
|
+
} | {
|
|
491
|
+
type: 'TableCell';
|
|
492
|
+
col_span: number;
|
|
493
|
+
row_span: number;
|
|
494
|
+
} | {
|
|
495
|
+
type: 'Fixed';
|
|
496
|
+
position: 'Header' | 'Footer';
|
|
497
|
+
} | {
|
|
498
|
+
type: 'Svg';
|
|
499
|
+
width: number;
|
|
500
|
+
height: number;
|
|
501
|
+
view_box?: string;
|
|
502
|
+
content: string;
|
|
503
|
+
} | {
|
|
504
|
+
type: 'QrCode';
|
|
505
|
+
data: string;
|
|
506
|
+
size?: number;
|
|
507
|
+
} | {
|
|
508
|
+
type: 'Barcode';
|
|
509
|
+
data: string;
|
|
510
|
+
format: BarcodeFormat;
|
|
511
|
+
width?: number;
|
|
512
|
+
height: number;
|
|
513
|
+
} | {
|
|
514
|
+
type: 'Canvas';
|
|
515
|
+
width: number;
|
|
516
|
+
height: number;
|
|
517
|
+
operations: CanvasOp[];
|
|
518
|
+
} | {
|
|
519
|
+
type: 'BarChart';
|
|
520
|
+
data: ChartDataPoint[];
|
|
521
|
+
width: number;
|
|
522
|
+
height: number;
|
|
523
|
+
color?: string;
|
|
524
|
+
show_labels: boolean;
|
|
525
|
+
show_values: boolean;
|
|
526
|
+
show_grid: boolean;
|
|
527
|
+
title?: string;
|
|
528
|
+
} | {
|
|
529
|
+
type: 'LineChart';
|
|
530
|
+
series: ChartSeries[];
|
|
531
|
+
labels: string[];
|
|
532
|
+
width: number;
|
|
533
|
+
height: number;
|
|
534
|
+
show_points: boolean;
|
|
535
|
+
show_grid: boolean;
|
|
536
|
+
title?: string;
|
|
537
|
+
} | {
|
|
538
|
+
type: 'PieChart';
|
|
539
|
+
data: ChartDataPoint[];
|
|
540
|
+
width: number;
|
|
541
|
+
height: number;
|
|
542
|
+
donut: boolean;
|
|
543
|
+
show_legend: boolean;
|
|
544
|
+
title?: string;
|
|
545
|
+
} | {
|
|
546
|
+
type: 'AreaChart';
|
|
547
|
+
series: ChartSeries[];
|
|
548
|
+
labels: string[];
|
|
549
|
+
width: number;
|
|
550
|
+
height: number;
|
|
551
|
+
show_grid: boolean;
|
|
552
|
+
title?: string;
|
|
553
|
+
} | {
|
|
554
|
+
type: 'DotPlot';
|
|
555
|
+
groups: DotPlotGroup[];
|
|
556
|
+
width: number;
|
|
557
|
+
height: number;
|
|
558
|
+
x_min?: number;
|
|
559
|
+
x_max?: number;
|
|
560
|
+
y_min?: number;
|
|
561
|
+
y_max?: number;
|
|
562
|
+
x_label?: string;
|
|
563
|
+
y_label?: string;
|
|
564
|
+
show_legend: boolean;
|
|
565
|
+
dot_size: number;
|
|
566
|
+
} | {
|
|
567
|
+
type: 'Watermark';
|
|
568
|
+
text: string;
|
|
569
|
+
font_size: number;
|
|
570
|
+
angle: number;
|
|
571
|
+
} | {
|
|
572
|
+
type: 'TextField';
|
|
573
|
+
name: string;
|
|
574
|
+
width: number;
|
|
575
|
+
height: number;
|
|
576
|
+
value?: string;
|
|
577
|
+
placeholder?: string;
|
|
578
|
+
multiline: boolean;
|
|
579
|
+
password: boolean;
|
|
580
|
+
read_only: boolean;
|
|
581
|
+
max_length?: number;
|
|
582
|
+
font_size: number;
|
|
583
|
+
} | {
|
|
584
|
+
type: 'Checkbox';
|
|
585
|
+
name: string;
|
|
586
|
+
width: number;
|
|
587
|
+
height: number;
|
|
588
|
+
checked: boolean;
|
|
589
|
+
read_only: boolean;
|
|
590
|
+
} | {
|
|
591
|
+
type: 'Dropdown';
|
|
592
|
+
name: string;
|
|
593
|
+
options: string[];
|
|
594
|
+
width: number;
|
|
595
|
+
height: number;
|
|
596
|
+
value?: string;
|
|
597
|
+
read_only: boolean;
|
|
598
|
+
font_size: number;
|
|
599
|
+
} | {
|
|
600
|
+
type: 'RadioButton';
|
|
601
|
+
name: string;
|
|
602
|
+
value: string;
|
|
603
|
+
width: number;
|
|
604
|
+
height: number;
|
|
605
|
+
checked: boolean;
|
|
606
|
+
read_only: boolean;
|
|
607
|
+
} | {
|
|
608
|
+
type: 'PageBreak';
|
|
609
|
+
};
|
|
610
|
+
/**
|
|
611
|
+
* Marker style for an ordered or unordered list. Matches CSS
|
|
612
|
+
* `list-style-type` for the supported values.
|
|
613
|
+
*/
|
|
614
|
+
export type ListMarker = 'disc' | 'circle' | 'square' | 'none' | 'decimal' | 'lower-alpha' | 'upper-alpha' | 'lower-roman' | 'upper-roman';
|
|
615
|
+
/** Engine wire format for list marker type — matches the Rust enum's
|
|
616
|
+
* serde camelCase output. */
|
|
617
|
+
export type FormeListMarkerType = 'disc' | 'circle' | 'square' | 'none' | 'decimal' | 'lowerAlpha' | 'upperAlpha' | 'lowerRoman' | 'upperRoman';
|
|
618
|
+
/** A single transform operation in the engine wire format. The discriminator
|
|
619
|
+
* is `type` matching the engine's serde tag. */
|
|
620
|
+
export type FormeTransformOp = {
|
|
621
|
+
type: 'rotate';
|
|
622
|
+
deg: number;
|
|
623
|
+
} | {
|
|
624
|
+
type: 'scale';
|
|
625
|
+
x: number;
|
|
626
|
+
y: number;
|
|
627
|
+
} | {
|
|
628
|
+
type: 'translate';
|
|
629
|
+
x: number;
|
|
630
|
+
y: number;
|
|
631
|
+
};
|
|
632
|
+
export interface FormeColumnDef {
|
|
633
|
+
width: FormeColumnWidth;
|
|
634
|
+
}
|
|
635
|
+
export type FormeColumnWidth = {
|
|
636
|
+
Fraction: number;
|
|
637
|
+
} | {
|
|
638
|
+
Fixed: number;
|
|
639
|
+
} | 'Auto';
|
|
640
|
+
export type FormeDimension = {
|
|
641
|
+
Pt: number;
|
|
642
|
+
} | {
|
|
643
|
+
Percent: number;
|
|
644
|
+
} | 'Auto';
|
|
645
|
+
export interface FormeColor {
|
|
646
|
+
r: number;
|
|
647
|
+
g: number;
|
|
648
|
+
b: number;
|
|
649
|
+
a: number;
|
|
650
|
+
}
|
|
651
|
+
export interface FormeEdgeValues<T> {
|
|
652
|
+
top: T;
|
|
653
|
+
right: T;
|
|
654
|
+
bottom: T;
|
|
655
|
+
left: T;
|
|
656
|
+
}
|
|
657
|
+
export interface FormeCornerValues {
|
|
658
|
+
top_left: number;
|
|
659
|
+
top_right: number;
|
|
660
|
+
bottom_right: number;
|
|
661
|
+
bottom_left: number;
|
|
662
|
+
}
|
|
663
|
+
/** Grid track size in Forme JSON format (matches Rust GridTrackSize enum) */
|
|
664
|
+
export type FormeGridTrackSize = {
|
|
665
|
+
Pt: number;
|
|
666
|
+
} | {
|
|
667
|
+
Fr: number;
|
|
668
|
+
} | 'Auto' | {
|
|
669
|
+
MinMax: [FormeGridTrackSize, FormeGridTrackSize];
|
|
670
|
+
};
|
|
671
|
+
/** Grid placement in Forme JSON format */
|
|
672
|
+
export interface FormeGridPlacement {
|
|
673
|
+
columnStart?: number;
|
|
674
|
+
columnEnd?: number;
|
|
675
|
+
rowStart?: number;
|
|
676
|
+
rowEnd?: number;
|
|
677
|
+
columnSpan?: number;
|
|
678
|
+
rowSpan?: number;
|
|
679
|
+
}
|
|
680
|
+
/** Style in the Forme JSON format (camelCase field names, PascalCase enum values) */
|
|
681
|
+
export interface FormeStyle {
|
|
682
|
+
display?: string;
|
|
683
|
+
width?: FormeDimension;
|
|
684
|
+
height?: FormeDimension;
|
|
685
|
+
minWidth?: FormeDimension;
|
|
686
|
+
minHeight?: FormeDimension;
|
|
687
|
+
maxWidth?: FormeDimension;
|
|
688
|
+
maxHeight?: FormeDimension;
|
|
689
|
+
padding?: FormeEdges;
|
|
690
|
+
margin?: FormeMarginEdges;
|
|
691
|
+
flexDirection?: string;
|
|
692
|
+
justifyContent?: string;
|
|
693
|
+
alignItems?: string;
|
|
694
|
+
alignSelf?: string;
|
|
695
|
+
alignContent?: string;
|
|
696
|
+
flexWrap?: string;
|
|
697
|
+
flexGrow?: number;
|
|
698
|
+
flexShrink?: number;
|
|
699
|
+
flexBasis?: FormeDimension;
|
|
700
|
+
gap?: number;
|
|
701
|
+
rowGap?: number;
|
|
702
|
+
columnGap?: number;
|
|
703
|
+
gridTemplateColumns?: FormeGridTrackSize[];
|
|
704
|
+
gridTemplateRows?: FormeGridTrackSize[];
|
|
705
|
+
gridAutoRows?: FormeGridTrackSize;
|
|
706
|
+
gridAutoColumns?: FormeGridTrackSize;
|
|
707
|
+
gridPlacement?: FormeGridPlacement;
|
|
708
|
+
fontFamily?: string;
|
|
709
|
+
fontSize?: number;
|
|
710
|
+
fontWeight?: number;
|
|
711
|
+
fontStyle?: string;
|
|
712
|
+
lineHeight?: number;
|
|
713
|
+
textAlign?: string;
|
|
714
|
+
letterSpacing?: number;
|
|
715
|
+
wordSpacing?: number;
|
|
716
|
+
boxShadow?: FormeBoxShadow;
|
|
717
|
+
transform?: FormeTransformOp[];
|
|
718
|
+
transformOrigin?: [number, number];
|
|
719
|
+
textDecoration?: string;
|
|
720
|
+
textTransform?: string;
|
|
721
|
+
hyphens?: string;
|
|
722
|
+
lang?: string;
|
|
723
|
+
direction?: string;
|
|
724
|
+
textOverflow?: string;
|
|
725
|
+
lineBreaking?: string;
|
|
726
|
+
overflow?: string;
|
|
727
|
+
color?: FormeColor;
|
|
728
|
+
backgroundColor?: FormeColor;
|
|
729
|
+
background?: FormeBackground;
|
|
730
|
+
opacity?: number;
|
|
731
|
+
borderWidth?: FormeEdgeValues<number>;
|
|
732
|
+
borderColor?: FormeEdgeValues<FormeColor>;
|
|
733
|
+
borderRadius?: FormeCornerValues;
|
|
734
|
+
position?: string;
|
|
735
|
+
top?: number;
|
|
736
|
+
right?: number;
|
|
737
|
+
bottom?: number;
|
|
738
|
+
left?: number;
|
|
739
|
+
wrap?: boolean;
|
|
740
|
+
breakBefore?: boolean;
|
|
741
|
+
minWidowLines?: number;
|
|
742
|
+
minOrphanLines?: number;
|
|
743
|
+
}
|