@poe-platform/safe-bash 0.1.809 → 0.1.810
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/dist/audio-ast/index.d.ts +1 -1
- package/dist/audio-ast/index.js +6 -0
- package/dist/audio-ast/wav-source.d.ts +7 -1
- package/dist/image-ast/index.js +1 -1
- package/dist/pdf-ast/cos/mutable-object-store.d.ts +3 -0
- package/dist/pdf-ast/cos/qpdf-json-document.d.ts +42 -0
- package/dist/pdf-ast/cos/qpdf-json-values.d.ts +7 -0
- package/dist/pdf-ast/index.d.ts +1 -0
- package/dist/pdf-ast/index.js +508 -37
- package/dist/pdf-ast/retained-document.d.ts +3 -1
- package/dist/safe-bash/chunks/{chunk-RQCK77SC.js → chunk-65TFMAZU.js} +2 -2
- package/dist/safe-bash/chunks/{chunk-SOFBGDXG.js → chunk-HHSOUC3Z.js} +32 -0
- package/dist/safe-bash/chunks/{chunk-WAZEELYB.js → chunk-ZA5FQ34E.js} +10 -5
- package/dist/safe-bash/command-chunks/biff-ORSHM4YX-QYPGRDAZ.js +4937 -0
- package/dist/safe-bash/command-chunks/{chunk-62ZAHKFS.js → chunk-2VCKUNDZ.js} +130 -14
- package/dist/safe-bash/command-chunks/{chunk-GLVD3JJG.js → chunk-BYZUOF6X.js} +2858 -2816
- package/dist/safe-bash/command-chunks/{chunk-6OKH4X67.js → chunk-CAXJ4RLF.js} +264 -1
- package/dist/safe-bash/command-chunks/{chunk-YJJBGN7U.js → chunk-CHR2OD2U.js} +9 -9
- package/dist/safe-bash/command-chunks/{chunk-D7XBUF76.js → chunk-D2ASPM7R.js} +109 -23
- package/dist/safe-bash/command-chunks/chunk-D5AYP2UM.js +816 -0
- package/dist/safe-bash/command-chunks/{chunk-WFDG3N5R.js → chunk-ECDEPKKW.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-OQCJGUI6.js → chunk-HARUYHH7.js} +10 -10
- package/dist/safe-bash/command-chunks/{chunk-NVBUC644.js → chunk-HKGNBH7Z.js} +2 -2
- package/dist/safe-bash/command-chunks/chunk-MGBHGZEX.js +12 -0
- package/dist/safe-bash/command-chunks/{chunk-4557HE3J.js → chunk-PMWW7KSB.js} +161 -42
- package/dist/safe-bash/command-chunks/{chunk-JW3KIZU6.js → chunk-RUXY7GN5.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-KELMIFVV.js → chunk-TI52LKLL.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-JJQ72P3V.js → chunk-VCML4T5D.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-5HGEXQVD.js → chunk-WC2OCF4H.js} +1 -1
- package/dist/safe-bash/command-chunks/chunk-WH3TIOTS.js +326 -0
- package/dist/safe-bash/command-chunks/{chunk-45FI2IPY.js → chunk-WQ6ABTJU.js} +3 -6
- package/dist/safe-bash/command-chunks/{chunk-NB7JO7FE.js → chunk-YTFWPJ3F.js} +1 -1
- package/dist/safe-bash/command-chunks/{chunk-GKYCV6BU.js → chunk-ZEPDT6I5.js} +482 -168
- package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js} +10 -3
- package/dist/safe-bash/command-chunks/{engine-RU4OFLPO-CPLFYD67.js → engine-MEPOXIXT-WZMRHACG.js} +1 -1
- package/dist/safe-bash/command-chunks/pdf-LOZAXXS6-ERI57IAV.js +557 -0
- package/dist/safe-bash/commands/audio/index.browser.js +2 -14
- package/dist/safe-bash/commands/diff-patch/index.js +0 -2
- package/dist/safe-bash/commands/ffprobe/index.browser.js +2 -5
- package/dist/safe-bash/commands/pandoc/index.browser.js +3 -1
- package/dist/safe-bash/commands/text.js +10 -1
- package/dist/safe-bash/core.d.ts +2 -2
- package/dist/safe-bash/core.js +2 -2
- package/dist/safe-bash/full-core.browser.js +18 -22
- package/dist/safe-bash/lazy-optional.d.ts +9 -0
- package/dist/safe-bash/lazy-optional.js +24 -0
- package/dist/safe-bash/plugins/index.browser.js +5 -3
- package/dist/safe-bash/registry-entry.browser.js +1 -1
- package/dist/safe-bash-command-apply-patch/apply.js +2 -2
- package/dist/safe-bash-command-apply-patch/index.js +2 -2
- package/dist/safe-bash-command-apply-patch/parser.d.ts +20 -1
- package/dist/safe-bash-command-apply-patch/parser.js +1 -1
- package/dist/safe-bash-command-ffprobe/index.js +2 -1
- package/dist/safe-bash-command-ffprobe/media.js +2 -1
- package/dist/safe-bash-command-ffprobe/options.d.ts +15 -0
- package/dist/safe-bash-command-ffprobe/options.js +7 -0
- package/dist/safe-bash-command-media/index.js +2 -2
- package/dist/safe-bash-command-media/plugin.js +1 -1
- package/dist/safe-bash-command-media/remote.js +2 -2
- package/dist/safe-bash-command-pandoc/command.js +6 -6
- package/dist/safe-bash-command-pandoc/index.js +31 -31
- package/dist/safe-bash-command-patch/index.js +2 -2
- package/dist/safe-bash-command-patch/patch-publication.d.ts +2 -2
- package/dist/safe-bash-command-patch/patch-publication.js +1 -1
- package/dist/safe-bash-command-patch/patch.js +2 -2
- package/dist/safe-bash-command-pptx/engine.js +1 -1
- package/dist/safe-bash-command-ssconvert/index.js +2 -2
- package/dist/safe-bash-command-xmllint/index.js +137 -30
- package/dist/safe-bash-compression-engine/bounded-codec.js +2 -2
- package/dist/safe-bash-compression-engine/codec-loader.js +1 -1
- package/dist/safe-bash-compression-engine/files.js +5 -5
- package/dist/safe-bash-compression-engine/index.js +4 -4
- package/dist/safe-bash-compression-engine/operand.js +5 -5
- package/dist/safe-bash-compression-engine/stream.js +4 -4
- package/dist/safe-bash-compression-engine/zstd-decode.js +3 -3
- package/dist/safe-bash-media-engine/imagemagick.d.ts +2 -0
- package/dist/safe-bash-media-engine/index.js +162 -72
- package/dist/safe-bash-network-engine/body.d.ts +1 -0
- package/dist/safe-bash-network-engine/body.js +1 -1
- package/dist/safe-bash-network-engine/transfer.js +11 -3
- package/dist/safe-bash-presentation-engine/command-placeholder.js +4 -3
- package/dist/safe-bash-presentation-engine/index.d.ts +1 -1
- package/dist/safe-bash-presentation-engine/index.js +9 -4
- package/dist/safe-bash-presentation-engine/presentation-model.js +3 -2
- package/dist/safe-bash-presentation-engine/retained-text.js +3 -3
- package/dist/safe-bash-presentation-engine/retained-xml-parts.d.ts +26 -0
- package/dist/safe-bash-presentation-engine/xml-parts.d.ts +1 -0
- package/dist/safe-bash-presentation-engine/xml-parts.js +7 -1
- package/dist/safe-bash-xml-engine/document.js +1 -1
- package/dist/safe-bash-xml-engine/index.js +1 -1
- package/dist/spreadsheet-engine/rendering/print/tab-layout.d.ts +11 -0
- package/dist/spreadsheet-engine/rendering/print/tab-layout.js +15 -0
- package/dist/spreadsheet-engine/rendering/print/text-lines.d.ts +2 -2
- package/dist/spreadsheet-engine/rendering/print/text-lines.js +3 -3
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.d.ts +4 -0
- package/dist/spreadsheet-format-xls/biff-encrypted-properties.js +137 -56
- package/dist/spreadsheet-format-xls/biff-encryption.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-encryption.js +8 -3
- package/dist/spreadsheet-format-xls/biff-property-bytes.d.ts +1 -1
- package/dist/spreadsheet-format-xls/biff-property-bytes.js +2 -2
- package/dist/spreadsheet-format-xls/biff.js +11 -3
- package/package.json +3 -2
- package/dist/safe-bash/chunks/chunk-I2A5ZCPD.js +0 -17
- package/dist/safe-bash/chunks/chunk-PQTT2EZP.js +0 -8
- package/dist/safe-bash/command-chunks/biff-DS263V2K-2GP4GZT7.js +0 -4868
- package/dist/safe-bash/command-chunks/chunk-6ZFYWT3U.js +0 -581
- package/dist/safe-bash/command-chunks/chunk-S244SWDH.js +0 -153
- package/dist/safe-bash/command-chunks/pdf-T7AWYZGQ-KNAYJ7YF.js +0 -552
- /package/dist/safe-bash/command-chunks/{chunk-EMMSXKEJ.js → chunk-4Q4R3VZU.js} +0 -0
package/dist/safe-bash/command-chunks/{command-engine-P5DFM4OU.js → command-engine-BEWABZ75.js}
RENAMED
|
@@ -8793,7 +8793,7 @@ import {
|
|
|
8793
8793
|
readPresentationSettings,
|
|
8794
8794
|
mutatePresentationSettings
|
|
8795
8795
|
} from "../../safe-bash-presentation-engine/presentation-settings.js";
|
|
8796
|
-
import { getXmlPart, replaceXmlPart } from "../../safe-bash-presentation-engine/xml-parts.js";
|
|
8796
|
+
import { getXmlPart, stageRetainedXmlPart, replaceXmlPart } from "../../safe-bash-presentation-engine/xml-parts.js";
|
|
8797
8797
|
import { validatePresentation, openRetainedPresentationValidation } from "../../safe-bash-presentation-engine/validation.js";
|
|
8798
8798
|
import { readPackage as readPackage3 } from "../../safe-bash-presentation-engine/package-reader.js";
|
|
8799
8799
|
import { resourceContext } from "../../safe-bash-presentation-engine/resource-limits.js";
|
|
@@ -11727,7 +11727,7 @@ async function execute(request, options2) {
|
|
|
11727
11727
|
output3.json = args.json;
|
|
11728
11728
|
output3.operation = args.operation;
|
|
11729
11729
|
const operation2 = args.operation;
|
|
11730
|
-
if ((args.operation === "inspect" || args.operation === "text.get" || args.operation === "fields.list" || args.operation === "fields.get") && request.streaming) {
|
|
11730
|
+
if ((args.operation === "inspect" || args.operation === "text.get" || args.operation === "fields.list" || args.operation === "fields.get" || args.operation === "xml.get") && request.streaming) {
|
|
11731
11731
|
if (args.token) decodeSelectionToken2(args.token);
|
|
11732
11732
|
const input = await request.streaming.openInput(args.input, Math.min(options2.context.limits.maxBytes, options2.context.archiveLimits.maxArchiveBytes));
|
|
11733
11733
|
const hash = sha2564.create();
|
|
@@ -11741,7 +11741,14 @@ async function execute(request, options2) {
|
|
|
11741
11741
|
let failed = false;
|
|
11742
11742
|
try {
|
|
11743
11743
|
const scope = args.token ? decodeSelectionToken2(args.token).scope : args.scope;
|
|
11744
|
-
stagedOutput = args.operation
|
|
11744
|
+
stagedOutput = args.operation === "xml.get" ? await stageRetainedXmlPart(archive, fingerprint, {
|
|
11745
|
+
...args.token === void 0 ? {} : { token: args.token },
|
|
11746
|
+
...args.slide === void 0 ? {} : { slide: args.slide },
|
|
11747
|
+
...args.shape === void 0 ? {} : { shape: args.shape },
|
|
11748
|
+
...args.part === void 0 ? {} : { part: args.part },
|
|
11749
|
+
...args.scope === void 0 ? {} : { scope: args.scope },
|
|
11750
|
+
...args.all === void 0 ? {} : { all: args.all }
|
|
11751
|
+
}, context, { json: args.json, pretty: args.pretty ?? false, maxOutputBytes: options2.maxOutputBytes }) : args.operation !== "inspect" ? await stageRetainedText(archive, fingerprint, {
|
|
11745
11752
|
...scope === void 0 ? {} : { scope },
|
|
11746
11753
|
...args.token ? { select: { token: args.token } } : args.slide === void 0 ? {} : { select: { kind: "slide", position: { coordinateSystem: "one-based", value: args.slide } } },
|
|
11747
11754
|
...args.shape === void 0 ? {} : { shape: args.shape }
|
|
@@ -0,0 +1,557 @@
|
|
|
1
|
+
import {
|
|
2
|
+
f
|
|
3
|
+
} from "./chunk-YXIB6JV5.js";
|
|
4
|
+
import {
|
|
5
|
+
n,
|
|
6
|
+
o
|
|
7
|
+
} from "./chunk-HQAHDJPX.js";
|
|
8
|
+
import {
|
|
9
|
+
a as a2,
|
|
10
|
+
p as p2
|
|
11
|
+
} from "./chunk-2BKOSQD3.js";
|
|
12
|
+
import {
|
|
13
|
+
p
|
|
14
|
+
} from "./chunk-4XWFUW5L.js";
|
|
15
|
+
import {
|
|
16
|
+
t
|
|
17
|
+
} from "./chunk-Y4RGZJIG.js";
|
|
18
|
+
import {
|
|
19
|
+
a
|
|
20
|
+
} from "./chunk-KDG3J4GN.js";
|
|
21
|
+
import {
|
|
22
|
+
e
|
|
23
|
+
} from "./chunk-SB3DHPKZ.js";
|
|
24
|
+
import "./chunk-WHWIZ2B7.js";
|
|
25
|
+
import "./chunk-65DS4IOB.js";
|
|
26
|
+
|
|
27
|
+
// packages/safe-bash-command-ssconvert/dist/chunks/pdf-LOZAXXS6.js
|
|
28
|
+
import { rotatedPrintLayout as oe } from "../../spreadsheet-engine/rendering/print/rotated-text.js";
|
|
29
|
+
import { printSharedBorders as We } from "../../spreadsheet-engine/rendering/print/shared-borders.js";
|
|
30
|
+
import { printBorderStrokes as ze } from "../../spreadsheet-engine/rendering/print/diagonal-borders.js";
|
|
31
|
+
import { createPrintBlankStyles as _e } from "../../spreadsheet-engine/rendering/print/blank-styles.js";
|
|
32
|
+
import { printDiagonalBorders as De } from "../../spreadsheet-engine/rendering/print/diagonal-borders.js";
|
|
33
|
+
import { createPrintMerges as Ie } from "../../spreadsheet-engine/rendering/print/merges.js";
|
|
34
|
+
import { justifyPrintLine as Le } from "../../spreadsheet-engine/rendering/print/justify-line.js";
|
|
35
|
+
import { wrapPrintLine as He } from "../../spreadsheet-engine/rendering/print/wrap-lines.js";
|
|
36
|
+
import { PDFDocument as Ee, PDFHexString as se, PDFName as be, PDFOperator as Qt, PDFOperatorNames as Bt, rgb as Tt, moveTo as Ge, lineTo as Xe, closePath as Ue, fill as Ye, pushGraphicsState as Nt, popGraphicsState as Rt, concatTransformationMatrix as ae, rectangle as Xt, clip as Ut, endPath as Yt, drawObject as $e, beginText as we, endText as ve, setFontAndSize as ke, setTextMatrix as Pe, showText as Se, setFillingRgbColor as qe, setGraphicsState as Je } from "pdf-lib";
|
|
37
|
+
import Me from "@pdf-lib/fontkit";
|
|
38
|
+
import { admitTrueTypeFont as Ze, suppliedDefaultFont as Ve, serializePdf as Ke, decodePng as Qe, PdfError as Ce } from "../../safe-bash-pdf-engine/index.js";
|
|
39
|
+
import { graphBackground as pe } from "../../spreadsheet-engine/rendering/images/scene.js";
|
|
40
|
+
import { nextPrintTabStop as Re, mirrorPrintTabRuns as Be } from "../../spreadsheet-engine/rendering/print/tab-layout.js";
|
|
41
|
+
import { splitPrintLines as tn, fillPrintNewlines as en, fillPrintItems as nn } from "../../spreadsheet-engine/rendering/print/text-lines.js";
|
|
42
|
+
import { renderPrintFormula as Fe } from "../../spreadsheet-engine/rendering/print/formula-text.js";
|
|
43
|
+
import { createPrintSpans as rn } from "../../spreadsheet-engine/rendering/print/text-span.js";
|
|
44
|
+
import { cellPrintStyle as Vt } from "../../spreadsheet-engine/rendering/print/cell-style.js";
|
|
45
|
+
import { sheetPrintSettings as ge } from "../../spreadsheet-engine/rendering/print/settings.js";
|
|
46
|
+
import { normalizeFontText as Kt } from "../../spreadsheet-engine/rendering/print/font-normalization.js";
|
|
47
|
+
import { createFontShaper as ye } from "../../spreadsheet-engine/rendering/print/font-shaping.js";
|
|
48
|
+
var f2 = 72 / 96;
|
|
49
|
+
function Lt(D, q) {
|
|
50
|
+
let r = D.view?.gnumeric;
|
|
51
|
+
return !!Number(D.view?.[q] ?? (r && typeof r == "object" && !Array.isArray(r) ? r[q.charAt(0).toUpperCase() + q.slice(1)] ?? 0 : 0));
|
|
52
|
+
}
|
|
53
|
+
function te(D) {
|
|
54
|
+
let q = D.style;
|
|
55
|
+
if (!q) return;
|
|
56
|
+
let r = q.gnumeric;
|
|
57
|
+
if (!(Object.keys(q).length === 1 && Object.hasOwn(q, "gnumeric") && r && typeof r == "object" && !Array.isArray(r) && r.name === "Style" && r.namespace === "http://www.gnumeric.org/v10.dtd" && typeof r.text == "string" && r.text.trim() === "" && Array.isArray(r.children) && r.children.length === 0 && Array.isArray(r.attributes) && r.attributes.every((at) => at && typeof at == "object" && at.namespace === "" && at.name === "Format" && typeof at.value == "string"))) {
|
|
58
|
+
if (Object.keys(q).length === 2 && Object.hasOwn(q, "xlsx") && Object.hasOwn(q, "gnumeric") && r && typeof r == "object" && !Array.isArray(r) && Array.isArray(r.attributes)) {
|
|
59
|
+
let I = r.attributes.some((st) => st && typeof st == "object" && st.name === "Format") ? r.attributes.map((st) => st && typeof st == "object" && st.name === "Format" ? { ...st, value: "General" } : st) : [...r.attributes, { name: "Format", namespace: "", value: "General" }];
|
|
60
|
+
return { gnumeric: { ...r, attributes: I } };
|
|
61
|
+
}
|
|
62
|
+
return Object.keys(q).length === 1 && Object.hasOwn(q, "gnumeric") && r && typeof r == "object" && !Array.isArray(r) && Array.isArray(r.attributes) && r.attributes.some((I) => I && typeof I == "object" && I.name === "Format" && I.value !== "General") ? { gnumeric: { ...r, attributes: r.attributes.map((I) => I && typeof I == "object" && I.name === "Format" ? { ...I, value: "General" } : I) } } : q;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var $t = { iso_a4: [15120 / 25.4, 297 * 72 / 25.4], na_letter: [612, 792], na_legal: [612, 1008], iso_a3: [297 * 72 / 25.4, 420 * 72 / 25.4], iso_a5: [10656 / 25.4, 15120 / 25.4], iso_b5: [12672 / 25.4, 18e3 / 25.4], na_ledger: [1224, 792], na_executive: [522, 756] };
|
|
66
|
+
function Ae(D) {
|
|
67
|
+
let r = { a4: "iso_a4", a3: "iso_a3", a5: "iso_a5", b5: "iso_b5", usletter: "na_letter", "us-letter": "na_letter", letter: "na_letter", uslegal: "na_legal" }[D.toLowerCase()];
|
|
68
|
+
if (r) return r;
|
|
69
|
+
if (D.toLowerCase().startsWith("executive")) return "na_executive";
|
|
70
|
+
for (let at of ["iso_a3", "iso_a4", "iso_a5", "iso_b5", "na_letter", "na_legal", "na_executive"]) if (D.startsWith(`${at}_`)) return at;
|
|
71
|
+
return D;
|
|
72
|
+
}
|
|
73
|
+
function v(D) {
|
|
74
|
+
throw new e("unsupported-feature", `Unsupported ssconvert feature: PDF ${D}`);
|
|
75
|
+
}
|
|
76
|
+
function Oe(D, q, r) {
|
|
77
|
+
let at, I = false, st, Ot, e2, lt, J = [], Ht = [], Wt = 0;
|
|
78
|
+
for (let Jt of q) for (let [rt, E] of p(Jt)) {
|
|
79
|
+
if (r.signal.throwIfAborted(), ++Wt > (r.limits.workbookWork ?? r.limits.inputBytes)) throw new e("resource-limit", "ssconvert PDF option work limit exceeded");
|
|
80
|
+
if (rt === "object") {
|
|
81
|
+
let S = false;
|
|
82
|
+
for (let ct of D.sheets) for (let Pt of [...a2(ct, r)].reverse()) if (Pt.name === E && (J.push({ sheet: ct, object: Pt }), S = true), ++Wt > (r.limits.workbookWork ?? r.limits.inputBytes)) throw new e("resource-limit", "ssconvert PDF option work limit exceeded");
|
|
83
|
+
if (!S) throw new e("invalid-request", `ssconvert: There is no object with name '${E}'`);
|
|
84
|
+
} else if (rt === "paper") if (E === "fit") I = true;
|
|
85
|
+
else {
|
|
86
|
+
let S = E.toLowerCase(), ct = S.endsWith("-landscape") ? "-landscape" : S.endsWith("_landscape") ? "_landscape" : S === "a4l" || S === "a3l" || S === "a5l" || S === "letterl" ? "l" : "", Pt = ct ? E.slice(0, -ct.length) : E;
|
|
87
|
+
ct && !st && (st = "landscape");
|
|
88
|
+
let Et = Ae(Pt);
|
|
89
|
+
if (!Object.hasOwn($t, Et)) {
|
|
90
|
+
if (E === "") throw new e("invalid-request", "ssconvert: Unknown paper size");
|
|
91
|
+
v("unqualified named-paper warning profile");
|
|
92
|
+
}
|
|
93
|
+
at = $t[Et];
|
|
94
|
+
}
|
|
95
|
+
else if (rt === "orientation") {
|
|
96
|
+
let S = E.toLowerCase();
|
|
97
|
+
if (S !== "portrait" && S !== "landscape" && S !== "reverse-portrait" && S !== "reverse-landscape") throw new e("invalid-request", `ssconvert: Invalid orientation "${E}" for format Gnumeric_pdf:pdf_assistant`);
|
|
98
|
+
st = S;
|
|
99
|
+
} else if (rt === "fit-width" || rt === "fit_width" || rt === "fit-to-pages-wide") {
|
|
100
|
+
let S = Number.parseInt(E, 10);
|
|
101
|
+
if (!Number.isSafeInteger(S) || S < 0 || String(S) !== E.trim()) throw new e("invalid-request", `ssconvert: Invalid fit-width "${E}" for format Gnumeric_pdf:pdf_assistant`);
|
|
102
|
+
Ot = S;
|
|
103
|
+
} else if (rt === "fit-height" || rt === "fit_height" || rt === "fit-to-pages-tall") {
|
|
104
|
+
let S = Number.parseInt(E, 10);
|
|
105
|
+
if (!Number.isSafeInteger(S) || S < 0 || String(S) !== E.trim()) throw new e("invalid-request", `ssconvert: Invalid fit-height "${E}" for format Gnumeric_pdf:pdf_assistant`);
|
|
106
|
+
e2 = S;
|
|
107
|
+
} else if (rt === "scale") {
|
|
108
|
+
let S = Number(E);
|
|
109
|
+
if (!Number.isFinite(S) || S <= 0) throw new e("invalid-request", `ssconvert: Invalid scale "${E}" for format Gnumeric_pdf:pdf_assistant`);
|
|
110
|
+
lt = S;
|
|
111
|
+
} else if (rt === "sheet" || rt === "active-sheet") {
|
|
112
|
+
let S = rt === "active-sheet" ? D.sheets.find((ct) => ct.id === D.activeSheet) ?? D.sheets[0] : D.sheets.find((ct) => f(ct.name) === f(E));
|
|
113
|
+
if (!S) throw new e("invalid-request", `ssconvert: Unknown sheet "${E}"`);
|
|
114
|
+
Ht.push(S.id);
|
|
115
|
+
} else throw new e("invalid-request", `ssconvert: Invalid export option "${rt}" for format Gnumeric_pdf:pdf_assistant`);
|
|
116
|
+
}
|
|
117
|
+
return { paper: at, fit: I, orientation: st, scale: Ot !== void 0 || e2 !== void 0 ? { kind: "fit", rows: e2 ?? 0, columns: Ot ?? 0 } : lt !== void 0 ? { kind: "percentage", x: lt, y: lt } : void 0, objects: J, sheets: Ht };
|
|
118
|
+
}
|
|
119
|
+
async function Un(D, q, r) {
|
|
120
|
+
return r && Oe(r, D, q), D;
|
|
121
|
+
}
|
|
122
|
+
async function Yn(D, q, r, at) {
|
|
123
|
+
let I = Oe(D, q, r), st = r.formatting ?? t(), Ot = 0, e2 = (J = 1) => {
|
|
124
|
+
if (r.signal.throwIfAborted(), Ot += J, !Number.isSafeInteger(Ot) || Ot > (r.limits.workbookWork ?? r.limits.inputBytes + r.limits.cells * 32)) throw new e("resource-limit", "ssconvert PDF work limit exceeded");
|
|
125
|
+
};
|
|
126
|
+
e2();
|
|
127
|
+
let lt = ye(r, e2);
|
|
128
|
+
try {
|
|
129
|
+
let J = await Ee.create({ updateMetadata: false });
|
|
130
|
+
J.setProducer("ssconvert JavaScript PDF writer");
|
|
131
|
+
let Ht = /* @__PURE__ */ new Map(), Wt = 0, qt = async (n2, p3, b) => {
|
|
132
|
+
let O = JSON.stringify([n2, p3, b]), s = Ht.get(O);
|
|
133
|
+
if (!s) {
|
|
134
|
+
J.registerFontkit(Me);
|
|
135
|
+
let o2;
|
|
136
|
+
if (r.fonts) {
|
|
137
|
+
let t2 = await r.fonts.resolve(Object.freeze({ family: n2, bold: p3, italic: b, maxBytes: r.limits.inputBytes - Wt, signal: r.signal }));
|
|
138
|
+
if (e2(), t2 === void 0 && v("supplied font unavailable"), t2 instanceof Uint8Array || v("supplied font bytes"), t2.byteLength > r.limits.inputBytes - Wt) throw new e("resource-limit", "ssconvert PDF font bytes limit exceeded");
|
|
139
|
+
Wt += t2.byteLength, e2(t2.byteLength), o2 = new Uint8Array(t2), Ze(o2, (d) => v(`supplied font: ${d}`), e2);
|
|
140
|
+
} else o2 = Ve((t2) => e2(t2)).bytes;
|
|
141
|
+
try {
|
|
142
|
+
let t2 = Me.create(o2);
|
|
143
|
+
(!Number.isFinite(t2.unitsPerEm) || t2.unitsPerEm <= 0 || !Number.isFinite(t2.ascent) || t2.ascent <= 0 || !Number.isFinite(t2.descent) || t2.descent > 0) && v("supplied font metrics"), await lt.addFont(o2, t2), J.registerFontkit({ create: () => t2 });
|
|
144
|
+
let d = await J.embedFont(o2, { subset: true }), a3 = t2.head, _ = t2["OS/2"], G = b && !a3?.macStyle?.italic && !_?.fsSelection?.italic && !_?.fsSelection?.oblique ? 0.2 : 0;
|
|
145
|
+
s = { font: d, metrics: t2, shear: G, bytes: o2, shaped: true, supported: new Set(d.getCharacterSet()), ascentRatio: t2.ascent / t2.unitsPerEm, descentRatio: -t2.descent / t2.unitsPerEm }, Ht.set(O, s);
|
|
146
|
+
} catch (t2) {
|
|
147
|
+
if (r.signal.throwIfAborted(), t2 instanceof e) throw t2;
|
|
148
|
+
v("supplied font parsing");
|
|
149
|
+
}
|
|
150
|
+
e2();
|
|
151
|
+
}
|
|
152
|
+
return s;
|
|
153
|
+
}, Jt = async (n2, p3, b, O, s = 10, o2 = "left", t2) => {
|
|
154
|
+
if (e2(p3.length), !p3) return;
|
|
155
|
+
let d = t2?.style.bold ?? false, a3 = t2?.style.italic ?? false, _ = t2?.style.family ?? "Sans", G = await qt(_, d, a3), { font: Z, metrics: F, shear: w, supported: L, ascentRatio: tt, descentRatio: mt } = G, k = t2?.style.rotation ?? 0, c = b, j = O;
|
|
156
|
+
if (t2?.generalNumber !== void 0 && !k) {
|
|
157
|
+
let X = await qt("Sans", false, false), i = (Math.ceil(X.ascentRatio * 10 / f2) + Math.ceil(X.descentRatio * 10 / f2) + 1) / 12.75, u = Math.max(0, Math.floor(t2.width * i * (t2.zoom ?? 1) + 0.5) - 5), g = (h) => {
|
|
158
|
+
let M = 0;
|
|
159
|
+
for (let P of lt.shape(F, h).positions) e2(), M += Math.round(P.xAdvance * t2.style.size / F.unitsPerEm);
|
|
160
|
+
return M;
|
|
161
|
+
};
|
|
162
|
+
p3 = await st.format({ kind: "number", value: t2.generalNumber }, "General", r, { unicodeMinus: true, generalLayout: { width: u, measure: g } });
|
|
163
|
+
}
|
|
164
|
+
t2?.style.alignment === "fill" && t2.fillString && p3.includes(`
|
|
165
|
+
`) && (p3 = en(p3, lt.shape(F, p3).direction === "rtl", e2));
|
|
166
|
+
let gt = t2?.style.alignment === "fill", wt = gt && p3.includes(" "), l = gt && (p3.includes("\u2028") || p3.includes("\r")), W = wt || l, dt = l && p3.split("\u2028").join("").split("\u2029").join("").split("\r").join("") === "", Ft = t2 && !gt ? tn(p3, e2) : [{ text: p3, forced: false }], ht = Ft.map((X) => t2 ? Kt(X.text, L, e2) : X.text);
|
|
167
|
+
for (let X of ht) for (let i of X) e2(), !(gt && (i === "\u2029" || i === "\u2028" || i === "\r" || i === " ")) && !L.has(i.codePointAt(0)) && v("font coverage");
|
|
168
|
+
let ot = n2.getHeight() - O - s, ut = t2 ? 0 : Z.widthOfTextAtSize(p3, s);
|
|
169
|
+
if (t2) {
|
|
170
|
+
if (!G.shaped) try {
|
|
171
|
+
await lt.addFont(G.bytes, F), G.shaped = true;
|
|
172
|
+
} catch (m) {
|
|
173
|
+
if (r.signal.throwIfAborted(), m instanceof e) throw m;
|
|
174
|
+
v("supplied font parsing");
|
|
175
|
+
}
|
|
176
|
+
let X = tt * s, i = X + mt * s, u = 0, g = 0;
|
|
177
|
+
if (wt) {
|
|
178
|
+
L.has(32) || v("font coverage");
|
|
179
|
+
for (let m of lt.shape(F, " ").positions) {
|
|
180
|
+
e2();
|
|
181
|
+
let R = m.xAdvance * t2.style.size / F.unitsPerEm;
|
|
182
|
+
u += Math.round(R) * f2 * 8, g += Math.round(R / f2) * f2 * 8;
|
|
183
|
+
}
|
|
184
|
+
(!(u > 0) || !Number.isFinite(u) || !(g > 0) || !Number.isFinite(g)) && v("supplied font advances");
|
|
185
|
+
}
|
|
186
|
+
let h;
|
|
187
|
+
if (l) {
|
|
188
|
+
let m = await qt("monospace", d, a3), R = Math.round(t2.style.size / 2.2 * 1024) / 1024, A = 0, z = 0;
|
|
189
|
+
for (let ft of "0123456789ABCDEF") {
|
|
190
|
+
e2(), m.supported.has(ft.codePointAt(0)) || v("font coverage");
|
|
191
|
+
let pt = m.metrics.glyphForCodePoint(ft.codePointAt(0)).bbox;
|
|
192
|
+
A = Math.max(A, (pt.maxX - pt.minX) / m.metrics.unitsPerEm * R), z = Math.max(z, (pt.maxY - pt.minY) / m.metrics.unitsPerEm * R);
|
|
193
|
+
}
|
|
194
|
+
let y = Math.min((tt + mt) * t2.style.size / 43, R), nt = 5 * y + 2 * z, K = tt * t2.style.size, it = mt * t2.style.size, x = nt <= K ? 2 * y : nt <= K + it - 2 * y ? 2 * y + nt - K : it * nt / (K + it);
|
|
195
|
+
dt && (X = Math.trunc((nt + y - x) * 1024) / 1024 * f2, i = Math.trunc((nt + 2 * y) * 1024) / 1024 * f2);
|
|
196
|
+
let T = Math.trunc((7 * y + 2 * A) * 1024) / 1024, Q = Math.round(T) * f2, C = Q * 0.6, Y = Math.min(A * f2, C * 0.75), N = y * f2 / 2, Mt = 5 * N, It = C - Y / 2, H = Q * 0.2, V = ((5 * y + 2 * z) * f2 - C) / 2, $ = (5 * y + 2 * A) * f2, bt = Math.floor((Q - $) / (2 * y * f2)) * y * f2;
|
|
197
|
+
h = { width: Q, mini: m, miniSize: R * f2, frame: { x: bt + 3 * N, y: (-x + y / 2) * f2, width: $ - y * f2, height: (nt - y) * f2, stroke: y * f2 }, digits: [..."000D"].map((ft, pt) => ({ text: ft, x: bt + (3 * y + pt % 2 * (A + y)) * f2, y: (-x + 2 * y + (pt < 2 ? z + y : 0)) * f2 })), inkLeft: y * f2, inkRight: (6 * y + 2 * A) * f2, inkBottom: -x * f2, displayWidth: Math.round(T / f2) * f2, points: [[H, V], [H + Y, V + Mt], [H + Y, V + N], [H + C - N, V + N], [H + C - N, V + It], [H + C + N, V + It], [H + C + N, V - N], [H + Y, V - N], [H + Y, V - Mt]] };
|
|
198
|
+
}
|
|
199
|
+
let M = (m) => {
|
|
200
|
+
let R = [], A = [], z = 0, y = 0, nt = [], K = [], it = gt && lt.shape(F, m).direction === "rtl", x = it && wt, T = [], Q = [], C = gt ? m.split(" ") : [m];
|
|
201
|
+
for (let [N, Mt] of C.entries()) {
|
|
202
|
+
e2(), N > 0 && (z = Re(z, u), y = Re(y, g));
|
|
203
|
+
let It = z, H = T.length, V = gt ? nn(Mt, it, e2) : [Mt];
|
|
204
|
+
for (let $ of V) {
|
|
205
|
+
if (e2(), !$ || it && $.split("\u200B").join("") === "") continue;
|
|
206
|
+
if (($ === "\u2028" || $ === "\r") && h) {
|
|
207
|
+
let ft = { x: z, carriageReturn: $ === "\r" };
|
|
208
|
+
A.push(ft), x && T.push(ft), z += h.width, y += h.displayWidth;
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
let bt = lt.shape(F, $);
|
|
212
|
+
K.push(bt);
|
|
213
|
+
for (let ft of bt.positions) {
|
|
214
|
+
e2();
|
|
215
|
+
let pt = ft.xAdvance * t2.style.size / F.unitsPerEm;
|
|
216
|
+
(!Number.isFinite(pt) || pt < 0 || !Number.isFinite(ft.xOffset) || !Number.isFinite(ft.yOffset) || ft.yAdvance !== 0) && v("supplied font advances");
|
|
217
|
+
let le = { x: z + Math.round(ft.xOffset * t2.style.size / F.unitsPerEm) * f2, y: -Math.round(-ft.yOffset * t2.style.size / F.unitsPerEm) * f2 };
|
|
218
|
+
R.push(le), x && T.push(le), nt.push(Math.round(pt)), z += Math.round(pt) * f2, y += Math.round(pt / f2) * f2;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
x && Q.push({ start: It, end: z, first: H, last: T.length });
|
|
222
|
+
}
|
|
223
|
+
x && Be(T, Q, z, e2), K.length > 1 && K.some((N) => N.direction === "rtl") && !(it && K.every((N) => N.direction === "rtl")) && v("bidirectional fill layout");
|
|
224
|
+
let Y = K.length < 2 ? K[0] : Object.create(K[0], { glyphs: { value: K.flatMap((N) => N.glyphs) }, positions: { value: K.flatMap((N) => N.positions) } });
|
|
225
|
+
return { shapedValue: m, run: Y, glyphs: R, width: z, displayWidth: y, advances: nt, markers: A };
|
|
226
|
+
}, P = 0, vt = 0;
|
|
227
|
+
if (t2.style.indent && o2 !== "center" && t2.style.alignment !== "fill" && t2.style.alignment !== "justify" && t2.style.alignment !== "distributed") {
|
|
228
|
+
let m = 0, R = 0;
|
|
229
|
+
for (let A of "0123456789") {
|
|
230
|
+
e2(), L.has(A.codePointAt(0)) || v("font coverage");
|
|
231
|
+
let z = lt.shape(F, A), y = 0, nt = 0;
|
|
232
|
+
for (let K of z.positions) {
|
|
233
|
+
e2();
|
|
234
|
+
let it = K.xAdvance * t2.style.size / F.unitsPerEm;
|
|
235
|
+
(!Number.isFinite(it) || it < 0) && v("supplied font advances"), y += Math.round(it), nt += Math.round(it / f2);
|
|
236
|
+
}
|
|
237
|
+
m += Math.max(1, y), R += Math.max(1, nt);
|
|
238
|
+
}
|
|
239
|
+
P = Math.min(65535, Math.round(t2.style.indent * Math.floor((m * 1024 + 5) / 10) / 1024)) * f2, vt = Math.min(65535, Math.round(t2.style.indent * Math.floor((R * 1024 + 5) / 10) / 1024)) * f2;
|
|
240
|
+
}
|
|
241
|
+
let U = t2.style.borders?.some((m) => ["Top", "Bottom", "Left", "Right"].includes(m.side)) ?? false, kt = t2.style.alignment === "fill", yt;
|
|
242
|
+
if (kt) {
|
|
243
|
+
lt.shape(F, p3).direction === "rtl" && (o2 = "right"), ht.length !== 1 && v("fill control-character layout");
|
|
244
|
+
let m = M(ht[0]).width;
|
|
245
|
+
k && !U && (yt = oe({ angle: k, widths: [m], ascent: X, lineHeight: i, width: t2.width, height: t2.height, indent: 0, bordered: U, alignment: o2, vertical: t2.style.verticalAlignment }, e2));
|
|
246
|
+
let R = yt?.width ?? m, A = k && U ? 1 : R > 0 ? Math.floor((t2.width - 5) / R) : 1;
|
|
247
|
+
A >= 2 && (l && (X = tt * s), e2(A * (p3.length + 1)), L.has(8203) || v("font coverage"), ht[0] = Array.from({ length: A }, () => ht[0]).join("\u200B"), p3 = p3.repeat(A)), yt && o2 === "right" && (yt = oe({ angle: k, widths: [m], ascent: X, lineHeight: i, horizontalWidth: M(ht[0]).width, width: t2.width, height: t2.height, indent: 0, bordered: U, alignment: o2, vertical: t2.style.verticalAlignment }, e2));
|
|
248
|
+
}
|
|
249
|
+
let et = t2.wrap === true && (!k || U), zt = k ? Math.max(0, t2.width - 5 - P) * Math.cos(k * Math.PI / 180) + (t2.height - 1) * Math.abs(Math.sin(k * Math.PI / 180)) : Math.max(0, t2.width - 5 - P), Ct = (et ? Ft.flatMap((m) => He(m.text, zt, (R) => M(Kt(R, L, e2)).width, e2).map((R, A, z) => ({ ...R, justify: m.forced || A < z.length - 1 }))) : ht.map((m) => ({ text: m, hyphen: false, justify: false }))).map((m) => {
|
|
250
|
+
m.hyphen && !L.has(8208) && v("font coverage");
|
|
251
|
+
let R = m.hyphen && m.text.endsWith("\xAD") ? m.text.slice(0, -1) : m.text, A = Kt(R + (m.hyphen ? "\u2010" : ""), L, e2), z = m.text.split("\u200B").join("").split("\u2060").join(""), y = M(A);
|
|
252
|
+
if (m.justify && y.run && (t2.style.alignment === "justify" || t2.style.alignment === "distributed")) {
|
|
253
|
+
let nt = Le(A, y.run, y.advances, (zt - y.width) / f2, e2);
|
|
254
|
+
for (let [K, it] of y.glyphs.entries()) e2(), it.x += nt.offsets[K] * f2;
|
|
255
|
+
y.width += nt.added * f2;
|
|
256
|
+
}
|
|
257
|
+
return { ...y, logicalText: z, marked: m.hyphen || A !== z };
|
|
258
|
+
}), _t = i * Ct.length, Dt = 0;
|
|
259
|
+
for (let m of Ct) e2(), ut = Math.max(ut, m.width), Dt = Math.max(Dt, m.displayWidth);
|
|
260
|
+
let xt = ut + P > t2.width - 5;
|
|
261
|
+
(!k && xt && !kt && !et && t2.overflow === void 0 && t2.generalNumber === void 0 || !Number.isFinite(_t)) && v("default-style text layout");
|
|
262
|
+
let St = k ? void 0 : t2.overflow?.(Dt + vt), At = b + 4 - (St?.left ?? 0), jt = Math.max(0, t2.width + (St?.left ?? 0) + (St?.right ?? 0) - 4);
|
|
263
|
+
b += 2 + 0.5 + 3 * f2 + (o2 === "left" ? 0 : (t2.width - 5) / (o2 === "center" ? 2 : 1)), o2 === "center" && t2.style.alignment !== "distributed" && St && (St.left > 0 || St.right > 0) && (b += 2.5 + (f2 - 1) * (t2.width / 2 + St.left));
|
|
264
|
+
let Gt = Math.max(0, t2.height - 1 - _t), Zt = t2.style.verticalAlignment === "top" || t2.style.verticalAlignment === "justify" ? 0 : Gt / (t2.style.verticalAlignment === "center" || t2.style.verticalAlignment === "distributed" ? 2 : 1);
|
|
265
|
+
ot = n2.getHeight() - O - f2 - Zt - X, b -= o2 === "left" ? -P : o2 === "center" ? ut / 2 : ut + P;
|
|
266
|
+
let xe = t2.style.verticalAlignment === "justify" && Ct.length > 1 ? Math.floor(Gt / f2 * 1024 / (Ct.length - 1)) / 1024 * f2 : 0, ne = yt?.origins ?? (k ? oe({ angle: k, ...et ? { layoutWidth: zt } : {}, widths: Ct.map((m) => m.width), ascent: X, lineHeight: i, width: t2.width, height: t2.height, indent: P, bordered: U, alignment: o2, vertical: t2.style.verticalAlignment }, e2).origins : void 0);
|
|
267
|
+
if (t2.style.foregroundAlpha === 0) return;
|
|
268
|
+
let je = b, Te = ot, Ne = n2.node.newFontDictionary(Z.name, Z.ref);
|
|
269
|
+
if (n2.pushOperators(Nt()), t2.style.foregroundAlpha !== 1) {
|
|
270
|
+
let m = n2.node.newExtGState("CellAlpha", J.context.obj({ Type: "ExtGState", ca: t2.style.foregroundAlpha, CA: t2.style.foregroundAlpha }));
|
|
271
|
+
n2.pushOperators(Je(m));
|
|
272
|
+
}
|
|
273
|
+
!k && (xt || _t > t2.height - 1) && n2.pushOperators(Xt(At, n2.getHeight() - O - t2.height, jt, t2.height), Ut(), Yt()), !et && !k && !W && n2.pushOperators(Qt.of(Bt.BeginMarkedContentSequence, [be.of("Span"), J.context.obj({ ActualText: se.fromText(p3) }).toString()]));
|
|
274
|
+
for (let [m, R] of Ct.entries()) {
|
|
275
|
+
let { run: A, glyphs: z, shapedValue: y } = R;
|
|
276
|
+
if (!A && !R.markers.length) continue;
|
|
277
|
+
let nt = (ut - R.width) / 2;
|
|
278
|
+
if (b = je + (o2 === "left" ? 0 : o2 === "right" ? ut - R.width : et && !Number.isInteger((t2.width - 5) / f2) ? nt : Math.round(nt / f2) * f2), ot = Te - m * (i + xe), ne) {
|
|
279
|
+
let x = k * Math.PI / 180, T = ne[m];
|
|
280
|
+
n2.pushOperators(Nt(), ae(Math.cos(x), Math.sin(x), -Math.sin(x), Math.cos(x), c + 2.5 + T.x, n2.getHeight() - j - T.y)), b = 0, ot = 0;
|
|
281
|
+
}
|
|
282
|
+
(et || k) && R.marked && !W && n2.pushOperators(Qt.of(Bt.BeginMarkedContentSequence, [be.of("Span"), J.context.obj({ ActualText: se.fromText(R.logicalText) }).toString()]));
|
|
283
|
+
let K = F.layout, it = "";
|
|
284
|
+
try {
|
|
285
|
+
A && (F.layout = () => A, it = Z.encodeText(y).asString());
|
|
286
|
+
} finally {
|
|
287
|
+
F.layout = K;
|
|
288
|
+
}
|
|
289
|
+
it.length !== z.length * 4 && v("supplied font glyph mapping"), n2.pushOperators(we(), ke(Ne, s), qe(...t2.style.foreground));
|
|
290
|
+
for (let [x, T] of z.entries()) {
|
|
291
|
+
e2();
|
|
292
|
+
let Q = A.glyphs[x].codePoints;
|
|
293
|
+
if (W && !k && xt) {
|
|
294
|
+
let C = A.glyphs[x].bbox, Y = s / F.unitsPerEm, N = b + T.x + (C.minX + Math.min(w * C.minY, w * C.maxY)) * Y, Mt = b + T.x + (C.maxX + Math.max(w * C.minY, w * C.maxY)) * Y;
|
|
295
|
+
if (N >= At + jt || Mt <= At) continue;
|
|
296
|
+
}
|
|
297
|
+
W && Q.length > 0 && Q.every((C) => C === 8203) && A.positions[x].xAdvance === 0 || n2.pushOperators(Pe(1, 0, w, 1, b + T.x, ot + T.y), Se(se.of(it.slice(x * 4, x * 4 + 4))));
|
|
298
|
+
}
|
|
299
|
+
if (n2.pushOperators(ve()), (et || k) && R.marked && !W && n2.pushOperators(Qt.of(Bt.EndMarkedContent)), h) {
|
|
300
|
+
let x = R.markers.some((T) => T.carriageReturn) ? n2.node.newFontDictionary(h.mini.font.name, h.mini.font.ref) : void 0;
|
|
301
|
+
for (let T of R.markers) if (e2(h.points.length), T.carriageReturn) {
|
|
302
|
+
k || n2.pushOperators(Nt(), Xt(At, n2.getHeight() - O - t2.height, jt, t2.height), Ut(), Yt());
|
|
303
|
+
let Q = h.frame;
|
|
304
|
+
n2.drawRectangle({ x: b + T.x + Q.x, y: ot + Q.y, width: Q.width, height: Q.height, borderWidth: Q.stroke, borderColor: Tt(...t2.style.foreground) }), n2.pushOperators(we(), ke(x, h.miniSize));
|
|
305
|
+
for (let C of h.digits) e2(), n2.pushOperators(Pe(1, 0, h.mini.shear, 1, b + T.x + C.x, ot + C.y), Se(h.mini.font.encodeText(C.text)));
|
|
306
|
+
n2.pushOperators(ve()), k || n2.pushOperators(Rt());
|
|
307
|
+
} else n2.pushOperators(...h.points.map(([Q, C], Y) => (Y ? Xe : Ge)(b + T.x + Q, ot + C)), Ue(), Ye());
|
|
308
|
+
}
|
|
309
|
+
if (t2.style.underline || t2.style.strikeThrough) {
|
|
310
|
+
let x = s / F.unitsPerEm, T = F.underlineThickness ? F.underlineThickness * x : f2, Q = F.underlinePosition ? F.underlinePosition * x : -f2, C = 1 / 0, Y = -1 / 0, N = 1 / 0;
|
|
311
|
+
for (let [H, V] of (A?.glyphs ?? []).entries()) {
|
|
312
|
+
e2();
|
|
313
|
+
let $ = V.bbox, bt = z[H];
|
|
314
|
+
Number.isFinite($.minX) && (C = Math.min(C, bt.x + ($.minX + w * $.minY) * x), Y = Math.max(Y, bt.x + ($.maxX + w * $.maxY) * x), N = Math.min(N, bt.y + $.minY * x));
|
|
315
|
+
}
|
|
316
|
+
if (h) for (let { x: H } of R.markers) e2(), C = Math.min(C, H + h.inkLeft), Y = Math.max(Y, H + h.inkRight), N = Math.min(N, h.inkBottom);
|
|
317
|
+
let Mt = t2.style.underline === 3, It = ot + (Mt ? Math.min(0, N) - 2 * T : Q - T);
|
|
318
|
+
Mt && !k && n2.pushOperators(Xt(At, n2.getHeight() - O - t2.height, jt, t2.height), Ut(), Yt());
|
|
319
|
+
for (let H = 0; H < (t2.style.underline === 0 ? 0 : t2.style.underline === 2 || t2.style.underline === 4 ? 2 : 1); H++) {
|
|
320
|
+
e2();
|
|
321
|
+
let V = It - H * 2 * T, $ = h && !k ? Math.max(V, n2.getHeight() - O - t2.height) : V, bt = h && !k ? Math.min(V + T, n2.getHeight() - O) : V + T;
|
|
322
|
+
bt <= $ || n2.drawRectangle({ x: b + Math.min(0, C), y: $, width: Math.max(R.width, Number.isFinite(Y - C) ? Y - C : 0), height: bt - $, color: Tt(...t2.style.foreground) });
|
|
323
|
+
}
|
|
324
|
+
if (t2.style.strikeThrough && Number.isFinite(Y - C)) {
|
|
325
|
+
let H = F["OS/2"], V = H?.yStrikeoutSize ? H.yStrikeoutSize * x : f2, $ = H?.yStrikeoutPosition ? H.yStrikeoutPosition * x : X / 2;
|
|
326
|
+
e2(), n2.drawRectangle({ x: b + C, y: ot + $ - V, width: dt ? Y : Y - C, height: V, color: Tt(...t2.style.foreground) });
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
ne && n2.pushOperators(Rt());
|
|
330
|
+
}
|
|
331
|
+
!et && !k && !W && n2.pushOperators(Qt.of(Bt.EndMarkedContent)), n2.pushOperators(Rt());
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
n2.drawText(p3, { x: b - (o2 === "left" ? 0 : ut / (o2 === "center" ? 2 : 1)), y: ot, size: s, font: Z });
|
|
335
|
+
}, rt = /* @__PURE__ */ new WeakMap(), E = (n2) => {
|
|
336
|
+
if (n2.columns?.length || n2.view?.defaultColumnWidth !== void 0) return n2.columns;
|
|
337
|
+
let p3 = /\.(?:csv|tsv)$/i.test(n2.name) || /\.(?:csv|tsv)$/i.test(r.inputFilename ?? ""), b = (!n2.columns || n2.columns.length === 0) && n2.view?.defaultColumnWidth === void 0 && n2.cells.every((d) => te(d) === void 0) && n2.cells.some((d) => {
|
|
338
|
+
let a3 = d.displayedText ?? (d.value.kind === "blank" ? "" : String(d.value.value));
|
|
339
|
+
return a3.length >= 9 && ![`
|
|
340
|
+
`, "\r", "\u2028", "\u2029"].some((_) => a3.includes(_));
|
|
341
|
+
});
|
|
342
|
+
if (!p3 && !b) return n2.columns;
|
|
343
|
+
let O = new Map((n2.columns ?? []).map((d) => [d.index, d])), s = typeof n2.view?.defaultColumnWidth == "number" ? n2.view.defaultColumnWidth : 48, o2 = /* @__PURE__ */ new Map();
|
|
344
|
+
for (let d of n2.cells) {
|
|
345
|
+
let a3 = Lt(n2, "displayFormulas") && d.formula ? rt.get(d) ?? d.formula : d.displayedText ?? (d.value.kind === "blank" ? "" : d.value.kind === "boolean" ? d.value.value ? "TRUE" : "FALSE" : String(d.value.value));
|
|
346
|
+
if (!a3 || [`
|
|
347
|
+
`, "\r", "\u2028", "\u2029"].some((Z) => a3.includes(Z))) continue;
|
|
348
|
+
let _ = Math.max(s, a3.length * 6 + 14), G = o2.get(d.column) ?? s;
|
|
349
|
+
_ > G && o2.set(d.column, _);
|
|
350
|
+
}
|
|
351
|
+
for (let [d, a3] of O) {
|
|
352
|
+
let _ = o2.get(d) ?? s;
|
|
353
|
+
o2.set(d, Math.max(_, a3.sizePoints ?? s));
|
|
354
|
+
}
|
|
355
|
+
let t2 = [...o2.entries()].filter(([d, a3]) => a3 > s || O.has(d)).sort((d, a3) => d[0] - a3[0]).map(([d, a3]) => ({ ...O.get(d), index: d, sizePoints: a3 }));
|
|
356
|
+
return t2.length ? t2 : n2.columns;
|
|
357
|
+
}, S = (n2) => {
|
|
358
|
+
let p3 = (b, O, s = 1) => (o2) => {
|
|
359
|
+
let t2 = o2 * O, d = O;
|
|
360
|
+
for (let a3 of b ?? []) e2(), a3.index < o2 && (t2 += (a3.hidden ? 0 : a3.sizePoints ?? O) - O), a3.index === o2 && (d = a3.hidden ? 0 : a3.sizePoints ?? O);
|
|
361
|
+
return { start: t2 * s, size: d * s };
|
|
362
|
+
};
|
|
363
|
+
return { column: p3(E(n2), typeof n2.view?.defaultColumnWidth == "number" ? n2.view.defaultColumnWidth : 48, Lt(n2, "displayFormulas") ? 2 : 1), row: p3(n2.rows, typeof n2.view?.defaultRowHeight == "number" ? n2.view.defaultRowHeight : 12.75) };
|
|
364
|
+
}, ct = async (n2, p3, b, O, s, o2) => {
|
|
365
|
+
if (e2(), p3.kind === "graph") {
|
|
366
|
+
let t2 = pe(p3.graph);
|
|
367
|
+
t2 && n2.drawRectangle({ x: b, y: n2.getHeight() - O - o2, width: s, height: o2, color: Tt(...[1, 3, 5].map((d) => Number.parseInt(t2.slice(d, d + 2), 16) / 255)) });
|
|
368
|
+
} else if (p3.kind === "image") {
|
|
369
|
+
let t2 = p3.payload.children.find((w) => w.name === "Content" && w.namespace === "");
|
|
370
|
+
t2 || v("image payload");
|
|
371
|
+
let d = t2.text.split(" ").join("").split(`
|
|
372
|
+
`).join("").split("\r").join("").split(" ").join("");
|
|
373
|
+
e2(d.length);
|
|
374
|
+
let a3;
|
|
375
|
+
try {
|
|
376
|
+
let w = atob(d);
|
|
377
|
+
a3 = new Uint8Array(w.length);
|
|
378
|
+
for (let L = 0; L < w.length; L++) a3[L] = w.charCodeAt(L);
|
|
379
|
+
} catch {
|
|
380
|
+
return v("image encoding");
|
|
381
|
+
}
|
|
382
|
+
e2();
|
|
383
|
+
let _ = new DataView(a3.buffer, a3.byteOffset, a3.byteLength), G = 0, Z = 0, F = a3[0] === 137;
|
|
384
|
+
if (F) (a3.length < 33 || ![137, 80, 78, 71, 13, 10, 26, 10].every((w, L) => a3[L] === w) || _.getUint32(8) !== 13 || _.getUint32(12) !== 1229472850) && v("PNG header"), G = _.getUint32(16), Z = _.getUint32(20);
|
|
385
|
+
else if (a3[0] === 255 && a3[1] === 216) {
|
|
386
|
+
let w = 2;
|
|
387
|
+
for (; w + 4 <= a3.length; ) {
|
|
388
|
+
e2(), a3[w] !== 255 && v("JPEG header");
|
|
389
|
+
let L = a3[w + 1], tt = _.getUint16(w + 2);
|
|
390
|
+
if ((tt < 2 || w + 2 + tt > a3.length) && v("JPEG header"), [192, 193, 194].includes(L)) {
|
|
391
|
+
tt < 8 && v("JPEG dimensions"), Z = _.getUint16(w + 5), G = _.getUint16(w + 7);
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
w += tt + 2;
|
|
395
|
+
}
|
|
396
|
+
} else v("image format");
|
|
397
|
+
if ((!G || !Z) && v("image dimensions"), e2(G * Z * 16), F) {
|
|
398
|
+
let w;
|
|
399
|
+
try {
|
|
400
|
+
w = Qe(a3, e2);
|
|
401
|
+
} catch (k) {
|
|
402
|
+
if (!(k instanceof Ce)) throw k;
|
|
403
|
+
if (k.code === "E_LIMIT") throw new e("resource-limit", "ssconvert PDF PNG decoding limit exceeded");
|
|
404
|
+
return v("PNG decoding");
|
|
405
|
+
}
|
|
406
|
+
let L = w.alpha === void 0 ? void 0 : J.context.register(J.context.flateStream(w.alpha, { Type: "XObject", Subtype: "Image", Width: G, Height: Z, BitsPerComponent: 8, ColorSpace: "DeviceGray" })), tt = J.context.register(J.context.flateStream(w.rgb, { Type: "XObject", Subtype: "Image", Width: G, Height: Z, BitsPerComponent: 8, ColorSpace: "DeviceRGB", SMask: L })), mt = n2.node.newXObject("Image", tt);
|
|
407
|
+
n2.pushOperators(Nt(), ae(s, 0, 0, o2, b, n2.getHeight() - O - o2), $e(mt), Rt());
|
|
408
|
+
} else {
|
|
409
|
+
let w = await J.embedJpg(a3);
|
|
410
|
+
e2(), (w.width !== G || w.height !== Z) && v("image dimension mismatch"), n2.drawImage(w, { x: b, y: n2.getHeight() - O - o2, width: s, height: o2 });
|
|
411
|
+
}
|
|
412
|
+
} else v(`object ${p3.sourceType}`);
|
|
413
|
+
}, Pt = I.objects[0], Et = (n2, p3) => (p3.anchor.mode !== "2" && p3.anchor.mode !== "absolute" && (n2.rows?.some((b) => b.hidden) || n2.columns?.some((b) => b.hidden)) && v("hidden-axis object placement"), p2(p3, S(n2), r));
|
|
414
|
+
if (Pt) {
|
|
415
|
+
let n2 = Et(Pt.sheet, Pt.object), p3 = I.fit && Pt.object.kind === "graph", b = p3 ? [Math.max(1, Math.abs(n2.width)), Math.max(1, Math.abs(n2.height))] : I.paper ?? $t.iso_a4;
|
|
416
|
+
e2();
|
|
417
|
+
let O = J.addPage([b[0], b[1]]);
|
|
418
|
+
await ct(O, Pt.object, p3 ? 0 : 72, p3 ? 0 : 72, Math.abs(n2.width), Math.abs(n2.height));
|
|
419
|
+
} else {
|
|
420
|
+
let n2 = I.sheets.length ? I.sheets : at?.sheets, p3 = [], b = 0, O = 1;
|
|
421
|
+
for (let s of D.sheets) {
|
|
422
|
+
if (e2(), n2 && !n2.includes(s.id) || s.visibility && s.visibility !== "visible") continue;
|
|
423
|
+
let o2 = ge(s, r);
|
|
424
|
+
if (!n2 && o2.doNotPrint) continue;
|
|
425
|
+
s.cells.some((l) => l.richText) && v("styled or merged cells");
|
|
426
|
+
let t2 = Ie(s.merges ?? [], e2), d = /* @__PURE__ */ new Map(), a3 = _e(s, t2, e2), _ = s.cells.filter((l) => {
|
|
427
|
+
let W = t2(l.row).find((dt) => (e2(), dt.startColumn <= l.column && dt.endColumn >= l.column));
|
|
428
|
+
return W ? l.row !== W.startRow || l.column !== W.startColumn ? false : (d.set(l, W), true) : true;
|
|
429
|
+
}), G = Lt(s, "displayFormulas"), Z = /* @__PURE__ */ new Map();
|
|
430
|
+
if (G) for (let l of s.formulaGroups ?? []) {
|
|
431
|
+
if (e2(), l.kind !== "array") continue;
|
|
432
|
+
let W = Fe(D, s, { row: l.range.startRow, column: l.range.startColumn, formula: l.expression, arrayStringLiterals: l.arrayStringLiterals ?? false }, r, e2);
|
|
433
|
+
W !== void 0 && Z.set(l.id, "{" + W + "}");
|
|
434
|
+
}
|
|
435
|
+
for (let l of s.cells) {
|
|
436
|
+
if (G) {
|
|
437
|
+
let dt = (l.formulaGroup ? Z.get(l.formulaGroup) : void 0) ?? Fe(D, s, l, r, e2);
|
|
438
|
+
dt !== void 0 && rt.set(l, dt);
|
|
439
|
+
}
|
|
440
|
+
let W = te(l);
|
|
441
|
+
W && (e2(), r.fonts || v("styled or merged cells"), Vt(W, e2));
|
|
442
|
+
}
|
|
443
|
+
let F = o2.paper === void 0 ? void 0 : $t[Ae(o2.paper)];
|
|
444
|
+
I.paper === void 0 && o2.paper !== void 0 && F === void 0 && v("persisted paper size");
|
|
445
|
+
let w = S(s), L = I.paper ?? F ?? $t.iso_a4, tt = a2(s, r).map((l) => ({ object: l, rectangle: Et(s, l) })), mt = /* @__PURE__ */ new Set(), k = /* @__PURE__ */ new Set();
|
|
446
|
+
for (let l of s.rows ?? []) e2(), l.hidden && mt.add(l.index);
|
|
447
|
+
for (let l of s.columns ?? []) e2(), l.hidden && k.add(l.index);
|
|
448
|
+
let c = a({ ...s, cells: _.filter((l) => (e2(), l.value.kind !== "blank" && !mt.has(l.row) && !k.has(l.column))) });
|
|
449
|
+
for (let [l, W] of d) e2(), !(l.value.kind === "blank" || mt.has(l.row) || k.has(l.column)) && (c = { ...c, endRow: Math.max(c.endRow, W.endRow), endColumn: Math.max(c.endColumn, W.endColumn) });
|
|
450
|
+
for (let { rectangle: l } of tt) {
|
|
451
|
+
e2(), (l.width < 0 || l.height < 0 || l.x < 0 || l.y < 0) && v("mirrored or negative workbook object placement");
|
|
452
|
+
let W = (ht, ot) => {
|
|
453
|
+
let ut = 0;
|
|
454
|
+
for (; ; ) {
|
|
455
|
+
e2();
|
|
456
|
+
let X = w[ht](ut);
|
|
457
|
+
if (X.start + X.size >= ot) return ut;
|
|
458
|
+
ut++;
|
|
459
|
+
}
|
|
460
|
+
}, dt = W("row", l.y + l.height), Ft = W("column", l.x + l.width);
|
|
461
|
+
c = { startRow: 0, startColumn: 0, endRow: Math.max(c.endRow, dt), endColumn: Math.max(c.endColumn, Ft) };
|
|
462
|
+
}
|
|
463
|
+
let j = c.endRow < c.startRow || c.endColumn < c.startColumn;
|
|
464
|
+
j && (c = { startRow: 0, startColumn: 0, endRow: 0, endColumn: 0 });
|
|
465
|
+
let gt = o2.firstPageNumber ?? O, wt = o({ area: c, startPage: gt, defaultRowPoints: typeof s.view?.defaultRowHeight == "number" ? s.view.defaultRowHeight : 12.75, defaultColumnPoints: typeof s.view?.defaultColumnWidth == "number" ? s.view.defaultColumnWidth : 48, ...s.rows ? { rows: s.rows } : {}, ...E(s) ? { columns: E(s) } : {}, paper: { widthPoints: L[0], heightPoints: L[1] }, margins: o2.margins, displayFormulas: Lt(s, "displayFormulas"), rowBreaks: o2.rowBreaks, columnBreaks: o2.columnBreaks, orientation: I.orientation ?? o2.orientation, scale: I.scale ?? o2.scale, centerHorizontally: o2.centerHorizontally, centerVertically: o2.centerVertically, acrossThenDown: o2.acrossThenDown }, r);
|
|
466
|
+
if (e2(wt.pages.length), O = gt + wt.pages.length, b += wt.pages.length, !Number.isSafeInteger(b)) throw new e("resource-limit", "ssconvert PDF page count limit exceeded");
|
|
467
|
+
p3.push({ sheet: s, print: o2, positions: w, objects: tt, layout: wt, hiddenRows: mt, hiddenColumns: k, cells: j ? _.filter((l) => (e2(), !mt.has(l.row))) : _, mergedCells: d, blankCells: a3 });
|
|
468
|
+
}
|
|
469
|
+
for (let { sheet: s, print: o2, positions: t2, objects: d, layout: a3, hiddenRows: _, hiddenColumns: G, cells: Z, mergedCells: F, blankCells: w } of p3) {
|
|
470
|
+
let L = /* @__PURE__ */ new Map();
|
|
471
|
+
for (let c of s.cells) e2(), L.set(`${c.row}:${c.column}`, c);
|
|
472
|
+
let tt = rn({ ...s, cells: Z }, t2.column, e2), mt = Lt(s, "displayFormulas"), k = Lt(s, "hideZero");
|
|
473
|
+
for (let c of a3.pages) {
|
|
474
|
+
e2();
|
|
475
|
+
let j = J.addPage([a3.widthPoints, a3.heightPoints]), gt = { page: c.number, pages: b, sheetName: s.name, filename: r.inputFilename ?? "", path: "", title: "" };
|
|
476
|
+
for (let [i, u, g] of [[o2.header, o2.headerPoints, o2.margins.top > o2.headerPoints], [o2.footer, a3.heightPoints - o2.footerPoints - 10, o2.margins.bottom > o2.footerPoints]]) if (g) for (let [h, M, P] of [["Left", o2.margins.left, "left"], ["Middle", (o2.margins.left + a3.widthPoints - o2.margins.right) / 2, "center"], ["Right", a3.widthPoints - o2.margins.right, "right"]]) await Jt(j, n(i[h], gt, r), M, u, 10, P);
|
|
477
|
+
j.pushOperators(Nt(), ae(a3.scaleX, 0, 0, a3.scaleY, c.originX * (1 - a3.scaleX), (j.getHeight() - c.originY) * (1 - a3.scaleY)));
|
|
478
|
+
let wt = t2.column(c.area.startColumn), l = t2.column(c.area.endColumn), W = t2.row(c.area.startRow), dt = t2.row(c.area.endRow), Ft = [Nt(), Xt(c.originX + 2, j.getHeight() - c.originY - (dt.start + dt.size - W.start), l.start + l.size - wt.start + 0.2, dt.start + dt.size - W.start + 0.2), Ut(), Yt()], ht = /* @__PURE__ */ new Map(), ot = [...Z.map((i) => ({ cell: i, merge: F.get(i) })), ...w.blankCells(c.area)].flatMap(({ cell: i, merge: u }) => {
|
|
479
|
+
e2();
|
|
480
|
+
let g = u ?? { startRow: i.row, endRow: i.row, startColumn: i.column, endColumn: i.column };
|
|
481
|
+
if (g.endRow < c.area.startRow || g.startRow > c.area.endRow || g.endColumn < c.area.startColumn || g.startColumn > c.area.endColumn || !u && _.has(i.row) || G.has(i.column)) return [];
|
|
482
|
+
let h = t2.column(g.startColumn), M = t2.column(g.endColumn), P = t2.row(g.startRow), vt = t2.row(g.endRow), U = u ? M.start + M.size - h.start : h.size, kt = u ? vt.start + vt.size - P.start : P.size;
|
|
483
|
+
if (!U || !kt) return [];
|
|
484
|
+
let yt = Vt(te(i), e2);
|
|
485
|
+
return [{ cell: i, merge: u, width: U, height: kt, style: yt, x: c.originX + h.start - wt.start, y: c.originY + P.start - W.start }];
|
|
486
|
+
}), ut = [...ot].sort((i, u) => (e2(), i.cell.row - u.cell.row || i.cell.column - u.cell.column));
|
|
487
|
+
for (let { merge: i, width: u, height: g, style: h, x: M, y: P } of ut) e2(), h.background && (i && j.pushOperators(...Ft), j.drawRectangle({ x: M + 2, y: j.getHeight() - P - g - 0.2, width: u + 0.2, height: g + 0.2, color: Tt(...h.background), ...h.backgroundAlpha === 1 ? {} : { opacity: h.backgroundAlpha } }), i && j.pushOperators(Rt()));
|
|
488
|
+
let X = ({ width: i, height: u, style: g, x: h, y: M }) => {
|
|
489
|
+
for (let P of De(g.borders ?? [], i, u, e2)) e2(), j.drawLine({ start: { x: h + 2 + P.x1, y: j.getHeight() - M - P.y1 }, end: { x: h + 2 + P.x2, y: j.getHeight() - M - P.y2 }, thickness: P.width, color: Tt(...P.border.color), opacity: P.border.alpha, ..."dash" in P ? { dashArray: [...P.dash] } : {}, ..."phase" in P ? { dashPhase: P.phase } : {} });
|
|
490
|
+
};
|
|
491
|
+
for (let i of ot) i.merge || X(i);
|
|
492
|
+
for (let { cell: i, merge: u, width: g, height: h, style: M, x: P, y: vt } of ot) {
|
|
493
|
+
e2();
|
|
494
|
+
let U = mt ? rt.get(i) ?? i.formula : void 0;
|
|
495
|
+
if (!U && k && (i.value.kind === "number" ? Math.abs(i.value.value) < 64 * Number.EPSILON : i.value.kind === "boolean" && !i.value.value)) continue;
|
|
496
|
+
let kt = !U && i.value.kind === "number" && (i.format === void 0 || i.format === "General") && (r.formatting !== void 0 || i.displayedText === void 0) ? i.value.value : void 0, yt = kt !== void 0 ? String(kt) : U ?? (i.displayedText !== void 0 && !i.style && !r.formatting ? i.displayedText : await st.format(i.value, i.format ?? "General", r, { unicodeMinus: i.value.kind === "number" }));
|
|
497
|
+
e2();
|
|
498
|
+
let et = M.alignment === "fill" || M.alignment === "justify" ? "left" : M.alignment === "distributed" ? "center" : M.alignment === "general" ? U ? "left" : i.value.kind === "number" ? "right" : i.value.kind === "boolean" || i.value.kind === "error" ? "center" : "left" : M.alignment, zt = (M.alignment !== "fill" || !!M.rotation) && !!(U || i.value.kind === "string") && (M.wrap === true || M.alignment === "justify" || M.verticalAlignment === "justify" || M.verticalAlignment === "distributed"), Ct = !u && M.alignment !== "fill" && !zt && (U || i.value.kind === "string") ? (_t) => {
|
|
499
|
+
let Dt = et === "center" ? g + Math.max(0, (_t - g + 5 * f2) / 2) : 1 / 0, xt = { left: et === "left" ? 0 : tt(i, P - c.originX + g, "left", Dt) - g, right: et === "right" ? 0 : tt(i, Math.max(g, (a3.widthPoints - o2.margins.right - c.originX) / a3.scaleX - (P - c.originX)), "right", Dt) - g }, St = g + Math.max(0, _t - g + 5 * f2) / (et === "center" ? 2 : 1), At = et === "left" ? 0 : tt(i, g + xt.left, "left", St) - g, jt = et === "right" ? 0 : tt(i, g + xt.right, "right", St) - g;
|
|
500
|
+
if (At > 0 || jt > 0) {
|
|
501
|
+
let Gt = t2.column(i.column).start, Zt = ht.get(i.row) ?? [];
|
|
502
|
+
Zt.push({ left: Gt - At, right: Gt + g + jt }), ht.set(i.row, Zt);
|
|
503
|
+
}
|
|
504
|
+
return xt;
|
|
505
|
+
} : void 0;
|
|
506
|
+
u && j.pushOperators(...Ft), await Jt(j, yt, P, vt, M.size * f2, et, { width: g, height: h, style: M, wrap: zt, fillString: !U && i.value.kind === "string", ...kt === void 0 ? {} : { generalNumber: kt, zoom: Number(s.view?.zoom ?? 1) }, ...u ? { overflow: () => ({ left: 0, right: 0 }) } : Ct === void 0 ? {} : { overflow: Ct } }), u && j.pushOperators(Rt());
|
|
507
|
+
}
|
|
508
|
+
for (let i of ot) i.merge && (j.pushOperators(...Ft), X(i), j.pushOperators(Rt()));
|
|
509
|
+
for (let i of We(c.area, { borders(u, g) {
|
|
510
|
+
e2();
|
|
511
|
+
let h = L.get(`${u}:${g}`);
|
|
512
|
+
return Vt(h ? te(h) : w.styleAt(u, g), e2).borders ?? [];
|
|
513
|
+
}, column: t2.column, row: t2.row, hiddenRows: _, hiddenColumns: G, merges: s.merges ?? [], spans: ht }, e2)) {
|
|
514
|
+
e2();
|
|
515
|
+
let u = ze[i.border.style];
|
|
516
|
+
j.drawLine({ start: { x: c.originX + 2 + i.x1, y: j.getHeight() - c.originY - i.y1 }, end: { x: c.originX + 2 + i.x2, y: j.getHeight() - c.originY - i.y2 }, thickness: u.width, color: Tt(...i.border.color), opacity: i.border.alpha, ..."dash" in u ? { dashArray: [...u.dash] } : {}, ..."phase" in u ? { dashPhase: u.phase } : {} });
|
|
517
|
+
}
|
|
518
|
+
for (let { object: i, rectangle: u } of d) {
|
|
519
|
+
e2();
|
|
520
|
+
let g = t2.column(c.area.startColumn).start, h = t2.row(c.area.startRow).start, M = t2.column(c.area.endColumn), P = t2.row(c.area.endRow), vt = M.start + M.size, U = P.start + P.size;
|
|
521
|
+
if (u.x >= vt || u.y >= U || u.x + u.width <= g || u.y + u.height <= h) continue;
|
|
522
|
+
(u.x < g || u.y < h || u.x + u.width > vt || u.y + u.height > U) && (i.anchor.mode === "2" || i.anchor.mode === "absolute") && v("absolute workbook objects spanning pages");
|
|
523
|
+
let yt = c.originX + 2, et = c.originY;
|
|
524
|
+
j.pushOperators(Nt(), Xt(yt, j.getHeight() - et - (U - h), vt - g, U - h), Ut(), Yt());
|
|
525
|
+
try {
|
|
526
|
+
await ct(j, i, yt + 0.5 + u.x - g, et + 0.5 + u.y - h, u.width, u.height);
|
|
527
|
+
} finally {
|
|
528
|
+
j.pushOperators(Rt());
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
j.pushOperators(Rt());
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
e2(), await J.flush(), e2();
|
|
536
|
+
let ee;
|
|
537
|
+
try {
|
|
538
|
+
ee = await Ke(J.context, { outputBytes: r.limits.outputBytes, objects: Math.min(1e6, r.limits.workbookWork ?? r.limits.inputBytes), work: e2, cooperate: async () => {
|
|
539
|
+
e2(), await new Promise((n2) => setTimeout(n2, 0)), e2();
|
|
540
|
+
} });
|
|
541
|
+
} catch (n2) {
|
|
542
|
+
if (n2 instanceof Ce) {
|
|
543
|
+
if (n2.code === "E_LIMIT") throw new e("resource-limit", "ssconvert PDF serialization limit exceeded");
|
|
544
|
+
v("serialization capability");
|
|
545
|
+
}
|
|
546
|
+
throw n2;
|
|
547
|
+
}
|
|
548
|
+
if (e2(), ee.length > r.limits.outputBytes) throw new e("resource-limit", "ssconvert output bytes limit exceeded");
|
|
549
|
+
return ee;
|
|
550
|
+
} finally {
|
|
551
|
+
lt.dispose();
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
export {
|
|
555
|
+
Un as pdfExportOptions,
|
|
556
|
+
Yn as writePdf
|
|
557
|
+
};
|