@vessel-dsp/core 0.6.0 → 0.6.1
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/dist/editor/commands.d.ts +48 -0
- package/dist/editor/commands.d.ts.map +1 -0
- package/{src/editor/commands.ts → dist/editor/commands.js} +44 -91
- package/dist/editor/commands.js.map +1 -0
- package/dist/editor/factory.d.ts +10 -0
- package/dist/editor/factory.d.ts.map +1 -0
- package/{src/editor/factory.ts → dist/editor/factory.js} +11 -27
- package/dist/editor/factory.js.map +1 -0
- package/dist/editor/history.d.ts +29 -0
- package/dist/editor/history.d.ts.map +1 -0
- package/{src/editor/history.ts → dist/editor/history.js} +12 -42
- package/dist/editor/history.js.map +1 -0
- package/{src/editor/index.ts → dist/editor/index.d.ts} +1 -3
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +5 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/layout.d.ts +8 -0
- package/dist/editor/layout.d.ts.map +1 -0
- package/{src/editor/layout.ts → dist/editor/layout.js} +36 -90
- package/dist/editor/layout.js.map +1 -0
- package/dist/formats/circuit-json/serializer.d.ts +86 -0
- package/dist/formats/circuit-json/serializer.d.ts.map +1 -0
- package/{src/formats/circuit-json/serializer.ts → dist/formats/circuit-json/serializer.js} +114 -414
- package/dist/formats/circuit-json/serializer.js.map +1 -0
- package/dist/formats/document.d.ts +64 -0
- package/dist/formats/document.d.ts.map +1 -0
- package/{src/formats/document.ts → dist/formats/document.js} +43 -159
- package/dist/formats/document.js.map +1 -0
- package/dist/formats/interchange/parser.d.ts +3 -0
- package/dist/formats/interchange/parser.d.ts.map +1 -0
- package/{src/formats/interchange/parser.ts → dist/formats/interchange/parser.js} +157 -463
- package/dist/formats/interchange/parser.js.map +1 -0
- package/dist/formats/interchange/serializer.d.ts +9 -0
- package/dist/formats/interchange/serializer.d.ts.map +1 -0
- package/{src/formats/interchange/serializer.ts → dist/formats/interchange/serializer.js} +84 -186
- package/dist/formats/interchange/serializer.js.map +1 -0
- package/dist/formats/ltspice/catalog.d.ts +19 -0
- package/dist/formats/ltspice/catalog.d.ts.map +1 -0
- package/{src/formats/ltspice/catalog.ts → dist/formats/ltspice/catalog.js} +18 -52
- package/dist/formats/ltspice/catalog.js.map +1 -0
- package/dist/formats/ltspice/encoding.d.ts +2 -0
- package/dist/formats/ltspice/encoding.d.ts.map +1 -0
- package/{src/formats/ltspice/encoding.ts → dist/formats/ltspice/encoding.js} +17 -41
- package/dist/formats/ltspice/encoding.js.map +1 -0
- package/dist/formats/ltspice/parser.d.ts +3 -0
- package/dist/formats/ltspice/parser.d.ts.map +1 -0
- package/{src/formats/ltspice/parser.ts → dist/formats/ltspice/parser.js} +39 -141
- package/dist/formats/ltspice/parser.js.map +1 -0
- package/dist/formats/ltspice/serializer.d.ts +7 -0
- package/dist/formats/ltspice/serializer.d.ts.map +1 -0
- package/{src/formats/ltspice/serializer.ts → dist/formats/ltspice/serializer.js} +18 -45
- package/dist/formats/ltspice/serializer.js.map +1 -0
- package/dist/formats/schx/catalog.d.ts +19 -0
- package/dist/formats/schx/catalog.d.ts.map +1 -0
- package/{src/formats/schx/catalog.ts → dist/formats/schx/catalog.js} +48 -101
- package/dist/formats/schx/catalog.js.map +1 -0
- package/dist/formats/schx/parser.d.ts +3 -0
- package/dist/formats/schx/parser.d.ts.map +1 -0
- package/{src/formats/schx/parser.ts → dist/formats/schx/parser.js} +31 -86
- package/dist/formats/schx/parser.js.map +1 -0
- package/dist/formats/schx/runtime-descriptors.d.ts +3 -0
- package/dist/formats/schx/runtime-descriptors.d.ts.map +1 -0
- package/{src/formats/schx/runtime-descriptors.ts → dist/formats/schx/runtime-descriptors.js} +36 -123
- package/dist/formats/schx/runtime-descriptors.js.map +1 -0
- package/dist/formats/schx/serializer.d.ts +5 -0
- package/dist/formats/schx/serializer.d.ts.map +1 -0
- package/{src/formats/schx/serializer.ts → dist/formats/schx/serializer.js} +17 -42
- package/dist/formats/schx/serializer.js.map +1 -0
- package/dist/formats/schx/transforms.d.ts +4 -0
- package/dist/formats/schx/transforms.d.ts.map +1 -0
- package/{src/formats/schx/transforms.ts → dist/formats/schx/transforms.js} +6 -10
- package/dist/formats/schx/transforms.js.map +1 -0
- package/dist/formats/spice/parser.d.ts +3 -0
- package/dist/formats/spice/parser.d.ts.map +1 -0
- package/{src/formats/spice/parser.ts → dist/formats/spice/parser.js} +50 -96
- package/dist/formats/spice/parser.js.map +1 -0
- package/dist/formats/spice/serializer.d.ts +3 -0
- package/dist/formats/spice/serializer.d.ts.map +1 -0
- package/{src/formats/spice/serializer.ts → dist/formats/spice/serializer.js} +8 -13
- package/dist/formats/spice/serializer.js.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/model/connectivity.d.ts +16 -0
- package/dist/model/connectivity.d.ts.map +1 -0
- package/{src/model/connectivity.ts → dist/model/connectivity.js} +28 -63
- package/dist/model/connectivity.js.map +1 -0
- package/dist/model/netlist.d.ts +24 -0
- package/dist/model/netlist.d.ts.map +1 -0
- package/{src/model/netlist.ts → dist/model/netlist.js} +42 -110
- package/dist/model/netlist.js.map +1 -0
- package/dist/model/properties.d.ts +9 -0
- package/dist/model/properties.d.ts.map +1 -0
- package/{src/model/properties.ts → dist/model/properties.js} +10 -18
- package/dist/model/properties.js.map +1 -0
- package/dist/model/quantity.d.ts +3 -0
- package/dist/model/quantity.d.ts.map +1 -0
- package/{src/model/quantity.ts → dist/model/quantity.js} +7 -30
- package/dist/model/quantity.js.map +1 -0
- package/{src/model/types.ts → dist/model/types.d.ts} +17 -196
- package/dist/model/types.d.ts.map +1 -0
- package/dist/model/types.js +10 -0
- package/dist/model/types.js.map +1 -0
- package/dist/model/validation.d.ts +32 -0
- package/dist/model/validation.d.ts.map +1 -0
- package/{src/model/validation.ts → dist/model/validation.js} +172 -653
- package/dist/model/validation.js.map +1 -0
- package/dist/model/wires.d.ts +3 -0
- package/dist/model/wires.d.ts.map +1 -0
- package/{src/model/wires.ts → dist/model/wires.js} +10 -16
- package/dist/model/wires.js.map +1 -0
- package/dist/panel/extract.d.ts +5 -0
- package/dist/panel/extract.d.ts.map +1 -0
- package/{src/panel/extract.ts → dist/panel/extract.js} +146 -235
- package/dist/panel/extract.js.map +1 -0
- package/dist/panel/index.d.ts +6 -0
- package/dist/panel/index.d.ts.map +1 -0
- package/dist/panel/index.js +5 -0
- package/dist/panel/index.js.map +1 -0
- package/dist/panel/knobs.d.ts +7 -0
- package/dist/panel/knobs.d.ts.map +1 -0
- package/{src/panel/knobs.ts → dist/panel/knobs.js} +7 -18
- package/dist/panel/knobs.js.map +1 -0
- package/dist/panel/protocol.d.ts +9 -0
- package/dist/panel/protocol.d.ts.map +1 -0
- package/{src/panel/protocol.ts → dist/panel/protocol.js} +10 -26
- package/dist/panel/protocol.js.map +1 -0
- package/{src/panel/types.ts → dist/panel/types.d.ts} +50 -89
- package/dist/panel/types.d.ts.map +1 -0
- package/dist/panel/types.js +2 -0
- package/dist/panel/types.js.map +1 -0
- package/dist/preview/bounds.d.ts +12 -0
- package/dist/preview/bounds.d.ts.map +1 -0
- package/{src/preview/bounds.ts → dist/preview/bounds.js} +15 -29
- package/dist/preview/bounds.js.map +1 -0
- package/dist/preview/box-layout.d.ts +4 -0
- package/dist/preview/box-layout.d.ts.map +1 -0
- package/{src/preview/box-layout.ts → dist/preview/box-layout.js} +2 -6
- package/dist/preview/box-layout.js.map +1 -0
- package/dist/preview/colors.d.ts +3 -0
- package/dist/preview/colors.d.ts.map +1 -0
- package/{src/preview/colors.ts → dist/preview/colors.js} +3 -5
- package/dist/preview/colors.js.map +1 -0
- package/dist/preview/hanging.d.ts +8 -0
- package/dist/preview/hanging.d.ts.map +1 -0
- package/{src/preview/hanging.ts → dist/preview/hanging.js} +9 -28
- package/dist/preview/hanging.js.map +1 -0
- package/dist/preview/junctions.d.ts +3 -0
- package/dist/preview/junctions.d.ts.map +1 -0
- package/{src/preview/junctions.ts → dist/preview/junctions.js} +9 -24
- package/dist/preview/junctions.js.map +1 -0
- package/dist/preview/label-layout.d.ts +12 -0
- package/dist/preview/label-layout.d.ts.map +1 -0
- package/{src/preview/label-layout.ts → dist/preview/label-layout.js} +15 -36
- package/dist/preview/label-layout.js.map +1 -0
- package/dist/preview/ports.d.ts +17 -0
- package/dist/preview/ports.d.ts.map +1 -0
- package/{src/preview/ports.ts → dist/preview/ports.js} +10 -37
- package/dist/preview/ports.js.map +1 -0
- package/dist/preview/renderable-wires.d.ts +3 -0
- package/dist/preview/renderable-wires.d.ts.map +1 -0
- package/{src/preview/renderable-wires.ts → dist/preview/renderable-wires.js} +12 -29
- package/dist/preview/renderable-wires.js.map +1 -0
- package/dist/preview/routing.d.ts +4 -0
- package/dist/preview/routing.d.ts.map +1 -0
- package/dist/preview/routing.js +13 -0
- package/dist/preview/routing.js.map +1 -0
- package/dist/preview/snap.d.ts +9 -0
- package/dist/preview/snap.d.ts.map +1 -0
- package/{src/preview/snap.ts → dist/preview/snap.js} +9 -31
- package/dist/preview/snap.js.map +1 -0
- package/dist/preview/symbols/svg-content.d.ts +7 -0
- package/dist/preview/symbols/svg-content.d.ts.map +1 -0
- package/{src/preview/symbols/svg-content.ts → dist/preview/symbols/svg-content.js} +3 -6
- package/dist/preview/symbols/svg-content.js.map +1 -0
- package/dist/preview/symbols.d.ts +7 -0
- package/dist/preview/symbols.d.ts.map +1 -0
- package/{src/preview/symbols.ts → dist/preview/symbols.js} +18 -43
- package/dist/preview/symbols.js.map +1 -0
- package/dist/preview/wire-chains.d.ts +4 -0
- package/dist/preview/wire-chains.d.ts.map +1 -0
- package/{src/preview/wire-chains.ts → dist/preview/wire-chains.js} +37 -37
- package/dist/preview/wire-chains.js.map +1 -0
- package/package.json +3 -3
- package/src/index.ts +0 -255
- package/src/panel/index.ts +0 -39
- package/src/preview/routing.ts +0 -15
- package/src/preview/symbols/analog-switch.svg +0 -17
- package/src/preview/symbols/battery.svg +0 -16
- package/src/preview/symbols/bbd.svg +0 -21
- package/src/preview/symbols/bjt-npn.svg +0 -16
- package/src/preview/symbols/bjt-pnp.svg +0 -17
- package/src/preview/symbols/capacitor-electrolytic.svg +0 -13
- package/src/preview/symbols/capacitor.svg +0 -12
- package/src/preview/symbols/current-source.svg +0 -14
- package/src/preview/symbols/delay-ic.svg +0 -22
- package/src/preview/symbols/diode-schottky.svg +0 -12
- package/src/preview/symbols/diode-zener.svg +0 -12
- package/src/preview/symbols/diode.svg +0 -13
- package/src/preview/symbols/flipflop.svg +0 -20
- package/src/preview/symbols/ground.svg +0 -12
- package/src/preview/symbols/ic-block.svg +0 -20
- package/src/preview/symbols/ic.svg +0 -19
- package/src/preview/symbols/inductor.svg +0 -11
- package/src/preview/symbols/jack-input.svg +0 -16
- package/src/preview/symbols/jack-output.svg +0 -16
- package/src/preview/symbols/jfet-junction-n.svg +0 -17
- package/src/preview/symbols/jfet-n.svg +0 -17
- package/src/preview/symbols/jfet-p.svg +0 -17
- package/src/preview/symbols/label.svg +0 -8
- package/src/preview/symbols/led.svg +0 -18
- package/src/preview/symbols/mosfet-n.svg +0 -21
- package/src/preview/symbols/mosfet-p.svg +0 -21
- package/src/preview/symbols/named-wire.svg +0 -11
- package/src/preview/symbols/opamp.svg +0 -21
- package/src/preview/symbols/optocoupler.svg +0 -30
- package/src/preview/symbols/ota.svg +0 -20
- package/src/preview/symbols/pentode.svg +0 -25
- package/src/preview/symbols/photoresistor.svg +0 -19
- package/src/preview/symbols/port.svg +0 -8
- package/src/preview/symbols/potentiometer.svg +0 -15
- package/src/preview/symbols/power-amp.svg +0 -20
- package/src/preview/symbols/rail.svg +0 -11
- package/src/preview/symbols/regulator.svg +0 -13
- package/src/preview/symbols/relay.svg +0 -20
- package/src/preview/symbols/resistor.svg +0 -11
- package/src/preview/symbols/switch-3pdt.svg +0 -32
- package/src/preview/symbols/switch-rotary.svg +0 -23
- package/src/preview/symbols/switch-spdt.svg +0 -16
- package/src/preview/symbols/switch-spst.svg +0 -14
- package/src/preview/symbols/switch-toggle.svg +0 -14
- package/src/preview/symbols/transformer.svg +0 -17
- package/src/preview/symbols/triode.svg +0 -17
- package/src/preview/symbols/tube-diode.svg +0 -13
- package/src/preview/symbols/unsupported.svg +0 -8
- package/src/preview/symbols/variable-resistor.svg +0 -13
- package/src/preview/symbols/voltage-source.svg +0 -15
|
@@ -1,95 +1,4 @@
|
|
|
1
|
-
import { isParsedQuantity } from '../../model/properties';
|
|
2
|
-
import type {
|
|
3
|
-
CircuitDocument,
|
|
4
|
-
CircuitDocumentDevice,
|
|
5
|
-
CircuitDocumentDeviceKind,
|
|
6
|
-
BoardApplicability,
|
|
7
|
-
BoardEdgeTerminal,
|
|
8
|
-
BoardFamily,
|
|
9
|
-
BoardFootprint,
|
|
10
|
-
BoardFootprintCatalog,
|
|
11
|
-
BoardFootprintPlacement,
|
|
12
|
-
BoardKind,
|
|
13
|
-
BoardNet,
|
|
14
|
-
BoardNetMember,
|
|
15
|
-
BoardNetlist,
|
|
16
|
-
BoardPlacedPad,
|
|
17
|
-
BoardRealization,
|
|
18
|
-
BoardRoute,
|
|
19
|
-
BoardSourceCircuitHash,
|
|
20
|
-
BoardSubtype,
|
|
21
|
-
BuildBom,
|
|
22
|
-
BuildBomItem,
|
|
23
|
-
BuildBomRef,
|
|
24
|
-
BuildCompleteness,
|
|
25
|
-
BuildIntent,
|
|
26
|
-
BuildPartProfile,
|
|
27
|
-
BuildPartProfileCatalog,
|
|
28
|
-
BuildScope,
|
|
29
|
-
Component,
|
|
30
|
-
ComponentKind,
|
|
31
|
-
ComponentTerminalRef,
|
|
32
|
-
ControlApplicabilityPredicate,
|
|
33
|
-
ControlContext,
|
|
34
|
-
ControlGroup,
|
|
35
|
-
DeviceInterface,
|
|
36
|
-
DeviceInterfaceBinding,
|
|
37
|
-
DeviceInterfaceControlKind,
|
|
38
|
-
ControlInterface,
|
|
39
|
-
ControlInterfaceAssignmentHint,
|
|
40
|
-
ControlInterfaceConnector,
|
|
41
|
-
ControlInterfacePolarity,
|
|
42
|
-
ControlInterfaceRole,
|
|
43
|
-
ControlOutput,
|
|
44
|
-
ControlOutputSwitchMode,
|
|
45
|
-
DocumentSource,
|
|
46
|
-
PanelColumnOrder,
|
|
47
|
-
PanelControlKind,
|
|
48
|
-
PanelElementBinding,
|
|
49
|
-
PanelElementPhysicalPlacement,
|
|
50
|
-
PanelFaceGeometry,
|
|
51
|
-
PanelGridLayout,
|
|
52
|
-
PanelGridIndexing,
|
|
53
|
-
PanelGridPosition,
|
|
54
|
-
PanelPlacementMetadata,
|
|
55
|
-
PanelRowOrder,
|
|
56
|
-
MechanicalBuildMetadata,
|
|
57
|
-
OffBoardWiringConnection,
|
|
58
|
-
OffBoardWiringCoverage,
|
|
59
|
-
OffBoardWiringEndpoint,
|
|
60
|
-
OffBoardWiringHarness,
|
|
61
|
-
OffBoardWiringHarnessStatus,
|
|
62
|
-
OffBoardWiringPlan,
|
|
63
|
-
ParsedQuantity,
|
|
64
|
-
Point,
|
|
65
|
-
PropertyValue,
|
|
66
|
-
Rotation,
|
|
67
|
-
Terminal,
|
|
68
|
-
VdspBuildDataObject,
|
|
69
|
-
VdspBuildDataValue,
|
|
70
|
-
Warning,
|
|
71
|
-
Wire,
|
|
72
|
-
} from '../../model/types';
|
|
73
|
-
|
|
74
|
-
type YamlScalar = string | number | boolean | null;
|
|
75
|
-
type YamlValue = YamlScalar | readonly YamlValue[] | YamlObject;
|
|
76
|
-
type YamlObject = { [key: string]: YamlValue };
|
|
77
|
-
|
|
78
|
-
type YamlLine = Readonly<{
|
|
79
|
-
indent: number;
|
|
80
|
-
text: string;
|
|
81
|
-
lineNumber: number;
|
|
82
|
-
}>;
|
|
83
|
-
|
|
84
|
-
type Cursor = {
|
|
85
|
-
index: number;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
type ParsedPair = Readonly<{
|
|
89
|
-
key: string;
|
|
90
|
-
rest: string;
|
|
91
|
-
}>;
|
|
92
|
-
|
|
1
|
+
import { isParsedQuantity } from '../../model/properties.js';
|
|
93
2
|
const INTERCHANGE_SCHEMA_V2 = 'circuit-interchange/v2';
|
|
94
3
|
const INTERCHANGE_SCHEMA_V3 = 'circuit-interchange/v3';
|
|
95
4
|
const V3_ONLY_TOP_LEVEL_FIELDS = [
|
|
@@ -100,9 +9,8 @@ const V3_ONLY_TOP_LEVEL_FIELDS = [
|
|
|
100
9
|
'footprints',
|
|
101
10
|
'offBoardWiring',
|
|
102
11
|
'boards',
|
|
103
|
-
]
|
|
104
|
-
|
|
105
|
-
export function parseInterchangeYaml(source: string): CircuitDocument {
|
|
12
|
+
];
|
|
13
|
+
export function parseInterchangeYaml(source) {
|
|
106
14
|
const value = parseYamlSubset(source);
|
|
107
15
|
const root = expectObject(value, 'root');
|
|
108
16
|
const schema = expectString(root.schema, 'schema');
|
|
@@ -113,7 +21,6 @@ export function parseInterchangeYaml(source: string): CircuitDocument {
|
|
|
113
21
|
if (!isV3) {
|
|
114
22
|
rejectV3OnlyTopLevelFields(root);
|
|
115
23
|
}
|
|
116
|
-
|
|
117
24
|
const panel = parsePanel(root.panel, isV3);
|
|
118
25
|
const controlInterfaces = parseControlInterfaces(root.controlInterfaces);
|
|
119
26
|
const device = parseDevice(root.device);
|
|
@@ -128,7 +35,6 @@ export function parseInterchangeYaml(source: string): CircuitDocument {
|
|
|
128
35
|
const footprints = isV3 ? parseFootprints(root.footprints) : undefined;
|
|
129
36
|
const offBoardWiring = isV3 ? parseOffBoardWiring(root.offBoardWiring) : undefined;
|
|
130
37
|
const boards = isV3 ? parseBoards(root.boards) : undefined;
|
|
131
|
-
|
|
132
38
|
return {
|
|
133
39
|
metadata: parseMetadata(root.metadata),
|
|
134
40
|
source: parseSource(root.source),
|
|
@@ -153,16 +59,14 @@ export function parseInterchangeYaml(source: string): CircuitDocument {
|
|
|
153
59
|
rawAttributes: parseStringRecord(root.rawAttributes, 'rawAttributes'),
|
|
154
60
|
};
|
|
155
61
|
}
|
|
156
|
-
|
|
157
|
-
function rejectV3OnlyTopLevelFields(root: YamlObject): void {
|
|
62
|
+
function rejectV3OnlyTopLevelFields(root) {
|
|
158
63
|
for (const field of V3_ONLY_TOP_LEVEL_FIELDS) {
|
|
159
64
|
if (root[field] !== undefined) {
|
|
160
65
|
throw new Error(`${field}: requires schema ${INTERCHANGE_SCHEMA_V3}`);
|
|
161
66
|
}
|
|
162
67
|
}
|
|
163
68
|
}
|
|
164
|
-
|
|
165
|
-
function parseMechanical(value: YamlValue | undefined): MechanicalBuildMetadata | undefined {
|
|
69
|
+
function parseMechanical(value) {
|
|
166
70
|
if (value === undefined) {
|
|
167
71
|
return undefined;
|
|
168
72
|
}
|
|
@@ -173,8 +77,7 @@ function parseMechanical(value: YamlValue | undefined): MechanicalBuildMetadata
|
|
|
173
77
|
...(mechanical.units === undefined ? {} : { units: expectString(mechanical.units, 'mechanical.units') }),
|
|
174
78
|
};
|
|
175
79
|
}
|
|
176
|
-
|
|
177
|
-
function parseBuild(value: YamlValue | undefined): BuildScope | undefined {
|
|
80
|
+
function parseBuild(value) {
|
|
178
81
|
if (value === undefined) {
|
|
179
82
|
return undefined;
|
|
180
83
|
}
|
|
@@ -192,10 +95,7 @@ function parseBuild(value: YamlValue | undefined): BuildScope | undefined {
|
|
|
192
95
|
...(build.selectedOffBoardWiringHarnessIds === undefined
|
|
193
96
|
? {}
|
|
194
97
|
: {
|
|
195
|
-
selectedOffBoardWiringHarnessIds: parseOptionalStringArray(
|
|
196
|
-
build.selectedOffBoardWiringHarnessIds,
|
|
197
|
-
'build.selectedOffBoardWiringHarnessIds',
|
|
198
|
-
) ?? [],
|
|
98
|
+
selectedOffBoardWiringHarnessIds: parseOptionalStringArray(build.selectedOffBoardWiringHarnessIds, 'build.selectedOffBoardWiringHarnessIds') ?? [],
|
|
199
99
|
}),
|
|
200
100
|
...(build.alternateBoardIds === undefined
|
|
201
101
|
? {}
|
|
@@ -203,24 +103,21 @@ function parseBuild(value: YamlValue | undefined): BuildScope | undefined {
|
|
|
203
103
|
...(build.bomScope === undefined ? {} : { bomScope: expectString(build.bomScope, 'build.bomScope') }),
|
|
204
104
|
};
|
|
205
105
|
}
|
|
206
|
-
|
|
207
|
-
function parseBuildIntent(value: YamlValue | undefined, path: string): BuildIntent {
|
|
106
|
+
function parseBuildIntent(value, path) {
|
|
208
107
|
const intent = expectString(value, path);
|
|
209
108
|
if (intent === 'diy-build-artifact' || intent === 'schema-review-sample') {
|
|
210
109
|
return intent;
|
|
211
110
|
}
|
|
212
111
|
throw new Error(`${path}: expected diy-build-artifact or schema-review-sample`);
|
|
213
112
|
}
|
|
214
|
-
|
|
215
|
-
function parseBuildCompleteness(value: YamlValue | undefined, path: string): BuildCompleteness {
|
|
113
|
+
function parseBuildCompleteness(value, path) {
|
|
216
114
|
const completeness = expectString(value, path);
|
|
217
115
|
if (completeness === 'complete-selected-build' || completeness === 'partial-offboard-wiring') {
|
|
218
116
|
return completeness;
|
|
219
117
|
}
|
|
220
118
|
throw new Error(`${path}: expected complete-selected-build or partial-offboard-wiring`);
|
|
221
119
|
}
|
|
222
|
-
|
|
223
|
-
function parseBom(value: YamlValue | undefined): BuildBom | undefined {
|
|
120
|
+
function parseBom(value) {
|
|
224
121
|
if (value === undefined) {
|
|
225
122
|
return undefined;
|
|
226
123
|
}
|
|
@@ -231,16 +128,13 @@ function parseBom(value: YamlValue | undefined): BuildBom | undefined {
|
|
|
231
128
|
items: optionalArray(bom.items, 'bom.items').map(parseBomItem),
|
|
232
129
|
};
|
|
233
130
|
}
|
|
234
|
-
|
|
235
|
-
function parseBomItem(value: YamlValue, index: number): BuildBomItem {
|
|
131
|
+
function parseBomItem(value, index) {
|
|
236
132
|
const path = `bom.items[${index}]`;
|
|
237
133
|
const item = expectObject(value, path);
|
|
238
134
|
return {
|
|
239
135
|
...parseBuildDataObject(item, path),
|
|
240
136
|
id: expectString(item.id, `${path}.id`),
|
|
241
|
-
refs: optionalArray(item.refs, `${path}.refs`).map((ref, refIndex) =>
|
|
242
|
-
parseBomRef(ref, `${path}.refs[${refIndex}]`)
|
|
243
|
-
),
|
|
137
|
+
refs: optionalArray(item.refs, `${path}.refs`).map((ref, refIndex) => parseBomRef(ref, `${path}.refs[${refIndex}]`)),
|
|
244
138
|
quantity: expectNumber(item.quantity, `${path}.quantity`),
|
|
245
139
|
...(item.value === undefined ? {} : { value: expectString(item.value, `${path}.value`) }),
|
|
246
140
|
...(item.partProfileId === undefined
|
|
@@ -250,8 +144,7 @@ function parseBomItem(value: YamlValue, index: number): BuildBomItem {
|
|
|
250
144
|
...(item.sku === undefined ? {} : { sku: expectString(item.sku, `${path}.sku`) }),
|
|
251
145
|
};
|
|
252
146
|
}
|
|
253
|
-
|
|
254
|
-
function parseBomRef(value: YamlValue, path: string): BuildBomRef {
|
|
147
|
+
function parseBomRef(value, path) {
|
|
255
148
|
const ref = expectObject(value, path);
|
|
256
149
|
const kind = expectString(ref.kind, `${path}.kind`);
|
|
257
150
|
switch (kind) {
|
|
@@ -275,8 +168,7 @@ function parseBomRef(value: YamlValue, path: string): BuildBomRef {
|
|
|
275
168
|
throw new Error(`${path}.kind: expected component, device-interface-control, panel-element, board, or freeform-build-item`);
|
|
276
169
|
}
|
|
277
170
|
}
|
|
278
|
-
|
|
279
|
-
function parsePartProfiles(value: YamlValue | undefined): BuildPartProfileCatalog | undefined {
|
|
171
|
+
function parsePartProfiles(value) {
|
|
280
172
|
if (value === undefined) {
|
|
281
173
|
return undefined;
|
|
282
174
|
}
|
|
@@ -288,13 +180,10 @@ function parsePartProfiles(value: YamlValue | undefined): BuildPartProfileCatalo
|
|
|
288
180
|
? {}
|
|
289
181
|
: { resolution: expectString(catalog.resolution, 'partProfiles.resolution') }),
|
|
290
182
|
...(catalog.units === undefined ? {} : { units: expectString(catalog.units, 'partProfiles.units') }),
|
|
291
|
-
profiles: optionalArray(catalog.profiles, 'partProfiles.profiles').map((profile, index) =>
|
|
292
|
-
parsePartProfile(profile, index)
|
|
293
|
-
),
|
|
183
|
+
profiles: optionalArray(catalog.profiles, 'partProfiles.profiles').map((profile, index) => parsePartProfile(profile, index)),
|
|
294
184
|
};
|
|
295
185
|
}
|
|
296
|
-
|
|
297
|
-
function parsePartProfile(value: YamlValue, index: number): BuildPartProfile {
|
|
186
|
+
function parsePartProfile(value, index) {
|
|
298
187
|
const path = `partProfiles.profiles[${index}]`;
|
|
299
188
|
const profile = expectObject(value, path);
|
|
300
189
|
return {
|
|
@@ -303,8 +192,7 @@ function parsePartProfile(value: YamlValue, index: number): BuildPartProfile {
|
|
|
303
192
|
...(profile.kind === undefined ? {} : { kind: expectString(profile.kind, `${path}.kind`) }),
|
|
304
193
|
};
|
|
305
194
|
}
|
|
306
|
-
|
|
307
|
-
function parseFootprints(value: YamlValue | undefined): BoardFootprintCatalog | undefined {
|
|
195
|
+
function parseFootprints(value) {
|
|
308
196
|
if (value === undefined) {
|
|
309
197
|
return undefined;
|
|
310
198
|
}
|
|
@@ -314,13 +202,10 @@ function parseFootprints(value: YamlValue | undefined): BoardFootprintCatalog |
|
|
|
314
202
|
schema: parseLiteralString(catalog.schema, 'footprints.schema', 'board-footprint-catalog/v1'),
|
|
315
203
|
...(catalog.resolution === undefined ? {} : { resolution: expectString(catalog.resolution, 'footprints.resolution') }),
|
|
316
204
|
...(catalog.units === undefined ? {} : { units: expectString(catalog.units, 'footprints.units') }),
|
|
317
|
-
footprints: optionalArray(catalog.footprints, 'footprints.footprints').map((footprint, index) =>
|
|
318
|
-
parseFootprint(footprint, index)
|
|
319
|
-
),
|
|
205
|
+
footprints: optionalArray(catalog.footprints, 'footprints.footprints').map((footprint, index) => parseFootprint(footprint, index)),
|
|
320
206
|
};
|
|
321
207
|
}
|
|
322
|
-
|
|
323
|
-
function parseFootprint(value: YamlValue, index: number): BoardFootprint {
|
|
208
|
+
function parseFootprint(value, index) {
|
|
324
209
|
const path = `footprints.footprints[${index}]`;
|
|
325
210
|
const footprint = expectObject(value, path);
|
|
326
211
|
return {
|
|
@@ -331,8 +216,7 @@ function parseFootprint(value: YamlValue, index: number): BoardFootprint {
|
|
|
331
216
|
: { boardApplicability: parseBoardApplicability(footprint.boardApplicability, `${path}.boardApplicability`) }),
|
|
332
217
|
};
|
|
333
218
|
}
|
|
334
|
-
|
|
335
|
-
function parseBoardApplicability(value: YamlValue, path: string): BoardApplicability {
|
|
219
|
+
function parseBoardApplicability(value, path) {
|
|
336
220
|
const applicability = expectObject(value, path);
|
|
337
221
|
return {
|
|
338
222
|
...parseBuildDataObject(applicability, path),
|
|
@@ -343,8 +227,7 @@ function parseBoardApplicability(value: YamlValue, path: string): BoardApplicabi
|
|
|
343
227
|
: { subtype: parseBoardSubtype(applicability.subtype, `${path}.subtype`) }),
|
|
344
228
|
};
|
|
345
229
|
}
|
|
346
|
-
|
|
347
|
-
function parseOffBoardWiring(value: YamlValue | undefined): OffBoardWiringPlan | undefined {
|
|
230
|
+
function parseOffBoardWiring(value) {
|
|
348
231
|
if (value === undefined) {
|
|
349
232
|
return undefined;
|
|
350
233
|
}
|
|
@@ -359,16 +242,14 @@ function parseOffBoardWiring(value: YamlValue | undefined): OffBoardWiringPlan |
|
|
|
359
242
|
harnesses: optionalArray(plan.harnesses, 'offBoardWiring.harnesses').map(parseOffBoardWiringHarness),
|
|
360
243
|
};
|
|
361
244
|
}
|
|
362
|
-
|
|
363
|
-
function parseOffBoardWiringCoverage(value: YamlValue | undefined, path: string): OffBoardWiringCoverage {
|
|
245
|
+
function parseOffBoardWiringCoverage(value, path) {
|
|
364
246
|
const coverage = expectString(value, path);
|
|
365
247
|
if (coverage === 'selected-build-complete' || coverage === 'representative-selected-build-endpoints') {
|
|
366
248
|
return coverage;
|
|
367
249
|
}
|
|
368
250
|
throw new Error(`${path}: expected selected-build-complete or representative-selected-build-endpoints`);
|
|
369
251
|
}
|
|
370
|
-
|
|
371
|
-
function parseOffBoardWiringHarness(value: YamlValue, index: number): OffBoardWiringHarness {
|
|
252
|
+
function parseOffBoardWiringHarness(value, index) {
|
|
372
253
|
const path = `offBoardWiring.harnesses[${index}]`;
|
|
373
254
|
const harness = expectObject(value, path);
|
|
374
255
|
return {
|
|
@@ -378,24 +259,18 @@ function parseOffBoardWiringHarness(value: YamlValue, index: number): OffBoardWi
|
|
|
378
259
|
? {}
|
|
379
260
|
: { status: parseOffBoardWiringHarnessStatus(harness.status, `${path}.status`) }),
|
|
380
261
|
...(harness.notes === undefined ? {} : { notes: expectString(harness.notes, `${path}.notes`) }),
|
|
381
|
-
endpoints: optionalArray(harness.endpoints, `${path}.endpoints`).map((endpoint, endpointIndex) =>
|
|
382
|
-
|
|
383
|
-
),
|
|
384
|
-
connections: optionalArray(harness.connections, `${path}.connections`).map((connection, connectionIndex) =>
|
|
385
|
-
parseOffBoardWiringConnection(connection, `${path}.connections[${connectionIndex}]`)
|
|
386
|
-
),
|
|
262
|
+
endpoints: optionalArray(harness.endpoints, `${path}.endpoints`).map((endpoint, endpointIndex) => parseOffBoardWiringEndpoint(endpoint, `${path}.endpoints[${endpointIndex}]`)),
|
|
263
|
+
connections: optionalArray(harness.connections, `${path}.connections`).map((connection, connectionIndex) => parseOffBoardWiringConnection(connection, `${path}.connections[${connectionIndex}]`)),
|
|
387
264
|
};
|
|
388
265
|
}
|
|
389
|
-
|
|
390
|
-
function parseOffBoardWiringHarnessStatus(value: YamlValue | undefined, path: string): OffBoardWiringHarnessStatus {
|
|
266
|
+
function parseOffBoardWiringHarnessStatus(value, path) {
|
|
391
267
|
const status = expectString(value, path);
|
|
392
268
|
if (status === 'complete' || status === 'partial' || status === 'candidate') {
|
|
393
269
|
return status;
|
|
394
270
|
}
|
|
395
271
|
throw new Error(`${path}: expected complete, partial, or candidate`);
|
|
396
272
|
}
|
|
397
|
-
|
|
398
|
-
function parseOffBoardWiringEndpoint(value: YamlValue, path: string): OffBoardWiringEndpoint {
|
|
273
|
+
function parseOffBoardWiringEndpoint(value, path) {
|
|
399
274
|
const endpoint = expectObject(value, path);
|
|
400
275
|
const kind = expectString(endpoint.kind, `${path}.kind`);
|
|
401
276
|
switch (kind) {
|
|
@@ -427,8 +302,7 @@ function parseOffBoardWiringEndpoint(value: YamlValue, path: string): OffBoardWi
|
|
|
427
302
|
throw new Error(`${path}.kind: expected a supported off-board wiring endpoint kind`);
|
|
428
303
|
}
|
|
429
304
|
}
|
|
430
|
-
|
|
431
|
-
function parseOffBoardWiringConnection(value: YamlValue, path: string): OffBoardWiringConnection {
|
|
305
|
+
function parseOffBoardWiringConnection(value, path) {
|
|
432
306
|
const connection = expectObject(value, path);
|
|
433
307
|
return {
|
|
434
308
|
...parseBuildDataObject(connection, path),
|
|
@@ -441,15 +315,13 @@ function parseOffBoardWiringConnection(value: YamlValue, path: string): OffBoard
|
|
|
441
315
|
...(connection.wire === undefined ? {} : { wire: parseBuildDataObject(connection.wire, `${path}.wire`) }),
|
|
442
316
|
};
|
|
443
317
|
}
|
|
444
|
-
|
|
445
|
-
function parseBoards(value: YamlValue | undefined): readonly BoardRealization[] | undefined {
|
|
318
|
+
function parseBoards(value) {
|
|
446
319
|
if (value === undefined) {
|
|
447
320
|
return undefined;
|
|
448
321
|
}
|
|
449
322
|
return optionalArray(value, 'boards').map(parseBoard);
|
|
450
323
|
}
|
|
451
|
-
|
|
452
|
-
function parseBoard(value: YamlValue, index: number): BoardRealization {
|
|
324
|
+
function parseBoard(value, index) {
|
|
453
325
|
const path = `boards[${index}]`;
|
|
454
326
|
const board = expectObject(value, path);
|
|
455
327
|
const sourceCircuit = board.sourceCircuit === undefined
|
|
@@ -466,23 +338,16 @@ function parseBoard(value: YamlValue, index: number): BoardRealization {
|
|
|
466
338
|
...(board.units === undefined ? {} : { units: expectString(board.units, `${path}.units`) }),
|
|
467
339
|
...(board.locked === undefined ? {} : { locked: expectBoolean(board.locked, `${path}.locked`) }),
|
|
468
340
|
...(sourceCircuit === undefined ? {} : { sourceCircuit }),
|
|
469
|
-
edgeTerminals: optionalArray(board.edgeTerminals, `${path}.edgeTerminals`).map((terminal, terminalIndex) =>
|
|
470
|
-
|
|
471
|
-
),
|
|
472
|
-
footprintPlacements: optionalArray(board.footprintPlacements, `${path}.footprintPlacements`).map((placement, placementIndex) =>
|
|
473
|
-
parseBoardFootprintPlacement(placement, `${path}.footprintPlacements[${placementIndex}]`)
|
|
474
|
-
),
|
|
341
|
+
edgeTerminals: optionalArray(board.edgeTerminals, `${path}.edgeTerminals`).map((terminal, terminalIndex) => parseBoardEdgeTerminal(terminal, `${path}.edgeTerminals[${terminalIndex}]`)),
|
|
342
|
+
footprintPlacements: optionalArray(board.footprintPlacements, `${path}.footprintPlacements`).map((placement, placementIndex) => parseBoardFootprintPlacement(placement, `${path}.footprintPlacements[${placementIndex}]`)),
|
|
475
343
|
...(board.netlist === undefined ? {} : { netlist: parseBoardNetlist(board.netlist, `${path}.netlist`) }),
|
|
476
|
-
routes: optionalArray(board.routes, `${path}.routes`).map((route, routeIndex) =>
|
|
477
|
-
parseBoardRoute(route, `${path}.routes[${routeIndex}]`)
|
|
478
|
-
),
|
|
344
|
+
routes: optionalArray(board.routes, `${path}.routes`).map((route, routeIndex) => parseBoardRoute(route, `${path}.routes[${routeIndex}]`)),
|
|
479
345
|
...(board.zones === undefined ? {} : { zones: parseBuildDataObjectArray(board.zones, `${path}.zones`) }),
|
|
480
346
|
...(board.drills === undefined ? {} : { drills: parseBuildDataObjectArray(board.drills, `${path}.drills`) }),
|
|
481
347
|
...(board.review === undefined ? {} : { review: parseBuildDataObject(board.review, `${path}.review`) }),
|
|
482
348
|
};
|
|
483
349
|
}
|
|
484
|
-
|
|
485
|
-
function parseBoardSourceCircuit(value: YamlValue, path: string): BoardSourceCircuitHash {
|
|
350
|
+
function parseBoardSourceCircuit(value, path) {
|
|
486
351
|
const sourceCircuit = expectObject(value, path);
|
|
487
352
|
const hash = expectString(sourceCircuit.hash, `${path}.hash`);
|
|
488
353
|
if (!/^sha256:[0-9a-f]{64}$/.test(hash)) {
|
|
@@ -495,8 +360,7 @@ function parseBoardSourceCircuit(value: YamlValue, path: string): BoardSourceCir
|
|
|
495
360
|
hash,
|
|
496
361
|
};
|
|
497
362
|
}
|
|
498
|
-
|
|
499
|
-
function parseBoardEdgeTerminal(value: YamlValue, path: string): BoardEdgeTerminal {
|
|
363
|
+
function parseBoardEdgeTerminal(value, path) {
|
|
500
364
|
const terminal = expectObject(value, path);
|
|
501
365
|
return {
|
|
502
366
|
...parseBuildDataObject(terminal, path),
|
|
@@ -508,8 +372,7 @@ function parseBoardEdgeTerminal(value: YamlValue, path: string): BoardEdgeTermin
|
|
|
508
372
|
...(terminal.hole === undefined ? {} : { hole: parseBoardHole(terminal.hole, `${path}.hole`) }),
|
|
509
373
|
};
|
|
510
374
|
}
|
|
511
|
-
|
|
512
|
-
function parseBoardFootprintPlacement(value: YamlValue, path: string): BoardFootprintPlacement {
|
|
375
|
+
function parseBoardFootprintPlacement(value, path) {
|
|
513
376
|
const placement = expectObject(value, path);
|
|
514
377
|
return {
|
|
515
378
|
...parseBuildDataObject(placement, path),
|
|
@@ -518,13 +381,10 @@ function parseBoardFootprintPlacement(value: YamlValue, path: string): BoardFoot
|
|
|
518
381
|
...(placement.atGrid === undefined ? {} : { atGrid: parseBoardHole(placement.atGrid, `${path}.atGrid`) }),
|
|
519
382
|
...(placement.atMm === undefined ? {} : { atMm: parsePoint(placement.atMm, `${path}.atMm`) }),
|
|
520
383
|
...(placement.rotationDeg === undefined ? {} : { rotationDeg: expectNumber(placement.rotationDeg, `${path}.rotationDeg`) }),
|
|
521
|
-
pads: optionalArray(placement.pads, `${path}.pads`).map((pad, padIndex) =>
|
|
522
|
-
parseBoardPlacedPad(pad, `${path}.pads[${padIndex}]`)
|
|
523
|
-
),
|
|
384
|
+
pads: optionalArray(placement.pads, `${path}.pads`).map((pad, padIndex) => parseBoardPlacedPad(pad, `${path}.pads[${padIndex}]`)),
|
|
524
385
|
};
|
|
525
386
|
}
|
|
526
|
-
|
|
527
|
-
function parseBoardPlacedPad(value: YamlValue, path: string): BoardPlacedPad {
|
|
387
|
+
function parseBoardPlacedPad(value, path) {
|
|
528
388
|
const pad = expectObject(value, path);
|
|
529
389
|
return {
|
|
530
390
|
...parseBuildDataObject(pad, path),
|
|
@@ -534,31 +394,24 @@ function parseBoardPlacedPad(value: YamlValue, path: string): BoardPlacedPad {
|
|
|
534
394
|
...(pad.positionMm === undefined ? {} : { positionMm: parsePoint(pad.positionMm, `${path}.positionMm`) }),
|
|
535
395
|
};
|
|
536
396
|
}
|
|
537
|
-
|
|
538
|
-
function parseBoardNetlist(value: YamlValue, path: string): BoardNetlist {
|
|
397
|
+
function parseBoardNetlist(value, path) {
|
|
539
398
|
const netlist = expectObject(value, path);
|
|
540
399
|
return {
|
|
541
400
|
...parseBuildDataObject(netlist, path),
|
|
542
401
|
...(netlist.source === undefined ? {} : { source: expectString(netlist.source, `${path}.source`) }),
|
|
543
|
-
nets: optionalArray(netlist.nets, `${path}.nets`).map((net, netIndex) =>
|
|
544
|
-
parseBoardNet(net, `${path}.nets[${netIndex}]`)
|
|
545
|
-
),
|
|
402
|
+
nets: optionalArray(netlist.nets, `${path}.nets`).map((net, netIndex) => parseBoardNet(net, `${path}.nets[${netIndex}]`)),
|
|
546
403
|
};
|
|
547
404
|
}
|
|
548
|
-
|
|
549
|
-
function parseBoardNet(value: YamlValue, path: string): BoardNet {
|
|
405
|
+
function parseBoardNet(value, path) {
|
|
550
406
|
const net = expectObject(value, path);
|
|
551
407
|
return {
|
|
552
408
|
...parseBuildDataObject(net, path),
|
|
553
409
|
id: expectString(net.id, `${path}.id`),
|
|
554
410
|
...(net.name === undefined ? {} : { name: expectString(net.name, `${path}.name`) }),
|
|
555
|
-
members: optionalArray(net.members, `${path}.members`).map((member, memberIndex) =>
|
|
556
|
-
parseBoardNetMember(member, `${path}.members[${memberIndex}]`)
|
|
557
|
-
),
|
|
411
|
+
members: optionalArray(net.members, `${path}.members`).map((member, memberIndex) => parseBoardNetMember(member, `${path}.members[${memberIndex}]`)),
|
|
558
412
|
};
|
|
559
413
|
}
|
|
560
|
-
|
|
561
|
-
function parseBoardNetMember(value: YamlValue, path: string): BoardNetMember {
|
|
414
|
+
function parseBoardNetMember(value, path) {
|
|
562
415
|
const member = expectObject(value, path);
|
|
563
416
|
return {
|
|
564
417
|
...parseBuildDataObject(member, path),
|
|
@@ -568,8 +421,7 @@ function parseBoardNetMember(value: YamlValue, path: string): BoardNetMember {
|
|
|
568
421
|
...(member.terminalId === undefined ? {} : { terminalId: expectString(member.terminalId, `${path}.terminalId`) }),
|
|
569
422
|
};
|
|
570
423
|
}
|
|
571
|
-
|
|
572
|
-
function parseBoardRoute(value: YamlValue, path: string): BoardRoute {
|
|
424
|
+
function parseBoardRoute(value, path) {
|
|
573
425
|
const route = expectObject(value, path);
|
|
574
426
|
return {
|
|
575
427
|
...parseBuildDataObject(route, path),
|
|
@@ -585,8 +437,7 @@ function parseBoardRoute(value: YamlValue, path: string): BoardRoute {
|
|
|
585
437
|
...(route.drills === undefined ? {} : { drills: parseBuildDataObjectArray(route.drills, `${path}.drills`) }),
|
|
586
438
|
};
|
|
587
439
|
}
|
|
588
|
-
|
|
589
|
-
function parseComponentTerminalRef(value: YamlValue, path: string): ComponentTerminalRef {
|
|
440
|
+
function parseComponentTerminalRef(value, path) {
|
|
590
441
|
const ref = expectObject(value, path);
|
|
591
442
|
return {
|
|
592
443
|
...parseBuildDataObject(ref, path),
|
|
@@ -594,8 +445,7 @@ function parseComponentTerminalRef(value: YamlValue, path: string): ComponentTer
|
|
|
594
445
|
terminalName: expectString(ref.terminalName, `${path}.terminalName`),
|
|
595
446
|
};
|
|
596
447
|
}
|
|
597
|
-
|
|
598
|
-
function parseBoardHole(value: YamlValue, path: string) {
|
|
448
|
+
function parseBoardHole(value, path) {
|
|
599
449
|
const hole = expectObject(value, path);
|
|
600
450
|
return {
|
|
601
451
|
...parseBuildDataObject(hole, path),
|
|
@@ -603,16 +453,14 @@ function parseBoardHole(value: YamlValue, path: string) {
|
|
|
603
453
|
column: expectPositiveInteger(hole.column, `${path}.column`),
|
|
604
454
|
};
|
|
605
455
|
}
|
|
606
|
-
|
|
607
|
-
function parseBoardFamily(value: YamlValue | undefined, path: string): BoardFamily {
|
|
456
|
+
function parseBoardFamily(value, path) {
|
|
608
457
|
const family = expectString(value, path);
|
|
609
458
|
if (family === 'prototype-board' || family === 'fabricated-board') {
|
|
610
459
|
return family;
|
|
611
460
|
}
|
|
612
461
|
throw new Error(`${path}: expected prototype-board or fabricated-board`);
|
|
613
462
|
}
|
|
614
|
-
|
|
615
|
-
function parseBoardKind(value: YamlValue | undefined, path: string): BoardKind {
|
|
463
|
+
function parseBoardKind(value, path) {
|
|
616
464
|
const kind = expectString(value, path);
|
|
617
465
|
switch (kind) {
|
|
618
466
|
case 'stripboard':
|
|
@@ -624,8 +472,7 @@ function parseBoardKind(value: YamlValue | undefined, path: string): BoardKind {
|
|
|
624
472
|
throw new Error(`${path}: expected stripboard, perfboard, breadboard-pattern, or pcb`);
|
|
625
473
|
}
|
|
626
474
|
}
|
|
627
|
-
|
|
628
|
-
function parseBoardSubtype(value: YamlValue | undefined, path: string): BoardSubtype {
|
|
475
|
+
function parseBoardSubtype(value, path) {
|
|
629
476
|
const subtype = expectString(value, path);
|
|
630
477
|
switch (subtype) {
|
|
631
478
|
case 'veroboard':
|
|
@@ -638,29 +485,25 @@ function parseBoardSubtype(value: YamlValue | undefined, path: string): BoardSub
|
|
|
638
485
|
throw new Error(`${path}: expected a supported board subtype`);
|
|
639
486
|
}
|
|
640
487
|
}
|
|
641
|
-
|
|
642
|
-
function parseLiteralString<T extends string>(value: YamlValue | undefined, path: string, expected: T): T {
|
|
488
|
+
function parseLiteralString(value, path, expected) {
|
|
643
489
|
const actual = expectString(value, path);
|
|
644
490
|
if (actual === expected) {
|
|
645
491
|
return expected;
|
|
646
492
|
}
|
|
647
493
|
throw new Error(`${path}: expected ${expected}`);
|
|
648
494
|
}
|
|
649
|
-
|
|
650
|
-
function parseBuildDataObjectArray(value: YamlValue | undefined, path: string): readonly VdspBuildDataObject[] {
|
|
495
|
+
function parseBuildDataObjectArray(value, path) {
|
|
651
496
|
return optionalArray(value, path).map((item, index) => parseBuildDataObject(item, `${path}[${index}]`));
|
|
652
497
|
}
|
|
653
|
-
|
|
654
|
-
function parseBuildDataObject(value: YamlValue | undefined, path: string): VdspBuildDataObject {
|
|
498
|
+
function parseBuildDataObject(value, path) {
|
|
655
499
|
const object = expectObject(value, path);
|
|
656
|
-
const out
|
|
500
|
+
const out = {};
|
|
657
501
|
for (const [key, child] of Object.entries(object)) {
|
|
658
502
|
out[key] = parseBuildDataValue(child, `${path}.${key}`);
|
|
659
503
|
}
|
|
660
504
|
return out;
|
|
661
505
|
}
|
|
662
|
-
|
|
663
|
-
function parseBuildDataValue(value: YamlValue, path: string): VdspBuildDataValue {
|
|
506
|
+
function parseBuildDataValue(value, path) {
|
|
664
507
|
if (isScalar(value)) {
|
|
665
508
|
return value;
|
|
666
509
|
}
|
|
@@ -672,8 +515,7 @@ function parseBuildDataValue(value: YamlValue, path: string): VdspBuildDataValue
|
|
|
672
515
|
}
|
|
673
516
|
throw new Error(`${path}: expected v3 build data value`);
|
|
674
517
|
}
|
|
675
|
-
|
|
676
|
-
function parseControlGroups(value: YamlValue | undefined): readonly ControlGroup[] | undefined {
|
|
518
|
+
function parseControlGroups(value) {
|
|
677
519
|
if (value === undefined) {
|
|
678
520
|
return undefined;
|
|
679
521
|
}
|
|
@@ -691,8 +533,7 @@ function parseControlGroups(value: YamlValue | undefined): readonly ControlGroup
|
|
|
691
533
|
};
|
|
692
534
|
});
|
|
693
535
|
}
|
|
694
|
-
|
|
695
|
-
function parseControlContexts(value: YamlValue | undefined): readonly ControlContext[] | undefined {
|
|
536
|
+
function parseControlContexts(value) {
|
|
696
537
|
if (value === undefined) {
|
|
697
538
|
return undefined;
|
|
698
539
|
}
|
|
@@ -708,8 +549,7 @@ function parseControlContexts(value: YamlValue | undefined): readonly ControlCon
|
|
|
708
549
|
};
|
|
709
550
|
});
|
|
710
551
|
}
|
|
711
|
-
|
|
712
|
-
function parseDeviceInterface(value: YamlValue | undefined): DeviceInterface | undefined {
|
|
552
|
+
function parseDeviceInterface(value) {
|
|
713
553
|
if (value === undefined) {
|
|
714
554
|
return undefined;
|
|
715
555
|
}
|
|
@@ -737,11 +577,7 @@ function parseDeviceInterface(value: YamlValue | undefined): DeviceInterface | u
|
|
|
737
577
|
}),
|
|
738
578
|
};
|
|
739
579
|
}
|
|
740
|
-
|
|
741
|
-
function parseDeviceInterfaceControlKind(
|
|
742
|
-
value: YamlValue | undefined,
|
|
743
|
-
path: string,
|
|
744
|
-
): DeviceInterfaceControlKind {
|
|
580
|
+
function parseDeviceInterfaceControlKind(value, path) {
|
|
745
581
|
const kind = expectString(value, path);
|
|
746
582
|
switch (kind) {
|
|
747
583
|
case 'knob':
|
|
@@ -756,11 +592,7 @@ function parseDeviceInterfaceControlKind(
|
|
|
756
592
|
throw new Error(`${path}: expected knob, slider, switch, selector, footswitch, led, or jack`);
|
|
757
593
|
}
|
|
758
594
|
}
|
|
759
|
-
|
|
760
|
-
function parseOptionalDeviceInterfaceBinding(
|
|
761
|
-
value: YamlValue | undefined,
|
|
762
|
-
path: string,
|
|
763
|
-
): DeviceInterfaceBinding | undefined {
|
|
595
|
+
function parseOptionalDeviceInterfaceBinding(value, path) {
|
|
764
596
|
if (value === undefined) {
|
|
765
597
|
return undefined;
|
|
766
598
|
}
|
|
@@ -777,11 +609,7 @@ function parseOptionalDeviceInterfaceBinding(
|
|
|
777
609
|
...(externalInterfaceId === undefined ? {} : { externalInterfaceId }),
|
|
778
610
|
};
|
|
779
611
|
}
|
|
780
|
-
|
|
781
|
-
function parseOptionalApplicabilityPredicate(
|
|
782
|
-
value: YamlValue | undefined,
|
|
783
|
-
path: string,
|
|
784
|
-
): ControlApplicabilityPredicate | undefined {
|
|
612
|
+
function parseOptionalApplicabilityPredicate(value, path) {
|
|
785
613
|
if (value === undefined) {
|
|
786
614
|
return undefined;
|
|
787
615
|
}
|
|
@@ -793,8 +621,7 @@ function parseOptionalApplicabilityPredicate(
|
|
|
793
621
|
...(anyOf === undefined ? {} : { anyOf }),
|
|
794
622
|
};
|
|
795
623
|
}
|
|
796
|
-
|
|
797
|
-
function parseDevice(value: YamlValue | undefined): CircuitDocumentDevice | undefined {
|
|
624
|
+
function parseDevice(value) {
|
|
798
625
|
if (value === undefined) {
|
|
799
626
|
return undefined;
|
|
800
627
|
}
|
|
@@ -813,8 +640,7 @@ function parseDevice(value: YamlValue | undefined): CircuitDocumentDevice | unde
|
|
|
813
640
|
...(audioProcessing === undefined ? {} : { audioProcessing }),
|
|
814
641
|
};
|
|
815
642
|
}
|
|
816
|
-
|
|
817
|
-
function parseCircuitDocumentDeviceKind(value: YamlValue | undefined, path: string): CircuitDocumentDeviceKind {
|
|
643
|
+
function parseCircuitDocumentDeviceKind(value, path) {
|
|
818
644
|
const kind = expectString(value, path);
|
|
819
645
|
switch (kind) {
|
|
820
646
|
case 'audio-pedal':
|
|
@@ -826,8 +652,7 @@ function parseCircuitDocumentDeviceKind(value: YamlValue | undefined, path: stri
|
|
|
826
652
|
throw new Error(`${path}: expected audio-pedal, control-accessory, utility, or unknown`);
|
|
827
653
|
}
|
|
828
654
|
}
|
|
829
|
-
|
|
830
|
-
function parseControlOutputs(value: YamlValue | undefined): readonly ControlOutput[] | undefined {
|
|
655
|
+
function parseControlOutputs(value) {
|
|
831
656
|
if (value === undefined) {
|
|
832
657
|
return undefined;
|
|
833
658
|
}
|
|
@@ -855,11 +680,7 @@ function parseControlOutputs(value: YamlValue | undefined): readonly ControlOutp
|
|
|
855
680
|
};
|
|
856
681
|
});
|
|
857
682
|
}
|
|
858
|
-
|
|
859
|
-
function parseOptionalControlOutputSwitchMode(
|
|
860
|
-
value: YamlValue | undefined,
|
|
861
|
-
path: string,
|
|
862
|
-
): ControlOutputSwitchMode | undefined {
|
|
683
|
+
function parseOptionalControlOutputSwitchMode(value, path) {
|
|
863
684
|
if (value === undefined) {
|
|
864
685
|
return undefined;
|
|
865
686
|
}
|
|
@@ -872,8 +693,7 @@ function parseOptionalControlOutputSwitchMode(
|
|
|
872
693
|
throw new Error(`${path}: expected momentary or latching`);
|
|
873
694
|
}
|
|
874
695
|
}
|
|
875
|
-
|
|
876
|
-
function parseControlInterfaces(value: YamlValue | undefined): readonly ControlInterface[] | undefined {
|
|
696
|
+
function parseControlInterfaces(value) {
|
|
877
697
|
if (value === undefined) {
|
|
878
698
|
return undefined;
|
|
879
699
|
}
|
|
@@ -884,10 +704,7 @@ function parseControlInterfaces(value: YamlValue | undefined): readonly ControlI
|
|
|
884
704
|
const controlRole = parseOptionalString(controlInterface.controlRole, `${path}.controlRole`);
|
|
885
705
|
const interfaceName = parseOptionalString(controlInterface.interface, `${path}.interface`);
|
|
886
706
|
const connector = parseOptionalControlInterfaceConnector(controlInterface.connector, `${path}.connector`);
|
|
887
|
-
const assignmentHint = parseOptionalControlInterfaceAssignmentHint(
|
|
888
|
-
controlInterface.assignmentHint,
|
|
889
|
-
`${path}.assignmentHint`,
|
|
890
|
-
);
|
|
707
|
+
const assignmentHint = parseOptionalControlInterfaceAssignmentHint(controlInterface.assignmentHint, `${path}.assignmentHint`);
|
|
891
708
|
const polarity = parseOptionalControlInterfacePolarity(controlInterface.polarity, `${path}.polarity`);
|
|
892
709
|
const binding = parseOptionalControlInterfaceBinding(controlInterface.binding, `${path}.binding`);
|
|
893
710
|
const description = parseOptionalString(controlInterface.description, `${path}.description`);
|
|
@@ -906,11 +723,7 @@ function parseControlInterfaces(value: YamlValue | undefined): readonly ControlI
|
|
|
906
723
|
};
|
|
907
724
|
});
|
|
908
725
|
}
|
|
909
|
-
|
|
910
|
-
function parseOptionalControlInterfaceBinding(
|
|
911
|
-
value: YamlValue | undefined,
|
|
912
|
-
path: string,
|
|
913
|
-
): ControlInterface['binding'] | undefined {
|
|
726
|
+
function parseOptionalControlInterfaceBinding(value, path) {
|
|
914
727
|
if (value === undefined) {
|
|
915
728
|
return undefined;
|
|
916
729
|
}
|
|
@@ -926,8 +739,7 @@ function parseOptionalControlInterfaceBinding(
|
|
|
926
739
|
...(property === undefined ? {} : { property }),
|
|
927
740
|
};
|
|
928
741
|
}
|
|
929
|
-
|
|
930
|
-
function parseControlInterfaceRole(value: YamlValue | undefined, path: string): ControlInterfaceRole {
|
|
742
|
+
function parseControlInterfaceRole(value, path) {
|
|
931
743
|
const role = expectString(value, path);
|
|
932
744
|
switch (role) {
|
|
933
745
|
case 'external-control':
|
|
@@ -942,11 +754,7 @@ function parseControlInterfaceRole(value: YamlValue | undefined, path: string):
|
|
|
942
754
|
throw new Error(`${path}: expected external-control, tempo-tap, trigger, reset, sampler-trigger, expression, or unknown`);
|
|
943
755
|
}
|
|
944
756
|
}
|
|
945
|
-
|
|
946
|
-
function parseOptionalControlInterfaceConnector(
|
|
947
|
-
value: YamlValue | undefined,
|
|
948
|
-
path: string,
|
|
949
|
-
): ControlInterfaceConnector | undefined {
|
|
757
|
+
function parseOptionalControlInterfaceConnector(value, path) {
|
|
950
758
|
if (value === undefined) {
|
|
951
759
|
return undefined;
|
|
952
760
|
}
|
|
@@ -963,11 +771,7 @@ function parseOptionalControlInterfaceConnector(
|
|
|
963
771
|
throw new Error(`${path}: expected a supported connector kind`);
|
|
964
772
|
}
|
|
965
773
|
}
|
|
966
|
-
|
|
967
|
-
function parseOptionalControlInterfaceAssignmentHint(
|
|
968
|
-
value: YamlValue | undefined,
|
|
969
|
-
path: string,
|
|
970
|
-
): ControlInterfaceAssignmentHint | undefined {
|
|
774
|
+
function parseOptionalControlInterfaceAssignmentHint(value, path) {
|
|
971
775
|
if (value === undefined) {
|
|
972
776
|
return undefined;
|
|
973
777
|
}
|
|
@@ -982,11 +786,7 @@ function parseOptionalControlInterfaceAssignmentHint(
|
|
|
982
786
|
throw new Error(`${path}: expected momentary, latching, momentary-or-latching, or continuous`);
|
|
983
787
|
}
|
|
984
788
|
}
|
|
985
|
-
|
|
986
|
-
function parseOptionalControlInterfacePolarity(
|
|
987
|
-
value: YamlValue | undefined,
|
|
988
|
-
path: string,
|
|
989
|
-
): ControlInterfacePolarity | undefined {
|
|
789
|
+
function parseOptionalControlInterfacePolarity(value, path) {
|
|
990
790
|
if (value === undefined) {
|
|
991
791
|
return undefined;
|
|
992
792
|
}
|
|
@@ -1001,13 +801,12 @@ function parseOptionalControlInterfacePolarity(
|
|
|
1001
801
|
throw new Error(`${path}: expected normally-open, normally-closed, expression, or unknown`);
|
|
1002
802
|
}
|
|
1003
803
|
}
|
|
1004
|
-
|
|
1005
|
-
function parseYamlSubset(source: string): YamlValue {
|
|
804
|
+
function parseYamlSubset(source) {
|
|
1006
805
|
const lines = tokenize(source);
|
|
1007
806
|
if (lines.length === 0) {
|
|
1008
807
|
throw new Error('interchange YAML is empty');
|
|
1009
808
|
}
|
|
1010
|
-
const cursor
|
|
809
|
+
const cursor = { index: 0 };
|
|
1011
810
|
const first = lines[0];
|
|
1012
811
|
if (first === undefined) {
|
|
1013
812
|
throw new Error('interchange YAML is empty');
|
|
@@ -1019,9 +818,8 @@ function parseYamlSubset(source: string): YamlValue {
|
|
|
1019
818
|
}
|
|
1020
819
|
return value;
|
|
1021
820
|
}
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
const lines: YamlLine[] = [];
|
|
821
|
+
function tokenize(source) {
|
|
822
|
+
const lines = [];
|
|
1025
823
|
const rawLines = source.replace(/^/, '').split(/\r?\n/);
|
|
1026
824
|
rawLines.forEach((rawLine, index) => {
|
|
1027
825
|
if (rawLine.trim().length === 0) {
|
|
@@ -1039,8 +837,7 @@ function tokenize(source: string): readonly YamlLine[] {
|
|
|
1039
837
|
});
|
|
1040
838
|
return lines;
|
|
1041
839
|
}
|
|
1042
|
-
|
|
1043
|
-
function parseBlock(lines: readonly YamlLine[], cursor: Cursor, indent: number): YamlValue {
|
|
840
|
+
function parseBlock(lines, cursor, indent) {
|
|
1044
841
|
const line = lines[cursor.index];
|
|
1045
842
|
if (line === undefined) {
|
|
1046
843
|
return {};
|
|
@@ -1053,9 +850,8 @@ function parseBlock(lines: readonly YamlLine[], cursor: Cursor, indent: number):
|
|
|
1053
850
|
}
|
|
1054
851
|
return parseObject(lines, cursor, indent);
|
|
1055
852
|
}
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
const out: YamlObject = {};
|
|
853
|
+
function parseObject(lines, cursor, indent) {
|
|
854
|
+
const out = {};
|
|
1059
855
|
while (cursor.index < lines.length) {
|
|
1060
856
|
const line = lines[cursor.index];
|
|
1061
857
|
if (line === undefined || line.indent < indent) {
|
|
@@ -1067,7 +863,6 @@ function parseObject(lines: readonly YamlLine[], cursor: Cursor, indent: number)
|
|
|
1067
863
|
if (line.text === '-' || line.text.startsWith('- ')) {
|
|
1068
864
|
break;
|
|
1069
865
|
}
|
|
1070
|
-
|
|
1071
866
|
const pair = parsePair(line.text, line.lineNumber);
|
|
1072
867
|
cursor.index += 1;
|
|
1073
868
|
out[pair.key] = pair.rest.length > 0
|
|
@@ -1076,9 +871,8 @@ function parseObject(lines: readonly YamlLine[], cursor: Cursor, indent: number)
|
|
|
1076
871
|
}
|
|
1077
872
|
return out;
|
|
1078
873
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
const out: YamlValue[] = [];
|
|
874
|
+
function parseArray(lines, cursor, indent) {
|
|
875
|
+
const out = [];
|
|
1082
876
|
while (cursor.index < lines.length) {
|
|
1083
877
|
const line = lines[cursor.index];
|
|
1084
878
|
if (line === undefined || line.indent < indent) {
|
|
@@ -1090,33 +884,26 @@ function parseArray(lines: readonly YamlLine[], cursor: Cursor, indent: number):
|
|
|
1090
884
|
if (line.text !== '-' && !line.text.startsWith('- ')) {
|
|
1091
885
|
break;
|
|
1092
886
|
}
|
|
1093
|
-
|
|
1094
887
|
const rest = line.text === '-' ? '' : line.text.slice(2);
|
|
1095
888
|
cursor.index += 1;
|
|
1096
889
|
if (rest.length === 0) {
|
|
1097
890
|
out.push(parseNestedValue(lines, cursor, indent, line.lineNumber));
|
|
1098
|
-
}
|
|
891
|
+
}
|
|
892
|
+
else if (looksLikePair(rest)) {
|
|
1099
893
|
out.push(parseObjectItem(rest, lines, cursor, indent + 2, line.lineNumber));
|
|
1100
|
-
}
|
|
894
|
+
}
|
|
895
|
+
else {
|
|
1101
896
|
out.push(parseInlineValue(rest, line.lineNumber));
|
|
1102
897
|
}
|
|
1103
898
|
}
|
|
1104
899
|
return out;
|
|
1105
900
|
}
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
firstPairText: string,
|
|
1109
|
-
lines: readonly YamlLine[],
|
|
1110
|
-
cursor: Cursor,
|
|
1111
|
-
indent: number,
|
|
1112
|
-
lineNumber: number,
|
|
1113
|
-
): YamlObject {
|
|
1114
|
-
const out: YamlObject = {};
|
|
901
|
+
function parseObjectItem(firstPairText, lines, cursor, indent, lineNumber) {
|
|
902
|
+
const out = {};
|
|
1115
903
|
const firstPair = parsePair(firstPairText, lineNumber);
|
|
1116
904
|
out[firstPair.key] = firstPair.rest.length > 0
|
|
1117
905
|
? parseInlineValue(firstPair.rest, lineNumber)
|
|
1118
906
|
: parseNestedValue(lines, cursor, indent, lineNumber);
|
|
1119
|
-
|
|
1120
907
|
while (cursor.index < lines.length) {
|
|
1121
908
|
const line = lines[cursor.index];
|
|
1122
909
|
if (line === undefined || line.indent < indent) {
|
|
@@ -1128,23 +915,15 @@ function parseObjectItem(
|
|
|
1128
915
|
if (line.text === '-' || line.text.startsWith('- ')) {
|
|
1129
916
|
break;
|
|
1130
917
|
}
|
|
1131
|
-
|
|
1132
918
|
const pair = parsePair(line.text, line.lineNumber);
|
|
1133
919
|
cursor.index += 1;
|
|
1134
920
|
out[pair.key] = pair.rest.length > 0
|
|
1135
921
|
? parseInlineValue(pair.rest, line.lineNumber)
|
|
1136
922
|
: parseNestedValue(lines, cursor, indent, line.lineNumber);
|
|
1137
923
|
}
|
|
1138
|
-
|
|
1139
924
|
return out;
|
|
1140
925
|
}
|
|
1141
|
-
|
|
1142
|
-
function parseNestedValue(
|
|
1143
|
-
lines: readonly YamlLine[],
|
|
1144
|
-
cursor: Cursor,
|
|
1145
|
-
parentIndent: number,
|
|
1146
|
-
lineNumber: number,
|
|
1147
|
-
): YamlValue {
|
|
926
|
+
function parseNestedValue(lines, cursor, parentIndent, lineNumber) {
|
|
1148
927
|
const next = lines[cursor.index];
|
|
1149
928
|
if (next === undefined || next.indent <= parentIndent) {
|
|
1150
929
|
return {};
|
|
@@ -1154,8 +933,7 @@ function parseNestedValue(
|
|
|
1154
933
|
}
|
|
1155
934
|
return parseBlock(lines, cursor, next.indent);
|
|
1156
935
|
}
|
|
1157
|
-
|
|
1158
|
-
function parsePair(text: string, lineNumber: number): ParsedPair {
|
|
936
|
+
function parsePair(text, lineNumber) {
|
|
1159
937
|
const colonIndex = findPairColon(text);
|
|
1160
938
|
if (colonIndex <= 0) {
|
|
1161
939
|
throw new Error(`line ${lineNumber}: expected key/value pair`);
|
|
@@ -1167,20 +945,17 @@ function parsePair(text: string, lineNumber: number): ParsedPair {
|
|
|
1167
945
|
rest: restText.startsWith(' ') ? restText.slice(1) : restText,
|
|
1168
946
|
};
|
|
1169
947
|
}
|
|
1170
|
-
|
|
1171
|
-
function looksLikePair(text: string): boolean {
|
|
948
|
+
function looksLikePair(text) {
|
|
1172
949
|
return findPairColon(text) > 0;
|
|
1173
950
|
}
|
|
1174
|
-
|
|
1175
|
-
function findPairColon(text: string): number {
|
|
951
|
+
function findPairColon(text) {
|
|
1176
952
|
if (text.startsWith('"')) {
|
|
1177
953
|
const end = findJsonStringEnd(text);
|
|
1178
954
|
return end >= 0 && text[end + 1] === ':' ? end + 1 : -1;
|
|
1179
955
|
}
|
|
1180
956
|
return text.indexOf(':');
|
|
1181
957
|
}
|
|
1182
|
-
|
|
1183
|
-
function findJsonStringEnd(text: string): number {
|
|
958
|
+
function findJsonStringEnd(text) {
|
|
1184
959
|
let escaped = false;
|
|
1185
960
|
for (let index = 1; index < text.length; index += 1) {
|
|
1186
961
|
const char = text[index];
|
|
@@ -1198,8 +973,7 @@ function findJsonStringEnd(text: string): number {
|
|
|
1198
973
|
}
|
|
1199
974
|
return -1;
|
|
1200
975
|
}
|
|
1201
|
-
|
|
1202
|
-
function parseKey(text: string, lineNumber: number): string {
|
|
976
|
+
function parseKey(text, lineNumber) {
|
|
1203
977
|
if (!text.startsWith('"')) {
|
|
1204
978
|
return text;
|
|
1205
979
|
}
|
|
@@ -1208,13 +982,13 @@ function parseKey(text: string, lineNumber: number): string {
|
|
|
1208
982
|
if (typeof parsed === 'string') {
|
|
1209
983
|
return parsed;
|
|
1210
984
|
}
|
|
1211
|
-
}
|
|
985
|
+
}
|
|
986
|
+
catch {
|
|
1212
987
|
// Fall through to the consistent parser error below.
|
|
1213
988
|
}
|
|
1214
989
|
throw new Error(`line ${lineNumber}: invalid quoted key`);
|
|
1215
990
|
}
|
|
1216
|
-
|
|
1217
|
-
function parseInlineValue(text: string, lineNumber: number): YamlValue {
|
|
991
|
+
function parseInlineValue(text, lineNumber) {
|
|
1218
992
|
if (text === '[]') {
|
|
1219
993
|
return [];
|
|
1220
994
|
}
|
|
@@ -1236,7 +1010,8 @@ function parseInlineValue(text: string, lineNumber: number): YamlValue {
|
|
|
1236
1010
|
if (typeof parsed === 'string') {
|
|
1237
1011
|
return parsed;
|
|
1238
1012
|
}
|
|
1239
|
-
}
|
|
1013
|
+
}
|
|
1014
|
+
catch {
|
|
1240
1015
|
// Fall through to the consistent parser error below.
|
|
1241
1016
|
}
|
|
1242
1017
|
throw new Error(`line ${lineNumber}: invalid quoted scalar`);
|
|
@@ -1246,8 +1021,7 @@ function parseInlineValue(text: string, lineNumber: number): YamlValue {
|
|
|
1246
1021
|
}
|
|
1247
1022
|
return text;
|
|
1248
1023
|
}
|
|
1249
|
-
|
|
1250
|
-
function parseMetadata(value: YamlValue | undefined): CircuitDocument['metadata'] {
|
|
1024
|
+
function parseMetadata(value) {
|
|
1251
1025
|
const metadata = optionalObject(value, 'metadata');
|
|
1252
1026
|
return {
|
|
1253
1027
|
name: scalarText(metadata.name),
|
|
@@ -1255,46 +1029,34 @@ function parseMetadata(value: YamlValue | undefined): CircuitDocument['metadata'
|
|
|
1255
1029
|
partNumber: scalarText(metadata.partNumber),
|
|
1256
1030
|
};
|
|
1257
1031
|
}
|
|
1258
|
-
|
|
1259
|
-
function parseSource(value: YamlValue | undefined): DocumentSource {
|
|
1032
|
+
function parseSource(value) {
|
|
1260
1033
|
return parseStringRecord(value, 'source');
|
|
1261
1034
|
}
|
|
1262
|
-
|
|
1263
|
-
function parsePanel(value: YamlValue | undefined, allowV3PhysicalFields: boolean): PanelPlacementMetadata | undefined {
|
|
1035
|
+
function parsePanel(value, allowV3PhysicalFields) {
|
|
1264
1036
|
if (value === undefined) {
|
|
1265
1037
|
return undefined;
|
|
1266
1038
|
}
|
|
1267
1039
|
const panel = expectObject(value, 'panel');
|
|
1268
|
-
|
|
1269
1040
|
if (panel.faces !== undefined) {
|
|
1270
1041
|
return {
|
|
1271
|
-
faces: optionalArray(panel.faces, 'panel.faces').map((item, index) =>
|
|
1272
|
-
parsePanelFace(item, index, allowV3PhysicalFields)
|
|
1273
|
-
),
|
|
1042
|
+
faces: optionalArray(panel.faces, 'panel.faces').map((item, index) => parsePanelFace(item, index, allowV3PhysicalFields)),
|
|
1274
1043
|
};
|
|
1275
1044
|
}
|
|
1276
|
-
|
|
1277
1045
|
if (panel.layout === undefined) {
|
|
1278
1046
|
return undefined;
|
|
1279
1047
|
}
|
|
1280
|
-
|
|
1281
1048
|
const layout = parsePanelLayout(panel.layout, 'panel.layout');
|
|
1282
1049
|
const elementsValue = panel.controls ?? panel.elements;
|
|
1283
1050
|
const elementsPath = panel.controls === undefined ? 'panel.elements' : 'panel.controls';
|
|
1284
1051
|
return {
|
|
1285
1052
|
faces: [{
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1053
|
+
id: 'top',
|
|
1054
|
+
layout,
|
|
1055
|
+
elements: parsePanelElements(elementsValue, layout, elementsPath, allowV3PhysicalFields),
|
|
1056
|
+
}],
|
|
1290
1057
|
};
|
|
1291
1058
|
}
|
|
1292
|
-
|
|
1293
|
-
function parsePanelFace(
|
|
1294
|
-
value: YamlValue,
|
|
1295
|
-
index: number,
|
|
1296
|
-
allowV3PhysicalFields: boolean,
|
|
1297
|
-
): PanelPlacementMetadata['faces'][number] {
|
|
1059
|
+
function parsePanelFace(value, index, allowV3PhysicalFields) {
|
|
1298
1060
|
const path = `panel.faces[${index}]`;
|
|
1299
1061
|
const face = expectObject(value, path);
|
|
1300
1062
|
const label = parseOptionalString(face.label, `${path}.label`);
|
|
@@ -1311,8 +1073,7 @@ function parsePanelFace(
|
|
|
1311
1073
|
elements: parsePanelElements(face.elements, layout, `${path}.elements`, allowV3PhysicalFields),
|
|
1312
1074
|
};
|
|
1313
1075
|
}
|
|
1314
|
-
|
|
1315
|
-
function parsePanelLayout(value: YamlValue | undefined, path: string): PanelGridLayout {
|
|
1076
|
+
function parsePanelLayout(value, path) {
|
|
1316
1077
|
const layout = expectObject(value, path);
|
|
1317
1078
|
const rowOrder = parseOptionalPanelRowOrder(layout.rowOrder, `${path}.rowOrder`);
|
|
1318
1079
|
const columnOrder = parseOptionalPanelColumnOrder(layout.columnOrder, `${path}.columnOrder`);
|
|
@@ -1325,13 +1086,7 @@ function parsePanelLayout(value: YamlValue | undefined, path: string): PanelGrid
|
|
|
1325
1086
|
...(columnOrder === undefined ? {} : { columnOrder }),
|
|
1326
1087
|
};
|
|
1327
1088
|
}
|
|
1328
|
-
|
|
1329
|
-
function parsePanelElements(
|
|
1330
|
-
value: YamlValue | undefined,
|
|
1331
|
-
layout: PanelGridLayout,
|
|
1332
|
-
path: string,
|
|
1333
|
-
allowV3PhysicalFields: boolean,
|
|
1334
|
-
): PanelPlacementMetadata['faces'][number]['elements'] {
|
|
1089
|
+
function parsePanelElements(value, layout, path, allowV3PhysicalFields) {
|
|
1335
1090
|
return optionalArray(value, path).map((item, index) => {
|
|
1336
1091
|
const elementPath = `${path}[${index}]`;
|
|
1337
1092
|
const element = expectObject(item, elementPath);
|
|
@@ -1350,12 +1105,9 @@ function parsePanelElements(
|
|
|
1350
1105
|
return {
|
|
1351
1106
|
...(id === undefined ? {} : { id }),
|
|
1352
1107
|
bind: parsePanelElementBinding(element, elementPath),
|
|
1353
|
-
kind: parsePanelControlKind(
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
? `${elementPath}.controlKind`
|
|
1357
|
-
: `${elementPath}.kind`,
|
|
1358
|
-
),
|
|
1108
|
+
kind: parsePanelControlKind(element.kind ?? element.controlKind, element.kind === undefined && element.controlKind !== undefined
|
|
1109
|
+
? `${elementPath}.controlKind`
|
|
1110
|
+
: `${elementPath}.kind`),
|
|
1359
1111
|
grid: parsePanelGridPosition(element.grid, `${elementPath}.grid`, layout),
|
|
1360
1112
|
...(label === undefined ? {} : { label }),
|
|
1361
1113
|
...(interfaceControlId === undefined ? {} : { interfaceControlId }),
|
|
@@ -1363,11 +1115,7 @@ function parsePanelElements(
|
|
|
1363
1115
|
};
|
|
1364
1116
|
});
|
|
1365
1117
|
}
|
|
1366
|
-
|
|
1367
|
-
function parseOptionalPanelFaceGeometry(
|
|
1368
|
-
value: YamlValue | undefined,
|
|
1369
|
-
path: string,
|
|
1370
|
-
): PanelFaceGeometry | undefined {
|
|
1118
|
+
function parseOptionalPanelFaceGeometry(value, path) {
|
|
1371
1119
|
if (value === undefined) {
|
|
1372
1120
|
return undefined;
|
|
1373
1121
|
}
|
|
@@ -1381,11 +1129,7 @@ function parseOptionalPanelFaceGeometry(
|
|
|
1381
1129
|
: { usableRectMm: parseMillimeterRect(geometry.usableRectMm, `${path}.usableRectMm`) }),
|
|
1382
1130
|
};
|
|
1383
1131
|
}
|
|
1384
|
-
|
|
1385
|
-
function parseOptionalPanelElementPhysical(
|
|
1386
|
-
value: YamlValue | undefined,
|
|
1387
|
-
path: string,
|
|
1388
|
-
): PanelElementPhysicalPlacement | undefined {
|
|
1132
|
+
function parseOptionalPanelElementPhysical(value, path) {
|
|
1389
1133
|
if (value === undefined) {
|
|
1390
1134
|
return undefined;
|
|
1391
1135
|
}
|
|
@@ -1403,8 +1147,7 @@ function parseOptionalPanelElementPhysical(
|
|
|
1403
1147
|
...(physical.locked === undefined ? {} : { locked: expectBoolean(physical.locked, `${path}.locked`) }),
|
|
1404
1148
|
};
|
|
1405
1149
|
}
|
|
1406
|
-
|
|
1407
|
-
function parseMillimeterRect(value: YamlValue | undefined, path: string) {
|
|
1150
|
+
function parseMillimeterRect(value, path) {
|
|
1408
1151
|
const rect = expectObject(value, path);
|
|
1409
1152
|
return {
|
|
1410
1153
|
x: expectNumber(rect.x, `${path}.x`),
|
|
@@ -1413,8 +1156,7 @@ function parseMillimeterRect(value: YamlValue | undefined, path: string) {
|
|
|
1413
1156
|
height: expectNumber(rect.height, `${path}.height`),
|
|
1414
1157
|
};
|
|
1415
1158
|
}
|
|
1416
|
-
|
|
1417
|
-
function parsePanelElementBinding(element: YamlObject, path: string): PanelElementBinding {
|
|
1159
|
+
function parsePanelElementBinding(element, path) {
|
|
1418
1160
|
if (element.bind !== undefined) {
|
|
1419
1161
|
const bind = expectObject(element.bind, `${path}.bind`);
|
|
1420
1162
|
const controlId = parseOptionalString(bind.controlId, `${path}.bind.controlId`);
|
|
@@ -1427,17 +1169,11 @@ function parsePanelElementBinding(element: YamlObject, path: string): PanelEleme
|
|
|
1427
1169
|
...(property === undefined ? {} : { property }),
|
|
1428
1170
|
};
|
|
1429
1171
|
}
|
|
1430
|
-
|
|
1431
1172
|
return {
|
|
1432
1173
|
componentId: expectString(element.componentId, `${path}.componentId`),
|
|
1433
1174
|
};
|
|
1434
1175
|
}
|
|
1435
|
-
|
|
1436
|
-
function parsePanelGridPosition(
|
|
1437
|
-
value: YamlValue | undefined,
|
|
1438
|
-
path: string,
|
|
1439
|
-
layout: PanelGridLayout,
|
|
1440
|
-
): PanelGridPosition {
|
|
1176
|
+
function parsePanelGridPosition(value, path, layout) {
|
|
1441
1177
|
const grid = expectObject(value, path);
|
|
1442
1178
|
const rowSpan = parseOptionalPositiveInteger(grid.rowSpan, `${path}.rowSpan`);
|
|
1443
1179
|
const columnSpan = parseOptionalPositiveInteger(grid.columnSpan, `${path}.columnSpan`);
|
|
@@ -1452,15 +1188,7 @@ function parsePanelGridPosition(
|
|
|
1452
1188
|
...(columnSpan === undefined ? {} : { columnSpan }),
|
|
1453
1189
|
};
|
|
1454
1190
|
}
|
|
1455
|
-
|
|
1456
|
-
function validateGridAxis(
|
|
1457
|
-
value: number,
|
|
1458
|
-
span: number,
|
|
1459
|
-
size: number,
|
|
1460
|
-
indexing: PanelGridIndexing,
|
|
1461
|
-
path: string,
|
|
1462
|
-
axisName: 'row' | 'column',
|
|
1463
|
-
): void {
|
|
1191
|
+
function validateGridAxis(value, span, size, indexing, path, axisName) {
|
|
1464
1192
|
const min = indexing === 'one-based' ? 1 : 0;
|
|
1465
1193
|
const occupiedEnd = indexing === 'one-based' ? value + span - 1 : value + span;
|
|
1466
1194
|
if (value < min || occupiedEnd > size) {
|
|
@@ -1468,24 +1196,21 @@ function validateGridAxis(
|
|
|
1468
1196
|
throw new Error(`${path}: expected ${indexing} ${axisName} coordinate within ${min}..${maxLabel}`);
|
|
1469
1197
|
}
|
|
1470
1198
|
}
|
|
1471
|
-
|
|
1472
|
-
function parsePanelLayoutKind(value: YamlValue | undefined, path: string): 'stompbox-grid' {
|
|
1199
|
+
function parsePanelLayoutKind(value, path) {
|
|
1473
1200
|
const kind = expectString(value, path);
|
|
1474
1201
|
if (kind === 'stompbox-grid') {
|
|
1475
1202
|
return kind;
|
|
1476
1203
|
}
|
|
1477
1204
|
throw new Error(`${path}: expected stompbox-grid`);
|
|
1478
1205
|
}
|
|
1479
|
-
|
|
1480
|
-
function parsePanelGridIndexing(value: YamlValue | undefined, path: string): PanelGridIndexing {
|
|
1206
|
+
function parsePanelGridIndexing(value, path) {
|
|
1481
1207
|
const indexing = expectString(value, path);
|
|
1482
1208
|
if (indexing === 'one-based' || indexing === 'zero-based') {
|
|
1483
1209
|
return indexing;
|
|
1484
1210
|
}
|
|
1485
1211
|
throw new Error(`${path}: expected one-based or zero-based`);
|
|
1486
1212
|
}
|
|
1487
|
-
|
|
1488
|
-
function parseOptionalPanelRowOrder(value: YamlValue | undefined, path: string): PanelRowOrder | undefined {
|
|
1213
|
+
function parseOptionalPanelRowOrder(value, path) {
|
|
1489
1214
|
if (value === undefined) {
|
|
1490
1215
|
return undefined;
|
|
1491
1216
|
}
|
|
@@ -1495,8 +1220,7 @@ function parseOptionalPanelRowOrder(value: YamlValue | undefined, path: string):
|
|
|
1495
1220
|
}
|
|
1496
1221
|
throw new Error(`${path}: expected top-to-bottom or bottom-to-top`);
|
|
1497
1222
|
}
|
|
1498
|
-
|
|
1499
|
-
function parseOptionalPanelColumnOrder(value: YamlValue | undefined, path: string): PanelColumnOrder | undefined {
|
|
1223
|
+
function parseOptionalPanelColumnOrder(value, path) {
|
|
1500
1224
|
if (value === undefined) {
|
|
1501
1225
|
return undefined;
|
|
1502
1226
|
}
|
|
@@ -1506,8 +1230,7 @@ function parseOptionalPanelColumnOrder(value: YamlValue | undefined, path: strin
|
|
|
1506
1230
|
}
|
|
1507
1231
|
throw new Error(`${path}: expected left-to-right or right-to-left`);
|
|
1508
1232
|
}
|
|
1509
|
-
|
|
1510
|
-
function parsePanelControlKind(value: YamlValue | undefined, path: string): PanelControlKind {
|
|
1233
|
+
function parsePanelControlKind(value, path) {
|
|
1511
1234
|
const kind = expectString(value, path);
|
|
1512
1235
|
switch (kind) {
|
|
1513
1236
|
case 'knob':
|
|
@@ -1522,8 +1245,7 @@ function parsePanelControlKind(value: YamlValue | undefined, path: string): Pane
|
|
|
1522
1245
|
throw new Error(`${path}: expected knob, slider, switch, selector, footswitch, led, or jack`);
|
|
1523
1246
|
}
|
|
1524
1247
|
}
|
|
1525
|
-
|
|
1526
|
-
function parseComponents(value: YamlValue | undefined): readonly Component[] {
|
|
1248
|
+
function parseComponents(value) {
|
|
1527
1249
|
return optionalArray(value, 'components').map((item, index) => {
|
|
1528
1250
|
const path = `components[${index}]`;
|
|
1529
1251
|
const component = expectObject(item, path);
|
|
@@ -1540,8 +1262,7 @@ function parseComponents(value: YamlValue | undefined): readonly Component[] {
|
|
|
1540
1262
|
};
|
|
1541
1263
|
});
|
|
1542
1264
|
}
|
|
1543
|
-
|
|
1544
|
-
function parseTerminals(value: YamlValue | undefined, path: string): readonly Terminal[] {
|
|
1265
|
+
function parseTerminals(value, path) {
|
|
1545
1266
|
return optionalArray(value, path).map((item, index) => {
|
|
1546
1267
|
const terminalPath = `${path}[${index}]`;
|
|
1547
1268
|
const terminal = expectObject(item, terminalPath);
|
|
@@ -1551,17 +1272,15 @@ function parseTerminals(value: YamlValue | undefined, path: string): readonly Te
|
|
|
1551
1272
|
};
|
|
1552
1273
|
});
|
|
1553
1274
|
}
|
|
1554
|
-
|
|
1555
|
-
function parseProperties(value: YamlValue | undefined, path: string): Readonly<Record<string, PropertyValue>> {
|
|
1275
|
+
function parseProperties(value, path) {
|
|
1556
1276
|
const properties = optionalObject(value, path);
|
|
1557
|
-
const out
|
|
1277
|
+
const out = {};
|
|
1558
1278
|
for (const [key, child] of Object.entries(properties)) {
|
|
1559
1279
|
out[key] = parsePropertyValue(child, `${path}.${key}`);
|
|
1560
1280
|
}
|
|
1561
1281
|
return out;
|
|
1562
1282
|
}
|
|
1563
|
-
|
|
1564
|
-
function parsePropertyValue(value: YamlValue, path: string): PropertyValue {
|
|
1283
|
+
function parsePropertyValue(value, path) {
|
|
1565
1284
|
if (isParsedQuantityValue(value)) {
|
|
1566
1285
|
return {
|
|
1567
1286
|
raw: expectString(value.raw, `${path}.raw`),
|
|
@@ -1573,7 +1292,7 @@ function parsePropertyValue(value: YamlValue, path: string): PropertyValue {
|
|
|
1573
1292
|
return value.map((item, index) => parsePropertyValue(item, `${path}[${index}]`));
|
|
1574
1293
|
}
|
|
1575
1294
|
if (isYamlObject(value)) {
|
|
1576
|
-
const out
|
|
1295
|
+
const out = {};
|
|
1577
1296
|
for (const [key, child] of Object.entries(value)) {
|
|
1578
1297
|
out[key] = parsePropertyValue(child, `${path}.${key}`);
|
|
1579
1298
|
}
|
|
@@ -1584,12 +1303,10 @@ function parsePropertyValue(value: YamlValue, path: string): PropertyValue {
|
|
|
1584
1303
|
}
|
|
1585
1304
|
throw new Error(`${path}: expected scalar property value or parsed quantity`);
|
|
1586
1305
|
}
|
|
1587
|
-
|
|
1588
|
-
function isParsedQuantityValue(value: YamlValue): value is ParsedQuantity {
|
|
1306
|
+
function isParsedQuantityValue(value) {
|
|
1589
1307
|
return isParsedQuantity(value);
|
|
1590
1308
|
}
|
|
1591
|
-
|
|
1592
|
-
function parseWires(value: YamlValue | undefined): readonly Wire[] {
|
|
1309
|
+
function parseWires(value) {
|
|
1593
1310
|
return optionalArray(value, 'wires').map((item, index) => {
|
|
1594
1311
|
const path = `wires[${index}]`;
|
|
1595
1312
|
const wire = expectObject(item, path);
|
|
@@ -1605,12 +1322,11 @@ function parseWires(value: YamlValue | undefined): readonly Wire[] {
|
|
|
1605
1322
|
};
|
|
1606
1323
|
});
|
|
1607
1324
|
}
|
|
1608
|
-
|
|
1609
|
-
function parseWarnings(value: YamlValue | undefined): readonly Warning[] {
|
|
1325
|
+
function parseWarnings(value) {
|
|
1610
1326
|
return optionalArray(value, 'diagnostics').map((item, index) => {
|
|
1611
1327
|
const path = `diagnostics[${index}]`;
|
|
1612
1328
|
const warning = expectObject(item, path);
|
|
1613
|
-
const out
|
|
1329
|
+
const out = {
|
|
1614
1330
|
code: expectString(warning.code, `${path}.code`),
|
|
1615
1331
|
message: expectString(warning.message, `${path}.message`),
|
|
1616
1332
|
...(warning.componentId === undefined
|
|
@@ -1623,44 +1339,38 @@ function parseWarnings(value: YamlValue | undefined): readonly Warning[] {
|
|
|
1623
1339
|
return out;
|
|
1624
1340
|
});
|
|
1625
1341
|
}
|
|
1626
|
-
|
|
1627
|
-
function parseStringArray(value: YamlValue | undefined, path: string): readonly string[] {
|
|
1342
|
+
function parseStringArray(value, path) {
|
|
1628
1343
|
return optionalArray(value, path).map((item, index) => scalarText(item, `${path}[${index}]`));
|
|
1629
1344
|
}
|
|
1630
|
-
|
|
1631
|
-
function parseStringRecord(value: YamlValue | undefined, path: string): Readonly<Record<string, string>> {
|
|
1345
|
+
function parseStringRecord(value, path) {
|
|
1632
1346
|
const record = optionalObject(value, path);
|
|
1633
|
-
const out
|
|
1347
|
+
const out = {};
|
|
1634
1348
|
for (const [key, child] of Object.entries(record)) {
|
|
1635
1349
|
out[key] = scalarText(child, `${path}.${key}`);
|
|
1636
1350
|
}
|
|
1637
1351
|
return out;
|
|
1638
1352
|
}
|
|
1639
|
-
|
|
1640
|
-
function parsePoint(value: YamlValue | undefined, path: string): Point {
|
|
1353
|
+
function parsePoint(value, path) {
|
|
1641
1354
|
const point = expectObject(value, path);
|
|
1642
1355
|
return {
|
|
1643
1356
|
x: expectNumber(point.x, `${path}.x`),
|
|
1644
1357
|
y: expectNumber(point.y, `${path}.y`),
|
|
1645
1358
|
};
|
|
1646
1359
|
}
|
|
1647
|
-
|
|
1648
|
-
function parseRotation(value: YamlValue | undefined, path: string): Rotation {
|
|
1360
|
+
function parseRotation(value, path) {
|
|
1649
1361
|
const rotation = expectNumber(value, path);
|
|
1650
1362
|
if (rotation === 0 || rotation === 1 || rotation === 2 || rotation === 3) {
|
|
1651
1363
|
return rotation;
|
|
1652
1364
|
}
|
|
1653
1365
|
throw new Error(`${path}: expected rotation 0, 1, 2, or 3`);
|
|
1654
1366
|
}
|
|
1655
|
-
|
|
1656
|
-
function parseNullableString(value: YamlValue | undefined, path: string): string | null {
|
|
1367
|
+
function parseNullableString(value, path) {
|
|
1657
1368
|
if (value === null || value === undefined) {
|
|
1658
1369
|
return null;
|
|
1659
1370
|
}
|
|
1660
1371
|
return expectString(value, path);
|
|
1661
1372
|
}
|
|
1662
|
-
|
|
1663
|
-
function parseComponentKind(value: YamlValue | undefined, path: string): ComponentKind {
|
|
1373
|
+
function parseComponentKind(value, path) {
|
|
1664
1374
|
const kind = expectString(value, path);
|
|
1665
1375
|
switch (kind) {
|
|
1666
1376
|
case 'resistor':
|
|
@@ -1703,108 +1413,93 @@ function parseComponentKind(value: YamlValue | undefined, path: string): Compone
|
|
|
1703
1413
|
throw new Error(`${path}: unsupported component kind "${kind}"`);
|
|
1704
1414
|
}
|
|
1705
1415
|
}
|
|
1706
|
-
|
|
1707
|
-
function optionalObject(value: YamlValue | undefined, path: string): YamlObject {
|
|
1416
|
+
function optionalObject(value, path) {
|
|
1708
1417
|
if (value === undefined) {
|
|
1709
1418
|
return {};
|
|
1710
1419
|
}
|
|
1711
1420
|
return expectObject(value, path);
|
|
1712
1421
|
}
|
|
1713
|
-
|
|
1714
|
-
function optionalArray(value: YamlValue | undefined, path: string): readonly YamlValue[] {
|
|
1422
|
+
function optionalArray(value, path) {
|
|
1715
1423
|
if (value === undefined) {
|
|
1716
1424
|
return [];
|
|
1717
1425
|
}
|
|
1718
1426
|
return expectArray(value, path);
|
|
1719
1427
|
}
|
|
1720
|
-
|
|
1721
|
-
function expectObject(value: YamlValue | undefined, path: string): YamlObject {
|
|
1428
|
+
function expectObject(value, path) {
|
|
1722
1429
|
if (isYamlObject(value)) {
|
|
1723
1430
|
return value;
|
|
1724
1431
|
}
|
|
1725
1432
|
throw new Error(`${path}: expected object`);
|
|
1726
1433
|
}
|
|
1727
|
-
|
|
1728
|
-
function expectArray(value: YamlValue | undefined, path: string): readonly YamlValue[] {
|
|
1434
|
+
function expectArray(value, path) {
|
|
1729
1435
|
if (Array.isArray(value)) {
|
|
1730
1436
|
return value;
|
|
1731
1437
|
}
|
|
1732
1438
|
throw new Error(`${path}: expected array`);
|
|
1733
1439
|
}
|
|
1734
|
-
|
|
1735
|
-
function expectString(value: YamlValue | undefined, path: string): string {
|
|
1440
|
+
function expectString(value, path) {
|
|
1736
1441
|
if (typeof value === 'string') {
|
|
1737
1442
|
return value;
|
|
1738
1443
|
}
|
|
1739
1444
|
throw new Error(`${path}: expected string`);
|
|
1740
1445
|
}
|
|
1741
|
-
|
|
1742
|
-
function expectNumber(value: YamlValue | undefined, path: string): number {
|
|
1446
|
+
function expectNumber(value, path) {
|
|
1743
1447
|
if (typeof value === 'number' && Number.isFinite(value)) {
|
|
1744
1448
|
return value;
|
|
1745
1449
|
}
|
|
1746
1450
|
throw new Error(`${path}: expected number`);
|
|
1747
1451
|
}
|
|
1748
|
-
|
|
1749
|
-
function expectPositiveInteger(value: YamlValue | undefined, path: string): number {
|
|
1452
|
+
function expectPositiveInteger(value, path) {
|
|
1750
1453
|
const number = expectNumber(value, path);
|
|
1751
1454
|
if (Number.isInteger(number) && number > 0) {
|
|
1752
1455
|
return number;
|
|
1753
1456
|
}
|
|
1754
1457
|
throw new Error(`${path}: expected positive integer`);
|
|
1755
1458
|
}
|
|
1756
|
-
|
|
1757
|
-
function expectNonNegativeInteger(value: YamlValue | undefined, path: string): number {
|
|
1459
|
+
function expectNonNegativeInteger(value, path) {
|
|
1758
1460
|
const number = expectNumber(value, path);
|
|
1759
1461
|
if (Number.isInteger(number) && number >= 0) {
|
|
1760
1462
|
return number;
|
|
1761
1463
|
}
|
|
1762
1464
|
throw new Error(`${path}: expected non-negative integer`);
|
|
1763
1465
|
}
|
|
1764
|
-
|
|
1765
|
-
function parseOptionalPositiveInteger(value: YamlValue | undefined, path: string): number | undefined {
|
|
1466
|
+
function parseOptionalPositiveInteger(value, path) {
|
|
1766
1467
|
if (value === undefined) {
|
|
1767
1468
|
return undefined;
|
|
1768
1469
|
}
|
|
1769
1470
|
return expectPositiveInteger(value, path);
|
|
1770
1471
|
}
|
|
1771
|
-
|
|
1772
|
-
function parseOptionalNumber(value: YamlValue | undefined, path: string): number | undefined {
|
|
1472
|
+
function parseOptionalNumber(value, path) {
|
|
1773
1473
|
if (value === undefined) {
|
|
1774
1474
|
return undefined;
|
|
1775
1475
|
}
|
|
1776
1476
|
return expectNumber(value, path);
|
|
1777
1477
|
}
|
|
1778
|
-
|
|
1779
|
-
function parseOptionalString(value: YamlValue | undefined, path: string): string | undefined {
|
|
1478
|
+
function parseOptionalString(value, path) {
|
|
1780
1479
|
if (value === undefined) {
|
|
1781
1480
|
return undefined;
|
|
1782
1481
|
}
|
|
1783
1482
|
return expectString(value, path);
|
|
1784
1483
|
}
|
|
1785
|
-
|
|
1786
|
-
function parseOptionalStringArray(value: YamlValue | undefined, path: string): readonly string[] | undefined {
|
|
1484
|
+
function parseOptionalStringArray(value, path) {
|
|
1787
1485
|
if (value === undefined) {
|
|
1788
1486
|
return undefined;
|
|
1789
1487
|
}
|
|
1790
1488
|
return expectArray(value, path).map((item, index) => expectString(item, `${path}[${index}]`));
|
|
1791
1489
|
}
|
|
1792
|
-
|
|
1793
|
-
function parseOptionalBoolean(value: YamlValue | undefined, path: string): boolean | undefined {
|
|
1490
|
+
function parseOptionalBoolean(value, path) {
|
|
1794
1491
|
if (value === undefined) {
|
|
1795
1492
|
return undefined;
|
|
1796
1493
|
}
|
|
1797
1494
|
return expectBoolean(value, path);
|
|
1798
1495
|
}
|
|
1799
|
-
|
|
1800
|
-
function expectBoolean(value: YamlValue | undefined, path: string): boolean {
|
|
1496
|
+
function expectBoolean(value, path) {
|
|
1801
1497
|
if (typeof value === 'boolean') {
|
|
1802
1498
|
return value;
|
|
1803
1499
|
}
|
|
1804
1500
|
throw new Error(`${path}: expected boolean`);
|
|
1805
1501
|
}
|
|
1806
|
-
|
|
1807
|
-
function scalarText(value: YamlValue | undefined, path = 'value'): string {
|
|
1502
|
+
function scalarText(value, path = 'value') {
|
|
1808
1503
|
if (value === undefined || value === null) {
|
|
1809
1504
|
return '';
|
|
1810
1505
|
}
|
|
@@ -1813,11 +1508,10 @@ function scalarText(value: YamlValue | undefined, path = 'value'): string {
|
|
|
1813
1508
|
}
|
|
1814
1509
|
throw new Error(`${path}: expected scalar`);
|
|
1815
1510
|
}
|
|
1816
|
-
|
|
1817
|
-
function isScalar(value: YamlValue): value is YamlScalar {
|
|
1511
|
+
function isScalar(value) {
|
|
1818
1512
|
return value === null || typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
1819
1513
|
}
|
|
1820
|
-
|
|
1821
|
-
function isYamlObject(value: YamlValue | undefined): value is YamlObject {
|
|
1514
|
+
function isYamlObject(value) {
|
|
1822
1515
|
return value !== undefined && value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
1823
1516
|
}
|
|
1517
|
+
//# sourceMappingURL=parser.js.map
|