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,290 @@
1
+ import { IEditingTool, ToolType, CursorType } from '../../shared/types';
2
+ import { CircuitController } from '../CircuitController';
3
+ /**
4
+ * Build Tool Implementation
5
+ * @module scene/static/tools/BuildTool
6
+ *
7
+ * Unified tool for all circuit editing operations:
8
+ * - Wire creation between endpoints
9
+ * - Element positioning (components, branching points, wire points)
10
+ * - Component rotation
11
+ * - Element deletion
12
+ * - Branching point creation
13
+ * - Component placement & addition (add_component mode with picker widget)
14
+ *
15
+ * Replaces old: PositionTool, WireTool, DeleteTool, BranchingPointTool, AddComponentTool
16
+ */
17
+ import * as THREE from 'three';
18
+ /**
19
+ * Unified tool for building circuits
20
+ * Implements all circuit editing functionality in a single tool
21
+ */
22
+ export declare class BuildTool implements IEditingTool {
23
+ readonly type: ToolType;
24
+ private _controller;
25
+ private mode;
26
+ private lastCancelledOp;
27
+ private lastOperationCompletedTs;
28
+ private wireCreationState;
29
+ private wireDragState;
30
+ private componentDragState;
31
+ private bpDragState;
32
+ private clipboard;
33
+ private pickerWidget;
34
+ private ghostPreview;
35
+ private hasOverlap;
36
+ private pickerSelection;
37
+ /**
38
+ * Construct a new BuildTool instance
39
+ * @param controller - The circuit scene controllerType instance
40
+ */
41
+ constructor(controller: CircuitController);
42
+ /**
43
+ * Activate build tool and set up event listeners
44
+ * Resets all tool state and attaches DOM event handlers
45
+ */
46
+ onActivate(): void;
47
+ /**
48
+ * Deactivate build tool and clean up event listeners
49
+ * Cancels any active operations and removes all event handlers
50
+ */
51
+ onDeactivate(): void;
52
+ /**
53
+ * Forward a language change to the component picker.
54
+ */
55
+ setLanguage(lng: string): void;
56
+ /**
57
+ * Cancel current ongoing operation : can be called from outside if needed
58
+ */
59
+ cancelOperation(): void;
60
+ /**
61
+ * Get the current cursor type for this tool
62
+ * Returns cursor based on current mode and hover state
63
+ */
64
+ getCursorType(): CursorType;
65
+ /**
66
+ * Get preview objects to render in the scene
67
+ * Returns array of preview objects currently visible
68
+ */
69
+ getPreviewObjects(): THREE.Object3D[];
70
+ /**
71
+ * Handle pointer down event
72
+ * Routes to appropriate operation based on hover target and state
73
+ */
74
+ private handlePointerDown;
75
+ /**
76
+ * Handle pointer up event
77
+ *
78
+ * Ends current operation, commits final positions to the circuit model,
79
+ * and re-enables camera controls.
80
+ *
81
+ * Completes current operation based on mode
82
+ */
83
+ private handlePointerUp;
84
+ /**
85
+ * Handle grid position move event according to ongoing mode
86
+ * Updates preview or drag position during active operations
87
+ */
88
+ private handleGridPositionMove;
89
+ /**
90
+ * Handle keyboard events
91
+ * Supports Escape (cancel), Delete/Backspace (delete), R (rotate), Ctrl+C (copy), Ctrl+V (paste)
92
+ */
93
+ private handleKeyDown;
94
+ /**
95
+ * Handle double-click events
96
+ * Routes to rotation (component) or branching point creation (wire/empty)
97
+ */
98
+ private handleDblClick;
99
+ /**
100
+ * Operations lifecycle methods
101
+ * (start, update, cancel, complete)
102
+ */
103
+ /**
104
+ * Start wire creation from source enode
105
+ * @param sourceEnodeId - Source enode ID
106
+ */
107
+ private startWireCreation;
108
+ /**
109
+ * Update wire creation preview with new target position
110
+ * @param position
111
+ * @private
112
+ */
113
+ private updateWireCreation;
114
+ /**
115
+ * Cancel wire creation and reset state
116
+ */
117
+ private cancelWireCreation;
118
+ /**
119
+ * Complete wire creation between source enode and :
120
+ * - existing target enode if it is hovered
121
+ * - new branching point on wire if target is a wire
122
+ * - new branching point if target is null
123
+ * @param hoveredElement - Currently hovered element at wire creation end
124
+ */
125
+ private completeWireCreation;
126
+ /**
127
+ * Start wire dragging operation
128
+ * @param wireId - Wire being dragged
129
+ * @param targetType - Type of drag target
130
+ * @param pointIndex - Index of intermediate point, or -1 for new/branching
131
+ * @param worldPosition - Initial position
132
+ */
133
+ private startWireDrag;
134
+ /**
135
+ * Update drag target position during drag
136
+ * @param worldPosition - Current cursor position in world space
137
+ */
138
+ private updateWireDrag;
139
+ /**
140
+ * Cancel wire drag operation and revert to original positions
141
+ */
142
+ private cancelWireDrag;
143
+ /**
144
+ * Commit drag operation and persist changes
145
+ */
146
+ private completeWireDrag;
147
+ /**
148
+ * Start component dragging operation
149
+ * @param componentId - UUID of the component being dragged
150
+ * @param worldPosition - Initial position
151
+ */
152
+ private startComponentDrag;
153
+ /**
154
+ * Update component visual position during drag
155
+ * @param worldPosition - Current cursor position in world space
156
+ */
157
+ private updateComponentDrag;
158
+ /**
159
+ * Cancel component drag operation and revert to original positions
160
+ */
161
+ private cancelComponentDrag;
162
+ /**
163
+ * complete component drag operation and persist changes
164
+ */
165
+ private completeComponentDrag;
166
+ /**
167
+ * Start branching point dragging operation
168
+ * @param enodeId - UUID of the branching point being dragged
169
+ * @param worldPosition - Initial position
170
+ */
171
+ private startBPDrag;
172
+ /**
173
+ * Update branching point position during drag
174
+ * @param worldPosition - Current cursor position in world space
175
+ */
176
+ private updateBPDrag;
177
+ /**
178
+ * Cancel branching point drag operation and revert to original positions
179
+ */
180
+ private cancelBPDrag;
181
+ /**
182
+ * Commit branching point drag operation and persist changes
183
+ */
184
+ private completeBPDrag;
185
+ /**
186
+ * private helpers
187
+ */
188
+ /**
189
+ * Create a standalone branching point at empty grid position (T048)
190
+ * @param worldPosition - 3D position in world space
191
+ */
192
+ private createStandaloneBranchingPoint;
193
+ /**
194
+ * Create a branching point on an existing wire, splitting it (T044)
195
+ * @param wireId - Wire to split
196
+ * @param worldPosition - 3D position in world space
197
+ */
198
+ private createBranchingPointOnWire;
199
+ /**
200
+ * Check if hoveredElement is a valid wire target during wire creation
201
+ * @param hoveredElement - Current hovered element or null
202
+ * @returns True if target is valid for wire endpoint
203
+ */
204
+ private isValidWireTarget;
205
+ /**
206
+ * Rotate a component 90° clockwise
207
+ *
208
+ * Updates both the circuit model and visual representation.
209
+ * Emits componentRotated event to notify listeners.
210
+ * Only works on selected components (not wires or enodes).
211
+ */
212
+ private rotateComponent;
213
+ /**
214
+ * Check if wire intermediate point should be merged or deleted
215
+ * Returns updated positions array after merge/delete check
216
+ * @param wire - Wire being modified
217
+ * @returns Final intermediate positions array
218
+ */
219
+ private checkMergeDelete;
220
+ /**
221
+ * Copy component type and rotation to clipboard
222
+ * @param componentId - UUID of the component to copy
223
+ */
224
+ private copyComponent;
225
+ /**
226
+ * Paste component from clipboard at hovered position
227
+ * Creates a new component with the type and rotation from clipboard
228
+ */
229
+ private pasteComponent;
230
+ /**
231
+ * Cycles the sourceType of an enode: null → Voltage → Current → null
232
+ * Updates both model and visual immediately.
233
+ * @param enodeId - UUID of the enode to cycle
234
+ * @param hitbox - hitbox of the enode being clicked
235
+ */
236
+ private cycleEnodeSourceType;
237
+ /**
238
+ * Open config panel for component (T014)
239
+ * Converts component world position to screen coordinates and opens panel
240
+ * @param componentId - UUID of the component to configure
241
+ * @param event - Mouse event for screen position
242
+ */
243
+ private openConfigPanel;
244
+ /**
245
+ * Enter add_component mode: open the picker widget and listen for cursor movement
246
+ * @param event - Mouse event (used for widget positioning)
247
+ */
248
+ private enterAddComponentMode;
249
+ /**
250
+ * Exit add_component mode: close widget, dispose ghost, return to idle
251
+ */
252
+ private exitAddComponentMode;
253
+ /**
254
+ * Called when user selects or deselects an item in the picker widget
255
+ */
256
+ private onPickerSelectionChange;
257
+ /**
258
+ * Place the currently selected item (component or branching point) at cursor position
259
+ */
260
+ private placeSelectedItem;
261
+ /**
262
+ * Update ghost preview position and overlap check during add_component mode
263
+ */
264
+ private updateAddComponentPreview;
265
+ /**
266
+ * Create ghost preview for the selected item
267
+ * @param selection - Component type or branching point sentinel
268
+ */
269
+ private createGhostPreview;
270
+ /**
271
+ * Dispose ghost preview and cleanup resources
272
+ */
273
+ private disposeGhostPreview;
274
+ /**
275
+ * Apply semi-transparent ghost effect to preview object
276
+ */
277
+ private applyGhostEffect;
278
+ /**
279
+ * Check if ghost preview overlaps with existing components
280
+ */
281
+ private checkGhostOverlap;
282
+ /**
283
+ * Apply red emissive to indicate invalid placement
284
+ */
285
+ private applyInvalidEffect;
286
+ /**
287
+ * Remove red emissive invalid placement effect
288
+ */
289
+ private removeInvalidEffect;
290
+ }
@@ -0,0 +1,89 @@
1
+ import { ComponentType } from '../../../core/index.ts';
2
+ import { IGroupedFactoryRegistry } from '../../shared/components/GroupedFactoryRegistry';
3
+ /**
4
+ * Sentinel value representing the "Branching Point" pseudo-component entry.
5
+ * When selected, BuildTool creates a branching point instead of a component.
6
+ */
7
+ export declare const BRANCHING_POINT_SENTINEL: "__branching_point__";
8
+ /**
9
+ * Union of actual component types and the branching point sentinel.
10
+ */
11
+ export type PickerSelection = ComponentType | typeof BRANCHING_POINT_SENTINEL;
12
+ /**
13
+ * Persisted widget state (survives open/close cycles within a session).
14
+ */
15
+ export interface ComponentPickerState {
16
+ selectedGroupId: string;
17
+ selectedItem: PickerSelection | null;
18
+ widgetWidth: number;
19
+ widgetHeight: number;
20
+ }
21
+ /**
22
+ * DOM overlay widget for selecting components from grouped registry.
23
+ *
24
+ * Features:
25
+ * - Group dropdown for filtering component types
26
+ * - Scrollable item list with selection highlight
27
+ * - Draggable header bar
28
+ * - Resizable via CSS resize
29
+ * - State persistence across open/close (group, selection, size)
30
+ */
31
+ export declare class ComponentPickerWidget {
32
+ private readonly registry;
33
+ private container;
34
+ private titleEl;
35
+ private groupDropdown;
36
+ private itemList;
37
+ private state;
38
+ private readonly onSelectionChange;
39
+ private readonly onClose;
40
+ private escapeHandler;
41
+ private dragOffset;
42
+ private dragMoveHandler;
43
+ private dragEndHandler;
44
+ /**
45
+ * @param registry - Grouped factory registry providing groups and component types
46
+ * @param onSelectionChange - Called when user selects or deselects an item
47
+ * @param onClose - Called when user closes the widget (close button or Escape)
48
+ */
49
+ constructor(registry: IGroupedFactoryRegistry, onSelectionChange: (selection: PickerSelection | null) => void, onClose: () => void);
50
+ /** Whether the widget is currently open and visible */
51
+ get isOpen(): boolean;
52
+ /** The currently selected item (persists across open/close) */
53
+ get currentSelection(): PickerSelection | null;
54
+ /**
55
+ * Open the widget at the given screen position.
56
+ * If already open, repositions to the new location.
57
+ *
58
+ * @param screenPosition - Screen coordinates (typically from mouse event)
59
+ */
60
+ open(screenPosition: {
61
+ x: number;
62
+ y: number;
63
+ }): void;
64
+ /**
65
+ * Close the widget and remove DOM.
66
+ * Preserves state (group, selection, size) for next open.
67
+ */
68
+ close(): void;
69
+ /**
70
+ * Full cleanup including state reset.
71
+ */
72
+ dispose(): void;
73
+ /**
74
+ * Refresh all user-visible text in place after a language change.
75
+ * No-op if the widget is not currently open.
76
+ * Preserves drag position, scroll, resize dimensions, and current selection.
77
+ */
78
+ setLanguage(_lng: string): void;
79
+ private createDOM;
80
+ private renderItemList;
81
+ private createItemElement;
82
+ private selectItem;
83
+ private positionContainer;
84
+ private startDrag;
85
+ private onDragMove;
86
+ private endDrag;
87
+ private registerEventListeners;
88
+ private removeEventListeners;
89
+ }
@@ -0,0 +1,107 @@
1
+ import { UUID, Component } from '../../../core/index.ts';
2
+ import { IFactoryRegistry } from '../../shared/components/ComponentVisualFactory';
3
+ /**
4
+ * Manages lil-gui configuration panel for component config editing
5
+ *
6
+ * Responsibilities:
7
+ * - Panel lifecycle (open, close, dispose)
8
+ * - DOM container creation and positioning
9
+ * - lil-gui initialization and form building
10
+ * - Click-outside and Escape key handling
11
+ * - onChange event wiring to update component config
12
+ * - Event emission for config changes
13
+ */
14
+ export declare class ConfigPanelWidget {
15
+ private factoryRegistry;
16
+ private readonly editComponentConfig;
17
+ private _isOpen;
18
+ private _currentComponentId;
19
+ private _currentComponent;
20
+ private _currentFactory;
21
+ private gui;
22
+ private container;
23
+ private formDataObject;
24
+ private clickOutsideHandler;
25
+ private escapeHandler;
26
+ /**
27
+ * Create a new ConfigPanelManager
28
+ *
29
+ * @param factoryRegistry - Factory registry for getting component factories
30
+ * @param editComponentConfig - Function to edit component config
31
+ * @param _camera - Three.js camera (reserved for future use)
32
+ * @param _domElement - Container DOM element (reserved for future use)
33
+ */
34
+ constructor(factoryRegistry: IFactoryRegistry, editComponentConfig: (componentId: UUID, newConfig: Map<string, string>) => void, _camera: unknown, _domElement: unknown);
35
+ /**
36
+ * Check if panel is currently open
37
+ */
38
+ get isOpen(): boolean;
39
+ /**
40
+ * Get the ID of the component currently being edited
41
+ */
42
+ get currentComponentId(): UUID | null;
43
+ /**
44
+ * Open the config panel for a component
45
+ *
46
+ * @param component - component to edit
47
+ * @param screenPosition - Screen coordinates for panel positioning
48
+ * @returns true if panel opened, false if component has no config
49
+ */
50
+ open(component: Component, screenPosition: {
51
+ x: number;
52
+ y: number;
53
+ }): boolean;
54
+ /**
55
+ * Close the config panel if open
56
+ */
57
+ close(): void;
58
+ /**
59
+ * Dispose of all resources
60
+ */
61
+ dispose(): void;
62
+ /**
63
+ * Position the container adjacent to component (right side preferred)
64
+ */
65
+ private positionContainer;
66
+ /**
67
+ * Build lil-gui from form definition
68
+ */
69
+ private buildGui;
70
+ /**
71
+ * Handle value change in the config form
72
+ * Maps form data back to core config and updates the component.
73
+ * When defaultLogicFamily or activationLogic changes, rebuilds the GUI to reflect
74
+ * updated disabled states and computed transitionSpan values.
75
+ *
76
+ * @param changedKey - The key of the field that changed
77
+ * @param _value - The new value
78
+ * @param component - Component being edited
79
+ * @param factory - Visual factory for the component
80
+ */
81
+ private onValueChange;
82
+ /**
83
+ * Resolve a form field label via i18n, falling back to a humanised form
84
+ * of the field key when no translation is available (e.g. "transitionSpan" →
85
+ * "Transition Span"). The fallback covers two cases: (a) the consumer never
86
+ * called registerSceTranslations, (b) the key is not yet in the locale file.
87
+ */
88
+ private _resolveFieldLabel;
89
+ /**
90
+ * Refresh the panel to display strings in the current language.
91
+ * No-op if the panel is not open.
92
+ */
93
+ setLanguage(_lng: string): void;
94
+ /**
95
+ * Rebuild the GUI in place, re-reading the updated component config.
96
+ * Used after interdependent field changes (defaultLogicFamily, activationLogic).
97
+ */
98
+ private rebuildGui;
99
+ /**
100
+ * Setup event listeners for dismissing the panel
101
+ */
102
+ private setupEventListeners;
103
+ /**
104
+ * Remove event listeners
105
+ */
106
+ private removeEventListeners;
107
+ }