@vessel-dsp/core 0.6.0 → 0.6.2

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.
Files changed (238) hide show
  1. package/dist/editor/commands.d.ts +48 -0
  2. package/dist/editor/commands.d.ts.map +1 -0
  3. package/{src/editor/commands.ts → dist/editor/commands.js} +44 -91
  4. package/dist/editor/commands.js.map +1 -0
  5. package/dist/editor/factory.d.ts +10 -0
  6. package/dist/editor/factory.d.ts.map +1 -0
  7. package/{src/editor/factory.ts → dist/editor/factory.js} +11 -27
  8. package/dist/editor/factory.js.map +1 -0
  9. package/dist/editor/history.d.ts +29 -0
  10. package/dist/editor/history.d.ts.map +1 -0
  11. package/{src/editor/history.ts → dist/editor/history.js} +12 -42
  12. package/dist/editor/history.js.map +1 -0
  13. package/{src/editor/index.ts → dist/editor/index.d.ts} +1 -3
  14. package/dist/editor/index.d.ts.map +1 -0
  15. package/dist/editor/index.js +5 -0
  16. package/dist/editor/index.js.map +1 -0
  17. package/dist/editor/layout.d.ts +8 -0
  18. package/dist/editor/layout.d.ts.map +1 -0
  19. package/{src/editor/layout.ts → dist/editor/layout.js} +36 -90
  20. package/dist/editor/layout.js.map +1 -0
  21. package/dist/formats/circuit-json/serializer.d.ts +101 -0
  22. package/dist/formats/circuit-json/serializer.d.ts.map +1 -0
  23. package/{src/formats/circuit-json/serializer.ts → dist/formats/circuit-json/serializer.js} +352 -418
  24. package/dist/formats/circuit-json/serializer.js.map +1 -0
  25. package/dist/formats/document.d.ts +64 -0
  26. package/dist/formats/document.d.ts.map +1 -0
  27. package/{src/formats/document.ts → dist/formats/document.js} +43 -159
  28. package/dist/formats/document.js.map +1 -0
  29. package/dist/formats/interchange/parser.d.ts +3 -0
  30. package/dist/formats/interchange/parser.d.ts.map +1 -0
  31. package/{src/formats/interchange/parser.ts → dist/formats/interchange/parser.js} +157 -463
  32. package/dist/formats/interchange/parser.js.map +1 -0
  33. package/dist/formats/interchange/serializer.d.ts +9 -0
  34. package/dist/formats/interchange/serializer.d.ts.map +1 -0
  35. package/{src/formats/interchange/serializer.ts → dist/formats/interchange/serializer.js} +84 -186
  36. package/dist/formats/interchange/serializer.js.map +1 -0
  37. package/dist/formats/ltspice/catalog.d.ts +19 -0
  38. package/dist/formats/ltspice/catalog.d.ts.map +1 -0
  39. package/{src/formats/ltspice/catalog.ts → dist/formats/ltspice/catalog.js} +18 -52
  40. package/dist/formats/ltspice/catalog.js.map +1 -0
  41. package/dist/formats/ltspice/encoding.d.ts +2 -0
  42. package/dist/formats/ltspice/encoding.d.ts.map +1 -0
  43. package/{src/formats/ltspice/encoding.ts → dist/formats/ltspice/encoding.js} +17 -41
  44. package/dist/formats/ltspice/encoding.js.map +1 -0
  45. package/dist/formats/ltspice/parser.d.ts +3 -0
  46. package/dist/formats/ltspice/parser.d.ts.map +1 -0
  47. package/{src/formats/ltspice/parser.ts → dist/formats/ltspice/parser.js} +39 -141
  48. package/dist/formats/ltspice/parser.js.map +1 -0
  49. package/dist/formats/ltspice/serializer.d.ts +7 -0
  50. package/dist/formats/ltspice/serializer.d.ts.map +1 -0
  51. package/{src/formats/ltspice/serializer.ts → dist/formats/ltspice/serializer.js} +18 -45
  52. package/dist/formats/ltspice/serializer.js.map +1 -0
  53. package/dist/formats/schx/catalog.d.ts +19 -0
  54. package/dist/formats/schx/catalog.d.ts.map +1 -0
  55. package/{src/formats/schx/catalog.ts → dist/formats/schx/catalog.js} +48 -101
  56. package/dist/formats/schx/catalog.js.map +1 -0
  57. package/dist/formats/schx/parser.d.ts +3 -0
  58. package/dist/formats/schx/parser.d.ts.map +1 -0
  59. package/{src/formats/schx/parser.ts → dist/formats/schx/parser.js} +31 -86
  60. package/dist/formats/schx/parser.js.map +1 -0
  61. package/dist/formats/schx/runtime-descriptors.d.ts +3 -0
  62. package/dist/formats/schx/runtime-descriptors.d.ts.map +1 -0
  63. package/{src/formats/schx/runtime-descriptors.ts → dist/formats/schx/runtime-descriptors.js} +36 -123
  64. package/dist/formats/schx/runtime-descriptors.js.map +1 -0
  65. package/dist/formats/schx/serializer.d.ts +5 -0
  66. package/dist/formats/schx/serializer.d.ts.map +1 -0
  67. package/{src/formats/schx/serializer.ts → dist/formats/schx/serializer.js} +17 -42
  68. package/dist/formats/schx/serializer.js.map +1 -0
  69. package/dist/formats/schx/transforms.d.ts +4 -0
  70. package/dist/formats/schx/transforms.d.ts.map +1 -0
  71. package/{src/formats/schx/transforms.ts → dist/formats/schx/transforms.js} +6 -10
  72. package/dist/formats/schx/transforms.js.map +1 -0
  73. package/dist/formats/spice/parser.d.ts +3 -0
  74. package/dist/formats/spice/parser.d.ts.map +1 -0
  75. package/{src/formats/spice/parser.ts → dist/formats/spice/parser.js} +50 -96
  76. package/dist/formats/spice/parser.js.map +1 -0
  77. package/dist/formats/spice/serializer.d.ts +3 -0
  78. package/dist/formats/spice/serializer.d.ts.map +1 -0
  79. package/{src/formats/spice/serializer.ts → dist/formats/spice/serializer.js} +20 -16
  80. package/dist/formats/spice/serializer.js.map +1 -0
  81. package/dist/index.d.ts +47 -0
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.js +32 -0
  84. package/dist/index.js.map +1 -0
  85. package/dist/model/connectivity.d.ts +16 -0
  86. package/dist/model/connectivity.d.ts.map +1 -0
  87. package/{src/model/connectivity.ts → dist/model/connectivity.js} +28 -63
  88. package/dist/model/connectivity.js.map +1 -0
  89. package/dist/model/netlist.d.ts +24 -0
  90. package/dist/model/netlist.d.ts.map +1 -0
  91. package/{src/model/netlist.ts → dist/model/netlist.js} +42 -110
  92. package/dist/model/netlist.js.map +1 -0
  93. package/dist/model/properties.d.ts +9 -0
  94. package/dist/model/properties.d.ts.map +1 -0
  95. package/{src/model/properties.ts → dist/model/properties.js} +10 -18
  96. package/dist/model/properties.js.map +1 -0
  97. package/dist/model/quantity.d.ts +3 -0
  98. package/dist/model/quantity.d.ts.map +1 -0
  99. package/{src/model/quantity.ts → dist/model/quantity.js} +7 -30
  100. package/dist/model/quantity.js.map +1 -0
  101. package/{src/model/types.ts → dist/model/types.d.ts} +17 -196
  102. package/dist/model/types.d.ts.map +1 -0
  103. package/dist/model/types.js +10 -0
  104. package/dist/model/types.js.map +1 -0
  105. package/dist/model/validation.d.ts +32 -0
  106. package/dist/model/validation.d.ts.map +1 -0
  107. package/{src/model/validation.ts → dist/model/validation.js} +172 -653
  108. package/dist/model/validation.js.map +1 -0
  109. package/dist/model/wires.d.ts +3 -0
  110. package/dist/model/wires.d.ts.map +1 -0
  111. package/{src/model/wires.ts → dist/model/wires.js} +10 -16
  112. package/dist/model/wires.js.map +1 -0
  113. package/dist/panel/extract.d.ts +5 -0
  114. package/dist/panel/extract.d.ts.map +1 -0
  115. package/{src/panel/extract.ts → dist/panel/extract.js} +146 -235
  116. package/dist/panel/extract.js.map +1 -0
  117. package/dist/panel/index.d.ts +6 -0
  118. package/dist/panel/index.d.ts.map +1 -0
  119. package/dist/panel/index.js +5 -0
  120. package/dist/panel/index.js.map +1 -0
  121. package/dist/panel/knobs.d.ts +7 -0
  122. package/dist/panel/knobs.d.ts.map +1 -0
  123. package/{src/panel/knobs.ts → dist/panel/knobs.js} +7 -18
  124. package/dist/panel/knobs.js.map +1 -0
  125. package/dist/panel/protocol.d.ts +9 -0
  126. package/dist/panel/protocol.d.ts.map +1 -0
  127. package/{src/panel/protocol.ts → dist/panel/protocol.js} +10 -26
  128. package/dist/panel/protocol.js.map +1 -0
  129. package/{src/panel/types.ts → dist/panel/types.d.ts} +50 -89
  130. package/dist/panel/types.d.ts.map +1 -0
  131. package/dist/panel/types.js +2 -0
  132. package/dist/panel/types.js.map +1 -0
  133. package/dist/preview/bounds.d.ts +12 -0
  134. package/dist/preview/bounds.d.ts.map +1 -0
  135. package/{src/preview/bounds.ts → dist/preview/bounds.js} +15 -29
  136. package/dist/preview/bounds.js.map +1 -0
  137. package/dist/preview/box-layout.d.ts +4 -0
  138. package/dist/preview/box-layout.d.ts.map +1 -0
  139. package/{src/preview/box-layout.ts → dist/preview/box-layout.js} +2 -6
  140. package/dist/preview/box-layout.js.map +1 -0
  141. package/dist/preview/colors.d.ts +3 -0
  142. package/dist/preview/colors.d.ts.map +1 -0
  143. package/{src/preview/colors.ts → dist/preview/colors.js} +3 -5
  144. package/dist/preview/colors.js.map +1 -0
  145. package/dist/preview/hanging.d.ts +8 -0
  146. package/dist/preview/hanging.d.ts.map +1 -0
  147. package/{src/preview/hanging.ts → dist/preview/hanging.js} +9 -28
  148. package/dist/preview/hanging.js.map +1 -0
  149. package/dist/preview/junctions.d.ts +3 -0
  150. package/dist/preview/junctions.d.ts.map +1 -0
  151. package/{src/preview/junctions.ts → dist/preview/junctions.js} +9 -24
  152. package/dist/preview/junctions.js.map +1 -0
  153. package/dist/preview/label-layout.d.ts +12 -0
  154. package/dist/preview/label-layout.d.ts.map +1 -0
  155. package/{src/preview/label-layout.ts → dist/preview/label-layout.js} +15 -36
  156. package/dist/preview/label-layout.js.map +1 -0
  157. package/dist/preview/ports.d.ts +17 -0
  158. package/dist/preview/ports.d.ts.map +1 -0
  159. package/{src/preview/ports.ts → dist/preview/ports.js} +10 -37
  160. package/dist/preview/ports.js.map +1 -0
  161. package/dist/preview/renderable-wires.d.ts +3 -0
  162. package/dist/preview/renderable-wires.d.ts.map +1 -0
  163. package/{src/preview/renderable-wires.ts → dist/preview/renderable-wires.js} +12 -29
  164. package/dist/preview/renderable-wires.js.map +1 -0
  165. package/dist/preview/routing.d.ts +4 -0
  166. package/dist/preview/routing.d.ts.map +1 -0
  167. package/dist/preview/routing.js +13 -0
  168. package/dist/preview/routing.js.map +1 -0
  169. package/dist/preview/snap.d.ts +9 -0
  170. package/dist/preview/snap.d.ts.map +1 -0
  171. package/{src/preview/snap.ts → dist/preview/snap.js} +9 -31
  172. package/dist/preview/snap.js.map +1 -0
  173. package/dist/preview/symbols/svg-content.d.ts +7 -0
  174. package/dist/preview/symbols/svg-content.d.ts.map +1 -0
  175. package/{src/preview/symbols/svg-content.ts → dist/preview/symbols/svg-content.js} +3 -6
  176. package/dist/preview/symbols/svg-content.js.map +1 -0
  177. package/dist/preview/symbols.d.ts +7 -0
  178. package/dist/preview/symbols.d.ts.map +1 -0
  179. package/{src/preview/symbols.ts → dist/preview/symbols.js} +18 -43
  180. package/dist/preview/symbols.js.map +1 -0
  181. package/dist/preview/wire-chains.d.ts +4 -0
  182. package/dist/preview/wire-chains.d.ts.map +1 -0
  183. package/{src/preview/wire-chains.ts → dist/preview/wire-chains.js} +37 -37
  184. package/dist/preview/wire-chains.js.map +1 -0
  185. package/package.json +3 -3
  186. package/src/index.ts +0 -255
  187. package/src/panel/index.ts +0 -39
  188. package/src/preview/routing.ts +0 -15
  189. package/src/preview/symbols/analog-switch.svg +0 -17
  190. package/src/preview/symbols/battery.svg +0 -16
  191. package/src/preview/symbols/bbd.svg +0 -21
  192. package/src/preview/symbols/bjt-npn.svg +0 -16
  193. package/src/preview/symbols/bjt-pnp.svg +0 -17
  194. package/src/preview/symbols/capacitor-electrolytic.svg +0 -13
  195. package/src/preview/symbols/capacitor.svg +0 -12
  196. package/src/preview/symbols/current-source.svg +0 -14
  197. package/src/preview/symbols/delay-ic.svg +0 -22
  198. package/src/preview/symbols/diode-schottky.svg +0 -12
  199. package/src/preview/symbols/diode-zener.svg +0 -12
  200. package/src/preview/symbols/diode.svg +0 -13
  201. package/src/preview/symbols/flipflop.svg +0 -20
  202. package/src/preview/symbols/ground.svg +0 -12
  203. package/src/preview/symbols/ic-block.svg +0 -20
  204. package/src/preview/symbols/ic.svg +0 -19
  205. package/src/preview/symbols/inductor.svg +0 -11
  206. package/src/preview/symbols/jack-input.svg +0 -16
  207. package/src/preview/symbols/jack-output.svg +0 -16
  208. package/src/preview/symbols/jfet-junction-n.svg +0 -17
  209. package/src/preview/symbols/jfet-n.svg +0 -17
  210. package/src/preview/symbols/jfet-p.svg +0 -17
  211. package/src/preview/symbols/label.svg +0 -8
  212. package/src/preview/symbols/led.svg +0 -18
  213. package/src/preview/symbols/mosfet-n.svg +0 -21
  214. package/src/preview/symbols/mosfet-p.svg +0 -21
  215. package/src/preview/symbols/named-wire.svg +0 -11
  216. package/src/preview/symbols/opamp.svg +0 -21
  217. package/src/preview/symbols/optocoupler.svg +0 -30
  218. package/src/preview/symbols/ota.svg +0 -20
  219. package/src/preview/symbols/pentode.svg +0 -25
  220. package/src/preview/symbols/photoresistor.svg +0 -19
  221. package/src/preview/symbols/port.svg +0 -8
  222. package/src/preview/symbols/potentiometer.svg +0 -15
  223. package/src/preview/symbols/power-amp.svg +0 -20
  224. package/src/preview/symbols/rail.svg +0 -11
  225. package/src/preview/symbols/regulator.svg +0 -13
  226. package/src/preview/symbols/relay.svg +0 -20
  227. package/src/preview/symbols/resistor.svg +0 -11
  228. package/src/preview/symbols/switch-3pdt.svg +0 -32
  229. package/src/preview/symbols/switch-rotary.svg +0 -23
  230. package/src/preview/symbols/switch-spdt.svg +0 -16
  231. package/src/preview/symbols/switch-spst.svg +0 -14
  232. package/src/preview/symbols/switch-toggle.svg +0 -14
  233. package/src/preview/symbols/transformer.svg +0 -17
  234. package/src/preview/symbols/triode.svg +0 -17
  235. package/src/preview/symbols/tube-diode.svg +0 -13
  236. package/src/preview/symbols/unsupported.svg +0 -8
  237. package/src/preview/symbols/variable-resistor.svg +0 -13
  238. package/src/preview/symbols/voltage-source.svg +0 -15
@@ -1,68 +1,51 @@
1
- import { parseQuantity } from '../../model/quantity';
2
- import type {
3
- CircuitDocument,
4
- Component,
5
- ComponentKind,
6
- DocumentMetadata,
7
- ParsedQuantity,
8
- Point,
9
- PropertyValue,
10
- Rotation,
11
- Warning,
12
- Wire,
13
- } from '../../model/types';
14
- import { splitWiresAtJunctions } from '../../model/wires';
15
- import { isSchxRuntimeDescriptor, lookupSchxDef, shortenSchxType, type SchxComponentDef } from './catalog';
16
- import { runtimeDescriptorProperties } from './runtime-descriptors';
17
- import { mapTerminal, normalizeRotation } from './transforms';
18
-
1
+ import { parseQuantity } from '../../model/quantity.js';
2
+ import { splitWiresAtJunctions } from '../../model/wires.js';
3
+ import { isSchxRuntimeDescriptor, lookupSchxDef, shortenSchxType } from './catalog.js';
4
+ import { runtimeDescriptorProperties } from './runtime-descriptors.js';
5
+ import { mapTerminal, normalizeRotation } from './transforms.js';
19
6
  const ELEMENT_REGEX = /<Element\b([^>]*?)\/>|<Element\b([^>]*?)>([\s\S]*?)<\/Element>/g;
20
7
  const COMPONENT_REGEX = /<Component\b([^>]*?)\/>/;
21
8
  const ATTR_REGEX = /([A-Za-z_][A-Za-z0-9_:.-]*)="([^"]*)"/g;
22
9
  const ROOT_REGEX = /<Schematic\b([^>]*)>/;
23
10
  const COMMENT_REGEX = /<!--[\s\S]*?-->/g;
24
-
25
- export function parseSchx(xml: string): CircuitDocument {
11
+ export function parseSchx(xml) {
26
12
  const normalized = xml.replace(/^/, '').replace(COMMENT_REGEX, '');
27
13
  const rootMatch = normalized.match(ROOT_REGEX);
28
14
  if (!rootMatch || rootMatch[1] === undefined) {
29
15
  throw new Error('not a LiveSPICE schematic: missing <Schematic> root');
30
16
  }
31
-
32
17
  const rawAttributes = parseAttributes(rootMatch[1]);
33
18
  const metadata = parseMetadata(rawAttributes);
34
- const warnings: Warning[] = [];
35
- const components: Component[] = [];
36
- const wires: Wire[] = [];
37
- const usedIds = new Map<string, number>();
19
+ const warnings = [];
20
+ const components = [];
21
+ const wires = [];
22
+ const usedIds = new Map();
38
23
  let elementIndex = 0;
39
-
40
24
  for (const match of normalized.matchAll(ELEMENT_REGEX)) {
41
25
  const headAttrs = match[1] ?? match[2] ?? '';
42
26
  const body = match[3] ?? '';
43
27
  const attrs = parseAttributes(headAttrs);
44
28
  const typeName = attrs.Type ?? '';
45
-
46
29
  if (typeName.includes('Circuit.Wire')) {
47
30
  const wire = parseWireElement(attrs, elementIndex, wires.length, warnings);
48
31
  if (wire) {
49
32
  wires.push(wire);
50
33
  }
51
- } else if (typeName.includes('Circuit.Symbol')) {
34
+ }
35
+ else if (typeName.includes('Circuit.Symbol')) {
52
36
  const component = parseSymbolElement(attrs, body, elementIndex, usedIds, warnings);
53
37
  if (component) {
54
38
  components.push(component);
55
39
  }
56
- } else if (typeName.length > 0) {
40
+ }
41
+ else if (typeName.length > 0) {
57
42
  warnings.push({
58
43
  code: 'unsupported-element',
59
44
  message: `Element ${elementIndex + 1}: unsupported Element type "${typeName}"`,
60
45
  });
61
46
  }
62
-
63
47
  elementIndex += 1;
64
48
  }
65
-
66
49
  return {
67
50
  metadata,
68
51
  components,
@@ -72,21 +55,14 @@ export function parseSchx(xml: string): CircuitDocument {
72
55
  rawAttributes,
73
56
  };
74
57
  }
75
-
76
- function parseMetadata(attrs: Readonly<Record<string, string>>): DocumentMetadata {
58
+ function parseMetadata(attrs) {
77
59
  return {
78
60
  name: attrs.Name ?? '',
79
61
  description: attrs.Description ?? '',
80
62
  partNumber: attrs.PartNumber ?? '',
81
63
  };
82
64
  }
83
-
84
- function parseWireElement(
85
- attrs: Readonly<Record<string, string>>,
86
- elementIndex: number,
87
- wireCount: number,
88
- warnings: Warning[],
89
- ): Wire | null {
65
+ function parseWireElement(attrs, elementIndex, wireCount, warnings) {
90
66
  const a = parsePoint(attrs.A);
91
67
  const b = parsePoint(attrs.B);
92
68
  if (a === null || b === null) {
@@ -98,14 +74,7 @@ function parseWireElement(
98
74
  }
99
75
  return { id: `wire-${wireCount + 1}`, endpoints: [a, b] };
100
76
  }
101
-
102
- function parseSymbolElement(
103
- attrs: Readonly<Record<string, string>>,
104
- body: string,
105
- elementIndex: number,
106
- usedIds: Map<string, number>,
107
- warnings: Warning[],
108
- ): Component | null {
77
+ function parseSymbolElement(attrs, body, elementIndex, usedIds, warnings) {
109
78
  const componentMatch = body.match(COMPONENT_REGEX);
110
79
  if (!componentMatch || componentMatch[1] === undefined) {
111
80
  warnings.push({
@@ -114,37 +83,31 @@ function parseSymbolElement(
114
83
  });
115
84
  return null;
116
85
  }
117
-
118
86
  const componentAttrs = parseAttributes(componentMatch[1]);
119
87
  const fullType = componentAttrs._Type ?? '';
120
88
  const shortType = shortenSchxType(fullType);
121
89
  const def = lookupSchxDef(shortType);
122
90
  const kind = resolveSchxKind(shortType, componentAttrs, def);
123
91
  const runtimeDescriptor = isSchxRuntimeDescriptor(shortType);
124
-
125
92
  if (def === undefined && fullType.length > 0) {
126
93
  warnings.push({
127
94
  code: 'unknown-component-type',
128
95
  message: `Element ${elementIndex + 1}: unrecognized component type "${shortType}"`,
129
96
  });
130
97
  }
131
-
132
98
  const baseName = componentAttrs.Name ?? componentAttrs.Text ?? shortType;
133
99
  const id = uniqueId(baseName, usedIds);
134
100
  const origin = parsePoint(attrs.Position) ?? { x: 0, y: 0 };
135
- const rotation: Rotation = normalizeRotation(Number.parseInt(attrs.Rotation ?? '0', 10));
101
+ const rotation = normalizeRotation(Number.parseInt(attrs.Rotation ?? '0', 10));
136
102
  const flipped = attrs.Flip === 'true';
137
-
138
103
  const propertyEntries = Object.entries(componentAttrs).filter(([k]) => k !== '_Type');
139
104
  const properties = runtimeDescriptor
140
105
  ? withRuntimeDescriptorProperties(buildProperties(propertyEntries, def), shortType)
141
106
  : buildProperties(propertyEntries, def);
142
-
143
107
  const terminals = (def?.terminals ?? []).map((terminal) => ({
144
108
  name: terminal.name,
145
109
  position: mapTerminal(terminal.local, origin, rotation, flipped),
146
110
  }));
147
-
148
111
  if (runtimeDescriptor) {
149
112
  warnings.push({
150
113
  code: 'runtime-descriptor-imported',
@@ -152,7 +115,6 @@ function parseSymbolElement(
152
115
  componentId: id,
153
116
  });
154
117
  }
155
-
156
118
  return {
157
119
  id,
158
120
  kind,
@@ -165,27 +127,18 @@ function parseSymbolElement(
165
127
  sourceTypeName: sourceTypeNameForComponent(shortType, fullType, runtimeDescriptor),
166
128
  };
167
129
  }
168
-
169
- function resolveSchxKind(
170
- shortType: string,
171
- componentAttrs: Readonly<Record<string, string>>,
172
- def: SchxComponentDef | undefined,
173
- ): ComponentKind {
130
+ function resolveSchxKind(shortType, componentAttrs, def) {
174
131
  if (shortType === 'Diode' && componentAttrs.Type?.toLowerCase() === 'led') {
175
132
  return 'led';
176
133
  }
177
134
  return def?.kind ?? 'unsupported';
178
135
  }
179
-
180
- function buildProperties(
181
- entries: ReadonlyArray<[string, string]>,
182
- def: SchxComponentDef | undefined,
183
- ): Readonly<Record<string, PropertyValue>> {
184
- const quantityKeys = new Set<string>(def?.quantityProps ?? []);
185
- const properties: Record<string, PropertyValue> = {};
136
+ function buildProperties(entries, def) {
137
+ const quantityKeys = new Set(def?.quantityProps ?? []);
138
+ const properties = {};
186
139
  for (const [key, value] of entries) {
187
140
  if (quantityKeys.has(key)) {
188
- const parsed: ParsedQuantity | null = parseQuantity(value);
141
+ const parsed = parseQuantity(value);
189
142
  if (parsed) {
190
143
  properties[key] = parsed;
191
144
  continue;
@@ -195,27 +148,21 @@ function buildProperties(
195
148
  }
196
149
  return properties;
197
150
  }
198
-
199
- function withRuntimeDescriptorProperties(
200
- properties: Readonly<Record<string, PropertyValue>>,
201
- shortType: string,
202
- ): Readonly<Record<string, PropertyValue>> {
151
+ function withRuntimeDescriptorProperties(properties, shortType) {
203
152
  return {
204
153
  ...properties,
205
154
  RuntimeDescriptor: 'true',
206
155
  ...runtimeDescriptorProperties(shortType, properties),
207
156
  };
208
157
  }
209
-
210
- function sourceTypeNameForComponent(shortType: string, fullType: string, runtimeDescriptor: boolean): string | null {
158
+ function sourceTypeNameForComponent(shortType, fullType, runtimeDescriptor) {
211
159
  if (runtimeDescriptor) {
212
160
  return `Circuit.${shortType}`;
213
161
  }
214
162
  return fullType.length > 0 ? fullType : null;
215
163
  }
216
-
217
- function parseAttributes(input: string): Readonly<Record<string, string>> {
218
- const out: Record<string, string> = {};
164
+ function parseAttributes(input) {
165
+ const out = {};
219
166
  for (const match of input.matchAll(ATTR_REGEX)) {
220
167
  const name = match[1];
221
168
  const value = match[2];
@@ -226,8 +173,7 @@ function parseAttributes(input: string): Readonly<Record<string, string>> {
226
173
  }
227
174
  return out;
228
175
  }
229
-
230
- function parsePoint(value: string | undefined): Point | null {
176
+ function parsePoint(value) {
231
177
  if (value === undefined || value.length === 0) {
232
178
  return null;
233
179
  }
@@ -242,16 +188,14 @@ function parsePoint(value: string | undefined): Point | null {
242
188
  }
243
189
  return { x, y };
244
190
  }
245
-
246
- function uniqueId(baseName: string, usedIds: Map<string, number>): string {
191
+ function uniqueId(baseName, usedIds) {
247
192
  const sanitized = baseName.replace(/\s+/g, '-').replace(/[^A-Za-z0-9_-]/g, '');
248
193
  const base = sanitized.length > 0 ? sanitized : 'component';
249
194
  const count = usedIds.get(base) ?? 0;
250
195
  usedIds.set(base, count + 1);
251
196
  return count === 0 ? base : `${base}-${count + 1}`;
252
197
  }
253
-
254
- function decodeXmlEntities(value: string): string {
198
+ function decodeXmlEntities(value) {
255
199
  return value
256
200
  .replaceAll('&quot;', '"')
257
201
  .replaceAll('&apos;', "'")
@@ -259,3 +203,4 @@ function decodeXmlEntities(value: string): string {
259
203
  .replaceAll('&gt;', '>')
260
204
  .replaceAll('&amp;', '&');
261
205
  }
206
+ //# sourceMappingURL=parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.js","sourceRoot":"","sources":["../../../src/formats/schx/parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAarD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,uBAAuB,EAAE,aAAa,EAAE,eAAe,EAAyB,MAAM,WAAW,CAAC;AAC3G,OAAO,EAAE,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,aAAa,GAAG,iEAAiE,CAAC;AACxF,MAAM,eAAe,GAAG,yBAAyB,CAAC;AAClD,MAAM,UAAU,GAAG,wCAAwC,CAAC;AAC5D,MAAM,UAAU,GAAG,sBAAsB,CAAC;AAC1C,MAAM,aAAa,GAAG,kBAAkB,CAAC;AAEzC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ties(shortType: string, properties: Readonly<Record<string, PropertyValue>>): Readonly<Record<string, PropertyValue>>;
3
+ //# sourceMappingURL=runtime-descriptors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-descriptors.d.ts","sourceRoot":"","sources":["../../../src/formats/schx/runtime-descriptors.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIvD,wBAAgB,2BAA2B,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,GACpD,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAkCzC"}
@@ -1,21 +1,9 @@
1
- import {
2
- propertyBooleanValue,
3
- propertyNumericValue,
4
- propertyStringValue,
5
- } from '../../model/properties';
6
- import type { PropertyValue } from '../../model/types';
7
-
8
- type MutableProperties = Record<string, PropertyValue>;
9
-
10
- export function runtimeDescriptorProperties(
11
- shortType: string,
12
- properties: Readonly<Record<string, PropertyValue>>,
13
- ): Readonly<Record<string, PropertyValue>> {
1
+ import { propertyBooleanValue, propertyNumericValue, propertyStringValue, } from '../../model/properties.js';
2
+ export function runtimeDescriptorProperties(shortType, properties) {
14
3
  const descriptorType = descriptorTypeForShortType(shortType);
15
- const out: MutableProperties = {
4
+ const out = {
16
5
  DescriptorType: descriptorType,
17
6
  };
18
-
19
7
  switch (descriptorType) {
20
8
  case 'microblock-tone-stack':
21
9
  Object.assign(out, toneStackDescriptor(properties));
@@ -42,27 +30,23 @@ export function runtimeDescriptorProperties(
42
30
  default:
43
31
  break;
44
32
  }
45
-
46
33
  return out;
47
34
  }
48
-
49
- function descriptorTypeForShortType(shortType: string): string {
35
+ function descriptorTypeForShortType(shortType) {
50
36
  if (shortType.startsWith('MicroBlock')) {
51
37
  const rest = shortType.slice('MicroBlock'.length);
52
38
  return rest.length === 0 ? 'microblock' : `microblock-${camelToKebab(rest)}`;
53
39
  }
54
40
  return camelToKebab(shortType);
55
41
  }
56
-
57
- function camelToKebab(value: string): string {
42
+ function camelToKebab(value) {
58
43
  return value
59
44
  .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
60
45
  .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2')
61
46
  .toLowerCase();
62
47
  }
63
-
64
- function toneStackDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
65
- const out: MutableProperties = {};
48
+ function toneStackDescriptor(properties) {
49
+ const out = {};
66
50
  addNumber(out, 'overallGainDb', properties, ['OverallGainDb']);
67
51
  addNumber(out, 'maxSections', properties, ['MaxSections']);
68
52
  const sections = parseToneStackSections(properties);
@@ -78,8 +62,7 @@ function toneStackDescriptor(properties: Readonly<Record<string, PropertyValue>>
78
62
  addNumber(out, 'defaultTrebleWipe', properties, ['DefaultTrebleWipe', 'TrebleControlWipe']);
79
63
  return out;
80
64
  }
81
-
82
- function activeEqDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
65
+ function activeEqDescriptor(properties) {
83
66
  const out = scalarDescriptor(properties, [
84
67
  ['inputGain', ['InputGain']],
85
68
  ['outputGain', ['OutputGain']],
@@ -93,8 +76,7 @@ function activeEqDescriptor(properties: Readonly<Record<string, PropertyValue>>)
93
76
  ['maxOutputLevel', ['MaxOutputLevel']],
94
77
  ['headroom', ['Headroom']],
95
78
  ]);
96
-
97
- const descriptor: MutableProperties = {};
79
+ const descriptor = {};
98
80
  addNumber(descriptor, 'preEmphasisGainDb', properties, ['DescriptorPreEmphasisGainDb', 'PreEmphasisGainDb']);
99
81
  addString(descriptor, 'saturationMode', properties, ['SaturationMode']);
100
82
  addNumber(descriptor, 'saturationPositiveScale', properties, ['SaturationPositiveScale']);
@@ -102,15 +84,13 @@ function activeEqDescriptor(properties: Readonly<Record<string, PropertyValue>>)
102
84
  if (Object.keys(descriptor).length > 0) {
103
85
  out.descriptor = descriptor;
104
86
  }
105
-
106
87
  const bands = parseActiveEqBands(properties);
107
88
  if (bands.length > 0) {
108
89
  out.bands = bands;
109
90
  }
110
91
  return out;
111
92
  }
112
-
113
- function delayChipDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
93
+ function delayChipDescriptor(properties) {
114
94
  const out = scalarDescriptor(properties, [
115
95
  ['inputGain', ['InputGain']],
116
96
  ['outputGain', ['OutputGain']],
@@ -139,8 +119,7 @@ function delayChipDescriptor(properties: Readonly<Record<string, PropertyValue>>
139
119
  addBoolean(out, 'dryUnity', properties, ['DryUnity']);
140
120
  addBoolean(out, 'hold', properties, ['Hold']);
141
121
  addBoolean(out, 'samplerRecordPlay', properties, ['SamplerRecordPlay']);
142
-
143
- const mechanism: MutableProperties = {};
122
+ const mechanism = {};
144
123
  addString(mechanism, 'memoryType', properties, ['MemoryType']);
145
124
  addNumber(mechanism, 'stageCount', properties, ['StageCount']);
146
125
  addNumber(mechanism, 'artifactSeed', properties, ['ArtifactSeed']);
@@ -161,8 +140,7 @@ function delayChipDescriptor(properties: Readonly<Record<string, PropertyValue>>
161
140
  }
162
141
  return out;
163
142
  }
164
-
165
- function reverbDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
143
+ function reverbDescriptor(properties) {
166
144
  const out = scalarDescriptor(properties, [
167
145
  ['inputGain', ['InputGain']],
168
146
  ['outputGain', ['OutputGain']],
@@ -180,8 +158,7 @@ function reverbDescriptor(properties: Readonly<Record<string, PropertyValue>>):
180
158
  ['headroom', ['Headroom']],
181
159
  ['stereoOutputMode', ['StereoOutputMode']],
182
160
  ]);
183
-
184
- const algorithm: MutableProperties = {};
161
+ const algorithm = {};
185
162
  addString(algorithm, 'profileAllPassMode', properties, ['ProfileAllPassMode']);
186
163
  addNumberArray(algorithm, 'tankBaseMs', properties, ['TankBaseMs'], 4);
187
164
  addNumberArray(algorithm, 'profileAllPassBaseMs', properties, ['ProfileAllPassBaseMs'], 2);
@@ -198,8 +175,7 @@ function reverbDescriptor(properties: Readonly<Record<string, PropertyValue>>):
198
175
  }
199
176
  return out;
200
177
  }
201
-
202
- function compressorDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
178
+ function compressorDescriptor(properties) {
203
179
  const out = scalarDescriptor(properties, [
204
180
  ['inputGain', ['InputGain']],
205
181
  ['outputGain', ['OutputGain']],
@@ -226,7 +202,7 @@ function compressorDescriptor(properties: Readonly<Record<string, PropertyValue>
226
202
  ['maxInputDrive', ['MaxInputDrive']],
227
203
  ['headroom', ['Headroom']],
228
204
  ]);
229
- const topology: MutableProperties = {};
205
+ const topology = {};
230
206
  addString(topology, 'topology', properties, ['Topology']);
231
207
  addNumber(topology, 'otaProfileScale', properties, ['OtaProfileScale']);
232
208
  addNumber(topology, 'makeupGainScale', properties, ['MakeupGainScale']);
@@ -235,8 +211,7 @@ function compressorDescriptor(properties: Readonly<Record<string, PropertyValue>
235
211
  }
236
212
  return out;
237
213
  }
238
-
239
- function octaveDescriptor(properties: Readonly<Record<string, PropertyValue>>): MutableProperties {
214
+ function octaveDescriptor(properties) {
240
215
  return scalarDescriptor(properties, [
241
216
  ['inputGain', ['InputGain']],
242
217
  ['outputGain', ['OutputGain']],
@@ -275,8 +250,7 @@ function octaveDescriptor(properties: Readonly<Record<string, PropertyValue>>):
275
250
  ['carrierModShape', ['CarrierModShape', 'LfoShape']],
276
251
  ]);
277
252
  }
278
-
279
- const COMMON_RUNTIME_FIELDS: readonly [string, readonly string[]][] = [
253
+ const COMMON_RUNTIME_FIELDS = [
280
254
  ['inputGain', ['InputGain']],
281
255
  ['outputGain', ['OutputGain']],
282
256
  ['sensitivity', ['Sensitivity']],
@@ -298,24 +272,14 @@ const COMMON_RUNTIME_FIELDS: readonly [string, readonly string[]][] = [
298
272
  ['minMix', ['MinMix']],
299
273
  ['maxMix', ['MaxMix']],
300
274
  ];
301
-
302
- function scalarDescriptor(
303
- properties: Readonly<Record<string, PropertyValue>>,
304
- fields: readonly [string, readonly string[]][],
305
- ): MutableProperties {
306
- const out: MutableProperties = {};
275
+ function scalarDescriptor(properties, fields) {
276
+ const out = {};
307
277
  for (const [target, sources] of fields) {
308
278
  addScalar(out, target, properties, sources);
309
279
  }
310
280
  return out;
311
281
  }
312
-
313
- function addScalar(
314
- out: MutableProperties,
315
- target: string,
316
- properties: Readonly<Record<string, PropertyValue>>,
317
- sourceNames: readonly string[],
318
- ): void {
282
+ function addScalar(out, target, properties, sourceNames) {
319
283
  const numberValue = firstNumber(properties, sourceNames);
320
284
  if (numberValue !== undefined) {
321
285
  out[target] = numberValue;
@@ -323,60 +287,31 @@ function addScalar(
323
287
  }
324
288
  addString(out, target, properties, sourceNames);
325
289
  }
326
-
327
- function addString(
328
- out: MutableProperties,
329
- target: string,
330
- properties: Readonly<Record<string, PropertyValue>>,
331
- sourceNames: readonly string[],
332
- ): void {
290
+ function addString(out, target, properties, sourceNames) {
333
291
  const value = firstString(properties, sourceNames);
334
292
  if (value !== undefined && value.length > 0) {
335
293
  out[target] = value;
336
294
  }
337
295
  }
338
-
339
- function addNumber(
340
- out: MutableProperties,
341
- target: string,
342
- properties: Readonly<Record<string, PropertyValue>>,
343
- sourceNames: readonly string[],
344
- ): void {
296
+ function addNumber(out, target, properties, sourceNames) {
345
297
  const value = firstNumber(properties, sourceNames);
346
298
  if (value !== undefined) {
347
299
  out[target] = value;
348
300
  }
349
301
  }
350
-
351
- function addBoolean(
352
- out: MutableProperties,
353
- target: string,
354
- properties: Readonly<Record<string, PropertyValue>>,
355
- sourceNames: readonly string[],
356
- ): void {
302
+ function addBoolean(out, target, properties, sourceNames) {
357
303
  const value = firstBoolean(properties, sourceNames);
358
304
  if (value !== undefined) {
359
305
  out[target] = value;
360
306
  }
361
307
  }
362
-
363
- function addNumberArray(
364
- out: MutableProperties,
365
- target: string,
366
- properties: Readonly<Record<string, PropertyValue>>,
367
- sourceNames: readonly string[],
368
- expectedLength: number,
369
- ): void {
308
+ function addNumberArray(out, target, properties, sourceNames, expectedLength) {
370
309
  const values = firstNumberList(properties, sourceNames);
371
310
  if (values.length === expectedLength) {
372
311
  out[target] = values;
373
312
  }
374
313
  }
375
-
376
- function firstString(
377
- properties: Readonly<Record<string, PropertyValue>>,
378
- sourceNames: readonly string[],
379
- ): string | undefined {
314
+ function firstString(properties, sourceNames) {
380
315
  for (const sourceName of sourceNames) {
381
316
  const value = propertyStringValue(properties[sourceName]);
382
317
  if (value !== null) {
@@ -385,11 +320,7 @@ function firstString(
385
320
  }
386
321
  return undefined;
387
322
  }
388
-
389
- function firstNumber(
390
- properties: Readonly<Record<string, PropertyValue>>,
391
- sourceNames: readonly string[],
392
- ): number | undefined {
323
+ function firstNumber(properties, sourceNames) {
393
324
  for (const sourceName of sourceNames) {
394
325
  const value = propertyNumericValue(properties[sourceName]);
395
326
  if (value !== undefined) {
@@ -398,11 +329,7 @@ function firstNumber(
398
329
  }
399
330
  return undefined;
400
331
  }
401
-
402
- function firstBoolean(
403
- properties: Readonly<Record<string, PropertyValue>>,
404
- sourceNames: readonly string[],
405
- ): boolean | undefined {
332
+ function firstBoolean(properties, sourceNames) {
406
333
  for (const sourceName of sourceNames) {
407
334
  const value = propertyBooleanValue(properties[sourceName]);
408
335
  if (value !== undefined) {
@@ -411,11 +338,7 @@ function firstBoolean(
411
338
  }
412
339
  return undefined;
413
340
  }
414
-
415
- function firstStringList(
416
- properties: Readonly<Record<string, PropertyValue>>,
417
- sourceNames: readonly string[],
418
- ): readonly string[] {
341
+ function firstStringList(properties, sourceNames) {
419
342
  const value = firstString(properties, sourceNames);
420
343
  if (value === undefined) {
421
344
  return [];
@@ -425,26 +348,20 @@ function firstStringList(
425
348
  .map((item) => item.trim())
426
349
  .filter((item) => item.length > 0);
427
350
  }
428
-
429
- function firstNumberList(
430
- properties: Readonly<Record<string, PropertyValue>>,
431
- sourceNames: readonly string[],
432
- ): readonly number[] {
351
+ function firstNumberList(properties, sourceNames) {
433
352
  const value = firstString(properties, sourceNames);
434
353
  if (value === undefined) {
435
354
  return [];
436
355
  }
437
356
  return parseNumberList(value);
438
357
  }
439
-
440
- function parseNumberList(value: string): readonly number[] {
358
+ function parseNumberList(value) {
441
359
  return value
442
360
  .split(',')
443
361
  .map((item) => Number.parseFloat(item.trim()))
444
362
  .filter((item) => Number.isFinite(item));
445
363
  }
446
-
447
- function parseToneStackSections(properties: Readonly<Record<string, PropertyValue>>): readonly MutableProperties[] {
364
+ function parseToneStackSections(properties) {
448
365
  const value = firstString(properties, ['ToneStackSections', 'Sections']);
449
366
  if (value === undefined) {
450
367
  return [];
@@ -454,21 +371,18 @@ function parseToneStackSections(properties: Readonly<Record<string, PropertyValu
454
371
  .map((section) => parseToneStackSection(section))
455
372
  .filter((section) => section !== null);
456
373
  }
457
-
458
- function parseToneStackSection(value: string): MutableProperties | null {
374
+ function parseToneStackSection(value) {
459
375
  const [gain, zeroHz, poleHz] = parseNumberList(value);
460
376
  if (gain === undefined || zeroHz === undefined || poleHz === undefined) {
461
377
  return null;
462
378
  }
463
379
  return { gain, zeroHz, poleHz };
464
380
  }
465
-
466
- function parseActiveEqBands(properties: Readonly<Record<string, PropertyValue>>): readonly MutableProperties[] {
381
+ function parseActiveEqBands(properties) {
467
382
  const frequencies = firstNumberList(properties, ['BandFrequenciesHz']);
468
383
  if (frequencies.length === 0) {
469
384
  return [];
470
385
  }
471
-
472
386
  const types = firstStringList(properties, ['BandFilterTypes']);
473
387
  const minFrequencies = firstNumberList(properties, ['MinBandFrequenciesHz']);
474
388
  const maxFrequencies = firstNumberList(properties, ['MaxBandFrequenciesHz']);
@@ -477,9 +391,8 @@ function parseActiveEqBands(properties: Readonly<Record<string, PropertyValue>>)
477
391
  const maxGains = firstNumberList(properties, ['MaxBandGainsDb', 'MaxGainDb']);
478
392
  const qValues = firstNumberList(properties, ['BandQ', 'Q']);
479
393
  const labels = firstStringList(properties, ['BandLabels']);
480
-
481
394
  return frequencies.map((frequencyHz, index) => {
482
- const band: MutableProperties = {
395
+ const band = {
483
396
  type: types[index] ?? 'peaking',
484
397
  frequencyHz,
485
398
  minFrequencyHz: numberAt(minFrequencies, index, frequencyHz),
@@ -496,7 +409,7 @@ function parseActiveEqBands(properties: Readonly<Record<string, PropertyValue>>)
496
409
  return band;
497
410
  });
498
411
  }
499
-
500
- function numberAt(values: readonly number[], index: number, fallback: number): number {
412
+ function numberAt(values, index, fallback) {
501
413
  return values[index] ?? values[0] ?? fallback;
502
414
  }
415
+ //# sourceMappingURL=runtime-descriptors.js.map