@vessel-dsp/core 0.5.0
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/LICENSE.md +21 -0
- package/README.md +6 -0
- package/package.json +56 -0
- package/src/editor/commands.ts +344 -0
- package/src/editor/factory.ts +148 -0
- package/src/editor/history.ts +142 -0
- package/src/editor/index.ts +11 -0
- package/src/editor/layout.ts +207 -0
- package/src/formats/circuit-json/serializer.ts +1410 -0
- package/src/formats/document.ts +274 -0
- package/src/formats/interchange/parser.ts +1165 -0
- package/src/formats/interchange/serializer.ts +594 -0
- package/src/formats/ltspice/catalog.ts +181 -0
- package/src/formats/ltspice/encoding.ts +151 -0
- package/src/formats/ltspice/parser.ts +432 -0
- package/src/formats/ltspice/serializer.ts +169 -0
- package/src/formats/schx/catalog.ts +439 -0
- package/src/formats/schx/parser.ts +261 -0
- package/src/formats/schx/runtime-descriptors.ts +502 -0
- package/src/formats/schx/serializer.ts +211 -0
- package/src/formats/schx/transforms.ts +38 -0
- package/src/formats/spice/parser.ts +373 -0
- package/src/formats/spice/serializer.ts +43 -0
- package/src/index.ts +205 -0
- package/src/model/connectivity.ts +239 -0
- package/src/model/netlist.ts +375 -0
- package/src/model/properties.ts +101 -0
- package/src/model/quantity.ts +173 -0
- package/src/model/types.ts +309 -0
- package/src/model/validation.ts +985 -0
- package/src/model/wires.ts +86 -0
- package/src/panel/extract.ts +878 -0
- package/src/panel/index.ts +39 -0
- package/src/panel/knobs.ts +70 -0
- package/src/panel/protocol.ts +117 -0
- package/src/panel/types.ts +180 -0
- package/src/preview/bounds.ts +85 -0
- package/src/preview/box-layout.ts +24 -0
- package/src/preview/colors.ts +43 -0
- package/src/preview/hanging.ts +94 -0
- package/src/preview/junctions.ts +94 -0
- package/src/preview/label-layout.ts +90 -0
- package/src/preview/ports.ts +101 -0
- package/src/preview/renderable-wires.ts +113 -0
- package/src/preview/routing.ts +15 -0
- package/src/preview/snap.ts +104 -0
- package/src/preview/symbols/analog-switch.svg +17 -0
- package/src/preview/symbols/battery.svg +16 -0
- package/src/preview/symbols/bbd.svg +21 -0
- package/src/preview/symbols/bjt-npn.svg +16 -0
- package/src/preview/symbols/bjt-pnp.svg +17 -0
- package/src/preview/symbols/capacitor-electrolytic.svg +13 -0
- package/src/preview/symbols/capacitor.svg +12 -0
- package/src/preview/symbols/current-source.svg +14 -0
- package/src/preview/symbols/delay-ic.svg +22 -0
- package/src/preview/symbols/diode-schottky.svg +12 -0
- package/src/preview/symbols/diode-zener.svg +12 -0
- package/src/preview/symbols/diode.svg +13 -0
- package/src/preview/symbols/flipflop.svg +20 -0
- package/src/preview/symbols/ground.svg +12 -0
- package/src/preview/symbols/ic-block.svg +20 -0
- package/src/preview/symbols/ic.svg +19 -0
- package/src/preview/symbols/inductor.svg +11 -0
- package/src/preview/symbols/jack-input.svg +16 -0
- package/src/preview/symbols/jack-output.svg +16 -0
- package/src/preview/symbols/jfet-junction-n.svg +17 -0
- package/src/preview/symbols/jfet-n.svg +17 -0
- package/src/preview/symbols/jfet-p.svg +17 -0
- package/src/preview/symbols/label.svg +8 -0
- package/src/preview/symbols/led.svg +18 -0
- package/src/preview/symbols/mosfet-n.svg +21 -0
- package/src/preview/symbols/mosfet-p.svg +21 -0
- package/src/preview/symbols/named-wire.svg +11 -0
- package/src/preview/symbols/opamp.svg +21 -0
- package/src/preview/symbols/optocoupler.svg +30 -0
- package/src/preview/symbols/ota.svg +20 -0
- package/src/preview/symbols/pentode.svg +25 -0
- package/src/preview/symbols/photoresistor.svg +19 -0
- package/src/preview/symbols/port.svg +8 -0
- package/src/preview/symbols/potentiometer.svg +15 -0
- package/src/preview/symbols/power-amp.svg +20 -0
- package/src/preview/symbols/rail.svg +11 -0
- package/src/preview/symbols/regulator.svg +13 -0
- package/src/preview/symbols/relay.svg +20 -0
- package/src/preview/symbols/resistor.svg +11 -0
- package/src/preview/symbols/svg-content.ts +59 -0
- package/src/preview/symbols/switch-3pdt.svg +32 -0
- package/src/preview/symbols/switch-rotary.svg +23 -0
- package/src/preview/symbols/switch-spdt.svg +16 -0
- package/src/preview/symbols/switch-spst.svg +14 -0
- package/src/preview/symbols/switch-toggle.svg +14 -0
- package/src/preview/symbols/transformer.svg +17 -0
- package/src/preview/symbols/triode.svg +17 -0
- package/src/preview/symbols/tube-diode.svg +13 -0
- package/src/preview/symbols/unsupported.svg +8 -0
- package/src/preview/symbols/variable-resistor.svg +13 -0
- package/src/preview/symbols/voltage-source.svg +15 -0
- package/src/preview/symbols.ts +207 -0
- package/src/preview/wire-chains.ts +153 -0
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
export type Point = Readonly<{ x: number; y: number }>;
|
|
2
|
+
|
|
3
|
+
export type Rotation = 0 | 1 | 2 | 3;
|
|
4
|
+
|
|
5
|
+
export type ParsedQuantity = Readonly<{
|
|
6
|
+
raw: string;
|
|
7
|
+
value: number;
|
|
8
|
+
unit: string;
|
|
9
|
+
}>;
|
|
10
|
+
|
|
11
|
+
export type ComponentKind =
|
|
12
|
+
| 'resistor'
|
|
13
|
+
| 'capacitor'
|
|
14
|
+
| 'inductor'
|
|
15
|
+
| 'diode'
|
|
16
|
+
| 'led'
|
|
17
|
+
| 'bjt'
|
|
18
|
+
| 'jfet'
|
|
19
|
+
| 'mosfet'
|
|
20
|
+
| 'opamp'
|
|
21
|
+
| 'ota'
|
|
22
|
+
| 'triode'
|
|
23
|
+
| 'pentode'
|
|
24
|
+
| 'tube-diode'
|
|
25
|
+
| 'transformer'
|
|
26
|
+
| 'potentiometer'
|
|
27
|
+
| 'variable-resistor'
|
|
28
|
+
| 'switch'
|
|
29
|
+
| 'optocoupler'
|
|
30
|
+
| 'voltage-source'
|
|
31
|
+
| 'current-source'
|
|
32
|
+
| 'battery'
|
|
33
|
+
| 'ground'
|
|
34
|
+
| 'rail'
|
|
35
|
+
| 'jack'
|
|
36
|
+
| 'bbd'
|
|
37
|
+
| 'delay-ic'
|
|
38
|
+
| 'power-amp'
|
|
39
|
+
| 'regulator'
|
|
40
|
+
| 'analog-switch'
|
|
41
|
+
| 'flipflop'
|
|
42
|
+
| 'ic'
|
|
43
|
+
| 'label'
|
|
44
|
+
| 'named-wire'
|
|
45
|
+
| 'port'
|
|
46
|
+
| 'unsupported';
|
|
47
|
+
|
|
48
|
+
export type Terminal = Readonly<{
|
|
49
|
+
name: string;
|
|
50
|
+
position: Point;
|
|
51
|
+
}>;
|
|
52
|
+
|
|
53
|
+
export type PropertyObject = Readonly<{
|
|
54
|
+
readonly [key: string]: PropertyValue;
|
|
55
|
+
}>;
|
|
56
|
+
|
|
57
|
+
export type PropertyValue =
|
|
58
|
+
| ParsedQuantity
|
|
59
|
+
| string
|
|
60
|
+
| number
|
|
61
|
+
| boolean
|
|
62
|
+
| null
|
|
63
|
+
| readonly PropertyValue[]
|
|
64
|
+
| PropertyObject;
|
|
65
|
+
|
|
66
|
+
export type Component = Readonly<{
|
|
67
|
+
id: string;
|
|
68
|
+
kind: ComponentKind;
|
|
69
|
+
name: string;
|
|
70
|
+
origin: Point;
|
|
71
|
+
rotation: Rotation;
|
|
72
|
+
flipped: boolean;
|
|
73
|
+
terminals: readonly Terminal[];
|
|
74
|
+
properties: Readonly<Record<string, PropertyValue>>;
|
|
75
|
+
sourceTypeName: string | null;
|
|
76
|
+
}>;
|
|
77
|
+
|
|
78
|
+
export type Wire = Readonly<{
|
|
79
|
+
id: string;
|
|
80
|
+
endpoints: readonly [Point, Point];
|
|
81
|
+
}>;
|
|
82
|
+
|
|
83
|
+
export type DocumentMetadata = Readonly<{
|
|
84
|
+
name: string;
|
|
85
|
+
description: string;
|
|
86
|
+
partNumber: string;
|
|
87
|
+
}>;
|
|
88
|
+
|
|
89
|
+
export type DocumentSource = Readonly<Record<string, string>>;
|
|
90
|
+
|
|
91
|
+
export type ControlInterfaceRole =
|
|
92
|
+
| 'external-control'
|
|
93
|
+
| 'tempo-tap'
|
|
94
|
+
| 'trigger'
|
|
95
|
+
| 'reset'
|
|
96
|
+
| 'sampler-trigger'
|
|
97
|
+
| 'expression'
|
|
98
|
+
| 'unknown';
|
|
99
|
+
|
|
100
|
+
export type ControlInterfaceConnector =
|
|
101
|
+
| '1/4-inch-mono-ts'
|
|
102
|
+
| '1/4-inch-trs'
|
|
103
|
+
| '3.5mm-mono-ts'
|
|
104
|
+
| '3.5mm-trs'
|
|
105
|
+
| 'proprietary'
|
|
106
|
+
| 'unknown';
|
|
107
|
+
|
|
108
|
+
export type ControlInterfaceAssignmentHint =
|
|
109
|
+
| 'momentary'
|
|
110
|
+
| 'latching'
|
|
111
|
+
| 'momentary-or-latching'
|
|
112
|
+
| 'continuous';
|
|
113
|
+
|
|
114
|
+
export type ControlInterfacePolarity =
|
|
115
|
+
| 'normally-open'
|
|
116
|
+
| 'normally-closed'
|
|
117
|
+
| 'expression'
|
|
118
|
+
| 'unknown';
|
|
119
|
+
|
|
120
|
+
export type ControlInterfaceBinding = Readonly<{
|
|
121
|
+
sourceComponentId?: string;
|
|
122
|
+
controlId?: string;
|
|
123
|
+
controlName?: string;
|
|
124
|
+
property?: string;
|
|
125
|
+
}>;
|
|
126
|
+
|
|
127
|
+
export type ControlInterface = Readonly<{
|
|
128
|
+
id: string;
|
|
129
|
+
name: string;
|
|
130
|
+
role: ControlInterfaceRole;
|
|
131
|
+
componentId?: string;
|
|
132
|
+
controlRole?: string;
|
|
133
|
+
interface?: string;
|
|
134
|
+
connector?: ControlInterfaceConnector;
|
|
135
|
+
assignmentHint?: ControlInterfaceAssignmentHint;
|
|
136
|
+
polarity?: ControlInterfacePolarity;
|
|
137
|
+
binding?: ControlInterfaceBinding;
|
|
138
|
+
description?: string;
|
|
139
|
+
}>;
|
|
140
|
+
|
|
141
|
+
export type CircuitDocumentDeviceKind =
|
|
142
|
+
| 'audio-pedal'
|
|
143
|
+
| 'control-accessory'
|
|
144
|
+
| 'utility'
|
|
145
|
+
| 'unknown';
|
|
146
|
+
|
|
147
|
+
export type CircuitDocumentDevice = Readonly<{
|
|
148
|
+
id?: string;
|
|
149
|
+
version?: number;
|
|
150
|
+
kind: CircuitDocumentDeviceKind;
|
|
151
|
+
family?: string;
|
|
152
|
+
model?: string;
|
|
153
|
+
audioProcessing?: boolean;
|
|
154
|
+
}>;
|
|
155
|
+
|
|
156
|
+
export type ControlOutputSwitchMode = 'momentary' | 'latching';
|
|
157
|
+
|
|
158
|
+
export type ControlOutput = Readonly<{
|
|
159
|
+
id: string;
|
|
160
|
+
name: string;
|
|
161
|
+
role: ControlInterfaceRole;
|
|
162
|
+
connector?: ControlInterfaceConnector;
|
|
163
|
+
switchMode?: ControlOutputSwitchMode;
|
|
164
|
+
polarity?: ControlInterfacePolarity;
|
|
165
|
+
inactiveValue?: number;
|
|
166
|
+
activeValue?: number;
|
|
167
|
+
componentId?: string;
|
|
168
|
+
description?: string;
|
|
169
|
+
}>;
|
|
170
|
+
|
|
171
|
+
export type ControlContext = Readonly<{
|
|
172
|
+
id: string;
|
|
173
|
+
name: string;
|
|
174
|
+
role: string;
|
|
175
|
+
description?: string;
|
|
176
|
+
}>;
|
|
177
|
+
|
|
178
|
+
export type ControlGroup = Readonly<{
|
|
179
|
+
id: string;
|
|
180
|
+
name: string;
|
|
181
|
+
role: string;
|
|
182
|
+
contextIds?: readonly string[];
|
|
183
|
+
description?: string;
|
|
184
|
+
}>;
|
|
185
|
+
|
|
186
|
+
export type DeviceInterfaceControlKind =
|
|
187
|
+
| 'knob'
|
|
188
|
+
| 'slider'
|
|
189
|
+
| 'switch'
|
|
190
|
+
| 'selector'
|
|
191
|
+
| 'footswitch'
|
|
192
|
+
| 'led'
|
|
193
|
+
| 'jack';
|
|
194
|
+
|
|
195
|
+
export type DeviceInterfaceBinding = Readonly<{
|
|
196
|
+
componentId: string;
|
|
197
|
+
controlId?: string;
|
|
198
|
+
controlName?: string;
|
|
199
|
+
property?: string;
|
|
200
|
+
externalInterfaceId?: string;
|
|
201
|
+
}>;
|
|
202
|
+
|
|
203
|
+
export type ControlApplicabilityPredicate = Readonly<{
|
|
204
|
+
allOf?: readonly string[];
|
|
205
|
+
anyOf?: readonly string[];
|
|
206
|
+
}>;
|
|
207
|
+
|
|
208
|
+
export type DeviceInterfaceControl = Readonly<{
|
|
209
|
+
id: string;
|
|
210
|
+
label: string;
|
|
211
|
+
kind: DeviceInterfaceControlKind;
|
|
212
|
+
role: string;
|
|
213
|
+
groupId?: string;
|
|
214
|
+
order?: number;
|
|
215
|
+
binding?: DeviceInterfaceBinding;
|
|
216
|
+
appliesWhen?: ControlApplicabilityPredicate;
|
|
217
|
+
description?: string;
|
|
218
|
+
}>;
|
|
219
|
+
|
|
220
|
+
export type DeviceInterface = Readonly<{
|
|
221
|
+
controls: readonly DeviceInterfaceControl[];
|
|
222
|
+
}>;
|
|
223
|
+
|
|
224
|
+
export type PanelGridIndexing = 'one-based' | 'zero-based';
|
|
225
|
+
|
|
226
|
+
export type PanelRowOrder = 'top-to-bottom' | 'bottom-to-top';
|
|
227
|
+
|
|
228
|
+
export type PanelColumnOrder = 'left-to-right' | 'right-to-left';
|
|
229
|
+
|
|
230
|
+
export type PanelGridLayout = Readonly<{
|
|
231
|
+
kind: 'stompbox-grid';
|
|
232
|
+
rows: number;
|
|
233
|
+
columns: number;
|
|
234
|
+
indexing: PanelGridIndexing;
|
|
235
|
+
rowOrder?: PanelRowOrder;
|
|
236
|
+
columnOrder?: PanelColumnOrder;
|
|
237
|
+
}>;
|
|
238
|
+
|
|
239
|
+
export type PanelControlKind = 'knob' | 'slider' | 'switch' | 'led' | 'jack';
|
|
240
|
+
|
|
241
|
+
export type PanelGridPosition = Readonly<{
|
|
242
|
+
row: number;
|
|
243
|
+
column: number;
|
|
244
|
+
rowSpan?: number;
|
|
245
|
+
columnSpan?: number;
|
|
246
|
+
}>;
|
|
247
|
+
|
|
248
|
+
export type PanelElementBinding = Readonly<{
|
|
249
|
+
componentId: string;
|
|
250
|
+
controlId?: string;
|
|
251
|
+
controlName?: string;
|
|
252
|
+
property?: string;
|
|
253
|
+
}>;
|
|
254
|
+
|
|
255
|
+
export type PanelElementPlacement = Readonly<{
|
|
256
|
+
bind: PanelElementBinding;
|
|
257
|
+
kind: PanelControlKind;
|
|
258
|
+
grid: PanelGridPosition;
|
|
259
|
+
label?: string;
|
|
260
|
+
interfaceControlId?: string;
|
|
261
|
+
}>;
|
|
262
|
+
|
|
263
|
+
/** @deprecated Use PanelElementPlacement. */
|
|
264
|
+
export type PanelControlPlacement = PanelElementPlacement;
|
|
265
|
+
|
|
266
|
+
export type PanelFace = Readonly<{
|
|
267
|
+
id: string;
|
|
268
|
+
label?: string;
|
|
269
|
+
layout: PanelGridLayout;
|
|
270
|
+
elements: readonly PanelElementPlacement[];
|
|
271
|
+
}>;
|
|
272
|
+
|
|
273
|
+
export type PanelPlacementMetadata = Readonly<{
|
|
274
|
+
faces: readonly PanelFace[];
|
|
275
|
+
}>;
|
|
276
|
+
|
|
277
|
+
export type Warning = Readonly<{
|
|
278
|
+
code: string;
|
|
279
|
+
message: string;
|
|
280
|
+
componentId?: string;
|
|
281
|
+
wireId?: string;
|
|
282
|
+
}>;
|
|
283
|
+
|
|
284
|
+
export type CircuitDocument = Readonly<{
|
|
285
|
+
metadata: DocumentMetadata;
|
|
286
|
+
source?: DocumentSource;
|
|
287
|
+
device?: CircuitDocumentDevice;
|
|
288
|
+
controlGroups?: readonly ControlGroup[];
|
|
289
|
+
controlContexts?: readonly ControlContext[];
|
|
290
|
+
deviceInterface?: DeviceInterface;
|
|
291
|
+
panel?: PanelPlacementMetadata;
|
|
292
|
+
controlInterfaces?: readonly ControlInterface[];
|
|
293
|
+
controlOutputs?: readonly ControlOutput[];
|
|
294
|
+
components: readonly Component[];
|
|
295
|
+
wires: readonly Wire[];
|
|
296
|
+
directives: readonly string[];
|
|
297
|
+
warnings: readonly Warning[];
|
|
298
|
+
rawAttributes: Readonly<Record<string, string>>;
|
|
299
|
+
}>;
|
|
300
|
+
|
|
301
|
+
export const EMPTY_DOCUMENT: CircuitDocument = {
|
|
302
|
+
metadata: { name: '', description: '', partNumber: '' },
|
|
303
|
+
source: {},
|
|
304
|
+
components: [],
|
|
305
|
+
wires: [],
|
|
306
|
+
directives: [],
|
|
307
|
+
warnings: [],
|
|
308
|
+
rawAttributes: {},
|
|
309
|
+
};
|