@mlightcad/cad-simple-viewer 1.4.7 → 1.4.9

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 (200) hide show
  1. package/dist/index.js +7749 -6724
  2. package/dist/index.umd.cjs +23 -23
  3. package/lib/app/AcApAnnotation.d.ts +46 -0
  4. package/lib/app/AcApAnnotation.d.ts.map +1 -0
  5. package/lib/app/AcApAnnotation.js +134 -0
  6. package/lib/app/AcApAnnotation.js.map +1 -0
  7. package/lib/app/AcApDocManager.d.ts +118 -6
  8. package/lib/app/AcApDocManager.d.ts.map +1 -1
  9. package/lib/app/AcApDocManager.js +163 -7
  10. package/lib/app/AcApDocManager.js.map +1 -1
  11. package/lib/app/AcApDocument.d.ts +16 -14
  12. package/lib/app/AcApDocument.d.ts.map +1 -1
  13. package/lib/app/AcApDocument.js +48 -31
  14. package/lib/app/AcApDocument.js.map +1 -1
  15. package/lib/app/AcApProgress.d.ts +8 -2
  16. package/lib/app/AcApProgress.d.ts.map +1 -1
  17. package/lib/app/AcApProgress.js +13 -7
  18. package/lib/app/AcApProgress.js.map +1 -1
  19. package/lib/app/AcDbOpenDatabaseOptions.d.ts +28 -0
  20. package/lib/app/AcDbOpenDatabaseOptions.d.ts.map +1 -0
  21. package/lib/app/AcDbOpenDatabaseOptions.js +2 -0
  22. package/lib/app/AcDbOpenDatabaseOptions.js.map +1 -0
  23. package/lib/app/index.d.ts +2 -0
  24. package/lib/app/index.d.ts.map +1 -1
  25. package/lib/app/index.js +2 -0
  26. package/lib/app/index.js.map +1 -1
  27. package/lib/command/AcApBaseRevCmd.d.ts +36 -0
  28. package/lib/command/AcApBaseRevCmd.d.ts.map +1 -0
  29. package/lib/command/AcApBaseRevCmd.js +68 -0
  30. package/lib/command/AcApBaseRevCmd.js.map +1 -0
  31. package/lib/command/AcApCircleCmd.d.ts +1 -0
  32. package/lib/command/AcApCircleCmd.d.ts.map +1 -1
  33. package/lib/command/AcApCircleCmd.js +4 -2
  34. package/lib/command/AcApCircleCmd.js.map +1 -1
  35. package/lib/command/AcApConvertToSvgCmd.d.ts +1 -1
  36. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -1
  37. package/lib/command/AcApConvertToSvgCmd.js +44 -2
  38. package/lib/command/AcApConvertToSvgCmd.js.map +1 -1
  39. package/lib/command/AcApDimLinearCmd.d.ts +1 -0
  40. package/lib/command/AcApDimLinearCmd.d.ts.map +1 -1
  41. package/lib/command/AcApDimLinearCmd.js +4 -2
  42. package/lib/command/AcApDimLinearCmd.js.map +1 -1
  43. package/lib/command/AcApEraseCmd.d.ts +1 -0
  44. package/lib/command/AcApEraseCmd.d.ts.map +1 -1
  45. package/lib/command/AcApEraseCmd.js +14 -4
  46. package/lib/command/AcApEraseCmd.js.map +1 -1
  47. package/lib/command/AcApLineCmd.d.ts +1 -0
  48. package/lib/command/AcApLineCmd.d.ts.map +1 -1
  49. package/lib/command/AcApLineCmd.js +4 -2
  50. package/lib/command/AcApLineCmd.js.map +1 -1
  51. package/lib/command/AcApLogCmd.d.ts +1 -1
  52. package/lib/command/AcApLogCmd.d.ts.map +1 -1
  53. package/lib/command/AcApLogCmd.js +44 -3
  54. package/lib/command/AcApLogCmd.js.map +1 -1
  55. package/lib/command/AcApOpenCmd.d.ts +1 -1
  56. package/lib/command/AcApOpenCmd.d.ts.map +1 -1
  57. package/lib/command/AcApOpenCmd.js +42 -1
  58. package/lib/command/AcApOpenCmd.js.map +1 -1
  59. package/lib/command/AcApPanCmd.d.ts +1 -1
  60. package/lib/command/AcApPanCmd.d.ts.map +1 -1
  61. package/lib/command/AcApPanCmd.js +43 -2
  62. package/lib/command/AcApPanCmd.js.map +1 -1
  63. package/lib/command/AcApQNewCmd.d.ts +1 -1
  64. package/lib/command/AcApQNewCmd.d.ts.map +1 -1
  65. package/lib/command/AcApQNewCmd.js +44 -2
  66. package/lib/command/AcApQNewCmd.js.map +1 -1
  67. package/lib/command/AcApRectCmd.d.ts +23 -0
  68. package/lib/command/AcApRectCmd.d.ts.map +1 -0
  69. package/lib/command/AcApRectCmd.js +134 -0
  70. package/lib/command/AcApRectCmd.js.map +1 -0
  71. package/lib/command/AcApRegenCmd.d.ts +1 -1
  72. package/lib/command/AcApRegenCmd.d.ts.map +1 -1
  73. package/lib/command/AcApRegenCmd.js +42 -1
  74. package/lib/command/AcApRegenCmd.js.map +1 -1
  75. package/lib/command/AcApRevCircleCmd.d.ts +10 -0
  76. package/lib/command/AcApRevCircleCmd.d.ts.map +1 -0
  77. package/lib/command/AcApRevCircleCmd.js +83 -0
  78. package/lib/command/AcApRevCircleCmd.js.map +1 -0
  79. package/lib/command/AcApRevCloudCmd.d.ts +26 -0
  80. package/lib/command/AcApRevCloudCmd.d.ts.map +1 -0
  81. package/lib/command/AcApRevCloudCmd.js +234 -0
  82. package/lib/command/AcApRevCloudCmd.js.map +1 -0
  83. package/lib/command/AcApRevRectCmd.d.ts +10 -0
  84. package/lib/command/AcApRevRectCmd.d.ts.map +1 -0
  85. package/lib/command/AcApRevRectCmd.js +83 -0
  86. package/lib/command/AcApRevRectCmd.js.map +1 -0
  87. package/lib/command/AcApRevVisibilityCmd.d.ts +15 -0
  88. package/lib/command/AcApRevVisibilityCmd.d.ts.map +1 -0
  89. package/lib/command/AcApRevVisibilityCmd.js +90 -0
  90. package/lib/command/AcApRevVisibilityCmd.js.map +1 -0
  91. package/lib/command/AcApSelectCmd.d.ts +1 -1
  92. package/lib/command/AcApSelectCmd.d.ts.map +1 -1
  93. package/lib/command/AcApSelectCmd.js +43 -2
  94. package/lib/command/AcApSelectCmd.js.map +1 -1
  95. package/lib/command/AcApSketchCmd.d.ts +32 -0
  96. package/lib/command/AcApSketchCmd.d.ts.map +1 -0
  97. package/lib/command/AcApSketchCmd.js +171 -0
  98. package/lib/command/AcApSketchCmd.js.map +1 -0
  99. package/lib/command/AcApSwitchBgCmd.d.ts +14 -0
  100. package/lib/command/AcApSwitchBgCmd.d.ts.map +1 -0
  101. package/lib/command/AcApSwitchBgCmd.js +86 -0
  102. package/lib/command/AcApSwitchBgCmd.js.map +1 -0
  103. package/lib/command/AcApSysVarCmd.d.ts +2 -1
  104. package/lib/command/AcApSysVarCmd.d.ts.map +1 -1
  105. package/lib/command/AcApSysVarCmd.js +6 -5
  106. package/lib/command/AcApSysVarCmd.js.map +1 -1
  107. package/lib/command/AcApZoomCmd.d.ts +1 -1
  108. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  109. package/lib/command/AcApZoomCmd.js +42 -1
  110. package/lib/command/AcApZoomCmd.js.map +1 -1
  111. package/lib/command/index.d.ts +8 -0
  112. package/lib/command/index.d.ts.map +1 -1
  113. package/lib/command/index.js +8 -0
  114. package/lib/command/index.js.map +1 -1
  115. package/lib/editor/command/AcEdCommand.d.ts +81 -22
  116. package/lib/editor/command/AcEdCommand.d.ts.map +1 -1
  117. package/lib/editor/command/AcEdCommand.js +157 -15
  118. package/lib/editor/command/AcEdCommand.js.map +1 -1
  119. package/lib/editor/command/AcEdCommandIterator.d.ts +1 -1
  120. package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -1
  121. package/lib/editor/command/AcEdCommandStack.d.ts +31 -6
  122. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  123. package/lib/editor/command/AcEdCommandStack.js +55 -11
  124. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  125. package/lib/editor/input/AcEditor.d.ts +14 -0
  126. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  127. package/lib/editor/input/AcEditor.js +5 -1
  128. package/lib/editor/input/AcEditor.js.map +1 -1
  129. package/lib/editor/input/marker/AcEdMarker.d.ts +4 -1
  130. package/lib/editor/input/marker/AcEdMarker.d.ts.map +1 -1
  131. package/lib/editor/input/marker/AcEdMarker.js +11 -3
  132. package/lib/editor/input/marker/AcEdMarker.js.map +1 -1
  133. package/lib/editor/input/marker/AcEdOSnapMarkerManager.d.ts.map +1 -1
  134. package/lib/editor/input/marker/AcEdOSnapMarkerManager.js +6 -3
  135. package/lib/editor/input/marker/AcEdOSnapMarkerManager.js.map +1 -1
  136. package/lib/editor/input/ui/AcEdCommandLine.d.ts +2 -0
  137. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  138. package/lib/editor/input/ui/AcEdCommandLine.js +22 -5
  139. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  140. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +2 -1
  141. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -1
  142. package/lib/editor/input/ui/AcEdFloatingMessage.d.ts +6 -4
  143. package/lib/editor/input/ui/AcEdFloatingMessage.d.ts.map +1 -1
  144. package/lib/editor/input/ui/AcEdFloatingMessage.js +19 -13
  145. package/lib/editor/input/ui/AcEdFloatingMessage.js.map +1 -1
  146. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  147. package/lib/editor/input/ui/AcEdInputManager.js +14 -7
  148. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  149. package/lib/editor/view/AcEdBaseView.d.ts +30 -2
  150. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  151. package/lib/editor/view/AcEdBaseView.js +42 -6
  152. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  153. package/lib/editor/view/AcEdOpenMode.d.ts +26 -0
  154. package/lib/editor/view/AcEdOpenMode.d.ts.map +1 -0
  155. package/lib/editor/view/AcEdOpenMode.js +27 -0
  156. package/lib/editor/view/AcEdOpenMode.js.map +1 -0
  157. package/lib/editor/view/index.d.ts +2 -0
  158. package/lib/editor/view/index.d.ts.map +1 -1
  159. package/lib/editor/view/index.js +2 -0
  160. package/lib/editor/view/index.js.map +1 -1
  161. package/lib/i18n/en/command.d.ts +18 -0
  162. package/lib/i18n/en/command.d.ts.map +1 -1
  163. package/lib/i18n/en/command.js +19 -1
  164. package/lib/i18n/en/command.js.map +1 -1
  165. package/lib/i18n/en/jig.d.ts +8 -0
  166. package/lib/i18n/en/jig.d.ts.map +1 -1
  167. package/lib/i18n/en/jig.js +8 -0
  168. package/lib/i18n/en/jig.js.map +1 -1
  169. package/lib/i18n/zh/command.d.ts +18 -0
  170. package/lib/i18n/zh/command.d.ts.map +1 -1
  171. package/lib/i18n/zh/command.js +18 -0
  172. package/lib/i18n/zh/command.js.map +1 -1
  173. package/lib/i18n/zh/jig.d.ts +8 -0
  174. package/lib/i18n/zh/jig.d.ts.map +1 -1
  175. package/lib/i18n/zh/jig.js +8 -0
  176. package/lib/i18n/zh/jig.js.map +1 -1
  177. package/lib/index.d.ts +1 -0
  178. package/lib/index.d.ts.map +1 -1
  179. package/lib/index.js +1 -0
  180. package/lib/index.js.map +1 -1
  181. package/lib/plugin/AcApPlugin.d.ts +83 -0
  182. package/lib/plugin/AcApPlugin.d.ts.map +1 -0
  183. package/lib/plugin/AcApPlugin.js +2 -0
  184. package/lib/plugin/AcApPlugin.js.map +1 -0
  185. package/lib/plugin/AcApPluginExample.d.ts +23 -0
  186. package/lib/plugin/AcApPluginExample.d.ts.map +1 -0
  187. package/lib/plugin/AcApPluginExample.js +160 -0
  188. package/lib/plugin/AcApPluginExample.js.map +1 -0
  189. package/lib/plugin/AcApPluginManager.d.ts +206 -0
  190. package/lib/plugin/AcApPluginManager.d.ts.map +1 -0
  191. package/lib/plugin/AcApPluginManager.js +499 -0
  192. package/lib/plugin/AcApPluginManager.js.map +1 -0
  193. package/lib/plugin/index.d.ts +4 -0
  194. package/lib/plugin/index.d.ts.map +1 -0
  195. package/lib/plugin/index.js +4 -0
  196. package/lib/plugin/index.js.map +1 -0
  197. package/lib/view/AcTrView2d.d.ts.map +1 -1
  198. package/lib/view/AcTrView2d.js +8 -1
  199. package/lib/view/AcTrView2d.js.map +1 -1
  200. package/package.json +5 -5
@@ -0,0 +1,160 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
17
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
18
+ return new (P || (P = Promise))(function (resolve, reject) {
19
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
20
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
23
+ });
24
+ };
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ var __values = (this && this.__values) || function(o) {
53
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
54
+ if (m) return m.call(o);
55
+ if (o && typeof o.length === "number") return {
56
+ next: function () {
57
+ if (o && i >= o.length) o = void 0;
58
+ return { value: o && o[i++], done: !o };
59
+ }
60
+ };
61
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
62
+ };
63
+ import { AcEdCommand } from '../editor/command/AcEdCommand';
64
+ /**
65
+ * Example plugin demonstrating how to create and use plugins in cad-simple-viewer.
66
+ *
67
+ * This example shows:
68
+ * - How to implement the AcApPlugin interface
69
+ * - How to register custom commands in the onLoad hook
70
+ * - How to clean up resources in the onUnload hook
71
+ *
72
+ * @example
73
+ * ```typescript
74
+ * import { AcApDocManager } from '@mlightcad/cad-simple-viewer';
75
+ * import { ExamplePlugin } from './AcApPluginExample';
76
+ *
77
+ * // Load the plugin
78
+ * const plugin = new ExamplePlugin();
79
+ * await AcApDocManager.instance.pluginManager.loadPlugin(plugin);
80
+ *
81
+ * // The plugin's commands are now available
82
+ * // You can execute them via: docManager.sendStringToExecute('HELLO');
83
+ *
84
+ * // Unload the plugin when done
85
+ * await AcApDocManager.instance.pluginManager.unloadPlugin('ExamplePlugin');
86
+ * ```
87
+ */
88
+ /**
89
+ * Example command that prints a greeting message.
90
+ */
91
+ var AcApHelloCommand = /** @class */ (function (_super) {
92
+ __extends(AcApHelloCommand, _super);
93
+ function AcApHelloCommand() {
94
+ return _super !== null && _super.apply(this, arguments) || this;
95
+ }
96
+ AcApHelloCommand.prototype.execute = function (context) {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ return __generator(this, function (_a) {
99
+ console.log('Hello from ExamplePlugin!');
100
+ console.log('Current document:', context.doc);
101
+ console.log('Current view:', context.view);
102
+ return [2 /*return*/];
103
+ });
104
+ });
105
+ };
106
+ return AcApHelloCommand;
107
+ }(AcEdCommand));
108
+ /**
109
+ * Example plugin implementation.
110
+ */
111
+ var AcApExamplePlugin = /** @class */ (function () {
112
+ function AcApExamplePlugin() {
113
+ this.name = 'ExamplePlugin';
114
+ this.version = '1.0.0';
115
+ this.description = 'An example plugin demonstrating the plugin system';
116
+ // Track registered commands for cleanup
117
+ this.registeredCommands = [];
118
+ }
119
+ /**
120
+ * Called when the plugin is loaded.
121
+ * Register custom commands here.
122
+ */
123
+ AcApExamplePlugin.prototype.onLoad = function (_context, commandManager) {
124
+ // Register a custom command
125
+ commandManager.addCommand('USER', // Command group
126
+ 'HELLO', // Global command name
127
+ 'Hello', // Local command name
128
+ new AcApHelloCommand());
129
+ // Track the command for cleanup
130
+ this.registeredCommands.push({ group: 'USER', name: 'HELLO' });
131
+ console.log("[".concat(this.name, "] Plugin loaded successfully"));
132
+ console.log("[".concat(this.name, "] Registered command: HELLO"));
133
+ };
134
+ /**
135
+ * Called when the plugin is unloaded.
136
+ * Clean up registered commands and other resources here.
137
+ */
138
+ AcApExamplePlugin.prototype.onUnload = function (_context, commandManager) {
139
+ var e_1, _a;
140
+ try {
141
+ // Remove all registered commands
142
+ for (var _b = __values(this.registeredCommands), _c = _b.next(); !_c.done; _c = _b.next()) {
143
+ var cmd = _c.value;
144
+ commandManager.removeCmd(cmd.group, cmd.name);
145
+ }
146
+ }
147
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
148
+ finally {
149
+ try {
150
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
151
+ }
152
+ finally { if (e_1) throw e_1.error; }
153
+ }
154
+ this.registeredCommands = [];
155
+ console.log("[".concat(this.name, "] Plugin unloaded"));
156
+ };
157
+ return AcApExamplePlugin;
158
+ }());
159
+ export { AcApExamplePlugin };
160
+ //# sourceMappingURL=AcApPluginExample.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcApPluginExample.js","sourceRoot":"","sources":["../../src/plugin/AcApPluginExample.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAI3D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;GAEG;AACH;IAA+B,oCAAW;IAA1C;;IAMA,CAAC;IALO,kCAAO,GAAb,UAAc,OAAoB;;;gBAChC,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;gBACxC,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;gBAC7C,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,CAAC,IAAI,CAAC,CAAA;;;;KAC3C;IACH,uBAAC;AAAD,CAAC,AAND,CAA+B,WAAW,GAMzC;AAED;;GAEG;AACH;IAAA;QACE,SAAI,GAAG,eAAe,CAAA;QACtB,YAAO,GAAG,OAAO,CAAA;QACjB,gBAAW,GAAG,mDAAmD,CAAA;QAEjE,wCAAwC;QAChC,uBAAkB,GAA2C,EAAE,CAAA;IAmCzE,CAAC;IAjCC;;;OAGG;IACH,kCAAM,GAAN,UAAO,QAAqB,EAAE,cAAgC;QAC5D,4BAA4B;QAC5B,cAAc,CAAC,UAAU,CACvB,MAAM,EAAE,gBAAgB;QACxB,OAAO,EAAE,sBAAsB;QAC/B,OAAO,EAAE,qBAAqB;QAC9B,IAAI,gBAAgB,EAAE,CACvB,CAAA;QAED,gCAAgC;QAChC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAA;QAE9D,OAAO,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,iCAA8B,CAAC,CAAA;QACxD,OAAO,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,gCAA6B,CAAC,CAAA;IACzD,CAAC;IAED;;;OAGG;IACH,oCAAQ,GAAR,UAAS,QAAqB,EAAE,cAAgC;;;YAC9D,iCAAiC;YACjC,KAAkB,IAAA,KAAA,SAAA,IAAI,CAAC,kBAAkB,CAAA,gBAAA,4BAAE,CAAC;gBAAvC,IAAM,GAAG,WAAA;gBACZ,cAAc,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,CAAA;YAC/C,CAAC;;;;;;;;;QACD,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAE5B,OAAO,CAAC,GAAG,CAAC,WAAI,IAAI,CAAC,IAAI,sBAAmB,CAAC,CAAA;IAC/C,CAAC;IACH,wBAAC;AAAD,CAAC,AAzCD,IAyCC"}
@@ -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"}