@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,18 +1,13 @@
1
- import type { Bounds } from './bounds';
2
- import type { Component } from '../model/types';
3
-
4
1
  // Every component renders in a uniform square container centered on its origin.
5
2
  // HALF_SIZE=20 matches the symbol viewBox (−25..25 with body content within ±20).
6
3
  // Lead axes that extend beyond ±20 (potentiometer ±40, op-amp ±30) intentionally
7
4
  // reach OUT of the container — they're connection lines to wires, not symbol body.
8
5
  const HALF_SIZE = 20;
9
-
10
- export function computeComponentBox(component: Component): Bounds {
6
+ export function computeComponentBox(component) {
11
7
  const minX = component.origin.x - HALF_SIZE;
12
8
  const minY = component.origin.y - HALF_SIZE;
13
9
  const maxX = component.origin.x + HALF_SIZE;
14
10
  const maxY = component.origin.y + HALF_SIZE;
15
-
16
11
  return {
17
12
  minX,
18
13
  minY,
@@ -22,3 +17,4 @@ export function computeComponentBox(component: Component): Bounds {
22
17
  height: maxY - minY,
23
18
  };
24
19
  }
20
+ //# sourceMappingURL=box-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"box-layout.js","sourceRoot":"","sources":["../../src/preview/box-layout.ts"],"names":[],"mappings":"AAGA,gFAAgF;AAChF,kFAAkF;AAClF,iFAAiF;AACjF,mFAAmF;AACnF,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,UAAU,mBAAmB,CAAC,SAAoB;IACpD,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IAC5C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IAC5C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IAC5C,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;IAE5C,OAAO;QACH,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,IAAI;QACJ,KAAK,EAAE,IAAI,GAAG,IAAI;QAClB,MAAM,EAAE,IAAI,GAAG,IAAI;KACtB,CAAC;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { ComponentKind } from '../model/types';
2
+ export declare function colorForKind(kind: ComponentKind): string;
3
+ //# sourceMappingURL=colors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../../src/preview/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAwCpD,wBAAgB,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,MAAM,CAExD"}
@@ -1,6 +1,4 @@
1
- import type { ComponentKind } from '../model/types';
2
-
3
- const KIND_COLOR: Readonly<Record<ComponentKind, string>> = {
1
+ const KIND_COLOR = {
4
2
  resistor: '#3b82f6',
5
3
  capacitor: '#3b82f6',
6
4
  inductor: '#3b82f6',
@@ -37,7 +35,7 @@ const KIND_COLOR: Readonly<Record<ComponentKind, string>> = {
37
35
  port: '#64748b',
38
36
  unsupported: '#94a3b8',
39
37
  };
40
-
41
- export function colorForKind(kind: ComponentKind): string {
38
+ export function colorForKind(kind) {
42
39
  return KIND_COLOR[kind];
43
40
  }
41
+ //# sourceMappingURL=colors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"colors.js","sourceRoot":"","sources":["../../src/preview/colors.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,GAA4C;IACxD,QAAQ,EAAE,SAAS;IACnB,SAAS,EAAE,SAAS;IACpB,QAAQ,EAAE,SAAS;IACnB,aAAa,EAAE,SAAS;IACxB,mBAAmB,EAAE,SAAS;IAC9B,WAAW,EAAE,SAAS;IACtB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,GAAG,EAAE,SAAS;IACd,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,KAAK,EAAE,SAAS;IAChB,GAAG,EAAE,SAAS;IACd,WAAW,EAAE,SAAS;IACtB,GAAG,EAAE,SAAS;IACd,UAAU,EAAE,SAAS;IACrB,WAAW,EAAE,SAAS;IACtB,SAAS,EAAE,SAAS;IACpB,eAAe,EAAE,SAAS;IAC1B,QAAQ,EAAE,SAAS;IACnB,EAAE,EAAE,SAAS;IACb,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,YAAY,EAAE,SAAS;IACvB,gBAAgB,EAAE,SAAS;IAC3B,gBAAgB,EAAE,SAAS;IAC3B,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,YAAY,EAAE,SAAS;IACvB,IAAI,EAAE,SAAS;IACf,WAAW,EAAE,SAAS;CACzB,CAAC;AAEF,MAAM,UAAU,YAAY,CAAC,IAAmB;IAC5C,OAAO,UAAU,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { CircuitDocument, Point } from '../model/types';
2
+ export type HangingEndpoint = Readonly<{
3
+ wireId: string;
4
+ point: Point;
5
+ endpointIndex: 0 | 1;
6
+ }>;
7
+ export declare function findHangingEndpoints(doc: CircuitDocument): readonly HangingEndpoint[];
8
+ //# sourceMappingURL=hanging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hanging.d.ts","sourceRoot":"","sources":["../../src/preview/hanging.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAQ,MAAM,gBAAgB,CAAC;AAEnE,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,KAAK,CAAC;IAEb,aAAa,EAAE,CAAC,GAAG,CAAC,CAAC;CACxB,CAAC,CAAC;AAQH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,SAAS,eAAe,EAAE,CAwBrF"}
@@ -1,35 +1,24 @@
1
- import type { CircuitDocument, Point, Wire } from '../model/types';
2
-
3
- export type HangingEndpoint = Readonly<{
4
- wireId: string;
5
- point: Point;
6
- // 0 = first endpoint (A), 1 = second endpoint (B)
7
- endpointIndex: 0 | 1;
8
- }>;
9
-
10
1
  // A wire endpoint is "hanging" when it doesn't actually connect to anything:
11
2
  // - It doesn't coincide with any component terminal position
12
3
  // - It doesn't coincide with another wire's endpoint
13
4
  // - It doesn't lie on another wire's body (T-junction)
14
5
  // These show up as floating dots in the schematic view and almost always
15
6
  // indicate a fixture data bug.
16
- export function findHangingEndpoints(doc: CircuitDocument): readonly HangingEndpoint[] {
17
- const terminalSet = new Set<string>();
7
+ export function findHangingEndpoints(doc) {
8
+ const terminalSet = new Set();
18
9
  for (const component of doc.components) {
19
10
  for (const terminal of component.terminals) {
20
11
  terminalSet.add(pointKey(terminal.position));
21
12
  }
22
13
  }
23
-
24
- const endpointCounts = new Map<string, number>();
14
+ const endpointCounts = new Map();
25
15
  for (const wire of doc.wires) {
26
16
  endpointCounts.set(pointKey(wire.endpoints[0]), (endpointCounts.get(pointKey(wire.endpoints[0])) ?? 0) + 1);
27
17
  endpointCounts.set(pointKey(wire.endpoints[1]), (endpointCounts.get(pointKey(wire.endpoints[1])) ?? 0) + 1);
28
18
  }
29
-
30
- const hanging: HangingEndpoint[] = [];
19
+ const hanging = [];
31
20
  for (const wire of doc.wires) {
32
- for (const [endpointIndex, point] of [[0, wire.endpoints[0]] as const, [1, wire.endpoints[1]] as const]) {
21
+ for (const [endpointIndex, point] of [[0, wire.endpoints[0]], [1, wire.endpoints[1]]]) {
33
22
  if (isConnected(point, wire, doc.wires, terminalSet, endpointCounts)) {
34
23
  continue;
35
24
  }
@@ -38,14 +27,7 @@ export function findHangingEndpoints(doc: CircuitDocument): readonly HangingEndp
38
27
  }
39
28
  return hanging;
40
29
  }
41
-
42
- function isConnected(
43
- point: Point,
44
- owningWire: Wire,
45
- allWires: readonly Wire[],
46
- terminalSet: ReadonlySet<string>,
47
- endpointCounts: ReadonlyMap<string, number>,
48
- ): boolean {
30
+ function isConnected(point, owningWire, allWires, terminalSet, endpointCounts) {
49
31
  if (terminalSet.has(pointKey(point))) {
50
32
  return true;
51
33
  }
@@ -65,8 +47,7 @@ function isConnected(
65
47
  }
66
48
  return false;
67
49
  }
68
-
69
- function pointOnSegmentInterior(p: Point, a: Point, b: Point): boolean {
50
+ function pointOnSegmentInterior(p, a, b) {
70
51
  const cross = (p.x - a.x) * (b.y - a.y) - (p.y - a.y) * (b.x - a.x);
71
52
  if (cross !== 0) {
72
53
  return false;
@@ -88,7 +69,7 @@ function pointOnSegmentInterior(p: Point, a: Point, b: Point): boolean {
88
69
  }
89
70
  return inXRange && inYRange;
90
71
  }
91
-
92
- function pointKey(p: Point): string {
72
+ function pointKey(p) {
93
73
  return `${p.x},${p.y}`;
94
74
  }
75
+ //# sourceMappingURL=hanging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hanging.js","sourceRoot":"","sources":["../../src/preview/hanging.ts"],"names":[],"mappings":"AASA,6EAA6E;AAC7E,6DAA6D;AAC7D,qDAAqD;AACrD,uDAAuD;AACvD,yEAAyE;AACzE,+BAA+B;AAC/B,MAAM,UAAU,oBAAoB,CAAC,GAAoB;IACrD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IACtC,KAAK,MAAM,SAAS,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;QACrC,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;YACzC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC;QACjD,CAAC;IACL,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;QAC3B,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QAC5G,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;IAChH,CAAC;IAED,MAAM,OAAO,GAAsB,EAAE,CAAC;I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CAAC;QAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,OAAO,QAAQ,IAAI,QAAQ,CAAC;AAChC,CAAC;AAED,SAAS,QAAQ,CAAC,CAAQ;IACtB,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Point, Wire } from '../model/types';
2
+ export declare function findJunctions(wires: readonly Wire[], terminals: readonly Point[]): readonly Point[];
3
+ //# sourceMappingURL=junctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junctions.d.ts","sourceRoot":"","sources":["../../src/preview/junctions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAElD,wBAAgB,aAAa,CACzB,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,SAAS,EAAE,SAAS,KAAK,EAAE,GAC5B,SAAS,KAAK,EAAE,CA2ClB"}
@@ -1,12 +1,6 @@
1
- import type { Point, Wire } from '../model/types';
2
-
3
- export function findJunctions(
4
- wires: readonly Wire[],
5
- terminals: readonly Point[],
6
- ): readonly Point[] {
7
- const endpointCounts = new Map<string, number>();
8
- const knownPoints = new Map<string, Point>();
9
-
1
+ export function findJunctions(wires, terminals) {
2
+ const endpointCounts = new Map();
3
+ const knownPoints = new Map();
10
4
  for (const wire of wires) {
11
5
  for (const endpoint of wire.endpoints) {
12
6
  const key = pointKey(endpoint);
@@ -16,25 +10,20 @@ export function findJunctions(
16
10
  }
17
11
  }
18
12
  }
19
-
20
- const junctions = new Map<string, Point>();
21
-
13
+ const junctions = new Map();
22
14
  for (const [key, count] of endpointCounts) {
23
15
  const point = knownPoints.get(key);
24
16
  if (point === undefined) {
25
17
  continue;
26
18
  }
27
-
28
19
  if (count >= 3) {
29
20
  junctions.set(key, point);
30
21
  continue;
31
22
  }
32
-
33
23
  if (count >= 1 && hasMidSegmentHit(point, wires)) {
34
24
  junctions.set(key, point);
35
25
  }
36
26
  }
37
-
38
27
  for (const terminal of terminals) {
39
28
  const key = pointKey(terminal);
40
29
  if (junctions.has(key)) {
@@ -44,11 +33,9 @@ export function findJunctions(
44
33
  junctions.set(key, terminal);
45
34
  }
46
35
  }
47
-
48
36
  return Array.from(junctions.values());
49
37
  }
50
-
51
- function hasMidSegmentHit(point: Point, wires: readonly Wire[]): boolean {
38
+ function hasMidSegmentHit(point, wires) {
52
39
  for (const wire of wires) {
53
40
  const a = wire.endpoints[0];
54
41
  const b = wire.endpoints[1];
@@ -61,8 +48,7 @@ function hasMidSegmentHit(point: Point, wires: readonly Wire[]): boolean {
61
48
  }
62
49
  return false;
63
50
  }
64
-
65
- function pointOnSegment(p: Point, a: Point, b: Point): boolean {
51
+ function pointOnSegment(p, a, b) {
66
52
  const cross = (p.x - a.x) * (b.y - a.y) - (p.y - a.y) * (b.x - a.x);
67
53
  if (cross !== 0) {
68
54
  return false;
@@ -84,11 +70,10 @@ function pointOnSegment(p: Point, a: Point, b: Point): boolean {
84
70
  }
85
71
  return inXRange && inYRange;
86
72
  }
87
-
88
- function pointEquals(a: Point, b: Point): boolean {
73
+ function pointEquals(a, b) {
89
74
  return a.x === b.x && a.y === b.y;
90
75
  }
91
-
92
- function pointKey(p: Point): string {
76
+ function pointKey(p) {
93
77
  return `${p.x},${p.y}`;
94
78
  }
79
+ //# sourceMappingURL=junctions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"junctions.js","sourceRoot":"","sources":["../../src/preview/junctions.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,aAAa,CACzB,KAAsB,EACtB,SAA2B;IAE3B,MAAM,cAAc,GAAG,IAAI,GAAG,EAAkB,CAAC;IACjD,MAAM,WAAW,GAAG,IAAI,GAAG,EAAiB,CAAC;IAE7C,KAAK,MAAM,IAAI,IAA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,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1C,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1C,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,OAAO,QAAQ,IAAI,QAAQ,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,CAAQ,EAAE,CAAQ;IACnC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,QAAQ,CAAC,CAAQ;IACtB,OAAO,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAC3B,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type LabelTextBoxLayout = Readonly<{
2
+ lines: readonly string[];
3
+ width: number;
4
+ height: number;
5
+ paddingX: number;
6
+ paddingY: number;
7
+ fontSize: number;
8
+ lineHeight: number;
9
+ }>;
10
+ export declare function shouldRenderLabelTextBox(text: string, subtext: string | null): boolean;
11
+ export declare function computeLabelTextBoxLayout(text: string, subtext: string | null): LabelTextBoxLayout;
12
+ //# sourceMappingURL=label-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-layout.d.ts","sourceRoot":"","sources":["../../src/preview/label-layout.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACtC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAWH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEtF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,kBAAkB,CAmBlG"}
@@ -1,13 +1,3 @@
1
- export type LabelTextBoxLayout = Readonly<{
2
- lines: readonly string[];
3
- width: number;
4
- height: number;
5
- paddingX: number;
6
- paddingY: number;
7
- fontSize: number;
8
- lineHeight: number;
9
- }>;
10
-
11
1
  const LABEL_TEXTBOX_MAX_CHARS = 52;
12
2
  const LABEL_TEXTBOX_MIN_WIDTH = 120;
13
3
  const LABEL_TEXTBOX_MAX_WIDTH = 320;
@@ -16,21 +6,14 @@ const LABEL_TEXTBOX_PADDING_X = 8;
16
6
  const LABEL_TEXTBOX_PADDING_Y = 6;
17
7
  const LABEL_TEXTBOX_FONT_SIZE = 10;
18
8
  const LABEL_TEXTBOX_LINE_HEIGHT = 14;
19
-
20
- export function shouldRenderLabelTextBox(text: string, subtext: string | null): boolean {
9
+ export function shouldRenderLabelTextBox(text, subtext) {
21
10
  return isLongOrMultiline(text) || (subtext !== null && isLongOrMultiline(subtext));
22
11
  }
23
-
24
- export function computeLabelTextBoxLayout(text: string, subtext: string | null): LabelTextBoxLayout {
12
+ export function computeLabelTextBoxLayout(text, subtext) {
25
13
  const lines = wrapLabelText(labelTextBody(text, subtext));
26
14
  const longestLine = Math.max(...lines.map((line) => line.length), 1);
27
- const width = clamp(
28
- Math.ceil(longestLine * LABEL_TEXTBOX_CHAR_WIDTH + LABEL_TEXTBOX_PADDING_X * 2),
29
- LABEL_TEXTBOX_MIN_WIDTH,
30
- LABEL_TEXTBOX_MAX_WIDTH,
31
- );
15
+ const width = clamp(Math.ceil(longestLine * LABEL_TEXTBOX_CHAR_WIDTH + LABEL_TEXTBOX_PADDING_X * 2), LABEL_TEXTBOX_MIN_WIDTH, LABEL_TEXTBOX_MAX_WIDTH);
32
16
  const height = LABEL_TEXTBOX_PADDING_Y * 2 + lines.length * LABEL_TEXTBOX_LINE_HEIGHT;
33
-
34
17
  return {
35
18
  lines,
36
19
  width,
@@ -41,29 +24,24 @@ export function computeLabelTextBoxLayout(text: string, subtext: string | null):
41
24
  lineHeight: LABEL_TEXTBOX_LINE_HEIGHT,
42
25
  };
43
26
  }
44
-
45
- function isLongOrMultiline(value: string): boolean {
27
+ function isLongOrMultiline(value) {
46
28
  return value.includes('\n') || value.length > LABEL_TEXTBOX_MAX_CHARS;
47
29
  }
48
-
49
- function labelTextBody(text: string, subtext: string | null): string {
30
+ function labelTextBody(text, subtext) {
50
31
  if (subtext === null) {
51
32
  return text;
52
33
  }
53
34
  return `${text}\n${subtext}`;
54
35
  }
55
-
56
- function wrapLabelText(text: string): readonly string[] {
36
+ function wrapLabelText(text) {
57
37
  const lines = text.split(/\r?\n/).flatMap((line) => wrapLabelLine(line));
58
38
  return lines.length === 0 ? [''] : lines;
59
39
  }
60
-
61
- function wrapLabelLine(line: string): readonly string[] {
40
+ function wrapLabelLine(line) {
62
41
  if (line.length <= LABEL_TEXTBOX_MAX_CHARS) {
63
42
  return [line];
64
43
  }
65
-
66
- const wrapped: string[] = [];
44
+ const wrapped = [];
67
45
  let rest = line.trimEnd();
68
46
  while (rest.length > LABEL_TEXTBOX_MAX_CHARS) {
69
47
  const breakAt = findWrapIndex(rest);
@@ -73,8 +51,7 @@ function wrapLabelLine(line: string): readonly string[] {
73
51
  wrapped.push(rest);
74
52
  return wrapped;
75
53
  }
76
-
77
- function findWrapIndex(text: string): number {
54
+ function findWrapIndex(text) {
78
55
  const search = text.slice(0, LABEL_TEXTBOX_MAX_CHARS + 1);
79
56
  const spaceIndex = search.lastIndexOf(' ');
80
57
  if (spaceIndex > 0) {
@@ -82,9 +59,11 @@ function findWrapIndex(text: string): number {
82
59
  }
83
60
  return LABEL_TEXTBOX_MAX_CHARS;
84
61
  }
85
-
86
- function clamp(value: number, min: number, max: number): number {
87
- if (value < min) return min;
88
- if (value > max) return max;
62
+ function clamp(value, min, max) {
63
+ if (value < min)
64
+ return min;
65
+ if (value > max)
66
+ return max;
89
67
  return value;
90
68
  }
69
+ //# sourceMappingURL=label-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label-layout.js","sourceRoot":"","sources":["../../src/preview/label-layout.ts"],"names":[],"mappings":"AAUA,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,wBAAwB,GAAG,GAAG,CAAC;AACrC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,uBAAuB,GAAG,CAAC,CAAC;AAClC,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACnC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC,MAAM,UAAU,wBAAwB,CAAC,IAAY,EAAE,OAAsB;IACzE,OAAO,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,KAAK,IAAI,IAAI,iBAAiB,CAAC,OAAO,CAAC,CAAC,CAAC;AACvF,CAAC;AAED,MAAM,UAAU,y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import type { Component, Point, Wire } from '../model/types';
2
+ export type WireBodyHit = Readonly<{
3
+ wireId: string;
4
+ position: Point;
5
+ }>;
6
+ export type Port = Readonly<{
7
+ componentId: string;
8
+ terminalName: string;
9
+ position: Point;
10
+ }>;
11
+ export declare function collectPorts(components: readonly Component[]): readonly Port[];
12
+ export declare function findNearestPort<T extends Port>(ports: readonly T[], cursor: Point, radius: number, exclude?: {
13
+ componentId: string;
14
+ terminalName: string;
15
+ } | null): T | null;
16
+ export declare function findNearestWireBodyHit(wires: readonly Wire[], cursor: Point, radius: number, excludeWireId?: string | null): WireBodyHit | null;
17
+ //# sourceMappingURL=ports.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.d.ts","sourceRoot":"","sources":["../../src/preview/ports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,KAAK,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,MAAM,IAAI,GAAG,QAAQ,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,KAAK,CAAC;CACnB,CAAC,CAAC;AAMH,wBAAgB,YAAY,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,GAAG,SAAS,IAAI,EAAE,CAY9E;AAKD,wBAAgB,eAAe,CAAC,CAAC,SAAS,IAAI,EAC1C,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,OAAO,GAAE;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,GAAG,IAAW,GACrE,CAAC,GAAG,IAAI,CAoBV;AAKD,wBAAgB,sBAAsB,CAClC,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,MAAM,EAAE,KAAK,EACb,MAAM,EAAE,MAAM,EACd,aAAa,GAAE,MAAM,GAAG,IAAW,GACpC,WAAW,GAAG,IAAI,CAiBpB"}
@@ -1,22 +1,9 @@
1
- import type { Component, Point, Wire } from '../model/types';
2
-
3
- export type WireBodyHit = Readonly<{
4
- wireId: string;
5
- position: Point;
6
- }>;
7
-
8
- export type Port = Readonly<{
9
- componentId: string;
10
- terminalName: string;
11
- position: Point;
12
- }>;
13
-
14
1
  // Flatten every component's terminals into a port list. The position is the
15
2
  // raw catalog terminal position — the same coordinate space used in wire
16
3
  // endpoints, so an add-wire command built from these positions lands on
17
4
  // existing junction / connectivity logic without further mapping.
18
- export function collectPorts(components: readonly Component[]): readonly Port[] {
19
- const ports: Port[] = [];
5
+ export function collectPorts(components) {
6
+ const ports = [];
20
7
  for (const component of components) {
21
8
  for (const terminal of component.terminals) {
22
9
  ports.push({
@@ -28,24 +15,16 @@ export function collectPorts(components: readonly Component[]): readonly Port[]
28
15
  }
29
16
  return ports;
30
17
  }
31
-
32
18
  // Find the port nearest to `cursor` within `radius` distance, optionally
33
19
  // excluding a particular port (used to avoid snapping back onto the wire's
34
20
  // own start terminal during a wire-create drag).
35
- export function findNearestPort<T extends Port>(
36
- ports: readonly T[],
37
- cursor: Point,
38
- radius: number,
39
- exclude: { componentId: string; terminalName: string } | null = null,
40
- ): T | null {
41
- let best: T | null = null;
21
+ export function findNearestPort(ports, cursor, radius, exclude = null) {
22
+ let best = null;
42
23
  let bestDistance = radius;
43
24
  for (const port of ports) {
44
- if (
45
- exclude !== null &&
25
+ if (exclude !== null &&
46
26
  port.componentId === exclude.componentId &&
47
- port.terminalName === exclude.terminalName
48
- ) {
27
+ port.terminalName === exclude.terminalName) {
49
28
  continue;
50
29
  }
51
30
  const dx = port.position.x - cursor.x;
@@ -58,17 +37,11 @@ export function findNearestPort<T extends Port>(
58
37
  }
59
38
  return best;
60
39
  }
61
-
62
40
  // Find the wire whose body is closest to `cursor`, within `radius`, and return
63
41
  // the projection of the cursor onto that wire. Used to snap a wire-create
64
42
  // gesture to a wire body so dropping there auto-forms a T-junction.
65
- export function findNearestWireBodyHit(
66
- wires: readonly Wire[],
67
- cursor: Point,
68
- radius: number,
69
- excludeWireId: string | null = null,
70
- ): WireBodyHit | null {
71
- let best: WireBodyHit | null = null;
43
+ export function findNearestWireBodyHit(wires, cursor, radius, excludeWireId = null) {
44
+ let best = null;
72
45
  let bestDistance = radius;
73
46
  for (const wire of wires) {
74
47
  if (excludeWireId !== null && wire.id === excludeWireId) {
@@ -85,8 +58,7 @@ export function findNearestWireBodyHit(
85
58
  }
86
59
  return best;
87
60
  }
88
-
89
- function projectOntoSegment(p: Point, a: Point, b: Point): Point {
61
+ function projectOntoSegment(p, a, b) {
90
62
  const dx = b.x - a.x;
91
63
  const dy = b.y - a.y;
92
64
  if (dx === 0 && dy === 0) {
@@ -99,3 +71,4 @@ function projectOntoSegment(p: Point, a: Point, b: Point): Point {
99
71
  y: Math.round(a.y + clamped * dy),
100
72
  };
101
73
  }
74
+ //# sourceMappingURL=ports.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ports.js","sourceRoot":"","sources":["../../src/preview/ports.ts"],"names":[],"mappings":"AAaA,4EAA4E;AAC5E,yEAAyE;AACzE,wEAAwE;AACxE,kEAAkE;AAClE,MAAM,UAAU,YAAY,CAAC,UAAgC;IACzD,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACjC,KAAK,MAAM,QAAQ,IAAI,SAAS,CAAC,SAAS,EAAE,CAAC;YACzC,KAAK,CAAC,IAAI,CAAC;gBACP,WAAW,EAAE,SAAS,CAAC,EAAE;gBACzB,YAAY,EAAE,QAAQ,CAAC,IAAI;gBAC3B,QAAQ,EAAE,QAAQ,CAAC,QAAQ;aAC9B,CAAC,CAAC;QACP,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAC;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OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO;QACH,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,EAAE,CAAC;QACjC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,EAAE,CAAC;KACpC,CAAC;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { CircuitDocument, Wire } from '../model/types';
2
+ export declare function buildRenderableWires(document: CircuitDocument): readonly Wire[];
3
+ //# sourceMappingURL=renderable-wires.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderable-wires.d.ts","sourceRoot":"","sources":["../../src/preview/renderable-wires.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAS,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAEnE,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,IAAI,EAAE,CAU/E"}
@@ -1,39 +1,29 @@
1
- import type { CircuitDocument, Point, Wire } from '../model/types';
2
-
3
- export function buildRenderableWires(document: CircuitDocument): readonly Wire[] {
1
+ export function buildRenderableWires(document) {
4
2
  const splitCandidates = collectSplitCandidates(document);
5
- const result: Wire[] = [];
6
-
3
+ const result = [];
7
4
  for (const wire of document.wires) {
8
5
  const segments = splitWire(wire, splitCandidates);
9
6
  result.push(...segments);
10
7
  }
11
-
12
8
  return result;
13
9
  }
14
-
15
- function collectSplitCandidates(document: CircuitDocument): readonly Point[] {
16
- const byKey = new Map<string, Point>();
17
-
10
+ function collectSplitCandidates(document) {
11
+ const byKey = new Map();
18
12
  for (const wire of document.wires) {
19
13
  addPoint(byKey, wire.endpoints[0]);
20
14
  addPoint(byKey, wire.endpoints[1]);
21
15
  }
22
-
23
16
  for (const component of document.components) {
24
17
  for (const terminal of component.terminals) {
25
18
  addPoint(byKey, terminal.position);
26
19
  }
27
20
  }
28
-
29
21
  return Array.from(byKey.values());
30
22
  }
31
-
32
- function splitWire(wire: Wire, candidates: readonly Point[]): readonly Wire[] {
23
+ function splitWire(wire, candidates) {
33
24
  const a = wire.endpoints[0];
34
25
  const b = wire.endpoints[1];
35
26
  const points = [a, b];
36
-
37
27
  for (const candidate of candidates) {
38
28
  if (pointEquals(candidate, a) || pointEquals(candidate, b)) {
39
29
  continue;
@@ -42,13 +32,11 @@ function splitWire(wire: Wire, candidates: readonly Point[]): readonly Wire[] {
42
32
  points.push(candidate);
43
33
  }
44
34
  }
45
-
46
35
  if (points.length === 2) {
47
36
  return [wire];
48
37
  }
49
-
50
38
  const ordered = points.slice().sort((p, q) => segmentParameter(p, a, b) - segmentParameter(q, a, b));
51
- const segments: Wire[] = [];
39
+ const segments = [];
52
40
  for (let i = 0; i < ordered.length - 1; i += 1) {
53
41
  const start = ordered[i];
54
42
  const end = ordered[i + 1];
@@ -60,18 +48,15 @@ function splitWire(wire: Wire, candidates: readonly Point[]): readonly Wire[] {
60
48
  endpoints: [start, end],
61
49
  });
62
50
  }
63
-
64
51
  return segments;
65
52
  }
66
-
67
- function addPoint(points: Map<string, Point>, point: Point): void {
53
+ function addPoint(points, point) {
68
54
  const key = pointKey(point);
69
55
  if (!points.has(key)) {
70
56
  points.set(key, point);
71
57
  }
72
58
  }
73
-
74
- function segmentParameter(point: Point, a: Point, b: Point): number {
59
+ function segmentParameter(point, a, b) {
75
60
  const dx = b.x - a.x;
76
61
  const dy = b.y - a.y;
77
62
  const lengthSq = dx * dx + dy * dy;
@@ -80,8 +65,7 @@ function segmentParameter(point: Point, a: Point, b: Point): number {
80
65
  }
81
66
  return ((point.x - a.x) * dx + (point.y - a.y) * dy) / lengthSq;
82
67
  }
83
-
84
- function pointOnSegment(point: Point, a: Point, b: Point): boolean {
68
+ function pointOnSegment(point, a, b) {
85
69
  const cross = (point.x - a.x) * (b.y - a.y) - (point.y - a.y) * (b.x - a.x);
86
70
  if (cross !== 0) {
87
71
  return false;
@@ -103,11 +87,10 @@ function pointOnSegment(point: Point, a: Point, b: Point): boolean {
103
87
  }
104
88
  return inXRange && inYRange;
105
89
  }
106
-
107
- function pointEquals(a: Point, b: Point): boolean {
90
+ function pointEquals(a, b) {
108
91
  return a.x === b.x && a.y === b.y;
109
92
  }
110
-
111
- function pointKey(point: Point): string {
93
+ function pointKey(point) {
112
94
  return `${point.x},${point.y}`;
113
95
  }
96
+ //# sourceMappingURL=renderable-wires.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderable-wires.js","sourceRoot":"","sources":["../../src/preview/renderable-wires.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,oBAAoB,CAAC,QAAyB;IAC1D,MAAM,eAAe,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;IACzD,MAAM,MAAM,GAAW,EAAE,CAAC;IAE1B,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAChC,MAAM,QAAQ,GAAG,SAAS,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;QAClD,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAED,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,sBAAsB,CAAC,QAAyB;IACrD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAiB,CAAC;IAEvC,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QAChC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QACnC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IAED,KAAK,MAAM,SAAS,IAAI,QAAQ,CAAC,UAAU,EAAE,CAAC;QAC1C,KA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O,QAAQ,CAAC;IACpB,CAAC;IACD,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,OAAO,QAAQ,CAAC;IACpB,CAAC;IACD,OAAO,QAAQ,IAAI,QAAQ,CAAC;AAChC,CAAC;AAED,SAAS,WAAW,CAAC,CAAQ,EAAE,CAAQ;IACnC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,QAAQ,CAAC,KAAY;IAC1B,OAAO,GAAG,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { Point } from '../model/types';
2
+ export declare function orthogonalPath(a: Point, b: Point): readonly Point[];
3
+ export declare function pointsToSvg(points: readonly Point[]): string;
4
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../src/preview/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,CAQnE;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,GAAG,MAAM,CAE5D"}