simple-circuit-engine 0.0.11 → 0.0.13

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 (161) hide show
  1. package/AGENTS.md +11 -7
  2. package/CLAUDE.md +6 -6
  3. package/README.md +5 -2
  4. package/dist/core/index.d.ts +0 -1
  5. package/dist/core/index.js +85 -2115
  6. package/dist/core/setup.d.ts +25 -0
  7. package/dist/core/simulation/CircuitRunner.d.ts +176 -0
  8. package/dist/core/simulation/DirtyTracker.d.ts +87 -0
  9. package/dist/core/simulation/EventQueue.d.ts +68 -0
  10. package/dist/core/simulation/StateManager.d.ts +100 -0
  11. package/dist/core/simulation/behaviors/BehaviorRegistry.d.ts +70 -0
  12. package/dist/core/simulation/behaviors/ComponentBehavior.d.ts +53 -0
  13. package/dist/core/simulation/behaviors/arithmetic/AdderBehavior.d.ts +28 -0
  14. package/dist/core/simulation/behaviors/arithmetic/ArithmeticBehaviorMixin.d.ts +63 -0
  15. package/dist/core/simulation/behaviors/arithmetic/EightBitAdderBehavior.d.ts +51 -0
  16. package/dist/core/simulation/behaviors/arithmetic/EightBitOnesComplementBehavior.d.ts +29 -0
  17. package/dist/core/simulation/behaviors/arithmetic/HalfAdderBehavior.d.ts +22 -0
  18. package/dist/core/simulation/behaviors/arithmetic/index.d.ts +7 -0
  19. package/dist/core/simulation/behaviors/basic/BatteryBehavior.d.ts +14 -0
  20. package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
  21. package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
  22. package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
  23. package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
  24. package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
  25. package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
  26. package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
  27. package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
  28. package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
  29. package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
  30. package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
  31. package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
  32. package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
  33. package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
  34. package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
  35. package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
  36. package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
  37. package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
  38. package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
  39. package/dist/core/simulation/behaviors/index.d.ts +28 -0
  40. package/dist/core/simulation/behaviors/types.d.ts +101 -0
  41. package/dist/core/simulation/index.d.ts +18 -0
  42. package/dist/core/simulation/states/ComponentState.d.ts +57 -0
  43. package/dist/core/simulation/states/SimulationState.d.ts +46 -0
  44. package/dist/core/simulation/states/arithmetic/AdderState.d.ts +16 -0
  45. package/dist/core/simulation/states/arithmetic/ArithmeticState.d.ts +53 -0
  46. package/dist/core/simulation/states/arithmetic/EightBitAdderState.d.ts +25 -0
  47. package/dist/core/simulation/states/arithmetic/EightBitOnesComplementState.d.ts +18 -0
  48. package/dist/core/simulation/states/arithmetic/HalfAdderState.d.ts +16 -0
  49. package/dist/core/simulation/states/arithmetic/index.d.ts +7 -0
  50. package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
  51. package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
  52. package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
  53. package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
  54. package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
  55. package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
  56. package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
  57. package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
  58. package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
  59. package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
  60. package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
  61. package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
  62. package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
  63. package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
  64. package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
  65. package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
  66. package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
  67. package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
  68. package/dist/core/simulation/states/gates/index.d.ts +25 -0
  69. package/dist/core/simulation/states/index.d.ts +31 -0
  70. package/dist/core/simulation/states/types.d.ts +32 -0
  71. package/dist/core/simulation/types.d.ts +155 -0
  72. package/dist/core/topology/Circuit.d.ts +420 -0
  73. package/dist/core/topology/CircuitMetadata.d.ts +24 -0
  74. package/dist/core/topology/CircuitOptions.d.ts +14 -0
  75. package/dist/core/topology/Component.d.ts +153 -0
  76. package/dist/core/topology/ENode.d.ts +200 -0
  77. package/dist/core/topology/Wire.d.ts +130 -0
  78. package/dist/core/topology/delays.d.ts +52 -0
  79. package/dist/core/topology/index.d.ts +14 -0
  80. package/dist/core/topology/types.d.ts +189 -0
  81. package/dist/core/utils/CameraOptions.d.ts +83 -0
  82. package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
  83. package/dist/core/utils/Position.d.ts +166 -0
  84. package/dist/core/utils/Position3D.d.ts +77 -0
  85. package/dist/core/utils/Rotation.d.ts +82 -0
  86. package/dist/core/utils/index.d.ts +24 -0
  87. package/dist/core/utils/types.d.ts +35 -0
  88. package/dist/core-b6Q8w2sn.js +3560 -0
  89. package/dist/core-b6Q8w2sn.js.map +1 -0
  90. package/dist/i18n/index.d.ts +882 -0
  91. package/dist/i18n/locales/en.json.d.ts +268 -0
  92. package/dist/i18n/locales/fr.json.d.ts +268 -0
  93. package/dist/index.d.ts +14 -6306
  94. package/dist/index.js +136 -112
  95. package/dist/scene/CircuitEngine.d.ts +283 -0
  96. package/dist/scene/index.d.ts +1 -2
  97. package/dist/scene/index.js +50 -41
  98. package/dist/scene/setup.d.ts +26 -0
  99. package/dist/scene/shared/AbstractCircuitController.d.ts +217 -0
  100. package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
  101. package/dist/scene/shared/EventEmitter.d.ts +92 -0
  102. package/dist/scene/shared/HoverManager.d.ts +151 -0
  103. package/dist/scene/shared/SelectionManager.d.ts +159 -0
  104. package/dist/scene/shared/WireVisualManager.d.ts +242 -0
  105. package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
  106. package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
  107. package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
  108. package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
  109. package/dist/scene/shared/components/arithmetic/AdderVisualFactory.d.ts +54 -0
  110. package/dist/scene/shared/components/arithmetic/EightBitAdderVisualFactory.d.ts +45 -0
  111. package/dist/scene/shared/components/arithmetic/EightBitOnesComplementVisualFactory.d.ts +63 -0
  112. package/dist/scene/shared/components/arithmetic/HalfAdderVisualFactory.d.ts +55 -0
  113. package/dist/scene/shared/components/arithmetic/index.d.ts +4 -0
  114. package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
  115. package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
  116. package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
  117. package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
  118. package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
  119. package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
  120. package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
  121. package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
  122. package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
  123. package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
  124. package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
  125. package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
  126. package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
  127. package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
  128. package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
  129. package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
  130. package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
  131. package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
  132. package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
  133. package/dist/scene/shared/components/index.d.ts +33 -0
  134. package/dist/scene/shared/components/types.d.ts +43 -0
  135. package/dist/scene/shared/types.d.ts +474 -0
  136. package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
  137. package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
  138. package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
  139. package/dist/scene/shared/utils/GeometryUtils.d.ts +337 -0
  140. package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
  141. package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
  142. package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
  143. package/dist/scene/shared/utils/Options.d.ts +16 -0
  144. package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
  145. package/dist/scene/static/CircuitController.d.ts +228 -0
  146. package/dist/scene/static/CircuitWriter.d.ts +146 -0
  147. package/dist/scene/static/PinTooltipWidget.d.ts +31 -0
  148. package/dist/scene/static/tools/BuildTool.d.ts +290 -0
  149. package/dist/scene/static/tools/ComponentPickerWidget.d.ts +89 -0
  150. package/dist/scene/static/tools/ConfigPanelWidget.d.ts +107 -0
  151. package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
  152. package/dist/scene-D4QcWeiq.js +8745 -0
  153. package/dist/scene-D4QcWeiq.js.map +1 -0
  154. package/package.json +29 -25
  155. package/dist/CircuitRunner-BQQlhwjD.js +0 -1981
  156. package/dist/CircuitRunner-BQQlhwjD.js.map +0 -1
  157. package/dist/core/index.js.map +0 -1
  158. package/dist/index.js.map +0 -1
  159. package/dist/scene/index.js.map +0 -1
  160. package/dist/setup-CIq_kgaw.js +0 -10230
  161. package/dist/setup-CIq_kgaw.js.map +0 -1
@@ -0,0 +1,265 @@
1
+ import { UUID, ENodeSourceType } from '../../../core/index.ts';
2
+ import { IEditingTool, CursorType } from '../../shared/types';
3
+ import { CircuitController } from '../CircuitController';
4
+ /**
5
+ * MultiSelectTool - Enables multi-element selection and bulk operations
6
+ * @module scene/static/tools/MultiSelectTool
7
+ */
8
+ import * as THREE from 'three';
9
+ /**
10
+ * Operating modes for the MultiSelectTool
11
+ */
12
+ export type MultiSelectToolMode = 'idle' | 'selecting' | 'dragging';
13
+ /**
14
+ * State during rectangle selection operation (T010)
15
+ */
16
+ export interface SelectionRectState {
17
+ /** Starting mouse position in screen coordinates */
18
+ startScreen: {
19
+ x: number;
20
+ y: number;
21
+ };
22
+ /** Current mouse position in screen coordinates */
23
+ currentScreen: {
24
+ x: number;
25
+ y: number;
26
+ };
27
+ /** DOM element for visual rectangle overlay */
28
+ overlayElement: HTMLDivElement;
29
+ /** Whether Shift key is held (additive selection mode) */
30
+ shiftHeld: boolean;
31
+ /** Elements currently previewed as "will be selected" */
32
+ previewedElements: Set<UUID>;
33
+ }
34
+ /**
35
+ * State during bulk move operation (T023)
36
+ */
37
+ export interface BulkDragState {
38
+ /** Starting cursor position in world coordinates */
39
+ dragStartWorld: THREE.Vector3;
40
+ /** Snapshot of initial positions for all selected elements */
41
+ initialPositions: Map<UUID, THREE.Vector3>;
42
+ /** Wire IDs that need geometry updates during drag */
43
+ affectedWireIds: Set<UUID>;
44
+ /** Initial intermediate positions for selected wires (wireId -> array of positions) */
45
+ initialWireIntermediatePositions: Map<UUID, THREE.Vector3[]>;
46
+ }
47
+ /**
48
+ * Complete clipboard data structure for copy/paste
49
+ * TODO : copy and paste edited enodes sourceType and components config
50
+ */
51
+ export interface ClipboardData {
52
+ /** Center of selection bounding box in grid coordinates */
53
+ anchor: {
54
+ x: number;
55
+ y: number;
56
+ };
57
+ /** Copied component definitions */
58
+ components: ClipboardComponent[];
59
+ /** Copied branching point definitions */
60
+ branchingPoints: ClipboardBranchingPoint[];
61
+ /** Copied wire definitions (only wires with both endpoints in selection) */
62
+ wires: ClipboardWire[];
63
+ }
64
+ /**
65
+ * Component data within clipboard
66
+ */
67
+ export interface ClipboardComponent {
68
+ /** Component type identifier */
69
+ type: string;
70
+ /** Position relative to clipboard anchor */
71
+ relativePosition: {
72
+ x: number;
73
+ y: number;
74
+ };
75
+ /** Rotation angle in degrees */
76
+ rotation: number;
77
+ /** Original element ID for wire remapping during paste */
78
+ originalId: UUID;
79
+ /** Original configuration data for the component */
80
+ config: Map<string, string>;
81
+ /** Original pins sourceTypes */
82
+ pinSources: Array<ENodeSourceType | undefined | null>;
83
+ }
84
+ /**
85
+ * Branching point data within clipboard
86
+ */
87
+ export interface ClipboardBranchingPoint {
88
+ /** Position relative to clipboard anchor */
89
+ relativePosition: {
90
+ x: number;
91
+ y: number;
92
+ };
93
+ /** Original element ID for wire remapping during paste */
94
+ originalId: UUID;
95
+ /** Source type of the branching point */
96
+ source?: ENodeSourceType | undefined;
97
+ }
98
+ /**
99
+ * Wire data within clipboard
100
+ */
101
+ export interface ClipboardWire {
102
+ /** Original ID of first endpoint (component pin or branching point) */
103
+ node1OriginalId: UUID;
104
+ /** Original ID of second endpoint */
105
+ node2OriginalId: UUID;
106
+ /** Intermediate positions relative to clipboard anchor */
107
+ relativeIntermediatePositions: Array<{
108
+ x: number;
109
+ y: number;
110
+ }>;
111
+ }
112
+ /**
113
+ * MultiSelectTool implementation
114
+ *
115
+ * Provides functionality for:
116
+ * - Rectangle selection of multiple elements
117
+ * - Bulk move operations
118
+ * - Bulk delete operations
119
+ * - Copy/paste and cut/paste operations
120
+ */
121
+ export declare class MultiSelectTool implements IEditingTool {
122
+ readonly type: "multiSelect";
123
+ private mode;
124
+ private readonly controller;
125
+ private selectionRectState;
126
+ private bulkDragState;
127
+ private clipboardData;
128
+ private clipboardPinToComponent;
129
+ private clipboardPinIndices;
130
+ private handlePointerDown;
131
+ private handlePointerMove;
132
+ private handlePointerUp;
133
+ private handleKeyDown;
134
+ private handleGridPositionMove;
135
+ constructor(controller: CircuitController);
136
+ /**
137
+ * Get the current operating mode
138
+ */
139
+ getMode(): MultiSelectToolMode;
140
+ /**
141
+ * Called when tool becomes active
142
+ */
143
+ onActivate(): void;
144
+ /**
145
+ * Called when tool is deactivated
146
+ */
147
+ onDeactivate(): void;
148
+ /**
149
+ * Cancel any in-progress operation
150
+ */
151
+ cancelOperation(): void;
152
+ /**
153
+ * Get the current cursor type for this tool (T031)
154
+ */
155
+ getCursorType(): CursorType;
156
+ /**
157
+ * Get preview objects to render in the scene
158
+ */
159
+ getPreviewObjects(): THREE.Object3D[];
160
+ /**
161
+ * Handle pointer down event (T011, T019, T020, T021, T024)
162
+ * - Empty space: start rectangle selection
163
+ * - Element click: select that element (clear others unless Shift held)
164
+ * - Selected element: prepare for bulk drag (Phase 4)
165
+ */
166
+ private _handlePointerDown;
167
+ /**
168
+ * Handle pointer move event (T013)
169
+ * Updates rectangle dimensions during selection
170
+ */
171
+ private _handlePointerMove;
172
+ /**
173
+ * Handle pointer up event (T016, T021, T029)
174
+ * Commits selection or bulk drag, or clears if it was just a click
175
+ */
176
+ private _handlePointerUp;
177
+ /**
178
+ * Handle grid position move event (T027)
179
+ * Updates element positions during bulk drag
180
+ */
181
+ private _handleGridPositionMove;
182
+ /**
183
+ * Handle keyboard events (T017, T030, T034, T043, T048, T053)
184
+ * - Escape: cancel current operation
185
+ * - Delete/Backspace: delete selection
186
+ * - Ctrl+C/Cmd+C: copy selection
187
+ * - Ctrl+V/Cmd+V: paste clipboard
188
+ * - Ctrl+X/Cmd+X: cut selection
189
+ */
190
+ private _handleKeyDown;
191
+ /**
192
+ * Start rectangle selection (T012)
193
+ */
194
+ private _startSelectionRect;
195
+ /**
196
+ * Update CSS overlay dimensions and position (T013)
197
+ */
198
+ private _updateSelectionRectOverlay;
199
+ /**
200
+ * Update preview highlighting for elements inside rectangle (T015)
201
+ */
202
+ private _updatePreviewHighlighting;
203
+ /**
204
+ * Get elements inside the current selection rectangle (T014)
205
+ * Components/BPs: selected if center is inside rectangle
206
+ * Wires: selected only if BOTH endpoints are selected
207
+ */
208
+ private _getElementsInSelectionRect;
209
+ /**
210
+ * Commit the rectangle selection (T016, T018, T022)
211
+ */
212
+ private _commitSelectionRect;
213
+ /**
214
+ * Cancel rectangle selection (T017)
215
+ */
216
+ private _cancelSelectionRect;
217
+ /**
218
+ * Clean up selection rectangle overlay
219
+ */
220
+ private _cleanupSelectionRect;
221
+ /**
222
+ * Start bulk drag operation (T024, T025, T026, T032)
223
+ */
224
+ private _startBulkDrag;
225
+ /**
226
+ * Update bulk drag - apply delta to all selected elements (T027, T028)
227
+ */
228
+ private _updateBulkDrag;
229
+ /**
230
+ * Commit bulk drag operation (T029, T032)
231
+ */
232
+ private _commitBulkDrag;
233
+ /**
234
+ * Cancel bulk drag operation - revert all elements to initial positions (T030)
235
+ */
236
+ private _cancelBulkDrag;
237
+ /**
238
+ * Check if clipboard has content (T050)
239
+ */
240
+ hasClipboardContent(): boolean;
241
+ /**
242
+ * Copy current selection to clipboard (T039, T040, T041, T042, T051)
243
+ * @returns true if copy succeeded (non-empty selection)
244
+ */
245
+ copySelection(): boolean;
246
+ /**
247
+ * Paste clipboard content at cursor position (T044, T045, T046, T047, T049, T051)
248
+ * @returns true if paste succeeded (non-empty clipboard)
249
+ */
250
+ pasteAtCursor(): boolean;
251
+ /**
252
+ * Cut current selection (copy + delete) (T052)
253
+ * @returns true if cut succeeded
254
+ */
255
+ cutSelection(): boolean;
256
+ /**
257
+ * Delete all selected elements (T033, T034, T035, T036, T037)
258
+ *
259
+ * Deletion order per research.md:
260
+ * 1. Selected wires
261
+ * 2. Selected components (cascades to connected wires)
262
+ * 3. Selected branching points
263
+ */
264
+ deleteSelection(): boolean;
265
+ }