@tscircuit/cli 0.1.653 → 0.1.655
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/main.js +1642 -695
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -74139,7 +74139,7 @@ var package_default = {
|
|
|
74139
74139
|
chokidar: "4.0.1",
|
|
74140
74140
|
"circuit-json": "0.0.325",
|
|
74141
74141
|
"circuit-json-to-gltf": "^0.0.56",
|
|
74142
|
-
"circuit-json-to-kicad": "^0.0.
|
|
74142
|
+
"circuit-json-to-kicad": "^0.0.29",
|
|
74143
74143
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
74144
74144
|
"circuit-json-to-spice": "^0.0.10",
|
|
74145
74145
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -80228,8 +80228,8 @@ Successfully cloned to:`));
|
|
|
80228
80228
|
var import_perfect_cli = __toESM2(require_dist7(), 1);
|
|
80229
80229
|
|
|
80230
80230
|
// lib/shared/export-snippet.ts
|
|
80231
|
-
import
|
|
80232
|
-
import
|
|
80231
|
+
import fs28 from "node:fs";
|
|
80232
|
+
import path30 from "node:path";
|
|
80233
80233
|
import { promisify as promisify3 } from "node:util";
|
|
80234
80234
|
|
|
80235
80235
|
// node_modules/circuit-json-to-readable-netlist/dist/index.js
|
|
@@ -81614,6 +81614,7 @@ import {
|
|
|
81614
81614
|
Xy
|
|
81615
81615
|
} from "kicadts";
|
|
81616
81616
|
import { symbols } from "schematic-symbols";
|
|
81617
|
+
import { applyToPoint as applyToPoint3, scale as createScaleMatrix } from "transformation-matrix";
|
|
81617
81618
|
import {
|
|
81618
81619
|
SchematicSymbol as SchematicSymbol2,
|
|
81619
81620
|
SymbolLibId,
|
|
@@ -81626,10 +81627,24 @@ import {
|
|
|
81626
81627
|
TextEffectsFont as TextEffectsFont2,
|
|
81627
81628
|
TextEffectsJustify
|
|
81628
81629
|
} from "kicadts";
|
|
81629
|
-
import { applyToPoint as
|
|
81630
|
+
import { applyToPoint as applyToPoint23 } from "transformation-matrix";
|
|
81630
81631
|
import { symbols as symbols2 } from "schematic-symbols";
|
|
81632
|
+
import {
|
|
81633
|
+
SchematicSymbol as SchematicSymbol3,
|
|
81634
|
+
SymbolLibId as SymbolLibId2,
|
|
81635
|
+
SymbolProperty as SymbolProperty3,
|
|
81636
|
+
SymbolPin as SymbolPin3,
|
|
81637
|
+
SymbolInstances as SymbolInstances2,
|
|
81638
|
+
SymbolInstancesProject as SymbolInstancesProject2,
|
|
81639
|
+
SymbolInstancePath as SymbolInstancePath2,
|
|
81640
|
+
TextEffects as TextEffects3,
|
|
81641
|
+
TextEffectsFont as TextEffectsFont3,
|
|
81642
|
+
TextEffectsJustify as TextEffectsJustify2,
|
|
81643
|
+
GlobalLabel
|
|
81644
|
+
} from "kicadts";
|
|
81645
|
+
import { applyToPoint as applyToPoint32 } from "transformation-matrix";
|
|
81631
81646
|
import { Wire, Pts as Pts2, Xy as Xy2, Stroke as Stroke2, Junction } from "kicadts";
|
|
81632
|
-
import { applyToPoint as
|
|
81647
|
+
import { applyToPoint as applyToPoint42 } from "transformation-matrix";
|
|
81633
81648
|
import {
|
|
81634
81649
|
SheetInstances,
|
|
81635
81650
|
SheetInstancesRootPath,
|
|
@@ -81638,7 +81653,7 @@ import {
|
|
|
81638
81653
|
} from "kicadts";
|
|
81639
81654
|
import { KicadPcb } from "kicadts";
|
|
81640
81655
|
import { cju as cju2 } from "@tscircuit/circuit-json-util";
|
|
81641
|
-
import { compose as
|
|
81656
|
+
import { compose as compose3, translate as translate3, scale as scale32 } from "transformation-matrix";
|
|
81642
81657
|
import {
|
|
81643
81658
|
Paper as Paper2,
|
|
81644
81659
|
PcbLayers,
|
|
@@ -81647,14 +81662,45 @@ import {
|
|
|
81647
81662
|
Setup
|
|
81648
81663
|
} from "kicadts";
|
|
81649
81664
|
import { PcbNet } from "kicadts";
|
|
81650
|
-
import { Footprint,
|
|
81651
|
-
import { applyToPoint as
|
|
81665
|
+
import { Footprint, FootprintModel } from "kicadts";
|
|
81666
|
+
import { applyToPoint as applyToPoint92 } from "transformation-matrix";
|
|
81667
|
+
import {
|
|
81668
|
+
FootprintPad,
|
|
81669
|
+
PadPrimitives,
|
|
81670
|
+
PadPrimitiveGrPoly,
|
|
81671
|
+
Pts as Pts3,
|
|
81672
|
+
Xy as Xy3,
|
|
81673
|
+
PadOptions,
|
|
81674
|
+
PadNet
|
|
81675
|
+
} from "kicadts";
|
|
81676
|
+
import {
|
|
81677
|
+
applyToPoint as applyToPoint52,
|
|
81678
|
+
compose as compose2,
|
|
81679
|
+
translate as translate2,
|
|
81680
|
+
scale as scale22,
|
|
81681
|
+
rotate
|
|
81682
|
+
} from "transformation-matrix";
|
|
81683
|
+
import { FootprintPad as FootprintPad2, PadDrill, PadNet as PadNet2 } from "kicadts";
|
|
81684
|
+
import { applyToPoint as applyToPoint62, rotate as rotate2, identity } from "transformation-matrix";
|
|
81685
|
+
import { FootprintPad as FootprintPad3, PadDrill as PadDrill2 } from "kicadts";
|
|
81686
|
+
import { applyToPoint as applyToPoint72, rotate as rotate3, identity as identity2 } from "transformation-matrix";
|
|
81687
|
+
import { FpText, TextEffects as TextEffects4, TextEffectsFont as TextEffectsFont4 } from "kicadts";
|
|
81688
|
+
import { applyToPoint as applyToPoint8, rotate as rotate4, identity as identity3 } from "transformation-matrix";
|
|
81652
81689
|
import { Segment, SegmentNet } from "kicadts";
|
|
81653
|
-
import { applyToPoint as
|
|
81690
|
+
import { applyToPoint as applyToPoint102 } from "transformation-matrix";
|
|
81654
81691
|
import { Via, ViaNet } from "kicadts";
|
|
81655
|
-
import { applyToPoint as
|
|
81692
|
+
import { applyToPoint as applyToPoint11 } from "transformation-matrix";
|
|
81656
81693
|
import { GrLine } from "kicadts";
|
|
81657
|
-
import { applyToPoint as
|
|
81694
|
+
import { applyToPoint as applyToPoint13 } from "transformation-matrix";
|
|
81695
|
+
import {
|
|
81696
|
+
GrText,
|
|
81697
|
+
TextEffects as TextEffects5,
|
|
81698
|
+
TextEffectsFont as TextEffectsFont5,
|
|
81699
|
+
TextEffectsJustify as TextEffectsJustify3,
|
|
81700
|
+
At
|
|
81701
|
+
} from "kicadts";
|
|
81702
|
+
import { applyToPoint as applyToPoint122 } from "transformation-matrix";
|
|
81703
|
+
import { cju as cju3 } from "@tscircuit/circuit-json-util";
|
|
81658
81704
|
var ConverterStage = class {
|
|
81659
81705
|
MAX_ITERATIONS = 1000;
|
|
81660
81706
|
iteration = 0;
|
|
@@ -81686,13 +81732,13 @@ var ConverterStage = class {
|
|
|
81686
81732
|
};
|
|
81687
81733
|
var InitializeSchematicStage = class extends ConverterStage {
|
|
81688
81734
|
_step() {
|
|
81689
|
-
const { kicadSch } = this.ctx;
|
|
81735
|
+
const { kicadSch, schematicPaperSize } = this.ctx;
|
|
81690
81736
|
if (!kicadSch) {
|
|
81691
81737
|
throw new Error("KicadSch instance not initialized in context");
|
|
81692
81738
|
}
|
|
81693
81739
|
kicadSch.version = 20250114;
|
|
81694
81740
|
const paper = new Paper;
|
|
81695
|
-
paper.size = "A4";
|
|
81741
|
+
paper.size = schematicPaperSize?.name ?? "A4";
|
|
81696
81742
|
kicadSch.paper = paper;
|
|
81697
81743
|
kicadSch.uuid = new Uuid(crypto.randomUUID());
|
|
81698
81744
|
this.finished = true;
|
|
@@ -81701,49 +81747,62 @@ var InitializeSchematicStage = class extends ConverterStage {
|
|
|
81701
81747
|
return this.ctx.kicadSch;
|
|
81702
81748
|
}
|
|
81703
81749
|
};
|
|
81750
|
+
function getLibraryId(sourceComp, schematicComp) {
|
|
81751
|
+
if (sourceComp.type !== "source_component") {
|
|
81752
|
+
if (schematicComp.symbol_name) {
|
|
81753
|
+
return `Custom:${schematicComp.symbol_name}`;
|
|
81754
|
+
}
|
|
81755
|
+
return "Device:Component";
|
|
81756
|
+
}
|
|
81757
|
+
if (sourceComp.ftype === "simple_resistor") {
|
|
81758
|
+
return `Device:R_${sourceComp.source_component_id}`;
|
|
81759
|
+
}
|
|
81760
|
+
if (sourceComp.ftype === "simple_capacitor") {
|
|
81761
|
+
return `Device:C_${sourceComp.source_component_id}`;
|
|
81762
|
+
}
|
|
81763
|
+
if (sourceComp.ftype === "simple_inductor") {
|
|
81764
|
+
return `Device:L_${sourceComp.source_component_id}`;
|
|
81765
|
+
}
|
|
81766
|
+
if (sourceComp.ftype === "simple_diode") {
|
|
81767
|
+
return `Device:D_${sourceComp.source_component_id}`;
|
|
81768
|
+
}
|
|
81769
|
+
if (sourceComp.ftype === "simple_chip") {
|
|
81770
|
+
return `Device:U_${sourceComp.source_component_id}`;
|
|
81771
|
+
}
|
|
81772
|
+
if (schematicComp.symbol_name) {
|
|
81773
|
+
return `Custom:${schematicComp.symbol_name}`;
|
|
81774
|
+
}
|
|
81775
|
+
return `Device:Component_${sourceComp.source_component_id}`;
|
|
81776
|
+
}
|
|
81704
81777
|
var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
81705
81778
|
_step() {
|
|
81706
81779
|
const { kicadSch, db } = this.ctx;
|
|
81707
|
-
const schematicComponents = db.schematic_component.list();
|
|
81708
|
-
if (schematicComponents.length === 0) {
|
|
81709
|
-
this.finished = true;
|
|
81710
|
-
return;
|
|
81711
|
-
}
|
|
81712
81780
|
const libSymbols = new LibSymbols;
|
|
81713
|
-
const symbolsToCreate = /* @__PURE__ */ new Set;
|
|
81714
|
-
for (const comp of schematicComponents) {
|
|
81715
|
-
if (comp.symbol_name) {
|
|
81716
|
-
symbolsToCreate.add(comp.symbol_name);
|
|
81717
|
-
} else {
|
|
81718
|
-
const sourceComp = comp.source_component_id ? db.source_component.get(comp.source_component_id) : null;
|
|
81719
|
-
if (sourceComp?.ftype === "simple_chip") {
|
|
81720
|
-
symbolsToCreate.add(`generic_chip_${comp.source_component_id}`);
|
|
81721
|
-
}
|
|
81722
|
-
}
|
|
81723
|
-
}
|
|
81724
81781
|
const librarySymbols = [];
|
|
81725
|
-
|
|
81726
|
-
|
|
81727
|
-
|
|
81728
|
-
|
|
81729
|
-
|
|
81730
|
-
|
|
81731
|
-
|
|
81732
|
-
|
|
81733
|
-
|
|
81734
|
-
|
|
81735
|
-
|
|
81736
|
-
|
|
81737
|
-
|
|
81738
|
-
if (
|
|
81739
|
-
|
|
81740
|
-
|
|
81782
|
+
const schematicComponents = db.schematic_component.list();
|
|
81783
|
+
for (const schematicComponent of schematicComponents) {
|
|
81784
|
+
const libSymbol = this.createLibrarySymbolForComponent(schematicComponent);
|
|
81785
|
+
if (libSymbol) {
|
|
81786
|
+
librarySymbols.push(libSymbol);
|
|
81787
|
+
}
|
|
81788
|
+
}
|
|
81789
|
+
const netLabels = db.schematic_net_label?.list?.() || [];
|
|
81790
|
+
for (const netLabel of netLabels) {
|
|
81791
|
+
if (netLabel.symbol_name) {
|
|
81792
|
+
const isPower = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_power : false;
|
|
81793
|
+
const isGround = netLabel.source_net_id ? db.source_net.get(netLabel.source_net_id)?.is_ground : false;
|
|
81794
|
+
const isPowerOrGround = isPower || isGround;
|
|
81795
|
+
if (isPowerOrGround) {
|
|
81796
|
+
const libSymbol = this.createLibrarySymbolForNetLabel({
|
|
81797
|
+
netLabel,
|
|
81798
|
+
isPower: isPower ?? false,
|
|
81799
|
+
isGround: isGround ?? false
|
|
81800
|
+
});
|
|
81801
|
+
if (libSymbol) {
|
|
81802
|
+
librarySymbols.push(libSymbol);
|
|
81803
|
+
}
|
|
81741
81804
|
}
|
|
81742
|
-
exampleComp = schematicComponents.find((c) => c.symbol_name === symbolName);
|
|
81743
|
-
sourceComp = exampleComp && exampleComp.source_component_id ? db.source_component.get(exampleComp.source_component_id) : null;
|
|
81744
81805
|
}
|
|
81745
|
-
const libSymbol = this.createLibrarySymbolFromSchematicSymbol(symbolName, symbolData, sourceComp);
|
|
81746
|
-
librarySymbols.push(libSymbol);
|
|
81747
81806
|
}
|
|
81748
81807
|
libSymbols.symbols = librarySymbols;
|
|
81749
81808
|
if (kicadSch) {
|
|
@@ -81751,6 +81810,59 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81751
81810
|
}
|
|
81752
81811
|
this.finished = true;
|
|
81753
81812
|
}
|
|
81813
|
+
createLibrarySymbolForComponent(schematicComponent) {
|
|
81814
|
+
const { db } = this.ctx;
|
|
81815
|
+
const sourceComp = schematicComponent.source_component_id ? db.source_component.get(schematicComponent.source_component_id) : null;
|
|
81816
|
+
if (!sourceComp)
|
|
81817
|
+
return null;
|
|
81818
|
+
const symbolName = schematicComponent.symbol_name || (sourceComp.ftype === "simple_chip" ? `generic_chip_${schematicComponent.source_component_id}` : null);
|
|
81819
|
+
if (!symbolName)
|
|
81820
|
+
return null;
|
|
81821
|
+
const symbolData = this.getSymbolData(symbolName, schematicComponent);
|
|
81822
|
+
if (!symbolData)
|
|
81823
|
+
return null;
|
|
81824
|
+
const libId = getLibraryId(sourceComp, schematicComponent);
|
|
81825
|
+
const isChip = sourceComp.ftype === "simple_chip";
|
|
81826
|
+
const footprintName = sourceComp.ftype || "";
|
|
81827
|
+
return this.createLibrarySymbol({
|
|
81828
|
+
libId,
|
|
81829
|
+
symbolData,
|
|
81830
|
+
isChip,
|
|
81831
|
+
schematicComponent,
|
|
81832
|
+
description: this.getDescription(sourceComp),
|
|
81833
|
+
keywords: this.getKeywords(sourceComp),
|
|
81834
|
+
fpFilters: this.getFpFilters(sourceComp),
|
|
81835
|
+
footprintRef: footprintName ? `tscircuit:${footprintName}` : ""
|
|
81836
|
+
});
|
|
81837
|
+
}
|
|
81838
|
+
createLibrarySymbolForNetLabel({
|
|
81839
|
+
netLabel,
|
|
81840
|
+
isPower,
|
|
81841
|
+
isGround
|
|
81842
|
+
}) {
|
|
81843
|
+
const symbolName = netLabel.symbol_name;
|
|
81844
|
+
if (!symbolName)
|
|
81845
|
+
return null;
|
|
81846
|
+
const symbolData = symbols[symbolName];
|
|
81847
|
+
if (!symbolData)
|
|
81848
|
+
return null;
|
|
81849
|
+
const libId = `Custom:${symbolName}`;
|
|
81850
|
+
return this.createLibrarySymbol({
|
|
81851
|
+
libId,
|
|
81852
|
+
symbolData,
|
|
81853
|
+
isChip: false,
|
|
81854
|
+
schematicComponent: undefined,
|
|
81855
|
+
description: isPower ? "Power net label" : isGround ? "Ground net label" : "Net symbol",
|
|
81856
|
+
keywords: isPower ? "power net" : isGround ? "ground net" : "net",
|
|
81857
|
+
fpFilters: ""
|
|
81858
|
+
});
|
|
81859
|
+
}
|
|
81860
|
+
getSymbolData(symbolName, schematicComponent) {
|
|
81861
|
+
if (symbolName.startsWith("generic_chip_")) {
|
|
81862
|
+
return this.createGenericChipSymbolData(schematicComponent, this.ctx.db);
|
|
81863
|
+
}
|
|
81864
|
+
return symbols[symbolName] || null;
|
|
81865
|
+
}
|
|
81754
81866
|
createGenericChipSymbolData(schematicComp, db) {
|
|
81755
81867
|
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));
|
|
81756
81868
|
const width = schematicComp.size?.width || 1.5;
|
|
@@ -81782,8 +81894,16 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81782
81894
|
size: { width, height }
|
|
81783
81895
|
};
|
|
81784
81896
|
}
|
|
81785
|
-
|
|
81786
|
-
|
|
81897
|
+
createLibrarySymbol({
|
|
81898
|
+
libId,
|
|
81899
|
+
symbolData,
|
|
81900
|
+
isChip,
|
|
81901
|
+
schematicComponent,
|
|
81902
|
+
description,
|
|
81903
|
+
keywords,
|
|
81904
|
+
fpFilters,
|
|
81905
|
+
footprintRef = ""
|
|
81906
|
+
}) {
|
|
81787
81907
|
const symbol = new SchematicSymbol({
|
|
81788
81908
|
libraryId: libId,
|
|
81789
81909
|
excludeFromSim: false,
|
|
@@ -81791,33 +81911,43 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81791
81911
|
onBoard: true
|
|
81792
81912
|
});
|
|
81793
81913
|
const pinNumbers = new SymbolPinNumbers;
|
|
81794
|
-
pinNumbers.hide =
|
|
81914
|
+
pinNumbers.hide = !isChip;
|
|
81795
81915
|
symbol._sxPinNumbers = pinNumbers;
|
|
81796
81916
|
const pinNames = new SymbolPinNames;
|
|
81797
|
-
pinNames.offset =
|
|
81917
|
+
pinNames.offset = isChip ? 1.27 : 0;
|
|
81798
81918
|
symbol._sxPinNames = pinNames;
|
|
81799
|
-
this.addSymbolProperties(
|
|
81800
|
-
|
|
81801
|
-
|
|
81919
|
+
this.addSymbolProperties({
|
|
81920
|
+
symbol,
|
|
81921
|
+
libId,
|
|
81922
|
+
description,
|
|
81923
|
+
keywords,
|
|
81924
|
+
fpFilters,
|
|
81925
|
+
footprintRef
|
|
81926
|
+
});
|
|
81927
|
+
const drawingSymbol = this.createDrawingSubsymbol({
|
|
81928
|
+
libId,
|
|
81929
|
+
symbolData,
|
|
81930
|
+
isChip
|
|
81931
|
+
});
|
|
81802
81932
|
symbol.subSymbols.push(drawingSymbol);
|
|
81803
|
-
const pinSymbol = this.createPinSubsymbol(
|
|
81933
|
+
const pinSymbol = this.createPinSubsymbol({
|
|
81934
|
+
libId,
|
|
81935
|
+
symbolData,
|
|
81936
|
+
isChip,
|
|
81937
|
+
schematicComponent
|
|
81938
|
+
});
|
|
81804
81939
|
symbol.subSymbols.push(pinSymbol);
|
|
81805
81940
|
symbol._sxEmbeddedFonts = new EmbeddedFonts(false);
|
|
81806
81941
|
return symbol;
|
|
81807
81942
|
}
|
|
81808
|
-
|
|
81809
|
-
|
|
81810
|
-
|
|
81811
|
-
|
|
81812
|
-
|
|
81813
|
-
|
|
81814
|
-
|
|
81815
|
-
|
|
81816
|
-
return "Device:U";
|
|
81817
|
-
}
|
|
81818
|
-
return `Custom:${symbolName}`;
|
|
81819
|
-
}
|
|
81820
|
-
addSymbolProperties(symbol, libId, sourceComp) {
|
|
81943
|
+
addSymbolProperties({
|
|
81944
|
+
symbol,
|
|
81945
|
+
libId,
|
|
81946
|
+
description,
|
|
81947
|
+
keywords,
|
|
81948
|
+
fpFilters,
|
|
81949
|
+
footprintRef = ""
|
|
81950
|
+
}) {
|
|
81821
81951
|
const refPrefix = libId.split(":")[1]?.[0] || "U";
|
|
81822
81952
|
const properties = [
|
|
81823
81953
|
{
|
|
@@ -81830,7 +81960,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81830
81960
|
{ key: "Value", value: refPrefix, id: 1, at: [0, 0, 90], hide: false },
|
|
81831
81961
|
{
|
|
81832
81962
|
key: "Footprint",
|
|
81833
|
-
value:
|
|
81963
|
+
value: footprintRef,
|
|
81834
81964
|
id: 2,
|
|
81835
81965
|
at: [-1.778, 0, 90],
|
|
81836
81966
|
hide: true
|
|
@@ -81844,21 +81974,21 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81844
81974
|
},
|
|
81845
81975
|
{
|
|
81846
81976
|
key: "Description",
|
|
81847
|
-
value:
|
|
81977
|
+
value: description,
|
|
81848
81978
|
id: 4,
|
|
81849
81979
|
at: [0, 0, 0],
|
|
81850
81980
|
hide: true
|
|
81851
81981
|
},
|
|
81852
81982
|
{
|
|
81853
81983
|
key: "ki_keywords",
|
|
81854
|
-
value:
|
|
81984
|
+
value: keywords,
|
|
81855
81985
|
id: 5,
|
|
81856
81986
|
at: [0, 0, 0],
|
|
81857
81987
|
hide: true
|
|
81858
81988
|
},
|
|
81859
81989
|
{
|
|
81860
81990
|
key: "ki_fp_filters",
|
|
81861
|
-
value:
|
|
81991
|
+
value: fpFilters,
|
|
81862
81992
|
id: 6,
|
|
81863
81993
|
at: [0, 0, 0],
|
|
81864
81994
|
hide: true
|
|
@@ -81901,7 +82031,11 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81901
82031
|
return "*";
|
|
81902
82032
|
return "*";
|
|
81903
82033
|
}
|
|
81904
|
-
createDrawingSubsymbol(
|
|
82034
|
+
createDrawingSubsymbol({
|
|
82035
|
+
libId,
|
|
82036
|
+
symbolData,
|
|
82037
|
+
isChip
|
|
82038
|
+
}) {
|
|
81905
82039
|
const drawingSymbol = new SchematicSymbol({
|
|
81906
82040
|
libraryId: `${libId.split(":")[1]}_0_1`
|
|
81907
82041
|
});
|
|
@@ -81909,15 +82043,31 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81909
82043
|
for (const primitive of symbolData.primitives || []) {
|
|
81910
82044
|
if (primitive.type === "path" && primitive.points) {
|
|
81911
82045
|
const fillType = isChip ? "background" : "none";
|
|
81912
|
-
const polyline = this.createPolylineFromPoints(
|
|
82046
|
+
const polyline = this.createPolylineFromPoints({
|
|
82047
|
+
points: primitive.points,
|
|
82048
|
+
scale: symbolScale,
|
|
82049
|
+
center: symbolData.center,
|
|
82050
|
+
fillType
|
|
82051
|
+
});
|
|
81913
82052
|
drawingSymbol.polylines.push(polyline);
|
|
81914
82053
|
}
|
|
81915
82054
|
}
|
|
81916
82055
|
return drawingSymbol;
|
|
81917
82056
|
}
|
|
81918
|
-
createPolylineFromPoints(
|
|
82057
|
+
createPolylineFromPoints({
|
|
82058
|
+
points,
|
|
82059
|
+
scale: scale42,
|
|
82060
|
+
center,
|
|
82061
|
+
fillType
|
|
82062
|
+
}) {
|
|
81919
82063
|
const polyline = new SymbolPolyline;
|
|
81920
|
-
const
|
|
82064
|
+
const cx = center?.x ?? 0;
|
|
82065
|
+
const cy = center?.y ?? 0;
|
|
82066
|
+
const scaleMatrix = createScaleMatrix(scale42, scale42);
|
|
82067
|
+
const xyPoints = points.map((p) => {
|
|
82068
|
+
const translated = applyToPoint3(scaleMatrix, { x: p.x - cx, y: p.y - cy });
|
|
82069
|
+
return new Xy(translated.x, translated.y);
|
|
82070
|
+
});
|
|
81921
82071
|
const pts = new Pts(xyPoints);
|
|
81922
82072
|
polyline.points = pts;
|
|
81923
82073
|
const stroke = new Stroke;
|
|
@@ -81929,7 +82079,12 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81929
82079
|
polyline.fill = fill;
|
|
81930
82080
|
return polyline;
|
|
81931
82081
|
}
|
|
81932
|
-
createPinSubsymbol(
|
|
82082
|
+
createPinSubsymbol({
|
|
82083
|
+
libId,
|
|
82084
|
+
symbolData,
|
|
82085
|
+
isChip,
|
|
82086
|
+
schematicComponent
|
|
82087
|
+
}) {
|
|
81933
82088
|
const pinSymbol = new SchematicSymbol({
|
|
81934
82089
|
libraryId: `${libId.split(":")[1]}_1_1`
|
|
81935
82090
|
});
|
|
@@ -81938,9 +82093,9 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81938
82093
|
const pin = new SymbolPin;
|
|
81939
82094
|
pin.pinElectricalType = "passive";
|
|
81940
82095
|
pin.pinGraphicStyle = "line";
|
|
81941
|
-
const { x, y, angle } = this.calculatePinPosition(port, symbolData.center, symbolData.size, isChip);
|
|
82096
|
+
const { x, y, angle } = this.calculatePinPosition(port, symbolData.center, symbolData.size, isChip, i, schematicComponent);
|
|
81942
82097
|
pin.at = [x, y, angle];
|
|
81943
|
-
pin.length = isChip ?
|
|
82098
|
+
pin.length = isChip ? 6 : 1.27;
|
|
81944
82099
|
const nameFont = new TextEffectsFont;
|
|
81945
82100
|
nameFont.size = { height: 1.27, width: 1.27 };
|
|
81946
82101
|
const nameEffects = new TextEffects({ font: nameFont });
|
|
@@ -81958,17 +82113,50 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81958
82113
|
}
|
|
81959
82114
|
return pinSymbol;
|
|
81960
82115
|
}
|
|
81961
|
-
calculatePinPosition(port, center, size, isChip) {
|
|
82116
|
+
calculatePinPosition(port, center, size, isChip, portIndex, schematicComponent) {
|
|
81962
82117
|
const symbolScale = this.ctx.c2kMatSch?.a || 15;
|
|
81963
|
-
|
|
81964
|
-
|
|
81965
|
-
let
|
|
81966
|
-
|
|
81967
|
-
|
|
82118
|
+
let portX = port.x ?? 0;
|
|
82119
|
+
let portY = port.y ?? 0;
|
|
82120
|
+
let usingCircuitJsonPort = false;
|
|
82121
|
+
if (portIndex !== undefined && schematicComponent) {
|
|
82122
|
+
const schematicPorts = this.ctx.db.schematic_port.list().filter((p) => p.schematic_component_id === schematicComponent.schematic_component_id).sort((a, b) => (a.pin_number || 0) - (b.pin_number || 0));
|
|
82123
|
+
if (schematicPorts[portIndex]) {
|
|
82124
|
+
const schPort = schematicPorts[portIndex];
|
|
82125
|
+
portX = schPort.center.x - schematicComponent.center.x;
|
|
82126
|
+
portY = schPort.center.y - schematicComponent.center.y;
|
|
82127
|
+
usingCircuitJsonPort = true;
|
|
82128
|
+
}
|
|
82129
|
+
}
|
|
82130
|
+
let dx;
|
|
82131
|
+
let dy;
|
|
82132
|
+
if (usingCircuitJsonPort) {
|
|
82133
|
+
dx = portX;
|
|
82134
|
+
dy = portY;
|
|
82135
|
+
} else {
|
|
82136
|
+
const cx = center?.x ?? 0;
|
|
82137
|
+
const cy = center?.y ?? 0;
|
|
82138
|
+
dx = portX - cx;
|
|
82139
|
+
dy = portY - cy;
|
|
82140
|
+
}
|
|
82141
|
+
const scaleMatrix = createScaleMatrix(symbolScale, symbolScale);
|
|
82142
|
+
const scaled = applyToPoint3(scaleMatrix, { x: dx, y: dy });
|
|
82143
|
+
let isHorizontalPin;
|
|
82144
|
+
if (isChip && size) {
|
|
82145
|
+
const halfWidth = size.width / 2;
|
|
82146
|
+
const halfHeight = size.height / 2;
|
|
82147
|
+
const normalizedDx = Math.abs(dx) / halfWidth;
|
|
82148
|
+
const normalizedDy = Math.abs(dy) / halfHeight;
|
|
82149
|
+
isHorizontalPin = normalizedDx > normalizedDy;
|
|
82150
|
+
} else {
|
|
82151
|
+
isHorizontalPin = Math.abs(dx) > Math.abs(dy);
|
|
82152
|
+
}
|
|
82153
|
+
let x = scaled.x;
|
|
82154
|
+
let y = scaled.y;
|
|
82155
|
+
const chipPinLength = 6;
|
|
81968
82156
|
if (isChip && size) {
|
|
81969
82157
|
const halfWidth = size.width / 2 * symbolScale;
|
|
81970
82158
|
const halfHeight = size.height / 2 * symbolScale;
|
|
81971
|
-
if (
|
|
82159
|
+
if (isHorizontalPin) {
|
|
81972
82160
|
x = dx > 0 ? halfWidth : -halfWidth;
|
|
81973
82161
|
y = dy * symbolScale;
|
|
81974
82162
|
} else {
|
|
@@ -81977,7 +82165,7 @@ var AddLibrarySymbolsStage = class extends ConverterStage {
|
|
|
81977
82165
|
}
|
|
81978
82166
|
}
|
|
81979
82167
|
let angle = 0;
|
|
81980
|
-
if (
|
|
82168
|
+
if (isHorizontalPin) {
|
|
81981
82169
|
if (dx > 0) {
|
|
81982
82170
|
if (isChip) {
|
|
81983
82171
|
angle = 180;
|
|
@@ -82042,7 +82230,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82042
82230
|
continue;
|
|
82043
82231
|
if (!this.ctx.c2kMatSch)
|
|
82044
82232
|
continue;
|
|
82045
|
-
const { x, y } =
|
|
82233
|
+
const { x, y } = applyToPoint23(this.ctx.c2kMatSch, {
|
|
82046
82234
|
x: schematicComponent.center.x,
|
|
82047
82235
|
y: schematicComponent.center.y
|
|
82048
82236
|
});
|
|
@@ -82057,7 +82245,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82057
82245
|
uuid,
|
|
82058
82246
|
fieldsAutoplaced: true
|
|
82059
82247
|
});
|
|
82060
|
-
const libId =
|
|
82248
|
+
const libId = getLibraryId(sourceComponent, schematicComponent);
|
|
82061
82249
|
const symLibId = new SymbolLibId(libId);
|
|
82062
82250
|
symbol._sxLibId = symLibId;
|
|
82063
82251
|
const { reference, value, description } = this.getComponentMetadata(sourceComponent);
|
|
@@ -82125,7 +82313,7 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82125
82313
|
const schematicTexts = this.ctx.db.schematic_text?.list?.()?.filter((t2) => t2.schematic_component_id === schematicComponent.schematic_component_id) || [];
|
|
82126
82314
|
const refText = schematicTexts.find((t2) => t2.text && t2.text.length > 0);
|
|
82127
82315
|
if (refText && this.ctx.c2kMatSch) {
|
|
82128
|
-
const refTextPos2 =
|
|
82316
|
+
const refTextPos2 = applyToPoint23(this.ctx.c2kMatSch, {
|
|
82129
82317
|
x: refText.position.x,
|
|
82130
82318
|
y: refText.position.y
|
|
82131
82319
|
});
|
|
@@ -82151,34 +82339,19 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82151
82339
|
}
|
|
82152
82340
|
}
|
|
82153
82341
|
}
|
|
82154
|
-
const
|
|
82155
|
-
|
|
82156
|
-
|
|
82342
|
+
const symbolCenter = symbol.center || { x: 0, y: 0 };
|
|
82343
|
+
const isVertical = symbolName.includes("_down") || symbolName.includes("_up");
|
|
82344
|
+
const horizontalTextOffset = isVertical ? 0.15 : 0;
|
|
82345
|
+
const refTextPos = refTextPrimitive && this.ctx.c2kMatSch ? applyToPoint23(this.ctx.c2kMatSch, {
|
|
82346
|
+
x: schematicComponent.center.x + (refTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
|
|
82347
|
+
y: schematicComponent.center.y + (refTextPrimitive.y - symbolCenter.y)
|
|
82157
82348
|
}) : { x: symbolKicadPos.x, y: symbolKicadPos.y - 6 };
|
|
82158
|
-
const valTextPos = valTextPrimitive && this.ctx.c2kMatSch ?
|
|
82159
|
-
x: schematicComponent.center.x + valTextPrimitive.x,
|
|
82160
|
-
y: schematicComponent.center.y + valTextPrimitive.y
|
|
82349
|
+
const valTextPos = valTextPrimitive && this.ctx.c2kMatSch ? applyToPoint23(this.ctx.c2kMatSch, {
|
|
82350
|
+
x: schematicComponent.center.x + (valTextPrimitive.x - symbolCenter.x) + horizontalTextOffset,
|
|
82351
|
+
y: schematicComponent.center.y + (valTextPrimitive.y - symbolCenter.y)
|
|
82161
82352
|
}) : { x: symbolKicadPos.x, y: symbolKicadPos.y + 6 };
|
|
82162
82353
|
return { refTextPos, valTextPos };
|
|
82163
82354
|
}
|
|
82164
|
-
getLibraryId(sourceComp) {
|
|
82165
|
-
if (sourceComp.ftype === "simple_resistor") {
|
|
82166
|
-
return "Device:R";
|
|
82167
|
-
}
|
|
82168
|
-
if (sourceComp.ftype === "simple_capacitor") {
|
|
82169
|
-
return "Device:C";
|
|
82170
|
-
}
|
|
82171
|
-
if (sourceComp.ftype === "simple_inductor") {
|
|
82172
|
-
return "Device:L";
|
|
82173
|
-
}
|
|
82174
|
-
if (sourceComp.ftype === "simple_diode") {
|
|
82175
|
-
return "Device:D";
|
|
82176
|
-
}
|
|
82177
|
-
if (sourceComp.ftype === "simple_chip") {
|
|
82178
|
-
return "Device:U";
|
|
82179
|
-
}
|
|
82180
|
-
return "Device:Component";
|
|
82181
|
-
}
|
|
82182
82355
|
getComponentMetadata(sourceComp) {
|
|
82183
82356
|
const name = sourceComp.name || "?";
|
|
82184
82357
|
if (sourceComp.ftype === "simple_resistor") {
|
|
@@ -82240,6 +82413,172 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82240
82413
|
return this.ctx.kicadSch;
|
|
82241
82414
|
}
|
|
82242
82415
|
};
|
|
82416
|
+
var AddSchematicNetLabelsStage = class extends ConverterStage {
|
|
82417
|
+
_step() {
|
|
82418
|
+
const { kicadSch, db } = this.ctx;
|
|
82419
|
+
const netLabels = db.schematic_net_label?.list?.() || [];
|
|
82420
|
+
if (netLabels.length === 0) {
|
|
82421
|
+
this.finished = true;
|
|
82422
|
+
return;
|
|
82423
|
+
}
|
|
82424
|
+
if (!this.ctx.c2kMatSch) {
|
|
82425
|
+
this.finished = true;
|
|
82426
|
+
return;
|
|
82427
|
+
}
|
|
82428
|
+
const symbols3 = [];
|
|
82429
|
+
const globalLabels = [];
|
|
82430
|
+
for (const netLabel of netLabels) {
|
|
82431
|
+
const labelText = netLabel.text || "";
|
|
82432
|
+
const symbolName = netLabel.symbol_name;
|
|
82433
|
+
if (symbolName) {
|
|
82434
|
+
const symbol = this.createSymbolFromNetLabel(netLabel, labelText, symbolName);
|
|
82435
|
+
if (symbol) {
|
|
82436
|
+
symbols3.push(symbol);
|
|
82437
|
+
}
|
|
82438
|
+
} else {
|
|
82439
|
+
const label = this.createGlobalLabel(netLabel, labelText);
|
|
82440
|
+
if (label) {
|
|
82441
|
+
globalLabels.push(label);
|
|
82442
|
+
}
|
|
82443
|
+
}
|
|
82444
|
+
}
|
|
82445
|
+
if (kicadSch && symbols3.length > 0) {
|
|
82446
|
+
const existingSymbols = kicadSch.symbols || [];
|
|
82447
|
+
kicadSch.symbols = [...existingSymbols, ...symbols3];
|
|
82448
|
+
}
|
|
82449
|
+
if (kicadSch && globalLabels.length > 0) {
|
|
82450
|
+
kicadSch.globalLabels = [
|
|
82451
|
+
...kicadSch.globalLabels || [],
|
|
82452
|
+
...globalLabels
|
|
82453
|
+
];
|
|
82454
|
+
}
|
|
82455
|
+
this.finished = true;
|
|
82456
|
+
}
|
|
82457
|
+
createSymbolFromNetLabel(netLabel, labelText, symbolName) {
|
|
82458
|
+
if (!this.ctx.c2kMatSch)
|
|
82459
|
+
return null;
|
|
82460
|
+
const { x, y } = applyToPoint32(this.ctx.c2kMatSch, {
|
|
82461
|
+
x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
|
|
82462
|
+
y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
|
|
82463
|
+
});
|
|
82464
|
+
const uuid = crypto.randomUUID();
|
|
82465
|
+
const symbol = new SchematicSymbol3({
|
|
82466
|
+
at: [x, y, 0],
|
|
82467
|
+
unit: 1,
|
|
82468
|
+
excludeFromSim: false,
|
|
82469
|
+
inBom: true,
|
|
82470
|
+
onBoard: true,
|
|
82471
|
+
dnp: false,
|
|
82472
|
+
uuid,
|
|
82473
|
+
fieldsAutoplaced: true
|
|
82474
|
+
});
|
|
82475
|
+
const libId = `Custom:${symbolName}`;
|
|
82476
|
+
const symLibId = new SymbolLibId2(libId);
|
|
82477
|
+
symbol._sxLibId = symLibId;
|
|
82478
|
+
const isUpSymbol = symbolName.includes("_up") || symbolName.toLowerCase().includes("vcc");
|
|
82479
|
+
const referenceOffset = isUpSymbol ? -4 : 4;
|
|
82480
|
+
const valueOffset = isUpSymbol ? -6 : 6;
|
|
82481
|
+
const referenceProperty = new SymbolProperty3({
|
|
82482
|
+
key: "Reference",
|
|
82483
|
+
value: labelText,
|
|
82484
|
+
id: 0,
|
|
82485
|
+
at: [x, y + referenceOffset, 0],
|
|
82486
|
+
effects: this.createTextEffects(1.27, false)
|
|
82487
|
+
});
|
|
82488
|
+
const valueProperty = new SymbolProperty3({
|
|
82489
|
+
key: "Value",
|
|
82490
|
+
value: labelText,
|
|
82491
|
+
id: 1,
|
|
82492
|
+
at: [x, y + valueOffset, 0],
|
|
82493
|
+
effects: this.createTextEffects(1.27, true)
|
|
82494
|
+
});
|
|
82495
|
+
const footprintProperty = new SymbolProperty3({
|
|
82496
|
+
key: "Footprint",
|
|
82497
|
+
value: "",
|
|
82498
|
+
id: 2,
|
|
82499
|
+
at: [x - 1.778, y, 90],
|
|
82500
|
+
effects: this.createTextEffects(1.27, true)
|
|
82501
|
+
});
|
|
82502
|
+
const datasheetProperty = new SymbolProperty3({
|
|
82503
|
+
key: "Datasheet",
|
|
82504
|
+
value: "~",
|
|
82505
|
+
id: 3,
|
|
82506
|
+
at: [x, y, 0],
|
|
82507
|
+
effects: this.createTextEffects(1.27, true)
|
|
82508
|
+
});
|
|
82509
|
+
const descriptionProperty = new SymbolProperty3({
|
|
82510
|
+
key: "Description",
|
|
82511
|
+
value: `Power/Net symbol: ${labelText}`,
|
|
82512
|
+
id: 4,
|
|
82513
|
+
at: [x, y, 0],
|
|
82514
|
+
effects: this.createTextEffects(1.27, true)
|
|
82515
|
+
});
|
|
82516
|
+
symbol.properties.push(referenceProperty, valueProperty, footprintProperty, datasheetProperty, descriptionProperty);
|
|
82517
|
+
const pin = new SymbolPin3;
|
|
82518
|
+
pin.numberString = "1";
|
|
82519
|
+
pin.uuid = crypto.randomUUID();
|
|
82520
|
+
symbol.pins.push(pin);
|
|
82521
|
+
const { kicadSch } = this.ctx;
|
|
82522
|
+
const instances = new SymbolInstances2;
|
|
82523
|
+
const project = new SymbolInstancesProject2("");
|
|
82524
|
+
const path27 = new SymbolInstancePath2(`/${kicadSch?.uuid?.value || ""}`);
|
|
82525
|
+
path27.reference = labelText;
|
|
82526
|
+
path27.unit = 1;
|
|
82527
|
+
project.paths.push(path27);
|
|
82528
|
+
instances.projects.push(project);
|
|
82529
|
+
symbol._sxInstances = instances;
|
|
82530
|
+
return symbol;
|
|
82531
|
+
}
|
|
82532
|
+
createGlobalLabel(netLabel, labelText) {
|
|
82533
|
+
if (!this.ctx.c2kMatSch || !this.ctx.kicadSch)
|
|
82534
|
+
return null;
|
|
82535
|
+
const { x, y } = applyToPoint32(this.ctx.c2kMatSch, {
|
|
82536
|
+
x: netLabel.anchor_position?.x ?? netLabel.center?.x ?? 0,
|
|
82537
|
+
y: netLabel.anchor_position?.y ?? netLabel.center?.y ?? 0
|
|
82538
|
+
});
|
|
82539
|
+
const anchorSide = netLabel.anchor_side || "left";
|
|
82540
|
+
const angleMap = {
|
|
82541
|
+
left: 0,
|
|
82542
|
+
right: 180,
|
|
82543
|
+
top: 270,
|
|
82544
|
+
bottom: 90
|
|
82545
|
+
};
|
|
82546
|
+
const angle = angleMap[anchorSide] || 0;
|
|
82547
|
+
const justifyMap = {
|
|
82548
|
+
left: { horizontal: "left" },
|
|
82549
|
+
right: { horizontal: "right" },
|
|
82550
|
+
top: { vertical: "top" },
|
|
82551
|
+
bottom: { vertical: "bottom" }
|
|
82552
|
+
};
|
|
82553
|
+
const justify = justifyMap[anchorSide] || {};
|
|
82554
|
+
const effects = this.createTextEffects(1.27, false);
|
|
82555
|
+
if (Object.keys(justify).length > 0) {
|
|
82556
|
+
effects.justify = new TextEffectsJustify2(justify);
|
|
82557
|
+
}
|
|
82558
|
+
const globalLabel = new GlobalLabel({
|
|
82559
|
+
value: labelText,
|
|
82560
|
+
at: [x, y, angle],
|
|
82561
|
+
effects,
|
|
82562
|
+
uuid: crypto.randomUUID(),
|
|
82563
|
+
fieldsAutoplaced: true
|
|
82564
|
+
});
|
|
82565
|
+
return globalLabel;
|
|
82566
|
+
}
|
|
82567
|
+
createTextEffects(size, hide = false) {
|
|
82568
|
+
const font = new TextEffectsFont3;
|
|
82569
|
+
font.size = { height: size, width: size };
|
|
82570
|
+
return new TextEffects3({
|
|
82571
|
+
font,
|
|
82572
|
+
hiddenText: hide
|
|
82573
|
+
});
|
|
82574
|
+
}
|
|
82575
|
+
getOutput() {
|
|
82576
|
+
if (!this.ctx.kicadSch) {
|
|
82577
|
+
throw new Error("kicadSch is not initialized");
|
|
82578
|
+
}
|
|
82579
|
+
return this.ctx.kicadSch;
|
|
82580
|
+
}
|
|
82581
|
+
};
|
|
82243
82582
|
var AddSchematicTracesStage = class extends ConverterStage {
|
|
82244
82583
|
_step() {
|
|
82245
82584
|
const { kicadSch, db } = this.ctx;
|
|
@@ -82272,11 +82611,11 @@ var AddSchematicTracesStage = class extends ConverterStage {
|
|
|
82272
82611
|
if (!this.ctx.c2kMatSch) {
|
|
82273
82612
|
throw new Error("Schematic transformation matrix not initialized in context");
|
|
82274
82613
|
}
|
|
82275
|
-
const from =
|
|
82614
|
+
const from = applyToPoint42(this.ctx.c2kMatSch, {
|
|
82276
82615
|
x: edge.from.x,
|
|
82277
82616
|
y: edge.from.y
|
|
82278
82617
|
});
|
|
82279
|
-
const to =
|
|
82618
|
+
const to = applyToPoint42(this.ctx.c2kMatSch, {
|
|
82280
82619
|
x: edge.to.x,
|
|
82281
82620
|
y: edge.to.y
|
|
82282
82621
|
});
|
|
@@ -82297,12 +82636,12 @@ var AddSchematicTracesStage = class extends ConverterStage {
|
|
|
82297
82636
|
if (!this.ctx.c2kMatSch) {
|
|
82298
82637
|
throw new Error("Schematic transformation matrix not initialized in context");
|
|
82299
82638
|
}
|
|
82300
|
-
const { x, y } =
|
|
82639
|
+
const { x, y } = applyToPoint42(this.ctx.c2kMatSch, {
|
|
82301
82640
|
x: junction.x,
|
|
82302
82641
|
y: junction.y
|
|
82303
82642
|
});
|
|
82304
82643
|
const kicadJunction = new Junction({
|
|
82305
|
-
at: [x, y
|
|
82644
|
+
at: [x, y],
|
|
82306
82645
|
diameter: 0
|
|
82307
82646
|
});
|
|
82308
82647
|
kicadJunction.uuid = crypto.randomUUID();
|
|
@@ -82332,6 +82671,68 @@ var AddSheetInstancesStage = class extends ConverterStage {
|
|
|
82332
82671
|
return this.ctx.kicadSch;
|
|
82333
82672
|
}
|
|
82334
82673
|
};
|
|
82674
|
+
function getSchematicBoundsAndCenter(db) {
|
|
82675
|
+
const schematicComponents = db.schematic_component.list();
|
|
82676
|
+
const schematicTraces = db.schematic_trace.list();
|
|
82677
|
+
let minX = Infinity;
|
|
82678
|
+
let minY = Infinity;
|
|
82679
|
+
let maxX = -Infinity;
|
|
82680
|
+
let maxY = -Infinity;
|
|
82681
|
+
for (const component of schematicComponents) {
|
|
82682
|
+
const width = component.size?.width ?? 0;
|
|
82683
|
+
const height = component.size?.height ?? 0;
|
|
82684
|
+
minX = Math.min(minX, component.center.x - width / 2);
|
|
82685
|
+
minY = Math.min(minY, component.center.y - height / 2);
|
|
82686
|
+
maxX = Math.max(maxX, component.center.x + width / 2);
|
|
82687
|
+
maxY = Math.max(maxY, component.center.y + height / 2);
|
|
82688
|
+
}
|
|
82689
|
+
for (const trace of schematicTraces) {
|
|
82690
|
+
for (const edge of trace.edges) {
|
|
82691
|
+
minX = Math.min(minX, edge.from.x, edge.to.x);
|
|
82692
|
+
minY = Math.min(minY, edge.from.y, edge.to.y);
|
|
82693
|
+
maxX = Math.max(maxX, edge.from.x, edge.to.x);
|
|
82694
|
+
maxY = Math.max(maxY, edge.from.y, edge.to.y);
|
|
82695
|
+
}
|
|
82696
|
+
}
|
|
82697
|
+
if (minX === Infinity) {
|
|
82698
|
+
minX = 0;
|
|
82699
|
+
minY = 0;
|
|
82700
|
+
maxX = 0;
|
|
82701
|
+
maxY = 0;
|
|
82702
|
+
}
|
|
82703
|
+
const centerX = (minX + maxX) / 2;
|
|
82704
|
+
const centerY = (minY + maxY) / 2;
|
|
82705
|
+
return {
|
|
82706
|
+
center: {
|
|
82707
|
+
x: centerX,
|
|
82708
|
+
y: centerY
|
|
82709
|
+
},
|
|
82710
|
+
bounds: {
|
|
82711
|
+
minX,
|
|
82712
|
+
minY,
|
|
82713
|
+
maxX,
|
|
82714
|
+
maxY
|
|
82715
|
+
}
|
|
82716
|
+
};
|
|
82717
|
+
}
|
|
82718
|
+
var PAPER_SIZES = [
|
|
82719
|
+
{ name: "A4", width: 297, height: 210 },
|
|
82720
|
+
{ name: "A3", width: 420, height: 297 },
|
|
82721
|
+
{ name: "A2", width: 594, height: 420 },
|
|
82722
|
+
{ name: "A1", width: 841, height: 594 },
|
|
82723
|
+
{ name: "A0", width: 1189, height: 841 }
|
|
82724
|
+
];
|
|
82725
|
+
function selectSchematicPaperSize(contentWidth, contentHeight, paddingMm = 20) {
|
|
82726
|
+
const requiredWidth = contentWidth + 2 * paddingMm;
|
|
82727
|
+
const requiredHeight = contentHeight + 2 * paddingMm;
|
|
82728
|
+
for (let i = 0;i < PAPER_SIZES.length; i++) {
|
|
82729
|
+
const paperSize = PAPER_SIZES[i];
|
|
82730
|
+
if (requiredWidth <= paperSize.width && requiredHeight <= paperSize.height) {
|
|
82731
|
+
return paperSize;
|
|
82732
|
+
}
|
|
82733
|
+
}
|
|
82734
|
+
return PAPER_SIZES[PAPER_SIZES.length - 1];
|
|
82735
|
+
}
|
|
82335
82736
|
var CircuitJsonToKicadSchConverter = class {
|
|
82336
82737
|
ctx;
|
|
82337
82738
|
pipeline;
|
|
@@ -82342,21 +82743,28 @@ var CircuitJsonToKicadSchConverter = class {
|
|
|
82342
82743
|
}
|
|
82343
82744
|
constructor(circuitJson) {
|
|
82344
82745
|
const CIRCUIT_JSON_SCALE_FACTOR = 15;
|
|
82345
|
-
const
|
|
82346
|
-
const
|
|
82746
|
+
const db = cju(circuitJson);
|
|
82747
|
+
const { center, bounds } = getSchematicBoundsAndCenter(db);
|
|
82748
|
+
const schematicWidthMm = (bounds.maxX - bounds.minX) * CIRCUIT_JSON_SCALE_FACTOR;
|
|
82749
|
+
const schematicHeightMm = (bounds.maxY - bounds.minY) * CIRCUIT_JSON_SCALE_FACTOR;
|
|
82750
|
+
const paperSize = selectSchematicPaperSize(schematicWidthMm, schematicHeightMm);
|
|
82751
|
+
const KICAD_CENTER_X = paperSize.width / 2;
|
|
82752
|
+
const KICAD_CENTER_Y = paperSize.height / 2;
|
|
82347
82753
|
this.ctx = {
|
|
82348
|
-
db
|
|
82754
|
+
db,
|
|
82349
82755
|
circuitJson,
|
|
82350
82756
|
kicadSch: new KicadSch({
|
|
82351
82757
|
generator: "circuit-json-to-kicad",
|
|
82352
82758
|
generatorVersion: "0.0.1"
|
|
82353
82759
|
}),
|
|
82354
|
-
|
|
82760
|
+
schematicPaperSize: paperSize,
|
|
82761
|
+
c2kMatSch: compose(translate(KICAD_CENTER_X, KICAD_CENTER_Y), scale6(CIRCUIT_JSON_SCALE_FACTOR, -CIRCUIT_JSON_SCALE_FACTOR), translate(-center.x, -center.y))
|
|
82355
82762
|
};
|
|
82356
82763
|
this.pipeline = [
|
|
82357
82764
|
new InitializeSchematicStage(circuitJson, this.ctx),
|
|
82358
82765
|
new AddLibrarySymbolsStage(circuitJson, this.ctx),
|
|
82359
82766
|
new AddSchematicSymbolsStage(circuitJson, this.ctx),
|
|
82767
|
+
new AddSchematicNetLabelsStage(circuitJson, this.ctx),
|
|
82360
82768
|
new AddSchematicTracesStage(circuitJson, this.ctx),
|
|
82361
82769
|
new AddSheetInstancesStage(circuitJson, this.ctx)
|
|
82362
82770
|
];
|
|
@@ -82436,36 +82844,426 @@ var AddNetsStage = class extends ConverterStage {
|
|
|
82436
82844
|
if (!kicadPcb) {
|
|
82437
82845
|
throw new Error("KicadPcb instance not initialized in context");
|
|
82438
82846
|
}
|
|
82439
|
-
|
|
82440
|
-
|
|
82441
|
-
|
|
82442
|
-
const
|
|
82443
|
-
|
|
82444
|
-
|
|
82445
|
-
|
|
82446
|
-
|
|
82447
|
-
|
|
82448
|
-
|
|
82449
|
-
|
|
82450
|
-
|
|
82451
|
-
|
|
82452
|
-
|
|
82453
|
-
|
|
82454
|
-
|
|
82455
|
-
|
|
82456
|
-
|
|
82457
|
-
|
|
82847
|
+
this.ctx.pcbNetMap = /* @__PURE__ */ new Map;
|
|
82848
|
+
const netNameByKey = /* @__PURE__ */ new Map;
|
|
82849
|
+
const sourceNets = this.ctx.db.source_net?.list() ?? [];
|
|
82850
|
+
for (const sourceNet of sourceNets) {
|
|
82851
|
+
const connectivityKey = sourceNet.subcircuit_connectivity_map_key || sourceNet.source_net_id;
|
|
82852
|
+
if (!connectivityKey)
|
|
82853
|
+
continue;
|
|
82854
|
+
const candidateName = sourceNet.name || sourceNet.source_net_id || "";
|
|
82855
|
+
const netName = candidateName && candidateName.trim().length > 0 ? candidateName : connectivityKey;
|
|
82856
|
+
netNameByKey.set(connectivityKey, netName);
|
|
82857
|
+
}
|
|
82858
|
+
const sourceTraces = this.ctx.db.source_trace?.list() ?? [];
|
|
82859
|
+
for (const sourceTrace of sourceTraces) {
|
|
82860
|
+
let connectivityKey = sourceTrace.subcircuit_connectivity_map_key;
|
|
82861
|
+
if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
|
|
82862
|
+
for (const sourceNetId of sourceTrace.connected_source_net_ids) {
|
|
82863
|
+
const connectedNet = this.ctx.db.source_net?.get(sourceNetId);
|
|
82864
|
+
if (connectedNet?.subcircuit_connectivity_map_key && connectedNet.subcircuit_connectivity_map_key.length > 0) {
|
|
82865
|
+
connectivityKey = connectedNet.subcircuit_connectivity_map_key;
|
|
82866
|
+
break;
|
|
82867
|
+
}
|
|
82868
|
+
}
|
|
82869
|
+
}
|
|
82870
|
+
if (!connectivityKey)
|
|
82871
|
+
continue;
|
|
82872
|
+
if (!netNameByKey.has(connectivityKey)) {
|
|
82873
|
+
const candidateName = sourceTrace.display_name || sourceTrace.source_trace_id || "";
|
|
82874
|
+
const netName = candidateName && candidateName.trim().length > 0 ? candidateName : connectivityKey;
|
|
82875
|
+
netNameByKey.set(connectivityKey, netName);
|
|
82876
|
+
}
|
|
82877
|
+
}
|
|
82878
|
+
const sortedEntries = Array.from(netNameByKey.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
82879
|
+
const nets = [];
|
|
82880
|
+
nets.push(new PcbNet(0, ""));
|
|
82881
|
+
let netNumber = 1;
|
|
82882
|
+
for (const [connectivityKey, netName] of sortedEntries) {
|
|
82883
|
+
const pcbNet = new PcbNet(netNumber, netName);
|
|
82884
|
+
nets.push(pcbNet);
|
|
82885
|
+
const netInfo = { id: netNumber, name: netName };
|
|
82886
|
+
this.ctx.pcbNetMap.set(connectivityKey, netInfo);
|
|
82458
82887
|
netNumber++;
|
|
82459
82888
|
}
|
|
82889
|
+
kicadPcb.nets = nets;
|
|
82460
82890
|
this.finished = true;
|
|
82461
82891
|
}
|
|
82462
82892
|
getOutput() {
|
|
82463
82893
|
return this.ctx.kicadPcb;
|
|
82464
82894
|
}
|
|
82465
82895
|
};
|
|
82896
|
+
function simpleHash(str) {
|
|
82897
|
+
let hash = 0;
|
|
82898
|
+
for (let i = 0;i < str.length; i++) {
|
|
82899
|
+
const char = str.charCodeAt(i);
|
|
82900
|
+
hash = (hash << 5) - hash + char;
|
|
82901
|
+
hash = hash & hash;
|
|
82902
|
+
}
|
|
82903
|
+
let result = "";
|
|
82904
|
+
for (let i = 0;i < 4; i++) {
|
|
82905
|
+
let h = hash;
|
|
82906
|
+
for (let j = 0;j < str.length; j++) {
|
|
82907
|
+
h = (h << 5) - h + str.charCodeAt(j) + i * 31;
|
|
82908
|
+
h = h & h;
|
|
82909
|
+
}
|
|
82910
|
+
result += Math.abs(h).toString(16).padStart(8, "0");
|
|
82911
|
+
}
|
|
82912
|
+
return result;
|
|
82913
|
+
}
|
|
82914
|
+
function generateDeterministicUuid(data) {
|
|
82915
|
+
const hash = simpleHash(data);
|
|
82916
|
+
return `${hash.slice(0, 8)}-${hash.slice(8, 12)}-${hash.slice(12, 16)}-${hash.slice(16, 20)}-${hash.slice(20, 32)}`;
|
|
82917
|
+
}
|
|
82918
|
+
function createSmdPadFromCircuitJson({
|
|
82919
|
+
pcbPad,
|
|
82920
|
+
componentCenter,
|
|
82921
|
+
padNumber,
|
|
82922
|
+
componentRotation = 0,
|
|
82923
|
+
netInfo,
|
|
82924
|
+
componentId
|
|
82925
|
+
}) {
|
|
82926
|
+
let padX;
|
|
82927
|
+
let padY;
|
|
82928
|
+
if ("x" in pcbPad && "y" in pcbPad) {
|
|
82929
|
+
padX = pcbPad.x;
|
|
82930
|
+
padY = pcbPad.y;
|
|
82931
|
+
} else if ("points" in pcbPad && Array.isArray(pcbPad.points)) {
|
|
82932
|
+
const points = pcbPad.points;
|
|
82933
|
+
padX = points.reduce((sum, p) => sum + p.x, 0) / points.length;
|
|
82934
|
+
padY = points.reduce((sum, p) => sum + p.y, 0) / points.length;
|
|
82935
|
+
} else {
|
|
82936
|
+
throw new Error("Pad must have either x/y coordinates or points array");
|
|
82937
|
+
}
|
|
82938
|
+
const cj2kicadMatrix = compose2(componentRotation !== 0 ? rotate(componentRotation * Math.PI / 180) : { a: 1, b: 0, c: 0, d: 1, e: 0, f: 0 }, scale22(1, -1), translate2(-componentCenter.x, -componentCenter.y));
|
|
82939
|
+
const rotatedPos = applyToPoint52(cj2kicadMatrix, {
|
|
82940
|
+
x: padX,
|
|
82941
|
+
y: padY
|
|
82942
|
+
});
|
|
82943
|
+
const layerMap = {
|
|
82944
|
+
top: "F.Cu",
|
|
82945
|
+
bottom: "B.Cu"
|
|
82946
|
+
};
|
|
82947
|
+
const padLayer = layerMap[pcbPad.layer] || "F.Cu";
|
|
82948
|
+
let padShape;
|
|
82949
|
+
let padSize;
|
|
82950
|
+
let padOptions;
|
|
82951
|
+
let padPrimitives;
|
|
82952
|
+
if (pcbPad.shape === "circle") {
|
|
82953
|
+
padShape = "circle";
|
|
82954
|
+
padSize = [
|
|
82955
|
+
"radius" in pcbPad ? pcbPad.radius * 2 : 0.5,
|
|
82956
|
+
"radius" in pcbPad ? pcbPad.radius * 2 : 0.5
|
|
82957
|
+
];
|
|
82958
|
+
} else if (pcbPad.shape === "polygon" && "points" in pcbPad) {
|
|
82959
|
+
const points = pcbPad.points;
|
|
82960
|
+
const pointTransformMatrix = compose2(scale22(1, -1), translate2(-padX, -padY));
|
|
82961
|
+
const relativePoints = points.map((p) => {
|
|
82962
|
+
const transformed = applyToPoint52(pointTransformMatrix, { x: p.x, y: p.y });
|
|
82963
|
+
return new Xy3(transformed.x, transformed.y);
|
|
82964
|
+
});
|
|
82965
|
+
const grPoly = new PadPrimitiveGrPoly;
|
|
82966
|
+
grPoly.contours = [new Pts3(relativePoints)];
|
|
82967
|
+
grPoly.width = 0;
|
|
82968
|
+
grPoly.filled = true;
|
|
82969
|
+
padPrimitives = new PadPrimitives;
|
|
82970
|
+
padPrimitives.addGraphic(grPoly);
|
|
82971
|
+
padShape = "custom";
|
|
82972
|
+
padOptions = new PadOptions;
|
|
82973
|
+
padOptions.anchor = "circle";
|
|
82974
|
+
padSize = [0.2, 0.2];
|
|
82975
|
+
} else {
|
|
82976
|
+
padShape = "rect";
|
|
82977
|
+
padSize = [
|
|
82978
|
+
"width" in pcbPad ? pcbPad.width : 0.5,
|
|
82979
|
+
"height" in pcbPad ? pcbPad.height : 0.5
|
|
82980
|
+
];
|
|
82981
|
+
}
|
|
82982
|
+
const padData = `pad:${componentId}:${padNumber}:${rotatedPos.x},${rotatedPos.y}`;
|
|
82983
|
+
const pad = new FootprintPad({
|
|
82984
|
+
number: String(padNumber),
|
|
82985
|
+
padType: "smd",
|
|
82986
|
+
shape: padShape,
|
|
82987
|
+
at: [rotatedPos.x, rotatedPos.y, 0],
|
|
82988
|
+
size: padSize,
|
|
82989
|
+
layers: [
|
|
82990
|
+
`${padLayer}`,
|
|
82991
|
+
`${padLayer === "F.Cu" ? "F" : "B"}.Paste`,
|
|
82992
|
+
`${padLayer === "F.Cu" ? "F" : "B"}.Mask`
|
|
82993
|
+
],
|
|
82994
|
+
uuid: generateDeterministicUuid(padData)
|
|
82995
|
+
});
|
|
82996
|
+
if (padOptions) {
|
|
82997
|
+
pad.options = padOptions;
|
|
82998
|
+
}
|
|
82999
|
+
if (padPrimitives) {
|
|
83000
|
+
pad.primitives = padPrimitives;
|
|
83001
|
+
}
|
|
83002
|
+
if (netInfo) {
|
|
83003
|
+
pad.net = new PadNet(netInfo.id, netInfo.name);
|
|
83004
|
+
}
|
|
83005
|
+
return pad;
|
|
83006
|
+
}
|
|
83007
|
+
function createThruHolePadFromCircuitJson({
|
|
83008
|
+
platedHole,
|
|
83009
|
+
componentCenter,
|
|
83010
|
+
padNumber,
|
|
83011
|
+
componentRotation = 0,
|
|
83012
|
+
netInfo,
|
|
83013
|
+
componentId
|
|
83014
|
+
}) {
|
|
83015
|
+
if (!(("x" in platedHole) && ("y" in platedHole))) {
|
|
83016
|
+
return null;
|
|
83017
|
+
}
|
|
83018
|
+
const relativeX = platedHole.x - componentCenter.x;
|
|
83019
|
+
const relativeY = -(platedHole.y - componentCenter.y);
|
|
83020
|
+
const rotationMatrix = componentRotation !== 0 ? rotate2(componentRotation * Math.PI / 180) : identity();
|
|
83021
|
+
const rotatedPos = applyToPoint62(rotationMatrix, {
|
|
83022
|
+
x: relativeX,
|
|
83023
|
+
y: relativeY
|
|
83024
|
+
});
|
|
83025
|
+
let padShape = "circle";
|
|
83026
|
+
let padSize;
|
|
83027
|
+
let drill;
|
|
83028
|
+
let rotation = 0;
|
|
83029
|
+
const hasHoleOffset = "hole_offset_x" in platedHole || "hole_offset_y" in platedHole;
|
|
83030
|
+
let drillOffset;
|
|
83031
|
+
if (hasHoleOffset) {
|
|
83032
|
+
const rawOffset = {
|
|
83033
|
+
x: platedHole.hole_offset_x ?? 0,
|
|
83034
|
+
y: platedHole.hole_offset_y ?? 0
|
|
83035
|
+
};
|
|
83036
|
+
if (rawOffset.x !== 0 || rawOffset.y !== 0) {
|
|
83037
|
+
const rotatedOffset = applyToPoint62(rotationMatrix, {
|
|
83038
|
+
x: -rawOffset.x,
|
|
83039
|
+
y: rawOffset.y
|
|
83040
|
+
});
|
|
83041
|
+
drillOffset = rotatedOffset;
|
|
83042
|
+
}
|
|
83043
|
+
}
|
|
83044
|
+
if (platedHole.shape === "circle") {
|
|
83045
|
+
padShape = "circle";
|
|
83046
|
+
padSize = [platedHole.outer_diameter, platedHole.outer_diameter];
|
|
83047
|
+
drill = new PadDrill({
|
|
83048
|
+
diameter: platedHole.hole_diameter,
|
|
83049
|
+
offset: drillOffset
|
|
83050
|
+
});
|
|
83051
|
+
} else if (platedHole.shape === "pill" || platedHole.shape === "oval") {
|
|
83052
|
+
padShape = "oval";
|
|
83053
|
+
padSize = [
|
|
83054
|
+
platedHole.outer_width,
|
|
83055
|
+
platedHole.outer_height
|
|
83056
|
+
];
|
|
83057
|
+
drill = new PadDrill({
|
|
83058
|
+
oval: true,
|
|
83059
|
+
diameter: platedHole.hole_width,
|
|
83060
|
+
width: platedHole.hole_height,
|
|
83061
|
+
offset: drillOffset
|
|
83062
|
+
});
|
|
83063
|
+
} else if (platedHole.shape === "pill_hole_with_rect_pad") {
|
|
83064
|
+
padShape = "rect";
|
|
83065
|
+
padSize = [
|
|
83066
|
+
platedHole.rect_pad_width,
|
|
83067
|
+
platedHole.rect_pad_height
|
|
83068
|
+
];
|
|
83069
|
+
drill = new PadDrill({
|
|
83070
|
+
oval: true,
|
|
83071
|
+
diameter: platedHole.hole_width,
|
|
83072
|
+
width: platedHole.hole_height,
|
|
83073
|
+
offset: drillOffset
|
|
83074
|
+
});
|
|
83075
|
+
} else if (platedHole.shape === "circular_hole_with_rect_pad") {
|
|
83076
|
+
padShape = "rect";
|
|
83077
|
+
padSize = [
|
|
83078
|
+
platedHole.rect_pad_width,
|
|
83079
|
+
platedHole.rect_pad_height
|
|
83080
|
+
];
|
|
83081
|
+
drill = new PadDrill({
|
|
83082
|
+
diameter: platedHole.hole_diameter,
|
|
83083
|
+
offset: drillOffset
|
|
83084
|
+
});
|
|
83085
|
+
} else if (platedHole.shape === "rotated_pill_hole_with_rect_pad") {
|
|
83086
|
+
padShape = "rect";
|
|
83087
|
+
padSize = [
|
|
83088
|
+
platedHole.rect_pad_width,
|
|
83089
|
+
platedHole.rect_pad_height
|
|
83090
|
+
];
|
|
83091
|
+
drill = new PadDrill({
|
|
83092
|
+
oval: true,
|
|
83093
|
+
diameter: platedHole.hole_width,
|
|
83094
|
+
width: platedHole.hole_height,
|
|
83095
|
+
offset: drillOffset
|
|
83096
|
+
});
|
|
83097
|
+
rotation = platedHole.rect_ccw_rotation || 0;
|
|
83098
|
+
} else {
|
|
83099
|
+
padShape = "circle";
|
|
83100
|
+
padSize = [1.6, 1.6];
|
|
83101
|
+
drill = new PadDrill({ diameter: 0.8, offset: drillOffset });
|
|
83102
|
+
}
|
|
83103
|
+
const padData = `thruhole:${componentId}:${padNumber}:${rotatedPos.x},${rotatedPos.y}`;
|
|
83104
|
+
const pad = new FootprintPad2({
|
|
83105
|
+
number: String(padNumber),
|
|
83106
|
+
padType: "thru_hole",
|
|
83107
|
+
shape: padShape,
|
|
83108
|
+
at: [rotatedPos.x, rotatedPos.y, rotation],
|
|
83109
|
+
size: padSize,
|
|
83110
|
+
drill,
|
|
83111
|
+
layers: ["*.Cu", "*.Mask"],
|
|
83112
|
+
removeUnusedLayers: false,
|
|
83113
|
+
uuid: generateDeterministicUuid(padData)
|
|
83114
|
+
});
|
|
83115
|
+
if (netInfo) {
|
|
83116
|
+
pad.net = new PadNet2(netInfo.id, netInfo.name);
|
|
83117
|
+
}
|
|
83118
|
+
return pad;
|
|
83119
|
+
}
|
|
83120
|
+
function createNpthPadFromCircuitJson({
|
|
83121
|
+
pcbHole,
|
|
83122
|
+
componentCenter,
|
|
83123
|
+
componentRotation = 0
|
|
83124
|
+
}) {
|
|
83125
|
+
if (!(("x" in pcbHole) && ("y" in pcbHole))) {
|
|
83126
|
+
return null;
|
|
83127
|
+
}
|
|
83128
|
+
const relativeX = pcbHole.x - componentCenter.x;
|
|
83129
|
+
const relativeY = -(pcbHole.y - componentCenter.y);
|
|
83130
|
+
const rotationMatrix = componentRotation !== 0 ? rotate3(componentRotation * Math.PI / 180) : identity2();
|
|
83131
|
+
const rotatedPos = applyToPoint72(rotationMatrix, {
|
|
83132
|
+
x: relativeX,
|
|
83133
|
+
y: relativeY
|
|
83134
|
+
});
|
|
83135
|
+
let padShape = "circle";
|
|
83136
|
+
let padSize;
|
|
83137
|
+
let drill;
|
|
83138
|
+
if (pcbHole.hole_shape === "circle") {
|
|
83139
|
+
padShape = "circle";
|
|
83140
|
+
const diameter = pcbHole.hole_diameter;
|
|
83141
|
+
padSize = [diameter, diameter];
|
|
83142
|
+
drill = new PadDrill2({
|
|
83143
|
+
diameter
|
|
83144
|
+
});
|
|
83145
|
+
} else if (pcbHole.hole_shape === "oval") {
|
|
83146
|
+
padShape = "oval";
|
|
83147
|
+
const width = pcbHole.hole_width;
|
|
83148
|
+
const height = pcbHole.hole_height;
|
|
83149
|
+
padSize = [width, height];
|
|
83150
|
+
drill = new PadDrill2({
|
|
83151
|
+
oval: true,
|
|
83152
|
+
diameter: width,
|
|
83153
|
+
width: height
|
|
83154
|
+
});
|
|
83155
|
+
} else {
|
|
83156
|
+
padShape = "circle";
|
|
83157
|
+
const diameter = "hole_diameter" in pcbHole ? pcbHole.hole_diameter : 1;
|
|
83158
|
+
padSize = [diameter, diameter];
|
|
83159
|
+
drill = new PadDrill2({ diameter });
|
|
83160
|
+
}
|
|
83161
|
+
return new FootprintPad3({
|
|
83162
|
+
number: "",
|
|
83163
|
+
padType: "np_thru_hole",
|
|
83164
|
+
shape: padShape,
|
|
83165
|
+
at: [rotatedPos.x, rotatedPos.y, 0],
|
|
83166
|
+
size: padSize,
|
|
83167
|
+
drill,
|
|
83168
|
+
layers: ["*.Cu", "*.Mask"],
|
|
83169
|
+
removeUnusedLayers: false,
|
|
83170
|
+
uuid: crypto.randomUUID()
|
|
83171
|
+
});
|
|
83172
|
+
}
|
|
83173
|
+
function createFpTextFromCircuitJson({
|
|
83174
|
+
textElement,
|
|
83175
|
+
componentCenter,
|
|
83176
|
+
componentRotation = 0
|
|
83177
|
+
}) {
|
|
83178
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
83179
|
+
return null;
|
|
83180
|
+
}
|
|
83181
|
+
const relativeX = textElement.anchor_position.x - componentCenter.x;
|
|
83182
|
+
const relativeY = -(textElement.anchor_position.y - componentCenter.y);
|
|
83183
|
+
const rotationMatrix = componentRotation !== 0 ? rotate4(componentRotation * Math.PI / 180) : identity3();
|
|
83184
|
+
const rotatedPos = applyToPoint8(rotationMatrix, {
|
|
83185
|
+
x: relativeX,
|
|
83186
|
+
y: relativeY
|
|
83187
|
+
});
|
|
83188
|
+
const relativePosition = {
|
|
83189
|
+
x: rotatedPos.x,
|
|
83190
|
+
y: rotatedPos.y
|
|
83191
|
+
};
|
|
83192
|
+
const layerMap = {
|
|
83193
|
+
top: "F.SilkS",
|
|
83194
|
+
bottom: "B.SilkS"
|
|
83195
|
+
};
|
|
83196
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
83197
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
83198
|
+
const font = new TextEffectsFont4;
|
|
83199
|
+
font.size = { width: fontSize, height: fontSize };
|
|
83200
|
+
const textEffects = new TextEffects4({
|
|
83201
|
+
font
|
|
83202
|
+
});
|
|
83203
|
+
const rotation = textElement.ccw_rotation || 0;
|
|
83204
|
+
return new FpText({
|
|
83205
|
+
type: "user",
|
|
83206
|
+
text: textElement.text,
|
|
83207
|
+
position: {
|
|
83208
|
+
x: relativePosition.x,
|
|
83209
|
+
y: relativePosition.y,
|
|
83210
|
+
angle: rotation
|
|
83211
|
+
},
|
|
83212
|
+
layer: kicadLayer,
|
|
83213
|
+
effects: textEffects
|
|
83214
|
+
});
|
|
83215
|
+
}
|
|
82466
83216
|
var AddFootprintsStage = class extends ConverterStage {
|
|
82467
83217
|
componentsProcessed = 0;
|
|
82468
83218
|
pcbComponents = [];
|
|
83219
|
+
getNetInfoForPcbPort(pcbPortId) {
|
|
83220
|
+
if (!pcbPortId)
|
|
83221
|
+
return;
|
|
83222
|
+
const pcbPort = this.ctx.db.pcb_port?.get(pcbPortId);
|
|
83223
|
+
if (!pcbPort)
|
|
83224
|
+
return;
|
|
83225
|
+
const sourcePortId = pcbPort.source_port_id;
|
|
83226
|
+
if (!sourcePortId)
|
|
83227
|
+
return;
|
|
83228
|
+
const sourcePort = this.ctx.db.source_port?.get(sourcePortId);
|
|
83229
|
+
if (!sourcePort)
|
|
83230
|
+
return;
|
|
83231
|
+
const connectivityKey = sourcePort.subcircuit_connectivity_map_key;
|
|
83232
|
+
if (!connectivityKey)
|
|
83233
|
+
return;
|
|
83234
|
+
return this.ctx.pcbNetMap?.get(connectivityKey);
|
|
83235
|
+
}
|
|
83236
|
+
getCadComponentForPcbComponent(pcbComponentId) {
|
|
83237
|
+
const cadComponents = this.ctx.db.cad_component?.list() || [];
|
|
83238
|
+
return cadComponents.find((cad) => cad.pcb_component_id === pcbComponentId);
|
|
83239
|
+
}
|
|
83240
|
+
create3DModelsFromCadComponent(cadComponent, componentCenter) {
|
|
83241
|
+
const models = [];
|
|
83242
|
+
const modelUrl = cadComponent.model_step_url || cadComponent.model_wrl_url;
|
|
83243
|
+
if (!modelUrl)
|
|
83244
|
+
return models;
|
|
83245
|
+
const model = new FootprintModel(modelUrl);
|
|
83246
|
+
if (cadComponent.position) {
|
|
83247
|
+
model.offset = {
|
|
83248
|
+
x: (cadComponent.position.x || 0) - componentCenter.x,
|
|
83249
|
+
y: -((cadComponent.position.y || 0) - componentCenter.y),
|
|
83250
|
+
z: cadComponent.position.z || 0
|
|
83251
|
+
};
|
|
83252
|
+
}
|
|
83253
|
+
if (cadComponent.rotation) {
|
|
83254
|
+
model.rotate = {
|
|
83255
|
+
x: cadComponent.rotation.x || 0,
|
|
83256
|
+
y: cadComponent.rotation.y || 0,
|
|
83257
|
+
z: cadComponent.rotation.z || 0
|
|
83258
|
+
};
|
|
83259
|
+
}
|
|
83260
|
+
if (cadComponent.model_unit_to_mm_scale_factor) {
|
|
83261
|
+
const scale42 = cadComponent.model_unit_to_mm_scale_factor;
|
|
83262
|
+
model.scale = { x: scale42, y: scale42, z: scale42 };
|
|
83263
|
+
}
|
|
83264
|
+
models.push(model);
|
|
83265
|
+
return models;
|
|
83266
|
+
}
|
|
82469
83267
|
constructor(input, ctx) {
|
|
82470
83268
|
super(input, ctx);
|
|
82471
83269
|
this.pcbComponents = this.ctx.db.pcb_component.list();
|
|
@@ -82485,74 +83283,81 @@ var AddFootprintsStage = class extends ConverterStage {
|
|
|
82485
83283
|
const component = this.pcbComponents[this.componentsProcessed];
|
|
82486
83284
|
const sourceComponent = component.source_component_id ? this.ctx.db.source_component.get(component.source_component_id) : null;
|
|
82487
83285
|
const footprintName = sourceComponent?.ftype || "Unknown";
|
|
82488
|
-
const
|
|
82489
|
-
const transformedPos = applyToPoint32(c2kMatPcb, {
|
|
83286
|
+
const transformedPos = applyToPoint92(c2kMatPcb, {
|
|
82490
83287
|
x: component.center.x,
|
|
82491
83288
|
y: component.center.y
|
|
82492
83289
|
});
|
|
83290
|
+
const footprintData = `footprint:${component.pcb_component_id}:${transformedPos.x},${transformedPos.y}`;
|
|
82493
83291
|
const footprint = new Footprint({
|
|
82494
83292
|
libraryLink: `tscircuit:${footprintName}`,
|
|
82495
83293
|
layer: "F.Cu",
|
|
82496
83294
|
at: [transformedPos.x, transformedPos.y, component.rotation || 0],
|
|
82497
|
-
uuid:
|
|
82498
|
-
});
|
|
82499
|
-
const refText = new FpText({
|
|
82500
|
-
type: "reference",
|
|
82501
|
-
text: componentName,
|
|
82502
|
-
position: [0, -1.5, 0],
|
|
82503
|
-
layer: "F.SilkS",
|
|
82504
|
-
uuid: crypto.randomUUID()
|
|
82505
|
-
});
|
|
82506
|
-
const valueText = new FpText({
|
|
82507
|
-
type: "value",
|
|
82508
|
-
text: footprintName,
|
|
82509
|
-
position: [0, 1.5, 0],
|
|
82510
|
-
layer: "F.Fab",
|
|
82511
|
-
uuid: crypto.randomUUID()
|
|
83295
|
+
uuid: generateDeterministicUuid(footprintData)
|
|
82512
83296
|
});
|
|
82513
83297
|
const fpTexts = footprint.fpTexts;
|
|
82514
|
-
|
|
82515
|
-
|
|
83298
|
+
const pcbSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => text.pcb_component_id === component.pcb_component_id) || [];
|
|
83299
|
+
for (const textElement of pcbSilkscreenTexts) {
|
|
83300
|
+
const fpText = createFpTextFromCircuitJson({
|
|
83301
|
+
textElement,
|
|
83302
|
+
componentCenter: component.center,
|
|
83303
|
+
componentRotation: component.rotation || 0
|
|
83304
|
+
});
|
|
83305
|
+
if (fpText) {
|
|
83306
|
+
fpTexts.push(fpText);
|
|
83307
|
+
}
|
|
83308
|
+
}
|
|
82516
83309
|
footprint.fpTexts = fpTexts;
|
|
82517
83310
|
const pcbPads = this.ctx.db.pcb_smtpad?.list().filter((pad) => pad.pcb_component_id === component.pcb_component_id) || [];
|
|
82518
83311
|
const fpPads = footprint.fpPads;
|
|
82519
83312
|
let padNumber = 1;
|
|
82520
83313
|
for (const pcbPad of pcbPads) {
|
|
82521
|
-
|
|
82522
|
-
|
|
82523
|
-
|
|
82524
|
-
|
|
82525
|
-
|
|
82526
|
-
|
|
82527
|
-
|
|
82528
|
-
|
|
82529
|
-
};
|
|
82530
|
-
const padLayer = layerMap[pcbPad.layer] || "F.Cu";
|
|
82531
|
-
const padShape = pcbPad.shape === "circle" ? "circle" : "rect";
|
|
82532
|
-
const padSize = pcbPad.shape === "circle" ? [
|
|
82533
|
-
"radius" in pcbPad ? pcbPad.radius * 2 : 0.5,
|
|
82534
|
-
"radius" in pcbPad ? pcbPad.radius * 2 : 0.5
|
|
82535
|
-
] : [
|
|
82536
|
-
"width" in pcbPad ? pcbPad.width : 0.5,
|
|
82537
|
-
"height" in pcbPad ? pcbPad.height : 0.5
|
|
82538
|
-
];
|
|
82539
|
-
const pad = new FootprintPad({
|
|
82540
|
-
number: String(padNumber),
|
|
82541
|
-
padType: "smd",
|
|
82542
|
-
shape: padShape,
|
|
82543
|
-
at: [relativeX, relativeY, 0],
|
|
82544
|
-
size: padSize,
|
|
82545
|
-
layers: [
|
|
82546
|
-
`${padLayer}`,
|
|
82547
|
-
`${padLayer === "F.Cu" ? "F" : "B"}.Paste`,
|
|
82548
|
-
`${padLayer === "F.Cu" ? "F" : "B"}.Mask`
|
|
82549
|
-
],
|
|
82550
|
-
uuid: crypto.randomUUID()
|
|
83314
|
+
const netInfo = this.getNetInfoForPcbPort(pcbPad.pcb_port_id);
|
|
83315
|
+
const pad = createSmdPadFromCircuitJson({
|
|
83316
|
+
pcbPad,
|
|
83317
|
+
componentCenter: component.center,
|
|
83318
|
+
padNumber,
|
|
83319
|
+
componentRotation: component.rotation || 0,
|
|
83320
|
+
netInfo,
|
|
83321
|
+
componentId: component.pcb_component_id
|
|
82551
83322
|
});
|
|
82552
83323
|
fpPads.push(pad);
|
|
82553
83324
|
padNumber++;
|
|
82554
83325
|
}
|
|
83326
|
+
const pcbPlatedHoles = this.ctx.db.pcb_plated_hole?.list().filter((hole) => hole.pcb_component_id === component.pcb_component_id) || [];
|
|
83327
|
+
for (const platedHole of pcbPlatedHoles) {
|
|
83328
|
+
const netInfo = this.getNetInfoForPcbPort(platedHole.pcb_port_id);
|
|
83329
|
+
const pad = createThruHolePadFromCircuitJson({
|
|
83330
|
+
platedHole,
|
|
83331
|
+
componentCenter: component.center,
|
|
83332
|
+
padNumber,
|
|
83333
|
+
componentRotation: component.rotation || 0,
|
|
83334
|
+
netInfo,
|
|
83335
|
+
componentId: component.pcb_component_id
|
|
83336
|
+
});
|
|
83337
|
+
if (pad) {
|
|
83338
|
+
fpPads.push(pad);
|
|
83339
|
+
padNumber++;
|
|
83340
|
+
}
|
|
83341
|
+
}
|
|
83342
|
+
const pcbHoles = this.ctx.db.pcb_hole?.list().filter((hole) => hole.subcircuit_id === component.subcircuit_id) || [];
|
|
83343
|
+
for (const pcbHole of pcbHoles) {
|
|
83344
|
+
const pad = createNpthPadFromCircuitJson({
|
|
83345
|
+
pcbHole,
|
|
83346
|
+
componentCenter: component.center,
|
|
83347
|
+
componentRotation: component.rotation || 0
|
|
83348
|
+
});
|
|
83349
|
+
if (pad) {
|
|
83350
|
+
fpPads.push(pad);
|
|
83351
|
+
}
|
|
83352
|
+
}
|
|
82555
83353
|
footprint.fpPads = fpPads;
|
|
83354
|
+
const cadComponent = this.getCadComponentForPcbComponent(component.pcb_component_id);
|
|
83355
|
+
if (cadComponent) {
|
|
83356
|
+
const models = this.create3DModelsFromCadComponent(cadComponent, component.center);
|
|
83357
|
+
if (models.length > 0) {
|
|
83358
|
+
footprint.models = models;
|
|
83359
|
+
}
|
|
83360
|
+
}
|
|
82556
83361
|
const footprints = kicadPcb.footprints;
|
|
82557
83362
|
footprints.push(footprint);
|
|
82558
83363
|
kicadPcb.footprints = footprints;
|
|
@@ -82589,30 +83394,55 @@ var AddTracesStage = class extends ConverterStage {
|
|
|
82589
83394
|
for (let i = 0;i < trace.route.length - 1; i++) {
|
|
82590
83395
|
const startPoint = trace.route[i];
|
|
82591
83396
|
const endPoint = trace.route[i + 1];
|
|
82592
|
-
const transformedStart =
|
|
83397
|
+
const transformedStart = applyToPoint102(c2kMatPcb, {
|
|
82593
83398
|
x: startPoint.x,
|
|
82594
83399
|
y: startPoint.y
|
|
82595
83400
|
});
|
|
82596
|
-
const transformedEnd =
|
|
83401
|
+
const transformedEnd = applyToPoint102(c2kMatPcb, {
|
|
82597
83402
|
x: endPoint.x,
|
|
82598
83403
|
y: endPoint.y
|
|
82599
83404
|
});
|
|
82600
|
-
let
|
|
83405
|
+
let netInfo;
|
|
82601
83406
|
if (pcbNetMap) {
|
|
82602
|
-
|
|
82603
|
-
|
|
83407
|
+
let connectivityKey = trace.subcircuit_connectivity_map_key;
|
|
83408
|
+
if (!connectivityKey && trace.source_trace_id) {
|
|
83409
|
+
const sourceTrace = this.ctx.db.source_trace?.get(trace.source_trace_id);
|
|
83410
|
+
if (sourceTrace) {
|
|
83411
|
+
connectivityKey = sourceTrace.subcircuit_connectivity_map_key;
|
|
83412
|
+
if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
|
|
83413
|
+
for (const sourceNetId of sourceTrace.connected_source_net_ids) {
|
|
83414
|
+
const sourceNet = this.ctx.db.source_net?.get(sourceNetId);
|
|
83415
|
+
if (sourceNet?.subcircuit_connectivity_map_key) {
|
|
83416
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
83417
|
+
break;
|
|
83418
|
+
}
|
|
83419
|
+
}
|
|
83420
|
+
}
|
|
83421
|
+
}
|
|
83422
|
+
}
|
|
83423
|
+
if (!connectivityKey && typeof trace.connection_name === "string") {
|
|
83424
|
+
const sourceNet = this.ctx.db.source_net?.get(trace.connection_name);
|
|
83425
|
+
if (sourceNet?.subcircuit_connectivity_map_key) {
|
|
83426
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
83427
|
+
}
|
|
83428
|
+
}
|
|
83429
|
+
if (connectivityKey) {
|
|
83430
|
+
netInfo = pcbNetMap.get(connectivityKey);
|
|
83431
|
+
}
|
|
82604
83432
|
}
|
|
82605
83433
|
const layerMap = {
|
|
82606
83434
|
top: "F.Cu",
|
|
82607
83435
|
bottom: "B.Cu"
|
|
82608
83436
|
};
|
|
82609
83437
|
const kicadLayer = layerMap[startPoint.layer] || startPoint.layer || "F.Cu";
|
|
83438
|
+
const segmentData = `segment:${transformedStart.x},${transformedStart.y}:${transformedEnd.x},${transformedEnd.y}:${kicadLayer}:${netInfo?.id ?? 0}`;
|
|
82610
83439
|
const segment = new Segment({
|
|
82611
83440
|
start: { x: transformedStart.x, y: transformedStart.y },
|
|
82612
83441
|
end: { x: transformedEnd.x, y: transformedEnd.y },
|
|
82613
83442
|
layer: kicadLayer,
|
|
82614
83443
|
width: trace.width || 0.25,
|
|
82615
|
-
net: new SegmentNet(
|
|
83444
|
+
net: new SegmentNet(netInfo?.id ?? 0),
|
|
83445
|
+
uuid: generateDeterministicUuid(segmentData)
|
|
82616
83446
|
});
|
|
82617
83447
|
const segments = kicadPcb.segments;
|
|
82618
83448
|
segments.push(segment);
|
|
@@ -82644,20 +83474,56 @@ var AddViasStage = class extends ConverterStage {
|
|
|
82644
83474
|
return;
|
|
82645
83475
|
}
|
|
82646
83476
|
const via = this.pcbVias[this.viasProcessed];
|
|
82647
|
-
const transformedPos =
|
|
83477
|
+
const transformedPos = applyToPoint11(c2kMatPcb, {
|
|
82648
83478
|
x: via.x,
|
|
82649
83479
|
y: via.y
|
|
82650
83480
|
});
|
|
82651
|
-
let
|
|
82652
|
-
if (pcbNetMap
|
|
82653
|
-
|
|
83481
|
+
let netInfo;
|
|
83482
|
+
if (pcbNetMap) {
|
|
83483
|
+
let connectivityKey = via.subcircuit_connectivity_map_key;
|
|
83484
|
+
if (!connectivityKey && via.pcb_trace_id) {
|
|
83485
|
+
const pcbTrace = this.ctx.db.pcb_trace?.get(via.pcb_trace_id);
|
|
83486
|
+
if (pcbTrace) {
|
|
83487
|
+
if ("subcircuit_connectivity_map_key" in pcbTrace) {
|
|
83488
|
+
connectivityKey = pcbTrace.subcircuit_connectivity_map_key;
|
|
83489
|
+
}
|
|
83490
|
+
if (!connectivityKey && pcbTrace.source_trace_id) {
|
|
83491
|
+
const sourceTrace = this.ctx.db.source_trace?.get(pcbTrace.source_trace_id);
|
|
83492
|
+
if (sourceTrace) {
|
|
83493
|
+
if ("subcircuit_connectivity_map_key" in sourceTrace) {
|
|
83494
|
+
connectivityKey = sourceTrace.subcircuit_connectivity_map_key;
|
|
83495
|
+
}
|
|
83496
|
+
if (!connectivityKey && sourceTrace.connected_source_net_ids?.length) {
|
|
83497
|
+
for (const sourceNetId of sourceTrace.connected_source_net_ids) {
|
|
83498
|
+
const sourceNet = this.ctx.db.source_net?.get(sourceNetId);
|
|
83499
|
+
if (sourceNet?.subcircuit_connectivity_map_key) {
|
|
83500
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
83501
|
+
break;
|
|
83502
|
+
}
|
|
83503
|
+
}
|
|
83504
|
+
}
|
|
83505
|
+
}
|
|
83506
|
+
}
|
|
83507
|
+
}
|
|
83508
|
+
}
|
|
83509
|
+
if (!connectivityKey && via.connection_name) {
|
|
83510
|
+
const sourceNet = this.ctx.db.source_net?.get(via.connection_name);
|
|
83511
|
+
if (sourceNet?.subcircuit_connectivity_map_key) {
|
|
83512
|
+
connectivityKey = sourceNet.subcircuit_connectivity_map_key;
|
|
83513
|
+
}
|
|
83514
|
+
}
|
|
83515
|
+
if (connectivityKey) {
|
|
83516
|
+
netInfo = pcbNetMap.get(connectivityKey);
|
|
83517
|
+
}
|
|
82654
83518
|
}
|
|
83519
|
+
const viaData = `via:${transformedPos.x},${transformedPos.y}:${via.outer_diameter || 0.8}:${via.hole_diameter || 0.4}:${netInfo?.id ?? 0}`;
|
|
82655
83520
|
const kicadVia = new Via({
|
|
82656
83521
|
at: [transformedPos.x, transformedPos.y],
|
|
82657
83522
|
size: via.outer_diameter || 0.8,
|
|
82658
83523
|
drill: via.hole_diameter || 0.4,
|
|
82659
83524
|
layers: ["F.Cu", "B.Cu"],
|
|
82660
|
-
net: new ViaNet(
|
|
83525
|
+
net: new ViaNet(netInfo?.id ?? 0),
|
|
83526
|
+
uuid: generateDeterministicUuid(viaData)
|
|
82661
83527
|
});
|
|
82662
83528
|
const vias = kicadPcb.vias;
|
|
82663
83529
|
vias.push(kicadVia);
|
|
@@ -82668,6 +83534,63 @@ var AddViasStage = class extends ConverterStage {
|
|
|
82668
83534
|
return this.ctx.kicadPcb;
|
|
82669
83535
|
}
|
|
82670
83536
|
};
|
|
83537
|
+
function createGrTextFromCircuitJson({
|
|
83538
|
+
textElement,
|
|
83539
|
+
c2kMatPcb
|
|
83540
|
+
}) {
|
|
83541
|
+
if (!textElement.text || !textElement.anchor_position) {
|
|
83542
|
+
return null;
|
|
83543
|
+
}
|
|
83544
|
+
const transformedPos = applyToPoint122(c2kMatPcb, {
|
|
83545
|
+
x: textElement.anchor_position.x,
|
|
83546
|
+
y: textElement.anchor_position.y
|
|
83547
|
+
});
|
|
83548
|
+
const layerMap = {
|
|
83549
|
+
top: "F.SilkS",
|
|
83550
|
+
bottom: "B.SilkS"
|
|
83551
|
+
};
|
|
83552
|
+
const kicadLayer = layerMap[textElement.layer] || textElement.layer || "F.SilkS";
|
|
83553
|
+
const fontSize = (textElement.font_size || 1) / 1.5;
|
|
83554
|
+
const font = new TextEffectsFont5;
|
|
83555
|
+
font.size = { width: fontSize, height: fontSize };
|
|
83556
|
+
const justify = new TextEffectsJustify3;
|
|
83557
|
+
const anchorAlignment = textElement.anchor_alignment || "center";
|
|
83558
|
+
switch (anchorAlignment) {
|
|
83559
|
+
case "top_left":
|
|
83560
|
+
justify.horizontal = "left";
|
|
83561
|
+
justify.vertical = "top";
|
|
83562
|
+
break;
|
|
83563
|
+
case "top_right":
|
|
83564
|
+
justify.horizontal = "right";
|
|
83565
|
+
justify.vertical = "top";
|
|
83566
|
+
break;
|
|
83567
|
+
case "bottom_left":
|
|
83568
|
+
justify.horizontal = "left";
|
|
83569
|
+
justify.vertical = "bottom";
|
|
83570
|
+
break;
|
|
83571
|
+
case "bottom_right":
|
|
83572
|
+
justify.horizontal = "right";
|
|
83573
|
+
justify.vertical = "bottom";
|
|
83574
|
+
break;
|
|
83575
|
+
case "center":
|
|
83576
|
+
break;
|
|
83577
|
+
}
|
|
83578
|
+
const textEffects = new TextEffects5({
|
|
83579
|
+
font
|
|
83580
|
+
});
|
|
83581
|
+
if (anchorAlignment !== "center") {
|
|
83582
|
+
textEffects.justify = justify;
|
|
83583
|
+
}
|
|
83584
|
+
const rotation = textElement.ccw_rotation || 0;
|
|
83585
|
+
const position = new At([transformedPos.x, transformedPos.y, rotation]);
|
|
83586
|
+
const grText = new GrText({
|
|
83587
|
+
text: textElement.text,
|
|
83588
|
+
layer: kicadLayer,
|
|
83589
|
+
effects: textEffects
|
|
83590
|
+
});
|
|
83591
|
+
grText.position = position;
|
|
83592
|
+
return grText;
|
|
83593
|
+
}
|
|
82671
83594
|
var AddGraphicsStage = class extends ConverterStage {
|
|
82672
83595
|
_step() {
|
|
82673
83596
|
const { kicadPcb, c2kMatPcb } = this.ctx;
|
|
@@ -82686,11 +83609,11 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82686
83609
|
const endPoint = path27.route[i + 1];
|
|
82687
83610
|
if (!startPoint || !endPoint)
|
|
82688
83611
|
continue;
|
|
82689
|
-
const transformedStart =
|
|
83612
|
+
const transformedStart = applyToPoint13(c2kMatPcb, {
|
|
82690
83613
|
x: startPoint.x,
|
|
82691
83614
|
y: startPoint.y
|
|
82692
83615
|
});
|
|
82693
|
-
const transformedEnd =
|
|
83616
|
+
const transformedEnd = applyToPoint13(c2kMatPcb, {
|
|
82694
83617
|
x: endPoint.x,
|
|
82695
83618
|
y: endPoint.y
|
|
82696
83619
|
});
|
|
@@ -82710,6 +83633,18 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82710
83633
|
kicadPcb.graphicLines = graphicLines;
|
|
82711
83634
|
}
|
|
82712
83635
|
}
|
|
83636
|
+
const standaloneSilkscreenTexts = this.ctx.db.pcb_silkscreen_text?.list().filter((text) => !text.pcb_component_id) || [];
|
|
83637
|
+
for (const textElement of standaloneSilkscreenTexts) {
|
|
83638
|
+
const grText = createGrTextFromCircuitJson({
|
|
83639
|
+
textElement,
|
|
83640
|
+
c2kMatPcb
|
|
83641
|
+
});
|
|
83642
|
+
if (grText) {
|
|
83643
|
+
const graphicTexts = kicadPcb.graphicTexts;
|
|
83644
|
+
graphicTexts.push(grText);
|
|
83645
|
+
kicadPcb.graphicTexts = graphicTexts;
|
|
83646
|
+
}
|
|
83647
|
+
}
|
|
82713
83648
|
const pcbBoards = this.ctx.db.pcb_board?.list() || [];
|
|
82714
83649
|
if (pcbBoards.length > 0) {
|
|
82715
83650
|
const board = pcbBoards[0];
|
|
@@ -82721,8 +83656,8 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82721
83656
|
if (board.outline && board.outline.length > 0) {
|
|
82722
83657
|
corners = board.outline;
|
|
82723
83658
|
} else {
|
|
82724
|
-
const halfWidth = board.width / 2;
|
|
82725
|
-
const halfHeight = board.height / 2;
|
|
83659
|
+
const halfWidth = board.width ? board.width / 2 : 0;
|
|
83660
|
+
const halfHeight = board.height ? board.height / 2 : 0;
|
|
82726
83661
|
corners = [
|
|
82727
83662
|
{ x: board.center.x - halfWidth, y: board.center.y - halfHeight },
|
|
82728
83663
|
{ x: board.center.x + halfWidth, y: board.center.y - halfHeight },
|
|
@@ -82730,7 +83665,7 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82730
83665
|
{ x: board.center.x - halfWidth, y: board.center.y + halfHeight }
|
|
82731
83666
|
];
|
|
82732
83667
|
}
|
|
82733
|
-
const transformedCorners = corners.map((corner) =>
|
|
83668
|
+
const transformedCorners = corners.map((corner) => applyToPoint13(c2kMatPcb, corner));
|
|
82734
83669
|
for (let i = 0;i < transformedCorners.length; i++) {
|
|
82735
83670
|
const start = transformedCorners[i];
|
|
82736
83671
|
const end = transformedCorners[(i + 1) % transformedCorners.length];
|
|
@@ -82772,7 +83707,7 @@ var CircuitJsonToKicadPcbConverter = class {
|
|
|
82772
83707
|
generator: "circuit-json-to-kicad",
|
|
82773
83708
|
generatorVersion: "0.0.1"
|
|
82774
83709
|
}),
|
|
82775
|
-
c2kMatPcb:
|
|
83710
|
+
c2kMatPcb: compose3(translate3(KICAD_PCB_CENTER_X, KICAD_PCB_CENTER_Y), scale32(CIRCUIT_JSON_TO_MM_SCALE, -CIRCUIT_JSON_TO_MM_SCALE))
|
|
82776
83711
|
};
|
|
82777
83712
|
this.pipeline = [
|
|
82778
83713
|
new InitializePcbStage(circuitJson, this.ctx),
|
|
@@ -82811,8 +83746,8 @@ var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
|
82811
83746
|
|
|
82812
83747
|
// lib/shared/generate-circuit-json.tsx
|
|
82813
83748
|
var import_make_vfs2 = __toESM2(require_dist8(), 1);
|
|
82814
|
-
import
|
|
82815
|
-
import
|
|
83749
|
+
import path28 from "node:path";
|
|
83750
|
+
import fs26 from "node:fs";
|
|
82816
83751
|
import { pathToFileURL } from "node:url";
|
|
82817
83752
|
import Debug11 from "debug";
|
|
82818
83753
|
|
|
@@ -82831,20 +83766,32 @@ var abbreviateStringifyObject = (obj) => {
|
|
|
82831
83766
|
};
|
|
82832
83767
|
|
|
82833
83768
|
// lib/shared/importFromUserLand.ts
|
|
82834
|
-
import {
|
|
83769
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
83770
|
+
import fs25 from "node:fs";
|
|
83771
|
+
import path27 from "node:path";
|
|
82835
83772
|
async function importFromUserLand(moduleName) {
|
|
83773
|
+
const userModulePath = path27.join(process.cwd(), "node_modules", moduleName);
|
|
83774
|
+
if (fs25.existsSync(userModulePath)) {
|
|
83775
|
+
const userRequire = createRequire2(path27.join(process.cwd(), "noop.js"));
|
|
83776
|
+
try {
|
|
83777
|
+
const resolvedUserPath = userRequire.resolve(moduleName);
|
|
83778
|
+
return await import(resolvedUserPath);
|
|
83779
|
+
} catch (error) {
|
|
83780
|
+
if (error?.code !== "MODULE_NOT_FOUND") {
|
|
83781
|
+
throw error;
|
|
83782
|
+
}
|
|
83783
|
+
}
|
|
83784
|
+
}
|
|
83785
|
+
const cliRequire = createRequire2(import.meta.url);
|
|
82836
83786
|
try {
|
|
82837
|
-
const
|
|
82838
|
-
return await import(
|
|
83787
|
+
const resolvedCliPath = cliRequire.resolve(moduleName);
|
|
83788
|
+
return await import(resolvedCliPath);
|
|
82839
83789
|
} catch (error) {
|
|
82840
|
-
|
|
82841
|
-
|
|
82842
|
-
return await import(modulePath);
|
|
82843
|
-
} catch (error2) {
|
|
82844
|
-
const module2 = await import(moduleName);
|
|
82845
|
-
return module2;
|
|
83790
|
+
if (error?.code !== "MODULE_NOT_FOUND") {
|
|
83791
|
+
throw error;
|
|
82846
83792
|
}
|
|
82847
83793
|
}
|
|
83794
|
+
return import(moduleName);
|
|
82848
83795
|
}
|
|
82849
83796
|
|
|
82850
83797
|
// lib/shared/generate-circuit-json.tsx
|
|
@@ -82875,12 +83822,12 @@ async function generateCircuitJson({
|
|
|
82875
83822
|
const runner = new userLandTscircuit.RootCircuit({
|
|
82876
83823
|
platform: platformConfig
|
|
82877
83824
|
});
|
|
82878
|
-
const absoluteFilePath =
|
|
82879
|
-
const projectDir =
|
|
83825
|
+
const absoluteFilePath = path28.isAbsolute(filePath) ? filePath : path28.resolve(process.cwd(), filePath);
|
|
83826
|
+
const projectDir = path28.dirname(absoluteFilePath);
|
|
82880
83827
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
82881
|
-
const relativeComponentPath =
|
|
82882
|
-
const baseFileName = outputFileName ||
|
|
82883
|
-
const outputPath =
|
|
83828
|
+
const relativeComponentPath = path28.relative(projectDir, absoluteFilePath);
|
|
83829
|
+
const baseFileName = outputFileName || path28.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
83830
|
+
const outputPath = path28.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
82884
83831
|
debug11(`Project directory: ${projectDir}`);
|
|
82885
83832
|
debug11(`Relative component path: ${relativeComponentPath}`);
|
|
82886
83833
|
debug11(`Output path: ${outputPath}`);
|
|
@@ -82900,7 +83847,7 @@ async function generateCircuitJson({
|
|
|
82900
83847
|
return false;
|
|
82901
83848
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
82902
83849
|
return false;
|
|
82903
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
83850
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path28.extname(normalizedFilePath)))
|
|
82904
83851
|
return false;
|
|
82905
83852
|
return true;
|
|
82906
83853
|
},
|
|
@@ -82918,7 +83865,7 @@ async function generateCircuitJson({
|
|
|
82918
83865
|
const circuitJson = await runner.getCircuitJson();
|
|
82919
83866
|
if (saveToFile) {
|
|
82920
83867
|
debug11(`Saving circuit JSON to ${outputPath}`);
|
|
82921
|
-
|
|
83868
|
+
fs26.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
82922
83869
|
}
|
|
82923
83870
|
return {
|
|
82924
83871
|
circuitJson,
|
|
@@ -82927,9 +83874,9 @@ async function generateCircuitJson({
|
|
|
82927
83874
|
}
|
|
82928
83875
|
|
|
82929
83876
|
// cli/build/generate-kicad-footprint-library.ts
|
|
82930
|
-
import
|
|
82931
|
-
import
|
|
82932
|
-
import { At, KicadPcb as KicadPcb2, parseKicadSexpr } from "kicadts";
|
|
83877
|
+
import fs27 from "node:fs";
|
|
83878
|
+
import path29 from "node:path";
|
|
83879
|
+
import { At as At2, KicadPcb as KicadPcb2, parseKicadSexpr } from "kicadts";
|
|
82933
83880
|
var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
82934
83881
|
if (!libraryLink) {
|
|
82935
83882
|
return {
|
|
@@ -82954,7 +83901,7 @@ var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
|
82954
83901
|
var sanitizeFootprint = (footprint) => {
|
|
82955
83902
|
const { libraryName, footprintName } = sanitizeLibraryAndFootprintName(footprint.libraryLink);
|
|
82956
83903
|
footprint.libraryLink = footprintName;
|
|
82957
|
-
footprint.position =
|
|
83904
|
+
footprint.position = At2.from([0, 0, 0]);
|
|
82958
83905
|
footprint.locked = false;
|
|
82959
83906
|
footprint.placed = false;
|
|
82960
83907
|
footprint.uuid = undefined;
|
|
@@ -82988,8 +83935,8 @@ var generateKicadFootprintLibrary = async ({
|
|
|
82988
83935
|
projects,
|
|
82989
83936
|
distDir
|
|
82990
83937
|
}) => {
|
|
82991
|
-
const libraryRoot =
|
|
82992
|
-
|
|
83938
|
+
const libraryRoot = path29.join(distDir, "kicad-footprints");
|
|
83939
|
+
fs27.mkdirSync(libraryRoot, { recursive: true });
|
|
82993
83940
|
const uniqueFootprints = new Map;
|
|
82994
83941
|
for (const project of projects) {
|
|
82995
83942
|
try {
|
|
@@ -83012,10 +83959,10 @@ var generateKicadFootprintLibrary = async ({
|
|
|
83012
83959
|
const libraryNames = new Set;
|
|
83013
83960
|
for (const entry of uniqueFootprints.values()) {
|
|
83014
83961
|
libraryNames.add(entry.libraryName);
|
|
83015
|
-
const libraryDir =
|
|
83016
|
-
|
|
83017
|
-
const footprintPath =
|
|
83018
|
-
|
|
83962
|
+
const libraryDir = path29.join(libraryRoot, `${entry.libraryName}.pretty`);
|
|
83963
|
+
fs27.mkdirSync(libraryDir, { recursive: true });
|
|
83964
|
+
const footprintPath = path29.join(libraryDir, `${entry.footprintName}.kicad_mod`);
|
|
83965
|
+
fs27.writeFileSync(footprintPath, `${entry.content}
|
|
83019
83966
|
`);
|
|
83020
83967
|
}
|
|
83021
83968
|
if (libraryNames.size > 0) {
|
|
@@ -83025,7 +83972,7 @@ ${libTableEntries.join(`
|
|
|
83025
83972
|
`)}
|
|
83026
83973
|
)
|
|
83027
83974
|
`;
|
|
83028
|
-
|
|
83975
|
+
fs27.writeFileSync(path29.join(libraryRoot, "fp-lib-table"), libTableContent);
|
|
83029
83976
|
}
|
|
83030
83977
|
};
|
|
83031
83978
|
var extractFootprintsFromPcb = (pcbContent) => {
|
|
@@ -83050,7 +83997,7 @@ var extractFootprintsFromPcb = (pcbContent) => {
|
|
|
83050
83997
|
};
|
|
83051
83998
|
|
|
83052
83999
|
// lib/shared/export-snippet.ts
|
|
83053
|
-
var writeFileAsync = promisify3(
|
|
84000
|
+
var writeFileAsync = promisify3(fs28.writeFile);
|
|
83054
84001
|
var ALLOWED_EXPORT_FORMATS = [
|
|
83055
84002
|
"json",
|
|
83056
84003
|
"circuit-json",
|
|
@@ -83095,10 +84042,10 @@ var exportSnippet = async ({
|
|
|
83095
84042
|
onError(`Invalid format: ${format}`);
|
|
83096
84043
|
return onExit(1);
|
|
83097
84044
|
}
|
|
83098
|
-
const projectDir =
|
|
83099
|
-
const outputBaseName =
|
|
84045
|
+
const projectDir = path30.dirname(filePath);
|
|
84046
|
+
const outputBaseName = path30.basename(filePath).replace(/\.[^.]+$/, "");
|
|
83100
84047
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
83101
|
-
const outputDestination =
|
|
84048
|
+
const outputDestination = path30.join(projectDir, outputPath ?? outputFileName);
|
|
83102
84049
|
const circuitData = await generateCircuitJson({
|
|
83103
84050
|
filePath,
|
|
83104
84051
|
saveToFile: format === "circuit-json",
|
|
@@ -83310,12 +84257,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
83310
84257
|
};
|
|
83311
84258
|
|
|
83312
84259
|
// lib/eecircuit-engine/run-simulation.ts
|
|
83313
|
-
import { promises as
|
|
83314
|
-
import
|
|
84260
|
+
import { promises as fs29, existsSync as existsSync11 } from "node:fs";
|
|
84261
|
+
import path31 from "node:path";
|
|
83315
84262
|
import os4 from "node:os";
|
|
83316
84263
|
var sim = null;
|
|
83317
84264
|
var fetchSimulation = async () => {
|
|
83318
|
-
const tempFilePath =
|
|
84265
|
+
const tempFilePath = path31.join(os4.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
83319
84266
|
if (!existsSync11(tempFilePath)) {
|
|
83320
84267
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
83321
84268
|
const response = await fetch(url);
|
|
@@ -83323,7 +84270,7 @@ var fetchSimulation = async () => {
|
|
|
83323
84270
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
83324
84271
|
}
|
|
83325
84272
|
const scriptContent = await response.text();
|
|
83326
|
-
await
|
|
84273
|
+
await fs29.writeFile(tempFilePath, scriptContent);
|
|
83327
84274
|
}
|
|
83328
84275
|
const module2 = await import(tempFilePath);
|
|
83329
84276
|
return module2.Simulation;
|
|
@@ -83412,8 +84359,8 @@ var resultToCsv = (result) => {
|
|
|
83412
84359
|
};
|
|
83413
84360
|
|
|
83414
84361
|
// cli/export/register.ts
|
|
83415
|
-
import
|
|
83416
|
-
import { promises as
|
|
84362
|
+
import path32 from "node:path";
|
|
84363
|
+
import { promises as fs30 } from "node:fs";
|
|
83417
84364
|
var registerExport = (program3) => {
|
|
83418
84365
|
program3.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").action(async (file, options) => {
|
|
83419
84366
|
const formatOption = options.format ?? "json";
|
|
@@ -83425,12 +84372,12 @@ var registerExport = (program3) => {
|
|
|
83425
84372
|
});
|
|
83426
84373
|
if (circuitJson) {
|
|
83427
84374
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
83428
|
-
const outputSpicePath = options.output ??
|
|
83429
|
-
await
|
|
84375
|
+
const outputSpicePath = options.output ?? path32.join(path32.dirname(file), `${path32.basename(file, path32.extname(file))}.spice.cir`);
|
|
84376
|
+
await fs30.writeFile(outputSpicePath, spiceString);
|
|
83430
84377
|
const { result } = await runSimulation(spiceString);
|
|
83431
84378
|
const csvContent = resultToCsv(result);
|
|
83432
84379
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
83433
|
-
await
|
|
84380
|
+
await fs30.writeFile(outputCsvPath, csvContent);
|
|
83434
84381
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
83435
84382
|
}
|
|
83436
84383
|
process.exit(0);
|
|
@@ -83654,14 +84601,14 @@ class KeyStore {
|
|
|
83654
84601
|
}
|
|
83655
84602
|
}
|
|
83656
84603
|
function createKey(key) {
|
|
83657
|
-
let
|
|
84604
|
+
let path33 = null;
|
|
83658
84605
|
let id = null;
|
|
83659
84606
|
let src = null;
|
|
83660
84607
|
let weight = 1;
|
|
83661
84608
|
let getFn = null;
|
|
83662
84609
|
if (isString2(key) || isArray(key)) {
|
|
83663
84610
|
src = key;
|
|
83664
|
-
|
|
84611
|
+
path33 = createKeyPath(key);
|
|
83665
84612
|
id = createKeyId(key);
|
|
83666
84613
|
} else {
|
|
83667
84614
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -83675,11 +84622,11 @@ function createKey(key) {
|
|
|
83675
84622
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
83676
84623
|
}
|
|
83677
84624
|
}
|
|
83678
|
-
|
|
84625
|
+
path33 = createKeyPath(name);
|
|
83679
84626
|
id = createKeyId(name);
|
|
83680
84627
|
getFn = key.getFn;
|
|
83681
84628
|
}
|
|
83682
|
-
return { path:
|
|
84629
|
+
return { path: path33, id, weight, src, getFn };
|
|
83683
84630
|
}
|
|
83684
84631
|
function createKeyPath(key) {
|
|
83685
84632
|
return isArray(key) ? key : key.split(".");
|
|
@@ -83687,34 +84634,34 @@ function createKeyPath(key) {
|
|
|
83687
84634
|
function createKeyId(key) {
|
|
83688
84635
|
return isArray(key) ? key.join(".") : key;
|
|
83689
84636
|
}
|
|
83690
|
-
function get(obj,
|
|
84637
|
+
function get(obj, path33) {
|
|
83691
84638
|
let list = [];
|
|
83692
84639
|
let arr = false;
|
|
83693
|
-
const deepGet = (obj2,
|
|
84640
|
+
const deepGet = (obj2, path34, index) => {
|
|
83694
84641
|
if (!isDefined(obj2)) {
|
|
83695
84642
|
return;
|
|
83696
84643
|
}
|
|
83697
|
-
if (!
|
|
84644
|
+
if (!path34[index]) {
|
|
83698
84645
|
list.push(obj2);
|
|
83699
84646
|
} else {
|
|
83700
|
-
let key =
|
|
84647
|
+
let key = path34[index];
|
|
83701
84648
|
const value = obj2[key];
|
|
83702
84649
|
if (!isDefined(value)) {
|
|
83703
84650
|
return;
|
|
83704
84651
|
}
|
|
83705
|
-
if (index ===
|
|
84652
|
+
if (index === path34.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
|
|
83706
84653
|
list.push(toString(value));
|
|
83707
84654
|
} else if (isArray(value)) {
|
|
83708
84655
|
arr = true;
|
|
83709
84656
|
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
83710
|
-
deepGet(value[i],
|
|
84657
|
+
deepGet(value[i], path34, index + 1);
|
|
83711
84658
|
}
|
|
83712
|
-
} else if (
|
|
83713
|
-
deepGet(value,
|
|
84659
|
+
} else if (path34.length) {
|
|
84660
|
+
deepGet(value, path34, index + 1);
|
|
83714
84661
|
}
|
|
83715
84662
|
}
|
|
83716
84663
|
};
|
|
83717
|
-
deepGet(obj, isString2(
|
|
84664
|
+
deepGet(obj, isString2(path33) ? path33.split(".") : path33, 0);
|
|
83718
84665
|
return arr ? list : list[0];
|
|
83719
84666
|
}
|
|
83720
84667
|
var MatchOptions = {
|
|
@@ -84906,8 +85853,8 @@ var registerSearch = (program3) => {
|
|
|
84906
85853
|
}
|
|
84907
85854
|
if (kicadResults.length) {
|
|
84908
85855
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
84909
|
-
kicadResults.forEach((
|
|
84910
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
85856
|
+
kicadResults.forEach((path33, idx) => {
|
|
85857
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path33.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
84911
85858
|
});
|
|
84912
85859
|
}
|
|
84913
85860
|
if (!onlyKicad && results.packages.length) {
|
|
@@ -85839,7 +86786,7 @@ var require_svgson_umd = __commonJS2({
|
|
|
85839
86786
|
});
|
|
85840
86787
|
}
|
|
85841
86788
|
});
|
|
85842
|
-
function
|
|
86789
|
+
function applyToPoint14(matrix, point2) {
|
|
85843
86790
|
return Array.isArray(point2) ? [
|
|
85844
86791
|
matrix.a * point2[0] + matrix.c * point2[1] + matrix.e,
|
|
85845
86792
|
matrix.b * point2[0] + matrix.d * point2[1] + matrix.f
|
|
@@ -85848,7 +86795,7 @@ function applyToPoint8(matrix, point2) {
|
|
|
85848
86795
|
y: matrix.b * point2.x + matrix.d * point2.y + matrix.f
|
|
85849
86796
|
};
|
|
85850
86797
|
}
|
|
85851
|
-
function
|
|
86798
|
+
function translate4(tx2, ty2 = 0) {
|
|
85852
86799
|
return {
|
|
85853
86800
|
a: 1,
|
|
85854
86801
|
c: 0,
|
|
@@ -85884,14 +86831,14 @@ function transform(...matrices) {
|
|
|
85884
86831
|
}
|
|
85885
86832
|
}
|
|
85886
86833
|
}
|
|
85887
|
-
function
|
|
86834
|
+
function compose4(...matrices) {
|
|
85888
86835
|
return transform(...matrices);
|
|
85889
86836
|
}
|
|
85890
86837
|
function isUndefined2(val) {
|
|
85891
86838
|
return typeof val === "undefined";
|
|
85892
86839
|
}
|
|
85893
86840
|
var { cos, sin, PI } = Math;
|
|
85894
|
-
function
|
|
86841
|
+
function rotate5(angle, cx2, cy2) {
|
|
85895
86842
|
const cosAngle = cos(angle);
|
|
85896
86843
|
const sinAngle = sin(angle);
|
|
85897
86844
|
const rotationMatrix = {
|
|
@@ -85906,9 +86853,9 @@ function rotate(angle, cx2, cy2) {
|
|
|
85906
86853
|
return rotationMatrix;
|
|
85907
86854
|
}
|
|
85908
86855
|
return transform([
|
|
85909
|
-
|
|
86856
|
+
translate4(cx2, cy2),
|
|
85910
86857
|
rotationMatrix,
|
|
85911
|
-
|
|
86858
|
+
translate4(-cx2, -cy2)
|
|
85912
86859
|
]);
|
|
85913
86860
|
}
|
|
85914
86861
|
function scale8(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
@@ -85926,12 +86873,12 @@ function scale8(sx2, sy2 = undefined, cx2 = undefined, cy2 = undefined) {
|
|
|
85926
86873
|
return scaleMatrix;
|
|
85927
86874
|
}
|
|
85928
86875
|
return transform([
|
|
85929
|
-
|
|
86876
|
+
translate4(cx2, cy2),
|
|
85930
86877
|
scaleMatrix,
|
|
85931
|
-
|
|
86878
|
+
translate4(-cx2, -cy2)
|
|
85932
86879
|
]);
|
|
85933
86880
|
}
|
|
85934
|
-
function
|
|
86881
|
+
function identity4() {
|
|
85935
86882
|
return {
|
|
85936
86883
|
a: 1,
|
|
85937
86884
|
c: 0,
|
|
@@ -86072,12 +87019,12 @@ peg$SyntaxError.buildMessage = function(expected, found) {
|
|
|
86072
87019
|
function decomposeTSR2(matrix, flipX = false, flipY2 = false) {
|
|
86073
87020
|
if (flipX) {
|
|
86074
87021
|
if (flipY2) {
|
|
86075
|
-
matrix =
|
|
87022
|
+
matrix = compose4(matrix, scale8(-1, -1));
|
|
86076
87023
|
} else {
|
|
86077
|
-
matrix =
|
|
87024
|
+
matrix = compose4(matrix, scale8(1, -1));
|
|
86078
87025
|
}
|
|
86079
87026
|
} else if (flipY2) {
|
|
86080
|
-
matrix =
|
|
87027
|
+
matrix = compose4(matrix, scale8(-1, 1));
|
|
86081
87028
|
}
|
|
86082
87029
|
const a = matrix.a;
|
|
86083
87030
|
const b3 = matrix.b;
|
|
@@ -88155,7 +89102,7 @@ function buildSubtree(soup, opts) {
|
|
|
88155
89102
|
}
|
|
88156
89103
|
return soup.filter((e3) => included.has(e3));
|
|
88157
89104
|
}
|
|
88158
|
-
var
|
|
89105
|
+
var cju4 = (circuitJsonInput, options = {}) => {
|
|
88159
89106
|
const circuitJson = circuitJsonInput;
|
|
88160
89107
|
let internalStore = circuitJson._internal_store;
|
|
88161
89108
|
if (!internalStore) {
|
|
@@ -88187,7 +89134,7 @@ var cju3 = (circuitJsonInput, options = {}) => {
|
|
|
88187
89134
|
return internalStore.editCount;
|
|
88188
89135
|
}
|
|
88189
89136
|
if (prop === "subtree") {
|
|
88190
|
-
return (opts) =>
|
|
89137
|
+
return (opts) => cju4(buildSubtree(circuitJson, opts), options);
|
|
88191
89138
|
}
|
|
88192
89139
|
const component_type = prop;
|
|
88193
89140
|
return {
|
|
@@ -88269,9 +89216,9 @@ var cju3 = (circuitJsonInput, options = {}) => {
|
|
|
88269
89216
|
});
|
|
88270
89217
|
return su22;
|
|
88271
89218
|
};
|
|
88272
|
-
|
|
88273
|
-
var su6 =
|
|
88274
|
-
var cju_default =
|
|
89219
|
+
cju4.unparsed = cju4;
|
|
89220
|
+
var su6 = cju4;
|
|
89221
|
+
var cju_default = cju4;
|
|
88275
89222
|
function createIdKey(element) {
|
|
88276
89223
|
const type = element.type;
|
|
88277
89224
|
return `${type}:${element[`${type}_id`]}`;
|
|
@@ -88739,20 +89686,20 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
88739
89686
|
const tsr = decomposeTSR2(matrix);
|
|
88740
89687
|
const flipPadWidthHeight = Math.round(tsr.rotation.angle / (Math.PI / 2)) % 2 === 1;
|
|
88741
89688
|
if (elm.type === "pcb_plated_hole" || elm.type === "pcb_hole" || elm.type === "pcb_via" || elm.type === "pcb_smtpad" || elm.type === "pcb_port") {
|
|
88742
|
-
const { x, y } =
|
|
89689
|
+
const { x, y } = applyToPoint14(matrix, {
|
|
88743
89690
|
x: Number(elm.x),
|
|
88744
89691
|
y: Number(elm.y)
|
|
88745
89692
|
});
|
|
88746
89693
|
elm.x = x;
|
|
88747
89694
|
elm.y = y;
|
|
88748
89695
|
} else if (elm.type === "pcb_keepout" || elm.type === "pcb_board") {
|
|
88749
|
-
elm.center =
|
|
89696
|
+
elm.center = applyToPoint14(matrix, elm.center);
|
|
88750
89697
|
} else if (elm.type === "pcb_silkscreen_text" || elm.type === "pcb_fabrication_note_text") {
|
|
88751
|
-
elm.anchor_position =
|
|
89698
|
+
elm.anchor_position = applyToPoint14(matrix, elm.anchor_position);
|
|
88752
89699
|
} else if (elm.type === "pcb_silkscreen_circle" || elm.type === "pcb_silkscreen_rect") {
|
|
88753
|
-
elm.center =
|
|
89700
|
+
elm.center = applyToPoint14(matrix, elm.center);
|
|
88754
89701
|
} else if (elm.type === "pcb_component") {
|
|
88755
|
-
elm.center =
|
|
89702
|
+
elm.center = applyToPoint14(matrix, elm.center);
|
|
88756
89703
|
elm.rotation = elm.rotation + tsr.rotation.angle / Math.PI * 180;
|
|
88757
89704
|
elm.rotation = elm.rotation % 360;
|
|
88758
89705
|
if (flipPadWidthHeight) {
|
|
@@ -88760,7 +89707,7 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
88760
89707
|
}
|
|
88761
89708
|
} else if (elm.type === "pcb_silkscreen_path" || elm.type === "pcb_trace" || elm.type === "pcb_fabrication_note_path") {
|
|
88762
89709
|
elm.route = elm.route.map((rp2) => {
|
|
88763
|
-
const tp2 =
|
|
89710
|
+
const tp2 = applyToPoint14(matrix, rp2);
|
|
88764
89711
|
rp2.x = tp2.x;
|
|
88765
89712
|
rp2.y = tp2.y;
|
|
88766
89713
|
return rp2;
|
|
@@ -88768,14 +89715,14 @@ var transformPCBElement = (elm, matrix) => {
|
|
|
88768
89715
|
} else if (elm.type === "pcb_silkscreen_line") {
|
|
88769
89716
|
const p12 = { x: elm.x1, y: elm.y1 };
|
|
88770
89717
|
const p2 = { x: elm.x2, y: elm.y2 };
|
|
88771
|
-
const p1t =
|
|
88772
|
-
const p2t =
|
|
89718
|
+
const p1t = applyToPoint14(matrix, p12);
|
|
89719
|
+
const p2t = applyToPoint14(matrix, p2);
|
|
88773
89720
|
elm.x1 = p1t.x;
|
|
88774
89721
|
elm.y1 = p1t.y;
|
|
88775
89722
|
elm.x2 = p2t.x;
|
|
88776
89723
|
elm.y2 = p2t.y;
|
|
88777
89724
|
} else if (elm.type === "cad_component") {
|
|
88778
|
-
const newPos =
|
|
89725
|
+
const newPos = applyToPoint14(matrix, {
|
|
88779
89726
|
x: elm.position.x,
|
|
88780
89727
|
y: elm.position.y
|
|
88781
89728
|
});
|
|
@@ -88808,7 +89755,7 @@ var getElementById = (soup, id2) => {
|
|
|
88808
89755
|
return soup.find((elm) => getElementId(elm) === id2) ?? null;
|
|
88809
89756
|
};
|
|
88810
89757
|
function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
88811
|
-
const pcbTrace =
|
|
89758
|
+
const pcbTrace = cju4(soup).pcb_trace.get(pcb_trace_id);
|
|
88812
89759
|
if (!pcbTrace) {
|
|
88813
89760
|
return `trace[${pcb_trace_id}]`;
|
|
88814
89761
|
}
|
|
@@ -88817,16 +89764,16 @@ function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
|
88817
89764
|
return `trace[${pcb_trace_id}]`;
|
|
88818
89765
|
}
|
|
88819
89766
|
function getComponentAndPortInfo(pcb_port_id) {
|
|
88820
|
-
const pcbPort =
|
|
89767
|
+
const pcbPort = cju4(soup).pcb_port.get(pcb_port_id);
|
|
88821
89768
|
if (!pcbPort)
|
|
88822
89769
|
return null;
|
|
88823
|
-
const pcbComponent =
|
|
89770
|
+
const pcbComponent = cju4(soup).pcb_component.get(pcbPort.pcb_component_id);
|
|
88824
89771
|
if (!pcbComponent)
|
|
88825
89772
|
return null;
|
|
88826
|
-
const sourceComponent =
|
|
89773
|
+
const sourceComponent = cju4(soup).source_component.get(pcbComponent.source_component_id);
|
|
88827
89774
|
if (!sourceComponent)
|
|
88828
89775
|
return null;
|
|
88829
|
-
const sourcePort =
|
|
89776
|
+
const sourcePort = cju4(soup).source_port.get(pcbPort.source_port_id);
|
|
88830
89777
|
const portHint = sourcePort?.port_hints ? sourcePort.port_hints[1] : "";
|
|
88831
89778
|
return {
|
|
88832
89779
|
componentName: sourceComponent.name,
|
|
@@ -88843,19 +89790,19 @@ function getReadableNameForPcbTrace(soup, pcb_trace_id) {
|
|
|
88843
89790
|
return `trace[${selectorParts.join(", ")}]`;
|
|
88844
89791
|
}
|
|
88845
89792
|
var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
88846
|
-
const pcbPort =
|
|
89793
|
+
const pcbPort = cju4(soup).pcb_port.get(pcb_port_id);
|
|
88847
89794
|
if (!pcbPort) {
|
|
88848
89795
|
return `pcb_port[#${pcb_port_id}]`;
|
|
88849
89796
|
}
|
|
88850
|
-
const pcbComponent =
|
|
89797
|
+
const pcbComponent = cju4(soup).pcb_component.get(pcbPort?.pcb_component_id);
|
|
88851
89798
|
if (!pcbComponent) {
|
|
88852
89799
|
return `pcb_port[#${pcb_port_id}]`;
|
|
88853
89800
|
}
|
|
88854
|
-
const sourceComponent =
|
|
89801
|
+
const sourceComponent = cju4(soup).source_component.get(pcbComponent.source_component_id);
|
|
88855
89802
|
if (!sourceComponent) {
|
|
88856
89803
|
return `pcb_port[#${pcb_port_id}]`;
|
|
88857
89804
|
}
|
|
88858
|
-
const sourcePort =
|
|
89805
|
+
const sourcePort = cju4(soup).source_port.get(pcbPort.source_port_id);
|
|
88859
89806
|
if (!sourcePort) {
|
|
88860
89807
|
return `pcb_port[#${pcb_port_id}]`;
|
|
88861
89808
|
}
|
|
@@ -88870,7 +89817,7 @@ var getReadableNameForPcbPort = (soup, pcb_port_id) => {
|
|
|
88870
89817
|
return `pcb_port[.${sourceComponent.name} > .${padIdentifier}]`;
|
|
88871
89818
|
};
|
|
88872
89819
|
function getReadableNameForPcbSmtpad(soup, pcb_smtpad_id) {
|
|
88873
|
-
const pcbSmtpad =
|
|
89820
|
+
const pcbSmtpad = cju4(soup).pcb_smtpad.get(pcb_smtpad_id);
|
|
88874
89821
|
if (!pcbSmtpad || !pcbSmtpad.pcb_port_id) {
|
|
88875
89822
|
return `smtpad[${pcb_smtpad_id}]`;
|
|
88876
89823
|
}
|
|
@@ -89172,7 +90119,7 @@ var repositionPcbComponentTo = (circuitJson, pcb_component_id, newCenter) => {
|
|
|
89172
90119
|
return true;
|
|
89173
90120
|
return false;
|
|
89174
90121
|
});
|
|
89175
|
-
const matrix =
|
|
90122
|
+
const matrix = translate4(dx2, dy2);
|
|
89176
90123
|
transformPCBElements(elementsToMove, matrix);
|
|
89177
90124
|
};
|
|
89178
90125
|
var getCircuitJsonTree = (circuitJson, opts) => {
|
|
@@ -89858,8 +90805,8 @@ var Ty = E(Fe);
|
|
|
89858
90805
|
var R = { paths: { path11: { type: "path", points: [{ x: -0.54, y: 0.04 }, { x: -0.22, y: 0.04 }], color: "primary", fill: false }, path12: { type: "path", points: [{ x: 0.14, y: 0.05 }, { x: 0.46, y: 0.05 }], color: "primary", fill: false }, "path12-6": { type: "path", points: [{ x: 0.14, y: -0.15 }, { x: 0.14, y: 0.25 }], color: "primary", fill: false }, "path11-0-9": { type: "path", points: [{ x: -0.22, y: 0.25 }, { x: -0.21, y: -0.15 }, { x: 0.14, y: 0.05 }, { x: -0.22, y: 0.25 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.09, y: 0.38 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.38 }, right1: { type: "text", text: "", x: 0.59, y: -0.33 } }, refblocks: { left1: { x: -0.56, y: 0.04 }, right1: { x: 0.48, y: 0.05 } }, bounds: { minX: -0.59, maxX: 0.59, minY: -0.38, maxY: 0.38, width: 1.18, height: 0.76, centerX: 0, centerY: 0 }, circles: {} };
|
|
89859
90806
|
var { paths: fc, texts: O7, bounds: Re, refblocks: Ey, circles: hc } = R;
|
|
89860
90807
|
var Yy = e({ primitives: [...Object.values(fc), ...Object.values(hc), { type: "text", text: "{REF}", x: -0.15, y: 0.3294553499999995 }, { type: "text", text: "{VAL}", x: 0.15, y: 0.3294553499999995 }], ports: [{ ...Ey.left1, labels: ["1"] }, { ...Ey.right1, labels: ["2"] }], size: { width: Re.width, height: Re.height }, center: { x: Re.centerX, y: Re.centerY } }).rotateRightFacingSymbol("down").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_left").changeTextAnchor("{VAL}", "middle_left").build();
|
|
89861
|
-
var { paths: cc, texts: C7, bounds: Te, refblocks:
|
|
89862
|
-
var Ly = e({ primitives: [...Object.values(cc), ...Object.values(dc), { type: "text", text: "{REF}", x: -0, y: 0.4094553499999995 }, { type: "text", text: "{VAL}", x: 0, y: -0.4094553499999995 }], ports: [{ ...
|
|
90808
|
+
var { paths: cc, texts: C7, bounds: Te, refblocks: Xy4, circles: dc } = R;
|
|
90809
|
+
var Ly = e({ primitives: [...Object.values(cc), ...Object.values(dc), { type: "text", text: "{REF}", x: -0, y: 0.4094553499999995 }, { type: "text", text: "{VAL}", x: 0, y: -0.4094553499999995 }], ports: [{ ...Xy4.left1, labels: ["1"] }, { ...Xy4.right1, labels: ["2"] }], size: { width: Te.width, height: Te.height }, center: { x: Te.centerX, y: Te.centerY } }).changeTextAnchor("{VAL}", "middle_top").rotateRightFacingSymbol("right").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_bottom").build();
|
|
89863
90810
|
var { paths: bc, texts: q7, bounds: Ee, refblocks: Vy, circles: _c } = R;
|
|
89864
90811
|
var jy = e({ primitives: [...Object.values(bc), ...Object.values(_c), { type: "text", text: "{REF}", x: -0, y: -0.3094553499999995 }, { type: "text", text: "{VAL}", x: 0, y: 0.4094553499999995 }], ports: [{ ...Vy.left1, labels: ["1"] }, { ...Vy.right1, labels: ["2"] }], size: { width: Ee.width, height: Ee.height }, center: { x: Ee.centerX, y: Ee.centerY } }).changeTextAnchor("{VAL}", "middle_bottom").rotateRightFacingSymbol("left").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_bottom").build();
|
|
89865
90812
|
var { paths: gc, texts: W7, bounds: Ye, refblocks: ky2, circles: uc } = R;
|
|
@@ -89870,12 +90817,12 @@ var { paths: Ac, texts: ov, bounds: Le, refblocks: $y, circles: Pc } = R;
|
|
|
89870
90817
|
var My = e({ primitives: [...Object.values(Ac), ...Object.values(Pc), { type: "text", text: "{REF}", x: 0.15, y: -0.2894553499999995 }, { type: "text", text: "{VAL}", x: -0.15, y: -0.2894553499999995 }], ports: [{ ...$y.left1, labels: ["1"] }, { ...$y.right1, labels: ["2"] }], size: { width: Le.width, height: Le.height }, center: { x: Le.centerX, y: Le.centerY } }).rotateRightFacingSymbol("up").labelPort("left1", ["1"]).labelPort("right1", ["2"]).changeTextAnchor("{REF}", "middle_left").changeTextAnchor("{VAL}", "middle_left").build();
|
|
89871
90818
|
var Cy = { paths: { path11: { type: "path", points: [{ x: -0.53, y: 0 }, { x: -0.3, y: 0 }], color: "primary", fill: false }, path12: { type: "path", points: [{ x: 0.29, y: 0 }, { x: 0.53, y: 0 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.18, y: -0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.01, y: 0.43 }, left1: { type: "text", text: "Hz", x: 0, y: -0.04 } }, refblocks: { left1: { x: -0.54, y: 0 }, right1: { x: 0.54, y: 0 } }, bounds: { minX: -0.53, maxX: 0.53, minY: 0, maxY: 0, width: 1.06, height: 1, centerX: 0, centerY: 0 }, circles: { path1: { type: "circle", x: -0.01, y: -0.01, radius: 0.29, color: "primary", fill: false } } };
|
|
89872
90819
|
var { paths: Fc, texts: Rc, bounds: Ve, refblocks: Ny, circles: Tc } = Cy;
|
|
89873
|
-
var
|
|
89874
|
-
var { 5: Ec, ...Yc } =
|
|
90820
|
+
var At3 = s({ primitives: [...Object.values(Fc), ...Object.values(Tc), { type: "text", text: "{REF}", x: 0, y: -0.3594553499999995, anchor: "middle_top" }, { type: "text", text: "{VAL}", x: 0, y: 0.35, anchor: "middle_bottom" }, { ...Rc.left1, x: 0, y: 0.01, anchor: "center", fontSize: 0.2 }], ports: [{ ...Ny.left1, labels: ["1"] }, { ...Ny.right1, labels: ["2"] }], size: { width: Ve.width, height: Ve.height }, center: { x: Ve.centerX, y: Ve.centerY } });
|
|
90821
|
+
var { 5: Ec, ...Yc } = At3.primitives;
|
|
89875
90822
|
function Xc(t2) {
|
|
89876
90823
|
return typeof t2 == "object";
|
|
89877
90824
|
}
|
|
89878
|
-
var Iy = r({ ...
|
|
90825
|
+
var Iy = r({ ...At3, primitives: Object.values(Yc).filter(Xc) });
|
|
89879
90826
|
var By = { ...Iy, primitives: [...Iy.primitives, Ec] };
|
|
89880
90827
|
var qy = { paths: { path10: { type: "path", points: [{ x: -0.53, y: 0.04 }, { x: 0.53, y: 0.04 }], color: "primary", fill: false }, path14: { type: "path", points: [{ x: 0, y: 0.17 }, { x: 0.27, y: 0.17 }, { x: 0.27, y: -0.1 }, { x: -0.26, y: -0.1 }, { x: -0.26, y: 0.17 }, { x: 0, y: 0.17 }], color: "primary", fill: false } }, texts: { top1: { type: "text", text: "{REF}", x: -0.01, y: 0.24 }, bottom1: { type: "text", text: "{VAL}", x: -0.17, y: -0.24 } }, refblocks: { left1: { x: -0.53, y: 0.04 }, right1: { x: 0.53, y: 0.04 } }, bounds: { minX: -0.56, maxX: 0.56, minY: -0.24, maxY: 0.24, width: 1.13, height: 0.47, centerX: 0, centerY: 0 }, circles: {} };
|
|
89881
90828
|
var { paths: Vc, texts: jc, bounds: je, refblocks: Dy } = qy;
|
|
@@ -90086,7 +91033,7 @@ var { paths: Ad, bounds: ss, refblocks: Pd } = xs;
|
|
|
90086
91033
|
var U = e({ primitives: [...Object.values(Ad)], ports: [{ ...Pd.left1, labels: ["1"] }], center: { x: ss.centerX, y: ss.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
|
|
90087
91034
|
var ms = r(U, "down");
|
|
90088
91035
|
var ns = r(U, "left");
|
|
90089
|
-
var
|
|
91036
|
+
var fs31 = r(U, "up");
|
|
90090
91037
|
var g = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.54 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.54 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
90091
91038
|
var { paths: Fd, texts: XA, bounds: e0, refblocks: Mo, circles: Rd } = g;
|
|
90092
91039
|
var hs = e({ primitives: [...Object.values(Fd), ...Object.values(Rd), { type: "text", text: "{REF}", x: -0.1, y: 0.3094553499999995 }, { type: "text", text: "{VAL}", x: -0.1, y: -0.3094553499999995 }], ports: [{ ...Mo.top1, labels: ["1", "collector"] }, { ...Mo.bottom1, labels: ["2", "emitter"] }, { ...Mo.left1, labels: ["3", "base"] }], size: { width: e0.width, height: e0.height }, center: { x: e0.centerX, y: e0.centerY } }).rotateRightFacingSymbol("right").changeTextAnchor("{REF}", "middle_right").changeTextAnchor("{VAL}", "middle_right").build();
|
|
@@ -90655,7 +91602,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
|
|
|
90655
91602
|
sb.anchor = "middle_left";
|
|
90656
91603
|
mb.anchor = "middle_right";
|
|
90657
91604
|
var B1 = Cl;
|
|
90658
|
-
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz:
|
|
91605
|
+
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At3, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os5, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs31, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
|
|
90659
91606
|
var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
|
|
90660
91607
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
90661
91608
|
lineThickness = 0
|
|
@@ -92685,11 +93632,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
92685
93632
|
fiber = fiber.next, id2--;
|
|
92686
93633
|
return fiber;
|
|
92687
93634
|
}
|
|
92688
|
-
function copyWithSetImpl(obj,
|
|
92689
|
-
if (index >=
|
|
93635
|
+
function copyWithSetImpl(obj, path33, index, value) {
|
|
93636
|
+
if (index >= path33.length)
|
|
92690
93637
|
return value;
|
|
92691
|
-
var key =
|
|
92692
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
93638
|
+
var key = path33[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
93639
|
+
updated[key] = copyWithSetImpl(obj[key], path33, index + 1, value);
|
|
92693
93640
|
return updated;
|
|
92694
93641
|
}
|
|
92695
93642
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -92709,11 +93656,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
92709
93656
|
index + 1 === oldPath.length ? (updated[newPath[index]] = updated[oldKey], isArrayImpl(updated) ? updated.splice(oldKey, 1) : delete updated[oldKey]) : updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index + 1);
|
|
92710
93657
|
return updated;
|
|
92711
93658
|
}
|
|
92712
|
-
function copyWithDeleteImpl(obj,
|
|
92713
|
-
var key =
|
|
92714
|
-
if (index + 1 ===
|
|
93659
|
+
function copyWithDeleteImpl(obj, path33, index) {
|
|
93660
|
+
var key = path33[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
93661
|
+
if (index + 1 === path33.length)
|
|
92715
93662
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
92716
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
93663
|
+
updated[key] = copyWithDeleteImpl(obj[key], path33, index + 1);
|
|
92717
93664
|
return updated;
|
|
92718
93665
|
}
|
|
92719
93666
|
function shouldSuspendImpl() {
|
|
@@ -101744,29 +102691,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
101744
102691
|
var didWarnAboutNestedUpdates = false;
|
|
101745
102692
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
101746
102693
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
101747
|
-
overrideHookState = function(fiber, id2,
|
|
102694
|
+
overrideHookState = function(fiber, id2, path33, value) {
|
|
101748
102695
|
id2 = findHook(fiber, id2);
|
|
101749
|
-
id2 !== null && (
|
|
102696
|
+
id2 !== null && (path33 = copyWithSetImpl(id2.memoizedState, path33, 0, value), id2.memoizedState = path33, id2.baseState = path33, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path33 = enqueueConcurrentRenderForLane(fiber, 2), path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2));
|
|
101750
102697
|
};
|
|
101751
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
102698
|
+
overrideHookStateDeletePath = function(fiber, id2, path33) {
|
|
101752
102699
|
id2 = findHook(fiber, id2);
|
|
101753
|
-
id2 !== null && (
|
|
102700
|
+
id2 !== null && (path33 = copyWithDeleteImpl(id2.memoizedState, path33, 0), id2.memoizedState = path33, id2.baseState = path33, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path33 = enqueueConcurrentRenderForLane(fiber, 2), path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2));
|
|
101754
102701
|
};
|
|
101755
102702
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
101756
102703
|
id2 = findHook(fiber, id2);
|
|
101757
102704
|
id2 !== null && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
101758
102705
|
};
|
|
101759
|
-
overrideProps = function(fiber,
|
|
101760
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
102706
|
+
overrideProps = function(fiber, path33, value) {
|
|
102707
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path33, 0, value);
|
|
101761
102708
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
101762
|
-
|
|
101763
|
-
|
|
102709
|
+
path33 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
102710
|
+
path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2);
|
|
101764
102711
|
};
|
|
101765
|
-
overridePropsDeletePath = function(fiber,
|
|
101766
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
102712
|
+
overridePropsDeletePath = function(fiber, path33) {
|
|
102713
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path33, 0);
|
|
101767
102714
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
101768
|
-
|
|
101769
|
-
|
|
102715
|
+
path33 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
102716
|
+
path33 !== null && scheduleUpdateOnFiber(path33, fiber, 2);
|
|
101770
102717
|
};
|
|
101771
102718
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
101772
102719
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -117103,10 +118050,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117103
118050
|
var setErrorHandler = null;
|
|
117104
118051
|
var setSuspenseHandler = null;
|
|
117105
118052
|
{
|
|
117106
|
-
var copyWithDeleteImpl = function(obj,
|
|
117107
|
-
var key =
|
|
118053
|
+
var copyWithDeleteImpl = function(obj, path33, index2) {
|
|
118054
|
+
var key = path33[index2];
|
|
117108
118055
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
117109
|
-
if (index2 + 1 ===
|
|
118056
|
+
if (index2 + 1 === path33.length) {
|
|
117110
118057
|
if (isArray2(updated)) {
|
|
117111
118058
|
updated.splice(key, 1);
|
|
117112
118059
|
} else {
|
|
@@ -117114,11 +118061,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117114
118061
|
}
|
|
117115
118062
|
return updated;
|
|
117116
118063
|
}
|
|
117117
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
118064
|
+
updated[key] = copyWithDeleteImpl(obj[key], path33, index2 + 1);
|
|
117118
118065
|
return updated;
|
|
117119
118066
|
};
|
|
117120
|
-
var copyWithDelete = function(obj,
|
|
117121
|
-
return copyWithDeleteImpl(obj,
|
|
118067
|
+
var copyWithDelete = function(obj, path33) {
|
|
118068
|
+
return copyWithDeleteImpl(obj, path33, 0);
|
|
117122
118069
|
};
|
|
117123
118070
|
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
|
117124
118071
|
var oldKey = oldPath[index2];
|
|
@@ -117150,17 +118097,17 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117150
118097
|
}
|
|
117151
118098
|
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
|
117152
118099
|
};
|
|
117153
|
-
var copyWithSetImpl = function(obj,
|
|
117154
|
-
if (index2 >=
|
|
118100
|
+
var copyWithSetImpl = function(obj, path33, index2, value) {
|
|
118101
|
+
if (index2 >= path33.length) {
|
|
117155
118102
|
return value;
|
|
117156
118103
|
}
|
|
117157
|
-
var key =
|
|
118104
|
+
var key = path33[index2];
|
|
117158
118105
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
117159
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
118106
|
+
updated[key] = copyWithSetImpl(obj[key], path33, index2 + 1, value);
|
|
117160
118107
|
return updated;
|
|
117161
118108
|
};
|
|
117162
|
-
var copyWithSet = function(obj,
|
|
117163
|
-
return copyWithSetImpl(obj,
|
|
118109
|
+
var copyWithSet = function(obj, path33, value) {
|
|
118110
|
+
return copyWithSetImpl(obj, path33, 0, value);
|
|
117164
118111
|
};
|
|
117165
118112
|
var findHook = function(fiber, id2) {
|
|
117166
118113
|
var currentHook2 = fiber.memoizedState;
|
|
@@ -117170,10 +118117,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117170
118117
|
}
|
|
117171
118118
|
return currentHook2;
|
|
117172
118119
|
};
|
|
117173
|
-
overrideHookState = function(fiber, id2,
|
|
118120
|
+
overrideHookState = function(fiber, id2, path33, value) {
|
|
117174
118121
|
var hook = findHook(fiber, id2);
|
|
117175
118122
|
if (hook !== null) {
|
|
117176
|
-
var newState = copyWithSet(hook.memoizedState,
|
|
118123
|
+
var newState = copyWithSet(hook.memoizedState, path33, value);
|
|
117177
118124
|
hook.memoizedState = newState;
|
|
117178
118125
|
hook.baseState = newState;
|
|
117179
118126
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -117183,10 +118130,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117183
118130
|
}
|
|
117184
118131
|
}
|
|
117185
118132
|
};
|
|
117186
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
118133
|
+
overrideHookStateDeletePath = function(fiber, id2, path33) {
|
|
117187
118134
|
var hook = findHook(fiber, id2);
|
|
117188
118135
|
if (hook !== null) {
|
|
117189
|
-
var newState = copyWithDelete(hook.memoizedState,
|
|
118136
|
+
var newState = copyWithDelete(hook.memoizedState, path33);
|
|
117190
118137
|
hook.memoizedState = newState;
|
|
117191
118138
|
hook.baseState = newState;
|
|
117192
118139
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -117209,8 +118156,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117209
118156
|
}
|
|
117210
118157
|
}
|
|
117211
118158
|
};
|
|
117212
|
-
overrideProps = function(fiber,
|
|
117213
|
-
fiber.pendingProps = copyWithSet(fiber.memoizedProps,
|
|
118159
|
+
overrideProps = function(fiber, path33, value) {
|
|
118160
|
+
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path33, value);
|
|
117214
118161
|
if (fiber.alternate) {
|
|
117215
118162
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
117216
118163
|
}
|
|
@@ -117219,8 +118166,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117219
118166
|
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
|
117220
118167
|
}
|
|
117221
118168
|
};
|
|
117222
|
-
overridePropsDeletePath = function(fiber,
|
|
117223
|
-
fiber.pendingProps = copyWithDelete(fiber.memoizedProps,
|
|
118169
|
+
overridePropsDeletePath = function(fiber, path33) {
|
|
118170
|
+
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path33);
|
|
117224
118171
|
if (fiber.alternate) {
|
|
117225
118172
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
117226
118173
|
}
|
|
@@ -123271,7 +124218,7 @@ var parsePin = (pinString) => {
|
|
|
123271
124218
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
123272
124219
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
123273
124220
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
123274
|
-
const
|
|
124221
|
+
const path33 = pathMatch ? pathMatch[1] : "";
|
|
123275
124222
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
123276
124223
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
123277
124224
|
const r3 = Number.parseFloat(rotation2);
|
|
@@ -123285,7 +124232,7 @@ var parsePin = (pinString) => {
|
|
|
123285
124232
|
rotation: Number.isNaN(r3) ? 0 : r3,
|
|
123286
124233
|
label,
|
|
123287
124234
|
labelColor,
|
|
123288
|
-
path:
|
|
124235
|
+
path: path33,
|
|
123289
124236
|
arrow
|
|
123290
124237
|
};
|
|
123291
124238
|
};
|
|
@@ -123725,15 +124672,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
123725
124672
|
}
|
|
123726
124673
|
}
|
|
123727
124674
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
123728
|
-
const
|
|
124675
|
+
const path33 = [];
|
|
123729
124676
|
for (let i = 0;i <= numPoints; i++) {
|
|
123730
124677
|
const t3 = i / numPoints;
|
|
123731
124678
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
123732
124679
|
const x = centerX + radius * Math.cos(angle2);
|
|
123733
124680
|
const y = centerY + radius * Math.sin(angle2);
|
|
123734
|
-
|
|
124681
|
+
path33.push({ x, y });
|
|
123735
124682
|
}
|
|
123736
|
-
return
|
|
124683
|
+
return path33;
|
|
123737
124684
|
}
|
|
123738
124685
|
var __defProp4 = Object.defineProperty;
|
|
123739
124686
|
var __export22 = (target, all) => {
|
|
@@ -125151,7 +126098,7 @@ var platedHoleWithRectPad = (pn2, x, y, holeDiameter, rectPadWidth, rectPadHeigh
|
|
|
125151
126098
|
};
|
|
125152
126099
|
};
|
|
125153
126100
|
var silkscreenPin = ({
|
|
125154
|
-
fs:
|
|
126101
|
+
fs: fs32,
|
|
125155
126102
|
pn: pn2,
|
|
125156
126103
|
anchor_x,
|
|
125157
126104
|
anchor_y,
|
|
@@ -125194,7 +126141,7 @@ var silkscreenPin = ({
|
|
|
125194
126141
|
type: "pcb_silkscreen_text",
|
|
125195
126142
|
pcb_silkscreen_text_id: "silkscreen_text_1",
|
|
125196
126143
|
font: "tscircuit2024",
|
|
125197
|
-
font_size:
|
|
126144
|
+
font_size: fs32,
|
|
125198
126145
|
pcb_component_id: "pcb_component_1",
|
|
125199
126146
|
text: `{PIN${pn2}}`,
|
|
125200
126147
|
layer,
|
|
@@ -129801,7 +130748,7 @@ var m2host = (raw_params) => {
|
|
|
129801
130748
|
}
|
|
129802
130749
|
const centerX = (minX + maxX) / 2;
|
|
129803
130750
|
const centerY = (minY + maxY) / 2;
|
|
129804
|
-
const
|
|
130751
|
+
const translate42 = (el2) => {
|
|
129805
130752
|
if (typeof el2.x === "number")
|
|
129806
130753
|
el2.x -= centerX;
|
|
129807
130754
|
if (typeof el2.y === "number")
|
|
@@ -129818,9 +130765,9 @@ var m2host = (raw_params) => {
|
|
|
129818
130765
|
}
|
|
129819
130766
|
};
|
|
129820
130767
|
for (const pad2 of pads)
|
|
129821
|
-
|
|
129822
|
-
|
|
129823
|
-
|
|
130768
|
+
translate42(pad2);
|
|
130769
|
+
translate42(cutout);
|
|
130770
|
+
translate42(pin1Marker);
|
|
129824
130771
|
return {
|
|
129825
130772
|
circuitJson: [
|
|
129826
130773
|
...pads,
|
|
@@ -132810,17 +133757,17 @@ var ObstacleList = class {
|
|
|
132810
133757
|
return obstacles;
|
|
132811
133758
|
}
|
|
132812
133759
|
};
|
|
132813
|
-
function removePathLoops(
|
|
132814
|
-
if (
|
|
132815
|
-
return
|
|
132816
|
-
const result = [{ ...
|
|
132817
|
-
let currentLayer =
|
|
132818
|
-
for (let i = 1;i <
|
|
132819
|
-
const currentSegment = { start:
|
|
132820
|
-
const isVia =
|
|
132821
|
-
if (
|
|
132822
|
-
result.push({ ...
|
|
132823
|
-
currentLayer =
|
|
133760
|
+
function removePathLoops(path33) {
|
|
133761
|
+
if (path33.length < 4)
|
|
133762
|
+
return path33;
|
|
133763
|
+
const result = [{ ...path33[0] }];
|
|
133764
|
+
let currentLayer = path33[0].layer;
|
|
133765
|
+
for (let i = 1;i < path33.length; i++) {
|
|
133766
|
+
const currentSegment = { start: path33[i - 1], end: path33[i] };
|
|
133767
|
+
const isVia = path33[i].route_type === "via" || path33[i - 1].route_type === "via";
|
|
133768
|
+
if (path33[i].layer !== currentLayer || isVia) {
|
|
133769
|
+
result.push({ ...path33[i] });
|
|
133770
|
+
currentLayer = path33[i].layer;
|
|
132824
133771
|
continue;
|
|
132825
133772
|
}
|
|
132826
133773
|
let intersectionFound = false;
|
|
@@ -132849,8 +133796,8 @@ function removePathLoops(path32) {
|
|
|
132849
133796
|
result.push(intersectionPoint);
|
|
132850
133797
|
}
|
|
132851
133798
|
const lastPoint = result[result.length - 1];
|
|
132852
|
-
if (lastPoint.x !==
|
|
132853
|
-
result.push(
|
|
133799
|
+
if (lastPoint.x !== path33[i].x || lastPoint.y !== path33[i].y) {
|
|
133800
|
+
result.push(path33[i]);
|
|
132854
133801
|
}
|
|
132855
133802
|
}
|
|
132856
133803
|
return result;
|
|
@@ -133339,10 +134286,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
133339
134286
|
});
|
|
133340
134287
|
}
|
|
133341
134288
|
if (current2.parent) {
|
|
133342
|
-
const
|
|
134289
|
+
const path33 = [];
|
|
133343
134290
|
let p = current2;
|
|
133344
134291
|
while (p) {
|
|
133345
|
-
|
|
134292
|
+
path33.unshift(p);
|
|
133346
134293
|
p = p.parent;
|
|
133347
134294
|
}
|
|
133348
134295
|
debugSolution.push({
|
|
@@ -133350,7 +134297,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
133350
134297
|
pcb_component_id: "",
|
|
133351
134298
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
133352
134299
|
layer: "top",
|
|
133353
|
-
route:
|
|
134300
|
+
route: path33,
|
|
133354
134301
|
stroke_width: 0.01
|
|
133355
134302
|
});
|
|
133356
134303
|
}
|
|
@@ -138272,13 +139219,13 @@ var RBush = class {
|
|
|
138272
139219
|
return this;
|
|
138273
139220
|
let node = this.data;
|
|
138274
139221
|
const bbox = this.toBBox(item);
|
|
138275
|
-
const
|
|
139222
|
+
const path33 = [];
|
|
138276
139223
|
const indexes = [];
|
|
138277
139224
|
let i, parent, goingUp;
|
|
138278
|
-
while (node ||
|
|
139225
|
+
while (node || path33.length) {
|
|
138279
139226
|
if (!node) {
|
|
138280
|
-
node =
|
|
138281
|
-
parent =
|
|
139227
|
+
node = path33.pop();
|
|
139228
|
+
parent = path33[path33.length - 1];
|
|
138282
139229
|
i = indexes.pop();
|
|
138283
139230
|
goingUp = true;
|
|
138284
139231
|
}
|
|
@@ -138286,13 +139233,13 @@ var RBush = class {
|
|
|
138286
139233
|
const index = findItem(item, node.children, equalsFn);
|
|
138287
139234
|
if (index !== -1) {
|
|
138288
139235
|
node.children.splice(index, 1);
|
|
138289
|
-
|
|
138290
|
-
this._condense(
|
|
139236
|
+
path33.push(node);
|
|
139237
|
+
this._condense(path33);
|
|
138291
139238
|
return this;
|
|
138292
139239
|
}
|
|
138293
139240
|
}
|
|
138294
139241
|
if (!goingUp && !node.leaf && contains(node, bbox)) {
|
|
138295
|
-
|
|
139242
|
+
path33.push(node);
|
|
138296
139243
|
indexes.push(i);
|
|
138297
139244
|
i = 0;
|
|
138298
139245
|
parent = node;
|
|
@@ -138363,10 +139310,10 @@ var RBush = class {
|
|
|
138363
139310
|
calcBBox(node, this.toBBox);
|
|
138364
139311
|
return node;
|
|
138365
139312
|
}
|
|
138366
|
-
_chooseSubtree(bbox, node, level,
|
|
139313
|
+
_chooseSubtree(bbox, node, level, path33) {
|
|
138367
139314
|
while (true) {
|
|
138368
|
-
|
|
138369
|
-
if (node.leaf ||
|
|
139315
|
+
path33.push(node);
|
|
139316
|
+
if (node.leaf || path33.length - 1 === level)
|
|
138370
139317
|
break;
|
|
138371
139318
|
let minArea = Infinity;
|
|
138372
139319
|
let minEnlargement = Infinity;
|
|
@@ -138475,21 +139422,21 @@ var RBush = class {
|
|
|
138475
139422
|
}
|
|
138476
139423
|
return margin;
|
|
138477
139424
|
}
|
|
138478
|
-
_adjustParentBBoxes(bbox,
|
|
139425
|
+
_adjustParentBBoxes(bbox, path33, level) {
|
|
138479
139426
|
for (let i = level;i >= 0; i--) {
|
|
138480
|
-
extend(
|
|
139427
|
+
extend(path33[i], bbox);
|
|
138481
139428
|
}
|
|
138482
139429
|
}
|
|
138483
|
-
_condense(
|
|
138484
|
-
for (let i =
|
|
138485
|
-
if (
|
|
139430
|
+
_condense(path33) {
|
|
139431
|
+
for (let i = path33.length - 1, siblings;i >= 0; i--) {
|
|
139432
|
+
if (path33[i].children.length === 0) {
|
|
138486
139433
|
if (i > 0) {
|
|
138487
|
-
siblings =
|
|
138488
|
-
siblings.splice(siblings.indexOf(
|
|
139434
|
+
siblings = path33[i - 1].children;
|
|
139435
|
+
siblings.splice(siblings.indexOf(path33[i]), 1);
|
|
138489
139436
|
} else
|
|
138490
139437
|
this.clear();
|
|
138491
139438
|
} else
|
|
138492
|
-
calcBBox(
|
|
139439
|
+
calcBBox(path33[i], this.toBBox);
|
|
138493
139440
|
}
|
|
138494
139441
|
}
|
|
138495
139442
|
};
|
|
@@ -139634,7 +140581,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139634
140581
|
this.capacityPaths = capacityPaths;
|
|
139635
140582
|
this.colorMap = colorMap ?? {};
|
|
139636
140583
|
this.unprocessedNodeIds = [
|
|
139637
|
-
...new Set(capacityPaths.flatMap((
|
|
140584
|
+
...new Set(capacityPaths.flatMap((path33) => path33.nodeIds))
|
|
139638
140585
|
];
|
|
139639
140586
|
this.nodePortSegments = /* @__PURE__ */ new Map;
|
|
139640
140587
|
}
|
|
@@ -139645,17 +140592,17 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139645
140592
|
return;
|
|
139646
140593
|
}
|
|
139647
140594
|
const pathsGoingThroughNode = [];
|
|
139648
|
-
for (const
|
|
139649
|
-
const indexOfNodeInPath =
|
|
140595
|
+
for (const path33 of this.capacityPaths) {
|
|
140596
|
+
const indexOfNodeInPath = path33.nodeIds.indexOf(nodeId);
|
|
139650
140597
|
if (indexOfNodeInPath !== -1) {
|
|
139651
|
-
pathsGoingThroughNode.push({ path:
|
|
140598
|
+
pathsGoingThroughNode.push({ path: path33, indexOfNodeInPath });
|
|
139652
140599
|
}
|
|
139653
140600
|
}
|
|
139654
140601
|
const node = this.nodeMap.get(nodeId);
|
|
139655
140602
|
const nodePortSegments = [];
|
|
139656
|
-
for (const { path:
|
|
139657
|
-
const entryNodeId =
|
|
139658
|
-
const exitNodeId =
|
|
140603
|
+
for (const { path: path33, indexOfNodeInPath } of pathsGoingThroughNode) {
|
|
140604
|
+
const entryNodeId = path33.nodeIds[indexOfNodeInPath - 1];
|
|
140605
|
+
const exitNodeId = path33.nodeIds[indexOfNodeInPath + 1];
|
|
139659
140606
|
for (const adjNodeId of [entryNodeId, exitNodeId]) {
|
|
139660
140607
|
const adjNode = this.nodeMap.get(adjNodeId);
|
|
139661
140608
|
if (!adjNode)
|
|
@@ -139668,7 +140615,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139668
140615
|
capacityMeshNodeId: nodeId,
|
|
139669
140616
|
start: segment2.start,
|
|
139670
140617
|
end: segment2.end,
|
|
139671
|
-
connectionNames: [
|
|
140618
|
+
connectionNames: [path33.connectionName],
|
|
139672
140619
|
availableZ: mutuallyAvailableZ
|
|
139673
140620
|
};
|
|
139674
140621
|
nodePortSegments.push(portSegment);
|
|
@@ -140474,37 +141421,37 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
|
|
|
140474
141421
|
return neighbors;
|
|
140475
141422
|
}
|
|
140476
141423
|
getNodePath(node) {
|
|
140477
|
-
const
|
|
141424
|
+
const path33 = [];
|
|
140478
141425
|
while (node) {
|
|
140479
|
-
|
|
141426
|
+
path33.push(node);
|
|
140480
141427
|
node = node.parent;
|
|
140481
141428
|
}
|
|
140482
|
-
return
|
|
141429
|
+
return path33;
|
|
140483
141430
|
}
|
|
140484
141431
|
getViasInNodePath(node) {
|
|
140485
|
-
const
|
|
141432
|
+
const path33 = this.getNodePath(node);
|
|
140486
141433
|
const vias = [];
|
|
140487
|
-
for (let i = 0;i <
|
|
140488
|
-
if (
|
|
140489
|
-
vias.push({ x:
|
|
141434
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
141435
|
+
if (path33[i].z !== path33[i + 1].z) {
|
|
141436
|
+
vias.push({ x: path33[i].x, y: path33[i].y });
|
|
140490
141437
|
}
|
|
140491
141438
|
}
|
|
140492
141439
|
return vias;
|
|
140493
141440
|
}
|
|
140494
141441
|
setSolvedPath(node) {
|
|
140495
|
-
const
|
|
140496
|
-
|
|
141442
|
+
const path33 = this.getNodePath(node);
|
|
141443
|
+
path33.reverse();
|
|
140497
141444
|
const vias = [];
|
|
140498
|
-
for (let i = 0;i <
|
|
140499
|
-
if (
|
|
140500
|
-
vias.push({ x:
|
|
141445
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
141446
|
+
if (path33[i].z !== path33[i + 1].z) {
|
|
141447
|
+
vias.push({ x: path33[i].x, y: path33[i].y });
|
|
140501
141448
|
}
|
|
140502
141449
|
}
|
|
140503
141450
|
this.solvedPath = {
|
|
140504
141451
|
connectionName: this.connectionName,
|
|
140505
141452
|
traceThickness: this.traceThickness,
|
|
140506
141453
|
viaDiameter: this.viaDiameter,
|
|
140507
|
-
route:
|
|
141454
|
+
route: path33.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
|
|
140508
141455
|
vias
|
|
140509
141456
|
};
|
|
140510
141457
|
}
|
|
@@ -141312,12 +142259,12 @@ function computeDumbbellPaths({
|
|
|
141312
142259
|
specialType: circleCenter === A3 ? "A" : "B"
|
|
141313
142260
|
};
|
|
141314
142261
|
};
|
|
141315
|
-
const subdivideOptimalPath = (
|
|
141316
|
-
if (
|
|
141317
|
-
return
|
|
141318
|
-
const result = [
|
|
141319
|
-
for (let i = 0;i <
|
|
141320
|
-
const segment2 = { start:
|
|
142262
|
+
const subdivideOptimalPath = (path33, numSubdivisions) => {
|
|
142263
|
+
if (path33.length < 2)
|
|
142264
|
+
return path33;
|
|
142265
|
+
const result = [path33[0]];
|
|
142266
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
142267
|
+
const segment2 = { start: path33[i], end: path33[i + 1] };
|
|
141321
142268
|
const segmentMidpoint = {
|
|
141322
142269
|
x: (segment2.start.x + segment2.end.x) / 2,
|
|
141323
142270
|
y: (segment2.start.y + segment2.end.y) / 2
|
|
@@ -141379,7 +142326,7 @@ function computeDumbbellPaths({
|
|
|
141379
142326
|
}
|
|
141380
142327
|
subdivisionPoints.forEach((p) => result.push(p));
|
|
141381
142328
|
}
|
|
141382
|
-
result.push(
|
|
142329
|
+
result.push(path33[i + 1]);
|
|
141383
142330
|
}
|
|
141384
142331
|
if (result.length > 1) {
|
|
141385
142332
|
const filteredResult = [result[0]];
|
|
@@ -141614,13 +142561,13 @@ function computeDumbbellPaths({
|
|
|
141614
142561
|
].map((l, index) => ({ ...l, index }));
|
|
141615
142562
|
};
|
|
141616
142563
|
const subdivideJLinePath = (jLine, oppositePoint, r3, m2, numSubdivisions) => {
|
|
141617
|
-
const
|
|
141618
|
-
if (
|
|
141619
|
-
return
|
|
142564
|
+
const path33 = jLine.points;
|
|
142565
|
+
if (path33.length < 2)
|
|
142566
|
+
return path33;
|
|
141620
142567
|
const minDistThreshold = r3 + m2;
|
|
141621
|
-
const result = [
|
|
141622
|
-
for (let i = 0;i <
|
|
141623
|
-
const segment2 = { start:
|
|
142568
|
+
const result = [path33[0]];
|
|
142569
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
142570
|
+
const segment2 = { start: path33[i], end: path33[i + 1] };
|
|
141624
142571
|
const distToOpposite = pointToSegmentDistance22(oppositePoint, segment2.start, segment2.end);
|
|
141625
142572
|
if (distToOpposite < minDistThreshold) {
|
|
141626
142573
|
const closestPt = closestPointOnSegment(segment2, oppositePoint);
|
|
@@ -141689,26 +142636,26 @@ function computeDumbbellPaths({
|
|
|
141689
142636
|
return { index: 0, path: [] };
|
|
141690
142637
|
}
|
|
141691
142638
|
const optimalPath2 = validPaths.sort((a, b3) => a.length - b3.length)[0];
|
|
141692
|
-
const
|
|
141693
|
-
const firstPoint =
|
|
141694
|
-
const dist3 = distance3(firstPoint,
|
|
141695
|
-
const dist4 = distance3(firstPoint,
|
|
142639
|
+
const path33 = [...optimalPath2.path];
|
|
142640
|
+
const firstPoint = path33[0];
|
|
142641
|
+
const dist3 = distance3(firstPoint, path33[2]);
|
|
142642
|
+
const dist4 = distance3(firstPoint, path33[3]);
|
|
141696
142643
|
const closerIdx = dist3 < dist4 ? 2 : 3;
|
|
141697
|
-
if (dist3 < distance3(firstPoint,
|
|
141698
|
-
|
|
142644
|
+
if (dist3 < distance3(firstPoint, path33[1]) || dist4 < distance3(firstPoint, path33[1])) {
|
|
142645
|
+
path33.splice(1, closerIdx - 1);
|
|
141699
142646
|
}
|
|
141700
|
-
const lastPoint =
|
|
141701
|
-
const distM3 = distance3(lastPoint,
|
|
141702
|
-
const distM4 = distance3(lastPoint,
|
|
141703
|
-
const closerLastIdx = distM3 < distM4 ?
|
|
141704
|
-
if (distM3 < distance3(lastPoint,
|
|
141705
|
-
|
|
142647
|
+
const lastPoint = path33[path33.length - 1];
|
|
142648
|
+
const distM3 = distance3(lastPoint, path33[path33.length - 3]);
|
|
142649
|
+
const distM4 = distance3(lastPoint, path33[path33.length - 4]);
|
|
142650
|
+
const closerLastIdx = distM3 < distM4 ? path33.length - 3 : path33.length - 4;
|
|
142651
|
+
if (distM3 < distance3(lastPoint, path33[path33.length - 2]) || distM4 < distance3(lastPoint, path33[path33.length - 2])) {
|
|
142652
|
+
path33.splice(closerLastIdx + 1, path33.length - closerLastIdx - 2);
|
|
141706
142653
|
}
|
|
141707
142654
|
return {
|
|
141708
142655
|
index: optimalPath2.index,
|
|
141709
|
-
path:
|
|
141710
|
-
startsAt:
|
|
141711
|
-
goesTo:
|
|
142656
|
+
path: path33,
|
|
142657
|
+
startsAt: path33[0] === C2 ? "C" : "D",
|
|
142658
|
+
goesTo: path33[path33.length - 1] === C2 ? "C" : "D"
|
|
141712
142659
|
};
|
|
141713
142660
|
};
|
|
141714
142661
|
const optimalPath = findOptimalPath();
|
|
@@ -143128,9 +144075,9 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
143128
144075
|
let closestIntersection = null;
|
|
143129
144076
|
let intersectedSegmentZ = null;
|
|
143130
144077
|
const checkIntersectionsWithPathMap = (pathMap) => {
|
|
143131
|
-
for (const
|
|
143132
|
-
for (let i = 0;i <
|
|
143133
|
-
const segment2 = [
|
|
144078
|
+
for (const path33 of pathMap.values()) {
|
|
144079
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
144080
|
+
const segment2 = [path33[i], path33[i + 1]];
|
|
143134
144081
|
if (segment2[0].x === segment2[1].x && segment2[0].y === segment2[1].y) {
|
|
143135
144082
|
continue;
|
|
143136
144083
|
}
|
|
@@ -143260,11 +144207,11 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
143260
144207
|
});
|
|
143261
144208
|
}
|
|
143262
144209
|
const drawPath = (pathMap, labelPrefix) => {
|
|
143263
|
-
for (const [connectionName,
|
|
144210
|
+
for (const [connectionName, path33] of pathMap.entries()) {
|
|
143264
144211
|
const color = colorMap[connectionName] ?? "black";
|
|
143265
|
-
for (let i = 0;i <
|
|
143266
|
-
const p12 =
|
|
143267
|
-
const p2 =
|
|
144212
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
144213
|
+
const p12 = path33[i];
|
|
144214
|
+
const p2 = path33[i + 1];
|
|
143268
144215
|
if (p12.x === p2.x && p12.y === p2.y && p12.z !== p2.z) {
|
|
143269
144216
|
graphics.circles.push({
|
|
143270
144217
|
center: { x: p12.x, y: p12.y },
|
|
@@ -143862,10 +144809,10 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
143862
144809
|
const allSegments = [];
|
|
143863
144810
|
const viaPoints = /* @__PURE__ */ new Map;
|
|
143864
144811
|
for (const polyLine of polyLines) {
|
|
143865
|
-
const
|
|
143866
|
-
for (let i = 0;i <
|
|
143867
|
-
const p12 =
|
|
143868
|
-
const p2 =
|
|
144812
|
+
const path33 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
144813
|
+
for (let i = 0;i < path33.length - 1; i++) {
|
|
144814
|
+
const p12 = path33[i];
|
|
144815
|
+
const p2 = path33[i + 1];
|
|
143869
144816
|
const layer = p12.z2;
|
|
143870
144817
|
allSegments.push({
|
|
143871
144818
|
start: { x: p12.x, y: p12.y },
|
|
@@ -143883,7 +144830,7 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
143883
144830
|
}
|
|
143884
144831
|
}
|
|
143885
144832
|
}
|
|
143886
|
-
const lastPoint =
|
|
144833
|
+
const lastPoint = path33[path33.length - 1];
|
|
143887
144834
|
if (lastPoint.z1 !== lastPoint.z2) {
|
|
143888
144835
|
const key = pointKey2(lastPoint);
|
|
143889
144836
|
if (!viaPoints.has(key)) {
|
|
@@ -144182,14 +145129,14 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
|
|
|
144182
145129
|
const polyLineVias = [];
|
|
144183
145130
|
for (let i = 0;i < polyLines.length; i++) {
|
|
144184
145131
|
const polyLine = polyLines[i];
|
|
144185
|
-
const
|
|
145132
|
+
const path33 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
144186
145133
|
const segmentsByLayer = new Map(this.availableZ.map((z852) => [z852, []]));
|
|
144187
|
-
for (let i22 = 0;i22 <
|
|
144188
|
-
const segment2 = [
|
|
145134
|
+
for (let i22 = 0;i22 < path33.length - 1; i22++) {
|
|
145135
|
+
const segment2 = [path33[i22], path33[i22 + 1]];
|
|
144189
145136
|
segmentsByLayer.get(segment2[0].z2).push(segment2);
|
|
144190
145137
|
}
|
|
144191
145138
|
polyLineSegmentsByLayer.push(segmentsByLayer);
|
|
144192
|
-
polyLineVias.push(
|
|
145139
|
+
polyLineVias.push(path33.filter((p) => p.z1 !== p.z2));
|
|
144193
145140
|
}
|
|
144194
145141
|
for (let i = 0;i < polyLines.length; i++) {
|
|
144195
145142
|
const path1SegmentsByLayer = polyLineSegmentsByLayer[i];
|
|
@@ -145618,7 +146565,7 @@ var HighDensitySolver = class extends BaseSolver {
|
|
|
145618
146565
|
if (this.failedSolvers.length > 0) {
|
|
145619
146566
|
this.solved = false;
|
|
145620
146567
|
this.failed = true;
|
|
145621
|
-
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((
|
|
146568
|
+
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((fs32) => fs32.nodeWithPortPoints.capacityMeshNodeId)}. err0: ${this.failedSolvers[0].error}.`;
|
|
145622
146569
|
return;
|
|
145623
146570
|
}
|
|
145624
146571
|
this.solved = true;
|
|
@@ -148399,13 +149346,13 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
148399
149346
|
return this.getDistanceBetweenNodes(node, endGoal);
|
|
148400
149347
|
}
|
|
148401
149348
|
getBacktrackedPath(candidate) {
|
|
148402
|
-
const
|
|
149349
|
+
const path33 = [];
|
|
148403
149350
|
let currentCandidate = candidate;
|
|
148404
149351
|
while (currentCandidate) {
|
|
148405
|
-
|
|
149352
|
+
path33.push(currentCandidate.node);
|
|
148406
149353
|
currentCandidate = currentCandidate.prevCandidate;
|
|
148407
149354
|
}
|
|
148408
|
-
return
|
|
149355
|
+
return path33;
|
|
148409
149356
|
}
|
|
148410
149357
|
getNeighboringNodes(node) {
|
|
148411
149358
|
return this.nodeEdgeMap.get(node.capacityMeshNodeId).flatMap((edge) => edge.nodeIds.filter((n3) => n3 !== node.capacityMeshNodeId)).map((n3) => this.nodeMap.get(n3));
|
|
@@ -148413,12 +149360,12 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
148413
149360
|
getCapacityPaths() {
|
|
148414
149361
|
const capacityPaths = [];
|
|
148415
149362
|
for (const connection of this.connectionsWithNodes) {
|
|
148416
|
-
const
|
|
148417
|
-
if (
|
|
149363
|
+
const path33 = connection.path;
|
|
149364
|
+
if (path33) {
|
|
148418
149365
|
capacityPaths.push({
|
|
148419
149366
|
capacityPathId: connection.connection.name,
|
|
148420
149367
|
connectionName: connection.connection.name,
|
|
148421
|
-
nodeIds:
|
|
149368
|
+
nodeIds: path33.map((node) => node.capacityMeshNodeId)
|
|
148422
149369
|
});
|
|
148423
149370
|
}
|
|
148424
149371
|
}
|
|
@@ -149103,10 +150050,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149103
150050
|
return this.getDistanceBetweenNodes(node, endGoal) + this.getNodeCapacityPenalty(node);
|
|
149104
150051
|
}
|
|
149105
150052
|
getBacktrackedPath(candidate) {
|
|
149106
|
-
const
|
|
150053
|
+
const path33 = [];
|
|
149107
150054
|
let currentCandidate = candidate;
|
|
149108
150055
|
while (currentCandidate) {
|
|
149109
|
-
|
|
150056
|
+
path33.push(currentCandidate.node);
|
|
149110
150057
|
if (this.nodeMap.has(currentCandidate.node.capacityMeshNodeId)) {
|
|
149111
150058
|
currentCandidate = currentCandidate.prevCandidate;
|
|
149112
150059
|
} else {
|
|
@@ -149114,7 +150061,7 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149114
150061
|
break;
|
|
149115
150062
|
}
|
|
149116
150063
|
}
|
|
149117
|
-
return
|
|
150064
|
+
return path33.reverse();
|
|
149118
150065
|
}
|
|
149119
150066
|
getNeighboringNodes(node) {
|
|
149120
150067
|
if (!this.nodeMap.has(node.capacityMeshNodeId))
|
|
@@ -149129,8 +150076,8 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149129
150076
|
doesNodeHaveCapacityForTrace(node, prevNode) {
|
|
149130
150077
|
return true;
|
|
149131
150078
|
}
|
|
149132
|
-
reduceCapacityAlongPath(
|
|
149133
|
-
for (const pathNode of
|
|
150079
|
+
reduceCapacityAlongPath(path33) {
|
|
150080
|
+
for (const pathNode of path33) {
|
|
149134
150081
|
if (this.usedNodeCapacityMap.has(pathNode.capacityMeshNodeId)) {
|
|
149135
150082
|
const nodeId = pathNode.capacityMeshNodeId;
|
|
149136
150083
|
const nodeInSection = this.nodeMap.get(nodeId);
|
|
@@ -149259,9 +150206,9 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149259
150206
|
this.queuedNodes = null;
|
|
149260
150207
|
}
|
|
149261
150208
|
_handleGoalReached(currentCandidate, currentTerminal, endNode) {
|
|
149262
|
-
const
|
|
149263
|
-
currentTerminal.path =
|
|
149264
|
-
this.reduceCapacityAlongPath(
|
|
150209
|
+
const path33 = this.getBacktrackedPath(currentCandidate);
|
|
150210
|
+
currentTerminal.path = path33;
|
|
150211
|
+
this.reduceCapacityAlongPath(path33);
|
|
149265
150212
|
this.currentConnectionIndex++;
|
|
149266
150213
|
this.candidates = null;
|
|
149267
150214
|
this.visitedNodes = null;
|
|
@@ -149310,10 +150257,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149310
150257
|
const connectionColor = this.colorMap[connectionName] ?? "purple";
|
|
149311
150258
|
topCandidates.forEach((candidate, index) => {
|
|
149312
150259
|
const opacity = 0.8 * (1 - index / 5);
|
|
149313
|
-
const
|
|
149314
|
-
if (
|
|
150260
|
+
const path33 = this.getBacktrackedPath(candidate);
|
|
150261
|
+
if (path33.length > 0) {
|
|
149315
150262
|
baseGraphics.lines.push({
|
|
149316
|
-
points:
|
|
150263
|
+
points: path33.map(({ center: { x, y } }) => ({ x, y })),
|
|
149317
150264
|
strokeColor: safeTransparentize(connectionColor, 1 - opacity),
|
|
149318
150265
|
strokeWidth: 0.05
|
|
149319
150266
|
});
|
|
@@ -150002,12 +150949,12 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
|
|
|
150002
150949
|
getCapacityPaths() {
|
|
150003
150950
|
const capacityPaths = [];
|
|
150004
150951
|
for (const connection of this.connectionsWithNodes) {
|
|
150005
|
-
const
|
|
150006
|
-
if (
|
|
150952
|
+
const path33 = connection.path;
|
|
150953
|
+
if (path33) {
|
|
150007
150954
|
capacityPaths.push({
|
|
150008
150955
|
capacityPathId: connection.connection.name,
|
|
150009
150956
|
connectionName: connection.connection.name,
|
|
150010
|
-
nodeIds:
|
|
150957
|
+
nodeIds: path33.map((node) => node.capacityMeshNodeId)
|
|
150011
150958
|
});
|
|
150012
150959
|
}
|
|
150013
150960
|
}
|
|
@@ -151028,22 +151975,22 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
|
|
|
151028
151975
|
return null;
|
|
151029
151976
|
}
|
|
151030
151977
|
const possiblePaths = calculate45DegreePaths({ x: start.x, y: start.y }, { x: end.x, y: end.y });
|
|
151031
|
-
for (const
|
|
151032
|
-
const fullPath =
|
|
151978
|
+
for (const path33 of possiblePaths) {
|
|
151979
|
+
const fullPath = path33.map((p) => ({ x: p.x, y: p.y, z: start.z }));
|
|
151033
151980
|
if (this.isValidPath(fullPath)) {
|
|
151034
151981
|
return fullPath;
|
|
151035
151982
|
}
|
|
151036
151983
|
}
|
|
151037
151984
|
return null;
|
|
151038
151985
|
}
|
|
151039
|
-
addPathToResult(
|
|
151040
|
-
if (
|
|
151986
|
+
addPathToResult(path33) {
|
|
151987
|
+
if (path33.length === 0)
|
|
151041
151988
|
return;
|
|
151042
|
-
for (let i = 0;i <
|
|
151043
|
-
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1],
|
|
151989
|
+
for (let i = 0;i < path33.length; i++) {
|
|
151990
|
+
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path33[i])) {
|
|
151044
151991
|
continue;
|
|
151045
151992
|
}
|
|
151046
|
-
this.newRoute.push(
|
|
151993
|
+
this.newRoute.push(path33[i]);
|
|
151047
151994
|
}
|
|
151048
151995
|
this.currentStepSize = this.maxStepSize;
|
|
151049
151996
|
}
|
|
@@ -166713,11 +167660,11 @@ var SchematicPartitionProcessor = class {
|
|
|
166713
167660
|
continue;
|
|
166714
167661
|
const stroke = getColorByIndex(partitionIdx, this.wipPartitions.length, 1);
|
|
166715
167662
|
const { x, y } = getPinPosition(this.lastGraph, boxId, pinId);
|
|
166716
|
-
const
|
|
167663
|
+
const scale33 = 1 + 0.1 * partitionIdx;
|
|
166717
167664
|
graphics.rects.push({
|
|
166718
167665
|
center: { x, y },
|
|
166719
|
-
width: unexploredRectBaseSize *
|
|
166720
|
-
height: unexploredRectBaseSize *
|
|
167666
|
+
width: unexploredRectBaseSize * scale33,
|
|
167667
|
+
height: unexploredRectBaseSize * scale33,
|
|
166721
167668
|
fill: "none",
|
|
166722
167669
|
stroke
|
|
166723
167670
|
});
|
|
@@ -174463,14 +175410,14 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174463
175410
|
}
|
|
174464
175411
|
computePcbPropsTransform() {
|
|
174465
175412
|
const { _parsedProps: props } = this;
|
|
174466
|
-
const matrix2 =
|
|
175413
|
+
const matrix2 = compose4(translate4(props.pcbX ?? 0, props.pcbY ?? 0), rotate5((props.pcbRotation ?? 0) * Math.PI / 180));
|
|
174467
175414
|
return matrix2;
|
|
174468
175415
|
}
|
|
174469
175416
|
_computePcbGlobalTransformBeforeLayout() {
|
|
174470
175417
|
const { _parsedProps: props } = this;
|
|
174471
175418
|
const manualPlacement = this.getSubcircuit()._getPcbManualPlacementForComponent(this);
|
|
174472
175419
|
if (manualPlacement && this.props.pcbX === undefined && this.props.pcbY === undefined) {
|
|
174473
|
-
return
|
|
175420
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity4(), compose4(translate4(manualPlacement.x, manualPlacement.y), rotate5((props.pcbRotation ?? 0) * Math.PI / 180)));
|
|
174474
175421
|
}
|
|
174475
175422
|
if (this.isPcbPrimitive) {
|
|
174476
175423
|
const primitiveContainer = this.getPrimitiveContainer();
|
|
@@ -174478,12 +175425,12 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174478
175425
|
const isFlipped = primitiveContainer._parsedProps.layer === "bottom";
|
|
174479
175426
|
const containerCenter = primitiveContainer._getGlobalPcbPositionBeforeLayout();
|
|
174480
175427
|
if (isFlipped) {
|
|
174481
|
-
const flipOperation =
|
|
174482
|
-
return
|
|
175428
|
+
const flipOperation = compose4(translate4(containerCenter.x, containerCenter.y), flipY(), translate4(-containerCenter.x, -containerCenter.y));
|
|
175429
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity4(), flipY(), this.computePcbPropsTransform());
|
|
174483
175430
|
}
|
|
174484
175431
|
}
|
|
174485
175432
|
}
|
|
174486
|
-
return
|
|
175433
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity4(), this.computePcbPropsTransform());
|
|
174487
175434
|
}
|
|
174488
175435
|
getPrimitiveContainer() {
|
|
174489
175436
|
if (this.isPrimitiveContainer)
|
|
@@ -174514,13 +175461,13 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174514
175461
|
}
|
|
174515
175462
|
computeSchematicPropsTransform() {
|
|
174516
175463
|
const { _parsedProps: props } = this;
|
|
174517
|
-
return
|
|
175464
|
+
return compose4(translate4(props.schX ?? 0, props.schY ?? 0));
|
|
174518
175465
|
}
|
|
174519
175466
|
computeSchematicGlobalTransform() {
|
|
174520
175467
|
const manualPlacementTransform = this._getSchematicGlobalManualPlacementTransform(this);
|
|
174521
175468
|
if (manualPlacementTransform)
|
|
174522
175469
|
return manualPlacementTransform;
|
|
174523
|
-
return
|
|
175470
|
+
return compose4(this.parent?.computeSchematicGlobalTransform?.() ?? identity4(), this.computeSchematicPropsTransform());
|
|
174524
175471
|
}
|
|
174525
175472
|
_getSchematicSymbolName() {
|
|
174526
175473
|
const { _parsedProps: props } = this;
|
|
@@ -174606,7 +175553,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174606
175553
|
return null;
|
|
174607
175554
|
for (const position2 of placementConfigPositions) {
|
|
174608
175555
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
174609
|
-
const center2 =
|
|
175556
|
+
const center2 = applyToPoint14(this._computePcbGlobalTransformBeforeLayout(), position2.center);
|
|
174610
175557
|
return center2;
|
|
174611
175558
|
}
|
|
174612
175559
|
}
|
|
@@ -174623,7 +175570,7 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174623
175570
|
return null;
|
|
174624
175571
|
for (const position2 of placementConfigPositions) {
|
|
174625
175572
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
174626
|
-
const center2 =
|
|
175573
|
+
const center2 = applyToPoint14(this.computeSchematicGlobalTransform(), position2.center);
|
|
174627
175574
|
return center2;
|
|
174628
175575
|
}
|
|
174629
175576
|
}
|
|
@@ -174636,20 +175583,20 @@ var PrimitiveComponent2 = class extends Renderable {
|
|
|
174636
175583
|
for (const position2 of manualEdits.schematic_placements ?? []) {
|
|
174637
175584
|
if (isMatchingSelector(component, position2.selector) || component.props.name === position2.selector) {
|
|
174638
175585
|
if (position2.relative_to === "group_center") {
|
|
174639
|
-
return
|
|
175586
|
+
return compose4(this.parent?._computePcbGlobalTransformBeforeLayout() ?? identity4(), translate4(position2.center.x, position2.center.y));
|
|
174640
175587
|
}
|
|
174641
175588
|
}
|
|
174642
175589
|
}
|
|
174643
175590
|
return null;
|
|
174644
175591
|
}
|
|
174645
175592
|
_getGlobalPcbPositionBeforeLayout() {
|
|
174646
|
-
return
|
|
175593
|
+
return applyToPoint14(this._computePcbGlobalTransformBeforeLayout(), {
|
|
174647
175594
|
x: 0,
|
|
174648
175595
|
y: 0
|
|
174649
175596
|
});
|
|
174650
175597
|
}
|
|
174651
175598
|
_getGlobalSchematicPositionBeforeLayout() {
|
|
174652
|
-
return
|
|
175599
|
+
return applyToPoint14(this.computeSchematicGlobalTransform(), { x: 0, y: 0 });
|
|
174653
175600
|
}
|
|
174654
175601
|
get root() {
|
|
174655
175602
|
return this.parent?.root ?? null;
|
|
@@ -175080,7 +176027,7 @@ var createInstanceFromReactElement = (reactElm) => {
|
|
|
175080
176027
|
this.children.push(instance);
|
|
175081
176028
|
},
|
|
175082
176029
|
computePcbGlobalTransform() {
|
|
175083
|
-
return
|
|
176030
|
+
return identity4();
|
|
175084
176031
|
}
|
|
175085
176032
|
};
|
|
175086
176033
|
const containerErrors = [];
|
|
@@ -175615,7 +176562,7 @@ var SilkscreenPath = class extends PrimitiveComponent2 {
|
|
|
175615
176562
|
pcb_component_id,
|
|
175616
176563
|
layer,
|
|
175617
176564
|
route: props.route.map((p) => {
|
|
175618
|
-
const transformedPosition =
|
|
176565
|
+
const transformedPosition = applyToPoint14(transform2, {
|
|
175619
176566
|
x: p.x,
|
|
175620
176567
|
y: p.y
|
|
175621
176568
|
});
|
|
@@ -175698,7 +176645,7 @@ var PcbTrace = class extends PrimitiveComponent2 {
|
|
|
175698
176645
|
const parentTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
175699
176646
|
const transformedRoute = props.route.map((point5) => {
|
|
175700
176647
|
const { x, y, ...restOfPoint } = point5;
|
|
175701
|
-
const transformedPoint =
|
|
176648
|
+
const transformedPoint = applyToPoint14(parentTransform, { x, y });
|
|
175702
176649
|
if (point5.route_type === "wire" && point5.layer) {
|
|
175703
176650
|
return {
|
|
175704
176651
|
...transformedPoint,
|
|
@@ -176145,7 +177092,7 @@ var Cutout = class extends PrimitiveComponent2 {
|
|
|
176145
177092
|
inserted_pcb_cutout = db.pcb_cutout.insert(circleData);
|
|
176146
177093
|
} else if (props.shape === "polygon") {
|
|
176147
177094
|
const transform2 = this._computePcbGlobalTransformBeforeLayout();
|
|
176148
|
-
const transformedPoints = props.points.map((p) =>
|
|
177095
|
+
const transformedPoints = props.points.map((p) => applyToPoint14(transform2, p));
|
|
176149
177096
|
const polygonData = {
|
|
176150
177097
|
shape: "polygon",
|
|
176151
177098
|
points: transformedPoints,
|
|
@@ -176616,8 +177563,8 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
176616
177563
|
throw new Error(`Couldn't find schematicSymbolPortDef for port ${this.getString()}, searched internally connected ports and none had a schematicSymbolPortDef. Why are we trying to get the schematic position of this port?`);
|
|
176617
177564
|
}
|
|
176618
177565
|
}
|
|
176619
|
-
const transform2 =
|
|
176620
|
-
return
|
|
177566
|
+
const transform2 = compose4(this.parent.computeSchematicGlobalTransform(), translate4(-symbol.center.x, -symbol.center.y));
|
|
177567
|
+
return applyToPoint14(transform2, schematicSymbolPortDef);
|
|
176621
177568
|
}
|
|
176622
177569
|
const parentBoxDim = this?.parent?._getSchematicBoxDimensions();
|
|
176623
177570
|
if (parentBoxDim && this.props.pinNumber !== undefined) {
|
|
@@ -176625,7 +177572,7 @@ var Port = class extends PrimitiveComponent2 {
|
|
|
176625
177572
|
if (!localPortPosition) {
|
|
176626
177573
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()} inside of the schematic box`);
|
|
176627
177574
|
}
|
|
176628
|
-
return
|
|
177575
|
+
return applyToPoint14(this.parent.computeSchematicGlobalTransform(), localPortPosition);
|
|
176629
177576
|
}
|
|
176630
177577
|
throw new Error(`Couldn't find position for schematic_port for port ${this.getString()}`);
|
|
176631
177578
|
}
|
|
@@ -178450,7 +179397,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
178450
179397
|
for (let i = 0;i < portsWithPosition.length - 1; i++) {
|
|
178451
179398
|
const start = portsWithPosition[i];
|
|
178452
179399
|
const end = portsWithPosition[i + 1];
|
|
178453
|
-
const
|
|
179400
|
+
const path33 = calculateElbow({
|
|
178454
179401
|
x: start.position.x,
|
|
178455
179402
|
y: start.position.y,
|
|
178456
179403
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -178459,8 +179406,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
178459
179406
|
y: end.position.y,
|
|
178460
179407
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
178461
179408
|
});
|
|
178462
|
-
for (let j4 = 0;j4 <
|
|
178463
|
-
elbowEdges.push({ from:
|
|
179409
|
+
for (let j4 = 0;j4 < path33.length - 1; j4++) {
|
|
179410
|
+
elbowEdges.push({ from: path33[j4], to: path33[j4 + 1] });
|
|
178464
179411
|
}
|
|
178465
179412
|
}
|
|
178466
179413
|
const doesSegmentIntersectRect = (edge, rect) => {
|
|
@@ -180192,7 +181139,7 @@ var TraceHint = class extends PrimitiveComponent2 {
|
|
|
180192
181139
|
return [];
|
|
180193
181140
|
const globalTransform = this._computePcbGlobalTransformBeforeLayout();
|
|
180194
181141
|
return offsets.map((offset) => ({
|
|
180195
|
-
...
|
|
181142
|
+
...applyToPoint14(globalTransform, offset),
|
|
180196
181143
|
via: offset.via,
|
|
180197
181144
|
to_layer: offset.to_layer,
|
|
180198
181145
|
trace_width: offset.trace_width
|
|
@@ -180913,7 +181860,7 @@ function Group_doInitialPcbLayoutGrid(group) {
|
|
|
180913
181860
|
const newCenter = { x: targetCellCenterX, y: targetCellCenterY };
|
|
180914
181861
|
const deltaX = newCenter.x - oldCenter.x;
|
|
180915
181862
|
const deltaY = newCenter.y - oldCenter.y;
|
|
180916
|
-
const mat =
|
|
181863
|
+
const mat = translate4(deltaX, deltaY);
|
|
180917
181864
|
const related = db.toArray().filter((e3) => e3.pcb_component_id === child.pcb_component_id);
|
|
180918
181865
|
const moved = transformPCBElements(related, mat);
|
|
180919
181866
|
for (const elm of moved) {
|
|
@@ -181008,7 +181955,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
181008
181955
|
const pcbComponent = db.pcb_component.get(componentId);
|
|
181009
181956
|
if (pcbComponent) {
|
|
181010
181957
|
const originalCenter2 = pcbComponent.center;
|
|
181011
|
-
const transformMatrix2 =
|
|
181958
|
+
const transformMatrix2 = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate5(ccwRotationOffset || 0), translate4(-originalCenter2.x, -originalCenter2.y));
|
|
181012
181959
|
const related = db.toArray().filter((elm) => ("pcb_component_id" in elm) && elm.pcb_component_id === componentId);
|
|
181013
181960
|
transformPCBElements(related, transformMatrix2);
|
|
181014
181961
|
continue;
|
|
@@ -181017,7 +181964,7 @@ var Group_doInitialPcbLayoutPack = (group) => {
|
|
|
181017
181964
|
if (!pcbGroup)
|
|
181018
181965
|
continue;
|
|
181019
181966
|
const originalCenter = pcbGroup.center;
|
|
181020
|
-
const transformMatrix =
|
|
181967
|
+
const transformMatrix = compose4(group._computePcbGlobalTransformBeforeLayout(), translate4(center2.x, center2.y), rotate5(ccwRotationOffset || 0), translate4(-originalCenter.x, -originalCenter.y));
|
|
181021
181968
|
const subtree = buildSubtree(db.toArray(), { source_group_id: componentId });
|
|
181022
181969
|
transformPCBElements(subtree, transformMatrix);
|
|
181023
181970
|
db.pcb_group.update(pcbGroup.pcb_group_id, { center: center2 });
|
|
@@ -181918,7 +182865,7 @@ var Board = class extends Group {
|
|
|
181918
182865
|
this.pcb_board_id = null;
|
|
181919
182866
|
}
|
|
181920
182867
|
_computePcbGlobalTransformBeforeLayout() {
|
|
181921
|
-
return
|
|
182868
|
+
return identity4();
|
|
181922
182869
|
}
|
|
181923
182870
|
doInitialPcbDesignRuleChecks() {
|
|
181924
182871
|
if (this.root?.pcbDisabled)
|
|
@@ -182599,7 +183546,7 @@ var FabricationNotePath = class extends PrimitiveComponent2 {
|
|
|
182599
183546
|
layer,
|
|
182600
183547
|
color: props.color,
|
|
182601
183548
|
route: props.route.map((p) => {
|
|
182602
|
-
const transformedPosition =
|
|
183549
|
+
const transformedPosition = applyToPoint14(transform2, {
|
|
182603
183550
|
x: p.x,
|
|
182604
183551
|
y: p.y
|
|
182605
183552
|
});
|
|
@@ -182817,8 +183764,8 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
182817
183764
|
const connectedPorts = this._getConnectedPorts();
|
|
182818
183765
|
if (connectedPorts.length > 0) {
|
|
182819
183766
|
const portPos = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
|
|
182820
|
-
const parentCenter =
|
|
182821
|
-
return
|
|
183767
|
+
const parentCenter = applyToPoint14(this.parent?.computeSchematicGlobalTransform?.() ?? identity4(), { x: 0, y: 0 });
|
|
183768
|
+
return translate4(portPos.x - parentCenter.x, portPos.y - parentCenter.y);
|
|
182822
183769
|
}
|
|
182823
183770
|
}
|
|
182824
183771
|
return super.computeSchematicPropsTransform();
|
|
@@ -184348,25 +185295,25 @@ var convertEasyEdaJsonToCircuitJson = (easyEdaJson, { useModelCdn, shouldRecente
|
|
|
184348
185295
|
const elementsForBounds = circuitElements.filter((e3) => e3.type !== "pcb_component" && e3.type !== "cad_component");
|
|
184349
185296
|
const bounds = findBoundsAndCenter(elementsForBounds);
|
|
184350
185297
|
if (Number.isFinite(bounds.center.x) && Number.isFinite(bounds.center.y)) {
|
|
184351
|
-
const matrix2 =
|
|
185298
|
+
const matrix2 = compose4(translate4(-bounds.center.x, bounds.center.y), scale8(1, -1));
|
|
184352
185299
|
const elementsForTransform = circuitElements.filter((e3) => !(e3.type === "pcb_smtpad" && e3.shape === "polygon") && e3.type !== "cad_component");
|
|
184353
185300
|
transformPCBElements(elementsForTransform, matrix2);
|
|
184354
185301
|
for (const e3 of circuitElements) {
|
|
184355
185302
|
if (e3.type === "pcb_cutout") {
|
|
184356
185303
|
if (e3.shape === "polygon") {
|
|
184357
|
-
e3.points = e3.points.map((p) =>
|
|
185304
|
+
e3.points = e3.points.map((p) => applyToPoint14(matrix2, p));
|
|
184358
185305
|
} else {
|
|
184359
|
-
e3.center =
|
|
185306
|
+
e3.center = applyToPoint14(matrix2, e3.center);
|
|
184360
185307
|
}
|
|
184361
185308
|
} else if (e3.type === "pcb_smtpad" && e3.shape === "polygon") {
|
|
184362
|
-
e3.points = e3.points.map((p) =>
|
|
185309
|
+
e3.points = e3.points.map((p) => applyToPoint14(matrix2, p));
|
|
184363
185310
|
}
|
|
184364
185311
|
}
|
|
184365
185312
|
const cad = circuitElements.find((e3) => e3.type === "cad_component");
|
|
184366
185313
|
if (cad) {
|
|
184367
185314
|
if (!cad.rotation)
|
|
184368
185315
|
cad.rotation = { x: 0, y: 0, z: 0 };
|
|
184369
|
-
const p =
|
|
185316
|
+
const p = applyToPoint14(matrix2, { x: cad.position.x, y: cad.position.y });
|
|
184370
185317
|
cad.position.x = p.x;
|
|
184371
185318
|
cad.position.y = p.y;
|
|
184372
185319
|
const side = pcb_component2.layer ?? "top";
|
|
@@ -184648,8 +185595,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
184648
185595
|
*/
|
|
184649
185596
|
|
|
184650
185597
|
// lib/import/import-component-from-jlcpcb.ts
|
|
184651
|
-
import
|
|
184652
|
-
import
|
|
185598
|
+
import fs32 from "node:fs/promises";
|
|
185599
|
+
import path33 from "node:path";
|
|
184653
185600
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
184654
185601
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
184655
185602
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -184657,10 +185604,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
184657
185604
|
if (!fileName) {
|
|
184658
185605
|
throw new Error("Could not determine file name of converted component");
|
|
184659
185606
|
}
|
|
184660
|
-
const importsDir =
|
|
184661
|
-
await
|
|
184662
|
-
const filePath =
|
|
184663
|
-
await
|
|
185607
|
+
const importsDir = path33.join(projectDir, "imports");
|
|
185608
|
+
await fs32.mkdir(importsDir, { recursive: true });
|
|
185609
|
+
const filePath = path33.join(importsDir, `${fileName}.tsx`);
|
|
185610
|
+
await fs32.writeFile(filePath, tsx);
|
|
184664
185611
|
return { filePath };
|
|
184665
185612
|
};
|
|
184666
185613
|
|
|
@@ -186025,12 +186972,12 @@ var registerRemove = (program3) => {
|
|
|
186025
186972
|
};
|
|
186026
186973
|
|
|
186027
186974
|
// cli/build/register.ts
|
|
186028
|
-
import
|
|
186029
|
-
import
|
|
186975
|
+
import path41 from "node:path";
|
|
186976
|
+
import fs40 from "node:fs";
|
|
186030
186977
|
|
|
186031
186978
|
// cli/build/build-file.ts
|
|
186032
|
-
import
|
|
186033
|
-
import
|
|
186979
|
+
import path34 from "node:path";
|
|
186980
|
+
import fs33 from "node:fs";
|
|
186034
186981
|
|
|
186035
186982
|
// lib/shared/circuit-json-diagnostics.ts
|
|
186036
186983
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -186092,9 +187039,9 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
186092
187039
|
filePath: input,
|
|
186093
187040
|
platformConfig: completePlatformConfig
|
|
186094
187041
|
});
|
|
186095
|
-
|
|
186096
|
-
|
|
186097
|
-
console.log(`Circuit JSON written to ${
|
|
187042
|
+
fs33.mkdirSync(path34.dirname(output), { recursive: true });
|
|
187043
|
+
fs33.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
|
|
187044
|
+
console.log(`Circuit JSON written to ${path34.relative(projectDir, output)}`);
|
|
186098
187045
|
const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
|
|
186099
187046
|
if (!options?.ignoreWarnings) {
|
|
186100
187047
|
for (const warn of warnings) {
|
|
@@ -186132,7 +187079,7 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
186132
187079
|
if (!match)
|
|
186133
187080
|
return;
|
|
186134
187081
|
const [, exportName, fromSpecifier] = match;
|
|
186135
|
-
const entryFileName =
|
|
187082
|
+
const entryFileName = path34.basename(entryFilePath);
|
|
186136
187083
|
console.error([
|
|
186137
187084
|
"",
|
|
186138
187085
|
`It looks like "${entryFileName}" re-exports the type-only symbol "${exportName}" from "${fromSpecifier}" without the "type" modifier.`,
|
|
@@ -186145,20 +187092,20 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
186145
187092
|
};
|
|
186146
187093
|
|
|
186147
187094
|
// cli/build/get-build-entrypoints.ts
|
|
186148
|
-
import
|
|
186149
|
-
import
|
|
187095
|
+
import fs34 from "node:fs";
|
|
187096
|
+
import path35 from "node:path";
|
|
186150
187097
|
var isSubPath2 = (maybeChild, maybeParent) => {
|
|
186151
|
-
const relative9 =
|
|
186152
|
-
return relative9 === "" || !relative9.startsWith("..") && !
|
|
187098
|
+
const relative9 = path35.relative(maybeParent, maybeChild);
|
|
187099
|
+
return relative9 === "" || !relative9.startsWith("..") && !path35.isAbsolute(relative9);
|
|
186153
187100
|
};
|
|
186154
187101
|
var findProjectRoot = (startDir) => {
|
|
186155
187102
|
let currentDir = startDir;
|
|
186156
|
-
while (currentDir !==
|
|
186157
|
-
const packageJsonPath =
|
|
186158
|
-
if (
|
|
187103
|
+
while (currentDir !== path35.dirname(currentDir)) {
|
|
187104
|
+
const packageJsonPath = path35.join(currentDir, "package.json");
|
|
187105
|
+
if (fs34.existsSync(packageJsonPath)) {
|
|
186159
187106
|
return currentDir;
|
|
186160
187107
|
}
|
|
186161
|
-
currentDir =
|
|
187108
|
+
currentDir = path35.dirname(currentDir);
|
|
186162
187109
|
}
|
|
186163
187110
|
return startDir;
|
|
186164
187111
|
};
|
|
@@ -186167,7 +187114,7 @@ async function getBuildEntrypoints({
|
|
|
186167
187114
|
rootDir = process.cwd(),
|
|
186168
187115
|
includeBoardFiles = true
|
|
186169
187116
|
}) {
|
|
186170
|
-
const resolvedRoot =
|
|
187117
|
+
const resolvedRoot = path35.resolve(rootDir);
|
|
186171
187118
|
const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
|
|
186172
187119
|
const buildFromProjectDir = async () => {
|
|
186173
187120
|
if (includeBoardFiles) {
|
|
@@ -186201,8 +187148,8 @@ async function getBuildEntrypoints({
|
|
|
186201
187148
|
};
|
|
186202
187149
|
};
|
|
186203
187150
|
if (fileOrDir) {
|
|
186204
|
-
const resolved =
|
|
186205
|
-
if (
|
|
187151
|
+
const resolved = path35.resolve(resolvedRoot, fileOrDir);
|
|
187152
|
+
if (fs34.existsSync(resolved) && fs34.statSync(resolved).isDirectory()) {
|
|
186206
187153
|
if (includeBoardFiles) {
|
|
186207
187154
|
const circuitFiles = findBoardFiles({
|
|
186208
187155
|
projectDir: resolvedRoot,
|
|
@@ -186232,7 +187179,7 @@ async function getBuildEntrypoints({
|
|
|
186232
187179
|
circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
|
|
186233
187180
|
};
|
|
186234
187181
|
}
|
|
186235
|
-
const fileDir =
|
|
187182
|
+
const fileDir = path35.dirname(resolved);
|
|
186236
187183
|
const projectDir = findProjectRoot(fileDir);
|
|
186237
187184
|
return { projectDir, circuitFiles: [resolved] };
|
|
186238
187185
|
}
|
|
@@ -186269,8 +187216,8 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
|
|
|
186269
187216
|
};
|
|
186270
187217
|
|
|
186271
187218
|
// cli/build/build-preview-images.ts
|
|
186272
|
-
import
|
|
186273
|
-
import
|
|
187219
|
+
import fs35 from "node:fs";
|
|
187220
|
+
import path36 from "node:path";
|
|
186274
187221
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
186275
187222
|
import {
|
|
186276
187223
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
@@ -186343,21 +187290,21 @@ var generatePreviewAssets = async ({
|
|
|
186343
187290
|
outputDir,
|
|
186344
187291
|
distDir
|
|
186345
187292
|
}) => {
|
|
186346
|
-
const prefixRelative =
|
|
187293
|
+
const prefixRelative = path36.relative(distDir, outputDir) || ".";
|
|
186347
187294
|
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
186348
187295
|
let circuitJson;
|
|
186349
187296
|
try {
|
|
186350
|
-
const circuitJsonRaw =
|
|
187297
|
+
const circuitJsonRaw = fs35.readFileSync(build.outputPath, "utf-8");
|
|
186351
187298
|
circuitJson = JSON.parse(circuitJsonRaw);
|
|
186352
187299
|
} catch (error) {
|
|
186353
187300
|
console.error(`${prefix}Failed to read circuit JSON:`, error);
|
|
186354
187301
|
return;
|
|
186355
187302
|
}
|
|
186356
|
-
|
|
187303
|
+
fs35.mkdirSync(outputDir, { recursive: true });
|
|
186357
187304
|
try {
|
|
186358
187305
|
console.log(`${prefix}Generating PCB SVG...`);
|
|
186359
187306
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson);
|
|
186360
|
-
|
|
187307
|
+
fs35.writeFileSync(path36.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
186361
187308
|
console.log(`${prefix}Written pcb.svg`);
|
|
186362
187309
|
} catch (error) {
|
|
186363
187310
|
console.error(`${prefix}Failed to generate PCB SVG:`, error);
|
|
@@ -186365,7 +187312,7 @@ var generatePreviewAssets = async ({
|
|
|
186365
187312
|
try {
|
|
186366
187313
|
console.log(`${prefix}Generating schematic SVG...`);
|
|
186367
187314
|
const schematicSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
|
|
186368
|
-
|
|
187315
|
+
fs35.writeFileSync(path36.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
186369
187316
|
console.log(`${prefix}Written schematic.svg`);
|
|
186370
187317
|
} catch (error) {
|
|
186371
187318
|
console.error(`${prefix}Failed to generate schematic SVG:`, error);
|
|
@@ -186382,7 +187329,7 @@ var generatePreviewAssets = async ({
|
|
|
186382
187329
|
camPos: [10, 10, 10],
|
|
186383
187330
|
lookAt: [0, 0, 0]
|
|
186384
187331
|
});
|
|
186385
|
-
|
|
187332
|
+
fs35.writeFileSync(path36.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
|
|
186386
187333
|
console.log(`${prefix}Written 3d.png`);
|
|
186387
187334
|
} catch (error) {
|
|
186388
187335
|
console.error(`${prefix}Failed to generate 3D PNG:`, error);
|
|
@@ -186395,14 +187342,14 @@ var buildPreviewImages = async ({
|
|
|
186395
187342
|
allImages
|
|
186396
187343
|
}) => {
|
|
186397
187344
|
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
186398
|
-
const normalizedMainEntrypoint = mainEntrypoint ?
|
|
187345
|
+
const normalizedMainEntrypoint = mainEntrypoint ? path36.resolve(mainEntrypoint) : undefined;
|
|
186399
187346
|
if (allImages) {
|
|
186400
187347
|
if (successfulBuilds.length === 0) {
|
|
186401
187348
|
console.warn("No successful build output available for preview image generation.");
|
|
186402
187349
|
return;
|
|
186403
187350
|
}
|
|
186404
187351
|
for (const build of successfulBuilds) {
|
|
186405
|
-
const outputDir =
|
|
187352
|
+
const outputDir = path36.dirname(build.outputPath);
|
|
186406
187353
|
await generatePreviewAssets({
|
|
186407
187354
|
build,
|
|
186408
187355
|
outputDir,
|
|
@@ -186413,7 +187360,7 @@ var buildPreviewImages = async ({
|
|
|
186413
187360
|
}
|
|
186414
187361
|
const previewBuild = (() => {
|
|
186415
187362
|
if (normalizedMainEntrypoint) {
|
|
186416
|
-
const match = successfulBuilds.find((built) =>
|
|
187363
|
+
const match = successfulBuilds.find((built) => path36.resolve(built.sourcePath) === normalizedMainEntrypoint);
|
|
186417
187364
|
if (match)
|
|
186418
187365
|
return match;
|
|
186419
187366
|
}
|
|
@@ -186431,8 +187378,8 @@ var buildPreviewImages = async ({
|
|
|
186431
187378
|
};
|
|
186432
187379
|
|
|
186433
187380
|
// cli/build/generate-kicad-project.ts
|
|
186434
|
-
import
|
|
186435
|
-
import
|
|
187381
|
+
import fs36 from "node:fs";
|
|
187382
|
+
import path37 from "node:path";
|
|
186436
187383
|
var createKicadProContent = ({
|
|
186437
187384
|
projectName,
|
|
186438
187385
|
schematicFileName,
|
|
@@ -186472,10 +187419,10 @@ var generateKicadProject = async ({
|
|
|
186472
187419
|
boardFileName
|
|
186473
187420
|
});
|
|
186474
187421
|
if (writeFiles) {
|
|
186475
|
-
|
|
186476
|
-
|
|
186477
|
-
|
|
186478
|
-
|
|
187422
|
+
fs36.mkdirSync(outputDir, { recursive: true });
|
|
187423
|
+
fs36.writeFileSync(path37.join(outputDir, schematicFileName), schContent);
|
|
187424
|
+
fs36.writeFileSync(path37.join(outputDir, boardFileName), pcbContent);
|
|
187425
|
+
fs36.writeFileSync(path37.join(outputDir, projectFileName), proContent);
|
|
186479
187426
|
}
|
|
186480
187427
|
return {
|
|
186481
187428
|
pcbContent,
|
|
@@ -186487,8 +187434,8 @@ var generateKicadProject = async ({
|
|
|
186487
187434
|
};
|
|
186488
187435
|
|
|
186489
187436
|
// cli/build/transpile/index.ts
|
|
186490
|
-
import
|
|
186491
|
-
import
|
|
187437
|
+
import path39 from "node:path";
|
|
187438
|
+
import fs38 from "node:fs";
|
|
186492
187439
|
import { rollup } from "rollup";
|
|
186493
187440
|
import typescript from "@rollup/plugin-typescript";
|
|
186494
187441
|
import resolve11 from "@rollup/plugin-node-resolve";
|
|
@@ -186497,11 +187444,11 @@ import json from "@rollup/plugin-json";
|
|
|
186497
187444
|
import dts from "rollup-plugin-dts";
|
|
186498
187445
|
|
|
186499
187446
|
// cli/build/transpile/static-asset-plugin.ts
|
|
186500
|
-
import
|
|
186501
|
-
import
|
|
187447
|
+
import fs37 from "node:fs";
|
|
187448
|
+
import path38 from "node:path";
|
|
186502
187449
|
import { createHash } from "node:crypto";
|
|
186503
187450
|
function normalizePathSeparators(filePath) {
|
|
186504
|
-
return filePath.split(
|
|
187451
|
+
return filePath.split(path38.sep).join("/");
|
|
186505
187452
|
}
|
|
186506
187453
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
186507
187454
|
".glb",
|
|
@@ -186532,24 +187479,24 @@ var createStaticAssetPlugin = ({
|
|
|
186532
187479
|
return {
|
|
186533
187480
|
name: "tsci-static-assets",
|
|
186534
187481
|
resolveId(source, importer) {
|
|
186535
|
-
const ext =
|
|
187482
|
+
const ext = path38.extname(source).toLowerCase();
|
|
186536
187483
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
186537
187484
|
return null;
|
|
186538
|
-
if (
|
|
186539
|
-
return
|
|
187485
|
+
if (path38.isAbsolute(source)) {
|
|
187486
|
+
return fs37.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
186540
187487
|
}
|
|
186541
187488
|
if (importer) {
|
|
186542
|
-
const importerNative = importer.split("/").join(
|
|
186543
|
-
const resolvedFromImporter =
|
|
186544
|
-
if (
|
|
187489
|
+
const importerNative = importer.split("/").join(path38.sep);
|
|
187490
|
+
const resolvedFromImporter = path38.resolve(path38.dirname(importerNative), source);
|
|
187491
|
+
if (fs37.existsSync(resolvedFromImporter)) {
|
|
186545
187492
|
return {
|
|
186546
187493
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
186547
187494
|
external: true
|
|
186548
187495
|
};
|
|
186549
187496
|
}
|
|
186550
187497
|
}
|
|
186551
|
-
const resolvedFromProject =
|
|
186552
|
-
if (
|
|
187498
|
+
const resolvedFromProject = path38.resolve(resolvedBaseUrl, source);
|
|
187499
|
+
if (fs37.existsSync(resolvedFromProject)) {
|
|
186553
187500
|
return {
|
|
186554
187501
|
id: normalizePathSeparators(resolvedFromProject),
|
|
186555
187502
|
external: true
|
|
@@ -186562,8 +187509,8 @@ var createStaticAssetPlugin = ({
|
|
|
186562
187509
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
186563
187510
|
for (const target of targets) {
|
|
186564
187511
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
186565
|
-
const resolvedTarget =
|
|
186566
|
-
if (
|
|
187512
|
+
const resolvedTarget = path38.resolve(resolvedBaseUrl, targetPath);
|
|
187513
|
+
if (fs37.existsSync(resolvedTarget)) {
|
|
186567
187514
|
return {
|
|
186568
187515
|
id: normalizePathSeparators(resolvedTarget),
|
|
186569
187516
|
external: true
|
|
@@ -186589,18 +187536,18 @@ var createStaticAssetPlugin = ({
|
|
|
186589
187536
|
if (chunk.type !== "chunk")
|
|
186590
187537
|
continue;
|
|
186591
187538
|
for (const importedId of chunk.imports) {
|
|
186592
|
-
const ext =
|
|
187539
|
+
const ext = path38.extname(importedId).toLowerCase();
|
|
186593
187540
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
186594
187541
|
continue;
|
|
186595
187542
|
if (!copiedAssets.has(importedId)) {
|
|
186596
|
-
const assetDir =
|
|
186597
|
-
|
|
186598
|
-
const nativePath = importedId.split("/").join(
|
|
186599
|
-
const fileBuffer =
|
|
187543
|
+
const assetDir = path38.join(outputDir, "assets");
|
|
187544
|
+
fs37.mkdirSync(assetDir, { recursive: true });
|
|
187545
|
+
const nativePath = importedId.split("/").join(path38.sep);
|
|
187546
|
+
const fileBuffer = fs37.readFileSync(nativePath);
|
|
186600
187547
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
186601
|
-
const fileName = `${
|
|
186602
|
-
const outputFilePath =
|
|
186603
|
-
|
|
187548
|
+
const fileName = `${path38.basename(importedId, ext)}-${hash}${ext}`;
|
|
187549
|
+
const outputFilePath = path38.join(assetDir, fileName);
|
|
187550
|
+
fs37.writeFileSync(outputFilePath, fileBuffer);
|
|
186604
187551
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
186605
187552
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
186606
187553
|
}
|
|
@@ -186622,17 +187569,17 @@ function escapeRegExp(string) {
|
|
|
186622
187569
|
|
|
186623
187570
|
// cli/build/transpile/index.ts
|
|
186624
187571
|
var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
186625
|
-
if (id2.startsWith(".") || id2.startsWith("/") ||
|
|
187572
|
+
if (id2.startsWith(".") || id2.startsWith("/") || path39.isAbsolute(id2)) {
|
|
186626
187573
|
return false;
|
|
186627
187574
|
}
|
|
186628
187575
|
let baseUrl = projectDir;
|
|
186629
187576
|
let pathMappings = {};
|
|
186630
|
-
if (tsconfigPath &&
|
|
187577
|
+
if (tsconfigPath && fs38.existsSync(tsconfigPath)) {
|
|
186631
187578
|
try {
|
|
186632
|
-
const tsconfigContent =
|
|
187579
|
+
const tsconfigContent = fs38.readFileSync(tsconfigPath, "utf-8");
|
|
186633
187580
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
186634
187581
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
186635
|
-
baseUrl =
|
|
187582
|
+
baseUrl = path39.resolve(path39.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
186636
187583
|
}
|
|
186637
187584
|
if (tsconfig.compilerOptions?.paths) {
|
|
186638
187585
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -186646,17 +187593,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
|
186646
187593
|
}
|
|
186647
187594
|
}
|
|
186648
187595
|
const potentialPaths = [
|
|
186649
|
-
|
|
186650
|
-
|
|
186651
|
-
|
|
186652
|
-
|
|
186653
|
-
|
|
186654
|
-
|
|
186655
|
-
|
|
186656
|
-
|
|
186657
|
-
|
|
187596
|
+
path39.join(baseUrl, id2),
|
|
187597
|
+
path39.join(baseUrl, `${id2}.ts`),
|
|
187598
|
+
path39.join(baseUrl, `${id2}.tsx`),
|
|
187599
|
+
path39.join(baseUrl, `${id2}.js`),
|
|
187600
|
+
path39.join(baseUrl, `${id2}.jsx`),
|
|
187601
|
+
path39.join(baseUrl, id2, "index.ts"),
|
|
187602
|
+
path39.join(baseUrl, id2, "index.tsx"),
|
|
187603
|
+
path39.join(baseUrl, id2, "index.js"),
|
|
187604
|
+
path39.join(baseUrl, id2, "index.jsx")
|
|
186658
187605
|
];
|
|
186659
|
-
if (potentialPaths.some((p) =>
|
|
187606
|
+
if (potentialPaths.some((p) => fs38.existsSync(p))) {
|
|
186660
187607
|
return false;
|
|
186661
187608
|
}
|
|
186662
187609
|
return true;
|
|
@@ -186667,17 +187614,17 @@ var transpileFile = async ({
|
|
|
186667
187614
|
projectDir
|
|
186668
187615
|
}) => {
|
|
186669
187616
|
try {
|
|
186670
|
-
|
|
186671
|
-
const tsconfigPath =
|
|
186672
|
-
const hasTsConfig =
|
|
187617
|
+
fs38.mkdirSync(outputDir, { recursive: true });
|
|
187618
|
+
const tsconfigPath = path39.join(projectDir, "tsconfig.json");
|
|
187619
|
+
const hasTsConfig = fs38.existsSync(tsconfigPath);
|
|
186673
187620
|
let tsconfigBaseUrl = projectDir;
|
|
186674
187621
|
let tsconfigPathMappings;
|
|
186675
187622
|
if (hasTsConfig) {
|
|
186676
187623
|
try {
|
|
186677
|
-
const tsconfigContent =
|
|
187624
|
+
const tsconfigContent = fs38.readFileSync(tsconfigPath, "utf-8");
|
|
186678
187625
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
186679
187626
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
186680
|
-
tsconfigBaseUrl =
|
|
187627
|
+
tsconfigBaseUrl = path39.resolve(path39.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
186681
187628
|
}
|
|
186682
187629
|
if (tsconfig.compilerOptions?.paths) {
|
|
186683
187630
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -186732,27 +187679,27 @@ var transpileFile = async ({
|
|
|
186732
187679
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
186733
187680
|
plugins: getPlugins()
|
|
186734
187681
|
});
|
|
186735
|
-
const esmOutputPath =
|
|
187682
|
+
const esmOutputPath = path39.join(outputDir, "index.js");
|
|
186736
187683
|
await esmBundle.write({
|
|
186737
187684
|
file: esmOutputPath,
|
|
186738
187685
|
format: "es",
|
|
186739
187686
|
sourcemap: false
|
|
186740
187687
|
});
|
|
186741
|
-
console.log(`ESM bundle written to ${
|
|
187688
|
+
console.log(`ESM bundle written to ${path39.relative(projectDir, esmOutputPath)}`);
|
|
186742
187689
|
console.log("Building CommonJS bundle...");
|
|
186743
187690
|
const cjsBundle = await rollup({
|
|
186744
187691
|
input,
|
|
186745
187692
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
186746
187693
|
plugins: getPlugins()
|
|
186747
187694
|
});
|
|
186748
|
-
const cjsOutputPath =
|
|
187695
|
+
const cjsOutputPath = path39.join(outputDir, "index.cjs");
|
|
186749
187696
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
186750
187697
|
await cjsBundle.write({
|
|
186751
187698
|
file: cjsOutputPath,
|
|
186752
187699
|
format: "cjs",
|
|
186753
187700
|
sourcemap: false
|
|
186754
187701
|
});
|
|
186755
|
-
console.log(`CommonJS bundle written to ${
|
|
187702
|
+
console.log(`CommonJS bundle written to ${path39.relative(projectDir, cjsOutputPath)}`);
|
|
186756
187703
|
console.log("Generating type declarations...");
|
|
186757
187704
|
const dtsBundle = await rollup({
|
|
186758
187705
|
input,
|
|
@@ -186777,9 +187724,9 @@ var transpileFile = async ({
|
|
|
186777
187724
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
186778
187725
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
186779
187726
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
186780
|
-
const dtsOutputPath =
|
|
186781
|
-
|
|
186782
|
-
console.log(`Type declarations written to ${
|
|
187727
|
+
const dtsOutputPath = path39.join(outputDir, "index.d.ts");
|
|
187728
|
+
fs38.writeFileSync(dtsOutputPath, dtsContent);
|
|
187729
|
+
console.log(`Type declarations written to ${path39.relative(projectDir, dtsOutputPath)}`);
|
|
186783
187730
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
186784
187731
|
return true;
|
|
186785
187732
|
} catch (err) {
|
|
@@ -186792,17 +187739,17 @@ var transpileFile = async ({
|
|
|
186792
187739
|
};
|
|
186793
187740
|
|
|
186794
187741
|
// cli/utils/validate-main-in-dist.ts
|
|
186795
|
-
import
|
|
186796
|
-
import
|
|
187742
|
+
import fs39 from "node:fs";
|
|
187743
|
+
import path40 from "node:path";
|
|
186797
187744
|
var validateMainInDist = (projectDir, distDir) => {
|
|
186798
|
-
const packageJsonPath =
|
|
186799
|
-
if (!
|
|
187745
|
+
const packageJsonPath = path40.join(projectDir, "package.json");
|
|
187746
|
+
if (!fs39.existsSync(packageJsonPath))
|
|
186800
187747
|
return;
|
|
186801
|
-
const packageJson = JSON.parse(
|
|
187748
|
+
const packageJson = JSON.parse(fs39.readFileSync(packageJsonPath, "utf-8"));
|
|
186802
187749
|
if (typeof packageJson.main !== "string")
|
|
186803
187750
|
return;
|
|
186804
|
-
const resolvedMainPath =
|
|
186805
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
187751
|
+
const resolvedMainPath = path40.resolve(projectDir, packageJson.main);
|
|
187752
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path40.sep}`);
|
|
186806
187753
|
if (!isMainInDist) {
|
|
186807
187754
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
186808
187755
|
}
|
|
@@ -186827,8 +187774,8 @@ var registerBuild = (program3) => {
|
|
|
186827
187774
|
}
|
|
186828
187775
|
return config;
|
|
186829
187776
|
})();
|
|
186830
|
-
const distDir =
|
|
186831
|
-
|
|
187777
|
+
const distDir = path41.join(projectDir, "dist");
|
|
187778
|
+
fs40.mkdirSync(distDir, { recursive: true });
|
|
186832
187779
|
console.log(`Building ${circuitFiles.length} file(s)...`);
|
|
186833
187780
|
let hasErrors = false;
|
|
186834
187781
|
const staticFileReferences = [];
|
|
@@ -186836,10 +187783,10 @@ var registerBuild = (program3) => {
|
|
|
186836
187783
|
const kicadProjects = [];
|
|
186837
187784
|
const shouldGenerateKicad = options?.kicad || options?.kicadFootprintLibrary;
|
|
186838
187785
|
for (const filePath of circuitFiles) {
|
|
186839
|
-
const relative9 =
|
|
187786
|
+
const relative9 = path41.relative(projectDir, filePath);
|
|
186840
187787
|
console.log(`Building ${relative9}...`);
|
|
186841
187788
|
const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
186842
|
-
const outputPath =
|
|
187789
|
+
const outputPath = path41.join(distDir, outputDirName, "circuit.json");
|
|
186843
187790
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, {
|
|
186844
187791
|
ignoreErrors: options?.ignoreErrors,
|
|
186845
187792
|
ignoreWarnings: options?.ignoreWarnings,
|
|
@@ -186853,17 +187800,17 @@ var registerBuild = (program3) => {
|
|
|
186853
187800
|
if (!buildOutcome.ok) {
|
|
186854
187801
|
hasErrors = true;
|
|
186855
187802
|
} else if (options?.site) {
|
|
186856
|
-
const normalizedSourcePath = relative9.split(
|
|
186857
|
-
const relativeOutputPath =
|
|
186858
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
187803
|
+
const normalizedSourcePath = relative9.split(path41.sep).join("/");
|
|
187804
|
+
const relativeOutputPath = path41.join(outputDirName, "circuit.json");
|
|
187805
|
+
const normalizedOutputPath = relativeOutputPath.split(path41.sep).join("/");
|
|
186859
187806
|
staticFileReferences.push({
|
|
186860
187807
|
filePath: normalizedSourcePath,
|
|
186861
187808
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
186862
187809
|
});
|
|
186863
187810
|
}
|
|
186864
187811
|
if (buildOutcome.ok && shouldGenerateKicad && buildOutcome.circuitJson) {
|
|
186865
|
-
const projectOutputDir =
|
|
186866
|
-
const projectName =
|
|
187812
|
+
const projectOutputDir = path41.join(distDir, outputDirName, "kicad");
|
|
187813
|
+
const projectName = path41.basename(outputDirName);
|
|
186867
187814
|
const project = await generateKicadProject({
|
|
186868
187815
|
circuitJson: buildOutcome.circuitJson,
|
|
186869
187816
|
outputDir: projectOutputDir,
|
|
@@ -186916,8 +187863,8 @@ var registerBuild = (program3) => {
|
|
|
186916
187863
|
files: staticFileReferences,
|
|
186917
187864
|
standaloneScriptSrc: "./standalone.min.js"
|
|
186918
187865
|
});
|
|
186919
|
-
|
|
186920
|
-
|
|
187866
|
+
fs40.writeFileSync(path41.join(distDir, "index.html"), indexHtml);
|
|
187867
|
+
fs40.writeFileSync(path41.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
186921
187868
|
}
|
|
186922
187869
|
if (options?.kicadFootprintLibrary) {
|
|
186923
187870
|
if (kicadProjects.length === 0) {
|
|
@@ -186940,8 +187887,8 @@ var registerBuild = (program3) => {
|
|
|
186940
187887
|
};
|
|
186941
187888
|
|
|
186942
187889
|
// lib/shared/snapshot-project.ts
|
|
186943
|
-
import
|
|
186944
|
-
import
|
|
187890
|
+
import fs42 from "node:fs";
|
|
187891
|
+
import path42 from "node:path";
|
|
186945
187892
|
import looksSame2 from "looks-same";
|
|
186946
187893
|
import {
|
|
186947
187894
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
@@ -186952,7 +187899,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
186952
187899
|
|
|
186953
187900
|
// lib/shared/compare-images.ts
|
|
186954
187901
|
import looksSame from "looks-same";
|
|
186955
|
-
import
|
|
187902
|
+
import fs41 from "node:fs/promises";
|
|
186956
187903
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
186957
187904
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
186958
187905
|
strict: false,
|
|
@@ -186968,7 +187915,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
186968
187915
|
tolerance: 2
|
|
186969
187916
|
});
|
|
186970
187917
|
} else {
|
|
186971
|
-
await
|
|
187918
|
+
await fs41.writeFile(diffPath, buffer2);
|
|
186972
187919
|
}
|
|
186973
187920
|
}
|
|
186974
187921
|
return { equal: equal2 };
|
|
@@ -186993,7 +187940,7 @@ var snapshotProject = async ({
|
|
|
186993
187940
|
...DEFAULT_IGNORED_PATTERNS,
|
|
186994
187941
|
...ignored.map(normalizeIgnorePattern)
|
|
186995
187942
|
];
|
|
186996
|
-
const resolvedPaths = filePaths.map((f) =>
|
|
187943
|
+
const resolvedPaths = filePaths.map((f) => path42.resolve(projectDir, f));
|
|
186997
187944
|
const boardFiles = findBoardFiles({
|
|
186998
187945
|
projectDir,
|
|
186999
187946
|
ignore,
|
|
@@ -187007,7 +187954,7 @@ var snapshotProject = async ({
|
|
|
187007
187954
|
const mismatches = [];
|
|
187008
187955
|
let didUpdate = false;
|
|
187009
187956
|
for (const file of boardFiles) {
|
|
187010
|
-
const relativeFilePath =
|
|
187957
|
+
const relativeFilePath = path42.relative(projectDir, file);
|
|
187011
187958
|
let circuitJson;
|
|
187012
187959
|
let pcbSvg;
|
|
187013
187960
|
let schSvg;
|
|
@@ -187062,17 +188009,17 @@ var snapshotProject = async ({
|
|
|
187062
188009
|
} catch (error) {
|
|
187063
188010
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
187064
188011
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
187065
|
-
const fileDir =
|
|
187066
|
-
const relativeDir =
|
|
187067
|
-
const snapDir2 = snapshotsDirName ?
|
|
187068
|
-
const base2 =
|
|
187069
|
-
const snap3dPath =
|
|
187070
|
-
const existing3dSnapshot =
|
|
188012
|
+
const fileDir = path42.dirname(file);
|
|
188013
|
+
const relativeDir = path42.relative(projectDir, fileDir);
|
|
188014
|
+
const snapDir2 = snapshotsDirName ? path42.join(projectDir, snapshotsDirName, relativeDir) : path42.join(fileDir, "__snapshots__");
|
|
188015
|
+
const base2 = path42.basename(file).replace(/\.tsx$/, "");
|
|
188016
|
+
const snap3dPath = path42.join(snapDir2, `${base2}-3d.snap.png`);
|
|
188017
|
+
const existing3dSnapshot = fs42.existsSync(snap3dPath);
|
|
187071
188018
|
if (existing3dSnapshot) {
|
|
187072
188019
|
onError(kleur_default.red(`
|
|
187073
188020
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
187074
188021
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
187075
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
188022
|
+
`) + kleur_default.red(` Existing snapshot: ${path42.relative(projectDir, snap3dPath)}
|
|
187076
188023
|
`));
|
|
187077
188024
|
return onExit2(1);
|
|
187078
188025
|
} else {
|
|
@@ -187088,9 +188035,9 @@ var snapshotProject = async ({
|
|
|
187088
188035
|
}
|
|
187089
188036
|
}
|
|
187090
188037
|
}
|
|
187091
|
-
const snapDir = snapshotsDirName ?
|
|
187092
|
-
|
|
187093
|
-
const base =
|
|
188038
|
+
const snapDir = snapshotsDirName ? path42.join(projectDir, snapshotsDirName, path42.relative(projectDir, path42.dirname(file))) : path42.join(path42.dirname(file), "__snapshots__");
|
|
188039
|
+
fs42.mkdirSync(snapDir, { recursive: true });
|
|
188040
|
+
const base = path42.basename(file).replace(/\.tsx$/, "");
|
|
187094
188041
|
const snapshots = [];
|
|
187095
188042
|
if (pcbOnly || !schematicOnly) {
|
|
187096
188043
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -187108,31 +188055,31 @@ var snapshotProject = async ({
|
|
|
187108
188055
|
for (const snapshot of snapshots) {
|
|
187109
188056
|
const { type } = snapshot;
|
|
187110
188057
|
const is3d = type === "3d";
|
|
187111
|
-
const snapPath =
|
|
187112
|
-
const existing =
|
|
188058
|
+
const snapPath = path42.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
188059
|
+
const existing = fs42.existsSync(snapPath);
|
|
187113
188060
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
187114
188061
|
const newContentForFile = snapshot.content;
|
|
187115
188062
|
if (!existing) {
|
|
187116
|
-
|
|
187117
|
-
console.log("✅", kleur_default.gray(
|
|
188063
|
+
fs42.writeFileSync(snapPath, newContentForFile);
|
|
188064
|
+
console.log("✅", kleur_default.gray(path42.relative(projectDir, snapPath)));
|
|
187118
188065
|
didUpdate = true;
|
|
187119
188066
|
continue;
|
|
187120
188067
|
}
|
|
187121
|
-
const oldContentBuffer =
|
|
188068
|
+
const oldContentBuffer = fs42.readFileSync(snapPath);
|
|
187122
188069
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
187123
188070
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
187124
188071
|
if (update) {
|
|
187125
188072
|
if (!forceUpdate && equal2) {
|
|
187126
|
-
console.log("✅", kleur_default.gray(
|
|
188073
|
+
console.log("✅", kleur_default.gray(path42.relative(projectDir, snapPath)));
|
|
187127
188074
|
} else {
|
|
187128
|
-
|
|
187129
|
-
console.log("✅", kleur_default.gray(
|
|
188075
|
+
fs42.writeFileSync(snapPath, newContentForFile);
|
|
188076
|
+
console.log("✅", kleur_default.gray(path42.relative(projectDir, snapPath)));
|
|
187130
188077
|
didUpdate = true;
|
|
187131
188078
|
}
|
|
187132
188079
|
} else if (!equal2) {
|
|
187133
188080
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
187134
188081
|
} else {
|
|
187135
|
-
console.log("✅", kleur_default.gray(
|
|
188082
|
+
console.log("✅", kleur_default.gray(path42.relative(projectDir, snapPath)));
|
|
187136
188083
|
}
|
|
187137
188084
|
}
|
|
187138
188085
|
}
|
|
@@ -187171,22 +188118,22 @@ var registerSnapshot = (program3) => {
|
|
|
187171
188118
|
};
|
|
187172
188119
|
|
|
187173
188120
|
// lib/shared/setup-github-actions.ts
|
|
187174
|
-
import
|
|
187175
|
-
import
|
|
188121
|
+
import fs43 from "node:fs";
|
|
188122
|
+
import path43 from "node:path";
|
|
187176
188123
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
187177
188124
|
const findGitRoot = (startDir) => {
|
|
187178
|
-
let dir =
|
|
187179
|
-
while (dir !==
|
|
187180
|
-
if (
|
|
188125
|
+
let dir = path43.resolve(startDir);
|
|
188126
|
+
while (dir !== path43.parse(dir).root) {
|
|
188127
|
+
if (fs43.existsSync(path43.join(dir, ".git"))) {
|
|
187181
188128
|
return dir;
|
|
187182
188129
|
}
|
|
187183
|
-
dir =
|
|
188130
|
+
dir = path43.dirname(dir);
|
|
187184
188131
|
}
|
|
187185
188132
|
return null;
|
|
187186
188133
|
};
|
|
187187
188134
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
187188
|
-
const workflowsDir =
|
|
187189
|
-
|
|
188135
|
+
const workflowsDir = path43.join(gitRoot, ".github", "workflows");
|
|
188136
|
+
fs43.mkdirSync(workflowsDir, { recursive: true });
|
|
187190
188137
|
const buildWorkflow = `name: tscircuit Build
|
|
187191
188138
|
|
|
187192
188139
|
on:
|
|
@@ -187225,8 +188172,8 @@ jobs:
|
|
|
187225
188172
|
- run: bun install
|
|
187226
188173
|
- run: bunx tsci snapshot
|
|
187227
188174
|
`;
|
|
187228
|
-
writeFileIfNotExists(
|
|
187229
|
-
writeFileIfNotExists(
|
|
188175
|
+
writeFileIfNotExists(path43.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
188176
|
+
writeFileIfNotExists(path43.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
187230
188177
|
};
|
|
187231
188178
|
|
|
187232
188179
|
// cli/setup/register.ts
|
|
@@ -187264,8 +188211,8 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
187264
188211
|
}
|
|
187265
188212
|
|
|
187266
188213
|
// cli/convert/register.ts
|
|
187267
|
-
import
|
|
187268
|
-
import
|
|
188214
|
+
import fs44 from "node:fs/promises";
|
|
188215
|
+
import path44 from "node:path";
|
|
187269
188216
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
187270
188217
|
|
|
187271
188218
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -187385,15 +188332,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
187385
188332
|
var registerConvert = (program3) => {
|
|
187386
188333
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
187387
188334
|
try {
|
|
187388
|
-
const inputPath =
|
|
187389
|
-
const modContent = await
|
|
188335
|
+
const inputPath = path44.resolve(file);
|
|
188336
|
+
const modContent = await fs44.readFile(inputPath, "utf-8");
|
|
187390
188337
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
187391
|
-
const componentName = options.name ??
|
|
188338
|
+
const componentName = options.name ?? path44.basename(inputPath, ".kicad_mod");
|
|
187392
188339
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
187393
188340
|
componentName
|
|
187394
188341
|
});
|
|
187395
|
-
const outputPath = options.output ?
|
|
187396
|
-
await
|
|
188342
|
+
const outputPath = options.output ? path44.resolve(options.output) : path44.join(path44.dirname(inputPath), `${componentName}.tsx`);
|
|
188343
|
+
await fs44.writeFile(outputPath, tsx);
|
|
187397
188344
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
187398
188345
|
} catch (error) {
|
|
187399
188346
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -187489,12 +188436,12 @@ var registerSimulate = (program3) => {
|
|
|
187489
188436
|
};
|
|
187490
188437
|
|
|
187491
188438
|
// lib/shared/install-project-dependencies.ts
|
|
187492
|
-
import
|
|
187493
|
-
import
|
|
188439
|
+
import fs46 from "node:fs";
|
|
188440
|
+
import path46 from "node:path";
|
|
187494
188441
|
|
|
187495
188442
|
// lib/shared/collect-tsci-dependencies.ts
|
|
187496
|
-
import
|
|
187497
|
-
import
|
|
188443
|
+
import fs45 from "node:fs";
|
|
188444
|
+
import path45 from "node:path";
|
|
187498
188445
|
var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
|
|
187499
188446
|
var DEFAULT_IGNORES = [
|
|
187500
188447
|
"**/node_modules/**",
|
|
@@ -187509,7 +188456,7 @@ function collectTsciDependencies({
|
|
|
187509
188456
|
patterns = DEFAULT_PATTERNS,
|
|
187510
188457
|
ignore = DEFAULT_IGNORES
|
|
187511
188458
|
} = {}) {
|
|
187512
|
-
const searchRoot =
|
|
188459
|
+
const searchRoot = path45.resolve(cwd);
|
|
187513
188460
|
const files = globbySync(patterns, {
|
|
187514
188461
|
cwd: searchRoot,
|
|
187515
188462
|
absolute: true,
|
|
@@ -187519,7 +188466,7 @@ function collectTsciDependencies({
|
|
|
187519
188466
|
const dependencies2 = new Set;
|
|
187520
188467
|
for (const filePath of files) {
|
|
187521
188468
|
try {
|
|
187522
|
-
const fileContents =
|
|
188469
|
+
const fileContents = fs45.readFileSync(filePath, "utf-8");
|
|
187523
188470
|
let match;
|
|
187524
188471
|
while (true) {
|
|
187525
188472
|
match = IMPORT_PATTERN.exec(fileContents);
|
|
@@ -187536,26 +188483,26 @@ function collectTsciDependencies({
|
|
|
187536
188483
|
async function installProjectDependencies({
|
|
187537
188484
|
cwd = process.cwd()
|
|
187538
188485
|
} = {}) {
|
|
187539
|
-
const projectRoot =
|
|
187540
|
-
const packageJsonPath =
|
|
187541
|
-
const npmrcPath =
|
|
188486
|
+
const projectRoot = path46.resolve(cwd);
|
|
188487
|
+
const packageJsonPath = path46.join(projectRoot, "package.json");
|
|
188488
|
+
const npmrcPath = path46.join(projectRoot, ".npmrc");
|
|
187542
188489
|
const packageManager = getPackageManager();
|
|
187543
|
-
if (!
|
|
188490
|
+
if (!fs46.existsSync(projectRoot)) {
|
|
187544
188491
|
throw new Error(`Directory not found: ${projectRoot}`);
|
|
187545
188492
|
}
|
|
187546
188493
|
let packageJsonCreated = false;
|
|
187547
|
-
if (!
|
|
188494
|
+
if (!fs46.existsSync(packageJsonPath)) {
|
|
187548
188495
|
console.log("No package.json found. Generating a new one.");
|
|
187549
188496
|
generatePackageJson(projectRoot);
|
|
187550
188497
|
packageJsonCreated = true;
|
|
187551
188498
|
} else {
|
|
187552
188499
|
console.log("Found existing package.json.");
|
|
187553
188500
|
}
|
|
187554
|
-
if (!
|
|
188501
|
+
if (!fs46.existsSync(npmrcPath)) {
|
|
187555
188502
|
console.log("Creating .npmrc with tscircuit registry configuration.");
|
|
187556
|
-
|
|
188503
|
+
fs46.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
|
|
187557
188504
|
}
|
|
187558
|
-
const packageJson = JSON.parse(
|
|
188505
|
+
const packageJson = JSON.parse(fs46.readFileSync(packageJsonPath, "utf-8"));
|
|
187559
188506
|
if (packageJsonCreated) {
|
|
187560
188507
|
const tsciDependencies = collectTsciDependencies({ cwd: projectRoot });
|
|
187561
188508
|
if (tsciDependencies.length > 0) {
|
|
@@ -187570,7 +188517,7 @@ async function installProjectDependencies({
|
|
|
187570
188517
|
console.log("No @tsci dependencies detected in circuit files.");
|
|
187571
188518
|
}
|
|
187572
188519
|
}
|
|
187573
|
-
|
|
188520
|
+
fs46.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
187574
188521
|
`);
|
|
187575
188522
|
console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
|
|
187576
188523
|
try {
|
|
@@ -187605,7 +188552,7 @@ var registerInstall = (program3) => {
|
|
|
187605
188552
|
};
|
|
187606
188553
|
|
|
187607
188554
|
// cli/transpile/register.ts
|
|
187608
|
-
import
|
|
188555
|
+
import path47 from "node:path";
|
|
187609
188556
|
var registerTranspile = (program3) => {
|
|
187610
188557
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
187611
188558
|
try {
|
|
@@ -187613,7 +188560,7 @@ var registerTranspile = (program3) => {
|
|
|
187613
188560
|
fileOrDir: file,
|
|
187614
188561
|
includeBoardFiles: false
|
|
187615
188562
|
});
|
|
187616
|
-
const distDir =
|
|
188563
|
+
const distDir = path47.join(projectDir, "dist");
|
|
187617
188564
|
validateMainInDist(projectDir, distDir);
|
|
187618
188565
|
console.log("Transpiling entry file...");
|
|
187619
188566
|
const entryFile = mainEntrypoint || circuitFiles[0];
|