@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,183 @@
|
|
|
1
|
+
/** @param {string} src */
|
|
2
|
+
export function compile(src: string): any;
|
|
3
|
+
/**
|
|
4
|
+
* A value is: a literal, "=expression", or a text with {expression} parts.
|
|
5
|
+
* "{{" and "}}" give literal braces.
|
|
6
|
+
* @param {any} v
|
|
7
|
+
*/
|
|
8
|
+
export function parseValue(v: any): any;
|
|
9
|
+
/** True when a value holds an expression. */
|
|
10
|
+
export function isDynamic(v: any): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Evaluate a property value. Expressions give raw values; templates give strings.
|
|
13
|
+
* @param {any} v @param {EvalCtx} ctx
|
|
14
|
+
*/
|
|
15
|
+
export function evalValue(v: any, ctx: EvalCtx): any;
|
|
16
|
+
/** @param {any} v @param {string|null|undefined} fmt @param {EvalCtx} ctx */
|
|
17
|
+
export function toText(v: any, fmt: string | null | undefined, ctx: EvalCtx): any;
|
|
18
|
+
/** Check syntax only. Returns null or an error message. */
|
|
19
|
+
export function checkValue(v: any): any;
|
|
20
|
+
/** @param {any} n @param {EvalCtx} ctx @returns {any} */
|
|
21
|
+
export function evaluate(n: any, ctx: EvalCtx): any;
|
|
22
|
+
export function truthy(v: any): boolean;
|
|
23
|
+
/** a + b on the decimal values. Past 2^49 a scaled integer leaves the fast path: the sum is then BigInt arithmetic. */
|
|
24
|
+
export function decAdd(a: any, b: any): any;
|
|
25
|
+
/** a * b on the decimal values. */
|
|
26
|
+
export function decMul(a: any, b: any): number;
|
|
27
|
+
export function cmpVal(a: any, b: any): 1 | 0 | -1;
|
|
28
|
+
export function collator(ctx: any): any;
|
|
29
|
+
/** @returns {number} for two keys (dates as their time), nulls last */
|
|
30
|
+
export function sortCompare(a: any, b: any, ctx: any): number;
|
|
31
|
+
/** A group key that merges values the sort calls equal ("ABC" and "abc" unless caseSensitive). */
|
|
32
|
+
export function groupKeyText(key: any, ctx: any): string;
|
|
33
|
+
/**
|
|
34
|
+
* True when a property value (a literal, an =expression or a {template}) reads only the current row, the parameters
|
|
35
|
+
* and the globals: no aggregate, scope, Lookup, Previous, Parent or report function. Streaming exports
|
|
36
|
+
* (engine/stream.js) evaluate such values one row at a time. rowNumber: RowNumber() / RowNumber(Nothing) is allowed
|
|
37
|
+
* too (the caller supplies ctx.rowNumber). A value that does not parse counts as row-local: it is #Error either way.
|
|
38
|
+
* @param {any} v @param {{ rowNumber?: boolean }} [o]
|
|
39
|
+
*/
|
|
40
|
+
export function streamable(v: any, { rowNumber }?: {
|
|
41
|
+
rowNumber?: boolean;
|
|
42
|
+
}): any;
|
|
43
|
+
/** streamable for a parsed expression. @param {any} ast @param {{ rowNumber?: boolean }} [o] */
|
|
44
|
+
export function streamableAst(ast: any, { rowNumber }?: {
|
|
45
|
+
rowNumber?: boolean;
|
|
46
|
+
}): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* A running Sum, Count, Avg, Min or Max: values added one at a time give the same result as the aggregate over the
|
|
49
|
+
* whole list (the same decimal addition, the same comparison, the same errors), in O(1) memory.
|
|
50
|
+
* @param {string} name lower case, one of FOLDS @param {EvalCtx} ctx
|
|
51
|
+
*/
|
|
52
|
+
export function aggregator(name: string, ctx: EvalCtx): {
|
|
53
|
+
/** @param {any} v one row's value (an array, a LookupSet's, adds each item) */
|
|
54
|
+
add(v: any): void;
|
|
55
|
+
value(): any;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Compile-on-call table of the report's functions. One per render: it also counts calls.
|
|
59
|
+
* @param {any} def @param {{n: number}} [count] shared by a render and its subreports
|
|
60
|
+
* @returns {{byName: Map<string, any>, count: {n: number}}}
|
|
61
|
+
*/
|
|
62
|
+
export function functionTable(def: any, count?: {
|
|
63
|
+
n: number;
|
|
64
|
+
}): {
|
|
65
|
+
byName: Map<string, any>;
|
|
66
|
+
count: {
|
|
67
|
+
n: number;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Calls an expression makes that no render could answer: an unknown function (Frobnicate(1)), Code.X(…) with no report
|
|
72
|
+
* function X, or a method after "." that is not one of the .NET string methods. One message per name, with the
|
|
73
|
+
* nearest known name. Pure: walks the AST, evaluates nothing.
|
|
74
|
+
* @param {any} ast @param {Set<string>} custom the report's own function names, lower case
|
|
75
|
+
* @param {(name: string, known: string[]) => string | null} [suggest]
|
|
76
|
+
* @returns {string[]}
|
|
77
|
+
*/
|
|
78
|
+
export function callIssues(ast: any, custom: Set<string>, suggest?: (name: string, known: string[]) => string | null): string[];
|
|
79
|
+
/** Errors in report functions: names, parameters, body syntax. */
|
|
80
|
+
export function checkFunctions(list: any): any[];
|
|
81
|
+
/** .NET composite formatting, String.Format("{0:N2} of {1,-8}", a, b): {index[,alignment][:format]}, {{ and }} */
|
|
82
|
+
export function netFormat(f: any, args: any, ctx: any): string;
|
|
83
|
+
/**
|
|
84
|
+
* A render's time limit (render(def, { timeoutMs })): ctx.clock = { until, n, over }. The clock is read every 1,024
|
|
85
|
+
* evaluations; once the limit has passed every evaluation throws at once, so even a quadratic report unwinds fast.
|
|
86
|
+
*/
|
|
87
|
+
export const OVER_TIME: "The report ran past its time limit.";
|
|
88
|
+
/**
|
|
89
|
+
* Data-set row → its parent: the parent data set's row (nested data sets) or the raw object that held a
|
|
90
|
+
* [*]-spread array. Parent.* reads it when no list row supplies a parent.
|
|
91
|
+
*/
|
|
92
|
+
export const ROW_PARENT: WeakMap<object, any>;
|
|
93
|
+
/** The aggregates a streaming export folds row by row (aggregator). */
|
|
94
|
+
export const FOLDS: Set<string>;
|
|
95
|
+
export namespace FUNCTIONS {
|
|
96
|
+
function format(ctx: any, v: any, f: any): any;
|
|
97
|
+
function upper(ctx: any, s: any): any;
|
|
98
|
+
function ucase(ctx: any, s: any): any;
|
|
99
|
+
function lower(ctx: any, s: any): string;
|
|
100
|
+
function lcase(ctx: any, s: any): string;
|
|
101
|
+
function left(ctx: any, s: any, n: any): string;
|
|
102
|
+
function right(ctx: any, s: any, n: any): string;
|
|
103
|
+
function mid(ctx: any, s: any, start: any, len: any): string;
|
|
104
|
+
function len(ctx: any, s: any): number;
|
|
105
|
+
function trim(ctx: any, s: any): string;
|
|
106
|
+
function replace(ctx: any, s: any, a: any, b: any, start: any, count: any): any;
|
|
107
|
+
function instr(ctx: any, s: any, sub: any): number;
|
|
108
|
+
function join(ctx: any, arr: any, sep: any): any;
|
|
109
|
+
function contains(ctx: any, hay: any, needle: any): boolean;
|
|
110
|
+
function inlist(ctx: any, v: any, ...list: any[]): boolean;
|
|
111
|
+
function cstr(ctx: any, v: any): any;
|
|
112
|
+
function javastr(ctx: any, v: any, kind: any): string;
|
|
113
|
+
function jsstr(ctx: any, v: any, digits: any): string;
|
|
114
|
+
function javaformat(ctx: any, f: any, ...args: any[]): string;
|
|
115
|
+
function cdbl(ctx: any, v: any): number;
|
|
116
|
+
function cnum(ctx: any, v: any): number;
|
|
117
|
+
function val(ctx: any, v: any): number;
|
|
118
|
+
function cint(ctx: any, v: any): number;
|
|
119
|
+
function cbool(ctx: any, v: any): boolean;
|
|
120
|
+
function cdate(ctx: any, v: any): Date;
|
|
121
|
+
function isnull(ctx: any, v: any): boolean;
|
|
122
|
+
function isnothing(ctx: any, v: any): boolean;
|
|
123
|
+
function coalesce(ctx: any, ...vs: any[]): any;
|
|
124
|
+
function round(ctx: any, v: any, d: any): number;
|
|
125
|
+
function roundhalfaway(ctx: any, v: any, d: any): number;
|
|
126
|
+
function abs(ctx: any, v: any): number;
|
|
127
|
+
function floor(ctx: any, v: any): number;
|
|
128
|
+
function ceiling(ctx: any, v: any): number;
|
|
129
|
+
function int(ctx: any, v: any): number;
|
|
130
|
+
function pow(ctx: any, a: any, b: any): number;
|
|
131
|
+
function sqrt(ctx: any, v: any): number;
|
|
132
|
+
function now(ctx: any): Date;
|
|
133
|
+
function today(ctx: any): Date;
|
|
134
|
+
function dateadd(ctx: any, i: any, n: any, d: any): Date;
|
|
135
|
+
function datediff(ctx: any, i: any, a: any, b: any, first: any): number;
|
|
136
|
+
function dateserial(ctx: any, y: any, m: any, d: any): Date;
|
|
137
|
+
function year(ctx: any, d: any): number;
|
|
138
|
+
function month(ctx: any, d: any): number;
|
|
139
|
+
function day(ctx: any, d: any): number;
|
|
140
|
+
function monthname(ctx: any, m: any, abbr: any): string;
|
|
141
|
+
}
|
|
142
|
+
/** Names shown in the designer's expression helper. */
|
|
143
|
+
export const FUNCTION_NAMES: string[];
|
|
144
|
+
export type EvalCtx = {
|
|
145
|
+
/**
|
|
146
|
+
* current row
|
|
147
|
+
*/
|
|
148
|
+
fields?: Record<string, any> | null;
|
|
149
|
+
params: Record<string, any>;
|
|
150
|
+
globals: Record<string, any>;
|
|
151
|
+
/**
|
|
152
|
+
* rows for aggregates in the current scope
|
|
153
|
+
*/
|
|
154
|
+
aggRows?: any[];
|
|
155
|
+
/**
|
|
156
|
+
* aggregate results for this render, per row array and call
|
|
157
|
+
*/
|
|
158
|
+
aggCache?: WeakMap<any[], Map<any, any>>;
|
|
159
|
+
/**
|
|
160
|
+
* rows from scope start up to the current row
|
|
161
|
+
*/
|
|
162
|
+
runningRows?: any[];
|
|
163
|
+
rowNumber?: number;
|
|
164
|
+
dataSets: Record<string, any[]>;
|
|
165
|
+
/**
|
|
166
|
+
* the render's time limit (see evaluate)
|
|
167
|
+
*/
|
|
168
|
+
clock?: {
|
|
169
|
+
until: number;
|
|
170
|
+
n: number;
|
|
171
|
+
over: boolean;
|
|
172
|
+
};
|
|
173
|
+
locale?: string;
|
|
174
|
+
currency?: string;
|
|
175
|
+
/**
|
|
176
|
+
* how Infinity and NaN print: undefined (as SSRS), "blank" or "error"
|
|
177
|
+
*/
|
|
178
|
+
nonFinite?: string;
|
|
179
|
+
/**
|
|
180
|
+
* digit grouping of numbers: undefined (the locale's rule, as Intl), "always" or "never"
|
|
181
|
+
*/
|
|
182
|
+
grouping?: string;
|
|
183
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/** A wall clock in the zone (as a UTC timestamp) → the instant; a time skipped by DST moves forward as Date does. */
|
|
2
|
+
export function fromWall(w: any, tz: any): Date;
|
|
3
|
+
/** 'mdy' | 'dmy' | 'ymd': the locale's numeric date order (from Intl). */
|
|
4
|
+
export function dateOrder(locale: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* Read a value as a Date, or null. A date without a zone ("2026-03-01", "05/03/2026 14:30") is that wall clock in the
|
|
7
|
+
* report's zone; one with a zone ("…T02:00:00Z") is that instant.
|
|
8
|
+
* @param {any} v @param {{ locale?: string, timeZone?: string }} [opt]
|
|
9
|
+
*/
|
|
10
|
+
export function toDate(v: any, opt?: {
|
|
11
|
+
locale?: string;
|
|
12
|
+
timeZone?: string;
|
|
13
|
+
}): Date;
|
|
14
|
+
/** The locale's decimal and grouping separators (en-US: "." and ","; de-DE: "," and "."). */
|
|
15
|
+
export function separators(locale: any): any;
|
|
16
|
+
/**
|
|
17
|
+
* Text as a number the way the locale writes it: "1,234.5" (en-US), "1.234,56" / "12,5" (de-DE), with grouping
|
|
18
|
+
* (also a space or a narrow no-break space), a currency symbol, a leading or trailing sign, accounting parentheses
|
|
19
|
+
* "(1,234)" and a trailing %. NaN when it is not a number. A plain JS number text ("1e3", "-0.5") always reads.
|
|
20
|
+
* @param {string} text @param {string} [locale]
|
|
21
|
+
*/
|
|
22
|
+
export function parseNumber(text: string, locale?: string): number;
|
|
23
|
+
/**
|
|
24
|
+
* Round half away from zero on the decimal value, like Intl, Excel and .NET format strings ("N2", "F0"): 1.005 → 1.01,
|
|
25
|
+
* 2.5 → 3. This is how displayed numbers round. VB's Round() rounds half to even instead: see roundHalfEven.
|
|
26
|
+
* @param {number} v @param {number} [digits] may be negative (1234 → 1200 with -2)
|
|
27
|
+
*/
|
|
28
|
+
export function roundHalfAway(v: number, digits?: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* VB / .NET Math.Round(x, digits): round half to even (MidpointRounding.ToEven, "banker's rounding"), 2.5 → 2,
|
|
31
|
+
* 3.5 → 4, on the decimal value (2.675 is the decimal 2.675, as a Decimal money field is in SSRS).
|
|
32
|
+
* @param {number} v @param {number} [digits] may be negative
|
|
33
|
+
*/
|
|
34
|
+
export function roundHalfEven(v: number, digits?: number): number;
|
|
35
|
+
/**
|
|
36
|
+
* Format a value. Neutral defaults: no locale means en-US; no currency means the locale's own currency when the
|
|
37
|
+
* locale names a country ("en-IN" → ₹, as a .NET culture does), else none, and "C" then shows the number alone.
|
|
38
|
+
* @param {any} value
|
|
39
|
+
* @param {string|undefined|null} fmt
|
|
40
|
+
* @param {{locale?: string, currency?: string, timeZone?: string, nonFinite?: string, grouping?: string, fmtMemo?: Map<string, Map<any, string>>}} [opt] fmtMemo: a render's memo of formatted dates
|
|
41
|
+
*/
|
|
42
|
+
export function formatValue(value: any, fmt: string | undefined | null, opt?: {
|
|
43
|
+
locale?: string;
|
|
44
|
+
currency?: string;
|
|
45
|
+
timeZone?: string;
|
|
46
|
+
nonFinite?: string;
|
|
47
|
+
grouping?: string;
|
|
48
|
+
fmtMemo?: Map<string, Map<any, string>>;
|
|
49
|
+
}): any;
|
|
50
|
+
/**
|
|
51
|
+
* A value from data as text, without JavaScript's own spellings: a number in plain digits (1e21 →
|
|
52
|
+
* 1000000000000000000000, 1e-7 → 0.0000001), an array as its items joined by ", ", an object as compact JSON
|
|
53
|
+
* ({"nested":true}), never "[object Object]". Strings and booleans as String() gives them.
|
|
54
|
+
* @param {any} v @returns {string}
|
|
55
|
+
*/
|
|
56
|
+
export function plainText(v: any): string;
|
|
57
|
+
export function standardDate(fmt: any, locale: any): any;
|
|
58
|
+
/**
|
|
59
|
+
* .NET custom date format: runs of y M d H h m s f F t, 'quoted' and \escaped text; "%d" is the custom "d" alone.
|
|
60
|
+
* The parts are read on the wall clock of the time zone (tz; the host's when none is given).
|
|
61
|
+
* @param {Date} d @param {string} fmt @param {string} [locale] month and day names follow it @param {string} [tz]
|
|
62
|
+
*/
|
|
63
|
+
export function formatDate(d: Date, fmt: string, locale?: string, tz?: string): string;
|
|
64
|
+
export function validTimeZone(tz: any): boolean;
|
|
65
|
+
export function toWall(d: any, tz: any): any;
|
|
66
|
+
export function zoneDate(y: any, m: any, d: any, tz: any, h?: number, mi?: number, sec?: number, ms?: number): Date;
|
|
67
|
+
export function wallDate(d: any, tz: any): Date;
|
|
68
|
+
export function isoDate(d: any, tz: any): string;
|
|
69
|
+
export function shiftDec(x: any, e: any): number;
|
|
70
|
+
export namespace REGION_CURRENCY {
|
|
71
|
+
let US: string;
|
|
72
|
+
let IN: string;
|
|
73
|
+
let GB: string;
|
|
74
|
+
let DE: string;
|
|
75
|
+
let FR: string;
|
|
76
|
+
let ES: string;
|
|
77
|
+
let IT: string;
|
|
78
|
+
let NL: string;
|
|
79
|
+
let BE: string;
|
|
80
|
+
let AT: string;
|
|
81
|
+
let PT: string;
|
|
82
|
+
let IE: string;
|
|
83
|
+
let FI: string;
|
|
84
|
+
let GR: string;
|
|
85
|
+
let JP: string;
|
|
86
|
+
let CN: string;
|
|
87
|
+
let CA: string;
|
|
88
|
+
let AU: string;
|
|
89
|
+
let NZ: string;
|
|
90
|
+
let CH: string;
|
|
91
|
+
let SG: string;
|
|
92
|
+
let AE: string;
|
|
93
|
+
let SA: string;
|
|
94
|
+
let BR: string;
|
|
95
|
+
let MX: string;
|
|
96
|
+
let ZA: string;
|
|
97
|
+
let KR: string;
|
|
98
|
+
let RU: string;
|
|
99
|
+
let ID: string;
|
|
100
|
+
let MY: string;
|
|
101
|
+
let PH: string;
|
|
102
|
+
let TH: string;
|
|
103
|
+
let VN: string;
|
|
104
|
+
let PK: string;
|
|
105
|
+
let BD: string;
|
|
106
|
+
let LK: string;
|
|
107
|
+
let NP: string;
|
|
108
|
+
let SE: string;
|
|
109
|
+
let NO: string;
|
|
110
|
+
let DK: string;
|
|
111
|
+
let PL: string;
|
|
112
|
+
let TR: string;
|
|
113
|
+
let IL: string;
|
|
114
|
+
let EG: string;
|
|
115
|
+
let NG: string;
|
|
116
|
+
let KE: string;
|
|
117
|
+
let HK: string;
|
|
118
|
+
let TW: string;
|
|
119
|
+
}
|
|
120
|
+
export function currencyOf(locale: string | undefined): any;
|
|
121
|
+
export function english(locale: any): boolean;
|
|
122
|
+
export const DAY_MS: 86400000;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Double.toString: shortest digits; "2.0"; 1.0E7 and 1.0E-4 outside [10^-3, 10^7) */
|
|
2
|
+
export function javaDouble(x: any): string;
|
|
3
|
+
/**
|
|
4
|
+
* Format a value with a "java:…" or "icu:…" format (see the top of this file). null and undefined give ''.
|
|
5
|
+
* @param {any} value @param {string} fmt @param {{ locale?: string, timeZone?: string }} [opt]
|
|
6
|
+
*/
|
|
7
|
+
export function formatJava(value: any, fmt: string, opt?: {
|
|
8
|
+
locale?: string;
|
|
9
|
+
timeZone?: string;
|
|
10
|
+
}): any;
|
|
11
|
+
/**
|
|
12
|
+
* String.valueOf(x) in Java, for string concatenation in JasperReports expressions: "null", true/false,
|
|
13
|
+
* Double.toString ("2.0"), Date.toString; kind "int" for an integral value (Integer, Long: "2").
|
|
14
|
+
* @param {any} v @param {string} [kind] @param {string} [tz]
|
|
15
|
+
*/
|
|
16
|
+
export function javaString(v: any, kind?: string, tz?: string): string;
|
|
17
|
+
/** JavaScript's String(x), for string concatenation in BIRT expressions: "null", true/false, shortest digits. */
|
|
18
|
+
export function jsString(v: any): string;
|
|
19
|
+
/**
|
|
20
|
+
* java.util.Formatter (String.format) for the common conversions: %s %S %b %c %d %o %x %X %f %e %E %% %n, with flags
|
|
21
|
+
* - + space 0 , ( and width, precision and argument index (%2$s). %f rounds half up on the shortest decimal form, as
|
|
22
|
+
* Java does (String.format("%.2f", 1.005) is "1.01"). Digits and separators are the locale's.
|
|
23
|
+
* @param {string} f @param {any[]} args @param {string} [locale] @param {string} [tz]
|
|
24
|
+
*/
|
|
25
|
+
export function javaFormatString(f: string, args: any[], locale?: string, tz?: string): string;
|
|
26
|
+
export function isJavaFormat(fmt: any): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @param {string} src */
|
|
2
|
+
export function lex(src: string): ({
|
|
3
|
+
t: string;
|
|
4
|
+
v: number;
|
|
5
|
+
p: number;
|
|
6
|
+
} | {
|
|
7
|
+
t: string;
|
|
8
|
+
v: string;
|
|
9
|
+
p: number;
|
|
10
|
+
})[];
|
|
11
|
+
/** @param {string} src */
|
|
12
|
+
export function parse(src: string): any;
|
|
13
|
+
/**
|
|
14
|
+
* Expression language: lexer + Pratt parser.
|
|
15
|
+
* No eval, no new Function. The AST is plain data.
|
|
16
|
+
*/
|
|
17
|
+
export class ExprError extends Error {
|
|
18
|
+
/** @param {string} msg @param {number} [pos] @param {string} [src] */
|
|
19
|
+
constructor(msg: string, pos?: number, src?: string);
|
|
20
|
+
pos: number;
|
|
21
|
+
src: string;
|
|
22
|
+
}
|
|
23
|
+
/** The longest string a function or a format may build, checked before it is built (capText). */
|
|
24
|
+
export const MAX_TEXT: 1000000;
|
|
25
|
+
export function capText(fname: string, n: number): void;
|
|
26
|
+
export const MAX_PATTERN: 1000;
|
|
27
|
+
export const MAX_DIGITS: 340;
|
|
28
|
+
export function capPattern(fname: any, pat: any): void;
|
|
29
|
+
export function capDigits(fname: any, n: any): void;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** @param {Uint8Array} b @returns {keyof MIME | null} */
|
|
2
|
+
export function sniff(b: Uint8Array): ("png" | "jpeg" | "gif" | "webp" | "svg") | null;
|
|
3
|
+
/**
|
|
4
|
+
* A data URI for bytes or bare base64; anything else (a URL, a data URI) comes back as it was.
|
|
5
|
+
* @param {unknown} v
|
|
6
|
+
* @returns {unknown}
|
|
7
|
+
*/
|
|
8
|
+
export function toDataUri(v: unknown): unknown;
|
|
9
|
+
/**
|
|
10
|
+
* The parts of a data URI: one rule for every caller (the size cap and the decoder must agree).
|
|
11
|
+
* Base64 when the last parameter is exactly "base64".
|
|
12
|
+
* @param {string} uri
|
|
13
|
+
*/
|
|
14
|
+
export function splitDataUri(uri: string): {
|
|
15
|
+
meta: string;
|
|
16
|
+
b64: boolean;
|
|
17
|
+
body: string;
|
|
18
|
+
};
|
|
19
|
+
/** Decoded size of a data URI, without decoding it (an upper bound). @param {string} uri */
|
|
20
|
+
export function dataUriBytes(uri: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* The first bytes of a data URI (enough for any image header), or all of it with max = Infinity.
|
|
23
|
+
* @param {string} uri
|
|
24
|
+
* @returns {Uint8Array | null}
|
|
25
|
+
*/
|
|
26
|
+
export function dataUriHead(uri: string, max?: number): Uint8Array | null;
|
|
27
|
+
/** All the bytes of a data URI (callers check the size first). @param {string} uri */
|
|
28
|
+
export function dataUriBytesOf(uri: string): Uint8Array<ArrayBufferLike>;
|
|
29
|
+
/** An SVG length in px; null for a percentage or nonsense. @param {string|undefined} v */
|
|
30
|
+
export function svgLength(v: string | undefined): number;
|
|
31
|
+
/**
|
|
32
|
+
* The tags of an XML text, in order: one pass with indexOf and a quote-aware scan, so the time is linear in
|
|
33
|
+
* the length whatever the input (no regular expression that can backtrack). Comments, CDATA, <?…?> and
|
|
34
|
+
* <!…> are skipped; an unfinished construct ends the scan.
|
|
35
|
+
* @param {string} text
|
|
36
|
+
* @returns {Generator<{ close: boolean, name: string, attrs: string, self: boolean }>}
|
|
37
|
+
*/
|
|
38
|
+
export function xmlTags(text: string): Generator<{
|
|
39
|
+
close: boolean;
|
|
40
|
+
name: string;
|
|
41
|
+
attrs: string;
|
|
42
|
+
self: boolean;
|
|
43
|
+
}>;
|
|
44
|
+
/** name="value" / name='value' pairs, in one linear pass. @param {string} s @returns {Record<string,string>} */
|
|
45
|
+
export function xmlAttrs(s: string): Record<string, string>;
|
|
46
|
+
/** Attributes of the root <svg> tag. @param {string} text */
|
|
47
|
+
export function svgRootAttrs(text: string): Record<string, string>;
|
|
48
|
+
/** Natural size of an SVG in px: width/height, else the viewBox. @param {string} text */
|
|
49
|
+
export function svgSize(text: string): {
|
|
50
|
+
w: number;
|
|
51
|
+
h: number;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Type and natural size (px) of image bytes, from the header.
|
|
55
|
+
* @param {Uint8Array} b
|
|
56
|
+
* @returns {{ type: string, w: number, h: number } | { type: string } | null}
|
|
57
|
+
*/
|
|
58
|
+
export function imageInfoOf(b: Uint8Array): {
|
|
59
|
+
type: string;
|
|
60
|
+
w: number;
|
|
61
|
+
h: number;
|
|
62
|
+
} | {
|
|
63
|
+
type: string;
|
|
64
|
+
} | null;
|
|
65
|
+
/**
|
|
66
|
+
* PNG size as pdf-lib's decoder (UPNG) will see it: it walks every chunk and keeps the LAST IHDR, and an
|
|
67
|
+
* animated PNG (acTL/fcTL/fdAT) allocates a buffer per frame from the frame's own size. So walk the chunks
|
|
68
|
+
* exactly as it does, and report animation, rather than trusting the bytes after the signature.
|
|
69
|
+
* @param {Uint8Array} b
|
|
70
|
+
*/
|
|
71
|
+
export function pngInfo(b: Uint8Array): {
|
|
72
|
+
type: string;
|
|
73
|
+
} | {
|
|
74
|
+
suspect?: boolean;
|
|
75
|
+
type: string;
|
|
76
|
+
w: number;
|
|
77
|
+
h: number;
|
|
78
|
+
};
|
|
79
|
+
/** Type and natural size (px) of a data URI image. @param {string} uri */
|
|
80
|
+
export function imageInfo(uri: string): {
|
|
81
|
+
type: string;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Resolve an image source to what the page model carries: a data URI, a URL, or null (left out).
|
|
85
|
+
* @param {unknown} v evaluated src
|
|
86
|
+
* @param {string} who for warnings
|
|
87
|
+
* @param {{ images?: Record<string, string>, budget?: { seen: Set<string>, bytes: number, memo?: Map<unknown, unknown> }, warn: (m: string) => void }} c
|
|
88
|
+
* @returns {string | null}
|
|
89
|
+
*/
|
|
90
|
+
export function resolveImageSrc(v: unknown, who: string, c: {
|
|
91
|
+
images?: Record<string, string>;
|
|
92
|
+
budget?: {
|
|
93
|
+
seen: Set<string>;
|
|
94
|
+
bytes: number;
|
|
95
|
+
memo?: Map<unknown, unknown>;
|
|
96
|
+
};
|
|
97
|
+
warn: (m: string) => void;
|
|
98
|
+
}): string | null;
|
|
99
|
+
export namespace IMAGE_LIMITS {
|
|
100
|
+
let bytes: number;
|
|
101
|
+
let total: number;
|
|
102
|
+
let pixels: number;
|
|
103
|
+
let svgBytes: number;
|
|
104
|
+
let svgShapes: number;
|
|
105
|
+
}
|
|
106
|
+
/** 1 image pixel = 0.75 pt (96 dpi, as in CSS). */
|
|
107
|
+
export const PX: 0.75;
|