simple-circuit-engine 0.0.11 → 0.0.12

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 (141) hide show
  1. package/AGENTS.md +10 -7
  2. package/CLAUDE.md +4 -6
  3. package/README.md +5 -2
  4. package/dist/core/index.d.ts +0 -1
  5. package/dist/core/index.js +74 -2114
  6. package/dist/core/setup.d.ts +17 -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/basic/BatteryBehavior.d.ts +14 -0
  14. package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
  15. package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
  16. package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
  17. package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
  18. package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
  19. package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
  20. package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
  21. package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
  22. package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
  23. package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
  24. package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
  25. package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
  26. package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
  27. package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
  28. package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
  29. package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
  30. package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
  31. package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
  32. package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
  33. package/dist/core/simulation/behaviors/index.d.ts +24 -0
  34. package/dist/core/simulation/behaviors/types.d.ts +101 -0
  35. package/dist/core/simulation/index.d.ts +18 -0
  36. package/dist/core/simulation/states/ComponentState.d.ts +57 -0
  37. package/dist/core/simulation/states/SimulationState.d.ts +46 -0
  38. package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
  39. package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
  40. package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
  41. package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
  42. package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
  43. package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
  44. package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
  45. package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
  46. package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
  47. package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
  48. package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
  49. package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
  50. package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
  51. package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
  52. package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
  53. package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
  54. package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
  55. package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
  56. package/dist/core/simulation/states/gates/index.d.ts +25 -0
  57. package/dist/core/simulation/states/index.d.ts +26 -0
  58. package/dist/core/simulation/states/types.d.ts +32 -0
  59. package/dist/core/simulation/types.d.ts +155 -0
  60. package/dist/core/topology/Circuit.d.ts +420 -0
  61. package/dist/core/topology/CircuitMetadata.d.ts +24 -0
  62. package/dist/core/topology/CircuitOptions.d.ts +14 -0
  63. package/dist/core/topology/Component.d.ts +152 -0
  64. package/dist/core/topology/ENode.d.ts +200 -0
  65. package/dist/core/topology/Wire.d.ts +130 -0
  66. package/dist/core/topology/delays.d.ts +52 -0
  67. package/dist/core/topology/index.d.ts +14 -0
  68. package/dist/core/topology/types.d.ts +175 -0
  69. package/dist/core/utils/CameraOptions.d.ts +83 -0
  70. package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
  71. package/dist/core/utils/Position.d.ts +166 -0
  72. package/dist/core/utils/Position3D.d.ts +77 -0
  73. package/dist/core/utils/Rotation.d.ts +82 -0
  74. package/dist/core/utils/index.d.ts +24 -0
  75. package/dist/core/utils/types.d.ts +35 -0
  76. package/dist/core-Bjta9Y7_.js +2707 -0
  77. package/dist/core-Bjta9Y7_.js.map +1 -0
  78. package/dist/index.d.ts +13 -6306
  79. package/dist/index.js +117 -110
  80. package/dist/scene/CircuitEngine.d.ts +270 -0
  81. package/dist/scene/index.d.ts +0 -1
  82. package/dist/scene/index.js +43 -39
  83. package/dist/scene/setup.d.ts +18 -0
  84. package/dist/scene/shared/AbstractCircuitController.d.ts +211 -0
  85. package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
  86. package/dist/scene/shared/EventEmitter.d.ts +92 -0
  87. package/dist/scene/shared/HoverManager.d.ts +151 -0
  88. package/dist/scene/shared/SelectionManager.d.ts +159 -0
  89. package/dist/scene/shared/WireVisualManager.d.ts +242 -0
  90. package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
  91. package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
  92. package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
  93. package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
  94. package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
  95. package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
  96. package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
  97. package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
  98. package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
  99. package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
  100. package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
  101. package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
  102. package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
  103. package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
  104. package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
  105. package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
  106. package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
  107. package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
  108. package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
  109. package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
  110. package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
  111. package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
  112. package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
  113. package/dist/scene/shared/components/index.d.ts +29 -0
  114. package/dist/scene/shared/components/types.d.ts +43 -0
  115. package/dist/scene/shared/types.d.ts +476 -0
  116. package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
  117. package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
  118. package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
  119. package/dist/scene/shared/utils/GeometryUtils.d.ts +261 -0
  120. package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
  121. package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
  122. package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
  123. package/dist/scene/shared/utils/Options.d.ts +16 -0
  124. package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
  125. package/dist/scene/static/CircuitController.d.ts +227 -0
  126. package/dist/scene/static/CircuitWriter.d.ts +146 -0
  127. package/dist/scene/static/PinTooltipWidget.d.ts +26 -0
  128. package/dist/scene/static/tools/BuildTool.d.ts +286 -0
  129. package/dist/scene/static/tools/ComponentPickerWidget.d.ts +82 -0
  130. package/dist/scene/static/tools/ConfigPanelWidget.d.ts +93 -0
  131. package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
  132. package/dist/scene-CVsDdySt.js +7357 -0
  133. package/dist/scene-CVsDdySt.js.map +1 -0
  134. package/package.json +24 -25
  135. package/dist/CircuitRunner-BQQlhwjD.js +0 -1981
  136. package/dist/CircuitRunner-BQQlhwjD.js.map +0 -1
  137. package/dist/core/index.js.map +0 -1
  138. package/dist/index.js.map +0 -1
  139. package/dist/scene/index.js.map +0 -1
  140. package/dist/setup-CIq_kgaw.js +0 -10230
  141. package/dist/setup-CIq_kgaw.js.map +0 -1
package/dist/index.js CHANGED
@@ -1,115 +1,122 @@
1
- import { A as e, b as o, d as r, C as s, m as i, i as n, c as l, D as c, k as u, h as S, E as y, e as G, j as h, P as N, a as B, R as F, S as C, n as p, l as v, T as g, f as E, g as m, s as L } from "./CircuitRunner-BQQlhwjD.js";
2
- import { BatteryBehavior as I, BatteryState as V, BehaviorRegistry as d, Circuit as D, CircuitMetadata as R, CircuitOptions as M, ComponentState as b, DoubleThrowSwitchBehavior as O, DoubleThrowSwitchState as A, InverterBehavior as _, InverterState as P, LightbulbBehavior as w, LightbulbState as X, Memoize as f, MemoizeExpiring as x, Nand4GateBehavior as U, Nand4GateState as W, Nand8GateBehavior as k, Nand8GateState as H, NandGateBehavior as j, NandGateState as z, Nor4GateBehavior as Y, Nor4GateState as q, Nor8GateBehavior as Q, Nor8GateState as J, NorGateBehavior as K, NorGateState as Z, RectangleLEDBehavior as $, RectangleLEDState as aa, RelayBehavior as ta, RelayState as ea, SmallLEDBehavior as oa, SmallLEDState as ra, SwitchBehavior as sa, SwitchState as ia, Wire as na, Xor4GateBehavior as la, Xor4GateState as ca, Xor8GateBehavior as ua, Xor8GateState as Sa, XorGateBehavior as ya, XorGateState as Ga, classifyGate as ha, computeGateDelay as Na, computeTransitionSpan as Ba, registerBasicComponentsBehaviors as Fa, registerGatesComponentsBehaviors as Ca } from "./core/index.js";
3
- import { d as va, i as ga, f as Ea, B as ma, a as La, C as Ta, b as Ia, e as Va, c as da, D as Da, n as Ra, F as Ma, G as ba, g as Oa, H as Aa, I as _a, L as Pa, j as wa, M as Xa, o as fa, p as xa, N as Ua, s as Wa, t as ka, q as Ha, R as ja, k as za, S as Ya, l as qa, m as Qa, W as Ja, u as Ka, v as Za, X as $a, x as at, y as tt, w as et, r as ot, h as rt } from "./setup-CIq_kgaw.js";
1
+ import { $ as t, A as s, B as e, C as o, D as r, E as i, F as n, G as l, H as c, I as u, J as S, K as y, L as h, M as C, N as G, O as p, P as N, Q as B, R as F, S as m, T as v, U as g, V as E, W as T, X as V, Y as L, Z as I, _ as d, _t as D, a as M, at as R, b as _, bt as A, c as O, ct as b, d as P, dt as w, et as X, f, ft as U, g as k, gt as x, h as W, ht as H, i as z, it as Y, j, k as Q, l as q, lt as J, m as K, mt as Z, n as $, nt as aa, o as ta, ot as sa, p as ea, pt as oa, q as ra, r as ia, rt as na, s as la, st as ca, t as ua, tt as Sa, u as ya, ut as ha, v as Ca, vt as Ga, w as pa, x as Na, y as Ba, yt as Fa, z as ma } from "./core-Bjta9Y7_.js";
2
+ import { A as ga, B as Ea, C as Ta, D as Va, E as La, F as Ia, H as da, I as Da, L as Ma, M as Ra, N as _a, O as Aa, P as Oa, R as ba, S as Pa, T as wa, U as Xa, V as fa, W as Ua, _ as ka, a as xa, b as Wa, c as Ha, d as za, f as Ya, g as ja, h as Qa, i as qa, j as Ja, k as Ka, l as Za, m as $a, n as at, o as tt, p as st, r as et, s as ot, t as rt, u as it, v as nt, w as lt, x as ct, y as ut, z as St } from "./scene-CVsDdySt.js";
4
3
  export {
5
- e as ALL_LOGIC_FAMILIES,
6
- va as BRANCHING_POINT_SENTINEL,
7
- I as BatteryBehavior,
8
- V as BatteryState,
9
- ga as BatteryVisualFactory,
10
- d as BehaviorRegistry,
11
- Ea as BranchingPointVisualFactory,
12
- ma as BuildTool,
13
- o as CIRCUIT_FILE_VERSION,
14
- r as COMPONENT_TYPE_METADATA,
15
- s as CameraOptions,
16
- D as Circuit,
17
- La as CircuitController,
18
- Ta as CircuitEngine,
19
- R as CircuitMetadata,
20
- M as CircuitOptions,
21
- i as CircuitRunner,
22
- Ia as CircuitRunnerController,
23
- Va as CircuitWriter,
24
- n as Component,
25
- da as ComponentPickerWidget,
26
- b as ComponentState,
27
- l as ComponentType,
28
- c as DEFAULT_LOGIC_FAMILY,
29
- Da as DefaultVisualFactory,
30
- u as DirtyTracker,
31
- O as DoubleThrowSwitchBehavior,
32
- A as DoubleThrowSwitchState,
33
- Ra as DoubleThrowSwitchVisualFactory,
34
- S as ENode,
35
- y as ENodeSourceType,
36
- G as ENodeType,
37
- h as EventQueue,
38
- Ma as FactoryRegistry,
39
- ba as GroupedFactoryRegistry,
40
- Oa as HitboxLayers,
41
- Aa as HoverManager,
42
- _ as InverterBehavior,
43
- P as InverterState,
44
- _a as InverterVisualFactory,
45
- Pa as LabelVisualFactory,
46
- w as LightbulbBehavior,
47
- X as LightbulbState,
48
- wa as LightbulbVisualFactory,
49
- f as Memoize,
50
- x as MemoizeExpiring,
51
- Xa as MultiSelectTool,
52
- U as Nand4GateBehavior,
53
- W as Nand4GateState,
54
- fa as Nand4GateVisualFactory,
55
- k as Nand8GateBehavior,
56
- H as Nand8GateState,
57
- xa as Nand8GateVisualFactory,
58
- j as NandGateBehavior,
59
- z as NandGateState,
60
- Ua as NandGateVisualFactory,
61
- Y as Nor4GateBehavior,
62
- q as Nor4GateState,
63
- Wa as Nor4GateVisualFactory,
64
- Q as Nor8GateBehavior,
65
- J as Nor8GateState,
66
- ka as Nor8GateVisualFactory,
67
- K as NorGateBehavior,
68
- Z as NorGateState,
4
+ R as ALL_LOGIC_FAMILIES,
5
+ Xa as BRANCHING_POINT_SENTINEL,
6
+ pa as BatteryBehavior,
7
+ T as BatteryState,
8
+ ct as BatteryVisualFactory,
9
+ i as BehaviorRegistry,
10
+ Da as BranchingPointVisualFactory,
11
+ da as BuildTool,
12
+ sa as CIRCUIT_FILE_VERSION,
13
+ wa as CMP_MATERIALS,
14
+ ca as COMPONENT_TYPE_METADATA,
15
+ D as CameraOptions,
16
+ V as Circuit,
17
+ Ja as CircuitController,
18
+ Ka as CircuitEngine,
19
+ X as CircuitMetadata,
20
+ Sa as CircuitOptions,
21
+ ia as CircuitRunner,
22
+ ga as CircuitRunnerController,
23
+ St as CircuitWriter,
24
+ d as ClockBehavior,
25
+ h as ClockState,
26
+ st as ClockVisualFactory,
27
+ La as CmpMatCategory,
28
+ Va as CmpMatType,
29
+ Aa as CmpMatVariant,
30
+ aa as Component,
31
+ Ua as ComponentPickerWidget,
32
+ l as ComponentState,
33
+ b as ComponentType,
34
+ J as DEFAULT_LOGIC_FAMILY,
35
+ Ta as DefaultVisualFactory,
36
+ M as DirtyTracker,
37
+ Ca as DoubleThrowSwitchBehavior,
38
+ F as DoubleThrowSwitchState,
39
+ $a as DoubleThrowSwitchVisualFactory,
40
+ Y as ENode,
41
+ ha as ENodeSourceType,
42
+ w as ENodeType,
43
+ ta as EventQueue,
44
+ lt as FactoryRegistry,
45
+ Pa as GroupedFactoryRegistry,
46
+ ba as HitboxLayers,
47
+ Ma as HoverManager,
48
+ k as InverterBehavior,
49
+ u as InverterState,
50
+ Ya as InverterVisualFactory,
51
+ Wa as LabelVisualFactory,
52
+ o as LightbulbBehavior,
53
+ g as LightbulbState,
54
+ ut as LightbulbVisualFactory,
55
+ Fa as Memoize,
56
+ A as MemoizeExpiring,
57
+ fa as MultiSelectTool,
58
+ K as Nand4GateBehavior,
59
+ N as Nand4GateState,
60
+ it as Nand4GateVisualFactory,
61
+ ea as Nand8GateBehavior,
62
+ G as Nand8GateState,
63
+ Za as Nand8GateVisualFactory,
64
+ W as NandGateBehavior,
65
+ n as NandGateState,
66
+ za as NandGateVisualFactory,
67
+ P as Nor4GateBehavior,
68
+ j as Nor4GateState,
69
+ ot as Nor4GateVisualFactory,
70
+ ya as Nor8GateBehavior,
71
+ s as Nor8GateState,
72
+ tt as Nor8GateVisualFactory,
73
+ f as NorGateBehavior,
74
+ C as NorGateState,
69
75
  Ha as NorGateVisualFactory,
70
- N as Position,
71
- B as Position3D,
72
- $ as RectangleLEDBehavior,
73
- aa as RectangleLEDState,
74
- ja as RectangleLEDVisualFactory,
75
- ta as RelayBehavior,
76
- ea as RelayState,
77
- za as RelayVisualFactory,
78
- F as Rotation,
79
- C as SIMULATION_SPEED,
80
- Ya as SelectionManager,
81
- p as SimulationState,
82
- oa as SmallLEDBehavior,
83
- ra as SmallLEDState,
84
- qa as SmallLEDVisualFactory,
85
- v as StateManager,
86
- sa as SwitchBehavior,
87
- ia as SwitchState,
76
+ Z as Position,
77
+ Ga as Position3D,
78
+ m as RectangleLEDBehavior,
79
+ E as RectangleLEDState,
80
+ nt as RectangleLEDVisualFactory,
81
+ Na as RelayBehavior,
82
+ e as RelayState,
83
+ ka as RelayVisualFactory,
84
+ oa as Rotation,
85
+ S as SIMULATION_SPEED,
86
+ Ea as SelectionManager,
87
+ y as SimulationState,
88
+ _ as SmallLEDBehavior,
89
+ c as SmallLEDState,
90
+ ja as SmallLEDVisualFactory,
91
+ z as StateManager,
92
+ Ba as SwitchBehavior,
93
+ ma as SwitchState,
88
94
  Qa as SwitchVisualFactory,
89
- g as TRANSITION_DEFAULTS,
95
+ L as TRANSITION_DEFAULTS,
90
96
  na as Wire,
91
- Ja as WireVisualManager,
92
- la as Xor4GateBehavior,
93
- ca as Xor4GateState,
94
- Ka as Xor4GateVisualFactory,
95
- ua as Xor8GateBehavior,
96
- Sa as Xor8GateState,
97
- Za as Xor8GateVisualFactory,
98
- ya as XorGateBehavior,
99
- Ga as XorGateState,
100
- $a as XorGateVisualFactory,
101
- ha as classifyGate,
102
- Na as computeGateDelay,
103
- Ba as computeTransitionSpan,
104
- at as controllerOptions,
105
- tt as engineOptions,
106
- E as findPositionBestIndex,
107
- m as generateUUID,
108
- et as mapControlsOptions,
109
- Fa as registerBasicComponentsBehaviors,
110
- ot as registerBasicComponentsFactories,
111
- Ca as registerGatesComponentsBehaviors,
112
- rt as registerGatesComponentsFactories,
113
- L as simplifyPositions
97
+ Ia as WireVisualManager,
98
+ O as Xor4GateBehavior,
99
+ p as Xor4GateState,
100
+ qa as Xor4GateVisualFactory,
101
+ la as Xor8GateBehavior,
102
+ r as Xor8GateState,
103
+ et as Xor8GateVisualFactory,
104
+ q as XorGateBehavior,
105
+ Q as XorGateState,
106
+ xa as XorGateVisualFactory,
107
+ I as classifyGate,
108
+ B as computeGateDelay,
109
+ t as computeTransitionSpan,
110
+ Ra as controllerOptions,
111
+ _a as engineOptions,
112
+ H as findPositionBestIndex,
113
+ U as generateUUID,
114
+ v as getTransitionSpan,
115
+ Oa as mapControlsOptions,
116
+ ua as registerBasicComponentsBehaviors,
117
+ rt as registerBasicComponentsFactories,
118
+ $ as registerGatesComponentsBehaviors,
119
+ at as registerGatesComponentsFactories,
120
+ x as simplifyPositions,
121
+ ra as unionElectricalStates
114
122
  };
115
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,270 @@
1
+ import { MapControls } from 'three/addons/controls/MapControls.js';
2
+ import { EventEmitter } from './shared/EventEmitter';
3
+ import { Circuit, BehaviorRegistry } from '../core/index.ts';
4
+ import { CircuitController } from './static/CircuitController';
5
+ import { CircuitRunnerController } from './simulation/CircuitRunnerController';
6
+ import { IFactoryRegistry } from './shared/components/ComponentVisualFactory';
7
+ import { EngineMode, CircuitEngineEventMap, EngineOptions, ToolType } from './shared/types';
8
+ /**
9
+ * CircuitEngine - Unified Facade for Circuit Editing and Simulation
10
+ * @module scene/CircuitEngine
11
+ *
12
+ * Provides a unified API for both static circuit editing and live simulation,
13
+ * managing mode transitions and resource sharing between controllers.
14
+ */
15
+ import * as THREE from 'three';
16
+ /**
17
+ * CircuitEngine - Unified Facade for Circuit Editing and Simulation
18
+ *
19
+ * Manages two internal controllers:
20
+ * - CircuitController: Static editing with tools, selection, and manipulation
21
+ * - CircuitRunnerController: Live simulation with playback and animation
22
+ *
23
+ * Both controllers share the same Three.js scene, camera, and visual objects,
24
+ * enabling seamless transitions between edit and simulation modes.
25
+ *
26
+ * @example
27
+ * ```typescript
28
+ * const engine = new CircuitEngine(factoryRegistry, behaviorRegistry);
29
+ * engine.initialize(container);
30
+ * engine.setCircuit(circuit);
31
+ *
32
+ * // Edit mode (default)
33
+ * engine.setEditModeEnabled(true);
34
+ * engine.setActiveTool('build');
35
+ *
36
+ * // Switch to simulation
37
+ * engine.setMode('simulation');
38
+ * engine.play();
39
+ *
40
+ * // Switch back to edit
41
+ * engine.setMode('edit');
42
+ * ```
43
+ */
44
+ export declare class CircuitEngine extends EventEmitter<CircuitEngineEventMap> {
45
+ private readonly _factoryRegistry;
46
+ private readonly _behaviorRegistry;
47
+ private _sharedResources;
48
+ private _container;
49
+ private _editController;
50
+ private _simulationController;
51
+ private _mode;
52
+ private _initialized;
53
+ private _options;
54
+ private _disposed;
55
+ private _editControllerCleanup;
56
+ private _simulationControllerCleanup;
57
+ /**
58
+ * Create a new CircuitEngine instance.
59
+ *
60
+ * @param factoryRegistry - Registry of component visual factories
61
+ * @param behaviorRegistry - Registry of component simulation behaviors
62
+ * @throws {TypeError} If factoryRegistry or behaviorRegistry is null/undefined
63
+ */
64
+ constructor(factoryRegistry: IFactoryRegistry, behaviorRegistry: BehaviorRegistry);
65
+ /**
66
+ * Check if engine is initialized
67
+ */
68
+ get isInitialized(): boolean;
69
+ /**
70
+ * Check if engine is disposed
71
+ */
72
+ get isDisposed(): boolean;
73
+ /**
74
+ * Initialize the engine with a DOM container.
75
+ * Creates shared Three.js resources and both controllers.
76
+ *
77
+ * @param container - HTMLElement to mount the scene
78
+ * @param options - Configuration options
79
+ * @throws {TypeError} If container is not a valid HTMLElement
80
+ * @throws {Error} If already initialized
81
+ */
82
+ initialize(container: HTMLElement, options?: EngineOptions): void;
83
+ /**
84
+ * Create shared resources for both controllers.
85
+ */
86
+ private _createSharedResources;
87
+ /**
88
+ * Setup event forwarding from both controllers to engine.
89
+ */
90
+ private _setupEventForwarding;
91
+ /**
92
+ * Teardown event forwarding cleanup.
93
+ */
94
+ private _teardownEventForwarding;
95
+ /**
96
+ * Dispose all resources and clean up.
97
+ *
98
+ * @throws {Error} If not initialized or already disposed
99
+ */
100
+ dispose(): void;
101
+ /**
102
+ * Current operating mode
103
+ */
104
+ get mode(): EngineMode;
105
+ /**
106
+ * Switch between edit and simulation modes.
107
+ *
108
+ * @param mode - Target mode to switch to
109
+ * @throws {Error} If not initialized
110
+ * @throws {Error} If switching to simulation without a circuit loaded
111
+ */
112
+ setMode(mode: EngineMode): void;
113
+ /**
114
+ * Transition from edit mode to simulation mode.
115
+ */
116
+ private _transitionToSimulation;
117
+ /**
118
+ * Transition from simulation mode to edit mode.
119
+ */
120
+ private _transitionToEdit;
121
+ /**
122
+ * Load a circuit for editing/simulation.
123
+ *
124
+ * @param circuit - Circuit to load, or null to clear
125
+ * @throws {Error} If not initialized
126
+ */
127
+ setCircuit(circuit: Circuit | null): void;
128
+ /**
129
+ * Get the currently loaded circuit
130
+ */
131
+ getCircuit(): Circuit | null;
132
+ /**
133
+ * Get the edit controller for advanced operations.
134
+ *
135
+ * @throws {Error} If not initialized
136
+ */
137
+ getEditController(): CircuitController;
138
+ /**
139
+ * Get the simulation controller for advanced operations.
140
+ *
141
+ * @throws {Error} If not initialized
142
+ */
143
+ getSimulationController(): CircuitRunnerController;
144
+ /**
145
+ * Activate an editing tool.
146
+ *
147
+ * @param toolType - Tool to activate
148
+ * @throws {Error} If not in edit mode
149
+ */
150
+ setActiveTool(toolType: ToolType): void;
151
+ /**
152
+ * Get the currently active tool
153
+ *
154
+ * @throws {Error} If not in edit mode
155
+ */
156
+ getActiveTool(): ToolType | null;
157
+ /**
158
+ * Enable or disable edit mode (tool system).
159
+ *
160
+ * @param enabled - True to enable, false to disable
161
+ * @throws {Error} If not in edit mode
162
+ */
163
+ setEditModeEnabled(enabled: boolean): void;
164
+ /**
165
+ * Start automatic simulation playback.
166
+ *
167
+ * @throws {Error} If not in simulation mode
168
+ */
169
+ play(): void;
170
+ /**
171
+ * Pause automatic simulation playback.
172
+ *
173
+ * @throws {Error} If not in simulation mode
174
+ */
175
+ pause(): void;
176
+ /**
177
+ * Execute a single simulation tick.
178
+ *
179
+ * @throws {Error} If not in simulation mode
180
+ */
181
+ step(): void;
182
+ /**
183
+ * Stop simulation and reset to initial state.
184
+ *
185
+ * @throws {Error} If not in simulation mode
186
+ */
187
+ stop(): void;
188
+ /**
189
+ * Check if simulation is currently playing
190
+ */
191
+ get isPlaying(): boolean;
192
+ /**
193
+ * Get current simulation tick
194
+ */
195
+ get currentTick(): number;
196
+ /**
197
+ * Tick interval in milliseconds
198
+ */
199
+ get tickInterval(): number;
200
+ set tickInterval(value: number);
201
+ /**
202
+ * Simulation speed in ticks per second.
203
+ * Range: 1-20 TPS. Works in both edit and simulation modes.
204
+ */
205
+ get simulationSpeed(): number;
206
+ set simulationSpeed(tps: number);
207
+ /**
208
+ * Minimum allowed simulation speed in ticks per second.
209
+ */
210
+ get minSimulationSpeed(): number;
211
+ /**
212
+ * Maximum allowed simulation speed in ticks per second.
213
+ */
214
+ get maxSimulationSpeed(): number;
215
+ /**
216
+ * Update active animations. Call once per frame from the render loop.
217
+ * No-op if not initialized, disposed, or not in simulation mode.
218
+ *
219
+ * @param delta - Time in seconds since last frame (from THREE.Clock.getDelta())
220
+ */
221
+ update(delta: number): void;
222
+ /**
223
+ * Get the Three.js scene for external rendering.
224
+ *
225
+ * @throws {Error} If not initialized
226
+ */
227
+ getScene(): THREE.Scene;
228
+ /**
229
+ * Get the camera for external rendering.
230
+ *
231
+ * @throws {Error} If not initialized
232
+ */
233
+ getCamera(): THREE.PerspectiveCamera;
234
+ /**
235
+ * Get the MapControls for external manipulation.
236
+ *
237
+ * @throws {Error} If not initialized
238
+ */
239
+ getControls(): MapControls;
240
+ /**
241
+ * Hook called before exporting the circuit visualization.
242
+ * Saves world informations such as camera position, in the circuit metadata.
243
+ */
244
+ beforeExport(): void;
245
+ /**
246
+ * Handle container resize.
247
+ *
248
+ * @param width - New width (optional, uses container if omitted)
249
+ * @param height - New height (optional, uses container if omitted)
250
+ */
251
+ onContainerResize(width?: number, height?: number): void;
252
+ /**
253
+ * Check that controller is initialized and not disposed.
254
+ *
255
+ * @throws {Error} If not initialized or disposed
256
+ */
257
+ private _checkInitialized;
258
+ /**
259
+ * Check that controller is in edit mode.
260
+ *
261
+ * @throws {Error} If not in edit mode
262
+ */
263
+ private _checkEditMode;
264
+ /**
265
+ * Check that engine is in simulation mode.
266
+ *
267
+ * @throws {Error} If not in simulation mode
268
+ */
269
+ private _checkSimulationMode;
270
+ }
@@ -41,4 +41,3 @@ export { HitboxLayers } from './shared/utils/LayerConstants';
41
41
  export type { HitboxLayerValue } from './shared/utils/LayerConstants';
42
42
  export * from './shared/utils/Options';
43
43
  export { registerBasicComponentsFactories, registerGatesComponentsFactories } from './setup';
44
- //# sourceMappingURL=index.d.ts.map
@@ -1,43 +1,47 @@
1
- import { d as t, i as r, f as o, B as i, a as e, C as l, b as c, e as u, c as n, D as y, n as F, F as V, G as g, g as G, H as C, I as N, L as p, j as d, M as m, o as L, p as R, N as S, s as b, t as h, q as B, R as D, k as E, S as I, l as M, m as T, W as w, u as H, v as O, X as W, x as X, y as f, w as v, r as x, h as P } from "../setup-CIq_kgaw.js";
1
+ import { A as s, B as t, C as r, D as o, E as i, F as e, H as l, I as c, L as u, M as n, N as y, O as F, P as V, R as C, S as g, T as p, U as G, V as N, W as m, _ as M, a as L, b as R, c as S, d as T, f as d, g as E, h as b, i as h, j as B, k as I, l as D, m as O, n as P, o as w, p as A, r as H, s as W, t as _, u as f, v as k, w as v, x, y as X, z as j } from "../scene-CVsDdySt.js";
2
2
  export {
3
- t as BRANCHING_POINT_SENTINEL,
4
- r as BatteryVisualFactory,
5
- o as BranchingPointVisualFactory,
6
- i as BuildTool,
7
- e as CircuitController,
8
- l as CircuitEngine,
9
- c as CircuitRunnerController,
10
- u as CircuitWriter,
11
- n as ComponentPickerWidget,
12
- y as DefaultVisualFactory,
13
- F as DoubleThrowSwitchVisualFactory,
14
- V as FactoryRegistry,
3
+ G as BRANCHING_POINT_SENTINEL,
4
+ x as BatteryVisualFactory,
5
+ c as BranchingPointVisualFactory,
6
+ l as BuildTool,
7
+ p as CMP_MATERIALS,
8
+ B as CircuitController,
9
+ I as CircuitEngine,
10
+ s as CircuitRunnerController,
11
+ j as CircuitWriter,
12
+ A as ClockVisualFactory,
13
+ i as CmpMatCategory,
14
+ o as CmpMatType,
15
+ F as CmpMatVariant,
16
+ m as ComponentPickerWidget,
17
+ r as DefaultVisualFactory,
18
+ O as DoubleThrowSwitchVisualFactory,
19
+ v as FactoryRegistry,
15
20
  g as GroupedFactoryRegistry,
16
- G as HitboxLayers,
17
- C as HoverManager,
18
- N as InverterVisualFactory,
19
- p as LabelVisualFactory,
20
- d as LightbulbVisualFactory,
21
- m as MultiSelectTool,
22
- L as Nand4GateVisualFactory,
23
- R as Nand8GateVisualFactory,
24
- S as NandGateVisualFactory,
25
- b as Nor4GateVisualFactory,
26
- h as Nor8GateVisualFactory,
27
- B as NorGateVisualFactory,
28
- D as RectangleLEDVisualFactory,
29
- E as RelayVisualFactory,
30
- I as SelectionManager,
31
- M as SmallLEDVisualFactory,
32
- T as SwitchVisualFactory,
33
- w as WireVisualManager,
34
- H as Xor4GateVisualFactory,
35
- O as Xor8GateVisualFactory,
36
- W as XorGateVisualFactory,
37
- X as controllerOptions,
38
- f as engineOptions,
39
- v as mapControlsOptions,
40
- x as registerBasicComponentsFactories,
21
+ C as HitboxLayers,
22
+ u as HoverManager,
23
+ d as InverterVisualFactory,
24
+ R as LabelVisualFactory,
25
+ X as LightbulbVisualFactory,
26
+ N as MultiSelectTool,
27
+ f as Nand4GateVisualFactory,
28
+ D as Nand8GateVisualFactory,
29
+ T as NandGateVisualFactory,
30
+ W as Nor4GateVisualFactory,
31
+ w as Nor8GateVisualFactory,
32
+ S as NorGateVisualFactory,
33
+ k as RectangleLEDVisualFactory,
34
+ M as RelayVisualFactory,
35
+ t as SelectionManager,
36
+ E as SmallLEDVisualFactory,
37
+ b as SwitchVisualFactory,
38
+ e as WireVisualManager,
39
+ h as Xor4GateVisualFactory,
40
+ H as Xor8GateVisualFactory,
41
+ L as XorGateVisualFactory,
42
+ n as controllerOptions,
43
+ y as engineOptions,
44
+ V as mapControlsOptions,
45
+ _ as registerBasicComponentsFactories,
41
46
  P as registerGatesComponentsFactories
42
47
  };
43
- //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ import { IGroupedFactoryRegistry } from './shared/components';
2
+ /**
3
+ * Register all basic components visual factories in the basic group
4
+ * Basic components are : Battery, Clock, Label, Switches, Lightbulb, RectangleLED, Relay, SmallLED
5
+ * @public
6
+ * @param registry - A grouped factory registry to populate
7
+ * @returns The input registry for chaining
8
+ */
9
+ export declare function registerBasicComponentsFactories(registry: IGroupedFactoryRegistry): IGroupedFactoryRegistry;
10
+ /**
11
+ * Register all logic gates components visual factories in the gates group
12
+ * gates are : Inverter, NAND (2,4,8 inputs), NOR (2,4,8 inputs) and XOR (2,4,8 inputs)
13
+ * AND/OR are gotten by changing the activationLogic of NAND/NOR
14
+ * @public
15
+ * @param registry - A grouped factory registry to populate
16
+ * @returns The input registry for chaining
17
+ */
18
+ export declare function registerGatesComponentsFactories(registry: IGroupedFactoryRegistry): IGroupedFactoryRegistry;