@silurus/ooxml 0.88.0 → 0.89.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +118 -23
- package/THIRD_PARTY_NOTICES.md +8 -7
- package/dist/abort-VrnK7mdP.js +10 -0
- package/dist/assets/render-worker-C5G_Nr_A.js +35 -0
- package/dist/assets/render-worker-DQfWdNsm.js +16 -0
- package/dist/assets/render-worker-Ds7LjwU-.js +15 -0
- package/dist/{hyperlink-Cxzhet30.js → bounded-raw-part-cache-CsnNptAy.js} +4937 -7458
- package/dist/bundled-asset-url-E2nXURF9.js +15 -0
- package/dist/canvas-viewer-mechanics-BZ8QCrRi.js +675 -0
- package/dist/cfb-guard-dNeUiANF.js +528 -0
- package/dist/chart-ex.mjs +667 -663
- package/dist/comment-overlay-controller-CBvQx-En.js +994 -0
- package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
- package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-BKidRH36.js} +5 -5
- package/dist/{comment-ui-runtime-CWGqn5Vr.js → comment-ui-runtime-C47QoDUy.js} +5 -5
- package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
- package/dist/document-model-source-MzFPrxt0.js +249 -0
- package/dist/document-pull-client-BoJeuURD.js +35941 -0
- package/dist/document-pull-worker-CaP8XESP.js +104 -0
- package/dist/docx-BN70UhvX.js +495 -0
- package/dist/docx-BRRtSvk3.js +3563 -0
- package/dist/docx-model-source-CTO9iw_W.js +98 -0
- package/dist/docx-source-worker.mjs +455 -0
- package/dist/docx.mjs +7 -7
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/drawingml-shape-CHmq8kpM.js +310 -0
- package/dist/duotone-DN8P4aXe.js +126 -0
- package/dist/emf-CGFQIz6c.js +1790 -0
- package/dist/font-preload-demand-Dmy31xt-.js +2058 -0
- package/dist/grid-geometry-C3IG20ut.js +384 -0
- package/dist/host-layout-DVMw8hDY.js +56 -0
- package/dist/host-layout-measure-DsuQ2UJs.js +7 -0
- package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
- package/dist/index.mjs +4 -4
- package/dist/internal-companion.mjs +12 -0
- package/dist/line-distribute-Bu8psjGd.js +2799 -0
- package/dist/math.mjs +2 -2
- package/dist/mathjax-stix2.js +10 -10
- package/dist/model-source-kz_NkZqT.js +179 -0
- package/dist/model-source-s5hRpk4w.js +61 -0
- package/dist/model-source-session-6fuaqbGs.js +71 -0
- package/dist/model-source-session-DqrR4XHR.js +85 -0
- package/dist/model-source-session-cPJSF_Ak.js +58 -0
- package/dist/node.mjs +7 -1327
- package/dist/{pixel-budget-9P63Bsk5.js → pixel-budget-BpTYrepD.js} +13 -10
- package/dist/plot-area-frame-Bs_j4uu7.js +41811 -0
- package/dist/pptx-CaJ6ILnw.js +183 -0
- package/dist/pptx-_BOGcBym.js +2936 -0
- package/dist/pptx-model-source-B_9afw9R.js +37 -0
- package/dist/pptx-source-worker.mjs +446 -0
- package/dist/pptx.mjs +8 -7
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/presentation-model-source-CGHLyX32.js +77 -0
- package/dist/raster-target-YQ4G6rxo.js +42 -0
- package/dist/region-map.mjs +117 -153
- package/dist/{render-D3iqVKCo.js → render-CzbDzRKa.js} +3 -3
- package/dist/{render-worker-host-B5wQfB7U.js → render-worker-host-B1u6BOUd.js} +1 -1
- package/dist/{render-worker-host-D4123J27.js → render-worker-host-C-EECo68.js} +1 -1
- package/dist/{render-worker-host-Di3LxLc0.js → render-worker-host-DDqZTCVf.js} +1 -1
- package/dist/renderer-CD2cvVAF.js +5823 -0
- package/dist/renderer-DRoeb14O.js +5170 -0
- package/dist/resource-measurement-Dhhm7P_l.js +772 -0
- package/dist/session-XPmC0CUd.js +656 -0
- package/dist/slide-pull-client-tq7U_fYg.js +6485 -0
- package/dist/three-d-BKwNPAP4.js +878 -0
- package/dist/three-d.mjs +925 -910
- package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
- package/dist/tiff.mjs +401 -248
- package/dist/types/chart-ex.d.ts +149 -2
- package/dist/types/docx.d.ts +333 -96
- package/dist/types/index.d.ts +566 -301
- package/dist/types/internal-companion.d.ts +11 -0
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +422 -9
- package/dist/types/pptx.d.ts +302 -95
- package/dist/types/region-map.d.ts +149 -2
- package/dist/types/three-d.d.ts +149 -2
- package/dist/types/tiff.d.ts +1 -1
- package/dist/types/xlsx.d.ts +343 -132
- package/dist/wasm-loader-rlgHmcSv.js +35 -0
- package/dist/wasm-runtime-generation-D6TKZdNb.js +97 -0
- package/dist/workbook-model-source-BIGrfZy6.js +94 -0
- package/dist/worker-source-DrwhR9fw.js +22 -0
- package/dist/worker-source-SbudzjYL.js +22 -0
- package/dist/worker-source-UAi3GNcM.js +22 -0
- package/dist/worksheet-pull-client-ClvPO_Jf.js +579 -0
- package/dist/xlsx-CsmREBaZ.js +5819 -0
- package/dist/xlsx-DmHfeNNp.js +534 -0
- package/dist/xlsx-model-source-D1flORqy.js +309 -0
- package/dist/xlsx-source-worker.mjs +525 -0
- package/dist/xlsx.mjs +8 -7
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +42 -16
- package/dist/assets/render-worker-1uPAxMZr.js +0 -31
- package/dist/assets/render-worker-BlvJybji.js +0 -10
- package/dist/assets/render-worker-CzmiJfFL.js +0 -11
- package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
- package/dist/canvas-viewer-mechanics-DbLz0rYW.js +0 -1384
- package/dist/cjk-fallback-bLI3z70h.js +0 -46
- package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
- package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
- package/dist/comments-Diid5ujN.js +0 -246
- package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
- package/dist/document-pull-client-B9PTM-pL.js +0 -27280
- package/dist/docx-BF9WXrYH.js +0 -3103
- package/dist/dom-interaction-boundary-Cnm8DSBN.js +0 -223
- package/dist/highlight-rect-C5hkRqUr.js +0 -13
- package/dist/line-distribute-D1WNHKz_.js +0 -1023
- package/dist/line-metrics-B60C86uh.js +0 -60
- package/dist/plot-area-frame-DLTYKHNP.js +0 -4354
- package/dist/pptx-DkyYBYoL.js +0 -3065
- package/dist/renderer-B4GZb5We.js +0 -6492
- package/dist/resource-measurement-SHQCbkh2.js +0 -150
- package/dist/session-BGq81gRQ.js +0 -743
- package/dist/slide-pull-client-DiPnm240.js +0 -6253
- package/dist/source-key-DIJG8BA0.js +0 -42
- package/dist/three-d-DJBl8g8M.js +0 -1162
- package/dist/transfer-p6iCC2R7.js +0 -6
- package/dist/units-BzZ0gAxs.js +0 -4
- package/dist/worksheet-pull-client-BM8ywvbu.js +0 -458
- package/dist/xlsx-C9NVjgaV.js +0 -8484
- /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
- /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
- /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
- /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
- /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
- /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
package/dist/node.mjs
CHANGED
|
@@ -1,1327 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { n as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { t as fe } from "./bounded-raw-part-cache-Cg1BsSZQ.js";
|
|
9
|
-
import { c as pe, d as me, f as he, l as ge, o as _e, r as ve, s as ye, t as be, u as xe } from "./worksheet-pull-client-BM8ywvbu.js";
|
|
10
|
-
import { a as Se, i as Ce, n as we, r as Te } from "./session-BGq81gRQ.js";
|
|
11
|
-
import { a as Ee, n as De, r as Oe, t as ke } from "./render-D3iqVKCo.js";
|
|
12
|
-
import { existsSync as Ae, readFileSync as je } from "node:fs";
|
|
13
|
-
import { fileURLToPath as Me } from "node:url";
|
|
14
|
-
import { basename as Ne, dirname as Pe, resolve as Fe } from "node:path";
|
|
15
|
-
import { createRequire as Ie } from "node:module";
|
|
16
|
-
//#region packages/core/src/internal/owned-session.ts
|
|
17
|
-
async function g(e, t) {
|
|
18
|
-
let n = await e(), r;
|
|
19
|
-
try {
|
|
20
|
-
return await t(n);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
throw r = e, e;
|
|
23
|
-
} finally {
|
|
24
|
-
try {
|
|
25
|
-
await n.close();
|
|
26
|
-
} catch (e) {
|
|
27
|
-
if (r === void 0) throw e;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region packages/core/src/internal/in-process-pull-transport.ts
|
|
33
|
-
var _ = class {
|
|
34
|
-
nextRequestId = 1;
|
|
35
|
-
terminated = !1;
|
|
36
|
-
constructor(e, t) {
|
|
37
|
-
this.dispatch = e, this.terminateHost = t;
|
|
38
|
-
}
|
|
39
|
-
async request(e, t, n) {
|
|
40
|
-
if (this.terminated) throw Error("pull transport terminated");
|
|
41
|
-
if (n?.signal?.aborted) {
|
|
42
|
-
n.onCancel?.(this.nextRequestId, "abort");
|
|
43
|
-
let e = /* @__PURE__ */ Error("worker request aborted");
|
|
44
|
-
throw e.name = "AbortError", e;
|
|
45
|
-
}
|
|
46
|
-
let r = e(this.nextRequestId++), i;
|
|
47
|
-
if (await this.dispatch(r, (e) => {
|
|
48
|
-
i = e;
|
|
49
|
-
}), i === void 0) throw Error("in-process pull host did not respond");
|
|
50
|
-
return i;
|
|
51
|
-
}
|
|
52
|
-
forgetOrphaned(e) {}
|
|
53
|
-
terminate() {
|
|
54
|
-
this.terminated || (this.terminated = !0, this.terminateHost());
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region packages/node/src/wasm-loader.ts
|
|
59
|
-
function Le(e) {
|
|
60
|
-
return new WebAssembly.Module(je(e));
|
|
61
|
-
}
|
|
62
|
-
function v(e, t = Le) {
|
|
63
|
-
let n = {};
|
|
64
|
-
return () => n.value ??= t(e());
|
|
65
|
-
}
|
|
66
|
-
function y(e, t, n) {
|
|
67
|
-
let r = Pe(Me(e)), i = Fe(r, t);
|
|
68
|
-
if (Ae(i)) return i;
|
|
69
|
-
let a = Fe(r, Ne(t));
|
|
70
|
-
return Ae(a) || !n ? a : Ie(e).resolve(n);
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region packages/node/src/pptx.ts
|
|
74
|
-
var Re = v(() => y(import.meta.url, "pptx_parser_bg.wasm", "@silurus/ooxml-pptx/wasm-binary"));
|
|
75
|
-
async function ze(e, t = {}) {
|
|
76
|
-
return Be(e, t);
|
|
77
|
-
}
|
|
78
|
-
async function Be(e, t = {}) {
|
|
79
|
-
let n = se(t.cjkFallback), r = await we(Ue(e), Re(), t);
|
|
80
|
-
return new Ve(r.closeArchive, r.archive, r.bootstrap, r.metrics, t.signal, n);
|
|
81
|
-
}
|
|
82
|
-
var Ve = class {
|
|
83
|
-
slideCount;
|
|
84
|
-
slideWidth;
|
|
85
|
-
slideHeight;
|
|
86
|
-
slidePull;
|
|
87
|
-
slideClient;
|
|
88
|
-
transport;
|
|
89
|
-
started = !1;
|
|
90
|
-
closed = !1;
|
|
91
|
-
closePromise;
|
|
92
|
-
usage;
|
|
93
|
-
consumedSlides = 0;
|
|
94
|
-
resourceFailure;
|
|
95
|
-
renderTail = Promise.resolve();
|
|
96
|
-
fetchImage = (e, t) => this.getPartInternal(e, t, (t) => t.extract_image(e));
|
|
97
|
-
fetchMedia = (e) => this.getPartInternal(e, "application/octet-stream", (t) => t.extract_media(e));
|
|
98
|
-
rawParts = new fe({
|
|
99
|
-
maxEntries: 64,
|
|
100
|
-
maxBytes: t
|
|
101
|
-
});
|
|
102
|
-
constructor(e, t, n, r, i, a) {
|
|
103
|
-
this.closeArchive = e, this.archive = t, this.bootstrap = n, this.metrics = r, this.signal = i, this.cjkFallback = a, this.slideCount = n.slideCount, this.slideWidth = n.slideWidth, this.slideHeight = n.slideHeight, this.slidePull = new Ce(() => this.archive), this.transport = new _((e, t) => this.slidePull.dispatchSafely(e, t), () => void 0), this.slideClient = new ue({
|
|
104
|
-
slideCount: this.slideCount,
|
|
105
|
-
transport: this.transport,
|
|
106
|
-
open: async (e, t) => {
|
|
107
|
-
this.slidePull.reserveOpen(t), await this.slidePull.open(e, t);
|
|
108
|
-
},
|
|
109
|
-
onUsage: (e) => {
|
|
110
|
-
this.usage = e, this.metrics.observeUsage(e);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
materialize(e) {
|
|
115
|
-
return {
|
|
116
|
-
slideWidth: this.slideWidth,
|
|
117
|
-
slideHeight: this.slideHeight,
|
|
118
|
-
slides: e,
|
|
119
|
-
defaultTextColor: this.bootstrap.defaultTextColor,
|
|
120
|
-
majorFont: this.bootstrap.majorFont,
|
|
121
|
-
minorFont: this.bootstrap.minorFont,
|
|
122
|
-
...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
|
|
123
|
-
...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
get resourceUsage() {
|
|
127
|
-
return this.closed ? this.usage : this.refreshResourceUsage();
|
|
128
|
-
}
|
|
129
|
-
async getImage(e, t) {
|
|
130
|
-
return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_image(e)).catch((e) => this.failOperation(e));
|
|
131
|
-
}
|
|
132
|
-
async getMedia(e, t = "application/octet-stream") {
|
|
133
|
-
return this.assertOpen(), this.getPartInternal(e, t, (t) => t.extract_media(e)).catch((e) => this.failOperation(e));
|
|
134
|
-
}
|
|
135
|
-
async renderSlide(e, t, n) {
|
|
136
|
-
return this.assertOpen(), this.enqueueRender(async () => {
|
|
137
|
-
b(this.signal);
|
|
138
|
-
let { renderSlideNode: r } = await import("./render-D3iqVKCo.js").then((e) => e.i);
|
|
139
|
-
await r(e, {
|
|
140
|
-
slideWidth: this.slideWidth,
|
|
141
|
-
slideHeight: this.slideHeight,
|
|
142
|
-
slides: [t],
|
|
143
|
-
defaultTextColor: this.bootstrap.defaultTextColor,
|
|
144
|
-
majorFont: this.bootstrap.majorFont,
|
|
145
|
-
minorFont: this.bootstrap.minorFont,
|
|
146
|
-
...this.bootstrap.hlinkColor ? { hlinkColor: this.bootstrap.hlinkColor } : {},
|
|
147
|
-
...this.bootstrap.folHlinkColor ? { folHlinkColor: this.bootstrap.folHlinkColor } : {}
|
|
148
|
-
}, 0, {
|
|
149
|
-
...n,
|
|
150
|
-
cjkFallback: this.cjkFallback,
|
|
151
|
-
fetchImage: this.fetchImage,
|
|
152
|
-
fetchMedia: this.fetchMedia
|
|
153
|
-
}), b(this.signal);
|
|
154
|
-
}).catch((e) => this.failOperation(e));
|
|
155
|
-
}
|
|
156
|
-
[Symbol.asyncIterator]() {
|
|
157
|
-
return this.slides();
|
|
158
|
-
}
|
|
159
|
-
async *slides() {
|
|
160
|
-
if (this.closed) throw Error("PPTX presentation session is closed");
|
|
161
|
-
if (this.started) throw Error("PPTX presentation session is one-pass and was already consumed");
|
|
162
|
-
this.started = !0;
|
|
163
|
-
let e;
|
|
164
|
-
try {
|
|
165
|
-
for (let e = 0; e < this.slideCount; e += 1) {
|
|
166
|
-
b(this.signal);
|
|
167
|
-
let t = await this.slideClient.load(e);
|
|
168
|
-
if (!t) throw Error(`PPTX slide ${e} was not decoded`);
|
|
169
|
-
this.usage ??= await this.slidePull.run(() => Se((e) => e(this.archive))), this.metrics.observeUsage(this.usage), this.consumedSlides = e + 1, yield t;
|
|
170
|
-
}
|
|
171
|
-
} catch (t) {
|
|
172
|
-
throw e = u(t) ?? t, this.metrics.fail(e), e;
|
|
173
|
-
} finally {
|
|
174
|
-
try {
|
|
175
|
-
await this.close();
|
|
176
|
-
} catch (t) {
|
|
177
|
-
if (e === void 0) throw t;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
close() {
|
|
182
|
-
return this.closePromise ? this.closePromise : (this.closed = !0, this.slideClient.cancelAll(), this.closePromise = this.release(), this.closePromise);
|
|
183
|
-
}
|
|
184
|
-
async release() {
|
|
185
|
-
let e;
|
|
186
|
-
await this.renderTail, d(this.fetchImage), f(this.fetchImage);
|
|
187
|
-
try {
|
|
188
|
-
await this.slidePull.reset();
|
|
189
|
-
} catch (t) {
|
|
190
|
-
e = u(t) ?? t;
|
|
191
|
-
}
|
|
192
|
-
this.transport.terminate(), this.rawParts.clear();
|
|
193
|
-
try {
|
|
194
|
-
this.closeArchive();
|
|
195
|
-
} catch (t) {
|
|
196
|
-
e ??= u(t) ?? t;
|
|
197
|
-
}
|
|
198
|
-
if (e !== void 0) throw this.metrics.fail(e), e;
|
|
199
|
-
this.metrics.checkpoint("presentation session closed"), this.metrics.succeed({ slides: this.consumedSlides });
|
|
200
|
-
}
|
|
201
|
-
enqueueRender(e) {
|
|
202
|
-
let t = this.renderTail.then(e, e);
|
|
203
|
-
return this.renderTail = t.then(() => void 0, () => void 0), t;
|
|
204
|
-
}
|
|
205
|
-
getPartInternal(e, t, n) {
|
|
206
|
-
return this.rawParts.get(e, t, () => {
|
|
207
|
-
b(this.signal);
|
|
208
|
-
let e = n(this.archive);
|
|
209
|
-
return this.refreshResourceUsage(), new Blob([e], { type: t });
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
refreshResourceUsage() {
|
|
213
|
-
try {
|
|
214
|
-
this.usage = i(this.archive.resource_usage()), this.metrics.observeUsage(this.usage);
|
|
215
|
-
} catch {}
|
|
216
|
-
return this.usage;
|
|
217
|
-
}
|
|
218
|
-
assertOpen() {
|
|
219
|
-
if (this.closed) throw Error("PPTX presentation session is closed");
|
|
220
|
-
if (this.resourceFailure) throw this.resourceFailure;
|
|
221
|
-
}
|
|
222
|
-
failOperation(e) {
|
|
223
|
-
let t = u(e) ?? e;
|
|
224
|
-
throw t instanceof m && (this.resourceFailure ??= t), this.metrics.fail(t), t;
|
|
225
|
-
}
|
|
226
|
-
};
|
|
227
|
-
async function He(e, t = {}) {
|
|
228
|
-
return g(() => Be(e, t), async (e) => {
|
|
229
|
-
let t = [];
|
|
230
|
-
for await (let n of e.slides()) t.push(n);
|
|
231
|
-
return e.materialize(t);
|
|
232
|
-
});
|
|
233
|
-
}
|
|
234
|
-
function Ue(e) {
|
|
235
|
-
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
236
|
-
}
|
|
237
|
-
function b(e) {
|
|
238
|
-
if (!e?.aborted) return;
|
|
239
|
-
let t = /* @__PURE__ */ Error("PPTX presentation session was aborted");
|
|
240
|
-
throw t.name = "AbortError", t;
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
//#region packages/docx/src/document-pull-worker.ts
|
|
244
|
-
function We(e) {
|
|
245
|
-
try {
|
|
246
|
-
let t = e((e) => e.document_cursor_resource_usage?.());
|
|
247
|
-
return t ? i(t) : void 0;
|
|
248
|
-
} catch (e) {
|
|
249
|
-
if (String(e).includes("document cursor usage is unavailable")) return;
|
|
250
|
-
throw e;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
var Ge = Math.max(p, a), Ke = class {
|
|
254
|
-
coordinator = new n();
|
|
255
|
-
host = null;
|
|
256
|
-
identity = null;
|
|
257
|
-
constructor(e, t = (e) => e(this.requireArchive())) {
|
|
258
|
-
this.archive = e, this.executeArchive = t;
|
|
259
|
-
}
|
|
260
|
-
open(e) {
|
|
261
|
-
if (this.host) throw Error("a DOCX document pull session is already active");
|
|
262
|
-
this.executeArchive((t) => {
|
|
263
|
-
t.open_document_cursor(e.operationId, e.generation);
|
|
264
|
-
});
|
|
265
|
-
let t = 0;
|
|
266
|
-
this.identity = e, this.host = new l({
|
|
267
|
-
...e,
|
|
268
|
-
maxByteCredit: Ge,
|
|
269
|
-
coordinator: this.coordinator,
|
|
270
|
-
driver: {
|
|
271
|
-
pull: (n) => {
|
|
272
|
-
let r;
|
|
273
|
-
try {
|
|
274
|
-
r = this.executeArchive((r) => r.pull_document_chunk(t, e.operationId, e.generation, n));
|
|
275
|
-
} catch (e) {
|
|
276
|
-
throw o(e, n, Ge) || e;
|
|
277
|
-
}
|
|
278
|
-
let i = de(r);
|
|
279
|
-
return {
|
|
280
|
-
payload: i,
|
|
281
|
-
byteLength: i.byteLength,
|
|
282
|
-
done: this.executeArchive((e) => e.document_chunk_done()),
|
|
283
|
-
transfer: [i]
|
|
284
|
-
};
|
|
285
|
-
},
|
|
286
|
-
measureChunk: ({ payload: e }) => e.byteLength,
|
|
287
|
-
acknowledge: (n) => {
|
|
288
|
-
if (n !== t) throw Error("DOCX document acknowledgement sequence mismatch");
|
|
289
|
-
this.executeArchive((n) => n.acknowledge_document_chunk(t, e.operationId, e.generation)), t += 1;
|
|
290
|
-
},
|
|
291
|
-
cancel: () => this.executeArchive((e) => e.cancel_document_cursor()),
|
|
292
|
-
close: () => this.executeArchive((e) => e.close_document_session()),
|
|
293
|
-
resourceUsage: () => We(this.executeArchive)
|
|
294
|
-
}
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
dispatch(e, t) {
|
|
298
|
-
return !this.host || !this.identity ? (t({
|
|
299
|
-
protocol: c,
|
|
300
|
-
kind: "error",
|
|
301
|
-
sessionId: e.sessionId,
|
|
302
|
-
operationId: e.operationId,
|
|
303
|
-
generation: e.generation,
|
|
304
|
-
requestId: e.requestId,
|
|
305
|
-
error: r(/* @__PURE__ */ Error("DOCX document pull session is not open"))
|
|
306
|
-
}), Promise.resolve()) : this.host.dispatch(e, t);
|
|
307
|
-
}
|
|
308
|
-
async reset() {
|
|
309
|
-
if (this.host) try {
|
|
310
|
-
this.archive() && this.executeArchive((e) => e.close_document_session());
|
|
311
|
-
} finally {
|
|
312
|
-
this.host = null, this.identity = null, this.coordinator = new n();
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
requireArchive() {
|
|
316
|
-
let e = this.archive();
|
|
317
|
-
if (!e) throw Error("No docx loaded");
|
|
318
|
-
return e;
|
|
319
|
-
}
|
|
320
|
-
}, qe = /* @__PURE__ */ e({
|
|
321
|
-
DocxArchive: () => x,
|
|
322
|
-
default: () => at,
|
|
323
|
-
docx_to_markdown: () => Je,
|
|
324
|
-
extract_image: () => Ye,
|
|
325
|
-
initSync: () => it,
|
|
326
|
-
parse_docx: () => Xe,
|
|
327
|
-
reinit: () => ot
|
|
328
|
-
}), x = class {
|
|
329
|
-
__destroy_into_raw() {
|
|
330
|
-
let e = this.__wbg_ptr;
|
|
331
|
-
return this.__wbg_ptr = 0, Qe.unregister(this), e;
|
|
332
|
-
}
|
|
333
|
-
free() {
|
|
334
|
-
let e = this.__destroy_into_raw();
|
|
335
|
-
F.__wbg_docxarchive_free(e, 0);
|
|
336
|
-
}
|
|
337
|
-
acknowledge_document_chunk(e, t, n) {
|
|
338
|
-
let r = F.docxarchive_acknowledge_document_chunk(this.__wbg_ptr, e, t, n);
|
|
339
|
-
if (r[1]) throw A(r[0]);
|
|
340
|
-
}
|
|
341
|
-
assert_healthy() {
|
|
342
|
-
let e = F.docxarchive_assert_healthy(this.__wbg_ptr);
|
|
343
|
-
if (e[1]) throw A(e[0]);
|
|
344
|
-
}
|
|
345
|
-
cancel_document_cursor() {
|
|
346
|
-
F.docxarchive_cancel_document_cursor(this.__wbg_ptr);
|
|
347
|
-
}
|
|
348
|
-
close_document_session() {
|
|
349
|
-
F.docxarchive_close_document_session(this.__wbg_ptr);
|
|
350
|
-
}
|
|
351
|
-
document_chunk_done() {
|
|
352
|
-
let e = F.docxarchive_document_chunk_done(this.__wbg_ptr);
|
|
353
|
-
if (e[2]) throw A(e[1]);
|
|
354
|
-
return e[0] !== 0;
|
|
355
|
-
}
|
|
356
|
-
document_cursor_resource_usage() {
|
|
357
|
-
let e = F.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);
|
|
358
|
-
if (e[3]) throw A(e[2]);
|
|
359
|
-
var t = S(e[0], e[1]).slice();
|
|
360
|
-
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
361
|
-
}
|
|
362
|
-
extract_image(e) {
|
|
363
|
-
let t = k(e, F.__wbindgen_malloc, F.__wbindgen_realloc), n = P, r = F.docxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
364
|
-
if (r[3]) throw A(r[2]);
|
|
365
|
-
var i = S(r[0], r[1]).slice();
|
|
366
|
-
return F.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
367
|
-
}
|
|
368
|
-
constructor(e, t, n, r) {
|
|
369
|
-
let i = O(e, F.__wbindgen_malloc), a = P, o = F.docxarchive_new(i, a, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n, !D(r), D(r) ? BigInt(0) : r);
|
|
370
|
-
if (o[2]) throw A(o[1]);
|
|
371
|
-
return this.__wbg_ptr = o[0] >>> 0, Qe.register(this, this.__wbg_ptr, this), this;
|
|
372
|
-
}
|
|
373
|
-
open_document_cursor(e, t) {
|
|
374
|
-
let n = F.docxarchive_open_document_cursor(this.__wbg_ptr, e, t);
|
|
375
|
-
if (n[1]) throw A(n[0]);
|
|
376
|
-
}
|
|
377
|
-
parse() {
|
|
378
|
-
let e = F.docxarchive_parse(this.__wbg_ptr);
|
|
379
|
-
if (e[3]) throw A(e[2]);
|
|
380
|
-
var t = S(e[0], e[1]).slice();
|
|
381
|
-
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
382
|
-
}
|
|
383
|
-
pull_document_chunk(e, t, n, r) {
|
|
384
|
-
let i = F.docxarchive_pull_document_chunk(this.__wbg_ptr, e, t, n, r);
|
|
385
|
-
if (i[3]) throw A(i[2]);
|
|
386
|
-
var a = S(i[0], i[1]).slice();
|
|
387
|
-
return F.__wbindgen_free(i[0], i[1] * 1, 1), a;
|
|
388
|
-
}
|
|
389
|
-
resource_usage() {
|
|
390
|
-
let e = F.docxarchive_resource_usage(this.__wbg_ptr);
|
|
391
|
-
if (e[3]) throw A(e[2]);
|
|
392
|
-
var t = S(e[0], e[1]).slice();
|
|
393
|
-
return F.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
394
|
-
}
|
|
395
|
-
to_markdown() {
|
|
396
|
-
let e, t;
|
|
397
|
-
try {
|
|
398
|
-
let i = F.docxarchive_to_markdown(this.__wbg_ptr);
|
|
399
|
-
var n = i[0], r = i[1];
|
|
400
|
-
if (i[3]) throw n = 0, r = 0, A(i[2]);
|
|
401
|
-
return e = n, t = r, w(n, r);
|
|
402
|
-
} finally {
|
|
403
|
-
F.__wbindgen_free(e, t, 1);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
Symbol.dispose && (x.prototype[Symbol.dispose] = x.prototype.free);
|
|
408
|
-
function Je(e, t, n) {
|
|
409
|
-
let r, i;
|
|
410
|
-
try {
|
|
411
|
-
let s = O(e, F.__wbindgen_malloc), c = P, l = F.docx_to_markdown(s, c, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n);
|
|
412
|
-
var a = l[0], o = l[1];
|
|
413
|
-
if (l[3]) throw a = 0, o = 0, A(l[2]);
|
|
414
|
-
return r = a, i = o, w(a, o);
|
|
415
|
-
} finally {
|
|
416
|
-
F.__wbindgen_free(r, i, 1);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
function Ye(e, t, n, r) {
|
|
420
|
-
let i = O(e, F.__wbindgen_malloc), a = P, o = k(t, F.__wbindgen_malloc, F.__wbindgen_realloc), s = P, c = F.extract_image(i, a, o, s, !D(n), D(n) ? BigInt(0) : n, !D(r), D(r) ? BigInt(0) : r);
|
|
421
|
-
if (c[3]) throw A(c[2]);
|
|
422
|
-
var l = S(c[0], c[1]).slice();
|
|
423
|
-
return F.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
424
|
-
}
|
|
425
|
-
function Xe(e, t, n) {
|
|
426
|
-
let r = O(e, F.__wbindgen_malloc), i = P, a = F.parse_docx(r, i, !D(t), D(t) ? BigInt(0) : t, !D(n), D(n) ? BigInt(0) : n);
|
|
427
|
-
if (a[3]) throw A(a[2]);
|
|
428
|
-
var o = S(a[0], a[1]).slice();
|
|
429
|
-
return F.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
430
|
-
}
|
|
431
|
-
function Ze() {
|
|
432
|
-
return {
|
|
433
|
-
__proto__: null,
|
|
434
|
-
"./docx_parser_bg.js": {
|
|
435
|
-
__proto__: null,
|
|
436
|
-
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
437
|
-
throw Error(w(e, t));
|
|
438
|
-
},
|
|
439
|
-
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
440
|
-
let n, r;
|
|
441
|
-
try {
|
|
442
|
-
n = e, r = t, console.error(w(e, t));
|
|
443
|
-
} finally {
|
|
444
|
-
F.__wbindgen_free(n, r, 1);
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
__wbg_new_227d7c05414eb861: function() {
|
|
448
|
-
return /* @__PURE__ */ Error();
|
|
449
|
-
},
|
|
450
|
-
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
451
|
-
let n = t.stack, r = k(n, F.__wbindgen_malloc, F.__wbindgen_realloc), i = P;
|
|
452
|
-
$e().setInt32(e + 4, i, !0), $e().setInt32(e + 0, r, !0);
|
|
453
|
-
},
|
|
454
|
-
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
455
|
-
return w(e, t);
|
|
456
|
-
},
|
|
457
|
-
__wbindgen_init_externref_table: function() {
|
|
458
|
-
let e = F.__wbindgen_externrefs, t = e.grow(4);
|
|
459
|
-
e.set(0, void 0), e.set(t + 0, void 0), e.set(t + 1, null), e.set(t + 2, !0), e.set(t + 3, !1);
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
var Qe = typeof FinalizationRegistry > "u" ? {
|
|
465
|
-
register: () => {},
|
|
466
|
-
unregister: () => {}
|
|
467
|
-
} : new FinalizationRegistry((e) => F.__wbg_docxarchive_free(e >>> 0, 1));
|
|
468
|
-
function S(e, t) {
|
|
469
|
-
return e >>>= 0, E().subarray(e / 1, e / 1 + t);
|
|
470
|
-
}
|
|
471
|
-
var C = null;
|
|
472
|
-
function $e() {
|
|
473
|
-
return (C === null || C.buffer.detached === !0 || C.buffer.detached === void 0 && C.buffer !== F.memory.buffer) && (C = new DataView(F.memory.buffer)), C;
|
|
474
|
-
}
|
|
475
|
-
function w(e, t) {
|
|
476
|
-
return e >>>= 0, tt(e, t);
|
|
477
|
-
}
|
|
478
|
-
var T = null;
|
|
479
|
-
function E() {
|
|
480
|
-
return (T === null || T.byteLength === 0) && (T = new Uint8Array(F.memory.buffer)), T;
|
|
481
|
-
}
|
|
482
|
-
function D(e) {
|
|
483
|
-
return e == null;
|
|
484
|
-
}
|
|
485
|
-
function O(e, t) {
|
|
486
|
-
let n = t(e.length * 1, 1) >>> 0;
|
|
487
|
-
return E().set(e, n / 1), P = e.length, n;
|
|
488
|
-
}
|
|
489
|
-
function k(e, t, n) {
|
|
490
|
-
if (n === void 0) {
|
|
491
|
-
let n = N.encode(e), r = t(n.length, 1) >>> 0;
|
|
492
|
-
return E().subarray(r, r + n.length).set(n), P = n.length, r;
|
|
493
|
-
}
|
|
494
|
-
let r = e.length, i = t(r, 1) >>> 0, a = E(), o = 0;
|
|
495
|
-
for (; o < r; o++) {
|
|
496
|
-
let t = e.charCodeAt(o);
|
|
497
|
-
if (t > 127) break;
|
|
498
|
-
a[i + o] = t;
|
|
499
|
-
}
|
|
500
|
-
if (o !== r) {
|
|
501
|
-
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
502
|
-
let t = E().subarray(i + o, i + r), a = N.encodeInto(e, t);
|
|
503
|
-
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
504
|
-
}
|
|
505
|
-
return P = o, i;
|
|
506
|
-
}
|
|
507
|
-
function A(e) {
|
|
508
|
-
let t = F.__wbindgen_externrefs.get(e);
|
|
509
|
-
return F.__externref_table_dealloc(e), t;
|
|
510
|
-
}
|
|
511
|
-
var j = new TextDecoder("utf-8", {
|
|
512
|
-
ignoreBOM: !0,
|
|
513
|
-
fatal: !0
|
|
514
|
-
});
|
|
515
|
-
j.decode();
|
|
516
|
-
var et = 2146435072, M = 0;
|
|
517
|
-
function tt(e, t) {
|
|
518
|
-
return M += t, M >= et && (j = new TextDecoder("utf-8", {
|
|
519
|
-
ignoreBOM: !0,
|
|
520
|
-
fatal: !0
|
|
521
|
-
}), j.decode(), M = t), j.decode(E().subarray(e, e + t));
|
|
522
|
-
}
|
|
523
|
-
var N = new TextEncoder();
|
|
524
|
-
"encodeInto" in N || (N.encodeInto = function(e, t) {
|
|
525
|
-
let n = N.encode(e);
|
|
526
|
-
return t.set(n), {
|
|
527
|
-
read: e.length,
|
|
528
|
-
written: n.length
|
|
529
|
-
};
|
|
530
|
-
});
|
|
531
|
-
var P = 0, F;
|
|
532
|
-
function nt(e, t) {
|
|
533
|
-
return F = e.exports, C = null, T = null, F.__wbindgen_start(), F;
|
|
534
|
-
}
|
|
535
|
-
async function rt(e, t) {
|
|
536
|
-
if (typeof Response == "function" && e instanceof Response) {
|
|
537
|
-
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
538
|
-
return await WebAssembly.instantiateStreaming(e, t);
|
|
539
|
-
} catch (t) {
|
|
540
|
-
if (e.ok && n(e.type) && e.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t);
|
|
541
|
-
else throw t;
|
|
542
|
-
}
|
|
543
|
-
let r = await e.arrayBuffer();
|
|
544
|
-
return await WebAssembly.instantiate(r, t);
|
|
545
|
-
} else {
|
|
546
|
-
let n = await WebAssembly.instantiate(e, t);
|
|
547
|
-
return n instanceof WebAssembly.Instance ? {
|
|
548
|
-
instance: n,
|
|
549
|
-
module: e
|
|
550
|
-
} : n;
|
|
551
|
-
}
|
|
552
|
-
function n(e) {
|
|
553
|
-
switch (e) {
|
|
554
|
-
case "basic":
|
|
555
|
-
case "cors":
|
|
556
|
-
case "default": return !0;
|
|
557
|
-
}
|
|
558
|
-
return !1;
|
|
559
|
-
}
|
|
560
|
-
}
|
|
561
|
-
function it(e) {
|
|
562
|
-
if (F !== void 0) return F;
|
|
563
|
-
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
564
|
-
let t = Ze();
|
|
565
|
-
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), nt(new WebAssembly.Instance(e, t), e);
|
|
566
|
-
}
|
|
567
|
-
async function at(e) {
|
|
568
|
-
if (F !== void 0) return F;
|
|
569
|
-
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module_or_path: e} = e : console.warn("using deprecated parameters for the initialization function; pass a single object instead"));
|
|
570
|
-
let t = Ze();
|
|
571
|
-
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
|
572
|
-
let { instance: n, module: r } = await rt(await e, t);
|
|
573
|
-
return nt(n, r);
|
|
574
|
-
}
|
|
575
|
-
async function ot(e) {
|
|
576
|
-
return F = void 0, C = null, T = null, at(e);
|
|
577
|
-
}
|
|
578
|
-
//#endregion
|
|
579
|
-
//#region packages/docx/src/internal/node-acquisition.ts
|
|
580
|
-
var st, I;
|
|
581
|
-
function ct(e) {
|
|
582
|
-
if (!I) st = e, I = new Te(qe, e);
|
|
583
|
-
else if (st !== e) throw Error("DOCX runtime was already initialized with another WebAssembly.Module");
|
|
584
|
-
return I;
|
|
585
|
-
}
|
|
586
|
-
async function lt(e, t, n, r) {
|
|
587
|
-
let i = h(n), a = new s({
|
|
588
|
-
enabled: i.debug || i.onResourceMetrics !== void 0,
|
|
589
|
-
format: "docx",
|
|
590
|
-
mode: "node",
|
|
591
|
-
scope: "session",
|
|
592
|
-
policy: i.policy,
|
|
593
|
-
onMetrics: i.onResourceMetrics,
|
|
594
|
-
emitToConsole: i.debug
|
|
595
|
-
});
|
|
596
|
-
a.setSourceBytes(e.byteLength);
|
|
597
|
-
let o, c, l;
|
|
598
|
-
try {
|
|
599
|
-
ut(n.signal);
|
|
600
|
-
let [s, u, d] = ee(i.policy), f = x;
|
|
601
|
-
o = await ct(t).open(() => new f(e, s, u, d), {
|
|
602
|
-
signal: n.signal,
|
|
603
|
-
abortError: dt,
|
|
604
|
-
disposeOnAbort: (e) => e.free()
|
|
605
|
-
}), ut(n.signal);
|
|
606
|
-
let p = o.proxy;
|
|
607
|
-
a.checkpoint("container ready"), c = new Ke(() => p);
|
|
608
|
-
let m = {
|
|
609
|
-
sessionId: 1,
|
|
610
|
-
operationId: 1,
|
|
611
|
-
generation: 1
|
|
612
|
-
};
|
|
613
|
-
c.open(m), l = new _((e, t) => c?.dispatch(e, t), () => void 0);
|
|
614
|
-
let h, te = await r(l, m, {
|
|
615
|
-
signal: n.signal,
|
|
616
|
-
onUsage: (e) => {
|
|
617
|
-
h = e, a.observeUsage(e);
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
return h ??= We((e) => e(p)), a.observeUsage(h), a.checkpoint("model streamed"), await c.reset(), l.terminate(), {
|
|
621
|
-
archive: p,
|
|
622
|
-
result: te,
|
|
623
|
-
usage: h,
|
|
624
|
-
metrics: a,
|
|
625
|
-
closeArchive: () => o?.close((e) => e.free())
|
|
626
|
-
};
|
|
627
|
-
} catch (e) {
|
|
628
|
-
await c?.reset().catch(() => void 0), l?.terminate();
|
|
629
|
-
try {
|
|
630
|
-
o?.close((e) => e.free());
|
|
631
|
-
} catch {}
|
|
632
|
-
let t = u(e) ?? e;
|
|
633
|
-
throw a.fail(t), t;
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
function ut(e) {
|
|
637
|
-
if (e?.aborted) throw dt();
|
|
638
|
-
}
|
|
639
|
-
function dt() {
|
|
640
|
-
let e = /* @__PURE__ */ Error("DOCX document session was aborted");
|
|
641
|
-
return e.name = "AbortError", e;
|
|
642
|
-
}
|
|
643
|
-
//#endregion
|
|
644
|
-
//#region packages/node/src/docx.ts
|
|
645
|
-
var ft = v(() => y(import.meta.url, "docx_parser_bg.wasm", "@silurus/ooxml-docx/wasm-binary"));
|
|
646
|
-
async function pt(e, t) {
|
|
647
|
-
if (!t?.factory) throw TypeError("openDocxDocument requires a canvas factory");
|
|
648
|
-
let n = se(t.cjkFallback), r = await lt(_t(e), ft(), t, (e, t, n) => ae(e, t, n));
|
|
649
|
-
try {
|
|
650
|
-
L(t.signal);
|
|
651
|
-
let e = t.factory.createCanvas(1, 1), i = ie(r.result, {
|
|
652
|
-
cjkFallback: n,
|
|
653
|
-
measureContext: e.getContext("2d")
|
|
654
|
-
}), a = gt(t.currentDate), o = te(r.result, i, a).layoutVariants.defaultLayout, s = new ht(r.closeArchive, r.archive, r.result, i, o, t.factory, a, r.usage, r.metrics, t.signal);
|
|
655
|
-
return r.metrics.observeUsage(s.resourceUsage), r.metrics.checkpoint("pagination ready"), s;
|
|
656
|
-
} catch (e) {
|
|
657
|
-
try {
|
|
658
|
-
r.closeArchive();
|
|
659
|
-
} catch {}
|
|
660
|
-
let t = u(e) ?? e;
|
|
661
|
-
throw r.metrics.fail(t), t;
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
async function mt(e, t = {}) {
|
|
665
|
-
return g(async () => {
|
|
666
|
-
let n = await lt(_t(e), ft(), t, (e, t, n) => re(e, t, n)), r = !1;
|
|
667
|
-
return {
|
|
668
|
-
acquired: n,
|
|
669
|
-
markSucceeded: () => {
|
|
670
|
-
r = !0;
|
|
671
|
-
},
|
|
672
|
-
close: async () => {
|
|
673
|
-
try {
|
|
674
|
-
n.closeArchive(), r && n.metrics.succeed({ documents: 1 });
|
|
675
|
-
} catch (e) {
|
|
676
|
-
throw n.metrics.fail(e), e;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
}, async ({ acquired: e, markSucceeded: t }) => {
|
|
681
|
-
try {
|
|
682
|
-
let n = oe(e.result);
|
|
683
|
-
return e.metrics.checkpoint("document materialized", e.usage), t(), n;
|
|
684
|
-
} catch (t) {
|
|
685
|
-
throw e.metrics.fail(t), t;
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
}
|
|
689
|
-
var ht = class {
|
|
690
|
-
pageCount;
|
|
691
|
-
sizes;
|
|
692
|
-
lastResourceUsage;
|
|
693
|
-
state;
|
|
694
|
-
renderTail = Promise.resolve();
|
|
695
|
-
pagesStarted = !1;
|
|
696
|
-
closed = !1;
|
|
697
|
-
closePromise;
|
|
698
|
-
resourceFailure = null;
|
|
699
|
-
fetchImage = async (e, t) => {
|
|
700
|
-
let n = this.archive.extract_image(e);
|
|
701
|
-
return new Blob([n], { type: t });
|
|
702
|
-
};
|
|
703
|
-
constructor(e, t, n, r, i, a, o, s, c, l) {
|
|
704
|
-
this.closeArchive = e, this.archive = t, this.factory = a, this.defaultCurrentDateMs = o, this.metrics = c, this.signal = l, this.state = {
|
|
705
|
-
source: n,
|
|
706
|
-
services: r
|
|
707
|
-
}, this.pageCount = i.pages.length, this.lastResourceUsage = s, this.sizes = Object.freeze(i.pages.map((e) => Object.freeze({
|
|
708
|
-
widthPt: e.geometry.widthPt,
|
|
709
|
-
heightPt: e.geometry.heightPt
|
|
710
|
-
})));
|
|
711
|
-
}
|
|
712
|
-
get resourceUsage() {
|
|
713
|
-
return this.closed ? this.lastResourceUsage : this.refreshResourceUsage();
|
|
714
|
-
}
|
|
715
|
-
refreshResourceUsage() {
|
|
716
|
-
try {
|
|
717
|
-
this.lastResourceUsage = i(this.archive.resource_usage()), this.metrics.observeUsage(this.lastResourceUsage);
|
|
718
|
-
} catch {}
|
|
719
|
-
return this.lastResourceUsage;
|
|
720
|
-
}
|
|
721
|
-
pageSize(e) {
|
|
722
|
-
let t = this.sizes[e];
|
|
723
|
-
if (!t) throw RangeError(`DOCX page index ${e} out of range`);
|
|
724
|
-
return t;
|
|
725
|
-
}
|
|
726
|
-
[Symbol.asyncIterator]() {
|
|
727
|
-
return this.pages();
|
|
728
|
-
}
|
|
729
|
-
renderPage(e, t = {}) {
|
|
730
|
-
return this.closed ? Promise.reject(/* @__PURE__ */ Error("DOCX document session is closed")) : this.resourceFailure ? Promise.reject(this.resourceFailure) : (this.pageSize(e), this.enqueueRender(async () => {
|
|
731
|
-
L(this.signal);
|
|
732
|
-
let n = this.requireState(), r = this.factory.createCanvas(1, 1);
|
|
733
|
-
return await Ee(this.factory, () => ne(n.source, r, e, {
|
|
734
|
-
...t,
|
|
735
|
-
currentDate: this.defaultCurrentDateMs,
|
|
736
|
-
defaultCurrentDateMs: this.defaultCurrentDateMs,
|
|
737
|
-
layoutServices: n.services,
|
|
738
|
-
fetchImage: this.fetchImage
|
|
739
|
-
})), L(this.signal), r;
|
|
740
|
-
}).catch((e) => {
|
|
741
|
-
let t = u(e) ?? e;
|
|
742
|
-
throw t instanceof m && (this.resourceFailure ??= t), this.metrics.fail(t), t;
|
|
743
|
-
}));
|
|
744
|
-
}
|
|
745
|
-
async *pages(e = {}) {
|
|
746
|
-
if (this.closed) throw Error("DOCX document session is closed");
|
|
747
|
-
if (this.pagesStarted) throw Error("DOCX page stream is one-pass and was already consumed");
|
|
748
|
-
this.pagesStarted = !0;
|
|
749
|
-
let t;
|
|
750
|
-
try {
|
|
751
|
-
for (let t = 0; t < this.pageCount; t += 1) {
|
|
752
|
-
let n = await this.renderPage(t, e), r = this.pageSize(t);
|
|
753
|
-
yield {
|
|
754
|
-
pageIndex: t,
|
|
755
|
-
...r,
|
|
756
|
-
canvas: n
|
|
757
|
-
};
|
|
758
|
-
}
|
|
759
|
-
} catch (e) {
|
|
760
|
-
throw t = u(e) ?? e, t;
|
|
761
|
-
} finally {
|
|
762
|
-
try {
|
|
763
|
-
await this.close();
|
|
764
|
-
} catch (e) {
|
|
765
|
-
if (t === void 0) throw e;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
close() {
|
|
770
|
-
return this.closePromise ? this.closePromise : (this.refreshResourceUsage(), this.closed = !0, this.closePromise = this.release(), this.closePromise);
|
|
771
|
-
}
|
|
772
|
-
enqueueRender(e) {
|
|
773
|
-
let t = this.renderTail.then(e, e);
|
|
774
|
-
return this.renderTail = t.then(() => void 0, () => void 0), t;
|
|
775
|
-
}
|
|
776
|
-
async release() {
|
|
777
|
-
await this.renderTail, d(this.fetchImage), f(this.fetchImage), this.state = null;
|
|
778
|
-
try {
|
|
779
|
-
this.closeArchive();
|
|
780
|
-
} catch (e) {
|
|
781
|
-
let t = u(e) ?? e;
|
|
782
|
-
throw this.metrics.fail(t), t;
|
|
783
|
-
}
|
|
784
|
-
this.metrics.checkpoint("document session closed", this.lastResourceUsage), this.metrics.succeed({ pages: this.pageCount });
|
|
785
|
-
}
|
|
786
|
-
requireState() {
|
|
787
|
-
if (!this.state) throw Error("DOCX document session is closed");
|
|
788
|
-
return this.state;
|
|
789
|
-
}
|
|
790
|
-
};
|
|
791
|
-
function gt(e) {
|
|
792
|
-
let t = e instanceof Date ? e.getTime() : e ?? Date.now();
|
|
793
|
-
if (!Number.isFinite(t)) throw RangeError("currentDate must resolve to finite epoch milliseconds");
|
|
794
|
-
return t;
|
|
795
|
-
}
|
|
796
|
-
function _t(e) {
|
|
797
|
-
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
798
|
-
}
|
|
799
|
-
function L(e) {
|
|
800
|
-
if (!e?.aborted) return;
|
|
801
|
-
let t = /* @__PURE__ */ Error("DOCX document session was aborted");
|
|
802
|
-
throw t.name = "AbortError", t;
|
|
803
|
-
}
|
|
804
|
-
//#endregion
|
|
805
|
-
//#region packages/xlsx/src/internal/archive-bootstrap.ts
|
|
806
|
-
var vt = "xlsx resource usage is unavailable";
|
|
807
|
-
function yt(e, t) {
|
|
808
|
-
let n = e();
|
|
809
|
-
try {
|
|
810
|
-
return {
|
|
811
|
-
workbook: n,
|
|
812
|
-
usage: i(t())
|
|
813
|
-
};
|
|
814
|
-
} catch (e) {
|
|
815
|
-
if ((e instanceof Error ? e.message : String(e)) === vt) return {
|
|
816
|
-
workbook: n,
|
|
817
|
-
usage: void 0
|
|
818
|
-
};
|
|
819
|
-
throw e;
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
//#endregion
|
|
823
|
-
//#region packages/xlsx/src/wasm/xlsx_parser.js
|
|
824
|
-
var bt = /* @__PURE__ */ e({
|
|
825
|
-
XlsxArchive: () => R,
|
|
826
|
-
default: () => Mt,
|
|
827
|
-
extract_image: () => xt,
|
|
828
|
-
initSync: () => jt,
|
|
829
|
-
parse_xlsx: () => St,
|
|
830
|
-
reinit: () => Nt,
|
|
831
|
-
xlsx_to_markdown: () => Ct
|
|
832
|
-
}), R = class {
|
|
833
|
-
__destroy_into_raw() {
|
|
834
|
-
let e = this.__wbg_ptr;
|
|
835
|
-
return this.__wbg_ptr = 0, Tt.unregister(this), e;
|
|
836
|
-
}
|
|
837
|
-
free() {
|
|
838
|
-
let e = this.__destroy_into_raw();
|
|
839
|
-
Q.__wbg_xlsxarchive_free(e, 0);
|
|
840
|
-
}
|
|
841
|
-
acknowledge_sheet_cursor_terminal() {
|
|
842
|
-
let e = Q.xlsxarchive_acknowledge_sheet_cursor_terminal(this.__wbg_ptr);
|
|
843
|
-
if (e[1]) throw q(e[0]);
|
|
844
|
-
}
|
|
845
|
-
assert_healthy() {
|
|
846
|
-
let e = Q.xlsxarchive_assert_healthy(this.__wbg_ptr);
|
|
847
|
-
if (e[1]) throw q(e[0]);
|
|
848
|
-
}
|
|
849
|
-
cancel_sheet_cursor() {
|
|
850
|
-
Q.xlsxarchive_cancel_sheet_cursor(this.__wbg_ptr);
|
|
851
|
-
}
|
|
852
|
-
close_sheet_cursor() {
|
|
853
|
-
Q.xlsxarchive_close_sheet_cursor(this.__wbg_ptr);
|
|
854
|
-
}
|
|
855
|
-
extract_image(e) {
|
|
856
|
-
let t = K(e, Q.__wbindgen_malloc, Q.__wbindgen_realloc), n = Z, r = Q.xlsxarchive_extract_image(this.__wbg_ptr, t, n);
|
|
857
|
-
if (r[3]) throw q(r[2]);
|
|
858
|
-
var i = z(r[0], r[1]).slice();
|
|
859
|
-
return Q.__wbindgen_free(r[0], r[1] * 1, 1), i;
|
|
860
|
-
}
|
|
861
|
-
constructor(e, t, n, r) {
|
|
862
|
-
let i = G(e, Q.__wbindgen_malloc), a = Z, o = Q.xlsxarchive_new(i, a, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n, !W(r), W(r) ? BigInt(0) : r);
|
|
863
|
-
if (o[2]) throw q(o[1]);
|
|
864
|
-
return this.__wbg_ptr = o[0] >>> 0, Tt.register(this, this.__wbg_ptr, this), this;
|
|
865
|
-
}
|
|
866
|
-
open_sheet_cursor(e, t) {
|
|
867
|
-
let n = K(t, Q.__wbindgen_malloc, Q.__wbindgen_realloc), r = Z, i = Q.xlsxarchive_open_sheet_cursor(this.__wbg_ptr, e, n, r);
|
|
868
|
-
if (i[1]) throw q(i[0]);
|
|
869
|
-
}
|
|
870
|
-
parse() {
|
|
871
|
-
let e = Q.xlsxarchive_parse(this.__wbg_ptr);
|
|
872
|
-
if (e[3]) throw q(e[2]);
|
|
873
|
-
var t = z(e[0], e[1]).slice();
|
|
874
|
-
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
875
|
-
}
|
|
876
|
-
pull_sheet_cursor(e) {
|
|
877
|
-
let t = Q.xlsxarchive_pull_sheet_cursor(this.__wbg_ptr, e);
|
|
878
|
-
if (t[3]) throw q(t[2]);
|
|
879
|
-
var n = z(t[0], t[1]).slice();
|
|
880
|
-
return Q.__wbindgen_free(t[0], t[1] * 1, 1), n;
|
|
881
|
-
}
|
|
882
|
-
resource_usage() {
|
|
883
|
-
let e = Q.xlsxarchive_resource_usage(this.__wbg_ptr);
|
|
884
|
-
if (e[3]) throw q(e[2]);
|
|
885
|
-
var t = z(e[0], e[1]).slice();
|
|
886
|
-
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
887
|
-
}
|
|
888
|
-
sheet_cursor_pull_finished() {
|
|
889
|
-
return Q.xlsxarchive_sheet_cursor_pull_finished(this.__wbg_ptr) !== 0;
|
|
890
|
-
}
|
|
891
|
-
sheet_cursor_resource_usage() {
|
|
892
|
-
let e = Q.xlsxarchive_sheet_cursor_resource_usage(this.__wbg_ptr);
|
|
893
|
-
if (e[3]) throw q(e[2]);
|
|
894
|
-
var t = z(e[0], e[1]).slice();
|
|
895
|
-
return Q.__wbindgen_free(e[0], e[1] * 1, 1), t;
|
|
896
|
-
}
|
|
897
|
-
to_markdown() {
|
|
898
|
-
let e, t;
|
|
899
|
-
try {
|
|
900
|
-
let i = Q.xlsxarchive_to_markdown(this.__wbg_ptr);
|
|
901
|
-
var n = i[0], r = i[1];
|
|
902
|
-
if (i[3]) throw n = 0, r = 0, q(i[2]);
|
|
903
|
-
return e = n, t = r, V(n, r);
|
|
904
|
-
} finally {
|
|
905
|
-
Q.__wbindgen_free(e, t, 1);
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
Symbol.dispose && (R.prototype[Symbol.dispose] = R.prototype.free);
|
|
910
|
-
function xt(e, t, n, r) {
|
|
911
|
-
let i = G(e, Q.__wbindgen_malloc), a = Z, o = K(t, Q.__wbindgen_malloc, Q.__wbindgen_realloc), s = Z, c = Q.extract_image(i, a, o, s, !W(n), W(n) ? BigInt(0) : n, !W(r), W(r) ? BigInt(0) : r);
|
|
912
|
-
if (c[3]) throw q(c[2]);
|
|
913
|
-
var l = z(c[0], c[1]).slice();
|
|
914
|
-
return Q.__wbindgen_free(c[0], c[1] * 1, 1), l;
|
|
915
|
-
}
|
|
916
|
-
function St(e, t, n) {
|
|
917
|
-
let r = G(e, Q.__wbindgen_malloc), i = Z, a = Q.parse_xlsx(r, i, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n);
|
|
918
|
-
if (a[3]) throw q(a[2]);
|
|
919
|
-
var o = z(a[0], a[1]).slice();
|
|
920
|
-
return Q.__wbindgen_free(a[0], a[1] * 1, 1), o;
|
|
921
|
-
}
|
|
922
|
-
function Ct(e, t, n) {
|
|
923
|
-
let r, i;
|
|
924
|
-
try {
|
|
925
|
-
let s = G(e, Q.__wbindgen_malloc), c = Z, l = Q.xlsx_to_markdown(s, c, !W(t), W(t) ? BigInt(0) : t, !W(n), W(n) ? BigInt(0) : n);
|
|
926
|
-
var a = l[0], o = l[1];
|
|
927
|
-
if (l[3]) throw a = 0, o = 0, q(l[2]);
|
|
928
|
-
return r = a, i = o, V(a, o);
|
|
929
|
-
} finally {
|
|
930
|
-
Q.__wbindgen_free(r, i, 1);
|
|
931
|
-
}
|
|
932
|
-
}
|
|
933
|
-
function wt() {
|
|
934
|
-
return {
|
|
935
|
-
__proto__: null,
|
|
936
|
-
"./xlsx_parser_bg.js": {
|
|
937
|
-
__proto__: null,
|
|
938
|
-
__wbg___wbindgen_throw_6b64449b9b9ed33c: function(e, t) {
|
|
939
|
-
throw Error(V(e, t));
|
|
940
|
-
},
|
|
941
|
-
__wbg_error_a6fa202b58aa1cd3: function(e, t) {
|
|
942
|
-
let n, r;
|
|
943
|
-
try {
|
|
944
|
-
n = e, r = t, console.error(V(e, t));
|
|
945
|
-
} finally {
|
|
946
|
-
Q.__wbindgen_free(n, r, 1);
|
|
947
|
-
}
|
|
948
|
-
},
|
|
949
|
-
__wbg_new_227d7c05414eb861: function() {
|
|
950
|
-
return /* @__PURE__ */ Error();
|
|
951
|
-
},
|
|
952
|
-
__wbg_stack_3b0d974bbf31e44f: function(e, t) {
|
|
953
|
-
let n = t.stack, r = K(n, Q.__wbindgen_malloc, Q.__wbindgen_realloc), i = Z;
|
|
954
|
-
Et().setInt32(e + 4, i, !0), Et().setInt32(e + 0, r, !0);
|
|
955
|
-
},
|
|
956
|
-
__wbindgen_cast_0000000000000001: function(e, t) {
|
|
957
|
-
return V(e, t);
|
|
958
|
-
},
|
|
959
|
-
__wbindgen_init_externref_table: function() {
|
|
960
|
-
let e = Q.__wbindgen_externrefs, t = e.grow(4);
|
|
961
|
-
e.set(0, void 0), e.set(t + 0, void 0), e.set(t + 1, null), e.set(t + 2, !0), e.set(t + 3, !1);
|
|
962
|
-
}
|
|
963
|
-
}
|
|
964
|
-
};
|
|
965
|
-
}
|
|
966
|
-
var Tt = typeof FinalizationRegistry > "u" ? {
|
|
967
|
-
register: () => {},
|
|
968
|
-
unregister: () => {}
|
|
969
|
-
} : new FinalizationRegistry((e) => Q.__wbg_xlsxarchive_free(e >>> 0, 1));
|
|
970
|
-
function z(e, t) {
|
|
971
|
-
return e >>>= 0, U().subarray(e / 1, e / 1 + t);
|
|
972
|
-
}
|
|
973
|
-
var B = null;
|
|
974
|
-
function Et() {
|
|
975
|
-
return (B === null || B.buffer.detached === !0 || B.buffer.detached === void 0 && B.buffer !== Q.memory.buffer) && (B = new DataView(Q.memory.buffer)), B;
|
|
976
|
-
}
|
|
977
|
-
function V(e, t) {
|
|
978
|
-
return e >>>= 0, Ot(e, t);
|
|
979
|
-
}
|
|
980
|
-
var H = null;
|
|
981
|
-
function U() {
|
|
982
|
-
return (H === null || H.byteLength === 0) && (H = new Uint8Array(Q.memory.buffer)), H;
|
|
983
|
-
}
|
|
984
|
-
function W(e) {
|
|
985
|
-
return e == null;
|
|
986
|
-
}
|
|
987
|
-
function G(e, t) {
|
|
988
|
-
let n = t(e.length * 1, 1) >>> 0;
|
|
989
|
-
return U().set(e, n / 1), Z = e.length, n;
|
|
990
|
-
}
|
|
991
|
-
function K(e, t, n) {
|
|
992
|
-
if (n === void 0) {
|
|
993
|
-
let n = X.encode(e), r = t(n.length, 1) >>> 0;
|
|
994
|
-
return U().subarray(r, r + n.length).set(n), Z = n.length, r;
|
|
995
|
-
}
|
|
996
|
-
let r = e.length, i = t(r, 1) >>> 0, a = U(), o = 0;
|
|
997
|
-
for (; o < r; o++) {
|
|
998
|
-
let t = e.charCodeAt(o);
|
|
999
|
-
if (t > 127) break;
|
|
1000
|
-
a[i + o] = t;
|
|
1001
|
-
}
|
|
1002
|
-
if (o !== r) {
|
|
1003
|
-
o !== 0 && (e = e.slice(o)), i = n(i, r, r = o + e.length * 3, 1) >>> 0;
|
|
1004
|
-
let t = U().subarray(i + o, i + r), a = X.encodeInto(e, t);
|
|
1005
|
-
o += a.written, i = n(i, r, o, 1) >>> 0;
|
|
1006
|
-
}
|
|
1007
|
-
return Z = o, i;
|
|
1008
|
-
}
|
|
1009
|
-
function q(e) {
|
|
1010
|
-
let t = Q.__wbindgen_externrefs.get(e);
|
|
1011
|
-
return Q.__externref_table_dealloc(e), t;
|
|
1012
|
-
}
|
|
1013
|
-
var J = new TextDecoder("utf-8", {
|
|
1014
|
-
ignoreBOM: !0,
|
|
1015
|
-
fatal: !0
|
|
1016
|
-
});
|
|
1017
|
-
J.decode();
|
|
1018
|
-
var Dt = 2146435072, Y = 0;
|
|
1019
|
-
function Ot(e, t) {
|
|
1020
|
-
return Y += t, Y >= Dt && (J = new TextDecoder("utf-8", {
|
|
1021
|
-
ignoreBOM: !0,
|
|
1022
|
-
fatal: !0
|
|
1023
|
-
}), J.decode(), Y = t), J.decode(U().subarray(e, e + t));
|
|
1024
|
-
}
|
|
1025
|
-
var X = new TextEncoder();
|
|
1026
|
-
"encodeInto" in X || (X.encodeInto = function(e, t) {
|
|
1027
|
-
let n = X.encode(e);
|
|
1028
|
-
return t.set(n), {
|
|
1029
|
-
read: e.length,
|
|
1030
|
-
written: n.length
|
|
1031
|
-
};
|
|
1032
|
-
});
|
|
1033
|
-
var Z = 0, Q;
|
|
1034
|
-
function kt(e, t) {
|
|
1035
|
-
return Q = e.exports, B = null, H = null, Q.__wbindgen_start(), Q;
|
|
1036
|
-
}
|
|
1037
|
-
async function At(e, t) {
|
|
1038
|
-
if (typeof Response == "function" && e instanceof Response) {
|
|
1039
|
-
if (typeof WebAssembly.instantiateStreaming == "function") try {
|
|
1040
|
-
return await WebAssembly.instantiateStreaming(e, t);
|
|
1041
|
-
} catch (t) {
|
|
1042
|
-
if (e.ok && n(e.type) && e.headers.get("Content-Type") !== "application/wasm") console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", t);
|
|
1043
|
-
else throw t;
|
|
1044
|
-
}
|
|
1045
|
-
let r = await e.arrayBuffer();
|
|
1046
|
-
return await WebAssembly.instantiate(r, t);
|
|
1047
|
-
} else {
|
|
1048
|
-
let n = await WebAssembly.instantiate(e, t);
|
|
1049
|
-
return n instanceof WebAssembly.Instance ? {
|
|
1050
|
-
instance: n,
|
|
1051
|
-
module: e
|
|
1052
|
-
} : n;
|
|
1053
|
-
}
|
|
1054
|
-
function n(e) {
|
|
1055
|
-
switch (e) {
|
|
1056
|
-
case "basic":
|
|
1057
|
-
case "cors":
|
|
1058
|
-
case "default": return !0;
|
|
1059
|
-
}
|
|
1060
|
-
return !1;
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
function jt(e) {
|
|
1064
|
-
if (Q !== void 0) return Q;
|
|
1065
|
-
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module: e} = e : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
1066
|
-
let t = wt();
|
|
1067
|
-
return e instanceof WebAssembly.Module || (e = new WebAssembly.Module(e)), kt(new WebAssembly.Instance(e, t), e);
|
|
1068
|
-
}
|
|
1069
|
-
async function Mt(e) {
|
|
1070
|
-
if (Q !== void 0) return Q;
|
|
1071
|
-
e !== void 0 && (Object.getPrototypeOf(e) === Object.prototype ? {module_or_path: e} = e : console.warn("using deprecated parameters for the initialization function; pass a single object instead"));
|
|
1072
|
-
let t = wt();
|
|
1073
|
-
(typeof e == "string" || typeof Request == "function" && e instanceof Request || typeof URL == "function" && e instanceof URL) && (e = fetch(e));
|
|
1074
|
-
let { instance: n, module: r } = await At(await e, t);
|
|
1075
|
-
return kt(n, r);
|
|
1076
|
-
}
|
|
1077
|
-
async function Nt(e) {
|
|
1078
|
-
return Q = void 0, B = null, H = null, Mt(e);
|
|
1079
|
-
}
|
|
1080
|
-
//#endregion
|
|
1081
|
-
//#region packages/xlsx/src/internal/node-acquisition.ts
|
|
1082
|
-
var Pt, Ft;
|
|
1083
|
-
function It(e) {
|
|
1084
|
-
if (!Ft) Pt = e, Ft = new Te(bt, e);
|
|
1085
|
-
else if (Pt !== e) throw Error("XLSX runtime was already initialized with another WebAssembly.Module");
|
|
1086
|
-
return Ft;
|
|
1087
|
-
}
|
|
1088
|
-
async function Lt(e, t, n = {}) {
|
|
1089
|
-
let r = h(n), i = new s({
|
|
1090
|
-
enabled: r.debug || r.onResourceMetrics !== void 0,
|
|
1091
|
-
format: "xlsx",
|
|
1092
|
-
mode: "node",
|
|
1093
|
-
scope: "session",
|
|
1094
|
-
policy: r.policy,
|
|
1095
|
-
onMetrics: r.onResourceMetrics,
|
|
1096
|
-
emitToConsole: r.debug
|
|
1097
|
-
});
|
|
1098
|
-
i.setSourceBytes(e.byteLength);
|
|
1099
|
-
let a;
|
|
1100
|
-
try {
|
|
1101
|
-
Rt(n.signal);
|
|
1102
|
-
let [o, s, c] = ee(r.policy), l = R;
|
|
1103
|
-
a = await It(t).open(() => new l(e, o, s, c), {
|
|
1104
|
-
signal: n.signal,
|
|
1105
|
-
abortError: zt,
|
|
1106
|
-
disposeOnAbort: (e) => e.free()
|
|
1107
|
-
}), Rt(n.signal);
|
|
1108
|
-
let u = a.proxy, { workbook: d, usage: f } = yt(() => JSON.parse(new TextDecoder().decode(u.parse())), () => u.resource_usage());
|
|
1109
|
-
return i.observeUsage(f), i.checkpoint("workbook index ready"), {
|
|
1110
|
-
archive: u,
|
|
1111
|
-
workbookIndex: d,
|
|
1112
|
-
usage: f,
|
|
1113
|
-
metrics: i,
|
|
1114
|
-
closeArchive: () => a?.close((e) => e.free())
|
|
1115
|
-
};
|
|
1116
|
-
} catch (e) {
|
|
1117
|
-
try {
|
|
1118
|
-
a?.close((e) => e.free());
|
|
1119
|
-
} catch {}
|
|
1120
|
-
let t = u(e) ?? e;
|
|
1121
|
-
throw i.fail(t), t;
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
function Rt(e) {
|
|
1125
|
-
if (e?.aborted) throw zt();
|
|
1126
|
-
}
|
|
1127
|
-
function zt() {
|
|
1128
|
-
let e = /* @__PURE__ */ Error("XLSX workbook session was aborted");
|
|
1129
|
-
return e.name = "AbortError", e;
|
|
1130
|
-
}
|
|
1131
|
-
//#endregion
|
|
1132
|
-
//#region packages/node/src/xlsx.ts
|
|
1133
|
-
var Bt = v(() => y(import.meta.url, "xlsx_parser_bg.wasm", "@silurus/ooxml-xlsx/wasm-binary"));
|
|
1134
|
-
async function $(e, t = {}) {
|
|
1135
|
-
let n = await Lt(Jt(e), Bt(), t);
|
|
1136
|
-
return new Vt(n.closeArchive, n.archive, n.workbookIndex, n.metrics, n.usage, t.signal);
|
|
1137
|
-
}
|
|
1138
|
-
var Vt = class {
|
|
1139
|
-
workbookIndex;
|
|
1140
|
-
sheetCount;
|
|
1141
|
-
sheetNames;
|
|
1142
|
-
pull;
|
|
1143
|
-
transport;
|
|
1144
|
-
worksheetPullClient;
|
|
1145
|
-
active;
|
|
1146
|
-
closed = !1;
|
|
1147
|
-
closePromise;
|
|
1148
|
-
lastUsage;
|
|
1149
|
-
completedWorksheets = 0;
|
|
1150
|
-
rowBatches = 0;
|
|
1151
|
-
emittedRows = 0;
|
|
1152
|
-
constructor(e, t, n, r, i, a) {
|
|
1153
|
-
this.closeArchive = e, this.archive = t, this.metrics = r, this.signal = a, this.workbookIndex = Kt(n), this.sheetNames = Object.freeze(this.workbookIndex.workbook.sheets.map((e) => e.name)), this.sheetCount = this.sheetNames.length, this.lastUsage = i, this.pull = new ve(() => this.archive), this.transport = new _((e, t) => this.pull.dispatchSafely(e, t), () => void 0), this.worksheetPullClient = new be({
|
|
1154
|
-
transport: this.transport,
|
|
1155
|
-
sharedStrings: n.sharedStrings,
|
|
1156
|
-
open: async (e, t, n) => {
|
|
1157
|
-
this.pull.reserveOpen(n), await this.pull.open(e, t, n);
|
|
1158
|
-
},
|
|
1159
|
-
onUsage: (e) => {
|
|
1160
|
-
this.lastUsage = e, this.metrics.observeUsage(e);
|
|
1161
|
-
}
|
|
1162
|
-
});
|
|
1163
|
-
}
|
|
1164
|
-
get resourceUsage() {
|
|
1165
|
-
if (this.closed) return this.lastUsage;
|
|
1166
|
-
try {
|
|
1167
|
-
this.lastUsage = qt(this.archive.resource_usage());
|
|
1168
|
-
} catch {}
|
|
1169
|
-
return this.lastUsage;
|
|
1170
|
-
}
|
|
1171
|
-
async *worksheetRows(e) {
|
|
1172
|
-
if (this.closed) throw Error("XLSX workbook session is closed");
|
|
1173
|
-
if (this.active) throw Error("another XLSX worksheet row stream is already active");
|
|
1174
|
-
if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
|
|
1175
|
-
let t = this.requireSheetName(e), n = {};
|
|
1176
|
-
this.active = n;
|
|
1177
|
-
let r;
|
|
1178
|
-
try {
|
|
1179
|
-
for await (let n of this.worksheetPullClient.stream(e, t, this.signal)) {
|
|
1180
|
-
if (this.closed) throw Error("XLSX workbook session is closed");
|
|
1181
|
-
if (n.kind === "rows") {
|
|
1182
|
-
this.rowBatches += 1, this.emittedRows += n.rows.length, yield {
|
|
1183
|
-
kind: "rows",
|
|
1184
|
-
rows: n.rows,
|
|
1185
|
-
sequence: n.sequence,
|
|
1186
|
-
wireBytes: n.wireBytes,
|
|
1187
|
-
usage: n.usage
|
|
1188
|
-
};
|
|
1189
|
-
continue;
|
|
1190
|
-
}
|
|
1191
|
-
yield {
|
|
1192
|
-
kind: "finished",
|
|
1193
|
-
worksheet: n.worksheet,
|
|
1194
|
-
sequence: n.sequence,
|
|
1195
|
-
wireBytes: n.wireBytes,
|
|
1196
|
-
usage: n.usage
|
|
1197
|
-
};
|
|
1198
|
-
}
|
|
1199
|
-
this.completedWorksheets += 1, this.metrics.checkpoint("worksheet stream complete", this.lastUsage);
|
|
1200
|
-
} catch (e) {
|
|
1201
|
-
throw r = u(e) ?? e, this.metrics.fail(r), await this.close().catch(() => void 0), r;
|
|
1202
|
-
} finally {
|
|
1203
|
-
try {
|
|
1204
|
-
await this.cleanupOperation(n, r === void 0 ? "closed" : "request-error");
|
|
1205
|
-
} catch (e) {
|
|
1206
|
-
if (r === void 0) {
|
|
1207
|
-
let t = u(e) ?? e;
|
|
1208
|
-
throw this.metrics.fail(t), await this.close().catch(() => void 0), t;
|
|
1209
|
-
}
|
|
1210
|
-
}
|
|
1211
|
-
}
|
|
1212
|
-
}
|
|
1213
|
-
close() {
|
|
1214
|
-
return this.closePromise ? this.closePromise : (this.closed = !0, this.closePromise = this.release(), this.closePromise);
|
|
1215
|
-
}
|
|
1216
|
-
cleanupOperation(e, t) {
|
|
1217
|
-
return e.cleanupPromise ||= (async () => {
|
|
1218
|
-
let n;
|
|
1219
|
-
try {
|
|
1220
|
-
await this.worksheetPullClient.cancelAll(t);
|
|
1221
|
-
} catch (e) {
|
|
1222
|
-
n = u(e) ?? e;
|
|
1223
|
-
}
|
|
1224
|
-
try {
|
|
1225
|
-
await this.pull.reset();
|
|
1226
|
-
} catch (e) {
|
|
1227
|
-
n ??= u(e) ?? e;
|
|
1228
|
-
}
|
|
1229
|
-
if (this.active === e && (this.active = void 0), n !== void 0) throw n;
|
|
1230
|
-
})(), e.cleanupPromise;
|
|
1231
|
-
}
|
|
1232
|
-
async release() {
|
|
1233
|
-
let e;
|
|
1234
|
-
if (this.active) try {
|
|
1235
|
-
await this.cleanupOperation(this.active, "closed");
|
|
1236
|
-
} catch (t) {
|
|
1237
|
-
e = u(t) ?? t;
|
|
1238
|
-
}
|
|
1239
|
-
this.transport.terminate();
|
|
1240
|
-
try {
|
|
1241
|
-
this.closeArchive();
|
|
1242
|
-
} catch (t) {
|
|
1243
|
-
e ??= u(t) ?? t;
|
|
1244
|
-
}
|
|
1245
|
-
if (e !== void 0) throw this.metrics.fail(e), e;
|
|
1246
|
-
this.metrics.checkpoint("workbook session closed", this.lastUsage), this.metrics.succeed({
|
|
1247
|
-
worksheets: this.completedWorksheets,
|
|
1248
|
-
"row-batches": this.rowBatches,
|
|
1249
|
-
rows: this.emittedRows
|
|
1250
|
-
});
|
|
1251
|
-
}
|
|
1252
|
-
requireSheetName(e) {
|
|
1253
|
-
let t = this.workbookIndex.workbook.sheets[e];
|
|
1254
|
-
if (!t) throw RangeError(`Sheet index ${e} out of range`);
|
|
1255
|
-
return t.name;
|
|
1256
|
-
}
|
|
1257
|
-
};
|
|
1258
|
-
async function Ht(e, t = {}) {
|
|
1259
|
-
return g(() => $(e, t), async (e) => structuredClone(e.workbookIndex));
|
|
1260
|
-
}
|
|
1261
|
-
async function Ut(e, t, n = {}) {
|
|
1262
|
-
return g(() => $(e, n), async (e) => (await Gt(e, t)).worksheet);
|
|
1263
|
-
}
|
|
1264
|
-
async function Wt(e, t = {}) {
|
|
1265
|
-
return g(() => $(e, t), async (e) => {
|
|
1266
|
-
let t = [], n = {
|
|
1267
|
-
rows: 0,
|
|
1268
|
-
cells: 0,
|
|
1269
|
-
ownedUtf8Bytes: 0,
|
|
1270
|
-
jsonBytes: 0
|
|
1271
|
-
};
|
|
1272
|
-
for (let r = 0; r < e.sheetCount; r += 1) {
|
|
1273
|
-
let i = await Gt(e, r), a = _e(n, i.usage);
|
|
1274
|
-
pe(a, "materialize-workbook", void 0, i.resourceUsage), n = a, t.push(i.worksheet);
|
|
1275
|
-
}
|
|
1276
|
-
return {
|
|
1277
|
-
workbookIndex: structuredClone(e.workbookIndex),
|
|
1278
|
-
worksheets: Object.freeze(t)
|
|
1279
|
-
};
|
|
1280
|
-
});
|
|
1281
|
-
}
|
|
1282
|
-
async function Gt(e, t) {
|
|
1283
|
-
let n = [], r = {
|
|
1284
|
-
rows: 0,
|
|
1285
|
-
cells: 0,
|
|
1286
|
-
ownedUtf8Bytes: 0
|
|
1287
|
-
}, i, a, o;
|
|
1288
|
-
for await (let s of e.worksheetRows(t)) if (o = s.usage ?? o, s.kind === "rows") {
|
|
1289
|
-
let e = ye(r, he(s.rows));
|
|
1290
|
-
xe(e, "materialize-worksheet", void 0, o), n.push(...s.rows), r = e;
|
|
1291
|
-
} else {
|
|
1292
|
-
a = s.worksheet, a.rows = a.parseError ? [] : n;
|
|
1293
|
-
let e = me(a, a.parseError ? {
|
|
1294
|
-
rows: 0,
|
|
1295
|
-
cells: 0,
|
|
1296
|
-
ownedUtf8Bytes: 0
|
|
1297
|
-
} : r);
|
|
1298
|
-
xe(e, "materialize-worksheet", void 0, o), ge(e.jsonBytes, "materialize-worksheet", void 0, o), r = e, i = e;
|
|
1299
|
-
}
|
|
1300
|
-
if (!a || !i) throw Error(`XLSX worksheet ${t} did not produce a terminal model`);
|
|
1301
|
-
return {
|
|
1302
|
-
worksheet: a,
|
|
1303
|
-
usage: i,
|
|
1304
|
-
resourceUsage: o
|
|
1305
|
-
};
|
|
1306
|
-
}
|
|
1307
|
-
function Kt(e, t = /* @__PURE__ */ new WeakSet()) {
|
|
1308
|
-
if (typeof e != "object" || !e) return e;
|
|
1309
|
-
let n = e;
|
|
1310
|
-
if (t.has(n)) return e;
|
|
1311
|
-
t.add(n);
|
|
1312
|
-
for (let e of Object.values(n)) Kt(e, t);
|
|
1313
|
-
return Object.freeze(e);
|
|
1314
|
-
}
|
|
1315
|
-
function qt(e) {
|
|
1316
|
-
try {
|
|
1317
|
-
return i(e);
|
|
1318
|
-
} catch (e) {
|
|
1319
|
-
if (String(e).includes("worksheet cursor usage is unavailable")) return;
|
|
1320
|
-
throw e;
|
|
1321
|
-
}
|
|
1322
|
-
}
|
|
1323
|
-
function Jt(e) {
|
|
1324
|
-
return e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
1325
|
-
}
|
|
1326
|
-
//#endregion
|
|
1327
|
-
export { le as OoxmlDecodedImageLimitError, m as OoxmlResourceLimitError, ke as installImageBitmapShim, De as installOffscreenCanvasShim, ce as isOoxmlDecodedImageLimitError, mt as materializeDocxDocument, He as materializePptxPresentation, Wt as materializeXlsxWorkbook, Ht as materializeXlsxWorkbookIndex, Ut as materializeXlsxWorksheet, pt as openDocxDocument, ze as openPptxPresentation, $ as openXlsxWorkbook, Oe as renderSlideNode };
|
|
1
|
+
import { vo as e, yo as t } from "./plot-area-frame-Bs_j4uu7.js";
|
|
2
|
+
import { f as n, u as r } from "./pixel-budget-BpTYrepD.js";
|
|
3
|
+
import { n as i, r as a } from "./pptx-CaJ6ILnw.js";
|
|
4
|
+
import { n as o, r as s } from "./docx-BN70UhvX.js";
|
|
5
|
+
import { n as c, r as l, t as u } from "./render-CzbDzRKa.js";
|
|
6
|
+
import { a as d, i as f, n as p, r as m } from "./xlsx-DmHfeNNp.js";
|
|
7
|
+
export { r as OoxmlDecodedImageLimitError, e as OoxmlError, t as OoxmlResourceLimitError, u as installImageBitmapShim, c as installOffscreenCanvasShim, n as isOoxmlDecodedImageLimitError, o as materializeDocxDocument, i as materializePptxPresentation, p as materializeXlsxWorkbook, m as materializeXlsxWorkbookIndex, f as materializeXlsxWorksheet, s as openDocxDocument, a as openPptxPresentation, d as openXlsxWorkbook, l as renderSlideNode };
|