@evotecit/officeimo 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +59 -51
- package/bundles/officeimo-canopyx.js +1553 -314
- package/bundles/officeimo-canopyx.mjs +1497 -269
- package/bundles/officeimo-csv.js +18 -15
- package/bundles/officeimo-csv.mjs +16 -13
- package/bundles/officeimo-datatables.js +463 -301
- package/bundles/officeimo-datatables.mjs +420 -259
- package/bundles/officeimo-pdf.js +148 -65
- package/bundles/officeimo-pdf.mjs +124 -41
- package/bundles/officeimo-xlsx.js +177 -101
- package/bundles/officeimo-xlsx.mjs +149 -74
- package/bundles/officeimo.js +461 -299
- package/bundles/officeimo.mjs +419 -258
- package/dist/csv/index.js +16 -13
- package/dist/integrations/canopyx/diagnostics.d.ts +3 -0
- package/dist/integrations/canopyx/diagnostics.js +17 -0
- package/dist/integrations/canopyx/grouping.d.ts +6 -0
- package/dist/integrations/canopyx/grouping.js +198 -0
- package/dist/integrations/canopyx/index.d.ts +2 -2
- package/dist/integrations/canopyx/index.js +89 -15
- package/dist/integrations/canopyx/metadata.d.ts +4 -0
- package/dist/integrations/canopyx/metadata.js +51 -0
- package/dist/integrations/canopyx/pdf-layout.d.ts +5 -0
- package/dist/integrations/canopyx/pdf-layout.js +97 -0
- package/dist/integrations/canopyx/pdf-number.d.ts +3 -0
- package/dist/integrations/canopyx/pdf-number.js +64 -0
- package/dist/integrations/canopyx/pivot.d.ts +15 -0
- package/dist/integrations/canopyx/pivot.js +67 -0
- package/dist/integrations/canopyx/presentation.d.ts +8 -0
- package/dist/integrations/canopyx/presentation.js +40 -0
- package/dist/integrations/canopyx/rule-predicates.d.ts +3 -0
- package/dist/integrations/canopyx/rule-predicates.js +110 -0
- package/dist/integrations/canopyx/rules.d.ts +6 -0
- package/dist/integrations/canopyx/rules.js +176 -0
- package/dist/integrations/canopyx/source.js +69 -31
- package/dist/integrations/canopyx/types.d.ts +134 -10
- package/dist/integrations/canopyx/workbook.d.ts +6 -0
- package/dist/integrations/canopyx/workbook.js +52 -0
- package/dist/opc/index.js +9 -0
- package/dist/pdf/font-resources.js +33 -14
- package/dist/pdf/pages.js +60 -14
- package/dist/pdf/table-band-flow.js +7 -2
- package/dist/pdf/table-band-plan.js +9 -1
- package/dist/pdf/table-layout.js +6 -2
- package/dist/pdf/table-structure.js +9 -8
- package/dist/xlsx/index.d.ts +1 -1
- package/dist/xlsx/options.js +1 -1
- package/dist/xlsx/outlines.d.ts +3 -0
- package/dist/xlsx/outlines.js +39 -0
- package/dist/xlsx/types.d.ts +9 -0
- package/dist/xlsx/values.js +11 -2
- package/dist/xlsx/workbook.js +2 -0
- package/dist/xlsx/worksheet.js +14 -6
- package/package.json +2 -2
package/dist/csv/index.js
CHANGED
|
@@ -10,29 +10,32 @@ import { captureBooleanText } from "../core/value-text.js";
|
|
|
10
10
|
import { captureCsvOptions } from "./options.js";
|
|
11
11
|
export { saveBlob } from "../core/index.js";
|
|
12
12
|
export { ExportCell } from "../core/presentation.js";
|
|
13
|
-
function csvField(value, delimiter, protect, quote, booleanText
|
|
14
|
-
|
|
15
|
-
value = nullValue;
|
|
13
|
+
function csvField(value, delimiter, protect, quote, booleanText) {
|
|
14
|
+
const kind = typeof value;
|
|
16
15
|
let text;
|
|
17
16
|
if (value == null)
|
|
18
17
|
text = "";
|
|
18
|
+
else if (kind === "string")
|
|
19
|
+
text = value;
|
|
20
|
+
else if (kind === "number") {
|
|
21
|
+
text = Number.isFinite(value) ? String(value) : "";
|
|
22
|
+
// Numeric text has no CSV delimiter, quote or line break to escape.
|
|
23
|
+
return quote === "all" ? '"' + text + '"' : text;
|
|
24
|
+
}
|
|
25
|
+
else if (kind === "boolean")
|
|
26
|
+
text = booleanText[value ? "true" : "false"];
|
|
19
27
|
else if (isDate(value))
|
|
20
28
|
text = Number.isFinite(value.getTime()) ? value.toISOString() : "";
|
|
21
|
-
else if (typeof value === "boolean")
|
|
22
|
-
text = booleanText[value ? "true" : "false"];
|
|
23
|
-
else if (typeof value === "number")
|
|
24
|
-
text = Number.isFinite(value) ? String(value) : "";
|
|
25
|
-
else if (typeof value === "string")
|
|
26
|
-
text = value;
|
|
27
29
|
else {
|
|
28
30
|
if (typeof value.then === "function")
|
|
29
31
|
void Promise.resolve(value).catch(() => { });
|
|
30
32
|
throw new TypeError("CSV cells and formatter results must be synchronous strings, numbers, booleans, Dates or null.");
|
|
31
33
|
}
|
|
32
|
-
|
|
34
|
+
// Only ASCII spaces, controls and markers through @ can begin the protected prefix.
|
|
35
|
+
if (protect && (kind === "string" || kind === "boolean") && text.charCodeAt(0) <= 64 && /^ *[=+\-@\t\r\n]/.test(text))
|
|
33
36
|
text = "'" + text;
|
|
34
|
-
return quote === "all" || (quote === "strings" &&
|
|
35
|
-
? '"' + text.replace(/"/g, '""') + '"' : text;
|
|
37
|
+
return quote === "all" || (quote === "strings" && kind === "string") || text.includes(delimiter) || /["\r\n]/.test(text)
|
|
38
|
+
? '"' + (text.includes('"') ? text.replace(/"/g, '""') : text) + '"' : text;
|
|
36
39
|
}
|
|
37
40
|
export async function writeCsvTo(rows, destination, configuration) {
|
|
38
41
|
const options = captureCsvOptions(configuration);
|
|
@@ -84,7 +87,7 @@ async function write(rows, sink, options) {
|
|
|
84
87
|
value = options.nullValue;
|
|
85
88
|
budget.cell(typeof value === "boolean" ? booleanText[value ? "true" : "false"] : value);
|
|
86
89
|
checkAbort(signal);
|
|
87
|
-
text += (i ? delimiter : "") + csvField(value, delimiter, protect, quote, booleanText
|
|
90
|
+
text += (i ? delimiter : "") + csvField(value, delimiter, protect, quote, booleanText);
|
|
88
91
|
if (text.length >= buffer.chunkSize || (i & 127) === 127 && taskYieldDue()) {
|
|
89
92
|
if (buffer.append(text))
|
|
90
93
|
return buffer.flush().then(() => record(values, header, i + 1, snapshot));
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { CanopyDiagnostic, CanopyFormat, CanopySourceOptions } from "./types.js";
|
|
2
|
+
/** One policy for capture diagnostics and unsupported adapter mappings; callbacks stay synchronous. */
|
|
3
|
+
export declare function canopyDiagnostics(format: CanopyFormat, options: CanopySourceOptions): (diagnostic: CanopyDiagnostic) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** One policy for capture diagnostics and unsupported adapter mappings; callbacks stay synchronous. */
|
|
2
|
+
export function canopyDiagnostics(format, options) {
|
|
3
|
+
const policy = options.unsupportedPresentation ?? (format === "csv" ? "text" : "reject"), notify = options.onDiagnostic;
|
|
4
|
+
if (policy !== "reject" && policy !== "text")
|
|
5
|
+
throw new TypeError("unsupportedPresentation must be reject or text.");
|
|
6
|
+
if (notify !== undefined && typeof notify !== "function")
|
|
7
|
+
throw new TypeError("onDiagnostic must be a synchronous function.");
|
|
8
|
+
return diagnostic => {
|
|
9
|
+
if (policy === "reject")
|
|
10
|
+
throw new TypeError("Unsupported Canopy presentation: " + diagnostic.code + (diagnostic.columnId ? " (" + diagnostic.columnId + ")" : ""));
|
|
11
|
+
const result = notify?.(Object.freeze(diagnostic));
|
|
12
|
+
if (result && typeof result.then === "function") {
|
|
13
|
+
void Promise.resolve(result).catch(() => { });
|
|
14
|
+
throw new TypeError("onDiagnostic must be synchronous.");
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GroupedReportSource } from "../../core/grouped-report.js";
|
|
2
|
+
import type { ExportLimits } from "../../core/index.js";
|
|
3
|
+
import type { CanopyCapture, CanopyDiagnostic, CanopyExport, CanopyFormat, CanopySourceOptions } from "./types.js";
|
|
4
|
+
/** Validate captured ranges, then use the owned grouping factory and its existing writers.
|
|
5
|
+
* Only ranges, labels and at most four active aggregate vectors are retained; no detail body is buffered. */
|
|
6
|
+
export declare function canopyGrouped(source: CanopyExport, request: CanopyCapture["request"], options: CanopySourceOptions, limits: ExportLimits | undefined, report: (diagnostic: CanopyDiagnostic) => void, format: CanopyFormat): GroupedReportSource | undefined;
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { createGroupedReport } from "../../core/grouped-report.js";
|
|
2
|
+
import { checkAbort } from "../../core/iteration.js";
|
|
3
|
+
import { createTotals } from "../../internal/totals.js";
|
|
4
|
+
import { captureFields } from "../../internal/capture.js";
|
|
5
|
+
import { datetime } from "./dates.js";
|
|
6
|
+
import { canopyIdentityValue } from "./source.js";
|
|
7
|
+
const identity = (value) => value instanceof Date ? "date:" + value.getTime() : typeof value + ":" + String(value);
|
|
8
|
+
const scalar = canopyIdentityValue;
|
|
9
|
+
/** Validate captured ranges, then use the owned grouping factory and its existing writers.
|
|
10
|
+
* Only ranges, labels and at most four active aggregate vectors are retained; no detail body is buffered. */
|
|
11
|
+
export function canopyGrouped(source, request, options, limits, report, format) {
|
|
12
|
+
const input = request.grouping;
|
|
13
|
+
if (input === undefined)
|
|
14
|
+
return undefined; // query.groupBy never manufactures a group snapshot.
|
|
15
|
+
if (request.values !== "raw") {
|
|
16
|
+
report({ code: "GROUPING_REQUIRES_RAW_VALUES" });
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
if (source.rowCount === null)
|
|
20
|
+
throw new TypeError("Captured grouping requires its exact scope recordCount.");
|
|
21
|
+
const grouping = captureFields(input, ["levels", "aggregates", "totals", "groups"]);
|
|
22
|
+
if (!Array.isArray(grouping.levels) || grouping.levels.length < 1 || grouping.levels.length > 4 || !Array.isArray(grouping.aggregates) || !Array.isArray(grouping.groups))
|
|
23
|
+
throw new TypeError("Canopy grouping needs one through four levels, aggregates and ordered groups.");
|
|
24
|
+
const levels = grouping.levels.map(level => Object.freeze(captureFields(level, ["column", "direction", "title"])));
|
|
25
|
+
if (levels.some(level => typeof level.column !== "string" || !level.column || level.direction !== "asc" && level.direction !== "desc") ||
|
|
26
|
+
new Set(levels.map(level => level.column)).size !== levels.length)
|
|
27
|
+
throw new TypeError("Canopy grouping levels need unique stable columns and directions.");
|
|
28
|
+
const declarations = grouping.aggregates.map(aggregate => Object.freeze(captureFields(aggregate, ["id", "column", "operation", "label"])));
|
|
29
|
+
const ids = new Set(), totals = Object.create(null);
|
|
30
|
+
const operations = { sum: "sum", count: "count", average: "average", minimum: "min", maximum: "max" };
|
|
31
|
+
for (const aggregate of declarations) {
|
|
32
|
+
if (typeof aggregate.id !== "string" || !aggregate.id || ids.has(aggregate.id))
|
|
33
|
+
throw new TypeError("Canopy aggregate IDs must be unique nonempty strings.");
|
|
34
|
+
ids.add(aggregate.id);
|
|
35
|
+
const column = source.columns.find(column => column.key === aggregate.column);
|
|
36
|
+
if (!column || column.type !== "number")
|
|
37
|
+
throw new TypeError("Canopy aggregate declarations require an exported raw numeric column.");
|
|
38
|
+
if (Object.hasOwn(totals, aggregate.column))
|
|
39
|
+
throw new TypeError("The grouped report supports one aggregate operation per column.");
|
|
40
|
+
const operation = operations[aggregate.operation];
|
|
41
|
+
if (operation === undefined) {
|
|
42
|
+
report({ code: "UNSUPPORTED_GROUP_AGGREGATE:" + aggregate.operation, columnId: aggregate.column });
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
totals[aggregate.column] = operation;
|
|
46
|
+
}
|
|
47
|
+
// Reuse the canonical operation validator rather than implementing aggregate semantics here.
|
|
48
|
+
createTotals(source.columns, totals);
|
|
49
|
+
const expected = (input) => {
|
|
50
|
+
if (!input || typeof input !== "object" || Array.isArray(input))
|
|
51
|
+
throw new TypeError("Canopy aggregate values must be an ID-keyed object.");
|
|
52
|
+
const snapshot = { ...input };
|
|
53
|
+
if (Object.keys(snapshot).some(key => !ids.has(key)) || declarations.some(aggregate => !Object.hasOwn(snapshot, aggregate.id)))
|
|
54
|
+
throw new TypeError("Canopy aggregate values must reference exactly the captured declarations.");
|
|
55
|
+
for (const value of Object.values(snapshot))
|
|
56
|
+
if (value !== null && (typeof value !== "number" || !Number.isFinite(value)))
|
|
57
|
+
throw new TypeError("Canopy aggregate values must be finite numbers or null.");
|
|
58
|
+
return Object.freeze(snapshot);
|
|
59
|
+
};
|
|
60
|
+
const grandExpected = expected(grouping.totals), byDepth = levels.map(() => []), labels = levels.map(() => new Map());
|
|
61
|
+
let groups = 0, characters = 0;
|
|
62
|
+
const ranges = (inputs, offset, end, depth) => {
|
|
63
|
+
if (!Array.isArray(inputs))
|
|
64
|
+
throw new TypeError("Canopy groups must be ordered arrays.");
|
|
65
|
+
let cursor = offset;
|
|
66
|
+
const keys = new Set(), values = new Set();
|
|
67
|
+
for (const input of inputs) {
|
|
68
|
+
const group = captureFields(input, ["key", "value", "text", "offset", "count", "aggregates", "groups"]);
|
|
69
|
+
if (!group || typeof group.key !== "string" || keys.has(group.key) || !Number.isSafeInteger(group.offset) || !Number.isSafeInteger(group.count) ||
|
|
70
|
+
group.count <= 0 || group.offset !== cursor || group.count > end - group.offset)
|
|
71
|
+
throw new TypeError("Canopy group ranges must be nonempty contiguous half-open partitions within their parent.");
|
|
72
|
+
if (group.value !== null && !["string", "number", "boolean"].includes(typeof group.value) ||
|
|
73
|
+
typeof group.value === "number" && !Number.isFinite(group.value))
|
|
74
|
+
throw new TypeError("Canopy group values must be portable finite scalars.");
|
|
75
|
+
const dateColumn = request.columns.find(column => column.id === levels[depth].column)?.kind === "datetime";
|
|
76
|
+
const value = format === "xlsx" && dateColumn && typeof group.value === "string"
|
|
77
|
+
? datetime(group.value, options.datetime ?? "preserve", options.xlsx?.dateMode ?? request.timeZone) : group.value;
|
|
78
|
+
const key = identity(value), text = group.text ?? String(group.value ?? "");
|
|
79
|
+
if (typeof text !== "string" || values.has(key))
|
|
80
|
+
throw new TypeError("A Canopy group key cannot recur within the same parent.");
|
|
81
|
+
const previousLabel = labels[depth].get(key);
|
|
82
|
+
if (previousLabel !== undefined && previousLabel !== text)
|
|
83
|
+
throw new TypeError("The same grouping value needs consistent captured text at one level.");
|
|
84
|
+
labels[depth].set(key, text);
|
|
85
|
+
keys.add(group.key);
|
|
86
|
+
values.add(key);
|
|
87
|
+
if (++groups > 1000 || (characters += group.key.length + key.length + text.length) > 1000000)
|
|
88
|
+
throw new RangeError("Canopy group metadata exceeds the existing bounded report profile.");
|
|
89
|
+
const next = group.offset + group.count;
|
|
90
|
+
byDepth[depth].push(Object.freeze({ offset: group.offset, end: next, value, text, expected: expected(group.aggregates) }));
|
|
91
|
+
if (depth + 1 < levels.length)
|
|
92
|
+
ranges(group.groups ?? [], group.offset, next, depth + 1);
|
|
93
|
+
else if (group.groups !== undefined && group.groups.length)
|
|
94
|
+
throw new TypeError("Canopy nested groups exceed their declared levels.");
|
|
95
|
+
cursor = next;
|
|
96
|
+
}
|
|
97
|
+
if (cursor !== end)
|
|
98
|
+
throw new TypeError("Canopy grouping does not cover its complete exported detail range.");
|
|
99
|
+
};
|
|
100
|
+
ranges(grouping.groups, 0, source.rowCount, 0);
|
|
101
|
+
// Validate the producer's wire arithmetic separately from the grouped writer's native formula caches.
|
|
102
|
+
// Canopy sum/average use compensated accumulation and return null without numeric inputs.
|
|
103
|
+
const wireTotals = () => {
|
|
104
|
+
const ordinary = createTotals(source.columns, totals), sums = source.columns.map(() => 0), corrections = source.columns.map(() => 0), counts = source.columns.map(() => 0);
|
|
105
|
+
return {
|
|
106
|
+
accept(values) {
|
|
107
|
+
for (let index = 0; index < values.length; index++) {
|
|
108
|
+
const value = scalar(values[index]), operation = totals[source.columns[index].key];
|
|
109
|
+
if (operation !== "sum" && operation !== "average") {
|
|
110
|
+
ordinary[index].accept(value);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
if (typeof value !== "number" || !Number.isFinite(value))
|
|
114
|
+
continue;
|
|
115
|
+
counts[index] = counts[index] + 1;
|
|
116
|
+
const next = value - corrections[index], total = sums[index] + next;
|
|
117
|
+
corrections[index] = total - sums[index] - next;
|
|
118
|
+
sums[index] = total;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
value(index) {
|
|
122
|
+
const operation = totals[source.columns[index].key];
|
|
123
|
+
return operation === "sum" || operation === "average" ? !counts[index] ? null
|
|
124
|
+
: operation === "sum" ? sums[index] : sums[index] / counts[index] : ordinary[index].value();
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const indexes = levels.map(() => 0), active = levels.map(() => undefined);
|
|
129
|
+
const at = (depth, row) => {
|
|
130
|
+
const list = byDepth[depth];
|
|
131
|
+
while (list[indexes[depth]] && list[indexes[depth]].end <= row)
|
|
132
|
+
indexes[depth] = indexes[depth] + 1;
|
|
133
|
+
const range = list[indexes[depth]];
|
|
134
|
+
if (!range || row < range.offset || row >= range.end)
|
|
135
|
+
throw new TypeError("A detail row is outside its captured Canopy grouping.");
|
|
136
|
+
return range;
|
|
137
|
+
};
|
|
138
|
+
const verify = (actual, expected) => {
|
|
139
|
+
for (const declaration of declarations) {
|
|
140
|
+
const position = source.columns.findIndex(column => column.key === declaration.column), observed = actual.value(position), declared = expected[declaration.id];
|
|
141
|
+
// Exact producer-wire comparison retains wrong-scope rejection without rounding native caches or applying an epsilon.
|
|
142
|
+
if (observed !== declared)
|
|
143
|
+
throw new TypeError("Canopy captured aggregate differs from its consumed rows: " + declaration.id + ".");
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const same = (actual, expected) => actual instanceof Date && expected instanceof Date
|
|
147
|
+
? actual.getTime() === expected.getTime() : actual === expected;
|
|
148
|
+
async function* rows() {
|
|
149
|
+
let index = 0;
|
|
150
|
+
const grand = wireTotals();
|
|
151
|
+
for await (const values of source.rows()) {
|
|
152
|
+
checkAbort(options.signal);
|
|
153
|
+
for (let depth = 0; depth < levels.length; depth++) {
|
|
154
|
+
const range = at(depth, index), column = source.columns.findIndex(column => column.key === levels[depth].column);
|
|
155
|
+
if (column >= 0 && !same(scalar(values[column]), range.value))
|
|
156
|
+
throw new TypeError("Canopy detail value disagrees with its captured group range.");
|
|
157
|
+
if (range.offset === index)
|
|
158
|
+
active[depth] = { range, aggregates: wireTotals() };
|
|
159
|
+
}
|
|
160
|
+
grand.accept(values);
|
|
161
|
+
for (const group of active)
|
|
162
|
+
group.aggregates.accept(values);
|
|
163
|
+
yield values;
|
|
164
|
+
index++;
|
|
165
|
+
for (let depth = levels.length - 1; depth >= 0; depth--) {
|
|
166
|
+
const group = active[depth];
|
|
167
|
+
if (group.range.end === index) {
|
|
168
|
+
verify(group.aggregates, group.range.expected);
|
|
169
|
+
active[depth] = undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
verify(grand, grandExpected);
|
|
174
|
+
}
|
|
175
|
+
// The factory's hidden fields keep raw group identity separate from projected
|
|
176
|
+
// detail labels. Never override a declared output column's value getter.
|
|
177
|
+
const groupKeys = new Set([...source.columns.map(column => column.key), ...levels.map(level => level.column)]);
|
|
178
|
+
const groupBy = levels.map((level, depth) => {
|
|
179
|
+
const column = source.columns.findIndex(column => column.key === level.column);
|
|
180
|
+
let key = level.column;
|
|
181
|
+
if (column >= 0) {
|
|
182
|
+
do {
|
|
183
|
+
key += "#raw";
|
|
184
|
+
} while (groupKeys.has(key));
|
|
185
|
+
groupKeys.add(key);
|
|
186
|
+
}
|
|
187
|
+
return { key,
|
|
188
|
+
value: (row, context) => column < 0 ? at(depth, context.rowIndex).value : scalar(row[column]),
|
|
189
|
+
label: (value) => labels[depth].get(identity(value)) ?? String(value ?? "") };
|
|
190
|
+
});
|
|
191
|
+
const sourceLimits = limits === undefined ? undefined : {
|
|
192
|
+
...(limits.maxRows === undefined ? {} : { maxRows: limits.maxRows }),
|
|
193
|
+
...(limits.maxCells === undefined ? {} : { maxCells: limits.maxCells }),
|
|
194
|
+
...(limits.maxTextCharacters === undefined ? {} : { maxTextCharacters: limits.maxTextCharacters })
|
|
195
|
+
};
|
|
196
|
+
return createGroupedReport(rows(), { columns: source.columns, groupBy, totals,
|
|
197
|
+
...(options.signal === undefined ? {} : { signal: options.signal }), ...(sourceLimits === undefined ? {} : { limits: sourceLimits }) });
|
|
198
|
+
}
|
|
@@ -3,8 +3,8 @@ import type { CanopyCapture, CanopyFormat, CanopyWriteOptions } from "./types.js
|
|
|
3
3
|
export { createCanopyExport } from "./source.js";
|
|
4
4
|
export { ExportCell } from "../../core/presentation.js";
|
|
5
5
|
export { PdfFont } from "../../pdf/font.js";
|
|
6
|
-
export type { CanopyCapture, CanopyExportCell, CanopyExportColumn, CanopyExportRow, CanopyExport, CanopyFormat, CanopyDiagnostic, CanopySourceOptions, CanopyWriteOptions } from "./types.js";
|
|
7
|
-
/** Write a captured CanopyX grid to a caller-owned destination;
|
|
6
|
+
export type { CanopyCapture, CanopyExportCell, CanopyExportColumn, CanopyExportRow, CanopyExport, CanopyFormat, CanopyDiagnostic, CanopySourceOptions, CanopyWriteOptions, CanopyPivotAxisPresentation, CanopyPivotAxis, CanopyPivotColumnGroup, CanopyPivotDescriptor, CanopyNumberFormat, CanopyExportGroup, CanopyExportGrouping, CanopyRuleFilter, CanopyRulePredicate, CanopyFormatRule } from "./types.js";
|
|
7
|
+
/** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
|
|
8
8
|
export declare function writeCanopyTo(capture: CanopyCapture, format: CanopyFormat, destination: OutputDestination, options?: CanopyWriteOptions): Promise<ExportResult>;
|
|
9
9
|
/** Export an immutable native capture as a Blob without loading or registering CanopyX. */
|
|
10
10
|
export declare function exportCanopy(capture: CanopyCapture, format: CanopyFormat, options?: CanopyWriteOptions): Promise<Blob>;
|
|
@@ -1,34 +1,108 @@
|
|
|
1
|
-
import { BlobByteSink } from "../../core/index.js";
|
|
1
|
+
import { BlobByteSink, ExportCell } from "../../core/index.js";
|
|
2
2
|
import { notifyProgress } from "../../core/progress.js";
|
|
3
3
|
import { captureFields } from "../../internal/capture.js";
|
|
4
4
|
import { captureCommonLimits, captureXlsxOptions, captureCsvOptions, capturePdfOptions, mergeAdapterLimits } from "../options.js";
|
|
5
5
|
import { writeXlsxTo } from "../../xlsx/index.js";
|
|
6
6
|
import { writeCsvTo } from "../../csv/index.js";
|
|
7
|
-
import { writePdfTo } from "../../pdf/index.js";
|
|
8
|
-
import {
|
|
7
|
+
import { writePdfTo, writeGroupedPdfTo } from "../../pdf/index.js";
|
|
8
|
+
import { canopyDiagnostics } from "./diagnostics.js";
|
|
9
|
+
import { prepareCanopyExport } from "./source.js";
|
|
10
|
+
import { canopyPins } from "./presentation.js";
|
|
11
|
+
import { canopyRules } from "./rules.js";
|
|
12
|
+
import { canopyGrouped } from "./grouping.js";
|
|
13
|
+
import { canopyAbout } from "./metadata.js";
|
|
14
|
+
import { writeCanopyWorkbook } from "./workbook.js";
|
|
15
|
+
import { withCanopyPdfLayout } from "./pdf-layout.js";
|
|
9
16
|
export { createCanopyExport } from "./source.js";
|
|
10
17
|
export { ExportCell } from "../../core/presentation.js";
|
|
11
18
|
export { PdfFont } from "../../pdf/font.js";
|
|
12
|
-
/** Write a captured CanopyX grid to a caller-owned destination;
|
|
19
|
+
/** Write a captured CanopyX grid to a caller-owned destination; partial bytes remain caller-owned on failure. */
|
|
13
20
|
export async function writeCanopyTo(capture, format, destination, options = {}) {
|
|
14
|
-
const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress"]);
|
|
21
|
+
const selected = captureFields(options, ["tones", "columnOptions", "unsupportedPresentation", "datetime", "xlsx", "csv", "pdf", "signal", "onDiagnostic", "limits", "onProgress", "grouped", "about"]);
|
|
15
22
|
const { signal, onProgress } = selected, limits = captureCommonLimits(selected.limits);
|
|
16
23
|
const xlsx = captureXlsxOptions(format === "xlsx" ? selected.xlsx : undefined);
|
|
17
24
|
const csv = captureCsvOptions(format === "csv" ? selected.csv : undefined);
|
|
18
25
|
const pdf = capturePdfOptions(format === "pdf" ? selected.pdf : undefined);
|
|
19
|
-
const
|
|
26
|
+
const prepared = prepareCanopyExport(capture, format, { ...selected, xlsx }), { request, report, tones, pivot } = prepared;
|
|
27
|
+
if (selected.about !== undefined && typeof selected.about !== "boolean")
|
|
28
|
+
throw new TypeError("Canopy about must be boolean.");
|
|
29
|
+
const labels = selected.grouped === undefined ? undefined : captureFields(selected.grouped, ["labelColumn", "subtotalLabel", "grandTotalLabel", "includeGrandTotal", "continuationLabel", "groupHeadingLevel"]);
|
|
30
|
+
const capturedLabels = labels && { ...labels, ...(labels.labelColumn === undefined ? {} : { labelColumn: Object.freeze({ header: labels.labelColumn.header }) }) };
|
|
31
|
+
const about = format === "xlsx" && selected.about ? canopyAbout(request, xlsx) : undefined;
|
|
32
|
+
const ruleCellTypes = new Map();
|
|
33
|
+
let consumed = 0;
|
|
34
|
+
const source = Object.freeze({ ...prepared.source, async *rows() {
|
|
35
|
+
for await (const row of prepared.source.rows()) {
|
|
36
|
+
for (const [column, type] of ruleCellTypes) {
|
|
37
|
+
const cell = row[column], raw = cell instanceof ExportCell ? cell.value : cell;
|
|
38
|
+
if (raw == null || type === "number" && typeof raw === "number" && Number.isFinite(raw) || type === "date" && raw instanceof Date && Number.isFinite(raw.getTime()))
|
|
39
|
+
continue;
|
|
40
|
+
const code = "UNSUPPORTED_NATIVE_RULE_CELL_TYPE:" + type;
|
|
41
|
+
report({ code, columnId: source.columns[column].key });
|
|
42
|
+
// Text fallback cannot retract an already captured native declaration after streaming starts.
|
|
43
|
+
throw new TypeError("Unsupported Canopy presentation: " + code + " (" + source.columns[column].key + ")");
|
|
44
|
+
}
|
|
45
|
+
consumed++;
|
|
46
|
+
yield row;
|
|
47
|
+
}
|
|
48
|
+
} });
|
|
20
49
|
const progress = onProgress ? { onProgress: (event) => {
|
|
21
|
-
|
|
50
|
+
// About and generated group rows consume output budgets, but never become exported source details.
|
|
51
|
+
notifyProgress(onProgress, { ...event, rows: consumed,
|
|
52
|
+
...(event.sheetRows === undefined ? {} : { sheetRows: about !== undefined && event.sheetName === "About" ? 0 : consumed }),
|
|
53
|
+
...(source.rowCount === null ? {} : { totalRows: source.rowCount }) });
|
|
22
54
|
} } : {};
|
|
23
55
|
const stream = { ...(signal ? { signal } : {}), ...progress };
|
|
24
|
-
if (format === "xlsx")
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
56
|
+
if (format === "xlsx") {
|
|
57
|
+
const formatLimits = mergeAdapterLimits(xlsx.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, { ...selected, xlsx }, formatLimits, report, format);
|
|
58
|
+
const pinned = canopyPins(request.columns, report), rules = canopyRules(request, format, grouped !== undefined, tones, report, { ...selected, xlsx }, ruleCellTypes);
|
|
59
|
+
if (pivot && (xlsx.sheet?.rowOutline !== undefined || xlsx.sheet?.columnOutlines !== undefined || xlsx.sheet?.maxOutlineLevel !== undefined ||
|
|
60
|
+
xlsx.sheet?.outlineSummaryBelow !== undefined || xlsx.sheet?.outlineSummaryRight !== undefined || xlsx.sheet?.table !== undefined || xlsx.sheet?.footer !== undefined))
|
|
61
|
+
throw new TypeError("Captured pivot metadata owns outlines and totals; worksheet overrides cannot regroup or recalculate it.");
|
|
62
|
+
if (pivot && xlsx.cellValueWriters !== undefined)
|
|
63
|
+
throw new TypeError("Captured pivot exports use frozen values rather than custom cellValueWriters.");
|
|
64
|
+
const sheet = { ...xlsx.sheet, ...(pivot?.sheet ?? {}), ...(pivot ? { autoFilter: false } : {}),
|
|
65
|
+
freezeHeader: xlsx.sheet?.freezeHeader ?? (xlsx.sheet?.includeHeader !== false),
|
|
66
|
+
freezeColumns: xlsx.sheet?.freezeColumns ?? (pinned ? pinned + (grouped ? 1 : 0) : 0),
|
|
67
|
+
conditionalFormats: [...rules, ...(xlsx.sheet?.conditionalFormats ?? [])] };
|
|
68
|
+
const settings = { ...xlsx, ...stream, columns: source.columns, sheet, dateMode: xlsx.dateMode ?? request.timeZone, limits: formatLimits };
|
|
69
|
+
if (grouped || about)
|
|
70
|
+
return writeCanopyWorkbook(source, grouped, destination, settings, capturedLabels, about);
|
|
71
|
+
return writeXlsxTo(source.rows(), destination, settings);
|
|
72
|
+
}
|
|
73
|
+
if (pivot)
|
|
74
|
+
canopyDiagnostics(format, { ...selected, unsupportedPresentation: "text" })({ code: "PIVOT_OUTLINES_XLSX_ONLY" });
|
|
75
|
+
if (format === "pdf") {
|
|
76
|
+
if (pivot && pdf.footer?.totals !== undefined)
|
|
77
|
+
throw new TypeError("Captured pivot metadata owns totals; PDF footer totals cannot recalculate it.");
|
|
78
|
+
const formatLimits = mergeAdapterLimits(pdf.limits, limits), grouped = pivot ? undefined : canopyGrouped(source, request, selected, formatLimits, report, format);
|
|
79
|
+
canopyRules(request, format, grouped !== undefined, tones, report, selected);
|
|
80
|
+
// CSS pixels become points before the existing fit/band policy. Explicit PDF point widths win.
|
|
81
|
+
const fitted = request.columns.every(column => column.width !== undefined) ? request.columns.map(column => column.width.preferred * 72 / 96) : undefined;
|
|
82
|
+
const widths = pdf.columnWidths ?? fitted;
|
|
83
|
+
const settings = { orientation: "landscape", wideTable: "fit", ...pdf, ...stream, limits: formatLimits };
|
|
84
|
+
if (grouped) {
|
|
85
|
+
if (pdf.headerRows !== undefined || pdf.footer !== undefined)
|
|
86
|
+
throw new TypeError("Grouped Canopy PDF owns heading and summary rows.");
|
|
87
|
+
const { headerRows: _headers, footer: _footer, ...groupedSettings } = settings;
|
|
88
|
+
return writeGroupedPdfTo(grouped, destination, { ...groupedSettings,
|
|
89
|
+
...(widths === undefined ? {} : { columnWidths: [72, ...widths] }),
|
|
90
|
+
labelColumn: { header: capturedLabels?.labelColumn?.header ?? "Group", width: 12 },
|
|
91
|
+
subtotalLabel: capturedLabels?.subtotalLabel ?? (group => group.label + " total"),
|
|
92
|
+
grandTotalLabel: capturedLabels?.grandTotalLabel ?? (() => "Grand total"),
|
|
93
|
+
...(capturedLabels?.includeGrandTotal === undefined ? {} : { includeGrandTotal: capturedLabels.includeGrandTotal }),
|
|
94
|
+
...(capturedLabels?.continuationLabel === undefined ? {} : { continuationLabel: capturedLabels.continuationLabel }),
|
|
95
|
+
...(capturedLabels?.groupHeadingLevel === undefined ? {} : { groupHeadingLevel: capturedLabels.groupHeadingLevel }) });
|
|
96
|
+
}
|
|
97
|
+
return withCanopyPdfLayout(prepared.source, request.columns, settings, async (rows, layout, captured) => {
|
|
98
|
+
const counted = async function* () { for await (const row of rows) {
|
|
99
|
+
consumed++;
|
|
100
|
+
yield row;
|
|
101
|
+
} };
|
|
102
|
+
return writePdfTo(counted(), destination, { ...captured, ...layout, columns: source.columns });
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return writeCsvTo(source.rows(), destination, { ...csv, ...stream, columns: source.columns, valueMode: request.values,
|
|
32
106
|
limits: mergeAdapterLimits(csv.limits, limits) });
|
|
33
107
|
}
|
|
34
108
|
/** Export an immutable native capture as a Blob without loading or registering CanopyX. */
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CanopyCapture } from "./types.js";
|
|
2
|
+
import type { XlsxOptions } from "../../xlsx/index.js";
|
|
3
|
+
/** Snapshot optional About metadata before enumeration. The accepted query is serialized, never evaluated. */
|
|
4
|
+
export declare function canopyAbout(request: CanopyCapture["request"], options: Pick<XlsxOptions, "oversizedText" | "invalidCharacterPolicy">): readonly (readonly [string, string | number])[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { cellText } from "../../xlsx/values.js";
|
|
2
|
+
import { cleanXml } from "../../xml/index.js";
|
|
3
|
+
/** Snapshot optional About metadata before enumeration. The accepted query is serialized, never evaluated. */
|
|
4
|
+
export function canopyAbout(request, options) {
|
|
5
|
+
const result = [["revision", request.revision], ["recordCount", request.recordCount === null ? "unknown" : request.recordCount]];
|
|
6
|
+
if (request.scope !== undefined) {
|
|
7
|
+
if (!["filtered", "selected", "all"].includes(request.scope))
|
|
8
|
+
throw new TypeError("Invalid Canopy export scope.");
|
|
9
|
+
result.push(["scope", request.scope]);
|
|
10
|
+
}
|
|
11
|
+
for (const key of ["total", "matched"])
|
|
12
|
+
if (request[key] !== undefined) {
|
|
13
|
+
const value = request[key];
|
|
14
|
+
if (value === null) {
|
|
15
|
+
result.push([key, "unknown"]);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
19
|
+
throw new TypeError("Canopy metadata counts must be nonnegative safe integers.");
|
|
20
|
+
result.push([key, value]);
|
|
21
|
+
}
|
|
22
|
+
if (request.generatedAt !== undefined) {
|
|
23
|
+
if (typeof request.generatedAt !== "string" || !/^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d(?:\.\d{1,9})?Z$/.test(request.generatedAt) || !Number.isFinite(new Date(request.generatedAt).getTime()))
|
|
24
|
+
throw new TypeError("Canopy generatedAt must be a captured UTC ISO instant.");
|
|
25
|
+
result.push(["generatedAt", request.generatedAt]);
|
|
26
|
+
}
|
|
27
|
+
if (request.selection !== undefined) {
|
|
28
|
+
if (!Array.isArray(request.selection) || request.selection.some(id => typeof id !== "string"))
|
|
29
|
+
throw new TypeError("Canopy selection metadata must contain stable string IDs.");
|
|
30
|
+
result.push(["selection", JSON.stringify(request.selection)]);
|
|
31
|
+
}
|
|
32
|
+
if (request.query !== undefined) {
|
|
33
|
+
if (!request.query || typeof request.query !== "object" || Array.isArray(request.query))
|
|
34
|
+
throw new TypeError("Canopy accepted query must be a captured object.");
|
|
35
|
+
const query = JSON.stringify(request.query);
|
|
36
|
+
if (typeof query !== "string")
|
|
37
|
+
throw new TypeError("Canopy accepted query must serialize as JSON metadata.");
|
|
38
|
+
result.push(["query", query]);
|
|
39
|
+
}
|
|
40
|
+
if (result.reduce((sum, row) => sum + row[0].length + String(row[1]).length, 0) > 65536)
|
|
41
|
+
throw new RangeError("Canopy About metadata exceeds 65,536 captured characters.");
|
|
42
|
+
// Validate known cell text before consuming details; overflow preservation and XML policy stay workbook-owned.
|
|
43
|
+
for (const [field, value] of result) {
|
|
44
|
+
cellText(field, options.invalidCharacterPolicy);
|
|
45
|
+
if (options.oversizedText === "preserve")
|
|
46
|
+
cleanXml(value, options.invalidCharacterPolicy);
|
|
47
|
+
else
|
|
48
|
+
cellText(value, options.invalidCharacterPolicy);
|
|
49
|
+
}
|
|
50
|
+
return Object.freeze(result.map(row => Object.freeze(row)));
|
|
51
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ExportValue, ExportResult } from "../../core/index.js";
|
|
2
|
+
import type { PdfOptions } from "../../pdf/index.js";
|
|
3
|
+
import type { CanopyExport, CanopyExportColumn } from "./types.js";
|
|
4
|
+
/** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
|
|
5
|
+
export declare function withCanopyPdfLayout(source: CanopyExport, captured: readonly CanopyExportColumn[], options: Omit<PdfOptions, "columns">, write: (rows: AsyncIterable<readonly ExportValue[]>, layout: Pick<PdfOptions, "columnWidths" | "wideTable">, capturedOptions: Omit<PdfOptions, "columns">) => Promise<ExportResult>): Promise<ExportResult>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ExportCell, NotSupportedError, OfficeIMOError } from "../../core/index.js";
|
|
2
|
+
import { inputRows, checkAbort, pause, taskYieldDue } from "../../core/iteration.js";
|
|
3
|
+
import { fontProgram } from "../../pdf/font.js";
|
|
4
|
+
import { resolveScalar, selectFont, validateFonts } from "../../pdf/font-support.js";
|
|
5
|
+
import { settings } from "../../pdf/settings.js";
|
|
6
|
+
import { canopyPdfNumbers } from "./pdf-number.js";
|
|
7
|
+
/** A bounded lookahead is replayed once; no second capture, full-dataset copy or smaller font is needed. */
|
|
8
|
+
export async function withCanopyPdfLayout(source, captured, options, write) {
|
|
9
|
+
const prepared = settings({ ...options, columns: source.columns }), { fontSize, padding, page, margins, limits } = prepared;
|
|
10
|
+
options = prepared.options;
|
|
11
|
+
validateFonts(options.fonts, limits.maxFontBytes);
|
|
12
|
+
const available = page.width - margins.left - margins.right;
|
|
13
|
+
const iterator = inputRows(source.rows(), options.signal)[Symbol.asyncIterator](), sample = [];
|
|
14
|
+
let done = false, characters = 0;
|
|
15
|
+
try {
|
|
16
|
+
while (sample.length < Math.min(128, options.limits?.maxRows ?? 128) && characters < 262144) {
|
|
17
|
+
const item = await iterator.next();
|
|
18
|
+
if (item.done) {
|
|
19
|
+
done = true;
|
|
20
|
+
break;
|
|
21
|
+
}
|
|
22
|
+
sample.push(item.value);
|
|
23
|
+
characters += item.value.reduce((n, cell) => n + (cell instanceof ExportCell ? cell.text?.length ?? 0 : String(cell ?? "").length), 0);
|
|
24
|
+
}
|
|
25
|
+
const format = canopyPdfNumbers(sample, source.columns), rows = sample.map(format);
|
|
26
|
+
const measure = (text, bold = false, italic = false) => {
|
|
27
|
+
if (text.length > limits.maxCellCharacters)
|
|
28
|
+
throw new OfficeIMOError("RESOURCE_LIMIT", "maxCellCharacters exceeded.");
|
|
29
|
+
const face = selectFont(options.fonts, bold, italic), program = face.font ? fontProgram(face.font) : undefined;
|
|
30
|
+
let width = 0;
|
|
31
|
+
for (const character of text.replace(/\t/g, " ")) {
|
|
32
|
+
const scalar = resolveScalar(character.codePointAt(0), program, bold);
|
|
33
|
+
if (!scalar.supported)
|
|
34
|
+
throw new NotSupportedError(scalar.message);
|
|
35
|
+
width += scalar.width * fontSize / 1000;
|
|
36
|
+
}
|
|
37
|
+
return width;
|
|
38
|
+
};
|
|
39
|
+
const largest = (parts, bold = false, italic = false) => parts.reduce((width, part) => Math.max(width, measure(part, bold, italic)), 0);
|
|
40
|
+
let layout = {};
|
|
41
|
+
// Explicit points/bands and shaping providers retain their own layout policy.
|
|
42
|
+
if (!options.columnWidths && typeof options.wideTable !== "object" && !options.textShaper) {
|
|
43
|
+
const minimum = source.columns.map(column => Math.min(available, largest(column.header.split(/\s+/), prepared.options.headerPresentation?.bold) + padding * 2 + .01));
|
|
44
|
+
const natural = source.columns.map((column, index) => Math.min(available, Math.max(minimum[index], largest(column.header.split(/\r\n?|\n/), prepared.options.headerPresentation?.bold) + padding * 2 + .01)));
|
|
45
|
+
for (const row of rows) {
|
|
46
|
+
for (let i = 0; i < row.length; i++) {
|
|
47
|
+
const cell = row[i], text = cell instanceof ExportCell ? cell.text ?? String(cell.value ?? "") : String(cell ?? "");
|
|
48
|
+
const style = cell instanceof ExportCell ? cell.presentation : undefined;
|
|
49
|
+
const line = largest(text.split(/\r\n?|\n/), style?.bold, style?.italic) + padding * 2 + .01;
|
|
50
|
+
const word = largest(text.split(/\s+/), style?.bold, style?.italic) + padding * 2 + .01;
|
|
51
|
+
natural[i] = Math.min(available, Math.max(natural[i], line));
|
|
52
|
+
minimum[i] = Math.min(available, Math.max(minimum[i], captured[i].kind === "text" ? word : line));
|
|
53
|
+
}
|
|
54
|
+
if (taskYieldDue())
|
|
55
|
+
await pause();
|
|
56
|
+
checkAbort(options.signal);
|
|
57
|
+
}
|
|
58
|
+
const sum = minimum.reduce((total, width) => total + width, 0), widths = [...minimum];
|
|
59
|
+
if (sum > available + .001)
|
|
60
|
+
layout = { columnWidths: widths, wideTable: options.wideTable === "reject" ? "reject" : {
|
|
61
|
+
mode: "bands", repeatColumns: widths[0] + Math.max(...widths.slice(1)) <= available ? [0] : []
|
|
62
|
+
} };
|
|
63
|
+
else {
|
|
64
|
+
let spare = available - sum;
|
|
65
|
+
const needs = natural.map((width, index) => Math.max(0, width - widths[index])), total = needs.reduce((n, width) => n + width, 0);
|
|
66
|
+
for (let i = 0; i < widths.length; i++)
|
|
67
|
+
widths[i] += total ? needs[i] * Math.min(1, spare / total) : 0;
|
|
68
|
+
spare = available - widths.reduce((n, width) => n + width, 0);
|
|
69
|
+
const text = captured.flatMap((column, index) => column.kind === "text" ? [index] : []);
|
|
70
|
+
for (const i of text.length ? text : widths.map((_, index) => index))
|
|
71
|
+
widths[i] += spare / (text.length || widths.length);
|
|
72
|
+
layout = { columnWidths: widths };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
const replay = async function* () {
|
|
76
|
+
for (const row of rows)
|
|
77
|
+
yield row;
|
|
78
|
+
while (!done) {
|
|
79
|
+
const item = await iterator.next();
|
|
80
|
+
if (item.done) {
|
|
81
|
+
done = true;
|
|
82
|
+
break;
|
|
83
|
+
}
|
|
84
|
+
yield format(item.value);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
return await write(replay(), layout, prepared.options);
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
if (!done) {
|
|
91
|
+
try {
|
|
92
|
+
void iterator.return(undefined).catch(() => { });
|
|
93
|
+
}
|
|
94
|
+
catch { /* Keep the writer's original failure. */ }
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExportValue, ColumnSettings } from "../../core/index.js";
|
|
2
|
+
/** Preserve the captured decimal convention across a column, including whole percentages without a separator. */
|
|
3
|
+
export declare function canopyPdfNumbers(sample: readonly (readonly ExportValue[])[], columns: readonly ColumnSettings[]): (row: readonly ExportValue[]) => readonly ExportValue[];
|