@tscircuit/cli 0.1.2412 → 0.1.2414

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/lib/index.js CHANGED
@@ -69766,7 +69766,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
69766
69766
  }));
69767
69767
  };
69768
69768
  // package.json
69769
- var version = "0.1.2411";
69769
+ var version = "0.1.2413";
69770
69770
  var package_default = {
69771
69771
  name: "@tscircuit/cli",
69772
69772
  version,
@@ -69786,8 +69786,8 @@ var package_default = {
69786
69786
  "@tscircuit/circuit-json-pcb-style-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-pcb-style-analysis/0.0.5.tgz",
69787
69787
  "@tscircuit/circuit-json-placement-analysis": "^0.0.17",
69788
69788
  "@tscircuit/circuit-json-routing-analysis": "^0.0.8",
69789
- "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.72.tgz",
69790
- "@tscircuit/circuit-json-util": "^0.0.121",
69789
+ "@tscircuit/circuit-json-schematic-placement-analysis": "https://jscdn.tscircuit.com/@tscircuit/circuit-json-schematic-placement-analysis/0.0.82.tgz",
69790
+ "@tscircuit/circuit-json-util": "^0.0.129",
69791
69791
  "@tscircuit/eval": "0.0.1619",
69792
69792
  "@tscircuit/fake-snippets": "^0.0.226",
69793
69793
  "@tscircuit/file-server": "^0.0.32",
@@ -69820,8 +69820,8 @@ var package_default = {
69820
69820
  "circuit-json-to-connectivity-map": "^0.0.32",
69821
69821
  "circuit-json-to-fdm-component-box": "^0.0.2",
69822
69822
  "circuit-json-to-footprinter": "^0.0.59",
69823
- "circuit-json-to-gerber": "^0.0.117",
69824
- "circuit-json-to-kicad": "0.0.241",
69823
+ "circuit-json-to-gerber": "^0.0.120",
69824
+ "circuit-json-to-kicad": "0.0.253",
69825
69825
  "circuit-json-to-pnp-csv": "^0.0.18",
69826
69826
  "circuit-json-to-readable-netlist": "^0.0.15",
69827
69827
  "circuit-json-to-spice": "^0.0.45",
@@ -69847,7 +69847,7 @@ var package_default = {
69847
69847
  jszip: "^3.10.1",
69848
69848
  "jwt-decode": "^4.0.0",
69849
69849
  "kicad-to-circuit-json": "^0.0.113",
69850
- kicadts: "^0.0.58",
69850
+ kicadts: "^0.0.59",
69851
69851
  kleur: "^4.1.5",
69852
69852
  ky: "^1.7.4",
69853
69853
  "make-vfs": "^1.0.15",
@@ -72599,13 +72599,9 @@ import {
72599
72599
  import { SymbolArc } from "kicadts";
72600
72600
  import { applyToPoint } from "transformation-matrix";
72601
72601
  import { SymbolCircle } from "kicadts";
72602
- import { applyToPoint as applyToPoint2 } from "transformation-matrix";
72603
72602
  import { Pts, Stroke as Stroke2, SymbolPolyline, SymbolPolylineFill, Xy } from "kicadts";
72604
- import { applyToPoint as applyToPoint3 } from "transformation-matrix";
72605
72603
  import { SymbolRectangle } from "kicadts";
72606
- import { applyToPoint as applyToPoint4 } from "transformation-matrix";
72607
72604
  import { SymbolText, TextEffects as TextEffects2, TextEffectsFont as TextEffectsFont2 } from "kicadts";
72608
- import { applyToPoint as applyToPoint5 } from "transformation-matrix";
72609
72605
  import { SymbolProperty } from "kicadts";
72610
72606
  import { TextEffects as TextEffects3, TextEffectsFont as TextEffectsFont3 } from "kicadts";
72611
72607
  import {
@@ -72616,7 +72612,8 @@ import {
72616
72612
  TextEffects as TextEffects4,
72617
72613
  TextEffectsFont as TextEffectsFont4
72618
72614
  } from "kicadts";
72619
- import { applyToPoint as applyToPoint6, scale as createScaleMatrix2 } from "transformation-matrix";
72615
+ import { applyToPoint as applyToPoint2, scale as createScaleMatrix2 } from "transformation-matrix";
72616
+ import { applyToPoint as applyToPoint3 } from "transformation-matrix";
72620
72617
  import {
72621
72618
  Polyline,
72622
72619
  Pts as Pts2,
@@ -72628,11 +72625,13 @@ import {
72628
72625
  SymbolRectangleFill,
72629
72626
  TextEffects as TextEffects5,
72630
72627
  TextEffectsFont as TextEffectsFont5,
72631
- TextEffectsJustify as TextEffectsJustify2,
72628
+ TextEffectsJustify as TextEffectsJustify3,
72632
72629
  Uuid,
72633
72630
  Xy as Xy2
72634
72631
  } from "kicadts";
72635
- import { applyToPoint as applyToPoint7 } from "transformation-matrix";
72632
+ import { applyToPoint as applyToPoint5 } from "transformation-matrix";
72633
+ import { Label, TextEffectsJustify as TextEffectsJustify2 } from "kicadts";
72634
+ import { applyToPoint as applyToPoint4 } from "transformation-matrix";
72636
72635
  import {
72637
72636
  SchematicSymbol as SchematicSymbol5,
72638
72637
  SymbolLibId,
@@ -72643,10 +72642,10 @@ import {
72643
72642
  SymbolInstancePath,
72644
72643
  TextEffects as TextEffects6,
72645
72644
  TextEffectsFont as TextEffectsFont6,
72646
- TextEffectsJustify as TextEffectsJustify3,
72645
+ TextEffectsJustify as TextEffectsJustify4,
72647
72646
  GlobalLabel
72648
72647
  } from "kicadts";
72649
- import { applyToPoint as applyToPoint8 } from "transformation-matrix";
72648
+ import { applyToPoint as applyToPoint6 } from "transformation-matrix";
72650
72649
  import { symbols as symbols4 } from "schematic-symbols";
72651
72650
  import { formatSiUnit } from "format-si-unit";
72652
72651
  import {
@@ -72662,11 +72661,11 @@ import {
72662
72661
  SymbolProperty as SymbolProperty3,
72663
72662
  TextEffects as TextEffects7,
72664
72663
  TextEffectsFont as TextEffectsFont7,
72665
- TextEffectsJustify as TextEffectsJustify4
72664
+ TextEffectsJustify as TextEffectsJustify5
72666
72665
  } from "kicadts";
72667
- import { applyToPoint as applyToPoint9 } from "transformation-matrix";
72666
+ import { applyToPoint as applyToPoint7 } from "transformation-matrix";
72668
72667
  import { Wire, Pts as Pts3, Xy as Xy3, Stroke as Stroke4, Junction } from "kicadts";
72669
- import { applyToPoint as applyToPoint10 } from "transformation-matrix";
72668
+ import { applyToPoint as applyToPoint8 } from "transformation-matrix";
72670
72669
  import {
72671
72670
  SheetInstances,
72672
72671
  SheetInstancesRootPath,
@@ -72676,7 +72675,7 @@ import {
72676
72675
  import { Paper, Uuid as Uuid4 } from "kicadts";
72677
72676
  import { KicadPcb as KicadPcb2 } from "kicadts";
72678
72677
  import { cju as cju2 } from "@tscircuit/circuit-json-util";
72679
- import { compose as compose7, translate as translate7, scale as scale5 } from "transformation-matrix";
72678
+ import { compose as compose8, translate as translate8, scale as scale6 } from "transformation-matrix";
72680
72679
  import {
72681
72680
  Layer,
72682
72681
  Pts as Pts4,
@@ -72689,13 +72688,13 @@ import {
72689
72688
  ZonePolygon
72690
72689
  } from "kicadts";
72691
72690
  import {
72692
- applyToPoint as applyToPoint11,
72691
+ applyToPoint as applyToPoint9,
72693
72692
  compose as compose3,
72694
72693
  rotate,
72695
72694
  translate as translate3
72696
72695
  } from "transformation-matrix";
72697
72696
  import { Pts as Pts5, Xy as Xy5, Zone as Zone2, ZoneKeepout, ZonePolygon as ZonePolygon2 } from "kicadts";
72698
- import { applyToPoint as applyToPoint12 } from "transformation-matrix";
72697
+ import { applyToPoint as applyToPoint10 } from "transformation-matrix";
72699
72698
  import {
72700
72699
  Paper as Paper2,
72701
72700
  PcbLayers,
@@ -72703,21 +72702,23 @@ import {
72703
72702
  PcbGeneral,
72704
72703
  Setup
72705
72704
  } from "kicadts";
72705
+ import { getElementId } from "@tscircuit/circuit-json-util";
72706
+ import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
72706
72707
  import { PcbNet } from "kicadts";
72707
- import { Footprint as Footprint3, FootprintModel as FootprintModel4, FootprintAttr as FootprintAttr3 } from "kicadts";
72708
+ var import_polygon_clipping = __toESM3(require_polygon_clipping_cjs(), 1);
72709
+ import { Footprint as Footprint4, FootprintModel as FootprintModel4, FootprintAttr as FootprintAttr3 } from "kicadts";
72708
72710
  import {
72709
72711
  parseKicadSexpr,
72710
72712
  KicadPcb,
72711
72713
  FootprintModel,
72712
72714
  At as At2,
72713
72715
  EmbeddedFonts as EmbeddedFonts4,
72714
- FootprintAttr,
72715
72716
  Property,
72716
72717
  TextEffects as TextEffects8,
72717
72718
  TextEffectsFont as TextEffectsFont8
72718
72719
  } from "kicadts";
72719
- var import_polygon_clipping = __toESM3(require_polygon_clipping_cjs(), 1);
72720
- import { applyToPoint as applyToPoint23 } from "transformation-matrix";
72720
+ import { FootprintAttr } from "kicadts";
72721
+ import { applyToPoint as applyToPoint22 } from "transformation-matrix";
72721
72722
  import {
72722
72723
  Property as Property2,
72723
72724
  TextEffects as TextEffects9,
@@ -72727,35 +72728,42 @@ import {
72727
72728
  FootprintAttr as FootprintAttr2
72728
72729
  } from "kicadts";
72729
72730
  import { FpCircle, Stroke as Stroke5 } from "kicadts";
72730
- import { applyToPoint as applyToPoint13, identity, rotate as rotate2 } from "transformation-matrix";
72731
+ import { applyToPoint as applyToPoint11, identity, rotate as rotate2 } from "transformation-matrix";
72731
72732
  import { FpCircle as FpCircle2, Stroke as Stroke6 } from "kicadts";
72732
72733
  import { FpRect, Stroke as Stroke7 } from "kicadts";
72733
72734
  import { FpRect as FpRect2, Stroke as Stroke8 } from "kicadts";
72734
- import { FpRect as FpRect3, Stroke as Stroke9 } from "kicadts";
72735
- import { FpPoly, Pts as Pts6, Stroke as Stroke10, Xy as Xy6 } from "kicadts";
72735
+ import { FpPoly, FpRect as FpRect3, Stroke as Stroke9 } from "kicadts";
72736
72736
  import {
72737
- applyToPoint as applyToPoint14,
72737
+ applyToPoint as applyToPoint12,
72738
72738
  compose as compose4,
72739
72739
  rotate as rotate3,
72740
72740
  scale as scale2,
72741
72741
  translate as translate4
72742
72742
  } from "transformation-matrix";
72743
- import"kicadts";
72744
- import { FpText, TextEffects as TextEffects10, TextEffectsFont as TextEffectsFont10 } from "kicadts";
72745
- import { applyToPoint as applyToPoint15, rotate as rotate4, identity as identity2 } from "transformation-matrix";
72746
- import { TextEffectsJustify as TextEffectsJustify5 } from "kicadts";
72747
- import { FpLine, Stroke as Stroke11 } from "kicadts";
72748
- import { applyToPoint as applyToPoint16, identity as identity3, rotate as rotate5 } from "transformation-matrix";
72749
- import { FpPoly as FpPoly2, Stroke as Stroke12 } from "kicadts";
72743
+ import { FpPoly as FpPoly2, Pts as Pts6, Stroke as Stroke10, Xy as Xy6 } from "kicadts";
72750
72744
  import {
72751
- applyToPoint as applyToPoint17,
72745
+ applyToPoint as applyToPoint13,
72752
72746
  compose as compose5,
72753
- rotate as rotate6,
72747
+ rotate as rotate4,
72754
72748
  scale as scale3,
72755
72749
  translate as translate5
72756
72750
  } from "transformation-matrix";
72751
+ import"kicadts";
72752
+ import { FpText, TextEffects as TextEffects10, TextEffectsFont as TextEffectsFont10 } from "kicadts";
72753
+ import { applyToPoint as applyToPoint14, rotate as rotate5, identity as identity2 } from "transformation-matrix";
72754
+ import { TextEffectsJustify as TextEffectsJustify6 } from "kicadts";
72755
+ import { FpLine, Stroke as Stroke11 } from "kicadts";
72756
+ import { applyToPoint as applyToPoint15, identity as identity3, rotate as rotate6 } from "transformation-matrix";
72757
+ import { FpPoly as FpPoly3, Stroke as Stroke12 } from "kicadts";
72758
+ import {
72759
+ applyToPoint as applyToPoint16,
72760
+ compose as compose6,
72761
+ rotate as rotate7,
72762
+ scale as scale4,
72763
+ translate as translate6
72764
+ } from "transformation-matrix";
72757
72765
  import { FpText as FpText3, TextEffects as TextEffects11, TextEffectsFont as TextEffectsFont11 } from "kicadts";
72758
- import { applyToPoint as applyToPoint18, rotate as rotate7, identity as identity4 } from "transformation-matrix";
72766
+ import { applyToPoint as applyToPoint17, rotate as rotate8, identity as identity4 } from "transformation-matrix";
72759
72767
  import { FootprintModel as FootprintModel3 } from "kicadts";
72760
72768
  import {
72761
72769
  FootprintPad,
@@ -72767,37 +72775,38 @@ import {
72767
72775
  PadNet
72768
72776
  } from "kicadts";
72769
72777
  import {
72770
- applyToPoint as applyToPoint19,
72771
- compose as compose6,
72772
- translate as translate6,
72773
- scale as scale4,
72774
- rotate as rotate8
72778
+ applyToPoint as applyToPoint18,
72779
+ compose as compose7,
72780
+ translate as translate7,
72781
+ scale as scale5,
72782
+ rotate as rotate9
72775
72783
  } from "transformation-matrix";
72776
72784
  import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
72777
- import { applyToPoint as applyToPoint20, rotate as rotate9, identity as identity5 } from "transformation-matrix";
72785
+ import { applyToPoint as applyToPoint19, rotate as rotate10, identity as identity5 } from "transformation-matrix";
72778
72786
  import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
72779
- import { applyToPoint as applyToPoint21, rotate as rotate10, identity as identity6 } from "transformation-matrix";
72787
+ import { applyToPoint as applyToPoint20, rotate as rotate11, identity as identity6 } from "transformation-matrix";
72780
72788
  import { FpLine as FpLine2, Stroke as Stroke13 } from "kicadts";
72781
- import { applyToPoint as applyToPoint22, identity as identity7, rotate as rotate11 } from "transformation-matrix";
72789
+ import { applyToPoint as applyToPoint21, identity as identity7, rotate as rotate12 } from "transformation-matrix";
72782
72790
  import { Segment, SegmentNet } from "kicadts";
72783
- import { applyToPoint as applyToPoint24 } from "transformation-matrix";
72791
+ import { applyToPoint as applyToPoint23 } from "transformation-matrix";
72792
+ import { isRouteViaCoveredByPhysicalVia } from "@tscircuit/circuit-json-util";
72784
72793
  import { Via, ViaNet } from "kicadts";
72785
- import { applyToPoint as applyToPoint25 } from "transformation-matrix";
72794
+ import { applyToPoint as applyToPoint24 } from "transformation-matrix";
72786
72795
  import { ViaTenting } from "kicadts";
72787
- import { Footprint as Footprint4 } from "kicadts";
72788
- import { applyToPoint as applyToPoint26 } from "transformation-matrix";
72796
+ import { Footprint as Footprint5 } from "kicadts";
72797
+ import { applyToPoint as applyToPoint25 } from "transformation-matrix";
72789
72798
  import { GrLine } from "kicadts";
72790
72799
  import {
72791
72800
  At as At3,
72792
72801
  GrText,
72793
72802
  TextEffects as TextEffects12,
72794
72803
  TextEffectsFont as TextEffectsFont12,
72795
- TextEffectsJustify as TextEffectsJustify6
72804
+ TextEffectsJustify as TextEffectsJustify7
72796
72805
  } from "kicadts";
72797
- import { applyToPoint as applyToPoint27 } from "transformation-matrix";
72798
- import { applyToPoint as applyToPoint29, rotate as rotate12 } from "transformation-matrix";
72806
+ import { applyToPoint as applyToPoint26 } from "transformation-matrix";
72807
+ import { applyToPoint as applyToPoint28, rotate as rotate13 } from "transformation-matrix";
72799
72808
  import { GrText as GrText2, TextEffects as TextEffects13, TextEffectsFont as TextEffectsFont13, At as At4 } from "kicadts";
72800
- import { applyToPoint as applyToPoint28 } from "transformation-matrix";
72809
+ import { applyToPoint as applyToPoint27 } from "transformation-matrix";
72801
72810
  import { cju as cju3 } from "@tscircuit/circuit-json-util";
72802
72811
  import { cju as cju4 } from "@tscircuit/circuit-json-util";
72803
72812
  import { parseKicadSexpr as parseKicadSexpr2, KicadSch as KicadSch2 } from "kicadts";
@@ -72805,7 +72814,7 @@ import { KicadSymbolLib } from "kicadts";
72805
72814
  import { parseKicadMod } from "kicadts";
72806
72815
  import {
72807
72816
  parseKicadSexpr as parseKicadSexpr3,
72808
- Footprint as Footprint5,
72817
+ Footprint as Footprint6,
72809
72818
  Property as Property3,
72810
72819
  TextEffects as TextEffects14,
72811
72820
  TextEffectsFont as TextEffectsFont14
@@ -72818,7 +72827,7 @@ import {
72818
72827
  SymbolProperty as SymbolProperty4,
72819
72828
  TextEffects as TextEffects15,
72820
72829
  TextEffectsFont as TextEffectsFont15,
72821
- TextEffectsJustify as TextEffectsJustify7
72830
+ TextEffectsJustify as TextEffectsJustify8
72822
72831
  } from "kicadts";
72823
72832
  import { KicadSymbolLib as KicadSymbolLib2 } from "kicadts";
72824
72833
  var BOX_WIDTH = 40;
@@ -73554,14 +73563,24 @@ function buildSymbolDataFromSchematicPrimitives(params2) {
73554
73563
  ports: symbolPorts
73555
73564
  };
73556
73565
  }
73566
+ function toSchematicInternalUnits(mm) {
73567
+ return Math.sign(mm) * Math.round(Math.abs(mm) * 1e4);
73568
+ }
73569
+ function roundSchematicCoordinate(mm) {
73570
+ return toSchematicInternalUnits(mm) / 1e4;
73571
+ }
73572
+ function transformSchematicPoint(transform, point) {
73573
+ const { x, y } = applyToPoint(transform, point);
73574
+ return { x: roundSchematicCoordinate(x), y: roundSchematicCoordinate(y) };
73575
+ }
73557
73576
  function createArcFromPrimitive({
73558
73577
  primitive,
73559
73578
  transform,
73560
- scale: scale6
73579
+ scale: scale7
73561
73580
  }) {
73562
- const start = applyToPoint(transform, primitive.start);
73563
- const mid = applyToPoint(transform, primitive.mid);
73564
- const end = applyToPoint(transform, primitive.end);
73581
+ const start = transformSchematicPoint(transform, primitive.start);
73582
+ const mid = transformSchematicPoint(transform, primitive.mid);
73583
+ const end = transformSchematicPoint(transform, primitive.end);
73565
73584
  return SymbolArc.fromSexprPrimitives([
73566
73585
  ["start", start.x, start.y],
73567
73586
  ["mid", mid.x, mid.y],
@@ -73570,7 +73589,7 @@ function createArcFromPrimitive({
73570
73589
  "stroke",
73571
73590
  [
73572
73591
  "width",
73573
- primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
73592
+ roundSchematicCoordinate(primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale7)
73574
73593
  ],
73575
73594
  ["type", primitive.isDashed ? "dash" : "default"]
73576
73595
  ],
@@ -73578,6 +73597,8 @@ function createArcFromPrimitive({
73578
73597
  ]);
73579
73598
  }
73580
73599
  function parseColor(color) {
73600
+ if (color === "transparent")
73601
+ return { r: 0, g: 0, b: 0, a: 0 };
73581
73602
  const rgbMatch = color.match(/^rgba?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)(?:\s*,\s*(\d+(?:\.\d+)?))?\s*\)$/i);
73582
73603
  if (rgbMatch) {
73583
73604
  return {
@@ -73624,20 +73645,20 @@ function createSymbolFillSexprPrimitives({
73624
73645
  function createCircleFromPrimitive({
73625
73646
  primitive,
73626
73647
  transform,
73627
- scale: scale6
73648
+ scale: scale7
73628
73649
  }) {
73629
- const scaledPos = applyToPoint2(transform, {
73650
+ const scaledPos = transformSchematicPoint(transform, {
73630
73651
  x: primitive.x,
73631
73652
  y: primitive.y
73632
73653
  });
73633
73654
  return SymbolCircle.fromSexprPrimitives([
73634
73655
  ["center", scaledPos.x, scaledPos.y],
73635
- ["radius", primitive.radius * scale6],
73656
+ ["radius", roundSchematicCoordinate(primitive.radius * scale7)],
73636
73657
  [
73637
73658
  "stroke",
73638
73659
  [
73639
73660
  "width",
73640
- primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
73661
+ roundSchematicCoordinate(primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale7)
73641
73662
  ],
73642
73663
  ["type", "default"]
73643
73664
  ],
@@ -73659,17 +73680,17 @@ function createPolylineFromPoints({
73659
73680
  fallbackFillType,
73660
73681
  strokeWidth,
73661
73682
  isDashed,
73662
- scale: scale6
73683
+ scale: scale7
73663
73684
  }) {
73664
73685
  const polyline = new SymbolPolyline;
73665
73686
  const xyPoints = points.map((p) => {
73666
- const transformed = applyToPoint3(transform, p);
73687
+ const transformed = transformSchematicPoint(transform, p);
73667
73688
  return new Xy(transformed.x, transformed.y);
73668
73689
  });
73669
73690
  const pts = new Pts(xyPoints);
73670
73691
  polyline.points = pts;
73671
73692
  const stroke = new Stroke2;
73672
- stroke.width = strokeWidth == null ? 0.254 : strokeWidth * scale6;
73693
+ stroke.width = roundSchematicCoordinate(strokeWidth == null ? 0.254 : strokeWidth * scale7);
73673
73694
  stroke.type = isDashed ? "dash" : "default";
73674
73695
  polyline.stroke = stroke;
73675
73696
  const fill = SymbolPolylineFill.fromSexprPrimitives(createSymbolFillSexprPrimitives({
@@ -73683,10 +73704,10 @@ function createPolylineFromPoints({
73683
73704
  function createRectangleFromPrimitive({
73684
73705
  primitive,
73685
73706
  transform,
73686
- scale: scale6
73707
+ scale: scale7
73687
73708
  }) {
73688
- const start = applyToPoint4(transform, primitive.start);
73689
- const end = applyToPoint4(transform, primitive.end);
73709
+ const start = transformSchematicPoint(transform, primitive.start);
73710
+ const end = transformSchematicPoint(transform, primitive.end);
73690
73711
  return SymbolRectangle.fromSexprPrimitives([
73691
73712
  ["start", start.x, start.y],
73692
73713
  ["end", end.x, end.y],
@@ -73694,7 +73715,7 @@ function createRectangleFromPrimitive({
73694
73715
  "stroke",
73695
73716
  [
73696
73717
  "width",
73697
- primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale6
73718
+ roundSchematicCoordinate(primitive.strokeWidth == null ? 0.254 : primitive.strokeWidth * scale7)
73698
73719
  ],
73699
73720
  ["type", primitive.isDashed ? "dash" : "default"]
73700
73721
  ],
@@ -73710,13 +73731,16 @@ function createRectangleFromPrimitive({
73710
73731
  function createTextFromPrimitive({
73711
73732
  schText,
73712
73733
  transform,
73713
- scale: scale6
73734
+ scale: scale7
73714
73735
  }) {
73715
73736
  const symbolText = new SymbolText;
73716
- const scaledPos = applyToPoint5(transform, { x: schText.x, y: schText.y });
73737
+ const scaledPos = transformSchematicPoint(transform, {
73738
+ x: schText.x,
73739
+ y: schText.y
73740
+ });
73717
73741
  symbolText.value = schText.text;
73718
73742
  symbolText.at = [scaledPos.x, scaledPos.y, 0];
73719
- const scaledFontSize = schText.fontSize * scale6;
73743
+ const scaledFontSize = roundSchematicCoordinate(schText.fontSize * scale7);
73720
73744
  const font = new TextEffectsFont2;
73721
73745
  font.size = { height: scaledFontSize, width: scaledFontSize };
73722
73746
  symbolText.effects = new TextEffects2({ font });
@@ -73736,6 +73760,9 @@ function createDrawingSubsymbol({
73736
73760
  const cy = symbolData.center?.y ?? 0;
73737
73761
  const transform = compose(createScaleMatrix(symbolScale, symbolScale), translate(-cx, -cy));
73738
73762
  for (const primitive of symbolData.primitives || []) {
73763
+ const strokeColor = primitive.color ? parseColor(primitive.color) : undefined;
73764
+ if (strokeColor?.a === 0 && !primitive.fill)
73765
+ continue;
73739
73766
  if (primitive.type === "arc") {
73740
73767
  drawingSymbol.arcs.push(createArcFromPrimitive({
73741
73768
  primitive,
@@ -73784,30 +73811,37 @@ function createGenericChipSymbolData(schematicComp, db) {
73784
73811
  const schematicPorts = db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComp.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
73785
73812
  const width = schematicComp.size?.width || 1.5;
73786
73813
  const height = schematicComp.size?.height || 1;
73814
+ const { x: cx, y: cy } = schematicComp.center;
73787
73815
  const boxPath = {
73788
73816
  type: "path",
73789
73817
  fill: true,
73790
73818
  points: [
73791
- { x: -width / 2, y: -height / 2 },
73792
- { x: width / 2, y: -height / 2 },
73793
- { x: width / 2, y: height / 2 },
73794
- { x: -width / 2, y: height / 2 },
73795
- { x: -width / 2, y: -height / 2 }
73819
+ { x: cx - width / 2, y: cy - height / 2 },
73820
+ { x: cx + width / 2, y: cy - height / 2 },
73821
+ { x: cx + width / 2, y: cy + height / 2 },
73822
+ { x: cx - width / 2, y: cy + height / 2 },
73823
+ { x: cx - width / 2, y: cy - height / 2 }
73796
73824
  ]
73797
73825
  };
73798
73826
  const ports = schematicPorts.map((port) => {
73799
- const portX = port.center.x - schematicComp.center.x;
73800
- const portY = port.center.y - schematicComp.center.y;
73801
73827
  return {
73802
- x: portX,
73803
- y: portY,
73828
+ x: port.center.x,
73829
+ y: port.center.y,
73804
73830
  labels: [port.display_pin_label || `${port.pin_number || 1}`],
73805
73831
  pinNumber: port.pin_number || 1
73806
73832
  };
73807
73833
  });
73834
+ const { primitives } = buildSymbolDataFromSchematicPrimitives({
73835
+ circuitJson: db.toArray(),
73836
+ schematicComponentId: schematicComp.schematic_component_id,
73837
+ schematicSymbol: {
73838
+ center: schematicComp.center,
73839
+ size: { width, height }
73840
+ }
73841
+ });
73808
73842
  return {
73809
- center: { x: 0, y: 0 },
73810
- primitives: [boxPath],
73843
+ center: schematicComp.center,
73844
+ primitives: [boxPath, ...primitives],
73811
73845
  ports,
73812
73846
  size: { width, height }
73813
73847
  };
@@ -73923,7 +73957,7 @@ function calculatePinPosition({
73923
73957
  dy = portY - cy;
73924
73958
  }
73925
73959
  const scaleMatrix = createScaleMatrix2(symbolScale, symbolScale);
73926
- const scaled = applyToPoint6(scaleMatrix, { x: dx, y: dy });
73960
+ const scaled = applyToPoint2(scaleMatrix, { x: dx, y: dy });
73927
73961
  let isHorizontalPin;
73928
73962
  if (isChip && size) {
73929
73963
  const halfWidth = size.width / 2;
@@ -74047,7 +74081,7 @@ function createPinSubsymbol({
74047
74081
  schematicComponent,
74048
74082
  schematicPorts,
74049
74083
  sourcePorts,
74050
- c2kMatSchScale
74084
+ c2kMatSch
74051
74085
  }) {
74052
74086
  const pinSymbol = new SchematicSymbol3({
74053
74087
  libraryId: `${libId.split(":")[1]}_1_1`
@@ -74061,6 +74095,7 @@ function createPinSubsymbol({
74061
74095
  sourcePorts
74062
74096
  });
74063
74097
  const circuitPinNumbers = validateInferredPinNumbers(symbolData, inferredPinNumbers);
74098
+ const origin = schematicComponent ? applyToPoint3(c2kMatSch, schematicComponent.center) : { x: 0, y: 0 };
74064
74099
  for (const [i, port] of symbolData.ports.entries()) {
74065
74100
  const pin = new SymbolPin;
74066
74101
  pin.pinElectricalType = "passive";
@@ -74073,9 +74108,17 @@ function createPinSubsymbol({
74073
74108
  portIndex: i,
74074
74109
  schematicComponent,
74075
74110
  schematicPorts,
74076
- c2kMatSchScale
74111
+ c2kMatSchScale: c2kMatSch.a
74077
74112
  });
74078
- pin.at = [x, y, angle];
74113
+ const sheetPosition = !isChip && schematicComponent ? applyToPoint3(c2kMatSch, {
74114
+ x: (port.x ?? 0) + (schematicComponent.center.x - (symbolData.center?.x ?? 0)),
74115
+ y: (port.y ?? 0) + (schematicComponent.center.y - (symbolData.center?.y ?? 0))
74116
+ }) : { x: origin.x + x, y: origin.y - y };
74117
+ pin.at = [
74118
+ (toSchematicInternalUnits(sheetPosition.x) - toSchematicInternalUnits(origin.x)) / 1e4,
74119
+ (toSchematicInternalUnits(origin.y) - toSchematicInternalUnits(sheetPosition.y)) / 1e4,
74120
+ angle
74121
+ ];
74079
74122
  pin.length = isChip ? CHIP_PIN_LENGTH : CUSTOM_SYMBOL_PIN_LENGTH;
74080
74123
  const nameFont = new TextEffectsFont4;
74081
74124
  nameFont.size = { height: 1.27, width: 1.27 };
@@ -74097,22 +74140,20 @@ function createPinSubsymbol({
74097
74140
  return pinSymbol;
74098
74141
  }
74099
74142
  var AddLibrarySymbolsStage = class extends ConverterStage {
74100
- processedSymbolNames = /* @__PURE__ */ new Set;
74101
- pinNumberingsByLibId = /* @__PURE__ */ new Map;
74143
+ symbolDefinitionsByLibId = /* @__PURE__ */ new Map;
74144
+ reservedLibraryIds = /* @__PURE__ */ new Set;
74145
+ usedLibraryIds = /* @__PURE__ */ new Set;
74102
74146
  _step() {
74103
74147
  const { kicadSch, db } = this.ctx;
74104
74148
  const libSymbols = new LibSymbols;
74105
74149
  const librarySymbols = [];
74106
- this.processedSymbolNames = /* @__PURE__ */ new Set;
74107
- this.pinNumberingsByLibId = /* @__PURE__ */ new Map;
74150
+ this.symbolDefinitionsByLibId.clear();
74108
74151
  this.ctx.schematicComponentLibraryIds = /* @__PURE__ */ new Map;
74109
- const schematicComponents = db.schematic_component.list();
74110
- for (const schematicComponent of schematicComponents) {
74111
- const libSymbol = this.createLibrarySymbolForComponent(schematicComponent);
74112
- if (libSymbol) {
74113
- librarySymbols.push(libSymbol);
74114
- }
74115
- }
74152
+ const componentSymbols = db.schematic_component.list().flatMap((component) => {
74153
+ const symbol = this.createLibrarySymbolForComponent(component);
74154
+ return symbol ? [{ component, symbol }] : [];
74155
+ });
74156
+ const netLabelSymbols = [];
74116
74157
  const netLabels = db.schematic_net_label?.list?.() || [];
74117
74158
  const railLibraryIds = /* @__PURE__ */ new Set;
74118
74159
  for (const netLabel of netLabels) {
@@ -74125,10 +74166,32 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74125
74166
  isGround: sourceNet?.is_ground ?? false
74126
74167
  });
74127
74168
  if (libSymbol) {
74128
- librarySymbols.push(libSymbol);
74169
+ netLabelSymbols.push(libSymbol);
74129
74170
  railLibraryIds.add(netLabel.symbol_name);
74130
74171
  }
74131
74172
  }
74173
+ this.reservedLibraryIds = /* @__PURE__ */ new Set([
74174
+ ...componentSymbols.map(({ symbol }) => symbol.libraryId),
74175
+ ...netLabelSymbols.map((symbol) => symbol.libraryId)
74176
+ ]);
74177
+ this.usedLibraryIds = new Set(netLabelSymbols.map((symbol) => symbol.libraryId));
74178
+ const emittedLibraryIds = /* @__PURE__ */ new Set;
74179
+ for (const { component, symbol } of componentSymbols) {
74180
+ const originalId = symbol.libraryId;
74181
+ const libraryId = this.getLibraryIdForSymbolDefinition(originalId, symbol);
74182
+ this.ctx.schematicComponentLibraryIds.set(component.schematic_component_id, libraryId);
74183
+ if (emittedLibraryIds.has(libraryId))
74184
+ continue;
74185
+ emittedLibraryIds.add(libraryId);
74186
+ if (libraryId !== originalId) {
74187
+ symbol.libraryId = libraryId;
74188
+ for (const unit of symbol.subSymbols) {
74189
+ unit.libraryId = libraryId.split(":")[1] + unit.libraryId.slice(originalId.split(":")[1].length);
74190
+ }
74191
+ }
74192
+ librarySymbols.push(symbol);
74193
+ }
74194
+ librarySymbols.push(...netLabelSymbols);
74132
74195
  libSymbols.symbols = librarySymbols;
74133
74196
  if (kicadSch) {
74134
74197
  kicadSch.libSymbols = libSymbols;
@@ -74210,39 +74273,34 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74210
74273
  referencePrefix: getReferencePrefixForComponent(sourceComp),
74211
74274
  symbolScale: this.ctx.kicadSchematicScaleFactor
74212
74275
  };
74213
- const librarySymbol = this.createLibrarySymbol({
74214
- libId: libraryId,
74215
- ...librarySymbolOptions
74216
- });
74217
- const pinNumberingLibId = this.getLibraryIdForPinNumbering(libraryId, librarySymbol);
74218
- if (pinNumberingLibId === libraryId)
74219
- return librarySymbol;
74220
- this.ctx.schematicComponentLibraryIds.set(schematicComponent.schematic_component_id, pinNumberingLibId);
74221
74276
  return this.createLibrarySymbol({
74222
- libId: pinNumberingLibId,
74277
+ libId: libraryId,
74223
74278
  ...librarySymbolOptions
74224
74279
  });
74225
74280
  }
74226
- getLibraryIdForPinNumbering(libId, librarySymbol) {
74227
- const pinNumbering = librarySymbol.subSymbols.flatMap((subSymbol) => subSymbol.pins.map((pin) => pin.numberString)).join(",");
74228
- const numberings = this.pinNumberingsByLibId.get(libId) ?? [];
74229
- this.pinNumberingsByLibId.set(libId, numberings);
74230
- let index = numberings.indexOf(pinNumbering);
74231
- if (index === -1) {
74232
- numberings.push(pinNumbering);
74233
- index = numberings.length - 1;
74281
+ getLibraryIdForSymbolDefinition(libId, librarySymbol) {
74282
+ const definition = librarySymbol.getString();
74283
+ const definitions = this.symbolDefinitionsByLibId.get(libId) ?? /* @__PURE__ */ new Map;
74284
+ this.symbolDefinitionsByLibId.set(libId, definitions);
74285
+ const existingId = definitions.get(definition);
74286
+ if (existingId)
74287
+ return existingId;
74288
+ let resolvedId = libId;
74289
+ let suffix = 2;
74290
+ if (this.usedLibraryIds.has(resolvedId)) {
74291
+ do {
74292
+ resolvedId = `${libId}_${suffix++}`;
74293
+ } while (this.reservedLibraryIds.has(resolvedId) || this.usedLibraryIds.has(resolvedId));
74234
74294
  }
74235
- return index === 0 ? libId : `${libId}_${index + 1}`;
74295
+ this.usedLibraryIds.add(resolvedId);
74296
+ definitions.set(definition, resolvedId);
74297
+ return resolvedId;
74236
74298
  }
74237
74299
  createLibrarySymbolFromSchematicSymbol(schematicComponent, sourceComp, symbolContext) {
74238
74300
  const { cadComponent, schematicSymbol, schematicSymbolId, libraryId } = symbolContext;
74239
74301
  if (!schematicSymbol || !schematicSymbolId) {
74240
74302
  return null;
74241
74303
  }
74242
- if (this.processedSymbolNames.has(libraryId)) {
74243
- return null;
74244
- }
74245
- this.processedSymbolNames.add(libraryId);
74246
74304
  const symbolData = buildSymbolDataFromSchematicPrimitives({
74247
74305
  circuitJson: this.ctx.circuitJson,
74248
74306
  schematicSymbolId,
@@ -74359,7 +74417,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
74359
74417
  schematicComponent,
74360
74418
  schematicPorts: this.ctx.db.schematic_port.list(),
74361
74419
  sourcePorts: this.ctx.db.source_port.list(),
74362
- c2kMatSchScale: symbolScale
74420
+ c2kMatSch: this.ctx.c2kMatSch
74363
74421
  });
74364
74422
  symbol.subSymbols.push(pinSymbol);
74365
74423
  symbol._sxEmbeddedFonts = new EmbeddedFonts(false);
@@ -74445,6 +74503,28 @@ var getTextJustificationFromAnchor = (anchor) => {
74445
74503
  return;
74446
74504
  return { horizontal, vertical };
74447
74505
  };
74506
+ function createInlineTraceLabel({
74507
+ text,
74508
+ db,
74509
+ transform,
74510
+ fontSize
74511
+ }) {
74512
+ if (!text.source_trace_id || !db.source_trace.get(text.source_trace_id)) {
74513
+ return;
74514
+ }
74515
+ const { x, y } = applyToPoint4(transform, text.position);
74516
+ const effects = createTextEffects(fontSize, false);
74517
+ effects.justify = new TextEffectsJustify2({
74518
+ horizontal: getTextJustificationFromAnchor(text.anchor)?.horizontal,
74519
+ vertical: "bottom"
74520
+ });
74521
+ return new Label({
74522
+ value: text.text,
74523
+ at: [x, y, (-(text.rotation ?? 0) % 360 + 360) % 360],
74524
+ effects,
74525
+ uuid: crypto.randomUUID()
74526
+ });
74527
+ }
74448
74528
  var DEFAULT_SECTION_TEXT_SIZE_MM = 1.27;
74449
74529
  var DEFAULT_SECTION_LINE_COLOR = { r: 0, g: 0, b: 0, a: 1 };
74450
74530
  var DEFAULT_SECTION_TEXT_COLOR = { r: 0, g: 0, b: 0, a: 1 };
@@ -74475,9 +74555,9 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74475
74555
  const arcs = kicadSch.arcs || [];
74476
74556
  for (const arc of schematicArcs) {
74477
74557
  const points = getSchematicArcPoints(arc);
74478
- const start = applyToPoint7(this.ctx.c2kMatSch, points.start);
74479
- const mid = applyToPoint7(this.ctx.c2kMatSch, points.mid);
74480
- const end = applyToPoint7(this.ctx.c2kMatSch, points.end);
74558
+ const start = applyToPoint5(this.ctx.c2kMatSch, points.start);
74559
+ const mid = applyToPoint5(this.ctx.c2kMatSch, points.mid);
74560
+ const end = applyToPoint5(this.ctx.c2kMatSch, points.end);
74481
74561
  const stroke = new Stroke3;
74482
74562
  stroke.width = (arc.stroke_width ?? 0) * (this.ctx.kicadSchematicScaleFactor ?? 1);
74483
74563
  stroke.type = arc.is_dashed ? "dash" : "default";
@@ -74498,11 +74578,11 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74498
74578
  if (schematicLines.length > 0) {
74499
74579
  const polylines = kicadSch.polylines || [];
74500
74580
  for (const line of schematicLines) {
74501
- const start = applyToPoint7(this.ctx.c2kMatSch, {
74581
+ const start = applyToPoint5(this.ctx.c2kMatSch, {
74502
74582
  x: line.x1,
74503
74583
  y: line.y1
74504
74584
  });
74505
- const end = applyToPoint7(this.ctx.c2kMatSch, {
74585
+ const end = applyToPoint5(this.ctx.c2kMatSch, {
74506
74586
  x: line.x2,
74507
74587
  y: line.y2
74508
74588
  });
@@ -74532,7 +74612,7 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74532
74612
  stroke.color = preserveStandaloneGraphics ? parseColor(path.stroke_color ?? "") ?? DEFAULT_SECTION_LINE_COLOR : DEFAULT_SECTION_LINE_COLOR;
74533
74613
  polylines.push(new Polyline({
74534
74614
  points: new Pts2(path.points.map((point) => {
74535
- const transformed = applyToPoint7(this.ctx.c2kMatSch, point);
74615
+ const transformed = applyToPoint5(this.ctx.c2kMatSch, point);
74536
74616
  return new Xy2(transformed.x, transformed.y);
74537
74617
  })),
74538
74618
  stroke,
@@ -74546,11 +74626,11 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74546
74626
  for (const rect of schematicRects) {
74547
74627
  const halfWidth = rect.width / 2;
74548
74628
  const halfHeight = rect.height / 2;
74549
- const firstCorner = applyToPoint7(this.ctx.c2kMatSch, {
74629
+ const firstCorner = applyToPoint5(this.ctx.c2kMatSch, {
74550
74630
  x: rect.center.x - halfWidth,
74551
74631
  y: rect.center.y - halfHeight
74552
74632
  });
74553
- const secondCorner = applyToPoint7(this.ctx.c2kMatSch, {
74633
+ const secondCorner = applyToPoint5(this.ctx.c2kMatSch, {
74554
74634
  x: rect.center.x + halfWidth,
74555
74635
  y: rect.center.y + halfHeight
74556
74636
  });
@@ -74581,14 +74661,25 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74581
74661
  }
74582
74662
  if (schematicTexts.length > 0) {
74583
74663
  const texts = kicadSch.texts || [];
74664
+ const labels = kicadSch.labels;
74584
74665
  for (const text of schematicTexts) {
74666
+ const inlineLabel = createInlineTraceLabel({
74667
+ text,
74668
+ db,
74669
+ transform: this.ctx.c2kMatSch,
74670
+ fontSize: DEFAULT_SECTION_TEXT_SIZE_MM
74671
+ });
74672
+ if (inlineLabel) {
74673
+ labels.push(inlineLabel);
74674
+ continue;
74675
+ }
74585
74676
  const isInlineTraceText = "source_trace_id" in text;
74586
74677
  const preserveText = preserveStandaloneGraphics && !isInlineTraceText;
74587
74678
  let sourceY = text.position?.y ?? 0;
74588
74679
  if (!isInlineTraceText && !preserveText && text.position?.y !== undefined && text.position.y < 2) {
74589
74680
  sourceY = text.position.y - DEFAULT_SECTION_TEXT_PADDING_Y_MM;
74590
74681
  }
74591
- const position = applyToPoint7(this.ctx.c2kMatSch, {
74682
+ const position = applyToPoint5(this.ctx.c2kMatSch, {
74592
74683
  x: (text.position?.x ?? 0) + (isInlineTraceText || preserveText ? 0 : DEFAULT_SECTION_TEXT_PADDING_X_MM),
74593
74684
  y: sourceY
74594
74685
  });
@@ -74600,7 +74691,7 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74600
74691
  const effects = new TextEffects5({
74601
74692
  font,
74602
74693
  hiddenText: false,
74603
- justify: justify ? new TextEffectsJustify2(justify) : undefined
74694
+ justify: justify ? new TextEffectsJustify3(justify) : undefined
74604
74695
  });
74605
74696
  const schematicText = new SchematicText({
74606
74697
  value: text.text || "",
@@ -74612,6 +74703,7 @@ var AddSchematicGraphicsStage = class extends ConverterStage {
74612
74703
  texts.push(schematicText);
74613
74704
  }
74614
74705
  kicadSch.texts = texts;
74706
+ kicadSch.labels = labels;
74615
74707
  }
74616
74708
  this.finished = true;
74617
74709
  }
@@ -74667,7 +74759,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74667
74759
  x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
74668
74760
  y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
74669
74761
  };
74670
- const anchorInKicad = applyToPoint8(this.ctx.c2kMatSch, anchorPoint);
74762
+ const anchorInKicad = applyToPoint6(this.ctx.c2kMatSch, anchorPoint);
74671
74763
  let { x, y } = anchorInKicad;
74672
74764
  const symbolData = symbols4[symbolName];
74673
74765
  const port = symbolData?.ports?.[0];
@@ -74755,7 +74847,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74755
74847
  createGlobalLabel(netLabel, labelText) {
74756
74848
  if (!this.ctx.c2kMatSch || !this.ctx.kicadSch)
74757
74849
  return null;
74758
- const { x, y } = applyToPoint8(this.ctx.c2kMatSch, {
74850
+ const { x, y } = applyToPoint6(this.ctx.c2kMatSch, {
74759
74851
  x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
74760
74852
  y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
74761
74853
  });
@@ -74785,7 +74877,7 @@ var AddSchematicNetLabelsStage = class extends ConverterStage {
74785
74877
  const orientation = orientationMap[anchorSide] || orientationMap["left"];
74786
74878
  const effects = this.createTextEffects(1.27, false);
74787
74879
  if (Object.keys(orientation.justify).length > 0) {
74788
- effects.justify = new TextEffectsJustify3(orientation.justify);
74880
+ effects.justify = new TextEffectsJustify4(orientation.justify);
74789
74881
  }
74790
74882
  const globalLabel = new GlobalLabel({
74791
74883
  value: labelText,
@@ -74841,7 +74933,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
74841
74933
  } = symbolContext;
74842
74934
  if (!this.ctx.c2kMatSch)
74843
74935
  continue;
74844
- const { x, y } = applyToPoint9(this.ctx.c2kMatSch, {
74936
+ const { x, y } = applyToPoint7(this.ctx.c2kMatSch, {
74845
74937
  x: schematicComponent.center.x,
74846
74938
  y: schematicComponent.center.y
74847
74939
  });
@@ -75032,11 +75124,11 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
75032
75124
  value
75033
75125
  }) {
75034
75126
  const c2kMatSch = this.ctx.c2kMatSch;
75035
- const symbolKicadPos = applyToPoint9(c2kMatSch, {
75127
+ const symbolKicadPos = applyToPoint7(c2kMatSch, {
75036
75128
  x: schematicComponent.center.x,
75037
75129
  y: schematicComponent.center.y
75038
75130
  });
75039
- const bodyEdge = applyToPoint9(c2kMatSch, {
75131
+ const bodyEdge = applyToPoint7(c2kMatSch, {
75040
75132
  x: schematicComponent.center.x,
75041
75133
  y: schematicComponent.center.y + (schematicComponent.size?.height || 1) / 2
75042
75134
  });
@@ -75119,11 +75211,11 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
75119
75211
  }
75120
75212
  }
75121
75213
  const symbolCenter = symbol.center || { x: 0, y: 0 };
75122
- const refTextPos = refTextPrimitive ? applyToPoint9(c2kMatSch, {
75214
+ const refTextPos = refTextPrimitive ? applyToPoint7(c2kMatSch, {
75123
75215
  x: schematicComponent.center.x + (refTextPrimitive.x - symbolCenter.x),
75124
75216
  y: schematicComponent.center.y + (refTextPrimitive.y - symbolCenter.y)
75125
75217
  }) : { x: symbolKicadPos.x, y: referenceAboveBodyY };
75126
- const valTextPos = valTextPrimitive ? applyToPoint9(c2kMatSch, {
75218
+ const valTextPos = valTextPrimitive ? applyToPoint7(c2kMatSch, {
75127
75219
  x: schematicComponent.center.x + (valTextPrimitive.x - symbolCenter.x),
75128
75220
  y: schematicComponent.center.y + (valTextPrimitive.y - symbolCenter.y)
75129
75221
  }) : { x: symbolKicadPos.x, y: valueBelowBodyY };
@@ -75138,7 +75230,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
75138
75230
  if (!text)
75139
75231
  return;
75140
75232
  return {
75141
- position: applyToPoint9(this.ctx.c2kMatSch, text.position),
75233
+ position: applyToPoint7(this.ctx.c2kMatSch, text.position),
75142
75234
  justify: getTextJustificationFromAnchor(text.anchor)
75143
75235
  };
75144
75236
  }
@@ -75229,7 +75321,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
75229
75321
  } = {}) {
75230
75322
  const font = new TextEffectsFont7;
75231
75323
  font.size = { height: size, width: size };
75232
- const justifyObj = justify ? new TextEffectsJustify4(justify) : undefined;
75324
+ const justifyObj = justify ? new TextEffectsJustify5(justify) : undefined;
75233
75325
  const effects = new TextEffects7({
75234
75326
  font,
75235
75327
  hiddenText: hide,
@@ -75277,11 +75369,11 @@ var AddSchematicTracesStage = class extends ConverterStage {
75277
75369
  if (!this.ctx.c2kMatSch) {
75278
75370
  throw new Error("Schematic transformation matrix not initialized in context");
75279
75371
  }
75280
- const from = applyToPoint10(this.ctx.c2kMatSch, {
75372
+ const from = applyToPoint8(this.ctx.c2kMatSch, {
75281
75373
  x: edge.from.x,
75282
75374
  y: edge.from.y
75283
75375
  });
75284
- const to = applyToPoint10(this.ctx.c2kMatSch, {
75376
+ const to = applyToPoint8(this.ctx.c2kMatSch, {
75285
75377
  x: edge.to.x,
75286
75378
  y: edge.to.y
75287
75379
  });
@@ -75302,7 +75394,7 @@ var AddSchematicTracesStage = class extends ConverterStage {
75302
75394
  if (!this.ctx.c2kMatSch) {
75303
75395
  throw new Error("Schematic transformation matrix not initialized in context");
75304
75396
  }
75305
- const { x, y } = applyToPoint10(this.ctx.c2kMatSch, {
75397
+ const { x, y } = applyToPoint8(this.ctx.c2kMatSch, {
75306
75398
  x: junction.x,
75307
75399
  y: junction.y
75308
75400
  });
@@ -75711,7 +75803,7 @@ var getCopperPourNetInfo = (pour, ctx) => {
75711
75803
  };
75712
75804
  var convertPointsToKicadXy = (points, c2kMatPcb) => {
75713
75805
  return (points ?? []).map((point) => {
75714
- const transformedPoint = applyToPoint11(c2kMatPcb, point);
75806
+ const transformedPoint = applyToPoint9(c2kMatPcb, point);
75715
75807
  return new Xy4(transformedPoint.x, transformedPoint.y);
75716
75808
  });
75717
75809
  };
@@ -75760,7 +75852,7 @@ var getRectRingPoints = (pour, c2kMatPcb) => {
75760
75852
  { x: halfWidth, y: -halfHeight },
75761
75853
  { x: halfWidth, y: halfHeight },
75762
75854
  { x: -halfWidth, y: halfHeight }
75763
- ].map((corner) => applyToPoint11(cornerTransform, corner));
75855
+ ].map((corner) => applyToPoint9(cornerTransform, corner));
75764
75856
  return convertPointsToKicadXy(corners, c2kMatPcb);
75765
75857
  };
75766
75858
  var getPolygonRingPoints = (pour, c2kMatPcb) => removeRepeatedClosingPoint(removeConsecutiveDuplicatePoints(rotateRingToStartAtTopRight(convertPointsToKicadXy(pour.points, c2kMatPcb))));
@@ -75932,7 +76024,7 @@ var AddKeepoutsStage = class extends ConverterStage {
75932
76024
  rawPoints = keepout.outline;
75933
76025
  }
75934
76026
  const kicadPoints = rawPoints.map((p) => {
75935
- const t = applyToPoint12(c2kMatPcb, p);
76027
+ const t = applyToPoint10(c2kMatPcb, p);
75936
76028
  return new Xy5(t.x, t.y);
75937
76029
  });
75938
76030
  const zone = new Zone2({
@@ -76043,6 +76135,28 @@ var AddNetsStage = class extends ConverterStage {
76043
76135
  this.ctx.pcbNetMap.set(connectivityKey, netInfo);
76044
76136
  netNumber++;
76045
76137
  }
76138
+ const connectivityMap = getFullConnectivityMapFromCircuitJson(this.input);
76139
+ const netByConnection = /* @__PURE__ */ new Map;
76140
+ for (const element of this.input) {
76141
+ const connectivityKey = "subcircuit_connectivity_map_key" in element && element.subcircuit_connectivity_map_key || (element.type === "source_net" ? element.source_net_id : undefined);
76142
+ if (!connectivityKey)
76143
+ continue;
76144
+ const netInfo = this.ctx.pcbNetMap.get(connectivityKey);
76145
+ if (!netInfo)
76146
+ continue;
76147
+ const elementId = getElementId(element);
76148
+ this.ctx.pcbNetMap.set(elementId, netInfo);
76149
+ const connection = connectivityMap.getNetConnectedToId(elementId);
76150
+ if (connection && !netByConnection.has(connection)) {
76151
+ netByConnection.set(connection, netInfo);
76152
+ }
76153
+ }
76154
+ for (const [elementId, connection] of Object.entries(connectivityMap.idToNetMap)) {
76155
+ const netInfo = netByConnection.get(connection);
76156
+ if (netInfo && !this.ctx.pcbNetMap.has(elementId)) {
76157
+ this.ctx.pcbNetMap.set(elementId, netInfo);
76158
+ }
76159
+ }
76046
76160
  kicadPcb.nets = nets;
76047
76161
  this.finished = true;
76048
76162
  }
@@ -76050,6 +76164,20 @@ var AddNetsStage = class extends ConverterStage {
76050
76164
  return this.ctx.kicadPcb;
76051
76165
  }
76052
76166
  };
76167
+ function applyInferredFootprintType(footprint) {
76168
+ if (footprint.attr?.type)
76169
+ return;
76170
+ let type;
76171
+ if (footprint.fpPads.some((pad) => pad.padType === "thru_hole")) {
76172
+ type = "through_hole";
76173
+ } else if (footprint.fpPads.some((pad) => pad.padType === "smd")) {
76174
+ type = "smd";
76175
+ }
76176
+ if (type) {
76177
+ footprint.attr ??= new FootprintAttr;
76178
+ footprint.attr.type = type;
76179
+ }
76180
+ }
76053
76181
  var MODEL_CDN_BASE_URL = "https://modelcdn.tscircuit.com/jscad_models";
76054
76182
  var KICAD_FP_VERSION = 20240108;
76055
76183
  var KICAD_FP_GENERATOR = "pcbnew";
@@ -76142,16 +76270,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
76142
76270
  if (!footprint.embeddedFonts) {
76143
76271
  footprint.embeddedFonts = new EmbeddedFonts4(false);
76144
76272
  }
76145
- if (!footprint.attr) {
76146
- const attr = new FootprintAttr;
76147
- const padTypes = (footprint.fpPads ?? []).map((pad) => pad.padType);
76148
- if (padTypes.some((padType) => padType.includes("thru_hole"))) {
76149
- attr.type = "through_hole";
76150
- } else if (padTypes.some((padType) => padType.includes("smd"))) {
76151
- attr.type = "smd";
76152
- }
76153
- footprint.attr = attr;
76154
- }
76273
+ applyInferredFootprintType(footprint);
76155
76274
  footprint.uuid = undefined;
76156
76275
  footprint.path = undefined;
76157
76276
  footprint.sheetfile = undefined;
@@ -76515,7 +76634,7 @@ function convertSilkscreenCircles(silkscreenCircles, { componentCenter, componen
76515
76634
  const fpCircles = [];
76516
76635
  const rotationMatrix = componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : identity();
76517
76636
  for (const circle of silkscreenCircles) {
76518
- const relativeCenter = applyToPoint13(rotationMatrix, {
76637
+ const relativeCenter = applyToPoint11(rotationMatrix, {
76519
76638
  x: circle.center.x - componentCenter.x,
76520
76639
  y: -(circle.center.y - componentCenter.y)
76521
76640
  });
@@ -76614,37 +76733,83 @@ function convertNoteRects(noteRects, componentCenter) {
76614
76733
  }
76615
76734
  return fpRects;
76616
76735
  }
76617
- function convertCourtyardRects(courtyardRects, componentCenter) {
76736
+ function rotateCenter(point, degrees) {
76737
+ switch ((degrees % 360 + 360) % 360) {
76738
+ case 0:
76739
+ return point;
76740
+ case 90:
76741
+ return { x: -point.y, y: point.x };
76742
+ case 180:
76743
+ return { x: -point.x, y: -point.y };
76744
+ case 270:
76745
+ return { x: point.y, y: -point.x };
76746
+ default:
76747
+ return applyToPoint12(rotate3(degrees * Math.PI / 180), point);
76748
+ }
76749
+ }
76750
+ function convertCourtyardRects({
76751
+ courtyardRects,
76752
+ componentCenter,
76753
+ componentRotation = 0
76754
+ }) {
76618
76755
  const fpRects = [];
76756
+ const fpPolys = [];
76757
+ const toLocal = compose4(rotate3(componentRotation * Math.PI / 180), scale2(1, -1), translate4(-componentCenter.x, -componentCenter.y));
76619
76758
  for (const rect of courtyardRects) {
76620
- const relX = rect.center.x - componentCenter.x;
76621
- const relY = -(rect.center.y - componentCenter.y);
76622
76759
  const halfW = rect.width / 2;
76623
76760
  const halfH = rect.height / 2;
76624
- const layerMap = {
76625
- top: "F.CrtYd",
76626
- bottom: "B.CrtYd"
76627
- };
76628
- const kicadLayer = layerMap[rect.layer] || "F.CrtYd";
76629
- const fpRect = new FpRect3({
76630
- start: { x: relX - halfW, y: relY - halfH },
76631
- end: { x: relX + halfW, y: relY + halfH },
76632
- layer: kicadLayer,
76633
- stroke: new Stroke9,
76634
- fill: false
76635
- });
76636
- if (fpRect.stroke) {
76637
- fpRect.stroke.width = 0.05;
76638
- fpRect.stroke.type = "default";
76761
+ const rotation = rect.ccw_rotation ?? 0;
76762
+ const layer = rect.layer === "bottom" ? "B.CrtYd" : "F.CrtYd";
76763
+ const stroke = new Stroke9;
76764
+ stroke.width = 0.05;
76765
+ stroke.type = "default";
76766
+ const color = rect.color ? parseColor(rect.color) : undefined;
76767
+ if (color)
76768
+ stroke.color = color;
76769
+ if ((rotation - componentRotation) % 90 === 0) {
76770
+ const center = rotateCenter({
76771
+ x: rect.center.x - componentCenter.x,
76772
+ y: -(rect.center.y - componentCenter.y)
76773
+ }, componentRotation);
76774
+ const swapAxes = (rotation - componentRotation) % 180 !== 0;
76775
+ const localHalfW = swapAxes ? halfH : halfW;
76776
+ const localHalfH = swapAxes ? halfW : halfH;
76777
+ fpRects.push(new FpRect3({
76778
+ start: {
76779
+ x: center.x - localHalfW,
76780
+ y: center.y - localHalfH
76781
+ },
76782
+ end: {
76783
+ x: center.x + localHalfW,
76784
+ y: center.y + localHalfH
76785
+ },
76786
+ layer,
76787
+ stroke,
76788
+ fill: false
76789
+ }));
76790
+ } else {
76791
+ const fromRectCenter = compose4(translate4(rect.center.x, rect.center.y), rotate3(rotation * Math.PI / 180));
76792
+ const points = [
76793
+ { x: -halfW, y: -halfH },
76794
+ { x: halfW, y: -halfH },
76795
+ { x: halfW, y: halfH },
76796
+ { x: -halfW, y: halfH }
76797
+ ].map((point) => applyToPoint12(toLocal, applyToPoint12(fromRectCenter, point)));
76798
+ fpPolys.push(new FpPoly({
76799
+ points,
76800
+ layer,
76801
+ stroke,
76802
+ fill: false,
76803
+ uuid: generateDeterministicUuid(rect.pcb_courtyard_rect_id)
76804
+ }));
76639
76805
  }
76640
- fpRects.push(fpRect);
76641
76806
  }
76642
- return fpRects;
76807
+ return { fpRects, fpPolys };
76643
76808
  }
76644
76809
  function convertCourtyardOutlines(params2) {
76645
76810
  const { courtyardOutlines, componentCenter, componentRotation = 0 } = params2;
76646
76811
  const fpPolys = [];
76647
- const cj2kicadMatrix = compose4(componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale2(1, -1), translate4(-componentCenter.x, -componentCenter.y));
76812
+ const cj2kicadMatrix = compose5(componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale3(1, -1), translate5(-componentCenter.x, -componentCenter.y));
76648
76813
  for (const outline of courtyardOutlines) {
76649
76814
  if (!outline.outline || outline.outline.length < 2)
76650
76815
  continue;
@@ -76654,10 +76819,10 @@ function convertCourtyardOutlines(params2) {
76654
76819
  };
76655
76820
  const kicadLayer = layerMap[outline.layer] || "F.CrtYd";
76656
76821
  const xyPoints = outline.outline.map((point) => {
76657
- const transformedPoint = applyToPoint14(cj2kicadMatrix, point);
76822
+ const transformedPoint = applyToPoint13(cj2kicadMatrix, point);
76658
76823
  return new Xy6(transformedPoint.x, transformedPoint.y);
76659
76824
  });
76660
- const fpPoly = new FpPoly;
76825
+ const fpPoly = new FpPoly2;
76661
76826
  fpPoly.points = new Pts6(xyPoints);
76662
76827
  fpPoly.layer = kicadLayer;
76663
76828
  fpPoly.fill = false;
@@ -76675,7 +76840,7 @@ function createPcbTextJustify({
76675
76840
  kicadLayer,
76676
76841
  isMirrored
76677
76842
  }) {
76678
- const justify = new TextEffectsJustify5;
76843
+ const justify = new TextEffectsJustify6;
76679
76844
  switch (anchorAlignment) {
76680
76845
  case "top_center":
76681
76846
  justify.vertical = "top";
@@ -76727,8 +76892,8 @@ function createFpTextFromCircuitJson({
76727
76892
  }
76728
76893
  const relativeX = textElement.anchor_position.x - componentCenter.x;
76729
76894
  const relativeY = -(textElement.anchor_position.y - componentCenter.y);
76730
- const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity2();
76731
- const rotatedPos = applyToPoint15(rotationMatrix, {
76895
+ const rotationMatrix = componentRotation !== 0 ? rotate5(componentRotation * Math.PI / 180) : identity2();
76896
+ const rotatedPos = applyToPoint14(rotationMatrix, {
76732
76897
  x: relativeX,
76733
76898
  y: relativeY
76734
76899
  });
@@ -76795,7 +76960,7 @@ function convertSilkscreenTexts(params2) {
76795
76960
  }
76796
76961
  function convertSilkscreenPaths(silkscreenPaths, { componentCenter, componentRotation = 0 }) {
76797
76962
  const fpLines = [];
76798
- const rotationMatrix = componentRotation !== 0 ? rotate5(componentRotation * Math.PI / 180) : identity3();
76963
+ const rotationMatrix = componentRotation !== 0 ? rotate6(componentRotation * Math.PI / 180) : identity3();
76799
76964
  for (const path of silkscreenPaths) {
76800
76965
  if (!path.route || path.route.length < 2)
76801
76966
  continue;
@@ -76809,11 +76974,11 @@ function convertSilkscreenPaths(silkscreenPaths, { componentCenter, componentRot
76809
76974
  const endPoint = path.route[i + 1];
76810
76975
  if (!startPoint || !endPoint)
76811
76976
  continue;
76812
- const startRelative = applyToPoint16(rotationMatrix, {
76977
+ const startRelative = applyToPoint15(rotationMatrix, {
76813
76978
  x: startPoint.x - componentCenter.x,
76814
76979
  y: -(startPoint.y - componentCenter.y)
76815
76980
  });
76816
- const endRelative = applyToPoint16(rotationMatrix, {
76981
+ const endRelative = applyToPoint15(rotationMatrix, {
76817
76982
  x: endPoint.x - componentCenter.x,
76818
76983
  y: -(endPoint.y - componentCenter.y)
76819
76984
  });
@@ -76863,20 +77028,20 @@ function convertSilkscreenRects({
76863
77028
  componentCenter,
76864
77029
  componentRotation = 0
76865
77030
  }) {
76866
- const toLocal = compose5(rotate6(componentRotation * Math.PI / 180), scale3(1, -1), translate5(-componentCenter.x, -componentCenter.y));
77031
+ const toLocal = compose6(rotate7(componentRotation * Math.PI / 180), scale4(1, -1), translate6(-componentCenter.x, -componentCenter.y));
76867
77032
  return silkscreenRects.flatMap((rect) => {
76868
77033
  const hasStroke = rect.has_stroke ?? rect.stroke_width > 0;
76869
77034
  if (!hasStroke && !rect.is_filled)
76870
77035
  return [];
76871
- const fromRectCenter = compose5(translate5(rect.center.x, rect.center.y), rotate6((rect.ccw_rotation ?? 0) * Math.PI / 180));
76872
- const points = getRectanglePoints(rect).map((point) => applyToPoint17(toLocal, applyToPoint17(fromRectCenter, point)));
77036
+ const fromRectCenter = compose6(translate6(rect.center.x, rect.center.y), rotate7((rect.ccw_rotation ?? 0) * Math.PI / 180));
77037
+ const points = getRectanglePoints(rect).map((point) => applyToPoint16(toLocal, applyToPoint16(fromRectCenter, point)));
76873
77038
  const stroke = hasStroke ? new Stroke12 : undefined;
76874
77039
  if (stroke) {
76875
77040
  stroke.width = rect.stroke_width;
76876
77041
  stroke.type = rect.is_stroke_dashed ? "dash" : "default";
76877
77042
  }
76878
77043
  return [
76879
- new FpPoly2({
77044
+ new FpPoly3({
76880
77045
  points,
76881
77046
  layer: rect.layer === "bottom" ? "B.SilkS" : "F.SilkS",
76882
77047
  stroke,
@@ -76892,8 +77057,8 @@ function convertNoteTexts(params2) {
76892
77057
  for (const textElement of noteTexts) {
76893
77058
  const relX = textElement.anchor_position.x - componentCenter.x;
76894
77059
  const relY = -(textElement.anchor_position.y - componentCenter.y);
76895
- const rotationMatrix = componentRotation !== 0 ? rotate7(componentRotation * Math.PI / 180) : identity4();
76896
- const rotatedPos = applyToPoint18(rotationMatrix, { x: relX, y: relY });
77060
+ const rotationMatrix = componentRotation !== 0 ? rotate8(componentRotation * Math.PI / 180) : identity4();
77061
+ const rotatedPos = applyToPoint17(rotationMatrix, { x: relX, y: relY });
76897
77062
  const fontSize = textElement.font_size || 1;
76898
77063
  const font = new TextEffectsFont11;
76899
77064
  font.size = { width: fontSize, height: fontSize };
@@ -77007,14 +77172,15 @@ function create3DModelsFromCadComponent(cadComponent, componentCenter, options)
77007
77172
  model.offset = transform.offset;
77008
77173
  model.rotate = transform.rotation;
77009
77174
  if (cadComponent.model_unit_to_mm_scale_factor) {
77010
- const scale6 = cadComponent.model_unit_to_mm_scale_factor;
77011
- model.scale = { x: scale6, y: scale6, z: scale6 };
77175
+ const scale7 = cadComponent.model_unit_to_mm_scale_factor;
77176
+ model.scale = { x: scale7, y: scale7, z: scale7 };
77012
77177
  }
77013
77178
  models.push(model);
77014
77179
  return models;
77015
77180
  }
77016
77181
  function createSmdPadFromCircuitJson({
77017
77182
  pcbPad,
77183
+ hasSolderPaste,
77018
77184
  componentCenter,
77019
77185
  padNumber,
77020
77186
  componentRotation = 0,
@@ -77033,8 +77199,8 @@ function createSmdPadFromCircuitJson({
77033
77199
  } else {
77034
77200
  throw new Error("Pad must have either x/y coordinates or points array");
77035
77201
  }
77036
- const cj2kicadMatrix = compose6(componentRotation !== 0 ? rotate8(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale4(1, -1), translate6(-componentCenter.x, -componentCenter.y));
77037
- const rotatedPos = applyToPoint19(cj2kicadMatrix, {
77202
+ const cj2kicadMatrix = compose7(componentRotation !== 0 ? rotate9(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale5(1, -1), translate7(-componentCenter.x, -componentCenter.y));
77203
+ const rotatedPos = applyToPoint18(cj2kicadMatrix, {
77038
77204
  x: padX,
77039
77205
  y: padY
77040
77206
  });
@@ -77057,9 +77223,9 @@ function createSmdPadFromCircuitJson({
77057
77223
  ];
77058
77224
  } else if (pcbPad.shape === "polygon" && "points" in pcbPad) {
77059
77225
  const points = pcbPad.points;
77060
- const pointTransformMatrix = compose6(scale4(1, -1), translate6(-padX, -padY));
77226
+ const pointTransformMatrix = compose7(scale5(1, -1), translate7(-padX, -padY));
77061
77227
  const relativePoints = points.map((p) => {
77062
- const transformed = applyToPoint19(pointTransformMatrix, { x: p.x, y: p.y });
77228
+ const transformed = applyToPoint18(pointTransformMatrix, { x: p.x, y: p.y });
77063
77229
  return new Xy7(transformed.x, transformed.y);
77064
77230
  });
77065
77231
  const grPoly = new PadPrimitiveGrPoly;
@@ -77110,8 +77276,8 @@ function createSmdPadFromCircuitJson({
77110
77276
  size: padSize,
77111
77277
  layers: [
77112
77278
  `${padLayer}`,
77113
- ...pcbPad.is_covered_with_solder_mask ? [] : [`${padLayer === "F.Cu" ? "F" : "B"}.Paste`],
77114
- `${padLayer === "F.Cu" ? "F" : "B"}.Mask`
77279
+ ...hasSolderPaste ? [`${padLayer === "F.Cu" ? "F" : "B"}.Paste`] : [],
77280
+ ...pcbPad.is_covered_with_solder_mask ? [] : [`${padLayer === "F.Cu" ? "F" : "B"}.Mask`]
77115
77281
  ],
77116
77282
  solderMaskMargin: pcbPad.soldermask_margin,
77117
77283
  roundrectRatio: roundrect_rratio,
@@ -77147,6 +77313,7 @@ function convertSmdPads({
77147
77313
  const resolvedPadNumber = getPhysicalPinName(sourcePort) ?? (sourcePort?.pin_number != null ? String(sourcePort.pin_number) : pinHint ? pinHint.replace(/^pin/i, "") : gridHint ?? String(padNumber));
77148
77314
  const pad = createSmdPadFromCircuitJson({
77149
77315
  pcbPad,
77316
+ hasSolderPaste: ctx.db.pcb_solder_paste.list().some((paste) => paste.pcb_smtpad_id === pcbPad.pcb_smtpad_id),
77150
77317
  componentCenter,
77151
77318
  padNumber: resolvedPadNumber,
77152
77319
  componentRotation,
@@ -77171,8 +77338,8 @@ function createThruHolePadFromCircuitJson({
77171
77338
  }
77172
77339
  const relativeX = platedHole.x - componentCenter.x;
77173
77340
  const relativeY = -(platedHole.y - componentCenter.y);
77174
- const rotationMatrix = componentRotation !== 0 ? rotate9(componentRotation * Math.PI / 180) : identity5();
77175
- const rotatedPos = applyToPoint20(rotationMatrix, {
77341
+ const rotationMatrix = componentRotation !== 0 ? rotate10(componentRotation * Math.PI / 180) : identity5();
77342
+ const rotatedPos = applyToPoint19(rotationMatrix, {
77176
77343
  x: relativeX,
77177
77344
  y: relativeY
77178
77345
  });
@@ -77188,7 +77355,7 @@ function createThruHolePadFromCircuitJson({
77188
77355
  y: platedHole.hole_offset_y ?? 0
77189
77356
  };
77190
77357
  if (rawOffset.x !== 0 || rawOffset.y !== 0) {
77191
- const rotatedOffset = applyToPoint20(rotationMatrix, {
77358
+ const rotatedOffset = applyToPoint19(rotationMatrix, {
77192
77359
  x: -rawOffset.x,
77193
77360
  y: rawOffset.y
77194
77361
  });
@@ -77303,8 +77470,8 @@ function createNpthPadFromCircuitJson({
77303
77470
  }
77304
77471
  const relativeX = pcbHole.x - componentCenter.x;
77305
77472
  const relativeY = -(pcbHole.y - componentCenter.y);
77306
- const rotationMatrix = componentRotation !== 0 ? rotate10(componentRotation * Math.PI / 180) : identity6();
77307
- const rotatedPos = applyToPoint21(rotationMatrix, {
77473
+ const rotationMatrix = componentRotation !== 0 ? rotate11(componentRotation * Math.PI / 180) : identity6();
77474
+ const rotatedPos = applyToPoint20(rotationMatrix, {
77308
77475
  x: relativeX,
77309
77476
  y: relativeY
77310
77477
  });
@@ -77378,7 +77545,7 @@ function convertFabricationNotePaths(fabricationNotePaths, {
77378
77545
  componentRotation = 0
77379
77546
  }) {
77380
77547
  const fpLines = [];
77381
- const rotationMatrix = componentRotation !== 0 ? rotate11(componentRotation * Math.PI / 180) : identity7();
77548
+ const rotationMatrix = componentRotation !== 0 ? rotate12(componentRotation * Math.PI / 180) : identity7();
77382
77549
  for (const fabricationNotePath of fabricationNotePaths) {
77383
77550
  if (fabricationNotePath.route.length < 2)
77384
77551
  continue;
@@ -77388,11 +77555,11 @@ function convertFabricationNotePaths(fabricationNotePaths, {
77388
77555
  const endPoint = fabricationNotePath.route[index + 1];
77389
77556
  if (!startPoint || !endPoint)
77390
77557
  continue;
77391
- const startRelative = applyToPoint22(rotationMatrix, {
77558
+ const startRelative = applyToPoint21(rotationMatrix, {
77392
77559
  x: startPoint.x - componentCenter.x,
77393
77560
  y: -(startPoint.y - componentCenter.y)
77394
77561
  });
77395
- const endRelative = applyToPoint22(rotationMatrix, {
77562
+ const endRelative = applyToPoint21(rotationMatrix, {
77396
77563
  x: endPoint.x - componentCenter.x,
77397
77564
  y: -(endPoint.y - componentCenter.y)
77398
77565
  });
@@ -77482,12 +77649,12 @@ var AddFootprintsStage = class extends ConverterStage {
77482
77649
  const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
77483
77650
  const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
77484
77651
  const footprintName = sourceComponent ? getKicadCompatibleComponentName(sourceComponent, cadComponent) : "Unknown";
77485
- const transformedPos = applyToPoint23(c2kMatPcb, {
77652
+ const transformedPos = applyToPoint22(c2kMatPcb, {
77486
77653
  x: component.center.x,
77487
77654
  y: component.center.y
77488
77655
  });
77489
77656
  const footprintData = `footprint:${component.pcb_component_id}:${transformedPos.x},${transformedPos.y}`;
77490
- const footprint = new Footprint3({
77657
+ const footprint = new Footprint4({
77491
77658
  libraryLink: `tscircuit:${footprintName}`,
77492
77659
  layer: component.layer === "bottom" ? "B.Cu" : "F.Cu",
77493
77660
  at: [transformedPos.x, transformedPos.y, component.rotation || 0],
@@ -77565,7 +77732,12 @@ var AddFootprintsStage = class extends ConverterStage {
77565
77732
  const pcbNoteRects = this.ctx.db.pcb_note_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
77566
77733
  fpRects.push(...convertNoteRects(pcbNoteRects, component.center));
77567
77734
  const pcbCourtyardRects = this.ctx.db.pcb_courtyard_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
77568
- fpRects.push(...convertCourtyardRects(pcbCourtyardRects, component.center));
77735
+ const courtyardRects = convertCourtyardRects({
77736
+ courtyardRects: pcbCourtyardRects,
77737
+ componentCenter: component.center,
77738
+ componentRotation: component.rotation || 0
77739
+ });
77740
+ fpRects.push(...courtyardRects.fpRects);
77569
77741
  footprint.fpRects = fpRects;
77570
77742
  const pcbCourtyardOutlines = this.ctx.db.pcb_courtyard_outline?.list().filter((outline) => outline.pcb_component_id === component.pcb_component_id) || [];
77571
77743
  const fpPolys = convertCourtyardOutlines({
@@ -77573,6 +77745,7 @@ var AddFootprintsStage = class extends ConverterStage {
77573
77745
  componentCenter: component.center,
77574
77746
  componentRotation: component.rotation || 0
77575
77747
  });
77748
+ fpPolys.push(...courtyardRects.fpPolys);
77576
77749
  const pcbSilkscreenRects = this.ctx.db.pcb_silkscreen_rect?.list().filter((rect) => rect.pcb_component_id === component.pcb_component_id) || [];
77577
77750
  fpPolys.push(...convertSilkscreenRects({
77578
77751
  silkscreenRects: pcbSilkscreenRects,
@@ -77639,6 +77812,7 @@ var AddFootprintsStage = class extends ConverterStage {
77639
77812
  footprint.attr ??= new FootprintAttr3;
77640
77813
  footprint.attr.dnp = true;
77641
77814
  }
77815
+ applyInferredFootprintType(footprint);
77642
77816
  const footprints = kicadPcb.footprints;
77643
77817
  footprints.push(footprint);
77644
77818
  kicadPcb.footprints = footprints;
@@ -77713,8 +77887,8 @@ var AddTracesStage = class extends ConverterStage {
77713
77887
  if (!startPosition || !endPosition) {
77714
77888
  throw new Error(`Unable to convert pcb_trace route segment ${trace.pcb_trace_id ?? this.tracesProcessed}:${i} to KiCad segment`);
77715
77889
  }
77716
- const transformedStart = applyToPoint24(c2kMatPcb, startPosition);
77717
- const transformedEnd = applyToPoint24(c2kMatPcb, endPosition);
77890
+ const transformedStart = applyToPoint23(c2kMatPcb, startPosition);
77891
+ const transformedEnd = applyToPoint23(c2kMatPcb, endPosition);
77718
77892
  if (transformedStart.x === transformedEnd.x && transformedStart.y === transformedEnd.y) {
77719
77893
  continue;
77720
77894
  }
@@ -77795,17 +77969,27 @@ var createViaTenting = (via) => {
77795
77969
  return;
77796
77970
  return new KicadViaTenting(toKicadTentingValue(top), toKicadTentingValue(bottom));
77797
77971
  };
77972
+ var DEFAULT_VIA_OUTER_DIAMETER = 0.8;
77973
+ var DEFAULT_VIA_HOLE_DIAMETER = 0.4;
77798
77974
  var AddViasStage = class extends ConverterStage {
77799
77975
  viasProcessed = 0;
77800
- pcbVias = [];
77801
- constructor(input, ctx) {
77802
- super(input, ctx);
77803
- this.pcbVias = this.collectPcbVias();
77804
- }
77976
+ pcbVias;
77805
77977
  collectPcbVias() {
77806
- const standaloneVias = this.ctx.db.pcb_via?.list() || [];
77807
- const seenViaKeys = new Set(standaloneVias.map((via) => this.getViaDedupeKey(via)));
77978
+ const { pcbNetMap } = this.ctx;
77979
+ const standaloneVias = this.ctx.db.pcb_via.list().map((via) => ({
77980
+ ...via,
77981
+ net: pcbNetMap?.get(via.subcircuit_connectivity_map_key || via.source_net_id || via.pcb_via_id)
77982
+ }));
77983
+ const seenRouteViaKeys = /* @__PURE__ */ new Set;
77984
+ const standaloneViasByPosition = /* @__PURE__ */ new Map;
77985
+ for (const via of standaloneVias) {
77986
+ const positionKey = `${via.x}:${via.y}`;
77987
+ const viasAtPosition = standaloneViasByPosition.get(positionKey) ?? [];
77988
+ viasAtPosition.push(via);
77989
+ standaloneViasByPosition.set(positionKey, viasAtPosition);
77990
+ }
77808
77991
  const routeDefinedVias = (this.ctx.db.pcb_trace?.list() || []).flatMap((trace) => (trace.route || []).filter((point) => point.route_type === "via").map((point) => ({
77992
+ net: pcbNetMap?.get(trace.pcb_trace_id) ?? pcbNetMap?.get(trace.connection_name),
77809
77993
  x: point.x,
77810
77994
  y: point.y,
77811
77995
  outer_diameter: point.outer_diameter ?? point.via_diameter,
@@ -77818,18 +78002,45 @@ var AddViasStage = class extends ConverterStage {
77818
78002
  tented_on_top: point.tented_on_top,
77819
78003
  tented_on_bottom: point.tented_on_bottom
77820
78004
  })).filter((via) => {
77821
- const viaKey = this.getViaDedupeKey(via);
77822
- if (seenViaKeys.has(viaKey)) {
78005
+ const physicalVias = standaloneViasByPosition.get(`${via.x}:${via.y}`);
78006
+ if (physicalVias?.some((physicalVia) => {
78007
+ const sameTrace = physicalVia.pcb_trace_id !== undefined && physicalVia.pcb_trace_id === via.pcb_trace_id;
78008
+ const physicalConnection = physicalVia.net?.id ?? physicalVia.subcircuit_connectivity_map_key;
78009
+ const routeConnection = via.net?.id ?? via.subcircuit_connectivity_map_key;
78010
+ if (physicalConnection !== undefined && routeConnection !== undefined) {
78011
+ if (physicalConnection !== routeConnection)
78012
+ return false;
78013
+ } else if (!sameTrace) {
78014
+ return false;
78015
+ }
78016
+ return isRouteViaCoveredByPhysicalVia(physicalVia, via);
78017
+ })) {
77823
78018
  return false;
77824
78019
  }
77825
- seenViaKeys.add(viaKey);
78020
+ const viaKey = this.getRouteViaDedupeKey(via);
78021
+ if (viaKey !== undefined) {
78022
+ if (seenRouteViaKeys.has(viaKey))
78023
+ return false;
78024
+ seenRouteViaKeys.add(viaKey);
78025
+ }
77826
78026
  return true;
77827
78027
  }));
77828
78028
  return [...standaloneVias, ...routeDefinedVias];
77829
78029
  }
77830
- getViaDedupeKey(via) {
78030
+ getRouteViaDedupeKey(via) {
78031
+ const connectivityKey = via.net?.id ?? via.subcircuit_connectivity_map_key;
78032
+ const connection = connectivityKey !== undefined ? ["net", connectivityKey] : via.pcb_trace_id !== undefined ? ["trace", via.pcb_trace_id] : undefined;
78033
+ if (connection === undefined)
78034
+ return;
77831
78035
  const span = [...this.getKicadViaLayers(via)].sort().join(",");
77832
- return `${via.x}:${via.y}:${span}`;
78036
+ return JSON.stringify([
78037
+ via.x,
78038
+ via.y,
78039
+ span,
78040
+ connection,
78041
+ via.outer_diameter ?? DEFAULT_VIA_OUTER_DIAMETER,
78042
+ via.hole_diameter ?? DEFAULT_VIA_HOLE_DIAMETER
78043
+ ]);
77833
78044
  }
77834
78045
  getRawViaLayers(via) {
77835
78046
  if (via.layers?.length) {
@@ -77844,13 +78055,14 @@ var AddViasStage = class extends ConverterStage {
77844
78055
  return getViaLayerSpan(kicadLayers, numLayers);
77845
78056
  }
77846
78057
  _step() {
77847
- const { kicadPcb, c2kMatPcb, pcbNetMap } = this.ctx;
78058
+ const { kicadPcb, c2kMatPcb } = this.ctx;
77848
78059
  if (!kicadPcb) {
77849
78060
  throw new Error("KicadPcb instance not initialized in context");
77850
78061
  }
77851
78062
  if (!c2kMatPcb) {
77852
78063
  throw new Error("PCB transformation matrix not initialized in context");
77853
78064
  }
78065
+ this.pcbVias ??= this.collectPcbVias();
77854
78066
  if (this.viasProcessed >= this.pcbVias.length) {
77855
78067
  this.finished = true;
77856
78068
  return;
@@ -77860,70 +78072,20 @@ var AddViasStage = class extends ConverterStage {
77860
78072
  this.finished = true;
77861
78073
  return;
77862
78074
  }
77863
- const transformedPos = applyToPoint25(c2kMatPcb, {
78075
+ const transformedPos = applyToPoint24(c2kMatPcb, {
77864
78076
  x: via.x,
77865
78077
  y: via.y
77866
78078
  });
77867
- let netInfo;
77868
- if (pcbNetMap) {
77869
- let connectivityKey = via.subcircuit_connectivity_map_key;
77870
- if (!connectivityKey && via.source_net_id) {
77871
- const sourceNet = this.ctx.db.source_net?.get(via.source_net_id);
77872
- if (sourceNet) {
77873
- connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
77874
- }
77875
- }
77876
- if (!connectivityKey && via.pcb_trace_id) {
77877
- const pcbTrace = this.ctx.db.pcb_trace?.get(via.pcb_trace_id);
77878
- if (pcbTrace) {
77879
- if ("subcircuit_connectivity_map_key" in pcbTrace) {
77880
- connectivityKey = pcbTrace.subcircuit_connectivity_map_key;
77881
- }
77882
- if (!connectivityKey && pcbTrace.source_trace_id) {
77883
- const sourceTrace = this.ctx.db.source_trace?.get(pcbTrace.source_trace_id);
77884
- if (sourceTrace) {
77885
- if ("subcircuit_connectivity_map_key" in sourceTrace) {
77886
- connectivityKey = sourceTrace.subcircuit_connectivity_map_key;
77887
- }
77888
- if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
77889
- for (const sourceNetId of sourceTrace.connected_source_net_ids) {
77890
- const sourceNet = this.ctx.db.source_net?.get(sourceNetId);
77891
- if (sourceNet) {
77892
- connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
77893
- break;
77894
- }
77895
- }
77896
- }
77897
- }
77898
- if (!connectivityKey) {
77899
- const sourceNet = this.ctx.db.source_net?.get(pcbTrace.source_trace_id);
77900
- if (sourceNet) {
77901
- connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
77902
- }
77903
- }
77904
- }
77905
- }
77906
- }
77907
- if (!connectivityKey && via.connection_name) {
77908
- const sourceNet = this.ctx.db.source_net?.get(via.connection_name);
77909
- if (sourceNet) {
77910
- connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
77911
- }
77912
- }
77913
- if (connectivityKey) {
77914
- netInfo = pcbNetMap.get(connectivityKey);
77915
- }
77916
- }
77917
78079
  const viaLayers = this.getKicadViaLayers(via);
77918
- const viaSize = via.outer_diameter ?? 0.8;
77919
- const viaDrill = via.hole_diameter ?? 0.4;
77920
- const viaData = `via:${transformedPos.x},${transformedPos.y}:${viaSize}:${viaDrill}:${netInfo?.id ?? 0}`;
78080
+ const viaSize = via.outer_diameter ?? DEFAULT_VIA_OUTER_DIAMETER;
78081
+ const viaDrill = via.hole_diameter ?? DEFAULT_VIA_HOLE_DIAMETER;
78082
+ const viaData = `via:${transformedPos.x},${transformedPos.y}:${viaSize}:${viaDrill}:${via.net?.id ?? 0}`;
77921
78083
  const kicadVia = new Via({
77922
78084
  at: [transformedPos.x, transformedPos.y],
77923
78085
  size: viaSize,
77924
78086
  drill: viaDrill,
77925
78087
  layers: viaLayers,
77926
- net: new ViaNet(netInfo?.id ?? 0),
78088
+ net: new ViaNet(via.net?.id ?? 0),
77927
78089
  uuid: generateDeterministicUuid(viaData),
77928
78090
  tenting: createViaTenting(via)
77929
78091
  });
@@ -77963,8 +78125,8 @@ var AddStandalonePcbElements = class extends ConverterStage {
77963
78125
  const pcbPad = elm;
77964
78126
  const padCenter = this.getPcbSmtPadCenter(pcbPad);
77965
78127
  const footprintSeed = `standalone_smtpad:${pcbPad.pcb_smtpad_id}:${padCenter.x},${padCenter.y}`;
77966
- const kicadPos = applyToPoint26(c2kMatPcb, padCenter);
77967
- const footprint = new Footprint4({
78128
+ const kicadPos = applyToPoint25(c2kMatPcb, padCenter);
78129
+ const footprint = new Footprint5({
77968
78130
  libraryLink: this.getSmtPadLibraryLink(pcbPad),
77969
78131
  layer: "F.Cu",
77970
78132
  at: [kicadPos.x, kicadPos.y, 0],
@@ -77973,21 +78135,23 @@ var AddStandalonePcbElements = class extends ConverterStage {
77973
78135
  footprint.fpPads = [
77974
78136
  createSmdPadFromCircuitJson({
77975
78137
  pcbPad,
78138
+ hasSolderPaste: this.ctx.db.pcb_solder_paste.list().some((paste) => paste.pcb_smtpad_id === pcbPad.pcb_smtpad_id),
77976
78139
  componentCenter: padCenter,
77977
78140
  padNumber: 1,
77978
78141
  componentRotation: 0,
77979
78142
  componentId: pcbPad.pcb_smtpad_id
77980
78143
  })
77981
78144
  ];
78145
+ applyInferredFootprintType(footprint);
77982
78146
  const footprints = kicadPcb.footprints;
77983
78147
  footprints.push(footprint);
77984
78148
  kicadPcb.footprints = footprints;
77985
78149
  } else if (elm.type === "pcb_hole") {
77986
78150
  const hole = elm;
77987
78151
  const footprintSeed = `standalone_hole:${hole.pcb_hole_id}:${hole.x},${hole.y}`;
77988
- const kicadPos = applyToPoint26(c2kMatPcb, { x: hole.x, y: hole.y });
78152
+ const kicadPos = applyToPoint25(c2kMatPcb, { x: hole.x, y: hole.y });
77989
78153
  const libraryLink = this.getHoleLibraryLink(hole);
77990
- const footprint = new Footprint4({
78154
+ const footprint = new Footprint5({
77991
78155
  libraryLink,
77992
78156
  layer: "F.Cu",
77993
78157
  at: [kicadPos.x, kicadPos.y, 0],
@@ -78008,9 +78172,9 @@ var AddStandalonePcbElements = class extends ConverterStage {
78008
78172
  } else if (elm.type === "pcb_plated_hole") {
78009
78173
  const hole = elm;
78010
78174
  const footprintSeed = `standalone_plated_hole:${hole.pcb_plated_hole_id}:${hole.x},${hole.y}`;
78011
- const kicadPos = applyToPoint26(c2kMatPcb, { x: hole.x, y: hole.y });
78175
+ const kicadPos = applyToPoint25(c2kMatPcb, { x: hole.x, y: hole.y });
78012
78176
  const libraryLink = this.getPlatedHoleLibraryLink(hole);
78013
- const footprint = new Footprint4({
78177
+ const footprint = new Footprint5({
78014
78178
  libraryLink,
78015
78179
  layer: "F.Cu",
78016
78180
  at: [kicadPos.x, kicadPos.y, 0],
@@ -78024,6 +78188,7 @@ var AddStandalonePcbElements = class extends ConverterStage {
78024
78188
  });
78025
78189
  if (pad) {
78026
78190
  footprint.fpPads = [pad];
78191
+ applyInferredFootprintType(footprint);
78027
78192
  const footprints = kicadPcb.footprints;
78028
78193
  footprints.push(footprint);
78029
78194
  kicadPcb.footprints = footprints;
@@ -78105,7 +78270,7 @@ function createFabricationNoteTextFromCircuitJson({
78105
78270
  if (!textElement.text || !textElement.anchor_position) {
78106
78271
  return null;
78107
78272
  }
78108
- const transformedPos = applyToPoint27(c2kMatPcb, {
78273
+ const transformedPos = applyToPoint26(c2kMatPcb, {
78109
78274
  x: textElement.anchor_position.x,
78110
78275
  y: textElement.anchor_position.y
78111
78276
  });
@@ -78114,7 +78279,7 @@ function createFabricationNoteTextFromCircuitJson({
78114
78279
  bottom: "B.Fab"
78115
78280
  };
78116
78281
  const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.Fab";
78117
- const justify = new TextEffectsJustify6;
78282
+ const justify = new TextEffectsJustify7;
78118
78283
  const anchorAlignment = textElement.anchor_alignment || "center";
78119
78284
  switch (anchorAlignment) {
78120
78285
  case "top_left":
@@ -78151,7 +78316,7 @@ function createFabricationNoteTextFromCircuitJson({
78151
78316
  text: textElement.text,
78152
78317
  layer: kicadLayer,
78153
78318
  effects: textEffects,
78154
- uuid: generateDeterministicUuid(textElement.pcb_fabrication_note_text_id ?? textElement.text)
78319
+ uuid: generateDeterministicUuid(textElement.type === "pcb_note_text" ? textElement.pcb_note_text_id : textElement.pcb_fabrication_note_text_id ?? textElement.text)
78155
78320
  });
78156
78321
  grText.position = position;
78157
78322
  return grText;
@@ -78163,7 +78328,7 @@ function createGrTextFromCircuitJson({
78163
78328
  if (!textElement.text || !textElement.anchor_position) {
78164
78329
  return null;
78165
78330
  }
78166
- const transformedPos = applyToPoint28(c2kMatPcb, {
78331
+ const transformedPos = applyToPoint27(c2kMatPcb, {
78167
78332
  x: textElement.anchor_position.x,
78168
78333
  y: textElement.anchor_position.y
78169
78334
  });
@@ -78223,7 +78388,7 @@ var appendGraphicLine = (kicadPcb, grLine) => {
78223
78388
  var rotatePointAroundOrigin = (point, rotationDegrees = 0) => {
78224
78389
  if (!rotationDegrees)
78225
78390
  return point;
78226
- return applyToPoint29(rotate12(rotationDegrees * Math.PI / 180), point);
78391
+ return applyToPoint28(rotate13(rotationDegrees * Math.PI / 180), point);
78227
78392
  };
78228
78393
  var getRectCutoutCorners = (cutout) => {
78229
78394
  const halfWidth = cutout.width / 2;
@@ -78261,11 +78426,11 @@ var AddGraphicsStage = class extends ConverterStage {
78261
78426
  const endPoint = path.route[i + 1];
78262
78427
  if (!startPoint || !endPoint)
78263
78428
  continue;
78264
- const transformedStart = applyToPoint29(c2kMatPcb, {
78429
+ const transformedStart = applyToPoint28(c2kMatPcb, {
78265
78430
  x: startPoint.x,
78266
78431
  y: startPoint.y
78267
78432
  });
78268
- const transformedEnd = applyToPoint29(c2kMatPcb, {
78433
+ const transformedEnd = applyToPoint28(c2kMatPcb, {
78269
78434
  x: endPoint.x,
78270
78435
  y: endPoint.y
78271
78436
  });
@@ -78295,8 +78460,12 @@ var AddGraphicsStage = class extends ConverterStage {
78295
78460
  kicadPcb.graphicTexts = graphicTexts;
78296
78461
  }
78297
78462
  }
78463
+ const standaloneNoteTexts = this.ctx.db.pcb_note_text?.list().filter((text) => !text.pcb_component_id) || [];
78298
78464
  const fabricationNoteTexts = this.ctx.db.pcb_fabrication_note_text?.list() || [];
78299
- for (const textElement of fabricationNoteTexts) {
78465
+ for (const textElement of [
78466
+ ...fabricationNoteTexts,
78467
+ ...standaloneNoteTexts
78468
+ ]) {
78300
78469
  const grText = createFabricationNoteTextFromCircuitJson({
78301
78470
  textElement,
78302
78471
  c2kMatPcb
@@ -78345,7 +78514,7 @@ var AddGraphicsStage = class extends ConverterStage {
78345
78514
  }
78346
78515
  for (const poly of boardGeom) {
78347
78516
  for (const ring of poly) {
78348
- const transformedRing = ring.map((point) => applyToPoint29(c2kMatPcb, { x: point[0], y: point[1] }));
78517
+ const transformedRing = ring.map((point) => applyToPoint28(c2kMatPcb, { x: point[0], y: point[1] }));
78349
78518
  for (let i = 0;i < transformedRing.length; i++) {
78350
78519
  const start = transformedRing[i];
78351
78520
  const end = transformedRing[(i + 1) % transformedRing.length];
@@ -78374,8 +78543,8 @@ var AddGraphicsStage = class extends ConverterStage {
78374
78543
  const endPoint = cutout.route[i + 1];
78375
78544
  if (!startPoint || !endPoint)
78376
78545
  continue;
78377
- const transformedStart = applyToPoint29(c2kMatPcb, startPoint);
78378
- const transformedEnd = applyToPoint29(c2kMatPcb, endPoint);
78546
+ const transformedStart = applyToPoint28(c2kMatPcb, startPoint);
78547
+ const transformedEnd = applyToPoint28(c2kMatPcb, endPoint);
78379
78548
  appendGraphicLine(kicadPcb, new GrLine({
78380
78549
  start: transformedStart,
78381
78550
  end: transformedEnd,
@@ -78410,7 +78579,7 @@ var CircuitJsonToKicadPcbConverter = class {
78410
78579
  generator: "circuit-json-to-kicad",
78411
78580
  generatorVersion: "0.0.1"
78412
78581
  }),
78413
- c2kMatPcb: compose7(translate7(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale5(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE)),
78582
+ c2kMatPcb: compose8(translate8(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale6(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE)),
78414
78583
  projectName: options?.projectName,
78415
78584
  edgeCutsWidth: options?.edgeCutsWidth,
78416
78585
  pcbModel3dSourcePaths: []
@@ -78965,7 +79134,7 @@ function createTextEffects3(metadataEffects) {
78965
79134
  function applyKicadFootprintMetadata(kicadModString, metadata, footprintName) {
78966
79135
  try {
78967
79136
  const parsed = parseKicadSexpr3(kicadModString);
78968
- const footprint = parsed.find((node) => node instanceof Footprint5);
79137
+ const footprint = parsed.find((node) => node instanceof Footprint6);
78969
79138
  if (!footprint) {
78970
79139
  return kicadModString;
78971
79140
  }
@@ -79253,7 +79422,7 @@ var createJustify = (justifyInput) => {
79253
79422
  if (!options.horizontal && !options.vertical && !options.mirror) {
79254
79423
  return;
79255
79424
  }
79256
- return new TextEffectsJustify7(options);
79425
+ return new TextEffectsJustify8(options);
79257
79426
  };
79258
79427
  var applySymbolProperty = (symbol, key, propertyMeta) => {
79259
79428
  const existingProperty = symbol.properties.find((prop) => prop.key === key);