@mlightcad/cad-simple-viewer 1.7.6 → 1.7.7-preview.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.
Files changed (114) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +190 -190
  3. package/dist/cad-simple-viewer.js +5959 -5771
  4. package/dist/cad-simple-viewer.umd.cjs +114 -114
  5. package/dist/mtext-renderer-worker.js +14124 -8730
  6. package/find.ts +7 -7
  7. package/icons.ts +7 -7
  8. package/lib/app/AcApDocManager.d.ts.map +1 -1
  9. package/lib/app/AcApDocManager.js +56 -66
  10. package/lib/app/AcApDocManager.js.map +1 -1
  11. package/lib/app/AcApOpenDatabaseOptions.d.ts +8 -2
  12. package/lib/app/AcApOpenDatabaseOptions.d.ts.map +1 -1
  13. package/lib/command/convert/AcApEntityPreviewCmd.d.ts.map +1 -1
  14. package/lib/command/convert/AcApEntityPreviewCmd.js +1 -0
  15. package/lib/command/convert/AcApEntityPreviewCmd.js.map +1 -1
  16. package/lib/command/convert/AcApRasterImageConvertor.d.ts +17 -8
  17. package/lib/command/convert/AcApRasterImageConvertor.d.ts.map +1 -1
  18. package/lib/command/convert/AcApRasterImageConvertor.js +50 -12
  19. package/lib/command/convert/AcApRasterImageConvertor.js.map +1 -1
  20. package/lib/command/draw/AcApHatchCmd.d.ts.map +1 -1
  21. package/lib/command/draw/AcApHatchCmd.js +1 -0
  22. package/lib/command/draw/AcApHatchCmd.js.map +1 -1
  23. package/lib/command/layer/AcApLayerIsoCmd.d.ts.map +1 -1
  24. package/lib/command/layer/AcApLayerIsoCmd.js +1 -0
  25. package/lib/command/layer/AcApLayerIsoCmd.js.map +1 -1
  26. package/lib/editor/grip/AcEdGripEditSession.d.ts.map +1 -1
  27. package/lib/editor/grip/AcEdGripEditSession.js +6 -1
  28. package/lib/editor/grip/AcEdGripEditSession.js.map +1 -1
  29. package/lib/editor/grip/AcEdGripManager.d.ts.map +1 -1
  30. package/lib/editor/grip/AcEdGripManager.js +2 -1
  31. package/lib/editor/grip/AcEdGripManager.js.map +1 -1
  32. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts +8 -0
  33. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.d.ts.map +1 -1
  34. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js +16 -0
  35. package/lib/editor/input/prompt/AcEdPromptSelectionOptions.js.map +1 -1
  36. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  37. package/lib/editor/input/ui/AcEdInputManager.js +6 -6
  38. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  39. package/lib/editor/input/ui/AcEdMTextEditor.d.ts +7 -6
  40. package/lib/editor/input/ui/AcEdMTextEditor.d.ts.map +1 -1
  41. package/lib/editor/input/ui/AcEdMTextEditor.js +33 -2
  42. package/lib/editor/input/ui/AcEdMTextEditor.js.map +1 -1
  43. package/lib/editor/view/AcEdBaseView.d.ts +16 -0
  44. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  45. package/lib/editor/view/AcEdBaseView.js +38 -0
  46. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  47. package/lib/i18n/ar/main.d.ts +1 -0
  48. package/lib/i18n/ar/main.d.ts.map +1 -1
  49. package/lib/i18n/ar/main.js +1 -0
  50. package/lib/i18n/ar/main.js.map +1 -1
  51. package/lib/i18n/cs/main.d.ts +1 -0
  52. package/lib/i18n/cs/main.d.ts.map +1 -1
  53. package/lib/i18n/cs/main.js +1 -0
  54. package/lib/i18n/cs/main.js.map +1 -1
  55. package/lib/i18n/en/main.d.ts +1 -0
  56. package/lib/i18n/en/main.d.ts.map +1 -1
  57. package/lib/i18n/en/main.js +1 -0
  58. package/lib/i18n/en/main.js.map +1 -1
  59. package/lib/i18n/tr/main.d.ts +1 -0
  60. package/lib/i18n/tr/main.d.ts.map +1 -1
  61. package/lib/i18n/tr/main.js +1 -0
  62. package/lib/i18n/tr/main.js.map +1 -1
  63. package/lib/i18n/zh/main.d.ts +1 -0
  64. package/lib/i18n/zh/main.d.ts.map +1 -1
  65. package/lib/i18n/zh/main.js +1 -0
  66. package/lib/i18n/zh/main.js.map +1 -1
  67. package/lib/service/AcApEntitySelection.d.ts.map +1 -1
  68. package/lib/service/AcApEntitySelection.js +34 -4
  69. package/lib/service/AcApEntitySelection.js.map +1 -1
  70. package/lib/service/AcApEntityService.d.ts.map +1 -1
  71. package/lib/service/AcApEntityService.js +11 -0
  72. package/lib/service/AcApEntityService.js.map +1 -1
  73. package/lib/service/AcApLayerService.d.ts +8 -1
  74. package/lib/service/AcApLayerService.d.ts.map +1 -1
  75. package/lib/service/AcApLayerService.js +10 -0
  76. package/lib/service/AcApLayerService.js.map +1 -1
  77. package/lib/service/AcApLockedLayer.d.ts +23 -0
  78. package/lib/service/AcApLockedLayer.d.ts.map +1 -0
  79. package/lib/service/AcApLockedLayer.js +94 -0
  80. package/lib/service/AcApLockedLayer.js.map +1 -0
  81. package/lib/service/index.d.ts +1 -0
  82. package/lib/service/index.d.ts.map +1 -1
  83. package/lib/service/index.js +1 -0
  84. package/lib/service/index.js.map +1 -1
  85. package/lib/ui/icons.d.ts +5 -2
  86. package/lib/ui/icons.d.ts.map +1 -1
  87. package/lib/ui/icons.js +5 -2
  88. package/lib/ui/icons.js.map +1 -1
  89. package/lib/util/AcApLayoutViewFraming.d.ts +68 -0
  90. package/lib/util/AcApLayoutViewFraming.d.ts.map +1 -0
  91. package/lib/util/AcApLayoutViewFraming.js +146 -0
  92. package/lib/util/AcApLayoutViewFraming.js.map +1 -0
  93. package/lib/util/index.d.ts +1 -0
  94. package/lib/util/index.d.ts.map +1 -1
  95. package/lib/util/index.js +1 -0
  96. package/lib/util/index.js.map +1 -1
  97. package/lib/view/AcTrDirectBatch.d.ts +4 -14
  98. package/lib/view/AcTrDirectBatch.d.ts.map +1 -1
  99. package/lib/view/AcTrDirectBatch.js +4 -120
  100. package/lib/view/AcTrDirectBatch.js.map +1 -1
  101. package/lib/view/AcTrScene.d.ts +1 -1
  102. package/lib/view/AcTrScene.d.ts.map +1 -1
  103. package/lib/view/AcTrView2d.d.ts +40 -36
  104. package/lib/view/AcTrView2d.d.ts.map +1 -1
  105. package/lib/view/AcTrView2d.js +156 -68
  106. package/lib/view/AcTrView2d.js.map +1 -1
  107. package/lib/view/AcTrViewSessionState.d.ts +7 -0
  108. package/lib/view/AcTrViewSessionState.d.ts.map +1 -1
  109. package/package.json +13 -13
  110. package/src/find/AcApFindNavigator.ts +190 -190
  111. package/src/find/findDrawing.ts +211 -211
  112. package/src/find/findText.ts +624 -624
  113. package/src/find/index.ts +2 -2
  114. package/src/ui/icons.ts +411 -408
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,191 +1,191 @@
1
- # CAD Simple Viewer
2
-
3
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
- [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-simple-viewer.svg)](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer)
5
-
6
- This package provides the **high-performance** core components of a CAD viewer such as document management, command handling, and collaboration between the UI and rendering engines. It's designed for optimal performance when handling large CAD files.
7
-
8
- This module doesn't depend on any UI framework and doesn't provide any UI except canvas. If you want to integrate a high-performance CAD viewer into a web application with your own UI, this module is the correct choice. It fully supports **mobile layout and touch interaction**—responsive chrome for phones and tablets, plus pinch-to-zoom, single-finger pan, and tap-to-select—so hosts can ship a mobile-friendly viewer without a separate mobile stack.
9
-
10
- ## Key Features
11
- - Document management optimized for large files
12
- - Efficient command stack and undo/redo operations
13
- - Optimized integration with rendering engines
14
- - Performance-focused settings and context management
15
- - Framework-agnostic design for maximum flexibility
16
- - Mobile-ready layout and touch gestures for phones and tablets
17
-
18
- ## When Should You Choose cad-simple-viewer?
19
-
20
- Use `cad-simple-viewer` if you need **core CAD logic only** (document management, command stack, rendering engine integration) without any UI framework dependencies. This package is ideal if:
21
-
22
- - You want to build your **own custom UI** or integrate CAD functionality into a non-Vue or non-web environment.
23
- - You require maximum flexibility and performance for handling large CAD files, and plan to connect the logic to your own rendering or UI layer.
24
- - You want a framework-agnostic solution that provides only the essential CAD operations and canvas rendering.
25
-
26
- **Recommended for:** Custom integrations, headless CAD processing, or advanced users building highly tailored CAD solutions.
27
-
28
- ## Directory Structure (partial)
29
- - `src/app/` – Document/context management, settings
30
- - `src/command/` – Command implementations (open, zoom, select, etc.)
31
- - `src/editor/` – Command stack, input handling, global functions
32
- - `src/service/` – Layer/entity services and UI layer store
33
- - `src/view/` – Layout and scene management
34
- - `src/util/` – Utilities
35
-
36
- ## Installation
37
-
38
- ```bash
39
- npm install @mlightcad/cad-simple-viewer
40
- ```
41
-
42
- ## Usage
43
-
44
- Please refer to [cad-simple-viewer-example](https://github.com/mlight-lee/cad-simple-viewer-example) on basic usage and advanced usage.
45
-
46
- To learn about the built-in notification center (and how to replace the default bell UI while still receiving font-missing and unsupported-entity alerts), see [docs/notification-center.md](./docs/notification-center.md).
47
-
48
- For the plain-DOM toolbar engine (`AcUiToolbar`, shortcut bar, and host customization), see [docs/toolbar.md](./docs/toolbar.md).
49
-
50
- ### Plugins and data sources
51
-
52
- - **`pluginManager`** — load command plugins (`AcApPlugin`) via `loadPlugin` / `registerLazyPlugin`.
53
- - **`dataSourceManager`** — registry of drawing origins (built-in **local** and **URL**, plus optional cloud plugins such as `@mlightcad/cad-onedrive-plugin` and `@mlightcad/cad-google-drive-plugin`). Open menus in hosts rebuild from `acapBuildDataSourceMenu(dataSourceManager.list())`. Cloud sources that use a popup File Picker must keep **Sign in** and **Open** as separate clicks so browsers do not block the picker.
54
-
55
- While `cad-simple-viewer` doesn't support saving drawings to DWG/DXF files, it provides comprehensive support for **modifying drawings in real-time**. You can add, edit, and delete entities within the drawing, and the viewer will automatically update to reflect these changes.
56
-
57
- When you modify entities, you're working directly with the underlying drawing database. The viewer automatically detects these changes and updates the display accordingly. This real-time synchronization ensures that:
58
-
59
- - All modifications are immediately visible
60
- - The command stack properly tracks changes for undo/redo operations. This will be implemented soon.
61
-
62
- This capability makes `cad-simple-viewer` suitable for applications that need to not only display CAD files but also allow users to interact with and modify the drawing content.
63
-
64
- **Important Note**: The usage patterns in `cad-simple-viewer` are **very similar to AutoCAD RealDWG**. If you're familiar with AutoCAD RealDWG development, you'll find the API structure and workflow nearly identical. The main difference is that we use the [**realdwg-web API**](https://mlight-lee.github.io/realdwg-web/) instead of the native RealDWG libraries.
65
-
66
- In [cad-simple-viewer-example](https://github.com/mlight-lee/cad-simple-viewer-example) it demonstrates how to create one drawing with [**realdwg-web API**](https://mlight-lee.github.io/realdwg-web/).
67
-
68
- ## Layer services
69
-
70
- Layer table mutations are centralized in `AcApLayerService`. UI integrations should use `AcApDocument.layerStore`, which observes that document's layer table and delegates mutations to its layer service.
71
-
72
- ### Turning layers on/off from UI vs CLI
73
-
74
- `AcApLayerService.setLayerOn` accepts `{ switchCurrentLayer?: boolean }`:
75
-
76
- - **CLI commands** leave the default `false`. Batch helpers skip the current layer instead.
77
- - **UI callers** (`AcApLayerStore`, Vue `useLayers`) pass `true` so hiding or freezing the active layer moves `CLAYER` to another visible layer first.
78
-
79
- ### LAYISO `LockAndFade` mode
80
-
81
- The `LockAndFade` isolation keyword matches AutoCAD naming but the viewer **locks** non-isolated layers only. It does not apply a visual fade; users are notified when selecting this mode in the `LAYISO` command.
82
-
83
- ## Web Worker deployment
84
-
85
- The viewer ships an MTEXT layout worker. DXF is parsed by the built-in converter
86
- in `@mlightcad/data-model` (no separate worker). **DWG support is opt-in**: this
87
- package does not depend on or register `@mlightcad/libredwg-converter` (GPL).
88
- Hosts that need DWG must add that dependency (or another converter), deploy its
89
- worker (+ wasm) assets, register the converter, and optionally pass
90
- `webworkerFileUrls.dwgParser` for readiness checks.
91
-
92
- ```typescript
93
- import {
94
- AcApDocManager,
95
- LIBREDWG_PARSER_WORKER_FILE,
96
- MTEXT_RENDERER_WORKER_FILE
97
- } from '@mlightcad/cad-simple-viewer'
98
- import {
99
- AcDbDatabaseConverterManager,
100
- AcDbFileType
101
- } from '@mlightcad/data-model'
102
- import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter'
103
-
104
- const dwgParserUrl = `./workers/${LIBREDWG_PARSER_WORKER_FILE}`
105
- AcDbDatabaseConverterManager.instance.register(
106
- AcDbFileType.DWG,
107
- new AcDbLibreDwgConverter({
108
- convertByEntityType: false,
109
- useWorker: true,
110
- parserWorkerUrl: dwgParserUrl
111
- })
112
- )
113
-
114
- const workerUrls = {
115
- dwgParser: dwgParserUrl,
116
- mtextRender: `./workers/${MTEXT_RENDERER_WORKER_FILE}`
117
- }
118
-
119
- // Option 1: check before creating the manager
120
- const ready = await AcApDocManager.checkWebworkerReadiness(workerUrls)
121
- if (!ready) {
122
- throw new Error('CAD worker scripts are missing or blocked')
123
- }
124
-
125
- const manager = AcApDocManager.createInstance({ webworkerFileUrls: workerUrls })
126
-
127
- // Option 2: check on an existing manager instance
128
- if (!(await manager.areWorkersReady())) {
129
- throw new Error('CAD worker scripts are missing or blocked')
130
- }
131
- ```
132
-
133
- `areWorkersReady()` and `checkWebworkerReadiness()` use HEAD requests internally. Successful URL probes are cached for the current page lifecycle; failures are not cached at the probe layer, so a transient network error can succeed on a later `areWorkersReady()` call. After each check, `manager.workersReady` is `true` or `false` (`null` only before the first check). Only URLs you pass are probed — `dwgParser` is skipped when omitted.
134
-
135
- You can also enable automatic checks during initialization:
136
-
137
- ```typescript
138
- AcApDocManager.createInstance({
139
- webworkerFileUrls: workerUrls,
140
- checkWorkersOnInit: true
141
- })
142
-
143
- manager.events.workersReady.addEventListener(({ ready }) => {
144
- if (!ready) console.error('CAD workers are not reachable')
145
- })
146
- ```
147
-
148
- ## Available Exports
149
-
150
- ### Core Classes
151
-
152
- - `AcApContext` - Main application context
153
- - `AcApDocManager` - Document management
154
- - `AcApDocument` - Individual document handling (includes `layerService` and `layerStore`)
155
- - `AcApSettingManager` - Settings management
156
-
157
- ### Services
158
-
159
- - `AcApLayerService` - Layer table mutations with undo
160
- - `AcApLayerStore` - Cached layer rows and UI-friendly mutations (via `AcApDocument.layerStore`)
161
- - `AcApEntityService` - Entity selection, transform, and edit helpers
162
- - `acapRunServiceEdit` - Undo-wrapped edits outside command transactions
163
-
164
- ### Commands
165
-
166
- - `AcApOpenCmd` - Open file command
167
- - `AcApZoomCmd` - Zoom command
168
- - `AcApPanCmd` - Pan command
169
- - `AcApSelectCmd` - Selection command
170
-
171
- SVG export (`csvg`) is provided by the optional `@mlightcad/cad-svg-plugin` package.
172
-
173
- ### Editor Components
174
-
175
- - `AcEditor` - Main editor class
176
- - `AcEdCommandStack` - Command stack management
177
- - `AcEdSelectionSet` - Selection handling
178
- - `AcEdInputPoint` - Input point management
179
-
180
- ### View Components
181
-
182
- - `AcTrScene` - Scene management
183
- - `AcTrLayoutView` - Layout view handling
184
- - `AcTrView2d` - 2D view management
185
-
186
- ## Role in MLightCAD
187
- This package acts as the core logic layer, connecting the frontend UI with the rendering engines and managing all document-related operations.
188
-
189
- ## License
190
-
1
+ # CAD Simple Viewer
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
4
+ [![npm version](https://img.shields.io/npm/v/@mlightcad/cad-simple-viewer.svg)](https://www.npmjs.com/package/@mlightcad/cad-simple-viewer)
5
+
6
+ This package provides the **high-performance** core components of a CAD viewer such as document management, command handling, and collaboration between the UI and rendering engines. It's designed for optimal performance when handling large CAD files.
7
+
8
+ This module doesn't depend on any UI framework and doesn't provide any UI except canvas. If you want to integrate a high-performance CAD viewer into a web application with your own UI, this module is the correct choice. It fully supports **mobile layout and touch interaction**—responsive chrome for phones and tablets, plus pinch-to-zoom, single-finger pan, and tap-to-select—so hosts can ship a mobile-friendly viewer without a separate mobile stack.
9
+
10
+ ## Key Features
11
+ - Document management optimized for large files
12
+ - Efficient command stack and undo/redo operations
13
+ - Optimized integration with rendering engines
14
+ - Performance-focused settings and context management
15
+ - Framework-agnostic design for maximum flexibility
16
+ - Mobile-ready layout and touch gestures for phones and tablets
17
+
18
+ ## When Should You Choose cad-simple-viewer?
19
+
20
+ Use `cad-simple-viewer` if you need **core CAD logic only** (document management, command stack, rendering engine integration) without any UI framework dependencies. This package is ideal if:
21
+
22
+ - You want to build your **own custom UI** or integrate CAD functionality into a non-Vue or non-web environment.
23
+ - You require maximum flexibility and performance for handling large CAD files, and plan to connect the logic to your own rendering or UI layer.
24
+ - You want a framework-agnostic solution that provides only the essential CAD operations and canvas rendering.
25
+
26
+ **Recommended for:** Custom integrations, headless CAD processing, or advanced users building highly tailored CAD solutions.
27
+
28
+ ## Directory Structure (partial)
29
+ - `src/app/` – Document/context management, settings
30
+ - `src/command/` – Command implementations (open, zoom, select, etc.)
31
+ - `src/editor/` – Command stack, input handling, global functions
32
+ - `src/service/` – Layer/entity services and UI layer store
33
+ - `src/view/` – Layout and scene management
34
+ - `src/util/` – Utilities
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ npm install @mlightcad/cad-simple-viewer
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Please refer to [cad-simple-viewer-example](https://github.com/mlight-lee/cad-simple-viewer-example) on basic usage and advanced usage.
45
+
46
+ To learn about the built-in notification center (and how to replace the default bell UI while still receiving font-missing and unsupported-entity alerts), see [docs/notification-center.md](./docs/notification-center.md).
47
+
48
+ For the plain-DOM toolbar engine (`AcUiToolbar`, shortcut bar, and host customization), see [docs/toolbar.md](./docs/toolbar.md).
49
+
50
+ ### Plugins and data sources
51
+
52
+ - **`pluginManager`** — load command plugins (`AcApPlugin`) via `loadPlugin` / `registerLazyPlugin`.
53
+ - **`dataSourceManager`** — registry of drawing origins (built-in **local** and **URL**, plus optional cloud plugins such as `@mlightcad/cad-onedrive-plugin` and `@mlightcad/cad-google-drive-plugin`). Open menus in hosts rebuild from `acapBuildDataSourceMenu(dataSourceManager.list())`. Cloud sources that use a popup File Picker must keep **Sign in** and **Open** as separate clicks so browsers do not block the picker.
54
+
55
+ While `cad-simple-viewer` doesn't support saving drawings to DWG/DXF files, it provides comprehensive support for **modifying drawings in real-time**. You can add, edit, and delete entities within the drawing, and the viewer will automatically update to reflect these changes.
56
+
57
+ When you modify entities, you're working directly with the underlying drawing database. The viewer automatically detects these changes and updates the display accordingly. This real-time synchronization ensures that:
58
+
59
+ - All modifications are immediately visible
60
+ - The command stack properly tracks changes for undo/redo operations. This will be implemented soon.
61
+
62
+ This capability makes `cad-simple-viewer` suitable for applications that need to not only display CAD files but also allow users to interact with and modify the drawing content.
63
+
64
+ **Important Note**: The usage patterns in `cad-simple-viewer` are **very similar to AutoCAD RealDWG**. If you're familiar with AutoCAD RealDWG development, you'll find the API structure and workflow nearly identical. The main difference is that we use the [**realdwg-web API**](https://mlight-lee.github.io/realdwg-web/) instead of the native RealDWG libraries.
65
+
66
+ In [cad-simple-viewer-example](https://github.com/mlight-lee/cad-simple-viewer-example) it demonstrates how to create one drawing with [**realdwg-web API**](https://mlight-lee.github.io/realdwg-web/).
67
+
68
+ ## Layer services
69
+
70
+ Layer table mutations are centralized in `AcApLayerService`. UI integrations should use `AcApDocument.layerStore`, which observes that document's layer table and delegates mutations to its layer service.
71
+
72
+ ### Turning layers on/off from UI vs CLI
73
+
74
+ `AcApLayerService.setLayerOn` accepts `{ switchCurrentLayer?: boolean }`:
75
+
76
+ - **CLI commands** leave the default `false`. Batch helpers skip the current layer instead.
77
+ - **UI callers** (`AcApLayerStore`, Vue `useLayers`) pass `true` so hiding or freezing the active layer moves `CLAYER` to another visible layer first.
78
+
79
+ ### LAYISO `LockAndFade` mode
80
+
81
+ The `LockAndFade` isolation keyword matches AutoCAD naming but the viewer **locks** non-isolated layers only. It does not apply a visual fade; users are notified when selecting this mode in the `LAYISO` command.
82
+
83
+ ## Web Worker deployment
84
+
85
+ The viewer ships an MTEXT layout worker. DXF is parsed by the built-in converter
86
+ in `@mlightcad/data-model` (no separate worker). **DWG support is opt-in**: this
87
+ package does not depend on or register `@mlightcad/libredwg-converter` (GPL).
88
+ Hosts that need DWG must add that dependency (or another converter), deploy its
89
+ worker (+ wasm) assets, register the converter, and optionally pass
90
+ `webworkerFileUrls.dwgParser` for readiness checks.
91
+
92
+ ```typescript
93
+ import {
94
+ AcApDocManager,
95
+ LIBREDWG_PARSER_WORKER_FILE,
96
+ MTEXT_RENDERER_WORKER_FILE
97
+ } from '@mlightcad/cad-simple-viewer'
98
+ import {
99
+ AcDbDatabaseConverterManager,
100
+ AcDbFileType
101
+ } from '@mlightcad/data-model'
102
+ import { AcDbLibreDwgConverter } from '@mlightcad/libredwg-converter'
103
+
104
+ const dwgParserUrl = `./workers/${LIBREDWG_PARSER_WORKER_FILE}`
105
+ AcDbDatabaseConverterManager.instance.register(
106
+ AcDbFileType.DWG,
107
+ new AcDbLibreDwgConverter({
108
+ convertByEntityType: false,
109
+ useWorker: true,
110
+ parserWorkerUrl: dwgParserUrl
111
+ })
112
+ )
113
+
114
+ const workerUrls = {
115
+ dwgParser: dwgParserUrl,
116
+ mtextRender: `./workers/${MTEXT_RENDERER_WORKER_FILE}`
117
+ }
118
+
119
+ // Option 1: check before creating the manager
120
+ const ready = await AcApDocManager.checkWebworkerReadiness(workerUrls)
121
+ if (!ready) {
122
+ throw new Error('CAD worker scripts are missing or blocked')
123
+ }
124
+
125
+ const manager = AcApDocManager.createInstance({ webworkerFileUrls: workerUrls })
126
+
127
+ // Option 2: check on an existing manager instance
128
+ if (!(await manager.areWorkersReady())) {
129
+ throw new Error('CAD worker scripts are missing or blocked')
130
+ }
131
+ ```
132
+
133
+ `areWorkersReady()` and `checkWebworkerReadiness()` use HEAD requests internally. Successful URL probes are cached for the current page lifecycle; failures are not cached at the probe layer, so a transient network error can succeed on a later `areWorkersReady()` call. After each check, `manager.workersReady` is `true` or `false` (`null` only before the first check). Only URLs you pass are probed — `dwgParser` is skipped when omitted.
134
+
135
+ You can also enable automatic checks during initialization:
136
+
137
+ ```typescript
138
+ AcApDocManager.createInstance({
139
+ webworkerFileUrls: workerUrls,
140
+ checkWorkersOnInit: true
141
+ })
142
+
143
+ manager.events.workersReady.addEventListener(({ ready }) => {
144
+ if (!ready) console.error('CAD workers are not reachable')
145
+ })
146
+ ```
147
+
148
+ ## Available Exports
149
+
150
+ ### Core Classes
151
+
152
+ - `AcApContext` - Main application context
153
+ - `AcApDocManager` - Document management
154
+ - `AcApDocument` - Individual document handling (includes `layerService` and `layerStore`)
155
+ - `AcApSettingManager` - Settings management
156
+
157
+ ### Services
158
+
159
+ - `AcApLayerService` - Layer table mutations with undo
160
+ - `AcApLayerStore` - Cached layer rows and UI-friendly mutations (via `AcApDocument.layerStore`)
161
+ - `AcApEntityService` - Entity selection, transform, and edit helpers
162
+ - `acapRunServiceEdit` - Undo-wrapped edits outside command transactions
163
+
164
+ ### Commands
165
+
166
+ - `AcApOpenCmd` - Open file command
167
+ - `AcApZoomCmd` - Zoom command
168
+ - `AcApPanCmd` - Pan command
169
+ - `AcApSelectCmd` - Selection command
170
+
171
+ SVG export (`csvg`) is provided by the optional `@mlightcad/cad-svg-plugin` package.
172
+
173
+ ### Editor Components
174
+
175
+ - `AcEditor` - Main editor class
176
+ - `AcEdCommandStack` - Command stack management
177
+ - `AcEdSelectionSet` - Selection handling
178
+ - `AcEdInputPoint` - Input point management
179
+
180
+ ### View Components
181
+
182
+ - `AcTrScene` - Scene management
183
+ - `AcTrLayoutView` - Layout view handling
184
+ - `AcTrView2d` - 2D view management
185
+
186
+ ## Role in MLightCAD
187
+ This package acts as the core logic layer, connecting the frontend UI with the rendering engines and managing all document-related operations.
188
+
189
+ ## License
190
+
191
191
  MIT