@silurus/ooxml 0.87.0 → 0.89.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. package/README.md +118 -23
  2. package/THIRD_PARTY_NOTICES.md +7 -6
  3. package/dist/abort-VrnK7mdP.js +10 -0
  4. package/dist/assets/render-worker-CUOU6mL2.js +16 -0
  5. package/dist/assets/render-worker-DOqrFhSU.js +15 -0
  6. package/dist/assets/render-worker-DvWUdZUN.js +35 -0
  7. package/dist/bounded-raw-part-cache-B7JoC1CD.js +64586 -0
  8. package/dist/bundled-asset-url-E2nXURF9.js +15 -0
  9. package/dist/canvas-viewer-mechanics-DfQqRKkD.js +675 -0
  10. package/dist/cfb-guard-9QTRTg7f.js +528 -0
  11. package/dist/chart-ex.mjs +708 -739
  12. package/dist/comment-overlay-controller-B5_zGgG5.js +994 -0
  13. package/dist/comment-ui-runtime-B7ZvovcS.js +2 -0
  14. package/dist/{comment-ui-runtime-DcJOYlw-.js → comment-ui-runtime-D_sb2K6s.js} +5 -5
  15. package/dist/{comment-ui-runtime-BfE7MJZn.js → comment-ui-runtime-Jy-3goA9.js} +5 -5
  16. package/dist/delimited-text-worker-host-CikWU6_m.js +27 -0
  17. package/dist/document-model-source-BKNrXjAL.js +249 -0
  18. package/dist/document-pull-client-CxONDGbk.js +37833 -0
  19. package/dist/document-pull-worker-AMyXYpPq.js +104 -0
  20. package/dist/docx-D91ER1_S.js +495 -0
  21. package/dist/docx-DhDnKEI6.js +3563 -0
  22. package/dist/docx-model-source-CdrSt3hF.js +98 -0
  23. package/dist/docx-source-worker.mjs +455 -0
  24. package/dist/docx.mjs +7 -7
  25. package/dist/docx_parser_bg.wasm +0 -0
  26. package/dist/drawingml-shape-ChcGZNd8.js +310 -0
  27. package/dist/duotone-ekYik4ix.js +126 -0
  28. package/dist/emf-UT6I8rVi.js +1790 -0
  29. package/dist/font-preload-demand-CdJZUMCT.js +2058 -0
  30. package/dist/grid-geometry-uQOgViJU.js +384 -0
  31. package/dist/host-layout-DVMw8hDY.js +56 -0
  32. package/dist/host-layout-measure-CCEgaC_v.js +7 -0
  33. package/dist/in-process-pull-transport-DuXcPZng.js +29 -0
  34. package/dist/index.mjs +4 -4
  35. package/dist/internal-companion.mjs +12 -0
  36. package/dist/line-distribute-CPOV6csk.js +2716 -0
  37. package/dist/math.mjs +2 -2
  38. package/dist/mathjax-stix2.js +10 -10
  39. package/dist/model-source-DJGzDtGb.js +61 -0
  40. package/dist/model-source-kz_NkZqT.js +179 -0
  41. package/dist/model-source-session-Bu9CHFHc.js +71 -0
  42. package/dist/model-source-session-CDuijwv1.js +85 -0
  43. package/dist/model-source-session-sKpNiIJI.js +58 -0
  44. package/dist/node.mjs +7 -1327
  45. package/dist/{pixel-budget-Dgjw269h.js → pixel-budget-BpTYrepD.js} +13 -10
  46. package/dist/plot-area-frame-CaJFvZ7p.js +8502 -0
  47. package/dist/pptx-CDP9dZHe.js +2936 -0
  48. package/dist/pptx-C_uxLVKB.js +183 -0
  49. package/dist/pptx-model-source-O7LhpOjz.js +37 -0
  50. package/dist/pptx-source-worker.mjs +446 -0
  51. package/dist/pptx.mjs +8 -7
  52. package/dist/pptx_parser_bg.wasm +0 -0
  53. package/dist/presentation-model-source-tmROzteR.js +77 -0
  54. package/dist/raster-target-YQ4G6rxo.js +42 -0
  55. package/dist/region-map.mjs +114 -150
  56. package/dist/{render-8Zo7dnds.js → render-CJVglUHl.js} +3 -3
  57. package/dist/{render-worker-host-BfbnEChF.js → render-worker-host-BseIaVvm.js} +1 -1
  58. package/dist/{render-worker-host-DNL9dWRh.js → render-worker-host-CyxPU4JU.js} +1 -1
  59. package/dist/{render-worker-host-IkHrYOci.js → render-worker-host-aF6aWkC0.js} +1 -1
  60. package/dist/renderer-CkGLj0CC.js +5170 -0
  61. package/dist/renderer-Czw1cCC7.js +5823 -0
  62. package/dist/resource-measurement-mXw-WjMF.js +771 -0
  63. package/dist/session-Csv9maad.js +656 -0
  64. package/dist/slide-pull-client-DRZYwBTu.js +6515 -0
  65. package/dist/three-d-BK5siJgJ.js +878 -0
  66. package/dist/three-d.mjs +871 -764
  67. package/dist/{raster-target-ojDdQizC.js → tiff-contract-C6M3QcPp.js} +1 -42
  68. package/dist/tiff.mjs +401 -248
  69. package/dist/types/chart-ex.d.ts +289 -4
  70. package/dist/types/docx.d.ts +473 -98
  71. package/dist/types/index.d.ts +674 -303
  72. package/dist/types/internal-companion.d.ts +11 -0
  73. package/dist/types/math.d.ts +1 -1
  74. package/dist/types/node.d.ts +530 -11
  75. package/dist/types/pptx.d.ts +410 -97
  76. package/dist/types/region-map.d.ts +289 -4
  77. package/dist/types/three-d.d.ts +289 -4
  78. package/dist/types/tiff.d.ts +1 -1
  79. package/dist/types/xlsx.d.ts +483 -134
  80. package/dist/wasm-loader-rlgHmcSv.js +35 -0
  81. package/dist/wasm-runtime-generation-DX4y0Ecl.js +97 -0
  82. package/dist/workbook-model-source-BTC4ISTS.js +94 -0
  83. package/dist/worker-source-I1cIYBel.js +22 -0
  84. package/dist/worker-source-SbudzjYL.js +22 -0
  85. package/dist/worker-source-UAi3GNcM.js +22 -0
  86. package/dist/worksheet-pull-client-CkHgbtyM.js +579 -0
  87. package/dist/xlsx-CpSDPAEU.js +5809 -0
  88. package/dist/xlsx-D5569TPf.js +534 -0
  89. package/dist/xlsx-model-source-DPSkjFic.js +309 -0
  90. package/dist/xlsx-source-worker.mjs +525 -0
  91. package/dist/xlsx.mjs +8 -7
  92. package/dist/xlsx_parser_bg.wasm +0 -0
  93. package/package.json +42 -16
  94. package/dist/assets/render-worker-CeK_iqK3.js +0 -10
  95. package/dist/assets/render-worker-DusrDhPk.js +0 -11
  96. package/dist/assets/render-worker-n2ZG0lrQ.js +0 -31
  97. package/dist/bounded-raw-part-cache-Cg1BsSZQ.js +0 -119
  98. package/dist/canvas-viewer-mechanics-Cpk0YFvM.js +0 -1384
  99. package/dist/cjk-fallback-bLI3z70h.js +0 -46
  100. package/dist/comment-occurrence-C8Y2uoVr.js +0 -6
  101. package/dist/comment-ui-runtime-BsK8pmUT.js +0 -2
  102. package/dist/comments-Diid5ujN.js +0 -246
  103. package/dist/delimited-text-worker-host-BVY-Ecni.js +0 -27
  104. package/dist/document-pull-client-yKxI8aDH.js +0 -27251
  105. package/dist/docx-BkSRiy07.js +0 -2995
  106. package/dist/dom-interaction-boundary-CBUQJsIM.js +0 -223
  107. package/dist/highlight-rect-C5hkRqUr.js +0 -13
  108. package/dist/hyperlink-ArrU3ArU.js +0 -36447
  109. package/dist/line-distribute-Dtudnqhs.js +0 -1023
  110. package/dist/line-metrics-B60C86uh.js +0 -60
  111. package/dist/plot-area-frame-D5hEOgkJ.js +0 -2903
  112. package/dist/pptx-62MmVbYB.js +0 -3063
  113. package/dist/renderer-XFSCOT6m.js +0 -5857
  114. package/dist/resource-measurement-CJsgolre.js +0 -150
  115. package/dist/session-CrU8f8DI.js +0 -743
  116. package/dist/slide-pull-client-B9KA8bU6.js +0 -6253
  117. package/dist/source-key-DIJG8BA0.js +0 -42
  118. package/dist/three-d-YYghQndN.js +0 -1346
  119. package/dist/transfer-p6iCC2R7.js +0 -6
  120. package/dist/units-EJdC96r6.js +0 -4
  121. package/dist/worksheet-pull-client-eIcQ-xlD.js +0 -458
  122. package/dist/xlsx-CRcSzZNq.js +0 -8482
  123. /package/dist/{chunk-DmhlhrBa.js → chunk-Dy4uBu1J.js} +0 -0
  124. /package/dist/{mathjax-DoyWZbSp.js → mathjax-BhwN6ilc.js} +0 -0
  125. /package/dist/{read-only-comment-decoration-Dz7eTQ4d.js → read-only-comment-decoration-PidH0wnP.js} +0 -0
  126. /package/dist/{read-only-comment-margin-DkgzASAl.js → read-only-comment-margin-B52rDVKo.js} +0 -0
  127. /package/dist/{renderer-module-contract-D91rkYHH.js → renderer-module-contract-CWM7jv6d.js} +0 -0
  128. /package/dist/{visible-index-BgiHEc1z.js → visible-index-FeVA0mGE.js} +0 -0
@@ -0,0 +1,579 @@
1
+ import { eo as e } from "./plot-area-frame-CaJFvZ7p.js";
2
+ import { A as t, Bn as n, Fn as r, H as i, In as a, K as o, Ln as s, Mn as c, Nn as l, O as u, Pn as d, Rn as f, j as p, k as m, q as h, zn as g } from "./bounded-raw-part-cache-B7JoC1CD.js";
3
+ import { n as _ } from "./abort-VrnK7mdP.js";
4
+ import { n as v, r as y, t as b } from "./resource-measurement-mXw-WjMF.js";
5
+ //#region packages/core/src/worker/transfer.ts
6
+ function x(e) {
7
+ return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength && e.buffer instanceof ArrayBuffer ? e.buffer : e.slice().buffer;
8
+ }
9
+ //#endregion
10
+ //#region packages/xlsx/src/internal/worksheet-policy.ts
11
+ var S = 2 ** 53 - 1 - 1;
12
+ function C(e) {
13
+ return Object.freeze({
14
+ maxRows: e.maxRows,
15
+ maxCells: e.maxCells,
16
+ maxOwnedUtf8Bytes: e.maxOwnedUtf8Bytes,
17
+ maxJsonBytes: e.maxJsonBytes
18
+ });
19
+ }
20
+ var w = Object.freeze({
21
+ worksheet: C({
22
+ maxRows: n,
23
+ maxCells: s,
24
+ maxOwnedUtf8Bytes: f,
25
+ maxJsonBytes: g
26
+ }),
27
+ cache: C({
28
+ maxRows: a,
29
+ maxCells: l,
30
+ maxOwnedUtf8Bytes: d,
31
+ maxJsonBytes: r
32
+ }),
33
+ maxCoordinateIndexEntries: c
34
+ });
35
+ function T(e, t) {
36
+ let n = e[t];
37
+ if (n === void 0) return w.worksheet[t];
38
+ if (typeof n != "number") throw TypeError(`xlsxWorksheetLimits.${t} must be a number`);
39
+ if (!Number.isSafeInteger(n) || n <= 0 || n > S) throw RangeError(`xlsxWorksheetLimits.${t} must be a positive safe integer no greater than ${S}`);
40
+ return n;
41
+ }
42
+ function E(e = {}) {
43
+ let t = e.xlsxWorksheetLimits, n = {};
44
+ if (t !== void 0) {
45
+ if (typeof t != "object" || !t || Array.isArray(t)) throw TypeError("xlsxWorksheetLimits must be a non-null, non-array object");
46
+ n = t;
47
+ }
48
+ let r = C({
49
+ maxRows: T(n, "maxRows"),
50
+ maxCells: T(n, "maxCells"),
51
+ maxOwnedUtf8Bytes: T(n, "maxOwnedUtf8Bytes"),
52
+ maxJsonBytes: T(n, "maxJsonBytes")
53
+ }), i = w, a = C({
54
+ maxRows: Math.max(i.cache.maxRows, r.maxRows),
55
+ maxCells: Math.max(i.cache.maxCells, r.maxCells),
56
+ maxOwnedUtf8Bytes: Math.max(i.cache.maxOwnedUtf8Bytes, r.maxOwnedUtf8Bytes),
57
+ maxJsonBytes: Math.max(i.cache.maxJsonBytes, r.maxJsonBytes)
58
+ });
59
+ return Object.freeze({
60
+ worksheet: r,
61
+ cache: a,
62
+ maxCoordinateIndexEntries: Math.max(i.maxCoordinateIndexEntries, r.maxCells)
63
+ });
64
+ }
65
+ function D(e) {
66
+ let { worksheet: t } = e;
67
+ return [
68
+ BigInt(t.maxRows),
69
+ BigInt(t.maxCells),
70
+ BigInt(t.maxOwnedUtf8Bytes),
71
+ BigInt(t.maxJsonBytes)
72
+ ];
73
+ }
74
+ //#endregion
75
+ //#region packages/xlsx/src/worksheet-policy-context.ts
76
+ var O = /* @__PURE__ */ new WeakMap();
77
+ function k(e, t) {
78
+ O.set(e, t);
79
+ }
80
+ function A(e) {
81
+ return O.get(e) ?? w;
82
+ }
83
+ function j(e, t) {
84
+ let n = O.get(e);
85
+ n === void 0 ? O.delete(t) : O.set(t, n);
86
+ }
87
+ //#endregion
88
+ //#region packages/xlsx/src/worksheet-resource-limits.ts
89
+ var M = g, N = Object.freeze({
90
+ archiveEntryCount: 0,
91
+ declaredInflatedBytes: 0,
92
+ distinctInflatedBytes: 0,
93
+ operationInflatedBytes: 0
94
+ });
95
+ function P(e, t = w) {
96
+ let { maxCells: n, maxOwnedUtf8Bytes: r } = t.worksheet, i = e.reduce((e, t) => b(e, t.cells.length, n), 0);
97
+ return {
98
+ rows: e.length,
99
+ cells: i,
100
+ ownedUtf8Bytes: e.reduce((e, t) => t.cells.reduce((e, t) => {
101
+ let n = v(t.value, r).stringValueUtf8Bytes;
102
+ return b(e, b(n, t.formula === void 0 ? 0 : y(t.formula, r), r), r);
103
+ }, e), 0)
104
+ };
105
+ }
106
+ function F(e, t = w) {
107
+ return I(e, P(e.rows, t), t);
108
+ }
109
+ function I(e, t, n = w) {
110
+ let r = v(e, n.worksheet.maxJsonBytes);
111
+ return {
112
+ ...t,
113
+ jsonBytes: r.jsonBytes
114
+ };
115
+ }
116
+ function L(e, t, n = w) {
117
+ let r = n.worksheet;
118
+ return {
119
+ rows: b(e.rows, t.rows, r.maxRows),
120
+ cells: b(e.cells, t.cells, r.maxCells),
121
+ ownedUtf8Bytes: b(e.ownedUtf8Bytes, t.ownedUtf8Bytes, r.maxOwnedUtf8Bytes)
122
+ };
123
+ }
124
+ function R(e, t, n = {}, r = w) {
125
+ let i = r.cache, a = e.rows - (n.rows ?? 0), o = e.cells - (n.cells ?? 0), s = e.ownedUtf8Bytes - (n.ownedUtf8Bytes ?? 0), c = e.jsonBytes - (n.jsonBytes ?? 0);
126
+ if (a < 0 || o < 0 || s < 0 || c < 0) throw Error("worksheet cache accounting underflow");
127
+ return {
128
+ rows: b(a, t.rows, i.maxRows),
129
+ cells: b(o, t.cells, i.maxCells),
130
+ ownedUtf8Bytes: b(s, t.ownedUtf8Bytes, i.maxOwnedUtf8Bytes),
131
+ jsonBytes: b(c, t.jsonBytes, i.maxJsonBytes)
132
+ };
133
+ }
134
+ function z(t, n, r, i, a, s, c, l = r !== "delimited-text-source") {
135
+ let u = r === "worksheet-json" ? "serialization" : "parsing";
136
+ return new e(o({
137
+ stage: u,
138
+ violation: {
139
+ part: n,
140
+ resource: r,
141
+ metric: i,
142
+ observed: s,
143
+ limit: a
144
+ }
145
+ }), {
146
+ stage: u,
147
+ violation: {
148
+ format: "xlsx",
149
+ operation: t,
150
+ resource: r,
151
+ metric: i,
152
+ ...n === void 0 ? {} : { part: n },
153
+ limit: a,
154
+ observed: Math.min(s, a + 1),
155
+ configurable: l,
156
+ usage: c ?? N
157
+ }
158
+ });
159
+ }
160
+ function B(e, t, n, r, i = w) {
161
+ let a = i.worksheet, o = [
162
+ [
163
+ "rows",
164
+ e.rows,
165
+ a.maxRows
166
+ ],
167
+ [
168
+ "cells",
169
+ e.cells,
170
+ a.maxCells
171
+ ],
172
+ [
173
+ "owned-utf8-bytes",
174
+ e.ownedUtf8Bytes,
175
+ a.maxOwnedUtf8Bytes
176
+ ]
177
+ ];
178
+ for (let [e, i, a] of o) if (i > a) throw z(t, n, e === "owned-utf8-bytes" ? "worksheet-cell-content" : "worksheet-model", e, a, i, r);
179
+ }
180
+ function V(e, t, n, r, i = w) {
181
+ let a = i.worksheet.maxJsonBytes;
182
+ if (e > a) throw z(t, n, "worksheet-json", "bytes", a, e, r);
183
+ }
184
+ function H(e, t, n, r, i = w) {
185
+ let a = i.cache;
186
+ if (e.rows > a.maxRows) throw z(t, n, "worksheet-cache", "rows", a.maxRows, e.rows, r);
187
+ if (e.cells > a.maxCells) throw z(t, n, "worksheet-cache", "cells", a.maxCells, e.cells, r);
188
+ if (e.ownedUtf8Bytes > a.maxOwnedUtf8Bytes) throw z(t, n, "worksheet-cache", "owned-utf8-bytes", a.maxOwnedUtf8Bytes, e.ownedUtf8Bytes, r);
189
+ if (e.jsonBytes > a.maxJsonBytes) throw z(t, n, "worksheet-cache", "bytes", a.maxJsonBytes, e.jsonBytes, r);
190
+ }
191
+ //#endregion
192
+ //#region packages/xlsx/src/shared-strings.ts
193
+ function U(e, t) {
194
+ return W(e.rows, t), e;
195
+ }
196
+ function W(e, t) {
197
+ for (let n of e) for (let e of n.cells) {
198
+ let n = e.value;
199
+ if (n.type === "shared") {
200
+ let r = t[n.si];
201
+ if (r) {
202
+ let t = {
203
+ type: "text",
204
+ text: r.text
205
+ };
206
+ 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;
207
+ } else e.value = {
208
+ type: "text",
209
+ text: ""
210
+ };
211
+ }
212
+ }
213
+ return e;
214
+ }
215
+ //#endregion
216
+ //#region packages/xlsx/src/worksheet-pull-codec.ts
217
+ var G = new Set([
218
+ "outline",
219
+ "merge",
220
+ "conditional-format",
221
+ "ancillary-content",
222
+ "metadata-unavailable",
223
+ "unordered-rows"
224
+ ]);
225
+ function K(e, t, n, r) {
226
+ let i = e instanceof ArrayBuffer ? new Uint8Array(e) : new Uint8Array(e.buffer, e.byteOffset, e.byteLength), a = JSON.parse(new TextDecoder().decode(i));
227
+ if (!a || typeof a != "object" || !("kind" in a)) throw Error("worksheet cursor returned an invalid unit");
228
+ let o = a;
229
+ if (t !== (o.kind === "finished")) throw Error("worksheet cursor terminal marker mismatch");
230
+ if (o.kind === "rows") {
231
+ if (!Array.isArray(o.rows)) throw Error("worksheet row unit is missing rows");
232
+ return n && W(o.rows, n), r?.(o.rows), {
233
+ kind: "rows",
234
+ rows: o.rows
235
+ };
236
+ }
237
+ if (o.kind === "preview") {
238
+ if (!Number.isSafeInteger(o.maxRow) || !Number.isSafeInteger(o.maxCol) || o.maxRow < 0 || o.maxCol < 0 || o.worksheet === null == (o.reason === null) || o.worksheet !== null && (typeof o.worksheet != "object" || Array.isArray(o.worksheet)) || o.reason !== null && !G.has(o.reason)) throw Error("worksheet preview unit is invalid");
239
+ return o.worksheet && (o.worksheet.rows = []), o;
240
+ }
241
+ if (o.kind === "finished") {
242
+ if (!o.worksheet || typeof o.worksheet != "object") throw Error("worksheet terminal unit is missing its worksheet");
243
+ return o.worksheet.rows = [], {
244
+ kind: "finished",
245
+ worksheet: o.worksheet
246
+ };
247
+ }
248
+ throw Error("worksheet cursor returned an unknown unit kind");
249
+ }
250
+ //#endregion
251
+ //#region packages/xlsx/src/worksheet-pull-worker.ts
252
+ var q = 64 * 1024 * 1024, J = class {
253
+ archive;
254
+ acceptWorksheet;
255
+ executeArchive;
256
+ prepareRows;
257
+ provisional;
258
+ worksheetPolicy;
259
+ coordinator = new p();
260
+ sessions = /* @__PURE__ */ new Map();
261
+ operationTail = Promise.resolve();
262
+ pendingOpens = /* @__PURE__ */ new Map();
263
+ resourceFailure;
264
+ constructor(e, t, n = (e) => e(this.requireArchive()), r, i, a = () => w) {
265
+ this.archive = e, this.acceptWorksheet = t, this.executeArchive = n, this.prepareRows = r, this.provisional = i, this.worksheetPolicy = a;
266
+ }
267
+ reserveOpen(e) {
268
+ this.pendingOpens.set(e.sessionId, {
269
+ identity: e,
270
+ canceled: !1
271
+ });
272
+ }
273
+ abandonOpen(e) {
274
+ this.pendingOpens.delete(e);
275
+ }
276
+ get pendingOpenCount() {
277
+ return this.pendingOpens.size;
278
+ }
279
+ runDuringPull(t) {
280
+ return this.sessions.size === 0 ? this.run(t) : this.coordinator.enqueue(async () => {
281
+ if (this.resourceFailure) throw this.resourceFailure;
282
+ try {
283
+ return t();
284
+ } catch (t) {
285
+ throw t instanceof e && (this.resourceFailure ??= t), t;
286
+ }
287
+ });
288
+ }
289
+ async open(n, r, i) {
290
+ if (this.resourceFailure) throw this.resourceFailure;
291
+ let a = this.pendingOpens.get(i.sessionId);
292
+ if (!a || a.identity.operationId !== i.operationId || a.identity.generation !== i.generation) throw Error("worksheet pull session open reservation is stale or missing");
293
+ let o = this.worksheetPolicy(), s, c = new Promise((e) => {
294
+ s = e;
295
+ }), l = this.operationTail.then(() => this.coordinator.enqueue(async () => {
296
+ if (a.canceled) throw Error("worksheet pull session open was canceled");
297
+ this.executeArchive((e) => e.open_sheet_cursor(n, r));
298
+ let c = [], l = {
299
+ rows: 0,
300
+ cells: 0,
301
+ ownedUtf8Bytes: 0
302
+ }, u, d = !1, f = new t({
303
+ ...i,
304
+ maxByteCredit: q,
305
+ coordinator: this.coordinator,
306
+ driver: {
307
+ pull: () => {
308
+ let t = this.executeArchive((e) => e.pull_sheet_cursor(128)), r = this.executeArchive((e) => e.sheet_cursor_pull_finished());
309
+ if (this.acceptWorksheet) {
310
+ let i = K(t, r, void 0, this.prepareRows);
311
+ try {
312
+ if (i.kind === "preview") i.worksheet && (i.worksheet.rows = c, k(i.worksheet, o), this.provisional?.preview(n, i.worksheet));
313
+ else if (i.kind === "rows") {
314
+ let e = L(l, P(i.rows, o), o);
315
+ B(e, "get-worksheet-worker", void 0, this.readResourceUsage(), o), c.push(...i.rows), l = e;
316
+ } else i.kind === "finished" && (u = i.worksheet);
317
+ } catch (t) {
318
+ throw t instanceof e && (this.resourceFailure ??= t), t;
319
+ }
320
+ }
321
+ d = r;
322
+ let i = x(t);
323
+ return {
324
+ payload: i,
325
+ byteLength: i.byteLength,
326
+ done: r,
327
+ transfer: [i]
328
+ };
329
+ },
330
+ measureChunk: ({ payload: e }) => e.byteLength,
331
+ acknowledge: () => {
332
+ if (!d) return;
333
+ let t, r;
334
+ try {
335
+ if (this.acceptWorksheet) {
336
+ if (!u) throw Error("worksheet terminal payload is missing");
337
+ u.rows = u.parseError ? [] : c;
338
+ let e = u.parseError ? {
339
+ rows: 0,
340
+ cells: 0,
341
+ ownedUtf8Bytes: 0
342
+ } : l, i = I(u, e, o), a = this.readResourceUsage();
343
+ B(i, "get-worksheet-worker", void 0, a, o), V(i.jsonBytes, "get-worksheet-worker", void 0, a, o), k(u, o);
344
+ let s = this.acceptWorksheet(n, u, i, a);
345
+ typeof s == "function" ? t = s : s && ({rollback: t, commit: r} = s);
346
+ }
347
+ this.executeArchive((e) => e.acknowledge_sheet_cursor_terminal()), r?.();
348
+ } catch (n) {
349
+ throw t?.(), n instanceof e && (this.resourceFailure ??= n), n;
350
+ }
351
+ d = !1, this.sessions.delete(i.sessionId), this.provisional?.stop(n), s();
352
+ },
353
+ cancel: () => {
354
+ try {
355
+ this.archive() && this.executeArchive((e) => e.cancel_sheet_cursor());
356
+ } finally {
357
+ this.sessions.delete(i.sessionId), this.provisional?.stop(n), s();
358
+ }
359
+ },
360
+ close: () => {
361
+ try {
362
+ this.archive() && this.executeArchive((e) => e.close_sheet_cursor());
363
+ } finally {
364
+ this.sessions.delete(i.sessionId), this.provisional?.stop(n), s();
365
+ }
366
+ },
367
+ resourceUsage: () => this.readResourceUsage()
368
+ }
369
+ });
370
+ this.sessions.set(i.sessionId, {
371
+ host: f,
372
+ identity: i
373
+ }), this.pendingOpens.delete(i.sessionId);
374
+ }));
375
+ this.operationTail = l.then(() => c, () => void 0);
376
+ try {
377
+ await l;
378
+ } catch (e) {
379
+ throw this.pendingOpens.delete(i.sessionId), s(), e;
380
+ }
381
+ }
382
+ async postOpenedSafely(e, t, n) {
383
+ try {
384
+ t();
385
+ } catch (t) {
386
+ await this.closeIdentity(e);
387
+ try {
388
+ n(t);
389
+ } catch {}
390
+ }
391
+ }
392
+ dispatch(e, t) {
393
+ let n = this.sessions.get(e.sessionId);
394
+ if (n) return n.host.dispatch(e, t);
395
+ let r = this.pendingOpens.get(e.sessionId);
396
+ if (r && (e.kind === "cancel" || e.kind === "close")) {
397
+ let n = r.identity.operationId === e.operationId && r.identity.generation === e.generation;
398
+ return n && (r.canceled = !0), t(n ? {
399
+ protocol: m,
400
+ kind: "accepted",
401
+ sessionId: e.sessionId,
402
+ operationId: e.operationId,
403
+ generation: e.generation,
404
+ requestId: e.requestId,
405
+ command: e.kind
406
+ } : {
407
+ protocol: m,
408
+ kind: "error",
409
+ sessionId: e.sessionId,
410
+ operationId: e.operationId,
411
+ generation: e.generation,
412
+ requestId: e.requestId,
413
+ error: {
414
+ message: "stale lifecycle targets another pending worksheet operation",
415
+ errorName: "PullSessionProtocolError",
416
+ code: "ooxml-stale-lifecycle"
417
+ }
418
+ }), Promise.resolve();
419
+ }
420
+ return e.kind === "cancel" || e.kind === "close" ? (t({
421
+ protocol: m,
422
+ kind: "accepted",
423
+ sessionId: e.sessionId,
424
+ operationId: e.operationId,
425
+ generation: e.generation,
426
+ requestId: e.requestId,
427
+ command: e.kind
428
+ }), Promise.resolve()) : (t({
429
+ protocol: m,
430
+ kind: "error",
431
+ sessionId: e.sessionId,
432
+ operationId: e.operationId,
433
+ generation: e.generation,
434
+ requestId: e.requestId,
435
+ error: h(/* @__PURE__ */ Error("worksheet pull session is not open"))
436
+ }), Promise.resolve());
437
+ }
438
+ async dispatchSafely(e, t) {
439
+ try {
440
+ await this.dispatch(e, t);
441
+ } catch (n) {
442
+ try {
443
+ t({
444
+ protocol: m,
445
+ kind: "error",
446
+ sessionId: e.sessionId,
447
+ operationId: e.operationId,
448
+ generation: e.generation,
449
+ requestId: e.requestId,
450
+ error: h(n)
451
+ });
452
+ } catch {}
453
+ }
454
+ }
455
+ run(t) {
456
+ let n = this.operationTail.then(() => this.coordinator.enqueue(async () => {
457
+ if (this.resourceFailure) throw this.resourceFailure;
458
+ return t();
459
+ })).catch((t) => {
460
+ throw t instanceof e && (this.resourceFailure ??= t), t;
461
+ });
462
+ return this.operationTail = n.then(() => void 0, () => void 0), n;
463
+ }
464
+ async reset() {
465
+ for (let e of this.pendingOpens.values()) e.canceled = !0;
466
+ let e = 1;
467
+ for (let { host: t, identity: n } of [...this.sessions.values()]) await t.dispatch({
468
+ protocol: m,
469
+ kind: "close",
470
+ ...n,
471
+ requestId: e++
472
+ }, () => void 0);
473
+ this.sessions.clear(), await this.operationTail, this.pendingOpens.clear(), this.resourceFailure = void 0;
474
+ }
475
+ requireArchive() {
476
+ let e = this.archive();
477
+ if (!e) throw Error("Workbook not loaded");
478
+ return e;
479
+ }
480
+ async closeIdentity(e) {
481
+ let t = this.sessions.get(e.sessionId);
482
+ if (t) {
483
+ await t.host.dispatch({
484
+ protocol: m,
485
+ kind: "close",
486
+ ...e,
487
+ requestId: 1
488
+ }, () => void 0);
489
+ return;
490
+ }
491
+ let n = this.pendingOpens.get(e.sessionId);
492
+ n && n.identity.operationId === e.operationId && n.identity.generation === e.generation && (n.canceled = !0);
493
+ }
494
+ readResourceUsage() {
495
+ return i(this.executeArchive((e) => e.sheet_cursor_resource_usage()));
496
+ }
497
+ }, Y = "XLSX workbook session was aborted", X = class {
498
+ options;
499
+ active = /* @__PURE__ */ new Set();
500
+ nextSessionId = 1;
501
+ constructor(e) {
502
+ if (this.options = e, e.generation !== void 0 && (!Number.isSafeInteger(e.generation) || e.generation <= 0)) throw TypeError("generation must be a positive safe integer");
503
+ }
504
+ async *stream(e, t, n) {
505
+ if (!Number.isSafeInteger(e) || e < 0) throw RangeError("sheetIndex must be a non-negative safe integer");
506
+ if (!t) throw TypeError("sheetName must be non-empty");
507
+ _(n, Y);
508
+ let r = this.nextSessionId++, i = {
509
+ sessionId: r,
510
+ operationId: r,
511
+ generation: this.options.generation ?? 1
512
+ }, a = new u(this.options.transport, {
513
+ ...i,
514
+ maxByteCredit: q,
515
+ timeoutMs: this.options.timeoutMs,
516
+ disposeTransferred: this.options.disposeTransferred
517
+ });
518
+ this.active.add(a);
519
+ let o = !1, s;
520
+ try {
521
+ for (await this.options.open(e, t, i, this.options.timeoutMs);;) {
522
+ _(n, Y);
523
+ let e = await a.pull(q, { signal: n });
524
+ try {
525
+ let t = e.usage ?? a.usageCheckpoint;
526
+ t && this.options.onUsage?.(t);
527
+ let r = K(e.payload, e.done, this.options.sharedStrings);
528
+ if (yield r.kind === "preview" ? {
529
+ ...r,
530
+ sequence: e.sequence,
531
+ wireBytes: e.byteLength,
532
+ usage: t
533
+ } : r.kind === "rows" ? {
534
+ kind: "rows",
535
+ rows: r.rows,
536
+ sequence: e.sequence,
537
+ wireBytes: e.byteLength,
538
+ usage: t
539
+ } : {
540
+ kind: "finished",
541
+ worksheet: r.worksheet,
542
+ sequence: e.sequence,
543
+ wireBytes: e.byteLength,
544
+ usage: t
545
+ }, await e.ack({ signal: n }), r.kind === "finished") {
546
+ o = !0;
547
+ return;
548
+ }
549
+ } finally {
550
+ e.disposeTransferred();
551
+ }
552
+ }
553
+ } catch (e) {
554
+ throw s = e, e;
555
+ } finally {
556
+ let e;
557
+ try {
558
+ o || await a.cancel(Q(s));
559
+ } catch (t) {
560
+ e = t;
561
+ } finally {
562
+ this.active.delete(a);
563
+ }
564
+ if (s === void 0 && e !== void 0) throw e;
565
+ }
566
+ }
567
+ async cancelAll(e = "closed") {
568
+ let t = (await Promise.allSettled([...this.active].map((t) => t.cancel(e)))).find((e) => e.status === "rejected");
569
+ if (t) throw t.reason;
570
+ }
571
+ };
572
+ function Z(e) {
573
+ return !!e && typeof e == "object" && e.protocol === "ooxml-pull-v1";
574
+ }
575
+ function Q(e) {
576
+ return e && typeof e == "object" && "name" in e && e.name === "AbortError" ? "abort" : e === void 0 ? "closed" : "request-error";
577
+ }
578
+ //#endregion
579
+ export { x as S, A as _, U as a, E as b, L as c, B as d, I as f, k as g, z as h, K as i, H as l, F as m, Z as n, M as o, P as p, J as r, R as s, X as t, V as u, j as v, D as x, w as y };