@reportwright/engine 0.0.0-stage → 0.12.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/CHANGELOG.md +233 -0
- package/LICENSE +23 -0
- package/README.md +105 -2
- package/dist/index.js +22548 -0
- package/dist/pdfstreamworker.js +38 -0
- package/dist/types/packages/engine/entry.d.ts +125 -0
- package/dist/types/src/designer/tableGen.d.ts +119 -0
- package/dist/types/src/engine/data/guard.d.ts +50 -0
- package/dist/types/src/engine/data/index.d.ts +120 -0
- package/dist/types/src/engine/data/odata.d.ts +35 -0
- package/dist/types/src/engine/data/stream.d.ts +48 -0
- package/dist/types/src/engine/data/xml.d.ts +108 -0
- package/dist/types/src/engine/expr/evaluate.d.ts +183 -0
- package/dist/types/src/engine/expr/format.d.ts +122 -0
- package/dist/types/src/engine/expr/javafmt.d.ts +26 -0
- package/dist/types/src/engine/expr/parser.d.ts +29 -0
- package/dist/types/src/engine/image.d.ts +107 -0
- package/dist/types/src/engine/index.d.ts +239 -0
- package/dist/types/src/engine/items/barcode.d.ts +121 -0
- package/dist/types/src/engine/items/cells.d.ts +11 -0
- package/dist/types/src/engine/items/chart-kit.d.ts +75 -0
- package/dist/types/src/engine/items/chart-more.d.ts +52 -0
- package/dist/types/src/engine/items/chart-round.d.ts +28 -0
- package/dist/types/src/engine/items/chart.d.ts +42 -0
- package/dist/types/src/engine/items/hpage.d.ts +33 -0
- package/dist/types/src/engine/items/index.d.ts +117 -0
- package/dist/types/src/engine/items/map.d.ts +11 -0
- package/dist/types/src/engine/items/paint.d.ts +138 -0
- package/dist/types/src/engine/items/pivot.d.ts +45 -0
- package/dist/types/src/engine/items/rich.d.ts +105 -0
- package/dist/types/src/engine/items/toc.d.ts +10 -0
- package/dist/types/src/engine/items/visuals.d.ts +5 -0
- package/dist/types/src/engine/layout.d.ts +24 -0
- package/dist/types/src/engine/paged.d.ts +19 -0
- package/dist/types/src/engine/paginate/index.d.ts +17 -0
- package/dist/types/src/engine/reuse.d.ts +120 -0
- package/dist/types/src/engine/schema/report.schema.d.ts +2421 -0
- package/dist/types/src/engine/schema/template.d.ts +212 -0
- package/dist/types/src/engine/schema/validate.d.ts +21 -0
- package/dist/types/src/engine/stream.d.ts +54 -0
- package/dist/types/src/engine/style.d.ts +70 -0
- package/dist/types/src/engine/text/fonts.d.ts +96 -0
- package/dist/types/src/engine/text/measure.d.ts +145 -0
- package/dist/types/src/engine/text/rich.d.ts +48 -0
- package/dist/types/src/engine/text/shaper.d.ts +20 -0
- package/dist/types/src/engine/units.d.ts +53 -0
- package/dist/types/src/engine/url.d.ts +23 -0
- package/dist/types/src/exporters/color.d.ts +9 -0
- package/dist/types/src/exporters/csv.d.ts +44 -0
- package/dist/types/src/exporters/deadline.d.ts +6 -0
- package/dist/types/src/exporters/docx.d.ts +19 -0
- package/dist/types/src/exporters/encrypt.d.ts +39 -0
- package/dist/types/src/exporters/figures.d.ts +112 -0
- package/dist/types/src/exporters/html.d.ts +24 -0
- package/dist/types/src/exporters/htmldata.d.ts +32 -0
- package/dist/types/src/exporters/pdf.d.ts +45 -0
- package/dist/types/src/exporters/pdfa.d.ts +42 -0
- package/dist/types/src/exporters/pdfpaint.d.ts +107 -0
- package/dist/types/src/exporters/pdfstream.d.ts +198 -0
- package/dist/types/src/exporters/pdfstreamtags.d.ts +38 -0
- package/dist/types/src/exporters/pdfua.d.ts +17 -0
- package/dist/types/src/exporters/png.d.ts +10 -0
- package/dist/types/src/exporters/pptx.d.ts +14 -0
- package/dist/types/src/exporters/regions.d.ts +30 -0
- package/dist/types/src/exporters/subset.d.ts +5 -0
- package/dist/types/src/exporters/svg.d.ts +26 -0
- package/dist/types/src/exporters/svgimage.d.ts +33 -0
- package/dist/types/src/exporters/xlsx.d.ts +61 -0
- package/dist/types/src/exporters/xlsxchart.d.ts +26 -0
- package/dist/types/src/exporters/xlsxwriter.d.ts +83 -0
- package/dist/types/src/importers/xml.d.ts +34 -0
- package/examples/stream-1m.mjs +87 -0
- package/index.d.ts +3 -0
- package/package.json +79 -4
- package/pool/index.d.ts +23 -0
- package/pool/index.js +85 -0
- package/pool/worker.js +27 -0
- package/report.d.ts +638 -0
- package/schema.json +2517 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{ write(u8: Uint8Array): any, once?: (ev: string, cb: () => void) => any }} Sink
|
|
3
|
+
* write may return a promise (awaited: back-pressure), or false with a 'drain' event to wait for (a Node Writable).
|
|
4
|
+
* @typedef {{ title: string, page: number, top?: number, level?: number }} OutlineEntry
|
|
5
|
+
* page: 1-based; top: the destination's y in PDF space (from the bottom), else the page fits the window.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @param {Sink} sink
|
|
9
|
+
* @param {{ fontStore: import('../engine/text/fonts.js').FontStore, fonts?: string[],
|
|
10
|
+
* subset?: (font: Uint8Array, codePoints: Iterable<number>, opt?: { glyphs?: Iterable<number> }) => Promise<Uint8Array>,
|
|
11
|
+
* id?: string }} opt
|
|
12
|
+
* fonts: font keys to name now (F1, F2… in this order); any other font is named on first use.
|
|
13
|
+
* subset: subset.js's subsetter; without it fonts embed in full. id: the file ID (32 hex digits), else random.
|
|
14
|
+
*/
|
|
15
|
+
export function createPdfStream(sink: Sink, opt: {
|
|
16
|
+
fontStore: import("../engine/text/fonts.js").FontStore;
|
|
17
|
+
fonts?: string[];
|
|
18
|
+
subset?: (font: Uint8Array, codePoints: Iterable<number>, opt?: {
|
|
19
|
+
glyphs?: Iterable<number>;
|
|
20
|
+
}) => Promise<Uint8Array>;
|
|
21
|
+
id?: string;
|
|
22
|
+
}): {
|
|
23
|
+
/** @param {string} key @returns {string} the font's resource name (F1…) */
|
|
24
|
+
fontName: (key: string) => string;
|
|
25
|
+
/**
|
|
26
|
+
* The text's glyphs, one per character (as the engine measured it: no layout features), as hex for <…> Tj, with
|
|
27
|
+
* the glyphs recorded for the subset, W and ToUnicode.
|
|
28
|
+
* @param {string} key @param {string} text
|
|
29
|
+
*/
|
|
30
|
+
encode(key: string, text: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* The same glyphs as a literal string's body, two bytes each, escaped (as pdf.js draws plain text): ( … ) Tj.
|
|
33
|
+
* @param {string} key @param {string} text
|
|
34
|
+
*/
|
|
35
|
+
literal(key: string, text: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Shaped glyphs drawn by ID (conjuncts, joined forms): [glyph ID, the text it stands for ('' for none)].
|
|
38
|
+
* @param {string} key @param {Iterable<[number, string]>} glyphs
|
|
39
|
+
*/
|
|
40
|
+
addGlyphs(key: string, glyphs: Iterable<[number, string]>): void;
|
|
41
|
+
/**
|
|
42
|
+
* A name in the shared Resources dictionary for a value (an indirect ref "12 0 R" or an inline dictionary).
|
|
43
|
+
* @param {'ExtGState'|'XObject'|'Pattern'|'Shading'|'ColorSpace'} kind @param {string} value
|
|
44
|
+
*/
|
|
45
|
+
resource(kind: "ExtGState" | "XObject" | "Pattern" | "Shading" | "ColorSpace", value: string, name?: any): string;
|
|
46
|
+
/**
|
|
47
|
+
* The ExtGState name for fill and stroke opacity, named by its values (the same name in every writer: pages
|
|
48
|
+
* painted elsewhere, parallel.js, use it too). @param {number} ca @param {number} CA
|
|
49
|
+
*/
|
|
50
|
+
gs: (ca: number, CA: number) => string;
|
|
51
|
+
/** What this writer's pages used, for another writer to take over (pages painted elsewhere). */
|
|
52
|
+
used: () => {
|
|
53
|
+
fonts: (string | number[] | [number, string][])[][];
|
|
54
|
+
gs: string[];
|
|
55
|
+
};
|
|
56
|
+
/** Take over what pages painted elsewhere used (used() of their writer). @param {any} u */
|
|
57
|
+
take(u: any): void;
|
|
58
|
+
/**
|
|
59
|
+
* Write an object now (an image: its dictionary and its stream, already filtered). @returns {Promise<number>} its number
|
|
60
|
+
* @param {string} dict @param {Uint8Array} [stream]
|
|
61
|
+
*/
|
|
62
|
+
object(dict: string, stream?: Uint8Array): Promise<number>;
|
|
63
|
+
/** An object number to write later (objectAt). */
|
|
64
|
+
reserve: () => number;
|
|
65
|
+
/** Write a reserved object. @param {number} n @param {string} dict @param {Uint8Array} [stream] */
|
|
66
|
+
objectAt: (n: number, dict: string, stream?: Uint8Array) => Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Write a reserved object whose text may be long (an array of every row's element): head, the parts as they come,
|
|
69
|
+
* tail; written out in place, never held whole. @param {number} n @param {string} head @param {Iterable<string>} parts @param {string} tail
|
|
70
|
+
*/
|
|
71
|
+
bigObject(n: number, head: string, parts: Iterable<string>, tail: string): Promise<void>;
|
|
72
|
+
/** The object number of page i (0-based), written or not: links and outline entries may point ahead. @param {number} i */
|
|
73
|
+
pageRef(i: number): number;
|
|
74
|
+
/**
|
|
75
|
+
* The total page count, drawn at the end: a Form XObject whose origin is the text's baseline at the box's left;
|
|
76
|
+
* draw it with `q 1 0 0 1 x y cm /<name> Do Q`. align: within width.
|
|
77
|
+
* @param {{ font: string, size: number, width: number, align?: 'left'|'center'|'right', color?: string }} o
|
|
78
|
+
*/
|
|
79
|
+
totalPages(o: {
|
|
80
|
+
font: string;
|
|
81
|
+
size: number;
|
|
82
|
+
width: number;
|
|
83
|
+
align?: "left" | "center" | "right";
|
|
84
|
+
color?: string;
|
|
85
|
+
}): string;
|
|
86
|
+
/**
|
|
87
|
+
* Write a page: its content stream (deflated) and its dictionary, now. Nothing of it stays but two offsets.
|
|
88
|
+
* @param {{ width: number, height: number, content?: string | Uint8Array, deflated?: Uint8Array, annots?: (string | { ref: number, dict: string })[], extra?: string }} p
|
|
89
|
+
* deflated: the content stream already compressed (zlib), as pages painted elsewhere come.
|
|
90
|
+
* content: the page's operators (a string holds bytes 0–255, as pdf.js's Content makes). annots: annotation
|
|
91
|
+
* dictionaries (with a reserved number: { ref, dict }). extra: more entries for the page dictionary (/StructParents 3).
|
|
92
|
+
*/
|
|
93
|
+
addPage(p: {
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
content?: string | Uint8Array;
|
|
97
|
+
deflated?: Uint8Array;
|
|
98
|
+
annots?: (string | {
|
|
99
|
+
ref: number;
|
|
100
|
+
dict: string;
|
|
101
|
+
})[];
|
|
102
|
+
extra?: string;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* The end of the file: totals, fonts, resources, page tree, outline, catalog, Info, xref, trailer.
|
|
106
|
+
* @param {{ outline?: OutlineEntry[], info?: { title?: string, author?: string, subject?: string, creationDate?: Date }, catalog?: string }} [o]
|
|
107
|
+
* catalog: more entries for the catalog (the structure tree, metadata, output intents).
|
|
108
|
+
* @returns {Promise<{ pages: number, bytes: number }>}
|
|
109
|
+
*/
|
|
110
|
+
finish(o?: {
|
|
111
|
+
outline?: OutlineEntry[];
|
|
112
|
+
info?: {
|
|
113
|
+
title?: string;
|
|
114
|
+
author?: string;
|
|
115
|
+
subject?: string;
|
|
116
|
+
creationDate?: Date;
|
|
117
|
+
};
|
|
118
|
+
catalog?: string;
|
|
119
|
+
}): Promise<{
|
|
120
|
+
pages: number;
|
|
121
|
+
bytes: number;
|
|
122
|
+
}>;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* A report to PDF bytes written to sink as its pages are laid out (planPaged: a flowing table, one window of rows at a
|
|
126
|
+
* time), else rendered whole and exported by exportPdf, the same file it always was, written to sink in one piece.
|
|
127
|
+
* opts: render()'s options and exportPdf's (fontStore, subset, title, author, creationDate, drillBase…). Tagged,
|
|
128
|
+
* PDF/A, encrypted and signed files take the whole-model path.
|
|
129
|
+
* @param {any} def @param {any} opts @param {Sink} sink
|
|
130
|
+
* @returns {Promise<{ streamed: boolean, pages: number, warnings: string[], why?: string }>}
|
|
131
|
+
*/
|
|
132
|
+
export function exportPdfStream(def: any, opts: any, sink: Sink): Promise<{
|
|
133
|
+
streamed: boolean;
|
|
134
|
+
pages: number;
|
|
135
|
+
warnings: string[];
|
|
136
|
+
why?: string;
|
|
137
|
+
}>;
|
|
138
|
+
/**
|
|
139
|
+
* The pages of a paged plan (planPaged) as a PDF written to sink, page by page.
|
|
140
|
+
* @param {any} plan @param {any} opts fontStore, subset, title, author, creationDate, drillBase @param {Sink} sink
|
|
141
|
+
* @returns {Promise<{ pages: number, warnings: string[] }>}
|
|
142
|
+
*/
|
|
143
|
+
export function writePagedPdf(plan: any, opts: any, sink: Sink): Promise<{
|
|
144
|
+
pages: number;
|
|
145
|
+
warnings: string[];
|
|
146
|
+
}>;
|
|
147
|
+
/**
|
|
148
|
+
* A page of the model as its content stream's operators and its link annotations, drawn with the shared painter
|
|
149
|
+
* (pdfpaint.js) as exportPdf draws it. env (paintEnv): the writer's names and glyph records, the page refs links jump
|
|
150
|
+
* to, the tagger when tagged. Pages painted in parallel (parallel.js) use a writer of their own and the same names.
|
|
151
|
+
* @param {any} pg @param {number} H @param {any} env
|
|
152
|
+
* @returns {{ content: string, annots: any[] }}
|
|
153
|
+
*/
|
|
154
|
+
export function paintPage(pg: any, H: number, env: any): {
|
|
155
|
+
content: string;
|
|
156
|
+
annots: any[];
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* What paintPage draws with: a writer's resource names and glyph records (w), the fonts, shaped glyphs' texts.
|
|
160
|
+
* @param {any} w @param {any} fontStore @param {{ drillBase?: string, pageRef?: (i: number) => any, tags?: any }} [o]
|
|
161
|
+
*/
|
|
162
|
+
export function paintEnv(w: any, fontStore: any, o?: {
|
|
163
|
+
drillBase?: string;
|
|
164
|
+
pageRef?: (i: number) => any;
|
|
165
|
+
tags?: any;
|
|
166
|
+
}): {
|
|
167
|
+
shared: {
|
|
168
|
+
font: (f: any) => any;
|
|
169
|
+
gs: (ca: any, CA: any) => any;
|
|
170
|
+
image: () => never;
|
|
171
|
+
};
|
|
172
|
+
pf: (key: string) => any;
|
|
173
|
+
font: (key: string) => any;
|
|
174
|
+
shaped: Map<string, Map<number, string>>;
|
|
175
|
+
shapedOf: (key: string) => Map<number, string>;
|
|
176
|
+
vmetrics: (key: string) => any;
|
|
177
|
+
literal: (key: string, text: string) => any;
|
|
178
|
+
pageRef: (i: number) => any;
|
|
179
|
+
reserve: () => any;
|
|
180
|
+
drillBase: string;
|
|
181
|
+
tags: any;
|
|
182
|
+
};
|
|
183
|
+
/**
|
|
184
|
+
* write may return a promise (awaited: back-pressure), or false with a 'drain' event to wait for (a Node Writable).
|
|
185
|
+
*/
|
|
186
|
+
export type Sink = {
|
|
187
|
+
write(u8: Uint8Array): any;
|
|
188
|
+
once?: (ev: string, cb: () => void) => any;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* page: 1-based; top: the destination's y in PDF space (from the bottom), else the page fits the window.
|
|
192
|
+
*/
|
|
193
|
+
export type OutlineEntry = {
|
|
194
|
+
title: string;
|
|
195
|
+
page: number;
|
|
196
|
+
top?: number;
|
|
197
|
+
level?: number;
|
|
198
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The structure tree of a streamed, tagged PDF (PDF/UA-1, and PDF/A-2a with it): pdfua.js's tree for the shapes that
|
|
3
|
+
* stream (engine/paged.js), written as the pages are. Document > P / H1–H6 (text boxes), Table > TR > TH/TD (the table's
|
|
4
|
+
* header rows TH with Scope Column the first time, an artifact where they repeat; empty cells as empty TD; spans as
|
|
5
|
+
* ColSpan), Link > OBJR inside the element whose text it covers; page header and footer, borders and boxes artifacts.
|
|
6
|
+
* Each page's rows (TR, TD), its parent-tree array and its links' elements are written when the page ends; what stays
|
|
7
|
+
* is one number per row (the Table's kids) and two per page and link (the parent tree), written at the end.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* @param {any} w the PDF writer (pdfstream.js createPdfStream)
|
|
11
|
+
*/
|
|
12
|
+
export function createStreamTagger(w: any): {
|
|
13
|
+
/** a new page (window: the paged window it came from; row ids are its own) @param {number} window */
|
|
14
|
+
page(window: number): void;
|
|
15
|
+
/**
|
|
16
|
+
* The marked content that opens item it: a structure element's MCID, or an artifact; null for a link.
|
|
17
|
+
* @param {any} it
|
|
18
|
+
*/
|
|
19
|
+
open(it: any): string;
|
|
20
|
+
/**
|
|
21
|
+
* A link annotation of the page: its Link element (in the element of the text it covers, else the Document).
|
|
22
|
+
* @returns {number} the annotation's StructParent
|
|
23
|
+
* @param {any} it @param {number} annot the annotation's object number
|
|
24
|
+
*/
|
|
25
|
+
link(it: any, annot: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* The page is drawn: its elements and parent-tree array are written. @returns {Promise<string>} the page's entries
|
|
28
|
+
* @param {number} pageRef
|
|
29
|
+
*/
|
|
30
|
+
end(pageRef: number): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* The tree's top: Table, Document, the parent tree, the root. @returns {Promise<string>} the catalog's entries
|
|
33
|
+
* @param {{ lang?: string }} o
|
|
34
|
+
*/
|
|
35
|
+
finish({ lang }?: {
|
|
36
|
+
lang?: string;
|
|
37
|
+
}): Promise<string>;
|
|
38
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} model
|
|
3
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
4
|
+
*/
|
|
5
|
+
export function createTagger(model: any, doc: import("pdf-lib").PDFDocument): {
|
|
6
|
+
/**
|
|
7
|
+
* Marked content around item ii of page pi: the operator that opens it, or null (nothing is drawn for it).
|
|
8
|
+
* @returns {string|null}
|
|
9
|
+
*/
|
|
10
|
+
open(pi: any, ii: any, it: any): string | null;
|
|
11
|
+
/** A link annotation of item ii (or a field's widget): its structure element; returns its StructParent key. */
|
|
12
|
+
annot(pi: any, ii: any, ref: any, kind: any): void;
|
|
13
|
+
finish({ lang, title }?: {
|
|
14
|
+
lang?: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
}): void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a PNG cannot be embedded, or null when it can.
|
|
3
|
+
* @param {Uint8Array} b @returns {string|null}
|
|
4
|
+
*/
|
|
5
|
+
export function pngProblem(b: Uint8Array): string | null;
|
|
6
|
+
export namespace PNG_LIMITS {
|
|
7
|
+
let pixels: number;
|
|
8
|
+
let rawBytes: number;
|
|
9
|
+
let chunks: number;
|
|
10
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {any} model render() output
|
|
3
|
+
* @param {{ title?: string, author?: string, lang?: string, fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
4
|
+
* rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null> }} [opt]
|
|
5
|
+
* @returns {Promise<Uint8Array>}
|
|
6
|
+
*/
|
|
7
|
+
export function exportPptx(model: any, opt?: {
|
|
8
|
+
title?: string;
|
|
9
|
+
author?: string;
|
|
10
|
+
lang?: string;
|
|
11
|
+
fontStore?: any;
|
|
12
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
13
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
14
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page model rendered without exportData (the default: a view, a plain PDF) has no table data and no cell tags:
|
|
3
|
+
* the exports that rebuild tables refuse it rather than write a file without its tables.
|
|
4
|
+
*/
|
|
5
|
+
export function needsTableData(model: any, what: any): void;
|
|
6
|
+
/** Merge table regions that share a name (a table repeated inside a list). */
|
|
7
|
+
export function mergedRegions(model: any): any[];
|
|
8
|
+
/**
|
|
9
|
+
* The visual lines of a text item, as strings. A justified line is one run per word on the same
|
|
10
|
+
* baseline; this joins them back (in x order) so text exports and search see whole lines.
|
|
11
|
+
* @param {{ lines: { x: number, y: number, text: string }[] }} it
|
|
12
|
+
* @returns {string[]}
|
|
13
|
+
*/
|
|
14
|
+
export function visualLines(it: {
|
|
15
|
+
lines: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
text: string;
|
|
19
|
+
}[];
|
|
20
|
+
}): string[];
|
|
21
|
+
/**
|
|
22
|
+
* The visual lines of a page's text items, as strings. Rich text draws one text item per styled
|
|
23
|
+
* fragment (`rich: {id, l}`); the fragments of one box on one line (superscripts included) are joined in x order with
|
|
24
|
+
* nothing between them (they keep their own spaces). Other items give their visualLines().
|
|
25
|
+
* @param {any[]} items page-model items (anything that is not text is skipped)
|
|
26
|
+
* @returns {string[]}
|
|
27
|
+
*/
|
|
28
|
+
export function textRows(items: any[]): string[];
|
|
29
|
+
export function needsExportData(fmt: any, o?: {}): boolean;
|
|
30
|
+
export function isJustified(it: any): boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** @param {() => Promise<ArrayBuffer|Uint8Array>} loadWasm */
|
|
2
|
+
export function createSubsetter(loadWasm: () => Promise<ArrayBuffer | Uint8Array>): (font: Uint8Array, codePoints: Iterable<number>, opt?: {
|
|
3
|
+
glyphs?: Iterable<number>;
|
|
4
|
+
layout?: boolean;
|
|
5
|
+
}) => Promise<Uint8Array>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address a browser may load an image from, by the policy of the data fetches: a data:image URI or this server's
|
|
3
|
+
* own path as it is; an absolute http(s) URL only through this server's data proxy (/api/data/proxy: PW_PROXY_ALLOW
|
|
4
|
+
* hosts, never a private address); anything else (another scheme, //host) not at all. So a stored report cannot make
|
|
5
|
+
* its viewers' browsers call hosts of its choosing. @param {any} src @param {string} [proxyBase] the server's origin,
|
|
6
|
+
* for a file opened elsewhere (the HTML export)
|
|
7
|
+
*/
|
|
8
|
+
export function imageHref(src: any, proxyBase?: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* box: draw only this part of the page (viewBox), as Word and PowerPoint figures do. outline: text as glyph outlines,
|
|
11
|
+
* from fontkit fonts (figures.js), for readers without the report's fonts.
|
|
12
|
+
* @param {{ background?: boolean, animate?: boolean, box?: { x: number, y: number, w: number, h: number }, outline?: ((key: string) => any) | null }} [opt]
|
|
13
|
+
*/
|
|
14
|
+
export function pageToSvg(page: any, w: any, h: any, { background, animate, box, outline, proxyBase }?: {
|
|
15
|
+
background?: boolean;
|
|
16
|
+
animate?: boolean;
|
|
17
|
+
box?: any;
|
|
18
|
+
outline?: any;
|
|
19
|
+
proxyBase?: string;
|
|
20
|
+
}): string;
|
|
21
|
+
export function linkTitle(a: any): any;
|
|
22
|
+
/** @font-face rules for report fonts served from /fonts (uploaded ones from /fonts/custom). */
|
|
23
|
+
export function fontFaceCss(keys: any, base?: string): any;
|
|
24
|
+
/** Every font key a page model draws with (text items, their runs, form fields). */
|
|
25
|
+
export function fontKeysOf(model: any): any[];
|
|
26
|
+
export function fontFamilyCss(key: any): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** A transform list, split on ")" and "(": linear, no backtracking. @param {string} s @returns {M} */
|
|
2
|
+
export function parseTransform(s: string): M;
|
|
3
|
+
/**
|
|
4
|
+
* Shapes of an SVG in its own user space (the root viewBox applied), with their paint resolved.
|
|
5
|
+
* @param {string} text
|
|
6
|
+
* @returns {{ w: number, h: number, shapes: { d: string, m: M, fill: any, stroke: any, sw: number, fo: number, so: number }[] } | null}
|
|
7
|
+
*/
|
|
8
|
+
export function parseSvg(text: string): {
|
|
9
|
+
w: number;
|
|
10
|
+
h: number;
|
|
11
|
+
shapes: {
|
|
12
|
+
d: string;
|
|
13
|
+
m: M;
|
|
14
|
+
fill: any;
|
|
15
|
+
stroke: any;
|
|
16
|
+
sw: number;
|
|
17
|
+
fo: number;
|
|
18
|
+
so: number;
|
|
19
|
+
}[];
|
|
20
|
+
} | null;
|
|
21
|
+
/**
|
|
22
|
+
* Draw a parsed SVG into the box (PDF coordinates: x, y of the bottom-left corner), scaled by sx, sy.
|
|
23
|
+
* @param {any} page pdf-lib PDFPage
|
|
24
|
+
* @param {NonNullable<ReturnType<typeof parseSvg>>} svg
|
|
25
|
+
* @param {{ x: number, y: number, sx: number, sy: number }} at
|
|
26
|
+
*/
|
|
27
|
+
export function drawSvg(page: any, svg: NonNullable<ReturnType<typeof parseSvg>>, at: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
sx: number;
|
|
31
|
+
sy: number;
|
|
32
|
+
}): void;
|
|
33
|
+
export type M = [number, number, number, number, number, number];
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Report format → Excel number format. value: the cell's value, so a date gets a date format (N6: "d" is a date,
|
|
3
|
+
* not two decimals) and an en-IN number its own lakh grouping (N22: Excel's conditions cannot cover negatives).
|
|
4
|
+
* @param {string|null|undefined} fmt @param {string} [currencySymbol] @param {string} [locale] @param {any} [value]
|
|
5
|
+
*/
|
|
6
|
+
export function excelFormat(fmt: string | null | undefined, currencySymbol?: string, locale?: string, value?: any): any;
|
|
7
|
+
/** The currency symbol for a code in the report locale ("INR" → ₹), else the code. */
|
|
8
|
+
export function currencySymbol(iso: any, locale: any): any;
|
|
9
|
+
/** A column's values over the rows a total covers, kept as they pass: what subtotalFn needs, in O(1) memory. */
|
|
10
|
+
export function colStats(): {
|
|
11
|
+
vals: number;
|
|
12
|
+
nums: number;
|
|
13
|
+
sum: number;
|
|
14
|
+
min: number;
|
|
15
|
+
max: number;
|
|
16
|
+
first: any;
|
|
17
|
+
differ: boolean;
|
|
18
|
+
/** @param {any} v a region cell's value */
|
|
19
|
+
add(v: any): void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* The SUBTOTAL function a total's shown value is, over its column's values (colStats), or null: 9 the sum, 2/3 the
|
|
23
|
+
* count (COUNTA when there is text), 1 the average, 5 the minimum, 4 the maximum, each within the format's precision.
|
|
24
|
+
* @param {{ value: any, format?: string }} c @param {ReturnType<typeof colStats>} st
|
|
25
|
+
*/
|
|
26
|
+
export function subtotalFn(c: {
|
|
27
|
+
value: any;
|
|
28
|
+
format?: string;
|
|
29
|
+
}, st: ReturnType<typeof colStats>): 1 | 2 | 3 | 4 | 5 | 9;
|
|
30
|
+
/** Excel's sheet names, unique in a workbook: no \\ / ? * [ ] :, no control characters, not starting or ending with ', at
|
|
31
|
+
* most 31 characters (28 here, room for a " 2"). suffix: kept whole (a split sheet's " (2)"). */
|
|
32
|
+
export function sheetNamer(): (n: any, suffix?: string) => string;
|
|
33
|
+
/** A region cell → an Excel cell: its value (dates as the report's wall clock), number format, bold and header fill. */
|
|
34
|
+
export function xlsxCell({ sym, locale, tz }: {
|
|
35
|
+
sym: any;
|
|
36
|
+
locale: any;
|
|
37
|
+
tz: any;
|
|
38
|
+
}): (c: any, header: boolean) => any;
|
|
39
|
+
/**
|
|
40
|
+
* Excel workbook in "data mode": one sheet per table, typed cells, number formats,
|
|
41
|
+
* bold header and group rows, and outline levels for grouped detail rows. Group and table totals that are a sum,
|
|
42
|
+
* count, average, minimum or maximum of their column are live SUBTOTAL formulas (formulas: false keeps values).
|
|
43
|
+
* Charts are native Excel charts; pictures go on a sheet of their own (PNG; needs a rasteriser, see figures.js).
|
|
44
|
+
* Written by xlsxwriter.js (no ExcelJS).
|
|
45
|
+
* @param {any} model render() output
|
|
46
|
+
* @param {{ currency?: string, title?: string, formulas?: boolean, pictures?: boolean, charts?: boolean, fontStore?: any, fonts?: any,
|
|
47
|
+
* fetchImage?: (src: string) => Promise<Uint8Array|null>, rasterize?: any, timeZone?: string }} [opt]
|
|
48
|
+
* @returns {Promise<Uint8Array>}
|
|
49
|
+
*/
|
|
50
|
+
export function exportXlsx(model: any, opt?: {
|
|
51
|
+
currency?: string;
|
|
52
|
+
title?: string;
|
|
53
|
+
formulas?: boolean;
|
|
54
|
+
pictures?: boolean;
|
|
55
|
+
charts?: boolean;
|
|
56
|
+
fontStore?: any;
|
|
57
|
+
fonts?: any;
|
|
58
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
59
|
+
rasterize?: any;
|
|
60
|
+
timeZone?: string;
|
|
61
|
+
}, legacy?: any): Promise<Uint8Array>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The cells a chart's data takes on its sheet, from row 1: a header row, then one row per category (or point).
|
|
3
|
+
* @param {any} spec items[0].xchart (engine/items/chart.js nativeSpec)
|
|
4
|
+
* @returns {any[][]}
|
|
5
|
+
*/
|
|
6
|
+
export function chartTable(spec: any): any[][];
|
|
7
|
+
/**
|
|
8
|
+
* The chart part (xl/charts/chartN.xml) for a spec whose data starts at A1 of `sheet`.
|
|
9
|
+
* @param {any} spec @param {string} sheet
|
|
10
|
+
*/
|
|
11
|
+
export function chartXml(spec: any, sheet: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Add the charts to a workbook ExcelJS wrote. Each chart: { sheet (its sheet's name), spec, at: { col, row } } with
|
|
14
|
+
* its data at A1 of that sheet; the sheets have no drawing of their own.
|
|
15
|
+
* @param {Uint8Array} bytes @param {{ sheet: string, spec: any, at: { col: number, row: number } }[]} charts
|
|
16
|
+
* @returns {Uint8Array}
|
|
17
|
+
*/
|
|
18
|
+
export function addCharts(bytes: Uint8Array, charts: {
|
|
19
|
+
sheet: string;
|
|
20
|
+
spec: any;
|
|
21
|
+
at: {
|
|
22
|
+
col: number;
|
|
23
|
+
row: number;
|
|
24
|
+
};
|
|
25
|
+
}[]): Uint8Array;
|
|
26
|
+
export function esc(s: any): string;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/** A worksheet's XML up to and including <sheetData> (what must be known before the rows: widths, frozen rows, outline). */
|
|
2
|
+
export function sheetHead({ widths, frozenRows, outlineLevelRow }: {
|
|
3
|
+
widths: any;
|
|
4
|
+
frozenRows: any;
|
|
5
|
+
outlineLevelRow: any;
|
|
6
|
+
}): string;
|
|
7
|
+
/** The rest of a worksheet after its rows: merges (they come after <sheetData>, so they can be gathered while rows stream). */
|
|
8
|
+
export function sheetTail(merges: any, drawing?: boolean): string;
|
|
9
|
+
export function colName(c: any): string;
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{ numFmt?: string|null, bold?: boolean, fill?: boolean }} CellStyle
|
|
12
|
+
* @typedef {{ v?: any, f?: string, style?: CellStyle }} Cell
|
|
13
|
+
*/
|
|
14
|
+
export class Sheet {
|
|
15
|
+
/** @param {Book} book @param {string} name */
|
|
16
|
+
constructor(book: Book, name: string);
|
|
17
|
+
book: Book;
|
|
18
|
+
name: string;
|
|
19
|
+
/** @type {string[]} */ xml: string[];
|
|
20
|
+
/** @type {number[]} */ widths: number[];
|
|
21
|
+
/** @type {string[]} */ merges: string[];
|
|
22
|
+
/** @type {{ bytes: Uint8Array, ext: string, col: number, row: number, w: number, h: number }[]} */ images: {
|
|
23
|
+
bytes: Uint8Array;
|
|
24
|
+
ext: string;
|
|
25
|
+
col: number;
|
|
26
|
+
row: number;
|
|
27
|
+
w: number;
|
|
28
|
+
h: number;
|
|
29
|
+
}[];
|
|
30
|
+
rowCount: number;
|
|
31
|
+
frozenRows: number;
|
|
32
|
+
outlineLevelRow: number;
|
|
33
|
+
/**
|
|
34
|
+
* Add a row (1-based number returned). cells: one per column (null = empty).
|
|
35
|
+
* @param {(Cell|null)[]} cells @param {{ outlineLevel?: number }} [opt]
|
|
36
|
+
*/
|
|
37
|
+
addRow(cells: (Cell | null)[], opt?: {
|
|
38
|
+
outlineLevel?: number;
|
|
39
|
+
}): number;
|
|
40
|
+
/** Merge (1-based, inclusive). */
|
|
41
|
+
merge(r1: any, c1: any, r2: any, c2: any): void;
|
|
42
|
+
/** A picture with its top-left at (col, row), 0-based, w × h pixels. */
|
|
43
|
+
addImage(bytes: any, ext: any, col: any, row: any, w: any, h: any): void;
|
|
44
|
+
/** @param {number} i */
|
|
45
|
+
toXml(i: number): string;
|
|
46
|
+
}
|
|
47
|
+
export class Book {
|
|
48
|
+
constructor({ title, creator }?: {
|
|
49
|
+
title?: string;
|
|
50
|
+
creator?: string;
|
|
51
|
+
});
|
|
52
|
+
title: string;
|
|
53
|
+
creator: string;
|
|
54
|
+
fullCalcOnLoad: boolean;
|
|
55
|
+
/** @type {Sheet[]} */ sheets: Sheet[];
|
|
56
|
+
/** @type {Map<string, number>} */ styles: Map<string, number>;
|
|
57
|
+
/** @type {Map<string, number>} */ numFmts: Map<string, number>;
|
|
58
|
+
/** @param {string} name */
|
|
59
|
+
addSheet(name: string): Sheet;
|
|
60
|
+
/** cellXfs index for a style */
|
|
61
|
+
style(st: CellStyle | undefined): number;
|
|
62
|
+
/** One <c> element. @param {string} ref @param {Cell} c */
|
|
63
|
+
cell(ref: string, c: Cell): string;
|
|
64
|
+
stylesXml(): string;
|
|
65
|
+
/** The .xlsx bytes. */
|
|
66
|
+
write(): Uint8Array<ArrayBuffer>;
|
|
67
|
+
/**
|
|
68
|
+
* The workbook's own parts, written after the sheets (their names, the styles they used): styles, workbook,
|
|
69
|
+
* relationships, properties and content types. over: [part, content type] of the sheets and drawings.
|
|
70
|
+
* @param {[string, string][]} over @returns {[string, string][]}
|
|
71
|
+
*/
|
|
72
|
+
bookParts(over: [string, string][]): [string, string][];
|
|
73
|
+
}
|
|
74
|
+
export type CellStyle = {
|
|
75
|
+
numFmt?: string | null;
|
|
76
|
+
bold?: boolean;
|
|
77
|
+
fill?: boolean;
|
|
78
|
+
};
|
|
79
|
+
export type Cell = {
|
|
80
|
+
v?: any;
|
|
81
|
+
f?: string;
|
|
82
|
+
style?: CellStyle;
|
|
83
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse an XML document into its root element.
|
|
3
|
+
* @param {string} src
|
|
4
|
+
* @param {Partial<typeof XML_LIMITS>} [limits]
|
|
5
|
+
* @returns {XmlElement}
|
|
6
|
+
*/
|
|
7
|
+
export function parseXml(src: string, limits?: Partial<typeof XML_LIMITS>): XmlElement;
|
|
8
|
+
/**
|
|
9
|
+
* A small XML reader for untrusted files (SSRS .rdl). Pure JavaScript, no DOM, so it runs anywhere.
|
|
10
|
+
*
|
|
11
|
+
* Safe by construction:
|
|
12
|
+
* - no DTDs: <!DOCTYPE and <!ENTITY are refused, so there is no entity expansion (XXE, billion laughs);
|
|
13
|
+
* only the five XML entities and character references are read;
|
|
14
|
+
* - caps on size, nesting depth, element count and attributes per element;
|
|
15
|
+
* - linear time: it scans with indexOf and character tests, no regular expression runs over the input.
|
|
16
|
+
*
|
|
17
|
+
* Elements come back as { name, ns, attrs, children, text }: name is the local name (prefix removed),
|
|
18
|
+
* ns the namespace URI, text the element's own character data (CDATA included).
|
|
19
|
+
*/
|
|
20
|
+
export class XmlError extends Error {
|
|
21
|
+
}
|
|
22
|
+
export namespace XML_LIMITS {
|
|
23
|
+
let maxChars: number;
|
|
24
|
+
let maxDepth: number;
|
|
25
|
+
let maxElements: number;
|
|
26
|
+
let maxAttributes: number;
|
|
27
|
+
}
|
|
28
|
+
export type XmlElement = {
|
|
29
|
+
name: string;
|
|
30
|
+
ns: string;
|
|
31
|
+
attrs: Record<string, string>;
|
|
32
|
+
children: XmlElement[];
|
|
33
|
+
text: string;
|
|
34
|
+
};
|