@silurus/ooxml 0.75.5 → 0.76.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.
Files changed (52) hide show
  1. package/README.md +66 -28
  2. package/dist/bounded-raw-part-cache-C6ro6Ezf.js +254 -0
  3. package/dist/{find-cursor-Dc5iM6s7.js → canvas-viewer-mechanics-CwVSOYke.js} +192 -64
  4. package/dist/{document-pull-client-BcNYhoAG.js → document-pull-client-AAnwzlig.js} +3625 -3601
  5. package/dist/docx-CCksIXd5.js +1301 -0
  6. package/dist/docx.mjs +4 -6
  7. package/dist/docx_parser_bg.wasm +0 -0
  8. package/dist/index.mjs +3 -3
  9. package/dist/{line-distribute-B8sqT8kC.js → line-distribute-C1r2zvji.js} +141 -141
  10. package/dist/{line-metrics-D9gqQWHl.js → line-metrics-BdCACYlq.js} +4026 -1170
  11. package/dist/math.mjs +1 -1
  12. package/dist/node.mjs +779 -465
  13. package/dist/pptx-CKAk5e-J.js +1735 -0
  14. package/dist/pptx.mjs +5 -7
  15. package/dist/pptx_parser_bg.wasm +0 -0
  16. package/dist/{render-CalC7GX4.js → render-CLcpSi0m.js} +11 -18
  17. package/dist/render-worker-host-B8HAb_sK.js +27 -0
  18. package/dist/render-worker-host-Bkf1jUcW.js +27 -0
  19. package/dist/render-worker-host-CKOmXdyr.js +27 -0
  20. package/dist/resource-measurement-E_S_iau4.js +119 -0
  21. package/dist/session-B4Y54cbT.js +730 -0
  22. package/dist/{renderer-B9R6F_QY.js → slide-pull-client-WCuYCjio.js} +973 -820
  23. package/dist/types/docx.d.ts +1181 -3994
  24. package/dist/types/index.d.ts +2733 -8171
  25. package/dist/types/math.d.ts +8 -33
  26. package/dist/types/node.d.ts +1852 -4433
  27. package/dist/types/pptx.d.ts +1030 -3678
  28. package/dist/types/xlsx.d.ts +1291 -3262
  29. package/dist/worksheet-pull-client-YzjJMOns.js +455 -0
  30. package/dist/xlsx-BBmmZNQn.js +6362 -0
  31. package/dist/xlsx.mjs +5 -7
  32. package/dist/xlsx_parser_bg.wasm +0 -0
  33. package/package.json +14 -7
  34. package/dist/bounded-raw-part-cache-BTfZD_Sz.js +0 -1248
  35. package/dist/docx-DjF8FgoP.js +0 -1274
  36. package/dist/duotone-bitmap-by-path-CWsSJkJu.js +0 -28
  37. package/dist/hyperlink-D85FexTa.js +0 -27
  38. package/dist/pptx-C17xP8AV.js +0 -1705
  39. package/dist/pptx-Dl8tOSmP.js +0 -822
  40. package/dist/preload-BEouWnlI.js +0 -132
  41. package/dist/render-worker-host-BG3a7brz.js +0 -27
  42. package/dist/render-worker-host-CsB-dPJv.js +0 -27
  43. package/dist/render-worker-host-Cyv5Hkbh.js +0 -27
  44. package/dist/resource-measurement-6aReN3K0.js +0 -93
  45. package/dist/slide-pull-client-D_T0AIoX.js +0 -175
  46. package/dist/svg-image-by-path-C1M3N2pT.js +0 -1623
  47. package/dist/worksheet-pull-worker-DCei8u-4.js +0 -347
  48. package/dist/xlsx-BaH9irS0.js +0 -5515
  49. /package/dist/{highlight-rect-cCvVU-MW.js → highlight-rect-CAkCWJ37.js} +0 -0
  50. /package/dist/{mathjax-Dqo857oC.js → mathjax-CMjda8Ip.js} +0 -0
  51. /package/dist/{transfer-3QEJrsJa.js → transfer-DCu4c2BL.js} +0 -0
  52. /package/dist/{visible-index-CKvgpUrf.js → visible-index-CgyJLAS_.js} +0 -0
@@ -0,0 +1,455 @@
1
+ import { $ as e, F as t, I as n, N as r, P as i, Q as a, X as o, Y as s, Z as c, et as l, hn as u, nt as d, ot as f, rt as p, tt as m } from "./line-metrics-BdCACYlq.js";
2
+ import { n as h, r as g, t as _ } from "./resource-measurement-E_S_iau4.js";
3
+ import { t as v } from "./transfer-DCu4c2BL.js";
4
+ //#region packages/xlsx/src/worksheet-resource-limits.ts
5
+ var y = d, b = e, x = l, S = m, C = a, w = s, T = o, E = c, D = Object.freeze({
6
+ archiveEntryCount: 0,
7
+ declaredInflatedBytes: 0,
8
+ distinctInflatedBytes: 0,
9
+ operationInflatedBytes: 0
10
+ });
11
+ function O(e) {
12
+ let t = e.reduce((e, t) => _(e, t.cells.length, b), 0);
13
+ return {
14
+ rows: e.length,
15
+ cells: t,
16
+ ownedUtf8Bytes: e.reduce((e, t) => t.cells.reduce((e, t) => {
17
+ let n = h(t.value, x).stringValueUtf8Bytes;
18
+ return _(e, _(n, t.formula === void 0 ? 0 : g(t.formula, x), x), x);
19
+ }, e), 0)
20
+ };
21
+ }
22
+ function k(e, t) {
23
+ let n = h(e, Math.max(x, S));
24
+ return {
25
+ ...t,
26
+ jsonBytes: n.jsonBytes
27
+ };
28
+ }
29
+ function A(e, t) {
30
+ return {
31
+ rows: _(e.rows, t.rows, y),
32
+ cells: _(e.cells, t.cells, b),
33
+ ownedUtf8Bytes: _(e.ownedUtf8Bytes, t.ownedUtf8Bytes, x)
34
+ };
35
+ }
36
+ function j(e, t, n = {}) {
37
+ let r = e.rows - (n.rows ?? 0), i = e.cells - (n.cells ?? 0), a = e.ownedUtf8Bytes - (n.ownedUtf8Bytes ?? 0), o = e.jsonBytes - (n.jsonBytes ?? 0);
38
+ if (r < 0 || i < 0 || a < 0 || o < 0) throw Error("worksheet cache accounting underflow");
39
+ return {
40
+ rows: _(r, t.rows, C),
41
+ cells: _(i, t.cells, w),
42
+ ownedUtf8Bytes: _(a, t.ownedUtf8Bytes, T),
43
+ jsonBytes: _(o, t.jsonBytes, E)
44
+ };
45
+ }
46
+ function M(e, t, n, r, i, a, o) {
47
+ let s = n === "worksheet-json" ? "serialization" : "parsing";
48
+ return new u(`OOXML resource limit exceeded${t ? ` for ${t}` : ""}: ${r} ${a} > ${i}`, {
49
+ stage: s,
50
+ violation: {
51
+ format: "xlsx",
52
+ operation: e,
53
+ resource: n,
54
+ metric: r,
55
+ ...t === void 0 ? {} : { part: t },
56
+ limit: i,
57
+ observed: Math.min(a, i + 1),
58
+ configurable: !1,
59
+ usage: o ?? D
60
+ }
61
+ });
62
+ }
63
+ function N(e, t, n, r) {
64
+ let i = [
65
+ [
66
+ "rows",
67
+ e.rows,
68
+ y
69
+ ],
70
+ [
71
+ "cells",
72
+ e.cells,
73
+ b
74
+ ],
75
+ [
76
+ "owned-utf8-bytes",
77
+ e.ownedUtf8Bytes,
78
+ x
79
+ ]
80
+ ];
81
+ for (let [e, a, o] of i) if (a > o) throw M(t, n, e === "owned-utf8-bytes" ? "worksheet-cell-content" : "worksheet-model", e, o, a, r);
82
+ }
83
+ function P(e, t, n, r) {
84
+ if (e > S) throw M(t, n, "worksheet-json", "bytes", S, e, r);
85
+ }
86
+ function F(e, t, n, r) {
87
+ if (e.rows > C) throw M(t, n, "worksheet-cache", "rows", C, e.rows, r);
88
+ if (e.cells > w) throw M(t, n, "worksheet-cache", "cells", w, e.cells, r);
89
+ if (e.ownedUtf8Bytes > T) throw M(t, n, "worksheet-cache", "owned-utf8-bytes", T, e.ownedUtf8Bytes, r);
90
+ if (e.jsonBytes > E) throw M(t, n, "worksheet-cache", "bytes", E, e.jsonBytes, r);
91
+ }
92
+ //#endregion
93
+ //#region packages/xlsx/src/shared-strings.ts
94
+ function I(e, t) {
95
+ return L(e.rows, t), e;
96
+ }
97
+ function L(e, t) {
98
+ for (let n of e) for (let e of n.cells) {
99
+ let n = e.value;
100
+ if (n.type === "shared") {
101
+ let r = t[n.si];
102
+ if (r) {
103
+ let t = {
104
+ type: "text",
105
+ text: r.text
106
+ };
107
+ r.runs !== void 0 && (t.runs = r.runs), r.phoneticRuns !== void 0 && (t.phoneticRuns = r.phoneticRuns), r.phoneticPr !== void 0 && (t.phoneticPr = r.phoneticPr), e.value = t;
108
+ } else e.value = {
109
+ type: "text",
110
+ text: ""
111
+ };
112
+ }
113
+ }
114
+ return e;
115
+ }
116
+ //#endregion
117
+ //#region packages/xlsx/src/worksheet-pull-codec.ts
118
+ function R(e, t, n, r) {
119
+ let i = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), a = JSON.parse(new TextDecoder().decode(i));
120
+ if (!a || typeof a != "object" || !("kind" in a)) throw Error("worksheet cursor returned an invalid unit");
121
+ let o = a;
122
+ if (t !== (o.kind === "finished")) throw Error("worksheet cursor terminal marker mismatch");
123
+ if (o.kind === "rows") {
124
+ if (!Array.isArray(o.rows)) throw Error("worksheet row unit is missing rows");
125
+ return n && L(o.rows, n), r?.(o.rows), {
126
+ kind: "rows",
127
+ rows: o.rows
128
+ };
129
+ }
130
+ if (o.kind === "finished") {
131
+ if (!o.worksheet || typeof o.worksheet != "object") throw Error("worksheet terminal unit is missing its worksheet");
132
+ return o.worksheet.rows = [], {
133
+ kind: "finished",
134
+ worksheet: o.worksheet
135
+ };
136
+ }
137
+ throw Error("worksheet cursor returned an unknown unit kind");
138
+ }
139
+ //#endregion
140
+ //#region packages/xlsx/src/worksheet-pull-worker.ts
141
+ var z = 64 * 1024 * 1024, B = class {
142
+ coordinator = new n();
143
+ sessions = /* @__PURE__ */ new Map();
144
+ operationTail = Promise.resolve();
145
+ pendingOpens = /* @__PURE__ */ new Map();
146
+ resourceFailure;
147
+ constructor(e, t, n = (e) => e(this.requireArchive()), r) {
148
+ this.archive = e, this.acceptWorksheet = t, this.executeArchive = n, this.prepareRows = r;
149
+ }
150
+ reserveOpen(e) {
151
+ this.pendingOpens.set(e.sessionId, {
152
+ identity: e,
153
+ canceled: !1
154
+ });
155
+ }
156
+ abandonOpen(e) {
157
+ this.pendingOpens.delete(e);
158
+ }
159
+ get pendingOpenCount() {
160
+ return this.pendingOpens.size;
161
+ }
162
+ async open(e, n, r) {
163
+ if (this.resourceFailure) throw this.resourceFailure;
164
+ let i = this.pendingOpens.get(r.sessionId);
165
+ if (!i || i.identity.operationId !== r.operationId || i.identity.generation !== r.generation) throw Error("worksheet pull session open reservation is stale or missing");
166
+ let a, o = new Promise((e) => {
167
+ a = e;
168
+ }), s = this.operationTail.then(() => this.coordinator.enqueue(async () => {
169
+ if (i.canceled) throw Error("worksheet pull session open was canceled");
170
+ this.executeArchive((t) => t.open_sheet_cursor(e, n));
171
+ let o = [], s = {
172
+ rows: 0,
173
+ cells: 0,
174
+ ownedUtf8Bytes: 0
175
+ }, c, l = !1, d = new t({
176
+ ...r,
177
+ maxByteCredit: z,
178
+ coordinator: this.coordinator,
179
+ driver: {
180
+ pull: () => {
181
+ let e = this.executeArchive((e) => e.pull_sheet_cursor(128)), t = this.executeArchive((e) => e.sheet_cursor_pull_finished());
182
+ if (this.acceptWorksheet) {
183
+ let n = R(e, t, void 0, this.prepareRows);
184
+ try {
185
+ if (n.kind === "rows") {
186
+ let e = A(s, O(n.rows));
187
+ N(e, "get-worksheet-worker", void 0, this.readResourceUsage()), o.push(...n.rows), s = e;
188
+ } else c = n.worksheet;
189
+ } catch (e) {
190
+ throw e instanceof u && (this.resourceFailure ??= e), e;
191
+ }
192
+ }
193
+ l = t;
194
+ let n = v(e);
195
+ return {
196
+ payload: n,
197
+ byteLength: n.byteLength,
198
+ done: t,
199
+ transfer: [n]
200
+ };
201
+ },
202
+ measureChunk: ({ payload: e }) => e.byteLength,
203
+ acknowledge: () => {
204
+ if (!l) return;
205
+ let t, n;
206
+ try {
207
+ if (this.acceptWorksheet) {
208
+ if (!c) throw Error("worksheet terminal payload is missing");
209
+ c.rows = c.parseError ? [] : o;
210
+ let r = c.parseError ? {
211
+ rows: 0,
212
+ cells: 0,
213
+ ownedUtf8Bytes: 0
214
+ } : s, i = k(c, r), a = this.readResourceUsage();
215
+ N(i, "get-worksheet-worker", void 0, a), P(i.jsonBytes, "get-worksheet-worker", void 0, a);
216
+ let l = this.acceptWorksheet(e, c, i, a);
217
+ typeof l == "function" ? t = l : l && ({rollback: t, commit: n} = l);
218
+ }
219
+ this.executeArchive((e) => e.acknowledge_sheet_cursor_terminal()), n?.();
220
+ } catch (e) {
221
+ throw t?.(), e instanceof u && (this.resourceFailure ??= e), e;
222
+ }
223
+ l = !1, this.sessions.delete(r.sessionId), a();
224
+ },
225
+ cancel: () => {
226
+ try {
227
+ this.archive() && this.executeArchive((e) => e.cancel_sheet_cursor());
228
+ } finally {
229
+ this.sessions.delete(r.sessionId), a();
230
+ }
231
+ },
232
+ close: () => {
233
+ try {
234
+ this.archive() && this.executeArchive((e) => e.close_sheet_cursor());
235
+ } finally {
236
+ this.sessions.delete(r.sessionId), a();
237
+ }
238
+ },
239
+ resourceUsage: () => this.readResourceUsage()
240
+ }
241
+ });
242
+ this.sessions.set(r.sessionId, {
243
+ host: d,
244
+ identity: r
245
+ }), this.pendingOpens.delete(r.sessionId);
246
+ }));
247
+ this.operationTail = s.then(() => o, () => void 0);
248
+ try {
249
+ await s;
250
+ } catch (e) {
251
+ throw this.pendingOpens.delete(r.sessionId), a(), e;
252
+ }
253
+ }
254
+ async postOpenedSafely(e, t, n) {
255
+ try {
256
+ t();
257
+ } catch (t) {
258
+ await this.closeIdentity(e);
259
+ try {
260
+ n(t);
261
+ } catch {}
262
+ }
263
+ }
264
+ dispatch(e, t) {
265
+ let n = this.sessions.get(e.sessionId);
266
+ if (n) return n.host.dispatch(e, t);
267
+ let r = this.pendingOpens.get(e.sessionId);
268
+ if (r && (e.kind === "cancel" || e.kind === "close")) {
269
+ let n = r.identity.operationId === e.operationId && r.identity.generation === e.generation;
270
+ return n && (r.canceled = !0), t(n ? {
271
+ protocol: i,
272
+ kind: "accepted",
273
+ sessionId: e.sessionId,
274
+ operationId: e.operationId,
275
+ generation: e.generation,
276
+ requestId: e.requestId,
277
+ command: e.kind
278
+ } : {
279
+ protocol: i,
280
+ kind: "error",
281
+ sessionId: e.sessionId,
282
+ operationId: e.operationId,
283
+ generation: e.generation,
284
+ requestId: e.requestId,
285
+ error: {
286
+ message: "stale lifecycle targets another pending worksheet operation",
287
+ errorName: "PullSessionProtocolError",
288
+ code: "ooxml-stale-lifecycle"
289
+ }
290
+ }), Promise.resolve();
291
+ }
292
+ return e.kind === "cancel" || e.kind === "close" ? (t({
293
+ protocol: i,
294
+ kind: "accepted",
295
+ sessionId: e.sessionId,
296
+ operationId: e.operationId,
297
+ generation: e.generation,
298
+ requestId: e.requestId,
299
+ command: e.kind
300
+ }), Promise.resolve()) : (t({
301
+ protocol: i,
302
+ kind: "error",
303
+ sessionId: e.sessionId,
304
+ operationId: e.operationId,
305
+ generation: e.generation,
306
+ requestId: e.requestId,
307
+ error: f(/* @__PURE__ */ Error("worksheet pull session is not open"))
308
+ }), Promise.resolve());
309
+ }
310
+ async dispatchSafely(e, t) {
311
+ try {
312
+ await this.dispatch(e, t);
313
+ } catch (n) {
314
+ try {
315
+ t({
316
+ protocol: i,
317
+ kind: "error",
318
+ sessionId: e.sessionId,
319
+ operationId: e.operationId,
320
+ generation: e.generation,
321
+ requestId: e.requestId,
322
+ error: f(n)
323
+ });
324
+ } catch {}
325
+ }
326
+ }
327
+ run(e) {
328
+ let t = this.operationTail.then(() => this.coordinator.enqueue(async () => {
329
+ if (this.resourceFailure) throw this.resourceFailure;
330
+ return e();
331
+ })).catch((e) => {
332
+ throw e instanceof u && (this.resourceFailure ??= e), e;
333
+ });
334
+ return this.operationTail = t.then(() => void 0, () => void 0), t;
335
+ }
336
+ async reset() {
337
+ for (let e of this.pendingOpens.values()) e.canceled = !0;
338
+ let e = 1;
339
+ for (let { host: t, identity: n } of [...this.sessions.values()]) await t.dispatch({
340
+ protocol: i,
341
+ kind: "close",
342
+ ...n,
343
+ requestId: e++
344
+ }, () => void 0);
345
+ this.sessions.clear(), await this.operationTail, this.pendingOpens.clear(), this.resourceFailure = void 0;
346
+ }
347
+ requireArchive() {
348
+ let e = this.archive();
349
+ if (!e) throw Error("Workbook not loaded");
350
+ return e;
351
+ }
352
+ async closeIdentity(e) {
353
+ let t = this.sessions.get(e.sessionId);
354
+ if (t) {
355
+ await t.host.dispatch({
356
+ protocol: i,
357
+ kind: "close",
358
+ ...e,
359
+ requestId: 1
360
+ }, () => void 0);
361
+ return;
362
+ }
363
+ let n = this.pendingOpens.get(e.sessionId);
364
+ n && n.identity.operationId === e.operationId && n.identity.generation === e.generation && (n.canceled = !0);
365
+ }
366
+ readResourceUsage() {
367
+ try {
368
+ return p(this.executeArchive((e) => e.sheet_cursor_resource_usage()));
369
+ } catch (e) {
370
+ if (String(e).includes("worksheet cursor usage is unavailable")) return;
371
+ throw e;
372
+ }
373
+ }
374
+ }, V = class {
375
+ active = /* @__PURE__ */ new Set();
376
+ nextSessionId = 1;
377
+ constructor(e) {
378
+ if (this.options = e, e.generation !== void 0 && (!Number.isSafeInteger(e.generation) || e.generation <= 0)) throw TypeError("generation must be a positive safe integer");
379
+ }
380
+ async *stream(e, t, n) {
381
+ if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
382
+ if (!t) throw TypeError("sheetName must be non-empty");
383
+ W(n);
384
+ let i = this.nextSessionId++, a = {
385
+ sessionId: i,
386
+ operationId: i,
387
+ generation: this.options.generation ?? 1
388
+ }, o = new r(this.options.transport, {
389
+ ...a,
390
+ maxByteCredit: z,
391
+ timeoutMs: this.options.timeoutMs,
392
+ disposeTransferred: this.options.disposeTransferred
393
+ });
394
+ this.active.add(o);
395
+ let s = !1, c;
396
+ try {
397
+ for (await this.options.open(e, t, a, this.options.timeoutMs);;) {
398
+ W(n);
399
+ let e = await o.pull(z, { signal: n });
400
+ try {
401
+ let t = e.usage ?? o.usageCheckpoint;
402
+ t && this.options.onUsage?.(t);
403
+ let r = R(e.payload, e.done, this.options.sharedStrings);
404
+ if (yield r.kind === "rows" ? {
405
+ kind: "rows",
406
+ rows: r.rows,
407
+ sequence: e.sequence,
408
+ wireBytes: e.byteLength,
409
+ usage: t
410
+ } : {
411
+ kind: "finished",
412
+ worksheet: r.worksheet,
413
+ sequence: e.sequence,
414
+ wireBytes: e.byteLength,
415
+ usage: t
416
+ }, await e.ack({ signal: n }), r.kind === "finished") {
417
+ s = !0;
418
+ return;
419
+ }
420
+ } finally {
421
+ e.disposeTransferred();
422
+ }
423
+ }
424
+ } catch (e) {
425
+ throw c = e, e;
426
+ } finally {
427
+ let e;
428
+ try {
429
+ s || await o.cancel(U(c));
430
+ } catch (t) {
431
+ e = t;
432
+ } finally {
433
+ this.active.delete(o);
434
+ }
435
+ if (c === void 0 && e !== void 0) throw e;
436
+ }
437
+ }
438
+ async cancelAll(e = "closed") {
439
+ let t = (await Promise.allSettled([...this.active].map((t) => t.cancel(e)))).find((e) => e.status === "rejected");
440
+ if (t) throw t.reason;
441
+ }
442
+ };
443
+ function H(e) {
444
+ return !!e && typeof e == "object" && e.protocol === "ooxml-pull-v1";
445
+ }
446
+ function U(e) {
447
+ return e && typeof e == "object" && "name" in e && e.name === "AbortError" ? "abort" : e === void 0 ? "closed" : "request-error";
448
+ }
449
+ function W(e) {
450
+ if (!e?.aborted) return;
451
+ let t = /* @__PURE__ */ Error("XLSX workbook session was aborted");
452
+ throw t.name = "AbortError", t;
453
+ }
454
+ //#endregion
455
+ export { j as a, P as c, O as d, I as i, N as l, H as n, A as o, B as r, F as s, V as t, k as u };