@tscircuit/cli 0.1.220 → 0.1.221
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/README.md +1 -0
- package/dist/main.js +1030 -277
- package/package.json +3 -2
package/dist/main.js
CHANGED
|
@@ -63215,7 +63215,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
63215
63215
|
import { execSync as execSync2 } from "node:child_process";
|
|
63216
63216
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
63217
63217
|
// package.json
|
|
63218
|
-
var version = "0.1.
|
|
63218
|
+
var version = "0.1.220";
|
|
63219
63219
|
var package_default = {
|
|
63220
63220
|
name: "@tscircuit/cli",
|
|
63221
63221
|
version,
|
|
@@ -63271,7 +63271,8 @@ var package_default = {
|
|
|
63271
63271
|
tscircuit: "^0.0.650-libonly",
|
|
63272
63272
|
tsx: "^4.7.1",
|
|
63273
63273
|
"typed-ky": "^0.0.4",
|
|
63274
|
-
zod: "3"
|
|
63274
|
+
zod: "3",
|
|
63275
|
+
"circuit-json-to-spice": "^0.0.10"
|
|
63275
63276
|
},
|
|
63276
63277
|
peerDependencies: {
|
|
63277
63278
|
tscircuit: "*"
|
|
@@ -71588,12 +71589,680 @@ var exportSnippet = async ({
|
|
|
71588
71589
|
});
|
|
71589
71590
|
};
|
|
71590
71591
|
|
|
71592
|
+
// node_modules/circuit-json-to-spice/dist/index.js
|
|
71593
|
+
import { getSourcePortConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
|
|
71594
|
+
var convertSpiceNetlistToString = (netlist) => {
|
|
71595
|
+
const lines = [];
|
|
71596
|
+
lines.push(netlist.title);
|
|
71597
|
+
if (netlist.models.size > 0) {
|
|
71598
|
+
lines.push(...Array.from(netlist.models.values()));
|
|
71599
|
+
}
|
|
71600
|
+
for (const component of netlist.components) {
|
|
71601
|
+
lines.push(component.toSpiceString());
|
|
71602
|
+
}
|
|
71603
|
+
for (const subcircuit of netlist.subcircuits) {
|
|
71604
|
+
lines.push(subcircuit.toSpiceString());
|
|
71605
|
+
}
|
|
71606
|
+
if (netlist.controls.length > 0) {
|
|
71607
|
+
lines.push(".control");
|
|
71608
|
+
lines.push(...netlist.controls);
|
|
71609
|
+
lines.push(".endc");
|
|
71610
|
+
}
|
|
71611
|
+
lines.push(".END");
|
|
71612
|
+
return lines.join(`
|
|
71613
|
+
`);
|
|
71614
|
+
};
|
|
71615
|
+
var SpiceNetlist = class {
|
|
71616
|
+
title;
|
|
71617
|
+
components;
|
|
71618
|
+
nodes;
|
|
71619
|
+
controls;
|
|
71620
|
+
subcircuits;
|
|
71621
|
+
models;
|
|
71622
|
+
constructor(title = "Circuit Netlist") {
|
|
71623
|
+
this.title = title;
|
|
71624
|
+
this.components = [];
|
|
71625
|
+
this.nodes = /* @__PURE__ */ new Set;
|
|
71626
|
+
this.controls = [];
|
|
71627
|
+
this.subcircuits = [];
|
|
71628
|
+
this.models = /* @__PURE__ */ new Map;
|
|
71629
|
+
}
|
|
71630
|
+
addComponent(component) {
|
|
71631
|
+
this.components.push(component);
|
|
71632
|
+
for (const node of component.nodes) {
|
|
71633
|
+
this.nodes.add(node);
|
|
71634
|
+
}
|
|
71635
|
+
}
|
|
71636
|
+
addSubcircuit(subcircuit) {
|
|
71637
|
+
if (this.subcircuits.find((s) => s.name === subcircuit.name))
|
|
71638
|
+
return;
|
|
71639
|
+
this.subcircuits.push(subcircuit);
|
|
71640
|
+
}
|
|
71641
|
+
toSpiceString() {
|
|
71642
|
+
return convertSpiceNetlistToString(this);
|
|
71643
|
+
}
|
|
71644
|
+
};
|
|
71645
|
+
var SpiceComponent = class {
|
|
71646
|
+
name;
|
|
71647
|
+
command;
|
|
71648
|
+
nodes;
|
|
71649
|
+
constructor(name, command, nodes) {
|
|
71650
|
+
this.name = name;
|
|
71651
|
+
this.command = command;
|
|
71652
|
+
this.nodes = nodes;
|
|
71653
|
+
}
|
|
71654
|
+
toSpiceString() {
|
|
71655
|
+
return this.command.toSpiceString();
|
|
71656
|
+
}
|
|
71657
|
+
};
|
|
71658
|
+
var ResistorCommand = class {
|
|
71659
|
+
commandName = "resistor";
|
|
71660
|
+
props;
|
|
71661
|
+
constructor(props) {
|
|
71662
|
+
this.props = props;
|
|
71663
|
+
}
|
|
71664
|
+
toSpiceString() {
|
|
71665
|
+
const { name, positiveNode, negativeNode, model, value } = this.props;
|
|
71666
|
+
let spiceString = `R${name} ${positiveNode} ${negativeNode}`;
|
|
71667
|
+
if (model) {
|
|
71668
|
+
spiceString += ` ${model}`;
|
|
71669
|
+
}
|
|
71670
|
+
spiceString += ` ${value}`;
|
|
71671
|
+
return spiceString;
|
|
71672
|
+
}
|
|
71673
|
+
};
|
|
71674
|
+
var CapacitorCommand = class {
|
|
71675
|
+
commandName = "capacitor";
|
|
71676
|
+
props;
|
|
71677
|
+
constructor(props) {
|
|
71678
|
+
this.props = props;
|
|
71679
|
+
}
|
|
71680
|
+
toSpiceString() {
|
|
71681
|
+
const {
|
|
71682
|
+
name,
|
|
71683
|
+
positiveNode,
|
|
71684
|
+
negativeNode,
|
|
71685
|
+
modelName,
|
|
71686
|
+
value,
|
|
71687
|
+
initialCondition
|
|
71688
|
+
} = this.props;
|
|
71689
|
+
let spiceString = `C${name} ${positiveNode} ${negativeNode}`;
|
|
71690
|
+
if (modelName) {
|
|
71691
|
+
spiceString += ` ${modelName}`;
|
|
71692
|
+
}
|
|
71693
|
+
spiceString += ` ${value}`;
|
|
71694
|
+
if (initialCondition) {
|
|
71695
|
+
spiceString += ` IC=${initialCondition}`;
|
|
71696
|
+
}
|
|
71697
|
+
return spiceString;
|
|
71698
|
+
}
|
|
71699
|
+
};
|
|
71700
|
+
var VoltageSourceCommand = class {
|
|
71701
|
+
commandName = "voltage_source";
|
|
71702
|
+
props;
|
|
71703
|
+
constructor(props) {
|
|
71704
|
+
this.props = props;
|
|
71705
|
+
}
|
|
71706
|
+
toSpiceString() {
|
|
71707
|
+
const { name, positiveNode, negativeNode, value, acMagnitude, acPhase } = this.props;
|
|
71708
|
+
let spiceString = `V${name} ${positiveNode} ${negativeNode}`;
|
|
71709
|
+
if (value) {
|
|
71710
|
+
spiceString += ` ${value}`;
|
|
71711
|
+
}
|
|
71712
|
+
if (acMagnitude) {
|
|
71713
|
+
spiceString += ` AC ${acMagnitude}`;
|
|
71714
|
+
if (acPhase) {
|
|
71715
|
+
spiceString += ` ${acPhase}`;
|
|
71716
|
+
}
|
|
71717
|
+
}
|
|
71718
|
+
return spiceString;
|
|
71719
|
+
}
|
|
71720
|
+
};
|
|
71721
|
+
var DiodeCommand = class {
|
|
71722
|
+
commandName = "diode";
|
|
71723
|
+
props;
|
|
71724
|
+
constructor(props) {
|
|
71725
|
+
this.props = props;
|
|
71726
|
+
}
|
|
71727
|
+
toSpiceString() {
|
|
71728
|
+
const { name, positiveNode, negativeNode, model, area } = this.props;
|
|
71729
|
+
let spiceString = `D${name} ${positiveNode} ${negativeNode} ${model}`;
|
|
71730
|
+
if (area) {
|
|
71731
|
+
spiceString += ` ${area}`;
|
|
71732
|
+
}
|
|
71733
|
+
return spiceString;
|
|
71734
|
+
}
|
|
71735
|
+
};
|
|
71736
|
+
var InductorCommand = class {
|
|
71737
|
+
commandName = "inductor";
|
|
71738
|
+
props;
|
|
71739
|
+
constructor(props) {
|
|
71740
|
+
this.props = props;
|
|
71741
|
+
}
|
|
71742
|
+
toSpiceString() {
|
|
71743
|
+
const { name, positiveNode, negativeNode, model, value, initialCondition } = this.props;
|
|
71744
|
+
let spiceString = `L${name} ${positiveNode} ${negativeNode}`;
|
|
71745
|
+
if (model) {
|
|
71746
|
+
spiceString += ` ${model}`;
|
|
71747
|
+
}
|
|
71748
|
+
spiceString += ` ${value}`;
|
|
71749
|
+
if (initialCondition) {
|
|
71750
|
+
spiceString += ` IC=${initialCondition}`;
|
|
71751
|
+
}
|
|
71752
|
+
return spiceString;
|
|
71753
|
+
}
|
|
71754
|
+
};
|
|
71755
|
+
var VoltageControlledSwitchCommand = class {
|
|
71756
|
+
commandName = "voltage_controlled_switch";
|
|
71757
|
+
props;
|
|
71758
|
+
constructor(props) {
|
|
71759
|
+
this.props = props;
|
|
71760
|
+
}
|
|
71761
|
+
toSpiceString() {
|
|
71762
|
+
const {
|
|
71763
|
+
name,
|
|
71764
|
+
positiveNode,
|
|
71765
|
+
negativeNode,
|
|
71766
|
+
positiveControl,
|
|
71767
|
+
negativeControl,
|
|
71768
|
+
model
|
|
71769
|
+
} = this.props;
|
|
71770
|
+
return `S${name} ${positiveNode} ${negativeNode} ${positiveControl} ${negativeControl} ${model}`;
|
|
71771
|
+
}
|
|
71772
|
+
};
|
|
71773
|
+
function circuitJsonToSpice(circuitJson) {
|
|
71774
|
+
const netlist = new SpiceNetlist("* Circuit JSON to SPICE Netlist");
|
|
71775
|
+
const sourceComponents = su_default(circuitJson).source_component.list();
|
|
71776
|
+
const sourcePorts = su_default(circuitJson).source_port.list();
|
|
71777
|
+
const connMap = getSourcePortConnectivityMapFromCircuitJson(circuitJson);
|
|
71778
|
+
const nodeMap = /* @__PURE__ */ new Map;
|
|
71779
|
+
const netToNodeName = /* @__PURE__ */ new Map;
|
|
71780
|
+
let nodeCounter = 1;
|
|
71781
|
+
const groundNets = /* @__PURE__ */ new Set;
|
|
71782
|
+
const gndSourceNetIds = new Set(su_default(circuitJson).source_net.list().filter((sn) => sn.name?.toLowerCase().includes("gnd")).map((sn) => sn.source_net_id));
|
|
71783
|
+
if (gndSourceNetIds.size > 0) {
|
|
71784
|
+
for (const trace of su_default(circuitJson).source_trace.list()) {
|
|
71785
|
+
if (trace.connected_source_port_ids.length > 0) {
|
|
71786
|
+
const isOnGndNet = trace.connected_source_net_ids.some((netId) => gndSourceNetIds.has(netId));
|
|
71787
|
+
if (isOnGndNet) {
|
|
71788
|
+
const aPortOnGnd = trace.connected_source_port_ids[0];
|
|
71789
|
+
const gndNet = connMap.getNetConnectedToId(aPortOnGnd);
|
|
71790
|
+
if (gndNet) {
|
|
71791
|
+
groundNets.add(gndNet);
|
|
71792
|
+
}
|
|
71793
|
+
}
|
|
71794
|
+
}
|
|
71795
|
+
}
|
|
71796
|
+
}
|
|
71797
|
+
const groundPorts = sourcePorts.filter((p) => p.name?.toLowerCase() === "gnd");
|
|
71798
|
+
for (const groundPort of groundPorts) {
|
|
71799
|
+
const groundNet = connMap.getNetConnectedToId(groundPort.source_port_id);
|
|
71800
|
+
if (groundNet) {
|
|
71801
|
+
groundNets.add(groundNet);
|
|
71802
|
+
}
|
|
71803
|
+
}
|
|
71804
|
+
for (const simSource of su_default(circuitJson).simulation_voltage_source.list()) {
|
|
71805
|
+
const neg_port_id = simSource.negative_source_port_id ?? simSource.terminal2_source_port_id;
|
|
71806
|
+
if (neg_port_id) {
|
|
71807
|
+
const gnd_net = connMap.getNetConnectedToId(neg_port_id);
|
|
71808
|
+
if (gnd_net) {
|
|
71809
|
+
groundNets.add(gnd_net);
|
|
71810
|
+
}
|
|
71811
|
+
}
|
|
71812
|
+
}
|
|
71813
|
+
for (const groundNet of groundNets) {
|
|
71814
|
+
netToNodeName.set(groundNet, "0");
|
|
71815
|
+
}
|
|
71816
|
+
for (const port of sourcePorts) {
|
|
71817
|
+
const portId = port.source_port_id;
|
|
71818
|
+
const net2 = connMap.getNetConnectedToId(portId);
|
|
71819
|
+
if (net2) {
|
|
71820
|
+
if (!netToNodeName.has(net2)) {
|
|
71821
|
+
netToNodeName.set(net2, `N${nodeCounter++}`);
|
|
71822
|
+
}
|
|
71823
|
+
nodeMap.set(portId, netToNodeName.get(net2));
|
|
71824
|
+
}
|
|
71825
|
+
}
|
|
71826
|
+
for (const port of sourcePorts) {
|
|
71827
|
+
const portId = port.source_port_id;
|
|
71828
|
+
if (!nodeMap.has(portId)) {
|
|
71829
|
+
nodeMap.set(portId, `N${nodeCounter++}`);
|
|
71830
|
+
}
|
|
71831
|
+
}
|
|
71832
|
+
for (const component of sourceComponents) {
|
|
71833
|
+
if (component.type !== "source_component")
|
|
71834
|
+
continue;
|
|
71835
|
+
const componentPorts = su_default(circuitJson).source_port.list({
|
|
71836
|
+
source_component_id: component.source_component_id
|
|
71837
|
+
}).sort((a, b) => (a.pin_number ?? 0) - (b.pin_number ?? 0));
|
|
71838
|
+
const nodes = componentPorts.map((port) => {
|
|
71839
|
+
return nodeMap.get(port.source_port_id) || "0";
|
|
71840
|
+
});
|
|
71841
|
+
if ("ftype" in component) {
|
|
71842
|
+
let spiceComponent = null;
|
|
71843
|
+
switch (component.ftype) {
|
|
71844
|
+
case "simple_resistor": {
|
|
71845
|
+
if ("resistance" in component && "name" in component) {
|
|
71846
|
+
const resistorCmd = new ResistorCommand({
|
|
71847
|
+
name: component.name,
|
|
71848
|
+
positiveNode: nodes[0] || "0",
|
|
71849
|
+
negativeNode: nodes[1] || "0",
|
|
71850
|
+
value: formatResistance(component.resistance)
|
|
71851
|
+
});
|
|
71852
|
+
spiceComponent = new SpiceComponent(component.name, resistorCmd, nodes);
|
|
71853
|
+
}
|
|
71854
|
+
break;
|
|
71855
|
+
}
|
|
71856
|
+
case "simple_capacitor": {
|
|
71857
|
+
if ("capacitance" in component && "name" in component) {
|
|
71858
|
+
const capacitorCmd = new CapacitorCommand({
|
|
71859
|
+
name: component.name,
|
|
71860
|
+
positiveNode: nodes[0] || "0",
|
|
71861
|
+
negativeNode: nodes[1] || "0",
|
|
71862
|
+
value: formatCapacitance(component.capacitance)
|
|
71863
|
+
});
|
|
71864
|
+
spiceComponent = new SpiceComponent(component.name, capacitorCmd, nodes);
|
|
71865
|
+
}
|
|
71866
|
+
break;
|
|
71867
|
+
}
|
|
71868
|
+
case "simple_diode": {
|
|
71869
|
+
if ("name" in component) {
|
|
71870
|
+
const anodePort = componentPorts.find((p) => p.name?.toLowerCase() === "anode" || p.port_hints?.includes("anode"));
|
|
71871
|
+
const cathodePort = componentPorts.find((p) => p.name?.toLowerCase() === "cathode" || p.port_hints?.includes("cathode"));
|
|
71872
|
+
const positiveNode = nodeMap.get(anodePort?.source_port_id ?? "") || "0";
|
|
71873
|
+
const negativeNode = nodeMap.get(cathodePort?.source_port_id ?? "") || "0";
|
|
71874
|
+
const modelName = "D";
|
|
71875
|
+
const diodeCmd = new DiodeCommand({
|
|
71876
|
+
name: component.name,
|
|
71877
|
+
positiveNode,
|
|
71878
|
+
negativeNode,
|
|
71879
|
+
model: modelName
|
|
71880
|
+
});
|
|
71881
|
+
netlist.models.set(modelName, `.MODEL ${modelName} D`);
|
|
71882
|
+
spiceComponent = new SpiceComponent(component.name, diodeCmd, [
|
|
71883
|
+
positiveNode,
|
|
71884
|
+
negativeNode
|
|
71885
|
+
]);
|
|
71886
|
+
}
|
|
71887
|
+
break;
|
|
71888
|
+
}
|
|
71889
|
+
case "simple_inductor": {
|
|
71890
|
+
if ("inductance" in component && "name" in component) {
|
|
71891
|
+
const inductorCmd = new InductorCommand({
|
|
71892
|
+
name: component.name,
|
|
71893
|
+
positiveNode: nodes[0] || "0",
|
|
71894
|
+
negativeNode: nodes[1] || "0",
|
|
71895
|
+
value: formatInductance(component.inductance)
|
|
71896
|
+
});
|
|
71897
|
+
spiceComponent = new SpiceComponent(component.name, inductorCmd, nodes);
|
|
71898
|
+
}
|
|
71899
|
+
break;
|
|
71900
|
+
}
|
|
71901
|
+
case "simple_mosfet": {
|
|
71902
|
+
if ("name" in component) {
|
|
71903
|
+
const drainPort = componentPorts.find((p) => p.name?.toLowerCase() === "drain" || p.port_hints?.includes("drain"));
|
|
71904
|
+
const gatePort = componentPorts.find((p) => p.name?.toLowerCase() === "gate" || p.port_hints?.includes("gate"));
|
|
71905
|
+
const sourcePort = componentPorts.find((p) => p.name?.toLowerCase() === "source" || p.port_hints?.includes("source"));
|
|
71906
|
+
const drainNode = nodeMap.get(drainPort?.source_port_id ?? "") || "0";
|
|
71907
|
+
const gateNode = nodeMap.get(gatePort?.source_port_id ?? "") || "0";
|
|
71908
|
+
const sourceNode = nodeMap.get(sourcePort?.source_port_id ?? "") || "0";
|
|
71909
|
+
const modelName = "SWMOD";
|
|
71910
|
+
const switchCmd = new VoltageControlledSwitchCommand({
|
|
71911
|
+
name: component.name,
|
|
71912
|
+
positiveNode: drainNode,
|
|
71913
|
+
negativeNode: sourceNode,
|
|
71914
|
+
positiveControl: gateNode,
|
|
71915
|
+
negativeControl: sourceNode,
|
|
71916
|
+
model: modelName
|
|
71917
|
+
});
|
|
71918
|
+
netlist.models.set(modelName, `.MODEL ${modelName} SW`);
|
|
71919
|
+
spiceComponent = new SpiceComponent(component.name, switchCmd, [
|
|
71920
|
+
drainNode,
|
|
71921
|
+
gateNode,
|
|
71922
|
+
sourceNode
|
|
71923
|
+
]);
|
|
71924
|
+
}
|
|
71925
|
+
break;
|
|
71926
|
+
}
|
|
71927
|
+
}
|
|
71928
|
+
if (spiceComponent) {
|
|
71929
|
+
netlist.addComponent(spiceComponent);
|
|
71930
|
+
}
|
|
71931
|
+
}
|
|
71932
|
+
}
|
|
71933
|
+
const simulationVoltageSources = su_default(circuitJson).simulation_voltage_source.list();
|
|
71934
|
+
for (const simSource of simulationVoltageSources) {
|
|
71935
|
+
if (simSource.type !== "simulation_voltage_source")
|
|
71936
|
+
continue;
|
|
71937
|
+
if (simSource.is_dc_source === false) {
|
|
71938
|
+
if ("terminal1_source_port_id" in simSource && "terminal2_source_port_id" in simSource && simSource.terminal1_source_port_id && simSource.terminal2_source_port_id) {
|
|
71939
|
+
const positiveNode = nodeMap.get(simSource.terminal1_source_port_id) || "0";
|
|
71940
|
+
const negativeNode = nodeMap.get(simSource.terminal2_source_port_id) || "0";
|
|
71941
|
+
let value = "";
|
|
71942
|
+
const wave_shape = simSource.wave_shape;
|
|
71943
|
+
if (wave_shape === "sinewave") {
|
|
71944
|
+
const v_offset = 0;
|
|
71945
|
+
const v_peak = simSource.voltage ?? 0;
|
|
71946
|
+
const freq = simSource.frequency ?? 0;
|
|
71947
|
+
const delay3 = 0;
|
|
71948
|
+
const damping_factor = 0;
|
|
71949
|
+
const phase = simSource.phase ?? 0;
|
|
71950
|
+
if (freq > 0) {
|
|
71951
|
+
value = `SIN(${v_offset} ${v_peak} ${freq} ${delay3} ${damping_factor} ${phase})`;
|
|
71952
|
+
} else {
|
|
71953
|
+
value = `DC ${simSource.voltage ?? 0}`;
|
|
71954
|
+
}
|
|
71955
|
+
} else if (wave_shape === "square") {
|
|
71956
|
+
const v_initial = 0;
|
|
71957
|
+
const v_pulsed = simSource.voltage ?? 0;
|
|
71958
|
+
const freq = simSource.frequency ?? 0;
|
|
71959
|
+
const period_from_freq = freq === 0 ? Infinity : 1 / freq;
|
|
71960
|
+
const period = simSource.period ?? period_from_freq;
|
|
71961
|
+
const duty_cycle = simSource.duty_cycle ?? 0.5;
|
|
71962
|
+
const pulse_width = period * duty_cycle;
|
|
71963
|
+
const delay3 = 0;
|
|
71964
|
+
const rise_time = "1n";
|
|
71965
|
+
const fall_time = "1n";
|
|
71966
|
+
value = `PULSE(${v_initial} ${v_pulsed} ${delay3} ${rise_time} ${fall_time} ${pulse_width} ${period})`;
|
|
71967
|
+
} else if (simSource.voltage !== undefined) {
|
|
71968
|
+
value = `DC ${simSource.voltage}`;
|
|
71969
|
+
}
|
|
71970
|
+
if (value) {
|
|
71971
|
+
const voltageSourceCmd = new VoltageSourceCommand({
|
|
71972
|
+
name: simSource.simulation_voltage_source_id,
|
|
71973
|
+
positiveNode,
|
|
71974
|
+
negativeNode,
|
|
71975
|
+
value
|
|
71976
|
+
});
|
|
71977
|
+
const spiceComponent = new SpiceComponent(simSource.simulation_voltage_source_id, voltageSourceCmd, [positiveNode, negativeNode]);
|
|
71978
|
+
netlist.addComponent(spiceComponent);
|
|
71979
|
+
}
|
|
71980
|
+
}
|
|
71981
|
+
} else {
|
|
71982
|
+
const positivePortId = simSource.positive_source_port_id ?? simSource.terminal1_source_port_id;
|
|
71983
|
+
const negativePortId = simSource.negative_source_port_id ?? simSource.terminal2_source_port_id;
|
|
71984
|
+
if (positivePortId && negativePortId && "voltage" in simSource && simSource.voltage !== undefined) {
|
|
71985
|
+
const positiveNode = nodeMap.get(positivePortId) || "0";
|
|
71986
|
+
const negativeNode = nodeMap.get(negativePortId) || "0";
|
|
71987
|
+
const voltageSourceCmd = new VoltageSourceCommand({
|
|
71988
|
+
name: simSource.simulation_voltage_source_id,
|
|
71989
|
+
positiveNode,
|
|
71990
|
+
negativeNode,
|
|
71991
|
+
value: `DC ${simSource.voltage}`
|
|
71992
|
+
});
|
|
71993
|
+
const spiceComponent = new SpiceComponent(simSource.simulation_voltage_source_id, voltageSourceCmd, [positiveNode, negativeNode]);
|
|
71994
|
+
netlist.addComponent(spiceComponent);
|
|
71995
|
+
}
|
|
71996
|
+
}
|
|
71997
|
+
}
|
|
71998
|
+
return netlist;
|
|
71999
|
+
}
|
|
72000
|
+
function formatResistance(resistance) {
|
|
72001
|
+
if (resistance >= 1e6)
|
|
72002
|
+
return `${resistance / 1e6}MEG`;
|
|
72003
|
+
if (resistance >= 1000)
|
|
72004
|
+
return `${resistance / 1000}K`;
|
|
72005
|
+
return resistance.toString();
|
|
72006
|
+
}
|
|
72007
|
+
function formatCapacitance(capacitance) {
|
|
72008
|
+
if (capacitance >= 0.001)
|
|
72009
|
+
return `${capacitance * 1000}M`;
|
|
72010
|
+
if (capacitance >= 0.000001)
|
|
72011
|
+
return `${capacitance * 1e6}U`;
|
|
72012
|
+
if (capacitance >= 0.000000001)
|
|
72013
|
+
return `${capacitance * 1e9}N`;
|
|
72014
|
+
if (capacitance >= 0.000000000001)
|
|
72015
|
+
return `${capacitance * 1000000000000}P`;
|
|
72016
|
+
return capacitance.toString();
|
|
72017
|
+
}
|
|
72018
|
+
function formatInductance(inductance) {
|
|
72019
|
+
if (inductance >= 1)
|
|
72020
|
+
return inductance.toString();
|
|
72021
|
+
if (inductance >= 0.001)
|
|
72022
|
+
return `${inductance * 1000}m`;
|
|
72023
|
+
if (inductance >= 0.000001)
|
|
72024
|
+
return `${inductance * 1e6}u`;
|
|
72025
|
+
if (inductance >= 0.000000001)
|
|
72026
|
+
return `${inductance * 1e9}n`;
|
|
72027
|
+
if (inductance >= 0.000000000001)
|
|
72028
|
+
return `${inductance * 1000000000000}p`;
|
|
72029
|
+
return inductance.toString();
|
|
72030
|
+
}
|
|
72031
|
+
|
|
72032
|
+
// lib/shared/get-spice-with-sim.ts
|
|
72033
|
+
var formatSimTime = (seconds) => {
|
|
72034
|
+
if (seconds === 0)
|
|
72035
|
+
return "0";
|
|
72036
|
+
const absSeconds = Math.abs(seconds);
|
|
72037
|
+
const precision = (v) => v.toPrecision(4);
|
|
72038
|
+
if (absSeconds >= 1)
|
|
72039
|
+
return precision(seconds);
|
|
72040
|
+
if (absSeconds >= 0.001)
|
|
72041
|
+
return `${precision(seconds * 1000)}m`;
|
|
72042
|
+
if (absSeconds >= 0.000001)
|
|
72043
|
+
return `${precision(seconds * 1e6)}u`;
|
|
72044
|
+
if (absSeconds >= 0.000000001)
|
|
72045
|
+
return `${precision(seconds * 1e9)}n`;
|
|
72046
|
+
if (absSeconds >= 0.000000000001)
|
|
72047
|
+
return `${precision(seconds * 1000000000000)}p`;
|
|
72048
|
+
if (absSeconds >= 0.000000000000001)
|
|
72049
|
+
return `${precision(seconds * 1000000000000000)}f`;
|
|
72050
|
+
return seconds.toExponential(3);
|
|
72051
|
+
};
|
|
72052
|
+
var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
72053
|
+
const spiceNetlist = circuitJsonToSpice(circuitJson);
|
|
72054
|
+
const baseSpiceString = spiceNetlist.toSpiceString();
|
|
72055
|
+
const hasAnalysis = /\.tran|\.ac|\.dc|\.op/i.test(baseSpiceString);
|
|
72056
|
+
const hasOutput = /\.probe|\.plot|wrdata/i.test(baseSpiceString);
|
|
72057
|
+
const lines = baseSpiceString.split(`
|
|
72058
|
+
`).filter((l) => l.trim() !== "");
|
|
72059
|
+
const componentLines = lines.filter((l) => !l.startsWith("*") && !l.startsWith(".") && l.trim() !== "");
|
|
72060
|
+
const allNodes = new Set;
|
|
72061
|
+
const capacitorNodes = new Set;
|
|
72062
|
+
const componentNamesToProbeCurrent = new Set;
|
|
72063
|
+
for (const line of componentLines) {
|
|
72064
|
+
const parts = line.trim().split(/\s+/);
|
|
72065
|
+
if (parts.length < 3)
|
|
72066
|
+
continue;
|
|
72067
|
+
const componentName = parts[0];
|
|
72068
|
+
const componentType = componentName[0].toUpperCase();
|
|
72069
|
+
let nodesOnLine = [];
|
|
72070
|
+
if (["R", "C", "L", "V", "I", "D"].includes(componentType)) {
|
|
72071
|
+
nodesOnLine = parts.slice(1, 3);
|
|
72072
|
+
if (componentType === "V") {
|
|
72073
|
+
componentNamesToProbeCurrent.add(componentName);
|
|
72074
|
+
}
|
|
72075
|
+
} else if (componentType === "Q" && parts.length >= 4) {
|
|
72076
|
+
nodesOnLine = parts.slice(1, 4);
|
|
72077
|
+
} else if (componentType === "M" && parts.length >= 5) {
|
|
72078
|
+
nodesOnLine = parts.slice(1, 5);
|
|
72079
|
+
} else if (componentType === "X") {
|
|
72080
|
+
nodesOnLine = parts.slice(1, -1);
|
|
72081
|
+
} else {
|
|
72082
|
+
continue;
|
|
72083
|
+
}
|
|
72084
|
+
nodesOnLine.forEach((node) => allNodes.add(node));
|
|
72085
|
+
if (componentType === "C") {
|
|
72086
|
+
nodesOnLine.forEach((node) => capacitorNodes.add(node));
|
|
72087
|
+
}
|
|
72088
|
+
}
|
|
72089
|
+
allNodes.delete("0");
|
|
72090
|
+
capacitorNodes.delete("0");
|
|
72091
|
+
const icLines = Array.from(capacitorNodes).map((node) => `.ic V(${node})=0`);
|
|
72092
|
+
let probeLine = "";
|
|
72093
|
+
if (!hasOutput) {
|
|
72094
|
+
const probes = [];
|
|
72095
|
+
const probeVoltages = Array.from(allNodes).map((node) => `V(${node})`);
|
|
72096
|
+
probes.push(...probeVoltages);
|
|
72097
|
+
const probeCurrents = Array.from(componentNamesToProbeCurrent).map((name) => `I(${name})`);
|
|
72098
|
+
probes.push(...probeCurrents);
|
|
72099
|
+
probeLine = probes.length > 0 ? `.probe ${probes.join(" ")}` : "";
|
|
72100
|
+
}
|
|
72101
|
+
let tranLine = "";
|
|
72102
|
+
if (!hasAnalysis) {
|
|
72103
|
+
const tstart_ms = options?.startTime ?? 0;
|
|
72104
|
+
const duration_ms = options?.duration ?? 20;
|
|
72105
|
+
const tstart = tstart_ms * 0.001;
|
|
72106
|
+
const duration = duration_ms * 0.001;
|
|
72107
|
+
const tstop = tstart + duration;
|
|
72108
|
+
const tstep = duration / 50;
|
|
72109
|
+
tranLine = `.tran ${formatSimTime(tstep)} ${formatSimTime(tstop)} ${formatSimTime(tstart)} UIC`;
|
|
72110
|
+
}
|
|
72111
|
+
const endStatement = ".end";
|
|
72112
|
+
const originalLines = baseSpiceString.split(`
|
|
72113
|
+
`);
|
|
72114
|
+
let endIndex = -1;
|
|
72115
|
+
for (let i = originalLines.length - 1;i >= 0; i--) {
|
|
72116
|
+
if (originalLines[i].trim().toLowerCase().startsWith(endStatement)) {
|
|
72117
|
+
endIndex = i;
|
|
72118
|
+
break;
|
|
72119
|
+
}
|
|
72120
|
+
}
|
|
72121
|
+
const injectionLines = [
|
|
72122
|
+
...icLines.length > 0 && !/\.ic/i.test(baseSpiceString) ? icLines : [],
|
|
72123
|
+
probeLine,
|
|
72124
|
+
tranLine
|
|
72125
|
+
].filter(Boolean);
|
|
72126
|
+
if (injectionLines.length === 0) {
|
|
72127
|
+
return baseSpiceString;
|
|
72128
|
+
}
|
|
72129
|
+
let finalLines;
|
|
72130
|
+
if (endIndex !== -1) {
|
|
72131
|
+
const beforeEnd = originalLines.slice(0, endIndex);
|
|
72132
|
+
const endLineAndAfter = originalLines.slice(endIndex);
|
|
72133
|
+
finalLines = [...beforeEnd, ...injectionLines, ...endLineAndAfter];
|
|
72134
|
+
} else {
|
|
72135
|
+
finalLines = [...originalLines, ...injectionLines, endStatement];
|
|
72136
|
+
}
|
|
72137
|
+
return finalLines.join(`
|
|
72138
|
+
`);
|
|
72139
|
+
};
|
|
72140
|
+
|
|
72141
|
+
// lib/eecircuit-engine/run-simulation.ts
|
|
72142
|
+
import { promises as fs23, existsSync as existsSync9 } from "node:fs";
|
|
72143
|
+
import path23 from "node:path";
|
|
72144
|
+
import os3 from "node:os";
|
|
72145
|
+
var sim = null;
|
|
72146
|
+
var fetchSimulation = async () => {
|
|
72147
|
+
const tempFilePath = path23.join(os3.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
72148
|
+
if (!existsSync9(tempFilePath)) {
|
|
72149
|
+
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
72150
|
+
const response = await fetch(url);
|
|
72151
|
+
if (!response.ok) {
|
|
72152
|
+
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
72153
|
+
}
|
|
72154
|
+
const scriptContent = await response.text();
|
|
72155
|
+
await fs23.writeFile(tempFilePath, scriptContent);
|
|
72156
|
+
}
|
|
72157
|
+
const module2 = await import(tempFilePath);
|
|
72158
|
+
return module2.Simulation;
|
|
72159
|
+
};
|
|
72160
|
+
var initializeSimulation = async () => {
|
|
72161
|
+
if (sim && sim.isInitialized())
|
|
72162
|
+
return;
|
|
72163
|
+
const Simulation = await fetchSimulation();
|
|
72164
|
+
sim = new Simulation;
|
|
72165
|
+
sim.start();
|
|
72166
|
+
const startTime = Date.now();
|
|
72167
|
+
const timeout2 = 15000;
|
|
72168
|
+
while (!sim.isInitialized()) {
|
|
72169
|
+
if (Date.now() - startTime > timeout2) {
|
|
72170
|
+
console.error("Error: Simulation engine initialization timed out.");
|
|
72171
|
+
const initInfo = sim.getInitInfo();
|
|
72172
|
+
if (initInfo) {
|
|
72173
|
+
console.error("Initialization Info:", initInfo);
|
|
72174
|
+
}
|
|
72175
|
+
const errors = sim.getError();
|
|
72176
|
+
if (errors && errors.length > 0) {
|
|
72177
|
+
console.error("Errors:", errors.join(`
|
|
72178
|
+
`));
|
|
72179
|
+
}
|
|
72180
|
+
throw new Error("Simulation engine initialization timed out.");
|
|
72181
|
+
}
|
|
72182
|
+
await new Promise((resolve10) => setTimeout(resolve10, 200));
|
|
72183
|
+
}
|
|
72184
|
+
};
|
|
72185
|
+
var runSimulation = async (spiceString) => {
|
|
72186
|
+
await initializeSimulation();
|
|
72187
|
+
if (!sim)
|
|
72188
|
+
throw new Error("Simulation not initialized");
|
|
72189
|
+
let engineSpiceString = spiceString;
|
|
72190
|
+
const wrdataMatch = engineSpiceString.match(/wrdata\s+(\S+)\s+(.*)/i);
|
|
72191
|
+
if (wrdataMatch) {
|
|
72192
|
+
const variables = wrdataMatch[2].trim().split(/\s+/);
|
|
72193
|
+
const probeLine = `.probe ${variables.join(" ")}`;
|
|
72194
|
+
engineSpiceString = engineSpiceString.replace(/wrdata.*/i, probeLine);
|
|
72195
|
+
} else if (!engineSpiceString.match(/\.probe/i)) {
|
|
72196
|
+
const plotMatch = engineSpiceString.match(/plot\s+(.*)/i);
|
|
72197
|
+
if (plotMatch) {
|
|
72198
|
+
throw new Error("The 'plot' command is not supported for data extraction. Please use 'wrdata <filename> <var1> ...' or '.probe <var1> ...' instead.");
|
|
72199
|
+
}
|
|
72200
|
+
throw new Error("No '.probe' or 'wrdata' command found in SPICE file. Use 'wrdata <filename> <var1> ...' to specify output.");
|
|
72201
|
+
}
|
|
72202
|
+
sim.setNetList(engineSpiceString);
|
|
72203
|
+
const result = await sim.runSim();
|
|
72204
|
+
return {
|
|
72205
|
+
result,
|
|
72206
|
+
info: sim.getInfo(),
|
|
72207
|
+
errors: sim.getError()
|
|
72208
|
+
};
|
|
72209
|
+
};
|
|
72210
|
+
|
|
72211
|
+
// lib/shared/result-to-csv.ts
|
|
72212
|
+
var resultToCsv = (result) => {
|
|
72213
|
+
const uniqueHeaders = [];
|
|
72214
|
+
const uniqueData = [];
|
|
72215
|
+
const seenHeaders = new Set;
|
|
72216
|
+
result.variableNames.forEach((header, index) => {
|
|
72217
|
+
if (!seenHeaders.has(header)) {
|
|
72218
|
+
seenHeaders.add(header);
|
|
72219
|
+
uniqueHeaders.push(header);
|
|
72220
|
+
uniqueData.push(result.data[index]);
|
|
72221
|
+
}
|
|
72222
|
+
});
|
|
72223
|
+
if (result.dataType === "real") {
|
|
72224
|
+
const headers2 = uniqueHeaders.join(",");
|
|
72225
|
+
const rows2 = [];
|
|
72226
|
+
for (let i = 0;i < result.numPoints; i++) {
|
|
72227
|
+
const row = uniqueData.map((d) => d.values[i]).join(",");
|
|
72228
|
+
rows2.push(row);
|
|
72229
|
+
}
|
|
72230
|
+
return [headers2, ...rows2].join(`
|
|
72231
|
+
`);
|
|
72232
|
+
}
|
|
72233
|
+
const headers = uniqueHeaders.flatMap((v) => [`${v}_real`, `${v}_img`]).join(",");
|
|
72234
|
+
const rows = [];
|
|
72235
|
+
for (let i = 0;i < result.numPoints; i++) {
|
|
72236
|
+
const row = uniqueData.flatMap((d) => [d.values[i].real, d.values[i].img]).join(",");
|
|
72237
|
+
rows.push(row);
|
|
72238
|
+
}
|
|
72239
|
+
return [headers, ...rows].join(`
|
|
72240
|
+
`);
|
|
72241
|
+
};
|
|
72242
|
+
|
|
71591
72243
|
// cli/export/register.ts
|
|
72244
|
+
import path24 from "node:path";
|
|
72245
|
+
import { promises as fs24 } from "node:fs";
|
|
71592
72246
|
var registerExport = (program3) => {
|
|
71593
72247
|
program3.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", "Output format").option("-o, --output <path>", "Output file path").action(async (file, options) => {
|
|
72248
|
+
const format = options.format ?? "json";
|
|
72249
|
+
if (format === "spice") {
|
|
72250
|
+
const { circuitJson } = await generateCircuitJson({ filePath: file });
|
|
72251
|
+
if (circuitJson) {
|
|
72252
|
+
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
72253
|
+
const outputSpicePath = options.output ?? path24.join(path24.dirname(file), `${path24.basename(file, path24.extname(file))}.spice.cir`);
|
|
72254
|
+
await fs24.writeFile(outputSpicePath, spiceString);
|
|
72255
|
+
const { result } = await runSimulation(spiceString);
|
|
72256
|
+
const csvContent = resultToCsv(result);
|
|
72257
|
+
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
72258
|
+
await fs24.writeFile(outputCsvPath, csvContent);
|
|
72259
|
+
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
72260
|
+
}
|
|
72261
|
+
return;
|
|
72262
|
+
}
|
|
71594
72263
|
await exportSnippet({
|
|
71595
72264
|
filePath: file,
|
|
71596
|
-
format
|
|
72265
|
+
format,
|
|
71597
72266
|
outputPath: options.output,
|
|
71598
72267
|
onExit: (code) => process.exit(code),
|
|
71599
72268
|
onError: (message) => console.error(message),
|
|
@@ -71774,14 +72443,14 @@ class KeyStore {
|
|
|
71774
72443
|
}
|
|
71775
72444
|
}
|
|
71776
72445
|
function createKey(key) {
|
|
71777
|
-
let
|
|
72446
|
+
let path25 = null;
|
|
71778
72447
|
let id = null;
|
|
71779
72448
|
let src = null;
|
|
71780
72449
|
let weight = 1;
|
|
71781
72450
|
let getFn = null;
|
|
71782
72451
|
if (isString2(key) || isArray(key)) {
|
|
71783
72452
|
src = key;
|
|
71784
|
-
|
|
72453
|
+
path25 = createKeyPath(key);
|
|
71785
72454
|
id = createKeyId(key);
|
|
71786
72455
|
} else {
|
|
71787
72456
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -71795,11 +72464,11 @@ function createKey(key) {
|
|
|
71795
72464
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
71796
72465
|
}
|
|
71797
72466
|
}
|
|
71798
|
-
|
|
72467
|
+
path25 = createKeyPath(name);
|
|
71799
72468
|
id = createKeyId(name);
|
|
71800
72469
|
getFn = key.getFn;
|
|
71801
72470
|
}
|
|
71802
|
-
return { path:
|
|
72471
|
+
return { path: path25, id, weight, src, getFn };
|
|
71803
72472
|
}
|
|
71804
72473
|
function createKeyPath(key) {
|
|
71805
72474
|
return isArray(key) ? key : key.split(".");
|
|
@@ -71807,34 +72476,34 @@ function createKeyPath(key) {
|
|
|
71807
72476
|
function createKeyId(key) {
|
|
71808
72477
|
return isArray(key) ? key.join(".") : key;
|
|
71809
72478
|
}
|
|
71810
|
-
function get(obj,
|
|
72479
|
+
function get(obj, path25) {
|
|
71811
72480
|
let list = [];
|
|
71812
72481
|
let arr = false;
|
|
71813
|
-
const deepGet = (obj2,
|
|
72482
|
+
const deepGet = (obj2, path26, index) => {
|
|
71814
72483
|
if (!isDefined(obj2)) {
|
|
71815
72484
|
return;
|
|
71816
72485
|
}
|
|
71817
|
-
if (!
|
|
72486
|
+
if (!path26[index]) {
|
|
71818
72487
|
list.push(obj2);
|
|
71819
72488
|
} else {
|
|
71820
|
-
let key =
|
|
72489
|
+
let key = path26[index];
|
|
71821
72490
|
const value = obj2[key];
|
|
71822
72491
|
if (!isDefined(value)) {
|
|
71823
72492
|
return;
|
|
71824
72493
|
}
|
|
71825
|
-
if (index ===
|
|
72494
|
+
if (index === path26.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
|
|
71826
72495
|
list.push(toString(value));
|
|
71827
72496
|
} else if (isArray(value)) {
|
|
71828
72497
|
arr = true;
|
|
71829
72498
|
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
71830
|
-
deepGet(value[i],
|
|
72499
|
+
deepGet(value[i], path26, index + 1);
|
|
71831
72500
|
}
|
|
71832
|
-
} else if (
|
|
71833
|
-
deepGet(value,
|
|
72501
|
+
} else if (path26.length) {
|
|
72502
|
+
deepGet(value, path26, index + 1);
|
|
71834
72503
|
}
|
|
71835
72504
|
}
|
|
71836
72505
|
};
|
|
71837
|
-
deepGet(obj, isString2(
|
|
72506
|
+
deepGet(obj, isString2(path25) ? path25.split(".") : path25, 0);
|
|
71838
72507
|
return arr ? list : list[0];
|
|
71839
72508
|
}
|
|
71840
72509
|
var MatchOptions = {
|
|
@@ -73026,8 +73695,8 @@ var registerSearch = (program3) => {
|
|
|
73026
73695
|
}
|
|
73027
73696
|
if (kicadResults.length) {
|
|
73028
73697
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
73029
|
-
kicadResults.forEach((
|
|
73030
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
73698
|
+
kicadResults.forEach((path25, idx) => {
|
|
73699
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path25.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
73031
73700
|
});
|
|
73032
73701
|
}
|
|
73033
73702
|
if (!onlyKicad && results.packages.length) {
|
|
@@ -78185,7 +78854,7 @@ var zo = rs.find((t2) => t2.text === "{REF}");
|
|
|
78185
78854
|
zo.y = 0;
|
|
78186
78855
|
zo.x = 0.35;
|
|
78187
78856
|
zo.anchor = "middle_left";
|
|
78188
|
-
var
|
|
78857
|
+
var os4 = es;
|
|
78189
78858
|
var is = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, path40: { type: "path", points: [{ x: 0.07, y: 0.19 }, { x: 0.07, y: -0.18 }], color: "primary", fill: false }, "path12-1": { type: "path", points: [{ x: 0.28, y: 0.53 }, { x: 0.28, y: 0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: -0.53 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path2: { type: "path", points: [{ x: 0.07, y: 0.11 }, { x: 0.29, y: 0.11 }], color: "primary", fill: false }, "path2-5": { type: "path", points: [{ x: 0.07, y: -0.1 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: -0.08, y: 0.06 }, { x: -0.08, y: -0.07 }, { x: 0.01, y: 0 }, { x: -0.08, y: 0.06 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.15, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: 0.04, y: -0.42 } }, refblocks: { top1: { x: 0.28, 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: { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
78190
78859
|
var { paths: ud, texts: ls, bounds: Ke, refblocks: Oo, circles: vd } = is;
|
|
78191
78860
|
var t0 = s({ primitives: [...Object.values(ud), ...Object.values(vd), { ...ls.top1, anchor: "middle_right", x: 0 }, { ...ls.bottom1, anchor: "middle_right", x: 0 }], ports: [{ ...Oo.top1, labels: ["1", "drain"] }, { ...Oo.bottom1, labels: ["2", "source"] }, { ...Oo.left1, labels: ["3", "gate"] }], size: { width: Ke.width, height: Ke.height }, center: { x: Ke.centerX, y: Ke.centerY } });
|
|
@@ -78205,7 +78874,7 @@ var { paths: Ad, bounds: ss, refblocks: Pd } = xs;
|
|
|
78205
78874
|
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();
|
|
78206
78875
|
var ms = r(U, "down");
|
|
78207
78876
|
var ns = r(U, "left");
|
|
78208
|
-
var
|
|
78877
|
+
var fs25 = r(U, "up");
|
|
78209
78878
|
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 } } };
|
|
78210
78879
|
var { paths: Fd, texts: XA, bounds: e0, refblocks: Mo, circles: Rd } = g;
|
|
78211
78880
|
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();
|
|
@@ -78774,7 +79443,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
|
|
|
78774
79443
|
sb.anchor = "middle_left";
|
|
78775
79444
|
mb.anchor = "middle_right";
|
|
78776
79445
|
var B1 = Cl;
|
|
78777
|
-
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: At, 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:
|
|
79446
|
+
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: At, 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: os4, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs25, 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 };
|
|
78778
79447
|
var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
|
|
78779
79448
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
78780
79449
|
lineThickness = 0
|
|
@@ -80804,11 +81473,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
80804
81473
|
fiber = fiber.next, id2--;
|
|
80805
81474
|
return fiber;
|
|
80806
81475
|
}
|
|
80807
|
-
function copyWithSetImpl(obj,
|
|
80808
|
-
if (index >=
|
|
81476
|
+
function copyWithSetImpl(obj, path25, index, value) {
|
|
81477
|
+
if (index >= path25.length)
|
|
80809
81478
|
return value;
|
|
80810
|
-
var key =
|
|
80811
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
81479
|
+
var key = path25[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
81480
|
+
updated[key] = copyWithSetImpl(obj[key], path25, index + 1, value);
|
|
80812
81481
|
return updated;
|
|
80813
81482
|
}
|
|
80814
81483
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -80828,11 +81497,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
80828
81497
|
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);
|
|
80829
81498
|
return updated;
|
|
80830
81499
|
}
|
|
80831
|
-
function copyWithDeleteImpl(obj,
|
|
80832
|
-
var key =
|
|
80833
|
-
if (index + 1 ===
|
|
81500
|
+
function copyWithDeleteImpl(obj, path25, index) {
|
|
81501
|
+
var key = path25[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
81502
|
+
if (index + 1 === path25.length)
|
|
80834
81503
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
80835
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
81504
|
+
updated[key] = copyWithDeleteImpl(obj[key], path25, index + 1);
|
|
80836
81505
|
return updated;
|
|
80837
81506
|
}
|
|
80838
81507
|
function shouldSuspendImpl() {
|
|
@@ -89863,29 +90532,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
89863
90532
|
var didWarnAboutNestedUpdates = false;
|
|
89864
90533
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
89865
90534
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
89866
|
-
overrideHookState = function(fiber, id2,
|
|
90535
|
+
overrideHookState = function(fiber, id2, path25, value) {
|
|
89867
90536
|
id2 = findHook(fiber, id2);
|
|
89868
|
-
id2 !== null && (
|
|
90537
|
+
id2 !== null && (path25 = copyWithSetImpl(id2.memoizedState, path25, 0, value), id2.memoizedState = path25, id2.baseState = path25, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path25 = enqueueConcurrentRenderForLane(fiber, 2), path25 !== null && scheduleUpdateOnFiber(path25, fiber, 2));
|
|
89869
90538
|
};
|
|
89870
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
90539
|
+
overrideHookStateDeletePath = function(fiber, id2, path25) {
|
|
89871
90540
|
id2 = findHook(fiber, id2);
|
|
89872
|
-
id2 !== null && (
|
|
90541
|
+
id2 !== null && (path25 = copyWithDeleteImpl(id2.memoizedState, path25, 0), id2.memoizedState = path25, id2.baseState = path25, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path25 = enqueueConcurrentRenderForLane(fiber, 2), path25 !== null && scheduleUpdateOnFiber(path25, fiber, 2));
|
|
89873
90542
|
};
|
|
89874
90543
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
89875
90544
|
id2 = findHook(fiber, id2);
|
|
89876
90545
|
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));
|
|
89877
90546
|
};
|
|
89878
|
-
overrideProps = function(fiber,
|
|
89879
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
90547
|
+
overrideProps = function(fiber, path25, value) {
|
|
90548
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path25, 0, value);
|
|
89880
90549
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
89881
|
-
|
|
89882
|
-
|
|
90550
|
+
path25 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
90551
|
+
path25 !== null && scheduleUpdateOnFiber(path25, fiber, 2);
|
|
89883
90552
|
};
|
|
89884
|
-
overridePropsDeletePath = function(fiber,
|
|
89885
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
90553
|
+
overridePropsDeletePath = function(fiber, path25) {
|
|
90554
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path25, 0);
|
|
89886
90555
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
89887
|
-
|
|
89888
|
-
|
|
90556
|
+
path25 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
90557
|
+
path25 !== null && scheduleUpdateOnFiber(path25, fiber, 2);
|
|
89889
90558
|
};
|
|
89890
90559
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
89891
90560
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -105222,10 +105891,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105222
105891
|
var setErrorHandler = null;
|
|
105223
105892
|
var setSuspenseHandler = null;
|
|
105224
105893
|
{
|
|
105225
|
-
var copyWithDeleteImpl = function(obj,
|
|
105226
|
-
var key =
|
|
105894
|
+
var copyWithDeleteImpl = function(obj, path25, index2) {
|
|
105895
|
+
var key = path25[index2];
|
|
105227
105896
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
105228
|
-
if (index2 + 1 ===
|
|
105897
|
+
if (index2 + 1 === path25.length) {
|
|
105229
105898
|
if (isArray2(updated)) {
|
|
105230
105899
|
updated.splice(key, 1);
|
|
105231
105900
|
} else {
|
|
@@ -105233,11 +105902,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105233
105902
|
}
|
|
105234
105903
|
return updated;
|
|
105235
105904
|
}
|
|
105236
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
105905
|
+
updated[key] = copyWithDeleteImpl(obj[key], path25, index2 + 1);
|
|
105237
105906
|
return updated;
|
|
105238
105907
|
};
|
|
105239
|
-
var copyWithDelete = function(obj,
|
|
105240
|
-
return copyWithDeleteImpl(obj,
|
|
105908
|
+
var copyWithDelete = function(obj, path25) {
|
|
105909
|
+
return copyWithDeleteImpl(obj, path25, 0);
|
|
105241
105910
|
};
|
|
105242
105911
|
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
|
105243
105912
|
var oldKey = oldPath[index2];
|
|
@@ -105269,17 +105938,17 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105269
105938
|
}
|
|
105270
105939
|
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
|
105271
105940
|
};
|
|
105272
|
-
var copyWithSetImpl = function(obj,
|
|
105273
|
-
if (index2 >=
|
|
105941
|
+
var copyWithSetImpl = function(obj, path25, index2, value) {
|
|
105942
|
+
if (index2 >= path25.length) {
|
|
105274
105943
|
return value;
|
|
105275
105944
|
}
|
|
105276
|
-
var key =
|
|
105945
|
+
var key = path25[index2];
|
|
105277
105946
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
105278
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
105947
|
+
updated[key] = copyWithSetImpl(obj[key], path25, index2 + 1, value);
|
|
105279
105948
|
return updated;
|
|
105280
105949
|
};
|
|
105281
|
-
var copyWithSet = function(obj,
|
|
105282
|
-
return copyWithSetImpl(obj,
|
|
105950
|
+
var copyWithSet = function(obj, path25, value) {
|
|
105951
|
+
return copyWithSetImpl(obj, path25, 0, value);
|
|
105283
105952
|
};
|
|
105284
105953
|
var findHook = function(fiber, id2) {
|
|
105285
105954
|
var currentHook2 = fiber.memoizedState;
|
|
@@ -105289,10 +105958,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105289
105958
|
}
|
|
105290
105959
|
return currentHook2;
|
|
105291
105960
|
};
|
|
105292
|
-
overrideHookState = function(fiber, id2,
|
|
105961
|
+
overrideHookState = function(fiber, id2, path25, value) {
|
|
105293
105962
|
var hook = findHook(fiber, id2);
|
|
105294
105963
|
if (hook !== null) {
|
|
105295
|
-
var newState = copyWithSet(hook.memoizedState,
|
|
105964
|
+
var newState = copyWithSet(hook.memoizedState, path25, value);
|
|
105296
105965
|
hook.memoizedState = newState;
|
|
105297
105966
|
hook.baseState = newState;
|
|
105298
105967
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -105302,10 +105971,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105302
105971
|
}
|
|
105303
105972
|
}
|
|
105304
105973
|
};
|
|
105305
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
105974
|
+
overrideHookStateDeletePath = function(fiber, id2, path25) {
|
|
105306
105975
|
var hook = findHook(fiber, id2);
|
|
105307
105976
|
if (hook !== null) {
|
|
105308
|
-
var newState = copyWithDelete(hook.memoizedState,
|
|
105977
|
+
var newState = copyWithDelete(hook.memoizedState, path25);
|
|
105309
105978
|
hook.memoizedState = newState;
|
|
105310
105979
|
hook.baseState = newState;
|
|
105311
105980
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -105328,8 +105997,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105328
105997
|
}
|
|
105329
105998
|
}
|
|
105330
105999
|
};
|
|
105331
|
-
overrideProps = function(fiber,
|
|
105332
|
-
fiber.pendingProps = copyWithSet(fiber.memoizedProps,
|
|
106000
|
+
overrideProps = function(fiber, path25, value) {
|
|
106001
|
+
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path25, value);
|
|
105333
106002
|
if (fiber.alternate) {
|
|
105334
106003
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
105335
106004
|
}
|
|
@@ -105338,8 +106007,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
105338
106007
|
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
|
105339
106008
|
}
|
|
105340
106009
|
};
|
|
105341
|
-
overridePropsDeletePath = function(fiber,
|
|
105342
|
-
fiber.pendingProps = copyWithDelete(fiber.memoizedProps,
|
|
106010
|
+
overridePropsDeletePath = function(fiber, path25) {
|
|
106011
|
+
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path25);
|
|
105343
106012
|
if (fiber.alternate) {
|
|
105344
106013
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
105345
106014
|
}
|
|
@@ -111390,7 +112059,7 @@ var parsePin = (pinString) => {
|
|
|
111390
112059
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
111391
112060
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
111392
112061
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
111393
|
-
const
|
|
112062
|
+
const path25 = pathMatch ? pathMatch[1] : "";
|
|
111394
112063
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
111395
112064
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
111396
112065
|
const r3 = Number.parseFloat(rotation2);
|
|
@@ -111404,7 +112073,7 @@ var parsePin = (pinString) => {
|
|
|
111404
112073
|
rotation: Number.isNaN(r3) ? 0 : r3,
|
|
111405
112074
|
label,
|
|
111406
112075
|
labelColor,
|
|
111407
|
-
path:
|
|
112076
|
+
path: path25,
|
|
111408
112077
|
arrow
|
|
111409
112078
|
};
|
|
111410
112079
|
};
|
|
@@ -111844,15 +112513,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
111844
112513
|
}
|
|
111845
112514
|
}
|
|
111846
112515
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
111847
|
-
const
|
|
112516
|
+
const path25 = [];
|
|
111848
112517
|
for (let i = 0;i <= numPoints; i++) {
|
|
111849
112518
|
const t3 = i / numPoints;
|
|
111850
112519
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
111851
112520
|
const x = centerX + radius * Math.cos(angle2);
|
|
111852
112521
|
const y = centerY + radius * Math.sin(angle2);
|
|
111853
|
-
|
|
112522
|
+
path25.push({ x, y });
|
|
111854
112523
|
}
|
|
111855
|
-
return
|
|
112524
|
+
return path25;
|
|
111856
112525
|
}
|
|
111857
112526
|
var __defProp4 = Object.defineProperty;
|
|
111858
112527
|
var __export22 = (target, all) => {
|
|
@@ -113270,7 +113939,7 @@ var platedHoleWithRectPad = (pn2, x, y, holeDiameter, rectPadWidth, rectPadHeigh
|
|
|
113270
113939
|
};
|
|
113271
113940
|
};
|
|
113272
113941
|
var silkscreenPin = ({
|
|
113273
|
-
fs:
|
|
113942
|
+
fs: fs26,
|
|
113274
113943
|
pn: pn2,
|
|
113275
113944
|
anchor_x,
|
|
113276
113945
|
anchor_y,
|
|
@@ -113313,7 +113982,7 @@ var silkscreenPin = ({
|
|
|
113313
113982
|
type: "pcb_silkscreen_text",
|
|
113314
113983
|
pcb_silkscreen_text_id: "silkscreen_text_1",
|
|
113315
113984
|
font: "tscircuit2024",
|
|
113316
|
-
font_size:
|
|
113985
|
+
font_size: fs26,
|
|
113317
113986
|
pcb_component_id: "pcb_component_1",
|
|
113318
113987
|
text: `{PIN${pn2}}`,
|
|
113319
113988
|
layer,
|
|
@@ -120929,17 +121598,17 @@ var ObstacleList = class {
|
|
|
120929
121598
|
return obstacles;
|
|
120930
121599
|
}
|
|
120931
121600
|
};
|
|
120932
|
-
function removePathLoops(
|
|
120933
|
-
if (
|
|
120934
|
-
return
|
|
120935
|
-
const result = [{ ...
|
|
120936
|
-
let currentLayer =
|
|
120937
|
-
for (let i = 1;i <
|
|
120938
|
-
const currentSegment = { start:
|
|
120939
|
-
const isVia =
|
|
120940
|
-
if (
|
|
120941
|
-
result.push({ ...
|
|
120942
|
-
currentLayer =
|
|
121601
|
+
function removePathLoops(path25) {
|
|
121602
|
+
if (path25.length < 4)
|
|
121603
|
+
return path25;
|
|
121604
|
+
const result = [{ ...path25[0] }];
|
|
121605
|
+
let currentLayer = path25[0].layer;
|
|
121606
|
+
for (let i = 1;i < path25.length; i++) {
|
|
121607
|
+
const currentSegment = { start: path25[i - 1], end: path25[i] };
|
|
121608
|
+
const isVia = path25[i].route_type === "via" || path25[i - 1].route_type === "via";
|
|
121609
|
+
if (path25[i].layer !== currentLayer || isVia) {
|
|
121610
|
+
result.push({ ...path25[i] });
|
|
121611
|
+
currentLayer = path25[i].layer;
|
|
120943
121612
|
continue;
|
|
120944
121613
|
}
|
|
120945
121614
|
let intersectionFound = false;
|
|
@@ -120968,8 +121637,8 @@ function removePathLoops(path23) {
|
|
|
120968
121637
|
result.push(intersectionPoint);
|
|
120969
121638
|
}
|
|
120970
121639
|
const lastPoint = result[result.length - 1];
|
|
120971
|
-
if (lastPoint.x !==
|
|
120972
|
-
result.push(
|
|
121640
|
+
if (lastPoint.x !== path25[i].x || lastPoint.y !== path25[i].y) {
|
|
121641
|
+
result.push(path25[i]);
|
|
120973
121642
|
}
|
|
120974
121643
|
}
|
|
120975
121644
|
return result;
|
|
@@ -121458,10 +122127,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
121458
122127
|
});
|
|
121459
122128
|
}
|
|
121460
122129
|
if (current2.parent) {
|
|
121461
|
-
const
|
|
122130
|
+
const path25 = [];
|
|
121462
122131
|
let p = current2;
|
|
121463
122132
|
while (p) {
|
|
121464
|
-
|
|
122133
|
+
path25.unshift(p);
|
|
121465
122134
|
p = p.parent;
|
|
121466
122135
|
}
|
|
121467
122136
|
debugSolution.push({
|
|
@@ -121469,7 +122138,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
121469
122138
|
pcb_component_id: "",
|
|
121470
122139
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
121471
122140
|
layer: "top",
|
|
121472
|
-
route:
|
|
122141
|
+
route: path25,
|
|
121473
122142
|
stroke_width: 0.01
|
|
121474
122143
|
});
|
|
121475
122144
|
}
|
|
@@ -126391,13 +127060,13 @@ var RBush = class {
|
|
|
126391
127060
|
return this;
|
|
126392
127061
|
let node = this.data;
|
|
126393
127062
|
const bbox = this.toBBox(item);
|
|
126394
|
-
const
|
|
127063
|
+
const path25 = [];
|
|
126395
127064
|
const indexes = [];
|
|
126396
127065
|
let i, parent, goingUp;
|
|
126397
|
-
while (node ||
|
|
127066
|
+
while (node || path25.length) {
|
|
126398
127067
|
if (!node) {
|
|
126399
|
-
node =
|
|
126400
|
-
parent =
|
|
127068
|
+
node = path25.pop();
|
|
127069
|
+
parent = path25[path25.length - 1];
|
|
126401
127070
|
i = indexes.pop();
|
|
126402
127071
|
goingUp = true;
|
|
126403
127072
|
}
|
|
@@ -126405,13 +127074,13 @@ var RBush = class {
|
|
|
126405
127074
|
const index = findItem(item, node.children, equalsFn);
|
|
126406
127075
|
if (index !== -1) {
|
|
126407
127076
|
node.children.splice(index, 1);
|
|
126408
|
-
|
|
126409
|
-
this._condense(
|
|
127077
|
+
path25.push(node);
|
|
127078
|
+
this._condense(path25);
|
|
126410
127079
|
return this;
|
|
126411
127080
|
}
|
|
126412
127081
|
}
|
|
126413
127082
|
if (!goingUp && !node.leaf && contains(node, bbox)) {
|
|
126414
|
-
|
|
127083
|
+
path25.push(node);
|
|
126415
127084
|
indexes.push(i);
|
|
126416
127085
|
i = 0;
|
|
126417
127086
|
parent = node;
|
|
@@ -126482,10 +127151,10 @@ var RBush = class {
|
|
|
126482
127151
|
calcBBox(node, this.toBBox);
|
|
126483
127152
|
return node;
|
|
126484
127153
|
}
|
|
126485
|
-
_chooseSubtree(bbox, node, level,
|
|
127154
|
+
_chooseSubtree(bbox, node, level, path25) {
|
|
126486
127155
|
while (true) {
|
|
126487
|
-
|
|
126488
|
-
if (node.leaf ||
|
|
127156
|
+
path25.push(node);
|
|
127157
|
+
if (node.leaf || path25.length - 1 === level)
|
|
126489
127158
|
break;
|
|
126490
127159
|
let minArea = Infinity;
|
|
126491
127160
|
let minEnlargement = Infinity;
|
|
@@ -126594,21 +127263,21 @@ var RBush = class {
|
|
|
126594
127263
|
}
|
|
126595
127264
|
return margin;
|
|
126596
127265
|
}
|
|
126597
|
-
_adjustParentBBoxes(bbox,
|
|
127266
|
+
_adjustParentBBoxes(bbox, path25, level) {
|
|
126598
127267
|
for (let i = level;i >= 0; i--) {
|
|
126599
|
-
extend(
|
|
127268
|
+
extend(path25[i], bbox);
|
|
126600
127269
|
}
|
|
126601
127270
|
}
|
|
126602
|
-
_condense(
|
|
126603
|
-
for (let i =
|
|
126604
|
-
if (
|
|
127271
|
+
_condense(path25) {
|
|
127272
|
+
for (let i = path25.length - 1, siblings;i >= 0; i--) {
|
|
127273
|
+
if (path25[i].children.length === 0) {
|
|
126605
127274
|
if (i > 0) {
|
|
126606
|
-
siblings =
|
|
126607
|
-
siblings.splice(siblings.indexOf(
|
|
127275
|
+
siblings = path25[i - 1].children;
|
|
127276
|
+
siblings.splice(siblings.indexOf(path25[i]), 1);
|
|
126608
127277
|
} else
|
|
126609
127278
|
this.clear();
|
|
126610
127279
|
} else
|
|
126611
|
-
calcBBox(
|
|
127280
|
+
calcBBox(path25[i], this.toBBox);
|
|
126612
127281
|
}
|
|
126613
127282
|
}
|
|
126614
127283
|
};
|
|
@@ -127753,7 +128422,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
127753
128422
|
this.capacityPaths = capacityPaths;
|
|
127754
128423
|
this.colorMap = colorMap ?? {};
|
|
127755
128424
|
this.unprocessedNodeIds = [
|
|
127756
|
-
...new Set(capacityPaths.flatMap((
|
|
128425
|
+
...new Set(capacityPaths.flatMap((path25) => path25.nodeIds))
|
|
127757
128426
|
];
|
|
127758
128427
|
this.nodePortSegments = /* @__PURE__ */ new Map;
|
|
127759
128428
|
}
|
|
@@ -127764,17 +128433,17 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
127764
128433
|
return;
|
|
127765
128434
|
}
|
|
127766
128435
|
const pathsGoingThroughNode = [];
|
|
127767
|
-
for (const
|
|
127768
|
-
const indexOfNodeInPath =
|
|
128436
|
+
for (const path25 of this.capacityPaths) {
|
|
128437
|
+
const indexOfNodeInPath = path25.nodeIds.indexOf(nodeId);
|
|
127769
128438
|
if (indexOfNodeInPath !== -1) {
|
|
127770
|
-
pathsGoingThroughNode.push({ path:
|
|
128439
|
+
pathsGoingThroughNode.push({ path: path25, indexOfNodeInPath });
|
|
127771
128440
|
}
|
|
127772
128441
|
}
|
|
127773
128442
|
const node = this.nodeMap.get(nodeId);
|
|
127774
128443
|
const nodePortSegments = [];
|
|
127775
|
-
for (const { path:
|
|
127776
|
-
const entryNodeId =
|
|
127777
|
-
const exitNodeId =
|
|
128444
|
+
for (const { path: path25, indexOfNodeInPath } of pathsGoingThroughNode) {
|
|
128445
|
+
const entryNodeId = path25.nodeIds[indexOfNodeInPath - 1];
|
|
128446
|
+
const exitNodeId = path25.nodeIds[indexOfNodeInPath + 1];
|
|
127778
128447
|
for (const adjNodeId of [entryNodeId, exitNodeId]) {
|
|
127779
128448
|
const adjNode = this.nodeMap.get(adjNodeId);
|
|
127780
128449
|
if (!adjNode)
|
|
@@ -127787,7 +128456,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
127787
128456
|
capacityMeshNodeId: nodeId,
|
|
127788
128457
|
start: segment2.start,
|
|
127789
128458
|
end: segment2.end,
|
|
127790
|
-
connectionNames: [
|
|
128459
|
+
connectionNames: [path25.connectionName],
|
|
127791
128460
|
availableZ: mutuallyAvailableZ
|
|
127792
128461
|
};
|
|
127793
128462
|
nodePortSegments.push(portSegment);
|
|
@@ -128593,37 +129262,37 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
|
|
|
128593
129262
|
return neighbors;
|
|
128594
129263
|
}
|
|
128595
129264
|
getNodePath(node) {
|
|
128596
|
-
const
|
|
129265
|
+
const path25 = [];
|
|
128597
129266
|
while (node) {
|
|
128598
|
-
|
|
129267
|
+
path25.push(node);
|
|
128599
129268
|
node = node.parent;
|
|
128600
129269
|
}
|
|
128601
|
-
return
|
|
129270
|
+
return path25;
|
|
128602
129271
|
}
|
|
128603
129272
|
getViasInNodePath(node) {
|
|
128604
|
-
const
|
|
129273
|
+
const path25 = this.getNodePath(node);
|
|
128605
129274
|
const vias = [];
|
|
128606
|
-
for (let i = 0;i <
|
|
128607
|
-
if (
|
|
128608
|
-
vias.push({ x:
|
|
129275
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
129276
|
+
if (path25[i].z !== path25[i + 1].z) {
|
|
129277
|
+
vias.push({ x: path25[i].x, y: path25[i].y });
|
|
128609
129278
|
}
|
|
128610
129279
|
}
|
|
128611
129280
|
return vias;
|
|
128612
129281
|
}
|
|
128613
129282
|
setSolvedPath(node) {
|
|
128614
|
-
const
|
|
128615
|
-
|
|
129283
|
+
const path25 = this.getNodePath(node);
|
|
129284
|
+
path25.reverse();
|
|
128616
129285
|
const vias = [];
|
|
128617
|
-
for (let i = 0;i <
|
|
128618
|
-
if (
|
|
128619
|
-
vias.push({ x:
|
|
129286
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
129287
|
+
if (path25[i].z !== path25[i + 1].z) {
|
|
129288
|
+
vias.push({ x: path25[i].x, y: path25[i].y });
|
|
128620
129289
|
}
|
|
128621
129290
|
}
|
|
128622
129291
|
this.solvedPath = {
|
|
128623
129292
|
connectionName: this.connectionName,
|
|
128624
129293
|
traceThickness: this.traceThickness,
|
|
128625
129294
|
viaDiameter: this.viaDiameter,
|
|
128626
|
-
route:
|
|
129295
|
+
route: path25.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
|
|
128627
129296
|
vias
|
|
128628
129297
|
};
|
|
128629
129298
|
}
|
|
@@ -129362,14 +130031,14 @@ function computeDumbbellPaths({
|
|
|
129362
130031
|
const u3 = (dx2 * d1y - dy2 * d1x) / det;
|
|
129363
130032
|
return t3 > 0 && t3 < 1 && u3 > 0 && u3 < 1;
|
|
129364
130033
|
};
|
|
129365
|
-
const doPathsIntersect = (path1,
|
|
130034
|
+
const doPathsIntersect = (path1, path25) => {
|
|
129366
130035
|
const segments1 = [];
|
|
129367
130036
|
for (let i = 0;i < path1.length - 1; i++) {
|
|
129368
130037
|
segments1.push({ start: path1[i], end: path1[i + 1] });
|
|
129369
130038
|
}
|
|
129370
130039
|
const segments2 = [];
|
|
129371
|
-
for (let i = 0;i <
|
|
129372
|
-
segments2.push({ start:
|
|
130040
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
130041
|
+
segments2.push({ start: path25[i], end: path25[i + 1] });
|
|
129373
130042
|
}
|
|
129374
130043
|
for (const seg1 of segments1) {
|
|
129375
130044
|
for (const seg2 of segments2) {
|
|
@@ -129431,12 +130100,12 @@ function computeDumbbellPaths({
|
|
|
129431
130100
|
specialType: circleCenter === A3 ? "A" : "B"
|
|
129432
130101
|
};
|
|
129433
130102
|
};
|
|
129434
|
-
const subdivideOptimalPath = (
|
|
129435
|
-
if (
|
|
129436
|
-
return
|
|
129437
|
-
const result = [
|
|
129438
|
-
for (let i = 0;i <
|
|
129439
|
-
const segment2 = { start:
|
|
130103
|
+
const subdivideOptimalPath = (path25, numSubdivisions) => {
|
|
130104
|
+
if (path25.length < 2)
|
|
130105
|
+
return path25;
|
|
130106
|
+
const result = [path25[0]];
|
|
130107
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
130108
|
+
const segment2 = { start: path25[i], end: path25[i + 1] };
|
|
129440
130109
|
const segmentMidpoint = {
|
|
129441
130110
|
x: (segment2.start.x + segment2.end.x) / 2,
|
|
129442
130111
|
y: (segment2.start.y + segment2.end.y) / 2
|
|
@@ -129498,7 +130167,7 @@ function computeDumbbellPaths({
|
|
|
129498
130167
|
}
|
|
129499
130168
|
subdivisionPoints.forEach((p) => result.push(p));
|
|
129500
130169
|
}
|
|
129501
|
-
result.push(
|
|
130170
|
+
result.push(path25[i + 1]);
|
|
129502
130171
|
}
|
|
129503
130172
|
if (result.length > 1) {
|
|
129504
130173
|
const filteredResult = [result[0]];
|
|
@@ -129733,13 +130402,13 @@ function computeDumbbellPaths({
|
|
|
129733
130402
|
].map((l, index) => ({ ...l, index }));
|
|
129734
130403
|
};
|
|
129735
130404
|
const subdivideJLinePath = (jLine, oppositePoint, r3, m2, numSubdivisions) => {
|
|
129736
|
-
const
|
|
129737
|
-
if (
|
|
129738
|
-
return
|
|
130405
|
+
const path25 = jLine.points;
|
|
130406
|
+
if (path25.length < 2)
|
|
130407
|
+
return path25;
|
|
129739
130408
|
const minDistThreshold = r3 + m2;
|
|
129740
|
-
const result = [
|
|
129741
|
-
for (let i = 0;i <
|
|
129742
|
-
const segment2 = { start:
|
|
130409
|
+
const result = [path25[0]];
|
|
130410
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
130411
|
+
const segment2 = { start: path25[i], end: path25[i + 1] };
|
|
129743
130412
|
const distToOpposite = pointToSegmentDistance22(oppositePoint, segment2.start, segment2.end);
|
|
129744
130413
|
if (distToOpposite < minDistThreshold) {
|
|
129745
130414
|
const closestPt = closestPointOnSegment(segment2, oppositePoint);
|
|
@@ -129789,18 +130458,18 @@ function computeDumbbellPaths({
|
|
|
129789
130458
|
const paths = getPaths();
|
|
129790
130459
|
const validPaths = [];
|
|
129791
130460
|
for (let i = 0;i < paths.length; i++) {
|
|
129792
|
-
const
|
|
129793
|
-
const firstSeg = { start:
|
|
130461
|
+
const path26 = paths[i];
|
|
130462
|
+
const firstSeg = { start: path26[0], end: path26[1] };
|
|
129794
130463
|
const lastSeg = {
|
|
129795
|
-
start:
|
|
129796
|
-
end:
|
|
130464
|
+
start: path26[path26.length - 2],
|
|
130465
|
+
end: path26[path26.length - 1]
|
|
129797
130466
|
};
|
|
129798
|
-
const midSeg = { start:
|
|
130467
|
+
const midSeg = { start: path26[3], end: path26[4] };
|
|
129799
130468
|
if (!intersect2(firstSeg, lastSeg) && !intersect2(firstSeg, midSeg) && !intersect2(lastSeg, midSeg)) {
|
|
129800
130469
|
validPaths.push({
|
|
129801
130470
|
index: i + 1,
|
|
129802
|
-
path:
|
|
129803
|
-
length: pathLength(
|
|
130471
|
+
path: path26,
|
|
130472
|
+
length: pathLength(path26)
|
|
129804
130473
|
});
|
|
129805
130474
|
}
|
|
129806
130475
|
}
|
|
@@ -129808,26 +130477,26 @@ function computeDumbbellPaths({
|
|
|
129808
130477
|
return { index: 0, path: [] };
|
|
129809
130478
|
}
|
|
129810
130479
|
const optimalPath2 = validPaths.sort((a, b3) => a.length - b3.length)[0];
|
|
129811
|
-
const
|
|
129812
|
-
const firstPoint =
|
|
129813
|
-
const dist3 = distance3(firstPoint,
|
|
129814
|
-
const dist4 = distance3(firstPoint,
|
|
130480
|
+
const path25 = [...optimalPath2.path];
|
|
130481
|
+
const firstPoint = path25[0];
|
|
130482
|
+
const dist3 = distance3(firstPoint, path25[2]);
|
|
130483
|
+
const dist4 = distance3(firstPoint, path25[3]);
|
|
129815
130484
|
const closerIdx = dist3 < dist4 ? 2 : 3;
|
|
129816
|
-
if (dist3 < distance3(firstPoint,
|
|
129817
|
-
|
|
130485
|
+
if (dist3 < distance3(firstPoint, path25[1]) || dist4 < distance3(firstPoint, path25[1])) {
|
|
130486
|
+
path25.splice(1, closerIdx - 1);
|
|
129818
130487
|
}
|
|
129819
|
-
const lastPoint =
|
|
129820
|
-
const distM3 = distance3(lastPoint,
|
|
129821
|
-
const distM4 = distance3(lastPoint,
|
|
129822
|
-
const closerLastIdx = distM3 < distM4 ?
|
|
129823
|
-
if (distM3 < distance3(lastPoint,
|
|
129824
|
-
|
|
130488
|
+
const lastPoint = path25[path25.length - 1];
|
|
130489
|
+
const distM3 = distance3(lastPoint, path25[path25.length - 3]);
|
|
130490
|
+
const distM4 = distance3(lastPoint, path25[path25.length - 4]);
|
|
130491
|
+
const closerLastIdx = distM3 < distM4 ? path25.length - 3 : path25.length - 4;
|
|
130492
|
+
if (distM3 < distance3(lastPoint, path25[path25.length - 2]) || distM4 < distance3(lastPoint, path25[path25.length - 2])) {
|
|
130493
|
+
path25.splice(closerLastIdx + 1, path25.length - closerLastIdx - 2);
|
|
129825
130494
|
}
|
|
129826
130495
|
return {
|
|
129827
130496
|
index: optimalPath2.index,
|
|
129828
|
-
path:
|
|
129829
|
-
startsAt:
|
|
129830
|
-
goesTo:
|
|
130497
|
+
path: path25,
|
|
130498
|
+
startsAt: path25[0] === C2 ? "C" : "D",
|
|
130499
|
+
goesTo: path25[path25.length - 1] === C2 ? "C" : "D"
|
|
129831
130500
|
};
|
|
129832
130501
|
};
|
|
129833
130502
|
const optimalPath = findOptimalPath();
|
|
@@ -131247,9 +131916,9 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
131247
131916
|
let closestIntersection = null;
|
|
131248
131917
|
let intersectedSegmentZ = null;
|
|
131249
131918
|
const checkIntersectionsWithPathMap = (pathMap) => {
|
|
131250
|
-
for (const
|
|
131251
|
-
for (let i = 0;i <
|
|
131252
|
-
const segment2 = [
|
|
131919
|
+
for (const path25 of pathMap.values()) {
|
|
131920
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
131921
|
+
const segment2 = [path25[i], path25[i + 1]];
|
|
131253
131922
|
if (segment2[0].x === segment2[1].x && segment2[0].y === segment2[1].y) {
|
|
131254
131923
|
continue;
|
|
131255
131924
|
}
|
|
@@ -131379,11 +132048,11 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
131379
132048
|
});
|
|
131380
132049
|
}
|
|
131381
132050
|
const drawPath = (pathMap, labelPrefix) => {
|
|
131382
|
-
for (const [connectionName,
|
|
132051
|
+
for (const [connectionName, path25] of pathMap.entries()) {
|
|
131383
132052
|
const color = colorMap[connectionName] ?? "black";
|
|
131384
|
-
for (let i = 0;i <
|
|
131385
|
-
const p12 =
|
|
131386
|
-
const p2 =
|
|
132053
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
132054
|
+
const p12 = path25[i];
|
|
132055
|
+
const p2 = path25[i + 1];
|
|
131387
132056
|
if (p12.x === p2.x && p12.y === p2.y && p12.z !== p2.z) {
|
|
131388
132057
|
graphics.circles.push({
|
|
131389
132058
|
center: { x: p12.x, y: p12.y },
|
|
@@ -131981,10 +132650,10 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
131981
132650
|
const allSegments = [];
|
|
131982
132651
|
const viaPoints = /* @__PURE__ */ new Map;
|
|
131983
132652
|
for (const polyLine of polyLines) {
|
|
131984
|
-
const
|
|
131985
|
-
for (let i = 0;i <
|
|
131986
|
-
const p12 =
|
|
131987
|
-
const p2 =
|
|
132653
|
+
const path25 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
132654
|
+
for (let i = 0;i < path25.length - 1; i++) {
|
|
132655
|
+
const p12 = path25[i];
|
|
132656
|
+
const p2 = path25[i + 1];
|
|
131988
132657
|
const layer = p12.z2;
|
|
131989
132658
|
allSegments.push({
|
|
131990
132659
|
start: { x: p12.x, y: p12.y },
|
|
@@ -132002,7 +132671,7 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
132002
132671
|
}
|
|
132003
132672
|
}
|
|
132004
132673
|
}
|
|
132005
|
-
const lastPoint =
|
|
132674
|
+
const lastPoint = path25[path25.length - 1];
|
|
132006
132675
|
if (lastPoint.z1 !== lastPoint.z2) {
|
|
132007
132676
|
const key = pointKey2(lastPoint);
|
|
132008
132677
|
if (!viaPoints.has(key)) {
|
|
@@ -132301,14 +132970,14 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
|
|
|
132301
132970
|
const polyLineVias = [];
|
|
132302
132971
|
for (let i = 0;i < polyLines.length; i++) {
|
|
132303
132972
|
const polyLine = polyLines[i];
|
|
132304
|
-
const
|
|
132973
|
+
const path25 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
132305
132974
|
const segmentsByLayer = new Map(this.availableZ.map((z852) => [z852, []]));
|
|
132306
|
-
for (let i22 = 0;i22 <
|
|
132307
|
-
const segment2 = [
|
|
132975
|
+
for (let i22 = 0;i22 < path25.length - 1; i22++) {
|
|
132976
|
+
const segment2 = [path25[i22], path25[i22 + 1]];
|
|
132308
132977
|
segmentsByLayer.get(segment2[0].z2).push(segment2);
|
|
132309
132978
|
}
|
|
132310
132979
|
polyLineSegmentsByLayer.push(segmentsByLayer);
|
|
132311
|
-
polyLineVias.push(
|
|
132980
|
+
polyLineVias.push(path25.filter((p) => p.z1 !== p.z2));
|
|
132312
132981
|
}
|
|
132313
132982
|
for (let i = 0;i < polyLines.length; i++) {
|
|
132314
132983
|
const path1SegmentsByLayer = polyLineSegmentsByLayer[i];
|
|
@@ -133737,7 +134406,7 @@ var HighDensitySolver = class extends BaseSolver {
|
|
|
133737
134406
|
if (this.failedSolvers.length > 0) {
|
|
133738
134407
|
this.solved = false;
|
|
133739
134408
|
this.failed = true;
|
|
133740
|
-
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((
|
|
134409
|
+
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((fs26) => fs26.nodeWithPortPoints.capacityMeshNodeId)}. err0: ${this.failedSolvers[0].error}.`;
|
|
133741
134410
|
return;
|
|
133742
134411
|
}
|
|
133743
134412
|
this.solved = true;
|
|
@@ -136518,13 +137187,13 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
136518
137187
|
return this.getDistanceBetweenNodes(node, endGoal);
|
|
136519
137188
|
}
|
|
136520
137189
|
getBacktrackedPath(candidate) {
|
|
136521
|
-
const
|
|
137190
|
+
const path25 = [];
|
|
136522
137191
|
let currentCandidate = candidate;
|
|
136523
137192
|
while (currentCandidate) {
|
|
136524
|
-
|
|
137193
|
+
path25.push(currentCandidate.node);
|
|
136525
137194
|
currentCandidate = currentCandidate.prevCandidate;
|
|
136526
137195
|
}
|
|
136527
|
-
return
|
|
137196
|
+
return path25;
|
|
136528
137197
|
}
|
|
136529
137198
|
getNeighboringNodes(node) {
|
|
136530
137199
|
return this.nodeEdgeMap.get(node.capacityMeshNodeId).flatMap((edge) => edge.nodeIds.filter((n3) => n3 !== node.capacityMeshNodeId)).map((n3) => this.nodeMap.get(n3));
|
|
@@ -136532,12 +137201,12 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
136532
137201
|
getCapacityPaths() {
|
|
136533
137202
|
const capacityPaths = [];
|
|
136534
137203
|
for (const connection of this.connectionsWithNodes) {
|
|
136535
|
-
const
|
|
136536
|
-
if (
|
|
137204
|
+
const path25 = connection.path;
|
|
137205
|
+
if (path25) {
|
|
136537
137206
|
capacityPaths.push({
|
|
136538
137207
|
capacityPathId: connection.connection.name,
|
|
136539
137208
|
connectionName: connection.connection.name,
|
|
136540
|
-
nodeIds:
|
|
137209
|
+
nodeIds: path25.map((node) => node.capacityMeshNodeId)
|
|
136541
137210
|
});
|
|
136542
137211
|
}
|
|
136543
137212
|
}
|
|
@@ -137222,10 +137891,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
137222
137891
|
return this.getDistanceBetweenNodes(node, endGoal) + this.getNodeCapacityPenalty(node);
|
|
137223
137892
|
}
|
|
137224
137893
|
getBacktrackedPath(candidate) {
|
|
137225
|
-
const
|
|
137894
|
+
const path25 = [];
|
|
137226
137895
|
let currentCandidate = candidate;
|
|
137227
137896
|
while (currentCandidate) {
|
|
137228
|
-
|
|
137897
|
+
path25.push(currentCandidate.node);
|
|
137229
137898
|
if (this.nodeMap.has(currentCandidate.node.capacityMeshNodeId)) {
|
|
137230
137899
|
currentCandidate = currentCandidate.prevCandidate;
|
|
137231
137900
|
} else {
|
|
@@ -137233,7 +137902,7 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
137233
137902
|
break;
|
|
137234
137903
|
}
|
|
137235
137904
|
}
|
|
137236
|
-
return
|
|
137905
|
+
return path25.reverse();
|
|
137237
137906
|
}
|
|
137238
137907
|
getNeighboringNodes(node) {
|
|
137239
137908
|
if (!this.nodeMap.has(node.capacityMeshNodeId))
|
|
@@ -137248,8 +137917,8 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
137248
137917
|
doesNodeHaveCapacityForTrace(node, prevNode) {
|
|
137249
137918
|
return true;
|
|
137250
137919
|
}
|
|
137251
|
-
reduceCapacityAlongPath(
|
|
137252
|
-
for (const pathNode of
|
|
137920
|
+
reduceCapacityAlongPath(path25) {
|
|
137921
|
+
for (const pathNode of path25) {
|
|
137253
137922
|
if (this.usedNodeCapacityMap.has(pathNode.capacityMeshNodeId)) {
|
|
137254
137923
|
const nodeId = pathNode.capacityMeshNodeId;
|
|
137255
137924
|
const nodeInSection = this.nodeMap.get(nodeId);
|
|
@@ -137378,9 +138047,9 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
137378
138047
|
this.queuedNodes = null;
|
|
137379
138048
|
}
|
|
137380
138049
|
_handleGoalReached(currentCandidate, currentTerminal, endNode) {
|
|
137381
|
-
const
|
|
137382
|
-
currentTerminal.path =
|
|
137383
|
-
this.reduceCapacityAlongPath(
|
|
138050
|
+
const path25 = this.getBacktrackedPath(currentCandidate);
|
|
138051
|
+
currentTerminal.path = path25;
|
|
138052
|
+
this.reduceCapacityAlongPath(path25);
|
|
137384
138053
|
this.currentConnectionIndex++;
|
|
137385
138054
|
this.candidates = null;
|
|
137386
138055
|
this.visitedNodes = null;
|
|
@@ -137429,10 +138098,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
137429
138098
|
const connectionColor = this.colorMap[connectionName] ?? "purple";
|
|
137430
138099
|
topCandidates.forEach((candidate, index) => {
|
|
137431
138100
|
const opacity = 0.8 * (1 - index / 5);
|
|
137432
|
-
const
|
|
137433
|
-
if (
|
|
138101
|
+
const path25 = this.getBacktrackedPath(candidate);
|
|
138102
|
+
if (path25.length > 0) {
|
|
137434
138103
|
baseGraphics.lines.push({
|
|
137435
|
-
points:
|
|
138104
|
+
points: path25.map(({ center: { x, y } }) => ({ x, y })),
|
|
137436
138105
|
strokeColor: safeTransparentize(connectionColor, 1 - opacity),
|
|
137437
138106
|
strokeWidth: 0.05
|
|
137438
138107
|
});
|
|
@@ -138121,12 +138790,12 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
|
|
|
138121
138790
|
getCapacityPaths() {
|
|
138122
138791
|
const capacityPaths = [];
|
|
138123
138792
|
for (const connection of this.connectionsWithNodes) {
|
|
138124
|
-
const
|
|
138125
|
-
if (
|
|
138793
|
+
const path25 = connection.path;
|
|
138794
|
+
if (path25) {
|
|
138126
138795
|
capacityPaths.push({
|
|
138127
138796
|
capacityPathId: connection.connection.name,
|
|
138128
138797
|
connectionName: connection.connection.name,
|
|
138129
|
-
nodeIds:
|
|
138798
|
+
nodeIds: path25.map((node) => node.capacityMeshNodeId)
|
|
138130
138799
|
});
|
|
138131
138800
|
}
|
|
138132
138801
|
}
|
|
@@ -139147,22 +139816,22 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
|
|
|
139147
139816
|
return null;
|
|
139148
139817
|
}
|
|
139149
139818
|
const possiblePaths = calculate45DegreePaths({ x: start.x, y: start.y }, { x: end.x, y: end.y });
|
|
139150
|
-
for (const
|
|
139151
|
-
const fullPath =
|
|
139819
|
+
for (const path25 of possiblePaths) {
|
|
139820
|
+
const fullPath = path25.map((p) => ({ x: p.x, y: p.y, z: start.z }));
|
|
139152
139821
|
if (this.isValidPath(fullPath)) {
|
|
139153
139822
|
return fullPath;
|
|
139154
139823
|
}
|
|
139155
139824
|
}
|
|
139156
139825
|
return null;
|
|
139157
139826
|
}
|
|
139158
|
-
addPathToResult(
|
|
139159
|
-
if (
|
|
139827
|
+
addPathToResult(path25) {
|
|
139828
|
+
if (path25.length === 0)
|
|
139160
139829
|
return;
|
|
139161
|
-
for (let i = 0;i <
|
|
139162
|
-
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1],
|
|
139830
|
+
for (let i = 0;i < path25.length; i++) {
|
|
139831
|
+
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path25[i])) {
|
|
139163
139832
|
continue;
|
|
139164
139833
|
}
|
|
139165
|
-
this.newRoute.push(
|
|
139834
|
+
this.newRoute.push(path25[i]);
|
|
139166
139835
|
}
|
|
139167
139836
|
this.currentStepSize = this.maxStepSize;
|
|
139168
139837
|
}
|
|
@@ -166569,7 +167238,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
166569
167238
|
for (let i = 0;i < portsWithPosition.length - 1; i++) {
|
|
166570
167239
|
const start = portsWithPosition[i];
|
|
166571
167240
|
const end = portsWithPosition[i + 1];
|
|
166572
|
-
const
|
|
167241
|
+
const path25 = calculateElbow({
|
|
166573
167242
|
x: start.position.x,
|
|
166574
167243
|
y: start.position.y,
|
|
166575
167244
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -166578,8 +167247,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
166578
167247
|
y: end.position.y,
|
|
166579
167248
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
166580
167249
|
});
|
|
166581
|
-
for (let j4 = 0;j4 <
|
|
166582
|
-
elbowEdges.push({ from:
|
|
167250
|
+
for (let j4 = 0;j4 < path25.length - 1; j4++) {
|
|
167251
|
+
elbowEdges.push({ from: path25[j4], to: path25[j4 + 1] });
|
|
166583
167252
|
}
|
|
166584
167253
|
}
|
|
166585
167254
|
const doesSegmentIntersectRect = (edge, rect) => {
|
|
@@ -172767,8 +173436,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
172767
173436
|
*/
|
|
172768
173437
|
|
|
172769
173438
|
// lib/import/import-component-from-jlcpcb.ts
|
|
172770
|
-
import
|
|
172771
|
-
import
|
|
173439
|
+
import fs26 from "node:fs/promises";
|
|
173440
|
+
import path25 from "node:path";
|
|
172772
173441
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
172773
173442
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
172774
173443
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -172776,10 +173445,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
172776
173445
|
if (!fileName) {
|
|
172777
173446
|
throw new Error("Could not determine file name of converted component");
|
|
172778
173447
|
}
|
|
172779
|
-
const importsDir =
|
|
172780
|
-
await
|
|
172781
|
-
const filePath =
|
|
172782
|
-
await
|
|
173448
|
+
const importsDir = path25.join(projectDir, "imports");
|
|
173449
|
+
await fs26.mkdir(importsDir, { recursive: true });
|
|
173450
|
+
const filePath = path25.join(importsDir, `${fileName}.tsx`);
|
|
173451
|
+
await fs26.writeFile(filePath, tsx);
|
|
172783
173452
|
return { filePath };
|
|
172784
173453
|
};
|
|
172785
173454
|
|
|
@@ -172880,12 +173549,12 @@ var registerRemove = (program3) => {
|
|
|
172880
173549
|
};
|
|
172881
173550
|
|
|
172882
173551
|
// cli/build/register.ts
|
|
172883
|
-
import
|
|
172884
|
-
import
|
|
173552
|
+
import path28 from "node:path";
|
|
173553
|
+
import fs29 from "node:fs";
|
|
172885
173554
|
|
|
172886
173555
|
// cli/build/build-file.ts
|
|
172887
|
-
import
|
|
172888
|
-
import
|
|
173556
|
+
import path26 from "node:path";
|
|
173557
|
+
import fs27 from "node:fs";
|
|
172889
173558
|
|
|
172890
173559
|
// lib/shared/circuit-json-diagnostics.ts
|
|
172891
173560
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -172916,9 +173585,9 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
172916
173585
|
filePath: input,
|
|
172917
173586
|
platformConfig: options?.platformConfig
|
|
172918
173587
|
});
|
|
172919
|
-
|
|
172920
|
-
|
|
172921
|
-
console.log(`Circuit JSON written to ${
|
|
173588
|
+
fs27.mkdirSync(path26.dirname(output), { recursive: true });
|
|
173589
|
+
fs27.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
|
|
173590
|
+
console.log(`Circuit JSON written to ${path26.relative(projectDir, output)}`);
|
|
172922
173591
|
const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
|
|
172923
173592
|
if (!options?.ignoreWarnings) {
|
|
172924
173593
|
for (const warn of warnings) {
|
|
@@ -172946,16 +173615,16 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
172946
173615
|
};
|
|
172947
173616
|
|
|
172948
173617
|
// cli/build/get-build-entrypoints.ts
|
|
172949
|
-
import
|
|
172950
|
-
import
|
|
173618
|
+
import fs28 from "node:fs";
|
|
173619
|
+
import path27 from "node:path";
|
|
172951
173620
|
async function getBuildEntrypoints({
|
|
172952
173621
|
fileOrDir,
|
|
172953
173622
|
rootDir = process.cwd()
|
|
172954
173623
|
}) {
|
|
172955
|
-
const resolvedRoot =
|
|
173624
|
+
const resolvedRoot = path27.resolve(rootDir);
|
|
172956
173625
|
if (fileOrDir) {
|
|
172957
|
-
const resolved =
|
|
172958
|
-
if (
|
|
173626
|
+
const resolved = path27.resolve(resolvedRoot, fileOrDir);
|
|
173627
|
+
if (fs28.existsSync(resolved) && fs28.statSync(resolved).isDirectory()) {
|
|
172959
173628
|
const projectDir2 = resolved;
|
|
172960
173629
|
const files2 = globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
172961
173630
|
cwd: projectDir2,
|
|
@@ -172963,10 +173632,10 @@ async function getBuildEntrypoints({
|
|
|
172963
173632
|
});
|
|
172964
173633
|
return {
|
|
172965
173634
|
projectDir: projectDir2,
|
|
172966
|
-
circuitFiles: files2.map((f) =>
|
|
173635
|
+
circuitFiles: files2.map((f) => path27.join(projectDir2, f))
|
|
172967
173636
|
};
|
|
172968
173637
|
}
|
|
172969
|
-
return { projectDir:
|
|
173638
|
+
return { projectDir: path27.dirname(resolved), circuitFiles: [resolved] };
|
|
172970
173639
|
}
|
|
172971
173640
|
const projectDir = resolvedRoot;
|
|
172972
173641
|
const files = globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
@@ -172975,7 +173644,7 @@ async function getBuildEntrypoints({
|
|
|
172975
173644
|
});
|
|
172976
173645
|
return {
|
|
172977
173646
|
projectDir,
|
|
172978
|
-
circuitFiles: files.map((f) =>
|
|
173647
|
+
circuitFiles: files.map((f) => path27.join(projectDir, f))
|
|
172979
173648
|
};
|
|
172980
173649
|
}
|
|
172981
173650
|
|
|
@@ -172983,13 +173652,13 @@ async function getBuildEntrypoints({
|
|
|
172983
173652
|
var registerBuild = (program3) => {
|
|
172984
173653
|
program3.command("build").description("Run tscircuit eval and output circuit json").argument("[file]", "Path to the entry file").option("--ignore-errors", "Do not exit with code 1 on errors").option("--ignore-warnings", "Do not log warnings").option("--disable-pcb", "Disable PCB outputs").action(async (file, options) => {
|
|
172985
173654
|
const { projectDir, mainEntrypoint, circuitFiles } = await getBuildEntrypoints({ fileOrDir: file });
|
|
172986
|
-
const distDir =
|
|
172987
|
-
|
|
173655
|
+
const distDir = path28.join(projectDir, "dist");
|
|
173656
|
+
fs29.mkdirSync(distDir, { recursive: true });
|
|
172988
173657
|
let hasErrors = false;
|
|
172989
173658
|
for (const filePath of circuitFiles) {
|
|
172990
|
-
const relative9 =
|
|
173659
|
+
const relative9 = path28.relative(projectDir, filePath);
|
|
172991
173660
|
const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
172992
|
-
const outputPath =
|
|
173661
|
+
const outputPath = path28.join(distDir, outputDirName, "circuit.json");
|
|
172993
173662
|
const ok = await buildFile(filePath, outputPath, projectDir, options);
|
|
172994
173663
|
if (!ok)
|
|
172995
173664
|
hasErrors = true;
|
|
@@ -173001,8 +173670,8 @@ var registerBuild = (program3) => {
|
|
|
173001
173670
|
};
|
|
173002
173671
|
|
|
173003
173672
|
// lib/shared/snapshot-project.ts
|
|
173004
|
-
import
|
|
173005
|
-
import
|
|
173673
|
+
import fs31 from "node:fs";
|
|
173674
|
+
import path29 from "node:path";
|
|
173006
173675
|
import looksSame2 from "looks-same";
|
|
173007
173676
|
import sharp from "sharp";
|
|
173008
173677
|
import {
|
|
@@ -173013,7 +173682,7 @@ import { convertCircuitJsonToSimple3dSvg } from "circuit-json-to-simple-3d";
|
|
|
173013
173682
|
|
|
173014
173683
|
// lib/shared/compare-images.ts
|
|
173015
173684
|
import looksSame from "looks-same";
|
|
173016
|
-
import
|
|
173685
|
+
import fs30 from "node:fs/promises";
|
|
173017
173686
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
173018
173687
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
173019
173688
|
strict: false,
|
|
@@ -173029,7 +173698,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
173029
173698
|
tolerance: 2
|
|
173030
173699
|
});
|
|
173031
173700
|
} else {
|
|
173032
|
-
await
|
|
173701
|
+
await fs30.writeFile(diffPath, buffer2);
|
|
173033
173702
|
}
|
|
173034
173703
|
}
|
|
173035
173704
|
return { equal: equal2 };
|
|
@@ -173053,19 +173722,19 @@ var snapshotProject = async ({
|
|
|
173053
173722
|
...DEFAULT_IGNORED_PATTERNS,
|
|
173054
173723
|
...ignored.map(normalizeIgnorePattern)
|
|
173055
173724
|
];
|
|
173056
|
-
const resolvedPaths = filePaths.map((f) =>
|
|
173725
|
+
const resolvedPaths = filePaths.map((f) => path29.resolve(projectDir, f));
|
|
173057
173726
|
const boardFiles = resolvedPaths.length > 0 ? resolvedPaths.flatMap((p) => {
|
|
173058
|
-
if (
|
|
173727
|
+
if (fs31.existsSync(p) && fs31.statSync(p).isDirectory()) {
|
|
173059
173728
|
return globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
173060
173729
|
cwd: p,
|
|
173061
173730
|
ignore
|
|
173062
|
-
}).map((f) =>
|
|
173731
|
+
}).map((f) => path29.join(p, f));
|
|
173063
173732
|
}
|
|
173064
173733
|
return [p];
|
|
173065
173734
|
}) : globbySync(["**/*.board.tsx", "**/*.circuit.tsx"], {
|
|
173066
173735
|
cwd: projectDir,
|
|
173067
173736
|
ignore
|
|
173068
|
-
}).map((f) =>
|
|
173737
|
+
}).map((f) => path29.join(projectDir, f));
|
|
173069
173738
|
if (boardFiles.length === 0) {
|
|
173070
173739
|
console.log("No entrypoint found. Run 'tsci init' to bootstrap a project or specify a file with 'tsci snapshot <file>'");
|
|
173071
173740
|
return onExit(0);
|
|
@@ -173077,9 +173746,9 @@ var snapshotProject = async ({
|
|
|
173077
173746
|
const pcbSvg = convertCircuitJsonToPcbSvg3(circuitJson);
|
|
173078
173747
|
const schSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
|
|
173079
173748
|
const svg3d = threeD ? await convertCircuitJsonToSimple3dSvg(circuitJson) : null;
|
|
173080
|
-
const snapDir =
|
|
173081
|
-
|
|
173082
|
-
const base =
|
|
173749
|
+
const snapDir = path29.join(path29.dirname(file), "__snapshots__");
|
|
173750
|
+
fs31.mkdirSync(snapDir, { recursive: true });
|
|
173751
|
+
const base = path29.basename(file).replace(/\.tsx$/, "");
|
|
173083
173752
|
const pairs3 = [];
|
|
173084
173753
|
if (pcbOnly || !schematicOnly)
|
|
173085
173754
|
pairs3.push(["pcb", pcbSvg]);
|
|
@@ -173093,31 +173762,31 @@ var snapshotProject = async ({
|
|
|
173093
173762
|
}
|
|
173094
173763
|
for (const [type, newSvg] of pairs3) {
|
|
173095
173764
|
const is3d = type === "3d";
|
|
173096
|
-
const snapPath =
|
|
173097
|
-
const existing =
|
|
173765
|
+
const snapPath = path29.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
173766
|
+
const existing = fs31.existsSync(snapPath);
|
|
173098
173767
|
const newContentBuffer = is3d ? await sharp(Buffer.from(newSvg)).png().toBuffer() : Buffer.from(newSvg, "utf8");
|
|
173099
173768
|
const newContentForFile = is3d ? newContentBuffer : newSvg;
|
|
173100
173769
|
if (!existing) {
|
|
173101
|
-
|
|
173102
|
-
console.log("✅", kleur_default.gray(
|
|
173770
|
+
fs31.writeFileSync(snapPath, newContentForFile);
|
|
173771
|
+
console.log("✅", kleur_default.gray(path29.relative(projectDir, snapPath)));
|
|
173103
173772
|
didUpdate = true;
|
|
173104
173773
|
continue;
|
|
173105
173774
|
}
|
|
173106
|
-
const oldContentBuffer =
|
|
173775
|
+
const oldContentBuffer = fs31.readFileSync(snapPath);
|
|
173107
173776
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
173108
173777
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
173109
173778
|
if (update) {
|
|
173110
173779
|
if (!forceUpdate && equal2) {
|
|
173111
|
-
console.log("✅", kleur_default.gray(
|
|
173780
|
+
console.log("✅", kleur_default.gray(path29.relative(projectDir, snapPath)));
|
|
173112
173781
|
} else {
|
|
173113
|
-
|
|
173114
|
-
console.log("✅", kleur_default.gray(
|
|
173782
|
+
fs31.writeFileSync(snapPath, newContentForFile);
|
|
173783
|
+
console.log("✅", kleur_default.gray(path29.relative(projectDir, snapPath)));
|
|
173115
173784
|
didUpdate = true;
|
|
173116
173785
|
}
|
|
173117
173786
|
} else if (!equal2) {
|
|
173118
173787
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
173119
173788
|
} else {
|
|
173120
|
-
console.log("✅", kleur_default.gray(
|
|
173789
|
+
console.log("✅", kleur_default.gray(path29.relative(projectDir, snapPath)));
|
|
173121
173790
|
}
|
|
173122
173791
|
}
|
|
173123
173792
|
}
|
|
@@ -173155,22 +173824,22 @@ var registerSnapshot = (program3) => {
|
|
|
173155
173824
|
};
|
|
173156
173825
|
|
|
173157
173826
|
// lib/shared/setup-github-actions.ts
|
|
173158
|
-
import
|
|
173159
|
-
import
|
|
173827
|
+
import fs32 from "node:fs";
|
|
173828
|
+
import path30 from "node:path";
|
|
173160
173829
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
173161
173830
|
const findGitRoot = (startDir) => {
|
|
173162
|
-
let dir =
|
|
173163
|
-
while (dir !==
|
|
173164
|
-
if (
|
|
173831
|
+
let dir = path30.resolve(startDir);
|
|
173832
|
+
while (dir !== path30.parse(dir).root) {
|
|
173833
|
+
if (fs32.existsSync(path30.join(dir, ".git"))) {
|
|
173165
173834
|
return dir;
|
|
173166
173835
|
}
|
|
173167
|
-
dir =
|
|
173836
|
+
dir = path30.dirname(dir);
|
|
173168
173837
|
}
|
|
173169
173838
|
return null;
|
|
173170
173839
|
};
|
|
173171
173840
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
173172
|
-
const workflowsDir =
|
|
173173
|
-
|
|
173841
|
+
const workflowsDir = path30.join(gitRoot, ".github", "workflows");
|
|
173842
|
+
fs32.mkdirSync(workflowsDir, { recursive: true });
|
|
173174
173843
|
const buildWorkflow = `name: tscircuit Build
|
|
173175
173844
|
|
|
173176
173845
|
on:
|
|
@@ -173209,8 +173878,8 @@ jobs:
|
|
|
173209
173878
|
- run: bun install
|
|
173210
173879
|
- run: bunx tsci snapshot
|
|
173211
173880
|
`;
|
|
173212
|
-
writeFileIfNotExists(
|
|
173213
|
-
writeFileIfNotExists(
|
|
173881
|
+
writeFileIfNotExists(path30.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
173882
|
+
writeFileIfNotExists(path30.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
173214
173883
|
};
|
|
173215
173884
|
|
|
173216
173885
|
// cli/setup/register.ts
|
|
@@ -173236,8 +173905,8 @@ var registerSetup = (program3) => {
|
|
|
173236
173905
|
};
|
|
173237
173906
|
|
|
173238
173907
|
// cli/convert/register.ts
|
|
173239
|
-
import
|
|
173240
|
-
import
|
|
173908
|
+
import fs33 from "node:fs/promises";
|
|
173909
|
+
import path31 from "node:path";
|
|
173241
173910
|
|
|
173242
173911
|
// node_modules/kicad-component-converter/dist/index.js
|
|
173243
173912
|
var __create4 = Object.create;
|
|
@@ -174549,8 +175218,8 @@ function getErrorMap() {
|
|
|
174549
175218
|
return overrideErrorMap;
|
|
174550
175219
|
}
|
|
174551
175220
|
var makeIssue = (params2) => {
|
|
174552
|
-
const { data, path:
|
|
174553
|
-
const fullPath = [...
|
|
175221
|
+
const { data, path: path31, errorMaps, issueData } = params2;
|
|
175222
|
+
const fullPath = [...path31, ...issueData.path || []];
|
|
174554
175223
|
const fullIssue = {
|
|
174555
175224
|
...issueData,
|
|
174556
175225
|
path: fullPath
|
|
@@ -174658,11 +175327,11 @@ var errorUtil;
|
|
|
174658
175327
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
174659
175328
|
})(errorUtil || (errorUtil = {}));
|
|
174660
175329
|
var ParseInputLazyPath = class {
|
|
174661
|
-
constructor(parent, value,
|
|
175330
|
+
constructor(parent, value, path31, key) {
|
|
174662
175331
|
this._cachedPath = [];
|
|
174663
175332
|
this.parent = parent;
|
|
174664
175333
|
this.data = value;
|
|
174665
|
-
this._path =
|
|
175334
|
+
this._path = path31;
|
|
174666
175335
|
this._key = key;
|
|
174667
175336
|
}
|
|
174668
175337
|
get path() {
|
|
@@ -178451,14 +179120,14 @@ function generateArcPath(start, mid, end, numPoints) {
|
|
|
178451
179120
|
if (angleDelta < 0) {
|
|
178452
179121
|
angleDelta += 2 * Math.PI;
|
|
178453
179122
|
}
|
|
178454
|
-
const
|
|
179123
|
+
const path31 = [];
|
|
178455
179124
|
for (let i = 0;i <= numPoints; i++) {
|
|
178456
179125
|
const angle = angleStart + i / numPoints * angleDelta;
|
|
178457
179126
|
const x = center2.x + radius * Math.cos(angle);
|
|
178458
179127
|
const y = center2.y + radius * Math.sin(angle);
|
|
178459
|
-
|
|
179128
|
+
path31.push({ x, y });
|
|
178460
179129
|
}
|
|
178461
|
-
return
|
|
179130
|
+
return path31;
|
|
178462
179131
|
}
|
|
178463
179132
|
var makePoint = (p) => {
|
|
178464
179133
|
if (Array.isArray(p)) {
|
|
@@ -178902,15 +179571,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
178902
179571
|
var registerConvert = (program3) => {
|
|
178903
179572
|
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) => {
|
|
178904
179573
|
try {
|
|
178905
|
-
const inputPath =
|
|
178906
|
-
const modContent = await
|
|
179574
|
+
const inputPath = path31.resolve(file);
|
|
179575
|
+
const modContent = await fs33.readFile(inputPath, "utf-8");
|
|
178907
179576
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
178908
|
-
const componentName = options.name ??
|
|
179577
|
+
const componentName = options.name ?? path31.basename(inputPath, ".kicad_mod");
|
|
178909
179578
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
178910
179579
|
componentName
|
|
178911
179580
|
});
|
|
178912
|
-
const outputPath = options.output ?
|
|
178913
|
-
await
|
|
179581
|
+
const outputPath = options.output ? path31.resolve(options.output) : path31.join(path31.dirname(inputPath), `${componentName}.tsx`);
|
|
179582
|
+
await fs33.writeFile(outputPath, tsx);
|
|
178914
179583
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
178915
179584
|
} catch (error) {
|
|
178916
179585
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -178919,6 +179588,89 @@ var registerConvert = (program3) => {
|
|
|
178919
179588
|
});
|
|
178920
179589
|
};
|
|
178921
179590
|
|
|
179591
|
+
// lib/shared/result-to-table.ts
|
|
179592
|
+
var formatNumber = (n3) => {
|
|
179593
|
+
return n3.toExponential(6);
|
|
179594
|
+
};
|
|
179595
|
+
function formatRows(rows) {
|
|
179596
|
+
if (rows.length === 0)
|
|
179597
|
+
return "";
|
|
179598
|
+
const colWidths = Array(rows[0].length).fill(0);
|
|
179599
|
+
for (const row of rows) {
|
|
179600
|
+
for (let i = 0;i < row.length; i++) {
|
|
179601
|
+
colWidths[i] = Math.max(colWidths[i], row[i].length);
|
|
179602
|
+
}
|
|
179603
|
+
}
|
|
179604
|
+
return rows.map((row) => row.map((cell, i) => cell.padEnd(colWidths[i])).join(" ")).join(`
|
|
179605
|
+
`);
|
|
179606
|
+
}
|
|
179607
|
+
var resultToTable = (result) => {
|
|
179608
|
+
const uniqueHeaders = [];
|
|
179609
|
+
const uniqueData = [];
|
|
179610
|
+
const seenHeaders = new Set;
|
|
179611
|
+
result.variableNames.forEach((header, index) => {
|
|
179612
|
+
if (!seenHeaders.has(header)) {
|
|
179613
|
+
seenHeaders.add(header);
|
|
179614
|
+
uniqueHeaders.push(header);
|
|
179615
|
+
uniqueData.push(result.data[index]);
|
|
179616
|
+
}
|
|
179617
|
+
});
|
|
179618
|
+
if (result.dataType === "real") {
|
|
179619
|
+
const headers2 = ["Index", ...uniqueHeaders];
|
|
179620
|
+
const dataRows2 = [];
|
|
179621
|
+
for (let i = 0;i < result.numPoints; i++) {
|
|
179622
|
+
const row = [
|
|
179623
|
+
i.toString(),
|
|
179624
|
+
...uniqueData.map((d) => formatNumber(d.values[i]))
|
|
179625
|
+
];
|
|
179626
|
+
dataRows2.push(row);
|
|
179627
|
+
}
|
|
179628
|
+
return formatRows([headers2, ...dataRows2]);
|
|
179629
|
+
}
|
|
179630
|
+
const headers = [
|
|
179631
|
+
"Index",
|
|
179632
|
+
...uniqueHeaders.flatMap((v2) => [`${v2}_real`, `${v2}_img`])
|
|
179633
|
+
];
|
|
179634
|
+
const dataRows = [];
|
|
179635
|
+
for (let i = 0;i < result.numPoints; i++) {
|
|
179636
|
+
const row = [
|
|
179637
|
+
i.toString(),
|
|
179638
|
+
...uniqueData.flatMap((d) => [
|
|
179639
|
+
formatNumber(d.values[i].real),
|
|
179640
|
+
formatNumber(d.values[i].img)
|
|
179641
|
+
])
|
|
179642
|
+
];
|
|
179643
|
+
dataRows.push(row);
|
|
179644
|
+
}
|
|
179645
|
+
return formatRows([headers, ...dataRows]);
|
|
179646
|
+
};
|
|
179647
|
+
|
|
179648
|
+
// cli/simulate/register.ts
|
|
179649
|
+
var registerSimulate = (program3) => {
|
|
179650
|
+
const simulateCommand = program3.command("simulate").description("Run a simulation");
|
|
179651
|
+
simulateCommand.command("analog").description("Run an analog SPICE simulation").argument("<file>", "Path to tscircuit tsx or circuit json file").action(async (file) => {
|
|
179652
|
+
const { circuitJson } = await generateCircuitJson({
|
|
179653
|
+
filePath: file,
|
|
179654
|
+
saveToFile: false
|
|
179655
|
+
});
|
|
179656
|
+
if (!circuitJson) {
|
|
179657
|
+
console.log("error: Failed to generate circuit JSON");
|
|
179658
|
+
return;
|
|
179659
|
+
}
|
|
179660
|
+
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
179661
|
+
const { result, info, errors } = await runSimulation(spiceString);
|
|
179662
|
+
if (errors?.length > 0) {
|
|
179663
|
+
console.error(errors.join(`
|
|
179664
|
+
`));
|
|
179665
|
+
}
|
|
179666
|
+
if (info) {
|
|
179667
|
+
console.log(info);
|
|
179668
|
+
}
|
|
179669
|
+
const tableContent = resultToTable(result);
|
|
179670
|
+
console.log(tableContent);
|
|
179671
|
+
});
|
|
179672
|
+
};
|
|
179673
|
+
|
|
178922
179674
|
// cli/main.ts
|
|
178923
179675
|
var program2 = new Command;
|
|
178924
179676
|
program2.name("tsci").description("CLI for developing tscircuit packages");
|
|
@@ -178944,6 +179696,7 @@ registerUpgradeCommand(program2);
|
|
|
178944
179696
|
registerSearch(program2);
|
|
178945
179697
|
registerImport(program2);
|
|
178946
179698
|
registerConvert(program2);
|
|
179699
|
+
registerSimulate(program2);
|
|
178947
179700
|
if (process.argv.includes("--version") || process.argv.includes("-v") || process.argv.includes("-V")) {
|
|
178948
179701
|
console.log(getVersion());
|
|
178949
179702
|
process.exit(0);
|