@silurus/ooxml 0.74.6 → 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.
- package/README.md +105 -6
- package/dist/bounded-raw-part-cache-BTfZD_Sz.js +1248 -0
- package/dist/{docx-DftZMp7R.js → document-pull-client-H80_E10V.js} +11165 -11517
- package/dist/docx-BX0mJqS1.js +1274 -0
- package/dist/docx.mjs +6 -3
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/duotone-bitmap-by-path-Dv5Ikbzl.js +28 -0
- package/dist/find-cursor-Dc5iM6s7.js +815 -0
- package/dist/highlight-rect-cCvVU-MW.js +48 -0
- package/dist/hyperlink-D85FexTa.js +27 -0
- package/dist/index.mjs +4 -4
- package/dist/{highlight-rect-IjFkGg4X.js → line-distribute-DkLgIa7B.js} +37 -84
- package/dist/{find-cursor-DtgyGs5V.js → line-metrics-qwIyTk7Q.js} +1169 -3641
- package/dist/math.mjs +1 -1
- package/dist/node.mjs +998 -0
- package/dist/pptx-BEYjiTnZ.js +822 -0
- package/dist/pptx-CXgyi7wu.js +1705 -0
- package/dist/pptx.mjs +7 -3
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/preload-BEouWnlI.js +132 -0
- package/dist/render-C0wMf5eT.js +71 -0
- package/dist/render-worker-host-CLdOlxFu.js +27 -0
- package/dist/render-worker-host-DZ4u0RFs.js +27 -0
- package/dist/render-worker-host-s3J-mWBP.js +27 -0
- package/dist/renderer-CwzTv9hH.js +5225 -0
- package/dist/resource-measurement-6aReN3K0.js +93 -0
- package/dist/slide-pull-client-D_T0AIoX.js +175 -0
- package/dist/svg-image-by-path-C1M3N2pT.js +1623 -0
- package/dist/transfer-3QEJrsJa.js +6 -0
- package/dist/types/docx.d.ts +290 -105
- package/dist/types/index.d.ts +399 -142
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +4855 -0
- package/dist/types/pptx.d.ts +431 -245
- package/dist/types/xlsx.d.ts +320 -120
- package/dist/visible-index-CKvgpUrf.js +17 -0
- package/dist/worksheet-pull-worker-DCei8u-4.js +347 -0
- package/dist/{xlsx-BqMHvfsE.js → xlsx-DJyPlzjB.js} +1499 -1284
- package/dist/xlsx.mjs +7 -3
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +12 -2
- package/dist/pptx-qbadwIv4.js +0 -6761
- package/dist/render-worker-host-Bcm9j4-H.js +0 -27
- package/dist/render-worker-host-BqSTDaYt.js +0 -27
- package/dist/render-worker-host-C523QxVw.js +0 -27
- package/dist/visible-index-C3_3gBg-.js +0 -50
- /package/dist/{mathjax-BPjQ2C_j.js → mathjax-Dqo857oC.js} +0 -0
|
@@ -0,0 +1,1623 @@
|
|
|
1
|
+
//#region packages/core/src/fonts/scripts.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (!e) return null;
|
|
4
|
+
let t = e.toLowerCase();
|
|
5
|
+
return /[ᄀ-ᇿ-가-]/.test(e) ? "kr" : /[-ヿ]/.test(e) ? "jp" : /jhenghei|微軟正黑|新細明|細明|pmingliu|mingliu|dfkai|標楷|華康|cns11643|kaiti tc|ming\s*liu/.test(t) || /新細明體|細明體|標楷體|微軟正黑體|華康/.test(e) ? "tc" : /simsun|nsimsun|simhei|simkai|simfang|yahei|dengxian|fangsong|kaiti|youyuan|lisu|stsong|stkaiti|stfangsong|stheiti|stxihei|stzhongsong|songti sc|heiti sc|微软雅黑/.test(t) || /宋体|黑体|楷体|仿宋|等线|微软雅黑|隶书|幼圆/.test(e) ? "sc" : /malgun|batang|gulim|dotum|gungsuh|nanum|new gulim|hancom|hy(gothic|graphic|namu)?/.test(t) ? "kr" : /\bmeiryo\b|\byu\s*(gothic|mincho)\b|yugothic|yumincho|hiragino|\bms\s*(gothic|mincho|pgothic|pmincho|ui\s*gothic)\b|\bms[pg]?(gothic|mincho)\b|ipa(ex)?(gothic|mincho)|noto\s+(sans|serif)\s+jp|游ゴシック|游明朝|MS|メイリオ|ヒラギノ/.test(t) || /游ゴシック|游明朝|MS ゴシック|MS 明朝|MS Pゴシック|メイリオ|ヒラギノ/.test(e) ? "jp" : null;
|
|
6
|
+
}
|
|
7
|
+
function t(e) {
|
|
8
|
+
if (!e) return "sans";
|
|
9
|
+
let t = e.toLowerCase();
|
|
10
|
+
return /mono|courier|consolas|等幅|gothic_m/.test(t) ? "mono" : /roman|times|cambria|caladea|georgia|garamond|century(?!\s*gothic)|palatino|antiqua|didot|bodoni|playfair|source serif|noto serif|min\s*cho|明朝体|明朝|song|sung|simsun|nsimsun|batang|gungsuh|ming\s*liu|mingliu|pmingliu|fang\s*song|fangsong|kai\s*ti|kaiti|simkai|simfang|stsong|stkaiti|stfangsong|stzhongsong|新細明|細明|宋体|楷体|楷體|仿宋|標楷|游明朝|MS 明朝|ms mincho|yu mincho|hiragino mincho|ヒラギノ明朝/.test(t) || /新細明體|細明體|宋体|明朝|楷体|楷體|仿宋|標楷體|游明朝|MS 明朝/.test(e) ? "serif" : "sans";
|
|
11
|
+
}
|
|
12
|
+
function n(e, t) {
|
|
13
|
+
let n = t === "serif" ? "Noto Serif" : "Noto Sans", r = {
|
|
14
|
+
jp: [
|
|
15
|
+
"jp",
|
|
16
|
+
"sc",
|
|
17
|
+
"tc",
|
|
18
|
+
"kr"
|
|
19
|
+
],
|
|
20
|
+
sc: [
|
|
21
|
+
"sc",
|
|
22
|
+
"tc",
|
|
23
|
+
"jp",
|
|
24
|
+
"kr"
|
|
25
|
+
],
|
|
26
|
+
tc: [
|
|
27
|
+
"tc",
|
|
28
|
+
"sc",
|
|
29
|
+
"jp",
|
|
30
|
+
"kr"
|
|
31
|
+
],
|
|
32
|
+
kr: [
|
|
33
|
+
"kr",
|
|
34
|
+
"jp",
|
|
35
|
+
"sc",
|
|
36
|
+
"tc"
|
|
37
|
+
]
|
|
38
|
+
}, i = {
|
|
39
|
+
kr: "KR",
|
|
40
|
+
sc: "SC",
|
|
41
|
+
tc: "TC",
|
|
42
|
+
jp: "JP"
|
|
43
|
+
};
|
|
44
|
+
return r[e].map((e) => `${n} ${i[e]}`);
|
|
45
|
+
}
|
|
46
|
+
var r = [
|
|
47
|
+
"Noto Sans",
|
|
48
|
+
"Noto Sans Hebrew",
|
|
49
|
+
"Noto Sans Thai",
|
|
50
|
+
"Noto Sans Devanagari"
|
|
51
|
+
], i = ["Noto Serif", "Noto Serif Hebrew"], a = (e) => `https://fonts.googleapis.com/css2?family=${e}:wght@400;700&display=swap`, o = {
|
|
52
|
+
"noto sans kr": { url: a("Noto+Sans+KR") },
|
|
53
|
+
"noto sans sc": { url: a("Noto+Sans+SC") },
|
|
54
|
+
"noto sans tc": { url: a("Noto+Sans+TC") },
|
|
55
|
+
"noto sans jp": { url: a("Noto+Sans+JP") },
|
|
56
|
+
"noto serif kr": { url: a("Noto+Serif+KR") },
|
|
57
|
+
"noto serif sc": { url: a("Noto+Serif+SC") },
|
|
58
|
+
"noto serif tc": { url: a("Noto+Serif+TC") },
|
|
59
|
+
"noto serif jp": { url: a("Noto+Serif+JP") },
|
|
60
|
+
"noto sans": { url: a("Noto+Sans") },
|
|
61
|
+
"noto serif": { url: a("Noto+Serif") },
|
|
62
|
+
"noto sans devanagari": { url: a("Noto+Sans+Devanagari") },
|
|
63
|
+
"noto sans thai": { url: a("Noto+Sans+Thai") },
|
|
64
|
+
"noto sans hebrew": { url: a("Noto+Sans+Hebrew") },
|
|
65
|
+
"noto serif hebrew": { url: a("Noto+Serif+Hebrew") }
|
|
66
|
+
}, s = class e {
|
|
67
|
+
hasHan = !1;
|
|
68
|
+
hasHangul = !1;
|
|
69
|
+
hasKana = !1;
|
|
70
|
+
hasArabic = !1;
|
|
71
|
+
hasThai = !1;
|
|
72
|
+
hasHebrew = !1;
|
|
73
|
+
hasDevanagari = !1;
|
|
74
|
+
hasCyrGreek = !1;
|
|
75
|
+
constructor(e) {
|
|
76
|
+
this.cjkLang = e;
|
|
77
|
+
}
|
|
78
|
+
clone() {
|
|
79
|
+
let t = new e(this.cjkLang);
|
|
80
|
+
return t.hasHan = this.hasHan, t.hasHangul = this.hasHangul, t.hasKana = this.hasKana, t.hasArabic = this.hasArabic, t.hasThai = this.hasThai, t.hasHebrew = this.hasHebrew, t.hasDevanagari = this.hasDevanagari, t.hasCyrGreek = this.hasCyrGreek, t;
|
|
81
|
+
}
|
|
82
|
+
addText(e) {
|
|
83
|
+
let t = () => this.hasHan && this.hasHangul && this.hasKana && this.hasArabic && this.hasThai && this.hasHebrew && this.hasDevanagari && this.hasCyrGreek;
|
|
84
|
+
outer: for (let n of e) if (n) for (let e of n) {
|
|
85
|
+
let n = e.codePointAt(0);
|
|
86
|
+
if (n !== void 0 && !(n <= 591) && (n >= 4352 && n <= 4607 || n >= 12592 && n <= 12687 || n >= 44032 && n <= 55215 ? this.hasHangul = !0 : n >= 12352 && n <= 12543 ? this.hasKana = !0 : n >= 13312 && n <= 19903 || n >= 19968 && n <= 40959 || n >= 63744 && n <= 64255 || n >= 131072 && n <= 195103 ? this.hasHan = !0 : n >= 1536 && n <= 1791 || n >= 1872 && n <= 1919 || n >= 2208 && n <= 2303 || n >= 64336 && n <= 65023 || n >= 65136 && n <= 65279 ? this.hasArabic = !0 : n >= 3584 && n <= 3711 ? this.hasThai = !0 : n >= 1424 && n <= 1535 || n >= 64285 && n <= 64335 ? this.hasHebrew = !0 : n >= 2304 && n <= 2431 ? this.hasDevanagari = !0 : (n >= 1024 && n <= 1279 || n >= 880 && n <= 1023) && (this.hasCyrGreek = !0), t())) break outer;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
names() {
|
|
90
|
+
let e = [], t = /* @__PURE__ */ new Set();
|
|
91
|
+
this.hasHangul && t.add("kr"), this.hasKana && t.add("jp"), this.hasHan && t.size === 0 && t.add(this.cjkLang ?? "jp");
|
|
92
|
+
for (let n of [
|
|
93
|
+
"kr",
|
|
94
|
+
"sc",
|
|
95
|
+
"tc",
|
|
96
|
+
"jp"
|
|
97
|
+
]) if (t.has(n)) {
|
|
98
|
+
let t = {
|
|
99
|
+
kr: "KR",
|
|
100
|
+
sc: "SC",
|
|
101
|
+
tc: "TC",
|
|
102
|
+
jp: "JP"
|
|
103
|
+
}[n];
|
|
104
|
+
e.push(`Noto Sans ${t}`, `Noto Serif ${t}`);
|
|
105
|
+
}
|
|
106
|
+
return this.hasCyrGreek && e.push("Noto Sans", "Noto Serif"), this.hasArabic && e.push("Noto Naskh Arabic", "Noto Sans Arabic"), this.hasThai && e.push("Noto Sans Thai"), this.hasHebrew && e.push("Noto Sans Hebrew", "Noto Serif Hebrew"), this.hasDevanagari && e.push("Noto Sans Devanagari"), e;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
function c(e, t) {
|
|
110
|
+
let n = new s(t);
|
|
111
|
+
return n.addText(e), n.names();
|
|
112
|
+
}
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region packages/core/src/canvas/aux-canvas.ts
|
|
115
|
+
function l(e, t) {
|
|
116
|
+
return [Math.max(1, Math.ceil(e)), Math.max(1, Math.ceil(t))];
|
|
117
|
+
}
|
|
118
|
+
function u(e, t) {
|
|
119
|
+
let [n, r] = l(e, t);
|
|
120
|
+
if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(n, r);
|
|
121
|
+
if (typeof document < "u") {
|
|
122
|
+
let e = document.createElement("canvas");
|
|
123
|
+
return e.width = n, e.height = r, e;
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region packages/core/src/image/pixel-budget.ts
|
|
129
|
+
var d = 32767, f = 1 << 25, p = f * 4, m = class e extends RangeError {
|
|
130
|
+
code = "ooxml-decoded-image-limit";
|
|
131
|
+
constructor(t, n, r) {
|
|
132
|
+
super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`), this.metric = t, this.limit = n, this.observed = r, this.name = "OoxmlDecodedImageLimitError", Object.setPrototypeOf(this, e.prototype);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
function h(e) {
|
|
136
|
+
return e instanceof m || !!e && typeof e == "object" && e.code === "ooxml-decoded-image-limit";
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region packages/core/src/image/dib.ts
|
|
140
|
+
var g = d, ee = f;
|
|
141
|
+
function _(e, t, n, r, i) {
|
|
142
|
+
if (n < 40 || t + 40 > e.byteLength) return null;
|
|
143
|
+
let a = e.getUint32(t, !0);
|
|
144
|
+
if (a < 40) return null;
|
|
145
|
+
let o = e.getInt32(t + 4, !0), s = e.getInt32(t + 8, !0), c = e.getUint16(t + 14, !0);
|
|
146
|
+
if (e.getUint32(t + 16, !0) !== 0) return null;
|
|
147
|
+
let l = s < 0, u = Math.abs(o), d = Math.abs(s);
|
|
148
|
+
if (u <= 0 || d <= 0 || u > g || d > g || u * d > ee) return null;
|
|
149
|
+
let f = new Uint8ClampedArray(u * d * 4), p = u * c + 31 >> 5 << 2 >>> 0;
|
|
150
|
+
if (r + p * d > r + i + p && r + p * d > e.byteLength) return null;
|
|
151
|
+
let m = null;
|
|
152
|
+
if (c <= 8) {
|
|
153
|
+
let n = e.getUint32(t + 32, !0);
|
|
154
|
+
n === 0 && (n = 1 << c);
|
|
155
|
+
let r = t + a;
|
|
156
|
+
m = [];
|
|
157
|
+
for (let t = 0; t < n; t++) {
|
|
158
|
+
let n = r + t * 4;
|
|
159
|
+
if (n + 4 > e.byteLength) break;
|
|
160
|
+
let i = e.getUint8(n), a = e.getUint8(n + 1), o = e.getUint8(n + 2);
|
|
161
|
+
m.push(o << 16 | a << 8 | i);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
let h = (e, t, n, r, i, a) => {
|
|
165
|
+
let o = (e * u + t) * 4;
|
|
166
|
+
f[o] = n, f[o + 1] = r, f[o + 2] = i, f[o + 3] = a;
|
|
167
|
+
}, _ = !1;
|
|
168
|
+
for (let t = 0; t < d; t++) {
|
|
169
|
+
let n = l ? t : d - 1 - t, i = t, a = r + n * p;
|
|
170
|
+
if (a + p > e.byteLength) break;
|
|
171
|
+
if (c === 32) for (let t = 0; t < u; t++) {
|
|
172
|
+
let n = a + t * 4, r = e.getUint8(n), o = e.getUint8(n + 1), s = e.getUint8(n + 2), c = e.getUint8(n + 3);
|
|
173
|
+
c !== 0 && (_ = !0), h(i, t, s, o, r, c);
|
|
174
|
+
}
|
|
175
|
+
else if (c === 24) {
|
|
176
|
+
for (let t = 0; t < u; t++) {
|
|
177
|
+
let n = a + t * 3;
|
|
178
|
+
h(i, t, e.getUint8(n + 2), e.getUint8(n + 1), e.getUint8(n), 255);
|
|
179
|
+
}
|
|
180
|
+
_ = !0;
|
|
181
|
+
} else if (c === 8 && m) {
|
|
182
|
+
for (let t = 0; t < u; t++) {
|
|
183
|
+
let n = e.getUint8(a + t), r = m[n] ?? 0;
|
|
184
|
+
h(i, t, r >> 16 & 255, r >> 8 & 255, r & 255, 255);
|
|
185
|
+
}
|
|
186
|
+
_ = !0;
|
|
187
|
+
} else if (c === 4 && m) {
|
|
188
|
+
for (let t = 0; t < u; t++) {
|
|
189
|
+
let n = e.getUint8(a + (t >> 1)), r = t & 1 ? n & 15 : n >> 4 & 15, o = m[r] ?? 0;
|
|
190
|
+
h(i, t, o >> 16 & 255, o >> 8 & 255, o & 255, 255);
|
|
191
|
+
}
|
|
192
|
+
_ = !0;
|
|
193
|
+
} else if (c === 1 && m) {
|
|
194
|
+
for (let t = 0; t < u; t++) {
|
|
195
|
+
let n = e.getUint8(a + (t >> 3)) >> 7 - (t & 7) & 1, r = m[n] ?? 0;
|
|
196
|
+
h(i, t, r >> 16 & 255, r >> 8 & 255, r & 255, 255);
|
|
197
|
+
}
|
|
198
|
+
_ = !0;
|
|
199
|
+
} else return null;
|
|
200
|
+
}
|
|
201
|
+
if (c === 32 && !_) for (let e = 3; e < f.length; e += 4) f[e] = 255;
|
|
202
|
+
return {
|
|
203
|
+
width: u,
|
|
204
|
+
height: d,
|
|
205
|
+
data: f
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
function te(e, t, n) {
|
|
209
|
+
if (n < 40 || t + 40 > e.byteLength) return null;
|
|
210
|
+
let r = e.getUint32(t, !0);
|
|
211
|
+
if (r < 40) return null;
|
|
212
|
+
let i = e.getUint16(t + 14, !0), a = 0;
|
|
213
|
+
if (i <= 8) {
|
|
214
|
+
let n = e.getUint32(t + 32, !0);
|
|
215
|
+
n === 0 && (n = 1 << i), a = n;
|
|
216
|
+
} else a = e.getUint32(t + 32, !0);
|
|
217
|
+
let o = r + a * 4, s = t + o, c = n - o;
|
|
218
|
+
return c <= 0 ? null : _(e, t, o, s, c);
|
|
219
|
+
}
|
|
220
|
+
function ne(e, t, n, r, i, a) {
|
|
221
|
+
try {
|
|
222
|
+
let o = u(t.width, t.height);
|
|
223
|
+
if (!o) return !1;
|
|
224
|
+
let s = o.getContext("2d");
|
|
225
|
+
if (!s) return !1;
|
|
226
|
+
let c = s.createImageData(t.width, t.height);
|
|
227
|
+
c.data.set(t.data), s.putImageData(c, 0, 0);
|
|
228
|
+
let l = Math.min(n, i), d = Math.min(r, a), f = Math.abs(i - n), p = Math.abs(a - r);
|
|
229
|
+
return e.drawImage(o, l, d, f, p), !0;
|
|
230
|
+
} catch {
|
|
231
|
+
return !1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//#endregion
|
|
235
|
+
//#region packages/core/src/image/emf.ts
|
|
236
|
+
var v = {
|
|
237
|
+
HEADER: 1,
|
|
238
|
+
POLYBEZIER: 2,
|
|
239
|
+
POLYGON: 3,
|
|
240
|
+
POLYLINE: 4,
|
|
241
|
+
POLYBEZIERTO: 5,
|
|
242
|
+
POLYLINETO: 6,
|
|
243
|
+
POLYPOLYLINE: 7,
|
|
244
|
+
POLYPOLYGON: 8,
|
|
245
|
+
SETWINDOWEXTEX: 9,
|
|
246
|
+
SETWINDOWORGEX: 10,
|
|
247
|
+
SETVIEWPORTEXTEX: 11,
|
|
248
|
+
SETVIEWPORTORGEX: 12,
|
|
249
|
+
EOF: 14,
|
|
250
|
+
SETMAPMODE: 17,
|
|
251
|
+
SETPOLYFILLMODE: 19,
|
|
252
|
+
SETBKMODE: 18,
|
|
253
|
+
SETTEXTALIGN: 22,
|
|
254
|
+
SETTEXTCOLOR: 24,
|
|
255
|
+
MOVETOEX: 27,
|
|
256
|
+
SCALEVIEWPORTEXTEX: 31,
|
|
257
|
+
SCALEWINDOWEXTEX: 32,
|
|
258
|
+
SAVEDC: 33,
|
|
259
|
+
RESTOREDC: 34,
|
|
260
|
+
SETWORLDTRANSFORM: 35,
|
|
261
|
+
MODIFYWORLDTRANSFORM: 36,
|
|
262
|
+
SELECTOBJECT: 37,
|
|
263
|
+
CREATEPEN: 38,
|
|
264
|
+
CREATEBRUSHINDIRECT: 39,
|
|
265
|
+
DELETEOBJECT: 40,
|
|
266
|
+
ELLIPSE: 42,
|
|
267
|
+
RECTANGLE: 43,
|
|
268
|
+
LINETO: 54,
|
|
269
|
+
BEGINPATH: 59,
|
|
270
|
+
ENDPATH: 60,
|
|
271
|
+
CLOSEFIGURE: 61,
|
|
272
|
+
SELECTCLIPPATH: 67,
|
|
273
|
+
EXTCREATEFONTINDIRECTW: 82,
|
|
274
|
+
EXTTEXTOUTW: 84,
|
|
275
|
+
POLYBEZIER16: 85,
|
|
276
|
+
POLYGON16: 86,
|
|
277
|
+
POLYLINE16: 87,
|
|
278
|
+
POLYBEZIERTO16: 88,
|
|
279
|
+
POLYLINETO16: 89,
|
|
280
|
+
POLYPOLYLINE16: 90,
|
|
281
|
+
POLYPOLYGON16: 91,
|
|
282
|
+
CREATEMONOBRUSH: 93,
|
|
283
|
+
CREATEDIBPATTERNBRUSHPT: 94,
|
|
284
|
+
EXTCREATEPEN: 95,
|
|
285
|
+
BITBLT: 76,
|
|
286
|
+
STRETCHDIBITS: 81
|
|
287
|
+
}, y = {
|
|
288
|
+
WHITE_BRUSH: 2147483648,
|
|
289
|
+
LTGRAY_BRUSH: 2147483649,
|
|
290
|
+
GRAY_BRUSH: 2147483650,
|
|
291
|
+
DKGRAY_BRUSH: 2147483651,
|
|
292
|
+
BLACK_BRUSH: 2147483652,
|
|
293
|
+
NULL_BRUSH: 2147483653,
|
|
294
|
+
WHITE_PEN: 2147483654,
|
|
295
|
+
BLACK_PEN: 2147483655,
|
|
296
|
+
NULL_PEN: 2147483656,
|
|
297
|
+
DC_BRUSH: 2147483666,
|
|
298
|
+
DC_PEN: 2147483662
|
|
299
|
+
}, b = {
|
|
300
|
+
TEXT: 1,
|
|
301
|
+
LOMETRIC: 2,
|
|
302
|
+
HIMETRIC: 3,
|
|
303
|
+
LOENGLISH: 4,
|
|
304
|
+
HIENGLISH: 5,
|
|
305
|
+
TWIPS: 6,
|
|
306
|
+
ISOTROPIC: 7,
|
|
307
|
+
ANISOTROPIC: 8
|
|
308
|
+
}, re = () => ({
|
|
309
|
+
m11: 1,
|
|
310
|
+
m12: 0,
|
|
311
|
+
m21: 0,
|
|
312
|
+
m22: 1,
|
|
313
|
+
dx: 0,
|
|
314
|
+
dy: 0
|
|
315
|
+
});
|
|
316
|
+
function ie(e, t) {
|
|
317
|
+
return {
|
|
318
|
+
m11: e.m11 * t.m11 + e.m21 * t.m12,
|
|
319
|
+
m12: e.m12 * t.m11 + e.m22 * t.m12,
|
|
320
|
+
m21: e.m11 * t.m21 + e.m21 * t.m22,
|
|
321
|
+
m22: e.m12 * t.m21 + e.m22 * t.m22,
|
|
322
|
+
dx: e.m11 * t.dx + e.m21 * t.dy + e.dx,
|
|
323
|
+
dy: e.m12 * t.dx + e.m22 * t.dy + e.dy
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
var ae = class {
|
|
327
|
+
p;
|
|
328
|
+
constructor(e, t, n) {
|
|
329
|
+
this.dv = e, this.end = n, this.p = t;
|
|
330
|
+
}
|
|
331
|
+
get pos() {
|
|
332
|
+
return this.p;
|
|
333
|
+
}
|
|
334
|
+
set pos(e) {
|
|
335
|
+
this.p = e;
|
|
336
|
+
}
|
|
337
|
+
get remaining() {
|
|
338
|
+
return this.end - this.p;
|
|
339
|
+
}
|
|
340
|
+
i16() {
|
|
341
|
+
let e = this.dv.getInt16(this.p, !0);
|
|
342
|
+
return this.p += 2, e;
|
|
343
|
+
}
|
|
344
|
+
i32() {
|
|
345
|
+
let e = this.dv.getInt32(this.p, !0);
|
|
346
|
+
return this.p += 4, e;
|
|
347
|
+
}
|
|
348
|
+
u32() {
|
|
349
|
+
let e = this.dv.getUint32(this.p, !0);
|
|
350
|
+
return this.p += 4, e;
|
|
351
|
+
}
|
|
352
|
+
f32() {
|
|
353
|
+
let e = this.dv.getFloat32(this.p, !0);
|
|
354
|
+
return this.p += 4, e;
|
|
355
|
+
}
|
|
356
|
+
xform() {
|
|
357
|
+
return {
|
|
358
|
+
m11: this.f32(),
|
|
359
|
+
m12: this.f32(),
|
|
360
|
+
m21: this.f32(),
|
|
361
|
+
m22: this.f32(),
|
|
362
|
+
dx: this.f32(),
|
|
363
|
+
dy: this.f32()
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
skip(e) {
|
|
367
|
+
this.p += e;
|
|
368
|
+
}
|
|
369
|
+
};
|
|
370
|
+
function oe(e, t, n) {
|
|
371
|
+
return e.wt.m11 * t + e.wt.m21 * n + e.wt.dx;
|
|
372
|
+
}
|
|
373
|
+
function se(e, t, n) {
|
|
374
|
+
return e.wt.m12 * t + e.wt.m22 * n + e.wt.dy;
|
|
375
|
+
}
|
|
376
|
+
function x(e) {
|
|
377
|
+
return e.winExtX === 0 ? 1 : e.vpExtX / e.winExtX;
|
|
378
|
+
}
|
|
379
|
+
function S(e) {
|
|
380
|
+
return e.winExtY === 0 ? 1 : e.vpExtY / e.winExtY;
|
|
381
|
+
}
|
|
382
|
+
function C(e) {
|
|
383
|
+
return Math.min(Math.abs(x(e)), Math.abs(S(e)));
|
|
384
|
+
}
|
|
385
|
+
function ce(e) {
|
|
386
|
+
return e.mapMode === b.ISOTROPIC ? x(e) < 0 ? -C(e) : C(e) : x(e);
|
|
387
|
+
}
|
|
388
|
+
function w(e) {
|
|
389
|
+
return e.mapMode === b.ISOTROPIC ? S(e) < 0 ? -C(e) : C(e) : S(e);
|
|
390
|
+
}
|
|
391
|
+
function le(e, t) {
|
|
392
|
+
return (t - e.winOrgX) * ce(e) + e.vpOrgX;
|
|
393
|
+
}
|
|
394
|
+
function ue(e, t) {
|
|
395
|
+
return (t - e.winOrgY) * w(e) + e.vpOrgY;
|
|
396
|
+
}
|
|
397
|
+
function T(e, t, n) {
|
|
398
|
+
let r = le(e, oe(e, t, n)), i = ue(e, se(e, t, n));
|
|
399
|
+
return [(r - e.left) * e.W / e.boundsW, (i - e.top) * e.H / e.boundsH];
|
|
400
|
+
}
|
|
401
|
+
function de(e) {
|
|
402
|
+
return (Math.hypot(e.wt.m11, e.wt.m12) + Math.hypot(e.wt.m21, e.wt.m22)) / 2;
|
|
403
|
+
}
|
|
404
|
+
function fe(e) {
|
|
405
|
+
return (Math.abs(ce(e)) + Math.abs(w(e))) / 2;
|
|
406
|
+
}
|
|
407
|
+
function pe(e) {
|
|
408
|
+
return (e.W / e.boundsW + e.H / e.boundsH) / 2;
|
|
409
|
+
}
|
|
410
|
+
function me(e) {
|
|
411
|
+
return Math.hypot(e.wt.m21, e.wt.m22);
|
|
412
|
+
}
|
|
413
|
+
function he(e) {
|
|
414
|
+
return e.H / e.boundsH;
|
|
415
|
+
}
|
|
416
|
+
function E(e, t) {
|
|
417
|
+
let n = t * de(e) * fe(e) * pe(e);
|
|
418
|
+
return Math.max(.75, n);
|
|
419
|
+
}
|
|
420
|
+
function ge(e, t) {
|
|
421
|
+
if (e.mapMode = t, t === b.TEXT) {
|
|
422
|
+
e.winOrgX = 0, e.winOrgY = 0, e.vpOrgX = 0, e.vpOrgY = 0, e.winExtX = 1, e.winExtY = 1, e.vpExtX = 1, e.vpExtY = 1;
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (t === b.ANISOTROPIC || t === b.ISOTROPIC || e.devPxPerMmX <= 0 || e.devPxPerMmY <= 0) return;
|
|
426
|
+
let n = 25.4, r = t === b.LOMETRIC ? .1 : t === b.HIMETRIC ? .01 : t === b.LOENGLISH ? .01 * n : t === b.HIENGLISH ? .001 * n : t === b.TWIPS ? n / 1440 : 0;
|
|
427
|
+
r <= 0 || (e.winOrgX = 0, e.winOrgY = 0, e.vpOrgX = 0, e.vpOrgY = 0, e.winExtX = 1, e.winExtY = 1, e.vpExtX = r * e.devPxPerMmX, e.vpExtY = -(r * e.devPxPerMmY));
|
|
428
|
+
}
|
|
429
|
+
var _e = {
|
|
430
|
+
[y.WHITE_BRUSH]: {
|
|
431
|
+
kind: "brush",
|
|
432
|
+
fill: "#ffffff"
|
|
433
|
+
},
|
|
434
|
+
[y.LTGRAY_BRUSH]: {
|
|
435
|
+
kind: "brush",
|
|
436
|
+
fill: "#c0c0c0"
|
|
437
|
+
},
|
|
438
|
+
[y.GRAY_BRUSH]: {
|
|
439
|
+
kind: "brush",
|
|
440
|
+
fill: "#808080"
|
|
441
|
+
},
|
|
442
|
+
[y.DKGRAY_BRUSH]: {
|
|
443
|
+
kind: "brush",
|
|
444
|
+
fill: "#404040"
|
|
445
|
+
},
|
|
446
|
+
[y.BLACK_BRUSH]: {
|
|
447
|
+
kind: "brush",
|
|
448
|
+
fill: "#000000"
|
|
449
|
+
},
|
|
450
|
+
[y.NULL_BRUSH]: {
|
|
451
|
+
kind: "brush",
|
|
452
|
+
fill: null
|
|
453
|
+
}
|
|
454
|
+
}, ve = {
|
|
455
|
+
[y.WHITE_PEN]: {
|
|
456
|
+
kind: "pen",
|
|
457
|
+
stroke: "#ffffff",
|
|
458
|
+
width: 1
|
|
459
|
+
},
|
|
460
|
+
[y.BLACK_PEN]: {
|
|
461
|
+
kind: "pen",
|
|
462
|
+
stroke: "#000000",
|
|
463
|
+
width: 1
|
|
464
|
+
},
|
|
465
|
+
[y.NULL_PEN]: {
|
|
466
|
+
kind: "pen",
|
|
467
|
+
stroke: null,
|
|
468
|
+
width: 1
|
|
469
|
+
},
|
|
470
|
+
[y.DC_PEN]: {
|
|
471
|
+
kind: "pen",
|
|
472
|
+
stroke: "#000000",
|
|
473
|
+
width: 1
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
function ye(e, t) {
|
|
477
|
+
let n = _e[t];
|
|
478
|
+
if (n) {
|
|
479
|
+
e.curBrush = n;
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
let r = ve[t];
|
|
483
|
+
if (r) {
|
|
484
|
+
e.curPen = r;
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
t === y.DC_BRUSH && (e.curBrush = e.curBrush ?? {
|
|
488
|
+
kind: "brush",
|
|
489
|
+
fill: "#000000"
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
function be(e) {
|
|
493
|
+
let t = 0, n = 0, r = 0, i = 0;
|
|
494
|
+
for (let a = 0; a < e.data.length; a += 4) e.data[a + 3] !== 0 && (t += e.data[a], n += e.data[a + 1], r += e.data[a + 2], i++);
|
|
495
|
+
if (i === 0) return "#808080";
|
|
496
|
+
let a = (e) => Math.round(e / i).toString(16).padStart(2, "0");
|
|
497
|
+
return `#${a(t)}${a(n)}${a(r)}`;
|
|
498
|
+
}
|
|
499
|
+
var D = (e) => [e.i16(), e.i16()], O = (e) => [e.i32(), e.i32()];
|
|
500
|
+
function xe(e, t, n) {
|
|
501
|
+
t.skip(16);
|
|
502
|
+
let r = t.u32();
|
|
503
|
+
if (r < 2 || r > 1048576 || !e.curPen || e.curPen.stroke == null) return;
|
|
504
|
+
let { ctx: i } = e;
|
|
505
|
+
i.beginPath();
|
|
506
|
+
let a = 0, o = 0;
|
|
507
|
+
for (let s = 0; s < r && !(t.remaining < 4); s++) {
|
|
508
|
+
let [r, c] = n(t), [l, u] = T(e, r, c);
|
|
509
|
+
s === 0 ? i.moveTo(l, u) : i.lineTo(l, u), a = r, o = c;
|
|
510
|
+
}
|
|
511
|
+
i.strokeStyle = e.curPen.stroke, i.lineWidth = E(e, e.curPen.width), i.stroke(), e.drew = !0, e.curX = a, e.curY = o;
|
|
512
|
+
}
|
|
513
|
+
function k(e, t, n) {
|
|
514
|
+
t.skip(16);
|
|
515
|
+
let r = t.u32();
|
|
516
|
+
if (r < 1 || r > 1048576) return;
|
|
517
|
+
let { ctx: i } = e, a = e.curPen != null && e.curPen.stroke != null;
|
|
518
|
+
if (a) {
|
|
519
|
+
i.beginPath();
|
|
520
|
+
let [t, n] = T(e, e.curX, e.curY);
|
|
521
|
+
i.moveTo(t, n);
|
|
522
|
+
}
|
|
523
|
+
for (let o = 0; o < r && !(t.remaining < 4); o++) {
|
|
524
|
+
let [r, o] = n(t);
|
|
525
|
+
if (a) {
|
|
526
|
+
let [t, n] = T(e, r, o);
|
|
527
|
+
i.lineTo(t, n);
|
|
528
|
+
}
|
|
529
|
+
e.curX = r, e.curY = o;
|
|
530
|
+
}
|
|
531
|
+
a && e.curPen && (i.strokeStyle = e.curPen.stroke, i.lineWidth = E(e, e.curPen.width), i.stroke(), e.drew = !0);
|
|
532
|
+
}
|
|
533
|
+
function Se(e, t, n) {
|
|
534
|
+
t.skip(16);
|
|
535
|
+
let r = t.u32();
|
|
536
|
+
if (r < 2 || r > 1048576) return;
|
|
537
|
+
let { ctx: i } = e;
|
|
538
|
+
e.inPath || i.beginPath();
|
|
539
|
+
let a = !1;
|
|
540
|
+
for (let o = 0; o < r && !(t.remaining < 4); o++) {
|
|
541
|
+
let [r, o] = n(t), [s, c] = T(e, r, o);
|
|
542
|
+
a ? i.lineTo(s, c) : (i.moveTo(s, c), a = !0);
|
|
543
|
+
}
|
|
544
|
+
a && (i.closePath(), !e.inPath && (e.curBrush && e.curBrush.fill != null && (i.fillStyle = e.curBrush.fill, i.fill(e.fillRule), e.drew = !0), e.curPen && e.curPen.stroke != null && (i.strokeStyle = e.curPen.stroke, i.lineWidth = E(e, e.curPen.width), i.stroke(), e.drew = !0)));
|
|
545
|
+
}
|
|
546
|
+
function A(e, t, n, r) {
|
|
547
|
+
t.skip(16);
|
|
548
|
+
let i = t.u32();
|
|
549
|
+
if (i < 1 || i > 1048576) return;
|
|
550
|
+
let a = [];
|
|
551
|
+
for (let e = 0; e < i && !(t.remaining < 4); e++) a.push(n(t));
|
|
552
|
+
if (a.length < (r ? 3 : 4)) {
|
|
553
|
+
a.length && (e.curX = a[a.length - 1][0], e.curY = a[a.length - 1][1]);
|
|
554
|
+
return;
|
|
555
|
+
}
|
|
556
|
+
let o = e.curPen != null && e.curPen.stroke != null, { ctx: s } = e;
|
|
557
|
+
if (o) {
|
|
558
|
+
s.beginPath();
|
|
559
|
+
let t = r ? T(e, e.curX, e.curY) : T(e, a[0][0], a[0][1]);
|
|
560
|
+
s.moveTo(t[0], t[1]);
|
|
561
|
+
}
|
|
562
|
+
let c = +!r;
|
|
563
|
+
for (; c + 2 < a.length + +!!r; c += 3) {
|
|
564
|
+
let t = a[c], n = a[c + 1], r = a[c + 2];
|
|
565
|
+
if (!t || !n || !r) break;
|
|
566
|
+
if (o) {
|
|
567
|
+
let i = T(e, t[0], t[1]), a = T(e, n[0], n[1]), o = T(e, r[0], r[1]);
|
|
568
|
+
s.bezierCurveTo(i[0], i[1], a[0], a[1], o[0], o[1]);
|
|
569
|
+
}
|
|
570
|
+
e.curX = r[0], e.curY = r[1];
|
|
571
|
+
}
|
|
572
|
+
o && e.curPen && (s.strokeStyle = e.curPen.stroke, s.lineWidth = E(e, e.curPen.width), s.stroke(), e.drew = !0);
|
|
573
|
+
}
|
|
574
|
+
function j(e, t, n, r) {
|
|
575
|
+
t.skip(16);
|
|
576
|
+
let i = t.u32(), a = t.u32();
|
|
577
|
+
if (i <= 0 || i > 65536 || a <= 0 || a > 2097152) return;
|
|
578
|
+
let o = [];
|
|
579
|
+
for (let e = 0; e < i; e++) {
|
|
580
|
+
if (t.remaining < 4) return;
|
|
581
|
+
o.push(t.u32());
|
|
582
|
+
}
|
|
583
|
+
let { ctx: s } = e;
|
|
584
|
+
e.inPath || s.beginPath();
|
|
585
|
+
let c = !1;
|
|
586
|
+
for (let i of o) {
|
|
587
|
+
if (i < 2) {
|
|
588
|
+
for (let e = 0; e < i && t.remaining >= 4; e++) n(t);
|
|
589
|
+
continue;
|
|
590
|
+
}
|
|
591
|
+
for (let r = 0; r < i && !(t.remaining < 4); r++) {
|
|
592
|
+
let [i, a] = n(t), [o, c] = T(e, i, a);
|
|
593
|
+
r === 0 ? s.moveTo(o, c) : s.lineTo(o, c);
|
|
594
|
+
}
|
|
595
|
+
r && s.closePath(), c = !0;
|
|
596
|
+
}
|
|
597
|
+
!c || e.inPath || (r && e.curBrush && e.curBrush.fill != null && (s.fillStyle = e.curBrush.fill, s.fill(e.fillRule), e.drew = !0), e.curPen && e.curPen.stroke != null && (s.strokeStyle = e.curPen.stroke, s.lineWidth = E(e, e.curPen.width), s.stroke(), e.drew = !0));
|
|
598
|
+
}
|
|
599
|
+
function Ce(e, t, n, r, i) {
|
|
600
|
+
let { ctx: a } = e, o = T(e, t, n), s = T(e, r, n), c = T(e, r, i), l = T(e, t, i);
|
|
601
|
+
e.inPath || a.beginPath(), a.moveTo(o[0], o[1]), a.lineTo(s[0], s[1]), a.lineTo(c[0], c[1]), a.lineTo(l[0], l[1]), a.closePath(), !e.inPath && (e.curBrush && e.curBrush.fill != null && (a.fillStyle = e.curBrush.fill, a.fill(e.fillRule), e.drew = !0), e.curPen && e.curPen.stroke != null && (a.strokeStyle = e.curPen.stroke, a.lineWidth = E(e, e.curPen.width), a.stroke(), e.drew = !0));
|
|
602
|
+
}
|
|
603
|
+
function we(e) {
|
|
604
|
+
let t = e.u32(), n = e.u32(), r = e.i32();
|
|
605
|
+
e.i32();
|
|
606
|
+
let i = e.u32();
|
|
607
|
+
return [t, {
|
|
608
|
+
kind: "pen",
|
|
609
|
+
stroke: (n & 255) == 5 ? null : R(i),
|
|
610
|
+
width: Math.abs(r)
|
|
611
|
+
}];
|
|
612
|
+
}
|
|
613
|
+
function Te(e) {
|
|
614
|
+
let t = e.u32();
|
|
615
|
+
e.skip(16);
|
|
616
|
+
let n = e.u32(), r = e.u32();
|
|
617
|
+
e.u32();
|
|
618
|
+
let i = e.u32();
|
|
619
|
+
return [t, {
|
|
620
|
+
kind: "pen",
|
|
621
|
+
stroke: (n & 255) == 5 ? null : R(i),
|
|
622
|
+
width: Math.abs(r)
|
|
623
|
+
}];
|
|
624
|
+
}
|
|
625
|
+
function Ee(e) {
|
|
626
|
+
let t = e.u32(), n = e.u32(), r = e.u32();
|
|
627
|
+
return e.u32(), [t, {
|
|
628
|
+
kind: "brush",
|
|
629
|
+
fill: n === 1 ? null : R(r)
|
|
630
|
+
}];
|
|
631
|
+
}
|
|
632
|
+
function De(e, t, n) {
|
|
633
|
+
let r = e.u32();
|
|
634
|
+
e.u32();
|
|
635
|
+
let i = e.u32(), a = e.u32(), o = e.u32(), s = e.u32(), c = "#808080";
|
|
636
|
+
try {
|
|
637
|
+
let e = _(t, n + i, a, n + o, s);
|
|
638
|
+
e && (c = be(e));
|
|
639
|
+
} catch {}
|
|
640
|
+
return [r, {
|
|
641
|
+
kind: "brush",
|
|
642
|
+
fill: c
|
|
643
|
+
}];
|
|
644
|
+
}
|
|
645
|
+
function Oe(e, t, n) {
|
|
646
|
+
let r = e.u32(), i = n + 12, a = t.getInt32(i, !0), o = t.getInt32(i + 8, !0), s = t.getInt32(i + 16, !0), c = t.getUint8(i + 20), l = "";
|
|
647
|
+
for (let e = 0; e < 32; e++) {
|
|
648
|
+
let n = i + 28 + e * 2;
|
|
649
|
+
if (n + 2 > t.byteLength) break;
|
|
650
|
+
let r = t.getUint16(n, !0);
|
|
651
|
+
if (r === 0) break;
|
|
652
|
+
l += String.fromCharCode(r);
|
|
653
|
+
}
|
|
654
|
+
return [r, {
|
|
655
|
+
kind: "font",
|
|
656
|
+
height: Math.abs(a),
|
|
657
|
+
weight: s,
|
|
658
|
+
italic: c !== 0,
|
|
659
|
+
face: l,
|
|
660
|
+
escapement: o
|
|
661
|
+
}];
|
|
662
|
+
}
|
|
663
|
+
function ke(e, t, n, r) {
|
|
664
|
+
t.skip(16), t.u32(), t.f32(), t.f32();
|
|
665
|
+
let i = t.i32(), a = t.i32(), o = t.u32(), s = t.u32();
|
|
666
|
+
if (t.u32(), o <= 0 || o > 65536) return;
|
|
667
|
+
let c = "";
|
|
668
|
+
for (let e = 0; e < o; e++) {
|
|
669
|
+
let t = r + s + e * 2;
|
|
670
|
+
if (t + 2 > n.byteLength) break;
|
|
671
|
+
c += String.fromCharCode(n.getUint16(t, !0));
|
|
672
|
+
}
|
|
673
|
+
if (c.length === 0) return;
|
|
674
|
+
let l = e.curFont, u = Math.abs(l?.height ?? 0) * me(e) * Math.abs(w(e)) * he(e);
|
|
675
|
+
if (!Number.isFinite(u) || u < 1) return;
|
|
676
|
+
let { ctx: d } = e, [f, p] = T(e, i, a);
|
|
677
|
+
d.fillStyle = e.textColor;
|
|
678
|
+
let m = l && l.weight >= 700 ? "bold " : "";
|
|
679
|
+
d.font = `${l?.italic ? "italic " : ""}${m}${u}px ${l?.face || "sans-serif"}`;
|
|
680
|
+
let h = e.textAlign & 6;
|
|
681
|
+
d.textAlign = h === 2 ? "right" : h === 6 ? "center" : "left", d.textBaseline = (e.textAlign & 24) == 24 ? "alphabetic" : "top";
|
|
682
|
+
let g = l?.escapement ?? 0;
|
|
683
|
+
try {
|
|
684
|
+
if (g !== 0) {
|
|
685
|
+
d.save();
|
|
686
|
+
try {
|
|
687
|
+
d.translate(f, p), d.rotate(-g / 10 * (Math.PI / 180)), d.fillText(c, 0, 0);
|
|
688
|
+
} finally {
|
|
689
|
+
d.restore();
|
|
690
|
+
}
|
|
691
|
+
} else d.fillText(c, f, p);
|
|
692
|
+
e.drew = !0;
|
|
693
|
+
} catch {}
|
|
694
|
+
}
|
|
695
|
+
function M(e, t, n, r, i, a, o, s, c, l, u) {
|
|
696
|
+
if (i === 0 || o === 0) return;
|
|
697
|
+
let d = _(t, n + r, i, n + a, o);
|
|
698
|
+
if (!d) return;
|
|
699
|
+
let [f, p] = T(e, s, c), [m, h] = T(e, l, u);
|
|
700
|
+
ne(e.ctx, d, f, p, m, h) && (e.drew = !0);
|
|
701
|
+
}
|
|
702
|
+
function Ae(e, t, n, r) {
|
|
703
|
+
t.skip(16);
|
|
704
|
+
let i = t.i32(), a = t.i32(), o = t.i32(), s = t.i32();
|
|
705
|
+
t.u32(), t.i32(), t.i32(), t.skip(24), t.u32(), t.u32(), M(e, n, r, t.u32(), t.u32(), t.u32(), t.u32(), i, a, i + o, a + s);
|
|
706
|
+
}
|
|
707
|
+
function je(e, t, n, r) {
|
|
708
|
+
t.skip(16);
|
|
709
|
+
let i = t.i32(), a = t.i32();
|
|
710
|
+
t.i32(), t.i32(), t.i32(), t.i32();
|
|
711
|
+
let o = t.u32(), s = t.u32(), c = t.u32(), l = t.u32();
|
|
712
|
+
t.u32(), t.u32();
|
|
713
|
+
let u = t.i32(), d = t.i32();
|
|
714
|
+
M(e, n, r, o, s, c, l, i, a, i + u, a + d);
|
|
715
|
+
}
|
|
716
|
+
function Me(e, t, n, r) {
|
|
717
|
+
if (!L(e) || n <= 0 || r <= 0) return !1;
|
|
718
|
+
let i = new DataView(e.buffer, e.byteOffset, e.byteLength), a = {
|
|
719
|
+
ctx: t,
|
|
720
|
+
W: n,
|
|
721
|
+
H: r,
|
|
722
|
+
left: 0,
|
|
723
|
+
top: 0,
|
|
724
|
+
boundsW: n,
|
|
725
|
+
boundsH: r,
|
|
726
|
+
wt: re(),
|
|
727
|
+
mapMode: b.TEXT,
|
|
728
|
+
winOrgX: 0,
|
|
729
|
+
winOrgY: 0,
|
|
730
|
+
winExtX: 1,
|
|
731
|
+
winExtY: 1,
|
|
732
|
+
vpOrgX: 0,
|
|
733
|
+
vpOrgY: 0,
|
|
734
|
+
vpExtX: 1,
|
|
735
|
+
vpExtY: 1,
|
|
736
|
+
devPxPerMmX: 0,
|
|
737
|
+
devPxPerMmY: 0,
|
|
738
|
+
objects: /* @__PURE__ */ new Map(),
|
|
739
|
+
curPen: null,
|
|
740
|
+
curBrush: null,
|
|
741
|
+
curFont: null,
|
|
742
|
+
textColor: "#000000",
|
|
743
|
+
bkMode: 1,
|
|
744
|
+
textAlign: 0,
|
|
745
|
+
fillRule: "nonzero",
|
|
746
|
+
curX: 0,
|
|
747
|
+
curY: 0,
|
|
748
|
+
stack: [],
|
|
749
|
+
drew: !1,
|
|
750
|
+
inPath: !1
|
|
751
|
+
}, o = 0;
|
|
752
|
+
for (; o + 8 <= e.length;) {
|
|
753
|
+
let n = i.getUint32(o, !0), r = i.getUint32(o + 4, !0);
|
|
754
|
+
if (r < 8 || r & 3) break;
|
|
755
|
+
let s = o + r;
|
|
756
|
+
if (s > e.length || n === v.EOF) break;
|
|
757
|
+
let c = new ae(i, o + 8, s);
|
|
758
|
+
try {
|
|
759
|
+
switch (n) {
|
|
760
|
+
case v.HEADER: {
|
|
761
|
+
let e = i.getInt32(o + 8, !0), t = i.getInt32(o + 12, !0), n = i.getInt32(o + 16, !0), r = i.getInt32(o + 20, !0);
|
|
762
|
+
if (a.left = e, a.top = t, a.boundsW = Math.max(1, n - e), a.boundsH = Math.max(1, r - t), s >= o + 88) {
|
|
763
|
+
let e = i.getInt32(o + 24, !0), t = i.getInt32(o + 28, !0), n = i.getInt32(o + 32, !0), r = i.getInt32(o + 36, !0), s = i.getInt32(o + 72, !0), c = i.getInt32(o + 76, !0), l = i.getInt32(o + 80, !0), u = i.getInt32(o + 84, !0), d = n - e, f = r - t;
|
|
764
|
+
if (d > 0 && f > 0 && s > 0 && c > 0 && l > 0 && u > 0) {
|
|
765
|
+
let n = s / (l * 100), r = c / (u * 100);
|
|
766
|
+
a.left = e * n, a.top = t * r, a.boundsW = Math.max(1, d * n), a.boundsH = Math.max(1, f * r), a.devPxPerMmX = s / l, a.devPxPerMmY = c / u;
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
break;
|
|
770
|
+
}
|
|
771
|
+
case v.SETWORLDTRANSFORM:
|
|
772
|
+
a.wt = c.xform();
|
|
773
|
+
break;
|
|
774
|
+
case v.MODIFYWORLDTRANSFORM: {
|
|
775
|
+
let e = c.xform(), t = c.u32();
|
|
776
|
+
t === 1 ? a.wt = re() : t === 2 ? a.wt = ie(e, a.wt) : t === 3 ? a.wt = ie(a.wt, e) : t === 4 && (a.wt = e);
|
|
777
|
+
break;
|
|
778
|
+
}
|
|
779
|
+
case v.SETMAPMODE:
|
|
780
|
+
ge(a, c.u32());
|
|
781
|
+
break;
|
|
782
|
+
case v.SETWINDOWORGEX:
|
|
783
|
+
a.winOrgX = c.i32(), a.winOrgY = c.i32();
|
|
784
|
+
break;
|
|
785
|
+
case v.SETWINDOWEXTEX: {
|
|
786
|
+
let e = c.i32(), t = c.i32();
|
|
787
|
+
e !== 0 && (a.winExtX = e), t !== 0 && (a.winExtY = t);
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
case v.SETVIEWPORTORGEX:
|
|
791
|
+
a.vpOrgX = c.i32(), a.vpOrgY = c.i32();
|
|
792
|
+
break;
|
|
793
|
+
case v.SETVIEWPORTEXTEX: {
|
|
794
|
+
let e = c.i32(), t = c.i32();
|
|
795
|
+
e !== 0 && (a.vpExtX = e), t !== 0 && (a.vpExtY = t);
|
|
796
|
+
break;
|
|
797
|
+
}
|
|
798
|
+
case v.SCALEWINDOWEXTEX: {
|
|
799
|
+
let e = c.i32(), t = c.i32(), n = c.i32(), r = c.i32();
|
|
800
|
+
t !== 0 && (a.winExtX = a.winExtX * e / t), r !== 0 && (a.winExtY = a.winExtY * n / r);
|
|
801
|
+
break;
|
|
802
|
+
}
|
|
803
|
+
case v.SCALEVIEWPORTEXTEX: {
|
|
804
|
+
let e = c.i32(), t = c.i32(), n = c.i32(), r = c.i32();
|
|
805
|
+
t !== 0 && (a.vpExtX = a.vpExtX * e / t), r !== 0 && (a.vpExtY = a.vpExtY * n / r);
|
|
806
|
+
break;
|
|
807
|
+
}
|
|
808
|
+
case v.SAVEDC:
|
|
809
|
+
a.ctx.save(), a.stack.push({
|
|
810
|
+
wt: { ...a.wt },
|
|
811
|
+
mapMode: a.mapMode,
|
|
812
|
+
winOrgX: a.winOrgX,
|
|
813
|
+
winOrgY: a.winOrgY,
|
|
814
|
+
winExtX: a.winExtX,
|
|
815
|
+
winExtY: a.winExtY,
|
|
816
|
+
vpOrgX: a.vpOrgX,
|
|
817
|
+
vpOrgY: a.vpOrgY,
|
|
818
|
+
vpExtX: a.vpExtX,
|
|
819
|
+
vpExtY: a.vpExtY,
|
|
820
|
+
curPen: a.curPen,
|
|
821
|
+
curBrush: a.curBrush,
|
|
822
|
+
curFont: a.curFont,
|
|
823
|
+
textColor: a.textColor,
|
|
824
|
+
bkMode: a.bkMode,
|
|
825
|
+
textAlign: a.textAlign,
|
|
826
|
+
fillRule: a.fillRule,
|
|
827
|
+
curX: a.curX,
|
|
828
|
+
curY: a.curY
|
|
829
|
+
});
|
|
830
|
+
break;
|
|
831
|
+
case v.RESTOREDC: {
|
|
832
|
+
let e = c.i32(), t = Math.min(Math.abs(e) || 1, a.stack.length), n;
|
|
833
|
+
for (let e = 0; e < t; e++) n = a.stack.pop(), a.ctx.restore();
|
|
834
|
+
n && (a.wt = n.wt, a.mapMode = n.mapMode, a.winOrgX = n.winOrgX, a.winOrgY = n.winOrgY, a.winExtX = n.winExtX, a.winExtY = n.winExtY, a.vpOrgX = n.vpOrgX, a.vpOrgY = n.vpOrgY, a.vpExtX = n.vpExtX, a.vpExtY = n.vpExtY, a.curPen = n.curPen, a.curBrush = n.curBrush, a.curFont = n.curFont, a.textColor = n.textColor, a.bkMode = n.bkMode, a.textAlign = n.textAlign, a.fillRule = n.fillRule, a.curX = n.curX, a.curY = n.curY);
|
|
835
|
+
break;
|
|
836
|
+
}
|
|
837
|
+
case v.BEGINPATH:
|
|
838
|
+
a.ctx.beginPath(), a.inPath = !0;
|
|
839
|
+
break;
|
|
840
|
+
case v.CLOSEFIGURE:
|
|
841
|
+
a.inPath && a.ctx.closePath();
|
|
842
|
+
break;
|
|
843
|
+
case v.ENDPATH:
|
|
844
|
+
a.inPath = !1;
|
|
845
|
+
break;
|
|
846
|
+
case v.SELECTCLIPPATH:
|
|
847
|
+
try {
|
|
848
|
+
a.ctx.clip(a.fillRule);
|
|
849
|
+
} catch {}
|
|
850
|
+
break;
|
|
851
|
+
case v.SELECTOBJECT: {
|
|
852
|
+
let e = c.u32();
|
|
853
|
+
if (e & 2147483648) ye(a, e >>> 0);
|
|
854
|
+
else {
|
|
855
|
+
let t = a.objects.get(e);
|
|
856
|
+
t?.kind === "pen" ? a.curPen = t : t?.kind === "brush" ? a.curBrush = t : t?.kind === "font" && (a.curFont = t);
|
|
857
|
+
}
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
case v.DELETEOBJECT: {
|
|
861
|
+
let e = c.u32(), t = a.objects.get(e);
|
|
862
|
+
t && (t === a.curPen && (a.curPen = null), t === a.curBrush && (a.curBrush = null), t === a.curFont && (a.curFont = null), a.objects.delete(e));
|
|
863
|
+
break;
|
|
864
|
+
}
|
|
865
|
+
case v.CREATEPEN: {
|
|
866
|
+
let [e, t] = we(c);
|
|
867
|
+
a.objects.set(e, t);
|
|
868
|
+
break;
|
|
869
|
+
}
|
|
870
|
+
case v.EXTCREATEPEN: {
|
|
871
|
+
let [e, t] = Te(c);
|
|
872
|
+
a.objects.set(e, t);
|
|
873
|
+
break;
|
|
874
|
+
}
|
|
875
|
+
case v.CREATEBRUSHINDIRECT: {
|
|
876
|
+
let [e, t] = Ee(c);
|
|
877
|
+
a.objects.set(e, t);
|
|
878
|
+
break;
|
|
879
|
+
}
|
|
880
|
+
case v.CREATEMONOBRUSH:
|
|
881
|
+
case v.CREATEDIBPATTERNBRUSHPT: {
|
|
882
|
+
let [e, t] = De(c, i, o);
|
|
883
|
+
a.objects.set(e, t);
|
|
884
|
+
break;
|
|
885
|
+
}
|
|
886
|
+
case v.EXTCREATEFONTINDIRECTW: {
|
|
887
|
+
let [e, t] = Oe(c, i, o);
|
|
888
|
+
a.objects.set(e, t);
|
|
889
|
+
break;
|
|
890
|
+
}
|
|
891
|
+
case v.POLYLINE16:
|
|
892
|
+
xe(a, c, D);
|
|
893
|
+
break;
|
|
894
|
+
case v.POLYLINE:
|
|
895
|
+
xe(a, c, O);
|
|
896
|
+
break;
|
|
897
|
+
case v.POLYLINETO16:
|
|
898
|
+
k(a, c, D);
|
|
899
|
+
break;
|
|
900
|
+
case v.POLYLINETO:
|
|
901
|
+
k(a, c, O);
|
|
902
|
+
break;
|
|
903
|
+
case v.POLYGON16:
|
|
904
|
+
Se(a, c, D);
|
|
905
|
+
break;
|
|
906
|
+
case v.POLYGON:
|
|
907
|
+
Se(a, c, O);
|
|
908
|
+
break;
|
|
909
|
+
case v.POLYBEZIER16:
|
|
910
|
+
A(a, c, D, !1);
|
|
911
|
+
break;
|
|
912
|
+
case v.POLYBEZIER:
|
|
913
|
+
A(a, c, O, !1);
|
|
914
|
+
break;
|
|
915
|
+
case v.POLYBEZIERTO16:
|
|
916
|
+
A(a, c, D, !0);
|
|
917
|
+
break;
|
|
918
|
+
case v.POLYBEZIERTO:
|
|
919
|
+
A(a, c, O, !0);
|
|
920
|
+
break;
|
|
921
|
+
case v.POLYPOLYGON16:
|
|
922
|
+
j(a, c, D, !0);
|
|
923
|
+
break;
|
|
924
|
+
case v.POLYPOLYGON:
|
|
925
|
+
j(a, c, O, !0);
|
|
926
|
+
break;
|
|
927
|
+
case v.POLYPOLYLINE16:
|
|
928
|
+
j(a, c, D, !1);
|
|
929
|
+
break;
|
|
930
|
+
case v.POLYPOLYLINE:
|
|
931
|
+
j(a, c, O, !1);
|
|
932
|
+
break;
|
|
933
|
+
case v.MOVETOEX:
|
|
934
|
+
a.curX = c.i32(), a.curY = c.i32();
|
|
935
|
+
break;
|
|
936
|
+
case v.LINETO: {
|
|
937
|
+
let e = c.i32(), n = c.i32();
|
|
938
|
+
if (a.curPen && a.curPen.stroke != null) {
|
|
939
|
+
let [r, i] = T(a, a.curX, a.curY), [o, s] = T(a, e, n);
|
|
940
|
+
t.beginPath(), t.moveTo(r, i), t.lineTo(o, s), t.strokeStyle = a.curPen.stroke, t.lineWidth = E(a, a.curPen.width), t.stroke(), a.drew = !0;
|
|
941
|
+
}
|
|
942
|
+
a.curX = e, a.curY = n;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
case v.RECTANGLE:
|
|
946
|
+
Ce(a, c.i32(), c.i32(), c.i32(), c.i32());
|
|
947
|
+
break;
|
|
948
|
+
case v.ELLIPSE: {
|
|
949
|
+
let e = c.i32(), n = c.i32(), r = c.i32(), i = c.i32(), [o, s] = [(e + r) / 2, (n + i) / 2], [l, u] = T(a, o, s), [d] = T(a, r, s), [, f] = T(a, o, i), p = Math.abs(d - l), m = Math.abs(f - u);
|
|
950
|
+
t.beginPath(), t.ellipse(l, u, p, m, 0, 0, Math.PI * 2), a.curBrush && a.curBrush.fill != null && (t.fillStyle = a.curBrush.fill, t.fill(a.fillRule), a.drew = !0), a.curPen && a.curPen.stroke != null && (t.strokeStyle = a.curPen.stroke, t.lineWidth = E(a, a.curPen.width), t.stroke(), a.drew = !0);
|
|
951
|
+
break;
|
|
952
|
+
}
|
|
953
|
+
case v.SETPOLYFILLMODE:
|
|
954
|
+
a.fillRule = c.u32() === 1 ? "evenodd" : "nonzero";
|
|
955
|
+
break;
|
|
956
|
+
case v.SETTEXTCOLOR:
|
|
957
|
+
a.textColor = R(c.u32());
|
|
958
|
+
break;
|
|
959
|
+
case v.SETTEXTALIGN:
|
|
960
|
+
a.textAlign = c.u32();
|
|
961
|
+
break;
|
|
962
|
+
case v.SETBKMODE:
|
|
963
|
+
a.bkMode = c.u32();
|
|
964
|
+
break;
|
|
965
|
+
case v.EXTTEXTOUTW:
|
|
966
|
+
ke(a, c, i, o);
|
|
967
|
+
break;
|
|
968
|
+
case v.BITBLT:
|
|
969
|
+
Ae(a, c, i, o);
|
|
970
|
+
break;
|
|
971
|
+
case v.STRETCHDIBITS:
|
|
972
|
+
je(a, c, i, o);
|
|
973
|
+
break;
|
|
974
|
+
default: break;
|
|
975
|
+
}
|
|
976
|
+
} catch {}
|
|
977
|
+
o = s;
|
|
978
|
+
}
|
|
979
|
+
return a.drew;
|
|
980
|
+
}
|
|
981
|
+
async function Ne(e, t, n) {
|
|
982
|
+
if (!L(e) || t <= 0 || n <= 0) return null;
|
|
983
|
+
let r = u(t, n);
|
|
984
|
+
if (!r) return null;
|
|
985
|
+
let i = r.getContext("2d");
|
|
986
|
+
return !i || (i.lineJoin = "round", i.lineCap = "round", !Me(e, i, t, n)) ? null : createImageBitmap(r);
|
|
987
|
+
}
|
|
988
|
+
//#endregion
|
|
989
|
+
//#region packages/core/src/image/raster-dimensions.ts
|
|
990
|
+
function N(e, t) {
|
|
991
|
+
return e[t] << 8 | e[t + 1];
|
|
992
|
+
}
|
|
993
|
+
function Pe(e, t) {
|
|
994
|
+
return (e[t] << 24 | e[t + 1] << 16 | e[t + 2] << 8 | e[t + 3]) >>> 0;
|
|
995
|
+
}
|
|
996
|
+
function P(e, t) {
|
|
997
|
+
return e[t] | e[t + 1] << 8;
|
|
998
|
+
}
|
|
999
|
+
function Fe(e, t) {
|
|
1000
|
+
return e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24 | 0;
|
|
1001
|
+
}
|
|
1002
|
+
function Ie(e) {
|
|
1003
|
+
let t = e.length;
|
|
1004
|
+
return t >= 24 && e[0] === 137 && e[1] === 80 && e[2] === 78 && e[3] === 71 && e[4] === 13 && e[5] === 10 && e[6] === 26 && e[7] === 10 ? e[12] === 73 && e[13] === 72 && e[14] === 68 && e[15] === 82 ? {
|
|
1005
|
+
width: Pe(e, 16),
|
|
1006
|
+
height: Pe(e, 20)
|
|
1007
|
+
} : null : t >= 10 && e[0] === 71 && e[1] === 73 && e[2] === 70 && e[3] === 56 && (e[4] === 55 || e[4] === 57) && e[5] === 97 ? {
|
|
1008
|
+
width: P(e, 6),
|
|
1009
|
+
height: P(e, 8)
|
|
1010
|
+
} : t >= 26 && e[0] === 66 && e[1] === 77 ? Le(e, 14) === 12 ? {
|
|
1011
|
+
width: P(e, 18),
|
|
1012
|
+
height: P(e, 20)
|
|
1013
|
+
} : {
|
|
1014
|
+
width: Math.abs(Fe(e, 18)),
|
|
1015
|
+
height: Math.abs(Fe(e, 22))
|
|
1016
|
+
} : t >= 16 && e[0] === 82 && e[1] === 73 && e[2] === 70 && e[3] === 70 && e[8] === 87 && e[9] === 69 && e[10] === 66 && e[11] === 80 ? Re(e) : t >= 4 && e[0] === 255 && e[1] === 216 ? ze(e) : null;
|
|
1017
|
+
}
|
|
1018
|
+
function Le(e, t) {
|
|
1019
|
+
return (e[t] | e[t + 1] << 8 | e[t + 2] << 16 | e[t + 3] << 24) >>> 0;
|
|
1020
|
+
}
|
|
1021
|
+
function Re(e) {
|
|
1022
|
+
let t = e.length, n = e[12], r = e[13], i = e[14], a = e[15];
|
|
1023
|
+
if (n === 86 && r === 80 && i === 56 && a === 32) return t < 30 ? null : {
|
|
1024
|
+
width: P(e, 26) & 16383,
|
|
1025
|
+
height: P(e, 28) & 16383
|
|
1026
|
+
};
|
|
1027
|
+
if (n === 86 && r === 80 && i === 56 && a === 76) {
|
|
1028
|
+
if (t < 25 || e[20] !== 47) return null;
|
|
1029
|
+
let n = Le(e, 21);
|
|
1030
|
+
return {
|
|
1031
|
+
width: (n & 16383) + 1,
|
|
1032
|
+
height: (n >>> 14 & 16383) + 1
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
return n === 86 && r === 80 && i === 56 && a === 88 ? t < 30 ? null : {
|
|
1036
|
+
width: (e[24] | e[25] << 8 | e[26] << 16) + 1,
|
|
1037
|
+
height: (e[27] | e[28] << 8 | e[29] << 16) + 1
|
|
1038
|
+
} : null;
|
|
1039
|
+
}
|
|
1040
|
+
function ze(e) {
|
|
1041
|
+
let t = e.length, n = 2;
|
|
1042
|
+
for (; n + 1 < t;) {
|
|
1043
|
+
if (e[n] !== 255) {
|
|
1044
|
+
n += 1;
|
|
1045
|
+
continue;
|
|
1046
|
+
}
|
|
1047
|
+
let r = e[n + 1];
|
|
1048
|
+
if (r === 255) {
|
|
1049
|
+
n += 1;
|
|
1050
|
+
continue;
|
|
1051
|
+
}
|
|
1052
|
+
if (r === 216 || r === 1 || r >= 208 && r <= 215) {
|
|
1053
|
+
n += 2;
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
if (r === 217 || n + 3 >= t) return null;
|
|
1057
|
+
let i = N(e, n + 2);
|
|
1058
|
+
if (r >= 192 && r <= 207 && r !== 196 && r !== 200 && r !== 204) {
|
|
1059
|
+
if (n + 8 >= t) return null;
|
|
1060
|
+
let r = N(e, n + 5);
|
|
1061
|
+
return {
|
|
1062
|
+
width: N(e, n + 7),
|
|
1063
|
+
height: r
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
if (i < 2) return null;
|
|
1067
|
+
n += 2 + i;
|
|
1068
|
+
}
|
|
1069
|
+
return null;
|
|
1070
|
+
}
|
|
1071
|
+
function Be(e) {
|
|
1072
|
+
let { width: t, height: n } = e;
|
|
1073
|
+
return !Number.isFinite(t) || !Number.isFinite(n) || t <= 0 || n <= 0 || t > 32767 || n > 32767 ? !0 : t * n > f;
|
|
1074
|
+
}
|
|
1075
|
+
//#endregion
|
|
1076
|
+
//#region packages/core/src/image/image-bitmap-lifecycle.ts
|
|
1077
|
+
function Ve(e) {
|
|
1078
|
+
let t = e.close;
|
|
1079
|
+
typeof t == "function" && t.call(e);
|
|
1080
|
+
}
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region packages/core/src/image/wmf.ts
|
|
1083
|
+
var F = {
|
|
1084
|
+
EOF: 0,
|
|
1085
|
+
SETBKMODE: 258,
|
|
1086
|
+
SETTEXTALIGN: 302,
|
|
1087
|
+
SETTEXTCOLOR: 521,
|
|
1088
|
+
SETPOLYFILLMODE: 262,
|
|
1089
|
+
SETWINDOWORG: 523,
|
|
1090
|
+
SETWINDOWEXT: 524,
|
|
1091
|
+
SELECTOBJECT: 301,
|
|
1092
|
+
DELETEOBJECT: 496,
|
|
1093
|
+
TEXTOUT: 1313,
|
|
1094
|
+
POLYGON: 804,
|
|
1095
|
+
POLYLINE: 805,
|
|
1096
|
+
POLYPOLYGON: 1336,
|
|
1097
|
+
RECTANGLE: 1051,
|
|
1098
|
+
CREATEPENINDIRECT: 762,
|
|
1099
|
+
CREATEFONTINDIRECT: 763,
|
|
1100
|
+
CREATEBRUSHINDIRECT: 764,
|
|
1101
|
+
DIBBITBLT: 2368,
|
|
1102
|
+
DIBSTRETCHBLT: 2881,
|
|
1103
|
+
STRETCHDIBITS: 3907
|
|
1104
|
+
}, He = 2596720087, Ue = 22, We = 18, Ge = 1179469088;
|
|
1105
|
+
function Ke(e, t) {
|
|
1106
|
+
if (e.length < t + We) return !1;
|
|
1107
|
+
let n = e[t] | e[t + 1] << 8, r = e[t + 2] | e[t + 3] << 8;
|
|
1108
|
+
return (n === 1 || n === 2) && r === 9;
|
|
1109
|
+
}
|
|
1110
|
+
function I(e) {
|
|
1111
|
+
return e.length < 4 ? !1 : (e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24) >>> 0 === He ? !0 : Ke(e, 0);
|
|
1112
|
+
}
|
|
1113
|
+
function L(e) {
|
|
1114
|
+
if (e.length < 44) return !1;
|
|
1115
|
+
let t = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1116
|
+
return t.getUint32(0, !0) === 1 && t.getUint32(40, !0) === Ge;
|
|
1117
|
+
}
|
|
1118
|
+
function qe(e) {
|
|
1119
|
+
return e === "image/wmf" || e === "image/emf";
|
|
1120
|
+
}
|
|
1121
|
+
function R(e) {
|
|
1122
|
+
let t = e & 255, n = e >>> 8 & 255, r = e >>> 16 & 255, i = (e) => e.toString(16).padStart(2, "0");
|
|
1123
|
+
return `#${i(t)}${i(n)}${i(r)}`;
|
|
1124
|
+
}
|
|
1125
|
+
function z(e, t) {
|
|
1126
|
+
for (let n = 0; n < e.length; n++) if (e[n] == null) {
|
|
1127
|
+
e[n] = t;
|
|
1128
|
+
return;
|
|
1129
|
+
}
|
|
1130
|
+
e.push(t);
|
|
1131
|
+
}
|
|
1132
|
+
var Je = class {
|
|
1133
|
+
p = 0;
|
|
1134
|
+
constructor(e, t, n) {
|
|
1135
|
+
this.b = e, this.end = n, this.p = t;
|
|
1136
|
+
}
|
|
1137
|
+
get remaining() {
|
|
1138
|
+
return this.end - this.p;
|
|
1139
|
+
}
|
|
1140
|
+
i16() {
|
|
1141
|
+
let e = this.u16();
|
|
1142
|
+
return e >= 32768 ? e - 65536 : e;
|
|
1143
|
+
}
|
|
1144
|
+
u16() {
|
|
1145
|
+
let e = this.b[this.p] | this.b[this.p + 1] << 8;
|
|
1146
|
+
return this.p += 2, e;
|
|
1147
|
+
}
|
|
1148
|
+
u8() {
|
|
1149
|
+
return this.b[this.p++];
|
|
1150
|
+
}
|
|
1151
|
+
u32() {
|
|
1152
|
+
let e = (this.b[this.p] | this.b[this.p + 1] << 8 | this.b[this.p + 2] << 16 | this.b[this.p + 3] << 24) >>> 0;
|
|
1153
|
+
return this.p += 4, e;
|
|
1154
|
+
}
|
|
1155
|
+
bytes(e) {
|
|
1156
|
+
let t = Math.min(this.p + Math.max(0, e), this.end), n = this.b.subarray(this.p, t);
|
|
1157
|
+
return this.p = t, n;
|
|
1158
|
+
}
|
|
1159
|
+
skip(e) {
|
|
1160
|
+
this.p = Math.min(this.p + Math.max(0, e), this.end);
|
|
1161
|
+
}
|
|
1162
|
+
};
|
|
1163
|
+
function B(e, t) {
|
|
1164
|
+
return (t - e.orgX) * (e.W / e.extX);
|
|
1165
|
+
}
|
|
1166
|
+
function V(e, t) {
|
|
1167
|
+
return (t - e.orgY) * (e.H / e.extY);
|
|
1168
|
+
}
|
|
1169
|
+
function Ye(e, t) {
|
|
1170
|
+
let n = t * Math.abs(e.W / e.extX);
|
|
1171
|
+
return n >= 1 ? n : 1;
|
|
1172
|
+
}
|
|
1173
|
+
var H = .001;
|
|
1174
|
+
function U(e, t, n) {
|
|
1175
|
+
return Math.abs(e - t) <= H || Math.abs(e - n) <= H;
|
|
1176
|
+
}
|
|
1177
|
+
function Xe(e, t, n) {
|
|
1178
|
+
let r = [], i = n ? t.length : t.length - 1;
|
|
1179
|
+
for (let n = 0; n < i; n++) {
|
|
1180
|
+
let i = t[n], a = t[(n + 1) % t.length], o = Math.abs(i[0] - a[0]) <= H && U(i[0], 0, e.W) && U(a[0], 0, e.W), s = Math.abs(i[1] - a[1]) <= H && U(i[1], 0, e.H) && U(a[1], 0, e.H);
|
|
1181
|
+
o || s || r.push([i, a]);
|
|
1182
|
+
}
|
|
1183
|
+
return r;
|
|
1184
|
+
}
|
|
1185
|
+
function Ze(e, t, n) {
|
|
1186
|
+
if (!e.curPen || e.curPen.stroke == null || t.length < 2) return;
|
|
1187
|
+
let { ctx: r } = e;
|
|
1188
|
+
if (r.strokeStyle = e.curPen.stroke, r.lineWidth = Ye(e, e.curPen.width), !e.suppressBoundaryFrame) {
|
|
1189
|
+
r.beginPath(), r.moveTo(t[0][0], t[0][1]);
|
|
1190
|
+
for (let e = 1; e < t.length; e++) r.lineTo(t[e][0], t[e][1]);
|
|
1191
|
+
n && r.closePath(), r.stroke(), e.drew = !0;
|
|
1192
|
+
return;
|
|
1193
|
+
}
|
|
1194
|
+
let i = Xe(e, t, n);
|
|
1195
|
+
if (i.length === 0) return;
|
|
1196
|
+
r.beginPath();
|
|
1197
|
+
let a = null;
|
|
1198
|
+
for (let [e, t] of i) (!a || a[0] !== e[0] || a[1] !== e[1]) && r.moveTo(e[0], e[1]), r.lineTo(t[0], t[1]), a = t;
|
|
1199
|
+
r.stroke(), e.drew = !0;
|
|
1200
|
+
}
|
|
1201
|
+
function W(e, t, n) {
|
|
1202
|
+
let r = [];
|
|
1203
|
+
for (let i = 0; i < n && !(t.remaining < 4); i++) {
|
|
1204
|
+
let n = t.i16(), i = t.i16();
|
|
1205
|
+
r.push([B(e, n), V(e, i)]);
|
|
1206
|
+
}
|
|
1207
|
+
return r;
|
|
1208
|
+
}
|
|
1209
|
+
function Qe(e, t) {
|
|
1210
|
+
t.length < 2 || !e.curPen || e.curPen.stroke == null || Ze(e, t, !1);
|
|
1211
|
+
}
|
|
1212
|
+
function $e(e, t) {
|
|
1213
|
+
if (t.length < 2) return;
|
|
1214
|
+
let { ctx: n } = e;
|
|
1215
|
+
if (e.curBrush && e.curBrush.fill != null) {
|
|
1216
|
+
n.beginPath(), n.moveTo(t[0][0], t[0][1]);
|
|
1217
|
+
for (let e = 1; e < t.length; e++) n.lineTo(t[e][0], t[e][1]);
|
|
1218
|
+
n.closePath(), n.fillStyle = e.curBrush.fill, n.fill(e.fillRule), e.drew = !0;
|
|
1219
|
+
}
|
|
1220
|
+
Ze(e, t, !0);
|
|
1221
|
+
}
|
|
1222
|
+
function et(e, t) {
|
|
1223
|
+
let n = t.u16();
|
|
1224
|
+
if (n <= 0 || n > 65536) return;
|
|
1225
|
+
let r = [];
|
|
1226
|
+
for (let e = 0; e < n; e++) {
|
|
1227
|
+
if (t.remaining < 2) return;
|
|
1228
|
+
r.push(t.u16());
|
|
1229
|
+
}
|
|
1230
|
+
let { ctx: i } = e;
|
|
1231
|
+
i.beginPath();
|
|
1232
|
+
let a = !1;
|
|
1233
|
+
for (let n of r) {
|
|
1234
|
+
if (n < 2) {
|
|
1235
|
+
for (let e = 0; e < n && t.remaining >= 4; e++) t.i16(), t.i16();
|
|
1236
|
+
continue;
|
|
1237
|
+
}
|
|
1238
|
+
let r = W(e, t, n);
|
|
1239
|
+
if (!(r.length < 2)) {
|
|
1240
|
+
i.moveTo(r[0][0], r[0][1]);
|
|
1241
|
+
for (let e = 1; e < r.length; e++) i.lineTo(r[e][0], r[e][1]);
|
|
1242
|
+
i.closePath(), a = !0;
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1245
|
+
a && (e.curBrush && e.curBrush.fill != null && (i.fillStyle = e.curBrush.fill, i.fill(e.fillRule), e.drew = !0), e.curPen && e.curPen.stroke != null && (i.strokeStyle = e.curPen.stroke, i.lineWidth = Ye(e, e.curPen.width), i.stroke(), e.drew = !0));
|
|
1246
|
+
}
|
|
1247
|
+
function tt(e) {
|
|
1248
|
+
let t = e.u16(), n = e.i16();
|
|
1249
|
+
e.i16();
|
|
1250
|
+
let r = e.u32();
|
|
1251
|
+
return {
|
|
1252
|
+
kind: "pen",
|
|
1253
|
+
stroke: (t & 255) == 5 ? null : R(r),
|
|
1254
|
+
width: Math.abs(n)
|
|
1255
|
+
};
|
|
1256
|
+
}
|
|
1257
|
+
function nt(e) {
|
|
1258
|
+
let t = e.u16(), n = e.u32();
|
|
1259
|
+
return e.u16(), {
|
|
1260
|
+
kind: "brush",
|
|
1261
|
+
fill: t === 1 ? null : R(n)
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function rt(e) {
|
|
1265
|
+
let t = e.indexOf(0), n = t >= 0 ? e.subarray(0, t) : e;
|
|
1266
|
+
if (n.length === 0) return "";
|
|
1267
|
+
try {
|
|
1268
|
+
return new TextDecoder("shift_jis").decode(n);
|
|
1269
|
+
} catch {
|
|
1270
|
+
return String.fromCharCode(...n);
|
|
1271
|
+
}
|
|
1272
|
+
}
|
|
1273
|
+
function it(e) {
|
|
1274
|
+
let t = Math.abs(e.i16());
|
|
1275
|
+
e.i16(), e.i16(), e.i16();
|
|
1276
|
+
let n = e.i16(), r = e.u8() !== 0;
|
|
1277
|
+
return e.u8(), e.u8(), e.u8(), e.u8(), e.u8(), e.u8(), e.u8(), {
|
|
1278
|
+
kind: "font",
|
|
1279
|
+
height: t,
|
|
1280
|
+
weight: n,
|
|
1281
|
+
italic: r,
|
|
1282
|
+
face: rt(e.bytes(Math.min(32, e.remaining)))
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
function at(e, t, n, r) {
|
|
1286
|
+
if (t.length === 0) return;
|
|
1287
|
+
let i = e.curFont, a = i?.height || 12, o = Math.abs(V(e, e.orgY + a) - V(e, e.orgY));
|
|
1288
|
+
if (!Number.isFinite(o) || o < 1) return;
|
|
1289
|
+
let { ctx: s } = e;
|
|
1290
|
+
try {
|
|
1291
|
+
s.fillStyle = e.textColor;
|
|
1292
|
+
let a = i && i.weight >= 700 ? "bold " : "";
|
|
1293
|
+
s.font = `${i?.italic ? "italic " : ""}${a}${o}px ${i?.face || "sans-serif"}`;
|
|
1294
|
+
let c = e.textAlign & 6;
|
|
1295
|
+
s.textAlign = c === 2 ? "right" : c === 6 ? "center" : "left", s.textBaseline = (e.textAlign & 24) == 24 ? "alphabetic" : "top", s.fillText(t, B(e, n), V(e, r)), e.drew = !0;
|
|
1296
|
+
} catch {}
|
|
1297
|
+
}
|
|
1298
|
+
function ot(e, t, n, r, i = !1) {
|
|
1299
|
+
if (!I(e)) return !1;
|
|
1300
|
+
let a = 0;
|
|
1301
|
+
(e.length >= 4 ? (e[0] | e[1] << 8 | e[2] << 16 | e[3] << 24) >>> 0 : 0) === He && (a = Ue);
|
|
1302
|
+
let o = a + We;
|
|
1303
|
+
if (o > e.length) return !1;
|
|
1304
|
+
let s = {
|
|
1305
|
+
ctx: t,
|
|
1306
|
+
W: n,
|
|
1307
|
+
H: r,
|
|
1308
|
+
orgX: 0,
|
|
1309
|
+
orgY: 0,
|
|
1310
|
+
extX: n || 1,
|
|
1311
|
+
extY: r || 1,
|
|
1312
|
+
haveExt: !1,
|
|
1313
|
+
objects: [],
|
|
1314
|
+
curPen: null,
|
|
1315
|
+
curBrush: null,
|
|
1316
|
+
curFont: null,
|
|
1317
|
+
textColor: "#000000",
|
|
1318
|
+
textAlign: 0,
|
|
1319
|
+
fillRule: "nonzero",
|
|
1320
|
+
drew: !1,
|
|
1321
|
+
suppressBoundaryFrame: i
|
|
1322
|
+
}, c = new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
1323
|
+
for (; o + 6 <= e.length;) {
|
|
1324
|
+
let t = c.getUint32(o, !0), n = c.getUint16(o + 4, !0);
|
|
1325
|
+
if (t < 3) break;
|
|
1326
|
+
let r = t * 2, i = o + r;
|
|
1327
|
+
if (i > e.length || n === F.EOF) break;
|
|
1328
|
+
let a = o + 6, l = new Je(e, a, i);
|
|
1329
|
+
switch (n) {
|
|
1330
|
+
case F.SETWINDOWORG:
|
|
1331
|
+
s.orgY = l.i16(), s.orgX = l.i16();
|
|
1332
|
+
break;
|
|
1333
|
+
case F.SETWINDOWEXT: {
|
|
1334
|
+
let e = l.i16(), t = l.i16();
|
|
1335
|
+
s.extY = e || 1, s.extX = t || 1, s.haveExt = !0;
|
|
1336
|
+
break;
|
|
1337
|
+
}
|
|
1338
|
+
case F.SETPOLYFILLMODE:
|
|
1339
|
+
s.fillRule = l.u16() === 1 ? "evenodd" : "nonzero";
|
|
1340
|
+
break;
|
|
1341
|
+
case F.SETTEXTCOLOR:
|
|
1342
|
+
s.textColor = R(l.u32());
|
|
1343
|
+
break;
|
|
1344
|
+
case F.SETTEXTALIGN:
|
|
1345
|
+
s.textAlign = l.u16();
|
|
1346
|
+
break;
|
|
1347
|
+
case F.CREATEPENINDIRECT:
|
|
1348
|
+
z(s.objects, tt(l));
|
|
1349
|
+
break;
|
|
1350
|
+
case F.CREATEBRUSHINDIRECT:
|
|
1351
|
+
z(s.objects, nt(l));
|
|
1352
|
+
break;
|
|
1353
|
+
case F.CREATEFONTINDIRECT:
|
|
1354
|
+
z(s.objects, it(l));
|
|
1355
|
+
break;
|
|
1356
|
+
case F.SELECTOBJECT: {
|
|
1357
|
+
let e = l.u16(), t = s.objects[e];
|
|
1358
|
+
t?.kind === "pen" ? s.curPen = t : t?.kind === "brush" ? s.curBrush = t : t?.kind === "font" && (s.curFont = t);
|
|
1359
|
+
break;
|
|
1360
|
+
}
|
|
1361
|
+
case F.DELETEOBJECT: {
|
|
1362
|
+
let e = l.u16(), t = s.objects[e];
|
|
1363
|
+
t && (t === s.curPen && (s.curPen = null), t === s.curBrush && (s.curBrush = null), t === s.curFont && (s.curFont = null), s.objects[e] = null);
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
case F.POLYLINE:
|
|
1367
|
+
Qe(s, W(s, l, l.i16()));
|
|
1368
|
+
break;
|
|
1369
|
+
case F.POLYGON:
|
|
1370
|
+
$e(s, W(s, l, l.i16()));
|
|
1371
|
+
break;
|
|
1372
|
+
case F.POLYPOLYGON:
|
|
1373
|
+
et(s, l);
|
|
1374
|
+
break;
|
|
1375
|
+
case F.RECTANGLE: {
|
|
1376
|
+
let e = l.i16(), t = l.i16(), n = l.i16(), r = l.i16();
|
|
1377
|
+
$e(s, [
|
|
1378
|
+
[B(s, r), V(s, n)],
|
|
1379
|
+
[B(s, t), V(s, n)],
|
|
1380
|
+
[B(s, t), V(s, e)],
|
|
1381
|
+
[B(s, r), V(s, e)]
|
|
1382
|
+
]);
|
|
1383
|
+
break;
|
|
1384
|
+
}
|
|
1385
|
+
case F.TEXTOUT: {
|
|
1386
|
+
let e = l.u16(), t = rt(l.bytes(e));
|
|
1387
|
+
e % 2 != 0 && l.skip(1);
|
|
1388
|
+
let n = l.i16();
|
|
1389
|
+
at(s, t, l.i16(), n);
|
|
1390
|
+
break;
|
|
1391
|
+
}
|
|
1392
|
+
case F.STRETCHDIBITS: {
|
|
1393
|
+
l.u32(), l.i16(), l.i16(), l.i16(), l.i16(), l.u16();
|
|
1394
|
+
let e = l.i16(), t = l.i16(), n = l.i16(), r = l.i16(), o = a + 22, u = te(c, o, i - o);
|
|
1395
|
+
if (u) {
|
|
1396
|
+
let i = B(s, r), a = V(s, n), o = B(s, r + t), c = V(s, n + e);
|
|
1397
|
+
ne(s.ctx, u, i, a, o, c) && (s.drew = !0);
|
|
1398
|
+
}
|
|
1399
|
+
break;
|
|
1400
|
+
}
|
|
1401
|
+
case F.DIBSTRETCHBLT:
|
|
1402
|
+
case F.DIBBITBLT:
|
|
1403
|
+
case F.SETBKMODE: break;
|
|
1404
|
+
default: break;
|
|
1405
|
+
}
|
|
1406
|
+
o = i;
|
|
1407
|
+
}
|
|
1408
|
+
return s.drew;
|
|
1409
|
+
}
|
|
1410
|
+
var st = 2e3, ct = 2;
|
|
1411
|
+
function lt(e, t) {
|
|
1412
|
+
let n = e > 0 ? e : 300, r = t > 0 ? t : 300, i = (e) => Math.max(1, Math.min(st, Math.round(e)));
|
|
1413
|
+
return {
|
|
1414
|
+
w: i(n * ct),
|
|
1415
|
+
h: i(r * ct)
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
async function ut(e, t, n, r = !1) {
|
|
1419
|
+
if (!I(e) || t <= 0 || n <= 0) return null;
|
|
1420
|
+
let i = u(t, n);
|
|
1421
|
+
if (!i) return null;
|
|
1422
|
+
let a = i.getContext("2d");
|
|
1423
|
+
return !a || (a.lineJoin = "round", a.lineCap = "round", !ot(e, a, t, n, r)) ? null : createImageBitmap(i);
|
|
1424
|
+
}
|
|
1425
|
+
async function dt(e, t = {}) {
|
|
1426
|
+
let { widthPt: n = 0, heightPt: r = 0, suppressBoundaryFrame: i = !1 } = t, a = new Uint8Array(await e.slice(0, 64 * 1024).arrayBuffer());
|
|
1427
|
+
if (I(a)) {
|
|
1428
|
+
let { w: t, h: a } = lt(n, r);
|
|
1429
|
+
return G(await ut(new Uint8Array(await e.arrayBuffer()), t, a, i));
|
|
1430
|
+
}
|
|
1431
|
+
if (L(a)) {
|
|
1432
|
+
let { w: t, h: i } = lt(n, r);
|
|
1433
|
+
return G(await Ne(new Uint8Array(await e.arrayBuffer()), t, i));
|
|
1434
|
+
}
|
|
1435
|
+
let o = Ie(a);
|
|
1436
|
+
if (o && Be(o)) throw new m("image-pixels", f, o.width * o.height);
|
|
1437
|
+
return G(await createImageBitmap(e));
|
|
1438
|
+
}
|
|
1439
|
+
function G(e) {
|
|
1440
|
+
if (!e) return null;
|
|
1441
|
+
let t = Number(e.width), n = Number(e.height);
|
|
1442
|
+
if (!Be({
|
|
1443
|
+
width: t,
|
|
1444
|
+
height: n
|
|
1445
|
+
})) return e;
|
|
1446
|
+
let r = t * n;
|
|
1447
|
+
throw Ve(e), new m("image-pixels", f, Number.isSafeInteger(r) && r >= 0 ? r : 2 ** 53 - 1);
|
|
1448
|
+
}
|
|
1449
|
+
//#endregion
|
|
1450
|
+
//#region packages/core/src/image/decode-gate.ts
|
|
1451
|
+
var K = /* @__PURE__ */ new WeakMap();
|
|
1452
|
+
async function ft(e, t) {
|
|
1453
|
+
let n = K.get(e);
|
|
1454
|
+
n || (n = {
|
|
1455
|
+
active: 0,
|
|
1456
|
+
waiters: []
|
|
1457
|
+
}, K.set(e, n)), n.active >= 2 || n.waiters.length > 0 ? await new Promise((e) => n.waiters.push(e)) : n.active++;
|
|
1458
|
+
try {
|
|
1459
|
+
return await Promise.resolve(), await t();
|
|
1460
|
+
} finally {
|
|
1461
|
+
let t = n.waiters.shift();
|
|
1462
|
+
t ? t() : (n.active--, n.active === 0 && K.delete(e));
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
//#endregion
|
|
1466
|
+
//#region packages/core/src/image/bitmap-image-by-path.ts
|
|
1467
|
+
var pt = 256, q = /* @__PURE__ */ new WeakMap();
|
|
1468
|
+
function mt(e) {
|
|
1469
|
+
let t = q.get(e);
|
|
1470
|
+
return t || (t = {
|
|
1471
|
+
entries: /* @__PURE__ */ new Map(),
|
|
1472
|
+
retainedBytes: 0
|
|
1473
|
+
}, q.set(e, t)), t;
|
|
1474
|
+
}
|
|
1475
|
+
var J = /* @__PURE__ */ new WeakMap(), ht = /* @__PURE__ */ new WeakSet();
|
|
1476
|
+
function Y(e) {
|
|
1477
|
+
!e || ht.has(e) || (ht.add(e), Ve(e));
|
|
1478
|
+
}
|
|
1479
|
+
function gt(e) {
|
|
1480
|
+
Y(e);
|
|
1481
|
+
}
|
|
1482
|
+
function _t(e) {
|
|
1483
|
+
let t = J.get(e);
|
|
1484
|
+
t || (t = {
|
|
1485
|
+
count: 0,
|
|
1486
|
+
deferred: [],
|
|
1487
|
+
activeBytes: 0,
|
|
1488
|
+
activeBitmaps: /* @__PURE__ */ new WeakSet()
|
|
1489
|
+
}, J.set(e, t));
|
|
1490
|
+
let n = t;
|
|
1491
|
+
n.count++;
|
|
1492
|
+
let r = !1;
|
|
1493
|
+
return () => {
|
|
1494
|
+
if (!r && (r = !0, n.count--, !(n.count > 0))) {
|
|
1495
|
+
for (let e of n.deferred) e.then((e) => Y(e)).catch(() => {});
|
|
1496
|
+
n.deferred = [], n.activeBytes = 0, n.activeBitmaps = /* @__PURE__ */ new WeakSet(), J.delete(e);
|
|
1497
|
+
}
|
|
1498
|
+
};
|
|
1499
|
+
}
|
|
1500
|
+
function vt(e) {
|
|
1501
|
+
if (!e) return 0;
|
|
1502
|
+
let t = Number(e.width), n = Number(e.height);
|
|
1503
|
+
return Number.isSafeInteger(t) && t > 0 && Number.isSafeInteger(n) && n > 0 ? t * n * 4 : 0;
|
|
1504
|
+
}
|
|
1505
|
+
function yt(e, t) {
|
|
1506
|
+
if (!t) return;
|
|
1507
|
+
let n = J.get(e);
|
|
1508
|
+
if (!n || n.count === 0 || n.activeBitmaps.has(t)) return;
|
|
1509
|
+
let r = n.activeBytes + vt(t);
|
|
1510
|
+
if (r > 134217728) throw new m("active-decoded-bytes", p, r);
|
|
1511
|
+
n.activeBitmaps.add(t), n.activeBytes = r;
|
|
1512
|
+
}
|
|
1513
|
+
function bt(e, t, n) {
|
|
1514
|
+
let r = [...t.entries].find(([e]) => e !== n);
|
|
1515
|
+
if (!r) return !1;
|
|
1516
|
+
let [i, a] = r;
|
|
1517
|
+
return t.entries.delete(i), t.retainedBytes -= a.weight, X(e, a.ownedPromise), !0;
|
|
1518
|
+
}
|
|
1519
|
+
function X(e, t) {
|
|
1520
|
+
let n = J.get(e);
|
|
1521
|
+
if (n && n.count > 0) {
|
|
1522
|
+
n.deferred.push(t);
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
t.then((e) => Y(e)).catch(() => {});
|
|
1526
|
+
}
|
|
1527
|
+
function xt(e, t, n) {
|
|
1528
|
+
let r = mt(t), i = r.entries, a = i.get(e);
|
|
1529
|
+
if (a) return i.delete(e), i.set(e, a), a.promise.then((e) => (yt(t, e), e));
|
|
1530
|
+
let o = ft(t, n), s = o.then(({ bitmap: e, owned: t }) => t ? e : null), c = o.then(({ bitmap: e, owned: n }) => {
|
|
1531
|
+
try {
|
|
1532
|
+
return yt(t, e), e;
|
|
1533
|
+
} catch (t) {
|
|
1534
|
+
throw n && Y(e), t;
|
|
1535
|
+
}
|
|
1536
|
+
}), l = {
|
|
1537
|
+
promise: c,
|
|
1538
|
+
ownedPromise: s,
|
|
1539
|
+
weight: 0
|
|
1540
|
+
};
|
|
1541
|
+
for (o.then(({ bitmap: n, owned: a }) => {
|
|
1542
|
+
if (i.get(e) === l) {
|
|
1543
|
+
if (l.bitmap = n, !a) {
|
|
1544
|
+
i.delete(e);
|
|
1545
|
+
return;
|
|
1546
|
+
}
|
|
1547
|
+
for (l.weight = vt(n), r.retainedBytes += l.weight; r.retainedBytes > p && bt(t, r, e););
|
|
1548
|
+
}
|
|
1549
|
+
}).catch(() => {}), c.catch(() => {
|
|
1550
|
+
i.get(e) === l && (i.delete(e), r.retainedBytes -= l.weight, X(t, s));
|
|
1551
|
+
}), i.set(e, l); i.size > pt && bt(t, r, e););
|
|
1552
|
+
return c;
|
|
1553
|
+
}
|
|
1554
|
+
var Z = "base", St = `${Z}:`, Ct = "derived:";
|
|
1555
|
+
function Q(e, t, n, r) {
|
|
1556
|
+
return xt(`${e}:${t}`, n, r);
|
|
1557
|
+
}
|
|
1558
|
+
function wt(e, t, n, r) {
|
|
1559
|
+
return Q(`${Ct}${e}`, t, n, r);
|
|
1560
|
+
}
|
|
1561
|
+
function Tt(e, t, n, r = {}) {
|
|
1562
|
+
let { widthPt: i = 0, heightPt: a = 0, suppressBoundaryFrame: o = !1 } = r;
|
|
1563
|
+
return Q(Z, e, n, async () => ({
|
|
1564
|
+
bitmap: await dt(await n(e, t), {
|
|
1565
|
+
widthPt: i,
|
|
1566
|
+
heightPt: a,
|
|
1567
|
+
suppressBoundaryFrame: o
|
|
1568
|
+
}),
|
|
1569
|
+
owned: !0
|
|
1570
|
+
}));
|
|
1571
|
+
}
|
|
1572
|
+
function Et(e, t) {
|
|
1573
|
+
return q.get(t)?.entries.get(`${St}${e}`)?.bitmap;
|
|
1574
|
+
}
|
|
1575
|
+
function Dt(e) {
|
|
1576
|
+
let t = q.get(e);
|
|
1577
|
+
if (t) {
|
|
1578
|
+
for (let n of t.entries.values()) X(e, n.ownedPromise);
|
|
1579
|
+
t.entries.clear(), t.retainedBytes = 0, q.delete(e);
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
//#endregion
|
|
1583
|
+
//#region packages/core/src/image/svg-image-by-path.ts
|
|
1584
|
+
var $ = /* @__PURE__ */ new WeakMap(), Ot = 256;
|
|
1585
|
+
function kt(e) {
|
|
1586
|
+
let t = $.get(e);
|
|
1587
|
+
return t || (t = { imgs: /* @__PURE__ */ new Map() }, $.set(e, t)), t;
|
|
1588
|
+
}
|
|
1589
|
+
function At(e, t) {
|
|
1590
|
+
if (typeof Image > "u") return Tt(e, "image/svg+xml", t).then((t) => {
|
|
1591
|
+
if (!t) throw Error(`svg decode failed: ${e}`);
|
|
1592
|
+
return t;
|
|
1593
|
+
});
|
|
1594
|
+
let n = kt(t), r = n.imgs.get(e);
|
|
1595
|
+
if (r) return n.imgs.delete(e), n.imgs.set(e, r), r.promise;
|
|
1596
|
+
let i = {};
|
|
1597
|
+
if (i.promise = ft(t, async () => {
|
|
1598
|
+
if (n.imgs.get(e) !== i) throw Error("SVG decode was superseded before it started");
|
|
1599
|
+
let r = await t(e, "image/svg+xml"), a = URL.createObjectURL(r);
|
|
1600
|
+
try {
|
|
1601
|
+
let t = new Image();
|
|
1602
|
+
return await new Promise((n, r) => {
|
|
1603
|
+
t.onload = () => {
|
|
1604
|
+
typeof t.decode == "function" ? t.decode().then(n).catch(n) : n();
|
|
1605
|
+
}, t.onerror = () => r(/* @__PURE__ */ Error(`svg load failed: ${e}`)), t.src = a;
|
|
1606
|
+
}), t;
|
|
1607
|
+
} finally {
|
|
1608
|
+
URL.revokeObjectURL(a);
|
|
1609
|
+
}
|
|
1610
|
+
}), i.promise.catch(() => {
|
|
1611
|
+
n.imgs.get(e) === i && n.imgs.delete(e);
|
|
1612
|
+
}), n.imgs.set(e, i), n.imgs.size > Ot) {
|
|
1613
|
+
let e = n.imgs.keys().next().value;
|
|
1614
|
+
n.imgs.delete(e);
|
|
1615
|
+
}
|
|
1616
|
+
return i.promise;
|
|
1617
|
+
}
|
|
1618
|
+
function jt(e) {
|
|
1619
|
+
let t = $.get(e);
|
|
1620
|
+
t && (t.imgs.clear(), $.delete(e));
|
|
1621
|
+
}
|
|
1622
|
+
//#endregion
|
|
1623
|
+
export { o as _, Tt as a, t as b, Et as c, qe as d, m as f, i as g, r as h, Dt as i, gt as l, u as m, At as n, Q as o, h as p, _t as r, wt as s, jt as t, dt as u, n as v, c as x, e as y };
|