@reportwright/engine 0.13.0 → 0.13.2-rc.1
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 +53 -0
- package/README.md +196 -7
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/dist/index.js +5420 -223
- package/dist/types/packages/engine/entry.d.ts +4 -30
- package/dist/types/src/engine/index.d.ts +1 -1
- package/dist/types/src/engine/schema/validate.d.ts +4 -2
- package/dist/types/src/engine/text/fonts.d.ts +5 -0
- package/dist/types/src/engine/text/measure.d.ts +2 -1
- package/dist/types/src/engine/text/standard-metrics.d.ts +190 -0
- package/dist/types/src/engine/text/standard.d.ts +8 -8
- package/dist/types/src/exporters/pdfstream.d.ts +2 -0
- package/dist/types/src/exporters/pdfstreamtags.d.ts +2 -0
- package/dist/types/src/exporters/spill.d.ts +15 -3
- package/dist/types/src/importers/xml.d.ts +4 -0
- package/examples/stream-1m.mjs +1 -1
- package/package.json +2 -3
- package/report.d.ts +5 -5
- package/schema.json +5 -5
|
@@ -15,8 +15,8 @@ export function render(def0: any, opts?: import("../../src/engine/index.js").Ren
|
|
|
15
15
|
* pdfa?: boolean | { icc?: Uint8Array, [k: string]: unknown } }} PdfOptions
|
|
16
16
|
*/
|
|
17
17
|
/**
|
|
18
|
-
* Page model → PDF bytes: exportPdf(model, { fonts, title, ... }). fonts:
|
|
19
|
-
* one over @reportwright/fonts). Fonts are subset with harfbuzz-subset.wasm from @reportwright/fonts (when it can't be
|
|
18
|
+
* Page model → PDF bytes: exportPdf(model, { fonts, title, ... }). fonts: optional, any FontStore (render()'s saves
|
|
19
|
+
* loading the fonts again; default: the one over @reportwright/fonts); the fonts the model uses are loaded into it. Fonts are subset with harfbuzz-subset.wasm from @reportwright/fonts (when it can't be
|
|
20
20
|
* loaded the full font is embedded); `subset: false` embeds every font in full, a function replaces the subsetter.
|
|
21
21
|
* The 0.7 form exportPdf(model, fontStore, options) still works in 0.8 (deprecated).
|
|
22
22
|
* @param {any} model render() output
|
|
@@ -49,33 +49,7 @@ export function exportDocx(model: any, options?: NonNullable<Parameters<typeof e
|
|
|
49
49
|
export function exportPptx(model: any, options?: NonNullable<Parameters<typeof exportPptxFull>[1]> & {
|
|
50
50
|
fonts?: FontStore;
|
|
51
51
|
}, ...args: any[]): Promise<Uint8Array>;
|
|
52
|
-
|
|
53
|
-
* @typedef {RenderOptions & Omit<PdfOptions, 'fonts'> & { fonts?: FontStore, tagged?: { lang?: string, maxElements?: number },
|
|
54
|
-
* window?: number, parallel?: number, maxRows?: number, id?: string, presorted?: boolean, signal?: AbortSignal,
|
|
55
|
-
* spill?: false | { dir?: string, maxMB?: number }, sorter?: (cmp: (a: any, b: any) => number) => any }} PdfStreamOptions
|
|
56
|
-
* render()'s options and exportPdf's, plus: window (rows laid out at once, 1000), parallel (Node: worker threads
|
|
57
|
-
* that lay out and paint pages, opt-in; the file is the same, each thread costs memory), maxRows (rows read,
|
|
58
|
-
* 5,000,000), id (the file ID). presorted: the rows come in the report's order (its sort, its groups together), so
|
|
59
|
-
* they are not sorted, only checked as they pass (a row out of order stops the export). spill: where a sort's runs go
|
|
60
|
-
* (Node: the system temp folder, 2 GB at most; false sorts in memory); in a browser a sort is in memory.
|
|
61
|
-
* timeoutMs: the whole export's time limit, waits for the sink included (504, code 'ETIMEDOUT'). signal: an
|
|
62
|
-
* AbortSignal that stops the export at its next wait (rejects with the signal's reason, an AbortError); sqlRows gets
|
|
63
|
-
* it as its third argument ({ signal }) so a database cursor can cancel its query.
|
|
64
|
-
*/
|
|
65
|
-
/**
|
|
66
|
-
* Report definition → PDF written to a sink as it is made, for reports too large to hold as a page model: a flowing
|
|
67
|
-
* table (and its groups) is laid out a window of rows at a time and each page leaves memory once written. Other
|
|
68
|
-
* reports are rendered whole and written by exportPdf in one piece (the result says why). sink: a Node Writable
|
|
69
|
-
* (fs.createWriteStream) or anything with write(bytes) that may return a promise (back-pressure); it is not closed.
|
|
70
|
-
* @param {any} def the report definition
|
|
71
|
-
* @param {PdfStreamOptions} options
|
|
72
|
-
* @param {{ write(bytes: Uint8Array): any, once?: (ev: string, cb: () => void) => any }} sink
|
|
73
|
-
* @returns {Promise<{ streamed: boolean, pages: number, warnings: string[], why?: string }>}
|
|
74
|
-
*/
|
|
75
|
-
export function exportPdfStream(def: any, options: PdfStreamOptions, sink: {
|
|
76
|
-
write(bytes: Uint8Array): any;
|
|
77
|
-
once?: (ev: string, cb: () => void) => any;
|
|
78
|
-
}): Promise<{
|
|
52
|
+
export function exportPdfStream(def: any, options: any, sink: any): Promise<{
|
|
79
53
|
streamed: boolean;
|
|
80
54
|
pages: number;
|
|
81
55
|
warnings: string[];
|
|
@@ -161,6 +135,7 @@ export type PdfOptions = Omit<NonNullable<Parameters<typeof exportPdfFull>[2]>,
|
|
|
161
135
|
[k: string]: unknown;
|
|
162
136
|
};
|
|
163
137
|
};
|
|
138
|
+
export type RenderOptions = import("../../src/engine/index.js").RenderOptions;
|
|
164
139
|
/**
|
|
165
140
|
* render()'s options and exportPdf's, plus: window (rows laid out at once, 1000), parallel (Node: worker threads
|
|
166
141
|
* that lay out and paint pages, opt-in; the file is the same, each thread costs memory), maxRows (rows read,
|
|
@@ -189,7 +164,6 @@ export type PdfStreamOptions = RenderOptions & Omit<PdfOptions, "fonts"> & {
|
|
|
189
164
|
};
|
|
190
165
|
sorter?: (cmp: (a: any, b: any) => number) => any;
|
|
191
166
|
};
|
|
192
|
-
export type RenderOptions = import("../../src/engine/index.js").RenderOptions;
|
|
193
167
|
import { FontStore } from '../../src/engine/index.js';
|
|
194
168
|
import { exportXlsx as exportXlsxFull } from '../../src/exporters/xlsx.js';
|
|
195
169
|
import { exportDocx as exportDocxFull } from '../../src/exporters/docx.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Render a report definition to a page model (pages, regions), the input of every exporter. Throws ReportError for a
|
|
3
3
|
* definition that cannot render at all; everything else is a warning in the model.
|
|
4
|
-
* @param {any} def0 the report definition (
|
|
4
|
+
* @param {any} def0 the report definition (reportwright/report@1), or a saved report's JSON
|
|
5
5
|
* @param {RenderOptions} [opts]
|
|
6
6
|
* @returns {Promise<any>} the page model
|
|
7
7
|
*/
|
|
@@ -11,11 +11,13 @@ export function validate(def: any): {
|
|
|
11
11
|
warnings: any[];
|
|
12
12
|
exprErrors: any[];
|
|
13
13
|
checkOnly: any[];
|
|
14
|
+
renderSays?: undefined;
|
|
14
15
|
} | {
|
|
15
16
|
errors: any[];
|
|
16
17
|
warnings: string[];
|
|
17
18
|
exprErrors: any[];
|
|
18
19
|
checkOnly: any[];
|
|
20
|
+
renderSays: string[];
|
|
19
21
|
};
|
|
20
|
-
export const SCHEMA_ID: "
|
|
21
|
-
export const SCHEMA_ALIAS: "
|
|
22
|
+
export const SCHEMA_ID: "reportwright/report@1";
|
|
23
|
+
export const SCHEMA_ALIAS: "pagewright/report@1";
|
|
@@ -43,6 +43,11 @@ export function fontCss(key: any): {
|
|
|
43
43
|
weight: number;
|
|
44
44
|
style: string;
|
|
45
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* The font keys a page model draws with (text runs, form fields, figures), for an exporter whose store render() did
|
|
48
|
+
* not fill (N40): load them first. @param {any} model @returns {string[]}
|
|
49
|
+
*/
|
|
50
|
+
export function modelFontKeys(model: any): string[];
|
|
46
51
|
/** The bundled fallback faces for `key` (one per script), for CSS font-family lists. */
|
|
47
52
|
export function fallbackKeys(key: any): string[];
|
|
48
53
|
/**
|
|
@@ -106,12 +106,13 @@ export class TextMeasurer {
|
|
|
106
106
|
* character), exactly as before. Others also break between CJK characters (kinsoku applied), never
|
|
107
107
|
* inside a grapheme cluster (a conjunct, a letter and its marks), and remember their direction.
|
|
108
108
|
* @param {string} text @param {string} key @param {number} size @param {number} maxWidth
|
|
109
|
-
* @returns {{text: string, width: number, dir?: 'ltr'|'rtl'}[]}
|
|
109
|
+
* @returns {{text: string, width: number, dir?: 'ltr'|'rtl', end?: boolean}[]}
|
|
110
110
|
*/
|
|
111
111
|
wrap(text: string, key: string, size: number, maxWidth: number): {
|
|
112
112
|
text: string;
|
|
113
113
|
width: number;
|
|
114
114
|
dir?: "ltr" | "rtl";
|
|
115
|
+
end?: boolean;
|
|
115
116
|
}[];
|
|
116
117
|
/** @param {string} para @param {string} key @param {number} size @param {number} maxWidth @param {'ltr'|'rtl'} dir @param {number} sp @param {any[]} out */
|
|
117
118
|
wrapComplex(para: string, key: string, size: number, maxWidth: number, dir: "ltr" | "rtl", sp: number, out: any[]): void;
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
export namespace ENCODINGS {
|
|
2
|
+
let WinAnsi: number[];
|
|
3
|
+
let Symbol: number[];
|
|
4
|
+
let ZapfDingbats: number[];
|
|
5
|
+
}
|
|
6
|
+
/** PostScript name → the font's metrics (units per em 1000); widths: the advance of each code in its encoding */
|
|
7
|
+
export const METRICS: {
|
|
8
|
+
Helvetica: {
|
|
9
|
+
encoding: string;
|
|
10
|
+
familyName: string;
|
|
11
|
+
ascent: number;
|
|
12
|
+
descent: number;
|
|
13
|
+
capHeight: number;
|
|
14
|
+
xHeight: number;
|
|
15
|
+
italicAngle: number;
|
|
16
|
+
underlinePosition: number;
|
|
17
|
+
underlineThickness: number;
|
|
18
|
+
bbox: number[];
|
|
19
|
+
widths: number[];
|
|
20
|
+
};
|
|
21
|
+
'Helvetica-Bold': {
|
|
22
|
+
encoding: string;
|
|
23
|
+
familyName: string;
|
|
24
|
+
ascent: number;
|
|
25
|
+
descent: number;
|
|
26
|
+
capHeight: number;
|
|
27
|
+
xHeight: number;
|
|
28
|
+
italicAngle: number;
|
|
29
|
+
underlinePosition: number;
|
|
30
|
+
underlineThickness: number;
|
|
31
|
+
bbox: number[];
|
|
32
|
+
widths: number[];
|
|
33
|
+
};
|
|
34
|
+
'Helvetica-Oblique': {
|
|
35
|
+
encoding: string;
|
|
36
|
+
familyName: string;
|
|
37
|
+
ascent: number;
|
|
38
|
+
descent: number;
|
|
39
|
+
capHeight: number;
|
|
40
|
+
xHeight: number;
|
|
41
|
+
italicAngle: number;
|
|
42
|
+
underlinePosition: number;
|
|
43
|
+
underlineThickness: number;
|
|
44
|
+
bbox: number[];
|
|
45
|
+
widths: number[];
|
|
46
|
+
};
|
|
47
|
+
'Helvetica-BoldOblique': {
|
|
48
|
+
encoding: string;
|
|
49
|
+
familyName: string;
|
|
50
|
+
ascent: number;
|
|
51
|
+
descent: number;
|
|
52
|
+
capHeight: number;
|
|
53
|
+
xHeight: number;
|
|
54
|
+
italicAngle: number;
|
|
55
|
+
underlinePosition: number;
|
|
56
|
+
underlineThickness: number;
|
|
57
|
+
bbox: number[];
|
|
58
|
+
widths: number[];
|
|
59
|
+
};
|
|
60
|
+
'Times-Roman': {
|
|
61
|
+
encoding: string;
|
|
62
|
+
familyName: string;
|
|
63
|
+
ascent: number;
|
|
64
|
+
descent: number;
|
|
65
|
+
capHeight: number;
|
|
66
|
+
xHeight: number;
|
|
67
|
+
italicAngle: number;
|
|
68
|
+
underlinePosition: number;
|
|
69
|
+
underlineThickness: number;
|
|
70
|
+
bbox: number[];
|
|
71
|
+
widths: number[];
|
|
72
|
+
};
|
|
73
|
+
'Times-Bold': {
|
|
74
|
+
encoding: string;
|
|
75
|
+
familyName: string;
|
|
76
|
+
ascent: number;
|
|
77
|
+
descent: number;
|
|
78
|
+
capHeight: number;
|
|
79
|
+
xHeight: number;
|
|
80
|
+
italicAngle: number;
|
|
81
|
+
underlinePosition: number;
|
|
82
|
+
underlineThickness: number;
|
|
83
|
+
bbox: number[];
|
|
84
|
+
widths: number[];
|
|
85
|
+
};
|
|
86
|
+
'Times-Italic': {
|
|
87
|
+
encoding: string;
|
|
88
|
+
familyName: string;
|
|
89
|
+
ascent: number;
|
|
90
|
+
descent: number;
|
|
91
|
+
capHeight: number;
|
|
92
|
+
xHeight: number;
|
|
93
|
+
italicAngle: number;
|
|
94
|
+
underlinePosition: number;
|
|
95
|
+
underlineThickness: number;
|
|
96
|
+
bbox: number[];
|
|
97
|
+
widths: number[];
|
|
98
|
+
};
|
|
99
|
+
'Times-BoldItalic': {
|
|
100
|
+
encoding: string;
|
|
101
|
+
familyName: string;
|
|
102
|
+
ascent: number;
|
|
103
|
+
descent: number;
|
|
104
|
+
capHeight: number;
|
|
105
|
+
xHeight: number;
|
|
106
|
+
italicAngle: number;
|
|
107
|
+
underlinePosition: number;
|
|
108
|
+
underlineThickness: number;
|
|
109
|
+
bbox: number[];
|
|
110
|
+
widths: number[];
|
|
111
|
+
};
|
|
112
|
+
Courier: {
|
|
113
|
+
encoding: string;
|
|
114
|
+
familyName: string;
|
|
115
|
+
ascent: number;
|
|
116
|
+
descent: number;
|
|
117
|
+
capHeight: number;
|
|
118
|
+
xHeight: number;
|
|
119
|
+
italicAngle: number;
|
|
120
|
+
underlinePosition: number;
|
|
121
|
+
underlineThickness: number;
|
|
122
|
+
bbox: number[];
|
|
123
|
+
widths: number[];
|
|
124
|
+
};
|
|
125
|
+
'Courier-Bold': {
|
|
126
|
+
encoding: string;
|
|
127
|
+
familyName: string;
|
|
128
|
+
ascent: number;
|
|
129
|
+
descent: number;
|
|
130
|
+
capHeight: number;
|
|
131
|
+
xHeight: number;
|
|
132
|
+
italicAngle: number;
|
|
133
|
+
underlinePosition: number;
|
|
134
|
+
underlineThickness: number;
|
|
135
|
+
bbox: number[];
|
|
136
|
+
widths: number[];
|
|
137
|
+
};
|
|
138
|
+
'Courier-Oblique': {
|
|
139
|
+
encoding: string;
|
|
140
|
+
familyName: string;
|
|
141
|
+
ascent: number;
|
|
142
|
+
descent: number;
|
|
143
|
+
capHeight: number;
|
|
144
|
+
xHeight: number;
|
|
145
|
+
italicAngle: number;
|
|
146
|
+
underlinePosition: number;
|
|
147
|
+
underlineThickness: number;
|
|
148
|
+
bbox: number[];
|
|
149
|
+
widths: number[];
|
|
150
|
+
};
|
|
151
|
+
'Courier-BoldOblique': {
|
|
152
|
+
encoding: string;
|
|
153
|
+
familyName: string;
|
|
154
|
+
ascent: number;
|
|
155
|
+
descent: number;
|
|
156
|
+
capHeight: number;
|
|
157
|
+
xHeight: number;
|
|
158
|
+
italicAngle: number;
|
|
159
|
+
underlinePosition: number;
|
|
160
|
+
underlineThickness: number;
|
|
161
|
+
bbox: number[];
|
|
162
|
+
widths: number[];
|
|
163
|
+
};
|
|
164
|
+
Symbol: {
|
|
165
|
+
encoding: string;
|
|
166
|
+
familyName: string;
|
|
167
|
+
ascent: number;
|
|
168
|
+
descent: number;
|
|
169
|
+
capHeight: number;
|
|
170
|
+
xHeight: number;
|
|
171
|
+
italicAngle: number;
|
|
172
|
+
underlinePosition: number;
|
|
173
|
+
underlineThickness: number;
|
|
174
|
+
bbox: number[];
|
|
175
|
+
widths: number[];
|
|
176
|
+
};
|
|
177
|
+
ZapfDingbats: {
|
|
178
|
+
encoding: string;
|
|
179
|
+
familyName: string;
|
|
180
|
+
ascent: number;
|
|
181
|
+
descent: number;
|
|
182
|
+
capHeight: number;
|
|
183
|
+
xHeight: number;
|
|
184
|
+
italicAngle: number;
|
|
185
|
+
underlinePosition: number;
|
|
186
|
+
underlineThickness: number;
|
|
187
|
+
bbox: number[];
|
|
188
|
+
widths: number[];
|
|
189
|
+
};
|
|
190
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A standard font as a fontkit-like object (unitsPerEm 1000).
|
|
2
|
+
* A standard font as a fontkit-like object (unitsPerEm 1000). The tables (about 22 KB) load on first use.
|
|
3
3
|
* @param {string} key a PostScript name of STANDARD_FACES
|
|
4
4
|
*/
|
|
5
5
|
export function standardFont(key: string): Promise<{
|
|
@@ -11,7 +11,7 @@ export function standardFont(key: string): Promise<{
|
|
|
11
11
|
descent: any;
|
|
12
12
|
capHeight: any;
|
|
13
13
|
xHeight: any;
|
|
14
|
-
italicAngle:
|
|
14
|
+
italicAngle: any;
|
|
15
15
|
underlinePosition: any;
|
|
16
16
|
underlineThickness: any;
|
|
17
17
|
bbox: {
|
|
@@ -22,7 +22,7 @@ export function standardFont(key: string): Promise<{
|
|
|
22
22
|
};
|
|
23
23
|
/** WinAnsi for the text fonts (Symbol and ZapfDingbats use their own built-in encodings) */
|
|
24
24
|
winAnsi: boolean;
|
|
25
|
-
widths: any
|
|
25
|
+
widths: any;
|
|
26
26
|
/** @param {number} cp */
|
|
27
27
|
hasGlyphForCodePoint: (cp: number) => boolean;
|
|
28
28
|
/** @param {number} cp */
|
|
@@ -31,11 +31,11 @@ export function standardFont(key: string): Promise<{
|
|
|
31
31
|
}>;
|
|
32
32
|
/**
|
|
33
33
|
* The 14 standard PDF fonts (Helvetica, Times, Courier in four faces each, Symbol, ZapfDingbats): every PDF reader has
|
|
34
|
-
* them, so a PDF names them and embeds nothing. Their metrics are Adobe's AFM files,
|
|
35
|
-
*
|
|
36
|
-
* layout measures with the widths the PDF's /Widths array gives. A glyph ID
|
|
37
|
-
* encoding (WinAnsi; Symbol and ZapfDingbats have their own), one byte;
|
|
38
|
-
*/
|
|
34
|
+
* them, so a PDF names them and embeds nothing. Their metrics are Adobe's AFM files, generated into standard-metrics.js
|
|
35
|
+
* (scripts/gen-standard-metrics.mjs, from @pdf-lib/standard-fonts); this wraps one in the part of fontkit's font API
|
|
36
|
+
* the engine and the PDF exporters read, so layout measures with the widths the PDF's /Widths array gives. A glyph ID
|
|
37
|
+
* here is the character's code in the font's encoding (WinAnsi; Symbol and ZapfDingbats have their own), one byte;
|
|
38
|
+
* 0 = not in the encoding. */
|
|
39
39
|
/** [family, PostScript name, weight, style] */
|
|
40
40
|
export const STANDARD_FACES: (string | number)[][];
|
|
41
41
|
export const STANDARD_KEYS: Set<string>;
|
|
@@ -61,6 +61,8 @@ export function createPdfStream(sink: Sink, opt: {
|
|
|
61
61
|
* @param {string} dict @param {Uint8Array} [stream]
|
|
62
62
|
*/
|
|
63
63
|
object(dict: string, stream?: Uint8Array): Promise<number>;
|
|
64
|
+
/** Bytes held for the cross-reference: the open blocks, the deflated ones, the late entries (a Map's ~40 each). */
|
|
65
|
+
readonly xrefBytes: number;
|
|
64
66
|
/** An object number to write later (objectAt). */
|
|
65
67
|
reserve: () => number;
|
|
66
68
|
/** Write a reserved object. @param {number} n @param {string} dict @param {Uint8Array} [stream] */
|
|
@@ -17,6 +17,8 @@ export function createStreamTagger(w: any, { maxElements }?: {
|
|
|
17
17
|
}): {
|
|
18
18
|
/** structure elements so far */
|
|
19
19
|
readonly count: number;
|
|
20
|
+
/** elements of the page being drawn, held until it ends */
|
|
21
|
+
readonly held: number;
|
|
20
22
|
/** a new page (window: the paged window it came from; row ids are its own) @param {number} window */
|
|
21
23
|
page(window: number): void;
|
|
22
24
|
/**
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
/** At the server's start: remove the spill folders of processes that are gone (pw-spill-<pid>-…) and old-style ones. */
|
|
2
2
|
export function sweepAtBoot(root?: any): void;
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A sorter factory for planStream (engine/stream.js): sorter(cmp) → { push, drain, close }. The engine closes it
|
|
5
|
+
* when the rows end, fail or are abandoned (a client that left): its files go then.
|
|
6
|
+
* Memory, whatever the row count (N44): one run in memory while reading (runMB of records, about, and at most run
|
|
7
|
+
* records), and while merging at most mergeMB of batches (frame records a run): past that many runs, groups of runs
|
|
8
|
+
* are first merged into longer ones on disk (one more pass over those records), so the merge never holds a batch from
|
|
9
|
+
* every run of a large sort.
|
|
10
|
+
* @param {{ runMB?: number, mergeMB?: number, run?: number, runBytes?: number, frame?: number, maxMB?: number, totalMB?: number, dir?: string, staleMs?: number }} [o]
|
|
11
|
+
*/
|
|
12
|
+
export function spillSorter({ runMB, mergeMB, run, runBytes, frame, maxMB, totalMB, dir: root, staleMs }?: {
|
|
13
|
+
runMB?: number;
|
|
14
|
+
mergeMB?: number;
|
|
4
15
|
run?: number;
|
|
5
16
|
runBytes?: number;
|
|
6
17
|
frame?: number;
|
|
7
18
|
maxMB?: number;
|
|
8
19
|
totalMB?: number;
|
|
9
|
-
dir?:
|
|
20
|
+
dir?: string;
|
|
10
21
|
staleMs?: number;
|
|
11
22
|
}): (cmp: (a: any, b: any) => number) => {
|
|
12
23
|
/** @param {any} r */
|
|
13
24
|
push(r: any): Promise<void>;
|
|
14
25
|
drain(): AsyncGenerator<any, void, unknown>;
|
|
15
26
|
close(): Promise<void>;
|
|
16
|
-
/** Tests: the runs
|
|
27
|
+
/** Tests: the runs on disk now, and the merges of groups of runs before the last. */
|
|
17
28
|
readonly runs: number;
|
|
29
|
+
readonly passes: number;
|
|
18
30
|
};
|
|
19
31
|
export function canSpill(): boolean;
|
|
20
32
|
export function spillShared(): any;
|
|
@@ -25,10 +25,14 @@ export namespace XML_LIMITS {
|
|
|
25
25
|
let maxElements: number;
|
|
26
26
|
let maxAttributes: number;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* pos: where its start tag begins in the input (a character offset)
|
|
30
|
+
*/
|
|
28
31
|
export type XmlElement = {
|
|
29
32
|
name: string;
|
|
30
33
|
ns: string;
|
|
31
34
|
attrs: Record<string, string>;
|
|
32
35
|
children: XmlElement[];
|
|
33
36
|
text: string;
|
|
37
|
+
pos?: number;
|
|
34
38
|
};
|
package/examples/stream-1m.mjs
CHANGED
|
@@ -54,7 +54,7 @@ async function* rows() {
|
|
|
54
54
|
const grouped = flag('grouped');
|
|
55
55
|
const total = (label) => [{ height: 15, style: { fontWeight: 'bold' }, cells: [{ value: label }, { value: '=CountRows()' }, null, null, null, { value: '=Sum(Fields.amount)', style: { format: 'N2', textAlign: 'right' } }, null] }];
|
|
56
56
|
const def = {
|
|
57
|
-
$schema: '
|
|
57
|
+
$schema: 'reportwright/report@1', name: 'Ledger', locale: 'en-IN', page: { size: 'A4', margins: [36, 36, 36, 36] },
|
|
58
58
|
// the rows come from opts.sqlRows below (a cursor); the query text is not run
|
|
59
59
|
dataSources: [{ name: 'db', type: 'sql', connection: 'ledger', query: 'select * from transactions order by id' }],
|
|
60
60
|
dataSets: [{ name: 'Tx', source: 'db', fields: [{ name: 'id', type: 'number' }, { name: 'account', type: 'string' }, { name: 'region', type: 'string' }, { name: 'type', type: 'string' },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reportwright/engine",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.2-rc.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -67,13 +67,12 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"pdf-lib": "1.17.1",
|
|
69
69
|
"@pdf-lib/fontkit": "1.1.1",
|
|
70
|
-
"@pdf-lib/standard-fonts": "1.0.0",
|
|
71
70
|
"bwip-js": "4.11.4",
|
|
72
71
|
"fflate": "0.8.3",
|
|
73
72
|
"bidi-js": "1.0.3"
|
|
74
73
|
},
|
|
75
74
|
"peerDependencies": {
|
|
76
|
-
"@reportwright/fonts": "0.13.
|
|
75
|
+
"@reportwright/fonts": "0.13.2-rc.1"
|
|
77
76
|
},
|
|
78
77
|
"peerDependenciesMeta": {
|
|
79
78
|
"@reportwright/fonts": {
|
package/report.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Types for a ReportWright report definition (
|
|
1
|
+
// Types for a ReportWright report definition (reportwright/report@1), the JSON that render() takes.
|
|
2
2
|
// GENERATED from src/engine/schema/report.schema.js by scripts/gen-report-types.mjs: do not edit by hand.
|
|
3
3
|
// The same schema is published as @reportwright/engine/schema.json, and validate() checks against it.
|
|
4
4
|
// Any value marked Expr may be a literal or an expression string starting with "=" (e.g. "=Fields.amount").
|
|
@@ -595,13 +595,13 @@ export interface DataSet {
|
|
|
595
595
|
sort?: SortSpec[];
|
|
596
596
|
[key: string]: unknown;
|
|
597
597
|
}
|
|
598
|
-
/** A ReportWright report definition (
|
|
598
|
+
/** A ReportWright report definition (reportwright/report@1).
|
|
599
599
|
* @example
|
|
600
|
-
* {"$schema":"
|
|
600
|
+
* {"$schema":"reportwright/report@1","name":"Invoice","page":{"size":"A4","margins":[36,36,36,36]},"dataSources":[{"name":"orders","type":"json","data":{"rows":[{"customer":"Asha Rao","amount":1200.5}]}}],"dataSets":[{"name":"Rows","source":"orders","path":"$.rows"}],"sections":{"body":{"items":[{"type":"textbox","name":"Title","x":0,"y":0,"w":300,"h":24,"value":"Invoice","style":{"fontSize":18,"fontWeight":"bold"}},{"type":"table","name":"Lines","x":0,"y":40,"w":400,"h":40,"dataSet":"Rows","columns":[{"width":250},{"width":150}],"header":[{"height":18,"cells":[{"value":"Customer","colSpan":1},{"value":"Amount"}]}],"detail":[{"height":18,"cells":[{"value":"=Fields.customer"},{"value":"=Fields.amount","style":{"format":"C2"}}]}],"footer":[{"height":18,"cells":[{"value":"Total","colSpan":2}]}]}]}}}
|
|
601
601
|
*/
|
|
602
602
|
export interface Report {
|
|
603
|
-
/**
|
|
604
|
-
$schema: '
|
|
603
|
+
/** reportwright/report@1; pagewright/report@1 (deprecated, the name before the rename) is the same format. */
|
|
604
|
+
$schema: 'reportwright/report@1' | 'pagewright/report@1';
|
|
605
605
|
name?: string;
|
|
606
606
|
description?: string;
|
|
607
607
|
locale?: string;
|
package/schema.json
CHANGED
|
@@ -2279,14 +2279,14 @@
|
|
|
2279
2279
|
"additionalProperties": true
|
|
2280
2280
|
},
|
|
2281
2281
|
"Report": {
|
|
2282
|
-
"description": "A ReportWright report definition (
|
|
2282
|
+
"description": "A ReportWright report definition (reportwright/report@1).",
|
|
2283
2283
|
"type": "object",
|
|
2284
2284
|
"properties": {
|
|
2285
2285
|
"$schema": {
|
|
2286
|
-
"description": "
|
|
2286
|
+
"description": "reportwright/report@1; pagewright/report@1 (deprecated, the name before the rename) is the same format.",
|
|
2287
2287
|
"enum": [
|
|
2288
|
-
"
|
|
2289
|
-
"
|
|
2288
|
+
"reportwright/report@1",
|
|
2289
|
+
"pagewright/report@1"
|
|
2290
2290
|
]
|
|
2291
2291
|
},
|
|
2292
2292
|
"name": {
|
|
@@ -2404,7 +2404,7 @@
|
|
|
2404
2404
|
],
|
|
2405
2405
|
"examples": [
|
|
2406
2406
|
{
|
|
2407
|
-
"$schema": "
|
|
2407
|
+
"$schema": "reportwright/report@1",
|
|
2408
2408
|
"name": "Invoice",
|
|
2409
2409
|
"page": {
|
|
2410
2410
|
"size": "A4",
|