@silurus/ooxml 0.74.5 → 0.75.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 (47) hide show
  1. package/README.md +105 -6
  2. package/dist/bounded-raw-part-cache-BTfZD_Sz.js +1248 -0
  3. package/dist/{docx-DftZMp7R.js → document-pull-client-H80_E10V.js} +11165 -11517
  4. package/dist/docx-BX0mJqS1.js +1274 -0
  5. package/dist/docx.mjs +6 -3
  6. package/dist/docx_parser_bg.wasm +0 -0
  7. package/dist/duotone-bitmap-by-path-Dv5Ikbzl.js +28 -0
  8. package/dist/find-cursor-Dc5iM6s7.js +815 -0
  9. package/dist/highlight-rect-cCvVU-MW.js +48 -0
  10. package/dist/hyperlink-D85FexTa.js +27 -0
  11. package/dist/index.mjs +4 -4
  12. package/dist/{highlight-rect-IjFkGg4X.js → line-distribute-DkLgIa7B.js} +37 -84
  13. package/dist/{find-cursor-DtgyGs5V.js → line-metrics-qwIyTk7Q.js} +1169 -3641
  14. package/dist/math.mjs +1 -1
  15. package/dist/node.mjs +998 -0
  16. package/dist/pptx-BEYjiTnZ.js +822 -0
  17. package/dist/pptx-CXgyi7wu.js +1705 -0
  18. package/dist/pptx.mjs +7 -3
  19. package/dist/pptx_parser_bg.wasm +0 -0
  20. package/dist/preload-BEouWnlI.js +132 -0
  21. package/dist/render-C0wMf5eT.js +71 -0
  22. package/dist/render-worker-host-CLdOlxFu.js +27 -0
  23. package/dist/render-worker-host-DZ4u0RFs.js +27 -0
  24. package/dist/render-worker-host-s3J-mWBP.js +27 -0
  25. package/dist/renderer-CwzTv9hH.js +5225 -0
  26. package/dist/resource-measurement-6aReN3K0.js +93 -0
  27. package/dist/slide-pull-client-D_T0AIoX.js +175 -0
  28. package/dist/svg-image-by-path-C1M3N2pT.js +1623 -0
  29. package/dist/transfer-3QEJrsJa.js +6 -0
  30. package/dist/types/docx.d.ts +290 -105
  31. package/dist/types/index.d.ts +399 -142
  32. package/dist/types/math.d.ts +1 -1
  33. package/dist/types/node.d.ts +4855 -0
  34. package/dist/types/pptx.d.ts +431 -245
  35. package/dist/types/xlsx.d.ts +320 -120
  36. package/dist/visible-index-CKvgpUrf.js +17 -0
  37. package/dist/worksheet-pull-worker-DCei8u-4.js +347 -0
  38. package/dist/{xlsx-BqMHvfsE.js → xlsx-DJyPlzjB.js} +1499 -1284
  39. package/dist/xlsx.mjs +7 -3
  40. package/dist/xlsx_parser_bg.wasm +0 -0
  41. package/package.json +12 -2
  42. package/dist/pptx-BxU0Lb3J.js +0 -6761
  43. package/dist/render-worker-host-Bcm9j4-H.js +0 -27
  44. package/dist/render-worker-host-BqSTDaYt.js +0 -27
  45. package/dist/render-worker-host-C523QxVw.js +0 -27
  46. package/dist/visible-index-C3_3gBg-.js +0 -50
  47. /package/dist/{mathjax-BPjQ2C_j.js → mathjax-Dqo857oC.js} +0 -0
@@ -0,0 +1,93 @@
1
+ //#region packages/core/src/internal/resource-measurement.ts
2
+ function e(e, t) {
3
+ if (!Number.isSafeInteger(e) || e < 0) throw Error(`${t} must be a non-negative safe integer`);
4
+ }
5
+ function t(t, n, r) {
6
+ return e(t, "resource measurement"), e(n, "resource measurement"), e(r, "resource measurement limit"), t > r || n > r || n > r - t ? r === 2 ** 53 - 1 ? r : r + 1 : t + n;
7
+ }
8
+ function n(n, r = 2 ** 53 - 1) {
9
+ e(r, "resource measurement limit");
10
+ let i = 0;
11
+ for (let e = 0; e < n.length; e += 1) {
12
+ let a = n.charCodeAt(e), o;
13
+ if (a <= 127) o = 1;
14
+ else if (a <= 2047) o = 2;
15
+ else if (a >= 55296 && a <= 56319 && e + 1 < n.length) {
16
+ let t = n.charCodeAt(e + 1);
17
+ t >= 56320 && t <= 57343 ? (o = 4, e += 1) : o = 3;
18
+ } else o = 3;
19
+ if (i = t(i, o, r), i > r) return i;
20
+ }
21
+ return i;
22
+ }
23
+ function r(n, r = 2 ** 53 - 1) {
24
+ e(r, "resource measurement limit");
25
+ let i = t(0, 2, r);
26
+ if (i > r) return i;
27
+ for (let e = 0; e < n.length; e += 1) {
28
+ let a = n.charCodeAt(e), o;
29
+ if (a === 34 || a === 92 || a === 8 || a === 9 || a === 10 || a === 12 || a === 13) o = 2;
30
+ else if (a <= 31) o = 6;
31
+ else if (a <= 127) o = 1;
32
+ else if (a <= 2047) o = 2;
33
+ else if (a >= 55296 && a <= 56319 && e + 1 < n.length) {
34
+ let t = n.charCodeAt(e + 1);
35
+ t >= 56320 && t <= 57343 ? (o = 4, e += 1) : o = 6;
36
+ } else o = a >= 55296 && a <= 57343 ? 6 : 3;
37
+ if (i = t(i, o, r), i > r) return i;
38
+ }
39
+ return i;
40
+ }
41
+ function i(e, n) {
42
+ return t(0, e, n);
43
+ }
44
+ function a(o, s = 2 ** 53 - 1, c = !1) {
45
+ if (e(s, "resource measurement limit"), o === null) return {
46
+ jsonBytes: i(4, s),
47
+ stringValueUtf8Bytes: 0
48
+ };
49
+ if (typeof o == "string") return {
50
+ jsonBytes: r(o, s),
51
+ stringValueUtf8Bytes: n(o, s)
52
+ };
53
+ if (typeof o == "boolean") return {
54
+ jsonBytes: i(o ? 4 : 5, s),
55
+ stringValueUtf8Bytes: 0
56
+ };
57
+ if (typeof o == "number") return {
58
+ jsonBytes: i((Number.isFinite(o) ? String(Object.is(o, -0) ? 0 : o) : "null").length, s),
59
+ stringValueUtf8Bytes: 0
60
+ };
61
+ if (typeof o == "bigint") throw TypeError("BigInt values cannot be serialized to JSON");
62
+ if (Array.isArray(o)) {
63
+ let e = i(2, s), n = 0;
64
+ for (let r = 0; r < o.length; r += 1) {
65
+ r !== 0 && (e = t(e, 1, s));
66
+ let i = a(o[r], s, !0);
67
+ e = t(e, i.jsonBytes, s), n = t(n, i.stringValueUtf8Bytes, s);
68
+ }
69
+ return {
70
+ jsonBytes: e,
71
+ stringValueUtf8Bytes: n
72
+ };
73
+ }
74
+ if (typeof o == "object") {
75
+ let e = i(2, s), n = 0, c = 0;
76
+ for (let [i, l] of Object.entries(o)) {
77
+ if (l === void 0 || typeof l == "function" || typeof l == "symbol") continue;
78
+ c++ !== 0 && (e = t(e, 1, s)), e = t(e, r(i, s), s), e = t(e, 1, s);
79
+ let o = a(l, s);
80
+ e = t(e, o.jsonBytes, s), n = t(n, o.stringValueUtf8Bytes, s);
81
+ }
82
+ return {
83
+ jsonBytes: e,
84
+ stringValueUtf8Bytes: n
85
+ };
86
+ }
87
+ return {
88
+ jsonBytes: c ? i(4, s) : 0,
89
+ stringValueUtf8Bytes: 0
90
+ };
91
+ }
92
+ //#endregion
93
+ export { a as n, n as r, t };
@@ -0,0 +1,175 @@
1
+ import { A as e, g as t, j as n, r } from "./bounded-raw-part-cache-BTfZD_Sz.js";
2
+ import { _ as i } from "./svg-image-by-path-C1M3N2pT.js";
3
+ //#region packages/pptx/src/google-fonts.ts
4
+ var a = {
5
+ ...n,
6
+ ...i
7
+ };
8
+ Object.freeze({
9
+ archiveEntryCount: 0,
10
+ declaredInflatedBytes: 0,
11
+ distinctInflatedBytes: 0,
12
+ operationInflatedBytes: 0
13
+ });
14
+ function o(e, t) {
15
+ if (e !== null && typeof e != "string") throw Error(`invalid PPTX presentation bootstrap ${t}`);
16
+ }
17
+ function s(e, t) {
18
+ if (!e || typeof e != "object" || Array.isArray(e)) throw Error(`invalid PPTX presentation bootstrap slide at ${t}`);
19
+ let n = e;
20
+ if (n.index !== t) throw Error(`invalid PPTX presentation bootstrap slide index ${n.index}`);
21
+ if (n.partName !== void 0 && typeof n.partName != "string") throw Error(`invalid PPTX presentation bootstrap slide partName at ${t}`);
22
+ return Object.freeze({
23
+ index: n.index,
24
+ ...n.partName === void 0 ? {} : { partName: n.partName }
25
+ });
26
+ }
27
+ function c(e) {
28
+ if (!e || typeof e != "object" || Array.isArray(e)) throw Error("invalid PPTX presentation bootstrap payload");
29
+ let t = e;
30
+ if (!Number.isSafeInteger(t.slideCount) || (t.slideCount ?? -1) < 0 || !Number.isSafeInteger(t.slideWidth) || (t.slideWidth ?? 0) <= 0 || !Number.isSafeInteger(t.slideHeight) || (t.slideHeight ?? 0) <= 0 || !Array.isArray(t.slides) || t.slides.length !== t.slideCount) throw Error("invalid PPTX presentation bootstrap dimensions or slide count");
31
+ return o(t.defaultTextColor, "defaultTextColor"), o(t.majorFont, "majorFont"), o(t.minorFont, "minorFont"), o(t.hlinkColor, "hlinkColor"), o(t.folHlinkColor, "folHlinkColor"), Object.freeze({
32
+ slideCount: t.slideCount,
33
+ slideWidth: t.slideWidth,
34
+ slideHeight: t.slideHeight,
35
+ defaultTextColor: t.defaultTextColor,
36
+ majorFont: t.majorFont,
37
+ minorFont: t.minorFont,
38
+ hlinkColor: t.hlinkColor,
39
+ folHlinkColor: t.folHlinkColor,
40
+ slides: Object.freeze(t.slides.map(s))
41
+ });
42
+ }
43
+ function l(e) {
44
+ return Object.freeze({
45
+ type: "media",
46
+ x: e.x,
47
+ y: e.y,
48
+ width: e.width,
49
+ height: e.height,
50
+ rotation: e.rotation,
51
+ flipH: e.flipH,
52
+ flipV: e.flipV,
53
+ mediaKind: e.mediaKind,
54
+ posterPath: e.posterPath,
55
+ posterMimeType: e.posterMimeType,
56
+ mediaPath: e.mediaPath,
57
+ mimeType: e.mimeType
58
+ });
59
+ }
60
+ function u(e, t) {
61
+ if (!e || typeof e != "object" || Array.isArray(e)) throw Error(`invalid PPTX presentation preflight media at slide ${t}`);
62
+ let n = e;
63
+ for (let e of [
64
+ "x",
65
+ "y",
66
+ "width",
67
+ "height",
68
+ "rotation"
69
+ ]) if (typeof n[e] != "number" || !Number.isFinite(n[e])) throw Error(`invalid PPTX presentation preflight media ${e} at slide ${t}`);
70
+ if (n.type !== "media" || typeof n.flipH != "boolean" || typeof n.flipV != "boolean" || n.mediaKind !== "audio" && n.mediaKind !== "video" || typeof n.posterPath != "string" || typeof n.posterMimeType != "string" || typeof n.mediaPath != "string" || typeof n.mimeType != "string") throw Error(`invalid PPTX presentation preflight media fields at slide ${t}`);
71
+ return l(n);
72
+ }
73
+ function d(e) {
74
+ if (!e || typeof e != "object" || Array.isArray(e)) throw Error("invalid PPTX presentation preflight payload");
75
+ let t = e;
76
+ if (!Number.isSafeInteger(t.slideCount) || (t.slideCount ?? -1) < 0 || !Number.isSafeInteger(t.slideWidth) || (t.slideWidth ?? 0) <= 0 || !Number.isSafeInteger(t.slideHeight) || (t.slideHeight ?? 0) <= 0 || !Array.isArray(t.slides) || t.slides.length !== t.slideCount || !Array.isArray(t.fontPreloadNames)) throw Error("invalid PPTX presentation preflight dimensions or slide count");
77
+ o(t.defaultTextColor, "defaultTextColor"), o(t.majorFont, "majorFont"), o(t.minorFont, "minorFont"), o(t.hlinkColor, "hlinkColor"), o(t.folHlinkColor, "folHlinkColor");
78
+ let n = t.slides.map((e, t) => {
79
+ if (!e || typeof e != "object" || Array.isArray(e)) throw Error(`invalid PPTX presentation preflight slide at ${t}`);
80
+ let n = e;
81
+ if (n.index !== t || n.partName !== void 0 && typeof n.partName != "string" || n.notes !== null && typeof n.notes != "string" || typeof n.hidden != "boolean" || !Array.isArray(n.mediaElements)) throw Error(`invalid PPTX presentation preflight slide fields at ${t}`);
82
+ return Object.freeze({
83
+ index: t,
84
+ ...n.partName === void 0 ? {} : { partName: n.partName },
85
+ notes: n.notes,
86
+ hidden: n.hidden,
87
+ mediaElements: Object.freeze(n.mediaElements.map((e) => u(e, t)))
88
+ });
89
+ }), r = t.fontPreloadNames.map((e, t) => {
90
+ if (e !== null && typeof e != "string") throw Error(`invalid PPTX presentation preflight font at ${t}`);
91
+ return e;
92
+ });
93
+ return Object.freeze({
94
+ slideCount: t.slideCount,
95
+ slideWidth: t.slideWidth,
96
+ slideHeight: t.slideHeight,
97
+ defaultTextColor: t.defaultTextColor,
98
+ majorFont: t.majorFont,
99
+ minorFont: t.minorFont,
100
+ hlinkColor: t.hlinkColor,
101
+ folHlinkColor: t.folHlinkColor,
102
+ slides: Object.freeze(n),
103
+ fontPreloadNames: Object.freeze(r)
104
+ });
105
+ }
106
+ function f(e, t) {
107
+ for (let n of e.slides) for (let e of n.mediaElements) {
108
+ if (e.mediaPath === t) return e.mimeType;
109
+ if (e.posterPath === t) return e.posterMimeType;
110
+ }
111
+ return "";
112
+ }
113
+ //#endregion
114
+ //#region packages/pptx/src/slide-pull-client.ts
115
+ var p = 1024 * 1024, m = class {
116
+ active = /* @__PURE__ */ new Set();
117
+ nextSessionId = 1;
118
+ constructor(e) {
119
+ if (this.options = e, !Number.isSafeInteger(e.slideCount) || e.slideCount < 0) throw TypeError("slideCount must be a non-negative safe integer");
120
+ if (e.generation !== void 0 && (!Number.isSafeInteger(e.generation) || e.generation <= 0)) throw TypeError("generation must be a positive safe integer");
121
+ }
122
+ async load(e, n = !0, i) {
123
+ this.assertSlideIndex(e);
124
+ let a = this.nextSessionId++, o = {
125
+ sessionId: a,
126
+ operationId: a,
127
+ generation: this.options.generation ?? 1
128
+ }, s = new r(this.options.transport, {
129
+ ...o,
130
+ maxByteCredit: t,
131
+ timeoutMs: i
132
+ });
133
+ this.active.add(s);
134
+ try {
135
+ await this.options.open(e, o, i);
136
+ let t = await g(s);
137
+ try {
138
+ let e = t.usage ?? s.usageCheckpoint;
139
+ e && this.options.onUsage?.(e);
140
+ let r = n ? JSON.parse(new TextDecoder().decode(new Uint8Array(t.payload))) : void 0;
141
+ return await t.ack(), r;
142
+ } finally {
143
+ t.disposeTransferred();
144
+ }
145
+ } catch (e) {
146
+ throw await s.cancel("request-error").catch(() => void 0), e;
147
+ } finally {
148
+ this.active.delete(s);
149
+ }
150
+ }
151
+ cancelAll() {
152
+ for (let e of this.active) e.cancel("closed").catch(() => void 0);
153
+ this.active.clear();
154
+ }
155
+ assertSlideIndex(e) {
156
+ if (!Number.isSafeInteger(e) || e < 0 || e >= this.options.slideCount) throw RangeError(`Slide index ${e} out of range (count: ${this.options.slideCount})`);
157
+ }
158
+ };
159
+ function h(e) {
160
+ return !!e && typeof e == "object" && e.protocol === "ooxml-pull-v1";
161
+ }
162
+ async function g(e) {
163
+ try {
164
+ return await e.pull(p);
165
+ } catch (t) {
166
+ let n = _(t);
167
+ if (n === void 0) throw t;
168
+ return e.pull(n);
169
+ }
170
+ }
171
+ function _(n) {
172
+ return e(n, p, t);
173
+ }
174
+ //#endregion
175
+ export { d as a, c as i, h as n, a as o, f as r, m as t };