@open-file-viewer/core 0.1.5 → 0.1.7
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 +45 -0
- package/dist/index.cjs +1793 -181
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -2
- package/dist/index.d.ts +41 -2
- package/dist/index.js +1793 -181
- package/dist/index.js.map +1 -1
- package/dist/style.css +218 -33
- package/package.json +12 -6
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Framework-agnostic browser file preview core for Open File Viewer.
|
|
|
4
4
|
|
|
5
5
|
Open File Viewer renders files inside your own DOM container instead of opening a new window. It supports images, PDF, Office documents, audio, video, text/code, archives, email, drawings, CAD, 3D and GIS formats through a plugin-based pipeline.
|
|
6
6
|
|
|
7
|
+
DWG/DWF are proprietary binary CAD formats. `cadPlugin()` uses a two-layer model: it tries the built-in LibreDWG WASM DWG preview by default, then falls back to embedded thumbnails or metadata; applications can use `binaryRenderer` as the highest-priority override for custom renderers or server-side CAD conversion services.
|
|
8
|
+
|
|
7
9
|
- Website: https://open-file-viewer-workspace.void.app
|
|
8
10
|
- GitHub: https://github.com/xushanpei/open-file-viewer
|
|
9
11
|
- npm: https://www.npmjs.com/package/@open-file-viewer/core
|
|
@@ -20,6 +22,18 @@ PDF preview requires `pdfjs-dist`:
|
|
|
20
22
|
npm install pdfjs-dist
|
|
21
23
|
```
|
|
22
24
|
|
|
25
|
+
DWG geometry preview uses optional LibreDWG WASM. The package can be installed by applications that want the default built-in DWG linework path:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @mlightcad/libredwg-web
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Copy `libredwg-web.wasm` to a public directory and point `cadPlugin` to it:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
cadPlugin({ libreDwg: { wasmBaseUrl: "/vendor/libredwg-web" } });
|
|
35
|
+
```
|
|
36
|
+
|
|
23
37
|
## Quick Start
|
|
24
38
|
|
|
25
39
|
```ts
|
|
@@ -72,6 +86,37 @@ viewer.resize();
|
|
|
72
86
|
viewer.destroy();
|
|
73
87
|
```
|
|
74
88
|
|
|
89
|
+
## CAD Customization
|
|
90
|
+
|
|
91
|
+
`cadPlugin()` has two CAD preview layers:
|
|
92
|
+
|
|
93
|
+
1. Default built-in path: DWG automatically tries LibreDWG WASM. If linework cannot be produced but the file contains an embedded preview image, the plugin shows that thumbnail. If the engine is unavailable or parsing fails, it shows DWG/DWF metadata and conversion guidance.
|
|
94
|
+
2. External enhancement path: `binaryRenderer` can take over DWG/DWF completely for CADViewer, MxCAD, a custom WebGL/SVG renderer, or a backend PNG/PDF/SVG/DXF conversion service.
|
|
95
|
+
|
|
96
|
+
Use the built-in DWG preview for lightweight local rendering:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
cadPlugin({ libreDwg: { wasmBaseUrl: "/vendor/libredwg-web" } });
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Disable it when you only want metadata and conversion guidance:
|
|
103
|
+
|
|
104
|
+
```ts
|
|
105
|
+
cadPlugin({ libreDwg: false });
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or let a custom renderer/service take over DWG/DWF completely. This is the recommended path for high-fidelity layouts, fonts, xrefs, print space, and production CAD workflows:
|
|
109
|
+
|
|
110
|
+
```ts
|
|
111
|
+
cadPlugin({
|
|
112
|
+
async binaryRenderer({ panel, fileName, bytes }) {
|
|
113
|
+
const result = await uploadToCadPreviewService(bytes, fileName);
|
|
114
|
+
panel.append(result.element);
|
|
115
|
+
return { destroy: () => result.dispose() };
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
75
120
|
## Supported Inputs
|
|
76
121
|
|
|
77
122
|
`createViewer` accepts local files and remote sources:
|