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.
- package/AGENTS.md +10 -7
- package/CLAUDE.md +4 -6
- package/README.md +5 -2
- package/dist/core/index.d.ts +0 -1
- package/dist/core/index.js +74 -2114
- package/dist/core/setup.d.ts +17 -0
- package/dist/core/simulation/CircuitRunner.d.ts +176 -0
- package/dist/core/simulation/DirtyTracker.d.ts +87 -0
- package/dist/core/simulation/EventQueue.d.ts +68 -0
- package/dist/core/simulation/StateManager.d.ts +100 -0
- package/dist/core/simulation/behaviors/BehaviorRegistry.d.ts +70 -0
- package/dist/core/simulation/behaviors/ComponentBehavior.d.ts +53 -0
- package/dist/core/simulation/behaviors/basic/BatteryBehavior.d.ts +14 -0
- package/dist/core/simulation/behaviors/basic/ClockBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/DoubleThrowSwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/LightbulbBehavior.d.ts +23 -0
- package/dist/core/simulation/behaviors/basic/RectangleLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/RelayBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/SmallLEDBehavior.d.ts +24 -0
- package/dist/core/simulation/behaviors/basic/SwitchBehavior.d.ts +33 -0
- package/dist/core/simulation/behaviors/basic/index.d.ts +20 -0
- package/dist/core/simulation/behaviors/gates/InverterBehavior.d.ts +29 -0
- package/dist/core/simulation/behaviors/gates/Nand4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nand8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NandGateBehavior.d.ts +28 -0
- package/dist/core/simulation/behaviors/gates/Nor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Nor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/NorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/Xor4GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/Xor8GateBehavior.d.ts +18 -0
- package/dist/core/simulation/behaviors/gates/XorGateBehavior.d.ts +22 -0
- package/dist/core/simulation/behaviors/gates/index.d.ts +34 -0
- package/dist/core/simulation/behaviors/index.d.ts +24 -0
- package/dist/core/simulation/behaviors/types.d.ts +101 -0
- package/dist/core/simulation/index.d.ts +18 -0
- package/dist/core/simulation/states/ComponentState.d.ts +57 -0
- package/dist/core/simulation/states/SimulationState.d.ts +46 -0
- package/dist/core/simulation/states/basic/BatteryState.d.ts +16 -0
- package/dist/core/simulation/states/basic/ClockState.d.ts +16 -0
- package/dist/core/simulation/states/basic/DoubleThrowSwitchState.d.ts +21 -0
- package/dist/core/simulation/states/basic/LightbulbState.d.ts +21 -0
- package/dist/core/simulation/states/basic/RectangleLEDState.d.ts +9 -0
- package/dist/core/simulation/states/basic/RelayState.d.ts +25 -0
- package/dist/core/simulation/states/basic/SmallLEDState.d.ts +21 -0
- package/dist/core/simulation/states/basic/SwitchState.d.ts +25 -0
- package/dist/core/simulation/states/gates/InverterState.d.ts +17 -0
- package/dist/core/simulation/states/gates/Nand4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nand8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NandGateState.d.ts +16 -0
- package/dist/core/simulation/states/gates/Nor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Nor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/NorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor4GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/Xor8GateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/XorGateState.d.ts +10 -0
- package/dist/core/simulation/states/gates/index.d.ts +25 -0
- package/dist/core/simulation/states/index.d.ts +26 -0
- package/dist/core/simulation/states/types.d.ts +32 -0
- package/dist/core/simulation/types.d.ts +155 -0
- package/dist/core/topology/Circuit.d.ts +420 -0
- package/dist/core/topology/CircuitMetadata.d.ts +24 -0
- package/dist/core/topology/CircuitOptions.d.ts +14 -0
- package/dist/core/topology/Component.d.ts +152 -0
- package/dist/core/topology/ENode.d.ts +200 -0
- package/dist/core/topology/Wire.d.ts +130 -0
- package/dist/core/topology/delays.d.ts +52 -0
- package/dist/core/topology/index.d.ts +14 -0
- package/dist/core/topology/types.d.ts +175 -0
- package/dist/core/utils/CameraOptions.d.ts +83 -0
- package/dist/core/utils/MemoizeDecorator.d.ts +9 -0
- package/dist/core/utils/Position.d.ts +166 -0
- package/dist/core/utils/Position3D.d.ts +77 -0
- package/dist/core/utils/Rotation.d.ts +82 -0
- package/dist/core/utils/index.d.ts +24 -0
- package/dist/core/utils/types.d.ts +35 -0
- package/dist/core-Bjta9Y7_.js +2707 -0
- package/dist/core-Bjta9Y7_.js.map +1 -0
- package/dist/index.d.ts +13 -6306
- package/dist/index.js +117 -110
- package/dist/scene/CircuitEngine.d.ts +270 -0
- package/dist/scene/index.d.ts +0 -1
- package/dist/scene/index.js +43 -39
- package/dist/scene/setup.d.ts +18 -0
- package/dist/scene/shared/AbstractCircuitController.d.ts +211 -0
- package/dist/scene/shared/BranchingPointVisualFactory.d.ts +70 -0
- package/dist/scene/shared/EventEmitter.d.ts +92 -0
- package/dist/scene/shared/HoverManager.d.ts +151 -0
- package/dist/scene/shared/SelectionManager.d.ts +159 -0
- package/dist/scene/shared/WireVisualManager.d.ts +242 -0
- package/dist/scene/shared/components/ComponentVisualFactory.d.ts +438 -0
- package/dist/scene/shared/components/DefaultVisualFactory.d.ts +51 -0
- package/dist/scene/shared/components/FactoryRegistry.d.ts +84 -0
- package/dist/scene/shared/components/GroupedFactoryRegistry.d.ts +153 -0
- package/dist/scene/shared/components/basic/BatteryVisualFactory.d.ts +13 -0
- package/dist/scene/shared/components/basic/ClockVisualFactory.d.ts +79 -0
- package/dist/scene/shared/components/basic/DoubleThrowSwitchVisualFactory.d.ts +87 -0
- package/dist/scene/shared/components/basic/LabelVisualFactory.d.ts +148 -0
- package/dist/scene/shared/components/basic/LightbulbVisualFactory.d.ts +72 -0
- package/dist/scene/shared/components/basic/RectangleLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/RelayVisualFactory.d.ts +92 -0
- package/dist/scene/shared/components/basic/SmallLEDVisualFactory.d.ts +86 -0
- package/dist/scene/shared/components/basic/SwitchVisualFactory.d.ts +85 -0
- package/dist/scene/shared/components/gates/InverterVisualFactory.d.ts +104 -0
- package/dist/scene/shared/components/gates/Nand4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nand8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NandGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Nor4GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/Nor8GateVisualFactory.d.ts +27 -0
- package/dist/scene/shared/components/gates/NorGateVisualFactory.d.ts +101 -0
- package/dist/scene/shared/components/gates/Xor4GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/Xor8GateVisualFactory.d.ts +29 -0
- package/dist/scene/shared/components/gates/XorGateVisualFactory.d.ts +103 -0
- package/dist/scene/shared/components/index.d.ts +29 -0
- package/dist/scene/shared/components/types.d.ts +43 -0
- package/dist/scene/shared/types.d.ts +476 -0
- package/dist/scene/shared/utils/CameraUtils.d.ts +23 -0
- package/dist/scene/shared/utils/ColorUtils.d.ts +26 -0
- package/dist/scene/shared/utils/ControlsUtils.d.ts +8 -0
- package/dist/scene/shared/utils/GeometryUtils.d.ts +261 -0
- package/dist/scene/shared/utils/LayerConstants.d.ts +40 -0
- package/dist/scene/shared/utils/LightingUtils.d.ts +31 -0
- package/dist/scene/shared/utils/MaterialUtils.d.ts +73 -0
- package/dist/scene/shared/utils/Options.d.ts +16 -0
- package/dist/scene/simulation/CircuitRunnerController.d.ts +227 -0
- package/dist/scene/static/CircuitController.d.ts +227 -0
- package/dist/scene/static/CircuitWriter.d.ts +146 -0
- package/dist/scene/static/PinTooltipWidget.d.ts +26 -0
- package/dist/scene/static/tools/BuildTool.d.ts +286 -0
- package/dist/scene/static/tools/ComponentPickerWidget.d.ts +82 -0
- package/dist/scene/static/tools/ConfigPanelWidget.d.ts +93 -0
- package/dist/scene/static/tools/MultiSelectTool.d.ts +265 -0
- package/dist/scene-CVsDdySt.js +7357 -0
- package/dist/scene-CVsDdySt.js.map +1 -0
- package/package.json +24 -25
- package/dist/CircuitRunner-BQQlhwjD.js +0 -1981
- package/dist/CircuitRunner-BQQlhwjD.js.map +0 -1
- package/dist/core/index.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/scene/index.js.map +0 -1
- package/dist/setup-CIq_kgaw.js +0 -10230
- package/dist/setup-CIq_kgaw.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
|
+
}
|