@flyfish-group/file-viewer 1.0.22 → 1.0.24
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 +62 -28
- package/dist/components/3MFLoader.js +1 -1
- package/dist/components/AMFLoader.js +1 -1
- package/dist/components/AudioViewer.js +1 -1
- package/dist/components/CadViewer.js +1 -1
- package/dist/components/CodeViewer.js +1 -1
- package/dist/components/ColladaLoader.js +1 -1
- package/dist/components/DrawingViewer.js +1 -1
- package/dist/components/EdaViewer.js +1 -1
- package/dist/components/EmailViewer.js +1 -1
- package/dist/components/EpubViewer.js +1 -1
- package/dist/components/FBXLoader.js +1 -1
- package/dist/components/GLTFLoader.js +1 -1
- package/dist/components/ImageViewer.js +1 -1
- package/dist/components/KMZLoader.js +1 -1
- package/dist/components/MarkdownViewer.js +1 -1
- package/dist/components/OBJLoader.js +1 -1
- package/dist/components/OfdViewer.js +1 -1
- package/dist/components/PCDLoader.js +1 -1
- package/dist/components/PLYLoader.js +1 -1
- package/dist/components/STLLoader.js +1 -1
- package/dist/components/TDSLoader.js +1 -1
- package/dist/components/USDLoader.js +1 -1
- package/dist/components/UmdViewer.js +2 -2
- package/dist/components/VRMLLoader.js +1 -1
- package/dist/components/VTKLoader.js +1 -1
- package/dist/components/XYZLoader.js +1 -1
- package/dist/components/XlsxTable.js +1 -1
- package/dist/components/___vite-browser-external_commonjs-proxy.js +1 -1
- package/dist/components/_commonjs-dynamic-modules.js +1 -1
- package/dist/components/_commonjsHelpers.js +1 -1
- package/dist/components/ar-SA-G6X2FPQ2.js +1 -1
- package/dist/components/arc.js +1 -1
- package/dist/components/architecture-7EHR7CIX.js +1 -1
- package/dist/components/architectureDiagram-3BPJPVTR.js +1 -1
- package/dist/components/az-AZ-76LH7QW2.js +1 -1
- package/dist/components/bg-BG-XCXSNQG7.js +1 -1
- package/dist/components/blockDiagram-GPEHLZMM.js +1 -1
- package/dist/components/bn-BD-2XOGV67Q.js +1 -1
- package/dist/components/c4Diagram-AAUBKEIU.js +1 -1
- package/dist/components/ca-ES-6MX7JW3Y.js +1 -1
- package/dist/components/cfb.js +1 -1
- package/dist/components/channel.js +1 -1
- package/dist/components/chunk-2J33WTMH.js +1 -1
- package/dist/components/chunk-4BX2VUAB.js +1 -1
- package/dist/components/chunk-55IACEB6.js +1 -1
- package/dist/components/chunk-727SXJPM.js +1 -1
- package/dist/components/chunk-AQP2D5EJ.js +1 -1
- package/dist/components/chunk-FMBD7UC4.js +1 -1
- package/dist/components/chunk-ND2GUHAM.js +1 -1
- package/dist/components/chunk-QZHKN3VN.js +1 -1
- package/dist/components/classDiagram-4FO5ZUOK.js +1 -1
- package/dist/components/classDiagram-v2-Q7XG4LA2.js +1 -1
- package/dist/components/cose-bilkent-S5V4N54A.js +1 -1
- package/dist/components/cs-CZ-2BRQDIVT.js +1 -1
- package/dist/components/cytoscape.esm.js +1 -1
- package/dist/components/da-DK-5WZEPLOC.js +1 -1
- package/dist/components/dagre-BM42HDAG.js +1 -1
- package/dist/components/de-DE-XR44H4JA.js +1 -1
- package/dist/components/defaultLocale.js +1 -1
- package/dist/components/diagram-2AECGRRQ.js +1 -1
- package/dist/components/diagram-5GNKFQAL.js +1 -1
- package/dist/components/diagram-KO2AKTUF.js +1 -1
- package/dist/components/diagram-LMA3HP47.js +1 -1
- package/dist/components/diagram-OG6HWLK6.js +1 -1
- package/dist/components/directory-open-01563666.js +1 -1
- package/dist/components/directory-open-4ed118d0.js +1 -1
- package/dist/components/docx-preview.js +2 -2
- package/dist/components/el-GR-BZB4AONW.js +1 -1
- package/dist/components/en-B4ZKOASM.js +1 -1
- package/dist/components/erDiagram-TEJ5UH35.js +1 -1
- package/dist/components/es-ES-U4NZUMDT.js +1 -1
- package/dist/components/eu-ES-A7QVB2H4.js +1 -1
- package/dist/components/eventmodeling-FCH6USID.js +1 -1
- package/dist/components/fa-IR-HGAKTJCU.js +1 -1
- package/dist/components/fflate.module.js +1 -1
- package/dist/components/fi-FI-Z5N7JZ37.js +1 -1
- package/dist/components/file-open-002ab408.js +1 -1
- package/dist/components/file-open-7c801643.js +1 -1
- package/dist/components/file-save-3189631c.js +1 -1
- package/dist/components/file-save-745eba88.js +1 -1
- package/dist/components/flowDiagram-I6XJVG4X.js +1 -1
- package/dist/components/fr-FR-RHASNOE6.js +1 -1
- package/dist/components/ganttDiagram-6RSMTGT7.js +1 -1
- package/dist/components/gitGraph-WXDBUCRP.js +1 -1
- package/dist/components/gitGraphDiagram-PVQCEYII.js +1 -1
- package/dist/components/gl-ES-HMX3MZ6V.js +1 -1
- package/dist/components/global-compiler.js +1 -1
- package/dist/components/global-renderer.js +1 -1
- package/dist/components/graph.js +1 -1
- package/dist/components/he-IL-6SHJWFNN.js +1 -1
- package/dist/components/hi-IN-IWLTKZ5I.js +1 -1
- package/dist/components/hu-HU-A5ZG7DT2.js +1 -1
- package/dist/components/id-ID-SAP4L64H.js +1 -1
- package/dist/components/image-GAAHSSAO.js +1 -1
- package/dist/components/image-blob-reduce.esm.js +1 -1
- package/dist/components/index10.js +1 -1
- package/dist/components/index11.js +1 -1
- package/dist/components/index12.js +1 -1
- package/dist/components/index13.js +1 -1
- package/dist/components/index14.js +1 -1
- package/dist/components/index15.js +1 -1
- package/dist/components/index16.js +1 -1
- package/dist/components/index17.js +1 -1
- package/dist/components/index18.js +1 -1
- package/dist/components/index19.js +1 -1
- package/dist/components/index2.js +1 -1
- package/dist/components/index20.js +1 -1
- package/dist/components/index21.js +1 -1
- package/dist/components/index22.js +2 -2
- package/dist/components/index23.js +1 -1
- package/dist/components/index24.js +1 -1
- package/dist/components/index3.js +1 -1
- package/dist/components/index4.js +1 -1
- package/dist/components/index5.js +1 -1
- package/dist/components/index6.js +1 -1
- package/dist/components/index7.js +1 -1
- package/dist/components/index8.js +1 -1
- package/dist/components/index9.js +1 -1
- package/dist/components/info-J43DQDTF.js +1 -1
- package/dist/components/infoDiagram-5YYISTIA.js +1 -1
- package/dist/components/init.js +1 -1
- package/dist/components/ishikawaDiagram-YF4QCWOH.js +1 -1
- package/dist/components/it-IT-JPQ66NNP.js +1 -1
- package/dist/components/ja-JP-DBVTYXUO.js +1 -1
- package/dist/components/journeyDiagram-JHISSGLW.js +1 -1
- package/dist/components/jszip.min.js +1 -1
- package/dist/components/kaa-6HZHGXH3.js +1 -1
- package/dist/components/kab-KAB-ZGHBKWFO.js +1 -1
- package/dist/components/kanban-definition-UN3LZRKU.js +1 -1
- package/dist/components/katex.js +1 -1
- package/dist/components/kk-KZ-P5N5QNE5.js +1 -1
- package/dist/components/km-KH-HSX4SM5Z.js +1 -1
- package/dist/components/ko-KR-MTYHY66A.js +1 -1
- package/dist/components/ku-TR-6OUDTVRD.js +1 -1
- package/dist/components/layout.js +1 -1
- package/dist/components/libarchive.js +1 -1
- package/dist/components/linear.js +1 -1
- package/dist/components/lt-LT-XHIRWOB4.js +1 -1
- package/dist/components/lv-LV-5QDEKY6T.js +1 -1
- package/dist/components/mermaid-parser.core.js +2 -2
- package/dist/components/mindmap-definition-RKZ34NQL.js +1 -1
- package/dist/components/mr-IN-CRQNXWMA.js +1 -1
- package/dist/components/my-MM-5M5IBNSE.js +1 -1
- package/dist/components/nb-NO-T6EIAALU.js +1 -1
- package/dist/components/nestedRender.js +1 -1
- package/dist/components/nl-NL-IS3SIHDZ.js +1 -1
- package/dist/components/nn-NO-6E72VCQL.js +1 -1
- package/dist/components/oc-FR-POXYY2M6.js +1 -1
- package/dist/components/ofd.js +1 -1
- package/dist/components/ordinal.js +1 -1
- package/dist/components/pa-IN-N4M65BXN.js +1 -1
- package/dist/components/packet-YPE3B663.js +1 -1
- package/dist/components/percentages-BXMCSKIN.js +1 -1
- package/dist/components/pica.js +1 -1
- package/dist/components/pie-LRSECV5Y.js +1 -1
- package/dist/components/pie.js +1 -1
- package/dist/components/pieDiagram-4H26LBE5.js +1 -1
- package/dist/components/pl-PL-T2D74RX3.js +1 -1
- package/dist/components/postal-mime.js +1 -1
- package/dist/components/printLayout.js +1 -1
- package/dist/components/pt-BR-5N22H2LF.js +1 -1
- package/dist/components/pt-PT-UZXXM6DQ.js +1 -1
- package/dist/components/quadrantDiagram-W4KKPZXB.js +1 -1
- package/dist/components/radar-GUYGQ44K.js +1 -1
- package/dist/components/requirementDiagram-4Y6WPE33.js +1 -1
- package/dist/components/ro-RO-JPDTUUEW.js +1 -1
- package/dist/components/rough.esm.js +1 -1
- package/dist/components/roundRect.js +1 -1
- package/dist/components/ru-RU-B4JR7IUQ.js +1 -1
- package/dist/components/sankeyDiagram-5OEKKPKP.js +1 -1
- package/dist/components/sequenceDiagram-3UESZ5HK.js +1 -1
- package/dist/components/si-LK-N5RQ5JYF.js +1 -1
- package/dist/components/sk-SK-C5VTKIMK.js +1 -1
- package/dist/components/sl-SI-NN7IZMDC.js +1 -1
- package/dist/components/stateDiagram-AJRCARHV.js +1 -1
- package/dist/components/stateDiagram-v2-BHNVJYJU.js +1 -1
- package/dist/components/subset-shared.chunk.js +1 -1
- package/dist/components/subset-worker.chunk.js +1 -1
- package/dist/components/sv-SE-XGPEYMSR.js +1 -1
- package/dist/components/ta-IN-2NMHFXQM.js +1 -1
- package/dist/components/th-TH-HPSO5L25.js +1 -1
- package/dist/components/time.js +1 -1
- package/dist/components/timeline-definition-PNZ67QCA.js +1 -1
- package/dist/components/tr-TR-DEFEU3FU.js +1 -1
- package/dist/components/transform.js +1 -1
- package/dist/components/treeView-BLDUP644.js +1 -1
- package/dist/components/treemap-LRROVOQU.js +1 -1
- package/dist/components/uk-UA-QMV73CPH.js +1 -1
- package/dist/components/vennDiagram-CIIHVFJN.js +1 -1
- package/dist/components/vi-VN-M7AON7JQ.js +1 -1
- package/dist/components/wardley-L42UT6IY.js +1 -1
- package/dist/components/wardleyDiagram-YWT4CUSO.js +1 -1
- package/dist/components/wasm-pack-shim.js +1 -1
- package/dist/components/wasm-pack-shim2.js +1 -1
- package/dist/components/worker-ref.js +1 -1
- package/dist/components/xychartDiagram-2RQKCTM6.js +1 -1
- package/dist/components/zh-CN-LNUGB5OW.js +1 -1
- package/dist/components/zh-HK-E62DVLB3.js +1 -1
- package/dist/components/zh-TW-RAJ6MFWO.js +1 -1
- package/dist/index.d.ts +48 -0
- package/dist/index.mjs +1 -1
- package/dist/style.css +1 -1
- package/dist/wasm/cad/DwgWorker-CuZJ5EUe.js +349 -0
- package/dist/wasm/cad/dwfv-render.wasm +0 -0
- package/dist/wasm/cad/dwg-worker.js +349 -0
- package/dist/wasm/cad/index-C365l3i9.js +4161 -0
- package/dist/wasm/cad/libredwg-web.js +15 -0
- package/dist/wasm/cad/libredwg-web.wasm +0 -0
- package/package.json +9 -8
- package/dist/components/index25.js +0 -1
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
function D(e) {
|
|
2
|
+
return {
|
|
3
|
+
format: e.format,
|
|
4
|
+
sourceName: e.sourceName,
|
|
5
|
+
units: e.units,
|
|
6
|
+
header: e.header ?? {},
|
|
7
|
+
layers: e.layers ?? {},
|
|
8
|
+
blocks: e.blocks ?? {},
|
|
9
|
+
entities: e.entities ?? [],
|
|
10
|
+
pages: e.pages,
|
|
11
|
+
metadata: e.metadata ?? {},
|
|
12
|
+
warnings: e.warnings ?? [],
|
|
13
|
+
raw: e.raw
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function L(e) {
|
|
17
|
+
switch (String(e ?? "").toUpperCase()) {
|
|
18
|
+
case "LINE":
|
|
19
|
+
return "line";
|
|
20
|
+
case "CIRCLE":
|
|
21
|
+
return "circle";
|
|
22
|
+
case "ARC":
|
|
23
|
+
return "arc";
|
|
24
|
+
case "LWPOLYLINE":
|
|
25
|
+
case "POLYLINE":
|
|
26
|
+
case "POLYLINE_2D":
|
|
27
|
+
case "POLYLINE2D":
|
|
28
|
+
case "POLYLINE_3D":
|
|
29
|
+
case "POLYLINE3D":
|
|
30
|
+
case "LEADER":
|
|
31
|
+
case "MULTILEADER":
|
|
32
|
+
return "polyline";
|
|
33
|
+
case "ELLIPSE":
|
|
34
|
+
return "ellipse";
|
|
35
|
+
case "TEXT":
|
|
36
|
+
case "MTEXT":
|
|
37
|
+
case "ATTRIB":
|
|
38
|
+
case "ATTDEF":
|
|
39
|
+
case "DIMENSION":
|
|
40
|
+
return "text";
|
|
41
|
+
case "POINT":
|
|
42
|
+
return "point";
|
|
43
|
+
case "INSERT":
|
|
44
|
+
return "insert";
|
|
45
|
+
case "SOLID":
|
|
46
|
+
case "TRACE":
|
|
47
|
+
case "3DFACE":
|
|
48
|
+
return "solid";
|
|
49
|
+
case "HATCH":
|
|
50
|
+
return "hatch";
|
|
51
|
+
case "SPLINE":
|
|
52
|
+
return "spline";
|
|
53
|
+
case "PATH":
|
|
54
|
+
case "XPS_PATH":
|
|
55
|
+
case "DWF_PATH":
|
|
56
|
+
return "path";
|
|
57
|
+
case "IMAGE":
|
|
58
|
+
case "RASTER_IMAGE":
|
|
59
|
+
case "DWF_IMAGE":
|
|
60
|
+
return "image";
|
|
61
|
+
case "VIEWPORT":
|
|
62
|
+
return "viewport";
|
|
63
|
+
default:
|
|
64
|
+
return "unsupported";
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function M(e, t, o = {}) {
|
|
68
|
+
const i = t ?? String(e.type ?? e.entityType ?? e.objectName ?? "UNKNOWN").toUpperCase(), n = o.includeUnknownProperties === !1 ? { type: i, kind: L(i) } : { ...e, type: i, kind: L(i) };
|
|
69
|
+
o.keepRaw && (n.raw = e), n.handle = g(e.handle ?? e.id), n.layer = g(e.layer ?? e.layerName), n.lineType = g(e.lineType ?? e.linetype);
|
|
70
|
+
const c = o.numericColorMode ?? "auto", s = u(e.color), r = u(e.colorIndex ?? e.colorNumber ?? e.aci ?? e.aciColor ?? e.color_index);
|
|
71
|
+
n.colorIndex = r ?? (c !== "rgb" && s !== void 0 && Math.abs(s) <= 257 ? s : void 0);
|
|
72
|
+
const a = e.trueColor ?? e.true_color ?? e.truecolor ?? e.colorRGB ?? e.colorRgb ?? e.rgbColor ?? e.rgb, d = s !== void 0 && s >= 0 && s <= 16777215 && (c === "rgb" || c === "auto" && Math.abs(s) > 257);
|
|
73
|
+
n.trueColor = a ?? (d ? s : void 0), (typeof e.color == "string" || typeof e.color == "number") && (n.color = e.color), n.colorNumber = u(e.colorNumber) ?? n.colorNumber, n.colorName = g(e.colorName ?? e.color_name) ?? n.colorName, n.fillColor = e.fillColor ?? e.fill_color, n.fillColorIndex = u(e.fillColorIndex ?? e.fill_color_index ?? e.fillColorNumber) ?? n.fillColorIndex, n.opacity = u(e.opacity ?? e.alpha) ?? n.opacity, n.lineweight = u(e.lineweight ?? e.lineWeight), n.isVisible = !(e.isVisible === !1 || e.visible === !1), n.startPoint = p(e.startPoint ?? e.start ?? e.p0 ?? e.from) ?? n.startPoint, n.endPoint = p(e.endPoint ?? e.end ?? e.p1 ?? e.to) ?? n.endPoint, n.center = p(e.center ?? e.centerPoint) ?? n.center, n.insertionPoint = p(e.insertionPoint ?? e.position ?? e.location ?? e.point ?? e.basePoint) ?? n.insertionPoint, n.radius = u(e.radius) ?? n.radius, n.startAngle = u(e.startAngle ?? e.start_angle) ?? n.startAngle, n.endAngle = u(e.endAngle ?? e.end_angle) ?? n.endAngle, n.majorAxisEndPoint = p(e.majorAxisEndPoint ?? e.majorAxis ?? e.major) ?? n.majorAxisEndPoint, n.axisRatio = u(e.axisRatio ?? e.ratio) ?? n.axisRatio, n.height = u(e.height ?? e.textHeight) ?? n.height, n.textHeight = u(e.textHeight ?? e.height) ?? n.textHeight, n.rotation = u(e.rotation ?? e.angle) ?? n.rotation, n.text = g(e.text ?? e.value ?? e.string ?? e.contents) ?? n.text, n.name = g(e.name ?? e.blockName) ?? n.name, n.blockName = g(e.blockName ?? e.name) ?? n.blockName;
|
|
74
|
+
const f = N(e.vertices ?? e.points);
|
|
75
|
+
f.length > 0 && (n.vertices = f);
|
|
76
|
+
const l = N(e.controlPoints ?? e.control_points);
|
|
77
|
+
l.length > 0 && (n.controlPoints = l);
|
|
78
|
+
const m = N(e.fitPoints ?? e.fit_points);
|
|
79
|
+
return m.length > 0 && (n.fitPoints = m), n;
|
|
80
|
+
}
|
|
81
|
+
function p(e) {
|
|
82
|
+
if (!e || typeof e != "object") return;
|
|
83
|
+
const t = e, o = Number(t.x ?? t.X ?? t[0]), i = Number(t.y ?? t.Y ?? t[1]), n = t.z ?? t.Z ?? t[2], c = n === void 0 ? void 0 : Number(n);
|
|
84
|
+
if (!(!Number.isFinite(o) || !Number.isFinite(i)))
|
|
85
|
+
return Number.isFinite(c) ? { x: o, y: i, z: c } : { x: o, y: i };
|
|
86
|
+
}
|
|
87
|
+
function N(e) {
|
|
88
|
+
if (!Array.isArray(e)) return [];
|
|
89
|
+
const t = [];
|
|
90
|
+
for (const o of e) {
|
|
91
|
+
const i = p(o);
|
|
92
|
+
if (!i) continue;
|
|
93
|
+
const n = o, c = i, s = u(n.bulge);
|
|
94
|
+
s !== void 0 && (c.bulge = s);
|
|
95
|
+
const r = u(n.startWidth ?? n.start_width);
|
|
96
|
+
r !== void 0 && (c.startWidth = r);
|
|
97
|
+
const a = u(n.endWidth ?? n.end_width);
|
|
98
|
+
a !== void 0 && (c.endWidth = a), t.push(c);
|
|
99
|
+
}
|
|
100
|
+
return t;
|
|
101
|
+
}
|
|
102
|
+
function T(e, t) {
|
|
103
|
+
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
104
|
+
}
|
|
105
|
+
function _(e, t) {
|
|
106
|
+
t.name && (e[t.name] = t, e[t.name.toLowerCase()] = t);
|
|
107
|
+
}
|
|
108
|
+
function u(e) {
|
|
109
|
+
const t = Number(e);
|
|
110
|
+
return Number.isFinite(t) ? t : void 0;
|
|
111
|
+
}
|
|
112
|
+
function g(e) {
|
|
113
|
+
if (typeof e != "string" && typeof e != "number") return;
|
|
114
|
+
const t = String(e);
|
|
115
|
+
return t.length > 0 ? t : void 0;
|
|
116
|
+
}
|
|
117
|
+
function O(e) {
|
|
118
|
+
return e.byteOffset === 0 && e.byteLength === e.buffer.byteLength ? e.buffer : e.slice().buffer;
|
|
119
|
+
}
|
|
120
|
+
const S = {
|
|
121
|
+
AC1009: "R12",
|
|
122
|
+
AC1012: "R13",
|
|
123
|
+
AC1014: "R14",
|
|
124
|
+
AC1015: "R2000",
|
|
125
|
+
AC1018: "R2004",
|
|
126
|
+
AC1021: "R2007",
|
|
127
|
+
AC1024: "R2010",
|
|
128
|
+
AC1027: "R2013",
|
|
129
|
+
AC1032: "R2018"
|
|
130
|
+
};
|
|
131
|
+
function U(e) {
|
|
132
|
+
const t = Array.from(e.slice(0, 6), (i) => String.fromCharCode(i)).join(""), o = S[t] ?? "UNKNOWN";
|
|
133
|
+
return {
|
|
134
|
+
signature: t,
|
|
135
|
+
release: o,
|
|
136
|
+
supportedByOpenDesignSpec: o !== "UNKNOWN",
|
|
137
|
+
notes: o === "UNKNOWN" ? "Unknown or unsupported DWG signature." : void 0
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const C = /* @__PURE__ */ new Map();
|
|
141
|
+
async function B(e, t = {}) {
|
|
142
|
+
var m, y, b, A, w, R;
|
|
143
|
+
const o = performance.now(), i = t.sourceName;
|
|
144
|
+
(m = t.onProgress) == null || m.call(t, { phase: "detect", format: "dwg", message: "Validating DWG header…", total: e.byteLength });
|
|
145
|
+
const n = U(e);
|
|
146
|
+
if (!n.signature.startsWith("AC"))
|
|
147
|
+
throw new Error(`Invalid DWG header: ${JSON.stringify(n.signature)}.`);
|
|
148
|
+
(y = t.onProgress) == null || y.call(t, { phase: "wasm-init", format: "dwg", message: "Initializing LibreDWG WebAssembly…", total: e.byteLength });
|
|
149
|
+
const c = await k(t.wasmPath ?? "/wasm/");
|
|
150
|
+
(b = t.onProgress) == null || b.call(t, { phase: "parse", format: "dwg", message: `Decoding ${n.signature} DWG…`, total: e.byteLength, percent: 35 });
|
|
151
|
+
const s = O(e), r = ((A = c.Dwg_File_Type) == null ? void 0 : A.DWG) ?? 0, a = c.instance.dwg_read_data(s, r);
|
|
152
|
+
if (!a) throw new Error("LibreDWG returned an empty DWG result.");
|
|
153
|
+
if (typeof a.error == "number" && a.error !== 0) throw new Error(`LibreDWG parse error code: ${a.error}.`);
|
|
154
|
+
(w = t.onProgress) == null || w.call(t, { phase: "normalize", format: "dwg", message: "Normalizing DWG database…", total: e.byteLength, percent: 72 });
|
|
155
|
+
const d = typeof c.instance.convert == "function" ? c.instance.convert(a) : a;
|
|
156
|
+
try {
|
|
157
|
+
typeof c.instance.dwg_free == "function" && c.instance.dwg_free(a);
|
|
158
|
+
} catch {
|
|
159
|
+
}
|
|
160
|
+
const f = z(d, i, n, { keepRaw: !!t.keepRaw }), l = performance.now() - o;
|
|
161
|
+
return (R = t.onProgress) == null || R.call(t, { phase: "done", format: "dwg", message: "DWG loaded.", total: e.byteLength, percent: 100, elapsedMs: l }), {
|
|
162
|
+
document: f,
|
|
163
|
+
raw: t.keepRaw ? d : void 0,
|
|
164
|
+
bytes: e.byteLength,
|
|
165
|
+
elapsedMs: l,
|
|
166
|
+
format: "dwg",
|
|
167
|
+
warnings: f.warnings
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
async function k(e = "/wasm/") {
|
|
171
|
+
const t = H(e);
|
|
172
|
+
let o = C.get(t);
|
|
173
|
+
o || (o = import("./index-C365l3i9.js").then(async (c) => {
|
|
174
|
+
const s = c, r = s.LibreDwg;
|
|
175
|
+
if (!r || typeof r.create != "function")
|
|
176
|
+
throw new Error("@mlightcad/libredwg-web did not expose LibreDwg.create().");
|
|
177
|
+
try {
|
|
178
|
+
if (typeof s.createModule == "function" && typeof r.createByWasmInstance == "function") {
|
|
179
|
+
const a = E(t), d = await V(a), f = await s.createModule({
|
|
180
|
+
wasmBinary: d,
|
|
181
|
+
locateFile: (l) => new URL(l, x(t)).href
|
|
182
|
+
});
|
|
183
|
+
return r.createByWasmInstance(f);
|
|
184
|
+
}
|
|
185
|
+
return await r.create(t);
|
|
186
|
+
} catch (a) {
|
|
187
|
+
const d = a instanceof Error ? a.message : String(a);
|
|
188
|
+
throw new Error(`Failed to initialize LibreDWG WebAssembly from ${t}. Ensure libredwg-web.wasm is deployed at ${E(t)} and wasmPath is resolved relative to the page, not the worker script. Run npm run copy:wasm before dev/build. Original error: ${d}`);
|
|
189
|
+
}
|
|
190
|
+
}), C.set(t, o));
|
|
191
|
+
const i = await o, n = await import("./index-C365l3i9.js");
|
|
192
|
+
return { module: n, instance: i, Dwg_File_Type: n.Dwg_File_Type };
|
|
193
|
+
}
|
|
194
|
+
function z(e, t, o, i = {}) {
|
|
195
|
+
const n = e && typeof e == "object" ? e : {}, c = F(n, i), s = $(n, i), r = Array.isArray(n.entities) ? n.entities : [], a = { keepRaw: !!i.keepRaw, includeUnknownProperties: !!i.keepRaw }, d = r.filter((l) => !!l && typeof l == "object").map((l) => I(l, a)), f = D({
|
|
196
|
+
format: "dwg",
|
|
197
|
+
sourceName: t,
|
|
198
|
+
header: j(n.header, o),
|
|
199
|
+
layers: c,
|
|
200
|
+
blocks: s,
|
|
201
|
+
entities: d,
|
|
202
|
+
metadata: {
|
|
203
|
+
parser: "@mlightcad/libredwg-web",
|
|
204
|
+
parserMode: "wasm",
|
|
205
|
+
version: o
|
|
206
|
+
},
|
|
207
|
+
warnings: [],
|
|
208
|
+
raw: i.keepRaw ? e : void 0
|
|
209
|
+
});
|
|
210
|
+
return d.length === 0 && f.warnings.push("DWG parsed successfully but no model-space entities were exposed by the converter. Check layout/paper-space content or unsupported proxy objects."), f;
|
|
211
|
+
}
|
|
212
|
+
function I(e, t) {
|
|
213
|
+
const o = M(e, void 0, { ...t, numericColorMode: "rgb" }), i = u(e.color);
|
|
214
|
+
return i !== void 0 && i >= 0 && i <= 16777215 && (o.color = i, o.trueColor = i), o.colorIndex = u(e.colorIndex ?? e.colorNumber ?? e.aci) ?? o.colorIndex, o.colorName = g(e.colorName ?? e.color_name) ?? o.colorName, o;
|
|
215
|
+
}
|
|
216
|
+
function G(e) {
|
|
217
|
+
return typeof e == "number" && Number.isFinite(e) && Math.abs(Math.trunc(e)) >= 1 && Math.abs(Math.trunc(e)) <= 255;
|
|
218
|
+
}
|
|
219
|
+
function j(e, t) {
|
|
220
|
+
const o = e && typeof e == "object" ? { ...e } : {};
|
|
221
|
+
return t && (o.dwgVersion = t), o;
|
|
222
|
+
}
|
|
223
|
+
function F(e, t) {
|
|
224
|
+
const o = {}, i = [], n = e.tables;
|
|
225
|
+
for (const c of ["LAYER", "layer", "layers"]) {
|
|
226
|
+
const s = e[c] ?? (n == null ? void 0 : n[c]);
|
|
227
|
+
s && i.push(s);
|
|
228
|
+
}
|
|
229
|
+
for (const c of i)
|
|
230
|
+
for (const s of W(c)) {
|
|
231
|
+
const r = s, a = g(r.name ?? r.layerName ?? r.entryName);
|
|
232
|
+
if (!a) continue;
|
|
233
|
+
const d = u(r.colorIndex ?? r.colorNumber), f = u(r.trueColor ?? r.true_color ?? r.truecolor ?? r.colorRGB ?? r.colorRgb ?? r.rgbColor ?? r.rgb), l = u(r.color), m = G(d), y = f ?? (!m && l !== void 0 && l >= 0 && l <= 16777215 ? l : void 0), b = {
|
|
234
|
+
name: a,
|
|
235
|
+
color: m ? void 0 : r.color ?? r.colorName,
|
|
236
|
+
colorIndex: d ?? (l !== void 0 && Math.abs(l) <= 257 ? l : void 0),
|
|
237
|
+
trueColor: y,
|
|
238
|
+
lineType: g(r.lineType ?? r.linetype),
|
|
239
|
+
lineweight: u(r.lineweight ?? r.lineWeight),
|
|
240
|
+
isVisible: !(r.isVisible === !1 || r.off === !0 || Number(d ?? r.color ?? 1) < 0),
|
|
241
|
+
isFrozen: !!(r.isFrozen ?? r.frozen),
|
|
242
|
+
isLocked: !!(r.isLocked ?? r.locked),
|
|
243
|
+
raw: t.keepRaw ? r : void 0
|
|
244
|
+
};
|
|
245
|
+
T(o, b);
|
|
246
|
+
}
|
|
247
|
+
return o;
|
|
248
|
+
}
|
|
249
|
+
function $(e, t) {
|
|
250
|
+
const o = {}, i = [e.blocks, e.blockHeaders, e.block_records, e.blockRecords], n = e.tables;
|
|
251
|
+
i.push(n == null ? void 0 : n.BLOCK, n == null ? void 0 : n.BLOCK_RECORD, n == null ? void 0 : n.blocks);
|
|
252
|
+
const c = { keepRaw: !!t.keepRaw, includeUnknownProperties: !!t.keepRaw };
|
|
253
|
+
for (const s of i)
|
|
254
|
+
for (const r of W(s)) {
|
|
255
|
+
const a = r, d = g(a.name ?? a.blockName ?? a.name2);
|
|
256
|
+
if (!d) continue;
|
|
257
|
+
const l = (Array.isArray(a.entities) ? a.entities : Array.isArray(a.ownedObjects) ? a.ownedObjects : []).filter((m) => !!m && typeof m == "object").map((m) => I(m, c));
|
|
258
|
+
_(o, {
|
|
259
|
+
name: d,
|
|
260
|
+
basePoint: p(a.basePoint ?? a.origin) ?? { x: 0, y: 0 },
|
|
261
|
+
entities: l,
|
|
262
|
+
raw: t.keepRaw ? a : void 0
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
return o;
|
|
266
|
+
}
|
|
267
|
+
function W(e) {
|
|
268
|
+
if (!e) return [];
|
|
269
|
+
if (Array.isArray(e)) return e;
|
|
270
|
+
if (typeof e != "object") return [];
|
|
271
|
+
const t = e, o = Object.values(t).filter((n) => n && typeof n == "object"), i = ["entries", "records", "items", "values", "layers", "blocks"].flatMap((n) => Array.isArray(t[n]) ? t[n] : []);
|
|
272
|
+
return i.length > 0 ? i : o;
|
|
273
|
+
}
|
|
274
|
+
function H(e) {
|
|
275
|
+
const t = e.trim() || "/wasm";
|
|
276
|
+
if (t === "/") return P();
|
|
277
|
+
const o = t.replace(/\/+$/, "");
|
|
278
|
+
return q(o) ? o : o.startsWith("/") ? `${P()}${o}` : new URL(o, v()).href.replace(/\/+$/, "");
|
|
279
|
+
}
|
|
280
|
+
function E(e) {
|
|
281
|
+
return new URL("libredwg-web.wasm", x(e)).href;
|
|
282
|
+
}
|
|
283
|
+
function x(e) {
|
|
284
|
+
return e.endsWith("/") ? e : `${e}/`;
|
|
285
|
+
}
|
|
286
|
+
function q(e) {
|
|
287
|
+
return /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
288
|
+
}
|
|
289
|
+
function v() {
|
|
290
|
+
return typeof document < "u" && document.baseURI ? document.baseURI : typeof location < "u" && location.href ? location.href : "http://localhost/";
|
|
291
|
+
}
|
|
292
|
+
function P() {
|
|
293
|
+
return typeof location < "u" && location.origin ? location.origin : new URL(v()).origin;
|
|
294
|
+
}
|
|
295
|
+
async function V(e) {
|
|
296
|
+
if (typeof fetch != "function")
|
|
297
|
+
throw new Error("fetch() is not available, so the LibreDWG WASM binary cannot be loaded.");
|
|
298
|
+
const t = await fetch(e, { credentials: "same-origin", cache: "force-cache" });
|
|
299
|
+
if (!t.ok)
|
|
300
|
+
throw new Error(`WASM asset request failed with HTTP ${t.status} for ${e}.`);
|
|
301
|
+
const o = new Uint8Array(await t.arrayBuffer());
|
|
302
|
+
if (!Y(o)) {
|
|
303
|
+
const i = X(o), n = t.headers.get("content-type") ?? "unknown content-type";
|
|
304
|
+
throw new Error(`Invalid WASM asset at ${e}. Expected bytes 00 61 73 6d, got ${K(o)} (${n}). The server probably returned an HTML fallback page instead of libredwg-web.wasm. Response preview: ${i}`);
|
|
305
|
+
}
|
|
306
|
+
return o;
|
|
307
|
+
}
|
|
308
|
+
function Y(e) {
|
|
309
|
+
return e.length >= 4 && e[0] === 0 && e[1] === 97 && e[2] === 115 && e[3] === 109;
|
|
310
|
+
}
|
|
311
|
+
function K(e) {
|
|
312
|
+
return Array.from(e.slice(0, 4)).map((t) => t.toString(16).padStart(2, "0")).join(" ");
|
|
313
|
+
}
|
|
314
|
+
function X(e) {
|
|
315
|
+
const t = Array.from(e.slice(0, 32)).map((o) => o >= 32 && o <= 126 ? String.fromCharCode(o) : ".").join("");
|
|
316
|
+
return JSON.stringify(t);
|
|
317
|
+
}
|
|
318
|
+
const h = self;
|
|
319
|
+
h.postMessage({ type: "ready" });
|
|
320
|
+
h.onmessage = async (e) => {
|
|
321
|
+
var n, c;
|
|
322
|
+
const t = e.data;
|
|
323
|
+
if (!t) return;
|
|
324
|
+
const o = performance.now(), i = (s) => {
|
|
325
|
+
h.postMessage({ type: "progress", requestId: t.requestId, progress: s });
|
|
326
|
+
};
|
|
327
|
+
try {
|
|
328
|
+
if (t.type === "warmup") {
|
|
329
|
+
i({ phase: "wasm-init", format: "dwg", message: "Warming LibreDWG WebAssembly instance…" }), await k(((n = t.options) == null ? void 0 : n.wasmPath) ?? "/wasm/"), h.postMessage({ type: "warmup-result", requestId: t.requestId, elapsedMs: performance.now() - o });
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (t.type !== "load") return;
|
|
333
|
+
i({ phase: "worker-ready", format: "dwg", message: "DWG worker received file bytes.", total: t.bytes.byteLength });
|
|
334
|
+
const s = await B(new Uint8Array(t.bytes), {
|
|
335
|
+
...t.options,
|
|
336
|
+
sourceName: t.fileName,
|
|
337
|
+
keepRaw: !!((c = t.options) != null && c.keepRaw),
|
|
338
|
+
onProgress: i
|
|
339
|
+
});
|
|
340
|
+
s.document.metadata.loaderMode = "worker", s.elapsedMs = performance.now() - o, h.postMessage({ type: "result", requestId: t.requestId, result: s });
|
|
341
|
+
} catch (s) {
|
|
342
|
+
const r = J(s);
|
|
343
|
+
h.postMessage({ type: "error", requestId: t.requestId, error: r });
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
function J(e) {
|
|
347
|
+
return e instanceof Error ? { name: e.name, message: e.message, stack: e.stack } : { message: String(e) };
|
|
348
|
+
}
|
|
349
|
+
//# sourceMappingURL=DwgWorker-CuZJ5EUe.js.map
|