@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,53 @@
|
|
|
1
|
+
/** @param {number} v @param {keyof UNITS} unit */
|
|
2
|
+
export function toPt(v: number, unit: "pt" | "in" | "cm" | "mm" | "px"): number;
|
|
3
|
+
/** @param {number} pt @param {keyof UNITS} unit */
|
|
4
|
+
export function fromPt(pt: number, unit: "pt" | "in" | "cm" | "mm" | "px"): number;
|
|
5
|
+
/**
|
|
6
|
+
* @param {{size?: string, width?: number, height?: number, orientation?: string, margins?: number[]|number}} page
|
|
7
|
+
*/
|
|
8
|
+
/** A size name as the engine reads it: trimmed, case-insensitive ("a4 " -> "A4"); undefined when it names no size. */
|
|
9
|
+
export function normalizePageSize(size: any): string;
|
|
10
|
+
export function resolvePage(page?: {}): {
|
|
11
|
+
width: number;
|
|
12
|
+
height: number;
|
|
13
|
+
margins: {
|
|
14
|
+
top: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
left: number;
|
|
18
|
+
};
|
|
19
|
+
bodyWidth: number;
|
|
20
|
+
pageless: boolean;
|
|
21
|
+
minHeight: number;
|
|
22
|
+
} | {
|
|
23
|
+
width: any;
|
|
24
|
+
height: any;
|
|
25
|
+
margins: {
|
|
26
|
+
top: number;
|
|
27
|
+
right: number;
|
|
28
|
+
bottom: number;
|
|
29
|
+
left: number;
|
|
30
|
+
};
|
|
31
|
+
bodyWidth: number;
|
|
32
|
+
pageless?: undefined;
|
|
33
|
+
minHeight?: undefined;
|
|
34
|
+
};
|
|
35
|
+
/** CSS-like box shorthand → [top, right, bottom, left] */
|
|
36
|
+
export function normBox(v: any): number[];
|
|
37
|
+
export namespace PAGE_SIZES {
|
|
38
|
+
let A4: number[];
|
|
39
|
+
let A5: number[];
|
|
40
|
+
let A3: number[];
|
|
41
|
+
let Letter: number[];
|
|
42
|
+
let Legal: number[];
|
|
43
|
+
}
|
|
44
|
+
export namespace UNITS {
|
|
45
|
+
export let pt: number;
|
|
46
|
+
let _in: number;
|
|
47
|
+
export { _in as in };
|
|
48
|
+
export let cm: number;
|
|
49
|
+
export let mm: number;
|
|
50
|
+
export let px: number;
|
|
51
|
+
}
|
|
52
|
+
/** A pageless report grows to fit its content, up to the largest PDF page (200 inches). */
|
|
53
|
+
export const PAGELESS_MAX: 14400;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one allow-list for links the engine emits (url actions, rich text <a href>), checked on the exact
|
|
3
|
+
* string that is emitted. Browsers and PDF readers parse URLs leniently (they drop tabs and newlines before
|
|
4
|
+
* the scheme, read "\" as "/", take "https:x" and "//host" as absolute), so the rule is strict:
|
|
5
|
+
* - no character at or below U+0020, no DEL or C1 control, no backslash;
|
|
6
|
+
* - http:// or https:// with a host (double slash required), or mailto:;
|
|
7
|
+
* - a relative path that starts with one "/" (not "//").
|
|
8
|
+
* @param {unknown} v
|
|
9
|
+
* @returns {string|null} v itself when allowed, else null
|
|
10
|
+
*/
|
|
11
|
+
export function safeUrl(v: unknown): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* A drill-through's address in the ReportWright viewer: `<base>/viewer/<report>?<parameters>` (a list parameter
|
|
14
|
+
* repeats its name), checked by safeUrl; null without a base URL or a report. The HTML and PDF exports link to it.
|
|
15
|
+
* @param {string|undefined|null} base @param {{ report?: string, params?: Record<string, any> }} a @returns {string|null}
|
|
16
|
+
*/
|
|
17
|
+
export function drillUrl(base: string | undefined | null, a: {
|
|
18
|
+
report?: string;
|
|
19
|
+
params?: Record<string, any>;
|
|
20
|
+
}): string | null;
|
|
21
|
+
/** A URL as a PDF URI action may hold it: 7-bit ASCII (an international host as punycode, other characters
|
|
22
|
+
* percent-encoded). @param {string} href @returns {string} */
|
|
23
|
+
export function asciiUrl(href: string): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** @returns {{r:number,g:number,b:number,a:number}|null} channels 0..1 */
|
|
2
|
+
export function parseColor(c: any): {
|
|
3
|
+
r: number;
|
|
4
|
+
g: number;
|
|
5
|
+
b: number;
|
|
6
|
+
a: number;
|
|
7
|
+
} | null;
|
|
8
|
+
/** Safe color for SVG/HTML attributes. */
|
|
9
|
+
export function cssColor(c: any): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CSV of the report's data: one header row and the detail rows of the main table (the one with the most detail rows),
|
|
3
|
+
* numbers without symbols or separators, dates in ISO form. Group headers, subtotals, totals and other tables are left
|
|
4
|
+
* out. layout: true gives the printed layout instead: every table with its name and every row (group lines, totals).
|
|
5
|
+
* @param {any} model @param {{ all?: boolean, layout?: boolean, locale?: string, currency?: string }} [o]
|
|
6
|
+
*/
|
|
7
|
+
export function exportCsv(model: any, { all, layout, locale, currency }?: {
|
|
8
|
+
all?: boolean;
|
|
9
|
+
layout?: boolean;
|
|
10
|
+
locale?: string;
|
|
11
|
+
currency?: string;
|
|
12
|
+
}): string;
|
|
13
|
+
/**
|
|
14
|
+
* A CSV line from a region row (one value per column, empty where no cell starts). Shared by exportCsv and the streaming
|
|
15
|
+
* writer (writeCsvStream), so both write the same bytes.
|
|
16
|
+
* @param {{ timeZone?: string|null, locale?: string, currency?: string }} o
|
|
17
|
+
*/
|
|
18
|
+
export function csvLine({ timeZone, locale, currency }: {
|
|
19
|
+
timeZone?: string | null;
|
|
20
|
+
locale?: string;
|
|
21
|
+
currency?: string;
|
|
22
|
+
}): (ncols: any, row: any) => string;
|
|
23
|
+
/** The data CSV's header line: header rows stacked into one, a cell spanning columns naming each of them ("Who Id"). */
|
|
24
|
+
export function csvNames(ncols: any): {
|
|
25
|
+
/** @param {{ cells: any[] }} row */
|
|
26
|
+
add(row: {
|
|
27
|
+
cells: any[];
|
|
28
|
+
}): void;
|
|
29
|
+
line: () => string;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* The data CSV of a streaming plan (engine/stream.js), written as its rows come: the same bytes exportCsv writes for the
|
|
33
|
+
* model of that report. put(text) may return a promise (back-pressure): it is awaited.
|
|
34
|
+
* @param {{ columns: number[], timeZone: string|null, rows: () => AsyncGenerator<any> }} plan
|
|
35
|
+
* @param {(s: string) => any} put @param {{ locale?: string, currency?: string }} [o]
|
|
36
|
+
*/
|
|
37
|
+
export function writeCsvStream(plan: {
|
|
38
|
+
columns: number[];
|
|
39
|
+
timeZone: string | null;
|
|
40
|
+
rows: () => AsyncGenerator<any>;
|
|
41
|
+
}, put: (s: string) => any, { locale, currency }?: {
|
|
42
|
+
locale?: string;
|
|
43
|
+
currency?: string;
|
|
44
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An export bounded by opt.timeoutMs: past it the promise rejects with status 504. The work itself is not stopped
|
|
3
|
+
* (a server render runs in a worker that the pool terminates); the caller is not left waiting.
|
|
4
|
+
* @template T @param {Promise<T>} work @param {number|undefined} ms @returns {Promise<T>}
|
|
5
|
+
*/
|
|
6
|
+
export function withDeadline<T>(work: Promise<T>, ms: number | undefined): Promise<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Left, right or centre, from where the lines sit in their box. */
|
|
2
|
+
export function alignOf(it: any): "center" | "left" | "right" | "both";
|
|
3
|
+
/**
|
|
4
|
+
* @param {any} model render() output
|
|
5
|
+
* @param {{ title?: string, author?: string, lang?: string, fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
6
|
+
* rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null>, figures?: boolean }} [opt]
|
|
7
|
+
* fontStore: text in pictures as outlines (else the reader's fallback font); fetchImage: pictures by URL;
|
|
8
|
+
* rasterize: the PNG fallback of a picture (default: a canvas in a browser, sharp in Node); figures: false leaves them out.
|
|
9
|
+
* @returns {Promise<Uint8Array>}
|
|
10
|
+
*/
|
|
11
|
+
export function exportDocx(model: any, opt?: {
|
|
12
|
+
title?: string;
|
|
13
|
+
author?: string;
|
|
14
|
+
lang?: string;
|
|
15
|
+
fontStore?: any;
|
|
16
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
17
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
18
|
+
figures?: boolean;
|
|
19
|
+
}): Promise<Uint8Array>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Algorithm 2.B: the hash of a password, a salt and (for the owner) the U string.
|
|
3
|
+
* @param {Uint8Array} pw @param {Uint8Array} salt @param {Uint8Array} udata
|
|
4
|
+
*/
|
|
5
|
+
export function hash2B(pw: Uint8Array, salt: Uint8Array, udata: Uint8Array): Promise<Uint8Array<ArrayBuffer>>;
|
|
6
|
+
/** A password as the handler wants it: NFKC (SASLprep's main step), UTF-8, at most 127 bytes. */
|
|
7
|
+
export function passwordBytes(pw: any, which: any): Uint8Array<ArrayBuffer>;
|
|
8
|
+
/** /P: reserved bits 7, 8 and 13–32 set, 1–2 clear; each permission allowed unless set to false. */
|
|
9
|
+
export function permissionsValue(perms?: {}): number;
|
|
10
|
+
/**
|
|
11
|
+
* Encrypt a pdf-lib document in place.
|
|
12
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
13
|
+
* @param {{ userPassword?: string, ownerPassword?: string, permissions?: Record<string, boolean> }} opt
|
|
14
|
+
*/
|
|
15
|
+
export function encryptPdf(doc: import("pdf-lib").PDFDocument, opt: {
|
|
16
|
+
userPassword?: string;
|
|
17
|
+
ownerPassword?: string;
|
|
18
|
+
permissions?: Record<string, boolean>;
|
|
19
|
+
}): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* The `pdf` option of an API request or the CLI → encryptPdf options, or undefined for no password.
|
|
22
|
+
* Checks the shape (400 on anything else); the passwords themselves are checked in passwordBytes.
|
|
23
|
+
* @param {any} pdf { userPassword?, ownerPassword?, permissions?: { print?: boolean, … } }
|
|
24
|
+
*/
|
|
25
|
+
export function pdfEncryptOptions(pdf: any): {
|
|
26
|
+
userPassword: any;
|
|
27
|
+
ownerPassword: any;
|
|
28
|
+
permissions: any;
|
|
29
|
+
};
|
|
30
|
+
export namespace PERMISSION_BITS {
|
|
31
|
+
let print: number;
|
|
32
|
+
let modify: number;
|
|
33
|
+
let copy: number;
|
|
34
|
+
let annotate: number;
|
|
35
|
+
let fillForms: number;
|
|
36
|
+
let accessibility: number;
|
|
37
|
+
let assemble: number;
|
|
38
|
+
let printHighQuality: number;
|
|
39
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The figures of a page, in page order: { tag, items, at, box } (at: index of the first item). A figure's items are
|
|
3
|
+
* consecutive in the page. One tag id marks one figure, also in a model that went through JSON (a tag copy per item).
|
|
4
|
+
* @param {any[]} items page items
|
|
5
|
+
*/
|
|
6
|
+
export function figures(items: any[]): any[];
|
|
7
|
+
/** Bounding box of page items (links and bookmarks left out), or null. @param {any[]} items */
|
|
8
|
+
export function boxOf(items: any[]): {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
w: number;
|
|
12
|
+
h: number;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A conservative bounding box of SVG path data: every end and control point, and an arc's end ± its radii.
|
|
16
|
+
* @param {string} d
|
|
17
|
+
*/
|
|
18
|
+
export function pathBox(d: string): {
|
|
19
|
+
x0: number;
|
|
20
|
+
y0: number;
|
|
21
|
+
x1: number;
|
|
22
|
+
y1: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Text as glyph outlines (SVG path data), where the engine placed it. Plain lines advance by the glyphs' own widths
|
|
26
|
+
* (as the engine measured them); shaped runs place each glyph by ID.
|
|
27
|
+
* @param {any} it a text item @param {(key: string) => any} fontOf fontkit font or null
|
|
28
|
+
* @returns {string|null} null when a font is missing
|
|
29
|
+
*/
|
|
30
|
+
export function textOutline(it: any, fontOf: (key: string) => any): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* The SVG of a figure: its items in their own box, text as outlines when the fonts are there.
|
|
33
|
+
* @param {{ items: any[], box: { x: number, y: number, w: number, h: number } }} fig
|
|
34
|
+
* @param {{ get: (key: string) => any } | null} [fontStore]
|
|
35
|
+
*/
|
|
36
|
+
export function figureSvg(fig: {
|
|
37
|
+
items: any[];
|
|
38
|
+
box: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
w: number;
|
|
42
|
+
h: number;
|
|
43
|
+
};
|
|
44
|
+
}, fontStore?: {
|
|
45
|
+
get: (key: string) => any;
|
|
46
|
+
} | null): string;
|
|
47
|
+
/**
|
|
48
|
+
* PNG bytes of an SVG, `scale` pixels per point: opt.rasterize when given (the caller's own), else a canvas in a
|
|
49
|
+
* browser, else sharp in Node (Next.js installs it). Null when none of them is there.
|
|
50
|
+
* @param {string} svg @param {number} w @param {number} h (points)
|
|
51
|
+
* @param {{ rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array|null>, scale?: number }} [opt]
|
|
52
|
+
* @returns {Promise<Uint8Array|null>}
|
|
53
|
+
*/
|
|
54
|
+
export function rasterize(svg: string, w: number, h: number, opt?: {
|
|
55
|
+
rasterize?: (svg: string, w: number, h: number, scale: number) => Promise<Uint8Array | null>;
|
|
56
|
+
scale?: number;
|
|
57
|
+
}): Promise<Uint8Array | null>;
|
|
58
|
+
/**
|
|
59
|
+
* A figure as picture parts: { png?, svg?, jpeg?, w, h, x, y } (where and how big it is drawn, in points). A figure that is one picture (an image item, maybe in a box)
|
|
60
|
+
* keeps the picture's own bytes; anything else is drawn as SVG and rasterised.
|
|
61
|
+
* @param {any} fig @param {{ fontStore?: any, fetchImage?: (src: string) => Promise<Uint8Array|null>, rasterize?: any }} opt
|
|
62
|
+
*/
|
|
63
|
+
export function figurePicture(fig: any, opt?: {
|
|
64
|
+
fontStore?: any;
|
|
65
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
66
|
+
rasterize?: any;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
[x: string]: any;
|
|
69
|
+
w: any;
|
|
70
|
+
h: any;
|
|
71
|
+
x: any;
|
|
72
|
+
y: any;
|
|
73
|
+
svg?: undefined;
|
|
74
|
+
png?: undefined;
|
|
75
|
+
} | {
|
|
76
|
+
svg: string;
|
|
77
|
+
png: Uint8Array<ArrayBufferLike>;
|
|
78
|
+
w: any;
|
|
79
|
+
h: any;
|
|
80
|
+
x: any;
|
|
81
|
+
y: any;
|
|
82
|
+
}>;
|
|
83
|
+
/** base64 of bytes (Node or browser). @param {Uint8Array} u8 */
|
|
84
|
+
export function b64(u8: Uint8Array): string;
|
|
85
|
+
/**
|
|
86
|
+
* The box a text item was painted in (paintBox: background rect, the text, its decoration lines, then the border
|
|
87
|
+
* lines or one rounded border rect), read back from the items around it: { fill, radius, sides: { top, right, bottom, left } }.
|
|
88
|
+
* @param {any[]} items @param {number} i the text item's index
|
|
89
|
+
*/
|
|
90
|
+
export function boxDecor(items: any[], i: number): {
|
|
91
|
+
fill: string;
|
|
92
|
+
radius: number;
|
|
93
|
+
sides: Record<string, any>;
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* The in-cell visuals of the tables on a page (sparklines, data bars, icons that a table cell draws; the engine does
|
|
97
|
+
* not tag those): shapes inside a table's rows that are not a cell's background. Each becomes a picture in its cell.
|
|
98
|
+
* Found by position: a visual in a row with no text cell at all is not found (it stays out).
|
|
99
|
+
* @param {any[]} items @param {Set<number>} used indexes already taken (marked here too)
|
|
100
|
+
* @param {Map<string, { cells: any[] }>} tables table key → its cell text items (with cell tags and clips)
|
|
101
|
+
* @returns {Map<string, Map<string, { items: any[], box: any }>>} table key → `${row}|${col}` → the visual
|
|
102
|
+
*/
|
|
103
|
+
export function cellVisuals(items: any[], used: Set<number>, tables: Map<string, {
|
|
104
|
+
cells: any[];
|
|
105
|
+
}>): Map<string, Map<string, {
|
|
106
|
+
items: any[];
|
|
107
|
+
box: any;
|
|
108
|
+
}>>;
|
|
109
|
+
/** Item kinds that are pictures in Word and PowerPoint (a heading tag alone is not). */
|
|
110
|
+
export const FIGURE_KINDS: Set<string>;
|
|
111
|
+
export function hexOrNull(c: any): string;
|
|
112
|
+
export function altOf(tag: any): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One self-contained HTML file: every page as inline SVG, fonts embedded as
|
|
3
|
+
* base64 (subset when a subsetter is given). URLs open, bookmark jumps and TOC entries scroll to their target, and
|
|
4
|
+
* drill-through opens the ReportWright viewer at drillBase (without one it is shown disabled).
|
|
5
|
+
* Unless static, a file whose report has tables also gets a Tables view (htmldata.js): the tables as HTML, re-sorted on
|
|
6
|
+
* their interactive-sort columns, groups opened and closed, rows filtered, by one inline script the file's CSP allows.
|
|
7
|
+
* @param {any} model
|
|
8
|
+
* @param {import('../engine/text/fonts.js').FontStore} fontStore
|
|
9
|
+
* @param {{ title?: string, drillBase?: string, subset?: (font: Uint8Array, cps: Iterable<number>, o?: { layout?: boolean }) => Promise<Uint8Array>,
|
|
10
|
+
* static?: boolean, locale?: string, currency?: string, lang?: string, strings?: Partial<typeof DATA_STRINGS> }} [opt]
|
|
11
|
+
*/
|
|
12
|
+
export function exportHtml(model: any, fontStore: import("../engine/text/fonts.js").FontStore, opt?: {
|
|
13
|
+
title?: string;
|
|
14
|
+
drillBase?: string;
|
|
15
|
+
subset?: (font: Uint8Array, cps: Iterable<number>, o?: {
|
|
16
|
+
layout?: boolean;
|
|
17
|
+
}) => Promise<Uint8Array>;
|
|
18
|
+
static?: boolean;
|
|
19
|
+
locale?: string;
|
|
20
|
+
currency?: string;
|
|
21
|
+
lang?: string;
|
|
22
|
+
strings?: Partial<typeof DATA_STRINGS>;
|
|
23
|
+
}): any;
|
|
24
|
+
import { DATA_STRINGS } from './htmldata.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tables of a model as the view's data, or null (no tables, or too many rows).
|
|
3
|
+
* Each row: { k: kind, l: level, c: [[col, text, key, span]] } (key: a number, or text in lower case, for sorting).
|
|
4
|
+
* sort: the columns the report sorts on click (its interactive-sort header cells, matched by position).
|
|
5
|
+
* @param {any} model @param {{ locale?: string, currency?: string }} [o]
|
|
6
|
+
*/
|
|
7
|
+
export function tablesData(model: any, o?: {
|
|
8
|
+
locale?: string;
|
|
9
|
+
currency?: string;
|
|
10
|
+
}): {
|
|
11
|
+
name: string;
|
|
12
|
+
cols: any;
|
|
13
|
+
sort: any[];
|
|
14
|
+
rows: any;
|
|
15
|
+
}[];
|
|
16
|
+
/** sha256 of a text, base64 (a CSP hash). */
|
|
17
|
+
export function cspHash(text: any): Promise<string>;
|
|
18
|
+
/** Most rows a file carries for the Tables view (beyond it, the file stays pages only). */
|
|
19
|
+
export const MAX_DATA_ROWS: 20000;
|
|
20
|
+
export namespace DATA_STRINGS {
|
|
21
|
+
let pages: string;
|
|
22
|
+
let tables: string;
|
|
23
|
+
let all: string;
|
|
24
|
+
let filter: string;
|
|
25
|
+
let toggle: string;
|
|
26
|
+
let sortAsc: string;
|
|
27
|
+
let sortDesc: string;
|
|
28
|
+
}
|
|
29
|
+
/** The script of the Tables view (a constant: its hash goes in the file's CSP). @type {string} */
|
|
30
|
+
export const DATA_SCRIPT: string;
|
|
31
|
+
/** CSS of the bar and the Tables view. @type {string} */
|
|
32
|
+
export const DATA_CSS: string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Page model → PDF bytes. Draws exactly the lines the engine made.
|
|
3
|
+
* @param {any} model render() output
|
|
4
|
+
* @param {import('../engine/text/fonts.js').FontStore} fontStore
|
|
5
|
+
* @param {{ title?: string, author?: string, fetchImage?: (src: string) => Promise<Uint8Array|null>,
|
|
6
|
+
* subset?: (font: Uint8Array, codePoints: Iterable<number>) => Promise<Uint8Array>,
|
|
7
|
+
* pdfa?: { icc?: Uint8Array }, prepare?: (doc: PDFDocument) => any, save?: object,
|
|
8
|
+
* encrypt?: { userPassword?: string, ownerPassword?: string, permissions?: Partial<Record<keyof typeof import('./encrypt.js').PERMISSION_BITS, boolean>> },
|
|
9
|
+
* tagged?: { lang?: string }, drillBase?: string, onWarning?: (message: string) => void, timeoutMs?: number,
|
|
10
|
+
* creationDate?: Date }} [opt]
|
|
11
|
+
* subset: a HarfBuzz subsetter (see subset.js). Without it, fonts embed in full.
|
|
12
|
+
* pdfa: make a PDF/A-2b file (needs an sRGB ICC profile). prepare: last change before saving
|
|
13
|
+
* (the server adds a signature placeholder there). save: extra pdf-lib save options.
|
|
14
|
+
* encrypt: { userPassword, ownerPassword, permissions } — AES-256 (see encrypt.js); not with pdfa or prepare.
|
|
15
|
+
* tagged: an accessible PDF (PDF/UA-1, see pdfua.js): structure tree, marked content, artifacts, language, title
|
|
16
|
+
* shown; with pdfa it is PDF/A-2a. Off, the file is exactly what it was.
|
|
17
|
+
* drillBase: the ReportWright server whose viewer a drill-through opens (a URI link); without it a drill-through
|
|
18
|
+
* is not a link. onWarning: what was left out (a damaged image). timeoutMs: the export's time limit (504).
|
|
19
|
+
* creationDate: the file's dates (UTC); else SOURCE_DATE_EPOCH when set; with either, the same report exports to the
|
|
20
|
+
* same bytes (encryption keeps its random key, so it does not).
|
|
21
|
+
*/
|
|
22
|
+
export function exportPdf(model: any, fontStore: import("../engine/text/fonts.js").FontStore, opt?: {
|
|
23
|
+
title?: string;
|
|
24
|
+
author?: string;
|
|
25
|
+
fetchImage?: (src: string) => Promise<Uint8Array | null>;
|
|
26
|
+
subset?: (font: Uint8Array, codePoints: Iterable<number>) => Promise<Uint8Array>;
|
|
27
|
+
pdfa?: {
|
|
28
|
+
icc?: Uint8Array;
|
|
29
|
+
};
|
|
30
|
+
prepare?: (doc: PDFDocument) => any;
|
|
31
|
+
save?: object;
|
|
32
|
+
encrypt?: {
|
|
33
|
+
userPassword?: string;
|
|
34
|
+
ownerPassword?: string;
|
|
35
|
+
permissions?: Partial<Record<keyof typeof import("./encrypt.js").PERMISSION_BITS, boolean>>;
|
|
36
|
+
};
|
|
37
|
+
tagged?: {
|
|
38
|
+
lang?: string;
|
|
39
|
+
};
|
|
40
|
+
drillBase?: string;
|
|
41
|
+
onWarning?: (message: string) => void;
|
|
42
|
+
timeoutMs?: number;
|
|
43
|
+
creationDate?: Date;
|
|
44
|
+
}): any;
|
|
45
|
+
import { PDFDocument } from 'pdf-lib';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {import('pdf-lib').PDFDocument} doc call after all pages, fields and annotations are added
|
|
3
|
+
* @param {{ icc?: Uint8Array, title?: string, author?: string, created?: Date, conformance?: 'A'|'B', ua?: boolean, id?: string }} opt
|
|
4
|
+
* id: the file identifier as hex (derived from the content for a fixed date), else random
|
|
5
|
+
* icc: an RGB ICC profile (the sRGB one in public/icc). conformance A (PDF/A-2a) for a tagged file; ua: it is PDF/UA-1 too.
|
|
6
|
+
*/
|
|
7
|
+
export function makePdfA(doc: import("pdf-lib").PDFDocument, { icc, title, author, created, conformance, ua, id }?: {
|
|
8
|
+
icc?: Uint8Array;
|
|
9
|
+
title?: string;
|
|
10
|
+
author?: string;
|
|
11
|
+
created?: Date;
|
|
12
|
+
conformance?: "A" | "B";
|
|
13
|
+
ua?: boolean;
|
|
14
|
+
id?: string;
|
|
15
|
+
}): void;
|
|
16
|
+
/**
|
|
17
|
+
* The Info dictionary's CreationDate and ModDate for an instant, in UTC (D:…+00'00'): the same instant gives the
|
|
18
|
+
* same bytes in any time zone. pdf-lib's own setters write the local offset.
|
|
19
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
20
|
+
* @param {Date} when
|
|
21
|
+
*/
|
|
22
|
+
export function setInfoDates(doc: import("pdf-lib").PDFDocument, when: Date): void;
|
|
23
|
+
/**
|
|
24
|
+
* The XMP metadata packet: title, author, dates, and the PDF/A and PDF/UA identifiers when asked.
|
|
25
|
+
* @param {{ title: string, author?: string, stamp: string, pdfa?: string|null, ua?: boolean }} o
|
|
26
|
+
*/
|
|
27
|
+
export function xmpPacket({ title, author, stamp, pdfa, ua }: {
|
|
28
|
+
title: string;
|
|
29
|
+
author?: string;
|
|
30
|
+
stamp: string;
|
|
31
|
+
pdfa?: string | null;
|
|
32
|
+
ua?: boolean;
|
|
33
|
+
}): string;
|
|
34
|
+
/**
|
|
35
|
+
* PDF/UA-1 without PDF/A: XMP metadata with the title and the PDF/UA identifier (the Info dictionary says the same).
|
|
36
|
+
* @param {import('pdf-lib').PDFDocument} doc
|
|
37
|
+
*/
|
|
38
|
+
export function setUaMetadata(doc: import("pdf-lib").PDFDocument, { title, author, created }?: {
|
|
39
|
+
title?: string;
|
|
40
|
+
author?: any;
|
|
41
|
+
created?: Date;
|
|
42
|
+
}): void;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Draw one run of shaped glyphs by ID, where the engine placed them: a TJ array whose numbers move each
|
|
3
|
+
* glyph from where the font's own advance (the W array) leaves it to the shaper's position; marks that sit
|
|
4
|
+
* higher or lower use the text rise. /ActualText gives copy and search the characters: for a left-to-right
|
|
5
|
+
* run the whole run in reading order; a right-to-left run (drawn in visual order, which readers reorder
|
|
6
|
+
* themselves) reads through ToUnicode, glyph by glyph, and only a cluster ToUnicode cannot spell gets a span
|
|
7
|
+
* (`spans`, from glyphText); glyphs that stand for nothing (`texts`: '') go last. A span per joined letter, and
|
|
8
|
+
* the dots of joined letters drawn among the letters, made pdftotext split words ("الج ميل", "الت قن ية").
|
|
9
|
+
* @param {Content} c @param {Set<number>} [spans] @param {Map<number, string>} [texts]
|
|
10
|
+
*/
|
|
11
|
+
export function drawRun(c: Content, run: any, x: any, y: any, size: any, pf: any, color: any, spans?: Set<number>, texts?: Map<number, string>): void;
|
|
12
|
+
/**
|
|
13
|
+
* The text each shaped glyph stands for, for the font's ToUnicode map: the character whose own (character-map)
|
|
14
|
+
* glyph it is; the characters of its cluster that have no glyph of their own there (a conjunct, a joined
|
|
15
|
+
* Arabic form, a reph) go to ONE glyph, the first that is not a mark, and the cluster's other glyphs (dots,
|
|
16
|
+
* marks) stand for nothing, so a reader gets each character once. A glyph keeps its first text: a
|
|
17
|
+
* right-to-left cluster that would read differently with the texts already set goes into `spans` (drawRun
|
|
18
|
+
* gives it /ActualText). Left-to-right runs always get one span for the whole run.
|
|
19
|
+
* @param {any} run @param {any} font fontkit font @param {Map<number, string>} out
|
|
20
|
+
* @param {WeakMap<any, Set<number>>} [spans]
|
|
21
|
+
*/
|
|
22
|
+
export function glyphText(run: any, font: any, out: Map<number, string>, spans?: WeakMap<any, Set<number>>): void;
|
|
23
|
+
/**
|
|
24
|
+
* Text inside its clip box needs no clip: the lines' advances within it across, the font's ascent and descent
|
|
25
|
+
* within it down. A cell's text almost always fits, and a clip per cell is most of a table page's operators.
|
|
26
|
+
*/
|
|
27
|
+
export function insideClip(it: any, m: any): any;
|
|
28
|
+
/** one byte per char: the content stream holds the glyph bytes of literal strings as chars 0–255 */
|
|
29
|
+
export function latin1(s: any): any;
|
|
30
|
+
/**
|
|
31
|
+
* zlib (Flate) compression: Node's zlib on its thread pool (pages compress in parallel, off the main thread), else
|
|
32
|
+
* the platform's CompressionStream (browsers; in Node it is the same zlib behind web streams, slower), else fflate.
|
|
33
|
+
*/
|
|
34
|
+
export function deflate(bytes: any): Promise<any>;
|
|
35
|
+
export function col(c: any): any;
|
|
36
|
+
export namespace BLACK {
|
|
37
|
+
let color: import("pdf-lib").RGB;
|
|
38
|
+
let opacity: number;
|
|
39
|
+
let rgb: string;
|
|
40
|
+
}
|
|
41
|
+
export function n2(v: any): number;
|
|
42
|
+
export function n3(v: any): number;
|
|
43
|
+
export function n4(v: any): number;
|
|
44
|
+
export function hex4(id: any): any;
|
|
45
|
+
export const KAPPA: number;
|
|
46
|
+
export function cleanText(t: any): any;
|
|
47
|
+
/**
|
|
48
|
+
* A page's operators as text. The graphics state is tracked, so a colour, line width, dash, opacity or font
|
|
49
|
+
* that is already set is not set again; q/Q save and restore it as the PDF does.
|
|
50
|
+
*/
|
|
51
|
+
export class Content {
|
|
52
|
+
constructor(shared: any);
|
|
53
|
+
shared: any;
|
|
54
|
+
_s: string;
|
|
55
|
+
bt: boolean;
|
|
56
|
+
tx: number;
|
|
57
|
+
ty: number;
|
|
58
|
+
st: {
|
|
59
|
+
fill: string;
|
|
60
|
+
stroke: string;
|
|
61
|
+
lw: number;
|
|
62
|
+
dash: string;
|
|
63
|
+
ca: number;
|
|
64
|
+
CA: number;
|
|
65
|
+
font: string;
|
|
66
|
+
size: number;
|
|
67
|
+
};
|
|
68
|
+
/** @type {any[]} */ saved: any[];
|
|
69
|
+
/** straight lines waiting to be drawn after the text around them: { key, stroke, w, dash, segs: [x1, y1, x2, y2][] } */
|
|
70
|
+
lines: any;
|
|
71
|
+
tagged: boolean;
|
|
72
|
+
set s(v: string);
|
|
73
|
+
/**
|
|
74
|
+
* The operators so far. Any other drawing reads or appends to it, so the lines waiting are drawn first: the text
|
|
75
|
+
* of a table's cells stays in one text object (relative moves, which compress to little) instead of one per cell.
|
|
76
|
+
*/
|
|
77
|
+
get s(): string;
|
|
78
|
+
/**
|
|
79
|
+
* A straight line. Untagged, it waits until something other than text is drawn (table borders between cell
|
|
80
|
+
* texts); collinear segments that touch, in the same stroke, become one (a row's border is one line).
|
|
81
|
+
* ponytail: lines move after the text drawn just after them; both are thin and do not cover each other.
|
|
82
|
+
*/
|
|
83
|
+
line(stroke: any, w: any, dash: any, x1: any, y1: any, x2: any, y2: any): void;
|
|
84
|
+
flushLines(): void;
|
|
85
|
+
q(): void;
|
|
86
|
+
Q(): void;
|
|
87
|
+
/**
|
|
88
|
+
* A line of plain text at (x, y). Lines follow one another in one text object, each placed relative to the
|
|
89
|
+
* last (in whole hundredths, so nothing drifts): most of a table page is these.
|
|
90
|
+
* @param {string} str the glyphs, as a literal string's escaped body (array: a TJ array's body)
|
|
91
|
+
*/
|
|
92
|
+
text(pf: any, size: any, color: any, x: any, y: any, str: string, array?: boolean): void;
|
|
93
|
+
/** end the open text object, if any: anything but text needs that (and draws the lines waiting) */
|
|
94
|
+
et(): void;
|
|
95
|
+
lineWidth(w: any): void;
|
|
96
|
+
setLineWidth(w: any): void;
|
|
97
|
+
/** the graphics state that sets these opacities, or undefined when they are set already */
|
|
98
|
+
gsFor(ca: any, CA: any): any;
|
|
99
|
+
alpha(ca: any, CA: any): void;
|
|
100
|
+
setAlpha(ca: any, CA: any): void;
|
|
101
|
+
/** set up to fill with fill and/or stroke with stroke (width w, dash); the lines waiting are drawn first */
|
|
102
|
+
paint(fill: any, stroke: any, w?: number, dash?: any): void;
|
|
103
|
+
setPaint(fill: any, stroke: any, w?: number, dash?: any): void;
|
|
104
|
+
font(pf: any, size: any): void;
|
|
105
|
+
setFont(pf: any, size: any): void;
|
|
106
|
+
}
|
|
107
|
+
export const NODE_ZLIB: any;
|