simple-circuit-engine 0.0.10 → 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 +13 -7
  2. package/CLAUDE.md +16 -103
  3. package/README.md +8 -5
  4. package/dist/core/index.d.ts +2 -23
  5. package/dist/core/index.js +75 -2000
  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 -6286
  79. package/dist/index.js +120 -100
  80. package/dist/scene/CircuitEngine.d.ts +270 -0
  81. package/dist/scene/index.d.ts +1 -2
  82. package/dist/scene/index.js +44 -38
  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-DEb7JdNf.js +0 -1809
  136. package/dist/CircuitRunner-DEb7JdNf.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-AB1vFiis.js +0 -9918
  141. package/dist/setup-AB1vFiis.js.map +0 -1
@@ -0,0 +1,16 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for Battery components.
5
+ * Batteries are stateless always-on pinSources.
6
+ *
7
+ * @public
8
+ */
9
+ export declare class BatteryState extends ComponentState {
10
+ /**
11
+ * Create a new battery state.
12
+ *
13
+ * @param componentId - UUID of the battery component
14
+ */
15
+ constructor(componentId: UUID);
16
+ }
@@ -0,0 +1,16 @@
1
+ import { UUID } from '../../../utils';
2
+ import { ComponentState } from '../ComponentState';
3
+ /**
4
+ * Simulation state for Clock components.
5
+ * Clock output either voltage (LOGIC HIGH) or LOGIC LOW switching periodically
6
+ *
7
+ * @public
8
+ */
9
+ export declare class ClockState extends ComponentState {
10
+ /**
11
+ * Create a new Clock state, either gnd or vcc
12
+ *
13
+ * @param componentId - UUID of the Clock component
14
+ */
15
+ constructor(componentId: UUID);
16
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for DoubleSwitch (SPDT - Single-Pole Double-Throw - switch) components.
5
+ * These switches can be "input1", "1to2", "input2" or "2to1"
6
+ *
7
+ * @public
8
+ */
9
+ export declare class DoubleThrowSwitchState extends ComponentState {
10
+ /**
11
+ * Create a new double Switch state.
12
+ *
13
+ * @param componentId - UUID of the double Switch component
14
+ * @param initialState - Initial operational state (default: "input1")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if switch is in 1to2 or 2to1 state
19
+ */
20
+ get isInTransition(): boolean;
21
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for Lightbulb components.
5
+ * Lightbulbs can be "on" (emitting light) or "off".
6
+ *
7
+ * @public
8
+ */
9
+ export declare class LightbulbState extends ComponentState {
10
+ /**
11
+ * Create a new Lightbulb state.
12
+ *
13
+ * @param componentId - UUID of the Lightbulb component
14
+ * @param initialState - Initial operational state (default: "off")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if Lightbulb is in lit state (on or going_on)
19
+ */
20
+ get isLit(): boolean;
21
+ }
@@ -0,0 +1,9 @@
1
+ import { SmallLEDState } from './SmallLEDState';
2
+ /**
3
+ * Simulation state for RectangleLED components. Same as SmallLEDState.
4
+ * LEDs can be "on" (emitting light) or "off".
5
+ *
6
+ * @public
7
+ */
8
+ export declare class RectangleLEDState extends SmallLEDState {
9
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for mechanical Relay components.
5
+ * Relays can be "open", "closing", "closed", or "opening".
6
+ *
7
+ * @public
8
+ */
9
+ export declare class RelayState extends ComponentState {
10
+ /**
11
+ * Create a new Relay state.
12
+ *
13
+ * @param componentId - UUID of the Relay component
14
+ * @param initialState - Initial operational state (default: "open")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if relay is in opening or closing state
19
+ */
20
+ get isInTransition(): boolean;
21
+ /**
22
+ * Check if relay is in closed or closing state
23
+ */
24
+ get isClosed(): boolean;
25
+ }
@@ -0,0 +1,21 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for SmallLED components.
5
+ * LEDs can be "on" (emitting light) or "off".
6
+ *
7
+ * @public
8
+ */
9
+ export declare class SmallLEDState extends ComponentState {
10
+ /**
11
+ * Create a new SmallLED state.
12
+ *
13
+ * @param componentId - UUID of the LED component
14
+ * @param initialState - Initial operational state (default: "off")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if LED is in lit state (on or going_on)
19
+ */
20
+ get isLit(): boolean;
21
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for Switch components.
5
+ * Switches can be "open", "closing", "closed", or "opening".
6
+ *
7
+ * @public
8
+ */
9
+ export declare class SwitchState extends ComponentState {
10
+ /**
11
+ * Create a new Switch state.
12
+ *
13
+ * @param componentId - UUID of the Switch component
14
+ * @param initialState - Initial operational state (default: "open")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if switch is in opening or closing state
19
+ */
20
+ get isInTransition(): boolean;
21
+ /**
22
+ * Check if switch is in closed or closing state
23
+ */
24
+ get isClosed(): boolean;
25
+ }
@@ -0,0 +1,17 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for Inverter components
5
+ * Inverters can be "low", "rising", "high", or "falling".
6
+ *
7
+ * @public
8
+ */
9
+ export declare class InverterState extends LogicGateState {
10
+ /**
11
+ * Create a new Inverter state.
12
+ *
13
+ * @param componentId - UUID of the Inverter component
14
+ * @param initialState - Initial operational state (default: "low")
15
+ */
16
+ constructor(componentId: UUID, initialState?: string);
17
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NAND4 Gate components (4 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Nand4GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NAND8 Gate components (8 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Nand8GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,16 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NAND Gate components.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class NandGateState extends LogicGateState {
9
+ /**
10
+ * Create a new NAND Gate state.
11
+ *
12
+ * @param componentId - UUID of the NAND Gate component
13
+ * @param initialState - Initial operational state (default: "low")
14
+ */
15
+ constructor(componentId: UUID, initialState?: string);
16
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NOR4 Gate components (4 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Nor4GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NOR8 Gate components (8 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Nor8GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for NOR Gate components.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class NorGateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for XOR4 Gate components (4 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Xor4GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for XOR8 Gate components (8 inputs).
5
+ *
6
+ * @public
7
+ */
8
+ export declare class Xor8GateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,10 @@
1
+ import { LogicGateState } from './index';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for XOR Gate components.
5
+ *
6
+ * @public
7
+ */
8
+ export declare class XorGateState extends LogicGateState {
9
+ constructor(componentId: UUID, initialState?: string);
10
+ }
@@ -0,0 +1,25 @@
1
+ import { ComponentState } from '../ComponentState';
2
+ import { UUID } from '../../../utils/types';
3
+ /**
4
+ * Simulation state for Logic gates components
5
+ * Gates can be "low", "rising", "high", "falling" or "indeterminate" (if their input is not well-defined)
6
+ *
7
+ * @public
8
+ */
9
+ export declare abstract class LogicGateState extends ComponentState {
10
+ /**
11
+ * Create a new Inverter state.
12
+ *
13
+ * @param componentId - UUID of the Inverter component
14
+ * @param initialState - Initial operational state (default: "low")
15
+ */
16
+ protected constructor(componentId: UUID, initialState?: string);
17
+ /**
18
+ * Check if output is in a rising or falling transition
19
+ */
20
+ get isInTransition(): boolean;
21
+ /**
22
+ * Check if output is high
23
+ */
24
+ get isHigh(): boolean;
25
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Simulation state definitions
3
+ * @module core/simulation/states
4
+ */
5
+ export type { INodeElectricalState } from './types';
6
+ export { unionElectricalStates } from './types';
7
+ export { SimulationState } from './SimulationState.js';
8
+ export { ComponentState } from './ComponentState.js';
9
+ export { BatteryState } from './basic/BatteryState';
10
+ export { LightbulbState } from './basic/LightbulbState';
11
+ export { RectangleLEDState } from './basic/RectangleLEDState';
12
+ export { RelayState } from './basic/RelayState';
13
+ export { SmallLEDState } from './basic/SmallLEDState';
14
+ export { SwitchState } from './basic/SwitchState';
15
+ export { DoubleThrowSwitchState } from './basic/DoubleThrowSwitchState';
16
+ export { ClockState } from './basic/ClockState';
17
+ export { InverterState } from './gates/InverterState';
18
+ export { NandGateState } from './gates/NandGateState';
19
+ export { Nand4GateState } from './gates/Nand4GateState';
20
+ export { Nand8GateState } from './gates/Nand8GateState';
21
+ export { NorGateState } from './gates/NorGateState';
22
+ export { Nor4GateState } from './gates/Nor4GateState';
23
+ export { Nor8GateState } from './gates/Nor8GateState';
24
+ export { XorGateState } from './gates/XorGateState';
25
+ export { Xor4GateState } from './gates/Xor4GateState';
26
+ export { Xor8GateState } from './gates/Xor8GateState';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Binary electrical state for wires and enodes (connection points)
3
+ * @module core/simulation/states
4
+ * @public
5
+ */
6
+ export interface INodeElectricalState {
7
+ /**
8
+ * True if voltage is present at this node (potential > 0V).
9
+ * False if node is at ground potential or floating.
10
+ */
11
+ hasVoltage: boolean;
12
+ /**
13
+ * True if current is actively flowing through this node.
14
+ * False if no current flow (open circuit or equilibrium).
15
+ */
16
+ hasCurrent: boolean;
17
+ /**
18
+ * True only if the node is locked from state changes at circuit build time (ex: battery pins or other fixed-voltage/current pinSources).
19
+ * Important: Those nodes should never have their electrical state modified by the simulation controller!
20
+ * Always false for wires
21
+ */
22
+ locked: boolean;
23
+ }
24
+ /**
25
+ * Compute the union of multiple electrical states.
26
+ * Useful to derive a combined pin state from two or more pins
27
+ * (e.g. cmd_in + cmd_out → coil state).
28
+ *
29
+ * @param states - Two or more electrical states to combine
30
+ * @returns A new state where hasVoltage/hasCurrent are OR'd across inputs, locked is always false
31
+ */
32
+ export declare function unionElectricalStates(...states: INodeElectricalState[]): INodeElectricalState;
@@ -0,0 +1,155 @@
1
+ import { UUID } from '../utils';
2
+ /**
3
+ * Simulation speed bounds and defaults for ticks per second (TPS).
4
+ * @public
5
+ */
6
+ export declare const SIMULATION_SPEED: {
7
+ /**
8
+ * Minimum simulation speed in ticks per second
9
+ */
10
+ readonly MIN_TPS: 1;
11
+ /**
12
+ * Maximum simulation speed in ticks per second
13
+ */
14
+ readonly MAX_TPS: 50;
15
+ /**
16
+ * Default simulation speed in ticks per second
17
+ */
18
+ readonly DEFAULT_TPS: 3;
19
+ /**
20
+ * Default tick interval in milliseconds (1000 / DEFAULT_TPS)
21
+ */
22
+ readonly DEFAULT_INTERVAL_MS: 500;
23
+ };
24
+ /**
25
+ * Default transition timing values for components.
26
+ * @public
27
+ */
28
+ export declare const TRANSITION_DEFAULTS: {
29
+ /**
30
+ * Default transitionSpan for relays and transistors in ticks (instant transition)
31
+ */
32
+ readonly TRANSITION_SPAN_TICKS: 1;
33
+ /**
34
+ * Default transitionUserSpan for switches in milliseconds
35
+ */
36
+ readonly TRANSITION_USER_SPAN_MS: 200;
37
+ };
38
+ /**
39
+ * User command to be executed during simulation.
40
+ * Commands can be queued for future ticks or executed immediately.
41
+ *
42
+ * @public
43
+ */
44
+ export interface IUserCommand {
45
+ /**
46
+ * Type of command.
47
+ */
48
+ readonly type: 'toggle_switch';
49
+ /**
50
+ * UUID of target component.
51
+ */
52
+ readonly targetId: UUID;
53
+ /**
54
+ * tick when this command was scheduled.
55
+ */
56
+ scheduledAtTick: number;
57
+ /**
58
+ * Extra parameters associated with this command.
59
+ *
60
+ * For `toggle_switch` commands:
61
+ * - `tickCount`: Number of ticks for the switch transition. Computed at toggle time
62
+ * using the formula: `ceil(transitionUserSpan × simulationSpeed / 1000)` with minimum of 1.
63
+ * If not provided, behavior uses default transition timing.
64
+ */
65
+ readonly parameters?: Map<string, string> | null;
66
+ }
67
+ /**
68
+ * all reachable nodes and wires from a seed
69
+ */
70
+ export type IReachabilityResult = {
71
+ nodes: Set<UUID>;
72
+ wires: Set<UUID>;
73
+ };
74
+ /**
75
+ * Configuration options for CircuitRunner
76
+ */
77
+ export interface IRunnerOptions {
78
+ /**
79
+ * Enable historical state tracking.
80
+ * When true, past simulation states are preserved up to historyLimit.
81
+ * When false (default), only current state is retained for better performance.
82
+ * @default false
83
+ */
84
+ enableHistory?: boolean;
85
+ /**
86
+ * Maximum number of historical states to retain when enableHistory is true.
87
+ * Uses circular buffer—oldest states are overwritten when limit is reached.
88
+ * Must be a positive integer.
89
+ * @default 1000
90
+ */
91
+ historyLimit?: number;
92
+ }
93
+ /**
94
+ * Result statistics of one simulation tick run
95
+ */
96
+ export interface IRunnerResult {
97
+ startTick: number;
98
+ endTick: number;
99
+ componentUpdateCount: number;
100
+ nodeUpdateCount: number;
101
+ wireUpdateCount: number;
102
+ processedCommandCount: number;
103
+ scheduledEventCount: number;
104
+ firedEventCount: number;
105
+ }
106
+ /**
107
+ * Scheduled event for delayed component transitions.
108
+ * Events are ordered by readyAtTick in a min-heap priority queue.
109
+ * Events with same readyAtTick are processed in FIFO order (by scheduledAtTick).
110
+ *
111
+ * @public
112
+ */
113
+ export interface IScheduledEvent {
114
+ /**
115
+ * UUID of target component.
116
+ */
117
+ readonly targetId: UUID;
118
+ /**
119
+ * Tick when this event was scheduled (for FIFO ordering).
120
+ * @readonly
121
+ */
122
+ readonly scheduledAtTick: number;
123
+ /**
124
+ * Tick when this event should be processed.
125
+ * @readonly
126
+ */
127
+ readonly readyAtTick: number;
128
+ /**
129
+ * Indicates the type of this event, eg 'ClosingEnd', 'OpeningEnd', etc.
130
+ */
131
+ readonly type: string;
132
+ /**
133
+ * extra parameters associated with this event.
134
+ */
135
+ readonly parameters?: Map<string, string> | undefined;
136
+ }
137
+ /**
138
+ * Dirty elements collected during a tick, returned by getDirtyElements().
139
+ *
140
+ * @public
141
+ */
142
+ export interface IDirtyElements {
143
+ /**
144
+ * Components that changed state.
145
+ */
146
+ readonly components: ReadonlySet<UUID>;
147
+ /**
148
+ * Wires that changed electrical state.
149
+ */
150
+ readonly wires: ReadonlySet<UUID>;
151
+ /**
152
+ * ENodes that changed electrical state.
153
+ */
154
+ readonly enodes: ReadonlySet<UUID>;
155
+ }