@mlightcad/cad-simple-viewer 1.2.2 → 1.2.4

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 (201) hide show
  1. package/dist/index.js +33647 -0
  2. package/dist/index.umd.cjs +295 -0
  3. package/dist/libredwg-parser-worker.js +15458 -0
  4. package/dist/mtext-renderer-worker.js +29930 -0
  5. package/lib/app/AcApContext.d.ts +57 -0
  6. package/lib/app/AcApContext.d.ts.map +1 -0
  7. package/lib/app/AcApContext.js +106 -0
  8. package/lib/app/AcApContext.js.map +1 -0
  9. package/lib/app/AcApDocManager.d.ts +291 -0
  10. package/lib/app/AcApDocManager.d.ts.map +1 -0
  11. package/lib/app/AcApDocManager.js +498 -0
  12. package/lib/app/AcApDocManager.js.map +1 -0
  13. package/lib/app/AcApDocument.d.ts +101 -0
  14. package/lib/app/AcApDocument.d.ts.map +1 -0
  15. package/lib/app/AcApDocument.js +237 -0
  16. package/lib/app/AcApDocument.js.map +1 -0
  17. package/lib/app/AcApFontLoader.d.ts +54 -0
  18. package/lib/app/AcApFontLoader.d.ts.map +1 -0
  19. package/lib/app/AcApFontLoader.js +151 -0
  20. package/lib/app/AcApFontLoader.js.map +1 -0
  21. package/lib/app/AcApGlobalFunc.d.ts +26 -0
  22. package/lib/app/AcApGlobalFunc.d.ts.map +1 -0
  23. package/lib/app/AcApGlobalFunc.js +66 -0
  24. package/lib/app/AcApGlobalFunc.js.map +1 -0
  25. package/lib/app/AcApSettingManager.d.ts +232 -0
  26. package/lib/app/AcApSettingManager.d.ts.map +1 -0
  27. package/lib/app/AcApSettingManager.js +283 -0
  28. package/lib/app/AcApSettingManager.js.map +1 -0
  29. package/lib/app/index.d.ts +6 -0
  30. package/lib/app/index.d.ts.map +1 -0
  31. package/lib/app/index.js +6 -0
  32. package/lib/app/index.js.map +1 -0
  33. package/lib/command/AcApConvertToSvgCmd.d.ts +32 -0
  34. package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -0
  35. package/lib/command/AcApConvertToSvgCmd.js +56 -0
  36. package/lib/command/AcApConvertToSvgCmd.js.map +1 -0
  37. package/lib/command/AcApOpenCmd.d.ts +37 -0
  38. package/lib/command/AcApOpenCmd.d.ts.map +1 -0
  39. package/lib/command/AcApOpenCmd.js +60 -0
  40. package/lib/command/AcApOpenCmd.js.map +1 -0
  41. package/lib/command/AcApPanCmd.d.ts +31 -0
  42. package/lib/command/AcApPanCmd.d.ts.map +1 -0
  43. package/lib/command/AcApPanCmd.js +55 -0
  44. package/lib/command/AcApPanCmd.js.map +1 -0
  45. package/lib/command/AcApQNewCmd.d.ts +32 -0
  46. package/lib/command/AcApQNewCmd.d.ts.map +1 -0
  47. package/lib/command/AcApQNewCmd.js +56 -0
  48. package/lib/command/AcApQNewCmd.js.map +1 -0
  49. package/lib/command/AcApRegenCmd.d.ts +21 -0
  50. package/lib/command/AcApRegenCmd.d.ts.map +1 -0
  51. package/lib/command/AcApRegenCmd.js +45 -0
  52. package/lib/command/AcApRegenCmd.js.map +1 -0
  53. package/lib/command/AcApSelectCmd.d.ts +32 -0
  54. package/lib/command/AcApSelectCmd.d.ts.map +1 -0
  55. package/lib/command/AcApSelectCmd.js +56 -0
  56. package/lib/command/AcApSelectCmd.js.map +1 -0
  57. package/lib/command/AcApSvgConvertor.d.ts +53 -0
  58. package/lib/command/AcApSvgConvertor.d.ts.map +1 -0
  59. package/lib/command/AcApSvgConvertor.js +103 -0
  60. package/lib/command/AcApSvgConvertor.js.map +1 -0
  61. package/lib/command/AcApZoomCmd.d.ts +35 -0
  62. package/lib/command/AcApZoomCmd.d.ts.map +1 -0
  63. package/lib/command/AcApZoomCmd.js +57 -0
  64. package/lib/command/AcApZoomCmd.js.map +1 -0
  65. package/lib/command/AcApZoomToBoxCmd.d.ts +68 -0
  66. package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -0
  67. package/lib/command/AcApZoomToBoxCmd.js +158 -0
  68. package/lib/command/AcApZoomToBoxCmd.js.map +1 -0
  69. package/lib/command/index.d.ts +11 -0
  70. package/lib/command/index.d.ts.map +1 -0
  71. package/lib/command/index.js +11 -0
  72. package/lib/command/index.js.map +1 -0
  73. package/lib/editor/command/AcEdCommand.d.ts +151 -0
  74. package/lib/editor/command/AcEdCommand.d.ts.map +1 -0
  75. package/lib/editor/command/AcEdCommand.js +164 -0
  76. package/lib/editor/command/AcEdCommand.js.map +1 -0
  77. package/lib/editor/command/AcEdCommandIterator.d.ts +36 -0
  78. package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -0
  79. package/lib/editor/command/AcEdCommandIterator.js +65 -0
  80. package/lib/editor/command/AcEdCommandIterator.js.map +1 -0
  81. package/lib/editor/command/AcEdCommandStack.d.ts +120 -0
  82. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -0
  83. package/lib/editor/command/AcEdCommandStack.js +235 -0
  84. package/lib/editor/command/AcEdCommandStack.js.map +1 -0
  85. package/lib/editor/command/index.d.ts +3 -0
  86. package/lib/editor/command/index.d.ts.map +1 -0
  87. package/lib/editor/command/index.js +3 -0
  88. package/lib/editor/command/index.js.map +1 -0
  89. package/lib/editor/global/AcEdConditionWaiter.d.ts +51 -0
  90. package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -0
  91. package/lib/editor/global/AcEdConditionWaiter.js +87 -0
  92. package/lib/editor/global/AcEdConditionWaiter.js.map +1 -0
  93. package/lib/editor/global/AcEdGlobalFunc.d.ts +8 -0
  94. package/lib/editor/global/AcEdGlobalFunc.d.ts.map +1 -0
  95. package/lib/editor/global/AcEdGlobalFunc.js +14 -0
  96. package/lib/editor/global/AcEdGlobalFunc.js.map +1 -0
  97. package/lib/editor/global/AcEdMessage.d.ts +5 -0
  98. package/lib/editor/global/AcEdMessage.d.ts.map +1 -0
  99. package/lib/editor/global/AcEdMessage.js +6 -0
  100. package/lib/editor/global/AcEdMessage.js.map +1 -0
  101. package/lib/editor/global/eventBus.d.ts +103 -0
  102. package/lib/editor/global/eventBus.d.ts.map +1 -0
  103. package/lib/editor/global/eventBus.js +41 -0
  104. package/lib/editor/global/eventBus.js.map +1 -0
  105. package/lib/editor/global/index.d.ts +4 -0
  106. package/lib/editor/global/index.d.ts.map +1 -0
  107. package/lib/editor/global/index.js +4 -0
  108. package/lib/editor/global/index.js.map +1 -0
  109. package/lib/editor/index.d.ts +5 -0
  110. package/lib/editor/index.d.ts.map +1 -0
  111. package/lib/editor/index.js +5 -0
  112. package/lib/editor/index.js.map +1 -0
  113. package/lib/editor/input/AcEdBaseInput.d.ts +89 -0
  114. package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -0
  115. package/lib/editor/input/AcEdBaseInput.js +166 -0
  116. package/lib/editor/input/AcEdBaseInput.js.map +1 -0
  117. package/lib/editor/input/AcEdBoxSelector.d.ts +108 -0
  118. package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -0
  119. package/lib/editor/input/AcEdBoxSelector.js +220 -0
  120. package/lib/editor/input/AcEdBoxSelector.js.map +1 -0
  121. package/lib/editor/input/AcEdCursorManager.d.ts +130 -0
  122. package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -0
  123. package/lib/editor/input/AcEdCursorManager.js +155 -0
  124. package/lib/editor/input/AcEdCursorManager.js.map +1 -0
  125. package/lib/editor/input/AcEdInputPoint.d.ts +51 -0
  126. package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -0
  127. package/lib/editor/input/AcEdInputPoint.js +78 -0
  128. package/lib/editor/input/AcEdInputPoint.js.map +1 -0
  129. package/lib/editor/input/AcEdJig.d.ts +180 -0
  130. package/lib/editor/input/AcEdJig.d.ts.map +1 -0
  131. package/lib/editor/input/AcEdJig.js +256 -0
  132. package/lib/editor/input/AcEdJig.js.map +1 -0
  133. package/lib/editor/input/AcEdJigLoop.d.ts +63 -0
  134. package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -0
  135. package/lib/editor/input/AcEdJigLoop.js +91 -0
  136. package/lib/editor/input/AcEdJigLoop.js.map +1 -0
  137. package/lib/editor/input/AcEdSelectionSet.d.ts +146 -0
  138. package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -0
  139. package/lib/editor/input/AcEdSelectionSet.js +179 -0
  140. package/lib/editor/input/AcEdSelectionSet.js.map +1 -0
  141. package/lib/editor/input/AcEditor.d.ts +111 -0
  142. package/lib/editor/input/AcEditor.d.ts.map +1 -0
  143. package/lib/editor/input/AcEditor.js +183 -0
  144. package/lib/editor/input/AcEditor.js.map +1 -0
  145. package/lib/editor/input/index.d.ts +5 -0
  146. package/lib/editor/input/index.d.ts.map +1 -0
  147. package/lib/editor/input/index.js +5 -0
  148. package/lib/editor/input/index.js.map +1 -0
  149. package/lib/editor/view/AcEdBaseView.d.ts +457 -0
  150. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -0
  151. package/lib/editor/view/AcEdBaseView.js +349 -0
  152. package/lib/editor/view/AcEdBaseView.js.map +1 -0
  153. package/lib/editor/view/AcEdLayerInfo.d.ts +21 -0
  154. package/lib/editor/view/AcEdLayerInfo.d.ts.map +1 -0
  155. package/lib/editor/view/AcEdLayerInfo.js +2 -0
  156. package/lib/editor/view/AcEdLayerInfo.js.map +1 -0
  157. package/lib/editor/view/index.d.ts +3 -0
  158. package/lib/editor/view/index.d.ts.map +1 -0
  159. package/lib/editor/view/index.js +3 -0
  160. package/lib/editor/view/index.js.map +1 -0
  161. package/lib/index.d.ts +5 -0
  162. package/lib/index.d.ts.map +1 -0
  163. package/lib/index.js +5 -0
  164. package/lib/index.js.map +1 -0
  165. package/lib/util/AcTrGeometryUtil.d.ts +92 -0
  166. package/lib/util/AcTrGeometryUtil.d.ts.map +1 -0
  167. package/lib/util/AcTrGeometryUtil.js +109 -0
  168. package/lib/util/AcTrGeometryUtil.js.map +1 -0
  169. package/lib/util/index.d.ts +2 -0
  170. package/lib/util/index.d.ts.map +1 -0
  171. package/lib/util/index.js +2 -0
  172. package/lib/util/index.js.map +1 -0
  173. package/lib/view/AcTrLayer.d.ts +132 -0
  174. package/lib/view/AcTrLayer.d.ts.map +1 -0
  175. package/lib/view/AcTrLayer.js +199 -0
  176. package/lib/view/AcTrLayer.js.map +1 -0
  177. package/lib/view/AcTrLayout.d.ts +218 -0
  178. package/lib/view/AcTrLayout.d.ts.map +1 -0
  179. package/lib/view/AcTrLayout.js +437 -0
  180. package/lib/view/AcTrLayout.js.map +1 -0
  181. package/lib/view/AcTrLayoutView.d.ts +115 -0
  182. package/lib/view/AcTrLayoutView.d.ts.map +1 -0
  183. package/lib/view/AcTrLayoutView.js +200 -0
  184. package/lib/view/AcTrLayoutView.js.map +1 -0
  185. package/lib/view/AcTrLayoutViewManager.d.ts +89 -0
  186. package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -0
  187. package/lib/view/AcTrLayoutViewManager.js +118 -0
  188. package/lib/view/AcTrLayoutViewManager.js.map +1 -0
  189. package/lib/view/AcTrScene.d.ts +162 -0
  190. package/lib/view/AcTrScene.d.ts.map +1 -0
  191. package/lib/view/AcTrScene.js +370 -0
  192. package/lib/view/AcTrScene.js.map +1 -0
  193. package/lib/view/AcTrView2d.d.ts +262 -0
  194. package/lib/view/AcTrView2d.d.ts.map +1 -0
  195. package/lib/view/AcTrView2d.js +772 -0
  196. package/lib/view/AcTrView2d.js.map +1 -0
  197. package/lib/view/index.d.ts +2 -0
  198. package/lib/view/index.d.ts.map +1 -0
  199. package/lib/view/index.js +2 -0
  200. package/lib/view/index.js.map +1 -0
  201. package/package.json +5 -5
@@ -0,0 +1,180 @@
1
+ import { AcEdBaseView } from '../view';
2
+ /**
3
+ * Base class for interactive drawing operations (jigs) in the CAD editor.
4
+ *
5
+ * A jig is an interactive operation that allows users to dynamically preview
6
+ * and modify geometric elements during creation. Common examples include:
7
+ * - Drawing lines with real-time preview as the mouse moves
8
+ * - Selecting rectangular areas with visual feedback
9
+ * - Dynamic entity placement with instant visual updates
10
+ *
11
+ * The jig system provides:
12
+ * - Real-time visual feedback during user interaction
13
+ * - Event-driven updates based on mouse movement
14
+ * - Asynchronous completion handling
15
+ * - Cancellation and error handling
16
+ *
17
+ * @template TResult - The type of result returned when the jig completes
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * class RectangleSelectionJig extends AcEdJig<Rectangle> {
22
+ * private startPoint?: Point;
23
+ * private currentPoint?: Point;
24
+ *
25
+ * async sampler() {
26
+ * // Get start point
27
+ * this.startPoint = await this.view.editor.getPoint();
28
+ *
29
+ * // Continue updating until complete
30
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
31
+ * }
32
+ *
33
+ * update() {
34
+ * if (this.startPoint && this.currentPoint) {
35
+ * // Update preview rectangle
36
+ * this.drawPreviewRectangle(this.startPoint, this.currentPoint);
37
+ * }
38
+ * }
39
+ *
40
+ * private onMouseMove = (args) => {
41
+ * this.currentPoint = args;
42
+ * // Jig loop will call update() automatically
43
+ * }
44
+ * }
45
+ *
46
+ * // Usage
47
+ * const jig = new RectangleSelectionJig(view);
48
+ * const rectangle = await jig.drag();
49
+ * ```
50
+ */
51
+ export declare class AcEdJig<TResult> {
52
+ /** Internal jig loop that handles the interactive operation */
53
+ private _jigLoop;
54
+ /** The view associated with this jig */
55
+ private _view;
56
+ /**
57
+ * Creates a new jig instance for the specified view.
58
+ *
59
+ * Sets up the jig loop and connects update event handling.
60
+ *
61
+ * @param view - The view this jig will operate in
62
+ */
63
+ constructor(view: AcEdBaseView);
64
+ /**
65
+ * Gets the view associated with this jig.
66
+ *
67
+ * @returns The view instance
68
+ */
69
+ get view(): AcEdBaseView;
70
+ /**
71
+ * Resolves the jig operation with the specified result.
72
+ *
73
+ * This method should be called when the jig operation completes successfully.
74
+ * It cleans up event listeners and resolves the underlying promise.
75
+ *
76
+ * @param result - The result to return from the jig operation
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * // In a line drawing jig, when user completes the line
81
+ * if (this.hasValidEndPoint()) {
82
+ * const line = new Line(this.startPoint, this.endPoint);
83
+ * this.resolve(line);
84
+ * }
85
+ * ```
86
+ */
87
+ resolve(result: TResult): void;
88
+ /**
89
+ * Rejects the jig operation with an error.
90
+ *
91
+ * This method should be called when the jig operation fails or is cancelled.
92
+ * It cleans up event listeners and rejects the underlying promise.
93
+ *
94
+ * @param reason - The reason for the rejection
95
+ *
96
+ * @example
97
+ * ```typescript
98
+ * // If user cancels or invalid input is detected
99
+ * if (userPressedEscape) {
100
+ * this.reject('Operation cancelled by user');
101
+ * }
102
+ * ```
103
+ */
104
+ reject(reason: string): void;
105
+ /**
106
+ * Starts the interactive jig operation.
107
+ *
108
+ * This method initiates both the jig loop and the sampling process.
109
+ * It returns a promise that resolves when the jig operation completes
110
+ * or rejects if an error occurs.
111
+ *
112
+ * @returns Promise that resolves when the jig operation completes
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const jig = new MyCustomJig(view);
117
+ * try {
118
+ * const result = await jig.drag();
119
+ * console.log('Jig completed with result:', result);
120
+ * } catch (error) {
121
+ * console.log('Jig was cancelled or failed:', error);
122
+ * }
123
+ * ```
124
+ */
125
+ drag(): Promise<void>;
126
+ /**
127
+ * Abstract method for handling jig input sampling.
128
+ *
129
+ * This method should be overridden by subclasses to implement
130
+ * the specific input handling logic for the jig. It typically:
131
+ * - Gets initial user input (like a start point)
132
+ * - Sets up event listeners for dynamic updates
133
+ * - Handles user interaction until completion
134
+ *
135
+ * The sampler runs concurrently with the jig loop and should
136
+ * call `resolve()` or `reject()` when the operation completes.
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * async sampler() {
141
+ * // Get initial point
142
+ * const startPoint = await this.view.editor.getPoint();
143
+ *
144
+ * // Set up mouse tracking for dynamic preview
145
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
146
+ * this.view.events.mouseClick.addEventListener(this.onMouseClick);
147
+ * }
148
+ * ```
149
+ */
150
+ sampler(): Promise<void>;
151
+ /**
152
+ * Called during each update cycle to refresh the jig display.
153
+ *
154
+ * This method should be overridden by subclasses to implement
155
+ * the visual update logic. It's called automatically by the jig loop
156
+ * whenever the display needs to be refreshed (typically on mouse movement).
157
+ *
158
+ * Common update operations include:
159
+ * - Redrawing preview geometry
160
+ * - Updating dimension displays
161
+ * - Refreshing visual feedback elements
162
+ *
163
+ * @example
164
+ * ```typescript
165
+ * update() {
166
+ * if (this.startPoint && this.currentMousePoint) {
167
+ * // Clear previous preview
168
+ * this.clearPreview();
169
+ *
170
+ * // Draw new preview line
171
+ * this.drawPreviewLine(this.startPoint, this.currentMousePoint);
172
+ * }
173
+ * }
174
+ * ```
175
+ */
176
+ update(): void;
177
+ /** Internal event handler for jig loop updates */
178
+ private onUpdate;
179
+ }
180
+ //# sourceMappingURL=AcEdJig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcEdJig.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdJig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAGtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,qBAAa,OAAO,CAAC,OAAO;IAC1B,+DAA+D;IAC/D,OAAO,CAAC,QAAQ,CAAsB;IACtC,wCAAwC;IACxC,OAAO,CAAC,KAAK,CAAc;IAE3B;;;;;;OAMG;gBACS,IAAI,EAAE,YAAY;IAM9B;;;;OAIG;IACH,IAAI,IAAI,iBAEP;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,MAAM,EAAE,OAAO;IAKvB;;;;;;;;;;;;;;;OAeG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM;IAKrB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,IAAI;IAMV;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,OAAO;IAIb;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,MAAM;IAIN,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAEf;CACF"}
@@ -0,0 +1,256 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ 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);
12
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ 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;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { AcEdJigLoop } from './AcEdJigLoop';
38
+ /**
39
+ * Base class for interactive drawing operations (jigs) in the CAD editor.
40
+ *
41
+ * A jig is an interactive operation that allows users to dynamically preview
42
+ * and modify geometric elements during creation. Common examples include:
43
+ * - Drawing lines with real-time preview as the mouse moves
44
+ * - Selecting rectangular areas with visual feedback
45
+ * - Dynamic entity placement with instant visual updates
46
+ *
47
+ * The jig system provides:
48
+ * - Real-time visual feedback during user interaction
49
+ * - Event-driven updates based on mouse movement
50
+ * - Asynchronous completion handling
51
+ * - Cancellation and error handling
52
+ *
53
+ * @template TResult - The type of result returned when the jig completes
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * class RectangleSelectionJig extends AcEdJig<Rectangle> {
58
+ * private startPoint?: Point;
59
+ * private currentPoint?: Point;
60
+ *
61
+ * async sampler() {
62
+ * // Get start point
63
+ * this.startPoint = await this.view.editor.getPoint();
64
+ *
65
+ * // Continue updating until complete
66
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
67
+ * }
68
+ *
69
+ * update() {
70
+ * if (this.startPoint && this.currentPoint) {
71
+ * // Update preview rectangle
72
+ * this.drawPreviewRectangle(this.startPoint, this.currentPoint);
73
+ * }
74
+ * }
75
+ *
76
+ * private onMouseMove = (args) => {
77
+ * this.currentPoint = args;
78
+ * // Jig loop will call update() automatically
79
+ * }
80
+ * }
81
+ *
82
+ * // Usage
83
+ * const jig = new RectangleSelectionJig(view);
84
+ * const rectangle = await jig.drag();
85
+ * ```
86
+ */
87
+ var AcEdJig = /** @class */ (function () {
88
+ /**
89
+ * Creates a new jig instance for the specified view.
90
+ *
91
+ * Sets up the jig loop and connects update event handling.
92
+ *
93
+ * @param view - The view this jig will operate in
94
+ */
95
+ function AcEdJig(view) {
96
+ var _this = this;
97
+ /** Internal event handler for jig loop updates */
98
+ this.onUpdate = function () {
99
+ _this.update();
100
+ };
101
+ this._view = view;
102
+ this._jigLoop = new AcEdJigLoop(view);
103
+ this._jigLoop.events.update.addEventListener(this.onUpdate);
104
+ }
105
+ Object.defineProperty(AcEdJig.prototype, "view", {
106
+ /**
107
+ * Gets the view associated with this jig.
108
+ *
109
+ * @returns The view instance
110
+ */
111
+ get: function () {
112
+ return this._view;
113
+ },
114
+ enumerable: false,
115
+ configurable: true
116
+ });
117
+ /**
118
+ * Resolves the jig operation with the specified result.
119
+ *
120
+ * This method should be called when the jig operation completes successfully.
121
+ * It cleans up event listeners and resolves the underlying promise.
122
+ *
123
+ * @param result - The result to return from the jig operation
124
+ *
125
+ * @example
126
+ * ```typescript
127
+ * // In a line drawing jig, when user completes the line
128
+ * if (this.hasValidEndPoint()) {
129
+ * const line = new Line(this.startPoint, this.endPoint);
130
+ * this.resolve(line);
131
+ * }
132
+ * ```
133
+ */
134
+ AcEdJig.prototype.resolve = function (result) {
135
+ this._jigLoop.events.update.removeEventListener(this.onUpdate);
136
+ this._jigLoop.resolve(result);
137
+ };
138
+ /**
139
+ * Rejects the jig operation with an error.
140
+ *
141
+ * This method should be called when the jig operation fails or is cancelled.
142
+ * It cleans up event listeners and rejects the underlying promise.
143
+ *
144
+ * @param reason - The reason for the rejection
145
+ *
146
+ * @example
147
+ * ```typescript
148
+ * // If user cancels or invalid input is detected
149
+ * if (userPressedEscape) {
150
+ * this.reject('Operation cancelled by user');
151
+ * }
152
+ * ```
153
+ */
154
+ AcEdJig.prototype.reject = function (reason) {
155
+ this._jigLoop.events.update.removeEventListener(this.onUpdate);
156
+ this._jigLoop.reject(reason);
157
+ };
158
+ /**
159
+ * Starts the interactive jig operation.
160
+ *
161
+ * This method initiates both the jig loop and the sampling process.
162
+ * It returns a promise that resolves when the jig operation completes
163
+ * or rejects if an error occurs.
164
+ *
165
+ * @returns Promise that resolves when the jig operation completes
166
+ *
167
+ * @example
168
+ * ```typescript
169
+ * const jig = new MyCustomJig(view);
170
+ * try {
171
+ * const result = await jig.drag();
172
+ * console.log('Jig completed with result:', result);
173
+ * } catch (error) {
174
+ * console.log('Jig was cancelled or failed:', error);
175
+ * }
176
+ * ```
177
+ */
178
+ AcEdJig.prototype.drag = function () {
179
+ return __awaiter(this, void 0, void 0, function () {
180
+ var promise1, promise2;
181
+ return __generator(this, function (_a) {
182
+ switch (_a.label) {
183
+ case 0:
184
+ promise1 = this._jigLoop.start();
185
+ promise2 = this.sampler();
186
+ return [4 /*yield*/, Promise.allSettled([promise1, promise2])];
187
+ case 1:
188
+ _a.sent();
189
+ return [2 /*return*/];
190
+ }
191
+ });
192
+ });
193
+ };
194
+ /**
195
+ * Abstract method for handling jig input sampling.
196
+ *
197
+ * This method should be overridden by subclasses to implement
198
+ * the specific input handling logic for the jig. It typically:
199
+ * - Gets initial user input (like a start point)
200
+ * - Sets up event listeners for dynamic updates
201
+ * - Handles user interaction until completion
202
+ *
203
+ * The sampler runs concurrently with the jig loop and should
204
+ * call `resolve()` or `reject()` when the operation completes.
205
+ *
206
+ * @example
207
+ * ```typescript
208
+ * async sampler() {
209
+ * // Get initial point
210
+ * const startPoint = await this.view.editor.getPoint();
211
+ *
212
+ * // Set up mouse tracking for dynamic preview
213
+ * this.view.events.mouseMove.addEventListener(this.onMouseMove);
214
+ * this.view.events.mouseClick.addEventListener(this.onMouseClick);
215
+ * }
216
+ * ```
217
+ */
218
+ AcEdJig.prototype.sampler = function () {
219
+ return __awaiter(this, void 0, void 0, function () {
220
+ return __generator(this, function (_a) {
221
+ return [2 /*return*/];
222
+ });
223
+ });
224
+ };
225
+ /**
226
+ * Called during each update cycle to refresh the jig display.
227
+ *
228
+ * This method should be overridden by subclasses to implement
229
+ * the visual update logic. It's called automatically by the jig loop
230
+ * whenever the display needs to be refreshed (typically on mouse movement).
231
+ *
232
+ * Common update operations include:
233
+ * - Redrawing preview geometry
234
+ * - Updating dimension displays
235
+ * - Refreshing visual feedback elements
236
+ *
237
+ * @example
238
+ * ```typescript
239
+ * update() {
240
+ * if (this.startPoint && this.currentMousePoint) {
241
+ * // Clear previous preview
242
+ * this.clearPreview();
243
+ *
244
+ * // Draw new preview line
245
+ * this.drawPreviewLine(this.startPoint, this.currentMousePoint);
246
+ * }
247
+ * }
248
+ * ```
249
+ */
250
+ AcEdJig.prototype.update = function () {
251
+ // Do nothing for now
252
+ };
253
+ return AcEdJig;
254
+ }());
255
+ export { AcEdJig };
256
+ //# sourceMappingURL=AcEdJig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcEdJig.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdJig.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH;IAME;;;;;;OAMG;IACH,iBAAY,IAAkB;QAA9B,iBAIC;QAyID,kDAAkD;QAC1C,aAAQ,GAAG;YACjB,KAAI,CAAC,MAAM,EAAE,CAAA;QACf,CAAC,CAAA;QA/IC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACjB,IAAI,CAAC,QAAQ,GAAG,IAAI,WAAW,CAAC,IAAI,CAAC,CAAA;QACrC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IAC7D,CAAC;IAOD,sBAAI,yBAAI;QALR;;;;WAIG;aACH;YACE,OAAO,IAAI,CAAC,KAAK,CAAA;QACnB,CAAC;;;OAAA;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,yBAAO,GAAP,UAAQ,MAAe;QACrB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9D,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACH,wBAAM,GAAN,UAAO,MAAc;QACnB,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9D,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAC9B,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACG,sBAAI,GAAV;;;;;;wBACQ,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;wBAChC,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE,CAAA;wBAC/B,qBAAM,OAAO,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,EAAA;;wBAA9C,SAA8C,CAAA;;;;;KAC/C;IAED;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACG,yBAAO,GAAb;;;;;;KAEC;IAED;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,wBAAM,GAAN;QACE,qBAAqB;IACvB,CAAC;IAMH,cAAC;AAAD,CAAC,AA9JD,IA8JC"}
@@ -0,0 +1,63 @@
1
+ import { AcCmEventManager, AcGePoint2d } from '@mlightcad/data-model';
2
+ import { AcEdBaseView } from '../view/AcEdBaseView';
3
+ import { AcEdBaseInput } from './AcEdBaseInput';
4
+ /**
5
+ * A specialized input class for jig operations that provides continuous mouse tracking.
6
+ *
7
+ * This class extends the base input functionality to provide real-time mouse position
8
+ * tracking for interactive operations like drawing previews or dynamic objects that
9
+ * follow the mouse cursor. It fires update events whenever the mouse moves, allowing
10
+ * subscribers to respond to cursor movement.
11
+ *
12
+ * Jig loops are commonly used in CAD applications for operations like:
13
+ * - Drawing preview lines that stretch from a fixed point to the cursor
14
+ * - Moving objects dynamically with the mouse
15
+ * - Providing visual feedback during interactive operations
16
+ *
17
+ * @template TResult - The type of result that this jig operation will return
18
+ *
19
+ * @example
20
+ * ```typescript
21
+ * const jigLoop = new AcEdJigLoop<string>(view);
22
+ * jigLoop.events.update.subscribe(() => {
23
+ * // Update preview based on jigLoop.curPos
24
+ * console.log(`Mouse at: ${jigLoop.curPos.x}, ${jigLoop.curPos.y}`);
25
+ * });
26
+ * const result = await jigLoop.start();
27
+ * ```
28
+ */
29
+ export declare class AcEdJigLoop<TResult> extends AcEdBaseInput<TResult> {
30
+ /** Event manager for handling mouse movement updates */
31
+ readonly events: {
32
+ /** Event fired when the mouse position updates */
33
+ update: AcCmEventManager<void>;
34
+ };
35
+ /** Current mouse position in screen coordinates */
36
+ curPos: AcGePoint2d;
37
+ /**
38
+ * Creates a new jig loop instance.
39
+ *
40
+ * @param view - The view that will handle this jig operation
41
+ */
42
+ constructor(view: AcEdBaseView);
43
+ /**
44
+ * Activates the jig loop operation.
45
+ * Sets up the mouse move event listener to track cursor position.
46
+ * Overrides the base class to add mouse move event handling.
47
+ */
48
+ activate(): void;
49
+ /**
50
+ * Deactivates the jig loop operation.
51
+ * Removes the mouse move event listener.
52
+ * Overrides the base class to clean up mouse move event handling.
53
+ */
54
+ deactivate(): void;
55
+ /**
56
+ * Handles mouse move events to update the current cursor position.
57
+ * Updates the current position and fires the update event to notify subscribers.
58
+ *
59
+ * @param event - The mouse move event containing the new cursor position
60
+ */
61
+ private onMouseMove;
62
+ }
63
+ //# sourceMappingURL=AcEdJigLoop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcEdJigLoop.d.ts","sourceRoot":"","sources":["../../../src/editor/input/AcEdJigLoop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,WAAW,CAAC,OAAO,CAAE,SAAQ,aAAa,CAAC,OAAO,CAAC;IAC9D,wDAAwD;IACxD,SAAgB,MAAM;QACpB,kDAAkD;;MAEnD;IACD,mDAAmD;IAC5C,MAAM,EAAE,WAAW,CAAA;IAE1B;;;;OAIG;gBACS,IAAI,EAAE,YAAY;IAK9B;;;;OAIG;IACH,QAAQ;IAKR;;;;OAIG;IACH,UAAU;IAKV;;;;;OAKG;IACH,OAAO,CAAC,WAAW,CAGlB;CACF"}
@@ -0,0 +1,91 @@
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
+ import { AcCmEventManager, AcGePoint2d } from '@mlightcad/data-model';
17
+ import { AcEdBaseInput } from './AcEdBaseInput';
18
+ /**
19
+ * A specialized input class for jig operations that provides continuous mouse tracking.
20
+ *
21
+ * This class extends the base input functionality to provide real-time mouse position
22
+ * tracking for interactive operations like drawing previews or dynamic objects that
23
+ * follow the mouse cursor. It fires update events whenever the mouse moves, allowing
24
+ * subscribers to respond to cursor movement.
25
+ *
26
+ * Jig loops are commonly used in CAD applications for operations like:
27
+ * - Drawing preview lines that stretch from a fixed point to the cursor
28
+ * - Moving objects dynamically with the mouse
29
+ * - Providing visual feedback during interactive operations
30
+ *
31
+ * @template TResult - The type of result that this jig operation will return
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const jigLoop = new AcEdJigLoop<string>(view);
36
+ * jigLoop.events.update.subscribe(() => {
37
+ * // Update preview based on jigLoop.curPos
38
+ * console.log(`Mouse at: ${jigLoop.curPos.x}, ${jigLoop.curPos.y}`);
39
+ * });
40
+ * const result = await jigLoop.start();
41
+ * ```
42
+ */
43
+ var AcEdJigLoop = /** @class */ (function (_super) {
44
+ __extends(AcEdJigLoop, _super);
45
+ /**
46
+ * Creates a new jig loop instance.
47
+ *
48
+ * @param view - The view that will handle this jig operation
49
+ */
50
+ function AcEdJigLoop(view) {
51
+ var _this = _super.call(this, view) || this;
52
+ /** Event manager for handling mouse movement updates */
53
+ _this.events = {
54
+ /** Event fired when the mouse position updates */
55
+ update: new AcCmEventManager()
56
+ };
57
+ /**
58
+ * Handles mouse move events to update the current cursor position.
59
+ * Updates the current position and fires the update event to notify subscribers.
60
+ *
61
+ * @param event - The mouse move event containing the new cursor position
62
+ */
63
+ _this.onMouseMove = function (event) {
64
+ _this.curPos.set(event.clientX, event.clientY);
65
+ _this.events.update.dispatch();
66
+ };
67
+ _this.curPos = new AcGePoint2d();
68
+ return _this;
69
+ }
70
+ /**
71
+ * Activates the jig loop operation.
72
+ * Sets up the mouse move event listener to track cursor position.
73
+ * Overrides the base class to add mouse move event handling.
74
+ */
75
+ AcEdJigLoop.prototype.activate = function () {
76
+ _super.prototype.activate.call(this);
77
+ this.view.canvas.addEventListener('mousemove', this.onMouseMove);
78
+ };
79
+ /**
80
+ * Deactivates the jig loop operation.
81
+ * Removes the mouse move event listener.
82
+ * Overrides the base class to clean up mouse move event handling.
83
+ */
84
+ AcEdJigLoop.prototype.deactivate = function () {
85
+ _super.prototype.deactivate.call(this);
86
+ this.view.canvas.removeEventListener('mousemove', this.onMouseMove);
87
+ };
88
+ return AcEdJigLoop;
89
+ }(AcEdBaseInput));
90
+ export { AcEdJigLoop };
91
+ //# sourceMappingURL=AcEdJigLoop.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcEdJigLoop.js","sourceRoot":"","sources":["../../../src/editor/input/AcEdJigLoop.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAGrE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAE/C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH;IAA0C,+BAAsB;IAS9D;;;;OAIG;IACH,qBAAY,IAAkB;QAC5B,YAAA,MAAK,YAAC,IAAI,CAAC,SAAA;QAdb,wDAAwD;QACxC,YAAM,GAAG;YACvB,kDAAkD;YAClD,MAAM,EAAE,IAAI,gBAAgB,EAAQ;SACrC,CAAA;QAkCD;;;;;WAKG;QACK,iBAAW,GAAG,UAAC,KAAiB;YACtC,KAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAA;YAC7C,KAAI,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAA;QAC/B,CAAC,CAAA;QAhCC,KAAI,CAAC,MAAM,GAAG,IAAI,WAAW,EAAE,CAAA;;IACjC,CAAC;IAED;;;;OAIG;IACH,8BAAQ,GAAR;QACE,gBAAK,CAAC,QAAQ,WAAE,CAAA;QAChB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IAClE,CAAC;IAED;;;;OAIG;IACH,gCAAU,GAAV;QACE,gBAAK,CAAC,UAAU,WAAE,CAAA;QAClB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;IACrE,CAAC;IAYH,kBAAC;AAAD,CAAC,AAjDD,CAA0C,aAAa,GAiDtD"}