@flyfish-dev/cad-viewer 0.6.2 → 0.6.4
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 +23 -7
- package/README.zh-CN.md +23 -7
- package/dist/cad-viewer.es.js +525 -411
- package/dist/cad-viewer.es.js.map +1 -1
- package/dist/cad-viewer.umd.cjs +8 -4
- package/dist/cad-viewer.umd.cjs.map +1 -1
- package/dist/types/core/types.d.ts +6 -0
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/loaders/dwg/DwgWorkerClient.d.ts.map +1 -1
- package/dist/types/loaders/dxf/DxfLoader.d.ts +1 -0
- package/dist/types/loaders/dxf/DxfLoader.d.ts.map +1 -1
- package/dist/wasm/dwg-worker.js +24 -0
- package/dist/wasm/dwg-worker.js.map +1 -0
- package/package.json +7 -4
- package/dist/assets/DwgWorker-CuZJ5EUe.js +0 -349
- package/dist/assets/DwgWorker-CuZJ5EUe.js.map +0 -1
- package/dist/assets/index-C365l3i9.js +0 -4161
- package/dist/assets/index-C365l3i9.js.map +0 -1
package/dist/cad-viewer.es.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (e, t, r) =>
|
|
4
|
-
import { openDwfDocument as
|
|
5
|
-
async function
|
|
1
|
+
var re = Object.defineProperty;
|
|
2
|
+
var ie = (e, t, r) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var d = (e, t, r) => ie(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { openDwfDocument as se, DwfViewer as ne } from "dwf-viewer";
|
|
5
|
+
async function U(e) {
|
|
6
6
|
if (e.buffer instanceof Uint8Array) return e.buffer;
|
|
7
7
|
if (e.buffer instanceof ArrayBuffer) return new Uint8Array(e.buffer);
|
|
8
8
|
if (e.file) return new Uint8Array(await e.file.arrayBuffer());
|
|
9
9
|
throw new Error("CadLoadInput requires a File, ArrayBuffer, or Uint8Array.");
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function oe(e) {
|
|
12
12
|
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
13
13
|
}
|
|
14
14
|
function L(e) {
|
|
@@ -16,7 +16,7 @@ function L(e) {
|
|
|
16
16
|
const t = e.fileName ?? ((i = e.file) == null ? void 0 : i.name) ?? "", r = t.lastIndexOf(".");
|
|
17
17
|
return r >= 0 ? t.slice(r + 1).toLowerCase() : "";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function B(e, t) {
|
|
20
20
|
const r = L(e);
|
|
21
21
|
if (r === "dwg") return "dwg";
|
|
22
22
|
if (r === "dxf") return "dxf";
|
|
@@ -24,19 +24,19 @@ function A(e, t) {
|
|
|
24
24
|
if (r === "xps") return "xps";
|
|
25
25
|
if (r === "dwf") return "dwf";
|
|
26
26
|
if (t && t.byteLength >= 6) {
|
|
27
|
-
const i =
|
|
27
|
+
const i = Ct(t.slice(0, 6));
|
|
28
28
|
if (/^AC10/.test(i)) return "dwg";
|
|
29
29
|
if (t[0] === 80 && t[1] === 75) return "dwfx";
|
|
30
|
-
const s =
|
|
30
|
+
const s = Ct(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
|
|
31
31
|
if (s.includes("SECTION") && s.includes("ENTITIES")) return "dxf";
|
|
32
32
|
if (s.includes("DWF")) return "dwf";
|
|
33
33
|
}
|
|
34
34
|
return "unknown";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Ct(e) {
|
|
37
37
|
return Array.from(e, (t) => t >= 32 && t <= 126 ? String.fromCharCode(t) : " ").join("");
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class ae {
|
|
40
40
|
constructor(t = []) {
|
|
41
41
|
d(this, "loaders", []);
|
|
42
42
|
for (const r of t) this.register(r);
|
|
@@ -53,7 +53,7 @@ class re {
|
|
|
53
53
|
return [...this.loaders];
|
|
54
54
|
}
|
|
55
55
|
async detect(t) {
|
|
56
|
-
const r = await
|
|
56
|
+
const r = await U(t), i = B(t, r), s = this.loaders.find((o) => o.formats.includes(i) && o.accepts(t, r));
|
|
57
57
|
if (s) return { loader: s, bytes: r, format: i };
|
|
58
58
|
const n = this.loaders.find((o) => o.accepts(t, r));
|
|
59
59
|
if (n) return { loader: n, bytes: r, format: i };
|
|
@@ -64,7 +64,8 @@ class re {
|
|
|
64
64
|
return i.load({ ...t, buffer: s }, r);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
|
|
67
|
+
const ce = "wasm/dwg-worker.js";
|
|
68
|
+
class he {
|
|
68
69
|
constructor() {
|
|
69
70
|
d(this, "worker");
|
|
70
71
|
d(this, "sequence", 0);
|
|
@@ -72,19 +73,19 @@ class ie {
|
|
|
72
73
|
}
|
|
73
74
|
load(t, r, i = {}) {
|
|
74
75
|
var h, l;
|
|
75
|
-
if (!
|
|
76
|
-
const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((h = r.file) == null ? void 0 : h.name), c =
|
|
76
|
+
if (!dt()) throw new Error("Web Worker is not available in this runtime.");
|
|
77
|
+
const s = this.ensureWorker(i), n = ++this.sequence, o = Math.max(0, Number(i.workerTimeoutMs ?? 0)), a = i.fileName ?? r.fileName ?? ((h = r.file) == null ? void 0 : h.name), c = fe(t, r, i);
|
|
77
78
|
return (l = i.onProgress) == null || l.call(i, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((f, u) => {
|
|
78
79
|
var g;
|
|
79
80
|
if ((g = i.signal) != null && g.aborted) {
|
|
80
|
-
u(
|
|
81
|
+
u(j());
|
|
81
82
|
return;
|
|
82
83
|
}
|
|
83
84
|
const p = { resolve: f, reject: u, onProgress: i.onProgress, signal: i.signal };
|
|
84
85
|
o > 0 && (p.timer = setTimeout(() => {
|
|
85
86
|
this.pending.delete(n), this.resetWorker(), u(new Error(`DWG worker timed out after ${o} ms.`));
|
|
86
87
|
}, o)), i.signal && (p.abortHandler = () => {
|
|
87
|
-
this.pending.delete(n), this.resetWorker(), u(
|
|
88
|
+
this.pending.delete(n), this.resetWorker(), u(j());
|
|
88
89
|
}, i.signal.addEventListener("abort", p.abortHandler, { once: !0 })), this.pending.set(n, p);
|
|
89
90
|
try {
|
|
90
91
|
s.postMessage({
|
|
@@ -92,21 +93,21 @@ class ie {
|
|
|
92
93
|
requestId: n,
|
|
93
94
|
bytes: c,
|
|
94
95
|
fileName: a,
|
|
95
|
-
options:
|
|
96
|
+
options: Pt(i)
|
|
96
97
|
}, [c]);
|
|
97
98
|
} catch (S) {
|
|
98
|
-
this.pending.delete(n),
|
|
99
|
+
this.pending.delete(n), $(p), u(S instanceof Error ? S : new Error(String(S)));
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
preload(t = {}) {
|
|
103
104
|
var n;
|
|
104
|
-
if (!
|
|
105
|
+
if (!dt()) return Promise.reject(new Error("Web Worker is not available in this runtime."));
|
|
105
106
|
const r = this.ensureWorker(t), i = ++this.sequence, s = Math.max(0, Number(t.workerTimeoutMs ?? 0));
|
|
106
107
|
return (n = t.onProgress) == null || n.call(t, { phase: "worker-start", format: "dwg", message: "Starting DWG worker warmup…" }), new Promise((o, a) => {
|
|
107
108
|
var h;
|
|
108
109
|
if ((h = t.signal) != null && h.aborted) {
|
|
109
|
-
a(
|
|
110
|
+
a(j());
|
|
110
111
|
return;
|
|
111
112
|
}
|
|
112
113
|
const c = {
|
|
@@ -118,12 +119,12 @@ class ie {
|
|
|
118
119
|
s > 0 && (c.timer = setTimeout(() => {
|
|
119
120
|
this.pending.delete(i), this.resetWorker(), a(new Error(`DWG worker warmup timed out after ${s} ms.`));
|
|
120
121
|
}, s)), t.signal && (c.abortHandler = () => {
|
|
121
|
-
this.pending.delete(i), this.resetWorker(), a(
|
|
122
|
+
this.pending.delete(i), this.resetWorker(), a(j());
|
|
122
123
|
}, t.signal.addEventListener("abort", c.abortHandler, { once: !0 })), this.pending.set(i, c);
|
|
123
124
|
try {
|
|
124
|
-
r.postMessage({ type: "warmup", requestId: i, options:
|
|
125
|
+
r.postMessage({ type: "warmup", requestId: i, options: Pt(t) });
|
|
125
126
|
} catch (l) {
|
|
126
|
-
this.pending.delete(i),
|
|
127
|
+
this.pending.delete(i), $(c), a(l instanceof Error ? l : new Error(String(l)));
|
|
127
128
|
}
|
|
128
129
|
});
|
|
129
130
|
}
|
|
@@ -131,7 +132,7 @@ class ie {
|
|
|
131
132
|
this.resetWorker();
|
|
132
133
|
}
|
|
133
134
|
ensureWorker(t) {
|
|
134
|
-
return this.worker || (this.worker =
|
|
135
|
+
return this.worker || (this.worker = le(t), this.worker.onmessage = (r) => this.handleMessage(r.data), this.worker.onerror = (r) => {
|
|
135
136
|
const i = r.message || "DWG worker failed.";
|
|
136
137
|
this.rejectAll(new Error(i)), this.resetWorker(!1);
|
|
137
138
|
}, this.worker.onmessageerror = () => {
|
|
@@ -147,7 +148,7 @@ class ie {
|
|
|
147
148
|
(s = r.onProgress) == null || s.call(r, t.progress);
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
|
-
if (this.pending.delete(t.requestId),
|
|
151
|
+
if (this.pending.delete(t.requestId), $(r), t.type === "result") {
|
|
151
152
|
r.resolve(t.result);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
@@ -160,7 +161,7 @@ class ie {
|
|
|
160
161
|
}
|
|
161
162
|
rejectAll(t) {
|
|
162
163
|
for (const [, r] of this.pending)
|
|
163
|
-
|
|
164
|
+
$(r), r.reject(t);
|
|
164
165
|
this.pending.clear();
|
|
165
166
|
}
|
|
166
167
|
resetWorker(t = !0) {
|
|
@@ -168,77 +169,78 @@ class ie {
|
|
|
168
169
|
t && this.rejectAll(new Error("DWG worker was terminated.")), (r = this.worker) == null || r.terminate(), this.worker = void 0;
|
|
169
170
|
}
|
|
170
171
|
}
|
|
171
|
-
function
|
|
172
|
+
function dt() {
|
|
172
173
|
return typeof Worker < "u" && typeof URL < "u";
|
|
173
174
|
}
|
|
174
|
-
function
|
|
175
|
-
return e.workerFactory ? e.workerFactory() :
|
|
176
|
-
/* @vite-ignore */
|
|
177
|
-
"/assets/DwgWorker-CuZJ5EUe.js",
|
|
178
|
-
import.meta.url
|
|
179
|
-
), { type: "module", name: "lightweight-cad-dwg-loader" });
|
|
175
|
+
function le(e) {
|
|
176
|
+
return e.workerFactory ? e.workerFactory() : new Worker(ue(e.workerUrl), { type: "module", name: "lightweight-cad-dwg-loader" });
|
|
180
177
|
}
|
|
181
|
-
function
|
|
178
|
+
function Pt(e) {
|
|
182
179
|
return {
|
|
183
180
|
// Resolve the asset directory on the UI thread. Relative paths such as
|
|
184
181
|
// './wasm' must be relative to the document URL, not to the generated
|
|
185
182
|
// worker chunk URL. Otherwise the worker may request /assets/wasm/... and
|
|
186
183
|
// receive the app's HTML fallback instead of libredwg-web.wasm.
|
|
187
|
-
wasmPath:
|
|
184
|
+
wasmPath: de(e.wasmPath),
|
|
188
185
|
includePaperSpace: e.includePaperSpace,
|
|
189
186
|
maxInsertDepth: e.maxInsertDepth,
|
|
190
187
|
keepRaw: !!e.keepRaw
|
|
191
188
|
};
|
|
192
189
|
}
|
|
193
|
-
function
|
|
194
|
-
return !!t.file || r.transferInputBuffer === !0 ?
|
|
190
|
+
function fe(e, t, r) {
|
|
191
|
+
return !!t.file || r.transferInputBuffer === !0 ? oe(e) : e.slice().buffer;
|
|
195
192
|
}
|
|
196
|
-
function
|
|
193
|
+
function $(e) {
|
|
197
194
|
e.timer && clearTimeout(e.timer), e.signal && e.abortHandler && e.signal.removeEventListener("abort", e.abortHandler);
|
|
198
195
|
}
|
|
199
|
-
function
|
|
196
|
+
function j() {
|
|
200
197
|
if (typeof DOMException < "u") return new DOMException("DWG loading was aborted.", "AbortError");
|
|
201
198
|
const e = new Error("DWG loading was aborted.");
|
|
202
199
|
return e.name = "AbortError", e;
|
|
203
200
|
}
|
|
204
|
-
function
|
|
201
|
+
function de(e) {
|
|
205
202
|
const t = ((e == null ? void 0 : e.trim()) || "/wasm").replace(/\/+$/, "");
|
|
206
|
-
return t === "" ?
|
|
203
|
+
return t === "" ? kt() : Xt(t) ? t : t.startsWith("/") ? `${kt()}${t}` : new URL(t, vt()).href.replace(/\/+$/, "");
|
|
204
|
+
}
|
|
205
|
+
function ue(e) {
|
|
206
|
+
if (e instanceof URL) return e;
|
|
207
|
+
const t = (e == null ? void 0 : e.trim()) || ce;
|
|
208
|
+
return Xt(t) ? t : new URL(t, vt()).href;
|
|
207
209
|
}
|
|
208
|
-
function
|
|
210
|
+
function vt() {
|
|
209
211
|
return typeof document < "u" && document.baseURI ? document.baseURI : typeof location < "u" && location.href ? location.href : "http://localhost/";
|
|
210
212
|
}
|
|
211
|
-
function
|
|
212
|
-
return typeof location < "u" && location.origin ? location.origin : new URL(
|
|
213
|
+
function kt() {
|
|
214
|
+
return typeof location < "u" && location.origin ? location.origin : new URL(vt()).origin;
|
|
213
215
|
}
|
|
214
|
-
function
|
|
216
|
+
function Xt(e) {
|
|
215
217
|
return /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
216
218
|
}
|
|
217
|
-
class
|
|
219
|
+
class me {
|
|
218
220
|
constructor(t = {}) {
|
|
219
221
|
d(this, "id", "dwg");
|
|
220
222
|
d(this, "label", "DWG / LibreDWG WebAssembly");
|
|
221
223
|
d(this, "formats", ["dwg"]);
|
|
222
224
|
d(this, "defaults");
|
|
223
|
-
d(this, "workerClient", new
|
|
225
|
+
d(this, "workerClient", new he());
|
|
224
226
|
this.defaults = { useWorker: !0, ...t };
|
|
225
227
|
}
|
|
226
228
|
accepts(t, r) {
|
|
227
|
-
return L(t) === "dwg" ? !0 :
|
|
229
|
+
return L(t) === "dwg" ? !0 : B(t, r) === "dwg";
|
|
228
230
|
}
|
|
229
231
|
async load(t, r = {}) {
|
|
230
232
|
var o, a;
|
|
231
233
|
const i = { ...this.defaults, ...r };
|
|
232
234
|
(o = i.onProgress) == null || o.call(i, { phase: "read", format: "dwg", message: "Reading DWG bytes…" });
|
|
233
|
-
const s = await
|
|
235
|
+
const s = await U(t), n = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
|
|
234
236
|
if (i.useWorker === !1)
|
|
235
237
|
throw new Error("DWG main-thread parsing is intentionally not bundled by the default viewer. Keep useWorker enabled, or register a custom DWG loader for non-browser runtimes.");
|
|
236
|
-
if (!
|
|
238
|
+
if (!dt())
|
|
237
239
|
throw new Error("DWG loading requires Web Worker support in this build. Provide a custom loader for this runtime.");
|
|
238
240
|
try {
|
|
239
241
|
return await this.workerClient.load(s, t, { ...i, fileName: n });
|
|
240
242
|
} catch (c) {
|
|
241
|
-
throw
|
|
243
|
+
throw pe(c) ? c : ge(c);
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
246
|
terminateWorker() {
|
|
@@ -249,14 +251,14 @@ class ce {
|
|
|
249
251
|
return r.useWorker === !1 ? Promise.reject(new Error("DWG preload requires worker mode in the default viewer.")) : this.workerClient.preload(r);
|
|
250
252
|
}
|
|
251
253
|
}
|
|
252
|
-
function
|
|
254
|
+
function pe(e) {
|
|
253
255
|
return e instanceof Error && e.name === "AbortError";
|
|
254
256
|
}
|
|
255
|
-
function
|
|
257
|
+
function ge(e) {
|
|
256
258
|
const t = e instanceof Error ? e.message : String(e);
|
|
257
259
|
return new Error(`${t} If the worker asset cannot be resolved by your bundler/CDN, pass workerUrl or workerFactory to CadViewer.`);
|
|
258
260
|
}
|
|
259
|
-
function
|
|
261
|
+
function Ut(e) {
|
|
260
262
|
return {
|
|
261
263
|
format: e.format,
|
|
262
264
|
sourceName: e.sourceName,
|
|
@@ -322,18 +324,18 @@ function R(e) {
|
|
|
322
324
|
return "unsupported";
|
|
323
325
|
}
|
|
324
326
|
}
|
|
325
|
-
function
|
|
327
|
+
function be(e, t, r = {}) {
|
|
326
328
|
const i = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), s = r.includeUnknownProperties === !1 ? { type: i, kind: R(i) } : { ...e, type: i, kind: R(i) };
|
|
327
329
|
r.keepRaw && (s.raw = e), s.handle = C(e.handle ?? e.id), s.layer = C(e.layer ?? e.layerName), s.lineType = C(e.lineType ?? e.linetype);
|
|
328
330
|
const n = r.numericColorMode ?? "auto", o = y(e.color), a = y(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
|
|
329
331
|
s.colorIndex = a ?? (n !== "rgb" && o !== void 0 && Math.abs(o) <= 257 ? o : void 0);
|
|
330
332
|
const c = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, h = o !== void 0 && o >= 0 && o <= 16777215 && (n === "rgb" || n === "auto" && Math.abs(o) > 257);
|
|
331
333
|
s.trueColor = c ?? (h ? o : void 0), (typeof e.color == "string" || typeof e.color == "number") && (s.color = e.color), s.colorNumber = y(e.colorNumber) ?? s.colorNumber, s.colorName = C(e.colorName ?? e.color_name) ?? s.colorName, s.fillColor = e.fillColor ?? e.fill_color, s.fillColorIndex = y(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? s.fillColorIndex, s.opacity = y(e.opacity ?? e.alpha) ?? s.opacity, s.lineweight = y(e.lineweight ?? e.lineWeight), s.isVisible = !(e.isVisible === !1 || e.visible === !1), s.startPoint = P(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? s.startPoint, s.endPoint = P(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? s.endPoint, s.center = P(e.center ?? e.centerPoint) ?? s.center, s.insertionPoint = P(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? s.insertionPoint, s.radius = y(e.radius) ?? s.radius, s.startAngle = y(e.startAngle ?? e.start_angle) ?? s.startAngle, s.endAngle = y(e.endAngle ?? e.end_angle) ?? s.endAngle, s.majorAxisEndPoint = P(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? s.majorAxisEndPoint, s.axisRatio = y(e.axisRatio ?? e.ratio) ?? s.axisRatio, s.height = y(e.height ?? e.textHeight) ?? s.height, s.textHeight = y(e.textHeight ?? e.height) ?? s.textHeight, s.rotation = y(e.rotation ?? e.angle) ?? s.rotation, s.text = C(e.text ?? e.value ?? e.string ?? e.contents) ?? s.text, s.name = C(e.name ?? e.blockName) ?? s.name, s.blockName = C(e.blockName ?? e.name) ?? s.blockName;
|
|
332
|
-
const l =
|
|
334
|
+
const l = rt(e.vertices ?? e.points);
|
|
333
335
|
l.length > 0 && (s.vertices = l);
|
|
334
|
-
const f =
|
|
336
|
+
const f = rt(e.controlPoints ?? e.control_points);
|
|
335
337
|
f.length > 0 && (s.controlPoints = f);
|
|
336
|
-
const u =
|
|
338
|
+
const u = rt(e.fitPoints ?? e.fit_points);
|
|
337
339
|
return u.length > 0 && (s.fitPoints = u), s;
|
|
338
340
|
}
|
|
339
341
|
function P(e) {
|
|
@@ -342,7 +344,7 @@ function P(e) {
|
|
|
342
344
|
if (!(!Number.isFinite(r) || !Number.isFinite(i)))
|
|
343
345
|
return Number.isFinite(n) ? { x: r, y: i, z: n } : { x: r, y: i };
|
|
344
346
|
}
|
|
345
|
-
function
|
|
347
|
+
function rt(e) {
|
|
346
348
|
if (!Array.isArray(e)) return [];
|
|
347
349
|
const t = [];
|
|
348
350
|
for (const r of e) {
|
|
@@ -357,7 +359,7 @@ function et(e) {
|
|
|
357
359
|
}
|
|
358
360
|
return t;
|
|
359
361
|
}
|
|
360
|
-
function
|
|
362
|
+
function G(e) {
|
|
361
363
|
var r;
|
|
362
364
|
const t = {};
|
|
363
365
|
for (const i of e.entities) {
|
|
@@ -375,13 +377,13 @@ function j(e) {
|
|
|
375
377
|
warnings: [...e.warnings]
|
|
376
378
|
};
|
|
377
379
|
}
|
|
378
|
-
function
|
|
380
|
+
function St(e, t) {
|
|
379
381
|
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
380
382
|
}
|
|
381
|
-
function
|
|
383
|
+
function ve(e, t) {
|
|
382
384
|
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
383
385
|
}
|
|
384
|
-
function
|
|
386
|
+
function ye(e) {
|
|
385
387
|
return e != null && e.length ? e.flatMap((t) => t.entities.map((r) => ({ ...r, pageIndex: t.index }))) : [];
|
|
386
388
|
}
|
|
387
389
|
function y(e) {
|
|
@@ -393,22 +395,22 @@ function C(e) {
|
|
|
393
395
|
const t = String(e);
|
|
394
396
|
return t.length > 0 ? t : void 0;
|
|
395
397
|
}
|
|
396
|
-
function
|
|
398
|
+
function N() {
|
|
397
399
|
return { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
398
400
|
}
|
|
399
|
-
function
|
|
401
|
+
function O(e) {
|
|
400
402
|
return Number.isFinite(e.minX) && Number.isFinite(e.minY) && Number.isFinite(e.maxX) && Number.isFinite(e.maxY) && e.maxX >= e.minX && e.maxY >= e.minY;
|
|
401
403
|
}
|
|
402
404
|
function v(e, t) {
|
|
403
405
|
m(t) && (e.minX = Math.min(e.minX, t.x), e.minY = Math.min(e.minY, t.y), e.maxX = Math.max(e.maxX, t.x), e.maxY = Math.max(e.maxY, t.y));
|
|
404
406
|
}
|
|
405
|
-
function
|
|
407
|
+
function Vt(e, t, r) {
|
|
406
408
|
if (!m(t) || !Number.isFinite(r)) return;
|
|
407
409
|
const i = Math.abs(r);
|
|
408
410
|
v(e, { x: t.x - i, y: t.y - i }), v(e, { x: t.x + i, y: t.y + i });
|
|
409
411
|
}
|
|
410
|
-
function
|
|
411
|
-
if (!
|
|
412
|
+
function $t(e, t = 0.02, r = 1e-6) {
|
|
413
|
+
if (!O(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
|
|
412
414
|
const i = Math.max((e.maxX - e.minX) * t, r), s = Math.max((e.maxY - e.minY) * t, r);
|
|
413
415
|
return { minX: e.minX - i, minY: e.minY - s, maxX: e.maxX + i, maxY: e.maxY + s };
|
|
414
416
|
}
|
|
@@ -418,14 +420,14 @@ function m(e) {
|
|
|
418
420
|
function x(e) {
|
|
419
421
|
return { x: e.x, y: e.y };
|
|
420
422
|
}
|
|
421
|
-
function
|
|
423
|
+
function I(e) {
|
|
422
424
|
return e * Math.PI / 180;
|
|
423
425
|
}
|
|
424
|
-
function
|
|
426
|
+
function K(e, t, r, i, s = !0, n = 64) {
|
|
425
427
|
if (!m(e) || !Number.isFinite(t)) return [];
|
|
426
428
|
let o = r, a = i;
|
|
427
429
|
if (!Number.isFinite(o) || !Number.isFinite(a)) return [];
|
|
428
|
-
(Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o =
|
|
430
|
+
(Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = I(o), a = I(a)), s && a < o && (a += Math.PI * 2), !s && o < a && (o += Math.PI * 2);
|
|
429
431
|
const c = a - o, h = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * n))), l = [];
|
|
430
432
|
for (let f = 0; f <= h; f++) {
|
|
431
433
|
const u = o + c * (f / h);
|
|
@@ -433,35 +435,35 @@ function q(e, t, r, i, s = !0, n = 64) {
|
|
|
433
435
|
}
|
|
434
436
|
return l;
|
|
435
437
|
}
|
|
436
|
-
function
|
|
438
|
+
function J(e, t, r = 1, i = 0, s = Math.PI * 2, n = 96) {
|
|
437
439
|
if (!m(e) || !m(t)) return [];
|
|
438
440
|
const o = Math.hypot(t.x, t.y);
|
|
439
441
|
if (!Number.isFinite(o) || o <= 0) return [];
|
|
440
442
|
const a = o * (Number.isFinite(r) && r > 0 ? r : 1), c = Math.atan2(t.y, t.x);
|
|
441
443
|
let h = Number.isFinite(i) ? i : 0, l = Number.isFinite(s) ? s : Math.PI * 2;
|
|
442
|
-
(Math.abs(h) > Math.PI * 2 + 1e-6 || Math.abs(l) > Math.PI * 2 + 1e-6) && (h =
|
|
444
|
+
(Math.abs(h) > Math.PI * 2 + 1e-6 || Math.abs(l) > Math.PI * 2 + 1e-6) && (h = I(h), l = I(l)), l < h && (l += Math.PI * 2);
|
|
443
445
|
const f = Math.max(12, Math.min(256, Math.ceil(Math.abs(l - h) / (Math.PI * 2) * n))), u = [], p = Math.cos(c), g = Math.sin(c);
|
|
444
446
|
for (let S = 0; S <= f; S++) {
|
|
445
|
-
const
|
|
446
|
-
u.push({ x: e.x +
|
|
447
|
+
const z = h + (l - h) * (S / f), _ = Math.cos(z) * o, H = Math.sin(z) * a;
|
|
448
|
+
u.push({ x: e.x + _ * p - H * g, y: e.y + _ * g + H * p });
|
|
447
449
|
}
|
|
448
450
|
return u;
|
|
449
451
|
}
|
|
450
|
-
function
|
|
452
|
+
function jt(e, t, r = 0, i = 16) {
|
|
451
453
|
if (!Number.isFinite(r) || Math.abs(r) < 1e-12) return [x(e), x(t)];
|
|
452
454
|
const s = Math.hypot(t.x - e.x, t.y - e.y);
|
|
453
455
|
if (s <= 1e-12) return [x(e), x(t)];
|
|
454
456
|
const n = 4 * Math.atan(r), o = Math.abs(s / (2 * Math.sin(n / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / s, h = (t.y - e.y) / s, l = r >= 0 ? 1 : -1, f = Math.sqrt(Math.max(o * o - (s / 2) ** 2, 0)), u = { x: a.x - l * h * f, y: a.y + l * c * f }, p = Math.atan2(e.y - u.y, e.x - u.x), g = Math.atan2(t.y - u.y, t.x - u.x);
|
|
455
|
-
return
|
|
457
|
+
return K(u, o, p, g, r >= 0, i);
|
|
456
458
|
}
|
|
457
|
-
function
|
|
459
|
+
function Gt(e) {
|
|
458
460
|
return e.replace(/\\P/g, `
|
|
459
461
|
`).replace(/\\~|\\ /g, " ").replace(/\\[A-Za-z][^;]*;/g, "").replace(/[{}]/g, "").replace(/\\[A-Za-z]/g, "").trim();
|
|
460
462
|
}
|
|
461
|
-
function
|
|
463
|
+
function A(e, t, r) {
|
|
462
464
|
return Math.min(r, Math.max(t, e));
|
|
463
465
|
}
|
|
464
|
-
class
|
|
466
|
+
class xe {
|
|
465
467
|
constructor(t = {}) {
|
|
466
468
|
d(this, "id", "dxf");
|
|
467
469
|
d(this, "label", "DXF / JavaScript parser");
|
|
@@ -470,29 +472,28 @@ class me {
|
|
|
470
472
|
this.defaults = t;
|
|
471
473
|
}
|
|
472
474
|
accepts(t, r) {
|
|
473
|
-
return L(t) === "dxf" ||
|
|
475
|
+
return L(t) === "dxf" || B(t, r) === "dxf";
|
|
474
476
|
}
|
|
475
477
|
async load(t, r = {}) {
|
|
476
|
-
var
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
let a;
|
|
478
|
+
var f;
|
|
479
|
+
const i = { ...this.defaults, ...r }, s = performance.now(), n = await U(t), o = Ee(n, i.dxfEncoding), a = [];
|
|
480
|
+
let c;
|
|
480
481
|
try {
|
|
481
|
-
|
|
482
|
-
} catch (
|
|
483
|
-
|
|
482
|
+
c = await we(o);
|
|
483
|
+
} catch (u) {
|
|
484
|
+
a.push(`dxf-parser failed, using built-in fallback parser: ${u instanceof Error ? u.message : String(u)}`), c = Fe(o);
|
|
484
485
|
}
|
|
485
|
-
const
|
|
486
|
-
return { document:
|
|
486
|
+
const h = Ce(c, t.fileName ?? ((f = t.file) == null ? void 0 : f.name), a), l = performance.now() - s;
|
|
487
|
+
return { document: h, raw: c, bytes: n.byteLength, elapsedMs: l, format: "dxf", warnings: h.warnings };
|
|
487
488
|
}
|
|
488
489
|
}
|
|
489
|
-
async function
|
|
490
|
+
async function we(e) {
|
|
490
491
|
const t = await import("dxf-parser"), r = t.default ?? t.DxfParser;
|
|
491
492
|
if (!r) throw new Error("dxf-parser did not expose a parser constructor.");
|
|
492
493
|
return new r().parseSync(e);
|
|
493
494
|
}
|
|
494
|
-
function
|
|
495
|
-
const i = e && typeof e == "object" ? e : {}, s =
|
|
495
|
+
function Ce(e, t, r = []) {
|
|
496
|
+
const i = e && typeof e == "object" ? e : {}, s = Pe(i), n = ke(i), a = (Array.isArray(i.entities) ? i.entities : []).filter((h) => !!h && typeof h == "object").map((h) => yt(h)), c = Ut({
|
|
496
497
|
format: "dxf",
|
|
497
498
|
sourceName: t,
|
|
498
499
|
header: i.header && typeof i.header == "object" ? i.header : {},
|
|
@@ -505,26 +506,26 @@ function ge(e, t, r = []) {
|
|
|
505
506
|
});
|
|
506
507
|
return a.length === 0 && c.warnings.push("DXF file did not expose any ENTITIES."), c;
|
|
507
508
|
}
|
|
508
|
-
function
|
|
509
|
-
const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r =
|
|
510
|
-
if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = C(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = P(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = P(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = P(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text =
|
|
509
|
+
function yt(e) {
|
|
510
|
+
const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), r = be(e, t), i = y(e.colorIndex ?? e.colorNumber ?? e.aci), s = y(e.color);
|
|
511
|
+
if (r.colorIndex = i ?? (s !== void 0 && Math.abs(s) <= 257 ? s : void 0), r.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (s !== void 0 && Math.abs(s) > 257 ? s : void 0), r.layer = C(e.layer ?? e.layerName) ?? "0", r.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (r.startPoint = P(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? r.startPoint, r.endPoint = P(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? r.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (r.insertionPoint = P(e.startPoint ?? e.position ?? e.insertionPoint) ?? r.insertionPoint, r.text = Be(e.text ?? e.string ?? e.value) ?? r.text, r.textHeight = y(e.textHeight ?? e.height) ?? r.textHeight, r.rotation = Mt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (r.startAngle = Et(e.startAngle ?? e.start_angle), r.endAngle = Et(e.endAngle ?? e.end_angle)), t === "INSERT") {
|
|
511
512
|
r.blockName = C(e.name ?? e.blockName) ?? r.blockName, r.insertionPoint = P(e.position ?? e.insertionPoint ?? e.point) ?? r.insertionPoint;
|
|
512
513
|
const n = y(e.xScale ?? e.scaleX ?? e.xscale), o = y(e.yScale ?? e.scaleY ?? e.yscale), a = y(e.zScale ?? e.scaleZ ?? e.zscale);
|
|
513
|
-
(n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation =
|
|
514
|
+
(n !== void 0 || o !== void 0 || a !== void 0) && (r.scale = { x: n ?? 1, y: o ?? n ?? 1, z: a ?? 1 }), r.rotation = Mt(e.rotation ?? e.angle);
|
|
514
515
|
}
|
|
515
516
|
if (t === "SPLINE") {
|
|
516
|
-
const n =
|
|
517
|
+
const n = Q(e.controlPoints ?? e.control_points ?? e.points);
|
|
517
518
|
n.length && (r.controlPoints = n);
|
|
518
|
-
const o =
|
|
519
|
+
const o = Q(e.fitPoints ?? e.fit_points);
|
|
519
520
|
o.length && (r.fitPoints = o);
|
|
520
521
|
}
|
|
521
|
-
return t === "HATCH" && (r.loops =
|
|
522
|
+
return t === "HATCH" && (r.loops = Me(e), r.fillColorIndex = r.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (r.vertices = Ne(e), r.fillColorIndex = r.colorIndex), r;
|
|
522
523
|
}
|
|
523
|
-
function
|
|
524
|
-
const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s =
|
|
524
|
+
function Pe(e) {
|
|
525
|
+
const t = {}, r = e.tables, i = e.layers ?? (r == null ? void 0 : r.layer) ?? (r == null ? void 0 : r.LAYER) ?? (r == null ? void 0 : r.layers), s = Se(i);
|
|
525
526
|
for (const n of s) {
|
|
526
527
|
const o = n, a = C(o.name ?? o.layerName);
|
|
527
|
-
a &&
|
|
528
|
+
a && St(t, {
|
|
528
529
|
name: a,
|
|
529
530
|
color: o.color ?? o.colorNumber ?? o.colorIndex,
|
|
530
531
|
colorIndex: y(o.colorNumber ?? o.colorIndex ?? o.color),
|
|
@@ -535,36 +536,36 @@ function be(e) {
|
|
|
535
536
|
raw: o
|
|
536
537
|
});
|
|
537
538
|
}
|
|
538
|
-
return t[0] ||
|
|
539
|
+
return t[0] || St(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
|
|
539
540
|
}
|
|
540
|
-
function
|
|
541
|
+
function ke(e) {
|
|
541
542
|
const t = {}, r = e.blocks;
|
|
542
543
|
if (!r || typeof r != "object") return t;
|
|
543
544
|
if (Array.isArray(r))
|
|
544
|
-
for (const i of r)
|
|
545
|
+
for (const i of r) Nt(t, i);
|
|
545
546
|
else
|
|
546
|
-
for (const [i, s] of Object.entries(r))
|
|
547
|
+
for (const [i, s] of Object.entries(r)) Nt(t, s, i);
|
|
547
548
|
return t;
|
|
548
549
|
}
|
|
549
|
-
function
|
|
550
|
+
function Nt(e, t, r) {
|
|
550
551
|
if (!t || typeof t != "object") return;
|
|
551
552
|
const i = t, s = C(i.name ?? i.blockName ?? r);
|
|
552
553
|
if (!s) return;
|
|
553
|
-
const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) =>
|
|
554
|
-
|
|
554
|
+
const o = (Array.isArray(i.entities) ? i.entities : []).filter((a) => !!a && typeof a == "object").map((a) => yt(a));
|
|
555
|
+
ve(e, { name: s, basePoint: P(i.basePoint ?? i.position) ?? { x: 0, y: 0 }, entities: o, raw: i });
|
|
555
556
|
}
|
|
556
|
-
function
|
|
557
|
+
function Se(e) {
|
|
557
558
|
if (!e) return [];
|
|
558
559
|
if (Array.isArray(e)) return e;
|
|
559
560
|
if (typeof e != "object") return [];
|
|
560
561
|
const t = e;
|
|
561
562
|
return Array.isArray(t.entries) ? t.entries : Array.isArray(t.records) ? t.records : Array.isArray(t.layers) ? t.layers : Object.values(t).filter((r) => r && typeof r == "object");
|
|
562
563
|
}
|
|
563
|
-
function
|
|
564
|
+
function Q(e) {
|
|
564
565
|
return Array.isArray(e) ? e.map(P).filter((t) => !!t) : [];
|
|
565
566
|
}
|
|
566
|
-
function
|
|
567
|
-
const t =
|
|
567
|
+
function Ne(e) {
|
|
568
|
+
const t = Q(e.vertices ?? e.points);
|
|
568
569
|
if (t.length) return t;
|
|
569
570
|
const r = [];
|
|
570
571
|
for (let i = 0; i < 4; i++) {
|
|
@@ -573,29 +574,142 @@ function xe(e) {
|
|
|
573
574
|
}
|
|
574
575
|
return r;
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
+
function Me(e) {
|
|
577
578
|
const t = e.boundaryLoops ?? e.loops ?? e.paths;
|
|
578
579
|
if (Array.isArray(t))
|
|
579
580
|
return t.map((r) => {
|
|
580
581
|
const i = r;
|
|
581
|
-
return { vertices:
|
|
582
|
+
return { vertices: Q(i.vertices ?? i.points), isClosed: !0 };
|
|
582
583
|
}).filter((r) => r.vertices && r.vertices.length > 0);
|
|
583
584
|
}
|
|
584
|
-
function
|
|
585
|
+
function Mt(e) {
|
|
585
586
|
const t = y(e);
|
|
586
587
|
if (t !== void 0)
|
|
587
|
-
return Math.abs(t) > Math.PI * 2 + 1e-6 ?
|
|
588
|
+
return Math.abs(t) > Math.PI * 2 + 1e-6 ? I(t) : t;
|
|
588
589
|
}
|
|
589
|
-
function
|
|
590
|
+
function Et(e) {
|
|
590
591
|
const t = y(e);
|
|
591
592
|
if (t !== void 0)
|
|
592
|
-
return Math.abs(t) > Math.PI * 2 + 1e-6 ?
|
|
593
|
+
return Math.abs(t) > Math.PI * 2 + 1e-6 ? I(t) : t;
|
|
594
|
+
}
|
|
595
|
+
function Ee(e, t) {
|
|
596
|
+
const r = ut(t);
|
|
597
|
+
if (r) return M(e, r);
|
|
598
|
+
const i = Ie(e);
|
|
599
|
+
if (i) return M(e, i);
|
|
600
|
+
const s = ut(Te(e));
|
|
601
|
+
if (s) return M(e, s);
|
|
602
|
+
const n = M(e, "utf-8");
|
|
603
|
+
return n.includes("�") ? Ae(e) : n;
|
|
604
|
+
}
|
|
605
|
+
const It = {
|
|
606
|
+
ANSI_874: "windows-874",
|
|
607
|
+
ANSI_932: "shift_jis",
|
|
608
|
+
ANSI_936: "gb18030",
|
|
609
|
+
ANSI_949: "euc-kr",
|
|
610
|
+
ANSI_950: "big5",
|
|
611
|
+
ANSI_1250: "windows-1250",
|
|
612
|
+
ANSI_1251: "windows-1251",
|
|
613
|
+
ANSI_1252: "windows-1252",
|
|
614
|
+
ANSI_1253: "windows-1253",
|
|
615
|
+
ANSI_1254: "windows-1254",
|
|
616
|
+
ANSI_1255: "windows-1255",
|
|
617
|
+
ANSI_1256: "windows-1256",
|
|
618
|
+
ANSI_1257: "windows-1257",
|
|
619
|
+
ANSI_1258: "windows-1258",
|
|
620
|
+
BIG5: "big5",
|
|
621
|
+
CP874: "windows-874",
|
|
622
|
+
CP932: "shift_jis",
|
|
623
|
+
CP936: "gb18030",
|
|
624
|
+
CP949: "euc-kr",
|
|
625
|
+
CP950: "big5",
|
|
626
|
+
CP1250: "windows-1250",
|
|
627
|
+
CP1251: "windows-1251",
|
|
628
|
+
CP1252: "windows-1252",
|
|
629
|
+
CP1253: "windows-1253",
|
|
630
|
+
CP1254: "windows-1254",
|
|
631
|
+
CP1255: "windows-1255",
|
|
632
|
+
CP1256: "windows-1256",
|
|
633
|
+
CP1257: "windows-1257",
|
|
634
|
+
CP1258: "windows-1258",
|
|
635
|
+
GB18030: "gb18030",
|
|
636
|
+
GB2312: "gb18030",
|
|
637
|
+
GBK: "gb18030",
|
|
638
|
+
SHIFT_JIS: "shift_jis",
|
|
639
|
+
SHIFTJIS: "shift_jis",
|
|
640
|
+
SJIS: "shift_jis",
|
|
641
|
+
UTF8: "utf-8",
|
|
642
|
+
UTF_8: "utf-8",
|
|
643
|
+
UTF16: "utf-16le",
|
|
644
|
+
UTF_16: "utf-16le",
|
|
645
|
+
UTF16LE: "utf-16le",
|
|
646
|
+
UTF_16LE: "utf-16le",
|
|
647
|
+
UTF16BE: "utf-16be",
|
|
648
|
+
UTF_16BE: "utf-16be"
|
|
649
|
+
};
|
|
650
|
+
function Ie(e) {
|
|
651
|
+
if (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191) return "utf-8";
|
|
652
|
+
if (e.length >= 2 && e[0] === 255 && e[1] === 254) return "utf-16le";
|
|
653
|
+
if (e.length >= 2 && e[0] === 254 && e[1] === 255) return "utf-16be";
|
|
654
|
+
}
|
|
655
|
+
function Te(e) {
|
|
656
|
+
var i, s, n, o;
|
|
657
|
+
const r = M(e.subarray(0, Math.min(e.byteLength, 131072)), "iso-8859-1").replace(/\r\n/g, `
|
|
658
|
+
`).replace(/\r/g, `
|
|
659
|
+
`).split(`
|
|
660
|
+
`);
|
|
661
|
+
for (let a = 0; a < r.length - 3; a++)
|
|
662
|
+
if (!(((i = r[a]) == null ? void 0 : i.trim()) !== "9" || ((s = r[a + 1]) == null ? void 0 : s.trim().toUpperCase()) !== "$DWGCODEPAGE"))
|
|
663
|
+
for (let c = a + 2; c < Math.min(a + 10, r.length - 1); c += 2) {
|
|
664
|
+
const h = (n = r[c]) == null ? void 0 : n.trim(), l = (o = r[c + 1]) == null ? void 0 : o.trim();
|
|
665
|
+
if (h === "3" && l) return l;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
function ut(e) {
|
|
669
|
+
const t = e == null ? void 0 : e.trim();
|
|
670
|
+
if (!t) return;
|
|
671
|
+
const r = t.replace(/[-\s]+/g, "_").toUpperCase();
|
|
672
|
+
if (It[r]) return It[r];
|
|
673
|
+
const i = /^ANSI_(\d{3,4})$/.exec(r);
|
|
674
|
+
if (i) return ut(`cp${i[1]}`);
|
|
675
|
+
const s = /^CP(\d{3,4})$/.exec(r);
|
|
676
|
+
return s ? s[1] === "936" ? "gb18030" : s[1] === "950" ? "big5" : s[1] === "932" ? "shift_jis" : s[1] === "949" ? "euc-kr" : `windows-${s[1]}` : t;
|
|
677
|
+
}
|
|
678
|
+
function M(e, t) {
|
|
679
|
+
try {
|
|
680
|
+
return new TextDecoder(t, { fatal: !1 }).decode(e);
|
|
681
|
+
} catch {
|
|
682
|
+
return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
|
|
683
|
+
}
|
|
593
684
|
}
|
|
594
|
-
function
|
|
595
|
-
const t =
|
|
596
|
-
|
|
685
|
+
function Ae(e) {
|
|
686
|
+
const t = ["windows-1252", "gb18030", "big5", "shift_jis", "euc-kr", "iso-8859-1"];
|
|
687
|
+
let r = "", i = Number.POSITIVE_INFINITY;
|
|
688
|
+
for (const s of t) {
|
|
689
|
+
const n = M(e, s), o = Le(n, s);
|
|
690
|
+
o < i && (i = o, r = n);
|
|
691
|
+
}
|
|
692
|
+
return r || M(e, "utf-8");
|
|
597
693
|
}
|
|
598
|
-
function
|
|
694
|
+
function Le(e, t) {
|
|
695
|
+
const r = it(e, /\uFFFD/g), i = it(e, /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g), s = it(e, /[\u3400-\u9FFF\uF900-\uFAFF]/g), n = e.includes("SECTION") && (e.includes("ENTITIES") || e.includes("HEADER"));
|
|
696
|
+
let o = r * 1e4 + i * 1e3;
|
|
697
|
+
return n && (o -= 500), t === "windows-1252" && (o -= 2), t === "gb18030" && s >= 2 && (o -= 50 + Math.min(s, 200) * 2), o;
|
|
698
|
+
}
|
|
699
|
+
function it(e, t) {
|
|
700
|
+
var r;
|
|
701
|
+
return ((r = e.match(t)) == null ? void 0 : r.length) ?? 0;
|
|
702
|
+
}
|
|
703
|
+
function Be(e) {
|
|
704
|
+
const t = C(e);
|
|
705
|
+
if (t !== void 0)
|
|
706
|
+
return t.replace(/\\U\+([0-9a-fA-F]{4,6})/g, (r, i) => {
|
|
707
|
+
const s = Number.parseInt(i, 16);
|
|
708
|
+
return Number.isFinite(s) && s >= 0 && s <= 1114111 ? String.fromCodePoint(s) : r;
|
|
709
|
+
}).replace(/%%[cC]/g, "∅").replace(/%%[dD]/g, "°").replace(/%%[pP]/g, "±").replace(/\\P/g, `
|
|
710
|
+
`);
|
|
711
|
+
}
|
|
712
|
+
function Fe(e) {
|
|
599
713
|
var h, l;
|
|
600
714
|
const t = e.replace(/\r\n/g, `
|
|
601
715
|
`).replace(/\r/g, `
|
|
@@ -637,18 +751,18 @@ function Pe(e) {
|
|
|
637
751
|
o = [];
|
|
638
752
|
return;
|
|
639
753
|
}
|
|
640
|
-
const u =
|
|
754
|
+
const u = De(f, o);
|
|
641
755
|
f === "POLYLINE" ? a = u : i.push(u), o = [];
|
|
642
756
|
}
|
|
643
757
|
}
|
|
644
|
-
function
|
|
758
|
+
function De(e, t) {
|
|
645
759
|
const r = {
|
|
646
760
|
type: e,
|
|
647
|
-
handle:
|
|
648
|
-
layer:
|
|
761
|
+
handle: Y(t, 5),
|
|
762
|
+
layer: Y(t, 8) ?? "0",
|
|
649
763
|
colorIndex: b(t, 62),
|
|
650
764
|
trueColor: b(t, 420),
|
|
651
|
-
lineType:
|
|
765
|
+
lineType: Y(t, 6),
|
|
652
766
|
lineweight: b(t, 370)
|
|
653
767
|
};
|
|
654
768
|
switch (e) {
|
|
@@ -659,17 +773,17 @@ function ke(e, t) {
|
|
|
659
773
|
Object.assign(r, { center: w(t, 10, 20, 30), radius: b(t, 40) });
|
|
660
774
|
break;
|
|
661
775
|
case "ARC":
|
|
662
|
-
Object.assign(r, { center: w(t, 10, 20, 30), radius: b(t, 40), startAngle:
|
|
776
|
+
Object.assign(r, { center: w(t, 10, 20, 30), radius: b(t, 40), startAngle: Z(b(t, 50)), endAngle: Z(b(t, 51)) });
|
|
663
777
|
break;
|
|
664
778
|
case "POINT":
|
|
665
779
|
Object.assign(r, { point: w(t, 10, 20, 30) });
|
|
666
780
|
break;
|
|
667
781
|
case "TEXT":
|
|
668
782
|
case "MTEXT":
|
|
669
|
-
Object.assign(r, { insertionPoint: w(t, 10, 20, 30), text:
|
|
783
|
+
Object.assign(r, { insertionPoint: w(t, 10, 20, 30), text: Oe(t), textHeight: b(t, 40), rotation: Z(b(t, 50)) });
|
|
670
784
|
break;
|
|
671
785
|
case "LWPOLYLINE":
|
|
672
|
-
Object.assign(r, { vertices:
|
|
786
|
+
Object.assign(r, { vertices: Re(t), flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
|
|
673
787
|
break;
|
|
674
788
|
case "POLYLINE":
|
|
675
789
|
Object.assign(r, { vertices: [], flag: b(t, 70), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
|
|
@@ -678,10 +792,10 @@ function ke(e, t) {
|
|
|
678
792
|
Object.assign(r, { center: w(t, 10, 20, 30), majorAxisEndPoint: w(t, 11, 21, 31), axisRatio: b(t, 40), startAngle: b(t, 41), endAngle: b(t, 42) });
|
|
679
793
|
break;
|
|
680
794
|
case "SPLINE":
|
|
681
|
-
Object.assign(r, { controlPoints:
|
|
795
|
+
Object.assign(r, { controlPoints: We(t, 10, 20, 30), degree: b(t, 71), isClosed: (Number(b(t, 70) ?? 0) & 1) === 1 });
|
|
682
796
|
break;
|
|
683
797
|
case "INSERT":
|
|
684
|
-
Object.assign(r, { name:
|
|
798
|
+
Object.assign(r, { name: Y(t, 2), blockName: Y(t, 2), insertionPoint: w(t, 10, 20, 30), rotation: Z(b(t, 50)), scale: { x: b(t, 41) ?? 1, y: b(t, 42) ?? b(t, 41) ?? 1, z: b(t, 43) ?? 1 } });
|
|
685
799
|
break;
|
|
686
800
|
case "SOLID":
|
|
687
801
|
case "TRACE":
|
|
@@ -689,14 +803,14 @@ function ke(e, t) {
|
|
|
689
803
|
Object.assign(r, { vertices: [w(t, 10, 20, 30), w(t, 11, 21, 31), w(t, 12, 22, 32), w(t, 13, 23, 33)].filter(Boolean) });
|
|
690
804
|
break;
|
|
691
805
|
}
|
|
692
|
-
return
|
|
806
|
+
return yt(r);
|
|
693
807
|
}
|
|
694
808
|
function b(e, t) {
|
|
695
809
|
var s;
|
|
696
810
|
const r = (s = e.find((n) => n.code === t)) == null ? void 0 : s.value, i = Number(r);
|
|
697
811
|
return Number.isFinite(i) ? i : void 0;
|
|
698
812
|
}
|
|
699
|
-
function
|
|
813
|
+
function Y(e, t) {
|
|
700
814
|
var i;
|
|
701
815
|
const r = (i = e.find((s) => s.code === t)) == null ? void 0 : i.value;
|
|
702
816
|
return r && r.length > 0 ? r : void 0;
|
|
@@ -706,7 +820,7 @@ function w(e, t, r, i) {
|
|
|
706
820
|
if (!(s === void 0 || n === void 0))
|
|
707
821
|
return o === void 0 ? { x: s, y: n } : { x: s, y: n, z: o };
|
|
708
822
|
}
|
|
709
|
-
function
|
|
823
|
+
function We(e, t, r, i) {
|
|
710
824
|
const s = [];
|
|
711
825
|
for (let n = 0; n < e.length; n++) {
|
|
712
826
|
if (e[n].code !== t) continue;
|
|
@@ -715,7 +829,7 @@ function Se(e, t, r, i) {
|
|
|
715
829
|
}
|
|
716
830
|
return s;
|
|
717
831
|
}
|
|
718
|
-
function
|
|
832
|
+
function Re(e) {
|
|
719
833
|
const t = [];
|
|
720
834
|
for (let r = 0; r < e.length; r++) {
|
|
721
835
|
if (e[r].code !== 10) continue;
|
|
@@ -727,14 +841,14 @@ function Me(e) {
|
|
|
727
841
|
}
|
|
728
842
|
return t;
|
|
729
843
|
}
|
|
730
|
-
function
|
|
844
|
+
function Oe(e) {
|
|
731
845
|
const t = e.filter((r) => r.code === 1 || r.code === 3).map((r) => r.value);
|
|
732
846
|
return t.length ? t.join("") : void 0;
|
|
733
847
|
}
|
|
734
|
-
function
|
|
735
|
-
return typeof e == "number" && Number.isFinite(e) ?
|
|
848
|
+
function Z(e) {
|
|
849
|
+
return typeof e == "number" && Number.isFinite(e) ? I(e) : void 0;
|
|
736
850
|
}
|
|
737
|
-
class
|
|
851
|
+
class ze {
|
|
738
852
|
constructor(t = {}) {
|
|
739
853
|
d(this, "id", "dwf");
|
|
740
854
|
d(this, "label", "DWF/DWFx native viewer powered by dwf-viewer");
|
|
@@ -749,29 +863,29 @@ class Ee {
|
|
|
749
863
|
accepts(t, r) {
|
|
750
864
|
const i = L(t);
|
|
751
865
|
if (i === "dwf" || i === "dwfx" || i === "xps") return !0;
|
|
752
|
-
const s =
|
|
866
|
+
const s = B(t, r);
|
|
753
867
|
return s === "dwf" || s === "dwfx" || s === "xps";
|
|
754
868
|
}
|
|
755
869
|
async load(t, r = {}) {
|
|
756
870
|
var f, u, p, g;
|
|
757
|
-
const i = { ...this.defaults, ...r }, s = performance.now(), n = t.fileName ?? ((f = t.file) == null ? void 0 : f.name), o = await
|
|
871
|
+
const i = { ...this.defaults, ...r }, s = performance.now(), n = t.fileName ?? ((f = t.file) == null ? void 0 : f.name), o = await U(t), a = Lt(B(t, o), L(t));
|
|
758
872
|
(u = i.onProgress) == null || u.call(i, { phase: "parse", format: a, message: "Opening DWF/DWFx with dwf-viewer…", percent: 48 });
|
|
759
|
-
const c = await
|
|
873
|
+
const c = await se(o, { fileName: n });
|
|
760
874
|
(p = i.onProgress) == null || p.call(i, { phase: "normalize", format: a, message: "Reading DWF pages, sheets and model metadata…", percent: 76 });
|
|
761
|
-
const h =
|
|
875
|
+
const h = Tt(c, n, a, i.keepRaw === !0), l = performance.now() - s;
|
|
762
876
|
return (g = i.onProgress) == null || g.call(i, { phase: "done", format: h.format, message: "DWF/DWFx document ready.", percent: 100, elapsedMs: l }), { document: h, raw: i.keepRaw ? c : void 0, bytes: o.byteLength, elapsedMs: l, format: h.format, warnings: h.warnings };
|
|
763
877
|
}
|
|
764
878
|
async mount(t, r, i = {}) {
|
|
765
|
-
var
|
|
766
|
-
const s = { ...this.defaults, ...i }, n = performance.now(), o = t.fileName ?? ((
|
|
767
|
-
(
|
|
879
|
+
var z, _, H, xt, wt;
|
|
880
|
+
const s = { ...this.defaults, ...i }, n = performance.now(), o = t.fileName ?? ((z = t.file) == null ? void 0 : z.name), a = await U(t), c = Lt(B(t, a), L(t)), h = Ue(s), l = Bt(s), f = Ve(s, h, l), u = Zt(s, h, l);
|
|
881
|
+
(_ = s.onProgress) == null || _.call(s, { phase: "native-render", format: c, message: "Mounting native DWF renderer…", percent: 28 }), this.unmount(), this.host = r, r.replaceChildren(), this.native = new ne(r, f), (H = s.onProgress) == null || H.call(s, { phase: "parse", format: c, message: "Parsing DWF package and page streams…", percent: 58 }), await this.native.load(a, {
|
|
768
882
|
fileName: o,
|
|
769
883
|
...u
|
|
770
|
-
}), (
|
|
771
|
-
const p = this.native.getDocument(), g =
|
|
884
|
+
}), (xt = s.onProgress) == null || xt.call(s, { phase: "render", format: c, message: "Rendering DWF/DWFx with dwf-viewer…", percent: 88 }), this.lastStats = await this.native.render();
|
|
885
|
+
const p = this.native.getDocument(), g = Tt(p, o, c, s.keepRaw === !0);
|
|
772
886
|
g.metadata.loaderMode = "Native DWF", g.metadata.nativeRenderer = "dwf-viewer", g.metadata.nativeRenderStats = this.lastStats ? { ...this.lastStats, warnings: this.lastStats.warnings.length } : void 0;
|
|
773
887
|
const S = performance.now() - n;
|
|
774
|
-
return (
|
|
888
|
+
return (wt = s.onProgress) == null || wt.call(s, { phase: "done", format: g.format, message: "DWF/DWFx rendered.", percent: 100, elapsedMs: S }), { document: g, raw: s.keepRaw ? p : void 0, bytes: a.byteLength, elapsedMs: S, format: g.format, warnings: g.warnings };
|
|
775
889
|
}
|
|
776
890
|
unmount() {
|
|
777
891
|
var t;
|
|
@@ -801,43 +915,43 @@ class Ee {
|
|
|
801
915
|
if (r) {
|
|
802
916
|
if (typeof t.dwfBackground == "string") r.background = t.dwfBackground;
|
|
803
917
|
else {
|
|
804
|
-
const a =
|
|
918
|
+
const a = Bt(t);
|
|
805
919
|
a && (r.background = a);
|
|
806
920
|
}
|
|
807
|
-
typeof t.dwfPreferWebgl == "boolean" && ((i = r.setPreferWebgl) == null || i.call(r, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((s = r.setPreferWasm) == null || s.call(r, t.dwfPreferWasm)), t.dwfLineWeightMode && ((n = r.setLineWeightMode) == null || n.call(r, t.dwfLineWeightMode)),
|
|
921
|
+
typeof t.dwfPreferWebgl == "boolean" && ((i = r.setPreferWebgl) == null || i.call(r, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((s = r.setPreferWasm) == null || s.call(r, t.dwfPreferWasm)), t.dwfLineWeightMode && ((n = r.setLineWeightMode) == null || n.call(r, t.dwfLineWeightMode)), q(r, "minStrokeCssPx", t.dwfMinStrokeCssPx), q(r, "maxOverviewStrokeCssPx", t.dwfMaxOverviewStrokeCssPx), q(r, "minTextCssPx", t.dwfMinTextCssPx), q(r, "minFilledAreaCssPx", t.dwfMinFilledAreaCssPx), (o = r.render) == null || o.call(r);
|
|
808
922
|
}
|
|
809
923
|
}
|
|
810
924
|
getLastNativeStats() {
|
|
811
925
|
return this.lastStats;
|
|
812
926
|
}
|
|
813
927
|
}
|
|
814
|
-
function
|
|
928
|
+
function Tt(e, t, r, i) {
|
|
815
929
|
var a, c;
|
|
816
|
-
const s =
|
|
817
|
-
for (const h of (e == null ? void 0 : e.pageData) ?? []) s.push(...
|
|
930
|
+
const s = At((e == null ? void 0 : e.diagnostics) ?? []), n = ((e == null ? void 0 : e.pageData) ?? []).map((h, l) => _e(h, l));
|
|
931
|
+
for (const h of (e == null ? void 0 : e.pageData) ?? []) s.push(...At(h.diagnostics));
|
|
818
932
|
const o = {
|
|
819
933
|
parser: "dwf-viewer",
|
|
820
934
|
nativeRenderer: "dwf-viewer",
|
|
821
935
|
dwfKind: e == null ? void 0 : e.kind,
|
|
822
936
|
packageEntries: ((a = e == null ? void 0 : e.packageEntries) == null ? void 0 : a.length) ?? 0,
|
|
823
937
|
resources: ((c = e == null ? void 0 : e.resources) == null ? void 0 : c.length) ?? 0,
|
|
824
|
-
pageKinds:
|
|
938
|
+
pageKinds: Ge(((e == null ? void 0 : e.pageData) ?? []).map((h) => h.kind)),
|
|
825
939
|
pageNames: ((e == null ? void 0 : e.pages) ?? []).map((h) => h.name)
|
|
826
940
|
};
|
|
827
|
-
return
|
|
941
|
+
return Ut({
|
|
828
942
|
format: r,
|
|
829
943
|
sourceName: t,
|
|
830
944
|
layers: {},
|
|
831
945
|
blocks: {},
|
|
832
946
|
pages: n,
|
|
833
|
-
entities:
|
|
947
|
+
entities: ye(n),
|
|
834
948
|
metadata: o,
|
|
835
|
-
warnings:
|
|
949
|
+
warnings: Ze(s),
|
|
836
950
|
raw: i ? e : void 0
|
|
837
951
|
});
|
|
838
952
|
}
|
|
839
|
-
function
|
|
840
|
-
const r =
|
|
953
|
+
function _e(e, t) {
|
|
954
|
+
const r = He(e, t);
|
|
841
955
|
return {
|
|
842
956
|
index: t,
|
|
843
957
|
name: e.name || e.sourcePath || `${t + 1}`,
|
|
@@ -846,18 +960,18 @@ function Ie(e, t) {
|
|
|
846
960
|
entities: r
|
|
847
961
|
};
|
|
848
962
|
}
|
|
849
|
-
function
|
|
850
|
-
return e.kind === "w2d-text" ? e.primitives.flatMap((r, i) =>
|
|
963
|
+
function He(e, t) {
|
|
964
|
+
return e.kind === "w2d-text" ? e.primitives.flatMap((r, i) => Ye(r, t, i)) : e.kind === "image" ? [{ type: "DWF_IMAGE_PAGE", kind: "image", pageIndex: t, width: e.width, height: e.height, imageSource: e.sourcePath }] : e.kind === "w3d-model" ? e.model.meshes.map((r, i) => ({
|
|
851
965
|
id: r.id,
|
|
852
966
|
type: "W3D_MESH",
|
|
853
967
|
kind: "solid",
|
|
854
968
|
pageIndex: t,
|
|
855
|
-
color: r.color ?
|
|
969
|
+
color: r.color ? je(r.color) : void 0,
|
|
856
970
|
name: r.name || `mesh-${i + 1}`,
|
|
857
971
|
raw: { vertexCount: r.vertexCount, triangleCount: r.triangleCount, materialId: r.materialId }
|
|
858
972
|
})) : e.kind === "xps-fixed-page" ? [{ type: "XPS_FIXED_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }] : [{ type: "DWF_PAGE", kind: "viewport", pageIndex: t, width: e.width, height: e.height, raw: { sourcePath: e.sourcePath } }];
|
|
859
973
|
}
|
|
860
|
-
function
|
|
974
|
+
function Ye(e, t, r) {
|
|
861
975
|
const i = {
|
|
862
976
|
id: `dwf-${t}-${r}`,
|
|
863
977
|
pageIndex: t,
|
|
@@ -871,7 +985,7 @@ function Le(e, t, r) {
|
|
|
871
985
|
...i,
|
|
872
986
|
type: e.type === "polygon" ? "DWF_POLYGON" : "DWF_POLYLINE",
|
|
873
987
|
kind: "polyline",
|
|
874
|
-
vertices:
|
|
988
|
+
vertices: Xe(e.points),
|
|
875
989
|
isClosed: e.type === "polygon"
|
|
876
990
|
}];
|
|
877
991
|
if (e.type === "path")
|
|
@@ -902,36 +1016,36 @@ function Le(e, t, r) {
|
|
|
902
1016
|
}
|
|
903
1017
|
return [];
|
|
904
1018
|
}
|
|
905
|
-
function
|
|
1019
|
+
function Xe(e) {
|
|
906
1020
|
const t = [];
|
|
907
1021
|
for (let r = 0; r + 1 < e.length; r += 2) t.push({ x: e[r], y: e[r + 1], z: 0 });
|
|
908
1022
|
return t;
|
|
909
1023
|
}
|
|
910
|
-
function
|
|
1024
|
+
function At(e) {
|
|
911
1025
|
return e.filter((t) => t.level !== "info").map((t) => `${t.code}: ${t.message}${t.source ? ` (${t.source})` : ""}`);
|
|
912
1026
|
}
|
|
913
|
-
function
|
|
1027
|
+
function Lt(e, t) {
|
|
914
1028
|
return t === "dwf" || t === "dwfx" || t === "xps" ? t : e === "dwf" || e === "dwfx" || e === "xps" ? e : "dwf";
|
|
915
1029
|
}
|
|
916
|
-
function
|
|
1030
|
+
function Ue(e) {
|
|
917
1031
|
if (e.dwfWasmUrl) return e.dwfWasmUrl;
|
|
918
1032
|
if (typeof document > "u") return;
|
|
919
|
-
const t = e.wasmPath ? new URL(
|
|
1033
|
+
const t = e.wasmPath ? new URL($e(e.wasmPath), document.baseURI).href : new URL("wasm/", document.baseURI).href;
|
|
920
1034
|
return new URL("dwfv-render.wasm", t).href;
|
|
921
1035
|
}
|
|
922
|
-
function
|
|
1036
|
+
function Bt(e) {
|
|
923
1037
|
if (e.dwfBackground) return e.dwfBackground;
|
|
924
1038
|
const t = e.canvasOptions;
|
|
925
1039
|
return (t == null ? void 0 : t.background) ?? "#05070d";
|
|
926
1040
|
}
|
|
927
|
-
function
|
|
1041
|
+
function Ve(e, t, r) {
|
|
928
1042
|
return {
|
|
929
|
-
...
|
|
1043
|
+
...Zt(e, t, r),
|
|
930
1044
|
maxDevicePixelRatio: e.dwfMaxDevicePixelRatio ?? 2,
|
|
931
1045
|
maxCanvasPixels: e.dwfMaxCanvasPixels ?? 16777216
|
|
932
1046
|
};
|
|
933
1047
|
}
|
|
934
|
-
function
|
|
1048
|
+
function Zt(e, t, r) {
|
|
935
1049
|
return {
|
|
936
1050
|
wasmUrl: t,
|
|
937
1051
|
preferWebgl: e.dwfPreferWebgl ?? !0,
|
|
@@ -946,39 +1060,39 @@ function Ut(e, t, r) {
|
|
|
946
1060
|
minFilledAreaCssPx: e.dwfMinFilledAreaCssPx
|
|
947
1061
|
};
|
|
948
1062
|
}
|
|
949
|
-
function
|
|
1063
|
+
function q(e, t, r) {
|
|
950
1064
|
typeof r == "number" && Number.isFinite(r) && (e[t] = r);
|
|
951
1065
|
}
|
|
952
|
-
function
|
|
1066
|
+
function $e(e) {
|
|
953
1067
|
return e.endsWith("/") ? e : `${e}/`;
|
|
954
1068
|
}
|
|
955
|
-
function
|
|
1069
|
+
function je(e) {
|
|
956
1070
|
const [t, r, i] = e.map((s) => Math.max(0, Math.min(255, Math.round(s * 255))));
|
|
957
|
-
return `#${
|
|
1071
|
+
return `#${st(t)}${st(r)}${st(i)}`;
|
|
958
1072
|
}
|
|
959
|
-
function
|
|
1073
|
+
function st(e) {
|
|
960
1074
|
return e.toString(16).padStart(2, "0");
|
|
961
1075
|
}
|
|
962
|
-
function
|
|
1076
|
+
function Ge(e) {
|
|
963
1077
|
const t = {};
|
|
964
1078
|
for (const r of e) t[r] = (t[r] ?? 0) + 1;
|
|
965
1079
|
return t;
|
|
966
1080
|
}
|
|
967
|
-
function
|
|
1081
|
+
function Ze(e) {
|
|
968
1082
|
return Array.from(new Set(e));
|
|
969
1083
|
}
|
|
970
|
-
function
|
|
971
|
-
return new
|
|
972
|
-
new ce(e),
|
|
1084
|
+
function qe(e = {}) {
|
|
1085
|
+
return new ae([
|
|
973
1086
|
new me(e),
|
|
974
|
-
new
|
|
1087
|
+
new xe(e),
|
|
1088
|
+
new ze(e)
|
|
975
1089
|
]);
|
|
976
1090
|
}
|
|
977
|
-
function
|
|
1091
|
+
function Ke(e) {
|
|
978
1092
|
const t = e;
|
|
979
1093
|
return t.nativeRenderer === !0 && typeof t.mount == "function";
|
|
980
1094
|
}
|
|
981
|
-
const
|
|
1095
|
+
const Je = {
|
|
982
1096
|
1: "#ff0000",
|
|
983
1097
|
2: "#ffff00",
|
|
984
1098
|
3: "#00ff00",
|
|
@@ -1234,19 +1348,19 @@ const He = {
|
|
|
1234
1348
|
254: "#bebebe",
|
|
1235
1349
|
255: "#ffffff"
|
|
1236
1350
|
};
|
|
1237
|
-
function
|
|
1351
|
+
function E(e, t = "#ffffff", r = t) {
|
|
1238
1352
|
if (typeof e != "number" || Number.isNaN(e)) return t;
|
|
1239
1353
|
const i = Math.abs(Math.trunc(e));
|
|
1240
|
-
return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r :
|
|
1354
|
+
return i === 0 || i === 256 || i === 257 ? t : i === 7 ? r : Je[i] ?? t;
|
|
1241
1355
|
}
|
|
1242
|
-
function
|
|
1356
|
+
function V(e, t = "rgb") {
|
|
1243
1357
|
const r = Math.max(0, Math.trunc(e)) & 16777215, i = r >> 16 & 255, s = r >> 8 & 255, n = r & 255;
|
|
1244
1358
|
return `rgb(${t === "rgb" ? i : n}, ${s}, ${t === "rgb" ? n : i})`;
|
|
1245
1359
|
}
|
|
1246
|
-
function
|
|
1360
|
+
function F(e) {
|
|
1247
1361
|
if (typeof e == "string") {
|
|
1248
1362
|
const t = e.trim();
|
|
1249
|
-
return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ?
|
|
1363
|
+
return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? Qe(t) ?? t : {
|
|
1250
1364
|
red: "#ff0000",
|
|
1251
1365
|
yellow: "#ffff00",
|
|
1252
1366
|
green: "#00ff00",
|
|
@@ -1265,111 +1379,111 @@ function B(e) {
|
|
|
1265
1379
|
return Number.isFinite(n) && n >= 0 && n < 1 ? `rgba(${r}, ${i}, ${s}, ${n})` : `rgb(${r}, ${i}, ${s})`;
|
|
1266
1380
|
}
|
|
1267
1381
|
}
|
|
1268
|
-
function
|
|
1382
|
+
function Qe(e) {
|
|
1269
1383
|
if (!e) return;
|
|
1270
1384
|
const t = e.trim();
|
|
1271
1385
|
if (/^#[0-9a-f]{8}$/i.test(t)) {
|
|
1272
1386
|
const r = parseInt(t.slice(1, 3), 16) / 255, i = parseInt(t.slice(3, 5), 16), s = parseInt(t.slice(5, 7), 16), n = parseInt(t.slice(7, 9), 16);
|
|
1273
|
-
return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${
|
|
1387
|
+
return r >= 0.999 ? `rgb(${i}, ${s}, ${n})` : `rgba(${i}, ${s}, ${n}, ${gt(r)})`;
|
|
1274
1388
|
}
|
|
1275
1389
|
if (/^#[0-9a-f]{6}$/i.test(t) || /^#[0-9a-f]{3}$/i.test(t)) return t;
|
|
1276
1390
|
if (/^sc#/i.test(t)) {
|
|
1277
1391
|
const r = t.slice(3).split(",").map((a) => Number(a.trim())), [i, s, n, o] = r.length === 4 ? r : [1, ...r];
|
|
1278
|
-
if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${
|
|
1392
|
+
if ([i, s, n, o].every(Number.isFinite)) return `rgba(${Math.round(s * 255)}, ${Math.round(n * 255)}, ${Math.round(o * 255)}, ${gt(i)})`;
|
|
1279
1393
|
}
|
|
1280
1394
|
}
|
|
1281
|
-
function
|
|
1395
|
+
function D(e, t, r = {}) {
|
|
1282
1396
|
const i = r.foreground ?? "#ffffff", s = i;
|
|
1283
1397
|
let n;
|
|
1284
|
-
const o =
|
|
1398
|
+
const o = F(e.trueColor) ?? F(e.color) ?? F(e.colorName);
|
|
1285
1399
|
if (o && (n = o), !n) {
|
|
1286
|
-
const a =
|
|
1287
|
-
typeof a == "number" && a >= 0 && a <= 16777215 && (n =
|
|
1400
|
+
const a = nr(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
|
|
1401
|
+
typeof a == "number" && a >= 0 && a <= 16777215 && (n = V(a, r.trueColorByteOrder ?? "rgb"));
|
|
1288
1402
|
}
|
|
1289
1403
|
if (!n) {
|
|
1290
|
-
const a =
|
|
1291
|
-
typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n =
|
|
1404
|
+
const a = Qt(e.colorIndex, e.colorNumber, e.aci);
|
|
1405
|
+
typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (n = E(a, s, i));
|
|
1292
1406
|
}
|
|
1293
1407
|
if (!n && typeof e.color == "number") {
|
|
1294
1408
|
const a = Number(e.color);
|
|
1295
|
-
Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n =
|
|
1409
|
+
Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (n = E(a, s, i)) : n = V(a, r.trueColorByteOrder ?? "rgb");
|
|
1296
1410
|
}
|
|
1297
1411
|
if (!n) {
|
|
1298
|
-
const a =
|
|
1299
|
-
n =
|
|
1412
|
+
const a = sr(t, e.layer);
|
|
1413
|
+
n = er(a, r);
|
|
1300
1414
|
}
|
|
1301
|
-
return
|
|
1415
|
+
return qt(n ?? s, r);
|
|
1302
1416
|
}
|
|
1303
|
-
function
|
|
1417
|
+
function mt(e, t, r = {}) {
|
|
1304
1418
|
let i;
|
|
1305
|
-
const s =
|
|
1419
|
+
const s = F(e.fillColor);
|
|
1306
1420
|
if (s && (i = s), !i && typeof e.fillColor == "number") {
|
|
1307
1421
|
const n = e.fillColor;
|
|
1308
|
-
i = Math.abs(n) <= 257 ?
|
|
1422
|
+
i = Math.abs(n) <= 257 ? E(n, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff") : V(n, r.trueColorByteOrder ?? "rgb");
|
|
1309
1423
|
}
|
|
1310
|
-
return !i && typeof e.fillColorIndex == "number" && (i =
|
|
1424
|
+
return !i && typeof e.fillColorIndex == "number" && (i = E(e.fillColorIndex, r.foreground ?? "#ffffff", r.foreground ?? "#ffffff")), i ? qt(i, r) : void 0;
|
|
1311
1425
|
}
|
|
1312
|
-
function
|
|
1426
|
+
function qt(e, t = {}) {
|
|
1313
1427
|
if (t.contrastMode !== "adaptive") return e;
|
|
1314
1428
|
const r = t.background ?? "#0b1020", i = t.foreground ?? "#ffffff";
|
|
1315
|
-
return
|
|
1429
|
+
return tr(e, r, i, t.minColorContrast ?? 2.4);
|
|
1316
1430
|
}
|
|
1317
|
-
function
|
|
1318
|
-
const s =
|
|
1431
|
+
function tr(e, t, r, i = 2.4) {
|
|
1432
|
+
const s = nt(r) ?? { r: 255, g: 255, b: 255, a: 1 }, n = nt(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = nt(e);
|
|
1319
1433
|
if (!o) return e;
|
|
1320
|
-
const a =
|
|
1321
|
-
if (
|
|
1322
|
-
const c =
|
|
1434
|
+
const a = Ft(o, n);
|
|
1435
|
+
if (ot(a, n) >= i) return e;
|
|
1436
|
+
const c = pt(n), h = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
|
|
1323
1437
|
for (const l of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
|
|
1324
|
-
const f =
|
|
1325
|
-
if (
|
|
1438
|
+
const f = or(o, h, l);
|
|
1439
|
+
if (ot(Ft(f, n), n) >= i) return Dt(f);
|
|
1326
1440
|
}
|
|
1327
|
-
return
|
|
1441
|
+
return ot(s, n) >= i ? Dt(s) : c < 0.5 ? "#ffffff" : "#000000";
|
|
1328
1442
|
}
|
|
1329
|
-
function
|
|
1443
|
+
function Kt(e) {
|
|
1330
1444
|
return e ? e.isVisible !== !1 && e.isFrozen !== !0 : !0;
|
|
1331
1445
|
}
|
|
1332
|
-
function
|
|
1446
|
+
function er(e, t) {
|
|
1333
1447
|
if (!e) return;
|
|
1334
|
-
const r = t.foreground ?? "#ffffff", i =
|
|
1448
|
+
const r = t.foreground ?? "#ffffff", i = F(e.trueColor);
|
|
1335
1449
|
if (i) return i;
|
|
1336
|
-
if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return
|
|
1337
|
-
const s =
|
|
1450
|
+
if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return V(e.trueColor, t.trueColorByteOrder ?? "rgb");
|
|
1451
|
+
const s = F(e.color);
|
|
1338
1452
|
if (s) return s;
|
|
1339
|
-
if (
|
|
1453
|
+
if (ir(e.colorIndex)) return E(e.colorIndex, r, r);
|
|
1340
1454
|
if (typeof e.color == "number") {
|
|
1341
1455
|
const n = Number(e.color);
|
|
1342
|
-
return Math.abs(n) <= 257 ?
|
|
1456
|
+
return Math.abs(n) <= 257 ? E(n, r, r) : V(n, t.trueColorByteOrder ?? "rgb");
|
|
1343
1457
|
}
|
|
1344
|
-
if (typeof e.colorIndex == "number") return
|
|
1458
|
+
if (typeof e.colorIndex == "number") return E(e.colorIndex, r, r);
|
|
1345
1459
|
}
|
|
1346
|
-
function
|
|
1347
|
-
return
|
|
1460
|
+
function rr(e) {
|
|
1461
|
+
return Qt(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
|
|
1348
1462
|
}
|
|
1349
|
-
function
|
|
1350
|
-
if (!
|
|
1351
|
-
const s =
|
|
1463
|
+
function Jt(e, t, r, i = {}) {
|
|
1464
|
+
if (!rr(e)) return e;
|
|
1465
|
+
const s = D(t, r, i);
|
|
1352
1466
|
return { ...e, color: s, trueColor: void 0, colorIndex: void 0, colorNumber: void 0 };
|
|
1353
1467
|
}
|
|
1354
|
-
function
|
|
1468
|
+
function ir(e) {
|
|
1355
1469
|
return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
|
|
1356
1470
|
}
|
|
1357
|
-
function
|
|
1471
|
+
function sr(e, t) {
|
|
1358
1472
|
if (!(!e || !t))
|
|
1359
1473
|
return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((r) => r.name.toLowerCase() === t.toLowerCase());
|
|
1360
1474
|
}
|
|
1361
|
-
function
|
|
1475
|
+
function Qt(...e) {
|
|
1362
1476
|
for (const t of e)
|
|
1363
1477
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
1364
1478
|
}
|
|
1365
|
-
function
|
|
1479
|
+
function nr(e, t) {
|
|
1366
1480
|
const r = e;
|
|
1367
1481
|
for (const i of t) {
|
|
1368
1482
|
const s = r[i];
|
|
1369
1483
|
if (typeof s == "number" && Number.isFinite(s)) return s;
|
|
1370
1484
|
}
|
|
1371
1485
|
}
|
|
1372
|
-
function
|
|
1486
|
+
function nt(e) {
|
|
1373
1487
|
const t = e.trim().toLowerCase();
|
|
1374
1488
|
if (/^#[0-9a-f]{3}$/i.test(t))
|
|
1375
1489
|
return {
|
|
@@ -1399,7 +1513,7 @@ function it(e) {
|
|
|
1399
1513
|
}
|
|
1400
1514
|
}
|
|
1401
1515
|
}
|
|
1402
|
-
function
|
|
1516
|
+
function Ft(e, t) {
|
|
1403
1517
|
const r = e.a + t.a * (1 - e.a);
|
|
1404
1518
|
return r <= 0 ? { r: 0, g: 0, b: 0, a: 0 } : {
|
|
1405
1519
|
r: (e.r * e.a + t.r * t.a * (1 - e.a)) / r,
|
|
@@ -1408,7 +1522,7 @@ function It(e, t) {
|
|
|
1408
1522
|
a: r
|
|
1409
1523
|
};
|
|
1410
1524
|
}
|
|
1411
|
-
function
|
|
1525
|
+
function or(e, t, r) {
|
|
1412
1526
|
const i = Math.max(0, Math.min(1, r));
|
|
1413
1527
|
return {
|
|
1414
1528
|
r: e.r + (t.r - e.r) * i,
|
|
@@ -1417,28 +1531,28 @@ function Ze(e, t, r) {
|
|
|
1417
1531
|
a: e.a
|
|
1418
1532
|
};
|
|
1419
1533
|
}
|
|
1420
|
-
function
|
|
1534
|
+
function pt(e) {
|
|
1421
1535
|
const t = [e.r, e.g, e.b].map((r) => {
|
|
1422
1536
|
const i = r / 255;
|
|
1423
1537
|
return i <= 0.03928 ? i / 12.92 : ((i + 0.055) / 1.055) ** 2.4;
|
|
1424
1538
|
});
|
|
1425
1539
|
return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
|
|
1426
1540
|
}
|
|
1427
|
-
function
|
|
1428
|
-
const r =
|
|
1541
|
+
function ot(e, t) {
|
|
1542
|
+
const r = pt(e), i = pt(t), s = Math.max(r, i), n = Math.min(r, i);
|
|
1429
1543
|
return (s + 0.05) / (n + 0.05);
|
|
1430
1544
|
}
|
|
1431
|
-
function
|
|
1545
|
+
function Dt(e) {
|
|
1432
1546
|
const t = W(e.r), r = W(e.g), i = W(e.b);
|
|
1433
|
-
return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${
|
|
1547
|
+
return e.a < 0.999 ? `rgba(${t}, ${r}, ${i}, ${gt(e.a)})` : `rgb(${t}, ${r}, ${i})`;
|
|
1434
1548
|
}
|
|
1435
1549
|
function W(e) {
|
|
1436
1550
|
return Math.max(0, Math.min(255, Math.round(e)));
|
|
1437
1551
|
}
|
|
1438
|
-
function
|
|
1552
|
+
function gt(e) {
|
|
1439
1553
|
return Math.round(e * 1e3) / 1e3;
|
|
1440
1554
|
}
|
|
1441
|
-
function
|
|
1555
|
+
function at(e, t) {
|
|
1442
1556
|
return {
|
|
1443
1557
|
a: e.a * t.a + e.c * t.b,
|
|
1444
1558
|
b: e.b * t.a + e.d * t.b,
|
|
@@ -1448,14 +1562,14 @@ function nt(e, t) {
|
|
|
1448
1562
|
f: e.b * t.e + e.d * t.f + e.f
|
|
1449
1563
|
};
|
|
1450
1564
|
}
|
|
1451
|
-
function
|
|
1565
|
+
function Wt(e, t) {
|
|
1452
1566
|
return { a: 1, b: 0, c: 0, d: 1, e, f: t };
|
|
1453
1567
|
}
|
|
1454
|
-
function
|
|
1568
|
+
function ar(e) {
|
|
1455
1569
|
const t = Math.cos(e), r = Math.sin(e);
|
|
1456
1570
|
return { a: t, b: r, c: -r, d: t, e: 0, f: 0 };
|
|
1457
1571
|
}
|
|
1458
|
-
function
|
|
1572
|
+
function cr(e, t = e) {
|
|
1459
1573
|
return { a: e, b: 0, c: 0, d: t, e: 0, f: 0 };
|
|
1460
1574
|
}
|
|
1461
1575
|
function k(e, t) {
|
|
@@ -1465,33 +1579,33 @@ function k(e, t) {
|
|
|
1465
1579
|
z: "z" in e ? e.z : void 0
|
|
1466
1580
|
};
|
|
1467
1581
|
}
|
|
1468
|
-
function
|
|
1582
|
+
function Rt(e, t) {
|
|
1469
1583
|
if (e)
|
|
1470
1584
|
return e.map((r) => ({ cmd: r.cmd, points: r.points.map((i) => k(i, t)) }));
|
|
1471
1585
|
}
|
|
1472
|
-
function
|
|
1586
|
+
function tt(e, t = { x: 0, y: 0 }) {
|
|
1473
1587
|
const r = e.insertionPoint ?? { x: 0, y: 0 }, i = e.scale, s = Number(typeof i == "object" && i ? i.x ?? 1 : e.scaleX ?? 1), n = Number(typeof i == "object" && i ? i.y ?? s : e.scaleY ?? s), o = Number(e.rotation ?? 0);
|
|
1474
|
-
let a =
|
|
1475
|
-
return a =
|
|
1588
|
+
let a = Wt(r.x, r.y);
|
|
1589
|
+
return a = at(a, ar(Number.isFinite(o) ? o : 0)), a = at(a, cr(Number.isFinite(s) ? s : 1, Number.isFinite(n) ? n : 1)), a = at(a, Wt(-t.x, -t.y)), a;
|
|
1476
1590
|
}
|
|
1477
|
-
function
|
|
1591
|
+
function et(e, t) {
|
|
1478
1592
|
const r = { ...e, raw: e.raw ?? e };
|
|
1479
1593
|
if (e.startPoint && (r.startPoint = k(e.startPoint, t)), e.endPoint && (r.endPoint = k(e.endPoint, t)), e.center && (r.center = k(e.center, t)), e.insertionPoint && (r.insertionPoint = k(e.insertionPoint, t)), e.majorAxisEndPoint) {
|
|
1480
1594
|
const s = k({ x: 0, y: 0 }, t), n = k(e.majorAxisEndPoint, t);
|
|
1481
1595
|
r.majorAxisEndPoint = { x: n.x - s.x, y: n.y - s.y, z: n.z };
|
|
1482
1596
|
}
|
|
1483
|
-
e.vertices && (r.vertices = e.vertices.map((s) => ({ ...k(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => k(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => k(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => k(s, t))), e.commands && (r.commands =
|
|
1597
|
+
e.vertices && (r.vertices = e.vertices.map((s) => ({ ...k(s, t), bulge: s.bulge, startWidth: s.startWidth, endWidth: s.endWidth }))), e.points && (r.points = e.points.map((s) => k(s, t))), e.controlPoints && (r.controlPoints = e.controlPoints.map((s) => k(s, t))), e.fitPoints && (r.fitPoints = e.fitPoints.map((s) => k(s, t))), e.commands && (r.commands = Rt(e.commands, t)), e.loops && (r.loops = e.loops.map((s) => {
|
|
1484
1598
|
var n;
|
|
1485
1599
|
return {
|
|
1486
1600
|
...s,
|
|
1487
1601
|
vertices: (n = s.vertices) == null ? void 0 : n.map((o) => k(o, t)),
|
|
1488
|
-
commands:
|
|
1602
|
+
commands: Rt(s.commands, t)
|
|
1489
1603
|
};
|
|
1490
1604
|
}));
|
|
1491
1605
|
const i = Math.sqrt(Math.abs(t.a * t.d - t.b * t.c));
|
|
1492
1606
|
return typeof e.radius == "number" && Number.isFinite(i) && (r.radius = e.radius * i), r;
|
|
1493
1607
|
}
|
|
1494
|
-
const
|
|
1608
|
+
const hr = {
|
|
1495
1609
|
background: "#0b1020",
|
|
1496
1610
|
foreground: "#ffffff",
|
|
1497
1611
|
showUnsupportedMarkers: !1,
|
|
@@ -1514,13 +1628,13 @@ const Je = {
|
|
|
1514
1628
|
preserveDrawingBuffer: !1,
|
|
1515
1629
|
enableSpatialIndex: !0
|
|
1516
1630
|
};
|
|
1517
|
-
class
|
|
1631
|
+
class Ot {
|
|
1518
1632
|
constructor(t, r = {}) {
|
|
1519
1633
|
d(this, "canvas");
|
|
1520
1634
|
d(this, "ctx");
|
|
1521
1635
|
d(this, "opts");
|
|
1522
1636
|
d(this, "document");
|
|
1523
|
-
d(this, "bounds",
|
|
1637
|
+
d(this, "bounds", N());
|
|
1524
1638
|
d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
|
|
1525
1639
|
d(this, "fitScale", 1);
|
|
1526
1640
|
d(this, "dpr", 1);
|
|
@@ -1533,14 +1647,14 @@ class Bt {
|
|
|
1533
1647
|
d(this, "onViewChange");
|
|
1534
1648
|
const i = t.getContext("2d");
|
|
1535
1649
|
if (!i) throw new Error("Canvas 2D context is not available.");
|
|
1536
|
-
this.canvas = t, this.ctx = i, this.opts = { ...
|
|
1650
|
+
this.canvas = t, this.ctx = i, this.opts = { ...hr, ...r }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
|
|
1537
1651
|
}
|
|
1538
1652
|
destroy() {
|
|
1539
1653
|
var t;
|
|
1540
1654
|
(t = this.resizeObserver) == null || t.disconnect();
|
|
1541
1655
|
}
|
|
1542
1656
|
clear() {
|
|
1543
|
-
this.document = void 0, this.bounds =
|
|
1657
|
+
this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
1544
1658
|
}
|
|
1545
1659
|
setDocument(t) {
|
|
1546
1660
|
this.document = t, this.bounds = this.computeBounds(t), this.fitToView();
|
|
@@ -1555,7 +1669,7 @@ class Bt {
|
|
|
1555
1669
|
return { ...this.opts };
|
|
1556
1670
|
}
|
|
1557
1671
|
fitToView(t = 0.92) {
|
|
1558
|
-
if (!
|
|
1672
|
+
if (!O(this.bounds)) {
|
|
1559
1673
|
this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
1560
1674
|
return;
|
|
1561
1675
|
}
|
|
@@ -1598,7 +1712,7 @@ class Bt {
|
|
|
1598
1712
|
return { ...this.bounds };
|
|
1599
1713
|
}
|
|
1600
1714
|
getStats() {
|
|
1601
|
-
return
|
|
1715
|
+
return lr(this.stats);
|
|
1602
1716
|
}
|
|
1603
1717
|
getZoomRatio() {
|
|
1604
1718
|
return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
|
|
@@ -1666,7 +1780,7 @@ class Bt {
|
|
|
1666
1780
|
const i = String(t.type ?? "UNKNOWN").toUpperCase();
|
|
1667
1781
|
this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
|
|
1668
1782
|
const s = this.lookupLayer(t.layer);
|
|
1669
|
-
if (t.isVisible === !1 ||
|
|
1783
|
+
if (t.isVisible === !1 || !Kt(s)) {
|
|
1670
1784
|
this.stats.skipped++;
|
|
1671
1785
|
return;
|
|
1672
1786
|
}
|
|
@@ -1709,8 +1823,8 @@ class Bt {
|
|
|
1709
1823
|
beginStyledPath(t, r = !1) {
|
|
1710
1824
|
const i = this.ctx;
|
|
1711
1825
|
i.save(), i.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
1712
|
-
const s =
|
|
1713
|
-
i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha =
|
|
1826
|
+
const s = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), n = mt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
|
|
1827
|
+
i.strokeStyle = s, i.fillStyle = r ? n : s, i.globalAlpha = A(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
|
|
1714
1828
|
const o = typeof t.lineweight == "number" && t.lineweight > 0 ? t.lineweight : 0;
|
|
1715
1829
|
i.lineWidth = Math.max(1, Math.min(12, o > 0 ? o / 30 : 1)), i.beginPath();
|
|
1716
1830
|
}
|
|
@@ -1735,7 +1849,7 @@ class Bt {
|
|
|
1735
1849
|
drawArc(t) {
|
|
1736
1850
|
const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
|
|
1737
1851
|
if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
|
|
1738
|
-
this.strokeWorldPolyline(t,
|
|
1852
|
+
this.strokeWorldPolyline(t, K(x(r), i, s, n, !0), !1);
|
|
1739
1853
|
}
|
|
1740
1854
|
drawPolyline(t) {
|
|
1741
1855
|
const r = t.vertices ?? t.points;
|
|
@@ -1744,7 +1858,7 @@ class Bt {
|
|
|
1744
1858
|
for (let o = 0; o < n; o++) {
|
|
1745
1859
|
const a = r[o], c = r[(o + 1) % r.length];
|
|
1746
1860
|
if (!m(a) || !m(c)) continue;
|
|
1747
|
-
const h =
|
|
1861
|
+
const h = jt(a, c, Number(a.bulge ?? 0));
|
|
1748
1862
|
s.length > 0 && h.shift(), s.push(...h);
|
|
1749
1863
|
}
|
|
1750
1864
|
this.strokeWorldPolyline(t, s, i);
|
|
@@ -1752,7 +1866,7 @@ class Bt {
|
|
|
1752
1866
|
drawEllipse(t) {
|
|
1753
1867
|
const r = t.center, i = t.majorAxisEndPoint, s = Number(t.axisRatio ?? 1);
|
|
1754
1868
|
if (!m(r) || !m(i)) return this.markSkipped("ELLIPSE");
|
|
1755
|
-
const n =
|
|
1869
|
+
const n = J(r, i, s, Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2)), o = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
|
|
1756
1870
|
this.strokeWorldPolyline(t, n, o);
|
|
1757
1871
|
}
|
|
1758
1872
|
drawPoint(t) {
|
|
@@ -1762,17 +1876,17 @@ class Bt {
|
|
|
1762
1876
|
this.beginStyledPath(t), this.ctx.moveTo(i.x - 3, i.y), this.ctx.lineTo(i.x + 3, i.y), this.ctx.moveTo(i.x, i.y - 3), this.ctx.lineTo(i.x, i.y + 3), this.finishStroke();
|
|
1763
1877
|
}
|
|
1764
1878
|
drawText(t) {
|
|
1765
|
-
const r = t.insertionPoint ?? t.startPoint ?? t.center, i =
|
|
1879
|
+
const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Gt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
|
|
1766
1880
|
if (!m(r) || !i) return this.markSkipped(String(t.type));
|
|
1767
1881
|
this.drawTextAt(t, r, i, s, Number(t.rotation ?? 0));
|
|
1768
1882
|
}
|
|
1769
1883
|
drawInsert(t, r) {
|
|
1770
1884
|
const i = this.lookupBlock(t.blockName ?? t.name);
|
|
1771
1885
|
if (i && r < this.opts.maxInsertDepth) {
|
|
1772
|
-
const a =
|
|
1886
|
+
const a = tt(t, i.basePoint ?? { x: 0, y: 0 });
|
|
1773
1887
|
for (const c of i.entities) {
|
|
1774
|
-
const h =
|
|
1775
|
-
this.drawEntityTracked(
|
|
1888
|
+
const h = Jt(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast });
|
|
1889
|
+
this.drawEntityTracked(et(h, a), r + 1);
|
|
1776
1890
|
}
|
|
1777
1891
|
return;
|
|
1778
1892
|
}
|
|
@@ -1812,7 +1926,7 @@ class Bt {
|
|
|
1812
1926
|
}
|
|
1813
1927
|
this.ctx.closePath();
|
|
1814
1928
|
}
|
|
1815
|
-
this.finishFillStroke(!!
|
|
1929
|
+
this.finishFillStroke(!!mt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
|
|
1816
1930
|
}
|
|
1817
1931
|
drawSpline(t) {
|
|
1818
1932
|
var i;
|
|
@@ -1870,7 +1984,7 @@ class Bt {
|
|
|
1870
1984
|
const o = this.ctx, a = this.worldToScreen(r);
|
|
1871
1985
|
o.save(), o.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), o.translate(a.x, a.y), o.rotate(-n);
|
|
1872
1986
|
const c = Math.max(4, Math.min(256, Math.abs(s) * this.view.scale));
|
|
1873
|
-
o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle =
|
|
1987
|
+
o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = D(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o.globalAlpha = A(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
|
|
1874
1988
|
for (const [h, l] of i.split(/\r?\n/g).entries()) o.fillText(l, 0, h * c * 1.22);
|
|
1875
1989
|
o.restore(), this.stats.drawn++;
|
|
1876
1990
|
}
|
|
@@ -1902,31 +2016,31 @@ class Bt {
|
|
|
1902
2016
|
}
|
|
1903
2017
|
computeBounds(t) {
|
|
1904
2018
|
var i;
|
|
1905
|
-
const r =
|
|
2019
|
+
const r = N();
|
|
1906
2020
|
if ((i = t.pages) != null && i.length)
|
|
1907
2021
|
for (const s of t.pages)
|
|
1908
2022
|
v(r, { x: 0, y: 0 }), v(r, { x: s.width, y: s.height });
|
|
1909
2023
|
for (const s of t.entities) this.includeEntityBounds(r, s, 0);
|
|
1910
|
-
return
|
|
2024
|
+
return $t(r);
|
|
1911
2025
|
}
|
|
1912
2026
|
includeEntityBounds(t, r, i) {
|
|
1913
2027
|
const s = String(r.type ?? "").toUpperCase(), n = r.kind ?? R(s);
|
|
1914
2028
|
if (n === "insert") {
|
|
1915
2029
|
const o = this.lookupBlock(r.blockName ?? r.name);
|
|
1916
2030
|
if (o && i < this.opts.maxInsertDepth) {
|
|
1917
|
-
const a =
|
|
1918
|
-
for (const c of o.entities) this.includeEntityBounds(t,
|
|
2031
|
+
const a = tt(r, o.basePoint ?? { x: 0, y: 0 });
|
|
2032
|
+
for (const c of o.entities) this.includeEntityBounds(t, et(c, a), i + 1);
|
|
1919
2033
|
return;
|
|
1920
2034
|
}
|
|
1921
2035
|
}
|
|
1922
2036
|
if (n === "line")
|
|
1923
2037
|
m(r.startPoint) && v(t, r.startPoint), m(r.endPoint) && v(t, r.endPoint);
|
|
1924
2038
|
else if (n === "circle" || n === "arc")
|
|
1925
|
-
m(r.center) && Number.isFinite(r.radius) &&
|
|
2039
|
+
m(r.center) && Number.isFinite(r.radius) && Vt(t, r.center, Number(r.radius));
|
|
1926
2040
|
else if (n === "polyline" || n === "solid" || n === "spline")
|
|
1927
2041
|
for (const o of [...r.vertices ?? [], ...r.points ?? [], ...r.controlPoints ?? [], ...r.fitPoints ?? []]) m(o) && v(t, o);
|
|
1928
2042
|
else if (n === "ellipse")
|
|
1929
|
-
m(r.center) && m(r.majorAxisEndPoint) &&
|
|
2043
|
+
m(r.center) && m(r.majorAxisEndPoint) && J(r.center, r.majorAxisEndPoint, Number(r.axisRatio ?? 1), Number(r.startAngle ?? 0), Number(r.endAngle ?? Math.PI * 2)).forEach((o) => v(t, o));
|
|
1930
2044
|
else if (n === "path")
|
|
1931
2045
|
for (const o of r.commands ?? []) for (const a of o.points) v(t, a);
|
|
1932
2046
|
else if (n === "hatch")
|
|
@@ -1961,7 +2075,7 @@ class Bt {
|
|
|
1961
2075
|
});
|
|
1962
2076
|
}
|
|
1963
2077
|
}
|
|
1964
|
-
function
|
|
2078
|
+
function lr(e) {
|
|
1965
2079
|
return {
|
|
1966
2080
|
total: e.total,
|
|
1967
2081
|
drawn: e.drawn,
|
|
@@ -1977,7 +2091,7 @@ function Qe(e) {
|
|
|
1977
2091
|
buildElapsedMs: e.buildElapsedMs
|
|
1978
2092
|
};
|
|
1979
2093
|
}
|
|
1980
|
-
const
|
|
2094
|
+
const fr = {
|
|
1981
2095
|
background: "#0b1020",
|
|
1982
2096
|
foreground: "#ffffff",
|
|
1983
2097
|
showUnsupportedMarkers: !1,
|
|
@@ -2000,7 +2114,7 @@ const tr = {
|
|
|
2000
2114
|
preserveDrawingBuffer: !1,
|
|
2001
2115
|
enableSpatialIndex: !0
|
|
2002
2116
|
};
|
|
2003
|
-
class
|
|
2117
|
+
class zt {
|
|
2004
2118
|
constructor(t, r = {}) {
|
|
2005
2119
|
d(this, "canvas");
|
|
2006
2120
|
d(this, "backend", "webgl");
|
|
@@ -2010,7 +2124,7 @@ class Ft {
|
|
|
2010
2124
|
d(this, "imageCache", /* @__PURE__ */ new Map());
|
|
2011
2125
|
d(this, "opts");
|
|
2012
2126
|
d(this, "document");
|
|
2013
|
-
d(this, "bounds",
|
|
2127
|
+
d(this, "bounds", N());
|
|
2014
2128
|
d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
|
|
2015
2129
|
d(this, "fitScale", 1);
|
|
2016
2130
|
d(this, "dpr", 1);
|
|
@@ -2024,30 +2138,30 @@ class Ft {
|
|
|
2024
2138
|
d(this, "rafHandle", 0);
|
|
2025
2139
|
d(this, "onStats");
|
|
2026
2140
|
d(this, "onViewChange");
|
|
2027
|
-
const i =
|
|
2141
|
+
const i = dr(t, r);
|
|
2028
2142
|
if (!i) throw new Error('WebGL is not available. Use renderer: "canvas2d" to force the Canvas2D fallback.');
|
|
2029
|
-
this.canvas = t, this.gl = i, this.program =
|
|
2143
|
+
this.canvas = t, this.gl = i, this.program = ur(i), this.opts = { ...fr, ...r }, this.canvas.classList.add("cad-viewer-canvas", "cad-viewer-webgl-canvas"), this.createOverlayCanvas(), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
|
|
2030
2144
|
}
|
|
2031
2145
|
static isSupported() {
|
|
2032
|
-
return
|
|
2146
|
+
return te();
|
|
2033
2147
|
}
|
|
2034
2148
|
destroy() {
|
|
2035
2149
|
var t, r;
|
|
2036
2150
|
this.eventController.abort(), (t = this.resizeObserver) == null || t.disconnect(), this.cancelScheduledRender(), this.disposeScene(), (r = this.overlayCanvas) == null || r.remove();
|
|
2037
2151
|
}
|
|
2038
2152
|
clear() {
|
|
2039
|
-
this.document = void 0, this.bounds =
|
|
2153
|
+
this.document = void 0, this.bounds = N(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
|
|
2040
2154
|
}
|
|
2041
2155
|
setDocument(t) {
|
|
2042
|
-
this.document = t, this.bounds =
|
|
2043
|
-
const r =
|
|
2044
|
-
this.scene =
|
|
2156
|
+
this.document = t, this.bounds = yr(t, this.opts), this.disposeScene();
|
|
2157
|
+
const r = pr(t, this.opts, this.bounds);
|
|
2158
|
+
this.scene = mr(this.gl, r), this.stats = Cr(this.scene, 0), this.fitToView();
|
|
2045
2159
|
}
|
|
2046
2160
|
getDocument() {
|
|
2047
2161
|
return this.document;
|
|
2048
2162
|
}
|
|
2049
2163
|
setOptions(t) {
|
|
2050
|
-
const r =
|
|
2164
|
+
const r = wr(this.opts, t);
|
|
2051
2165
|
if (this.opts = { ...this.opts, ...t }, r && this.document) {
|
|
2052
2166
|
this.setDocument(this.document);
|
|
2053
2167
|
return;
|
|
@@ -2058,7 +2172,7 @@ class Ft {
|
|
|
2058
2172
|
return { ...this.opts };
|
|
2059
2173
|
}
|
|
2060
2174
|
fitToView(t = 0.92) {
|
|
2061
|
-
if (!
|
|
2175
|
+
if (!O(this.bounds)) {
|
|
2062
2176
|
this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
2063
2177
|
return;
|
|
2064
2178
|
}
|
|
@@ -2101,7 +2215,7 @@ class Ft {
|
|
|
2101
2215
|
return { ...this.bounds };
|
|
2102
2216
|
}
|
|
2103
2217
|
getStats() {
|
|
2104
|
-
return
|
|
2218
|
+
return Pr(this.stats);
|
|
2105
2219
|
}
|
|
2106
2220
|
getZoomRatio() {
|
|
2107
2221
|
return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
|
|
@@ -2128,7 +2242,7 @@ class Ft {
|
|
|
2128
2242
|
var h;
|
|
2129
2243
|
const t = performance.now(), r = this.gl;
|
|
2130
2244
|
r.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
2131
|
-
const i =
|
|
2245
|
+
const i = bt(this.opts.background, [11, 16, 32, 255]);
|
|
2132
2246
|
r.clearColor(i[0] / 255, i[1] / 255, i[2] / 255, i[3] / 255), r.clear(r.COLOR_BUFFER_BIT), r.disable(r.DEPTH_TEST), r.enable(r.BLEND), r.blendFunc(r.SRC_ALPHA, r.ONE_MINUS_SRC_ALPHA);
|
|
2133
2247
|
let s = 0, n = 0;
|
|
2134
2248
|
const o = this.scene, a = this.visibleWorldBounds();
|
|
@@ -2149,7 +2263,7 @@ class Ft {
|
|
|
2149
2263
|
const s = this.gl;
|
|
2150
2264
|
let n = 0, o = 0;
|
|
2151
2265
|
for (const a of t) {
|
|
2152
|
-
if (!
|
|
2266
|
+
if (!lt(a.bounds, i)) {
|
|
2153
2267
|
o += a.primitiveCount;
|
|
2154
2268
|
continue;
|
|
2155
2269
|
}
|
|
@@ -2186,7 +2300,7 @@ class Ft {
|
|
|
2186
2300
|
let n = 0;
|
|
2187
2301
|
for (const o of r) {
|
|
2188
2302
|
if (n >= s) break;
|
|
2189
|
-
if (!
|
|
2303
|
+
if (!lt(o.bounds, i)) continue;
|
|
2190
2304
|
const a = Math.abs(o.height) * this.view.scale;
|
|
2191
2305
|
if (a < this.opts.textMinPixelHeight) continue;
|
|
2192
2306
|
const c = this.worldToScreen(o.point);
|
|
@@ -2200,7 +2314,7 @@ class Ft {
|
|
|
2200
2314
|
}
|
|
2201
2315
|
drawImagesOverlay(t, r, i) {
|
|
2202
2316
|
for (const s of r) {
|
|
2203
|
-
if (!
|
|
2317
|
+
if (!lt(s.bounds, i)) continue;
|
|
2204
2318
|
const n = this.worldToScreen(s.point), o = this.worldToScreen({ x: s.point.x + s.width, y: s.point.y - s.height }), a = Math.min(n.x, o.x), c = Math.min(n.y, o.y), h = Math.abs(o.x - n.x), l = Math.abs(o.y - n.y);
|
|
2205
2319
|
if (!(h < 1 || l < 1)) {
|
|
2206
2320
|
if (s.source) {
|
|
@@ -2285,12 +2399,12 @@ class Ft {
|
|
|
2285
2399
|
});
|
|
2286
2400
|
}
|
|
2287
2401
|
}
|
|
2288
|
-
function
|
|
2402
|
+
function te() {
|
|
2289
2403
|
if (typeof document > "u") return !1;
|
|
2290
2404
|
const e = document.createElement("canvas");
|
|
2291
2405
|
return !!(e.getContext("webgl2") ?? e.getContext("webgl") ?? e.getContext("experimental-webgl"));
|
|
2292
2406
|
}
|
|
2293
|
-
function
|
|
2407
|
+
function dr(e, t) {
|
|
2294
2408
|
const r = {
|
|
2295
2409
|
alpha: !1,
|
|
2296
2410
|
antialias: t.antialias ?? !0,
|
|
@@ -2301,7 +2415,7 @@ function er(e, t) {
|
|
|
2301
2415
|
};
|
|
2302
2416
|
return e.getContext("webgl2", r) ?? e.getContext("webgl", r) ?? e.getContext("experimental-webgl", r) ?? void 0;
|
|
2303
2417
|
}
|
|
2304
|
-
function
|
|
2418
|
+
function ur(e) {
|
|
2305
2419
|
const t = `
|
|
2306
2420
|
attribute vec2 a_position;
|
|
2307
2421
|
attribute vec4 a_color;
|
|
@@ -2326,7 +2440,7 @@ function rr(e) {
|
|
|
2326
2440
|
void main() {
|
|
2327
2441
|
gl_FragColor = v_color;
|
|
2328
2442
|
}
|
|
2329
|
-
`, i =
|
|
2443
|
+
`, i = _t(e, e.VERTEX_SHADER, t), s = _t(e, e.FRAGMENT_SHADER, r), n = e.createProgram();
|
|
2330
2444
|
if (!n) throw new Error("Failed to create WebGL program.");
|
|
2331
2445
|
if (e.attachShader(n, i), e.attachShader(n, s), e.linkProgram(n), !e.getProgramParameter(n, e.LINK_STATUS)) {
|
|
2332
2446
|
const l = e.getProgramInfoLog(n) ?? "Unknown WebGL program link error.";
|
|
@@ -2345,7 +2459,7 @@ function rr(e) {
|
|
|
2345
2459
|
uPointSize: h
|
|
2346
2460
|
};
|
|
2347
2461
|
}
|
|
2348
|
-
function
|
|
2462
|
+
function _t(e, t, r) {
|
|
2349
2463
|
const i = e.createShader(t);
|
|
2350
2464
|
if (!i) throw new Error("Failed to create WebGL shader.");
|
|
2351
2465
|
if (e.shaderSource(i, r), e.compileShader(i), !e.getShaderParameter(i, e.COMPILE_STATUS)) {
|
|
@@ -2354,10 +2468,10 @@ function Wt(e, t, r) {
|
|
|
2354
2468
|
}
|
|
2355
2469
|
return i;
|
|
2356
2470
|
}
|
|
2357
|
-
function
|
|
2471
|
+
function mr(e, t) {
|
|
2358
2472
|
let r = 0;
|
|
2359
2473
|
const i = (a) => a.map((c) => {
|
|
2360
|
-
const h =
|
|
2474
|
+
const h = Ht(e, c.positions), l = Ht(e, c.colors), f = c.positions.byteLength + c.colors.byteLength;
|
|
2361
2475
|
return r += f, {
|
|
2362
2476
|
positionBuffer: h,
|
|
2363
2477
|
colorBuffer: l,
|
|
@@ -2380,18 +2494,18 @@ function ir(e, t) {
|
|
|
2380
2494
|
buildElapsedMs: t.buildElapsedMs
|
|
2381
2495
|
};
|
|
2382
2496
|
}
|
|
2383
|
-
function
|
|
2497
|
+
function Ht(e, t) {
|
|
2384
2498
|
const r = e.createBuffer();
|
|
2385
2499
|
if (!r) throw new Error("Failed to create WebGL buffer.");
|
|
2386
2500
|
return e.bindBuffer(e.ARRAY_BUFFER, r), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), r;
|
|
2387
2501
|
}
|
|
2388
|
-
function
|
|
2389
|
-
const i = performance.now(), s =
|
|
2502
|
+
function pr(e, t, r) {
|
|
2503
|
+
const i = performance.now(), s = O(r) ? { x: (r.minX + r.maxX) / 2, y: (r.minY + r.maxY) / 2 } : { x: 0, y: 0 }, n = new gr(e, t, r, s);
|
|
2390
2504
|
for (const a of e.entities) n.addEntityTracked(a, 0);
|
|
2391
2505
|
const o = n.finalize();
|
|
2392
2506
|
return o.buildElapsedMs = performance.now() - i, o;
|
|
2393
2507
|
}
|
|
2394
|
-
class
|
|
2508
|
+
class gr {
|
|
2395
2509
|
constructor(t, r, i, s) {
|
|
2396
2510
|
d(this, "lineBuckets", /* @__PURE__ */ new Map());
|
|
2397
2511
|
d(this, "triangleBuckets", /* @__PURE__ */ new Map());
|
|
@@ -2403,7 +2517,7 @@ class nr {
|
|
|
2403
2517
|
d(this, "maxVerticesPerBatch");
|
|
2404
2518
|
d(this, "primitiveCount", 0);
|
|
2405
2519
|
this.document = t, this.opts = r, this.bounds = i, this.origin = s;
|
|
2406
|
-
const n =
|
|
2520
|
+
const n = O(i) ? Math.max(i.maxX - i.minX, i.maxY - i.minY, 1e-9) : 1;
|
|
2407
2521
|
this.tileSize = r.enableSpatialIndex ? n / Math.max(8, r.spatialIndexCellCount) : Number.POSITIVE_INFINITY, this.maxVerticesPerBatch = Math.max(4096, Math.floor(r.maxVerticesPerBatch));
|
|
2408
2522
|
}
|
|
2409
2523
|
addEntityTracked(t, r) {
|
|
@@ -2411,14 +2525,14 @@ class nr {
|
|
|
2411
2525
|
const i = String(t.type ?? "UNKNOWN").toUpperCase();
|
|
2412
2526
|
this.stats.byType[i] = (this.stats.byType[i] ?? 0) + 1;
|
|
2413
2527
|
const s = this.lookupLayer(t.layer);
|
|
2414
|
-
if (t.isVisible === !1 ||
|
|
2528
|
+
if (t.isVisible === !1 || !Kt(s)) {
|
|
2415
2529
|
this.stats.skipped++;
|
|
2416
2530
|
return;
|
|
2417
2531
|
}
|
|
2418
2532
|
this.addEntity(t, i, r);
|
|
2419
2533
|
}
|
|
2420
2534
|
finalize() {
|
|
2421
|
-
const t =
|
|
2535
|
+
const t = ct(this.lineBuckets, this.maxVerticesPerBatch), r = ct(this.triangleBuckets, this.maxVerticesPerBatch), i = ct(this.pointBuckets, this.maxVerticesPerBatch);
|
|
2422
2536
|
return this.stats.primitiveCount = this.primitiveCount, {
|
|
2423
2537
|
origin: this.origin,
|
|
2424
2538
|
lineBatches: t,
|
|
@@ -2472,13 +2586,13 @@ class nr {
|
|
|
2472
2586
|
addCircleEntity(t) {
|
|
2473
2587
|
const r = t.center, i = Number(t.radius);
|
|
2474
2588
|
if (!m(r) || !Number.isFinite(i)) return this.markSkipped("CIRCLE");
|
|
2475
|
-
const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n =
|
|
2589
|
+
const s = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(i)) * 12))), n = K(r, i, 0, Math.PI * 2, !0, s);
|
|
2476
2590
|
this.addPolyline(n, !0, this.strokeBytes(t)), this.stats.drawn++;
|
|
2477
2591
|
}
|
|
2478
2592
|
addArcEntity(t) {
|
|
2479
2593
|
const r = t.center, i = Number(t.radius), s = Number(t.startAngle), n = Number(t.endAngle);
|
|
2480
2594
|
if (!m(r) || !Number.isFinite(i) || !Number.isFinite(s) || !Number.isFinite(n)) return this.markSkipped("ARC");
|
|
2481
|
-
this.addPolyline(
|
|
2595
|
+
this.addPolyline(K(r, i, s, n, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t)), this.stats.drawn++;
|
|
2482
2596
|
}
|
|
2483
2597
|
addPolylineEntity(t) {
|
|
2484
2598
|
const r = t.vertices ?? t.points;
|
|
@@ -2487,7 +2601,7 @@ class nr {
|
|
|
2487
2601
|
for (let o = 0; o < n; o++) {
|
|
2488
2602
|
const a = r[o], c = r[(o + 1) % r.length];
|
|
2489
2603
|
if (!m(a) || !m(c)) continue;
|
|
2490
|
-
const h =
|
|
2604
|
+
const h = jt(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
|
|
2491
2605
|
s.length > 0 && h.shift(), s.push(...h);
|
|
2492
2606
|
}
|
|
2493
2607
|
if (s.length < 2) return this.markSkipped(String(t.type));
|
|
@@ -2495,11 +2609,11 @@ class nr {
|
|
|
2495
2609
|
}
|
|
2496
2610
|
addEllipseEntity(t) {
|
|
2497
2611
|
if (!m(t.center) || !m(t.majorAxisEndPoint)) return this.markSkipped("ELLIPSE");
|
|
2498
|
-
const r =
|
|
2612
|
+
const r = J(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), i = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
|
|
2499
2613
|
this.addPolyline(r, i, this.strokeBytes(t)), this.stats.drawn++;
|
|
2500
2614
|
}
|
|
2501
2615
|
addTextEntity(t) {
|
|
2502
|
-
const r = t.insertionPoint ?? t.startPoint ?? t.center, i =
|
|
2616
|
+
const r = t.insertionPoint ?? t.startPoint ?? t.center, i = Gt(String(t.text ?? t.value ?? "")), s = Number(t.textHeight ?? t.height ?? 1);
|
|
2503
2617
|
if (!m(r) || !i || !Number.isFinite(s)) return this.markSkipped(String(t.type));
|
|
2504
2618
|
const n = x(r), o = Math.max(1, i.split(/\r?\n/g).reduce((c, h) => Math.max(c, h.length), 0)) * Math.abs(s) * 0.62, a = Math.max(1, i.split(/\r?\n/g).length) * Math.abs(s) * 1.22;
|
|
2505
2619
|
this.textItems.push({
|
|
@@ -2507,8 +2621,8 @@ class nr {
|
|
|
2507
2621
|
text: i,
|
|
2508
2622
|
height: s,
|
|
2509
2623
|
rotation: Number(t.rotation ?? 0),
|
|
2510
|
-
color:
|
|
2511
|
-
opacity:
|
|
2624
|
+
color: D(t, this.document, this.colorOptions()),
|
|
2625
|
+
opacity: A(Number(t.opacity ?? 1), 0, 1),
|
|
2512
2626
|
bounds: { minX: n.x - o * 0.1, minY: n.y - a, maxX: n.x + o, maxY: n.y + a }
|
|
2513
2627
|
}), this.stats.drawn++;
|
|
2514
2628
|
}
|
|
@@ -2520,10 +2634,10 @@ class nr {
|
|
|
2520
2634
|
addInsertEntity(t, r) {
|
|
2521
2635
|
const i = this.lookupBlock(t.blockName ?? t.name);
|
|
2522
2636
|
if (i && r < this.opts.maxInsertDepth) {
|
|
2523
|
-
const n =
|
|
2637
|
+
const n = tt(t, i.basePoint ?? { x: 0, y: 0 });
|
|
2524
2638
|
for (const o of i.entities) {
|
|
2525
|
-
const a =
|
|
2526
|
-
this.addEntityTracked(
|
|
2639
|
+
const a = Jt(o, t, this.document, this.colorOptions());
|
|
2640
|
+
this.addEntityTracked(et(a, n), r + 1);
|
|
2527
2641
|
}
|
|
2528
2642
|
return;
|
|
2529
2643
|
}
|
|
@@ -2547,7 +2661,7 @@ class nr {
|
|
|
2547
2661
|
const i = this.strokeBytes(t), s = this.fillBytes(t);
|
|
2548
2662
|
let n = !1;
|
|
2549
2663
|
for (const a of r) {
|
|
2550
|
-
const c = (o = a.commands) != null && o.length ?
|
|
2664
|
+
const c = (o = a.commands) != null && o.length ? Yt(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(m).map(x);
|
|
2551
2665
|
c.length < 2 || (this.addPolyline(c, !0, i), s && c.length >= 3 && this.addTriangleFan(c, s), n = !0);
|
|
2552
2666
|
}
|
|
2553
2667
|
if (!n) return this.markSkipped("HATCH");
|
|
@@ -2562,7 +2676,7 @@ class nr {
|
|
|
2562
2676
|
addPathEntity(t) {
|
|
2563
2677
|
var s;
|
|
2564
2678
|
if (!((s = t.commands) != null && s.length)) return this.markSkipped(String(t.type));
|
|
2565
|
-
const r =
|
|
2679
|
+
const r = Yt(t.commands, this.opts.maxCurveSegments);
|
|
2566
2680
|
if (r.length < 2) return this.markSkipped(String(t.type));
|
|
2567
2681
|
this.addPolyline(r, !1, this.strokeBytes(t));
|
|
2568
2682
|
const i = this.fillBytes(t);
|
|
@@ -2573,11 +2687,11 @@ class nr {
|
|
|
2573
2687
|
if (!m(r)) return this.markSkipped(String(t.type));
|
|
2574
2688
|
const i = Number(t.width ?? 32), s = Number(t.height ?? 32);
|
|
2575
2689
|
if (!Number.isFinite(i) || !Number.isFinite(s)) return this.markSkipped(String(t.type));
|
|
2576
|
-
const n = x(r), o =
|
|
2577
|
-
this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color:
|
|
2690
|
+
const n = x(r), o = ht([n, { x: n.x + i, y: n.y - s }]);
|
|
2691
|
+
this.imageItems.push({ point: n, width: i, height: s, source: t.imageDataUrl ?? t.imageSource, color: D(t, this.document, this.colorOptions()), opacity: A(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
|
|
2578
2692
|
}
|
|
2579
2693
|
addUnsupportedMarker(t) {
|
|
2580
|
-
const r =
|
|
2694
|
+
const r = ee(t);
|
|
2581
2695
|
r && this.addPoint(r, this.strokeBytes(t));
|
|
2582
2696
|
}
|
|
2583
2697
|
addPolyline(t, r, i) {
|
|
@@ -2589,24 +2703,24 @@ class nr {
|
|
|
2589
2703
|
}
|
|
2590
2704
|
addSegment(t, r, i) {
|
|
2591
2705
|
if (!m(t) || !m(r) || Math.hypot(t.x - r.x, t.y - r.y) <= 1e-14) return;
|
|
2592
|
-
const s = this.batchFor(this.lineBuckets,
|
|
2593
|
-
|
|
2706
|
+
const s = this.batchFor(this.lineBuckets, ht([t, r]));
|
|
2707
|
+
T(s, t, i, this.origin), T(s, r, i, this.origin), s.primitiveCount++, this.primitiveCount++;
|
|
2594
2708
|
}
|
|
2595
2709
|
addPoint(t, r) {
|
|
2596
|
-
const i = this.batchFor(this.pointBuckets,
|
|
2597
|
-
|
|
2710
|
+
const i = this.batchFor(this.pointBuckets, xr(t));
|
|
2711
|
+
T(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
|
|
2598
2712
|
}
|
|
2599
2713
|
addTriangleFan(t, r) {
|
|
2600
2714
|
const i = t.filter(m).map(x);
|
|
2601
2715
|
if (i.length < 3) return;
|
|
2602
|
-
const s =
|
|
2716
|
+
const s = ht(i), n = this.batchFor(this.triangleBuckets, s);
|
|
2603
2717
|
for (let o = 1; o < i.length - 1; o++)
|
|
2604
|
-
|
|
2718
|
+
T(n, i[0], r, this.origin), T(n, i[o], r, this.origin), T(n, i[o + 1], r, this.origin), n.primitiveCount++, this.primitiveCount++;
|
|
2605
2719
|
}
|
|
2606
2720
|
batchFor(t, r) {
|
|
2607
2721
|
const i = this.bucketKey(r);
|
|
2608
2722
|
let s = t.get(i);
|
|
2609
|
-
return s || (s =
|
|
2723
|
+
return s || (s = br(), t.set(i, s)), v(s.bounds, { x: r.minX, y: r.minY }), v(s.bounds, { x: r.maxX, y: r.maxY }), s;
|
|
2610
2724
|
}
|
|
2611
2725
|
bucketKey(t) {
|
|
2612
2726
|
if (!Number.isFinite(this.tileSize)) return "all";
|
|
@@ -2614,11 +2728,11 @@ class nr {
|
|
|
2614
2728
|
return `${s}:${n}`;
|
|
2615
2729
|
}
|
|
2616
2730
|
strokeBytes(t) {
|
|
2617
|
-
return
|
|
2731
|
+
return bt(D(t, this.document, this.colorOptions()), [255, 255, 255, 255], A(Number(t.opacity ?? 1), 0, 1));
|
|
2618
2732
|
}
|
|
2619
2733
|
fillBytes(t) {
|
|
2620
|
-
const r =
|
|
2621
|
-
return r ?
|
|
2734
|
+
const r = mt(t, this.document, this.colorOptions());
|
|
2735
|
+
return r ? bt(r, [255, 255, 255, 255], A(Number(t.opacity ?? 1), 0, 1)) : void 0;
|
|
2622
2736
|
}
|
|
2623
2737
|
colorOptions() {
|
|
2624
2738
|
return { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast };
|
|
@@ -2635,37 +2749,37 @@ class nr {
|
|
|
2635
2749
|
return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((r) => r.name.toLowerCase() === t.toLowerCase());
|
|
2636
2750
|
}
|
|
2637
2751
|
}
|
|
2638
|
-
function
|
|
2639
|
-
return { positions: [], colors: [], bounds:
|
|
2752
|
+
function br() {
|
|
2753
|
+
return { positions: [], colors: [], bounds: N(), primitiveCount: 0 };
|
|
2640
2754
|
}
|
|
2641
|
-
function
|
|
2755
|
+
function T(e, t, r, i) {
|
|
2642
2756
|
e.positions.push(t.x - i.x, t.y - i.y), e.colors.push(r[0], r[1], r[2], r[3]);
|
|
2643
2757
|
}
|
|
2644
|
-
function
|
|
2758
|
+
function ct(e, t) {
|
|
2645
2759
|
const r = [];
|
|
2646
2760
|
for (const i of e.values()) {
|
|
2647
2761
|
const s = i.positions.length / 2;
|
|
2648
|
-
if (s <= 0 || !
|
|
2762
|
+
if (s <= 0 || !O(i.bounds)) continue;
|
|
2649
2763
|
if (s <= t) {
|
|
2650
2764
|
r.push({ positions: new Float32Array(i.positions), colors: new Uint8Array(i.colors), bounds: { ...i.bounds }, primitiveCount: i.primitiveCount });
|
|
2651
2765
|
continue;
|
|
2652
2766
|
}
|
|
2653
|
-
const n =
|
|
2767
|
+
const n = vr(i), o = Math.max(n, Math.floor(t / n) * n);
|
|
2654
2768
|
for (let a = 0; a < s; a += o) {
|
|
2655
|
-
const c = Math.min(s, a + o), h = i.positions.slice(a * 2, c * 2), l = i.colors.slice(a * 4, c * 4), f =
|
|
2769
|
+
const c = Math.min(s, a + o), h = i.positions.slice(a * 2, c * 2), l = i.colors.slice(a * 4, c * 4), f = N();
|
|
2656
2770
|
for (let u = 0; u < h.length; u += 2) v(f, { x: h[u], y: h[u + 1] });
|
|
2657
2771
|
r.push({ positions: new Float32Array(h), colors: new Uint8Array(l), bounds: { ...i.bounds }, primitiveCount: Math.floor((c - a) / n) });
|
|
2658
2772
|
}
|
|
2659
2773
|
}
|
|
2660
2774
|
return r;
|
|
2661
2775
|
}
|
|
2662
|
-
function
|
|
2776
|
+
function vr(e) {
|
|
2663
2777
|
const t = e.positions.length / 2;
|
|
2664
2778
|
return t === e.primitiveCount ? 1 : t === e.primitiveCount * 3 ? 3 : 2;
|
|
2665
2779
|
}
|
|
2666
|
-
function
|
|
2780
|
+
function yr(e, t) {
|
|
2667
2781
|
var n;
|
|
2668
|
-
const r =
|
|
2782
|
+
const r = N();
|
|
2669
2783
|
if ((n = e.pages) != null && n.length)
|
|
2670
2784
|
for (const o of e.pages)
|
|
2671
2785
|
v(r, { x: 0, y: 0 }), v(r, { x: o.width, y: o.height });
|
|
@@ -2677,19 +2791,19 @@ function cr(e, t) {
|
|
|
2677
2791
|
if (h === "insert") {
|
|
2678
2792
|
const l = i(o.blockName ?? o.name);
|
|
2679
2793
|
if (l && a < t.maxInsertDepth) {
|
|
2680
|
-
const f =
|
|
2681
|
-
for (const u of l.entities) s(
|
|
2794
|
+
const f = tt(o, l.basePoint ?? { x: 0, y: 0 });
|
|
2795
|
+
for (const u of l.entities) s(et(u, f), a + 1);
|
|
2682
2796
|
return;
|
|
2683
2797
|
}
|
|
2684
2798
|
}
|
|
2685
2799
|
if (h === "line")
|
|
2686
2800
|
m(o.startPoint) && v(r, o.startPoint), m(o.endPoint) && v(r, o.endPoint);
|
|
2687
2801
|
else if (h === "circle" || h === "arc")
|
|
2688
|
-
m(o.center) && Number.isFinite(o.radius) &&
|
|
2802
|
+
m(o.center) && Number.isFinite(o.radius) && Vt(r, o.center, Number(o.radius));
|
|
2689
2803
|
else if (h === "polyline" || h === "solid" || h === "spline")
|
|
2690
2804
|
for (const l of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(l) && v(r, l);
|
|
2691
2805
|
else if (h === "ellipse")
|
|
2692
|
-
m(o.center) && m(o.majorAxisEndPoint) &&
|
|
2806
|
+
m(o.center) && m(o.majorAxisEndPoint) && J(o.center, o.majorAxisEndPoint, Number(o.axisRatio ?? 1), Number(o.startAngle ?? 0), Number(o.endAngle ?? Math.PI * 2), t.maxCurveSegments).forEach((l) => v(r, l));
|
|
2693
2807
|
else if (h === "path")
|
|
2694
2808
|
for (const l of o.commands ?? []) for (const f of l.points) v(r, f);
|
|
2695
2809
|
else if (h === "hatch")
|
|
@@ -2698,14 +2812,14 @@ function cr(e, t) {
|
|
|
2698
2812
|
for (const f of l.commands ?? []) for (const u of f.points) v(r, u);
|
|
2699
2813
|
}
|
|
2700
2814
|
else {
|
|
2701
|
-
const l =
|
|
2815
|
+
const l = ee(o);
|
|
2702
2816
|
l && v(r, l);
|
|
2703
2817
|
}
|
|
2704
2818
|
};
|
|
2705
2819
|
for (const o of e.entities) s(o, 0);
|
|
2706
|
-
return
|
|
2820
|
+
return $t(r);
|
|
2707
2821
|
}
|
|
2708
|
-
function
|
|
2822
|
+
function Yt(e, t) {
|
|
2709
2823
|
const r = [];
|
|
2710
2824
|
let i, s;
|
|
2711
2825
|
const n = (o) => {
|
|
@@ -2734,7 +2848,7 @@ function Dt(e, t) {
|
|
|
2734
2848
|
} else o.cmd === "Z" && s && n(s);
|
|
2735
2849
|
return r;
|
|
2736
2850
|
}
|
|
2737
|
-
function
|
|
2851
|
+
function ee(e) {
|
|
2738
2852
|
for (const t of ["startPoint", "insertionPoint", "center", "point", "location"]) {
|
|
2739
2853
|
const r = e[t];
|
|
2740
2854
|
if (m(r)) return x(r);
|
|
@@ -2745,24 +2859,24 @@ function qt(e) {
|
|
|
2745
2859
|
if (t) return x(t.points[0]);
|
|
2746
2860
|
}
|
|
2747
2861
|
}
|
|
2748
|
-
function
|
|
2749
|
-
const t =
|
|
2862
|
+
function ht(e) {
|
|
2863
|
+
const t = N();
|
|
2750
2864
|
for (const r of e) v(t, r);
|
|
2751
2865
|
return t;
|
|
2752
2866
|
}
|
|
2753
|
-
function
|
|
2867
|
+
function xr(e) {
|
|
2754
2868
|
return { minX: e.x, minY: e.y, maxX: e.x, maxY: e.y };
|
|
2755
2869
|
}
|
|
2756
|
-
function
|
|
2870
|
+
function lt(e, t) {
|
|
2757
2871
|
return e.minX <= t.maxX && e.maxX >= t.minX && e.minY <= t.maxY && e.maxY >= t.minY;
|
|
2758
2872
|
}
|
|
2759
|
-
function
|
|
2873
|
+
function wr(e, t) {
|
|
2760
2874
|
return t.trueColorByteOrder !== void 0 && t.trueColorByteOrder !== e.trueColorByteOrder || t.contrastMode !== void 0 && t.contrastMode !== e.contrastMode || t.minColorContrast !== void 0 && t.minColorContrast !== e.minColorContrast || t.foreground !== void 0 && t.foreground !== e.foreground || t.background !== void 0 && t.background !== e.background || t.maxInsertDepth !== void 0 && t.maxInsertDepth !== e.maxInsertDepth || t.maxCurveSegments !== void 0 && t.maxCurveSegments !== e.maxCurveSegments || t.spatialIndexCellCount !== void 0 && t.spatialIndexCellCount !== e.spatialIndexCellCount || t.maxVerticesPerBatch !== void 0 && t.maxVerticesPerBatch !== e.maxVerticesPerBatch || t.enableSpatialIndex !== void 0 && t.enableSpatialIndex !== e.enableSpatialIndex;
|
|
2761
2875
|
}
|
|
2762
|
-
function
|
|
2876
|
+
function Cr(e, t) {
|
|
2763
2877
|
return { ...e.stats, renderElapsedMs: t, backend: "webgl", primitiveCount: e.primitiveCount, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: e.gpuMemoryBytes, buildElapsedMs: e.buildElapsedMs };
|
|
2764
2878
|
}
|
|
2765
|
-
function
|
|
2879
|
+
function Pr(e) {
|
|
2766
2880
|
return {
|
|
2767
2881
|
total: e.total,
|
|
2768
2882
|
drawn: e.drawn,
|
|
@@ -2778,7 +2892,7 @@ function dr(e) {
|
|
|
2778
2892
|
buildElapsedMs: e.buildElapsedMs
|
|
2779
2893
|
};
|
|
2780
2894
|
}
|
|
2781
|
-
function
|
|
2895
|
+
function bt(e, t, r = 1) {
|
|
2782
2896
|
const i = e.trim().toLowerCase();
|
|
2783
2897
|
let s;
|
|
2784
2898
|
if (/^#[0-9a-f]{3}$/i.test(i))
|
|
@@ -2798,7 +2912,7 @@ function mt(e, t, r = 1) {
|
|
|
2798
2912
|
function X(e) {
|
|
2799
2913
|
return Math.max(0, Math.min(255, Math.round(e)));
|
|
2800
2914
|
}
|
|
2801
|
-
class
|
|
2915
|
+
class kr {
|
|
2802
2916
|
constructor(t = {}) {
|
|
2803
2917
|
d(this, "canvas");
|
|
2804
2918
|
d(this, "renderer");
|
|
@@ -2808,7 +2922,7 @@ class ur {
|
|
|
2808
2922
|
d(this, "lastResult");
|
|
2809
2923
|
d(this, "activeNativeLoader");
|
|
2810
2924
|
var r;
|
|
2811
|
-
if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ??
|
|
2925
|
+
if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? qe(t), t.loaders) for (const i of t.loaders) this.registry.register(i);
|
|
2812
2926
|
if (this.canvas = t.canvas ?? document.createElement("canvas"), this.canvas.classList.add("cad-viewer-canvas"), t.container)
|
|
2813
2927
|
t.container.classList.add("cad-viewer-container"), t.canvas || (this.canvas.style.width = "100%", this.canvas.style.height = "100%", this.canvas.style.display = "block", t.container.appendChild(this.canvas)), this.nativeHost = t.nativeHost ?? document.createElement("div"), this.nativeHost.classList.add("cad-viewer-native-host"), t.nativeHost || t.container.appendChild(this.nativeHost);
|
|
2814
2928
|
else if (t.nativeHost)
|
|
@@ -2818,7 +2932,7 @@ class ur {
|
|
|
2818
2932
|
const i = document.createElement("div");
|
|
2819
2933
|
i.classList.add("cad-viewer-native-host"), t.canvas.parentElement.appendChild(i), this.nativeHost = i;
|
|
2820
2934
|
}
|
|
2821
|
-
this.renderer =
|
|
2935
|
+
this.renderer = Nr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (i) => {
|
|
2822
2936
|
var s, n;
|
|
2823
2937
|
return (n = (s = this.options).onRenderStats) == null ? void 0 : n.call(s, i);
|
|
2824
2938
|
}, this.renderer.onViewChange = (i) => {
|
|
@@ -2851,7 +2965,7 @@ class ur {
|
|
|
2851
2965
|
elapsedMs: 0,
|
|
2852
2966
|
format: t.format,
|
|
2853
2967
|
warnings: t.warnings,
|
|
2854
|
-
summary:
|
|
2968
|
+
summary: G(t),
|
|
2855
2969
|
fileName: r
|
|
2856
2970
|
};
|
|
2857
2971
|
return this.renderer.setDocument(t), this.options.autoFit || this.renderer.render(), this.lastResult = i, (n = (s = this.options).onLoad) == null || n.call(s, i), i;
|
|
@@ -2913,14 +3027,14 @@ class ur {
|
|
|
2913
3027
|
var s, n;
|
|
2914
3028
|
try {
|
|
2915
3029
|
const o = this.mergeLoadOptions(r);
|
|
2916
|
-
|
|
3030
|
+
ft(o.signal);
|
|
2917
3031
|
const a = await this.registry.detect(t), c = { ...t, buffer: a.bytes };
|
|
2918
|
-
if (
|
|
3032
|
+
if (Ke(a.loader))
|
|
2919
3033
|
return await this.applyNativeLoadResult(a.loader, c, o, i);
|
|
2920
3034
|
const h = await a.loader.load(c, o);
|
|
2921
3035
|
return this.applyLoadResult(h, i);
|
|
2922
3036
|
} catch (o) {
|
|
2923
|
-
const a =
|
|
3037
|
+
const a = Sr(o);
|
|
2924
3038
|
throw (n = (s = this.options).onError) == null || n.call(s, a), a;
|
|
2925
3039
|
}
|
|
2926
3040
|
}
|
|
@@ -2930,7 +3044,7 @@ class ur {
|
|
|
2930
3044
|
const i = {
|
|
2931
3045
|
...t,
|
|
2932
3046
|
fileName: r,
|
|
2933
|
-
summary:
|
|
3047
|
+
summary: G(t.document)
|
|
2934
3048
|
};
|
|
2935
3049
|
return this.lastResult = i, (a = (o = this.options).onLoad) == null || a.call(o, i), i;
|
|
2936
3050
|
}
|
|
@@ -2938,14 +3052,14 @@ class ur {
|
|
|
2938
3052
|
var n, o, a;
|
|
2939
3053
|
if (!this.nativeHost)
|
|
2940
3054
|
throw new Error("Native DWF rendering requires CadViewerOptions.container, nativeHost, or a canvas parent element.");
|
|
2941
|
-
|
|
3055
|
+
ft(i.signal), this.renderer.clear(), (n = this.activeNativeLoader) == null || n.unmount(), this.activeNativeLoader = t, this.canvas.style.display = "none", this.nativeHost.classList.add("is-active");
|
|
2942
3056
|
try {
|
|
2943
3057
|
const c = await t.mount(r, this.nativeHost, i);
|
|
2944
|
-
|
|
3058
|
+
ft(i.signal);
|
|
2945
3059
|
const h = {
|
|
2946
3060
|
...c,
|
|
2947
3061
|
fileName: s,
|
|
2948
|
-
summary:
|
|
3062
|
+
summary: G(c.document)
|
|
2949
3063
|
};
|
|
2950
3064
|
return this.lastResult = h, this.emitNativeRenderStats(c), (a = (o = this.options).onLoad) == null || a.call(o, h), h;
|
|
2951
3065
|
} catch (c) {
|
|
@@ -2967,7 +3081,7 @@ class ur {
|
|
|
2967
3081
|
total: i,
|
|
2968
3082
|
drawn: i,
|
|
2969
3083
|
skipped: 0,
|
|
2970
|
-
byType:
|
|
3084
|
+
byType: G(t.document).byType,
|
|
2971
3085
|
unsupported: {},
|
|
2972
3086
|
renderElapsedMs: t.elapsedMs,
|
|
2973
3087
|
backend: n,
|
|
@@ -2990,48 +3104,48 @@ class ur {
|
|
|
2990
3104
|
};
|
|
2991
3105
|
}
|
|
2992
3106
|
}
|
|
2993
|
-
function
|
|
2994
|
-
return new
|
|
3107
|
+
function Ir(e = {}) {
|
|
3108
|
+
return new kr(e);
|
|
2995
3109
|
}
|
|
2996
|
-
function
|
|
3110
|
+
function Sr(e) {
|
|
2997
3111
|
return e instanceof Error ? e : new Error(String(e));
|
|
2998
3112
|
}
|
|
2999
|
-
function
|
|
3113
|
+
function ft(e) {
|
|
3000
3114
|
if (e != null && e.aborted)
|
|
3001
3115
|
throw new DOMException("Loading cancelled.", "AbortError");
|
|
3002
3116
|
}
|
|
3003
|
-
function
|
|
3004
|
-
if (e === "canvas2d") return new
|
|
3005
|
-
if (e === "webgl") return new
|
|
3006
|
-
if (
|
|
3117
|
+
function Nr(e, t, r = {}) {
|
|
3118
|
+
if (e === "canvas2d") return new Ot(t, r);
|
|
3119
|
+
if (e === "webgl") return new zt(t, r);
|
|
3120
|
+
if (te())
|
|
3007
3121
|
try {
|
|
3008
|
-
return new
|
|
3122
|
+
return new zt(t, r);
|
|
3009
3123
|
} catch {
|
|
3010
3124
|
}
|
|
3011
|
-
return new
|
|
3125
|
+
return new Ot(t, r);
|
|
3012
3126
|
}
|
|
3013
3127
|
export {
|
|
3014
|
-
|
|
3015
|
-
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3128
|
+
Ot as CadCanvasRenderer,
|
|
3129
|
+
ae as CadLoaderRegistry,
|
|
3130
|
+
kr as CadViewer,
|
|
3131
|
+
zt as CadWebGLRenderer,
|
|
3132
|
+
ze as DwfLoader,
|
|
3133
|
+
me as DwgLoader,
|
|
3134
|
+
he as DwgWorkerClient,
|
|
3135
|
+
xe as DxfLoader,
|
|
3136
|
+
E as colorFromAci,
|
|
3137
|
+
V as colorFromTrueColor,
|
|
3138
|
+
Ut as createCadDocument,
|
|
3139
|
+
Ir as createCadViewer,
|
|
3140
|
+
qe as createDefaultLoaderRegistry,
|
|
3141
|
+
B as detectCadFormat,
|
|
3028
3142
|
R as inferEntityKind,
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3143
|
+
Ke as isCadNativeRenderableLoader,
|
|
3144
|
+
te as isWebGLAvailable,
|
|
3145
|
+
be as normalizeCadEntity,
|
|
3146
|
+
U as readInputBytes,
|
|
3147
|
+
D as resolveCadColor,
|
|
3148
|
+
G as summarizeCadDocument,
|
|
3149
|
+
dt as supportsDwgWorker
|
|
3036
3150
|
};
|
|
3037
3151
|
//# sourceMappingURL=cad-viewer.es.js.map
|