@mlightcad/cad-simple-viewer-cli 1.7.0 → 1.7.1
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/LICENSE +21 -21
- package/README.md +143 -140
- package/dist-runner/assets/cad-html-plugin-CH5xALXb.js +1547 -0
- package/dist-runner/assets/cad-pdf-plugin-DkcMorOI.js +213 -0
- package/dist-runner/assets/{cad-svg-plugin-D7i6E3aJ.js → cad-svg-plugin-BJNA8aLS.js} +7 -7
- package/dist-runner/assets/index-BSoxUnC1.js +7324 -0
- package/dist-runner/index.html +12 -12
- package/dist-runner/viewer-runtime.iife.js +892 -236
- package/dist-runner/workers/libredwg-parser-worker.js +19 -19
- package/dist-runner/workers/mtext-renderer-worker.js +1908 -1765
- package/examples/batch-export-html-multi-preview.mjs +236 -0
- package/examples/batch-export-html.mjs +105 -105
- package/examples/batch-export-png.mjs +103 -103
- package/examples/create-drawing-dxf.scr +15 -15
- package/examples/create-drawing-png.scr +19 -19
- package/examples/create-shapes-dxf.scr +17 -17
- package/examples/export-dxf.scr +5 -5
- package/examples/export-html-multi-preview.scr +18 -0
- package/examples/export-html-multi.scr +13 -13
- package/examples/export-html.scr +12 -12
- package/examples/export-pdf.scr +9 -0
- package/examples/export-png.scr +9 -9
- package/examples/freeze-layer-png.scr +15 -15
- package/examples/index.json +114 -96
- package/package.json +9 -8
- package/dist-runner/assets/cad-html-plugin-Dw_UabVa.js +0 -1526
- package/dist-runner/assets/cad-pdf-plugin-BoBimdKx.js +0 -312
- package/dist-runner/assets/index-D6ZWapu2.js +0 -6993
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 mlightcad
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mlightcad
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,140 +1,143 @@
|
|
|
1
|
-
# @mlightcad/cad-simple-viewer-cli
|
|
2
|
-
|
|
3
|
-
[](https://opensource.org/licenses/MIT)
|
|
4
|
-
[](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer-cli)
|
|
5
|
-
|
|
6
|
-
AcCoreConsole-style **headless** CLI for MLight CAD Viewer. Install from npm, open a DXF/DWG (or start blank), run an AutoCAD-like **`.scr` command script**, and save exports (`pngout`, `-chtml`, `cdxf`, …) to disk.
|
|
7
|
-
|
|
8
|
-
Requires **Node.js 20+**. The CLI uses headless Chromium via Playwright; on first use you must install the browser once.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
|
|
12
|
-
```bash
|
|
13
|
-
npm install -g @mlightcad/cad-simple-viewer-cli
|
|
14
|
-
npx playwright install chromium
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Or as a project dependency:
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
npm install -D @mlightcad/cad-simple-viewer-cli
|
|
21
|
-
npx playwright install chromium
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Quick start
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
# Export a drawing to PNG (sample script shipped with the package)
|
|
28
|
-
cad-simple-viewer-cli \
|
|
29
|
-
-i ./drawing.dwg \
|
|
30
|
-
-s node_modules/@mlightcad/cad-simple-viewer-cli/examples/export-png.scr \
|
|
31
|
-
-o ./out
|
|
32
|
-
|
|
33
|
-
# Global install: same, with your own script
|
|
34
|
-
cad-simple-viewer-cli -i ./drawing.dxf -s ./export-png.scr -o ./out
|
|
35
|
-
|
|
36
|
-
# Open from URL
|
|
37
|
-
cad-simple-viewer-cli \
|
|
38
|
-
-i https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/data/canteen.dwg \
|
|
39
|
-
-s ./export-png.scr \
|
|
40
|
-
-o ./out
|
|
41
|
-
|
|
42
|
-
# No input file: start from a blank ISO drawing (write mode)
|
|
43
|
-
cad-simple-viewer-cli -s ./create-drawing-dxf.scr -o ./out --mode write
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
With a local install, use `npx`:
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
npx cad-simple-viewer-cli -i ./drawing.dwg -s ./export-png.scr -o ./out
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Options
|
|
53
|
-
|
|
54
|
-
| Option | Description |
|
|
55
|
-
|--------|-------------|
|
|
56
|
-
| `-i, --input <file-or-url>` | Local `.dxf` / `.dwg` path or `http(s)` URL. Omit to start from a blank ISO template |
|
|
57
|
-
| `-s, --script <file>` | `.scr` command script (**required**) |
|
|
58
|
-
| `-o, --output <dir>` | Directory for downloaded exports (default: input file’s directory, or cwd when no `-i`) |
|
|
59
|
-
| `--mode <read\|write>` | Document open mode (default: `read` with `-i`, `write` without `-i`) |
|
|
60
|
-
| `--locale <code>` | Prompt/keyword locale (`en`, `zh`, …) |
|
|
61
|
-
| `--logfile <path>` | Append start / finish / download log lines |
|
|
62
|
-
|
|
63
|
-
## AcCoreConsole mapping
|
|
64
|
-
|
|
65
|
-
| AcCoreConsole | cad-simple-viewer-cli |
|
|
66
|
-
|---------------|------------------------|
|
|
67
|
-
| `accoreconsole /i drawing.dwg /s script.scr` | `cad-simple-viewer-cli -i drawing.dwg -s script.scr` |
|
|
68
|
-
| `/i` | `-i, --input` (optional path or URL) |
|
|
69
|
-
| `/s` | `-s, --script` |
|
|
70
|
-
| plot / export path | `-o, --output` (download directory) |
|
|
71
|
-
|
|
72
|
-
## Script format
|
|
73
|
-
|
|
74
|
-
1. First non-blank line of each command is the **command name**
|
|
75
|
-
2. Following lines answer prompts (empty line = Enter / default / None)
|
|
76
|
-
3. Full-line `;` comments are ignored
|
|
77
|
-
4. `QUIT` / `EXIT` ends the script
|
|
78
|
-
|
|
79
|
-
Example — zoom extents, then PNG (long side 2048):
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
; export-png.scr
|
|
83
|
-
zoom
|
|
84
|
-
e
|
|
85
|
-
pngout
|
|
86
|
-
|
|
87
|
-
2048
|
|
88
|
-
quit
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Useful commands (non-exhaustive): `zoom`, `pngout`, `cdxf`, `-chtml`, `chtml`, `cpdf`, `csvg`, `-layer`, `qnew`, `line`, `circle`, …
|
|
92
|
-
|
|
93
|
-
Layer edits need `--mode write`. Export commands write files via browser download; the CLI captures them into `-o`.
|
|
94
|
-
|
|
95
|
-
## Sample scripts
|
|
96
|
-
|
|
97
|
-
After install, examples live under `node_modules/@mlightcad/cad-simple-viewer-cli/examples/` (or the global package folder):
|
|
98
|
-
|
|
99
|
-
| Script | Purpose |
|
|
100
|
-
|--------|---------|
|
|
101
|
-
| `export-png.scr` | Zoom extents → PNG |
|
|
102
|
-
| `export-html.scr` | Offline HTML (`-chtml`) |
|
|
103
|
-
| `export-html-multi.scr` | Multi-file ACEX package zip (`-chtml` Multi) |
|
|
104
|
-
| `export-
|
|
105
|
-
| `
|
|
106
|
-
| `create-
|
|
107
|
-
| `create-
|
|
108
|
-
| `
|
|
109
|
-
| `
|
|
110
|
-
| `batch-export-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
1
|
+
# @mlightcad/cad-simple-viewer-cli
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer-cli)
|
|
5
|
+
|
|
6
|
+
AcCoreConsole-style **headless** CLI for MLight CAD Viewer. Install from npm, open a DXF/DWG (or start blank), run an AutoCAD-like **`.scr` command script**, and save exports (`pngout`, `-chtml`, `cdxf`, …) to disk.
|
|
7
|
+
|
|
8
|
+
Requires **Node.js 20+**. The CLI uses headless Chromium via Playwright; on first use you must install the browser once.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @mlightcad/cad-simple-viewer-cli
|
|
14
|
+
npx playwright install chromium
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Or as a project dependency:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install -D @mlightcad/cad-simple-viewer-cli
|
|
21
|
+
npx playwright install chromium
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Export a drawing to PNG (sample script shipped with the package)
|
|
28
|
+
cad-simple-viewer-cli \
|
|
29
|
+
-i ./drawing.dwg \
|
|
30
|
+
-s node_modules/@mlightcad/cad-simple-viewer-cli/examples/export-png.scr \
|
|
31
|
+
-o ./out
|
|
32
|
+
|
|
33
|
+
# Global install: same, with your own script
|
|
34
|
+
cad-simple-viewer-cli -i ./drawing.dxf -s ./export-png.scr -o ./out
|
|
35
|
+
|
|
36
|
+
# Open from URL
|
|
37
|
+
cad-simple-viewer-cli \
|
|
38
|
+
-i https://cdn.jsdelivr.net/gh/mlightcad/cad-data@main/data/canteen.dwg \
|
|
39
|
+
-s ./export-png.scr \
|
|
40
|
+
-o ./out
|
|
41
|
+
|
|
42
|
+
# No input file: start from a blank ISO drawing (write mode)
|
|
43
|
+
cad-simple-viewer-cli -s ./create-drawing-dxf.scr -o ./out --mode write
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
With a local install, use `npx`:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
npx cad-simple-viewer-cli -i ./drawing.dwg -s ./export-png.scr -o ./out
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Options
|
|
53
|
+
|
|
54
|
+
| Option | Description |
|
|
55
|
+
|--------|-------------|
|
|
56
|
+
| `-i, --input <file-or-url>` | Local `.dxf` / `.dwg` path or `http(s)` URL. Omit to start from a blank ISO template |
|
|
57
|
+
| `-s, --script <file>` | `.scr` command script (**required**) |
|
|
58
|
+
| `-o, --output <dir>` | Directory for downloaded exports (default: input file’s directory, or cwd when no `-i`) |
|
|
59
|
+
| `--mode <read\|write>` | Document open mode (default: `read` with `-i`, `write` without `-i`) |
|
|
60
|
+
| `--locale <code>` | Prompt/keyword locale (`en`, `zh`, …) |
|
|
61
|
+
| `--logfile <path>` | Append start / finish / download log lines |
|
|
62
|
+
|
|
63
|
+
## AcCoreConsole mapping
|
|
64
|
+
|
|
65
|
+
| AcCoreConsole | cad-simple-viewer-cli |
|
|
66
|
+
|---------------|------------------------|
|
|
67
|
+
| `accoreconsole /i drawing.dwg /s script.scr` | `cad-simple-viewer-cli -i drawing.dwg -s script.scr` |
|
|
68
|
+
| `/i` | `-i, --input` (optional path or URL) |
|
|
69
|
+
| `/s` | `-s, --script` |
|
|
70
|
+
| plot / export path | `-o, --output` (download directory) |
|
|
71
|
+
|
|
72
|
+
## Script format
|
|
73
|
+
|
|
74
|
+
1. First non-blank line of each command is the **command name**
|
|
75
|
+
2. Following lines answer prompts (empty line = Enter / default / None)
|
|
76
|
+
3. Full-line `;` comments are ignored
|
|
77
|
+
4. `QUIT` / `EXIT` ends the script
|
|
78
|
+
|
|
79
|
+
Example — zoom extents, then PNG (long side 2048):
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
; export-png.scr
|
|
83
|
+
zoom
|
|
84
|
+
e
|
|
85
|
+
pngout
|
|
86
|
+
|
|
87
|
+
2048
|
|
88
|
+
quit
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Useful commands (non-exhaustive): `zoom`, `pngout`, `cdxf`, `-chtml`, `chtml`, `cpdf`, `csvg`, `-layer`, `qnew`, `line`, `circle`, …
|
|
92
|
+
|
|
93
|
+
Layer edits need `--mode write`. Export commands write files via browser download; the CLI captures them into `-o`.
|
|
94
|
+
|
|
95
|
+
## Sample scripts
|
|
96
|
+
|
|
97
|
+
After install, examples live under `node_modules/@mlightcad/cad-simple-viewer-cli/examples/` (or the global package folder):
|
|
98
|
+
|
|
99
|
+
| Script | Purpose |
|
|
100
|
+
|--------|---------|
|
|
101
|
+
| `export-png.scr` | Zoom extents → PNG |
|
|
102
|
+
| `export-html.scr` | Offline HTML (`-chtml`) |
|
|
103
|
+
| `export-html-multi.scr` | Multi-file ACEX package zip (`-chtml` Multi) |
|
|
104
|
+
| `export-html-multi-preview.scr` | Multi ACEX zip + zoom-extents JPEG preview (one run) |
|
|
105
|
+
| `export-dxf.scr` | DXF download (`cdxf`) |
|
|
106
|
+
| `create-drawing-dxf.scr` | Blank drawing + LINE → DXF (no `-i`) |
|
|
107
|
+
| `create-shapes-dxf.scr` | Blank drawing + LINE + CIRCLE → DXF |
|
|
108
|
+
| `create-drawing-png.scr` | Blank drawing → PNG |
|
|
109
|
+
| `freeze-layer-png.scr` | `-layer` Off then PNG (`--mode write`; edit `LAYER_NAME`) |
|
|
110
|
+
| `batch-export-png.mjs` | Scan a folder of drawings → PNG |
|
|
111
|
+
| `batch-export-html.mjs` | Scan a folder → HTML |
|
|
112
|
+
| `batch-export-html-multi-preview.mjs` | Scan a folder → multi ACEX + preview, demo-drawings layout |
|
|
113
|
+
|
|
114
|
+
Batch helpers (from your project after `npm install -D`):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-png.mjs ./drawings ./out-png
|
|
118
|
+
node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-html.mjs ./drawings ./out-html
|
|
119
|
+
node node_modules/@mlightcad/cad-simple-viewer-cli/examples/batch-export-html-multi-preview.mjs ./drawings ./out-demo
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Programmatic API
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import { runHeadless } from '@mlightcad/cad-simple-viewer-cli'
|
|
126
|
+
|
|
127
|
+
const { outputDir, savedFiles } = await runHeadless({
|
|
128
|
+
inputPath: './drawing.dwg', // optional; omit for blank drawing
|
|
129
|
+
scriptPath: './export-png.scr',
|
|
130
|
+
outputDir: './out',
|
|
131
|
+
mode: 'read', // optional
|
|
132
|
+
locale: 'en', // optional
|
|
133
|
+
logfile: './cli.log' // optional
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
console.log(outputDir, savedFiles)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## How it works
|
|
140
|
+
|
|
141
|
+
1. The published package includes a prebuilt Playwright runner (`dist-runner/`).
|
|
142
|
+
2. The CLI starts headless Chromium, opens the drawing (or a blank template), waits for entity convert / deferred text geometry, then runs `AcApDocManager.runScript()`.
|
|
143
|
+
3. Export commands trigger downloads; the CLI writes captured files under `-o`.
|