@mlightcad/cad-simple-viewer 1.4.7 → 1.4.8

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 (177) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +88 -88
  3. package/dist/index.js +6014 -5042
  4. package/dist/index.umd.cjs +22 -22
  5. package/lib/app/AcApAnnotation.d.ts +46 -0
  6. package/lib/app/AcApAnnotation.d.ts.map +1 -0
  7. package/lib/app/AcApAnnotation.js +134 -0
  8. package/lib/app/AcApAnnotation.js.map +1 -0
  9. package/lib/app/AcApDocManager.d.ts +118 -6
  10. package/lib/app/AcApDocManager.d.ts.map +1 -1
  11. package/lib/app/AcApDocManager.js +162 -6
  12. package/lib/app/AcApDocManager.js.map +1 -1
  13. package/lib/app/AcApDocument.d.ts +16 -14
  14. package/lib/app/AcApDocument.d.ts.map +1 -1
  15. package/lib/app/AcApDocument.js +48 -31
  16. package/lib/app/AcApDocument.js.map +1 -1
  17. package/lib/app/AcDbOpenDatabaseOptions.d.ts +28 -0
  18. package/lib/app/AcDbOpenDatabaseOptions.d.ts.map +1 -0
  19. package/lib/app/AcDbOpenDatabaseOptions.js +2 -0
  20. package/lib/app/AcDbOpenDatabaseOptions.js.map +1 -0
  21. package/lib/app/index.d.ts +2 -0
  22. package/lib/app/index.d.ts.map +1 -1
  23. package/lib/app/index.js +2 -0
  24. package/lib/app/index.js.map +1 -1
  25. package/lib/command/AcApBaseRevCmd.d.ts +36 -0
  26. package/lib/command/AcApBaseRevCmd.d.ts.map +1 -0
  27. package/lib/command/AcApBaseRevCmd.js +68 -0
  28. package/lib/command/AcApBaseRevCmd.js.map +1 -0
  29. package/lib/command/AcApCircleCmd.d.ts +1 -0
  30. package/lib/command/AcApCircleCmd.d.ts.map +1 -1
  31. package/lib/command/AcApCircleCmd.js +4 -2
  32. package/lib/command/AcApCircleCmd.js.map +1 -1
  33. package/lib/command/AcApConvertToSvgCmd.d.ts +1 -1
  34. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
  35. package/lib/command/AcApConvertToSvgCmd.js +44 -2
  36. package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
  37. package/lib/command/AcApDimLinearCmd.d.ts +1 -0
  38. package/lib/command/AcApDimLinearCmd.d.ts.map +1 -1
  39. package/lib/command/AcApDimLinearCmd.js +4 -2
  40. package/lib/command/AcApDimLinearCmd.js.map +1 -1
  41. package/lib/command/AcApEraseCmd.d.ts +1 -0
  42. package/lib/command/AcApEraseCmd.d.ts.map +1 -1
  43. package/lib/command/AcApEraseCmd.js +14 -4
  44. package/lib/command/AcApEraseCmd.js.map +1 -1
  45. package/lib/command/AcApLineCmd.d.ts +1 -0
  46. package/lib/command/AcApLineCmd.d.ts.map +1 -1
  47. package/lib/command/AcApLineCmd.js +4 -2
  48. package/lib/command/AcApLineCmd.js.map +1 -1
  49. package/lib/command/AcApLogCmd.d.ts +1 -1
  50. package/lib/command/AcApLogCmd.d.ts.map +1 -1
  51. package/lib/command/AcApLogCmd.js +44 -3
  52. package/lib/command/AcApLogCmd.js.map +1 -1
  53. package/lib/command/AcApOpenCmd.d.ts +1 -1
  54. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  55. package/lib/command/AcApOpenCmd.js +42 -1
  56. package/lib/command/AcApOpenCmd.js.map +1 -1
  57. package/lib/command/AcApPanCmd.d.ts +1 -1
  58. package/lib/command/AcApPanCmd.d.ts.map +1 -1
  59. package/lib/command/AcApPanCmd.js +43 -2
  60. package/lib/command/AcApPanCmd.js.map +1 -1
  61. package/lib/command/AcApQNewCmd.d.ts +1 -1
  62. package/lib/command/AcApQNewCmd.d.ts.map +1 -1
  63. package/lib/command/AcApQNewCmd.js +44 -2
  64. package/lib/command/AcApQNewCmd.js.map +1 -1
  65. package/lib/command/AcApRectCmd.d.ts +23 -0
  66. package/lib/command/AcApRectCmd.d.ts.map +1 -0
  67. package/lib/command/AcApRectCmd.js +134 -0
  68. package/lib/command/AcApRectCmd.js.map +1 -0
  69. package/lib/command/AcApRegenCmd.d.ts +1 -1
  70. package/lib/command/AcApRegenCmd.d.ts.map +1 -1
  71. package/lib/command/AcApRegenCmd.js +42 -1
  72. package/lib/command/AcApRegenCmd.js.map +1 -1
  73. package/lib/command/AcApRevCircleCmd.d.ts +10 -0
  74. package/lib/command/AcApRevCircleCmd.d.ts.map +1 -0
  75. package/lib/command/AcApRevCircleCmd.js +83 -0
  76. package/lib/command/AcApRevCircleCmd.js.map +1 -0
  77. package/lib/command/AcApRevCloudCmd.d.ts +26 -0
  78. package/lib/command/AcApRevCloudCmd.d.ts.map +1 -0
  79. package/lib/command/AcApRevCloudCmd.js +234 -0
  80. package/lib/command/AcApRevCloudCmd.js.map +1 -0
  81. package/lib/command/AcApRevRectCmd.d.ts +10 -0
  82. package/lib/command/AcApRevRectCmd.d.ts.map +1 -0
  83. package/lib/command/AcApRevRectCmd.js +83 -0
  84. package/lib/command/AcApRevRectCmd.js.map +1 -0
  85. package/lib/command/AcApRevVisibilityCmd.d.ts +15 -0
  86. package/lib/command/AcApRevVisibilityCmd.d.ts.map +1 -0
  87. package/lib/command/AcApRevVisibilityCmd.js +90 -0
  88. package/lib/command/AcApRevVisibilityCmd.js.map +1 -0
  89. package/lib/command/AcApSelectCmd.d.ts +1 -1
  90. package/lib/command/AcApSelectCmd.d.ts.map +1 -1
  91. package/lib/command/AcApSelectCmd.js +43 -2
  92. package/lib/command/AcApSelectCmd.js.map +1 -1
  93. package/lib/command/AcApSketchCmd.d.ts +32 -0
  94. package/lib/command/AcApSketchCmd.d.ts.map +1 -0
  95. package/lib/command/AcApSketchCmd.js +171 -0
  96. package/lib/command/AcApSketchCmd.js.map +1 -0
  97. package/lib/command/AcApSwitchBgCmd.d.ts +15 -0
  98. package/lib/command/AcApSwitchBgCmd.d.ts.map +1 -0
  99. package/lib/command/AcApSwitchBgCmd.js +88 -0
  100. package/lib/command/AcApSwitchBgCmd.js.map +1 -0
  101. package/lib/command/AcApSysVarCmd.d.ts +2 -1
  102. package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
  103. package/lib/command/AcApSysVarCmd.js +6 -5
  104. package/lib/command/AcApSysVarCmd.js.map +1 -1
  105. package/lib/command/AcApZoomCmd.d.ts +1 -1
  106. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  107. package/lib/command/AcApZoomCmd.js +42 -1
  108. package/lib/command/AcApZoomCmd.js.map +1 -1
  109. package/lib/command/index.d.ts +8 -0
  110. package/lib/command/index.d.ts.map +1 -1
  111. package/lib/command/index.js +8 -0
  112. package/lib/command/index.js.map +1 -1
  113. package/lib/editor/command/AcEdCommand.d.ts +81 -22
  114. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  115. package/lib/editor/command/AcEdCommand.js +157 -15
  116. package/lib/editor/command/AcEdCommand.js.map +1 -1
  117. package/lib/editor/command/AcEdCommandIterator.d.ts +1 -1
  118. package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -1
  119. package/lib/editor/command/AcEdCommandStack.d.ts +31 -6
  120. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  121. package/lib/editor/command/AcEdCommandStack.js +55 -11
  122. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  123. package/lib/editor/input/AcEditor.d.ts +14 -0
  124. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  125. package/lib/editor/input/AcEditor.js +5 -1
  126. package/lib/editor/input/AcEditor.js.map +1 -1
  127. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  128. package/lib/editor/input/ui/AcEdCommandLine.js +2 -2
  129. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  130. package/lib/editor/view/AcEdOpenMode.d.ts +26 -0
  131. package/lib/editor/view/AcEdOpenMode.d.ts.map +1 -0
  132. package/lib/editor/view/AcEdOpenMode.js +27 -0
  133. package/lib/editor/view/AcEdOpenMode.js.map +1 -0
  134. package/lib/editor/view/index.d.ts +2 -0
  135. package/lib/editor/view/index.d.ts.map +1 -1
  136. package/lib/editor/view/index.js +2 -0
  137. package/lib/editor/view/index.js.map +1 -1
  138. package/lib/i18n/en/command.d.ts +18 -0
  139. package/lib/i18n/en/command.d.ts.map +1 -1
  140. package/lib/i18n/en/command.js +19 -1
  141. package/lib/i18n/en/command.js.map +1 -1
  142. package/lib/i18n/en/jig.d.ts +8 -0
  143. package/lib/i18n/en/jig.d.ts.map +1 -1
  144. package/lib/i18n/en/jig.js +8 -0
  145. package/lib/i18n/en/jig.js.map +1 -1
  146. package/lib/i18n/zh/command.d.ts +18 -0
  147. package/lib/i18n/zh/command.d.ts.map +1 -1
  148. package/lib/i18n/zh/command.js +18 -0
  149. package/lib/i18n/zh/command.js.map +1 -1
  150. package/lib/i18n/zh/jig.d.ts +8 -0
  151. package/lib/i18n/zh/jig.d.ts.map +1 -1
  152. package/lib/i18n/zh/jig.js +8 -0
  153. package/lib/i18n/zh/jig.js.map +1 -1
  154. package/lib/index.d.ts +1 -0
  155. package/lib/index.d.ts.map +1 -1
  156. package/lib/index.js +1 -0
  157. package/lib/index.js.map +1 -1
  158. package/lib/plugin/AcApPlugin.d.ts +83 -0
  159. package/lib/plugin/AcApPlugin.d.ts.map +1 -0
  160. package/lib/plugin/AcApPlugin.js +2 -0
  161. package/lib/plugin/AcApPlugin.js.map +1 -0
  162. package/lib/plugin/AcApPluginExample.d.ts +23 -0
  163. package/lib/plugin/AcApPluginExample.d.ts.map +1 -0
  164. package/lib/plugin/AcApPluginExample.js +160 -0
  165. package/lib/plugin/AcApPluginExample.js.map +1 -0
  166. package/lib/plugin/AcApPluginManager.d.ts +206 -0
  167. package/lib/plugin/AcApPluginManager.d.ts.map +1 -0
  168. package/lib/plugin/AcApPluginManager.js +499 -0
  169. package/lib/plugin/AcApPluginManager.js.map +1 -0
  170. package/lib/plugin/index.d.ts +4 -0
  171. package/lib/plugin/index.d.ts.map +1 -0
  172. package/lib/plugin/index.js +4 -0
  173. package/lib/plugin/index.js.map +1 -0
  174. package/lib/view/AcTrView2d.d.ts.map +1 -1
  175. package/lib/view/AcTrView2d.js +8 -1
  176. package/lib/view/AcTrView2d.js.map +1 -1
  177. package/package.json +5 -5
@@ -0,0 +1,206 @@
1
+ import { AcApContext } from '../app/AcApContext';
2
+ import { AcEdCommandStack } from '../editor/command/AcEdCommandStack';
3
+ import { AcApPlugin } from './AcApPlugin';
4
+ /**
5
+ * Plugin manager for dynamically loading and unloading plugins.
6
+ *
7
+ * This class manages the lifecycle of plugins, including:
8
+ * - Loading plugins and calling their `onLoad` hooks
9
+ * - Unloading plugins and calling their `onUnload` hooks
10
+ * - Providing access to the application context and command manager
11
+ *
12
+ * Plugins are responsible for cleaning up their own registered commands
13
+ * in the `onUnload` hook using `commandManager.removeCmd()`.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const pluginManager = AcApDocManager.instance.pluginManager;
18
+ *
19
+ * // Load a plugin
20
+ * const myPlugin = new MyPlugin();
21
+ * await pluginManager.loadPlugin(myPlugin);
22
+ *
23
+ * // Unload a plugin
24
+ * await pluginManager.unloadPlugin('MyPlugin');
25
+ *
26
+ * // Check if a plugin is loaded
27
+ * if (pluginManager.isPluginLoaded('MyPlugin')) {
28
+ * console.log('Plugin is loaded');
29
+ * }
30
+ *
31
+ * // Get all loaded plugins
32
+ * const loadedPlugins = pluginManager.getLoadedPlugins();
33
+ * ```
34
+ */
35
+ export declare class AcApPluginManager {
36
+ /** Map of loaded plugins by name */
37
+ private _plugins;
38
+ /** The application context */
39
+ private _context;
40
+ /** The command manager */
41
+ private _commandManager;
42
+ /**
43
+ * Creates a new plugin manager.
44
+ *
45
+ * @param context - The application context
46
+ * @param commandManager - The command manager for plugin command registration
47
+ */
48
+ constructor(context: AcApContext, commandManager: AcEdCommandStack);
49
+ /**
50
+ * Loads a plugin and calls its `onLoad` hook.
51
+ *
52
+ * If the plugin is already loaded, this method will throw an error.
53
+ * The plugin's `onLoad` method will be called with the context and command manager.
54
+ *
55
+ * @param plugin - The plugin instance to load
56
+ * @throws {Error} If a plugin with the same name is already loaded
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const plugin = new MyPlugin();
61
+ * await pluginManager.loadPlugin(plugin);
62
+ * ```
63
+ */
64
+ loadPlugin(plugin: AcApPlugin): Promise<void>;
65
+ /**
66
+ * Unloads a plugin and calls its `onUnload` hook.
67
+ *
68
+ * This method will:
69
+ * 1. Call the plugin's `onUnload` hook (plugins should clean up their commands here)
70
+ * 2. Remove the plugin from the loaded plugins map
71
+ *
72
+ * @param pluginName - The name of the plugin to unload
73
+ * @returns `true` if the plugin was successfully unloaded, `false` if it wasn't loaded
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * const success = await pluginManager.unloadPlugin('MyPlugin');
78
+ * if (success) {
79
+ * console.log('Plugin unloaded successfully');
80
+ * }
81
+ * ```
82
+ */
83
+ unloadPlugin(pluginName: string): Promise<boolean>;
84
+ /**
85
+ * Checks if a plugin is currently loaded.
86
+ *
87
+ * @param pluginName - The name of the plugin to check
88
+ * @returns `true` if the plugin is loaded, `false` otherwise
89
+ */
90
+ isPluginLoaded(pluginName: string): boolean;
91
+ /**
92
+ * Gets information about a loaded plugin.
93
+ *
94
+ * @param pluginName - The name of the plugin
95
+ * @returns The plugin instance if loaded, `undefined` otherwise
96
+ */
97
+ getPlugin(pluginName: string): AcApPlugin | undefined;
98
+ /**
99
+ * Gets all currently loaded plugins.
100
+ *
101
+ * @returns Array of loaded plugin names
102
+ */
103
+ getLoadedPlugins(): string[];
104
+ /**
105
+ * Unloads all currently loaded plugins.
106
+ *
107
+ * This method calls `unloadPlugin` for each loaded plugin.
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * await pluginManager.unloadAllPlugins();
112
+ * ```
113
+ */
114
+ unloadAllPlugins(): Promise<void>;
115
+ /**
116
+ * Loads multiple plugins from a configuration array.
117
+ *
118
+ * This method accepts an array of plugin instances or plugin factory functions.
119
+ * Factory functions are useful when you want to create plugin instances lazily.
120
+ *
121
+ * @param plugins - Array of plugin instances or factory functions that return plugin instances
122
+ * @param options - Optional configuration for loading behavior
123
+ * @param options.continueOnError - If true, continue loading other plugins even if one fails (default: false)
124
+ * @returns Promise that resolves to an object containing successful and failed plugin loads
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Load plugins from instances
129
+ * await pluginManager.loadPluginsFromConfig([
130
+ * new MyPlugin1(),
131
+ * new MyPlugin2()
132
+ * ]);
133
+ *
134
+ * // Load plugins from factory functions
135
+ * await pluginManager.loadPluginsFromConfig([
136
+ * () => new MyPlugin1(),
137
+ * () => new MyPlugin2()
138
+ * ]);
139
+ *
140
+ * // Continue loading even if some fail
141
+ * const result = await pluginManager.loadPluginsFromConfig(
142
+ * [new Plugin1(), new Plugin2()],
143
+ * { continueOnError: true }
144
+ * );
145
+ * console.log('Loaded:', result.loaded);
146
+ * console.log('Failed:', result.failed);
147
+ * ```
148
+ */
149
+ loadPluginsFromConfig(plugins: Array<AcApPlugin | (() => AcApPlugin)>, options?: {
150
+ continueOnError?: boolean;
151
+ }): Promise<{
152
+ loaded: string[];
153
+ failed: Array<{
154
+ name: string;
155
+ error: Error;
156
+ }>;
157
+ }>;
158
+ /**
159
+ * Loads plugins from a folder using dynamic imports.
160
+ *
161
+ * This method scans a folder for plugin files and dynamically imports them.
162
+ * It expects each plugin file to export a default export that is either:
163
+ * - A plugin instance
164
+ * - A plugin class (constructor function)
165
+ * - A factory function that returns a plugin instance
166
+ *
167
+ * @param folderPath - Path to the folder containing plugin files (relative to the base URL)
168
+ * @param options - Optional configuration for loading behavior
169
+ * @param options.pattern - Glob pattern to match plugin files (default: '*.js' or '*.ts')
170
+ * @param options.continueOnError - If true, continue loading other plugins even if one fails (default: false)
171
+ * @param options.pluginList - Optional array of specific plugin file names to load (if not provided, attempts to auto-discover)
172
+ * @returns Promise that resolves to an object containing successful and failed plugin loads
173
+ *
174
+ * @example
175
+ * ```typescript
176
+ * // Load all plugins from a folder (requires plugin list or manifest)
177
+ * await pluginManager.loadPluginsFromFolder('./plugins', {
178
+ * pluginList: ['MyPlugin1.js', 'MyPlugin2.js']
179
+ * });
180
+ *
181
+ * // Or with continue on error
182
+ * const result = await pluginManager.loadPluginsFromFolder('./plugins', {
183
+ * pluginList: ['Plugin1.js', 'Plugin2.js'],
184
+ * continueOnError: true
185
+ * });
186
+ * ```
187
+ *
188
+ * @remarks
189
+ * In browser environments, you typically need to provide a list of plugin files
190
+ * to load, as there's no direct way to list directory contents. You can:
191
+ * 1. Provide a `pluginList` array with specific file names
192
+ * 2. Create a manifest file that lists all plugins
193
+ * 3. Use a build-time tool to generate the plugin list
194
+ */
195
+ loadPluginsFromFolder(folderPath: string, options?: {
196
+ pluginList?: string[];
197
+ continueOnError?: boolean;
198
+ }): Promise<{
199
+ loaded: string[];
200
+ failed: Array<{
201
+ name: string;
202
+ error: Error;
203
+ }>;
204
+ }>;
205
+ }
206
+ //# sourceMappingURL=AcApPluginManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPluginManager.d.ts","sourceRoot":"","sources":["../../src/plugin/AcApPluginManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,iBAAiB;IAC5B,oCAAoC;IACpC,OAAO,CAAC,QAAQ,CAAyB;IACzC,8BAA8B;IAC9B,OAAO,CAAC,QAAQ,CAAa;IAC7B,0BAA0B;IAC1B,OAAO,CAAC,eAAe,CAAkB;IAEzC;;;;;OAKG;gBACS,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,gBAAgB;IAMlE;;;;;;;;;;;;;;OAcG;IACG,UAAU,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BnD;;;;;;;;;;;;;;;;;OAiBG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAuBxD;;;;;OAKG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAI3C;;;;;OAKG;IACH,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIrD;;;;OAIG;IACH,gBAAgB,IAAI,MAAM,EAAE;IAI5B;;;;;;;;;OASG;IACG,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;IAOvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiCG;IACG,qBAAqB,CACzB,OAAO,EAAE,KAAK,CAAC,UAAU,GAAG,CAAC,MAAM,UAAU,CAAC,CAAC,EAC/C,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAA;KAAE,GACtC,OAAO,CAAC;QACT,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,MAAM,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,KAAK,CAAA;SAAE,CAAC,CAAA;KAC9C,CAAC;IAiCF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACG,qBAAqB,CACzB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,eAAe,CAAC,EAAE,OAAO,CAAA;KAC1B,GACA,OAAO,CAAC;QACT,MAAM,EAAE,MAAM,EAAE,CAAA;QAChB,MAAM,EAAE,KAAK,CAAC;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,KAAK,EAAE,KAAK,CAAA;SAAE,CAAC,CAAA;KAC9C,CAAC;CA0FH"}