simple-circuit-engine 0.0.13 → 0.0.14
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 +7 -5
- package/README.md +8 -8
- package/dist/core/index.js +110 -85
- package/dist/core/setup.d.ts +10 -0
- package/dist/core/simulation/behaviors/index.d.ts +10 -0
- package/dist/core/simulation/behaviors/interface/EightInputBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/EightLightBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/FourInputBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/FourLightBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/InputBehaviorMixin.d.ts +37 -0
- package/dist/core/simulation/behaviors/interface/LightBehaviorMixin.d.ts +60 -0
- package/dist/core/simulation/behaviors/interface/OneInputBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/OneLightBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/TwoInputBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/TwoLightBehavior.d.ts +9 -0
- package/dist/core/simulation/behaviors/interface/index.d.ts +0 -0
- package/dist/core/simulation/states/index.d.ts +10 -0
- package/dist/core/simulation/states/interface/EightInputState.d.ts +6 -0
- package/dist/core/simulation/states/interface/EightLightState.d.ts +6 -0
- package/dist/core/simulation/states/interface/FourInputState.d.ts +6 -0
- package/dist/core/simulation/states/interface/FourLightState.d.ts +6 -0
- package/dist/core/simulation/states/interface/InputState.d.ts +45 -0
- package/dist/core/simulation/states/interface/LightState.d.ts +54 -0
- package/dist/core/simulation/states/interface/OneInputState.d.ts +6 -0
- package/dist/core/simulation/states/interface/OneLightState.d.ts +6 -0
- package/dist/core/simulation/states/interface/TwoInputState.d.ts +6 -0
- package/dist/core/simulation/states/interface/TwoLightState.d.ts +6 -0
- package/dist/core/simulation/types.d.ts +9 -1
- package/dist/core/topology/Component.d.ts +4 -0
- package/dist/core/topology/ENode.d.ts +7 -2
- package/dist/core/topology/index.d.ts +2 -0
- package/dist/core/topology/networkTraversal.d.ts +50 -0
- package/dist/core/topology/types.d.ts +13 -2
- package/dist/{core-b6Q8w2sn.js → core-HH6iRWtB.js} +1850 -739
- package/dist/core-HH6iRWtB.js.map +1 -0
- package/dist/i18n/index.d.ts +276 -0
- package/dist/i18n/locales/en.json.d.ts +98 -0
- package/dist/i18n/locales/fr.json.d.ts +98 -0
- package/dist/index.js +172 -135
- package/dist/scene/CircuitEngine.d.ts +36 -4
- package/dist/scene/index.d.ts +6 -2
- package/dist/scene/index.js +62 -50
- package/dist/scene/setup.d.ts +10 -0
- package/dist/scene/shared/AbstractCircuitController.d.ts +5 -3
- package/dist/scene/shared/HoverManager.d.ts +15 -0
- package/dist/scene/shared/components/index.d.ts +10 -0
- package/dist/scene/shared/components/interface/EightInputVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/EightLightVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/FourInputVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/FourLightVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/InputVisualFactoryBase.d.ts +50 -0
- package/dist/scene/shared/components/interface/LightVisualFactoryBase.d.ts +46 -0
- package/dist/scene/shared/components/interface/OneInputVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/OneLightVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/TwoInputVisualFactory.d.ts +15 -0
- package/dist/scene/shared/components/interface/TwoLightVisualFactory.d.ts +15 -0
- package/dist/scene/shared/types.d.ts +34 -2
- package/dist/scene/shared/utils/ControlsUtils.d.ts +1 -1
- package/dist/scene/shared/utils/GeometryUtils.d.ts +35 -0
- package/dist/scene/static/CircuitController.d.ts +12 -1
- package/dist/scene/static/tools/BuildTool.d.ts +77 -0
- package/dist/scene/static/tools/MultiWiringPlacement.d.ts +40 -0
- package/dist/scene/widgets/HelpWidget.d.ts +13 -0
- package/dist/scene/widgets/ModeWidget.d.ts +16 -0
- package/dist/scene/widgets/MultiWiringWidget.d.ts +21 -0
- package/dist/scene/{static → widgets}/PinTooltipWidget.d.ts +2 -1
- package/dist/scene/widgets/SimulationPlayerWidget.d.ts +62 -0
- package/dist/scene/widgets/ToolsWidget.d.ts +18 -0
- package/dist/scene/widgets/WidgetsManager.d.ts +65 -0
- package/dist/scene/widgets/assets/icons.d.ts +20 -0
- package/dist/scene/widgets/index.d.ts +9 -0
- package/dist/scene/widgets/styles.d.ts +33 -0
- package/dist/{scene-D4QcWeiq.js → scene-C1xhdw_B.js} +3311 -1478
- package/dist/scene-C1xhdw_B.js.map +1 -0
- package/package.json +2 -2
- package/dist/core-b6Q8w2sn.js.map +0 -1
- package/dist/scene-D4QcWeiq.js.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UUID } from '../../../utils/types';
|
|
2
|
+
import { LightState } from './LightState';
|
|
3
|
+
/** Single-light input mirror. Stable states `'0'` and `'1'`. */
|
|
4
|
+
export declare class OneLightState extends LightState {
|
|
5
|
+
constructor(componentId: UUID, initialState?: string);
|
|
6
|
+
}
|
|
@@ -44,8 +44,13 @@ export declare const TRANSITION_DEFAULTS: {
|
|
|
44
44
|
export interface IUserCommand {
|
|
45
45
|
/**
|
|
46
46
|
* Type of command.
|
|
47
|
+
*
|
|
48
|
+
* - `toggle_switch`: flip a (double-throw) switch component.
|
|
49
|
+
* - `toggle_input`: flip one switch of a multi-switch input component
|
|
50
|
+
* (OneInput, TwoInput, FourInput, EightInput); `parameters` MUST carry
|
|
51
|
+
* `index` identifying which switch was toggled.
|
|
47
52
|
*/
|
|
48
|
-
readonly type: 'toggle_switch';
|
|
53
|
+
readonly type: 'toggle_switch' | 'toggle_input';
|
|
49
54
|
/**
|
|
50
55
|
* UUID of target component.
|
|
51
56
|
*/
|
|
@@ -61,6 +66,9 @@ export interface IUserCommand {
|
|
|
61
66
|
* - `tickCount`: Number of ticks for the switch transition. Computed at toggle time
|
|
62
67
|
* using the formula: `ceil(transitionUserSpan × simulationSpeed / 1000)` with minimum of 1.
|
|
63
68
|
* If not provided, behavior uses default transition timing.
|
|
69
|
+
*
|
|
70
|
+
* For `toggle_input` commands:
|
|
71
|
+
* - `index`: index of the toggled switch within the multi-switch component.
|
|
64
72
|
*/
|
|
65
73
|
readonly parameters?: Map<string, string> | null;
|
|
66
74
|
}
|
|
@@ -97,6 +97,10 @@ export declare class Component {
|
|
|
97
97
|
constructor(type: ComponentType, position: Position, rotation: Rotation, pins: ReadonlyArray<UUID>, editable?: boolean);
|
|
98
98
|
getPinLabel(pinId: UUID): string | undefined;
|
|
99
99
|
getPinMetadata(pinId: UUID): IPinMetadata | undefined;
|
|
100
|
+
/** Resolve the ENode UUID of the logic pin at `index` within `interfaceName`, or undefined. */
|
|
101
|
+
getPinIdByInterface(interfaceName: string, index: number): UUID | undefined;
|
|
102
|
+
/** Largest index found across pins of the given logic interface, or -1 if none. */
|
|
103
|
+
getInterfaceMaxIndex(interfaceName: string): number;
|
|
100
104
|
setAllParameters(config: Map<string, string>): void;
|
|
101
105
|
setParameter(key: string, value: string): void;
|
|
102
106
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UUID, Position } from '../utils';
|
|
2
|
-
import { ENodeSourceType, ENodeType, IENode } from './types';
|
|
2
|
+
import { ENodeSourceType, ENodeType, IENode, ILogicPinMetadata } from './types';
|
|
3
3
|
import { Circuit } from './Circuit';
|
|
4
4
|
/**
|
|
5
5
|
* Electrical connection point (component pin or wire branching point).
|
|
@@ -76,6 +76,10 @@ export declare class ENode {
|
|
|
76
76
|
* @readonly
|
|
77
77
|
*/
|
|
78
78
|
readonly subtype: string;
|
|
79
|
+
/**
|
|
80
|
+
* logic pin metadata for logicInput / logicOutput pins
|
|
81
|
+
*/
|
|
82
|
+
readonly logicMetadata: ILogicPinMetadata | undefined;
|
|
79
83
|
/**
|
|
80
84
|
* Create a new electrical node.
|
|
81
85
|
*
|
|
@@ -89,6 +93,7 @@ export declare class ENode {
|
|
|
89
93
|
* @param source - Source type (Voltage/Current) or undefined
|
|
90
94
|
*
|
|
91
95
|
* @param subtype
|
|
96
|
+
* @param logicMetadata
|
|
92
97
|
* @example
|
|
93
98
|
* ```typescript
|
|
94
99
|
* // Pin node (internal to Circuit)
|
|
@@ -110,7 +115,7 @@ export declare class ENode {
|
|
|
110
115
|
* );
|
|
111
116
|
* ```
|
|
112
117
|
*/
|
|
113
|
-
constructor(type: ENodeType, component: UUID | undefined, pinLabel: string | undefined, position: Position | undefined, source
|
|
118
|
+
constructor(type: ENodeType, component: UUID | undefined, pinLabel: string | undefined, position: Position | undefined, source: ENodeSourceType | undefined, subtype: string | undefined, logicMetadata: ILogicPinMetadata | undefined);
|
|
114
119
|
/**
|
|
115
120
|
* Get the position of this electrical node.
|
|
116
121
|
*
|
|
@@ -12,3 +12,5 @@ export { CircuitOptions } from './CircuitOptions.js';
|
|
|
12
12
|
export { CircuitMetadata } from './CircuitMetadata.js';
|
|
13
13
|
export { Circuit } from './Circuit.js';
|
|
14
14
|
export { computeTransitionSpan, classifyGate, computeGateDelay } from './delays.js';
|
|
15
|
+
export { findPinsReachableFromBp, findBpsAtLogicDistance, findPinsReachableFromBpWithPath, findBpsAtLogicDistanceWithPath, } from './networkTraversal.js';
|
|
16
|
+
export type { IPinReach, IBpAtDistance } from './networkTraversal.js';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Circuit } from './Circuit';
|
|
2
|
+
import { UUID } from '../utils';
|
|
3
|
+
/** Reach record returned by `findPinsReachableFromBpWithPath`. */
|
|
4
|
+
export interface IPinReach {
|
|
5
|
+
/** Logic distance — number of wire edges from the start BP to this pin. */
|
|
6
|
+
Dl: number;
|
|
7
|
+
/** ENode immediately preceding the pin on the shortest BFS path back to the
|
|
8
|
+
* start BP. For Dl=1 this is the start BP itself. */
|
|
9
|
+
predecessor: UUID;
|
|
10
|
+
}
|
|
11
|
+
/** Sibling record returned by `findBpsAtLogicDistanceWithPath`. */
|
|
12
|
+
export interface IBpAtDistance {
|
|
13
|
+
/** Branching-point UUID at exactly the requested logic distance. */
|
|
14
|
+
id: UUID;
|
|
15
|
+
/** ENode immediately preceding this BP on the shortest BFS path back to
|
|
16
|
+
* the start pin. For Dl=1 this is the start pin itself. */
|
|
17
|
+
predecessor: UUID;
|
|
18
|
+
}
|
|
19
|
+
/** BFS the BP-only sub-graph from a start branching point and report every
|
|
20
|
+
* pin reached as a terminal endpoint, with its logic distance Dl.
|
|
21
|
+
*
|
|
22
|
+
* Pins are NEVER traversed through. If two paths reach the same pin, the
|
|
23
|
+
* smallest Dl wins.
|
|
24
|
+
*
|
|
25
|
+
* @returns A map of `pinId → Dl`. Empty if no pin is reachable.
|
|
26
|
+
*/
|
|
27
|
+
export declare function findPinsReachableFromBp(circuit: Circuit, startBpId: UUID): Map<UUID, number>;
|
|
28
|
+
/** Same as `findPinsReachableFromBp` but each entry also carries the BFS
|
|
29
|
+
* predecessor (the ENode one step closer to the start BP on the shortest
|
|
30
|
+
* path). Used by rule 4 to identify which of newBP's two wires leads back
|
|
31
|
+
* to the anchor pin.
|
|
32
|
+
*
|
|
33
|
+
* Map insertion order matches BFS visit order, so iterating it yields ties
|
|
34
|
+
* in BFS-first order.
|
|
35
|
+
*/
|
|
36
|
+
export declare function findPinsReachableFromBpWithPath(circuit: Circuit, startBpId: UUID): Map<UUID, IPinReach>;
|
|
37
|
+
/** BFS the BP-only sub-graph from a start pin and return every BP reached at
|
|
38
|
+
* exactly logic distance `Dl` (i.e. path-edge count = `Dl`).
|
|
39
|
+
*
|
|
40
|
+
* Branches that hit any pin before reaching the target depth are cut. The
|
|
41
|
+
* start pin itself is never returned.
|
|
42
|
+
*
|
|
43
|
+
* @returns Array of branching-point UUIDs at logic distance Dl from the pin.
|
|
44
|
+
*/
|
|
45
|
+
export declare function findBpsAtLogicDistance(circuit: Circuit, startPinId: UUID, Dl: number): UUID[];
|
|
46
|
+
/** Same as `findBpsAtLogicDistance` but each entry carries the BFS
|
|
47
|
+
* predecessor (one step closer to the start pin). Used by rule 4 to identify
|
|
48
|
+
* which wire of each sibling to split.
|
|
49
|
+
*/
|
|
50
|
+
export declare function findBpsAtLogicDistanceWithPath(circuit: Circuit, startPinId: UUID, Dl: number): IBpAtDistance[];
|
|
@@ -2,7 +2,7 @@ import { ICameraOptions, IPosition, UUID } from '../utils';
|
|
|
2
2
|
/**
|
|
3
3
|
* canonic version for circuit files produced
|
|
4
4
|
*/
|
|
5
|
-
export declare const CIRCUIT_FILE_VERSION = "0.0.
|
|
5
|
+
export declare const CIRCUIT_FILE_VERSION = "0.0.14";
|
|
6
6
|
/**
|
|
7
7
|
* Type of electrical pinSources in the circuit.
|
|
8
8
|
*
|
|
@@ -55,10 +55,12 @@ export declare enum ENodeType {
|
|
|
55
55
|
*
|
|
56
56
|
* @property interface - name of the pin's interface (one interface combine several pins in the case of numeric inputs/outpus)
|
|
57
57
|
* @property index - index of the pin within the interface (starts at 0 by convention)
|
|
58
|
+
* @property size - whole size of the interface, e.g. number of pins it has
|
|
58
59
|
*/
|
|
59
60
|
export interface ILogicPinMetadata {
|
|
60
61
|
readonly interface: string;
|
|
61
62
|
readonly index: number;
|
|
63
|
+
readonly size: number;
|
|
62
64
|
}
|
|
63
65
|
/**
|
|
64
66
|
* Metadata describing a component pin's source type and subtype.
|
|
@@ -105,6 +107,7 @@ export interface IENode {
|
|
|
105
107
|
position?: IPosition | null;
|
|
106
108
|
source?: ENodeSourceType | null;
|
|
107
109
|
subtype: string;
|
|
110
|
+
logicMetadata: ILogicPinMetadata | null;
|
|
108
111
|
}
|
|
109
112
|
/** Interface defining a Wire (link between 2 ENodes supporting intermediate position to tune its path) **/
|
|
110
113
|
export interface IWire {
|
|
@@ -177,7 +180,15 @@ export declare enum ComponentType {
|
|
|
177
180
|
HalfAdder = "halfAdder",
|
|
178
181
|
Adder = "adder",
|
|
179
182
|
EightBitAdder = "eightBitAdder",
|
|
180
|
-
EightBitOnesComplement = "eightBitOnesComplement"
|
|
183
|
+
EightBitOnesComplement = "eightBitOnesComplement",
|
|
184
|
+
OneInput = "oneInput",
|
|
185
|
+
TwoInput = "twoInput",
|
|
186
|
+
FourInput = "fourInput",
|
|
187
|
+
EightInput = "eightInput",
|
|
188
|
+
OneLight = "oneLight",
|
|
189
|
+
TwoLight = "twoLight",
|
|
190
|
+
FourLight = "fourLight",
|
|
191
|
+
EightLight = "eightLight"
|
|
181
192
|
}
|
|
182
193
|
/**
|
|
183
194
|
* Component type metadata lookup table.
|