@flyfish-dev/cad-viewer 0.6.4 → 0.6.6
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 +25 -2
- package/README.zh-CN.md +25 -2
- package/dist/cad-viewer.es.js +1824 -1378
- package/dist/cad-viewer.es.js.map +1 -1
- package/dist/cad-viewer.umd.cjs +7 -7
- package/dist/cad-viewer.umd.cjs.map +1 -1
- package/dist/types/core/bounds.d.ts +9 -0
- package/dist/types/core/bounds.d.ts.map +1 -0
- package/dist/types/core/entity.d.ts +3 -1
- package/dist/types/core/entity.d.ts.map +1 -1
- package/dist/types/core/linetype.d.ts +32 -0
- package/dist/types/core/linetype.d.ts.map +1 -0
- package/dist/types/core/scene.d.ts +8 -0
- package/dist/types/core/scene.d.ts.map +1 -0
- package/dist/types/core/transform.d.ts.map +1 -1
- package/dist/types/core/types.d.ts +48 -0
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +8 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/loaders/dwg/DwgParser.d.ts.map +1 -1
- package/dist/types/viewer/CadCanvasRenderer.d.ts +7 -4
- package/dist/types/viewer/CadCanvasRenderer.d.ts.map +1 -1
- package/dist/types/viewer/CadViewer.d.ts +3 -2
- package/dist/types/viewer/CadViewer.d.ts.map +1 -1
- package/dist/types/viewer/CadWebGLRenderer.d.ts +5 -2
- package/dist/types/viewer/CadWebGLRenderer.d.ts.map +1 -1
- package/dist/wasm/dwg-worker.js +8 -8
- package/dist/wasm/dwg-worker.js.map +1 -1
- package/package.json +4 -2
package/dist/cad-viewer.es.js
CHANGED
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (e, t,
|
|
4
|
-
import { openDwfDocument as
|
|
5
|
-
async function
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var Le = (e, t, n) => t in e ? Te(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var d = (e, t, n) => Le(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { openDwfDocument as Ae, DwfViewer as Be } from "dwf-viewer";
|
|
5
|
+
async function K(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 Fe(e) {
|
|
12
12
|
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
13
13
|
}
|
|
14
|
-
function
|
|
15
|
-
var
|
|
16
|
-
const t = e.fileName ?? ((
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
if (
|
|
23
|
-
if (
|
|
24
|
-
if (
|
|
25
|
-
if (
|
|
14
|
+
function z(e) {
|
|
15
|
+
var r;
|
|
16
|
+
const t = e.fileName ?? ((r = e.file) == null ? void 0 : r.name) ?? "", n = t.lastIndexOf(".");
|
|
17
|
+
return n >= 0 ? t.slice(n + 1).toLowerCase() : "";
|
|
18
|
+
}
|
|
19
|
+
function Y(e, t) {
|
|
20
|
+
const n = z(e);
|
|
21
|
+
if (n === "dwg") return "dwg";
|
|
22
|
+
if (n === "dxf") return "dxf";
|
|
23
|
+
if (n === "dwfx") return "dwfx";
|
|
24
|
+
if (n === "xps") return "xps";
|
|
25
|
+
if (n === "dwf") return "dwf";
|
|
26
26
|
if (t && t.byteLength >= 6) {
|
|
27
|
-
const
|
|
28
|
-
if (/^AC10/.test(
|
|
27
|
+
const r = Wt(t.slice(0, 6));
|
|
28
|
+
if (/^AC10/.test(r)) return "dwg";
|
|
29
29
|
if (t[0] === 80 && t[1] === 75) return "dwfx";
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
32
|
-
if (
|
|
30
|
+
const i = Wt(t.slice(0, Math.min(t.byteLength, 2048))).toUpperCase();
|
|
31
|
+
if (i.includes("SECTION") && i.includes("ENTITIES")) return "dxf";
|
|
32
|
+
if (i.includes("DWF")) return "dwf";
|
|
33
33
|
}
|
|
34
34
|
return "unknown";
|
|
35
35
|
}
|
|
36
|
-
function
|
|
36
|
+
function Wt(e) {
|
|
37
37
|
return Array.from(e, (t) => t >= 32 && t <= 126 ? String.fromCharCode(t) : " ").join("");
|
|
38
38
|
}
|
|
39
|
-
class
|
|
39
|
+
class De {
|
|
40
40
|
constructor(t = []) {
|
|
41
41
|
d(this, "loaders", []);
|
|
42
|
-
for (const
|
|
42
|
+
for (const n of t) this.register(n);
|
|
43
43
|
}
|
|
44
44
|
register(t) {
|
|
45
|
-
const
|
|
46
|
-
return
|
|
45
|
+
const n = this.loaders.findIndex((r) => r.id === t.id);
|
|
46
|
+
return n >= 0 ? this.loaders.splice(n, 1, t) : this.loaders.push(t), this;
|
|
47
47
|
}
|
|
48
48
|
unregister(t) {
|
|
49
|
-
const
|
|
50
|
-
return
|
|
49
|
+
const n = this.loaders.findIndex((r) => r.id === t);
|
|
50
|
+
return n >= 0 && this.loaders.splice(n, 1), this;
|
|
51
51
|
}
|
|
52
52
|
list() {
|
|
53
53
|
return [...this.loaders];
|
|
54
54
|
}
|
|
55
55
|
async detect(t) {
|
|
56
|
-
const
|
|
57
|
-
if (
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
throw new Error(`No CAD loader registered for ${
|
|
56
|
+
const n = await K(t), r = Y(t, n), i = this.loaders.find((o) => o.formats.includes(r) && o.accepts(t, n));
|
|
57
|
+
if (i) return { loader: i, bytes: n, format: r };
|
|
58
|
+
const s = this.loaders.find((o) => o.accepts(t, n));
|
|
59
|
+
if (s) return { loader: s, bytes: n, format: r };
|
|
60
|
+
throw new Error(`No CAD loader registered for ${r === "unknown" ? "this file" : r.toUpperCase()}.`);
|
|
61
61
|
}
|
|
62
|
-
async load(t,
|
|
63
|
-
const { loader:
|
|
64
|
-
return
|
|
62
|
+
async load(t, n = {}) {
|
|
63
|
+
const { loader: r, bytes: i } = await this.detect(t);
|
|
64
|
+
return r.load({ ...t, buffer: i }, n);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
const
|
|
68
|
-
class
|
|
67
|
+
const Re = "wasm/dwg-worker.js";
|
|
68
|
+
class Oe {
|
|
69
69
|
constructor() {
|
|
70
70
|
d(this, "worker");
|
|
71
71
|
d(this, "sequence", 0);
|
|
72
72
|
d(this, "pending", /* @__PURE__ */ new Map());
|
|
73
73
|
}
|
|
74
|
-
load(t,
|
|
75
|
-
var
|
|
76
|
-
if (!
|
|
77
|
-
const
|
|
78
|
-
return (
|
|
79
|
-
var
|
|
80
|
-
if ((
|
|
81
|
-
|
|
74
|
+
load(t, n, r = {}) {
|
|
75
|
+
var l, h;
|
|
76
|
+
if (!xt()) throw new Error("Web Worker is not available in this runtime.");
|
|
77
|
+
const i = this.ensureWorker(r), s = ++this.sequence, o = Math.max(0, Number(r.workerTimeoutMs ?? 0)), a = r.fileName ?? n.fileName ?? ((l = n.file) == null ? void 0 : l.name), c = _e(t, n, r);
|
|
78
|
+
return (h = r.onProgress) == null || h.call(r, { phase: "worker-start", format: "dwg", message: "Dispatching DWG parse to worker…", total: t.byteLength }), new Promise((u, f) => {
|
|
79
|
+
var p;
|
|
80
|
+
if ((p = r.signal) != null && p.aborted) {
|
|
81
|
+
f(rt());
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
85
|
-
o > 0 && (
|
|
86
|
-
this.pending.delete(
|
|
87
|
-
}, o)),
|
|
88
|
-
this.pending.delete(
|
|
89
|
-
},
|
|
84
|
+
const m = { resolve: u, reject: f, onProgress: r.onProgress, signal: r.signal };
|
|
85
|
+
o > 0 && (m.timer = setTimeout(() => {
|
|
86
|
+
this.pending.delete(s), this.resetWorker(), f(new Error(`DWG worker timed out after ${o} ms.`));
|
|
87
|
+
}, o)), r.signal && (m.abortHandler = () => {
|
|
88
|
+
this.pending.delete(s), this.resetWorker(), f(rt());
|
|
89
|
+
}, r.signal.addEventListener("abort", m.abortHandler, { once: !0 })), this.pending.set(s, m);
|
|
90
90
|
try {
|
|
91
|
-
|
|
91
|
+
i.postMessage({
|
|
92
92
|
type: "load",
|
|
93
|
-
requestId:
|
|
93
|
+
requestId: s,
|
|
94
94
|
bytes: c,
|
|
95
95
|
fileName: a,
|
|
96
|
-
options:
|
|
96
|
+
options: _t(r)
|
|
97
97
|
}, [c]);
|
|
98
|
-
} catch (
|
|
99
|
-
this.pending.delete(
|
|
98
|
+
} catch (C) {
|
|
99
|
+
this.pending.delete(s), nt(m), f(C instanceof Error ? C : new Error(String(C)));
|
|
100
100
|
}
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
103
|
preload(t = {}) {
|
|
104
|
-
var
|
|
105
|
-
if (!
|
|
106
|
-
const
|
|
107
|
-
return (
|
|
108
|
-
var
|
|
109
|
-
if ((
|
|
110
|
-
a(
|
|
104
|
+
var s;
|
|
105
|
+
if (!xt()) return Promise.reject(new Error("Web Worker is not available in this runtime."));
|
|
106
|
+
const n = this.ensureWorker(t), r = ++this.sequence, i = Math.max(0, Number(t.workerTimeoutMs ?? 0));
|
|
107
|
+
return (s = t.onProgress) == null || s.call(t, { phase: "worker-start", format: "dwg", message: "Starting DWG worker warmup…" }), new Promise((o, a) => {
|
|
108
|
+
var l;
|
|
109
|
+
if ((l = t.signal) != null && l.aborted) {
|
|
110
|
+
a(rt());
|
|
111
111
|
return;
|
|
112
112
|
}
|
|
113
113
|
const c = {
|
|
@@ -116,15 +116,15 @@ class he {
|
|
|
116
116
|
onProgress: t.onProgress,
|
|
117
117
|
signal: t.signal
|
|
118
118
|
};
|
|
119
|
-
|
|
120
|
-
this.pending.delete(
|
|
121
|
-
},
|
|
122
|
-
this.pending.delete(
|
|
123
|
-
}, t.signal.addEventListener("abort", c.abortHandler, { once: !0 })), this.pending.set(
|
|
119
|
+
i > 0 && (c.timer = setTimeout(() => {
|
|
120
|
+
this.pending.delete(r), this.resetWorker(), a(new Error(`DWG worker warmup timed out after ${i} ms.`));
|
|
121
|
+
}, i)), t.signal && (c.abortHandler = () => {
|
|
122
|
+
this.pending.delete(r), this.resetWorker(), a(rt());
|
|
123
|
+
}, t.signal.addEventListener("abort", c.abortHandler, { once: !0 })), this.pending.set(r, c);
|
|
124
124
|
try {
|
|
125
|
-
|
|
126
|
-
} catch (
|
|
127
|
-
this.pending.delete(
|
|
125
|
+
n.postMessage({ type: "warmup", requestId: r, options: _t(t) });
|
|
126
|
+
} catch (h) {
|
|
127
|
+
this.pending.delete(r), nt(c), a(h instanceof Error ? h : new Error(String(h)));
|
|
128
128
|
}
|
|
129
129
|
});
|
|
130
130
|
}
|
|
@@ -132,148 +132,150 @@ class he {
|
|
|
132
132
|
this.resetWorker();
|
|
133
133
|
}
|
|
134
134
|
ensureWorker(t) {
|
|
135
|
-
return this.worker || (this.worker =
|
|
136
|
-
const
|
|
137
|
-
this.rejectAll(new Error(
|
|
135
|
+
return this.worker || (this.worker = We(t), this.worker.onmessage = (n) => this.handleMessage(n.data), this.worker.onerror = (n) => {
|
|
136
|
+
const r = n.message || "DWG worker failed.";
|
|
137
|
+
this.rejectAll(new Error(r)), this.resetWorker(!1);
|
|
138
138
|
}, this.worker.onmessageerror = () => {
|
|
139
139
|
this.rejectAll(new Error("DWG worker returned a message that could not be cloned.")), this.resetWorker(!1);
|
|
140
140
|
}), this.worker;
|
|
141
141
|
}
|
|
142
142
|
handleMessage(t) {
|
|
143
|
-
var
|
|
143
|
+
var i, s;
|
|
144
144
|
if (t.type === "ready") return;
|
|
145
|
-
const
|
|
146
|
-
if (!
|
|
145
|
+
const n = this.pending.get(t.requestId);
|
|
146
|
+
if (!n) return;
|
|
147
147
|
if (t.type === "progress") {
|
|
148
|
-
(
|
|
148
|
+
(i = n.onProgress) == null || i.call(n, t.progress);
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
if (this.pending.delete(t.requestId),
|
|
152
|
-
|
|
151
|
+
if (this.pending.delete(t.requestId), nt(n), t.type === "result") {
|
|
152
|
+
n.resolve(t.result);
|
|
153
153
|
return;
|
|
154
154
|
}
|
|
155
155
|
if (t.type === "warmup-result") {
|
|
156
|
-
(
|
|
156
|
+
(s = n.onProgress) == null || s.call(n, { phase: "worker-ready", format: "dwg", message: "DWG worker warmup complete.", percent: 100, elapsedMs: t.elapsedMs }), n.resolve(void 0);
|
|
157
157
|
return;
|
|
158
158
|
}
|
|
159
|
-
const
|
|
160
|
-
|
|
159
|
+
const r = new Error(t.error.message);
|
|
160
|
+
r.name = t.error.name || "DwgWorkerError", t.error.stack && (r.stack = t.error.stack), n.reject(r);
|
|
161
161
|
}
|
|
162
162
|
rejectAll(t) {
|
|
163
|
-
for (const [,
|
|
164
|
-
|
|
163
|
+
for (const [, n] of this.pending)
|
|
164
|
+
nt(n), n.reject(t);
|
|
165
165
|
this.pending.clear();
|
|
166
166
|
}
|
|
167
167
|
resetWorker(t = !0) {
|
|
168
|
-
var
|
|
169
|
-
t && this.rejectAll(new Error("DWG worker was terminated.")), (
|
|
168
|
+
var n;
|
|
169
|
+
t && this.rejectAll(new Error("DWG worker was terminated.")), (n = this.worker) == null || n.terminate(), this.worker = void 0;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
function
|
|
172
|
+
function xt() {
|
|
173
173
|
return typeof Worker < "u" && typeof URL < "u";
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
return e.workerFactory ? e.workerFactory() : new Worker(
|
|
175
|
+
function We(e) {
|
|
176
|
+
return e.workerFactory ? e.workerFactory() : new Worker(Ye(e.workerUrl), { type: "module", name: "lightweight-cad-dwg-loader" });
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function _t(e) {
|
|
179
179
|
return {
|
|
180
180
|
// Resolve the asset directory on the UI thread. Relative paths such as
|
|
181
181
|
// './wasm' must be relative to the document URL, not to the generated
|
|
182
182
|
// worker chunk URL. Otherwise the worker may request /assets/wasm/... and
|
|
183
183
|
// receive the app's HTML fallback instead of libredwg-web.wasm.
|
|
184
|
-
wasmPath:
|
|
184
|
+
wasmPath: ze(e.wasmPath),
|
|
185
185
|
includePaperSpace: e.includePaperSpace,
|
|
186
186
|
maxInsertDepth: e.maxInsertDepth,
|
|
187
187
|
keepRaw: !!e.keepRaw
|
|
188
188
|
};
|
|
189
189
|
}
|
|
190
|
-
function
|
|
191
|
-
return !!t.file ||
|
|
190
|
+
function _e(e, t, n) {
|
|
191
|
+
return !!t.file || n.transferInputBuffer === !0 ? Fe(e) : e.slice().buffer;
|
|
192
192
|
}
|
|
193
|
-
function
|
|
193
|
+
function nt(e) {
|
|
194
194
|
e.timer && clearTimeout(e.timer), e.signal && e.abortHandler && e.signal.removeEventListener("abort", e.abortHandler);
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function rt() {
|
|
197
197
|
if (typeof DOMException < "u") return new DOMException("DWG loading was aborted.", "AbortError");
|
|
198
198
|
const e = new Error("DWG loading was aborted.");
|
|
199
199
|
return e.name = "AbortError", e;
|
|
200
200
|
}
|
|
201
|
-
function
|
|
201
|
+
function ze(e) {
|
|
202
202
|
const t = ((e == null ? void 0 : e.trim()) || "/wasm").replace(/\/+$/, "");
|
|
203
|
-
return t === "" ?
|
|
203
|
+
return t === "" ? zt() : oe(t) ? t : t.startsWith("/") ? `${zt()}${t}` : new URL(t, Et()).href.replace(/\/+$/, "");
|
|
204
204
|
}
|
|
205
|
-
function
|
|
205
|
+
function Ye(e) {
|
|
206
206
|
if (e instanceof URL) return e;
|
|
207
|
-
const t = (e == null ? void 0 : e.trim()) ||
|
|
208
|
-
return
|
|
207
|
+
const t = (e == null ? void 0 : e.trim()) || Re;
|
|
208
|
+
return oe(t) ? t : new URL(t, Et()).href;
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function Et() {
|
|
211
211
|
return typeof document < "u" && document.baseURI ? document.baseURI : typeof location < "u" && location.href ? location.href : "http://localhost/";
|
|
212
212
|
}
|
|
213
|
-
function
|
|
214
|
-
return typeof location < "u" && location.origin ? location.origin : new URL(
|
|
213
|
+
function zt() {
|
|
214
|
+
return typeof location < "u" && location.origin ? location.origin : new URL(Et()).origin;
|
|
215
215
|
}
|
|
216
|
-
function
|
|
216
|
+
function oe(e) {
|
|
217
217
|
return /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
218
218
|
}
|
|
219
|
-
class
|
|
219
|
+
class Xe {
|
|
220
220
|
constructor(t = {}) {
|
|
221
221
|
d(this, "id", "dwg");
|
|
222
222
|
d(this, "label", "DWG / LibreDWG WebAssembly");
|
|
223
223
|
d(this, "formats", ["dwg"]);
|
|
224
224
|
d(this, "defaults");
|
|
225
|
-
d(this, "workerClient", new
|
|
225
|
+
d(this, "workerClient", new Oe());
|
|
226
226
|
this.defaults = { useWorker: !0, ...t };
|
|
227
227
|
}
|
|
228
|
-
accepts(t,
|
|
229
|
-
return
|
|
228
|
+
accepts(t, n) {
|
|
229
|
+
return z(t) === "dwg" ? !0 : Y(t, n) === "dwg";
|
|
230
230
|
}
|
|
231
|
-
async load(t,
|
|
231
|
+
async load(t, n = {}) {
|
|
232
232
|
var o, a;
|
|
233
|
-
const
|
|
234
|
-
(o =
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
233
|
+
const r = { ...this.defaults, ...n };
|
|
234
|
+
(o = r.onProgress) == null || o.call(r, { phase: "read", format: "dwg", message: "Reading DWG bytes…" });
|
|
235
|
+
const i = await K(t), s = t.fileName ?? ((a = t.file) == null ? void 0 : a.name);
|
|
236
|
+
if (r.useWorker === !1)
|
|
237
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.");
|
|
238
|
-
if (!
|
|
238
|
+
if (!xt())
|
|
239
239
|
throw new Error("DWG loading requires Web Worker support in this build. Provide a custom loader for this runtime.");
|
|
240
240
|
try {
|
|
241
|
-
return await this.workerClient.load(
|
|
241
|
+
return await this.workerClient.load(i, t, { ...r, fileName: s });
|
|
242
242
|
} catch (c) {
|
|
243
|
-
throw
|
|
243
|
+
throw Ve(c) ? c : He(c);
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
246
|
terminateWorker() {
|
|
247
247
|
this.workerClient.terminate();
|
|
248
248
|
}
|
|
249
249
|
preload(t = {}) {
|
|
250
|
-
const
|
|
251
|
-
return
|
|
250
|
+
const n = { ...this.defaults, ...t };
|
|
251
|
+
return n.useWorker === !1 ? Promise.reject(new Error("DWG preload requires worker mode in the default viewer.")) : this.workerClient.preload(n);
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function Ve(e) {
|
|
255
255
|
return e instanceof Error && e.name === "AbortError";
|
|
256
256
|
}
|
|
257
|
-
function
|
|
257
|
+
function He(e) {
|
|
258
258
|
const t = e instanceof Error ? e.message : String(e);
|
|
259
259
|
return new Error(`${t} If the worker asset cannot be resolved by your bundler/CDN, pass workerUrl or workerFactory to CadViewer.`);
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function It(e) {
|
|
262
262
|
return {
|
|
263
263
|
format: e.format,
|
|
264
264
|
sourceName: e.sourceName,
|
|
265
265
|
units: e.units,
|
|
266
266
|
header: e.header ?? {},
|
|
267
267
|
layers: e.layers ?? {},
|
|
268
|
+
lineTypes: e.lineTypes ?? {},
|
|
268
269
|
blocks: e.blocks ?? {},
|
|
269
270
|
entities: e.entities ?? [],
|
|
270
271
|
pages: e.pages,
|
|
272
|
+
savedView: e.savedView,
|
|
271
273
|
metadata: e.metadata ?? {},
|
|
272
274
|
warnings: e.warnings ?? [],
|
|
273
275
|
raw: e.raw
|
|
274
276
|
};
|
|
275
277
|
}
|
|
276
|
-
function
|
|
278
|
+
function J(e) {
|
|
277
279
|
switch (String(e ?? "").toUpperCase()) {
|
|
278
280
|
case "LINE":
|
|
279
281
|
return "line";
|
|
@@ -324,47 +326,51 @@ function R(e) {
|
|
|
324
326
|
return "unsupported";
|
|
325
327
|
}
|
|
326
328
|
}
|
|
327
|
-
function
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
const
|
|
331
|
-
s
|
|
332
|
-
const c =
|
|
333
|
-
|
|
334
|
-
const
|
|
335
|
-
|
|
336
|
-
const
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
329
|
+
function Tt(e, t, n = {}) {
|
|
330
|
+
const r = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), i = n.includeUnknownProperties === !1 ? { type: r, kind: J(r) } : { ...e, type: r, kind: J(r) };
|
|
331
|
+
n.keepRaw && (i.raw = e), i.handle = w(e.handle ?? e.id), i.layer = w(e.layer ?? e.layerName), i.lineType = w(e.lineType ?? e.linetype), i.lineTypeScale = b(e.lineTypeScale ?? e.linetypeScale ?? e.ltscale) ?? i.lineTypeScale, i.flag = b(e.flag ?? e.flags) ?? i.flag;
|
|
332
|
+
const s = e.isClosed === !0 || e.closed === !0 || e.shape === !0, o = /^(POLYLINE|POLYLINE_2D|POLYLINE2D|POLYLINE_3D|POLYLINE3D|SPLINE)$/.test(r), a = r === "LWPOLYLINE";
|
|
333
|
+
(s || o && (Number(i.flag ?? 0) & 1) === 1 || a && (Number(i.flag ?? 0) & 512) === 512) && (i.isClosed = !0);
|
|
334
|
+
const c = n.numericColorMode ?? "auto", l = b(e.color), h = b(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
|
|
335
|
+
i.colorIndex = h ?? (c !== "rgb" && l !== void 0 && Math.abs(l) <= 257 ? l : void 0);
|
|
336
|
+
const u = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, f = l !== void 0 && l >= 0 && l <= 16777215 && (c === "rgb" || c === "auto" && Math.abs(l) > 257);
|
|
337
|
+
i.trueColor = u ?? (f ? l : void 0), (typeof e.color == "string" || typeof e.color == "number") && (i.color = e.color), i.colorNumber = b(e.colorNumber) ?? i.colorNumber, i.colorName = w(e.colorName ?? e.color_name) ?? i.colorName, i.fillColor = e.fillColor ?? e.fill_color, i.fillColorIndex = b(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? i.fillColorIndex, i.opacity = b(e.opacity ?? e.alpha) ?? i.opacity, i.lineweight = b(e.lineweight ?? e.lineWeight), i.isVisible = !(e.isVisible === !1 || e.visible === !1), i.startPoint = k(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? i.startPoint, i.endPoint = k(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? i.endPoint, i.center = k(e.center ?? e.centerPoint) ?? i.center, i.insertionPoint = k(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? i.insertionPoint, i.radius = b(e.radius) ?? i.radius, i.startAngle = b(e.startAngle ?? e.start_angle) ?? i.startAngle, i.endAngle = b(e.endAngle ?? e.end_angle) ?? i.endAngle, i.majorAxisEndPoint = k(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? i.majorAxisEndPoint, i.axisRatio = b(e.axisRatio ?? e.ratio) ?? i.axisRatio, i.height = b(e.height ?? e.textHeight) ?? i.height, i.textHeight = b(e.textHeight ?? e.height) ?? i.textHeight, i.rotation = b(e.rotation ?? e.angle) ?? i.rotation, i.text = w(e.text ?? e.value ?? e.string ?? e.contents) ?? i.text, i.name = w(e.name ?? e.blockName) ?? i.name, i.blockName = w(e.blockName ?? e.name) ?? i.blockName;
|
|
338
|
+
const m = ft(e.vertices ?? e.points);
|
|
339
|
+
m.length > 0 && (i.vertices = m);
|
|
340
|
+
const p = ft(e.controlPoints ?? e.control_points);
|
|
341
|
+
p.length > 0 && (i.controlPoints = p);
|
|
342
|
+
const C = ft(e.fitPoints ?? e.fit_points);
|
|
343
|
+
C.length > 0 && (i.fitPoints = C);
|
|
344
|
+
const y = e.attribs ?? e.attributes;
|
|
345
|
+
return Array.isArray(y) && (i.attribs = y.filter((v) => !!v && typeof v == "object").map((v) => Tt(v, void 0, n))), i;
|
|
346
|
+
}
|
|
347
|
+
function k(e) {
|
|
342
348
|
if (!e || typeof e != "object") return;
|
|
343
|
-
const t = e,
|
|
344
|
-
if (!(!Number.isFinite(
|
|
345
|
-
return Number.isFinite(
|
|
349
|
+
const t = e, n = Number(t.x ?? t.X ?? t[0]), r = Number(t.y ?? t.Y ?? t[1]), i = t.z ?? t.Z ?? t[2], s = i === void 0 ? void 0 : Number(i);
|
|
350
|
+
if (!(!Number.isFinite(n) || !Number.isFinite(r)))
|
|
351
|
+
return Number.isFinite(s) ? { x: n, y: r, z: s } : { x: n, y: r };
|
|
346
352
|
}
|
|
347
|
-
function
|
|
353
|
+
function ft(e) {
|
|
348
354
|
if (!Array.isArray(e)) return [];
|
|
349
355
|
const t = [];
|
|
350
|
-
for (const
|
|
351
|
-
const
|
|
352
|
-
if (!
|
|
353
|
-
const
|
|
354
|
-
o !== void 0 && (
|
|
355
|
-
const a =
|
|
356
|
-
a !== void 0 && (
|
|
357
|
-
const c =
|
|
358
|
-
c !== void 0 && (
|
|
356
|
+
for (const n of e) {
|
|
357
|
+
const r = k(n);
|
|
358
|
+
if (!r) continue;
|
|
359
|
+
const i = n, s = r, o = b(i.bulge);
|
|
360
|
+
o !== void 0 && (s.bulge = o);
|
|
361
|
+
const a = b(i.startWidth ?? i.start_width);
|
|
362
|
+
a !== void 0 && (s.startWidth = a);
|
|
363
|
+
const c = b(i.endWidth ?? i.end_width);
|
|
364
|
+
c !== void 0 && (s.endWidth = c), t.push(s);
|
|
359
365
|
}
|
|
360
366
|
return t;
|
|
361
367
|
}
|
|
362
|
-
function
|
|
363
|
-
var
|
|
368
|
+
function it(e) {
|
|
369
|
+
var n;
|
|
364
370
|
const t = {};
|
|
365
|
-
for (const
|
|
366
|
-
const
|
|
367
|
-
t[
|
|
371
|
+
for (const r of e.entities) {
|
|
372
|
+
const i = String(r.type ?? "UNKNOWN").toUpperCase();
|
|
373
|
+
t[i] = (t[i] ?? 0) + 1;
|
|
368
374
|
}
|
|
369
375
|
return {
|
|
370
376
|
format: e.format,
|
|
@@ -372,98 +378,109 @@ function G(e) {
|
|
|
372
378
|
entityCount: e.entities.length,
|
|
373
379
|
layerCount: Object.keys(e.layers).length,
|
|
374
380
|
blockCount: Object.keys(e.blocks).length,
|
|
375
|
-
pageCount: ((
|
|
381
|
+
pageCount: ((n = e.pages) == null ? void 0 : n.length) ?? 0,
|
|
376
382
|
byType: t,
|
|
377
383
|
warnings: [...e.warnings]
|
|
378
384
|
};
|
|
379
385
|
}
|
|
380
|
-
function
|
|
386
|
+
function ae(e) {
|
|
387
|
+
if (e.isClosed === !0) return !0;
|
|
388
|
+
const t = String(e.type ?? "").toUpperCase(), n = Number(e.flag ?? 0);
|
|
389
|
+
return t === "LWPOLYLINE" ? (n & 512) === 512 : /^(POLYLINE|POLYLINE_2D|POLYLINE2D|POLYLINE_3D|POLYLINE3D)$/.test(t) ? (n & 1) === 1 : !1;
|
|
390
|
+
}
|
|
391
|
+
function wt(e, t) {
|
|
381
392
|
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
382
393
|
}
|
|
383
|
-
function
|
|
394
|
+
function ce(e, t) {
|
|
384
395
|
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
385
396
|
}
|
|
386
|
-
function
|
|
387
|
-
|
|
397
|
+
function Ue(e, t) {
|
|
398
|
+
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t, t.handle && (e[t.handle] = t, e[t.handle.toLowerCase()] = t));
|
|
388
399
|
}
|
|
389
|
-
function
|
|
400
|
+
function $e(e) {
|
|
401
|
+
return e != null && e.length ? e.flatMap((t) => t.entities.map((n) => ({ ...n, pageIndex: t.index }))) : [];
|
|
402
|
+
}
|
|
403
|
+
function b(e) {
|
|
390
404
|
const t = Number(e);
|
|
391
405
|
return Number.isFinite(t) ? t : void 0;
|
|
392
406
|
}
|
|
393
|
-
function
|
|
407
|
+
function w(e) {
|
|
394
408
|
if (typeof e != "string" && typeof e != "number") return;
|
|
395
409
|
const t = String(e);
|
|
396
410
|
return t.length > 0 ? t : void 0;
|
|
397
411
|
}
|
|
398
|
-
function
|
|
412
|
+
function L() {
|
|
399
413
|
return { minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
|
|
400
414
|
}
|
|
401
|
-
function
|
|
415
|
+
function I(e) {
|
|
402
416
|
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;
|
|
403
417
|
}
|
|
404
|
-
function
|
|
405
|
-
|
|
418
|
+
function S(e, t) {
|
|
419
|
+
g(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));
|
|
420
|
+
}
|
|
421
|
+
function je(e, t, n) {
|
|
422
|
+
if (!g(t) || !Number.isFinite(n)) return;
|
|
423
|
+
const r = Math.abs(n);
|
|
424
|
+
S(e, { x: t.x - r, y: t.y - r }), S(e, { x: t.x + r, y: t.y + r });
|
|
406
425
|
}
|
|
407
|
-
function
|
|
408
|
-
|
|
409
|
-
const i = Math.abs(r);
|
|
410
|
-
v(e, { x: t.x - i, y: t.y - i }), v(e, { x: t.x + i, y: t.y + i });
|
|
426
|
+
function le(e, t) {
|
|
427
|
+
I(t) && (S(e, { x: t.minX, y: t.minY }), S(e, { x: t.maxX, y: t.maxY }));
|
|
411
428
|
}
|
|
412
|
-
function
|
|
413
|
-
if (!
|
|
414
|
-
const
|
|
415
|
-
return { minX: e.minX -
|
|
429
|
+
function he(e, t = 0.02, n = 1e-6) {
|
|
430
|
+
if (!I(e)) return { minX: -10, minY: -10, maxX: 10, maxY: 10 };
|
|
431
|
+
const r = Math.max((e.maxX - e.minX) * t, n), i = Math.max((e.maxY - e.minY) * t, n);
|
|
432
|
+
return { minX: e.minX - r, minY: e.minY - i, maxX: e.maxX + r, maxY: e.maxY + i };
|
|
416
433
|
}
|
|
417
|
-
function
|
|
434
|
+
function g(e) {
|
|
418
435
|
return !!e && typeof e == "object" && Number.isFinite(e.x) && Number.isFinite(e.y);
|
|
419
436
|
}
|
|
420
|
-
function
|
|
437
|
+
function P(e) {
|
|
421
438
|
return { x: e.x, y: e.y };
|
|
422
439
|
}
|
|
423
|
-
function
|
|
440
|
+
function W(e) {
|
|
424
441
|
return e * Math.PI / 180;
|
|
425
442
|
}
|
|
426
|
-
function
|
|
427
|
-
if (!
|
|
428
|
-
let o =
|
|
443
|
+
function Q(e, t, n, r, i = !0, s = 64) {
|
|
444
|
+
if (!g(e) || !Number.isFinite(t)) return [];
|
|
445
|
+
let o = n, a = r;
|
|
429
446
|
if (!Number.isFinite(o) || !Number.isFinite(a)) return [];
|
|
430
|
-
(Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o =
|
|
431
|
-
const c = a - o,
|
|
432
|
-
for (let
|
|
433
|
-
const
|
|
434
|
-
|
|
447
|
+
(Math.abs(o) > Math.PI * 2 + 1e-6 || Math.abs(a) > Math.PI * 2 + 1e-6) && (o = W(o), a = W(a)), i && a < o && (a += Math.PI * 2), !i && o < a && (o += Math.PI * 2);
|
|
448
|
+
const c = a - o, l = Math.max(8, Math.min(256, Math.ceil(Math.abs(c) / (Math.PI * 2) * s))), h = [];
|
|
449
|
+
for (let u = 0; u <= l; u++) {
|
|
450
|
+
const f = o + c * (u / l);
|
|
451
|
+
h.push({ x: e.x + Math.cos(f) * t, y: e.y + Math.sin(f) * t });
|
|
435
452
|
}
|
|
436
|
-
return
|
|
453
|
+
return h;
|
|
437
454
|
}
|
|
438
|
-
function
|
|
439
|
-
if (!
|
|
455
|
+
function Lt(e, t, n = 1, r = 0, i = Math.PI * 2, s = 96) {
|
|
456
|
+
if (!g(e) || !g(t)) return [];
|
|
440
457
|
const o = Math.hypot(t.x, t.y);
|
|
441
458
|
if (!Number.isFinite(o) || o <= 0) return [];
|
|
442
|
-
const a = o * (Number.isFinite(
|
|
443
|
-
let
|
|
444
|
-
(Math.abs(
|
|
445
|
-
const
|
|
446
|
-
for (let
|
|
447
|
-
const
|
|
448
|
-
|
|
449
|
-
}
|
|
450
|
-
return
|
|
451
|
-
}
|
|
452
|
-
function
|
|
453
|
-
if (!Number.isFinite(
|
|
454
|
-
const
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
return
|
|
459
|
+
const a = o * (Number.isFinite(n) && n > 0 ? n : 1), c = Math.atan2(t.y, t.x);
|
|
460
|
+
let l = Number.isFinite(r) ? r : 0, h = Number.isFinite(i) ? i : Math.PI * 2;
|
|
461
|
+
(Math.abs(l) > Math.PI * 2 + 1e-6 || Math.abs(h) > Math.PI * 2 + 1e-6) && (l = W(l), h = W(h)), h < l && (h += Math.PI * 2);
|
|
462
|
+
const u = Math.max(12, Math.min(256, Math.ceil(Math.abs(h - l) / (Math.PI * 2) * s))), f = [], m = Math.cos(c), p = Math.sin(c);
|
|
463
|
+
for (let C = 0; C <= u; C++) {
|
|
464
|
+
const y = l + (h - l) * (C / u), v = Math.cos(y) * o, N = Math.sin(y) * a;
|
|
465
|
+
f.push({ x: e.x + v * m - N * p, y: e.y + v * p + N * m });
|
|
466
|
+
}
|
|
467
|
+
return f;
|
|
468
|
+
}
|
|
469
|
+
function fe(e, t, n = 0, r = 16) {
|
|
470
|
+
if (!Number.isFinite(n) || Math.abs(n) < 1e-12) return [P(e), P(t)];
|
|
471
|
+
const i = Math.hypot(t.x - e.x, t.y - e.y);
|
|
472
|
+
if (i <= 1e-12) return [P(e), P(t)];
|
|
473
|
+
const s = 4 * Math.atan(n), o = Math.abs(i / (2 * Math.sin(s / 2))), a = { x: (e.x + t.x) / 2, y: (e.y + t.y) / 2 }, c = (t.x - e.x) / i, l = (t.y - e.y) / i, h = n >= 0 ? 1 : -1, u = Math.sqrt(Math.max(o * o - (i / 2) ** 2, 0)), f = { x: a.x - h * l * u, y: a.y + h * c * u }, m = Math.atan2(e.y - f.y, e.x - f.x), p = Math.atan2(t.y - f.y, t.x - f.x);
|
|
474
|
+
return Q(f, o, m, p, n >= 0, r);
|
|
458
475
|
}
|
|
459
|
-
function
|
|
476
|
+
function ue(e) {
|
|
460
477
|
return e.replace(/\\P/g, `
|
|
461
478
|
`).replace(/\\~|\\ /g, " ").replace(/\\[A-Za-z][^;]*;/g, "").replace(/[{}]/g, "").replace(/\\[A-Za-z]/g, "").trim();
|
|
462
479
|
}
|
|
463
|
-
function
|
|
464
|
-
return Math.min(
|
|
480
|
+
function _(e, t, n) {
|
|
481
|
+
return Math.min(n, Math.max(t, e));
|
|
465
482
|
}
|
|
466
|
-
class
|
|
483
|
+
class Ge {
|
|
467
484
|
constructor(t = {}) {
|
|
468
485
|
d(this, "id", "dxf");
|
|
469
486
|
d(this, "label", "DXF / JavaScript parser");
|
|
@@ -471,138 +488,138 @@ class xe {
|
|
|
471
488
|
d(this, "defaults");
|
|
472
489
|
this.defaults = t;
|
|
473
490
|
}
|
|
474
|
-
accepts(t,
|
|
475
|
-
return
|
|
491
|
+
accepts(t, n) {
|
|
492
|
+
return z(t) === "dxf" || Y(t, n) === "dxf";
|
|
476
493
|
}
|
|
477
|
-
async load(t,
|
|
478
|
-
var
|
|
479
|
-
const
|
|
494
|
+
async load(t, n = {}) {
|
|
495
|
+
var u;
|
|
496
|
+
const r = { ...this.defaults, ...n }, i = performance.now(), s = await K(t), o = nn(s, r.dxfEncoding), a = [];
|
|
480
497
|
let c;
|
|
481
498
|
try {
|
|
482
|
-
c = await
|
|
483
|
-
} catch (
|
|
484
|
-
a.push(`dxf-parser failed, using built-in fallback parser: ${
|
|
499
|
+
c = await Ze(o);
|
|
500
|
+
} catch (f) {
|
|
501
|
+
a.push(`dxf-parser failed, using built-in fallback parser: ${f instanceof Error ? f.message : String(f)}`), c = ln(o);
|
|
485
502
|
}
|
|
486
|
-
const
|
|
487
|
-
return { document:
|
|
503
|
+
const l = qe(c, t.fileName ?? ((u = t.file) == null ? void 0 : u.name), a), h = performance.now() - i;
|
|
504
|
+
return { document: l, raw: c, bytes: s.byteLength, elapsedMs: h, format: "dxf", warnings: l.warnings };
|
|
488
505
|
}
|
|
489
506
|
}
|
|
490
|
-
async function
|
|
491
|
-
const t = await import("dxf-parser"),
|
|
492
|
-
if (!
|
|
493
|
-
return new
|
|
507
|
+
async function Ze(e) {
|
|
508
|
+
const t = await import("dxf-parser"), n = t.default ?? t.DxfParser;
|
|
509
|
+
if (!n) throw new Error("dxf-parser did not expose a parser constructor.");
|
|
510
|
+
return new n().parseSync(e);
|
|
494
511
|
}
|
|
495
|
-
function
|
|
496
|
-
const
|
|
512
|
+
function qe(e, t, n = []) {
|
|
513
|
+
const r = e && typeof e == "object" ? e : {}, i = Ke(r), s = Je(r), a = (Array.isArray(r.entities) ? r.entities : []).filter((l) => !!l && typeof l == "object").map((l) => At(l)), c = It({
|
|
497
514
|
format: "dxf",
|
|
498
515
|
sourceName: t,
|
|
499
|
-
header:
|
|
500
|
-
layers:
|
|
501
|
-
blocks:
|
|
516
|
+
header: r.header && typeof r.header == "object" ? r.header : {},
|
|
517
|
+
layers: i,
|
|
518
|
+
blocks: s,
|
|
502
519
|
entities: a,
|
|
503
520
|
metadata: { parser: "dxf-parser + cad-viewer normalizer" },
|
|
504
|
-
warnings:
|
|
521
|
+
warnings: n,
|
|
505
522
|
raw: e
|
|
506
523
|
});
|
|
507
524
|
return a.length === 0 && c.warnings.push("DXF file did not expose any ENTITIES."), c;
|
|
508
525
|
}
|
|
509
|
-
function
|
|
510
|
-
const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(),
|
|
511
|
-
if (
|
|
512
|
-
|
|
513
|
-
const
|
|
514
|
-
(
|
|
526
|
+
function At(e) {
|
|
527
|
+
const t = String(e.type ?? e.entityType ?? "UNKNOWN").toUpperCase(), n = Tt(e, t), r = b(e.colorIndex ?? e.colorNumber ?? e.aci), i = b(e.color);
|
|
528
|
+
if (n.colorIndex = r ?? (i !== void 0 && Math.abs(i) <= 257 ? i : void 0), n.trueColor = e.trueColor ?? e.true_color ?? e.colorRGB ?? e.trueColorValue ?? (i !== void 0 && Math.abs(i) > 257 ? i : void 0), n.layer = w(e.layer ?? e.layerName) ?? "0", n.isClosed = !!(e.shape ?? e.closed ?? e.isClosed) || (Number(e.flag ?? e.flags ?? 0) & 1) === 1, t === "LINE" && (n.startPoint = k(e.startPoint ?? { x: e.x1 ?? e.x, y: e.y1 ?? e.y, z: e.z1 ?? e.z }) ?? n.startPoint, n.endPoint = k(e.endPoint ?? { x: e.x2, y: e.y2, z: e.z2 }) ?? n.endPoint), (t === "TEXT" || t === "MTEXT" || t === "ATTRIB" || t === "ATTDEF") && (n.insertionPoint = k(e.startPoint ?? e.position ?? e.insertionPoint) ?? n.insertionPoint, n.text = cn(e.text ?? e.string ?? e.value) ?? n.text, n.textHeight = b(e.textHeight ?? e.height) ?? n.textHeight, n.rotation = Xt(e.rotation ?? e.angle)), (t === "ARC" || t === "ELLIPSE") && (n.startAngle = Vt(e.startAngle ?? e.start_angle), n.endAngle = Vt(e.endAngle ?? e.end_angle)), t === "INSERT") {
|
|
529
|
+
n.blockName = w(e.name ?? e.blockName) ?? n.blockName, n.insertionPoint = k(e.position ?? e.insertionPoint ?? e.point) ?? n.insertionPoint;
|
|
530
|
+
const s = b(e.xScale ?? e.scaleX ?? e.xscale), o = b(e.yScale ?? e.scaleY ?? e.yscale), a = b(e.zScale ?? e.scaleZ ?? e.zscale);
|
|
531
|
+
(s !== void 0 || o !== void 0 || a !== void 0) && (n.scale = { x: s ?? 1, y: o ?? s ?? 1, z: a ?? 1 }), n.rotation = Xt(e.rotation ?? e.angle);
|
|
515
532
|
}
|
|
516
533
|
if (t === "SPLINE") {
|
|
517
|
-
const
|
|
518
|
-
|
|
519
|
-
const o =
|
|
520
|
-
o.length && (
|
|
521
|
-
}
|
|
522
|
-
return t === "HATCH" && (
|
|
523
|
-
}
|
|
524
|
-
function
|
|
525
|
-
const t = {},
|
|
526
|
-
for (const
|
|
527
|
-
const o =
|
|
528
|
-
a &&
|
|
534
|
+
const s = lt(e.controlPoints ?? e.control_points ?? e.points);
|
|
535
|
+
s.length && (n.controlPoints = s);
|
|
536
|
+
const o = lt(e.fitPoints ?? e.fit_points);
|
|
537
|
+
o.length && (n.fitPoints = o);
|
|
538
|
+
}
|
|
539
|
+
return t === "HATCH" && (n.loops = en(e), n.fillColorIndex = n.colorIndex), (t === "SOLID" || t === "TRACE" || t === "3DFACE") && (n.vertices = tn(e), n.fillColorIndex = n.colorIndex), n;
|
|
540
|
+
}
|
|
541
|
+
function Ke(e) {
|
|
542
|
+
const t = {}, n = e.tables, r = e.layers ?? (n == null ? void 0 : n.layer) ?? (n == null ? void 0 : n.LAYER) ?? (n == null ? void 0 : n.layers), i = Qe(r);
|
|
543
|
+
for (const s of i) {
|
|
544
|
+
const o = s, a = w(o.name ?? o.layerName);
|
|
545
|
+
a && wt(t, {
|
|
529
546
|
name: a,
|
|
530
547
|
color: o.color ?? o.colorNumber ?? o.colorIndex,
|
|
531
|
-
colorIndex:
|
|
532
|
-
lineType:
|
|
548
|
+
colorIndex: b(o.colorNumber ?? o.colorIndex ?? o.color),
|
|
549
|
+
lineType: w(o.lineType ?? o.linetype),
|
|
533
550
|
isVisible: Number(o.colorNumber ?? o.colorIndex ?? o.color ?? 1) >= 0,
|
|
534
551
|
isFrozen: !!o.frozen,
|
|
535
552
|
isLocked: !!o.locked,
|
|
536
553
|
raw: o
|
|
537
554
|
});
|
|
538
555
|
}
|
|
539
|
-
return t[0] ||
|
|
556
|
+
return t[0] || wt(t, { name: "0", colorIndex: 7, isVisible: !0 }), t;
|
|
540
557
|
}
|
|
541
|
-
function
|
|
542
|
-
const t = {},
|
|
543
|
-
if (!
|
|
544
|
-
if (Array.isArray(
|
|
545
|
-
for (const
|
|
558
|
+
function Je(e) {
|
|
559
|
+
const t = {}, n = e.blocks;
|
|
560
|
+
if (!n || typeof n != "object") return t;
|
|
561
|
+
if (Array.isArray(n))
|
|
562
|
+
for (const r of n) Yt(t, r);
|
|
546
563
|
else
|
|
547
|
-
for (const [
|
|
564
|
+
for (const [r, i] of Object.entries(n)) Yt(t, i, r);
|
|
548
565
|
return t;
|
|
549
566
|
}
|
|
550
|
-
function
|
|
567
|
+
function Yt(e, t, n) {
|
|
551
568
|
if (!t || typeof t != "object") return;
|
|
552
|
-
const
|
|
553
|
-
if (!
|
|
554
|
-
const o = (Array.isArray(
|
|
555
|
-
|
|
569
|
+
const r = t, i = w(r.name ?? r.blockName ?? n);
|
|
570
|
+
if (!i) return;
|
|
571
|
+
const o = (Array.isArray(r.entities) ? r.entities : []).filter((a) => !!a && typeof a == "object").map((a) => At(a));
|
|
572
|
+
ce(e, { name: i, basePoint: k(r.basePoint ?? r.position) ?? { x: 0, y: 0 }, entities: o, raw: r });
|
|
556
573
|
}
|
|
557
|
-
function
|
|
574
|
+
function Qe(e) {
|
|
558
575
|
if (!e) return [];
|
|
559
576
|
if (Array.isArray(e)) return e;
|
|
560
577
|
if (typeof e != "object") return [];
|
|
561
578
|
const t = e;
|
|
562
|
-
return Array.isArray(t.entries) ? t.entries : Array.isArray(t.records) ? t.records : Array.isArray(t.layers) ? t.layers : Object.values(t).filter((
|
|
579
|
+
return Array.isArray(t.entries) ? t.entries : Array.isArray(t.records) ? t.records : Array.isArray(t.layers) ? t.layers : Object.values(t).filter((n) => n && typeof n == "object");
|
|
563
580
|
}
|
|
564
|
-
function
|
|
565
|
-
return Array.isArray(e) ? e.map(
|
|
581
|
+
function lt(e) {
|
|
582
|
+
return Array.isArray(e) ? e.map(k).filter((t) => !!t) : [];
|
|
566
583
|
}
|
|
567
|
-
function
|
|
568
|
-
const t =
|
|
584
|
+
function tn(e) {
|
|
585
|
+
const t = lt(e.vertices ?? e.points);
|
|
569
586
|
if (t.length) return t;
|
|
570
|
-
const
|
|
571
|
-
for (let
|
|
572
|
-
const
|
|
573
|
-
|
|
587
|
+
const n = [];
|
|
588
|
+
for (let r = 0; r < 4; r++) {
|
|
589
|
+
const i = k({ x: e[`x${r}`] ?? e[`x${r + 1}`], y: e[`y${r}`] ?? e[`y${r + 1}`], z: e[`z${r}`] ?? e[`z${r + 1}`] });
|
|
590
|
+
i && n.push(i);
|
|
574
591
|
}
|
|
575
|
-
return
|
|
592
|
+
return n;
|
|
576
593
|
}
|
|
577
|
-
function
|
|
594
|
+
function en(e) {
|
|
578
595
|
const t = e.boundaryLoops ?? e.loops ?? e.paths;
|
|
579
596
|
if (Array.isArray(t))
|
|
580
|
-
return t.map((
|
|
581
|
-
const
|
|
582
|
-
return { vertices:
|
|
583
|
-
}).filter((
|
|
597
|
+
return t.map((n) => {
|
|
598
|
+
const r = n;
|
|
599
|
+
return { vertices: lt(r.vertices ?? r.points), isClosed: !0 };
|
|
600
|
+
}).filter((n) => n.vertices && n.vertices.length > 0);
|
|
584
601
|
}
|
|
585
|
-
function
|
|
586
|
-
const t =
|
|
602
|
+
function Xt(e) {
|
|
603
|
+
const t = b(e);
|
|
587
604
|
if (t !== void 0)
|
|
588
|
-
return Math.abs(t) > Math.PI * 2 + 1e-6 ?
|
|
605
|
+
return Math.abs(t) > Math.PI * 2 + 1e-6 ? W(t) : t;
|
|
589
606
|
}
|
|
590
|
-
function
|
|
591
|
-
const t =
|
|
607
|
+
function Vt(e) {
|
|
608
|
+
const t = b(e);
|
|
592
609
|
if (t !== void 0)
|
|
593
|
-
return Math.abs(t) > Math.PI * 2 + 1e-6 ?
|
|
594
|
-
}
|
|
595
|
-
function
|
|
596
|
-
const
|
|
597
|
-
if (
|
|
598
|
-
const
|
|
599
|
-
if (
|
|
600
|
-
const
|
|
601
|
-
if (
|
|
602
|
-
const
|
|
603
|
-
return
|
|
604
|
-
}
|
|
605
|
-
const
|
|
610
|
+
return Math.abs(t) > Math.PI * 2 + 1e-6 ? W(t) : t;
|
|
611
|
+
}
|
|
612
|
+
function nn(e, t) {
|
|
613
|
+
const n = Ct(t);
|
|
614
|
+
if (n) return R(e, n);
|
|
615
|
+
const r = rn(e);
|
|
616
|
+
if (r) return R(e, r);
|
|
617
|
+
const i = Ct(sn(e));
|
|
618
|
+
if (i) return R(e, i);
|
|
619
|
+
const s = R(e, "utf-8");
|
|
620
|
+
return s.includes("�") ? on(e) : s;
|
|
621
|
+
}
|
|
622
|
+
const Ht = {
|
|
606
623
|
ANSI_874: "windows-874",
|
|
607
624
|
ANSI_932: "shift_jis",
|
|
608
625
|
ANSI_936: "gb18030",
|
|
@@ -647,208 +664,208 @@ const It = {
|
|
|
647
664
|
UTF16BE: "utf-16be",
|
|
648
665
|
UTF_16BE: "utf-16be"
|
|
649
666
|
};
|
|
650
|
-
function
|
|
667
|
+
function rn(e) {
|
|
651
668
|
if (e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191) return "utf-8";
|
|
652
669
|
if (e.length >= 2 && e[0] === 255 && e[1] === 254) return "utf-16le";
|
|
653
670
|
if (e.length >= 2 && e[0] === 254 && e[1] === 255) return "utf-16be";
|
|
654
671
|
}
|
|
655
|
-
function
|
|
656
|
-
var i, s,
|
|
657
|
-
const
|
|
672
|
+
function sn(e) {
|
|
673
|
+
var r, i, s, o;
|
|
674
|
+
const n = R(e.subarray(0, Math.min(e.byteLength, 131072)), "iso-8859-1").replace(/\r\n/g, `
|
|
658
675
|
`).replace(/\r/g, `
|
|
659
676
|
`).split(`
|
|
660
677
|
`);
|
|
661
|
-
for (let a = 0; a <
|
|
662
|
-
if (!(((
|
|
663
|
-
for (let c = a + 2; c < Math.min(a + 10,
|
|
664
|
-
const
|
|
665
|
-
if (
|
|
678
|
+
for (let a = 0; a < n.length - 3; a++)
|
|
679
|
+
if (!(((r = n[a]) == null ? void 0 : r.trim()) !== "9" || ((i = n[a + 1]) == null ? void 0 : i.trim().toUpperCase()) !== "$DWGCODEPAGE"))
|
|
680
|
+
for (let c = a + 2; c < Math.min(a + 10, n.length - 1); c += 2) {
|
|
681
|
+
const l = (s = n[c]) == null ? void 0 : s.trim(), h = (o = n[c + 1]) == null ? void 0 : o.trim();
|
|
682
|
+
if (l === "3" && h) return h;
|
|
666
683
|
}
|
|
667
684
|
}
|
|
668
|
-
function
|
|
685
|
+
function Ct(e) {
|
|
669
686
|
const t = e == null ? void 0 : e.trim();
|
|
670
687
|
if (!t) return;
|
|
671
|
-
const
|
|
672
|
-
if (
|
|
673
|
-
const
|
|
674
|
-
if (
|
|
675
|
-
const
|
|
676
|
-
return
|
|
677
|
-
}
|
|
678
|
-
function
|
|
688
|
+
const n = t.replace(/[-\s]+/g, "_").toUpperCase();
|
|
689
|
+
if (Ht[n]) return Ht[n];
|
|
690
|
+
const r = /^ANSI_(\d{3,4})$/.exec(n);
|
|
691
|
+
if (r) return Ct(`cp${r[1]}`);
|
|
692
|
+
const i = /^CP(\d{3,4})$/.exec(n);
|
|
693
|
+
return i ? i[1] === "936" ? "gb18030" : i[1] === "950" ? "big5" : i[1] === "932" ? "shift_jis" : i[1] === "949" ? "euc-kr" : `windows-${i[1]}` : t;
|
|
694
|
+
}
|
|
695
|
+
function R(e, t) {
|
|
679
696
|
try {
|
|
680
697
|
return new TextDecoder(t, { fatal: !1 }).decode(e);
|
|
681
698
|
} catch {
|
|
682
699
|
return new TextDecoder("utf-8", { fatal: !1 }).decode(e);
|
|
683
700
|
}
|
|
684
701
|
}
|
|
685
|
-
function
|
|
702
|
+
function on(e) {
|
|
686
703
|
const t = ["windows-1252", "gb18030", "big5", "shift_jis", "euc-kr", "iso-8859-1"];
|
|
687
|
-
let
|
|
688
|
-
for (const
|
|
689
|
-
const
|
|
690
|
-
o <
|
|
704
|
+
let n = "", r = Number.POSITIVE_INFINITY;
|
|
705
|
+
for (const i of t) {
|
|
706
|
+
const s = R(e, i), o = an(s, i);
|
|
707
|
+
o < r && (r = o, n = s);
|
|
691
708
|
}
|
|
692
|
-
return
|
|
709
|
+
return n || R(e, "utf-8");
|
|
693
710
|
}
|
|
694
|
-
function
|
|
695
|
-
const
|
|
696
|
-
let o =
|
|
697
|
-
return
|
|
711
|
+
function an(e, t) {
|
|
712
|
+
const n = ut(e, /\uFFFD/g), r = ut(e, /[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g), i = ut(e, /[\u3400-\u9FFF\uF900-\uFAFF]/g), s = e.includes("SECTION") && (e.includes("ENTITIES") || e.includes("HEADER"));
|
|
713
|
+
let o = n * 1e4 + r * 1e3;
|
|
714
|
+
return s && (o -= 500), t === "windows-1252" && (o -= 2), t === "gb18030" && i >= 2 && (o -= 50 + Math.min(i, 200) * 2), o;
|
|
698
715
|
}
|
|
699
|
-
function
|
|
700
|
-
var
|
|
701
|
-
return ((
|
|
716
|
+
function ut(e, t) {
|
|
717
|
+
var n;
|
|
718
|
+
return ((n = e.match(t)) == null ? void 0 : n.length) ?? 0;
|
|
702
719
|
}
|
|
703
|
-
function
|
|
704
|
-
const t =
|
|
720
|
+
function cn(e) {
|
|
721
|
+
const t = w(e);
|
|
705
722
|
if (t !== void 0)
|
|
706
|
-
return t.replace(/\\U\+([0-9a-fA-F]{4,6})/g, (
|
|
707
|
-
const
|
|
708
|
-
return Number.isFinite(
|
|
723
|
+
return t.replace(/\\U\+([0-9a-fA-F]{4,6})/g, (n, r) => {
|
|
724
|
+
const i = Number.parseInt(r, 16);
|
|
725
|
+
return Number.isFinite(i) && i >= 0 && i <= 1114111 ? String.fromCodePoint(i) : n;
|
|
709
726
|
}).replace(/%%[cC]/g, "∅").replace(/%%[dD]/g, "°").replace(/%%[pP]/g, "±").replace(/\\P/g, `
|
|
710
727
|
`);
|
|
711
728
|
}
|
|
712
|
-
function
|
|
713
|
-
var
|
|
729
|
+
function ln(e) {
|
|
730
|
+
var l, h;
|
|
714
731
|
const t = e.replace(/\r\n/g, `
|
|
715
732
|
`).replace(/\r/g, `
|
|
716
733
|
`).split(`
|
|
717
|
-
`),
|
|
718
|
-
for (let
|
|
719
|
-
const
|
|
720
|
-
Number.isFinite(
|
|
721
|
-
}
|
|
722
|
-
const
|
|
723
|
-
let
|
|
724
|
-
for (let
|
|
725
|
-
const
|
|
726
|
-
if (
|
|
727
|
-
|
|
734
|
+
`), n = [];
|
|
735
|
+
for (let u = 0; u < t.length - 1; u += 2) {
|
|
736
|
+
const f = Number((l = t[u]) == null ? void 0 : l.trim()), m = t[u + 1] ?? "";
|
|
737
|
+
Number.isFinite(f) && n.push({ code: f, value: m.trimEnd() });
|
|
738
|
+
}
|
|
739
|
+
const r = [], i = {};
|
|
740
|
+
let s = "", o = [], a;
|
|
741
|
+
for (let u = 0; u < n.length; u++) {
|
|
742
|
+
const f = n[u];
|
|
743
|
+
if (f.code === 0 && f.value === "SECTION") {
|
|
744
|
+
s = ((h = n[u + 1]) == null ? void 0 : h.code) === 2 ? n[u + 1].value.toUpperCase() : "", u++;
|
|
728
745
|
continue;
|
|
729
746
|
}
|
|
730
|
-
if (
|
|
731
|
-
c(),
|
|
747
|
+
if (f.code === 0 && f.value === "ENDSEC") {
|
|
748
|
+
c(), s = "";
|
|
732
749
|
continue;
|
|
733
750
|
}
|
|
734
|
-
|
|
751
|
+
s === "ENTITIES" && (f.code === 0 ? (c(), o = [f]) : o.push(f));
|
|
735
752
|
}
|
|
736
|
-
return c(), { header: {}, tables: {}, entities:
|
|
753
|
+
return c(), { header: {}, tables: {}, entities: r, blocks: i };
|
|
737
754
|
function c() {
|
|
738
|
-
var
|
|
755
|
+
var m;
|
|
739
756
|
if (!o.length) return;
|
|
740
|
-
const
|
|
741
|
-
if (
|
|
742
|
-
const
|
|
743
|
-
|
|
757
|
+
const u = (m = o[0]) == null ? void 0 : m.value.toUpperCase();
|
|
758
|
+
if (u === "VERTEX" && a) {
|
|
759
|
+
const p = M(o, 10, 20, 30);
|
|
760
|
+
p && (a.vertices ?? (a.vertices = [])).push({ ...p, bulge: x(o, 42) }), o = [];
|
|
744
761
|
return;
|
|
745
762
|
}
|
|
746
|
-
if (
|
|
747
|
-
a &&
|
|
763
|
+
if (u === "SEQEND") {
|
|
764
|
+
a && r.push(a), a = void 0, o = [];
|
|
748
765
|
return;
|
|
749
766
|
}
|
|
750
|
-
if (a && (
|
|
767
|
+
if (a && (r.push(a), a = void 0), !u || u === "EOF") {
|
|
751
768
|
o = [];
|
|
752
769
|
return;
|
|
753
770
|
}
|
|
754
|
-
const
|
|
755
|
-
|
|
771
|
+
const f = hn(u, o);
|
|
772
|
+
u === "POLYLINE" ? a = f : r.push(f), o = [];
|
|
756
773
|
}
|
|
757
774
|
}
|
|
758
|
-
function
|
|
759
|
-
const
|
|
775
|
+
function hn(e, t) {
|
|
776
|
+
const n = {
|
|
760
777
|
type: e,
|
|
761
|
-
handle:
|
|
762
|
-
layer:
|
|
763
|
-
colorIndex:
|
|
764
|
-
trueColor:
|
|
765
|
-
lineType:
|
|
766
|
-
lineweight:
|
|
778
|
+
handle: G(t, 5),
|
|
779
|
+
layer: G(t, 8) ?? "0",
|
|
780
|
+
colorIndex: x(t, 62),
|
|
781
|
+
trueColor: x(t, 420),
|
|
782
|
+
lineType: G(t, 6),
|
|
783
|
+
lineweight: x(t, 370)
|
|
767
784
|
};
|
|
768
785
|
switch (e) {
|
|
769
786
|
case "LINE":
|
|
770
|
-
Object.assign(
|
|
787
|
+
Object.assign(n, { startPoint: M(t, 10, 20, 30), endPoint: M(t, 11, 21, 31) });
|
|
771
788
|
break;
|
|
772
789
|
case "CIRCLE":
|
|
773
|
-
Object.assign(
|
|
790
|
+
Object.assign(n, { center: M(t, 10, 20, 30), radius: x(t, 40) });
|
|
774
791
|
break;
|
|
775
792
|
case "ARC":
|
|
776
|
-
Object.assign(
|
|
793
|
+
Object.assign(n, { center: M(t, 10, 20, 30), radius: x(t, 40), startAngle: st(x(t, 50)), endAngle: st(x(t, 51)) });
|
|
777
794
|
break;
|
|
778
795
|
case "POINT":
|
|
779
|
-
Object.assign(
|
|
796
|
+
Object.assign(n, { point: M(t, 10, 20, 30) });
|
|
780
797
|
break;
|
|
781
798
|
case "TEXT":
|
|
782
799
|
case "MTEXT":
|
|
783
|
-
Object.assign(
|
|
800
|
+
Object.assign(n, { insertionPoint: M(t, 10, 20, 30), text: dn(t), textHeight: x(t, 40), rotation: st(x(t, 50)) });
|
|
784
801
|
break;
|
|
785
802
|
case "LWPOLYLINE":
|
|
786
|
-
Object.assign(
|
|
803
|
+
Object.assign(n, { vertices: un(t), flag: x(t, 70), isClosed: (Number(x(t, 70) ?? 0) & 1) === 1 });
|
|
787
804
|
break;
|
|
788
805
|
case "POLYLINE":
|
|
789
|
-
Object.assign(
|
|
806
|
+
Object.assign(n, { vertices: [], flag: x(t, 70), isClosed: (Number(x(t, 70) ?? 0) & 1) === 1 });
|
|
790
807
|
break;
|
|
791
808
|
case "ELLIPSE":
|
|
792
|
-
Object.assign(
|
|
809
|
+
Object.assign(n, { center: M(t, 10, 20, 30), majorAxisEndPoint: M(t, 11, 21, 31), axisRatio: x(t, 40), startAngle: x(t, 41), endAngle: x(t, 42) });
|
|
793
810
|
break;
|
|
794
811
|
case "SPLINE":
|
|
795
|
-
Object.assign(
|
|
812
|
+
Object.assign(n, { controlPoints: fn(t, 10, 20, 30), degree: x(t, 71), isClosed: (Number(x(t, 70) ?? 0) & 1) === 1 });
|
|
796
813
|
break;
|
|
797
814
|
case "INSERT":
|
|
798
|
-
Object.assign(
|
|
815
|
+
Object.assign(n, { name: G(t, 2), blockName: G(t, 2), insertionPoint: M(t, 10, 20, 30), rotation: st(x(t, 50)), scale: { x: x(t, 41) ?? 1, y: x(t, 42) ?? x(t, 41) ?? 1, z: x(t, 43) ?? 1 } });
|
|
799
816
|
break;
|
|
800
817
|
case "SOLID":
|
|
801
818
|
case "TRACE":
|
|
802
819
|
case "3DFACE":
|
|
803
|
-
Object.assign(
|
|
820
|
+
Object.assign(n, { vertices: [M(t, 10, 20, 30), M(t, 11, 21, 31), M(t, 12, 22, 32), M(t, 13, 23, 33)].filter(Boolean) });
|
|
804
821
|
break;
|
|
805
822
|
}
|
|
806
|
-
return
|
|
823
|
+
return At(n);
|
|
807
824
|
}
|
|
808
|
-
function
|
|
809
|
-
var s;
|
|
810
|
-
const r = (s = e.find((n) => n.code === t)) == null ? void 0 : s.value, i = Number(r);
|
|
811
|
-
return Number.isFinite(i) ? i : void 0;
|
|
812
|
-
}
|
|
813
|
-
function Y(e, t) {
|
|
825
|
+
function x(e, t) {
|
|
814
826
|
var i;
|
|
815
|
-
const
|
|
816
|
-
return r
|
|
827
|
+
const n = (i = e.find((s) => s.code === t)) == null ? void 0 : i.value, r = Number(n);
|
|
828
|
+
return Number.isFinite(r) ? r : void 0;
|
|
817
829
|
}
|
|
818
|
-
function
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
830
|
+
function G(e, t) {
|
|
831
|
+
var r;
|
|
832
|
+
const n = (r = e.find((i) => i.code === t)) == null ? void 0 : r.value;
|
|
833
|
+
return n && n.length > 0 ? n : void 0;
|
|
822
834
|
}
|
|
823
|
-
function
|
|
824
|
-
const s =
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
835
|
+
function M(e, t, n, r) {
|
|
836
|
+
const i = x(e, t), s = x(e, n), o = x(e, r);
|
|
837
|
+
if (!(i === void 0 || s === void 0))
|
|
838
|
+
return o === void 0 ? { x: i, y: s } : { x: i, y: s, z: o };
|
|
839
|
+
}
|
|
840
|
+
function fn(e, t, n, r) {
|
|
841
|
+
const i = [];
|
|
842
|
+
for (let s = 0; s < e.length; s++) {
|
|
843
|
+
if (e[s].code !== t) continue;
|
|
844
|
+
const o = Number(e[s].value), a = e.slice(s + 1).find((u) => u.code === n), c = e.slice(s + 1).find((u) => u.code === r), l = Number(a == null ? void 0 : a.value), h = Number(c == null ? void 0 : c.value);
|
|
845
|
+
Number.isFinite(o) && Number.isFinite(l) && i.push(Number.isFinite(h) ? { x: o, y: l, z: h } : { x: o, y: l });
|
|
829
846
|
}
|
|
830
|
-
return
|
|
847
|
+
return i;
|
|
831
848
|
}
|
|
832
|
-
function
|
|
849
|
+
function un(e) {
|
|
833
850
|
const t = [];
|
|
834
|
-
for (let
|
|
835
|
-
if (e[
|
|
836
|
-
const
|
|
837
|
-
let
|
|
838
|
-
for (let o =
|
|
839
|
-
e[o].code === 20 && (
|
|
840
|
-
Number.isFinite(
|
|
851
|
+
for (let n = 0; n < e.length; n++) {
|
|
852
|
+
if (e[n].code !== 10) continue;
|
|
853
|
+
const r = Number(e[n].value);
|
|
854
|
+
let i, s;
|
|
855
|
+
for (let o = n + 1; o < e.length && e[o].code !== 10; o++)
|
|
856
|
+
e[o].code === 20 && (i = Number(e[o].value)), e[o].code === 42 && (s = Number(e[o].value));
|
|
857
|
+
Number.isFinite(r) && Number.isFinite(i) && t.push({ x: r, y: i, bulge: Number.isFinite(s) ? s : void 0 });
|
|
841
858
|
}
|
|
842
859
|
return t;
|
|
843
860
|
}
|
|
844
|
-
function
|
|
845
|
-
const t = e.filter((
|
|
861
|
+
function dn(e) {
|
|
862
|
+
const t = e.filter((n) => n.code === 1 || n.code === 3).map((n) => n.value);
|
|
846
863
|
return t.length ? t.join("") : void 0;
|
|
847
864
|
}
|
|
848
|
-
function
|
|
849
|
-
return typeof e == "number" && Number.isFinite(e) ?
|
|
865
|
+
function st(e) {
|
|
866
|
+
return typeof e == "number" && Number.isFinite(e) ? W(e) : void 0;
|
|
850
867
|
}
|
|
851
|
-
class
|
|
868
|
+
class mn {
|
|
852
869
|
constructor(t = {}) {
|
|
853
870
|
d(this, "id", "dwf");
|
|
854
871
|
d(this, "label", "DWF/DWFx native viewer powered by dwf-viewer");
|
|
@@ -860,32 +877,32 @@ class ze {
|
|
|
860
877
|
d(this, "lastStats");
|
|
861
878
|
this.defaults = t;
|
|
862
879
|
}
|
|
863
|
-
accepts(t,
|
|
864
|
-
const
|
|
865
|
-
if (
|
|
866
|
-
const
|
|
867
|
-
return
|
|
868
|
-
}
|
|
869
|
-
async load(t,
|
|
870
|
-
var f,
|
|
871
|
-
const
|
|
872
|
-
(
|
|
873
|
-
const c = await
|
|
874
|
-
(
|
|
875
|
-
const
|
|
876
|
-
return (
|
|
877
|
-
}
|
|
878
|
-
async mount(t,
|
|
879
|
-
var
|
|
880
|
-
const
|
|
881
|
-
(
|
|
880
|
+
accepts(t, n) {
|
|
881
|
+
const r = z(t);
|
|
882
|
+
if (r === "dwf" || r === "dwfx" || r === "xps") return !0;
|
|
883
|
+
const i = Y(t, n);
|
|
884
|
+
return i === "dwf" || i === "dwfx" || i === "xps";
|
|
885
|
+
}
|
|
886
|
+
async load(t, n = {}) {
|
|
887
|
+
var u, f, m, p;
|
|
888
|
+
const r = { ...this.defaults, ...n }, i = performance.now(), s = t.fileName ?? ((u = t.file) == null ? void 0 : u.name), o = await K(t), a = jt(Y(t, o), z(t));
|
|
889
|
+
(f = r.onProgress) == null || f.call(r, { phase: "parse", format: a, message: "Opening DWF/DWFx with dwf-viewer…", percent: 48 });
|
|
890
|
+
const c = await Ae(o, { fileName: s });
|
|
891
|
+
(m = r.onProgress) == null || m.call(r, { phase: "normalize", format: a, message: "Reading DWF pages, sheets and model metadata…", percent: 76 });
|
|
892
|
+
const l = Ut(c, s, a, r.keepRaw === !0), h = performance.now() - i;
|
|
893
|
+
return (p = r.onProgress) == null || p.call(r, { phase: "done", format: l.format, message: "DWF/DWFx document ready.", percent: 100, elapsedMs: h }), { document: l, raw: r.keepRaw ? c : void 0, bytes: o.byteLength, elapsedMs: h, format: l.format, warnings: l.warnings };
|
|
894
|
+
}
|
|
895
|
+
async mount(t, n, r = {}) {
|
|
896
|
+
var y, v, N, A, T;
|
|
897
|
+
const i = { ...this.defaults, ...r }, s = performance.now(), o = t.fileName ?? ((y = t.file) == null ? void 0 : y.name), a = await K(t), c = jt(Y(t, a), z(t)), l = vn(i), h = Gt(i), u = xn(i, l, h), f = de(i, l, h);
|
|
898
|
+
(v = i.onProgress) == null || v.call(i, { phase: "native-render", format: c, message: "Mounting native DWF renderer…", percent: 28 }), this.unmount(), this.host = n, n.replaceChildren(), this.native = new Be(n, u), (N = i.onProgress) == null || N.call(i, { phase: "parse", format: c, message: "Parsing DWF package and page streams…", percent: 58 }), await this.native.load(a, {
|
|
882
899
|
fileName: o,
|
|
883
|
-
...
|
|
884
|
-
}), (
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
const
|
|
888
|
-
return (
|
|
900
|
+
...f
|
|
901
|
+
}), (A = i.onProgress) == null || A.call(i, { phase: "render", format: c, message: "Rendering DWF/DWFx with dwf-viewer…", percent: 88 }), this.lastStats = await this.native.render();
|
|
902
|
+
const m = this.native.getDocument(), p = Ut(m, o, c, i.keepRaw === !0);
|
|
903
|
+
p.metadata.loaderMode = "Native DWF", p.metadata.nativeRenderer = "dwf-viewer", p.metadata.nativeRenderStats = this.lastStats ? { ...this.lastStats, warnings: this.lastStats.warnings.length } : void 0;
|
|
904
|
+
const C = performance.now() - s;
|
|
905
|
+
return (T = i.onProgress) == null || T.call(i, { phase: "done", format: p.format, message: "DWF/DWFx rendered.", percent: 100, elapsedMs: C }), { document: p, raw: i.keepRaw ? m : void 0, bytes: a.byteLength, elapsedMs: C, format: p.format, warnings: p.warnings };
|
|
889
906
|
}
|
|
890
907
|
unmount() {
|
|
891
908
|
var t;
|
|
@@ -896,13 +913,13 @@ class ze {
|
|
|
896
913
|
(t = this.native) == null || t.fit();
|
|
897
914
|
}
|
|
898
915
|
zoomIn() {
|
|
899
|
-
var
|
|
900
|
-
const t = (
|
|
916
|
+
var n;
|
|
917
|
+
const t = (n = this.native) == null ? void 0 : n.zoomInButton;
|
|
901
918
|
t == null || t.click();
|
|
902
919
|
}
|
|
903
920
|
zoomOut() {
|
|
904
|
-
var
|
|
905
|
-
const t = (
|
|
921
|
+
var n;
|
|
922
|
+
const t = (n = this.native) == null ? void 0 : n.zoomOutButton;
|
|
906
923
|
t == null || t.click();
|
|
907
924
|
}
|
|
908
925
|
resize() {
|
|
@@ -910,70 +927,70 @@ class ze {
|
|
|
910
927
|
(t = this.native) == null || t.render();
|
|
911
928
|
}
|
|
912
929
|
setNativeOptions(t) {
|
|
913
|
-
var i, s,
|
|
914
|
-
const
|
|
915
|
-
if (
|
|
916
|
-
if (typeof t.dwfBackground == "string")
|
|
930
|
+
var r, i, s, o;
|
|
931
|
+
const n = this.native;
|
|
932
|
+
if (n) {
|
|
933
|
+
if (typeof t.dwfBackground == "string") n.background = t.dwfBackground;
|
|
917
934
|
else {
|
|
918
|
-
const a =
|
|
919
|
-
a && (
|
|
935
|
+
const a = Gt(t);
|
|
936
|
+
a && (n.background = a);
|
|
920
937
|
}
|
|
921
|
-
typeof t.dwfPreferWebgl == "boolean" && ((
|
|
938
|
+
typeof t.dwfPreferWebgl == "boolean" && ((r = n.setPreferWebgl) == null || r.call(n, t.dwfPreferWebgl)), typeof t.dwfPreferWasm == "boolean" && ((i = n.setPreferWasm) == null || i.call(n, t.dwfPreferWasm)), t.dwfLineWeightMode && ((s = n.setLineWeightMode) == null || s.call(n, t.dwfLineWeightMode)), ot(n, "minStrokeCssPx", t.dwfMinStrokeCssPx), ot(n, "maxOverviewStrokeCssPx", t.dwfMaxOverviewStrokeCssPx), ot(n, "minTextCssPx", t.dwfMinTextCssPx), ot(n, "minFilledAreaCssPx", t.dwfMinFilledAreaCssPx), (o = n.render) == null || o.call(n);
|
|
922
939
|
}
|
|
923
940
|
}
|
|
924
941
|
getLastNativeStats() {
|
|
925
942
|
return this.lastStats;
|
|
926
943
|
}
|
|
927
944
|
}
|
|
928
|
-
function
|
|
945
|
+
function Ut(e, t, n, r) {
|
|
929
946
|
var a, c;
|
|
930
|
-
const
|
|
931
|
-
for (const
|
|
947
|
+
const i = $t((e == null ? void 0 : e.diagnostics) ?? []), s = ((e == null ? void 0 : e.pageData) ?? []).map((l, h) => pn(l, h));
|
|
948
|
+
for (const l of (e == null ? void 0 : e.pageData) ?? []) i.push(...$t(l.diagnostics));
|
|
932
949
|
const o = {
|
|
933
950
|
parser: "dwf-viewer",
|
|
934
951
|
nativeRenderer: "dwf-viewer",
|
|
935
952
|
dwfKind: e == null ? void 0 : e.kind,
|
|
936
953
|
packageEntries: ((a = e == null ? void 0 : e.packageEntries) == null ? void 0 : a.length) ?? 0,
|
|
937
954
|
resources: ((c = e == null ? void 0 : e.resources) == null ? void 0 : c.length) ?? 0,
|
|
938
|
-
pageKinds:
|
|
939
|
-
pageNames: ((e == null ? void 0 : e.pages) ?? []).map((
|
|
955
|
+
pageKinds: Pn(((e == null ? void 0 : e.pageData) ?? []).map((l) => l.kind)),
|
|
956
|
+
pageNames: ((e == null ? void 0 : e.pages) ?? []).map((l) => l.name)
|
|
940
957
|
};
|
|
941
|
-
return
|
|
942
|
-
format:
|
|
958
|
+
return It({
|
|
959
|
+
format: n,
|
|
943
960
|
sourceName: t,
|
|
944
961
|
layers: {},
|
|
945
962
|
blocks: {},
|
|
946
|
-
pages:
|
|
947
|
-
entities:
|
|
963
|
+
pages: s,
|
|
964
|
+
entities: $e(s),
|
|
948
965
|
metadata: o,
|
|
949
|
-
warnings:
|
|
950
|
-
raw:
|
|
966
|
+
warnings: kn(i),
|
|
967
|
+
raw: r ? e : void 0
|
|
951
968
|
});
|
|
952
969
|
}
|
|
953
|
-
function
|
|
954
|
-
const
|
|
970
|
+
function pn(e, t) {
|
|
971
|
+
const n = gn(e, t);
|
|
955
972
|
return {
|
|
956
973
|
index: t,
|
|
957
974
|
name: e.name || e.sourcePath || `${t + 1}`,
|
|
958
975
|
width: e.width || 1e3,
|
|
959
976
|
height: e.height || 1e3,
|
|
960
|
-
entities:
|
|
977
|
+
entities: n
|
|
961
978
|
};
|
|
962
979
|
}
|
|
963
|
-
function
|
|
964
|
-
return e.kind === "w2d-text" ? e.primitives.flatMap((
|
|
965
|
-
id:
|
|
980
|
+
function gn(e, t) {
|
|
981
|
+
return e.kind === "w2d-text" ? e.primitives.flatMap((n, r) => bn(n, t, r)) : 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((n, r) => ({
|
|
982
|
+
id: n.id,
|
|
966
983
|
type: "W3D_MESH",
|
|
967
984
|
kind: "solid",
|
|
968
985
|
pageIndex: t,
|
|
969
|
-
color:
|
|
970
|
-
name:
|
|
971
|
-
raw: { vertexCount:
|
|
986
|
+
color: n.color ? Cn(n.color) : void 0,
|
|
987
|
+
name: n.name || `mesh-${r + 1}`,
|
|
988
|
+
raw: { vertexCount: n.vertexCount, triangleCount: n.triangleCount, materialId: n.materialId }
|
|
972
989
|
})) : 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 } }];
|
|
973
990
|
}
|
|
974
|
-
function
|
|
975
|
-
const
|
|
976
|
-
id: `dwf-${t}-${
|
|
991
|
+
function bn(e, t, n) {
|
|
992
|
+
const r = {
|
|
993
|
+
id: `dwf-${t}-${n}`,
|
|
977
994
|
pageIndex: t,
|
|
978
995
|
color: e.stroke,
|
|
979
996
|
fillColor: e.fill,
|
|
@@ -982,17 +999,17 @@ function Ye(e, t, r) {
|
|
|
982
999
|
};
|
|
983
1000
|
if (e.type === "polyline" || e.type === "polygon")
|
|
984
1001
|
return [{
|
|
985
|
-
...
|
|
1002
|
+
...r,
|
|
986
1003
|
type: e.type === "polygon" ? "DWF_POLYGON" : "DWF_POLYLINE",
|
|
987
1004
|
kind: "polyline",
|
|
988
|
-
vertices:
|
|
1005
|
+
vertices: yn(e.points),
|
|
989
1006
|
isClosed: e.type === "polygon"
|
|
990
1007
|
}];
|
|
991
1008
|
if (e.type === "path")
|
|
992
|
-
return [{ ...
|
|
1009
|
+
return [{ ...r, type: "DWF_PATH", kind: "path", commands: e.commands }];
|
|
993
1010
|
if (e.type === "text")
|
|
994
1011
|
return [{
|
|
995
|
-
...
|
|
1012
|
+
...r,
|
|
996
1013
|
type: "DWF_TEXT",
|
|
997
1014
|
kind: "text",
|
|
998
1015
|
insertionPoint: { x: e.x, y: e.y, z: 0 },
|
|
@@ -1000,57 +1017,57 @@ function Ye(e, t, r) {
|
|
|
1000
1017
|
textHeight: e.size
|
|
1001
1018
|
}];
|
|
1002
1019
|
if (e.type === "rect") {
|
|
1003
|
-
const
|
|
1020
|
+
const i = e.x, s = e.y, o = e.width, a = e.height;
|
|
1004
1021
|
return [{
|
|
1005
|
-
...
|
|
1022
|
+
...r,
|
|
1006
1023
|
type: "DWF_RECT",
|
|
1007
1024
|
kind: "polyline",
|
|
1008
1025
|
isClosed: !0,
|
|
1009
1026
|
vertices: [
|
|
1010
|
-
{ x:
|
|
1011
|
-
{ x:
|
|
1012
|
-
{ x:
|
|
1013
|
-
{ x:
|
|
1027
|
+
{ x: i, y: s, z: 0 },
|
|
1028
|
+
{ x: i + o, y: s, z: 0 },
|
|
1029
|
+
{ x: i + o, y: s + a, z: 0 },
|
|
1030
|
+
{ x: i, y: s + a, z: 0 }
|
|
1014
1031
|
]
|
|
1015
1032
|
}];
|
|
1016
1033
|
}
|
|
1017
1034
|
return [];
|
|
1018
1035
|
}
|
|
1019
|
-
function
|
|
1036
|
+
function yn(e) {
|
|
1020
1037
|
const t = [];
|
|
1021
|
-
for (let
|
|
1038
|
+
for (let n = 0; n + 1 < e.length; n += 2) t.push({ x: e[n], y: e[n + 1], z: 0 });
|
|
1022
1039
|
return t;
|
|
1023
1040
|
}
|
|
1024
|
-
function
|
|
1041
|
+
function $t(e) {
|
|
1025
1042
|
return e.filter((t) => t.level !== "info").map((t) => `${t.code}: ${t.message}${t.source ? ` (${t.source})` : ""}`);
|
|
1026
1043
|
}
|
|
1027
|
-
function
|
|
1044
|
+
function jt(e, t) {
|
|
1028
1045
|
return t === "dwf" || t === "dwfx" || t === "xps" ? t : e === "dwf" || e === "dwfx" || e === "xps" ? e : "dwf";
|
|
1029
1046
|
}
|
|
1030
|
-
function
|
|
1047
|
+
function vn(e) {
|
|
1031
1048
|
if (e.dwfWasmUrl) return e.dwfWasmUrl;
|
|
1032
1049
|
if (typeof document > "u") return;
|
|
1033
|
-
const t = e.wasmPath ? new URL(
|
|
1050
|
+
const t = e.wasmPath ? new URL(wn(e.wasmPath), document.baseURI).href : new URL("wasm/", document.baseURI).href;
|
|
1034
1051
|
return new URL("dwfv-render.wasm", t).href;
|
|
1035
1052
|
}
|
|
1036
|
-
function
|
|
1053
|
+
function Gt(e) {
|
|
1037
1054
|
if (e.dwfBackground) return e.dwfBackground;
|
|
1038
1055
|
const t = e.canvasOptions;
|
|
1039
1056
|
return (t == null ? void 0 : t.background) ?? "#05070d";
|
|
1040
1057
|
}
|
|
1041
|
-
function
|
|
1058
|
+
function xn(e, t, n) {
|
|
1042
1059
|
return {
|
|
1043
|
-
...
|
|
1060
|
+
...de(e, t, n),
|
|
1044
1061
|
maxDevicePixelRatio: e.dwfMaxDevicePixelRatio ?? 2,
|
|
1045
1062
|
maxCanvasPixels: e.dwfMaxCanvasPixels ?? 16777216
|
|
1046
1063
|
};
|
|
1047
1064
|
}
|
|
1048
|
-
function
|
|
1065
|
+
function de(e, t, n) {
|
|
1049
1066
|
return {
|
|
1050
1067
|
wasmUrl: t,
|
|
1051
1068
|
preferWebgl: e.dwfPreferWebgl ?? !0,
|
|
1052
1069
|
preferWasm: e.dwfPreferWasm ?? !0,
|
|
1053
|
-
background:
|
|
1070
|
+
background: n,
|
|
1054
1071
|
maxGpuCacheBytes: e.dwfMaxGpuCacheBytes ?? 160 * 1024 * 1024,
|
|
1055
1072
|
maxCachedScenes: e.dwfMaxCachedScenes ?? 2,
|
|
1056
1073
|
lineWeightMode: e.dwfLineWeightMode ?? "adaptive",
|
|
@@ -1060,39 +1077,39 @@ function Zt(e, t, r) {
|
|
|
1060
1077
|
minFilledAreaCssPx: e.dwfMinFilledAreaCssPx
|
|
1061
1078
|
};
|
|
1062
1079
|
}
|
|
1063
|
-
function
|
|
1064
|
-
typeof
|
|
1080
|
+
function ot(e, t, n) {
|
|
1081
|
+
typeof n == "number" && Number.isFinite(n) && (e[t] = n);
|
|
1065
1082
|
}
|
|
1066
|
-
function
|
|
1083
|
+
function wn(e) {
|
|
1067
1084
|
return e.endsWith("/") ? e : `${e}/`;
|
|
1068
1085
|
}
|
|
1069
|
-
function
|
|
1070
|
-
const [t,
|
|
1071
|
-
return `#${
|
|
1086
|
+
function Cn(e) {
|
|
1087
|
+
const [t, n, r] = e.map((i) => Math.max(0, Math.min(255, Math.round(i * 255))));
|
|
1088
|
+
return `#${dt(t)}${dt(n)}${dt(r)}`;
|
|
1072
1089
|
}
|
|
1073
|
-
function
|
|
1090
|
+
function dt(e) {
|
|
1074
1091
|
return e.toString(16).padStart(2, "0");
|
|
1075
1092
|
}
|
|
1076
|
-
function
|
|
1093
|
+
function Pn(e) {
|
|
1077
1094
|
const t = {};
|
|
1078
|
-
for (const
|
|
1095
|
+
for (const n of e) t[n] = (t[n] ?? 0) + 1;
|
|
1079
1096
|
return t;
|
|
1080
1097
|
}
|
|
1081
|
-
function
|
|
1098
|
+
function kn(e) {
|
|
1082
1099
|
return Array.from(new Set(e));
|
|
1083
1100
|
}
|
|
1084
|
-
function
|
|
1085
|
-
return new
|
|
1086
|
-
new
|
|
1087
|
-
new
|
|
1088
|
-
new
|
|
1101
|
+
function Sn(e = {}) {
|
|
1102
|
+
return new De([
|
|
1103
|
+
new Xe(e),
|
|
1104
|
+
new Ge(e),
|
|
1105
|
+
new mn(e)
|
|
1089
1106
|
]);
|
|
1090
1107
|
}
|
|
1091
|
-
function
|
|
1108
|
+
function Nn(e) {
|
|
1092
1109
|
const t = e;
|
|
1093
1110
|
return t.nativeRenderer === !0 && typeof t.mount == "function";
|
|
1094
1111
|
}
|
|
1095
|
-
const
|
|
1112
|
+
const Mn = {
|
|
1096
1113
|
1: "#ff0000",
|
|
1097
1114
|
2: "#ffff00",
|
|
1098
1115
|
3: "#00ff00",
|
|
@@ -1348,19 +1365,19 @@ const Je = {
|
|
|
1348
1365
|
254: "#bebebe",
|
|
1349
1366
|
255: "#ffffff"
|
|
1350
1367
|
};
|
|
1351
|
-
function
|
|
1368
|
+
function O(e, t = "#ffffff", n = t) {
|
|
1352
1369
|
if (typeof e != "number" || Number.isNaN(e)) return t;
|
|
1353
|
-
const
|
|
1354
|
-
return
|
|
1370
|
+
const r = Math.abs(Math.trunc(e));
|
|
1371
|
+
return r === 0 || r === 256 || r === 257 ? t : r === 7 ? n : Mn[r] ?? t;
|
|
1355
1372
|
}
|
|
1356
|
-
function
|
|
1357
|
-
const
|
|
1358
|
-
return `rgb(${t === "rgb" ?
|
|
1373
|
+
function tt(e, t = "rgb") {
|
|
1374
|
+
const n = Math.max(0, Math.trunc(e)) & 16777215, r = n >> 16 & 255, i = n >> 8 & 255, s = n & 255;
|
|
1375
|
+
return `rgb(${t === "rgb" ? r : s}, ${i}, ${t === "rgb" ? s : r})`;
|
|
1359
1376
|
}
|
|
1360
|
-
function
|
|
1377
|
+
function X(e) {
|
|
1361
1378
|
if (typeof e == "string") {
|
|
1362
1379
|
const t = e.trim();
|
|
1363
|
-
return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ?
|
|
1380
|
+
return t ? /^(#|rgb\(|rgba\(|hsl\(|hsla\()/i.test(t) ? En(t) ?? t : {
|
|
1364
1381
|
red: "#ff0000",
|
|
1365
1382
|
yellow: "#ffff00",
|
|
1366
1383
|
green: "#00ff00",
|
|
@@ -1374,116 +1391,116 @@ function F(e) {
|
|
|
1374
1391
|
}[t.toLowerCase()] : void 0;
|
|
1375
1392
|
}
|
|
1376
1393
|
if (e && typeof e == "object") {
|
|
1377
|
-
const t = e,
|
|
1378
|
-
if ([r, i
|
|
1379
|
-
return Number.isFinite(
|
|
1394
|
+
const t = e, n = Number(t.r ?? t.red), r = Number(t.g ?? t.green), i = Number(t.b ?? t.blue), s = Number(t.a ?? t.alpha ?? 1);
|
|
1395
|
+
if ([n, r, i].every(Number.isFinite))
|
|
1396
|
+
return Number.isFinite(s) && s >= 0 && s < 1 ? `rgba(${n}, ${r}, ${i}, ${s})` : `rgb(${n}, ${r}, ${i})`;
|
|
1380
1397
|
}
|
|
1381
1398
|
}
|
|
1382
|
-
function
|
|
1399
|
+
function En(e) {
|
|
1383
1400
|
if (!e) return;
|
|
1384
1401
|
const t = e.trim();
|
|
1385
1402
|
if (/^#[0-9a-f]{8}$/i.test(t)) {
|
|
1386
|
-
const
|
|
1387
|
-
return
|
|
1403
|
+
const n = parseInt(t.slice(1, 3), 16) / 255, r = parseInt(t.slice(3, 5), 16), i = parseInt(t.slice(5, 7), 16), s = parseInt(t.slice(7, 9), 16);
|
|
1404
|
+
return n >= 0.999 ? `rgb(${r}, ${i}, ${s})` : `rgba(${r}, ${i}, ${s}, ${St(n)})`;
|
|
1388
1405
|
}
|
|
1389
1406
|
if (/^#[0-9a-f]{6}$/i.test(t) || /^#[0-9a-f]{3}$/i.test(t)) return t;
|
|
1390
1407
|
if (/^sc#/i.test(t)) {
|
|
1391
|
-
const
|
|
1392
|
-
if ([i, s,
|
|
1408
|
+
const n = t.slice(3).split(",").map((a) => Number(a.trim())), [r, i, s, o] = n.length === 4 ? n : [1, ...n];
|
|
1409
|
+
if ([r, i, s, o].every(Number.isFinite)) return `rgba(${Math.round(i * 255)}, ${Math.round(s * 255)}, ${Math.round(o * 255)}, ${St(r)})`;
|
|
1393
1410
|
}
|
|
1394
1411
|
}
|
|
1395
|
-
function
|
|
1396
|
-
const
|
|
1397
|
-
let
|
|
1398
|
-
const o =
|
|
1399
|
-
if (o && (
|
|
1400
|
-
const a =
|
|
1401
|
-
typeof a == "number" && a >= 0 && a <= 16777215 && (
|
|
1412
|
+
function V(e, t, n = {}) {
|
|
1413
|
+
const r = n.foreground ?? "#ffffff", i = r;
|
|
1414
|
+
let s;
|
|
1415
|
+
const o = X(e.trueColor) ?? X(e.color) ?? X(e.colorName);
|
|
1416
|
+
if (o && (s = o), !s) {
|
|
1417
|
+
const a = Fn(e, ["trueColor", "true_color", "truecolor", "colorRGB", "colorRgb", "rgbColor", "rgb"]);
|
|
1418
|
+
typeof a == "number" && a >= 0 && a <= 16777215 && (s = tt(a, n.trueColorByteOrder ?? "rgb"));
|
|
1402
1419
|
}
|
|
1403
|
-
if (!
|
|
1404
|
-
const a =
|
|
1405
|
-
typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (
|
|
1420
|
+
if (!s) {
|
|
1421
|
+
const a = be(e.colorIndex, e.colorNumber, e.aci);
|
|
1422
|
+
typeof a == "number" && Math.abs(a) <= 257 && a !== 256 && a !== 0 && a !== 257 && (s = O(a, i, r));
|
|
1406
1423
|
}
|
|
1407
|
-
if (!
|
|
1424
|
+
if (!s && typeof e.color == "number") {
|
|
1408
1425
|
const a = Number(e.color);
|
|
1409
|
-
Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (
|
|
1426
|
+
Math.abs(a) <= 257 ? a !== 0 && a !== 256 && a !== 257 && (s = O(a, i, r)) : s = tt(a, n.trueColorByteOrder ?? "rgb");
|
|
1410
1427
|
}
|
|
1411
|
-
if (!
|
|
1412
|
-
const a =
|
|
1413
|
-
|
|
1428
|
+
if (!s) {
|
|
1429
|
+
const a = Bn(t, e.layer);
|
|
1430
|
+
s = Tn(a, n);
|
|
1414
1431
|
}
|
|
1415
|
-
return
|
|
1432
|
+
return me(s ?? i, n);
|
|
1416
1433
|
}
|
|
1417
|
-
function
|
|
1418
|
-
let
|
|
1419
|
-
const
|
|
1420
|
-
if (
|
|
1421
|
-
const
|
|
1422
|
-
|
|
1434
|
+
function Pt(e, t, n = {}) {
|
|
1435
|
+
let r;
|
|
1436
|
+
const i = X(e.fillColor);
|
|
1437
|
+
if (i && (r = i), !r && typeof e.fillColor == "number") {
|
|
1438
|
+
const s = e.fillColor;
|
|
1439
|
+
r = Math.abs(s) <= 257 ? O(s, n.foreground ?? "#ffffff", n.foreground ?? "#ffffff") : tt(s, n.trueColorByteOrder ?? "rgb");
|
|
1423
1440
|
}
|
|
1424
|
-
return !
|
|
1441
|
+
return !r && typeof e.fillColorIndex == "number" && (r = O(e.fillColorIndex, n.foreground ?? "#ffffff", n.foreground ?? "#ffffff")), r ? me(r, n) : void 0;
|
|
1425
1442
|
}
|
|
1426
|
-
function
|
|
1443
|
+
function me(e, t = {}) {
|
|
1427
1444
|
if (t.contrastMode !== "adaptive") return e;
|
|
1428
|
-
const
|
|
1429
|
-
return
|
|
1445
|
+
const n = t.background ?? "#0b1020", r = t.foreground ?? "#ffffff";
|
|
1446
|
+
return In(e, n, r, t.minColorContrast ?? 2.4);
|
|
1430
1447
|
}
|
|
1431
|
-
function
|
|
1432
|
-
const
|
|
1448
|
+
function In(e, t, n, r = 2.4) {
|
|
1449
|
+
const i = mt(n) ?? { r: 255, g: 255, b: 255, a: 1 }, s = mt(t) ?? { r: 11, g: 16, b: 32, a: 1 }, o = mt(e);
|
|
1433
1450
|
if (!o) return e;
|
|
1434
|
-
const a =
|
|
1435
|
-
if (
|
|
1436
|
-
const c =
|
|
1437
|
-
for (const
|
|
1438
|
-
const
|
|
1439
|
-
if (
|
|
1451
|
+
const a = Zt(o, s);
|
|
1452
|
+
if (pt(a, s) >= r) return e;
|
|
1453
|
+
const c = kt(s), l = c < 0.5 ? { r: 255, g: 255, b: 255, a: o.a } : { r: 0, g: 0, b: 0, a: o.a };
|
|
1454
|
+
for (const h of [0.25, 0.4, 0.55, 0.7, 0.85, 1]) {
|
|
1455
|
+
const u = Dn(o, l, h);
|
|
1456
|
+
if (pt(Zt(u, s), s) >= r) return qt(u);
|
|
1440
1457
|
}
|
|
1441
|
-
return
|
|
1458
|
+
return pt(i, s) >= r ? qt(i) : c < 0.5 ? "#ffffff" : "#000000";
|
|
1442
1459
|
}
|
|
1443
|
-
function
|
|
1460
|
+
function pe(e) {
|
|
1444
1461
|
return e ? e.isVisible !== !1 && e.isFrozen !== !0 : !0;
|
|
1445
1462
|
}
|
|
1446
|
-
function
|
|
1463
|
+
function Tn(e, t) {
|
|
1447
1464
|
if (!e) return;
|
|
1448
|
-
const
|
|
1465
|
+
const n = t.foreground ?? "#ffffff", r = X(e.trueColor);
|
|
1466
|
+
if (r) return r;
|
|
1467
|
+
if (typeof e.trueColor == "number" && e.trueColor >= 0 && e.trueColor <= 16777215) return tt(e.trueColor, t.trueColorByteOrder ?? "rgb");
|
|
1468
|
+
const i = X(e.color);
|
|
1449
1469
|
if (i) return i;
|
|
1450
|
-
if (
|
|
1451
|
-
const s = F(e.color);
|
|
1452
|
-
if (s) return s;
|
|
1453
|
-
if (ir(e.colorIndex)) return E(e.colorIndex, r, r);
|
|
1470
|
+
if (An(e.colorIndex)) return O(e.colorIndex, n, n);
|
|
1454
1471
|
if (typeof e.color == "number") {
|
|
1455
|
-
const
|
|
1456
|
-
return Math.abs(
|
|
1472
|
+
const s = Number(e.color);
|
|
1473
|
+
return Math.abs(s) <= 257 ? O(s, n, n) : tt(s, t.trueColorByteOrder ?? "rgb");
|
|
1457
1474
|
}
|
|
1458
|
-
if (typeof e.colorIndex == "number") return
|
|
1475
|
+
if (typeof e.colorIndex == "number") return O(e.colorIndex, n, n);
|
|
1459
1476
|
}
|
|
1460
|
-
function
|
|
1461
|
-
return
|
|
1477
|
+
function Ln(e) {
|
|
1478
|
+
return be(e.colorIndex, e.colorNumber, e.aci) === 0 ? !0 : e.trueColor === void 0 && e.color === 0;
|
|
1462
1479
|
}
|
|
1463
|
-
function
|
|
1464
|
-
if (!
|
|
1465
|
-
const
|
|
1466
|
-
return { ...e, color:
|
|
1480
|
+
function ge(e, t, n, r = {}) {
|
|
1481
|
+
if (!Ln(e)) return e;
|
|
1482
|
+
const i = V(t, n, r);
|
|
1483
|
+
return { ...e, color: i, trueColor: void 0, colorIndex: void 0, colorNumber: void 0 };
|
|
1467
1484
|
}
|
|
1468
|
-
function
|
|
1485
|
+
function An(e) {
|
|
1469
1486
|
return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
|
|
1470
1487
|
}
|
|
1471
|
-
function
|
|
1488
|
+
function Bn(e, t) {
|
|
1472
1489
|
if (!(!e || !t))
|
|
1473
|
-
return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((
|
|
1490
|
+
return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
1474
1491
|
}
|
|
1475
|
-
function
|
|
1492
|
+
function be(...e) {
|
|
1476
1493
|
for (const t of e)
|
|
1477
1494
|
if (typeof t == "number" && Number.isFinite(t)) return t;
|
|
1478
1495
|
}
|
|
1479
|
-
function
|
|
1480
|
-
const
|
|
1481
|
-
for (const
|
|
1482
|
-
const
|
|
1483
|
-
if (typeof
|
|
1496
|
+
function Fn(e, t) {
|
|
1497
|
+
const n = e;
|
|
1498
|
+
for (const r of t) {
|
|
1499
|
+
const i = n[r];
|
|
1500
|
+
if (typeof i == "number" && Number.isFinite(i)) return i;
|
|
1484
1501
|
}
|
|
1485
1502
|
}
|
|
1486
|
-
function
|
|
1503
|
+
function mt(e) {
|
|
1487
1504
|
const t = e.trim().toLowerCase();
|
|
1488
1505
|
if (/^#[0-9a-f]{3}$/i.test(t))
|
|
1489
1506
|
return {
|
|
@@ -1499,60 +1516,61 @@ function nt(e) {
|
|
|
1499
1516
|
b: parseInt(t.slice(5, 7), 16),
|
|
1500
1517
|
a: 1
|
|
1501
1518
|
};
|
|
1502
|
-
const
|
|
1503
|
-
if (
|
|
1504
|
-
const
|
|
1505
|
-
if (
|
|
1506
|
-
const
|
|
1519
|
+
const n = t.match(/^rgba?\(([^)]+)\)$/i);
|
|
1520
|
+
if (n) {
|
|
1521
|
+
const r = n[1].split(/[,\s/]+/).filter(Boolean).map((i) => Number(i.replace("%", "")));
|
|
1522
|
+
if (r.length >= 3 && r.slice(0, 3).every(Number.isFinite)) {
|
|
1523
|
+
const i = /%/.test(n[1]);
|
|
1507
1524
|
return {
|
|
1508
|
-
r:
|
|
1509
|
-
g:
|
|
1510
|
-
b:
|
|
1511
|
-
a: Number.isFinite(
|
|
1525
|
+
r: H(i ? r[0] * 2.55 : r[0]),
|
|
1526
|
+
g: H(i ? r[1] * 2.55 : r[1]),
|
|
1527
|
+
b: H(i ? r[2] * 2.55 : r[2]),
|
|
1528
|
+
a: Number.isFinite(r[3]) ? Math.max(0, Math.min(1, r[3])) : 1
|
|
1512
1529
|
};
|
|
1513
1530
|
}
|
|
1514
1531
|
}
|
|
1515
1532
|
}
|
|
1516
|
-
function
|
|
1517
|
-
const
|
|
1518
|
-
return
|
|
1519
|
-
r: (e.r * e.a + t.r * t.a * (1 - e.a)) /
|
|
1520
|
-
g: (e.g * e.a + t.g * t.a * (1 - e.a)) /
|
|
1521
|
-
b: (e.b * e.a + t.b * t.a * (1 - e.a)) /
|
|
1522
|
-
a:
|
|
1533
|
+
function Zt(e, t) {
|
|
1534
|
+
const n = e.a + t.a * (1 - e.a);
|
|
1535
|
+
return n <= 0 ? { r: 0, g: 0, b: 0, a: 0 } : {
|
|
1536
|
+
r: (e.r * e.a + t.r * t.a * (1 - e.a)) / n,
|
|
1537
|
+
g: (e.g * e.a + t.g * t.a * (1 - e.a)) / n,
|
|
1538
|
+
b: (e.b * e.a + t.b * t.a * (1 - e.a)) / n,
|
|
1539
|
+
a: n
|
|
1523
1540
|
};
|
|
1524
1541
|
}
|
|
1525
|
-
function
|
|
1526
|
-
const
|
|
1542
|
+
function Dn(e, t, n) {
|
|
1543
|
+
const r = Math.max(0, Math.min(1, n));
|
|
1527
1544
|
return {
|
|
1528
|
-
r: e.r + (t.r - e.r) *
|
|
1529
|
-
g: e.g + (t.g - e.g) *
|
|
1530
|
-
b: e.b + (t.b - e.b) *
|
|
1545
|
+
r: e.r + (t.r - e.r) * r,
|
|
1546
|
+
g: e.g + (t.g - e.g) * r,
|
|
1547
|
+
b: e.b + (t.b - e.b) * r,
|
|
1531
1548
|
a: e.a
|
|
1532
1549
|
};
|
|
1533
1550
|
}
|
|
1534
|
-
function
|
|
1535
|
-
const t = [e.r, e.g, e.b].map((
|
|
1536
|
-
const
|
|
1537
|
-
return
|
|
1551
|
+
function kt(e) {
|
|
1552
|
+
const t = [e.r, e.g, e.b].map((n) => {
|
|
1553
|
+
const r = n / 255;
|
|
1554
|
+
return r <= 0.03928 ? r / 12.92 : ((r + 0.055) / 1.055) ** 2.4;
|
|
1538
1555
|
});
|
|
1539
1556
|
return 0.2126 * t[0] + 0.7152 * t[1] + 0.0722 * t[2];
|
|
1540
1557
|
}
|
|
1541
|
-
function
|
|
1542
|
-
const
|
|
1543
|
-
return (
|
|
1558
|
+
function pt(e, t) {
|
|
1559
|
+
const n = kt(e), r = kt(t), i = Math.max(n, r), s = Math.min(n, r);
|
|
1560
|
+
return (i + 0.05) / (s + 0.05);
|
|
1544
1561
|
}
|
|
1545
|
-
function
|
|
1546
|
-
const t =
|
|
1547
|
-
return e.a < 0.999 ? `rgba(${t}, ${
|
|
1562
|
+
function qt(e) {
|
|
1563
|
+
const t = H(e.r), n = H(e.g), r = H(e.b);
|
|
1564
|
+
return e.a < 0.999 ? `rgba(${t}, ${n}, ${r}, ${St(e.a)})` : `rgb(${t}, ${n}, ${r})`;
|
|
1548
1565
|
}
|
|
1549
|
-
function
|
|
1566
|
+
function H(e) {
|
|
1550
1567
|
return Math.max(0, Math.min(255, Math.round(e)));
|
|
1551
1568
|
}
|
|
1552
|
-
function
|
|
1569
|
+
function St(e) {
|
|
1553
1570
|
return Math.round(e * 1e3) / 1e3;
|
|
1554
1571
|
}
|
|
1555
|
-
|
|
1572
|
+
const Rn = { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 };
|
|
1573
|
+
function ct(e, t) {
|
|
1556
1574
|
return {
|
|
1557
1575
|
a: e.a * t.a + e.c * t.b,
|
|
1558
1576
|
b: e.b * t.a + e.d * t.b,
|
|
@@ -1562,50 +1580,308 @@ function at(e, t) {
|
|
|
1562
1580
|
f: e.b * t.e + e.d * t.f + e.f
|
|
1563
1581
|
};
|
|
1564
1582
|
}
|
|
1565
|
-
function
|
|
1583
|
+
function Kt(e, t) {
|
|
1566
1584
|
return { a: 1, b: 0, c: 0, d: 1, e, f: t };
|
|
1567
1585
|
}
|
|
1568
|
-
function
|
|
1569
|
-
const t = Math.cos(e),
|
|
1570
|
-
return { a: t, b:
|
|
1586
|
+
function ye(e) {
|
|
1587
|
+
const t = Math.cos(e), n = Math.sin(e);
|
|
1588
|
+
return { a: t, b: n, c: -n, d: t, e: 0, f: 0 };
|
|
1571
1589
|
}
|
|
1572
|
-
function
|
|
1590
|
+
function On(e, t = e) {
|
|
1573
1591
|
return { a: e, b: 0, c: 0, d: t, e: 0, f: 0 };
|
|
1574
1592
|
}
|
|
1575
|
-
function
|
|
1593
|
+
function E(e, t) {
|
|
1576
1594
|
return {
|
|
1577
1595
|
x: e.x * t.a + e.y * t.c + t.e,
|
|
1578
1596
|
y: e.x * t.b + e.y * t.d + t.f,
|
|
1579
1597
|
z: "z" in e ? e.z : void 0
|
|
1580
1598
|
};
|
|
1581
1599
|
}
|
|
1582
|
-
function
|
|
1600
|
+
function Jt(e, t) {
|
|
1583
1601
|
if (e)
|
|
1584
|
-
return e.map((
|
|
1602
|
+
return e.map((n) => ({ cmd: n.cmd, points: n.points.map((r) => E(r, t)) }));
|
|
1585
1603
|
}
|
|
1586
|
-
function
|
|
1587
|
-
const
|
|
1588
|
-
let a =
|
|
1589
|
-
return a =
|
|
1604
|
+
function Bt(e, t = { x: 0, y: 0 }) {
|
|
1605
|
+
const n = e.insertionPoint ?? { x: 0, y: 0 }, r = e.scale, i = Number(typeof r == "object" && r ? r.x ?? 1 : e.scaleX ?? 1), s = Number(typeof r == "object" && r ? r.y ?? i : e.scaleY ?? i), o = Number(e.rotation ?? 0);
|
|
1606
|
+
let a = Kt(n.x, n.y);
|
|
1607
|
+
return a = ct(a, ye(Number.isFinite(o) ? o : 0)), a = ct(a, On(Number.isFinite(i) ? i : 1, Number.isFinite(s) ? s : 1)), a = ct(a, Kt(-t.x, -t.y)), a;
|
|
1590
1608
|
}
|
|
1591
|
-
function
|
|
1592
|
-
const
|
|
1593
|
-
if (e.startPoint && (
|
|
1594
|
-
const
|
|
1595
|
-
|
|
1609
|
+
function $(e, t) {
|
|
1610
|
+
const n = { ...e };
|
|
1611
|
+
if (e.startPoint && (n.startPoint = E(e.startPoint, t)), e.endPoint && (n.endPoint = E(e.endPoint, t)), e.center && (n.center = E(e.center, t)), e.insertionPoint && (n.insertionPoint = E(e.insertionPoint, t)), e.majorAxisEndPoint) {
|
|
1612
|
+
const o = E({ x: 0, y: 0 }, t), a = E(e.majorAxisEndPoint, t);
|
|
1613
|
+
n.majorAxisEndPoint = { x: a.x - o.x, y: a.y - o.y, z: a.z };
|
|
1596
1614
|
}
|
|
1597
|
-
e.vertices && (
|
|
1598
|
-
var
|
|
1615
|
+
e.vertices && (n.vertices = e.vertices.map((o) => ({ ...E(o, t), bulge: o.bulge, startWidth: o.startWidth, endWidth: o.endWidth }))), e.points && (n.points = e.points.map((o) => E(o, t))), e.controlPoints && (n.controlPoints = e.controlPoints.map((o) => E(o, t))), e.fitPoints && (n.fitPoints = e.fitPoints.map((o) => E(o, t))), e.attribs && (n.attribs = e.attribs.map((o) => $(o, t))), e.commands && (n.commands = Jt(e.commands, t)), e.loops && (n.loops = e.loops.map((o) => {
|
|
1616
|
+
var a;
|
|
1599
1617
|
return {
|
|
1600
|
-
...
|
|
1601
|
-
vertices: (
|
|
1602
|
-
commands:
|
|
1618
|
+
...o,
|
|
1619
|
+
vertices: (a = o.vertices) == null ? void 0 : a.map((c) => E(c, t)),
|
|
1620
|
+
commands: Jt(o.commands, t)
|
|
1603
1621
|
};
|
|
1604
1622
|
}));
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1623
|
+
const r = Math.sqrt(Math.abs(t.a * t.d - t.b * t.c));
|
|
1624
|
+
typeof e.radius == "number" && Number.isFinite(r) && (n.radius = e.radius * r);
|
|
1625
|
+
const i = Math.atan2(t.b, t.a), s = e.kind === "ellipse" || String(e.type ?? "").toUpperCase() === "ELLIPSE";
|
|
1626
|
+
return Number.isFinite(i) && Math.abs(i) > 1e-14 && ((typeof e.rotation == "number" || e.kind === "text" || e.kind === "insert") && (n.rotation = Number(e.rotation ?? 0) + i), !s && typeof e.startAngle == "number" && (n.startAngle = e.startAngle + i), !s && typeof e.endAngle == "number" && (n.endAngle = e.endAngle + i)), t.a * t.d - t.b * t.c < 0 && n.vertices && (n.vertices = n.vertices.map((o) => ({ ...o, bulge: typeof o.bulge == "number" ? -o.bulge : void 0 }))), n;
|
|
1627
|
+
}
|
|
1628
|
+
const Wn = 16, _n = 96, zn = 0.01;
|
|
1629
|
+
function ve(e, t = {}) {
|
|
1630
|
+
const n = L();
|
|
1631
|
+
for (const i of e.pages ?? [])
|
|
1632
|
+
S(n, { x: 0, y: 0 }), S(n, { x: i.width, y: i.height });
|
|
1633
|
+
const r = we(e, t);
|
|
1634
|
+
for (const i of e.entities) le(n, Ce(i, r));
|
|
1635
|
+
return he(n);
|
|
1636
|
+
}
|
|
1637
|
+
function xe(e, t, n = "auto", r = {}) {
|
|
1638
|
+
if (n === "extents") return t;
|
|
1639
|
+
const i = Yn(e);
|
|
1640
|
+
if (!i) return t;
|
|
1641
|
+
if (n === "saved-view") return i;
|
|
1642
|
+
const s = L(), o = we(e, r);
|
|
1643
|
+
let a = 0;
|
|
1644
|
+
for (const c of e.entities) {
|
|
1645
|
+
const l = Hn(Ce(c, o), i);
|
|
1646
|
+
l && (a++, le(s, l));
|
|
1647
|
+
}
|
|
1648
|
+
return a === 0 || !Un(s, i) ? i : he(s);
|
|
1649
|
+
}
|
|
1650
|
+
function Yn(e) {
|
|
1651
|
+
const t = e.savedView;
|
|
1652
|
+
if (!t || t.source !== "vport" || t.sceneTransformApplied !== !0 || !g(t.center)) return;
|
|
1653
|
+
const n = Number(t.viewHeight), r = Number(t.aspectRatio);
|
|
1654
|
+
if (!Number.isFinite(n) || n <= 1e-9 || !Number.isFinite(r) || r <= 1e-9) return;
|
|
1655
|
+
const i = n * r;
|
|
1656
|
+
return {
|
|
1657
|
+
minX: t.center.x - i / 2,
|
|
1658
|
+
minY: t.center.y - n / 2,
|
|
1659
|
+
maxX: t.center.x + i / 2,
|
|
1660
|
+
maxY: t.center.y + n / 2
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
function we(e, t) {
|
|
1664
|
+
return {
|
|
1665
|
+
document: e,
|
|
1666
|
+
maxInsertDepth: Math.max(0, Math.floor(t.maxInsertDepth ?? Wn)),
|
|
1667
|
+
maxCurveSegments: Math.max(12, Math.floor(t.maxCurveSegments ?? _n))
|
|
1668
|
+
};
|
|
1669
|
+
}
|
|
1670
|
+
function Ce(e, t, n = 0) {
|
|
1671
|
+
const r = L();
|
|
1672
|
+
return Pe(r, e, t, n), r;
|
|
1673
|
+
}
|
|
1674
|
+
function Pe(e, t, n, r) {
|
|
1675
|
+
const i = String(t.type ?? "").toUpperCase(), s = t.kind ?? J(i);
|
|
1676
|
+
if (s === "insert") {
|
|
1677
|
+
const o = Vn(n.document, t.blockName ?? t.name);
|
|
1678
|
+
if (o && r < n.maxInsertDepth) {
|
|
1679
|
+
const a = Bt(t, o.basePoint ?? { x: 0, y: 0 });
|
|
1680
|
+
for (const c of o.entities) Pe(e, $(c, a), n, r + 1);
|
|
1681
|
+
return;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
if (s === "line")
|
|
1685
|
+
g(t.startPoint) && S(e, t.startPoint), g(t.endPoint) && S(e, t.endPoint);
|
|
1686
|
+
else if (s === "circle" || s === "arc")
|
|
1687
|
+
g(t.center) && Number.isFinite(t.radius) && je(e, t.center, Number(t.radius));
|
|
1688
|
+
else if (s === "polyline" || s === "solid" || s === "spline")
|
|
1689
|
+
for (const o of [...t.vertices ?? [], ...t.points ?? [], ...t.controlPoints ?? [], ...t.fitPoints ?? []])
|
|
1690
|
+
g(o) && S(e, o);
|
|
1691
|
+
else if (s === "ellipse") {
|
|
1692
|
+
if (g(t.center) && g(t.majorAxisEndPoint))
|
|
1693
|
+
for (const o of Lt(
|
|
1694
|
+
t.center,
|
|
1695
|
+
t.majorAxisEndPoint,
|
|
1696
|
+
Number(t.axisRatio ?? 1),
|
|
1697
|
+
Number(t.startAngle ?? 0),
|
|
1698
|
+
Number(t.endAngle ?? Math.PI * 2),
|
|
1699
|
+
n.maxCurveSegments
|
|
1700
|
+
)) S(e, o);
|
|
1701
|
+
} else if (s === "path")
|
|
1702
|
+
for (const o of t.commands ?? []) for (const a of o.points) S(e, a);
|
|
1703
|
+
else if (s === "hatch")
|
|
1704
|
+
for (const o of t.loops ?? []) {
|
|
1705
|
+
for (const a of o.vertices ?? []) S(e, a);
|
|
1706
|
+
for (const a of o.commands ?? []) for (const c of a.points) S(e, c);
|
|
1707
|
+
}
|
|
1708
|
+
else {
|
|
1709
|
+
const o = Xn(t);
|
|
1710
|
+
o && S(e, o);
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
function Xn(e) {
|
|
1714
|
+
for (const t of ["startPoint", "insertionPoint", "center", "point", "location"]) {
|
|
1715
|
+
const n = e[t];
|
|
1716
|
+
if (g(n)) return n;
|
|
1717
|
+
}
|
|
1718
|
+
if (Array.isArray(e.vertices) && g(e.vertices[0])) return e.vertices[0];
|
|
1719
|
+
if (Array.isArray(e.commands)) {
|
|
1720
|
+
const t = e.commands.find((n) => n.points.length > 0);
|
|
1721
|
+
if (t) return t.points[0];
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function Vn(e, t) {
|
|
1725
|
+
if (t)
|
|
1726
|
+
return e.blocks[t] ?? e.blocks[t.toLowerCase()] ?? Object.values(e.blocks).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
1727
|
+
}
|
|
1728
|
+
function Hn(e, t) {
|
|
1729
|
+
if (!I(e) || !I(t)) return;
|
|
1730
|
+
const n = {
|
|
1731
|
+
minX: Math.max(e.minX, t.minX),
|
|
1732
|
+
minY: Math.max(e.minY, t.minY),
|
|
1733
|
+
maxX: Math.min(e.maxX, t.maxX),
|
|
1734
|
+
maxY: Math.min(e.maxY, t.maxY)
|
|
1735
|
+
};
|
|
1736
|
+
return I(n) ? n : void 0;
|
|
1737
|
+
}
|
|
1738
|
+
function Un(e, t) {
|
|
1739
|
+
if (!I(e) || !I(t)) return !1;
|
|
1740
|
+
const n = Math.hypot(e.maxX - e.minX, e.maxY - e.minY), r = Math.hypot(t.maxX - t.minX, t.maxY - t.minY);
|
|
1741
|
+
return r > 1e-9 && n / r >= zn;
|
|
1742
|
+
}
|
|
1743
|
+
const Qt = 1e5, ke = /* @__PURE__ */ new Set(["", "bylayer", "15"]), Ft = /* @__PURE__ */ new Set(["byblock", "14"]), $n = /* @__PURE__ */ new Set(["continuous", "16"]), U = (e) => String(e ?? "").trim().toLowerCase();
|
|
1744
|
+
function jn(e) {
|
|
1745
|
+
return Ft.has(U(e));
|
|
1746
|
+
}
|
|
1747
|
+
function Se(e, t, n) {
|
|
1748
|
+
if (!jn(e.lineType)) return e;
|
|
1749
|
+
const r = Ne(t, n);
|
|
1750
|
+
return {
|
|
1751
|
+
...e,
|
|
1752
|
+
lineType: r || "Continuous",
|
|
1753
|
+
lineTypeScale: q(e.lineTypeScale, 1) * q(t.lineTypeScale, 1)
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1756
|
+
function Ne(e, t) {
|
|
1757
|
+
var i;
|
|
1758
|
+
let n = String(e.lineType ?? "").trim();
|
|
1759
|
+
const r = U(n);
|
|
1760
|
+
return ke.has(r) ? n = ((i = Kn(t, e.layer)) == null ? void 0 : i.lineType) ?? "Continuous" : Ft.has(r) && (n = "Continuous"), n || "Continuous";
|
|
1761
|
+
}
|
|
1762
|
+
function Nt(e, t) {
|
|
1763
|
+
var u, f;
|
|
1764
|
+
if (!t) return;
|
|
1765
|
+
const n = Ne(e, t), r = U(n);
|
|
1766
|
+
if ($n.has(r) || ke.has(r) || Ft.has(r)) return;
|
|
1767
|
+
const i = qn(t, n);
|
|
1768
|
+
if (!(i != null && i.pattern.length)) return;
|
|
1769
|
+
const s = q(e.lineTypeScale, q((u = t.header) == null ? void 0 : u.CELTSCALE, 1)), o = q((f = t.header) == null ? void 0 : f.LTSCALE, 1) * s, a = Gn(i, o), c = a.reduce((m, p) => m + p.length, 0);
|
|
1770
|
+
if (!Number.isFinite(c) || c <= 1e-9) return;
|
|
1771
|
+
const l = a.some((m) => !m.draw && m.length > 1e-12), h = a.some((m) => m.marker);
|
|
1772
|
+
if (!(!l && !h))
|
|
1773
|
+
return { name: i.name, segments: Zn(a, l), runs: a, period: c };
|
|
1774
|
+
}
|
|
1775
|
+
function Mr(e, t, n) {
|
|
1776
|
+
return Dt(e, t, n).segments;
|
|
1777
|
+
}
|
|
1778
|
+
function Dt(e, t, n, r = Qt) {
|
|
1779
|
+
const i = e.filter((y) => Number.isFinite(y.x) && Number.isFinite(y.y));
|
|
1780
|
+
if (i.length < 2 || n.runs.length === 0) return { segments: [], dots: [] };
|
|
1781
|
+
const s = [];
|
|
1782
|
+
for (let y = 0; y < i.length - 1; y++) s.push([i[y], i[y + 1]]);
|
|
1783
|
+
t && s.push([i[i.length - 1], i[0]]);
|
|
1784
|
+
const o = Number.isFinite(r) ? Math.max(1, Math.floor(r)) : Qt, a = s.reduce((y, [v, N]) => y + Math.hypot(N.x - v.x, N.y - v.y), 0), l = (n.period > 1e-12 ? a / n.period : Number.POSITIVE_INFINITY) * Math.max(1, n.runs.length);
|
|
1785
|
+
if (!Number.isFinite(l) || l > o)
|
|
1786
|
+
return { segments: s, dots: [] };
|
|
1787
|
+
const h = { segments: [], dots: [] };
|
|
1788
|
+
let u = 0, f = n.runs[0].length, m = !0;
|
|
1789
|
+
const p = (y) => {
|
|
1790
|
+
const v = h.dots[h.dots.length - 1];
|
|
1791
|
+
v && Math.hypot(v.x - y.x, v.y - y.y) <= 1e-10 || h.dots.push(y);
|
|
1792
|
+
}, C = () => {
|
|
1793
|
+
u = (u + 1) % n.runs.length, f = n.runs[u].length, m = !0;
|
|
1794
|
+
};
|
|
1795
|
+
for (const [y, v] of s) {
|
|
1796
|
+
const N = v.x - y.x, A = v.y - y.y, T = Math.hypot(N, A);
|
|
1797
|
+
if (T <= 1e-14) continue;
|
|
1798
|
+
let B = 0;
|
|
1799
|
+
for (; B < T - 1e-12; ) {
|
|
1800
|
+
let Rt = 0;
|
|
1801
|
+
for (; f <= 1e-12 && Rt < n.runs.length; ) {
|
|
1802
|
+
const F = n.runs[u];
|
|
1803
|
+
if (m && F.marker) {
|
|
1804
|
+
const j = B / T;
|
|
1805
|
+
p({ x: y.x + N * j, y: y.y + A * j });
|
|
1806
|
+
}
|
|
1807
|
+
C(), Rt++;
|
|
1808
|
+
}
|
|
1809
|
+
if (f <= 1e-12) break;
|
|
1810
|
+
const Ot = n.runs[u];
|
|
1811
|
+
if (m) {
|
|
1812
|
+
if (Ot.marker) {
|
|
1813
|
+
const F = B / T;
|
|
1814
|
+
p({ x: y.x + N * F, y: y.y + A * F });
|
|
1815
|
+
}
|
|
1816
|
+
m = !1;
|
|
1817
|
+
}
|
|
1818
|
+
const et = Math.min(f, T - B);
|
|
1819
|
+
if (Ot.draw && et > 1e-12) {
|
|
1820
|
+
const F = B / T, j = (B + et) / T;
|
|
1821
|
+
h.segments.push([
|
|
1822
|
+
{ x: y.x + N * F, y: y.y + A * F },
|
|
1823
|
+
{ x: y.x + N * j, y: y.y + A * j }
|
|
1824
|
+
]);
|
|
1825
|
+
}
|
|
1826
|
+
B += et, f -= et, f <= 1e-12 && C();
|
|
1827
|
+
}
|
|
1828
|
+
}
|
|
1829
|
+
return h;
|
|
1830
|
+
}
|
|
1831
|
+
function Gn(e, t) {
|
|
1832
|
+
const n = [];
|
|
1833
|
+
for (const r of e.pattern) {
|
|
1834
|
+
const i = Number(r.length), s = Number(r.elementTypeFlag ?? 0) !== 0;
|
|
1835
|
+
Number.isFinite(i) && n.push({ draw: i >= 0, length: Math.abs(i) * t, marker: i >= 0 && (i === 0 || s) });
|
|
1836
|
+
}
|
|
1837
|
+
return n;
|
|
1838
|
+
}
|
|
1839
|
+
function Zn(e, t) {
|
|
1840
|
+
if (!t) return [];
|
|
1841
|
+
const n = [];
|
|
1842
|
+
for (const i of e) {
|
|
1843
|
+
if (i.length <= 1e-12) continue;
|
|
1844
|
+
const s = n[n.length - 1];
|
|
1845
|
+
(s == null ? void 0 : s.draw) === i.draw ? s.length += i.length : n.push({ draw: i.draw, length: i.length });
|
|
1846
|
+
}
|
|
1847
|
+
const r = [];
|
|
1848
|
+
for (const i of n) {
|
|
1849
|
+
const s = r.length % 2 === 0;
|
|
1850
|
+
i.draw !== s && r.push(1e-9), r.push(i.length);
|
|
1851
|
+
}
|
|
1852
|
+
return r.length % 2 === 1 && r.push(1e-9), r;
|
|
1853
|
+
}
|
|
1854
|
+
function qn(e, t) {
|
|
1855
|
+
const n = U(t), r = e.lineTypes ?? {};
|
|
1856
|
+
return r[t] ?? r[n] ?? Object.values(r).find((i) => U(i.name) === n || U(i.handle) === n);
|
|
1857
|
+
}
|
|
1858
|
+
function Kn(e, t) {
|
|
1859
|
+
if (!(!e || !t))
|
|
1860
|
+
return e.layers[t] ?? e.layers[t.toLowerCase()] ?? Object.values(e.layers).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
1607
1861
|
}
|
|
1608
|
-
|
|
1862
|
+
function q(e, t) {
|
|
1863
|
+
const n = Number(e);
|
|
1864
|
+
return Number.isFinite(n) && n > 0 ? n : t;
|
|
1865
|
+
}
|
|
1866
|
+
const Jn = (e) => Math.abs(e.a - 1) < 1e-12 && Math.abs(e.b) < 1e-12 && Math.abs(e.c) < 1e-12 && Math.abs(e.d - 1) < 1e-12 && Math.abs(e.e) < 1e-9 && Math.abs(e.f) < 1e-9;
|
|
1867
|
+
function Me(e) {
|
|
1868
|
+
var n, r, i;
|
|
1869
|
+
if (e.metadata.sceneTransformApplied === !0 || ((n = e.savedView) == null ? void 0 : n.sceneTransformApplied) === !1) return e;
|
|
1870
|
+
const t = ((r = e.savedView) == null ? void 0 : r.sceneTransform) ?? Rn;
|
|
1871
|
+
return Jn(t) ? e : {
|
|
1872
|
+
...e,
|
|
1873
|
+
entities: e.entities.map((s) => $(s, t)),
|
|
1874
|
+
pages: (i = e.pages) == null ? void 0 : i.map((s) => ({
|
|
1875
|
+
...s,
|
|
1876
|
+
entities: s.entities.map((o) => $(o, t))
|
|
1877
|
+
})),
|
|
1878
|
+
metadata: {
|
|
1879
|
+
...e.metadata,
|
|
1880
|
+
sceneTransformApplied: !0
|
|
1881
|
+
}
|
|
1882
|
+
};
|
|
1883
|
+
}
|
|
1884
|
+
const Qn = {
|
|
1609
1885
|
background: "#0b1020",
|
|
1610
1886
|
foreground: "#ffffff",
|
|
1611
1887
|
showUnsupportedMarkers: !1,
|
|
@@ -1616,6 +1892,7 @@ const hr = {
|
|
|
1616
1892
|
wheelZoomFactor: 1.14,
|
|
1617
1893
|
trueColorByteOrder: "rgb",
|
|
1618
1894
|
maxInsertDepth: 16,
|
|
1895
|
+
fitMode: "auto",
|
|
1619
1896
|
contrastMode: "adaptive",
|
|
1620
1897
|
minColorContrast: 2.4,
|
|
1621
1898
|
maxCurveSegments: 96,
|
|
@@ -1628,13 +1905,14 @@ const hr = {
|
|
|
1628
1905
|
preserveDrawingBuffer: !1,
|
|
1629
1906
|
enableSpatialIndex: !0
|
|
1630
1907
|
};
|
|
1631
|
-
class
|
|
1632
|
-
constructor(t,
|
|
1908
|
+
class te {
|
|
1909
|
+
constructor(t, n = {}) {
|
|
1633
1910
|
d(this, "canvas");
|
|
1634
1911
|
d(this, "ctx");
|
|
1635
1912
|
d(this, "opts");
|
|
1913
|
+
d(this, "sourceDocument");
|
|
1636
1914
|
d(this, "document");
|
|
1637
|
-
d(this, "bounds",
|
|
1915
|
+
d(this, "bounds", L());
|
|
1638
1916
|
d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
|
|
1639
1917
|
d(this, "fitScale", 1);
|
|
1640
1918
|
d(this, "dpr", 1);
|
|
@@ -1645,52 +1923,61 @@ class Ot {
|
|
|
1645
1923
|
d(this, "stats", { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "canvas2d" });
|
|
1646
1924
|
d(this, "onStats");
|
|
1647
1925
|
d(this, "onViewChange");
|
|
1648
|
-
const
|
|
1649
|
-
if (!
|
|
1650
|
-
this.canvas = t, this.ctx =
|
|
1926
|
+
const r = t.getContext("2d");
|
|
1927
|
+
if (!r) throw new Error("Canvas 2D context is not available.");
|
|
1928
|
+
this.canvas = t, this.ctx = r, this.opts = { ...Qn, ...n }, this.canvas.classList.add("cad-viewer-canvas"), this.bindEvents(), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => this.resize()), this.resizeObserver.observe(t)), this.resize();
|
|
1651
1929
|
}
|
|
1652
1930
|
destroy() {
|
|
1653
1931
|
var t;
|
|
1654
1932
|
(t = this.resizeObserver) == null || t.disconnect();
|
|
1655
1933
|
}
|
|
1656
1934
|
clear() {
|
|
1657
|
-
this.document = void 0, this.bounds =
|
|
1935
|
+
this.sourceDocument = void 0, this.document = void 0, this.bounds = L(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
1658
1936
|
}
|
|
1659
1937
|
setDocument(t) {
|
|
1660
|
-
this.document = t, this.bounds = this.
|
|
1938
|
+
this.sourceDocument = t, this.document = Me(t), this.bounds = ve(this.document, this.boundsOptions()), this.fitToView();
|
|
1661
1939
|
}
|
|
1662
1940
|
getDocument() {
|
|
1663
1941
|
return this.document;
|
|
1664
1942
|
}
|
|
1943
|
+
getSourceDocument() {
|
|
1944
|
+
return this.sourceDocument;
|
|
1945
|
+
}
|
|
1665
1946
|
setOptions(t) {
|
|
1666
|
-
|
|
1947
|
+
const n = t.fitMode !== void 0 && t.fitMode !== this.opts.fitMode;
|
|
1948
|
+
if (Object.assign(this.opts, t), n && this.document) {
|
|
1949
|
+
this.fitToView();
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1952
|
+
this.render(), this.emitViewChange();
|
|
1667
1953
|
}
|
|
1668
1954
|
getOptions() {
|
|
1669
1955
|
return { ...this.opts };
|
|
1670
1956
|
}
|
|
1671
|
-
fitToView(t = 0.92) {
|
|
1672
|
-
|
|
1957
|
+
fitToView(t = 0.92, n = this.opts.fitMode) {
|
|
1958
|
+
const r = this.document ? xe(this.document, this.bounds, n, this.boundsOptions()) : this.bounds;
|
|
1959
|
+
if (!I(r)) {
|
|
1673
1960
|
this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
1674
1961
|
return;
|
|
1675
1962
|
}
|
|
1676
|
-
const
|
|
1677
|
-
this.fitScale =
|
|
1678
|
-
centerX: (
|
|
1679
|
-
centerY: (
|
|
1680
|
-
scale:
|
|
1963
|
+
const i = Math.max(1, this.cssWidth), s = Math.max(1, this.cssHeight), o = Math.max(r.maxX - r.minX, 1e-9), a = Math.max(r.maxY - r.minY, 1e-9), c = this.clampScale(Math.min(i / o, s / a) * t);
|
|
1964
|
+
this.fitScale = c, this.view = {
|
|
1965
|
+
centerX: (r.minX + r.maxX) / 2,
|
|
1966
|
+
centerY: (r.minY + r.maxY) / 2,
|
|
1967
|
+
scale: c
|
|
1681
1968
|
}, this.render(), this.emitViewChange();
|
|
1682
1969
|
}
|
|
1683
1970
|
resize() {
|
|
1684
1971
|
this.dpr = Math.max(1, window.devicePixelRatio || 1);
|
|
1685
|
-
const t = Math.max(1, Math.floor(this.cssWidth * this.dpr)),
|
|
1686
|
-
(this.canvas.width !== t || this.canvas.height !==
|
|
1972
|
+
const t = Math.max(1, Math.floor(this.cssWidth * this.dpr)), n = Math.max(1, Math.floor(this.cssHeight * this.dpr));
|
|
1973
|
+
(this.canvas.width !== t || this.canvas.height !== n) && (this.canvas.width = t, this.canvas.height = n), this.render(), this.emitViewChange();
|
|
1687
1974
|
}
|
|
1688
|
-
zoom(t,
|
|
1975
|
+
zoom(t, n) {
|
|
1689
1976
|
if (!Number.isFinite(t) || t <= 0) return;
|
|
1690
|
-
const
|
|
1977
|
+
const r = n ?? { x: this.cssWidth / 2, y: this.cssHeight / 2 }, i = this.screenToWorld(r);
|
|
1691
1978
|
this.view.scale = this.clampScale(this.view.scale * t);
|
|
1692
|
-
const
|
|
1693
|
-
this.view.centerX +=
|
|
1979
|
+
const s = this.screenToWorld(r);
|
|
1980
|
+
this.view.centerX += i.x - s.x, this.view.centerY += i.y - s.y, this.render(), this.emitViewChange();
|
|
1694
1981
|
}
|
|
1695
1982
|
zoomIn() {
|
|
1696
1983
|
this.zoom(this.opts.wheelZoomFactor);
|
|
@@ -1698,8 +1985,8 @@ class Ot {
|
|
|
1698
1985
|
zoomOut() {
|
|
1699
1986
|
this.zoom(1 / this.opts.wheelZoomFactor);
|
|
1700
1987
|
}
|
|
1701
|
-
panByScreenDelta(t,
|
|
1702
|
-
!Number.isFinite(t) || !Number.isFinite(
|
|
1988
|
+
panByScreenDelta(t, n) {
|
|
1989
|
+
!Number.isFinite(t) || !Number.isFinite(n) || (this.view.centerX -= t / this.view.scale, this.view.centerY += n / this.view.scale, this.render(), this.emitViewChange());
|
|
1703
1990
|
}
|
|
1704
1991
|
setViewState(t) {
|
|
1705
1992
|
if (![t.centerX, t.centerY, t.scale].every(Number.isFinite)) throw new Error("Invalid view state.");
|
|
@@ -1712,7 +1999,7 @@ class Ot {
|
|
|
1712
1999
|
return { ...this.bounds };
|
|
1713
2000
|
}
|
|
1714
2001
|
getStats() {
|
|
1715
|
-
return
|
|
2002
|
+
return tr(this.stats);
|
|
1716
2003
|
}
|
|
1717
2004
|
getZoomRatio() {
|
|
1718
2005
|
return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
|
|
@@ -1733,13 +2020,13 @@ class Ot {
|
|
|
1733
2020
|
};
|
|
1734
2021
|
}
|
|
1735
2022
|
render() {
|
|
1736
|
-
var
|
|
2023
|
+
var n, r;
|
|
1737
2024
|
const t = performance.now();
|
|
1738
2025
|
if (this.stats = { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: 0, backend: "canvas2d" }, this.clearCanvas(), this.document) {
|
|
1739
|
-
this.opts.showPageBounds && ((
|
|
1740
|
-
for (const
|
|
2026
|
+
this.opts.showPageBounds && ((n = this.document.pages) != null && n.length) && this.drawPageBounds(this.document);
|
|
2027
|
+
for (const i of this.document.entities) this.drawEntityTracked(i, 0);
|
|
1741
2028
|
}
|
|
1742
|
-
return this.stats.renderElapsedMs = performance.now() - t, (
|
|
2029
|
+
return this.stats.renderElapsedMs = performance.now() - t, (r = this.onStats) == null || r.call(this, this.getStats()), this.getStats();
|
|
1743
2030
|
}
|
|
1744
2031
|
get cssWidth() {
|
|
1745
2032
|
return this.canvas.clientWidth || 1;
|
|
@@ -1748,17 +2035,17 @@ class Ot {
|
|
|
1748
2035
|
return this.canvas.clientHeight || 1;
|
|
1749
2036
|
}
|
|
1750
2037
|
bindEvents() {
|
|
1751
|
-
this.canvas.addEventListener("wheel", (
|
|
1752
|
-
|
|
1753
|
-
const
|
|
1754
|
-
this.zoom(
|
|
1755
|
-
}, { passive: !1 }), this.canvas.addEventListener("pointerdown", (
|
|
1756
|
-
this.canvas.setPointerCapture(
|
|
1757
|
-
}), this.canvas.addEventListener("pointermove", (
|
|
1758
|
-
!this.isDragging || !this.lastPointer || (this.panByScreenDelta(
|
|
2038
|
+
this.canvas.addEventListener("wheel", (n) => {
|
|
2039
|
+
n.preventDefault();
|
|
2040
|
+
const r = n.deltaY < 0 ? this.opts.wheelZoomFactor : 1 / this.opts.wheelZoomFactor;
|
|
2041
|
+
this.zoom(r, { x: n.offsetX, y: n.offsetY });
|
|
2042
|
+
}, { passive: !1 }), this.canvas.addEventListener("pointerdown", (n) => {
|
|
2043
|
+
this.canvas.setPointerCapture(n.pointerId), this.isDragging = !0, this.lastPointer = { x: n.clientX, y: n.clientY }, this.canvas.classList.add("is-dragging");
|
|
2044
|
+
}), this.canvas.addEventListener("pointermove", (n) => {
|
|
2045
|
+
!this.isDragging || !this.lastPointer || (this.panByScreenDelta(n.clientX - this.lastPointer.x, n.clientY - this.lastPointer.y), this.lastPointer = { x: n.clientX, y: n.clientY });
|
|
1759
2046
|
});
|
|
1760
|
-
const t = (
|
|
1761
|
-
|
|
2047
|
+
const t = (n) => {
|
|
2048
|
+
n && this.canvas.hasPointerCapture(n.pointerId) && this.canvas.releasePointerCapture(n.pointerId), this.isDragging = !1, this.lastPointer = void 0, this.canvas.classList.remove("is-dragging");
|
|
1762
2049
|
};
|
|
1763
2050
|
this.canvas.addEventListener("pointerup", t), this.canvas.addEventListener("pointercancel", () => t());
|
|
1764
2051
|
}
|
|
@@ -1767,27 +2054,27 @@ class Ot {
|
|
|
1767
2054
|
t.save(), t.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), t.clearRect(0, 0, this.cssWidth, this.cssHeight), t.fillStyle = this.opts.background, t.fillRect(0, 0, this.cssWidth, this.cssHeight), t.restore();
|
|
1768
2055
|
}
|
|
1769
2056
|
drawPageBounds(t) {
|
|
1770
|
-
const
|
|
1771
|
-
|
|
1772
|
-
for (const
|
|
1773
|
-
const
|
|
1774
|
-
|
|
2057
|
+
const n = this.ctx;
|
|
2058
|
+
n.save(), n.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), n.strokeStyle = "rgba(148, 163, 184, 0.35)", n.lineWidth = 1, n.setLineDash([8, 6]);
|
|
2059
|
+
for (const r of t.pages ?? []) {
|
|
2060
|
+
const i = this.worldToScreen({ x: 0, y: 0 }), s = this.worldToScreen({ x: r.width, y: r.height });
|
|
2061
|
+
n.strokeRect(Math.min(i.x, s.x), Math.min(i.y, s.y), Math.abs(s.x - i.x), Math.abs(s.y - i.y));
|
|
1775
2062
|
}
|
|
1776
|
-
|
|
2063
|
+
n.restore();
|
|
1777
2064
|
}
|
|
1778
|
-
drawEntityTracked(t,
|
|
2065
|
+
drawEntityTracked(t, n) {
|
|
1779
2066
|
this.stats.total++;
|
|
1780
|
-
const
|
|
1781
|
-
this.stats.byType[
|
|
1782
|
-
const
|
|
1783
|
-
if (t.isVisible === !1 || !
|
|
2067
|
+
const r = String(t.type ?? "UNKNOWN").toUpperCase();
|
|
2068
|
+
this.stats.byType[r] = (this.stats.byType[r] ?? 0) + 1;
|
|
2069
|
+
const i = this.lookupLayer(t.layer);
|
|
2070
|
+
if (t.isVisible === !1 || !pe(i)) {
|
|
1784
2071
|
this.stats.skipped++;
|
|
1785
2072
|
return;
|
|
1786
2073
|
}
|
|
1787
|
-
this.drawEntity(t,
|
|
2074
|
+
this.drawEntity(t, r, n);
|
|
1788
2075
|
}
|
|
1789
|
-
drawEntity(t,
|
|
1790
|
-
switch (t.kind ??
|
|
2076
|
+
drawEntity(t, n, r) {
|
|
2077
|
+
switch (t.kind ?? J(n)) {
|
|
1791
2078
|
case "line":
|
|
1792
2079
|
return this.drawLine(t);
|
|
1793
2080
|
case "circle":
|
|
@@ -1803,7 +2090,7 @@ class Ot {
|
|
|
1803
2090
|
case "point":
|
|
1804
2091
|
return this.drawPoint(t);
|
|
1805
2092
|
case "insert":
|
|
1806
|
-
return this.drawInsert(t,
|
|
2093
|
+
return this.drawInsert(t, r);
|
|
1807
2094
|
case "solid":
|
|
1808
2095
|
return this.drawSolid(t);
|
|
1809
2096
|
case "hatch":
|
|
@@ -1815,18 +2102,20 @@ class Ot {
|
|
|
1815
2102
|
case "image":
|
|
1816
2103
|
return this.drawImage(t);
|
|
1817
2104
|
case "viewport":
|
|
1818
|
-
return this.markSkipped(
|
|
2105
|
+
return this.markSkipped(n);
|
|
1819
2106
|
default:
|
|
1820
|
-
this.stats.unsupported[
|
|
2107
|
+
this.stats.unsupported[n] = (this.stats.unsupported[n] ?? 0) + 1, this.stats.skipped++, this.opts.showUnsupportedMarkers && this.drawUnsupportedMarker(t);
|
|
1821
2108
|
}
|
|
1822
2109
|
}
|
|
1823
|
-
beginStyledPath(t, r = !
|
|
2110
|
+
beginStyledPath(t, n = !1, r = !0) {
|
|
1824
2111
|
const i = this.ctx;
|
|
1825
2112
|
i.save(), i.setTransform(this.dpr, 0, 0, this.dpr, 0, 0);
|
|
1826
|
-
const s =
|
|
1827
|
-
i.strokeStyle = s, i.fillStyle =
|
|
1828
|
-
const
|
|
1829
|
-
i.lineWidth = Math.max(1, Math.min(12,
|
|
2113
|
+
const s = V(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), o = Pt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }) ?? s;
|
|
2114
|
+
i.strokeStyle = s, i.fillStyle = n ? o : s, i.globalAlpha = _(Number(t.opacity ?? 1), 0, 1), i.lineCap = "round", i.lineJoin = "round";
|
|
2115
|
+
const a = typeof t.lineweight == "number" && t.lineweight > 0 ? t.lineweight : 0;
|
|
2116
|
+
i.lineWidth = Math.max(1, Math.min(12, a > 0 ? a / 30 : 1));
|
|
2117
|
+
const c = r ? Nt(t, this.document) : void 0;
|
|
2118
|
+
i.setLineDash(c ? c.segments.map((l) => Math.max(0.05, l * this.view.scale)) : []), i.beginPath();
|
|
1830
2119
|
}
|
|
1831
2120
|
finishStroke() {
|
|
1832
2121
|
this.ctx.stroke(), this.ctx.restore(), this.stats.drawn++;
|
|
@@ -1835,235 +2124,217 @@ class Ot {
|
|
|
1835
2124
|
t && this.ctx.fill(), this.ctx.stroke(), this.ctx.restore(), this.stats.drawn++;
|
|
1836
2125
|
}
|
|
1837
2126
|
drawLine(t) {
|
|
1838
|
-
const
|
|
1839
|
-
if (!
|
|
1840
|
-
|
|
1841
|
-
this.beginStyledPath(t), this.ctx.moveTo(s.x, s.y), this.ctx.lineTo(n.x, n.y), this.finishStroke();
|
|
2127
|
+
const n = t.startPoint, r = t.endPoint;
|
|
2128
|
+
if (!g(n) || !g(r)) return this.markSkipped("LINE");
|
|
2129
|
+
this.strokeWorldPolyline(t, [n, r], !1);
|
|
1842
2130
|
}
|
|
1843
2131
|
drawCircle(t) {
|
|
1844
|
-
const
|
|
1845
|
-
if (!
|
|
1846
|
-
|
|
1847
|
-
this.beginStyledPath(t), this.ctx.arc(s.x, s.y, Math.abs(i) * this.view.scale, 0, Math.PI * 2), this.finishStroke();
|
|
2132
|
+
const n = t.center, r = Number(t.radius);
|
|
2133
|
+
if (!g(n) || !Number.isFinite(r)) return this.markSkipped("CIRCLE");
|
|
2134
|
+
this.strokeWorldPolyline(t, Q(P(n), r, 0, Math.PI * 2, !0), !0);
|
|
1848
2135
|
}
|
|
1849
2136
|
drawArc(t) {
|
|
1850
|
-
const
|
|
1851
|
-
if (!
|
|
1852
|
-
this.strokeWorldPolyline(t,
|
|
2137
|
+
const n = t.center, r = Number(t.radius), i = Number(t.startAngle), s = Number(t.endAngle);
|
|
2138
|
+
if (!g(n) || !Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(s)) return this.markSkipped("ARC");
|
|
2139
|
+
this.strokeWorldPolyline(t, Q(P(n), r, i, s, !0), !1);
|
|
1853
2140
|
}
|
|
1854
2141
|
drawPolyline(t) {
|
|
1855
|
-
const
|
|
1856
|
-
if (!Array.isArray(
|
|
1857
|
-
const
|
|
1858
|
-
for (let o = 0; o <
|
|
1859
|
-
const a =
|
|
1860
|
-
if (!
|
|
1861
|
-
const
|
|
1862
|
-
|
|
2142
|
+
const n = t.vertices ?? t.points;
|
|
2143
|
+
if (!Array.isArray(n) || n.length < 2) return this.markSkipped(String(t.type));
|
|
2144
|
+
const r = ae(t), i = [], s = r ? n.length : n.length - 1;
|
|
2145
|
+
for (let o = 0; o < s; o++) {
|
|
2146
|
+
const a = n[o], c = n[(o + 1) % n.length];
|
|
2147
|
+
if (!g(a) || !g(c)) continue;
|
|
2148
|
+
const l = fe(a, c, Number(a.bulge ?? 0));
|
|
2149
|
+
i.length > 0 && l.shift(), i.push(...l);
|
|
1863
2150
|
}
|
|
1864
|
-
this.strokeWorldPolyline(t,
|
|
2151
|
+
this.strokeWorldPolyline(t, i, r);
|
|
1865
2152
|
}
|
|
1866
2153
|
drawEllipse(t) {
|
|
1867
|
-
const
|
|
1868
|
-
if (!
|
|
1869
|
-
const
|
|
1870
|
-
this.strokeWorldPolyline(t,
|
|
2154
|
+
const n = t.center, r = t.majorAxisEndPoint, i = Number(t.axisRatio ?? 1);
|
|
2155
|
+
if (!g(n) || !g(r)) return this.markSkipped("ELLIPSE");
|
|
2156
|
+
const s = Lt(n, r, i, 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;
|
|
2157
|
+
this.strokeWorldPolyline(t, s, o);
|
|
1871
2158
|
}
|
|
1872
2159
|
drawPoint(t) {
|
|
1873
|
-
const
|
|
1874
|
-
if (!
|
|
1875
|
-
const
|
|
1876
|
-
this.beginStyledPath(t), this.ctx.moveTo(
|
|
2160
|
+
const n = t.point ?? t.location ?? t.center ?? t.insertionPoint;
|
|
2161
|
+
if (!g(n)) return this.markSkipped("POINT");
|
|
2162
|
+
const r = this.worldToScreen(n);
|
|
2163
|
+
this.beginStyledPath(t), this.ctx.moveTo(r.x - 3, r.y), this.ctx.lineTo(r.x + 3, r.y), this.ctx.moveTo(r.x, r.y - 3), this.ctx.lineTo(r.x, r.y + 3), this.finishStroke();
|
|
1877
2164
|
}
|
|
1878
2165
|
drawText(t) {
|
|
1879
|
-
const
|
|
1880
|
-
if (!
|
|
1881
|
-
this.drawTextAt(t, r, i,
|
|
1882
|
-
}
|
|
1883
|
-
drawInsert(t,
|
|
1884
|
-
const
|
|
1885
|
-
if (
|
|
1886
|
-
const a =
|
|
1887
|
-
for (const c of
|
|
1888
|
-
const
|
|
1889
|
-
this.drawEntityTracked(
|
|
2166
|
+
const n = t.insertionPoint ?? t.startPoint ?? t.center, r = ue(String(t.text ?? t.value ?? "")), i = Number(t.textHeight ?? t.height ?? 1);
|
|
2167
|
+
if (!g(n) || !r) return this.markSkipped(String(t.type));
|
|
2168
|
+
this.drawTextAt(t, n, r, i, Number(t.rotation ?? 0));
|
|
2169
|
+
}
|
|
2170
|
+
drawInsert(t, n) {
|
|
2171
|
+
const r = this.lookupBlock(t.blockName ?? t.name);
|
|
2172
|
+
if (r && n < this.opts.maxInsertDepth) {
|
|
2173
|
+
const a = Bt(t, r.basePoint ?? { x: 0, y: 0 });
|
|
2174
|
+
for (const c of r.entities) {
|
|
2175
|
+
const l = ge(c, t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }), h = Se(l, t, this.document);
|
|
2176
|
+
this.drawEntityTracked($(h, a), n + 1);
|
|
1890
2177
|
}
|
|
1891
2178
|
return;
|
|
1892
2179
|
}
|
|
1893
|
-
const
|
|
1894
|
-
if (!
|
|
1895
|
-
const
|
|
2180
|
+
const i = t.insertionPoint;
|
|
2181
|
+
if (!g(i)) return this.markSkipped("INSERT");
|
|
2182
|
+
const s = this.worldToScreen(i);
|
|
1896
2183
|
this.beginStyledPath(t);
|
|
1897
2184
|
const o = 5;
|
|
1898
|
-
if (this.ctx.rect(
|
|
2185
|
+
if (this.ctx.rect(s.x - o, s.y - o, o * 2, o * 2), this.finishStroke(), Array.isArray(t.attribs)) for (const a of t.attribs) this.drawText(a);
|
|
1899
2186
|
}
|
|
1900
2187
|
drawSolid(t) {
|
|
1901
|
-
const
|
|
1902
|
-
if (!Array.isArray(
|
|
2188
|
+
const n = t.vertices ?? t.points;
|
|
2189
|
+
if (!Array.isArray(n) || n.length < 3) return this.markSkipped(String(t.type));
|
|
1903
2190
|
this.beginStyledPath(t, !0);
|
|
1904
|
-
const
|
|
1905
|
-
this.ctx.moveTo(
|
|
1906
|
-
for (const
|
|
1907
|
-
if (!
|
|
1908
|
-
const
|
|
1909
|
-
this.ctx.lineTo(
|
|
2191
|
+
const r = this.worldToScreen(n[0]);
|
|
2192
|
+
this.ctx.moveTo(r.x, r.y);
|
|
2193
|
+
for (const i of n.slice(1)) {
|
|
2194
|
+
if (!g(i)) continue;
|
|
2195
|
+
const s = this.worldToScreen(i);
|
|
2196
|
+
this.ctx.lineTo(s.x, s.y);
|
|
1910
2197
|
}
|
|
1911
2198
|
this.ctx.closePath(), this.finishFillStroke(!0);
|
|
1912
2199
|
}
|
|
1913
2200
|
drawHatch(t) {
|
|
1914
|
-
var
|
|
1915
|
-
const
|
|
1916
|
-
if (!Array.isArray(
|
|
2201
|
+
var r, i;
|
|
2202
|
+
const n = t.loops;
|
|
2203
|
+
if (!Array.isArray(n) || n.length === 0) return this.markSkipped("HATCH");
|
|
1917
2204
|
this.beginStyledPath(t, !0);
|
|
1918
|
-
for (const
|
|
1919
|
-
if ((
|
|
1920
|
-
else if ((
|
|
1921
|
-
const o = this.worldToScreen(
|
|
2205
|
+
for (const s of n)
|
|
2206
|
+
if ((r = s.commands) != null && r.length) this.addPathCommands(s.commands);
|
|
2207
|
+
else if ((i = s.vertices) != null && i.length) {
|
|
2208
|
+
const o = this.worldToScreen(s.vertices[0]);
|
|
1922
2209
|
this.ctx.moveTo(o.x, o.y);
|
|
1923
|
-
for (const a of
|
|
2210
|
+
for (const a of s.vertices.slice(1)) {
|
|
1924
2211
|
const c = this.worldToScreen(a);
|
|
1925
2212
|
this.ctx.lineTo(c.x, c.y);
|
|
1926
2213
|
}
|
|
1927
2214
|
this.ctx.closePath();
|
|
1928
2215
|
}
|
|
1929
|
-
this.finishFillStroke(!!
|
|
2216
|
+
this.finishFillStroke(!!Pt(t, this.document, { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast }));
|
|
1930
2217
|
}
|
|
1931
2218
|
drawSpline(t) {
|
|
1932
|
-
var
|
|
1933
|
-
const
|
|
1934
|
-
if (!
|
|
1935
|
-
this.strokeWorldPolyline(t,
|
|
2219
|
+
var r;
|
|
2220
|
+
const n = (r = t.fitPoints) != null && r.length ? t.fitPoints : t.controlPoints;
|
|
2221
|
+
if (!n || n.length < 2) return this.markSkipped("SPLINE");
|
|
2222
|
+
this.strokeWorldPolyline(t, n, !!t.isClosed);
|
|
1936
2223
|
}
|
|
1937
2224
|
drawPath(t) {
|
|
1938
|
-
var
|
|
1939
|
-
if (!((
|
|
2225
|
+
var n;
|
|
2226
|
+
if (!((n = t.commands) != null && n.length)) return this.markSkipped(String(t.type));
|
|
1940
2227
|
this.beginStyledPath(t, !!t.fillColor), this.addPathCommands(t.commands), this.finishFillStroke(!!t.fillColor);
|
|
1941
2228
|
}
|
|
1942
2229
|
addPathCommands(t) {
|
|
1943
|
-
for (const
|
|
1944
|
-
if (
|
|
1945
|
-
const
|
|
1946
|
-
this.ctx.moveTo(
|
|
1947
|
-
} else if (
|
|
1948
|
-
const
|
|
1949
|
-
this.ctx.lineTo(
|
|
1950
|
-
} else if (
|
|
1951
|
-
const [i, s
|
|
1952
|
-
this.ctx.bezierCurveTo(
|
|
1953
|
-
} else if (
|
|
1954
|
-
const [
|
|
1955
|
-
this.ctx.quadraticCurveTo(
|
|
1956
|
-
} else
|
|
2230
|
+
for (const n of t)
|
|
2231
|
+
if (n.cmd === "M") {
|
|
2232
|
+
const r = this.worldToScreen(n.points[0]);
|
|
2233
|
+
this.ctx.moveTo(r.x, r.y);
|
|
2234
|
+
} else if (n.cmd === "L") {
|
|
2235
|
+
const r = this.worldToScreen(n.points[0]);
|
|
2236
|
+
this.ctx.lineTo(r.x, r.y);
|
|
2237
|
+
} else if (n.cmd === "C") {
|
|
2238
|
+
const [r, i, s] = n.points.map((o) => this.worldToScreen(o));
|
|
2239
|
+
this.ctx.bezierCurveTo(r.x, r.y, i.x, i.y, s.x, s.y);
|
|
2240
|
+
} else if (n.cmd === "Q") {
|
|
2241
|
+
const [r, i] = n.points.map((s) => this.worldToScreen(s));
|
|
2242
|
+
this.ctx.quadraticCurveTo(r.x, r.y, i.x, i.y);
|
|
2243
|
+
} else n.cmd === "Z" && this.ctx.closePath();
|
|
1957
2244
|
}
|
|
1958
2245
|
drawImage(t) {
|
|
1959
|
-
const
|
|
1960
|
-
if (!
|
|
1961
|
-
const
|
|
1962
|
-
if (
|
|
1963
|
-
const
|
|
1964
|
-
if (
|
|
1965
|
-
this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(
|
|
2246
|
+
const n = t.insertionPoint;
|
|
2247
|
+
if (!g(n)) return this.markSkipped(String(t.type));
|
|
2248
|
+
const r = Number(t.width ?? 32), i = Number(t.height ?? 32), s = this.worldToScreen(n), o = this.worldToScreen({ x: n.x + r, y: n.y - i }), a = Math.min(s.x, o.x), c = Math.min(s.y, o.y), l = Math.abs(o.x - s.x), h = Math.abs(o.y - s.y), u = t.imageDataUrl;
|
|
2249
|
+
if (u) {
|
|
2250
|
+
const f = this.getImage(u);
|
|
2251
|
+
if (f.complete && f.naturalWidth > 0) {
|
|
2252
|
+
this.ctx.save(), this.ctx.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), this.ctx.drawImage(f, a, c, l, h), this.ctx.restore(), this.stats.drawn++;
|
|
1966
2253
|
return;
|
|
1967
2254
|
}
|
|
1968
|
-
|
|
2255
|
+
f.onload = () => this.render();
|
|
1969
2256
|
}
|
|
1970
2257
|
if (!this.opts.showImagePlaceholders) return this.markSkipped(String(t.type));
|
|
1971
|
-
this.beginStyledPath(t), this.ctx.rect(a, c,
|
|
2258
|
+
this.beginStyledPath(t), this.ctx.rect(a, c, l, h), this.ctx.moveTo(a, c), this.ctx.lineTo(a + l, c + h), this.ctx.moveTo(a + l, c), this.ctx.lineTo(a, c + h), this.finishStroke();
|
|
1972
2259
|
}
|
|
1973
2260
|
getImage(t) {
|
|
1974
|
-
let
|
|
1975
|
-
return
|
|
2261
|
+
let n = this.imageCache.get(t);
|
|
2262
|
+
return n || (n = new Image(), n.src = t, this.imageCache.set(t, n)), n;
|
|
1976
2263
|
}
|
|
1977
2264
|
drawUnsupportedMarker(t) {
|
|
1978
|
-
const
|
|
1979
|
-
if (!
|
|
1980
|
-
const
|
|
1981
|
-
this.beginStyledPath(t), this.ctx.moveTo(
|
|
1982
|
-
}
|
|
1983
|
-
drawTextAt(t, r, i, s
|
|
1984
|
-
const o = this.ctx, a = this.worldToScreen(
|
|
1985
|
-
o.save(), o.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), o.translate(a.x, a.y), o.rotate(-
|
|
1986
|
-
const c = Math.max(4, Math.min(256, Math.abs(
|
|
1987
|
-
o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle =
|
|
1988
|
-
for (const [
|
|
2265
|
+
const n = this.entityAnchor(t);
|
|
2266
|
+
if (!n) return;
|
|
2267
|
+
const r = this.worldToScreen(n);
|
|
2268
|
+
this.beginStyledPath(t), this.ctx.moveTo(r.x - 4, r.y - 4), this.ctx.lineTo(r.x + 4, r.y + 4), this.ctx.moveTo(r.x + 4, r.y - 4), this.ctx.lineTo(r.x - 4, r.y + 4), this.finishStroke();
|
|
2269
|
+
}
|
|
2270
|
+
drawTextAt(t, n, r, i, s) {
|
|
2271
|
+
const o = this.ctx, a = this.worldToScreen(n);
|
|
2272
|
+
o.save(), o.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), o.translate(a.x, a.y), o.rotate(-s);
|
|
2273
|
+
const c = Math.max(4, Math.min(256, Math.abs(i) * this.view.scale));
|
|
2274
|
+
o.font = `${c}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, o.fillStyle = V(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 = _(Number(t.opacity ?? 1), 0, 1), o.textBaseline = "alphabetic";
|
|
2275
|
+
for (const [l, h] of r.split(/\r?\n/g).entries()) o.fillText(h, 0, l * c * 1.22);
|
|
1989
2276
|
o.restore(), this.stats.drawn++;
|
|
1990
2277
|
}
|
|
1991
|
-
strokeWorldPolyline(t,
|
|
1992
|
-
const
|
|
1993
|
-
if (
|
|
2278
|
+
strokeWorldPolyline(t, n, r) {
|
|
2279
|
+
const i = n.filter(g);
|
|
2280
|
+
if (i.length < 2) return this.markSkipped(String(t.type));
|
|
2281
|
+
const s = Nt(t, this.document);
|
|
2282
|
+
if (s) {
|
|
2283
|
+
const a = Dt(i, r, s);
|
|
2284
|
+
this.beginStyledPath(t, !1, !1);
|
|
2285
|
+
for (const [c, l] of a.segments) {
|
|
2286
|
+
const h = this.worldToScreen(c), u = this.worldToScreen(l);
|
|
2287
|
+
this.ctx.moveTo(h.x, h.y), this.ctx.lineTo(u.x, u.y);
|
|
2288
|
+
}
|
|
2289
|
+
if (this.ctx.stroke(), a.dots.length > 0) {
|
|
2290
|
+
this.ctx.setLineDash([]), this.ctx.beginPath();
|
|
2291
|
+
const c = Math.max(0.5, this.ctx.lineWidth / 2);
|
|
2292
|
+
for (const l of a.dots) {
|
|
2293
|
+
const h = this.worldToScreen(l);
|
|
2294
|
+
this.ctx.moveTo(h.x + c, h.y), this.ctx.arc(h.x, h.y, c, 0, Math.PI * 2);
|
|
2295
|
+
}
|
|
2296
|
+
this.ctx.fillStyle = this.ctx.strokeStyle, this.ctx.fill();
|
|
2297
|
+
}
|
|
2298
|
+
this.ctx.restore(), this.stats.drawn++;
|
|
2299
|
+
return;
|
|
2300
|
+
}
|
|
1994
2301
|
this.beginStyledPath(t);
|
|
1995
|
-
const
|
|
1996
|
-
this.ctx.moveTo(
|
|
1997
|
-
for (const
|
|
1998
|
-
const
|
|
1999
|
-
this.ctx.lineTo(
|
|
2302
|
+
const o = this.worldToScreen(i[0]);
|
|
2303
|
+
this.ctx.moveTo(o.x, o.y);
|
|
2304
|
+
for (const a of i.slice(1)) {
|
|
2305
|
+
const c = this.worldToScreen(a);
|
|
2306
|
+
this.ctx.lineTo(c.x, c.y);
|
|
2000
2307
|
}
|
|
2001
|
-
|
|
2308
|
+
r && this.ctx.closePath(), this.finishStroke();
|
|
2002
2309
|
}
|
|
2003
2310
|
markSkipped(t) {
|
|
2004
2311
|
this.stats.skipped++, this.stats.unsupported[t] = this.stats.unsupported[t] ?? 0;
|
|
2005
2312
|
}
|
|
2006
2313
|
entityAnchor(t) {
|
|
2007
|
-
for (const
|
|
2008
|
-
const
|
|
2009
|
-
if (
|
|
2314
|
+
for (const n of ["startPoint", "insertionPoint", "center", "point", "location"]) {
|
|
2315
|
+
const r = t[n];
|
|
2316
|
+
if (g(r)) return P(r);
|
|
2010
2317
|
}
|
|
2011
|
-
if (Array.isArray(t.vertices) &&
|
|
2318
|
+
if (Array.isArray(t.vertices) && g(t.vertices[0])) return P(t.vertices[0]);
|
|
2012
2319
|
if (Array.isArray(t.commands) && t.commands.length) {
|
|
2013
|
-
const
|
|
2014
|
-
if (
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
computeBounds(t) {
|
|
2018
|
-
var i;
|
|
2019
|
-
const r = N();
|
|
2020
|
-
if ((i = t.pages) != null && i.length)
|
|
2021
|
-
for (const s of t.pages)
|
|
2022
|
-
v(r, { x: 0, y: 0 }), v(r, { x: s.width, y: s.height });
|
|
2023
|
-
for (const s of t.entities) this.includeEntityBounds(r, s, 0);
|
|
2024
|
-
return $t(r);
|
|
2025
|
-
}
|
|
2026
|
-
includeEntityBounds(t, r, i) {
|
|
2027
|
-
const s = String(r.type ?? "").toUpperCase(), n = r.kind ?? R(s);
|
|
2028
|
-
if (n === "insert") {
|
|
2029
|
-
const o = this.lookupBlock(r.blockName ?? r.name);
|
|
2030
|
-
if (o && i < this.opts.maxInsertDepth) {
|
|
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);
|
|
2033
|
-
return;
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if (n === "line")
|
|
2037
|
-
m(r.startPoint) && v(t, r.startPoint), m(r.endPoint) && v(t, r.endPoint);
|
|
2038
|
-
else if (n === "circle" || n === "arc")
|
|
2039
|
-
m(r.center) && Number.isFinite(r.radius) && Vt(t, r.center, Number(r.radius));
|
|
2040
|
-
else if (n === "polyline" || n === "solid" || n === "spline")
|
|
2041
|
-
for (const o of [...r.vertices ?? [], ...r.points ?? [], ...r.controlPoints ?? [], ...r.fitPoints ?? []]) m(o) && v(t, o);
|
|
2042
|
-
else if (n === "ellipse")
|
|
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));
|
|
2044
|
-
else if (n === "path")
|
|
2045
|
-
for (const o of r.commands ?? []) for (const a of o.points) v(t, a);
|
|
2046
|
-
else if (n === "hatch")
|
|
2047
|
-
for (const o of r.loops ?? []) {
|
|
2048
|
-
for (const a of o.vertices ?? []) v(t, a);
|
|
2049
|
-
for (const a of o.commands ?? []) for (const c of a.points) v(t, c);
|
|
2050
|
-
}
|
|
2051
|
-
else {
|
|
2052
|
-
const o = this.entityAnchor(r);
|
|
2053
|
-
o && v(t, o);
|
|
2320
|
+
const n = t.commands.find((r) => r.points.length > 0);
|
|
2321
|
+
if (n) return P(n.points[0]);
|
|
2054
2322
|
}
|
|
2055
2323
|
}
|
|
2056
2324
|
lookupLayer(t) {
|
|
2057
2325
|
if (!(!this.document || !t))
|
|
2058
|
-
return this.document.layers[t] ?? this.document.layers[t.toLowerCase()] ?? Object.values(this.document.layers).find((
|
|
2326
|
+
return this.document.layers[t] ?? this.document.layers[t.toLowerCase()] ?? Object.values(this.document.layers).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
2059
2327
|
}
|
|
2060
2328
|
lookupBlock(t) {
|
|
2061
2329
|
if (!(!this.document || !t))
|
|
2062
|
-
return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((
|
|
2330
|
+
return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
2063
2331
|
}
|
|
2064
2332
|
clampScale(t) {
|
|
2065
2333
|
return Math.min(this.opts.maxScale, Math.max(this.opts.minScale, t));
|
|
2066
2334
|
}
|
|
2335
|
+
boundsOptions() {
|
|
2336
|
+
return { maxInsertDepth: this.opts.maxInsertDepth, maxCurveSegments: this.opts.maxCurveSegments };
|
|
2337
|
+
}
|
|
2067
2338
|
emitViewChange() {
|
|
2068
2339
|
var t;
|
|
2069
2340
|
(t = this.onViewChange) == null || t.call(this, {
|
|
@@ -2075,7 +2346,7 @@ class Ot {
|
|
|
2075
2346
|
});
|
|
2076
2347
|
}
|
|
2077
2348
|
}
|
|
2078
|
-
function
|
|
2349
|
+
function tr(e) {
|
|
2079
2350
|
return {
|
|
2080
2351
|
total: e.total,
|
|
2081
2352
|
drawn: e.drawn,
|
|
@@ -2091,7 +2362,7 @@ function lr(e) {
|
|
|
2091
2362
|
buildElapsedMs: e.buildElapsedMs
|
|
2092
2363
|
};
|
|
2093
2364
|
}
|
|
2094
|
-
const
|
|
2365
|
+
const er = {
|
|
2095
2366
|
background: "#0b1020",
|
|
2096
2367
|
foreground: "#ffffff",
|
|
2097
2368
|
showUnsupportedMarkers: !1,
|
|
@@ -2102,6 +2373,7 @@ const fr = {
|
|
|
2102
2373
|
wheelZoomFactor: 1.14,
|
|
2103
2374
|
trueColorByteOrder: "rgb",
|
|
2104
2375
|
maxInsertDepth: 16,
|
|
2376
|
+
fitMode: "auto",
|
|
2105
2377
|
contrastMode: "adaptive",
|
|
2106
2378
|
minColorContrast: 2.4,
|
|
2107
2379
|
maxCurveSegments: 96,
|
|
@@ -2114,8 +2386,8 @@ const fr = {
|
|
|
2114
2386
|
preserveDrawingBuffer: !1,
|
|
2115
2387
|
enableSpatialIndex: !0
|
|
2116
2388
|
};
|
|
2117
|
-
class
|
|
2118
|
-
constructor(t,
|
|
2389
|
+
class ee {
|
|
2390
|
+
constructor(t, n = {}) {
|
|
2119
2391
|
d(this, "canvas");
|
|
2120
2392
|
d(this, "backend", "webgl");
|
|
2121
2393
|
d(this, "gl");
|
|
@@ -2123,8 +2395,9 @@ class zt {
|
|
|
2123
2395
|
d(this, "eventController", new AbortController());
|
|
2124
2396
|
d(this, "imageCache", /* @__PURE__ */ new Map());
|
|
2125
2397
|
d(this, "opts");
|
|
2398
|
+
d(this, "sourceDocument");
|
|
2126
2399
|
d(this, "document");
|
|
2127
|
-
d(this, "bounds",
|
|
2400
|
+
d(this, "bounds", L());
|
|
2128
2401
|
d(this, "view", { centerX: 0, centerY: 0, scale: 1 });
|
|
2129
2402
|
d(this, "fitScale", 1);
|
|
2130
2403
|
d(this, "dpr", 1);
|
|
@@ -2138,32 +2411,39 @@ class zt {
|
|
|
2138
2411
|
d(this, "rafHandle", 0);
|
|
2139
2412
|
d(this, "onStats");
|
|
2140
2413
|
d(this, "onViewChange");
|
|
2141
|
-
const
|
|
2142
|
-
if (!
|
|
2143
|
-
this.canvas = t, this.gl =
|
|
2414
|
+
const r = nr(t, n);
|
|
2415
|
+
if (!r) throw new Error('WebGL is not available. Use renderer: "canvas2d" to force the Canvas2D fallback.');
|
|
2416
|
+
this.canvas = t, this.gl = r, this.program = rr(r), this.opts = { ...er, ...n }, 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();
|
|
2144
2417
|
}
|
|
2145
2418
|
static isSupported() {
|
|
2146
|
-
return
|
|
2419
|
+
return Ee();
|
|
2147
2420
|
}
|
|
2148
2421
|
destroy() {
|
|
2149
|
-
var t,
|
|
2150
|
-
this.eventController.abort(), (t = this.resizeObserver) == null || t.disconnect(), this.cancelScheduledRender(), this.disposeScene(), (
|
|
2422
|
+
var t, n;
|
|
2423
|
+
this.eventController.abort(), (t = this.resizeObserver) == null || t.disconnect(), this.cancelScheduledRender(), this.disposeScene(), (n = this.overlayCanvas) == null || n.remove();
|
|
2151
2424
|
}
|
|
2152
2425
|
clear() {
|
|
2153
|
-
this.document = void 0, this.bounds =
|
|
2426
|
+
this.sourceDocument = void 0, this.document = void 0, this.bounds = L(), this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.disposeScene(), this.render(), this.emitViewChange();
|
|
2154
2427
|
}
|
|
2155
2428
|
setDocument(t) {
|
|
2156
|
-
this.document = t, this.bounds =
|
|
2157
|
-
const
|
|
2158
|
-
this.scene =
|
|
2429
|
+
this.sourceDocument = t, this.document = Me(t), this.bounds = ve(this.document, this.boundsOptions()), this.disposeScene();
|
|
2430
|
+
const n = sr(this.document, this.opts, this.bounds);
|
|
2431
|
+
this.scene = ir(this.gl, n), this.stats = fr(this.scene, 0), this.fitToView();
|
|
2159
2432
|
}
|
|
2160
2433
|
getDocument() {
|
|
2161
2434
|
return this.document;
|
|
2162
2435
|
}
|
|
2436
|
+
getSourceDocument() {
|
|
2437
|
+
return this.sourceDocument;
|
|
2438
|
+
}
|
|
2163
2439
|
setOptions(t) {
|
|
2164
|
-
const
|
|
2165
|
-
if (this.opts = { ...this.opts, ...t },
|
|
2166
|
-
this.setDocument(this.document);
|
|
2440
|
+
const n = hr(this.opts, t), r = t.fitMode !== void 0 && t.fitMode !== this.opts.fitMode;
|
|
2441
|
+
if (this.opts = { ...this.opts, ...t }, n && (this.sourceDocument ?? this.document)) {
|
|
2442
|
+
this.setDocument(this.sourceDocument ?? this.document);
|
|
2443
|
+
return;
|
|
2444
|
+
}
|
|
2445
|
+
if (r && this.document) {
|
|
2446
|
+
this.fitToView();
|
|
2167
2447
|
return;
|
|
2168
2448
|
}
|
|
2169
2449
|
this.render(), this.emitViewChange();
|
|
@@ -2171,29 +2451,30 @@ class zt {
|
|
|
2171
2451
|
getOptions() {
|
|
2172
2452
|
return { ...this.opts };
|
|
2173
2453
|
}
|
|
2174
|
-
fitToView(t = 0.92) {
|
|
2175
|
-
|
|
2454
|
+
fitToView(t = 0.92, n = this.opts.fitMode) {
|
|
2455
|
+
const r = this.document ? xe(this.document, this.bounds, n, this.boundsOptions()) : this.bounds;
|
|
2456
|
+
if (!I(r)) {
|
|
2176
2457
|
this.view = { centerX: 0, centerY: 0, scale: 1 }, this.fitScale = 1, this.render(), this.emitViewChange();
|
|
2177
2458
|
return;
|
|
2178
2459
|
}
|
|
2179
|
-
const
|
|
2180
|
-
this.fitScale =
|
|
2181
|
-
centerX: (
|
|
2182
|
-
centerY: (
|
|
2183
|
-
scale:
|
|
2460
|
+
const i = Math.max(1, this.cssWidth), s = Math.max(1, this.cssHeight), o = Math.max(r.maxX - r.minX, 1e-9), a = Math.max(r.maxY - r.minY, 1e-9), c = this.clampScale(Math.min(i / o, s / a) * t);
|
|
2461
|
+
this.fitScale = c, this.view = {
|
|
2462
|
+
centerX: (r.minX + r.maxX) / 2,
|
|
2463
|
+
centerY: (r.minY + r.maxY) / 2,
|
|
2464
|
+
scale: c
|
|
2184
2465
|
}, this.render(), this.emitViewChange();
|
|
2185
2466
|
}
|
|
2186
2467
|
resize() {
|
|
2187
2468
|
this.dpr = Math.max(1, window.devicePixelRatio || 1);
|
|
2188
|
-
const t = Math.max(1, Math.floor(this.cssWidth * this.dpr)),
|
|
2189
|
-
(this.canvas.width !== t || this.canvas.height !==
|
|
2469
|
+
const t = Math.max(1, Math.floor(this.cssWidth * this.dpr)), n = Math.max(1, Math.floor(this.cssHeight * this.dpr));
|
|
2470
|
+
(this.canvas.width !== t || this.canvas.height !== n) && (this.canvas.width = t, this.canvas.height = n), this.resizeOverlay(t, n), this.render(), this.emitViewChange();
|
|
2190
2471
|
}
|
|
2191
|
-
zoom(t,
|
|
2472
|
+
zoom(t, n) {
|
|
2192
2473
|
if (!Number.isFinite(t) || t <= 0) return;
|
|
2193
|
-
const
|
|
2474
|
+
const r = n ?? { x: this.cssWidth / 2, y: this.cssHeight / 2 }, i = this.screenToWorld(r);
|
|
2194
2475
|
this.view.scale = this.clampScale(this.view.scale * t);
|
|
2195
|
-
const
|
|
2196
|
-
this.view.centerX +=
|
|
2476
|
+
const s = this.screenToWorld(r);
|
|
2477
|
+
this.view.centerX += i.x - s.x, this.view.centerY += i.y - s.y, this.scheduleRender(), this.emitViewChange();
|
|
2197
2478
|
}
|
|
2198
2479
|
zoomIn() {
|
|
2199
2480
|
this.zoom(this.opts.wheelZoomFactor);
|
|
@@ -2201,8 +2482,8 @@ class zt {
|
|
|
2201
2482
|
zoomOut() {
|
|
2202
2483
|
this.zoom(1 / this.opts.wheelZoomFactor);
|
|
2203
2484
|
}
|
|
2204
|
-
panByScreenDelta(t,
|
|
2205
|
-
!Number.isFinite(t) || !Number.isFinite(
|
|
2485
|
+
panByScreenDelta(t, n) {
|
|
2486
|
+
!Number.isFinite(t) || !Number.isFinite(n) || (this.view.centerX -= t / this.view.scale, this.view.centerY += n / this.view.scale, this.scheduleRender(), this.emitViewChange());
|
|
2206
2487
|
}
|
|
2207
2488
|
setViewState(t) {
|
|
2208
2489
|
if (![t.centerX, t.centerY, t.scale].every(Number.isFinite)) throw new Error("Invalid view state.");
|
|
@@ -2215,7 +2496,7 @@ class zt {
|
|
|
2215
2496
|
return { ...this.bounds };
|
|
2216
2497
|
}
|
|
2217
2498
|
getStats() {
|
|
2218
|
-
return
|
|
2499
|
+
return ur(this.stats);
|
|
2219
2500
|
}
|
|
2220
2501
|
getZoomRatio() {
|
|
2221
2502
|
return Math.abs(this.fitScale) < 1e-12 ? 1 : this.view.scale / this.fitScale;
|
|
@@ -2239,37 +2520,39 @@ class zt {
|
|
|
2239
2520
|
return this.cancelScheduledRender(), this.renderNow();
|
|
2240
2521
|
}
|
|
2241
2522
|
renderNow() {
|
|
2242
|
-
var
|
|
2243
|
-
const t = performance.now(),
|
|
2244
|
-
|
|
2245
|
-
const
|
|
2246
|
-
|
|
2247
|
-
let
|
|
2523
|
+
var l;
|
|
2524
|
+
const t = performance.now(), n = this.gl;
|
|
2525
|
+
n.viewport(0, 0, this.canvas.width, this.canvas.height);
|
|
2526
|
+
const r = Mt(this.opts.background, [11, 16, 32, 255]);
|
|
2527
|
+
n.clearColor(r[0] / 255, r[1] / 255, r[2] / 255, r[3] / 255), n.clear(n.COLOR_BUFFER_BIT), n.disable(n.DEPTH_TEST), n.enable(n.BLEND), n.blendFunc(n.SRC_ALPHA, n.ONE_MINUS_SRC_ALPHA);
|
|
2528
|
+
let i = 0, s = 0;
|
|
2248
2529
|
const o = this.scene, a = this.visibleWorldBounds();
|
|
2249
2530
|
if (o) {
|
|
2250
|
-
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2253
|
-
const
|
|
2254
|
-
|
|
2255
|
-
const
|
|
2256
|
-
|
|
2531
|
+
n.useProgram(this.program.program), n.uniform2f(this.program.uViewCenter, this.view.centerX - o.origin.x, this.view.centerY - o.origin.y), n.uniform1f(this.program.uScale, this.view.scale * this.dpr), n.uniform2f(this.program.uViewport, this.canvas.width, this.canvas.height), n.uniform1f(this.program.uPointSize, Math.max(1, this.dpr));
|
|
2532
|
+
const h = this.drawBatches(o.lineBatches, n.LINES, a);
|
|
2533
|
+
i += h.visible, s += h.culled;
|
|
2534
|
+
const u = this.drawBatches(o.triangleBatches, n.TRIANGLES, a);
|
|
2535
|
+
i += u.visible, s += u.culled;
|
|
2536
|
+
const f = this.drawBatches(o.lineTypePointBatches, n.POINTS, a);
|
|
2537
|
+
i += f.visible, s += f.culled, n.uniform1f(this.program.uPointSize, Math.max(2, Math.min(12, 4 * this.dpr)));
|
|
2538
|
+
const m = this.drawBatches(o.pointBatches, n.POINTS, a);
|
|
2539
|
+
i += m.visible, s += m.culled;
|
|
2257
2540
|
}
|
|
2258
2541
|
this.renderOverlay(a);
|
|
2259
2542
|
const c = performance.now() - t;
|
|
2260
|
-
return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount:
|
|
2543
|
+
return this.stats = o ? { ...o.stats, renderElapsedMs: c, backend: "webgl", primitiveCount: o.primitiveCount, visiblePrimitiveCount: i, culledPrimitiveCount: s, gpuMemoryBytes: o.gpuMemoryBytes, buildElapsedMs: o.buildElapsedMs } : { total: 0, drawn: 0, skipped: 0, byType: {}, unsupported: {}, renderElapsedMs: c, backend: "webgl", primitiveCount: 0, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: 0, buildElapsedMs: 0 }, (l = this.onStats) == null || l.call(this, this.getStats()), this.getStats();
|
|
2261
2544
|
}
|
|
2262
|
-
drawBatches(t,
|
|
2263
|
-
const
|
|
2264
|
-
let
|
|
2545
|
+
drawBatches(t, n, r) {
|
|
2546
|
+
const i = this.gl;
|
|
2547
|
+
let s = 0, o = 0;
|
|
2265
2548
|
for (const a of t) {
|
|
2266
|
-
if (!
|
|
2549
|
+
if (!bt(a.bounds, r)) {
|
|
2267
2550
|
o += a.primitiveCount;
|
|
2268
2551
|
continue;
|
|
2269
2552
|
}
|
|
2270
|
-
|
|
2553
|
+
i.bindBuffer(i.ARRAY_BUFFER, a.positionBuffer), i.enableVertexAttribArray(this.program.aPosition), i.vertexAttribPointer(this.program.aPosition, 2, i.FLOAT, !1, 0, 0), i.bindBuffer(i.ARRAY_BUFFER, a.colorBuffer), i.enableVertexAttribArray(this.program.aColor), i.vertexAttribPointer(this.program.aColor, 4, i.UNSIGNED_BYTE, !0, 0, 0), i.drawArrays(n, 0, a.vertexCount), s += a.primitiveCount;
|
|
2271
2554
|
}
|
|
2272
|
-
return { visible:
|
|
2555
|
+
return { visible: s, culled: o };
|
|
2273
2556
|
}
|
|
2274
2557
|
scheduleRender() {
|
|
2275
2558
|
this.rafHandle || (this.rafHandle = window.requestAnimationFrame(() => {
|
|
@@ -2280,96 +2563,96 @@ class zt {
|
|
|
2280
2563
|
this.rafHandle && (window.cancelAnimationFrame(this.rafHandle), this.rafHandle = 0);
|
|
2281
2564
|
}
|
|
2282
2565
|
renderOverlay(t) {
|
|
2283
|
-
var
|
|
2284
|
-
const
|
|
2285
|
-
!
|
|
2566
|
+
var i, s;
|
|
2567
|
+
const n = this.overlayCtx, r = this.overlayCanvas;
|
|
2568
|
+
!n || !r || (n.save(), n.setTransform(this.dpr, 0, 0, this.dpr, 0, 0), n.clearRect(0, 0, this.cssWidth, this.cssHeight), this.opts.showPageBounds && ((s = (i = this.document) == null ? void 0 : i.pages) != null && s.length) && this.drawPageBoundsOverlay(n), this.scene && (this.drawImagesOverlay(n, this.scene.imageItems, t), this.drawTextOverlay(n, this.scene.textItems, t)), n.restore());
|
|
2286
2569
|
}
|
|
2287
2570
|
drawPageBoundsOverlay(t) {
|
|
2288
|
-
var
|
|
2289
|
-
if ((
|
|
2571
|
+
var n, r;
|
|
2572
|
+
if ((r = (n = this.document) == null ? void 0 : n.pages) != null && r.length) {
|
|
2290
2573
|
t.save(), t.strokeStyle = "rgba(148, 163, 184, 0.34)", t.lineWidth = 1, t.setLineDash([8, 6]);
|
|
2291
|
-
for (const
|
|
2292
|
-
const
|
|
2293
|
-
t.strokeRect(Math.min(
|
|
2574
|
+
for (const i of this.document.pages) {
|
|
2575
|
+
const s = this.worldToScreen({ x: 0, y: 0 }), o = this.worldToScreen({ x: i.width, y: i.height });
|
|
2576
|
+
t.strokeRect(Math.min(s.x, o.x), Math.min(s.y, o.y), Math.abs(o.x - s.x), Math.abs(o.y - s.y));
|
|
2294
2577
|
}
|
|
2295
2578
|
t.restore();
|
|
2296
2579
|
}
|
|
2297
2580
|
}
|
|
2298
|
-
drawTextOverlay(t,
|
|
2299
|
-
const
|
|
2300
|
-
let
|
|
2301
|
-
for (const o of
|
|
2302
|
-
if (
|
|
2303
|
-
if (!
|
|
2581
|
+
drawTextOverlay(t, n, r) {
|
|
2582
|
+
const i = this.opts.maxVisibleTextLabels;
|
|
2583
|
+
let s = 0;
|
|
2584
|
+
for (const o of n) {
|
|
2585
|
+
if (s >= i) break;
|
|
2586
|
+
if (!bt(o.bounds, r)) continue;
|
|
2304
2587
|
const a = Math.abs(o.height) * this.view.scale;
|
|
2305
2588
|
if (a < this.opts.textMinPixelHeight) continue;
|
|
2306
2589
|
const c = this.worldToScreen(o.point);
|
|
2307
2590
|
if (c.x < -512 || c.y < -512 || c.x > this.cssWidth + 512 || c.y > this.cssHeight + 512) continue;
|
|
2308
2591
|
t.save(), t.translate(c.x, c.y), t.rotate(-o.rotation);
|
|
2309
|
-
const
|
|
2310
|
-
t.font = `${
|
|
2311
|
-
for (const [
|
|
2312
|
-
t.restore(),
|
|
2592
|
+
const l = Math.max(4, Math.min(256, a));
|
|
2593
|
+
t.font = `${l}px ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif`, t.fillStyle = o.color, t.globalAlpha = o.opacity, t.textBaseline = "alphabetic";
|
|
2594
|
+
for (const [h, u] of o.text.split(/\r?\n/g).entries()) t.fillText(u, 0, h * l * 1.22);
|
|
2595
|
+
t.restore(), s++;
|
|
2313
2596
|
}
|
|
2314
2597
|
}
|
|
2315
|
-
drawImagesOverlay(t,
|
|
2316
|
-
for (const
|
|
2317
|
-
if (!
|
|
2318
|
-
const
|
|
2319
|
-
if (!(
|
|
2320
|
-
if (
|
|
2321
|
-
const
|
|
2322
|
-
if (
|
|
2323
|
-
t.save(), t.globalAlpha =
|
|
2598
|
+
drawImagesOverlay(t, n, r) {
|
|
2599
|
+
for (const i of n) {
|
|
2600
|
+
if (!bt(i.bounds, r)) continue;
|
|
2601
|
+
const s = this.worldToScreen(i.point), o = this.worldToScreen({ x: i.point.x + i.width, y: i.point.y - i.height }), a = Math.min(s.x, o.x), c = Math.min(s.y, o.y), l = Math.abs(o.x - s.x), h = Math.abs(o.y - s.y);
|
|
2602
|
+
if (!(l < 1 || h < 1)) {
|
|
2603
|
+
if (i.source) {
|
|
2604
|
+
const u = this.getImage(i.source);
|
|
2605
|
+
if (u.complete && u.naturalWidth > 0) {
|
|
2606
|
+
t.save(), t.globalAlpha = i.opacity, t.drawImage(u, a, c, l, h), t.restore();
|
|
2324
2607
|
continue;
|
|
2325
2608
|
}
|
|
2326
|
-
|
|
2609
|
+
u.onload = () => this.scheduleRender();
|
|
2327
2610
|
}
|
|
2328
|
-
this.opts.showImagePlaceholders && (t.save(), t.strokeStyle =
|
|
2611
|
+
this.opts.showImagePlaceholders && (t.save(), t.strokeStyle = i.color, t.globalAlpha = i.opacity, t.lineWidth = 1, t.strokeRect(a, c, l, h), t.beginPath(), t.moveTo(a, c), t.lineTo(a + l, c + h), t.moveTo(a + l, c), t.lineTo(a, c + h), t.stroke(), t.restore());
|
|
2329
2612
|
}
|
|
2330
2613
|
}
|
|
2331
2614
|
}
|
|
2332
2615
|
getImage(t) {
|
|
2333
|
-
let
|
|
2334
|
-
return
|
|
2616
|
+
let n = this.imageCache.get(t);
|
|
2617
|
+
return n || (n = new Image(), n.src = t, this.imageCache.set(t, n)), n;
|
|
2335
2618
|
}
|
|
2336
2619
|
createOverlayCanvas() {
|
|
2337
2620
|
const t = this.canvas.parentElement;
|
|
2338
2621
|
if (!t || typeof document > "u") return;
|
|
2339
2622
|
window.getComputedStyle(t).position === "static" && (t.style.position = "relative");
|
|
2340
|
-
const
|
|
2341
|
-
|
|
2342
|
-
const
|
|
2343
|
-
|
|
2623
|
+
const r = document.createElement("canvas");
|
|
2624
|
+
r.className = "cad-viewer-text-overlay", r.setAttribute("aria-hidden", "true"), r.style.position = "absolute", r.style.inset = "0", r.style.width = "100%", r.style.height = "100%", r.style.pointerEvents = "none", r.style.zIndex = "1";
|
|
2625
|
+
const i = r.getContext("2d");
|
|
2626
|
+
i && (t.appendChild(r), this.overlayCanvas = r, this.overlayCtx = i);
|
|
2344
2627
|
}
|
|
2345
|
-
resizeOverlay(t,
|
|
2346
|
-
this.overlayCanvas && (this.overlayCanvas.width !== t || this.overlayCanvas.height !==
|
|
2628
|
+
resizeOverlay(t, n) {
|
|
2629
|
+
this.overlayCanvas && (this.overlayCanvas.width !== t || this.overlayCanvas.height !== n) && (this.overlayCanvas.width = t, this.overlayCanvas.height = n);
|
|
2347
2630
|
}
|
|
2348
2631
|
bindEvents() {
|
|
2349
2632
|
const t = this.eventController.signal;
|
|
2350
|
-
this.canvas.addEventListener("wheel", (
|
|
2351
|
-
|
|
2352
|
-
const
|
|
2353
|
-
this.zoom(
|
|
2354
|
-
}, { passive: !1, signal: t }), this.canvas.addEventListener("pointerdown", (
|
|
2355
|
-
this.canvas.setPointerCapture(
|
|
2356
|
-
}, { signal: t }), this.canvas.addEventListener("pointermove", (
|
|
2357
|
-
!this.isDragging || !this.lastPointer || (this.panByScreenDelta(
|
|
2633
|
+
this.canvas.addEventListener("wheel", (r) => {
|
|
2634
|
+
r.preventDefault();
|
|
2635
|
+
const i = r.deltaY < 0 ? this.opts.wheelZoomFactor : 1 / this.opts.wheelZoomFactor;
|
|
2636
|
+
this.zoom(i, { x: r.offsetX, y: r.offsetY });
|
|
2637
|
+
}, { passive: !1, signal: t }), this.canvas.addEventListener("pointerdown", (r) => {
|
|
2638
|
+
this.canvas.setPointerCapture(r.pointerId), this.isDragging = !0, this.lastPointer = { x: r.clientX, y: r.clientY }, this.canvas.classList.add("is-dragging");
|
|
2639
|
+
}, { signal: t }), this.canvas.addEventListener("pointermove", (r) => {
|
|
2640
|
+
!this.isDragging || !this.lastPointer || (this.panByScreenDelta(r.clientX - this.lastPointer.x, r.clientY - this.lastPointer.y), this.lastPointer = { x: r.clientX, y: r.clientY });
|
|
2358
2641
|
}, { signal: t });
|
|
2359
|
-
const
|
|
2360
|
-
|
|
2642
|
+
const n = (r) => {
|
|
2643
|
+
r && this.canvas.hasPointerCapture(r.pointerId) && this.canvas.releasePointerCapture(r.pointerId), this.isDragging = !1, this.lastPointer = void 0, this.canvas.classList.remove("is-dragging");
|
|
2361
2644
|
};
|
|
2362
|
-
this.canvas.addEventListener("pointerup",
|
|
2363
|
-
|
|
2645
|
+
this.canvas.addEventListener("pointerup", n, { signal: t }), this.canvas.addEventListener("pointercancel", () => n(), { signal: t }), this.canvas.addEventListener("webglcontextlost", (r) => {
|
|
2646
|
+
r.preventDefault(), this.cancelScheduledRender();
|
|
2364
2647
|
}, { signal: t });
|
|
2365
2648
|
}
|
|
2366
2649
|
visibleWorldBounds() {
|
|
2367
|
-
const t = this.cssWidth / Math.max(this.view.scale, 1e-12) / 2,
|
|
2650
|
+
const t = this.cssWidth / Math.max(this.view.scale, 1e-12) / 2, n = this.cssHeight / Math.max(this.view.scale, 1e-12) / 2;
|
|
2368
2651
|
return {
|
|
2369
2652
|
minX: this.view.centerX - t,
|
|
2370
2653
|
maxX: this.view.centerX + t,
|
|
2371
|
-
minY: this.view.centerY -
|
|
2372
|
-
maxY: this.view.centerY +
|
|
2654
|
+
minY: this.view.centerY - n,
|
|
2655
|
+
maxY: this.view.centerY + n
|
|
2373
2656
|
};
|
|
2374
2657
|
}
|
|
2375
2658
|
get cssWidth() {
|
|
@@ -2381,11 +2664,14 @@ class zt {
|
|
|
2381
2664
|
clampScale(t) {
|
|
2382
2665
|
return Math.min(this.opts.maxScale, Math.max(this.opts.minScale, t));
|
|
2383
2666
|
}
|
|
2667
|
+
boundsOptions() {
|
|
2668
|
+
return { maxInsertDepth: this.opts.maxInsertDepth, maxCurveSegments: this.opts.maxCurveSegments };
|
|
2669
|
+
}
|
|
2384
2670
|
disposeScene() {
|
|
2385
2671
|
if (!this.scene) return;
|
|
2386
2672
|
const t = this.gl;
|
|
2387
|
-
for (const
|
|
2388
|
-
t.deleteBuffer(
|
|
2673
|
+
for (const n of [...this.scene.lineBatches, ...this.scene.triangleBatches, ...this.scene.lineTypePointBatches, ...this.scene.pointBatches])
|
|
2674
|
+
t.deleteBuffer(n.positionBuffer), t.deleteBuffer(n.colorBuffer);
|
|
2389
2675
|
this.scene = void 0;
|
|
2390
2676
|
}
|
|
2391
2677
|
emitViewChange() {
|
|
@@ -2399,13 +2685,13 @@ class zt {
|
|
|
2399
2685
|
});
|
|
2400
2686
|
}
|
|
2401
2687
|
}
|
|
2402
|
-
function
|
|
2688
|
+
function Ee() {
|
|
2403
2689
|
if (typeof document > "u") return !1;
|
|
2404
2690
|
const e = document.createElement("canvas");
|
|
2405
2691
|
return !!(e.getContext("webgl2") ?? e.getContext("webgl") ?? e.getContext("experimental-webgl"));
|
|
2406
2692
|
}
|
|
2407
|
-
function
|
|
2408
|
-
const
|
|
2693
|
+
function nr(e, t) {
|
|
2694
|
+
const n = {
|
|
2409
2695
|
alpha: !1,
|
|
2410
2696
|
antialias: t.antialias ?? !0,
|
|
2411
2697
|
depth: !1,
|
|
@@ -2413,9 +2699,9 @@ function dr(e, t) {
|
|
|
2413
2699
|
preserveDrawingBuffer: t.preserveDrawingBuffer ?? !1,
|
|
2414
2700
|
powerPreference: t.powerPreference ?? "high-performance"
|
|
2415
2701
|
};
|
|
2416
|
-
return e.getContext("webgl2",
|
|
2702
|
+
return e.getContext("webgl2", n) ?? e.getContext("webgl", n) ?? e.getContext("experimental-webgl", n) ?? void 0;
|
|
2417
2703
|
}
|
|
2418
|
-
function
|
|
2704
|
+
function rr(e) {
|
|
2419
2705
|
const t = `
|
|
2420
2706
|
attribute vec2 a_position;
|
|
2421
2707
|
attribute vec4 a_color;
|
|
@@ -2434,81 +2720,83 @@ function ur(e) {
|
|
|
2434
2720
|
gl_PointSize = u_pointSize;
|
|
2435
2721
|
v_color = a_color;
|
|
2436
2722
|
}
|
|
2437
|
-
`,
|
|
2723
|
+
`, n = `
|
|
2438
2724
|
precision mediump float;
|
|
2439
2725
|
varying vec4 v_color;
|
|
2440
2726
|
void main() {
|
|
2441
2727
|
gl_FragColor = v_color;
|
|
2442
2728
|
}
|
|
2443
|
-
`,
|
|
2444
|
-
if (!
|
|
2445
|
-
if (e.attachShader(
|
|
2446
|
-
const
|
|
2447
|
-
throw e.deleteProgram(
|
|
2448
|
-
}
|
|
2449
|
-
e.deleteShader(
|
|
2450
|
-
const o = e.getUniformLocation(
|
|
2451
|
-
if (!o || !a || !c || !
|
|
2729
|
+
`, r = ne(e, e.VERTEX_SHADER, t), i = ne(e, e.FRAGMENT_SHADER, n), s = e.createProgram();
|
|
2730
|
+
if (!s) throw new Error("Failed to create WebGL program.");
|
|
2731
|
+
if (e.attachShader(s, r), e.attachShader(s, i), e.linkProgram(s), !e.getProgramParameter(s, e.LINK_STATUS)) {
|
|
2732
|
+
const h = e.getProgramInfoLog(s) ?? "Unknown WebGL program link error.";
|
|
2733
|
+
throw e.deleteProgram(s), new Error(h);
|
|
2734
|
+
}
|
|
2735
|
+
e.deleteShader(r), e.deleteShader(i);
|
|
2736
|
+
const o = e.getUniformLocation(s, "u_viewCenter"), a = e.getUniformLocation(s, "u_scale"), c = e.getUniformLocation(s, "u_viewport"), l = e.getUniformLocation(s, "u_pointSize");
|
|
2737
|
+
if (!o || !a || !c || !l) throw new Error("Failed to resolve WebGL shader uniforms.");
|
|
2452
2738
|
return {
|
|
2453
|
-
program:
|
|
2454
|
-
aPosition: e.getAttribLocation(
|
|
2455
|
-
aColor: e.getAttribLocation(
|
|
2739
|
+
program: s,
|
|
2740
|
+
aPosition: e.getAttribLocation(s, "a_position"),
|
|
2741
|
+
aColor: e.getAttribLocation(s, "a_color"),
|
|
2456
2742
|
uViewCenter: o,
|
|
2457
2743
|
uScale: a,
|
|
2458
2744
|
uViewport: c,
|
|
2459
|
-
uPointSize:
|
|
2745
|
+
uPointSize: l
|
|
2460
2746
|
};
|
|
2461
2747
|
}
|
|
2462
|
-
function
|
|
2463
|
-
const
|
|
2464
|
-
if (!
|
|
2465
|
-
if (e.shaderSource(
|
|
2466
|
-
const
|
|
2467
|
-
throw e.deleteShader(
|
|
2748
|
+
function ne(e, t, n) {
|
|
2749
|
+
const r = e.createShader(t);
|
|
2750
|
+
if (!r) throw new Error("Failed to create WebGL shader.");
|
|
2751
|
+
if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
|
|
2752
|
+
const i = e.getShaderInfoLog(r) ?? "Unknown WebGL shader compile error.";
|
|
2753
|
+
throw e.deleteShader(r), new Error(i);
|
|
2468
2754
|
}
|
|
2469
|
-
return
|
|
2755
|
+
return r;
|
|
2470
2756
|
}
|
|
2471
|
-
function
|
|
2472
|
-
let
|
|
2473
|
-
const
|
|
2474
|
-
const h =
|
|
2475
|
-
return
|
|
2757
|
+
function ir(e, t) {
|
|
2758
|
+
let n = 0;
|
|
2759
|
+
const r = (c) => c.map((l) => {
|
|
2760
|
+
const h = re(e, l.positions), u = re(e, l.colors), f = l.positions.byteLength + l.colors.byteLength;
|
|
2761
|
+
return n += f, {
|
|
2476
2762
|
positionBuffer: h,
|
|
2477
|
-
colorBuffer:
|
|
2478
|
-
vertexCount:
|
|
2479
|
-
primitiveCount:
|
|
2480
|
-
bounds:
|
|
2763
|
+
colorBuffer: u,
|
|
2764
|
+
vertexCount: l.positions.length / 2,
|
|
2765
|
+
primitiveCount: l.primitiveCount,
|
|
2766
|
+
bounds: l.bounds,
|
|
2481
2767
|
gpuBytes: f
|
|
2482
2768
|
};
|
|
2483
|
-
}),
|
|
2769
|
+
}), i = r(t.lineBatches), s = r(t.triangleBatches), o = r(t.lineTypePointBatches), a = r(t.pointBatches);
|
|
2484
2770
|
return {
|
|
2485
2771
|
origin: t.origin,
|
|
2486
|
-
lineBatches:
|
|
2487
|
-
triangleBatches:
|
|
2488
|
-
|
|
2772
|
+
lineBatches: i,
|
|
2773
|
+
triangleBatches: s,
|
|
2774
|
+
lineTypePointBatches: o,
|
|
2775
|
+
pointBatches: a,
|
|
2489
2776
|
textItems: t.textItems,
|
|
2490
2777
|
imageItems: t.imageItems,
|
|
2491
2778
|
stats: t.stats,
|
|
2492
2779
|
primitiveCount: t.primitiveCount,
|
|
2493
|
-
gpuMemoryBytes:
|
|
2780
|
+
gpuMemoryBytes: n,
|
|
2494
2781
|
buildElapsedMs: t.buildElapsedMs
|
|
2495
2782
|
};
|
|
2496
2783
|
}
|
|
2497
|
-
function
|
|
2498
|
-
const
|
|
2499
|
-
if (!
|
|
2500
|
-
return e.bindBuffer(e.ARRAY_BUFFER,
|
|
2784
|
+
function re(e, t) {
|
|
2785
|
+
const n = e.createBuffer();
|
|
2786
|
+
if (!n) throw new Error("Failed to create WebGL buffer.");
|
|
2787
|
+
return e.bindBuffer(e.ARRAY_BUFFER, n), e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW), n;
|
|
2501
2788
|
}
|
|
2502
|
-
function
|
|
2503
|
-
const
|
|
2504
|
-
for (const a of e.entities)
|
|
2505
|
-
const o =
|
|
2506
|
-
return o.buildElapsedMs = performance.now() -
|
|
2789
|
+
function sr(e, t, n) {
|
|
2790
|
+
const r = performance.now(), i = I(n) ? { x: (n.minX + n.maxX) / 2, y: (n.minY + n.maxY) / 2 } : { x: 0, y: 0 }, s = new or(e, t, n, i);
|
|
2791
|
+
for (const a of e.entities) s.addEntityTracked(a, 0);
|
|
2792
|
+
const o = s.finalize();
|
|
2793
|
+
return o.buildElapsedMs = performance.now() - r, o;
|
|
2507
2794
|
}
|
|
2508
|
-
class
|
|
2509
|
-
constructor(t, r, i
|
|
2795
|
+
class or {
|
|
2796
|
+
constructor(t, n, r, i) {
|
|
2510
2797
|
d(this, "lineBuckets", /* @__PURE__ */ new Map());
|
|
2511
2798
|
d(this, "triangleBuckets", /* @__PURE__ */ new Map());
|
|
2799
|
+
d(this, "lineTypePointBuckets", /* @__PURE__ */ new Map());
|
|
2512
2800
|
d(this, "pointBuckets", /* @__PURE__ */ new Map());
|
|
2513
2801
|
d(this, "textItems", []);
|
|
2514
2802
|
d(this, "imageItems", []);
|
|
@@ -2516,27 +2804,28 @@ class gr {
|
|
|
2516
2804
|
d(this, "tileSize");
|
|
2517
2805
|
d(this, "maxVerticesPerBatch");
|
|
2518
2806
|
d(this, "primitiveCount", 0);
|
|
2519
|
-
this.document = t, this.opts =
|
|
2520
|
-
const
|
|
2521
|
-
this.tileSize =
|
|
2807
|
+
this.document = t, this.opts = n, this.bounds = r, this.origin = i;
|
|
2808
|
+
const s = I(r) ? Math.max(r.maxX - r.minX, r.maxY - r.minY, 1e-9) : 1;
|
|
2809
|
+
this.tileSize = n.enableSpatialIndex ? s / Math.max(8, n.spatialIndexCellCount) : Number.POSITIVE_INFINITY, this.maxVerticesPerBatch = Math.max(4096, Math.floor(n.maxVerticesPerBatch));
|
|
2522
2810
|
}
|
|
2523
|
-
addEntityTracked(t,
|
|
2811
|
+
addEntityTracked(t, n) {
|
|
2524
2812
|
this.stats.total++;
|
|
2525
|
-
const
|
|
2526
|
-
this.stats.byType[
|
|
2527
|
-
const
|
|
2528
|
-
if (t.isVisible === !1 || !
|
|
2813
|
+
const r = String(t.type ?? "UNKNOWN").toUpperCase();
|
|
2814
|
+
this.stats.byType[r] = (this.stats.byType[r] ?? 0) + 1;
|
|
2815
|
+
const i = this.lookupLayer(t.layer);
|
|
2816
|
+
if (t.isVisible === !1 || !pe(i)) {
|
|
2529
2817
|
this.stats.skipped++;
|
|
2530
2818
|
return;
|
|
2531
2819
|
}
|
|
2532
|
-
this.addEntity(t,
|
|
2820
|
+
this.addEntity(t, r, n);
|
|
2533
2821
|
}
|
|
2534
2822
|
finalize() {
|
|
2535
|
-
const t =
|
|
2823
|
+
const t = at(this.lineBuckets, this.maxVerticesPerBatch), n = at(this.triangleBuckets, this.maxVerticesPerBatch), r = at(this.lineTypePointBuckets, this.maxVerticesPerBatch), i = at(this.pointBuckets, this.maxVerticesPerBatch);
|
|
2536
2824
|
return this.stats.primitiveCount = this.primitiveCount, {
|
|
2537
2825
|
origin: this.origin,
|
|
2538
2826
|
lineBatches: t,
|
|
2539
|
-
triangleBatches:
|
|
2827
|
+
triangleBatches: n,
|
|
2828
|
+
lineTypePointBatches: r,
|
|
2540
2829
|
pointBatches: i,
|
|
2541
2830
|
textItems: this.textItems,
|
|
2542
2831
|
imageItems: this.imageItems,
|
|
@@ -2545,8 +2834,8 @@ class gr {
|
|
|
2545
2834
|
buildElapsedMs: 0
|
|
2546
2835
|
};
|
|
2547
2836
|
}
|
|
2548
|
-
addEntity(t,
|
|
2549
|
-
switch (t.kind ??
|
|
2837
|
+
addEntity(t, n, r) {
|
|
2838
|
+
switch (t.kind ?? J(n)) {
|
|
2550
2839
|
case "line":
|
|
2551
2840
|
return this.addLineEntity(t);
|
|
2552
2841
|
case "circle":
|
|
@@ -2562,7 +2851,7 @@ class gr {
|
|
|
2562
2851
|
case "point":
|
|
2563
2852
|
return this.addPointEntity(t);
|
|
2564
2853
|
case "insert":
|
|
2565
|
-
return this.addInsertEntity(t,
|
|
2854
|
+
return this.addInsertEntity(t, r);
|
|
2566
2855
|
case "solid":
|
|
2567
2856
|
return this.addSolidEntity(t);
|
|
2568
2857
|
case "hatch":
|
|
@@ -2574,165 +2863,175 @@ class gr {
|
|
|
2574
2863
|
case "image":
|
|
2575
2864
|
return this.addImageEntity(t);
|
|
2576
2865
|
case "viewport":
|
|
2577
|
-
return this.markSkipped(
|
|
2866
|
+
return this.markSkipped(n);
|
|
2578
2867
|
default:
|
|
2579
|
-
this.stats.unsupported[
|
|
2868
|
+
this.stats.unsupported[n] = (this.stats.unsupported[n] ?? 0) + 1, this.stats.skipped++, this.opts.showUnsupportedMarkers && this.addUnsupportedMarker(t);
|
|
2580
2869
|
}
|
|
2581
2870
|
}
|
|
2582
2871
|
addLineEntity(t) {
|
|
2583
|
-
if (!
|
|
2584
|
-
this.
|
|
2872
|
+
if (!g(t.startPoint) || !g(t.endPoint)) return this.markSkipped("LINE");
|
|
2873
|
+
this.addPolyline([t.startPoint, t.endPoint], !1, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2585
2874
|
}
|
|
2586
2875
|
addCircleEntity(t) {
|
|
2587
|
-
const
|
|
2588
|
-
if (!
|
|
2589
|
-
const
|
|
2590
|
-
this.addPolyline(
|
|
2876
|
+
const n = t.center, r = Number(t.radius);
|
|
2877
|
+
if (!g(n) || !Number.isFinite(r)) return this.markSkipped("CIRCLE");
|
|
2878
|
+
const i = Math.max(16, Math.min(this.opts.maxCurveSegments, Math.ceil(Math.sqrt(Math.abs(r)) * 12))), s = Q(n, r, 0, Math.PI * 2, !0, i);
|
|
2879
|
+
this.addPolyline(s, !0, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2591
2880
|
}
|
|
2592
2881
|
addArcEntity(t) {
|
|
2593
|
-
const
|
|
2594
|
-
if (!
|
|
2595
|
-
this.addPolyline(
|
|
2882
|
+
const n = t.center, r = Number(t.radius), i = Number(t.startAngle), s = Number(t.endAngle);
|
|
2883
|
+
if (!g(n) || !Number.isFinite(r) || !Number.isFinite(i) || !Number.isFinite(s)) return this.markSkipped("ARC");
|
|
2884
|
+
this.addPolyline(Q(n, r, i, s, !0, this.opts.maxCurveSegments), !1, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2596
2885
|
}
|
|
2597
2886
|
addPolylineEntity(t) {
|
|
2598
|
-
const
|
|
2599
|
-
if (!Array.isArray(
|
|
2600
|
-
const
|
|
2601
|
-
for (let o = 0; o <
|
|
2602
|
-
const a =
|
|
2603
|
-
if (!
|
|
2604
|
-
const
|
|
2605
|
-
|
|
2887
|
+
const n = t.vertices ?? t.points;
|
|
2888
|
+
if (!Array.isArray(n) || n.length < 2) return this.markSkipped(String(t.type));
|
|
2889
|
+
const r = ae(t), i = [], s = r ? n.length : n.length - 1;
|
|
2890
|
+
for (let o = 0; o < s; o++) {
|
|
2891
|
+
const a = n[o], c = n[(o + 1) % n.length];
|
|
2892
|
+
if (!g(a) || !g(c)) continue;
|
|
2893
|
+
const l = fe(a, c, Number(a.bulge ?? 0), Math.max(4, Math.min(24, this.opts.maxCurveSegments / 4)));
|
|
2894
|
+
i.length > 0 && l.shift(), i.push(...l);
|
|
2606
2895
|
}
|
|
2607
|
-
if (
|
|
2608
|
-
this.addPolyline(
|
|
2896
|
+
if (i.length < 2) return this.markSkipped(String(t.type));
|
|
2897
|
+
this.addPolyline(i, r, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2609
2898
|
}
|
|
2610
2899
|
addEllipseEntity(t) {
|
|
2611
|
-
if (!
|
|
2612
|
-
const
|
|
2613
|
-
this.addPolyline(
|
|
2900
|
+
if (!g(t.center) || !g(t.majorAxisEndPoint)) return this.markSkipped("ELLIPSE");
|
|
2901
|
+
const n = Lt(t.center, t.majorAxisEndPoint, Number(t.axisRatio ?? 1), Number(t.startAngle ?? 0), Number(t.endAngle ?? Math.PI * 2), this.opts.maxCurveSegments), r = Math.abs(Number(t.endAngle ?? Math.PI * 2) - Number(t.startAngle ?? 0)) >= Math.PI * 2 - 1e-6;
|
|
2902
|
+
this.addPolyline(n, r, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2614
2903
|
}
|
|
2615
2904
|
addTextEntity(t) {
|
|
2616
|
-
const
|
|
2617
|
-
if (!
|
|
2618
|
-
const
|
|
2905
|
+
const n = t.insertionPoint ?? t.startPoint ?? t.center, r = ue(String(t.text ?? t.value ?? "")), i = Number(t.textHeight ?? t.height ?? 1);
|
|
2906
|
+
if (!g(n) || !r || !Number.isFinite(i)) return this.markSkipped(String(t.type));
|
|
2907
|
+
const s = P(n), o = Math.max(1, r.split(/\r?\n/g).reduce((c, l) => Math.max(c, l.length), 0)) * Math.abs(i) * 0.62, a = Math.max(1, r.split(/\r?\n/g).length) * Math.abs(i) * 1.22;
|
|
2619
2908
|
this.textItems.push({
|
|
2620
|
-
point:
|
|
2621
|
-
text:
|
|
2622
|
-
height:
|
|
2909
|
+
point: s,
|
|
2910
|
+
text: r,
|
|
2911
|
+
height: i,
|
|
2623
2912
|
rotation: Number(t.rotation ?? 0),
|
|
2624
|
-
color:
|
|
2625
|
-
opacity:
|
|
2626
|
-
bounds: { minX:
|
|
2913
|
+
color: V(t, this.document, this.colorOptions()),
|
|
2914
|
+
opacity: _(Number(t.opacity ?? 1), 0, 1),
|
|
2915
|
+
bounds: { minX: s.x - o * 0.1, minY: s.y - a, maxX: s.x + o, maxY: s.y + a }
|
|
2627
2916
|
}), this.stats.drawn++;
|
|
2628
2917
|
}
|
|
2629
2918
|
addPointEntity(t) {
|
|
2630
|
-
const
|
|
2631
|
-
if (!
|
|
2632
|
-
this.addPoint(
|
|
2633
|
-
}
|
|
2634
|
-
addInsertEntity(t,
|
|
2635
|
-
const
|
|
2636
|
-
if (
|
|
2637
|
-
const
|
|
2638
|
-
for (const o of
|
|
2639
|
-
const a =
|
|
2640
|
-
this.addEntityTracked(
|
|
2919
|
+
const n = t.point ?? t.location ?? t.center ?? t.insertionPoint;
|
|
2920
|
+
if (!g(n)) return this.markSkipped("POINT");
|
|
2921
|
+
this.addPoint(n, this.strokeBytes(t)), this.stats.drawn++;
|
|
2922
|
+
}
|
|
2923
|
+
addInsertEntity(t, n) {
|
|
2924
|
+
const r = this.lookupBlock(t.blockName ?? t.name);
|
|
2925
|
+
if (r && n < this.opts.maxInsertDepth) {
|
|
2926
|
+
const s = Bt(t, r.basePoint ?? { x: 0, y: 0 });
|
|
2927
|
+
for (const o of r.entities) {
|
|
2928
|
+
const a = ge(o, t, this.document, this.colorOptions()), c = Se(a, t, this.document);
|
|
2929
|
+
this.addEntityTracked($(c, s), n + 1);
|
|
2641
2930
|
}
|
|
2642
2931
|
return;
|
|
2643
2932
|
}
|
|
2644
|
-
const
|
|
2645
|
-
if (!
|
|
2646
|
-
if (this.addPoint(
|
|
2933
|
+
const i = t.insertionPoint;
|
|
2934
|
+
if (!g(i)) return this.markSkipped("INSERT");
|
|
2935
|
+
if (this.addPoint(i, this.strokeBytes(t)), Array.isArray(t.attribs)) for (const s of t.attribs) this.addTextEntity(s);
|
|
2647
2936
|
this.stats.drawn++;
|
|
2648
2937
|
}
|
|
2649
2938
|
addSolidEntity(t) {
|
|
2650
|
-
const
|
|
2651
|
-
if (!Array.isArray(
|
|
2652
|
-
const
|
|
2653
|
-
if (
|
|
2654
|
-
const
|
|
2655
|
-
this.addTriangleFan(
|
|
2939
|
+
const n = t.vertices ?? t.points;
|
|
2940
|
+
if (!Array.isArray(n) || n.length < 3) return this.markSkipped(String(t.type));
|
|
2941
|
+
const r = n.filter(g).map(P);
|
|
2942
|
+
if (r.length < 3) return this.markSkipped(String(t.type));
|
|
2943
|
+
const i = this.fillBytes(t) ?? this.strokeBytes(t);
|
|
2944
|
+
this.addTriangleFan(r, i), this.addPolyline(r, !0, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2656
2945
|
}
|
|
2657
2946
|
addHatchEntity(t) {
|
|
2658
2947
|
var o;
|
|
2659
|
-
const
|
|
2660
|
-
if (!Array.isArray(
|
|
2661
|
-
const
|
|
2662
|
-
let
|
|
2663
|
-
for (const a of
|
|
2664
|
-
const c = (o = a.commands) != null && o.length ?
|
|
2665
|
-
c.length < 2 || (this.addPolyline(c, !0,
|
|
2948
|
+
const n = t.loops;
|
|
2949
|
+
if (!Array.isArray(n) || n.length === 0) return this.markSkipped("HATCH");
|
|
2950
|
+
const r = this.strokeBytes(t), i = this.fillBytes(t);
|
|
2951
|
+
let s = !1;
|
|
2952
|
+
for (const a of n) {
|
|
2953
|
+
const c = (o = a.commands) != null && o.length ? ie(a.commands, this.opts.maxCurveSegments) : (a.vertices ?? []).filter(g).map(P);
|
|
2954
|
+
c.length < 2 || (this.addPolyline(c, !0, r, t), i && c.length >= 3 && this.addTriangleFan(c, i), s = !0);
|
|
2666
2955
|
}
|
|
2667
|
-
if (!
|
|
2956
|
+
if (!s) return this.markSkipped("HATCH");
|
|
2668
2957
|
this.stats.drawn++;
|
|
2669
2958
|
}
|
|
2670
2959
|
addSplineEntity(t) {
|
|
2671
|
-
var
|
|
2672
|
-
const
|
|
2673
|
-
if (!
|
|
2674
|
-
this.addPolyline(
|
|
2960
|
+
var r;
|
|
2961
|
+
const n = (r = t.fitPoints) != null && r.length ? t.fitPoints : t.controlPoints;
|
|
2962
|
+
if (!n || n.length < 2) return this.markSkipped("SPLINE");
|
|
2963
|
+
this.addPolyline(n.filter(g).map(P), !!t.isClosed, this.strokeBytes(t), t), this.stats.drawn++;
|
|
2675
2964
|
}
|
|
2676
2965
|
addPathEntity(t) {
|
|
2677
|
-
var
|
|
2678
|
-
if (!((
|
|
2679
|
-
const
|
|
2680
|
-
if (
|
|
2681
|
-
this.addPolyline(
|
|
2682
|
-
const
|
|
2683
|
-
|
|
2966
|
+
var i;
|
|
2967
|
+
if (!((i = t.commands) != null && i.length)) return this.markSkipped(String(t.type));
|
|
2968
|
+
const n = ie(t.commands, this.opts.maxCurveSegments);
|
|
2969
|
+
if (n.length < 2) return this.markSkipped(String(t.type));
|
|
2970
|
+
this.addPolyline(n, !1, this.strokeBytes(t), t);
|
|
2971
|
+
const r = this.fillBytes(t);
|
|
2972
|
+
r && n.length >= 3 && this.addTriangleFan(n, r), this.stats.drawn++;
|
|
2684
2973
|
}
|
|
2685
2974
|
addImageEntity(t) {
|
|
2686
|
-
const
|
|
2687
|
-
if (!
|
|
2688
|
-
const
|
|
2689
|
-
if (!Number.isFinite(
|
|
2690
|
-
const
|
|
2691
|
-
this.imageItems.push({ point:
|
|
2975
|
+
const n = t.insertionPoint;
|
|
2976
|
+
if (!g(n)) return this.markSkipped(String(t.type));
|
|
2977
|
+
const r = Number(t.width ?? 32), i = Number(t.height ?? 32);
|
|
2978
|
+
if (!Number.isFinite(r) || !Number.isFinite(i)) return this.markSkipped(String(t.type));
|
|
2979
|
+
const s = P(n), o = gt([s, { x: s.x + r, y: s.y - i }]);
|
|
2980
|
+
this.imageItems.push({ point: s, width: r, height: i, source: t.imageDataUrl ?? t.imageSource, color: V(t, this.document, this.colorOptions()), opacity: _(Number(t.opacity ?? 1), 0, 1), bounds: o }), this.stats.drawn++;
|
|
2692
2981
|
}
|
|
2693
2982
|
addUnsupportedMarker(t) {
|
|
2694
|
-
const
|
|
2695
|
-
|
|
2696
|
-
}
|
|
2697
|
-
addPolyline(t, r, i) {
|
|
2698
|
-
const s = t.filter(m).map(x);
|
|
2699
|
-
if (!(s.length < 2)) {
|
|
2700
|
-
for (let n = 0; n < s.length - 1; n++) this.addSegment(s[n], s[n + 1], i);
|
|
2701
|
-
r && this.addSegment(s[s.length - 1], s[0], i);
|
|
2702
|
-
}
|
|
2703
|
-
}
|
|
2704
|
-
addSegment(t, r, i) {
|
|
2705
|
-
if (!m(t) || !m(r) || Math.hypot(t.x - r.x, t.y - r.y) <= 1e-14) return;
|
|
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++;
|
|
2708
|
-
}
|
|
2709
|
-
addPoint(t, r) {
|
|
2710
|
-
const i = this.batchFor(this.pointBuckets, xr(t));
|
|
2711
|
-
T(i, t, r, this.origin), i.primitiveCount++, this.primitiveCount++;
|
|
2983
|
+
const n = lr(t);
|
|
2984
|
+
n && this.addPoint(n, this.strokeBytes(t));
|
|
2712
2985
|
}
|
|
2713
|
-
|
|
2714
|
-
const
|
|
2715
|
-
if (
|
|
2716
|
-
const
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2986
|
+
addPolyline(t, n, r, i) {
|
|
2987
|
+
const s = t.filter(g).map(P);
|
|
2988
|
+
if (s.length < 2) return;
|
|
2989
|
+
const o = i ? Nt(i, this.document) : void 0;
|
|
2990
|
+
if (o) {
|
|
2991
|
+
const a = Dt(s, n, o);
|
|
2992
|
+
for (const [c, l] of a.segments) this.addSegment(c, l, r);
|
|
2993
|
+
for (const c of a.dots) this.addLineTypePoint(c, r);
|
|
2994
|
+
return;
|
|
2995
|
+
}
|
|
2996
|
+
for (let a = 0; a < s.length - 1; a++) this.addSegment(s[a], s[a + 1], r);
|
|
2997
|
+
n && this.addSegment(s[s.length - 1], s[0], r);
|
|
2998
|
+
}
|
|
2999
|
+
addSegment(t, n, r) {
|
|
3000
|
+
if (!g(t) || !g(n) || Math.hypot(t.x - n.x, t.y - n.y) <= 1e-14) return;
|
|
3001
|
+
const i = this.batchFor(this.lineBuckets, gt([t, n]));
|
|
3002
|
+
D(i, t, r, this.origin), D(i, n, r, this.origin), i.primitiveCount++, this.primitiveCount++;
|
|
3003
|
+
}
|
|
3004
|
+
addPoint(t, n) {
|
|
3005
|
+
const r = this.batchFor(this.pointBuckets, se(t));
|
|
3006
|
+
D(r, t, n, this.origin), r.primitiveCount++, this.primitiveCount++;
|
|
3007
|
+
}
|
|
3008
|
+
addLineTypePoint(t, n) {
|
|
3009
|
+
const r = this.batchFor(this.lineTypePointBuckets, se(t));
|
|
3010
|
+
D(r, t, n, this.origin), r.primitiveCount++, this.primitiveCount++;
|
|
3011
|
+
}
|
|
3012
|
+
addTriangleFan(t, n) {
|
|
3013
|
+
const r = t.filter(g).map(P);
|
|
3014
|
+
if (r.length < 3) return;
|
|
3015
|
+
const i = gt(r), s = this.batchFor(this.triangleBuckets, i);
|
|
3016
|
+
for (let o = 1; o < r.length - 1; o++)
|
|
3017
|
+
D(s, r[0], n, this.origin), D(s, r[o], n, this.origin), D(s, r[o + 1], n, this.origin), s.primitiveCount++, this.primitiveCount++;
|
|
3018
|
+
}
|
|
3019
|
+
batchFor(t, n) {
|
|
3020
|
+
const r = this.bucketKey(n);
|
|
3021
|
+
let i = t.get(r);
|
|
3022
|
+
return i || (i = ar(), t.set(r, i)), S(i.bounds, { x: n.minX, y: n.minY }), S(i.bounds, { x: n.maxX, y: n.maxY }), i;
|
|
2724
3023
|
}
|
|
2725
3024
|
bucketKey(t) {
|
|
2726
3025
|
if (!Number.isFinite(this.tileSize)) return "all";
|
|
2727
|
-
const
|
|
2728
|
-
return `${
|
|
3026
|
+
const n = (t.minX + t.maxX) / 2, r = (t.minY + t.maxY) / 2, i = Math.floor((n - this.bounds.minX) / this.tileSize), s = Math.floor((r - this.bounds.minY) / this.tileSize);
|
|
3027
|
+
return `${i}:${s}`;
|
|
2729
3028
|
}
|
|
2730
3029
|
strokeBytes(t) {
|
|
2731
|
-
return
|
|
3030
|
+
return Mt(V(t, this.document, this.colorOptions()), [255, 255, 255, 255], _(Number(t.opacity ?? 1), 0, 1));
|
|
2732
3031
|
}
|
|
2733
3032
|
fillBytes(t) {
|
|
2734
|
-
const
|
|
2735
|
-
return
|
|
3033
|
+
const n = Pt(t, this.document, this.colorOptions());
|
|
3034
|
+
return n ? Mt(n, [255, 255, 255, 255], _(Number(t.opacity ?? 1), 0, 1)) : void 0;
|
|
2736
3035
|
}
|
|
2737
3036
|
colorOptions() {
|
|
2738
3037
|
return { foreground: this.opts.foreground, background: this.opts.background, trueColorByteOrder: this.opts.trueColorByteOrder, contrastMode: this.opts.contrastMode, minColorContrast: this.opts.minColorContrast };
|
|
@@ -2742,141 +3041,99 @@ class gr {
|
|
|
2742
3041
|
}
|
|
2743
3042
|
lookupLayer(t) {
|
|
2744
3043
|
if (t)
|
|
2745
|
-
return this.document.layers[t] ?? this.document.layers[t.toLowerCase()] ?? Object.values(this.document.layers).find((
|
|
3044
|
+
return this.document.layers[t] ?? this.document.layers[t.toLowerCase()] ?? Object.values(this.document.layers).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
2746
3045
|
}
|
|
2747
3046
|
lookupBlock(t) {
|
|
2748
3047
|
if (t)
|
|
2749
|
-
return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((
|
|
3048
|
+
return this.document.blocks[t] ?? this.document.blocks[t.toLowerCase()] ?? Object.values(this.document.blocks).find((n) => n.name.toLowerCase() === t.toLowerCase());
|
|
2750
3049
|
}
|
|
2751
3050
|
}
|
|
2752
|
-
function
|
|
2753
|
-
return { positions: [], colors: [], bounds:
|
|
3051
|
+
function ar() {
|
|
3052
|
+
return { positions: [], colors: [], bounds: L(), primitiveCount: 0 };
|
|
2754
3053
|
}
|
|
2755
|
-
function
|
|
2756
|
-
e.positions.push(t.x -
|
|
3054
|
+
function D(e, t, n, r) {
|
|
3055
|
+
e.positions.push(t.x - r.x, t.y - r.y), e.colors.push(n[0], n[1], n[2], n[3]);
|
|
2757
3056
|
}
|
|
2758
|
-
function
|
|
2759
|
-
const
|
|
2760
|
-
for (const
|
|
2761
|
-
const
|
|
2762
|
-
if (
|
|
2763
|
-
if (
|
|
2764
|
-
|
|
3057
|
+
function at(e, t) {
|
|
3058
|
+
const n = [];
|
|
3059
|
+
for (const r of e.values()) {
|
|
3060
|
+
const i = r.positions.length / 2;
|
|
3061
|
+
if (i <= 0 || !I(r.bounds)) continue;
|
|
3062
|
+
if (i <= t) {
|
|
3063
|
+
n.push({ positions: new Float32Array(r.positions), colors: new Uint8Array(r.colors), bounds: { ...r.bounds }, primitiveCount: r.primitiveCount });
|
|
2765
3064
|
continue;
|
|
2766
3065
|
}
|
|
2767
|
-
const
|
|
2768
|
-
for (let a = 0; a <
|
|
2769
|
-
const c = Math.min(
|
|
2770
|
-
for (let
|
|
2771
|
-
|
|
3066
|
+
const s = cr(r), o = Math.max(s, Math.floor(t / s) * s);
|
|
3067
|
+
for (let a = 0; a < i; a += o) {
|
|
3068
|
+
const c = Math.min(i, a + o), l = r.positions.slice(a * 2, c * 2), h = r.colors.slice(a * 4, c * 4), u = L();
|
|
3069
|
+
for (let f = 0; f < l.length; f += 2) S(u, { x: l[f], y: l[f + 1] });
|
|
3070
|
+
n.push({ positions: new Float32Array(l), colors: new Uint8Array(h), bounds: { ...r.bounds }, primitiveCount: Math.floor((c - a) / s) });
|
|
2772
3071
|
}
|
|
2773
3072
|
}
|
|
2774
|
-
return
|
|
3073
|
+
return n;
|
|
2775
3074
|
}
|
|
2776
|
-
function
|
|
3075
|
+
function cr(e) {
|
|
2777
3076
|
const t = e.positions.length / 2;
|
|
2778
3077
|
return t === e.primitiveCount ? 1 : t === e.primitiveCount * 3 ? 3 : 2;
|
|
2779
3078
|
}
|
|
2780
|
-
function
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
v(r, { x: 0, y: 0 }), v(r, { x: o.width, y: o.height });
|
|
2786
|
-
const i = (o) => {
|
|
2787
|
-
if (o)
|
|
2788
|
-
return e.blocks[o] ?? e.blocks[o.toLowerCase()] ?? Object.values(e.blocks).find((a) => a.name.toLowerCase() === o.toLowerCase());
|
|
2789
|
-
}, s = (o, a) => {
|
|
2790
|
-
const c = String(o.type ?? "").toUpperCase(), h = o.kind ?? R(c);
|
|
2791
|
-
if (h === "insert") {
|
|
2792
|
-
const l = i(o.blockName ?? o.name);
|
|
2793
|
-
if (l && a < t.maxInsertDepth) {
|
|
2794
|
-
const f = tt(o, l.basePoint ?? { x: 0, y: 0 });
|
|
2795
|
-
for (const u of l.entities) s(et(u, f), a + 1);
|
|
2796
|
-
return;
|
|
2797
|
-
}
|
|
2798
|
-
}
|
|
2799
|
-
if (h === "line")
|
|
2800
|
-
m(o.startPoint) && v(r, o.startPoint), m(o.endPoint) && v(r, o.endPoint);
|
|
2801
|
-
else if (h === "circle" || h === "arc")
|
|
2802
|
-
m(o.center) && Number.isFinite(o.radius) && Vt(r, o.center, Number(o.radius));
|
|
2803
|
-
else if (h === "polyline" || h === "solid" || h === "spline")
|
|
2804
|
-
for (const l of [...o.vertices ?? [], ...o.points ?? [], ...o.controlPoints ?? [], ...o.fitPoints ?? []]) m(l) && v(r, l);
|
|
2805
|
-
else if (h === "ellipse")
|
|
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));
|
|
2807
|
-
else if (h === "path")
|
|
2808
|
-
for (const l of o.commands ?? []) for (const f of l.points) v(r, f);
|
|
2809
|
-
else if (h === "hatch")
|
|
2810
|
-
for (const l of o.loops ?? []) {
|
|
2811
|
-
for (const f of l.vertices ?? []) v(r, f);
|
|
2812
|
-
for (const f of l.commands ?? []) for (const u of f.points) v(r, u);
|
|
2813
|
-
}
|
|
2814
|
-
else {
|
|
2815
|
-
const l = ee(o);
|
|
2816
|
-
l && v(r, l);
|
|
2817
|
-
}
|
|
2818
|
-
};
|
|
2819
|
-
for (const o of e.entities) s(o, 0);
|
|
2820
|
-
return $t(r);
|
|
2821
|
-
}
|
|
2822
|
-
function Yt(e, t) {
|
|
2823
|
-
const r = [];
|
|
2824
|
-
let i, s;
|
|
2825
|
-
const n = (o) => {
|
|
2826
|
-
(!r.length || Math.hypot(r[r.length - 1].x - o.x, r[r.length - 1].y - o.y) > 1e-12) && r.push(x(o)), i = x(o);
|
|
3079
|
+
function ie(e, t) {
|
|
3080
|
+
const n = [];
|
|
3081
|
+
let r, i;
|
|
3082
|
+
const s = (o) => {
|
|
3083
|
+
(!n.length || Math.hypot(n[n.length - 1].x - o.x, n[n.length - 1].y - o.y) > 1e-12) && n.push(P(o)), r = P(o);
|
|
2827
3084
|
};
|
|
2828
3085
|
for (const o of e)
|
|
2829
3086
|
if (o.cmd === "M")
|
|
2830
|
-
|
|
3087
|
+
r = P(o.points[0]), i = r, s(r);
|
|
2831
3088
|
else if (o.cmd === "L")
|
|
2832
|
-
|
|
2833
|
-
else if (o.cmd === "Q" &&
|
|
2834
|
-
const a =
|
|
2835
|
-
for (let
|
|
2836
|
-
const
|
|
2837
|
-
|
|
3089
|
+
s(o.points[0]);
|
|
3090
|
+
else if (o.cmd === "Q" && r && o.points.length >= 2) {
|
|
3091
|
+
const a = r, [c, l] = o.points, h = Math.max(4, Math.min(t, 24));
|
|
3092
|
+
for (let u = 1; u <= h; u++) {
|
|
3093
|
+
const f = u / h, m = 1 - f;
|
|
3094
|
+
s({ x: m * m * a.x + 2 * m * f * c.x + f * f * l.x, y: m * m * a.y + 2 * m * f * c.y + f * f * l.y });
|
|
2838
3095
|
}
|
|
2839
|
-
} else if (o.cmd === "C" &&
|
|
2840
|
-
const a =
|
|
2841
|
-
for (let
|
|
2842
|
-
const
|
|
2843
|
-
|
|
2844
|
-
x:
|
|
2845
|
-
y:
|
|
3096
|
+
} else if (o.cmd === "C" && r && o.points.length >= 3) {
|
|
3097
|
+
const a = r, [c, l, h] = o.points, u = Math.max(6, Math.min(t, 32));
|
|
3098
|
+
for (let f = 1; f <= u; f++) {
|
|
3099
|
+
const m = f / u, p = 1 - m;
|
|
3100
|
+
s({
|
|
3101
|
+
x: p ** 3 * a.x + 3 * p * p * m * c.x + 3 * p * m * m * l.x + m ** 3 * h.x,
|
|
3102
|
+
y: p ** 3 * a.y + 3 * p * p * m * c.y + 3 * p * m * m * l.y + m ** 3 * h.y
|
|
2846
3103
|
});
|
|
2847
3104
|
}
|
|
2848
|
-
} else o.cmd === "Z" &&
|
|
2849
|
-
return
|
|
3105
|
+
} else o.cmd === "Z" && i && s(i);
|
|
3106
|
+
return n;
|
|
2850
3107
|
}
|
|
2851
|
-
function
|
|
3108
|
+
function lr(e) {
|
|
2852
3109
|
for (const t of ["startPoint", "insertionPoint", "center", "point", "location"]) {
|
|
2853
|
-
const
|
|
2854
|
-
if (
|
|
3110
|
+
const n = e[t];
|
|
3111
|
+
if (g(n)) return P(n);
|
|
2855
3112
|
}
|
|
2856
|
-
if (Array.isArray(e.vertices) &&
|
|
3113
|
+
if (Array.isArray(e.vertices) && g(e.vertices[0])) return P(e.vertices[0]);
|
|
2857
3114
|
if (Array.isArray(e.commands) && e.commands.length) {
|
|
2858
|
-
const t = e.commands.find((
|
|
2859
|
-
if (t) return
|
|
3115
|
+
const t = e.commands.find((n) => n.points.length > 0);
|
|
3116
|
+
if (t) return P(t.points[0]);
|
|
2860
3117
|
}
|
|
2861
3118
|
}
|
|
2862
|
-
function
|
|
2863
|
-
const t =
|
|
2864
|
-
for (const
|
|
3119
|
+
function gt(e) {
|
|
3120
|
+
const t = L();
|
|
3121
|
+
for (const n of e) S(t, n);
|
|
2865
3122
|
return t;
|
|
2866
3123
|
}
|
|
2867
|
-
function
|
|
3124
|
+
function se(e) {
|
|
2868
3125
|
return { minX: e.x, minY: e.y, maxX: e.x, maxY: e.y };
|
|
2869
3126
|
}
|
|
2870
|
-
function
|
|
3127
|
+
function bt(e, t) {
|
|
2871
3128
|
return e.minX <= t.maxX && e.maxX >= t.minX && e.minY <= t.maxY && e.maxY >= t.minY;
|
|
2872
3129
|
}
|
|
2873
|
-
function
|
|
3130
|
+
function hr(e, t) {
|
|
2874
3131
|
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;
|
|
2875
3132
|
}
|
|
2876
|
-
function
|
|
3133
|
+
function fr(e, t) {
|
|
2877
3134
|
return { ...e.stats, renderElapsedMs: t, backend: "webgl", primitiveCount: e.primitiveCount, visiblePrimitiveCount: 0, culledPrimitiveCount: 0, gpuMemoryBytes: e.gpuMemoryBytes, buildElapsedMs: e.buildElapsedMs };
|
|
2878
3135
|
}
|
|
2879
|
-
function
|
|
3136
|
+
function ur(e) {
|
|
2880
3137
|
return {
|
|
2881
3138
|
total: e.total,
|
|
2882
3139
|
drawn: e.drawn,
|
|
@@ -2892,27 +3149,27 @@ function Pr(e) {
|
|
|
2892
3149
|
buildElapsedMs: e.buildElapsedMs
|
|
2893
3150
|
};
|
|
2894
3151
|
}
|
|
2895
|
-
function
|
|
2896
|
-
const
|
|
2897
|
-
let
|
|
2898
|
-
if (/^#[0-9a-f]{3}$/i.test(
|
|
2899
|
-
|
|
2900
|
-
else if (/^#[0-9a-f]{6}$/i.test(
|
|
2901
|
-
|
|
3152
|
+
function Mt(e, t, n = 1) {
|
|
3153
|
+
const r = e.trim().toLowerCase();
|
|
3154
|
+
let i;
|
|
3155
|
+
if (/^#[0-9a-f]{3}$/i.test(r))
|
|
3156
|
+
i = [parseInt(r[1] + r[1], 16), parseInt(r[2] + r[2], 16), parseInt(r[3] + r[3], 16), 255];
|
|
3157
|
+
else if (/^#[0-9a-f]{6}$/i.test(r))
|
|
3158
|
+
i = [parseInt(r.slice(1, 3), 16), parseInt(r.slice(3, 5), 16), parseInt(r.slice(5, 7), 16), 255];
|
|
2902
3159
|
else {
|
|
2903
|
-
const o =
|
|
3160
|
+
const o = r.match(/^rgba?\(([^)]+)\)$/i);
|
|
2904
3161
|
if (o) {
|
|
2905
|
-
const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((
|
|
2906
|
-
|
|
3162
|
+
const a = o[1].split(/[\s,\/]+/).filter(Boolean), c = a.slice(0, 3).some((h) => h.includes("%")), l = a.map((h) => Number(h.replace("%", "")));
|
|
3163
|
+
l.length >= 3 && l.slice(0, 3).every(Number.isFinite) && (i = [Z(c ? l[0] * 2.55 : l[0]), Z(c ? l[1] * 2.55 : l[1]), Z(c ? l[2] * 2.55 : l[2]), Z((Number.isFinite(l[3]) ? l[3] : 1) * 255)]);
|
|
2907
3164
|
}
|
|
2908
3165
|
}
|
|
2909
|
-
const
|
|
2910
|
-
return [
|
|
3166
|
+
const s = i ?? t;
|
|
3167
|
+
return [s[0], s[1], s[2], Z(s[3] * n)];
|
|
2911
3168
|
}
|
|
2912
|
-
function
|
|
3169
|
+
function Z(e) {
|
|
2913
3170
|
return Math.max(0, Math.min(255, Math.round(e)));
|
|
2914
3171
|
}
|
|
2915
|
-
class
|
|
3172
|
+
class dr {
|
|
2916
3173
|
constructor(t = {}) {
|
|
2917
3174
|
d(this, "canvas");
|
|
2918
3175
|
d(this, "renderer");
|
|
@@ -2921,92 +3178,92 @@ class kr {
|
|
|
2921
3178
|
d(this, "options");
|
|
2922
3179
|
d(this, "lastResult");
|
|
2923
3180
|
d(this, "activeNativeLoader");
|
|
2924
|
-
var
|
|
2925
|
-
if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ??
|
|
3181
|
+
var n;
|
|
3182
|
+
if (this.options = { autoFit: !0, ...t }, this.registry = t.registry ?? Sn(t), t.loaders) for (const r of t.loaders) this.registry.register(r);
|
|
2926
3183
|
if (this.canvas = t.canvas ?? document.createElement("canvas"), this.canvas.classList.add("cad-viewer-canvas"), t.container)
|
|
2927
3184
|
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);
|
|
2928
3185
|
else if (t.nativeHost)
|
|
2929
3186
|
this.nativeHost = t.nativeHost, this.nativeHost.classList.add("cad-viewer-native-host");
|
|
2930
|
-
else if ((
|
|
3187
|
+
else if ((n = t.canvas) != null && n.parentElement) {
|
|
2931
3188
|
t.canvas.parentElement.classList.add("cad-viewer-container");
|
|
2932
|
-
const
|
|
2933
|
-
|
|
3189
|
+
const r = document.createElement("div");
|
|
3190
|
+
r.classList.add("cad-viewer-native-host"), t.canvas.parentElement.appendChild(r), this.nativeHost = r;
|
|
2934
3191
|
}
|
|
2935
|
-
this.renderer =
|
|
2936
|
-
var
|
|
2937
|
-
return (
|
|
2938
|
-
}, this.renderer.onViewChange = (
|
|
2939
|
-
var
|
|
2940
|
-
return (
|
|
3192
|
+
this.renderer = pr(t.renderer ?? "auto", this.canvas, t.canvasOptions), this.renderer.onStats = (r) => {
|
|
3193
|
+
var i, s;
|
|
3194
|
+
return (s = (i = this.options).onRenderStats) == null ? void 0 : s.call(i, r);
|
|
3195
|
+
}, this.renderer.onViewChange = (r) => {
|
|
3196
|
+
var i, s;
|
|
3197
|
+
return (s = (i = this.options).onViewChange) == null ? void 0 : s.call(i, r);
|
|
2941
3198
|
};
|
|
2942
3199
|
}
|
|
2943
3200
|
registerLoader(t) {
|
|
2944
3201
|
return this.registry.register(t), this;
|
|
2945
3202
|
}
|
|
2946
|
-
async loadFile(t,
|
|
2947
|
-
var
|
|
2948
|
-
return (
|
|
3203
|
+
async loadFile(t, n = {}) {
|
|
3204
|
+
var r, i;
|
|
3205
|
+
return (i = (r = this.options).onLoadStart) == null || i.call(r, t), this.loadThroughRegistry({ file: t, fileName: t.name }, n, t.name);
|
|
2949
3206
|
}
|
|
2950
|
-
async loadBuffer(t,
|
|
2951
|
-
var
|
|
2952
|
-
return (
|
|
3207
|
+
async loadBuffer(t, n, r = {}) {
|
|
3208
|
+
var i, s;
|
|
3209
|
+
return (s = (i = this.options).onLoadStart) == null || s.call(i, t), this.loadThroughRegistry({ buffer: t, fileName: n }, r, n);
|
|
2953
3210
|
}
|
|
2954
|
-
async load(t,
|
|
2955
|
-
var i, s
|
|
2956
|
-
return (
|
|
3211
|
+
async load(t, n = {}) {
|
|
3212
|
+
var r, i, s;
|
|
3213
|
+
return (i = (r = this.options).onLoadStart) == null || i.call(r, t), this.loadThroughRegistry(t, n, t.fileName ?? ((s = t.file) == null ? void 0 : s.name));
|
|
2957
3214
|
}
|
|
2958
|
-
setDocument(t,
|
|
2959
|
-
var
|
|
3215
|
+
setDocument(t, n) {
|
|
3216
|
+
var i, s;
|
|
2960
3217
|
this.deactivateNativeRenderer();
|
|
2961
|
-
const
|
|
3218
|
+
const r = {
|
|
2962
3219
|
document: t,
|
|
2963
3220
|
raw: t.raw,
|
|
2964
3221
|
bytes: 0,
|
|
2965
3222
|
elapsedMs: 0,
|
|
2966
3223
|
format: t.format,
|
|
2967
3224
|
warnings: t.warnings,
|
|
2968
|
-
summary:
|
|
2969
|
-
fileName:
|
|
3225
|
+
summary: it(t),
|
|
3226
|
+
fileName: n
|
|
2970
3227
|
};
|
|
2971
|
-
return this.renderer.setDocument(t), this.options.autoFit || this.renderer.render(), this.lastResult =
|
|
3228
|
+
return this.renderer.setDocument(t), this.options.autoFit || this.renderer.render(), this.lastResult = r, (s = (i = this.options).onLoad) == null || s.call(i, r), r;
|
|
2972
3229
|
}
|
|
2973
|
-
fit() {
|
|
2974
|
-
var
|
|
2975
|
-
this.activeNativeLoader ? (r = (
|
|
3230
|
+
fit(t) {
|
|
3231
|
+
var n, r;
|
|
3232
|
+
this.activeNativeLoader ? (r = (n = this.activeNativeLoader).fit) == null || r.call(n) : this.renderer.fitToView(0.92, t);
|
|
2976
3233
|
}
|
|
2977
3234
|
zoomIn() {
|
|
2978
|
-
var t,
|
|
2979
|
-
this.activeNativeLoader ? (
|
|
3235
|
+
var t, n;
|
|
3236
|
+
this.activeNativeLoader ? (n = (t = this.activeNativeLoader).zoomIn) == null || n.call(t) : this.renderer.zoomIn();
|
|
2980
3237
|
}
|
|
2981
3238
|
zoomOut() {
|
|
2982
|
-
var t,
|
|
2983
|
-
this.activeNativeLoader ? (
|
|
3239
|
+
var t, n;
|
|
3240
|
+
this.activeNativeLoader ? (n = (t = this.activeNativeLoader).zoomOut) == null || n.call(t) : this.renderer.zoomOut();
|
|
2984
3241
|
}
|
|
2985
3242
|
resize() {
|
|
2986
|
-
var t,
|
|
2987
|
-
this.activeNativeLoader ? (
|
|
3243
|
+
var t, n;
|
|
3244
|
+
this.activeNativeLoader ? (n = (t = this.activeNativeLoader).resize) == null || n.call(t) : this.renderer.resize();
|
|
2988
3245
|
}
|
|
2989
3246
|
setCanvasOptions(t) {
|
|
2990
|
-
var
|
|
2991
|
-
this.options.canvasOptions = { ...this.options.canvasOptions ?? {}, ...t }, this.renderer.setOptions(t), this.activeNativeLoader && ((
|
|
3247
|
+
var n, r;
|
|
3248
|
+
this.options.canvasOptions = { ...this.options.canvasOptions ?? {}, ...t }, this.renderer.setOptions(t), this.activeNativeLoader && ((r = (n = this.activeNativeLoader).setNativeOptions) == null || r.call(n, {
|
|
2992
3249
|
...this.mergeLoadOptions({}),
|
|
2993
3250
|
dwfBackground: t.background ?? this.options.dwfBackground
|
|
2994
3251
|
}));
|
|
2995
3252
|
}
|
|
2996
3253
|
async preloadDwg(t = {}) {
|
|
2997
|
-
const
|
|
2998
|
-
if (!(
|
|
2999
|
-
return
|
|
3254
|
+
const n = this.registry.list().find((r) => r.id === "dwg");
|
|
3255
|
+
if (!(n != null && n.preload)) throw new Error("The registered DWG loader does not support preload().");
|
|
3256
|
+
return n.preload(this.mergeLoadOptions(t));
|
|
3000
3257
|
}
|
|
3001
3258
|
clear() {
|
|
3002
3259
|
this.lastResult = void 0, this.deactivateNativeRenderer(), this.renderer.clear();
|
|
3003
3260
|
}
|
|
3004
3261
|
destroy() {
|
|
3005
|
-
var t,
|
|
3262
|
+
var t, n, r;
|
|
3006
3263
|
this.deactivateNativeRenderer();
|
|
3007
|
-
for (const
|
|
3008
|
-
const
|
|
3009
|
-
(t =
|
|
3264
|
+
for (const i of this.registry.list()) {
|
|
3265
|
+
const s = i;
|
|
3266
|
+
(t = s.terminateWorker) == null || t.call(s), (n = s.unmount) == null || n.call(s), (r = s.destroy) == null || r.call(s);
|
|
3010
3267
|
}
|
|
3011
3268
|
this.renderer.destroy();
|
|
3012
3269
|
}
|
|
@@ -3017,135 +3274,324 @@ class kr {
|
|
|
3017
3274
|
var t;
|
|
3018
3275
|
return this.activeNativeLoader ? (t = this.lastResult) == null ? void 0 : t.document : this.renderer.getDocument();
|
|
3019
3276
|
}
|
|
3277
|
+
getSourceDocument() {
|
|
3278
|
+
var t;
|
|
3279
|
+
return this.activeNativeLoader ? (t = this.lastResult) == null ? void 0 : t.document : this.renderer.getSourceDocument();
|
|
3280
|
+
}
|
|
3020
3281
|
getZoomPercent() {
|
|
3021
3282
|
return this.activeNativeLoader ? 100 : this.renderer.getZoomPercent();
|
|
3022
3283
|
}
|
|
3023
3284
|
isNativeRendererActive() {
|
|
3024
3285
|
return !!this.activeNativeLoader;
|
|
3025
3286
|
}
|
|
3026
|
-
async loadThroughRegistry(t,
|
|
3027
|
-
var
|
|
3287
|
+
async loadThroughRegistry(t, n, r) {
|
|
3288
|
+
var i, s;
|
|
3028
3289
|
try {
|
|
3029
|
-
const o = this.mergeLoadOptions(
|
|
3030
|
-
|
|
3290
|
+
const o = this.mergeLoadOptions(n);
|
|
3291
|
+
yt(o.signal);
|
|
3031
3292
|
const a = await this.registry.detect(t), c = { ...t, buffer: a.bytes };
|
|
3032
|
-
if (
|
|
3033
|
-
return await this.applyNativeLoadResult(a.loader, c, o,
|
|
3034
|
-
const
|
|
3035
|
-
return this.applyLoadResult(
|
|
3293
|
+
if (Nn(a.loader))
|
|
3294
|
+
return await this.applyNativeLoadResult(a.loader, c, o, r);
|
|
3295
|
+
const l = await a.loader.load(c, o);
|
|
3296
|
+
return this.applyLoadResult(l, r);
|
|
3036
3297
|
} catch (o) {
|
|
3037
|
-
const a =
|
|
3038
|
-
throw (
|
|
3298
|
+
const a = mr(o);
|
|
3299
|
+
throw (s = (i = this.options).onError) == null || s.call(i, a), a;
|
|
3039
3300
|
}
|
|
3040
3301
|
}
|
|
3041
|
-
applyLoadResult(t,
|
|
3042
|
-
var
|
|
3043
|
-
this.deactivateNativeRenderer(), (
|
|
3044
|
-
const
|
|
3302
|
+
applyLoadResult(t, n) {
|
|
3303
|
+
var i, s, o, a;
|
|
3304
|
+
this.deactivateNativeRenderer(), (s = (i = this.options).onLoadProgress) == null || s.call(i, { phase: "render", format: t.format, message: "Rendering normalized CAD scene…", percent: 96 }), this.renderer.setDocument(t.document), this.options.autoFit || this.renderer.render();
|
|
3305
|
+
const r = {
|
|
3045
3306
|
...t,
|
|
3046
|
-
fileName:
|
|
3047
|
-
summary:
|
|
3307
|
+
fileName: n,
|
|
3308
|
+
summary: it(t.document)
|
|
3048
3309
|
};
|
|
3049
|
-
return this.lastResult =
|
|
3310
|
+
return this.lastResult = r, (a = (o = this.options).onLoad) == null || a.call(o, r), r;
|
|
3050
3311
|
}
|
|
3051
|
-
async applyNativeLoadResult(t, r, i
|
|
3052
|
-
var
|
|
3312
|
+
async applyNativeLoadResult(t, n, r, i) {
|
|
3313
|
+
var s, o, a;
|
|
3053
3314
|
if (!this.nativeHost)
|
|
3054
3315
|
throw new Error("Native DWF rendering requires CadViewerOptions.container, nativeHost, or a canvas parent element.");
|
|
3055
|
-
|
|
3316
|
+
yt(r.signal), this.renderer.clear(), (s = this.activeNativeLoader) == null || s.unmount(), this.activeNativeLoader = t, this.canvas.style.display = "none", this.nativeHost.classList.add("is-active");
|
|
3056
3317
|
try {
|
|
3057
|
-
const c = await t.mount(
|
|
3058
|
-
|
|
3059
|
-
const
|
|
3318
|
+
const c = await t.mount(n, this.nativeHost, r);
|
|
3319
|
+
yt(r.signal);
|
|
3320
|
+
const l = {
|
|
3060
3321
|
...c,
|
|
3061
|
-
fileName:
|
|
3062
|
-
summary:
|
|
3322
|
+
fileName: i,
|
|
3323
|
+
summary: it(c.document)
|
|
3063
3324
|
};
|
|
3064
|
-
return this.lastResult =
|
|
3325
|
+
return this.lastResult = l, this.emitNativeRenderStats(c), (a = (o = this.options).onLoad) == null || a.call(o, l), l;
|
|
3065
3326
|
} catch (c) {
|
|
3066
3327
|
throw this.deactivateNativeRenderer(), c;
|
|
3067
3328
|
}
|
|
3068
3329
|
}
|
|
3069
3330
|
deactivateNativeRenderer() {
|
|
3070
|
-
var t,
|
|
3331
|
+
var t, n;
|
|
3071
3332
|
if (!this.activeNativeLoader && !((t = this.nativeHost) != null && t.classList.contains("is-active"))) {
|
|
3072
3333
|
this.canvas.style.display = "";
|
|
3073
3334
|
return;
|
|
3074
3335
|
}
|
|
3075
|
-
(
|
|
3336
|
+
(n = this.activeNativeLoader) == null || n.unmount(), this.activeNativeLoader = void 0, this.nativeHost && (this.nativeHost.classList.remove("is-active"), this.nativeHost.replaceChildren()), this.canvas.style.display = "";
|
|
3076
3337
|
}
|
|
3077
3338
|
emitNativeRenderStats(t) {
|
|
3078
|
-
var o, a, c,
|
|
3079
|
-
const
|
|
3080
|
-
(
|
|
3081
|
-
total:
|
|
3082
|
-
drawn:
|
|
3339
|
+
var o, a, c, l;
|
|
3340
|
+
const n = t.document.metadata, r = Number(((o = n.nativeRenderStats) == null ? void 0 : o.commands) ?? t.document.entities.length ?? 0), s = String(((a = n.nativeRenderStats) == null ? void 0 : a.backend) ?? "webgl").includes("webgl") ? "webgl" : "canvas2d";
|
|
3341
|
+
(l = (c = this.options).onRenderStats) == null || l.call(c, {
|
|
3342
|
+
total: r,
|
|
3343
|
+
drawn: r,
|
|
3083
3344
|
skipped: 0,
|
|
3084
|
-
byType:
|
|
3345
|
+
byType: it(t.document).byType,
|
|
3085
3346
|
unsupported: {},
|
|
3086
3347
|
renderElapsedMs: t.elapsedMs,
|
|
3087
|
-
backend:
|
|
3088
|
-
primitiveCount:
|
|
3089
|
-
visiblePrimitiveCount:
|
|
3348
|
+
backend: s,
|
|
3349
|
+
primitiveCount: r,
|
|
3350
|
+
visiblePrimitiveCount: r,
|
|
3090
3351
|
culledPrimitiveCount: 0,
|
|
3091
3352
|
gpuMemoryBytes: void 0,
|
|
3092
3353
|
buildElapsedMs: t.elapsedMs
|
|
3093
3354
|
});
|
|
3094
3355
|
}
|
|
3095
3356
|
mergeLoadOptions(t) {
|
|
3096
|
-
const
|
|
3357
|
+
const n = this.options.onProgress, r = t.onProgress;
|
|
3097
3358
|
return {
|
|
3098
3359
|
...this.options,
|
|
3099
3360
|
...t,
|
|
3100
|
-
onProgress: (
|
|
3101
|
-
var
|
|
3102
|
-
(o = (
|
|
3361
|
+
onProgress: (i) => {
|
|
3362
|
+
var s, o;
|
|
3363
|
+
(o = (s = this.options).onLoadProgress) == null || o.call(s, i), n == null || n(i), r && r !== n && r(i);
|
|
3103
3364
|
}
|
|
3104
3365
|
};
|
|
3105
3366
|
}
|
|
3106
3367
|
}
|
|
3107
|
-
function
|
|
3108
|
-
return new
|
|
3368
|
+
function Er(e = {}) {
|
|
3369
|
+
return new dr(e);
|
|
3109
3370
|
}
|
|
3110
|
-
function
|
|
3371
|
+
function mr(e) {
|
|
3111
3372
|
return e instanceof Error ? e : new Error(String(e));
|
|
3112
3373
|
}
|
|
3113
|
-
function
|
|
3374
|
+
function yt(e) {
|
|
3114
3375
|
if (e != null && e.aborted)
|
|
3115
3376
|
throw new DOMException("Loading cancelled.", "AbortError");
|
|
3116
3377
|
}
|
|
3117
|
-
function
|
|
3118
|
-
if (e === "canvas2d") return new
|
|
3119
|
-
if (e === "webgl") return new
|
|
3120
|
-
if (
|
|
3378
|
+
function pr(e, t, n = {}) {
|
|
3379
|
+
if (e === "canvas2d") return new te(t, n);
|
|
3380
|
+
if (e === "webgl") return new ee(t, n);
|
|
3381
|
+
if (Ee())
|
|
3121
3382
|
try {
|
|
3122
|
-
return new
|
|
3383
|
+
return new ee(t, n);
|
|
3123
3384
|
} catch {
|
|
3124
3385
|
}
|
|
3125
|
-
return new
|
|
3386
|
+
return new te(t, n);
|
|
3387
|
+
}
|
|
3388
|
+
function Ir(e, t, n, r = {}) {
|
|
3389
|
+
const i = e && typeof e == "object" ? e : {}, s = yr(i, r), o = vr(i, r), a = kr(i, r), c = br(i.header, n), l = xr(i, c), h = l.view, u = Array.isArray(i.entities) ? i.entities : [], f = { keepRaw: !!r.keepRaw, includeUnknownProperties: !!r.keepRaw }, m = u.filter((y) => !!y && typeof y == "object").map((y) => Ie(y, f)), p = It({
|
|
3390
|
+
format: "dwg",
|
|
3391
|
+
sourceName: t,
|
|
3392
|
+
header: c,
|
|
3393
|
+
layers: s,
|
|
3394
|
+
lineTypes: o,
|
|
3395
|
+
blocks: a,
|
|
3396
|
+
entities: m,
|
|
3397
|
+
savedView: h,
|
|
3398
|
+
metadata: {
|
|
3399
|
+
parser: "@mlightcad/libredwg-web",
|
|
3400
|
+
parserMode: "wasm",
|
|
3401
|
+
version: n,
|
|
3402
|
+
savedView: h
|
|
3403
|
+
},
|
|
3404
|
+
warnings: l.warning ? [l.warning] : [],
|
|
3405
|
+
raw: r.keepRaw ? e : void 0
|
|
3406
|
+
});
|
|
3407
|
+
return m.length === 0 && p.warnings.push("DWG parsed successfully but no model-space entities were exposed by the converter. Check layout/paper-space content or unsupported proxy objects."), [...new Set(Object.values(o))].some((y) => y.pattern.some((v) => Number(v.elementTypeFlag ?? 0) !== 0)) && p.warnings.push("Complex SHX linetype glyphs are preserved in the normalized LTYPE definition and rendered as a dash/dot approximation; embedded shape glyph fidelity is not available yet."), p;
|
|
3408
|
+
}
|
|
3409
|
+
function Ie(e, t) {
|
|
3410
|
+
const n = Tt(e, void 0, { ...t, numericColorMode: "rgb" }), r = b(e.color);
|
|
3411
|
+
r !== void 0 && r >= 0 && r <= 16777215 && (n.color = r, n.trueColor = r), n.colorIndex = b(e.colorIndex ?? e.colorNumber ?? e.aci) ?? n.colorIndex, n.colorName = w(e.colorName ?? e.color_name) ?? n.colorName;
|
|
3412
|
+
const i = b(e.flag ?? e.flags);
|
|
3413
|
+
i !== void 0 && (n.flag = i);
|
|
3414
|
+
const s = String(e.type ?? e.entityType ?? "").toUpperCase(), o = /^(POLYLINE|POLYLINE_2D|POLYLINE2D|POLYLINE_3D|POLYLINE3D)$/.test(s);
|
|
3415
|
+
return (e.isClosed === !0 || e.closed === !0 || o && (Number(i ?? 0) & 1) === 1 || s === "LWPOLYLINE" && (Number(i ?? 0) & 512) === 512) && (n.isClosed = !0), n;
|
|
3416
|
+
}
|
|
3417
|
+
function gr(e) {
|
|
3418
|
+
return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
|
|
3419
|
+
}
|
|
3420
|
+
function br(e, t) {
|
|
3421
|
+
const n = e && typeof e == "object" ? { ...e } : {};
|
|
3422
|
+
return t && (n.dwgVersion = t), n;
|
|
3423
|
+
}
|
|
3424
|
+
function yr(e, t) {
|
|
3425
|
+
const n = {}, r = [], i = e.tables;
|
|
3426
|
+
for (const s of ["LAYER", "layer", "layers"]) {
|
|
3427
|
+
const o = e[s] ?? (i == null ? void 0 : i[s]);
|
|
3428
|
+
o && r.push(o);
|
|
3429
|
+
}
|
|
3430
|
+
for (const s of r)
|
|
3431
|
+
for (const o of ht(s)) {
|
|
3432
|
+
const a = o, c = w(a.name ?? a.layerName ?? a.entryName);
|
|
3433
|
+
if (!c) continue;
|
|
3434
|
+
const l = b(a.colorIndex ?? a.colorNumber), h = b(a.trueColor ?? a.true_color ?? a.truecolor ?? a.colorRGB ?? a.colorRgb ?? a.rgbColor ?? a.rgb), u = b(a.color), f = gr(l), m = h ?? (!f && u !== void 0 && u >= 0 && u <= 16777215 ? u : void 0), p = {
|
|
3435
|
+
name: c,
|
|
3436
|
+
color: f ? void 0 : a.color ?? a.colorName,
|
|
3437
|
+
colorIndex: l ?? (u !== void 0 && Math.abs(u) <= 257 ? u : void 0),
|
|
3438
|
+
trueColor: m,
|
|
3439
|
+
lineType: w(a.lineType ?? a.linetype),
|
|
3440
|
+
lineweight: b(a.lineweight ?? a.lineWeight),
|
|
3441
|
+
isVisible: !(a.isVisible === !1 || a.off === !0 || Number(l ?? a.color ?? 1) < 0),
|
|
3442
|
+
isFrozen: !!(a.isFrozen ?? a.frozen),
|
|
3443
|
+
isLocked: !!(a.isLocked ?? a.locked),
|
|
3444
|
+
raw: t.keepRaw ? a : void 0
|
|
3445
|
+
};
|
|
3446
|
+
wt(n, p);
|
|
3447
|
+
}
|
|
3448
|
+
return n;
|
|
3449
|
+
}
|
|
3450
|
+
function vr(e, t) {
|
|
3451
|
+
const n = {}, r = e.tables, i = [e.LTYPE, e.ltype, e.lineTypes, r == null ? void 0 : r.LTYPE, r == null ? void 0 : r.ltype, r == null ? void 0 : r.lineTypes];
|
|
3452
|
+
for (const s of i)
|
|
3453
|
+
for (const o of ht(s)) {
|
|
3454
|
+
const a = o, c = w(a.name ?? a.lineTypeName ?? a.entryName);
|
|
3455
|
+
if (!c) continue;
|
|
3456
|
+
const h = (Array.isArray(a.pattern) ? a.pattern : Array.isArray(a.dashes) ? a.dashes : []).flatMap((u) => {
|
|
3457
|
+
if (typeof u == "number") return [{ length: u }];
|
|
3458
|
+
if (!u || typeof u != "object") return [];
|
|
3459
|
+
const f = u, m = b(f.elementLength ?? f.length ?? f.dashLength);
|
|
3460
|
+
if (m === void 0) return [];
|
|
3461
|
+
const p = b(f.elementTypeFlag), C = b(f.shapeNumber), y = p !== void 0 && C !== void 0;
|
|
3462
|
+
return [{
|
|
3463
|
+
length: m,
|
|
3464
|
+
elementTypeFlag: y ? C : b(f.typeFlag ?? f.elementTypeFlag),
|
|
3465
|
+
shapeNumber: y ? p : b(f.shapeCode ?? f.shapeNumber),
|
|
3466
|
+
scale: b(f.scale),
|
|
3467
|
+
rotation: b(f.rotation),
|
|
3468
|
+
offsetX: b(f.offsetX),
|
|
3469
|
+
offsetY: b(f.offsetY),
|
|
3470
|
+
text: w(f.text)
|
|
3471
|
+
}];
|
|
3472
|
+
});
|
|
3473
|
+
Ue(n, {
|
|
3474
|
+
name: c,
|
|
3475
|
+
handle: w(a.handle ?? a.id),
|
|
3476
|
+
description: w(a.description),
|
|
3477
|
+
totalPatternLength: b(a.totalPatternLength ?? a.patternLength),
|
|
3478
|
+
pattern: h,
|
|
3479
|
+
raw: t.keepRaw ? a : void 0
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
return n;
|
|
3483
|
+
}
|
|
3484
|
+
function xr(e, t) {
|
|
3485
|
+
const n = e.tables, i = ht(e.VPORT ?? e.vports ?? (n == null ? void 0 : n.VPORT) ?? (n == null ? void 0 : n.vports)).filter((v) => !!v && typeof v == "object").find((v) => String(v.name ?? "").trim().toLowerCase() === "*active"), s = i ? "vport" : "header-ucs", o = i ?? t, a = k(o.ucsOrigin ?? o.UCSORG ?? t.UCSORG), c = k(o.ucsXAxis ?? o.UCSXDIR ?? t.UCSXDIR), l = k(o.ucsYAxis ?? o.UCSYDIR ?? t.UCSYDIR), h = b(o.viewTwistAngle ?? o.twistAngle ?? o.VIEWTWIST) ?? 0, u = k(o.viewDirectionFromTarget ?? o.viewDirection ?? o.direction ?? o.VIEWDIR), f = !Pr(a, c, l);
|
|
3486
|
+
if (!(!!i || !!u || f || Math.abs(h) > 1e-12)) return {};
|
|
3487
|
+
const p = Cr(u), C = p ? wr(a, c, l, h) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, y = {
|
|
3488
|
+
source: s,
|
|
3489
|
+
name: w(o.name),
|
|
3490
|
+
handle: w(o.handle),
|
|
3491
|
+
center: k(o.center ?? o.VIEWCTR),
|
|
3492
|
+
target: k(o.viewTarget ?? o.target ?? o.TARGET),
|
|
3493
|
+
direction: u,
|
|
3494
|
+
viewHeight: b(o.viewHeight ?? o.height ?? o.VIEWSIZE),
|
|
3495
|
+
aspectRatio: b(o.aspectRatio),
|
|
3496
|
+
twistAngle: h,
|
|
3497
|
+
ucsOrigin: a,
|
|
3498
|
+
ucsXAxis: c,
|
|
3499
|
+
ucsYAxis: l,
|
|
3500
|
+
sceneTransformApplied: p,
|
|
3501
|
+
sceneTransform: C
|
|
3502
|
+
};
|
|
3503
|
+
return p ? { view: y } : {
|
|
3504
|
+
view: y,
|
|
3505
|
+
warning: "The saved CAD view has a missing, non-finite, or tilted VIEWDIR. File Viewer kept world coordinates instead of applying an unsafe 2D UCS/PLAN rotation."
|
|
3506
|
+
};
|
|
3507
|
+
}
|
|
3508
|
+
function wr(e, t, n, r) {
|
|
3509
|
+
const i = vt(t) ?? { x: 1, y: 0 }, s = vt(n) ?? { x: -i.y, y: i.x }, o = i.x * s.x + i.y * s.y, a = vt({
|
|
3510
|
+
x: s.x - i.x * o,
|
|
3511
|
+
y: s.y - i.y * o
|
|
3512
|
+
}) ?? { x: -i.y, y: i.x }, c = {
|
|
3513
|
+
a: i.x,
|
|
3514
|
+
b: a.x,
|
|
3515
|
+
c: i.y,
|
|
3516
|
+
d: a.y,
|
|
3517
|
+
e: e ? -(e.x * i.x + e.y * i.y) : 0,
|
|
3518
|
+
f: e ? -(e.x * a.x + e.y * a.y) : 0
|
|
3519
|
+
};
|
|
3520
|
+
return ct(ye(Number.isFinite(r) ? r : 0), c);
|
|
3521
|
+
}
|
|
3522
|
+
function vt(e) {
|
|
3523
|
+
if (!e || Math.abs(Number(e.z ?? 0)) > 1e-6) return;
|
|
3524
|
+
const t = Math.hypot(e.x, e.y);
|
|
3525
|
+
if (!(!Number.isFinite(t) || t < 1e-12))
|
|
3526
|
+
return { x: e.x / t, y: e.y / t };
|
|
3527
|
+
}
|
|
3528
|
+
function Cr(e) {
|
|
3529
|
+
if (!e || !Number.isFinite(e.x) || !Number.isFinite(e.y) || !Number.isFinite(e.z)) return !1;
|
|
3530
|
+
const t = Math.hypot(e.x, e.y, Number(e.z));
|
|
3531
|
+
return !Number.isFinite(t) || t < 1e-12 ? !1 : Math.hypot(e.x, e.y) / t <= 1e-4 && Math.abs(Number(e.z)) / t >= 1 - 1e-8;
|
|
3532
|
+
}
|
|
3533
|
+
function Pr(e, t, n) {
|
|
3534
|
+
const r = (a, c) => Number.isFinite(a) && Math.abs(Number(a) - c) <= 1e-10, i = !e || r(e.x, 0) && r(e.y, 0) && r(e.z ?? 0, 0), s = !t || r(t.x, 1) && r(t.y, 0) && r(t.z ?? 0, 0), o = !n || r(n.x, 0) && r(n.y, 1) && r(n.z ?? 0, 0);
|
|
3535
|
+
return i && s && o;
|
|
3536
|
+
}
|
|
3537
|
+
function kr(e, t) {
|
|
3538
|
+
const n = {}, r = [e.blocks, e.blockHeaders, e.block_records, e.blockRecords], i = e.tables;
|
|
3539
|
+
r.push(i == null ? void 0 : i.BLOCK, i == null ? void 0 : i.BLOCK_RECORD, i == null ? void 0 : i.blocks);
|
|
3540
|
+
const s = { keepRaw: !!t.keepRaw, includeUnknownProperties: !!t.keepRaw };
|
|
3541
|
+
for (const o of r)
|
|
3542
|
+
for (const a of ht(o)) {
|
|
3543
|
+
const c = a, l = w(c.name ?? c.blockName ?? c.name2);
|
|
3544
|
+
if (!l) continue;
|
|
3545
|
+
const u = (Array.isArray(c.entities) ? c.entities : Array.isArray(c.ownedObjects) ? c.ownedObjects : []).filter((f) => !!f && typeof f == "object").map((f) => Ie(f, s));
|
|
3546
|
+
ce(n, {
|
|
3547
|
+
name: l,
|
|
3548
|
+
basePoint: k(c.basePoint ?? c.origin) ?? { x: 0, y: 0 },
|
|
3549
|
+
entities: u,
|
|
3550
|
+
raw: t.keepRaw ? c : void 0
|
|
3551
|
+
});
|
|
3552
|
+
}
|
|
3553
|
+
return n;
|
|
3554
|
+
}
|
|
3555
|
+
function ht(e) {
|
|
3556
|
+
if (!e) return [];
|
|
3557
|
+
if (Array.isArray(e)) return e;
|
|
3558
|
+
if (typeof e != "object") return [];
|
|
3559
|
+
const t = e, n = Object.values(t).filter((i) => i && typeof i == "object"), r = ["entries", "records", "items", "values", "layers", "blocks"].flatMap((i) => Array.isArray(t[i]) ? t[i] : []);
|
|
3560
|
+
return r.length > 0 ? r : n;
|
|
3126
3561
|
}
|
|
3127
3562
|
export {
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3563
|
+
te as CadCanvasRenderer,
|
|
3564
|
+
De as CadLoaderRegistry,
|
|
3565
|
+
dr as CadViewer,
|
|
3566
|
+
ee as CadWebGLRenderer,
|
|
3567
|
+
mn as DwfLoader,
|
|
3568
|
+
Xe as DwgLoader,
|
|
3569
|
+
Oe as DwgWorkerClient,
|
|
3570
|
+
Ge as DxfLoader,
|
|
3571
|
+
Se as applyByBlockLineTypeInheritance,
|
|
3572
|
+
O as colorFromAci,
|
|
3573
|
+
tt as colorFromTrueColor,
|
|
3574
|
+
ve as computeCadDocumentBounds,
|
|
3575
|
+
It as createCadDocument,
|
|
3576
|
+
Me as createCadSceneDocument,
|
|
3577
|
+
Er as createCadViewer,
|
|
3578
|
+
Dt as createDashedCadPrimitives,
|
|
3579
|
+
Mr as createDashedCadSegments,
|
|
3580
|
+
Sn as createDefaultLoaderRegistry,
|
|
3581
|
+
Y as detectCadFormat,
|
|
3582
|
+
J as inferEntityKind,
|
|
3583
|
+
Nn as isCadNativeRenderableLoader,
|
|
3584
|
+
ae as isCadPolylineClosed,
|
|
3585
|
+
Ee as isWebGLAvailable,
|
|
3586
|
+
Tt as normalizeCadEntity,
|
|
3587
|
+
Ir as normalizeDwgDatabase,
|
|
3588
|
+
K as readInputBytes,
|
|
3589
|
+
V as resolveCadColor,
|
|
3590
|
+
xe as resolveCadFitBounds,
|
|
3591
|
+
Nt as resolveCadLinePattern,
|
|
3592
|
+
Ne as resolveCadLineTypeReference,
|
|
3593
|
+
Yn as resolveCadSavedViewBounds,
|
|
3594
|
+
it as summarizeCadDocument,
|
|
3595
|
+
xt as supportsDwgWorker
|
|
3150
3596
|
};
|
|
3151
3597
|
//# sourceMappingURL=cad-viewer.es.js.map
|