-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ts
More file actions
87 lines (75 loc) · 1.91 KB
/
types.ts
File metadata and controls
87 lines (75 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
export type Signal = boolean;
export type ComponentType =
| 'AND'
| 'OR'
| 'NOT'
| 'NAND'
| 'NOR'
| 'XOR'
| 'LEVER'
| 'BUTTON'
| 'BULB'
| 'IC';
export interface Pin {
id: string;
componentId: string;
type: 'input' | 'output';
label?: string; // For ICs inputs/outputs
index: number; // Index in the inputs/outputs array
value: Signal; // Current simulation value
}
export interface CircuitComponent {
id: string;
type: ComponentType;
x: number;
y: number;
label: string;
inputs: Pin[];
outputs: Pin[];
state: Record<string, any>; // For levers (isOn), etc.
icDefinitionId?: string; // If type === 'IC'
}
export interface Wire {
id: string;
sourcePinId: string;
targetPinId: string;
}
export interface ICDefinition {
id: string;
name: string;
// The internal structure
components: CircuitComponent[];
wires: Wire[];
// Maps external pin index to the internal component ID and pin index
inputMap: { internalComponentId: string; pinIndex: number; label: string }[];
outputMap: { internalComponentId: string; pinIndex: number; label: string }[];
}
export interface CircuitState {
components: CircuitComponent[];
wires: Wire[];
selection: string[]; // Selected component IDs
icDefinitions: ICDefinition[];
}
export interface DragItem {
type: ComponentType | 'IC';
icId?: string; // If dragging a custom IC
}
// --- AI Generation Types ---
export interface AIComponentSpec {
id: string; // Temporary ID used by AI for connection references
type: ComponentType;
label: string;
gridX: number; // Logical grid position (e.g., 0, 1, 2)
gridY: number;
icName?: string; // If type is IC, the name of the custom IC to use
}
export interface AIConnectionSpec {
sourceId: string;
targetId: string;
targetInputIndex: number;
}
export interface AIBlueprint {
explanation: string;
components: AIComponentSpec[];
connections: AIConnectionSpec[];
}