@tscircuit/cli 0.1.1053 → 0.1.1055
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/main.js +745 -681
- package/dist/lib/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/main.js
CHANGED
|
@@ -68605,18 +68605,18 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68605
68605
|
abs = abs.replace(/\\/g, "/");
|
|
68606
68606
|
return abs;
|
|
68607
68607
|
}
|
|
68608
|
-
function isIgnored(self2,
|
|
68608
|
+
function isIgnored(self2, path47) {
|
|
68609
68609
|
if (!self2.ignore.length)
|
|
68610
68610
|
return false;
|
|
68611
68611
|
return self2.ignore.some(function(item) {
|
|
68612
|
-
return item.matcher.match(
|
|
68612
|
+
return item.matcher.match(path47) || !!(item.gmatcher && item.gmatcher.match(path47));
|
|
68613
68613
|
});
|
|
68614
68614
|
}
|
|
68615
|
-
function childrenIgnored(self2,
|
|
68615
|
+
function childrenIgnored(self2, path47) {
|
|
68616
68616
|
if (!self2.ignore.length)
|
|
68617
68617
|
return false;
|
|
68618
68618
|
return self2.ignore.some(function(item) {
|
|
68619
|
-
return !!(item.gmatcher && item.gmatcher.match(
|
|
68619
|
+
return !!(item.gmatcher && item.gmatcher.match(path47));
|
|
68620
68620
|
});
|
|
68621
68621
|
}
|
|
68622
68622
|
}
|
|
@@ -71664,7 +71664,7 @@ var registerStaticAssetLoaders = () => {
|
|
|
71664
71664
|
// cli/main.ts
|
|
71665
71665
|
var import_perfect_cli = __toESM2(require_dist2(), 1);
|
|
71666
71666
|
// package.json
|
|
71667
|
-
var version = "0.1.
|
|
71667
|
+
var version = "0.1.1054";
|
|
71668
71668
|
var package_default = {
|
|
71669
71669
|
name: "@tscircuit/cli",
|
|
71670
71670
|
version,
|
|
@@ -82554,16 +82554,293 @@ var registerBuild = (program2) => {
|
|
|
82554
82554
|
});
|
|
82555
82555
|
};
|
|
82556
82556
|
|
|
82557
|
+
// node_modules/circuit-json-to-readable-netlist/dist/index.js
|
|
82558
|
+
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
82559
|
+
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
|
|
82560
|
+
import { su as su2 } from "@tscircuit/circuit-json-util";
|
|
82561
|
+
import { su } from "@tscircuit/circuit-json-util";
|
|
82562
|
+
var wordQualityScore = {
|
|
82563
|
+
MISO: 1.2,
|
|
82564
|
+
MOSI: 1.2,
|
|
82565
|
+
SCLK: 1.2,
|
|
82566
|
+
SDA: 1.2,
|
|
82567
|
+
SCL: 1.2,
|
|
82568
|
+
RX: 1.15,
|
|
82569
|
+
TX: 1.15,
|
|
82570
|
+
GPIO: 1.1,
|
|
82571
|
+
cathode: 0.5,
|
|
82572
|
+
anode: 0.5,
|
|
82573
|
+
GND: 1.1,
|
|
82574
|
+
VDD: 1.1,
|
|
82575
|
+
AGND: 1.1,
|
|
82576
|
+
V5: 1.1,
|
|
82577
|
+
V3: 1.1,
|
|
82578
|
+
V1: 1.1,
|
|
82579
|
+
neg: 0.9,
|
|
82580
|
+
pos: 0.9,
|
|
82581
|
+
pin: 0.5,
|
|
82582
|
+
left: 0.3,
|
|
82583
|
+
right: 0.3
|
|
82584
|
+
};
|
|
82585
|
+
var wordQualityScoreEntries = Object.entries(wordQualityScore).sort((a, b) => b[1] - a[1]);
|
|
82586
|
+
var scorePhrase = (phrase) => {
|
|
82587
|
+
if (phrase.match(/\d+/)) {
|
|
82588
|
+
return 0.5;
|
|
82589
|
+
}
|
|
82590
|
+
for (const [word, score] of wordQualityScoreEntries) {
|
|
82591
|
+
if (phrase.includes(word)) {
|
|
82592
|
+
return score;
|
|
82593
|
+
}
|
|
82594
|
+
}
|
|
82595
|
+
return 1;
|
|
82596
|
+
};
|
|
82597
|
+
var getReadableNameForPin = ({
|
|
82598
|
+
circuitJson,
|
|
82599
|
+
source_port_id
|
|
82600
|
+
}) => {
|
|
82601
|
+
const source_ports = su(circuitJson).source_port.list();
|
|
82602
|
+
const source_components = su(circuitJson).source_component.list();
|
|
82603
|
+
const port = source_ports.find((p) => p.source_port_id === source_port_id);
|
|
82604
|
+
if (!port)
|
|
82605
|
+
return "";
|
|
82606
|
+
const component = source_components.find((c) => c.source_component_id === port.source_component_id);
|
|
82607
|
+
if (!component)
|
|
82608
|
+
return "";
|
|
82609
|
+
const isPositive = port.port_hints?.some((hint) => ["anode", "pos", "positive"].includes(hint.toLowerCase()));
|
|
82610
|
+
const isNegative = port.port_hints?.some((hint) => ["cathode", "neg", "negative"].includes(hint.toLowerCase()));
|
|
82611
|
+
const mainPinName = port.name ? port.name : `Pin${port.pin_number}`;
|
|
82612
|
+
const additionalPinLabels = [];
|
|
82613
|
+
if (isPositive && component.ftype !== "simple_resistor") {
|
|
82614
|
+
additionalPinLabels.push("+");
|
|
82615
|
+
} else if (isNegative && component.ftype !== "simple_resistor") {
|
|
82616
|
+
additionalPinLabels.push("-");
|
|
82617
|
+
}
|
|
82618
|
+
for (const port_hint of port.port_hints ?? []) {
|
|
82619
|
+
if (port_hint === mainPinName)
|
|
82620
|
+
continue;
|
|
82621
|
+
const score = scorePhrase(port_hint);
|
|
82622
|
+
if (score > 1) {
|
|
82623
|
+
additionalPinLabels.push(port_hint);
|
|
82624
|
+
}
|
|
82625
|
+
}
|
|
82626
|
+
const displayValue = component.display_value ? ` (${component.display_value})` : "";
|
|
82627
|
+
return `${component.name} ${mainPinName}${additionalPinLabels.length > 0 ? ` (${additionalPinLabels.join(",")})` : ""}${displayValue}`;
|
|
82628
|
+
};
|
|
82629
|
+
var scoreComponentOrder = (component) => {
|
|
82630
|
+
if (!("ftype" in component))
|
|
82631
|
+
return 0;
|
|
82632
|
+
if (component.ftype === "simple_resistor")
|
|
82633
|
+
return 0;
|
|
82634
|
+
if (component.ftype === "simple_capacitor")
|
|
82635
|
+
return 1;
|
|
82636
|
+
return 2;
|
|
82637
|
+
};
|
|
82638
|
+
var generateNetName = ({
|
|
82639
|
+
circuitJson,
|
|
82640
|
+
connectedIds
|
|
82641
|
+
}) => {
|
|
82642
|
+
const all_source_components = su2(circuitJson).source_component.list();
|
|
82643
|
+
const sourceComponentIdToScore = /* @__PURE__ */ new Map;
|
|
82644
|
+
for (const component of all_source_components) {
|
|
82645
|
+
sourceComponentIdToScore.set(component.source_component_id, scoreComponentOrder(component));
|
|
82646
|
+
}
|
|
82647
|
+
all_source_components.sort((a, b) => sourceComponentIdToScore.get(b.source_component_id) - sourceComponentIdToScore.get(a.source_component_id));
|
|
82648
|
+
const all_source_ports = su2(circuitJson).source_port.list().sort((a, b) => sourceComponentIdToScore.get(b.source_component_id) - sourceComponentIdToScore.get(a.source_component_id));
|
|
82649
|
+
const all_source_nets = su2(circuitJson).source_net.list();
|
|
82650
|
+
const all_source_traces = su2(circuitJson).source_trace.list();
|
|
82651
|
+
const ports = all_source_ports.filter((p) => connectedIds.includes(p.source_port_id));
|
|
82652
|
+
const nets = all_source_nets.filter((n) => connectedIds.includes(n.source_net_id));
|
|
82653
|
+
const traces = all_source_traces.filter((t) => connectedIds.includes(t.source_trace_id));
|
|
82654
|
+
const possibleNames = ports.flatMap((p) => Array.from(/* @__PURE__ */ new Set([...p.name ? [p.name] : [], ...p.port_hints ?? []]))).concat(nets.map((n) => n.name));
|
|
82655
|
+
const phrases = possibleNames.map((name) => ({
|
|
82656
|
+
name,
|
|
82657
|
+
score: scorePhrase(name)
|
|
82658
|
+
}));
|
|
82659
|
+
const bestPortName = phrases.sort((a, b) => b.score - a.score)[0].name;
|
|
82660
|
+
const bestPort = ports.find((p) => p.name === bestPortName || p.port_hints?.includes(bestPortName));
|
|
82661
|
+
const componentWithBestPort = all_source_components.find((c) => c.source_component_id === bestPort?.source_component_id);
|
|
82662
|
+
return [componentWithBestPort?.name, bestPortName].filter(Boolean).join("_");
|
|
82663
|
+
};
|
|
82664
|
+
var convertCircuitJsonToReadableNetlist = (circuitJson) => {
|
|
82665
|
+
const connectivityMap = getFullConnectivityMapFromCircuitJson(circuitJson.filter((e) => e.type.startsWith("source_")));
|
|
82666
|
+
const netMap = connectivityMap.netMap;
|
|
82667
|
+
const source_ports = su3(circuitJson).source_port.list();
|
|
82668
|
+
const source_components = su3(circuitJson).source_component.list();
|
|
82669
|
+
const source_nets = su3(circuitJson).source_net.list();
|
|
82670
|
+
const source_traces = su3(circuitJson).source_trace.list();
|
|
82671
|
+
const netlist = [];
|
|
82672
|
+
netlist.push("COMPONENTS:");
|
|
82673
|
+
for (const component of source_components) {
|
|
82674
|
+
let componentDescription = "";
|
|
82675
|
+
const cadComponent = su3(circuitJson).cad_component.getWhere({
|
|
82676
|
+
source_component_id: component.source_component_id
|
|
82677
|
+
});
|
|
82678
|
+
const footprint = cadComponent?.footprinter_string;
|
|
82679
|
+
if (component.ftype === "simple_resistor") {
|
|
82680
|
+
componentDescription = `${component.display_resistance}${footprint ? ` ${footprint}` : ""} resistor`;
|
|
82681
|
+
} else if (component.ftype === "simple_capacitor") {
|
|
82682
|
+
componentDescription = `${component.display_capacitance}${footprint ? ` ${footprint}` : ""} capacitor`;
|
|
82683
|
+
} else if (component.ftype === "simple_chip") {
|
|
82684
|
+
const manufacturerPartNumber = component.manufacturer_part_number;
|
|
82685
|
+
componentDescription = [manufacturerPartNumber, footprint].filter(Boolean).join(", ");
|
|
82686
|
+
} else {
|
|
82687
|
+
componentDescription = [component.name, component.type].filter(Boolean).join(", ");
|
|
82688
|
+
}
|
|
82689
|
+
netlist.push(` - ${component.name}: ${componentDescription}`);
|
|
82690
|
+
}
|
|
82691
|
+
netlist.push("");
|
|
82692
|
+
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
82693
|
+
const net = source_nets.find((n) => connectedIds.includes(n.source_net_id));
|
|
82694
|
+
let netName = net?.name;
|
|
82695
|
+
if (!netName) {
|
|
82696
|
+
netName = generateNetName({ circuitJson, connectedIds });
|
|
82697
|
+
}
|
|
82698
|
+
const connectedPortCount = connectedIds.filter((id) => id.startsWith("source_port")).length;
|
|
82699
|
+
if (connectedPortCount <= 1)
|
|
82700
|
+
continue;
|
|
82701
|
+
netlist.push(`NET: ${netName}`);
|
|
82702
|
+
for (const id of connectedIds) {
|
|
82703
|
+
const pinName = getReadableNameForPin({
|
|
82704
|
+
circuitJson,
|
|
82705
|
+
source_port_id: id
|
|
82706
|
+
});
|
|
82707
|
+
if (pinName) {
|
|
82708
|
+
netlist.push(` - ${pinName}`);
|
|
82709
|
+
}
|
|
82710
|
+
}
|
|
82711
|
+
netlist.push("");
|
|
82712
|
+
}
|
|
82713
|
+
let hasEmptyNets = false;
|
|
82714
|
+
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
82715
|
+
const connectedPortCount = connectedIds.filter((id) => id.startsWith("source_port")).length;
|
|
82716
|
+
if (connectedPortCount === 1) {
|
|
82717
|
+
if (!hasEmptyNets) {
|
|
82718
|
+
netlist.push("");
|
|
82719
|
+
netlist.push("EMPTY NET PINS:");
|
|
82720
|
+
hasEmptyNets = true;
|
|
82721
|
+
}
|
|
82722
|
+
const source_port_id = netMap[netId].find((id) => id.startsWith("source_port"));
|
|
82723
|
+
const pinName = getReadableNameForPin({
|
|
82724
|
+
circuitJson,
|
|
82725
|
+
source_port_id
|
|
82726
|
+
});
|
|
82727
|
+
if (pinName) {
|
|
82728
|
+
netlist.push(` - ${pinName}`);
|
|
82729
|
+
}
|
|
82730
|
+
}
|
|
82731
|
+
}
|
|
82732
|
+
const portIdToNetNames = {};
|
|
82733
|
+
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
82734
|
+
const portIds = connectedIds.filter((id) => id.startsWith("source_port"));
|
|
82735
|
+
if (portIds.length === 0)
|
|
82736
|
+
continue;
|
|
82737
|
+
const net = source_nets.find((n) => connectedIds.includes(n.source_net_id));
|
|
82738
|
+
let netName = net?.name;
|
|
82739
|
+
if (!netName) {
|
|
82740
|
+
netName = generateNetName({ circuitJson, connectedIds });
|
|
82741
|
+
}
|
|
82742
|
+
for (const portId of portIds) {
|
|
82743
|
+
if (!portIdToNetNames[portId])
|
|
82744
|
+
portIdToNetNames[portId] = [];
|
|
82745
|
+
portIdToNetNames[portId].push(netName);
|
|
82746
|
+
}
|
|
82747
|
+
}
|
|
82748
|
+
if (source_components.length > 0) {
|
|
82749
|
+
netlist.push("");
|
|
82750
|
+
netlist.push("COMPONENT_PINS:");
|
|
82751
|
+
for (const component of source_components) {
|
|
82752
|
+
const cadComponent = su3(circuitJson).cad_component.getWhere({
|
|
82753
|
+
source_component_id: component.source_component_id
|
|
82754
|
+
});
|
|
82755
|
+
const footprint = cadComponent?.footprinter_string;
|
|
82756
|
+
let header = component.name;
|
|
82757
|
+
if (component.ftype === "simple_resistor") {
|
|
82758
|
+
header = `${component.name} (${component.display_resistance} ${footprint})`;
|
|
82759
|
+
} else if (component.ftype === "simple_capacitor") {
|
|
82760
|
+
header = `${component.name} (${component.display_capacitance} ${footprint})`;
|
|
82761
|
+
} else if (component.manufacturer_part_number) {
|
|
82762
|
+
header = `${component.name} (${component.manufacturer_part_number})`;
|
|
82763
|
+
}
|
|
82764
|
+
netlist.push(header);
|
|
82765
|
+
const ports = source_ports.filter((p) => p.source_component_id === component.source_component_id).sort((a, b) => (a.pin_number ?? 0) - (b.pin_number ?? 0));
|
|
82766
|
+
for (const port of ports) {
|
|
82767
|
+
const mainPin = port.pin_number !== undefined ? `pin${port.pin_number}` : port.name;
|
|
82768
|
+
const aliases = [];
|
|
82769
|
+
if (port.name && port.name !== mainPin)
|
|
82770
|
+
aliases.push(port.name);
|
|
82771
|
+
for (const hint of port.port_hints ?? []) {
|
|
82772
|
+
if (hint === String(port.pin_number))
|
|
82773
|
+
continue;
|
|
82774
|
+
if (hint !== mainPin && hint !== port.name)
|
|
82775
|
+
aliases.push(hint);
|
|
82776
|
+
}
|
|
82777
|
+
const aliasPart = aliases.length > 0 ? `(${Array.from(new Set(aliases)).join(", ")})` : "";
|
|
82778
|
+
const nets = portIdToNetNames[port.source_port_id] ?? [];
|
|
82779
|
+
const netsPart = nets.length > 0 ? `NETS(${nets.join(", ")})` : "NOT_CONNECTED";
|
|
82780
|
+
netlist.push(`- ${mainPin}${aliasPart}: ${netsPart}`);
|
|
82781
|
+
}
|
|
82782
|
+
netlist.push("");
|
|
82783
|
+
}
|
|
82784
|
+
}
|
|
82785
|
+
return netlist.join(`
|
|
82786
|
+
`);
|
|
82787
|
+
};
|
|
82788
|
+
|
|
82557
82789
|
// cli/check/netlist/register.ts
|
|
82790
|
+
import path40 from "node:path";
|
|
82791
|
+
var resolveInputFilePath = async (file) => {
|
|
82792
|
+
if (file) {
|
|
82793
|
+
return path40.isAbsolute(file) ? file : path40.resolve(process.cwd(), file);
|
|
82794
|
+
}
|
|
82795
|
+
const entrypoint = await getEntrypoint({
|
|
82796
|
+
projectDir: process.cwd()
|
|
82797
|
+
});
|
|
82798
|
+
if (!entrypoint) {
|
|
82799
|
+
throw new Error("No input file provided and no entrypoint found");
|
|
82800
|
+
}
|
|
82801
|
+
return entrypoint;
|
|
82802
|
+
};
|
|
82803
|
+
var checkNetlist = async (file) => {
|
|
82804
|
+
const resolvedInputFilePath = await resolveInputFilePath(file);
|
|
82805
|
+
const completePlatformConfig = getCompletePlatformConfig({
|
|
82806
|
+
routingDrcChecksDisabled: true,
|
|
82807
|
+
placementDrcChecksDisabled: true
|
|
82808
|
+
});
|
|
82809
|
+
const { circuitJson } = await generateCircuitJson({
|
|
82810
|
+
filePath: resolvedInputFilePath,
|
|
82811
|
+
platformConfig: completePlatformConfig
|
|
82812
|
+
});
|
|
82813
|
+
const typedCircuitJson = circuitJson;
|
|
82814
|
+
const diagnostics = analyzeCircuitJson(typedCircuitJson);
|
|
82815
|
+
const readableNetlist = convertCircuitJsonToReadableNetlist(typedCircuitJson);
|
|
82816
|
+
const diagnosticsLines = [
|
|
82817
|
+
`Errors: ${diagnostics.errors.length}`,
|
|
82818
|
+
`Warnings: ${diagnostics.warnings.length}`
|
|
82819
|
+
];
|
|
82820
|
+
if (diagnostics.errors.length > 0) {
|
|
82821
|
+
diagnosticsLines.push(...diagnostics.errors.map((err) => `- ${err.type}: ${err.message ?? ""}`));
|
|
82822
|
+
}
|
|
82823
|
+
return `${diagnosticsLines.join(`
|
|
82824
|
+
`)}
|
|
82825
|
+
|
|
82826
|
+
Readable Netlist:
|
|
82827
|
+
${readableNetlist}`;
|
|
82828
|
+
};
|
|
82558
82829
|
var registerCheckNetlist = (program2) => {
|
|
82559
|
-
program2.commands.find((c) => c.name() === "check").command("netlist").description("Partially build and validate the netlist").argument("[
|
|
82560
|
-
|
|
82830
|
+
program2.commands.find((c) => c.name() === "check").command("netlist").description("Partially build and validate the netlist").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
82831
|
+
try {
|
|
82832
|
+
const output = await checkNetlist(file);
|
|
82833
|
+
console.log(output);
|
|
82834
|
+
} catch (error) {
|
|
82835
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
82836
|
+
process.exit(1);
|
|
82837
|
+
}
|
|
82561
82838
|
});
|
|
82562
82839
|
};
|
|
82563
82840
|
|
|
82564
82841
|
// cli/check/placement/register.ts
|
|
82565
82842
|
import fs38 from "node:fs";
|
|
82566
|
-
import
|
|
82843
|
+
import path41 from "node:path";
|
|
82567
82844
|
|
|
82568
82845
|
// node_modules/@tscircuit/circuit-json-placement-analysis/dist/index.js
|
|
82569
82846
|
var CENTER_ANCHOR = "center";
|
|
@@ -82878,9 +83155,9 @@ var isPrebuiltCircuitJsonFile = (filePath) => {
|
|
|
82878
83155
|
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
82879
83156
|
return normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
82880
83157
|
};
|
|
82881
|
-
var
|
|
83158
|
+
var resolveInputFilePath2 = async (file) => {
|
|
82882
83159
|
if (file) {
|
|
82883
|
-
return
|
|
83160
|
+
return path41.isAbsolute(file) ? file : path41.resolve(process.cwd(), file);
|
|
82884
83161
|
}
|
|
82885
83162
|
const entrypoint = await getEntrypoint({
|
|
82886
83163
|
projectDir: process.cwd()
|
|
@@ -82906,7 +83183,7 @@ var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
|
82906
83183
|
return circuitJson;
|
|
82907
83184
|
};
|
|
82908
83185
|
var checkPlacement = async (file, refdes) => {
|
|
82909
|
-
const resolvedInputFilePath = await
|
|
83186
|
+
const resolvedInputFilePath = await resolveInputFilePath2(file);
|
|
82910
83187
|
const circuitJson = await getCircuitJsonForPlacementCheck(resolvedInputFilePath);
|
|
82911
83188
|
const analysis = refdes ? analyzeComponentPlacement(circuitJson, refdes) : analyzeAllPlacements(circuitJson);
|
|
82912
83189
|
return analysis.getString();
|
|
@@ -82937,25 +83214,25 @@ var registerCheckRouting = (program2) => {
|
|
|
82937
83214
|
|
|
82938
83215
|
// cli/clone/register.ts
|
|
82939
83216
|
import * as fs41 from "node:fs";
|
|
82940
|
-
import * as
|
|
83217
|
+
import * as path44 from "node:path";
|
|
82941
83218
|
|
|
82942
83219
|
// cli/clone/clone-bug-report.ts
|
|
82943
83220
|
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
82944
83221
|
var import_prompts4 = __toESM2(require_prompts3(), 1);
|
|
82945
83222
|
import * as fs40 from "node:fs";
|
|
82946
|
-
import * as
|
|
83223
|
+
import * as path43 from "node:path";
|
|
82947
83224
|
|
|
82948
83225
|
// cli/clone/handle-existing-directory.ts
|
|
82949
83226
|
var import_prompts3 = __toESM2(require_prompts3(), 1);
|
|
82950
83227
|
import * as fs39 from "node:fs";
|
|
82951
|
-
import * as
|
|
83228
|
+
import * as path42 from "node:path";
|
|
82952
83229
|
var handleExistingDirectory = async (dirPath) => {
|
|
82953
83230
|
if (!fs39.existsSync(dirPath))
|
|
82954
83231
|
return;
|
|
82955
83232
|
const response = await import_prompts3.default({
|
|
82956
83233
|
type: "select",
|
|
82957
83234
|
name: "action",
|
|
82958
|
-
message: `Directory "${
|
|
83235
|
+
message: `Directory "${path42.basename(dirPath)}" already exists. What would you like to do?`,
|
|
82959
83236
|
choices: [
|
|
82960
83237
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
82961
83238
|
{
|
|
@@ -82996,12 +83273,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
82996
83273
|
return commonSegments.join("/");
|
|
82997
83274
|
};
|
|
82998
83275
|
var sanitizeRelativePath = (relativePath) => {
|
|
82999
|
-
const normalizedPath =
|
|
83276
|
+
const normalizedPath = path43.normalize(relativePath);
|
|
83000
83277
|
if (!normalizedPath)
|
|
83001
83278
|
return null;
|
|
83002
|
-
if (
|
|
83279
|
+
if (path43.isAbsolute(normalizedPath))
|
|
83003
83280
|
return null;
|
|
83004
|
-
const segments = normalizedPath.split(
|
|
83281
|
+
const segments = normalizedPath.split(path43.sep);
|
|
83005
83282
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
83006
83283
|
return null;
|
|
83007
83284
|
}
|
|
@@ -83016,7 +83293,7 @@ var cloneBugReport = async ({
|
|
|
83016
83293
|
console.error("Bug report ID must not be empty.");
|
|
83017
83294
|
process.exit(1);
|
|
83018
83295
|
}
|
|
83019
|
-
let dirPath =
|
|
83296
|
+
let dirPath = path43.resolve(`bug-report-${trimmedBugReportId}`);
|
|
83020
83297
|
await handleExistingDirectory(dirPath);
|
|
83021
83298
|
const ky2 = getRegistryApiKy();
|
|
83022
83299
|
let zipBuffer;
|
|
@@ -83046,25 +83323,25 @@ var cloneBugReport = async ({
|
|
|
83046
83323
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
83047
83324
|
continue;
|
|
83048
83325
|
}
|
|
83049
|
-
const fullPath =
|
|
83050
|
-
fs40.mkdirSync(
|
|
83326
|
+
const fullPath = path43.join(dirPath, sanitizedRelativePath);
|
|
83327
|
+
fs40.mkdirSync(path43.dirname(fullPath), { recursive: true });
|
|
83051
83328
|
const fileContent = await entry.async("nodebuffer");
|
|
83052
83329
|
fs40.writeFileSync(fullPath, fileContent);
|
|
83053
83330
|
}
|
|
83054
|
-
const packageJsonPath =
|
|
83331
|
+
const packageJsonPath = path43.join(dirPath, "package.json");
|
|
83055
83332
|
if (fs40.existsSync(packageJsonPath)) {
|
|
83056
83333
|
try {
|
|
83057
83334
|
const packageJson = JSON.parse(fs40.readFileSync(packageJsonPath, "utf-8"));
|
|
83058
83335
|
const packageName = packageJson?.name;
|
|
83059
83336
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
83060
83337
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
83061
|
-
const suggestedDirPath =
|
|
83338
|
+
const suggestedDirPath = path43.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
83062
83339
|
if (suggestedDirPath !== dirPath) {
|
|
83063
83340
|
const response = await import_prompts4.default({
|
|
83064
83341
|
type: "confirm",
|
|
83065
83342
|
name: "rename",
|
|
83066
83343
|
initial: true,
|
|
83067
|
-
message: `Rename the directory to "${
|
|
83344
|
+
message: `Rename the directory to "${path43.basename(suggestedDirPath)}"?`
|
|
83068
83345
|
});
|
|
83069
83346
|
if (response.rename) {
|
|
83070
83347
|
await handleExistingDirectory(suggestedDirPath);
|
|
@@ -83077,9 +83354,9 @@ var cloneBugReport = async ({
|
|
|
83077
83354
|
console.warn("Unable to read package name for renaming:", error);
|
|
83078
83355
|
}
|
|
83079
83356
|
}
|
|
83080
|
-
fs40.writeFileSync(
|
|
83357
|
+
fs40.writeFileSync(path43.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83081
83358
|
generateTsConfig(dirPath);
|
|
83082
|
-
const relativeDirPath =
|
|
83359
|
+
const relativeDirPath = path43.relative(originalCwd, dirPath);
|
|
83083
83360
|
console.log(kleur_default.green(`
|
|
83084
83361
|
Successfully cloned bug report to:`));
|
|
83085
83362
|
console.log(` ${dirPath}/
|
|
@@ -83118,7 +83395,7 @@ var registerClone = (program2) => {
|
|
|
83118
83395
|
const [, author, packageName] = match;
|
|
83119
83396
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
83120
83397
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
83121
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
83398
|
+
const dirPath = userSettingToIncludeAuthor ? path44.resolve(`${author}.${packageName}`) : path44.resolve(packageName);
|
|
83122
83399
|
await handleExistingDirectory(dirPath);
|
|
83123
83400
|
const ky2 = getRegistryApiKy();
|
|
83124
83401
|
let packageFileList = {
|
|
@@ -83144,8 +83421,8 @@ var registerClone = (program2) => {
|
|
|
83144
83421
|
const filePath = fileInfo.file_path.replace(/^\/+/, "");
|
|
83145
83422
|
if (!filePath)
|
|
83146
83423
|
continue;
|
|
83147
|
-
const fullPath =
|
|
83148
|
-
fs41.mkdirSync(
|
|
83424
|
+
const fullPath = path44.join(dirPath, filePath);
|
|
83425
|
+
fs41.mkdirSync(path44.dirname(fullPath), { recursive: true });
|
|
83149
83426
|
try {
|
|
83150
83427
|
const fileContent = await ky2.get("package_files/get", {
|
|
83151
83428
|
searchParams: {
|
|
@@ -83171,10 +83448,10 @@ var registerClone = (program2) => {
|
|
|
83171
83448
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
83172
83449
|
}
|
|
83173
83450
|
}
|
|
83174
|
-
fs41.writeFileSync(
|
|
83451
|
+
fs41.writeFileSync(path44.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83175
83452
|
generateTsConfig(dirPath);
|
|
83176
83453
|
await setupTsciProject(dirPath);
|
|
83177
|
-
const relativeDirPath =
|
|
83454
|
+
const relativeDirPath = path44.relative(originalCwd, dirPath);
|
|
83178
83455
|
console.log(kleur_default.green(`
|
|
83179
83456
|
Successfully cloned to:`));
|
|
83180
83457
|
console.log(` ${dirPath}/
|
|
@@ -83242,7 +83519,7 @@ var registerConfigSet = (program2) => {
|
|
|
83242
83519
|
|
|
83243
83520
|
// cli/convert/register.ts
|
|
83244
83521
|
import fs42 from "node:fs/promises";
|
|
83245
|
-
import
|
|
83522
|
+
import path45 from "node:path";
|
|
83246
83523
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
83247
83524
|
|
|
83248
83525
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -83271,14 +83548,14 @@ var mmStr = (n) => {
|
|
|
83271
83548
|
};
|
|
83272
83549
|
|
|
83273
83550
|
// node_modules/circuit-json-to-tscircuit/dist/chunk-EX2F3BMQ.js
|
|
83274
|
-
import { su } from "@tscircuit/soup-util";
|
|
83551
|
+
import { su as su4 } from "@tscircuit/soup-util";
|
|
83275
83552
|
var generateFootprintTsx = (circuitJson) => {
|
|
83276
|
-
const holes =
|
|
83277
|
-
const platedHoles =
|
|
83278
|
-
const smtPads =
|
|
83279
|
-
const silkscreenPaths =
|
|
83280
|
-
const fabricationNotePaths =
|
|
83281
|
-
const silkscreenTexts =
|
|
83553
|
+
const holes = su4(circuitJson).pcb_hole.list();
|
|
83554
|
+
const platedHoles = su4(circuitJson).pcb_plated_hole.list();
|
|
83555
|
+
const smtPads = su4(circuitJson).pcb_smtpad.list();
|
|
83556
|
+
const silkscreenPaths = su4(circuitJson).pcb_silkscreen_path.list();
|
|
83557
|
+
const fabricationNotePaths = su4(circuitJson).pcb_fabrication_note_path.list();
|
|
83558
|
+
const silkscreenTexts = su4(circuitJson).pcb_silkscreen_text.list();
|
|
83282
83559
|
const elementStrings = [];
|
|
83283
83560
|
for (const hole of holes) {
|
|
83284
83561
|
if (hole.hole_shape === "circle") {
|
|
@@ -83363,14 +83640,14 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
83363
83640
|
var registerConvert = (program2) => {
|
|
83364
83641
|
program2.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) => {
|
|
83365
83642
|
try {
|
|
83366
|
-
const inputPath =
|
|
83643
|
+
const inputPath = path45.resolve(file);
|
|
83367
83644
|
const modContent = await fs42.readFile(inputPath, "utf-8");
|
|
83368
83645
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
83369
|
-
const componentName = options.name ??
|
|
83646
|
+
const componentName = options.name ?? path45.basename(inputPath, ".kicad_mod");
|
|
83370
83647
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
83371
83648
|
componentName
|
|
83372
83649
|
});
|
|
83373
|
-
const outputPath = options.output ?
|
|
83650
|
+
const outputPath = options.output ? path45.resolve(options.output) : path45.join(path45.dirname(inputPath), `${componentName}.tsx`);
|
|
83374
83651
|
await fs42.writeFile(outputPath, tsx);
|
|
83375
83652
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
83376
83653
|
} catch (error) {
|
|
@@ -83383,11 +83660,11 @@ var registerConvert = (program2) => {
|
|
|
83383
83660
|
// cli/dev/register.ts
|
|
83384
83661
|
import * as fs49 from "node:fs";
|
|
83385
83662
|
import * as net from "node:net";
|
|
83386
|
-
import * as
|
|
83663
|
+
import * as path53 from "node:path";
|
|
83387
83664
|
|
|
83388
83665
|
// cli/dev/DevServer.ts
|
|
83389
83666
|
import fs47 from "node:fs";
|
|
83390
|
-
import
|
|
83667
|
+
import path51 from "node:path";
|
|
83391
83668
|
|
|
83392
83669
|
// node_modules/chokidar/esm/index.js
|
|
83393
83670
|
import { stat as statcb } from "fs";
|
|
@@ -83466,7 +83743,7 @@ class ReaddirpStream extends Readable {
|
|
|
83466
83743
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
83467
83744
|
const statMethod = opts.lstat ? lstat : stat;
|
|
83468
83745
|
if (wantBigintFsStats) {
|
|
83469
|
-
this._stat = (
|
|
83746
|
+
this._stat = (path46) => statMethod(path46, { bigint: true });
|
|
83470
83747
|
} else {
|
|
83471
83748
|
this._stat = statMethod;
|
|
83472
83749
|
}
|
|
@@ -83491,8 +83768,8 @@ class ReaddirpStream extends Readable {
|
|
|
83491
83768
|
const par = this.parent;
|
|
83492
83769
|
const fil = par && par.files;
|
|
83493
83770
|
if (fil && fil.length > 0) {
|
|
83494
|
-
const { path:
|
|
83495
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
83771
|
+
const { path: path46, depth } = par;
|
|
83772
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path46));
|
|
83496
83773
|
const awaited = await Promise.all(slice);
|
|
83497
83774
|
for (const entry of awaited) {
|
|
83498
83775
|
if (!entry)
|
|
@@ -83532,20 +83809,20 @@ class ReaddirpStream extends Readable {
|
|
|
83532
83809
|
this.reading = false;
|
|
83533
83810
|
}
|
|
83534
83811
|
}
|
|
83535
|
-
async _exploreDir(
|
|
83812
|
+
async _exploreDir(path46, depth) {
|
|
83536
83813
|
let files;
|
|
83537
83814
|
try {
|
|
83538
|
-
files = await readdir(
|
|
83815
|
+
files = await readdir(path46, this._rdOptions);
|
|
83539
83816
|
} catch (error) {
|
|
83540
83817
|
this._onError(error);
|
|
83541
83818
|
}
|
|
83542
|
-
return { files, depth, path:
|
|
83819
|
+
return { files, depth, path: path46 };
|
|
83543
83820
|
}
|
|
83544
|
-
async _formatEntry(dirent,
|
|
83821
|
+
async _formatEntry(dirent, path46) {
|
|
83545
83822
|
let entry;
|
|
83546
83823
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
83547
83824
|
try {
|
|
83548
|
-
const fullPath = presolve(pjoin(
|
|
83825
|
+
const fullPath = presolve(pjoin(path46, basename4));
|
|
83549
83826
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
|
|
83550
83827
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
83551
83828
|
} catch (err) {
|
|
@@ -83943,16 +84220,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
83943
84220
|
};
|
|
83944
84221
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
83945
84222
|
var FsWatchInstances = new Map;
|
|
83946
|
-
function createFsWatchInstance(
|
|
84223
|
+
function createFsWatchInstance(path46, options, listener, errHandler, emitRaw) {
|
|
83947
84224
|
const handleEvent = (rawEvent, evPath) => {
|
|
83948
|
-
listener(
|
|
83949
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
83950
|
-
if (evPath &&
|
|
83951
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
84225
|
+
listener(path46);
|
|
84226
|
+
emitRaw(rawEvent, evPath, { watchedPath: path46 });
|
|
84227
|
+
if (evPath && path46 !== evPath) {
|
|
84228
|
+
fsWatchBroadcast(sysPath.resolve(path46, evPath), KEY_LISTENERS, sysPath.join(path46, evPath));
|
|
83952
84229
|
}
|
|
83953
84230
|
};
|
|
83954
84231
|
try {
|
|
83955
|
-
return fs_watch(
|
|
84232
|
+
return fs_watch(path46, {
|
|
83956
84233
|
persistent: options.persistent
|
|
83957
84234
|
}, handleEvent);
|
|
83958
84235
|
} catch (error) {
|
|
@@ -83968,12 +84245,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
83968
84245
|
listener(val1, val2, val3);
|
|
83969
84246
|
});
|
|
83970
84247
|
};
|
|
83971
|
-
var setFsWatchListener = (
|
|
84248
|
+
var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
83972
84249
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
83973
84250
|
let cont = FsWatchInstances.get(fullPath);
|
|
83974
84251
|
let watcher;
|
|
83975
84252
|
if (!options.persistent) {
|
|
83976
|
-
watcher = createFsWatchInstance(
|
|
84253
|
+
watcher = createFsWatchInstance(path46, options, listener, errHandler, rawEmitter);
|
|
83977
84254
|
if (!watcher)
|
|
83978
84255
|
return;
|
|
83979
84256
|
return watcher.close.bind(watcher);
|
|
@@ -83983,7 +84260,7 @@ var setFsWatchListener = (path45, fullPath, options, handlers) => {
|
|
|
83983
84260
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
83984
84261
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
83985
84262
|
} else {
|
|
83986
|
-
watcher = createFsWatchInstance(
|
|
84263
|
+
watcher = createFsWatchInstance(path46, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
83987
84264
|
if (!watcher)
|
|
83988
84265
|
return;
|
|
83989
84266
|
watcher.on(EV.ERROR, async (error) => {
|
|
@@ -83992,7 +84269,7 @@ var setFsWatchListener = (path45, fullPath, options, handlers) => {
|
|
|
83992
84269
|
cont.watcherUnusable = true;
|
|
83993
84270
|
if (isWindows && error.code === "EPERM") {
|
|
83994
84271
|
try {
|
|
83995
|
-
const fd = await open(
|
|
84272
|
+
const fd = await open(path46, "r");
|
|
83996
84273
|
await fd.close();
|
|
83997
84274
|
broadcastErr(error);
|
|
83998
84275
|
} catch (err) {}
|
|
@@ -84022,7 +84299,7 @@ var setFsWatchListener = (path45, fullPath, options, handlers) => {
|
|
|
84022
84299
|
};
|
|
84023
84300
|
};
|
|
84024
84301
|
var FsWatchFileInstances = new Map;
|
|
84025
|
-
var setFsWatchFileListener = (
|
|
84302
|
+
var setFsWatchFileListener = (path46, fullPath, options, handlers) => {
|
|
84026
84303
|
const { listener, rawEmitter } = handlers;
|
|
84027
84304
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
84028
84305
|
const copts = cont && cont.options;
|
|
@@ -84044,7 +84321,7 @@ var setFsWatchFileListener = (path45, fullPath, options, handlers) => {
|
|
|
84044
84321
|
});
|
|
84045
84322
|
const currmtime = curr.mtimeMs;
|
|
84046
84323
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
84047
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
84324
|
+
foreach(cont.listeners, (listener2) => listener2(path46, curr));
|
|
84048
84325
|
}
|
|
84049
84326
|
})
|
|
84050
84327
|
};
|
|
@@ -84067,13 +84344,13 @@ class NodeFsHandler {
|
|
|
84067
84344
|
this.fsw = fsW;
|
|
84068
84345
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
84069
84346
|
}
|
|
84070
|
-
_watchWithNodeFs(
|
|
84347
|
+
_watchWithNodeFs(path46, listener) {
|
|
84071
84348
|
const opts = this.fsw.options;
|
|
84072
|
-
const directory = sysPath.dirname(
|
|
84073
|
-
const basename5 = sysPath.basename(
|
|
84349
|
+
const directory = sysPath.dirname(path46);
|
|
84350
|
+
const basename5 = sysPath.basename(path46);
|
|
84074
84351
|
const parent = this.fsw._getWatchedDir(directory);
|
|
84075
84352
|
parent.add(basename5);
|
|
84076
|
-
const absolutePath = sysPath.resolve(
|
|
84353
|
+
const absolutePath = sysPath.resolve(path46);
|
|
84077
84354
|
const options = {
|
|
84078
84355
|
persistent: opts.persistent
|
|
84079
84356
|
};
|
|
@@ -84083,12 +84360,12 @@ class NodeFsHandler {
|
|
|
84083
84360
|
if (opts.usePolling) {
|
|
84084
84361
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
84085
84362
|
options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
|
|
84086
|
-
closer = setFsWatchFileListener(
|
|
84363
|
+
closer = setFsWatchFileListener(path46, absolutePath, options, {
|
|
84087
84364
|
listener,
|
|
84088
84365
|
rawEmitter: this.fsw._emitRaw
|
|
84089
84366
|
});
|
|
84090
84367
|
} else {
|
|
84091
|
-
closer = setFsWatchListener(
|
|
84368
|
+
closer = setFsWatchListener(path46, absolutePath, options, {
|
|
84092
84369
|
listener,
|
|
84093
84370
|
errHandler: this._boundHandleError,
|
|
84094
84371
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -84106,7 +84383,7 @@ class NodeFsHandler {
|
|
|
84106
84383
|
let prevStats = stats;
|
|
84107
84384
|
if (parent.has(basename5))
|
|
84108
84385
|
return;
|
|
84109
|
-
const listener = async (
|
|
84386
|
+
const listener = async (path46, newStats) => {
|
|
84110
84387
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
84111
84388
|
return;
|
|
84112
84389
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -84120,11 +84397,11 @@ class NodeFsHandler {
|
|
|
84120
84397
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
84121
84398
|
}
|
|
84122
84399
|
if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
|
|
84123
|
-
this.fsw._closeFile(
|
|
84400
|
+
this.fsw._closeFile(path46);
|
|
84124
84401
|
prevStats = newStats2;
|
|
84125
84402
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
84126
84403
|
if (closer2)
|
|
84127
|
-
this.fsw._addPathCloser(
|
|
84404
|
+
this.fsw._addPathCloser(path46, closer2);
|
|
84128
84405
|
} else {
|
|
84129
84406
|
prevStats = newStats2;
|
|
84130
84407
|
}
|
|
@@ -84148,7 +84425,7 @@ class NodeFsHandler {
|
|
|
84148
84425
|
}
|
|
84149
84426
|
return closer;
|
|
84150
84427
|
}
|
|
84151
|
-
async _handleSymlink(entry, directory,
|
|
84428
|
+
async _handleSymlink(entry, directory, path46, item) {
|
|
84152
84429
|
if (this.fsw.closed) {
|
|
84153
84430
|
return;
|
|
84154
84431
|
}
|
|
@@ -84158,7 +84435,7 @@ class NodeFsHandler {
|
|
|
84158
84435
|
this.fsw._incrReadyCount();
|
|
84159
84436
|
let linkPath;
|
|
84160
84437
|
try {
|
|
84161
|
-
linkPath = await fsrealpath(
|
|
84438
|
+
linkPath = await fsrealpath(path46);
|
|
84162
84439
|
} catch (e) {
|
|
84163
84440
|
this.fsw._emitReady();
|
|
84164
84441
|
return true;
|
|
@@ -84168,12 +84445,12 @@ class NodeFsHandler {
|
|
|
84168
84445
|
if (dir.has(item)) {
|
|
84169
84446
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
84170
84447
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84171
|
-
this.fsw._emit(EV.CHANGE,
|
|
84448
|
+
this.fsw._emit(EV.CHANGE, path46, entry.stats);
|
|
84172
84449
|
}
|
|
84173
84450
|
} else {
|
|
84174
84451
|
dir.add(item);
|
|
84175
84452
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84176
|
-
this.fsw._emit(EV.ADD,
|
|
84453
|
+
this.fsw._emit(EV.ADD, path46, entry.stats);
|
|
84177
84454
|
}
|
|
84178
84455
|
this.fsw._emitReady();
|
|
84179
84456
|
return true;
|
|
@@ -84202,9 +84479,9 @@ class NodeFsHandler {
|
|
|
84202
84479
|
return;
|
|
84203
84480
|
}
|
|
84204
84481
|
const item = entry.path;
|
|
84205
|
-
let
|
|
84482
|
+
let path46 = sysPath.join(directory, item);
|
|
84206
84483
|
current.add(item);
|
|
84207
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
84484
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path46, item)) {
|
|
84208
84485
|
return;
|
|
84209
84486
|
}
|
|
84210
84487
|
if (this.fsw.closed) {
|
|
@@ -84213,8 +84490,8 @@ class NodeFsHandler {
|
|
|
84213
84490
|
}
|
|
84214
84491
|
if (item === target || !target && !previous.has(item)) {
|
|
84215
84492
|
this.fsw._incrReadyCount();
|
|
84216
|
-
|
|
84217
|
-
this._addToNodeFs(
|
|
84493
|
+
path46 = sysPath.join(dir, sysPath.relative(dir, path46));
|
|
84494
|
+
this._addToNodeFs(path46, initialAdd, wh, depth + 1);
|
|
84218
84495
|
}
|
|
84219
84496
|
}).on(EV.ERROR, this._boundHandleError);
|
|
84220
84497
|
return new Promise((resolve7, reject) => {
|
|
@@ -84263,13 +84540,13 @@ class NodeFsHandler {
|
|
|
84263
84540
|
}
|
|
84264
84541
|
return closer;
|
|
84265
84542
|
}
|
|
84266
|
-
async _addToNodeFs(
|
|
84543
|
+
async _addToNodeFs(path46, initialAdd, priorWh, depth, target) {
|
|
84267
84544
|
const ready = this.fsw._emitReady;
|
|
84268
|
-
if (this.fsw._isIgnored(
|
|
84545
|
+
if (this.fsw._isIgnored(path46) || this.fsw.closed) {
|
|
84269
84546
|
ready();
|
|
84270
84547
|
return false;
|
|
84271
84548
|
}
|
|
84272
|
-
const wh = this.fsw._getWatchHelpers(
|
|
84549
|
+
const wh = this.fsw._getWatchHelpers(path46);
|
|
84273
84550
|
if (priorWh) {
|
|
84274
84551
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
84275
84552
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -84285,8 +84562,8 @@ class NodeFsHandler {
|
|
|
84285
84562
|
const follow = this.fsw.options.followSymlinks;
|
|
84286
84563
|
let closer;
|
|
84287
84564
|
if (stats.isDirectory()) {
|
|
84288
|
-
const absPath = sysPath.resolve(
|
|
84289
|
-
const targetPath = follow ? await fsrealpath(
|
|
84565
|
+
const absPath = sysPath.resolve(path46);
|
|
84566
|
+
const targetPath = follow ? await fsrealpath(path46) : path46;
|
|
84290
84567
|
if (this.fsw.closed)
|
|
84291
84568
|
return;
|
|
84292
84569
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -84296,29 +84573,29 @@ class NodeFsHandler {
|
|
|
84296
84573
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
84297
84574
|
}
|
|
84298
84575
|
} else if (stats.isSymbolicLink()) {
|
|
84299
|
-
const targetPath = follow ? await fsrealpath(
|
|
84576
|
+
const targetPath = follow ? await fsrealpath(path46) : path46;
|
|
84300
84577
|
if (this.fsw.closed)
|
|
84301
84578
|
return;
|
|
84302
84579
|
const parent = sysPath.dirname(wh.watchPath);
|
|
84303
84580
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
84304
84581
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
84305
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
84582
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path46, wh, targetPath);
|
|
84306
84583
|
if (this.fsw.closed)
|
|
84307
84584
|
return;
|
|
84308
84585
|
if (targetPath !== undefined) {
|
|
84309
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
84586
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path46), targetPath);
|
|
84310
84587
|
}
|
|
84311
84588
|
} else {
|
|
84312
84589
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
84313
84590
|
}
|
|
84314
84591
|
ready();
|
|
84315
84592
|
if (closer)
|
|
84316
|
-
this.fsw._addPathCloser(
|
|
84593
|
+
this.fsw._addPathCloser(path46, closer);
|
|
84317
84594
|
return false;
|
|
84318
84595
|
} catch (error) {
|
|
84319
84596
|
if (this.fsw._handleError(error)) {
|
|
84320
84597
|
ready();
|
|
84321
|
-
return
|
|
84598
|
+
return path46;
|
|
84322
84599
|
}
|
|
84323
84600
|
}
|
|
84324
84601
|
}
|
|
@@ -84361,26 +84638,26 @@ function createPattern(matcher) {
|
|
|
84361
84638
|
}
|
|
84362
84639
|
return () => false;
|
|
84363
84640
|
}
|
|
84364
|
-
function normalizePath(
|
|
84365
|
-
if (typeof
|
|
84641
|
+
function normalizePath(path46) {
|
|
84642
|
+
if (typeof path46 !== "string")
|
|
84366
84643
|
throw new Error("string expected");
|
|
84367
|
-
|
|
84368
|
-
|
|
84644
|
+
path46 = sysPath2.normalize(path46);
|
|
84645
|
+
path46 = path46.replace(/\\/g, "/");
|
|
84369
84646
|
let prepend = false;
|
|
84370
|
-
if (
|
|
84647
|
+
if (path46.startsWith("//"))
|
|
84371
84648
|
prepend = true;
|
|
84372
84649
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
84373
|
-
while (
|
|
84374
|
-
|
|
84650
|
+
while (path46.match(DOUBLE_SLASH_RE2))
|
|
84651
|
+
path46 = path46.replace(DOUBLE_SLASH_RE2, "/");
|
|
84375
84652
|
if (prepend)
|
|
84376
|
-
|
|
84377
|
-
return
|
|
84653
|
+
path46 = "/" + path46;
|
|
84654
|
+
return path46;
|
|
84378
84655
|
}
|
|
84379
84656
|
function matchPatterns(patterns, testString, stats) {
|
|
84380
|
-
const
|
|
84657
|
+
const path46 = normalizePath(testString);
|
|
84381
84658
|
for (let index = 0;index < patterns.length; index++) {
|
|
84382
84659
|
const pattern = patterns[index];
|
|
84383
|
-
if (pattern(
|
|
84660
|
+
if (pattern(path46, stats)) {
|
|
84384
84661
|
return true;
|
|
84385
84662
|
}
|
|
84386
84663
|
}
|
|
@@ -84420,19 +84697,19 @@ var toUnix = (string) => {
|
|
|
84420
84697
|
}
|
|
84421
84698
|
return str;
|
|
84422
84699
|
};
|
|
84423
|
-
var normalizePathToUnix = (
|
|
84424
|
-
var normalizeIgnored = (cwd = "") => (
|
|
84425
|
-
if (typeof
|
|
84426
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
84700
|
+
var normalizePathToUnix = (path46) => toUnix(sysPath2.normalize(toUnix(path46)));
|
|
84701
|
+
var normalizeIgnored = (cwd = "") => (path46) => {
|
|
84702
|
+
if (typeof path46 === "string") {
|
|
84703
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path46) ? path46 : sysPath2.join(cwd, path46));
|
|
84427
84704
|
} else {
|
|
84428
|
-
return
|
|
84705
|
+
return path46;
|
|
84429
84706
|
}
|
|
84430
84707
|
};
|
|
84431
|
-
var getAbsolutePath = (
|
|
84432
|
-
if (sysPath2.isAbsolute(
|
|
84433
|
-
return
|
|
84708
|
+
var getAbsolutePath = (path46, cwd) => {
|
|
84709
|
+
if (sysPath2.isAbsolute(path46)) {
|
|
84710
|
+
return path46;
|
|
84434
84711
|
}
|
|
84435
|
-
return sysPath2.join(cwd,
|
|
84712
|
+
return sysPath2.join(cwd, path46);
|
|
84436
84713
|
};
|
|
84437
84714
|
var EMPTY_SET = Object.freeze(new Set);
|
|
84438
84715
|
|
|
@@ -84489,10 +84766,10 @@ var STAT_METHOD_F = "stat";
|
|
|
84489
84766
|
var STAT_METHOD_L = "lstat";
|
|
84490
84767
|
|
|
84491
84768
|
class WatchHelper {
|
|
84492
|
-
constructor(
|
|
84769
|
+
constructor(path46, follow, fsw) {
|
|
84493
84770
|
this.fsw = fsw;
|
|
84494
|
-
const watchPath =
|
|
84495
|
-
this.path =
|
|
84771
|
+
const watchPath = path46;
|
|
84772
|
+
this.path = path46 = path46.replace(REPLACER_RE, "");
|
|
84496
84773
|
this.watchPath = watchPath;
|
|
84497
84774
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
84498
84775
|
this.dirParts = [];
|
|
@@ -84605,20 +84882,20 @@ class FSWatcher extends EventEmitter {
|
|
|
84605
84882
|
this._closePromise = undefined;
|
|
84606
84883
|
let paths = unifyPaths(paths_);
|
|
84607
84884
|
if (cwd) {
|
|
84608
|
-
paths = paths.map((
|
|
84609
|
-
const absPath = getAbsolutePath(
|
|
84885
|
+
paths = paths.map((path46) => {
|
|
84886
|
+
const absPath = getAbsolutePath(path46, cwd);
|
|
84610
84887
|
return absPath;
|
|
84611
84888
|
});
|
|
84612
84889
|
}
|
|
84613
|
-
paths.forEach((
|
|
84614
|
-
this._removeIgnoredPath(
|
|
84890
|
+
paths.forEach((path46) => {
|
|
84891
|
+
this._removeIgnoredPath(path46);
|
|
84615
84892
|
});
|
|
84616
84893
|
this._userIgnored = undefined;
|
|
84617
84894
|
if (!this._readyCount)
|
|
84618
84895
|
this._readyCount = 0;
|
|
84619
84896
|
this._readyCount += paths.length;
|
|
84620
|
-
Promise.all(paths.map(async (
|
|
84621
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
84897
|
+
Promise.all(paths.map(async (path46) => {
|
|
84898
|
+
const res = await this._nodeFsHandler._addToNodeFs(path46, !_internal, undefined, 0, _origAdd);
|
|
84622
84899
|
if (res)
|
|
84623
84900
|
this._emitReady();
|
|
84624
84901
|
return res;
|
|
@@ -84637,17 +84914,17 @@ class FSWatcher extends EventEmitter {
|
|
|
84637
84914
|
return this;
|
|
84638
84915
|
const paths = unifyPaths(paths_);
|
|
84639
84916
|
const { cwd } = this.options;
|
|
84640
|
-
paths.forEach((
|
|
84641
|
-
if (!sysPath2.isAbsolute(
|
|
84917
|
+
paths.forEach((path46) => {
|
|
84918
|
+
if (!sysPath2.isAbsolute(path46) && !this._closers.has(path46)) {
|
|
84642
84919
|
if (cwd)
|
|
84643
|
-
|
|
84644
|
-
|
|
84920
|
+
path46 = sysPath2.join(cwd, path46);
|
|
84921
|
+
path46 = sysPath2.resolve(path46);
|
|
84645
84922
|
}
|
|
84646
|
-
this._closePath(
|
|
84647
|
-
this._addIgnoredPath(
|
|
84648
|
-
if (this._watched.has(
|
|
84923
|
+
this._closePath(path46);
|
|
84924
|
+
this._addIgnoredPath(path46);
|
|
84925
|
+
if (this._watched.has(path46)) {
|
|
84649
84926
|
this._addIgnoredPath({
|
|
84650
|
-
path:
|
|
84927
|
+
path: path46,
|
|
84651
84928
|
recursive: true
|
|
84652
84929
|
});
|
|
84653
84930
|
}
|
|
@@ -84696,38 +84973,38 @@ class FSWatcher extends EventEmitter {
|
|
|
84696
84973
|
if (event !== EVENTS.ERROR)
|
|
84697
84974
|
this.emit(EVENTS.ALL, ...args);
|
|
84698
84975
|
}
|
|
84699
|
-
async _emit(event,
|
|
84976
|
+
async _emit(event, path46, stats) {
|
|
84700
84977
|
if (this.closed)
|
|
84701
84978
|
return;
|
|
84702
84979
|
const opts = this.options;
|
|
84703
84980
|
if (isWindows)
|
|
84704
|
-
|
|
84981
|
+
path46 = sysPath2.normalize(path46);
|
|
84705
84982
|
if (opts.cwd)
|
|
84706
|
-
|
|
84707
|
-
const args = [event,
|
|
84983
|
+
path46 = sysPath2.relative(opts.cwd, path46);
|
|
84984
|
+
const args = [event, path46];
|
|
84708
84985
|
if (stats != null)
|
|
84709
84986
|
args.push(stats);
|
|
84710
84987
|
const awf = opts.awaitWriteFinish;
|
|
84711
84988
|
let pw;
|
|
84712
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
84989
|
+
if (awf && (pw = this._pendingWrites.get(path46))) {
|
|
84713
84990
|
pw.lastChange = new Date;
|
|
84714
84991
|
return this;
|
|
84715
84992
|
}
|
|
84716
84993
|
if (opts.atomic) {
|
|
84717
84994
|
if (event === EVENTS.UNLINK) {
|
|
84718
|
-
this._pendingUnlinks.set(
|
|
84995
|
+
this._pendingUnlinks.set(path46, args);
|
|
84719
84996
|
setTimeout(() => {
|
|
84720
|
-
this._pendingUnlinks.forEach((entry,
|
|
84997
|
+
this._pendingUnlinks.forEach((entry, path47) => {
|
|
84721
84998
|
this.emit(...entry);
|
|
84722
84999
|
this.emit(EVENTS.ALL, ...entry);
|
|
84723
|
-
this._pendingUnlinks.delete(
|
|
85000
|
+
this._pendingUnlinks.delete(path47);
|
|
84724
85001
|
});
|
|
84725
85002
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
84726
85003
|
return this;
|
|
84727
85004
|
}
|
|
84728
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
85005
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path46)) {
|
|
84729
85006
|
event = args[0] = EVENTS.CHANGE;
|
|
84730
|
-
this._pendingUnlinks.delete(
|
|
85007
|
+
this._pendingUnlinks.delete(path46);
|
|
84731
85008
|
}
|
|
84732
85009
|
}
|
|
84733
85010
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -84745,16 +85022,16 @@ class FSWatcher extends EventEmitter {
|
|
|
84745
85022
|
this.emitWithAll(event, args);
|
|
84746
85023
|
}
|
|
84747
85024
|
};
|
|
84748
|
-
this._awaitWriteFinish(
|
|
85025
|
+
this._awaitWriteFinish(path46, awf.stabilityThreshold, event, awfEmit);
|
|
84749
85026
|
return this;
|
|
84750
85027
|
}
|
|
84751
85028
|
if (event === EVENTS.CHANGE) {
|
|
84752
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
85029
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path46, 50);
|
|
84753
85030
|
if (isThrottled)
|
|
84754
85031
|
return this;
|
|
84755
85032
|
}
|
|
84756
85033
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
84757
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
85034
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path46) : path46;
|
|
84758
85035
|
let stats2;
|
|
84759
85036
|
try {
|
|
84760
85037
|
stats2 = await stat3(fullPath);
|
|
@@ -84773,23 +85050,23 @@ class FSWatcher extends EventEmitter {
|
|
|
84773
85050
|
}
|
|
84774
85051
|
return error || this.closed;
|
|
84775
85052
|
}
|
|
84776
|
-
_throttle(actionType,
|
|
85053
|
+
_throttle(actionType, path46, timeout2) {
|
|
84777
85054
|
if (!this._throttled.has(actionType)) {
|
|
84778
85055
|
this._throttled.set(actionType, new Map);
|
|
84779
85056
|
}
|
|
84780
85057
|
const action = this._throttled.get(actionType);
|
|
84781
85058
|
if (!action)
|
|
84782
85059
|
throw new Error("invalid throttle");
|
|
84783
|
-
const actionPath = action.get(
|
|
85060
|
+
const actionPath = action.get(path46);
|
|
84784
85061
|
if (actionPath) {
|
|
84785
85062
|
actionPath.count++;
|
|
84786
85063
|
return false;
|
|
84787
85064
|
}
|
|
84788
85065
|
let timeoutObject;
|
|
84789
85066
|
const clear = () => {
|
|
84790
|
-
const item = action.get(
|
|
85067
|
+
const item = action.get(path46);
|
|
84791
85068
|
const count = item ? item.count : 0;
|
|
84792
|
-
action.delete(
|
|
85069
|
+
action.delete(path46);
|
|
84793
85070
|
clearTimeout(timeoutObject);
|
|
84794
85071
|
if (item)
|
|
84795
85072
|
clearTimeout(item.timeoutObject);
|
|
@@ -84797,50 +85074,50 @@ class FSWatcher extends EventEmitter {
|
|
|
84797
85074
|
};
|
|
84798
85075
|
timeoutObject = setTimeout(clear, timeout2);
|
|
84799
85076
|
const thr = { timeoutObject, clear, count: 0 };
|
|
84800
|
-
action.set(
|
|
85077
|
+
action.set(path46, thr);
|
|
84801
85078
|
return thr;
|
|
84802
85079
|
}
|
|
84803
85080
|
_incrReadyCount() {
|
|
84804
85081
|
return this._readyCount++;
|
|
84805
85082
|
}
|
|
84806
|
-
_awaitWriteFinish(
|
|
85083
|
+
_awaitWriteFinish(path46, threshold, event, awfEmit) {
|
|
84807
85084
|
const awf = this.options.awaitWriteFinish;
|
|
84808
85085
|
if (typeof awf !== "object")
|
|
84809
85086
|
return;
|
|
84810
85087
|
const pollInterval = awf.pollInterval;
|
|
84811
85088
|
let timeoutHandler;
|
|
84812
|
-
let fullPath =
|
|
84813
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
84814
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
85089
|
+
let fullPath = path46;
|
|
85090
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path46)) {
|
|
85091
|
+
fullPath = sysPath2.join(this.options.cwd, path46);
|
|
84815
85092
|
}
|
|
84816
85093
|
const now = new Date;
|
|
84817
85094
|
const writes = this._pendingWrites;
|
|
84818
85095
|
function awaitWriteFinishFn(prevStat) {
|
|
84819
85096
|
statcb(fullPath, (err, curStat) => {
|
|
84820
|
-
if (err || !writes.has(
|
|
85097
|
+
if (err || !writes.has(path46)) {
|
|
84821
85098
|
if (err && err.code !== "ENOENT")
|
|
84822
85099
|
awfEmit(err);
|
|
84823
85100
|
return;
|
|
84824
85101
|
}
|
|
84825
85102
|
const now2 = Number(new Date);
|
|
84826
85103
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
84827
|
-
writes.get(
|
|
85104
|
+
writes.get(path46).lastChange = now2;
|
|
84828
85105
|
}
|
|
84829
|
-
const pw = writes.get(
|
|
85106
|
+
const pw = writes.get(path46);
|
|
84830
85107
|
const df = now2 - pw.lastChange;
|
|
84831
85108
|
if (df >= threshold) {
|
|
84832
|
-
writes.delete(
|
|
85109
|
+
writes.delete(path46);
|
|
84833
85110
|
awfEmit(undefined, curStat);
|
|
84834
85111
|
} else {
|
|
84835
85112
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
84836
85113
|
}
|
|
84837
85114
|
});
|
|
84838
85115
|
}
|
|
84839
|
-
if (!writes.has(
|
|
84840
|
-
writes.set(
|
|
85116
|
+
if (!writes.has(path46)) {
|
|
85117
|
+
writes.set(path46, {
|
|
84841
85118
|
lastChange: now,
|
|
84842
85119
|
cancelWait: () => {
|
|
84843
|
-
writes.delete(
|
|
85120
|
+
writes.delete(path46);
|
|
84844
85121
|
clearTimeout(timeoutHandler);
|
|
84845
85122
|
return event;
|
|
84846
85123
|
}
|
|
@@ -84848,8 +85125,8 @@ class FSWatcher extends EventEmitter {
|
|
|
84848
85125
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
84849
85126
|
}
|
|
84850
85127
|
}
|
|
84851
|
-
_isIgnored(
|
|
84852
|
-
if (this.options.atomic && DOT_RE.test(
|
|
85128
|
+
_isIgnored(path46, stats) {
|
|
85129
|
+
if (this.options.atomic && DOT_RE.test(path46))
|
|
84853
85130
|
return true;
|
|
84854
85131
|
if (!this._userIgnored) {
|
|
84855
85132
|
const { cwd } = this.options;
|
|
@@ -84859,13 +85136,13 @@ class FSWatcher extends EventEmitter {
|
|
|
84859
85136
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
84860
85137
|
this._userIgnored = anymatch(list, undefined);
|
|
84861
85138
|
}
|
|
84862
|
-
return this._userIgnored(
|
|
85139
|
+
return this._userIgnored(path46, stats);
|
|
84863
85140
|
}
|
|
84864
|
-
_isntIgnored(
|
|
84865
|
-
return !this._isIgnored(
|
|
85141
|
+
_isntIgnored(path46, stat4) {
|
|
85142
|
+
return !this._isIgnored(path46, stat4);
|
|
84866
85143
|
}
|
|
84867
|
-
_getWatchHelpers(
|
|
84868
|
-
return new WatchHelper(
|
|
85144
|
+
_getWatchHelpers(path46) {
|
|
85145
|
+
return new WatchHelper(path46, this.options.followSymlinks, this);
|
|
84869
85146
|
}
|
|
84870
85147
|
_getWatchedDir(directory) {
|
|
84871
85148
|
const dir = sysPath2.resolve(directory);
|
|
@@ -84879,57 +85156,57 @@ class FSWatcher extends EventEmitter {
|
|
|
84879
85156
|
return Boolean(Number(stats.mode) & 256);
|
|
84880
85157
|
}
|
|
84881
85158
|
_remove(directory, item, isDirectory2) {
|
|
84882
|
-
const
|
|
84883
|
-
const fullPath = sysPath2.resolve(
|
|
84884
|
-
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(
|
|
84885
|
-
if (!this._throttle("remove",
|
|
85159
|
+
const path46 = sysPath2.join(directory, item);
|
|
85160
|
+
const fullPath = sysPath2.resolve(path46);
|
|
85161
|
+
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path46) || this._watched.has(fullPath);
|
|
85162
|
+
if (!this._throttle("remove", path46, 100))
|
|
84886
85163
|
return;
|
|
84887
85164
|
if (!isDirectory2 && this._watched.size === 1) {
|
|
84888
85165
|
this.add(directory, item, true);
|
|
84889
85166
|
}
|
|
84890
|
-
const wp = this._getWatchedDir(
|
|
85167
|
+
const wp = this._getWatchedDir(path46);
|
|
84891
85168
|
const nestedDirectoryChildren = wp.getChildren();
|
|
84892
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
85169
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path46, nested));
|
|
84893
85170
|
const parent = this._getWatchedDir(directory);
|
|
84894
85171
|
const wasTracked = parent.has(item);
|
|
84895
85172
|
parent.remove(item);
|
|
84896
85173
|
if (this._symlinkPaths.has(fullPath)) {
|
|
84897
85174
|
this._symlinkPaths.delete(fullPath);
|
|
84898
85175
|
}
|
|
84899
|
-
let relPath =
|
|
85176
|
+
let relPath = path46;
|
|
84900
85177
|
if (this.options.cwd)
|
|
84901
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
85178
|
+
relPath = sysPath2.relative(this.options.cwd, path46);
|
|
84902
85179
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
84903
85180
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
84904
85181
|
if (event === EVENTS.ADD)
|
|
84905
85182
|
return;
|
|
84906
85183
|
}
|
|
84907
|
-
this._watched.delete(
|
|
85184
|
+
this._watched.delete(path46);
|
|
84908
85185
|
this._watched.delete(fullPath);
|
|
84909
85186
|
const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
84910
|
-
if (wasTracked && !this._isIgnored(
|
|
84911
|
-
this._emit(eventName,
|
|
84912
|
-
this._closePath(
|
|
85187
|
+
if (wasTracked && !this._isIgnored(path46))
|
|
85188
|
+
this._emit(eventName, path46);
|
|
85189
|
+
this._closePath(path46);
|
|
84913
85190
|
}
|
|
84914
|
-
_closePath(
|
|
84915
|
-
this._closeFile(
|
|
84916
|
-
const dir = sysPath2.dirname(
|
|
84917
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
85191
|
+
_closePath(path46) {
|
|
85192
|
+
this._closeFile(path46);
|
|
85193
|
+
const dir = sysPath2.dirname(path46);
|
|
85194
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path46));
|
|
84918
85195
|
}
|
|
84919
|
-
_closeFile(
|
|
84920
|
-
const closers = this._closers.get(
|
|
85196
|
+
_closeFile(path46) {
|
|
85197
|
+
const closers = this._closers.get(path46);
|
|
84921
85198
|
if (!closers)
|
|
84922
85199
|
return;
|
|
84923
85200
|
closers.forEach((closer) => closer());
|
|
84924
|
-
this._closers.delete(
|
|
85201
|
+
this._closers.delete(path46);
|
|
84925
85202
|
}
|
|
84926
|
-
_addPathCloser(
|
|
85203
|
+
_addPathCloser(path46, closer) {
|
|
84927
85204
|
if (!closer)
|
|
84928
85205
|
return;
|
|
84929
|
-
let list = this._closers.get(
|
|
85206
|
+
let list = this._closers.get(path46);
|
|
84930
85207
|
if (!list) {
|
|
84931
85208
|
list = [];
|
|
84932
|
-
this._closers.set(
|
|
85209
|
+
this._closers.set(path46, list);
|
|
84933
85210
|
}
|
|
84934
85211
|
list.push(closer);
|
|
84935
85212
|
}
|
|
@@ -84962,10 +85239,10 @@ import Debug3 from "debug";
|
|
|
84962
85239
|
|
|
84963
85240
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
84964
85241
|
import * as ts from "typescript";
|
|
84965
|
-
import * as
|
|
85242
|
+
import * as path46 from "path";
|
|
84966
85243
|
import * as fs43 from "fs";
|
|
84967
85244
|
function getAllDependencyPackages(projectDir) {
|
|
84968
|
-
const packageJsonPath =
|
|
85245
|
+
const packageJsonPath = path46.join(projectDir, "package.json");
|
|
84969
85246
|
const allPackages = new Set;
|
|
84970
85247
|
if (!fs43.existsSync(packageJsonPath)) {
|
|
84971
85248
|
return allPackages;
|
|
@@ -84986,7 +85263,7 @@ function getAllDependencyPackages(projectDir) {
|
|
|
84986
85263
|
return allPackages;
|
|
84987
85264
|
}
|
|
84988
85265
|
function getNodeModuleImports(filePath) {
|
|
84989
|
-
const absolutePath =
|
|
85266
|
+
const absolutePath = path46.resolve(filePath);
|
|
84990
85267
|
if (!fs43.existsSync(absolutePath)) {
|
|
84991
85268
|
return [];
|
|
84992
85269
|
}
|
|
@@ -85040,17 +85317,17 @@ function resolveNodeModuleImport({
|
|
|
85040
85317
|
}) {
|
|
85041
85318
|
const packageName = getPackageNameFromImport(importPath);
|
|
85042
85319
|
const searchPaths = [
|
|
85043
|
-
|
|
85320
|
+
path46.join(projectDir, "node_modules", packageName)
|
|
85044
85321
|
];
|
|
85045
85322
|
if (searchFromDir) {
|
|
85046
|
-
let currentDir =
|
|
85047
|
-
const projectDirNormalized =
|
|
85323
|
+
let currentDir = path46.dirname(searchFromDir);
|
|
85324
|
+
const projectDirNormalized = path46.normalize(projectDir);
|
|
85048
85325
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
85049
|
-
const candidatePath =
|
|
85326
|
+
const candidatePath = path46.join(currentDir, "node_modules", packageName);
|
|
85050
85327
|
if (!searchPaths.includes(candidatePath)) {
|
|
85051
85328
|
searchPaths.push(candidatePath);
|
|
85052
85329
|
}
|
|
85053
|
-
const parentDir =
|
|
85330
|
+
const parentDir = path46.dirname(currentDir);
|
|
85054
85331
|
if (parentDir === currentDir)
|
|
85055
85332
|
break;
|
|
85056
85333
|
currentDir = parentDir;
|
|
@@ -85066,22 +85343,22 @@ function resolveNodeModuleImport({
|
|
|
85066
85343
|
if (!packageDir) {
|
|
85067
85344
|
return [];
|
|
85068
85345
|
}
|
|
85069
|
-
const packageJsonPath =
|
|
85346
|
+
const packageJsonPath = path46.join(packageDir, "package.json");
|
|
85070
85347
|
const hasPackageJson = fs43.existsSync(packageJsonPath);
|
|
85071
85348
|
const packageJson = hasPackageJson ? JSON.parse(fs43.readFileSync(packageJsonPath, "utf-8")) : null;
|
|
85072
85349
|
const resolvedFiles = [];
|
|
85073
85350
|
if (importPath !== packageName) {
|
|
85074
85351
|
const subpath = importPath.slice(packageName.length + 1);
|
|
85075
85352
|
const possiblePaths = [
|
|
85076
|
-
|
|
85077
|
-
|
|
85078
|
-
|
|
85079
|
-
|
|
85080
|
-
|
|
85081
|
-
|
|
85082
|
-
|
|
85083
|
-
|
|
85084
|
-
|
|
85353
|
+
path46.join(packageDir, subpath),
|
|
85354
|
+
path46.join(packageDir, `${subpath}.js`),
|
|
85355
|
+
path46.join(packageDir, `${subpath}.mjs`),
|
|
85356
|
+
path46.join(packageDir, `${subpath}.ts`),
|
|
85357
|
+
path46.join(packageDir, `${subpath}.tsx`),
|
|
85358
|
+
path46.join(packageDir, subpath, "index.js"),
|
|
85359
|
+
path46.join(packageDir, subpath, "index.mjs"),
|
|
85360
|
+
path46.join(packageDir, subpath, "index.ts"),
|
|
85361
|
+
path46.join(packageDir, subpath, "index.tsx")
|
|
85085
85362
|
];
|
|
85086
85363
|
for (const p of possiblePaths) {
|
|
85087
85364
|
if (fs43.existsSync(p) && fs43.statSync(p).isFile()) {
|
|
@@ -85116,22 +85393,22 @@ function resolveNodeModuleImport({
|
|
|
85116
85393
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
85117
85394
|
].filter((entry) => typeof entry === "string");
|
|
85118
85395
|
for (const entry of entryPoints) {
|
|
85119
|
-
const entryPath =
|
|
85396
|
+
const entryPath = path46.join(packageDir, entry);
|
|
85120
85397
|
if (fs43.existsSync(entryPath) && fs43.statSync(entryPath).isFile()) {
|
|
85121
85398
|
resolvedFiles.push(entryPath);
|
|
85122
85399
|
}
|
|
85123
85400
|
}
|
|
85124
85401
|
if (resolvedFiles.length === 0) {
|
|
85125
85402
|
const fallbackPaths = [
|
|
85126
|
-
|
|
85127
|
-
|
|
85128
|
-
|
|
85129
|
-
|
|
85130
|
-
|
|
85131
|
-
|
|
85132
|
-
|
|
85133
|
-
|
|
85134
|
-
|
|
85403
|
+
path46.join(packageDir, "index.js"),
|
|
85404
|
+
path46.join(packageDir, "index.mjs"),
|
|
85405
|
+
path46.join(packageDir, "index.ts"),
|
|
85406
|
+
path46.join(packageDir, "index.tsx"),
|
|
85407
|
+
path46.join(packageDir, "dist", "index.js"),
|
|
85408
|
+
path46.join(packageDir, "dist", "index.mjs"),
|
|
85409
|
+
path46.join(packageDir, "lib", "index.js"),
|
|
85410
|
+
path46.join(packageDir, "src", "index.ts"),
|
|
85411
|
+
path46.join(packageDir, "src", "index.tsx")
|
|
85135
85412
|
];
|
|
85136
85413
|
for (const p of fallbackPaths) {
|
|
85137
85414
|
if (fs43.existsSync(p) && fs43.statSync(p).isFile()) {
|
|
@@ -85172,8 +85449,8 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85172
85449
|
}
|
|
85173
85450
|
}
|
|
85174
85451
|
function getLocalDependencies(filePath) {
|
|
85175
|
-
const absolutePath =
|
|
85176
|
-
const baseDir =
|
|
85452
|
+
const absolutePath = path46.resolve(filePath);
|
|
85453
|
+
const baseDir = path46.dirname(absolutePath);
|
|
85177
85454
|
if (!fs43.existsSync(absolutePath)) {
|
|
85178
85455
|
return [];
|
|
85179
85456
|
}
|
|
@@ -85199,7 +85476,7 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85199
85476
|
}
|
|
85200
85477
|
function resolveLocalImport(importPath, baseDir) {
|
|
85201
85478
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
85202
|
-
const resolvedPath =
|
|
85479
|
+
const resolvedPath = path46.resolve(baseDir, importPath);
|
|
85203
85480
|
if (fs43.existsSync(resolvedPath) && fs43.statSync(resolvedPath).isFile()) {
|
|
85204
85481
|
return resolvedPath;
|
|
85205
85482
|
}
|
|
@@ -85211,7 +85488,7 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85211
85488
|
}
|
|
85212
85489
|
if (fs43.existsSync(resolvedPath) && fs43.statSync(resolvedPath).isDirectory()) {
|
|
85213
85490
|
for (const ext of extensions) {
|
|
85214
|
-
const indexPath =
|
|
85491
|
+
const indexPath = path46.join(resolvedPath, `index${ext}`);
|
|
85215
85492
|
if (fs43.existsSync(indexPath)) {
|
|
85216
85493
|
return indexPath;
|
|
85217
85494
|
}
|
|
@@ -85237,11 +85514,11 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
85237
85514
|
function collectLocalPackageFiles(packageDir) {
|
|
85238
85515
|
const buildDirs = ["dist", "build"];
|
|
85239
85516
|
for (const dirName of buildDirs) {
|
|
85240
|
-
const dirPath =
|
|
85517
|
+
const dirPath = path46.join(packageDir, dirName);
|
|
85241
85518
|
if (fs43.existsSync(dirPath)) {
|
|
85242
85519
|
const files = walkDirectory(dirPath, new Set);
|
|
85243
85520
|
if (files.length > 0) {
|
|
85244
|
-
const packageJsonPath =
|
|
85521
|
+
const packageJsonPath = path46.join(packageDir, "package.json");
|
|
85245
85522
|
if (fs43.existsSync(packageJsonPath)) {
|
|
85246
85523
|
files.push(packageJsonPath);
|
|
85247
85524
|
}
|
|
@@ -85257,7 +85534,7 @@ function walkDirectory(dir, excludedDirs) {
|
|
|
85257
85534
|
return files;
|
|
85258
85535
|
const entries = fs43.readdirSync(dir, { withFileTypes: true });
|
|
85259
85536
|
for (const entry of entries) {
|
|
85260
|
-
const fullPath =
|
|
85537
|
+
const fullPath = path46.join(dir, entry.name);
|
|
85261
85538
|
if (entry.isDirectory()) {
|
|
85262
85539
|
if (excludedDirs.has(entry.name)) {
|
|
85263
85540
|
continue;
|
|
@@ -85318,10 +85595,10 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
85318
85595
|
processedPackages.add(packageName);
|
|
85319
85596
|
if (resolvedFiles.length > 0) {
|
|
85320
85597
|
const firstResolvedFile = resolvedFiles[0];
|
|
85321
|
-
let packageDir =
|
|
85598
|
+
let packageDir = path46.dirname(firstResolvedFile);
|
|
85322
85599
|
let hasPackageJson = false;
|
|
85323
85600
|
while (packageDir.includes("node_modules")) {
|
|
85324
|
-
const packageJsonPath =
|
|
85601
|
+
const packageJsonPath = path46.join(packageDir, "package.json");
|
|
85325
85602
|
if (fs43.existsSync(packageJsonPath)) {
|
|
85326
85603
|
try {
|
|
85327
85604
|
const pkgJson = JSON.parse(fs43.readFileSync(packageJsonPath, "utf-8"));
|
|
@@ -85332,10 +85609,10 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
85332
85609
|
} catch {}
|
|
85333
85610
|
}
|
|
85334
85611
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
85335
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
85612
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path46.sep))) {
|
|
85336
85613
|
break;
|
|
85337
85614
|
}
|
|
85338
|
-
const parentDir =
|
|
85615
|
+
const parentDir = path46.dirname(packageDir);
|
|
85339
85616
|
if (parentDir === packageDir)
|
|
85340
85617
|
break;
|
|
85341
85618
|
packageDir = parentDir;
|
|
@@ -86109,10 +86386,10 @@ var databaseSchema = z5.object({
|
|
|
86109
86386
|
files: z5.array(fileSchema).default([]),
|
|
86110
86387
|
events: z5.array(eventSchema).default([])
|
|
86111
86388
|
});
|
|
86112
|
-
function normalizePath2(
|
|
86113
|
-
if (!
|
|
86389
|
+
function normalizePath2(path47) {
|
|
86390
|
+
if (!path47 || path47 === "/")
|
|
86114
86391
|
return "";
|
|
86115
|
-
let normalized =
|
|
86392
|
+
let normalized = path47.replace(/\\+/g, "/").replace(/\/\/+/, "/");
|
|
86116
86393
|
if (normalized.startsWith("/")) {
|
|
86117
86394
|
normalized = normalized.slice(1);
|
|
86118
86395
|
}
|
|
@@ -86970,13 +87247,13 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
86970
87247
|
|
|
86971
87248
|
// lib/server/kicad-pcm-proxy.ts
|
|
86972
87249
|
import * as fs44 from "node:fs";
|
|
86973
|
-
import * as
|
|
87250
|
+
import * as path47 from "node:path";
|
|
86974
87251
|
var getSourceFilesChecksum = (projectDir) => {
|
|
86975
87252
|
const sourceFiles = globbySync(["**/*.tsx", "**/*.ts", "**/*.json", "!node_modules/**", "!dist/**"], { cwd: projectDir });
|
|
86976
87253
|
let checksum = "";
|
|
86977
87254
|
for (const file of sourceFiles) {
|
|
86978
87255
|
try {
|
|
86979
|
-
const stat4 = fs44.statSync(
|
|
87256
|
+
const stat4 = fs44.statSync(path47.join(projectDir, file));
|
|
86980
87257
|
checksum += `${file}:${stat4.mtimeMs};`;
|
|
86981
87258
|
} catch {}
|
|
86982
87259
|
}
|
|
@@ -86996,9 +87273,9 @@ var createKicadPcmProxy = ({
|
|
|
86996
87273
|
};
|
|
86997
87274
|
const handleRequest = async (url, res) => {
|
|
86998
87275
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
86999
|
-
const distDir =
|
|
87000
|
-
const pcmDir =
|
|
87001
|
-
const filePath =
|
|
87276
|
+
const distDir = path47.join(projectDir, "dist");
|
|
87277
|
+
const pcmDir = path47.join(distDir, "pcm");
|
|
87278
|
+
const filePath = path47.join(pcmDir, requestedFile);
|
|
87002
87279
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
87003
87280
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
87004
87281
|
if (needsRebuild) {
|
|
@@ -87048,7 +87325,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
87048
87325
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
87049
87326
|
return;
|
|
87050
87327
|
}
|
|
87051
|
-
const ext =
|
|
87328
|
+
const ext = path47.extname(filePath).toLowerCase();
|
|
87052
87329
|
let contentType = "application/octet-stream";
|
|
87053
87330
|
if (ext === ".json") {
|
|
87054
87331
|
contentType = "application/json";
|
|
@@ -87180,7 +87457,7 @@ var createHttpServer = async ({
|
|
|
87180
87457
|
// lib/shared/push-snippet.ts
|
|
87181
87458
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
87182
87459
|
import * as fs46 from "node:fs";
|
|
87183
|
-
import * as
|
|
87460
|
+
import * as path50 from "node:path";
|
|
87184
87461
|
import Debug2 from "debug";
|
|
87185
87462
|
|
|
87186
87463
|
// lib/utils/validate-package-name.ts
|
|
@@ -87198,7 +87475,7 @@ var validatePackageName = (name) => {
|
|
|
87198
87475
|
};
|
|
87199
87476
|
|
|
87200
87477
|
// cli/dev/get-package-file-paths.ts
|
|
87201
|
-
import * as
|
|
87478
|
+
import * as path48 from "node:path";
|
|
87202
87479
|
var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
87203
87480
|
const ignorePatterns = [
|
|
87204
87481
|
...DEFAULT_IGNORED_PATTERNS,
|
|
@@ -87209,7 +87486,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
87209
87486
|
ignore: ignorePatterns
|
|
87210
87487
|
});
|
|
87211
87488
|
fileNames.sort();
|
|
87212
|
-
return fileNames.map((fileName) =>
|
|
87489
|
+
return fileNames.map((fileName) => path48.join(projectDir, fileName));
|
|
87213
87490
|
};
|
|
87214
87491
|
|
|
87215
87492
|
// lib/utils/check-org-access.ts
|
|
@@ -87225,7 +87502,7 @@ var checkOrgAccess = async (ky2, orgTscircuitHandle) => {
|
|
|
87225
87502
|
};
|
|
87226
87503
|
|
|
87227
87504
|
// lib/shared/is-binary-file.ts
|
|
87228
|
-
import * as
|
|
87505
|
+
import * as path49 from "node:path";
|
|
87229
87506
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
87230
87507
|
".glb",
|
|
87231
87508
|
".gltf",
|
|
@@ -87241,7 +87518,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
87241
87518
|
".tar"
|
|
87242
87519
|
]);
|
|
87243
87520
|
var isBinaryFile = (filePath) => {
|
|
87244
|
-
const ext =
|
|
87521
|
+
const ext = path49.extname(filePath).toLowerCase();
|
|
87245
87522
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
87246
87523
|
};
|
|
87247
87524
|
|
|
@@ -87267,7 +87544,7 @@ var debug2 = Debug2("tsci:push-snippet");
|
|
|
87267
87544
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
87268
87545
|
const zip = new import_jszip3.default;
|
|
87269
87546
|
for (const fullFilePath of filePaths) {
|
|
87270
|
-
const relativeFilePath =
|
|
87547
|
+
const relativeFilePath = path50.relative(projectDir, fullFilePath);
|
|
87271
87548
|
zip.file(relativeFilePath, fs46.readFileSync(fullFilePath));
|
|
87272
87549
|
}
|
|
87273
87550
|
const archive = await zip.generateAsync({
|
|
@@ -87305,10 +87582,10 @@ var pushSnippet = async ({
|
|
|
87305
87582
|
return onExit(1);
|
|
87306
87583
|
}
|
|
87307
87584
|
const packageJsonPath = [
|
|
87308
|
-
|
|
87309
|
-
|
|
87310
|
-
].find((
|
|
87311
|
-
const projectDir = packageJsonPath ?
|
|
87585
|
+
path50.resolve(path50.join(path50.dirname(snippetFilePath), "package.json")),
|
|
87586
|
+
path50.resolve(path50.join(process.cwd(), "package.json"))
|
|
87587
|
+
].find((path51) => fs46.existsSync(path51));
|
|
87588
|
+
const projectDir = packageJsonPath ? path50.dirname(packageJsonPath) : path50.dirname(snippetFilePath);
|
|
87312
87589
|
if (!packageJsonPath) {
|
|
87313
87590
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
87314
87591
|
return onExit(1);
|
|
@@ -87502,7 +87779,7 @@ var pushSnippet = async ({
|
|
|
87502
87779
|
json: archivePayload
|
|
87503
87780
|
});
|
|
87504
87781
|
for (const fullFilePath of filePaths) {
|
|
87505
|
-
const relativeFilePath =
|
|
87782
|
+
const relativeFilePath = path50.relative(projectDir, fullFilePath);
|
|
87506
87783
|
uploadResults.succeeded.push(relativeFilePath);
|
|
87507
87784
|
}
|
|
87508
87785
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -87512,7 +87789,7 @@ var pushSnippet = async ({
|
|
|
87512
87789
|
}
|
|
87513
87790
|
if (uploadResults.succeeded.length === 0) {
|
|
87514
87791
|
for (const fullFilePath of filePaths) {
|
|
87515
|
-
const relativeFilePath =
|
|
87792
|
+
const relativeFilePath = path50.relative(projectDir, fullFilePath);
|
|
87516
87793
|
const fileBuffer = fs46.readFileSync(fullFilePath);
|
|
87517
87794
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
87518
87795
|
const payload = {
|
|
@@ -87602,7 +87879,7 @@ class DevServer {
|
|
|
87602
87879
|
}) {
|
|
87603
87880
|
this.port = port;
|
|
87604
87881
|
this.componentFilePath = componentFilePath;
|
|
87605
|
-
this.projectDir = projectDir ??
|
|
87882
|
+
this.projectDir = projectDir ?? path51.dirname(componentFilePath);
|
|
87606
87883
|
this.kicadPcm = kicadPcm ?? false;
|
|
87607
87884
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
87608
87885
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
@@ -87613,7 +87890,7 @@ class DevServer {
|
|
|
87613
87890
|
async start() {
|
|
87614
87891
|
const { server } = await createHttpServer({
|
|
87615
87892
|
port: this.port,
|
|
87616
|
-
defaultMainComponentPath:
|
|
87893
|
+
defaultMainComponentPath: path51.relative(this.projectDir, this.componentFilePath),
|
|
87617
87894
|
kicadPcm: this.kicadPcm,
|
|
87618
87895
|
projectDir: this.projectDir,
|
|
87619
87896
|
entryFile: this.componentFilePath
|
|
@@ -87629,7 +87906,7 @@ class DevServer {
|
|
|
87629
87906
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
87630
87907
|
persistent: true,
|
|
87631
87908
|
ignoreInitial: true,
|
|
87632
|
-
ignored: (p) => shouldIgnorePath(
|
|
87909
|
+
ignored: (p) => shouldIgnorePath(path51.relative(this.projectDir, p), this.ignoredFiles)
|
|
87633
87910
|
});
|
|
87634
87911
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
87635
87912
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -87644,8 +87921,8 @@ class DevServer {
|
|
|
87644
87921
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
87645
87922
|
searchParams: { file_path: ev.file_path }
|
|
87646
87923
|
}).json();
|
|
87647
|
-
const fullPath =
|
|
87648
|
-
const dirPath =
|
|
87924
|
+
const fullPath = path51.join(this.projectDir, ev.file_path);
|
|
87925
|
+
const dirPath = path51.dirname(fullPath);
|
|
87649
87926
|
if (!fs47.existsSync(dirPath)) {
|
|
87650
87927
|
fs47.mkdirSync(dirPath, { recursive: true });
|
|
87651
87928
|
}
|
|
@@ -87657,14 +87934,14 @@ class DevServer {
|
|
|
87657
87934
|
}
|
|
87658
87935
|
}
|
|
87659
87936
|
async handleFileDeletedEventFromServer(ev) {
|
|
87660
|
-
const fullPath =
|
|
87937
|
+
const fullPath = path51.join(this.projectDir, ev.file_path);
|
|
87661
87938
|
if (fs47.existsSync(fullPath)) {
|
|
87662
87939
|
debug3(`Deleting file ${ev.file_path} from filesystem`);
|
|
87663
87940
|
fs47.unlinkSync(fullPath);
|
|
87664
87941
|
}
|
|
87665
87942
|
}
|
|
87666
87943
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
87667
|
-
const relativeFilePath =
|
|
87944
|
+
const relativeFilePath = path51.relative(this.projectDir, absoluteFilePath);
|
|
87668
87945
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
87669
87946
|
return;
|
|
87670
87947
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -87679,14 +87956,14 @@ class DevServer {
|
|
|
87679
87956
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
87680
87957
|
}
|
|
87681
87958
|
async checkAndUploadNewNodeModules(filePath) {
|
|
87682
|
-
const ext =
|
|
87959
|
+
const ext = path51.extname(filePath).toLowerCase();
|
|
87683
87960
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
87684
87961
|
if (!isSourceFile)
|
|
87685
87962
|
return;
|
|
87686
87963
|
try {
|
|
87687
87964
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
87688
87965
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
87689
|
-
const relativePath =
|
|
87966
|
+
const relativePath = path51.relative(this.projectDir, file);
|
|
87690
87967
|
return !this.uploadedNodeModules.has(relativePath);
|
|
87691
87968
|
});
|
|
87692
87969
|
if (newFiles.length === 0)
|
|
@@ -87699,7 +87976,7 @@ class DevServer {
|
|
|
87699
87976
|
}
|
|
87700
87977
|
}
|
|
87701
87978
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
87702
|
-
const relativeFilePath =
|
|
87979
|
+
const relativeFilePath = path51.relative(this.projectDir, absoluteFilePath);
|
|
87703
87980
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
87704
87981
|
return;
|
|
87705
87982
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -87737,8 +88014,8 @@ class DevServer {
|
|
|
87737
88014
|
debug3(`Successfully deleted file ${relativeFilePath} from server`);
|
|
87738
88015
|
}
|
|
87739
88016
|
async handleFileRename(oldPath, newPath) {
|
|
87740
|
-
const oldRelativePath =
|
|
87741
|
-
const newRelativePath =
|
|
88017
|
+
const oldRelativePath = path51.relative(this.projectDir, oldPath);
|
|
88018
|
+
const newRelativePath = path51.relative(this.projectDir, newPath);
|
|
87742
88019
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
87743
88020
|
return;
|
|
87744
88021
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -87756,7 +88033,7 @@ class DevServer {
|
|
|
87756
88033
|
});
|
|
87757
88034
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
87758
88035
|
for (const filePath of filePaths) {
|
|
87759
|
-
const relativeFilePath =
|
|
88036
|
+
const relativeFilePath = path51.relative(this.projectDir, filePath);
|
|
87760
88037
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
87761
88038
|
await this.postFileUpsert({
|
|
87762
88039
|
filePath: relativeFilePath,
|
|
@@ -87788,7 +88065,7 @@ class DevServer {
|
|
|
87788
88065
|
}
|
|
87789
88066
|
async uploadNodeModuleFiles(files) {
|
|
87790
88067
|
for (const nodeModuleFile of files) {
|
|
87791
|
-
const relativeFilePath =
|
|
88068
|
+
const relativeFilePath = path51.relative(this.projectDir, nodeModuleFile);
|
|
87792
88069
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
87793
88070
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
87794
88071
|
await this.postFileUpsert({
|
|
@@ -87833,7 +88110,7 @@ class DevServer {
|
|
|
87833
88110
|
formData.set("file_path", filePath);
|
|
87834
88111
|
formData.set("initiator", initiator);
|
|
87835
88112
|
const binaryBytes = Uint8Array.from(binaryContent);
|
|
87836
|
-
formData.set("binary_file", new Blob([binaryBytes]),
|
|
88113
|
+
formData.set("binary_file", new Blob([binaryBytes]), path51.basename(filePath));
|
|
87837
88114
|
const response = await fetch(`http://localhost:${this.port}/api/files/upsert-multipart`, {
|
|
87838
88115
|
method: "POST",
|
|
87839
88116
|
body: formData
|
|
@@ -87873,7 +88150,7 @@ class DevServer {
|
|
|
87873
88150
|
await this.filesystemWatcher?.close();
|
|
87874
88151
|
}
|
|
87875
88152
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
87876
|
-
const ext =
|
|
88153
|
+
const ext = path51.extname(relativeFilePath).toLowerCase();
|
|
87877
88154
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
87878
88155
|
const fileBuffer = fs47.readFileSync(absoluteFilePath);
|
|
87879
88156
|
return { binary_content: fileBuffer };
|
|
@@ -87909,7 +88186,7 @@ class DevServer {
|
|
|
87909
88186
|
|
|
87910
88187
|
// cli/dev/resolve-dev-target.ts
|
|
87911
88188
|
import * as fs48 from "node:fs";
|
|
87912
|
-
import * as
|
|
88189
|
+
import * as path52 from "node:path";
|
|
87913
88190
|
var findSelectableFiles = (projectDir) => {
|
|
87914
88191
|
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs48.existsSync(file)).sort();
|
|
87915
88192
|
if (boardFiles.length > 0) {
|
|
@@ -87919,7 +88196,7 @@ var findSelectableFiles = (projectDir) => {
|
|
|
87919
88196
|
cwd: projectDir,
|
|
87920
88197
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
87921
88198
|
});
|
|
87922
|
-
return files.map((file) =>
|
|
88199
|
+
return files.map((file) => path52.resolve(projectDir, file)).filter((file) => fs48.existsSync(file)).sort();
|
|
87923
88200
|
};
|
|
87924
88201
|
var isValidDevFile = (filePath) => {
|
|
87925
88202
|
return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
|
|
@@ -87927,7 +88204,7 @@ var isValidDevFile = (filePath) => {
|
|
|
87927
88204
|
var resolveDevTarget = async (file) => {
|
|
87928
88205
|
let projectDir = process.cwd();
|
|
87929
88206
|
if (file) {
|
|
87930
|
-
const resolvedPath =
|
|
88207
|
+
const resolvedPath = path52.resolve(file);
|
|
87931
88208
|
if (fs48.existsSync(resolvedPath) && fs48.statSync(resolvedPath).isDirectory()) {
|
|
87932
88209
|
projectDir = resolvedPath;
|
|
87933
88210
|
const availableFiles2 = findSelectableFiles(projectDir);
|
|
@@ -87935,7 +88212,7 @@ var resolveDevTarget = async (file) => {
|
|
|
87935
88212
|
console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
|
|
87936
88213
|
return null;
|
|
87937
88214
|
}
|
|
87938
|
-
console.log("Selected file:",
|
|
88215
|
+
console.log("Selected file:", path52.relative(projectDir, availableFiles2[0]));
|
|
87939
88216
|
return { absolutePath: availableFiles2[0], projectDir };
|
|
87940
88217
|
}
|
|
87941
88218
|
if (!fs48.existsSync(resolvedPath)) {
|
|
@@ -87958,7 +88235,7 @@ var resolveDevTarget = async (file) => {
|
|
|
87958
88235
|
console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
|
|
87959
88236
|
return null;
|
|
87960
88237
|
}
|
|
87961
|
-
console.log("Selected file:",
|
|
88238
|
+
console.log("Selected file:", path52.relative(projectDir, availableFiles[0]));
|
|
87962
88239
|
return { absolutePath: availableFiles[0], projectDir };
|
|
87963
88240
|
};
|
|
87964
88241
|
|
|
@@ -87974,7 +88251,7 @@ var isPortAvailable = (port) => {
|
|
|
87974
88251
|
});
|
|
87975
88252
|
};
|
|
87976
88253
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
87977
|
-
const tsconfigPath =
|
|
88254
|
+
const tsconfigPath = path53.join(projectDir, "tsconfig.json");
|
|
87978
88255
|
if (!fs49.existsSync(tsconfigPath)) {
|
|
87979
88256
|
return;
|
|
87980
88257
|
}
|
|
@@ -88011,7 +88288,7 @@ var registerDev = (program2) => {
|
|
|
88011
88288
|
|
|
88012
88289
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
88013
88290
|
console.log(`
|
|
88014
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
88291
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path53.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
88015
88292
|
|
|
88016
88293
|
`);
|
|
88017
88294
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -88041,13 +88318,13 @@ var checkLoggedIn = () => {
|
|
|
88041
88318
|
import { spawnSync } from "node:child_process";
|
|
88042
88319
|
import fs50 from "node:fs";
|
|
88043
88320
|
import os5 from "node:os";
|
|
88044
|
-
import
|
|
88321
|
+
import path54 from "node:path";
|
|
88045
88322
|
var hasBunInstalled = () => {
|
|
88046
88323
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
88047
88324
|
return result.status === 0;
|
|
88048
88325
|
};
|
|
88049
88326
|
var createTempProject = (tempDir) => {
|
|
88050
|
-
const packageJsonPath =
|
|
88327
|
+
const packageJsonPath = path54.join(tempDir, "package.json");
|
|
88051
88328
|
const packageJson = {
|
|
88052
88329
|
name: "tsci-doctor-check",
|
|
88053
88330
|
version: "0.0.0",
|
|
@@ -88067,7 +88344,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
88067
88344
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
88068
88345
|
};
|
|
88069
88346
|
}
|
|
88070
|
-
const tempDir = fs50.mkdtempSync(
|
|
88347
|
+
const tempDir = fs50.mkdtempSync(path54.join(os5.tmpdir(), "tsci-doctor-"));
|
|
88071
88348
|
try {
|
|
88072
88349
|
createTempProject(tempDir);
|
|
88073
88350
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -88139,243 +88416,9 @@ var registerDoctor = (program2) => {
|
|
|
88139
88416
|
|
|
88140
88417
|
// lib/shared/export-snippet.ts
|
|
88141
88418
|
import fs51 from "node:fs";
|
|
88142
|
-
import
|
|
88419
|
+
import path55 from "node:path";
|
|
88143
88420
|
import { promisify as promisify3 } from "node:util";
|
|
88144
88421
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
88145
|
-
|
|
88146
|
-
// node_modules/circuit-json-to-readable-netlist/dist/index.js
|
|
88147
|
-
import { su as su3 } from "@tscircuit/circuit-json-util";
|
|
88148
|
-
import { getFullConnectivityMapFromCircuitJson } from "circuit-json-to-connectivity-map";
|
|
88149
|
-
import { su as su2 } from "@tscircuit/circuit-json-util";
|
|
88150
|
-
import { su as su4 } from "@tscircuit/circuit-json-util";
|
|
88151
|
-
var wordQualityScore = {
|
|
88152
|
-
MISO: 1.2,
|
|
88153
|
-
MOSI: 1.2,
|
|
88154
|
-
SCLK: 1.2,
|
|
88155
|
-
SDA: 1.2,
|
|
88156
|
-
SCL: 1.2,
|
|
88157
|
-
RX: 1.15,
|
|
88158
|
-
TX: 1.15,
|
|
88159
|
-
GPIO: 1.1,
|
|
88160
|
-
cathode: 0.5,
|
|
88161
|
-
anode: 0.5,
|
|
88162
|
-
GND: 1.1,
|
|
88163
|
-
VDD: 1.1,
|
|
88164
|
-
AGND: 1.1,
|
|
88165
|
-
V5: 1.1,
|
|
88166
|
-
V3: 1.1,
|
|
88167
|
-
V1: 1.1,
|
|
88168
|
-
neg: 0.9,
|
|
88169
|
-
pos: 0.9,
|
|
88170
|
-
pin: 0.5,
|
|
88171
|
-
left: 0.3,
|
|
88172
|
-
right: 0.3
|
|
88173
|
-
};
|
|
88174
|
-
var wordQualityScoreEntries = Object.entries(wordQualityScore).sort((a, b) => b[1] - a[1]);
|
|
88175
|
-
var scorePhrase = (phrase) => {
|
|
88176
|
-
if (phrase.match(/\d+/)) {
|
|
88177
|
-
return 0.5;
|
|
88178
|
-
}
|
|
88179
|
-
for (const [word, score] of wordQualityScoreEntries) {
|
|
88180
|
-
if (phrase.includes(word)) {
|
|
88181
|
-
return score;
|
|
88182
|
-
}
|
|
88183
|
-
}
|
|
88184
|
-
return 1;
|
|
88185
|
-
};
|
|
88186
|
-
var getReadableNameForPin = ({
|
|
88187
|
-
circuitJson,
|
|
88188
|
-
source_port_id
|
|
88189
|
-
}) => {
|
|
88190
|
-
const source_ports = su4(circuitJson).source_port.list();
|
|
88191
|
-
const source_components = su4(circuitJson).source_component.list();
|
|
88192
|
-
const port = source_ports.find((p) => p.source_port_id === source_port_id);
|
|
88193
|
-
if (!port)
|
|
88194
|
-
return "";
|
|
88195
|
-
const component = source_components.find((c) => c.source_component_id === port.source_component_id);
|
|
88196
|
-
if (!component)
|
|
88197
|
-
return "";
|
|
88198
|
-
const isPositive = port.port_hints?.some((hint) => ["anode", "pos", "positive"].includes(hint.toLowerCase()));
|
|
88199
|
-
const isNegative = port.port_hints?.some((hint) => ["cathode", "neg", "negative"].includes(hint.toLowerCase()));
|
|
88200
|
-
const mainPinName = port.name ? port.name : `Pin${port.pin_number}`;
|
|
88201
|
-
const additionalPinLabels = [];
|
|
88202
|
-
if (isPositive && component.ftype !== "simple_resistor") {
|
|
88203
|
-
additionalPinLabels.push("+");
|
|
88204
|
-
} else if (isNegative && component.ftype !== "simple_resistor") {
|
|
88205
|
-
additionalPinLabels.push("-");
|
|
88206
|
-
}
|
|
88207
|
-
for (const port_hint of port.port_hints ?? []) {
|
|
88208
|
-
if (port_hint === mainPinName)
|
|
88209
|
-
continue;
|
|
88210
|
-
const score = scorePhrase(port_hint);
|
|
88211
|
-
if (score > 1) {
|
|
88212
|
-
additionalPinLabels.push(port_hint);
|
|
88213
|
-
}
|
|
88214
|
-
}
|
|
88215
|
-
const displayValue = component.display_value ? ` (${component.display_value})` : "";
|
|
88216
|
-
return `${component.name} ${mainPinName}${additionalPinLabels.length > 0 ? ` (${additionalPinLabels.join(",")})` : ""}${displayValue}`;
|
|
88217
|
-
};
|
|
88218
|
-
var scoreComponentOrder = (component) => {
|
|
88219
|
-
if (!("ftype" in component))
|
|
88220
|
-
return 0;
|
|
88221
|
-
if (component.ftype === "simple_resistor")
|
|
88222
|
-
return 0;
|
|
88223
|
-
if (component.ftype === "simple_capacitor")
|
|
88224
|
-
return 1;
|
|
88225
|
-
return 2;
|
|
88226
|
-
};
|
|
88227
|
-
var generateNetName = ({
|
|
88228
|
-
circuitJson,
|
|
88229
|
-
connectedIds
|
|
88230
|
-
}) => {
|
|
88231
|
-
const all_source_components = su2(circuitJson).source_component.list();
|
|
88232
|
-
const sourceComponentIdToScore = /* @__PURE__ */ new Map;
|
|
88233
|
-
for (const component of all_source_components) {
|
|
88234
|
-
sourceComponentIdToScore.set(component.source_component_id, scoreComponentOrder(component));
|
|
88235
|
-
}
|
|
88236
|
-
all_source_components.sort((a, b) => sourceComponentIdToScore.get(b.source_component_id) - sourceComponentIdToScore.get(a.source_component_id));
|
|
88237
|
-
const all_source_ports = su2(circuitJson).source_port.list().sort((a, b) => sourceComponentIdToScore.get(b.source_component_id) - sourceComponentIdToScore.get(a.source_component_id));
|
|
88238
|
-
const all_source_nets = su2(circuitJson).source_net.list();
|
|
88239
|
-
const all_source_traces = su2(circuitJson).source_trace.list();
|
|
88240
|
-
const ports = all_source_ports.filter((p) => connectedIds.includes(p.source_port_id));
|
|
88241
|
-
const nets = all_source_nets.filter((n) => connectedIds.includes(n.source_net_id));
|
|
88242
|
-
const traces = all_source_traces.filter((t) => connectedIds.includes(t.source_trace_id));
|
|
88243
|
-
const possibleNames = ports.flatMap((p) => Array.from(/* @__PURE__ */ new Set([...p.name ? [p.name] : [], ...p.port_hints ?? []]))).concat(nets.map((n) => n.name));
|
|
88244
|
-
const phrases = possibleNames.map((name) => ({
|
|
88245
|
-
name,
|
|
88246
|
-
score: scorePhrase(name)
|
|
88247
|
-
}));
|
|
88248
|
-
const bestPortName = phrases.sort((a, b) => b.score - a.score)[0].name;
|
|
88249
|
-
const bestPort = ports.find((p) => p.name === bestPortName || p.port_hints?.includes(bestPortName));
|
|
88250
|
-
const componentWithBestPort = all_source_components.find((c) => c.source_component_id === bestPort?.source_component_id);
|
|
88251
|
-
return [componentWithBestPort?.name, bestPortName].filter(Boolean).join("_");
|
|
88252
|
-
};
|
|
88253
|
-
var convertCircuitJsonToReadableNetlist = (circuitJson) => {
|
|
88254
|
-
const connectivityMap = getFullConnectivityMapFromCircuitJson(circuitJson.filter((e) => e.type.startsWith("source_")));
|
|
88255
|
-
const netMap = connectivityMap.netMap;
|
|
88256
|
-
const source_ports = su3(circuitJson).source_port.list();
|
|
88257
|
-
const source_components = su3(circuitJson).source_component.list();
|
|
88258
|
-
const source_nets = su3(circuitJson).source_net.list();
|
|
88259
|
-
const source_traces = su3(circuitJson).source_trace.list();
|
|
88260
|
-
const netlist = [];
|
|
88261
|
-
netlist.push("COMPONENTS:");
|
|
88262
|
-
for (const component of source_components) {
|
|
88263
|
-
let componentDescription = "";
|
|
88264
|
-
const cadComponent = su3(circuitJson).cad_component.getWhere({
|
|
88265
|
-
source_component_id: component.source_component_id
|
|
88266
|
-
});
|
|
88267
|
-
const footprint = cadComponent?.footprinter_string;
|
|
88268
|
-
if (component.ftype === "simple_resistor") {
|
|
88269
|
-
componentDescription = `${component.display_resistance}${footprint ? ` ${footprint}` : ""} resistor`;
|
|
88270
|
-
} else if (component.ftype === "simple_capacitor") {
|
|
88271
|
-
componentDescription = `${component.display_capacitance}${footprint ? ` ${footprint}` : ""} capacitor`;
|
|
88272
|
-
} else if (component.ftype === "simple_chip") {
|
|
88273
|
-
const manufacturerPartNumber = component.manufacturer_part_number;
|
|
88274
|
-
componentDescription = [manufacturerPartNumber, footprint].filter(Boolean).join(", ");
|
|
88275
|
-
} else {
|
|
88276
|
-
componentDescription = [component.name, component.type].filter(Boolean).join(", ");
|
|
88277
|
-
}
|
|
88278
|
-
netlist.push(` - ${component.name}: ${componentDescription}`);
|
|
88279
|
-
}
|
|
88280
|
-
netlist.push("");
|
|
88281
|
-
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
88282
|
-
const net2 = source_nets.find((n) => connectedIds.includes(n.source_net_id));
|
|
88283
|
-
let netName = net2?.name;
|
|
88284
|
-
if (!netName) {
|
|
88285
|
-
netName = generateNetName({ circuitJson, connectedIds });
|
|
88286
|
-
}
|
|
88287
|
-
const connectedPortCount = connectedIds.filter((id) => id.startsWith("source_port")).length;
|
|
88288
|
-
if (connectedPortCount <= 1)
|
|
88289
|
-
continue;
|
|
88290
|
-
netlist.push(`NET: ${netName}`);
|
|
88291
|
-
for (const id of connectedIds) {
|
|
88292
|
-
const pinName = getReadableNameForPin({
|
|
88293
|
-
circuitJson,
|
|
88294
|
-
source_port_id: id
|
|
88295
|
-
});
|
|
88296
|
-
if (pinName) {
|
|
88297
|
-
netlist.push(` - ${pinName}`);
|
|
88298
|
-
}
|
|
88299
|
-
}
|
|
88300
|
-
netlist.push("");
|
|
88301
|
-
}
|
|
88302
|
-
let hasEmptyNets = false;
|
|
88303
|
-
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
88304
|
-
const connectedPortCount = connectedIds.filter((id) => id.startsWith("source_port")).length;
|
|
88305
|
-
if (connectedPortCount === 1) {
|
|
88306
|
-
if (!hasEmptyNets) {
|
|
88307
|
-
netlist.push("");
|
|
88308
|
-
netlist.push("EMPTY NET PINS:");
|
|
88309
|
-
hasEmptyNets = true;
|
|
88310
|
-
}
|
|
88311
|
-
const source_port_id = netMap[netId].find((id) => id.startsWith("source_port"));
|
|
88312
|
-
const pinName = getReadableNameForPin({
|
|
88313
|
-
circuitJson,
|
|
88314
|
-
source_port_id
|
|
88315
|
-
});
|
|
88316
|
-
if (pinName) {
|
|
88317
|
-
netlist.push(` - ${pinName}`);
|
|
88318
|
-
}
|
|
88319
|
-
}
|
|
88320
|
-
}
|
|
88321
|
-
const portIdToNetNames = {};
|
|
88322
|
-
for (const [netId, connectedIds] of Object.entries(netMap)) {
|
|
88323
|
-
const portIds = connectedIds.filter((id) => id.startsWith("source_port"));
|
|
88324
|
-
if (portIds.length === 0)
|
|
88325
|
-
continue;
|
|
88326
|
-
const net2 = source_nets.find((n) => connectedIds.includes(n.source_net_id));
|
|
88327
|
-
let netName = net2?.name;
|
|
88328
|
-
if (!netName) {
|
|
88329
|
-
netName = generateNetName({ circuitJson, connectedIds });
|
|
88330
|
-
}
|
|
88331
|
-
for (const portId of portIds) {
|
|
88332
|
-
if (!portIdToNetNames[portId])
|
|
88333
|
-
portIdToNetNames[portId] = [];
|
|
88334
|
-
portIdToNetNames[portId].push(netName);
|
|
88335
|
-
}
|
|
88336
|
-
}
|
|
88337
|
-
if (source_components.length > 0) {
|
|
88338
|
-
netlist.push("");
|
|
88339
|
-
netlist.push("COMPONENT_PINS:");
|
|
88340
|
-
for (const component of source_components) {
|
|
88341
|
-
const cadComponent = su3(circuitJson).cad_component.getWhere({
|
|
88342
|
-
source_component_id: component.source_component_id
|
|
88343
|
-
});
|
|
88344
|
-
const footprint = cadComponent?.footprinter_string;
|
|
88345
|
-
let header = component.name;
|
|
88346
|
-
if (component.ftype === "simple_resistor") {
|
|
88347
|
-
header = `${component.name} (${component.display_resistance} ${footprint})`;
|
|
88348
|
-
} else if (component.ftype === "simple_capacitor") {
|
|
88349
|
-
header = `${component.name} (${component.display_capacitance} ${footprint})`;
|
|
88350
|
-
} else if (component.manufacturer_part_number) {
|
|
88351
|
-
header = `${component.name} (${component.manufacturer_part_number})`;
|
|
88352
|
-
}
|
|
88353
|
-
netlist.push(header);
|
|
88354
|
-
const ports = source_ports.filter((p) => p.source_component_id === component.source_component_id).sort((a, b) => (a.pin_number ?? 0) - (b.pin_number ?? 0));
|
|
88355
|
-
for (const port of ports) {
|
|
88356
|
-
const mainPin = port.pin_number !== undefined ? `pin${port.pin_number}` : port.name;
|
|
88357
|
-
const aliases = [];
|
|
88358
|
-
if (port.name && port.name !== mainPin)
|
|
88359
|
-
aliases.push(port.name);
|
|
88360
|
-
for (const hint of port.port_hints ?? []) {
|
|
88361
|
-
if (hint === String(port.pin_number))
|
|
88362
|
-
continue;
|
|
88363
|
-
if (hint !== mainPin && hint !== port.name)
|
|
88364
|
-
aliases.push(hint);
|
|
88365
|
-
}
|
|
88366
|
-
const aliasPart = aliases.length > 0 ? `(${Array.from(new Set(aliases)).join(", ")})` : "";
|
|
88367
|
-
const nets = portIdToNetNames[port.source_port_id] ?? [];
|
|
88368
|
-
const netsPart = nets.length > 0 ? `NETS(${nets.join(", ")})` : "NOT_CONNECTED";
|
|
88369
|
-
netlist.push(`- ${mainPin}${aliasPart}: ${netsPart}`);
|
|
88370
|
-
}
|
|
88371
|
-
netlist.push("");
|
|
88372
|
-
}
|
|
88373
|
-
}
|
|
88374
|
-
return netlist.join(`
|
|
88375
|
-
`);
|
|
88376
|
-
};
|
|
88377
|
-
|
|
88378
|
-
// lib/shared/export-snippet.ts
|
|
88379
88422
|
import {
|
|
88380
88423
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
88381
88424
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
|
|
@@ -89212,9 +89255,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
89212
89255
|
const stringifyCoordinates = (coordinates) => {
|
|
89213
89256
|
return coordinates.join(" ");
|
|
89214
89257
|
};
|
|
89215
|
-
const stringifyPath = (
|
|
89258
|
+
const stringifyPath = (path55, level) => {
|
|
89216
89259
|
const padding = indent.repeat(level);
|
|
89217
|
-
return `${padding}(path ${
|
|
89260
|
+
return `${padding}(path ${path55.layer} ${path55.width} ${stringifyCoordinates(path55.coordinates)})`;
|
|
89218
89261
|
};
|
|
89219
89262
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
89220
89263
|
`;
|
|
@@ -89441,10 +89484,10 @@ var exportSnippet = async ({
|
|
|
89441
89484
|
onError(`Invalid format: ${format}`);
|
|
89442
89485
|
return onExit(1);
|
|
89443
89486
|
}
|
|
89444
|
-
const projectDir =
|
|
89445
|
-
const outputBaseName =
|
|
89487
|
+
const projectDir = path55.dirname(filePath);
|
|
89488
|
+
const outputBaseName = path55.basename(filePath).replace(/\.[^.]+$/, "");
|
|
89446
89489
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
89447
|
-
const outputDestination =
|
|
89490
|
+
const outputDestination = path55.join(projectDir, outputPath ?? outputFileName);
|
|
89448
89491
|
if (format === "kicad-library") {
|
|
89449
89492
|
try {
|
|
89450
89493
|
const result = await convertToKicadLibrary({
|
|
@@ -89642,11 +89685,11 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
89642
89685
|
|
|
89643
89686
|
// lib/eecircuit-engine/run-simulation.ts
|
|
89644
89687
|
import { promises as fs52, existsSync as existsSync13 } from "node:fs";
|
|
89645
|
-
import
|
|
89688
|
+
import path56 from "node:path";
|
|
89646
89689
|
import os6 from "node:os";
|
|
89647
89690
|
var sim = null;
|
|
89648
89691
|
var fetchSimulation = async () => {
|
|
89649
|
-
const tempFilePath =
|
|
89692
|
+
const tempFilePath = path56.join(os6.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
89650
89693
|
if (!existsSync13(tempFilePath)) {
|
|
89651
89694
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
89652
89695
|
const response = await fetch(url);
|
|
@@ -89743,7 +89786,7 @@ var resultToCsv = (result) => {
|
|
|
89743
89786
|
};
|
|
89744
89787
|
|
|
89745
89788
|
// cli/export/register.ts
|
|
89746
|
-
import
|
|
89789
|
+
import path57 from "node:path";
|
|
89747
89790
|
import { promises as fs53 } from "node:fs";
|
|
89748
89791
|
var registerExport = (program2) => {
|
|
89749
89792
|
program2.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").action(async (file, options) => {
|
|
@@ -89756,7 +89799,7 @@ var registerExport = (program2) => {
|
|
|
89756
89799
|
});
|
|
89757
89800
|
if (circuitJson) {
|
|
89758
89801
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
89759
|
-
const outputSpicePath = options.output ??
|
|
89802
|
+
const outputSpicePath = options.output ?? path57.join(path57.dirname(file), `${path57.basename(file, path57.extname(file))}.spice.cir`);
|
|
89760
89803
|
await fs53.writeFile(outputSpicePath, spiceString);
|
|
89761
89804
|
const { result } = await runSimulation(spiceString);
|
|
89762
89805
|
const csvContent = resultToCsv(result);
|
|
@@ -91229,8 +91272,8 @@ function getErrorMap() {
|
|
|
91229
91272
|
return overrideErrorMap;
|
|
91230
91273
|
}
|
|
91231
91274
|
var makeIssue = (params2) => {
|
|
91232
|
-
const { data, path:
|
|
91233
|
-
const fullPath = [...
|
|
91275
|
+
const { data, path: path58, errorMaps, issueData } = params2;
|
|
91276
|
+
const fullPath = [...path58, ...issueData.path || []];
|
|
91234
91277
|
const fullIssue = {
|
|
91235
91278
|
...issueData,
|
|
91236
91279
|
path: fullPath
|
|
@@ -91338,11 +91381,11 @@ var errorUtil;
|
|
|
91338
91381
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
91339
91382
|
})(errorUtil || (errorUtil = {}));
|
|
91340
91383
|
var ParseInputLazyPath = class {
|
|
91341
|
-
constructor(parent, value,
|
|
91384
|
+
constructor(parent, value, path58, key) {
|
|
91342
91385
|
this._cachedPath = [];
|
|
91343
91386
|
this.parent = parent;
|
|
91344
91387
|
this.data = value;
|
|
91345
|
-
this._path =
|
|
91388
|
+
this._path = path58;
|
|
91346
91389
|
this._key = key;
|
|
91347
91390
|
}
|
|
91348
91391
|
get path() {
|
|
@@ -102440,11 +102483,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102440
102483
|
fiber = fiber.next, id--;
|
|
102441
102484
|
return fiber;
|
|
102442
102485
|
}
|
|
102443
|
-
function copyWithSetImpl(obj,
|
|
102444
|
-
if (index >=
|
|
102486
|
+
function copyWithSetImpl(obj, path58, index, value) {
|
|
102487
|
+
if (index >= path58.length)
|
|
102445
102488
|
return value;
|
|
102446
|
-
var key =
|
|
102447
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
102489
|
+
var key = path58[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
102490
|
+
updated[key] = copyWithSetImpl(obj[key], path58, index + 1, value);
|
|
102448
102491
|
return updated;
|
|
102449
102492
|
}
|
|
102450
102493
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -102464,11 +102507,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102464
102507
|
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);
|
|
102465
102508
|
return updated;
|
|
102466
102509
|
}
|
|
102467
|
-
function copyWithDeleteImpl(obj,
|
|
102468
|
-
var key =
|
|
102469
|
-
if (index + 1 ===
|
|
102510
|
+
function copyWithDeleteImpl(obj, path58, index) {
|
|
102511
|
+
var key = path58[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
102512
|
+
if (index + 1 === path58.length)
|
|
102470
102513
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
102471
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
102514
|
+
updated[key] = copyWithDeleteImpl(obj[key], path58, index + 1);
|
|
102472
102515
|
return updated;
|
|
102473
102516
|
}
|
|
102474
102517
|
function shouldSuspendImpl() {
|
|
@@ -111494,29 +111537,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
111494
111537
|
var didWarnAboutNestedUpdates = false;
|
|
111495
111538
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
111496
111539
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
111497
|
-
overrideHookState = function(fiber, id,
|
|
111540
|
+
overrideHookState = function(fiber, id, path58, value) {
|
|
111498
111541
|
id = findHook(fiber, id);
|
|
111499
|
-
id !== null && (
|
|
111542
|
+
id !== null && (path58 = copyWithSetImpl(id.memoizedState, path58, 0, value), id.memoizedState = path58, id.baseState = path58, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path58 = enqueueConcurrentRenderForLane(fiber, 2), path58 !== null && scheduleUpdateOnFiber(path58, fiber, 2));
|
|
111500
111543
|
};
|
|
111501
|
-
overrideHookStateDeletePath = function(fiber, id,
|
|
111544
|
+
overrideHookStateDeletePath = function(fiber, id, path58) {
|
|
111502
111545
|
id = findHook(fiber, id);
|
|
111503
|
-
id !== null && (
|
|
111546
|
+
id !== null && (path58 = copyWithDeleteImpl(id.memoizedState, path58, 0), id.memoizedState = path58, id.baseState = path58, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path58 = enqueueConcurrentRenderForLane(fiber, 2), path58 !== null && scheduleUpdateOnFiber(path58, fiber, 2));
|
|
111504
111547
|
};
|
|
111505
111548
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
111506
111549
|
id = findHook(fiber, id);
|
|
111507
111550
|
id !== null && (oldPath = copyWithRename(id.memoizedState, oldPath, newPath), id.memoizedState = oldPath, id.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
111508
111551
|
};
|
|
111509
|
-
overrideProps = function(fiber,
|
|
111510
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
111552
|
+
overrideProps = function(fiber, path58, value) {
|
|
111553
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path58, 0, value);
|
|
111511
111554
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
111512
|
-
|
|
111513
|
-
|
|
111555
|
+
path58 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
111556
|
+
path58 !== null && scheduleUpdateOnFiber(path58, fiber, 2);
|
|
111514
111557
|
};
|
|
111515
|
-
overridePropsDeletePath = function(fiber,
|
|
111516
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
111558
|
+
overridePropsDeletePath = function(fiber, path58) {
|
|
111559
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path58, 0);
|
|
111517
111560
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
111518
|
-
|
|
111519
|
-
|
|
111561
|
+
path58 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
111562
|
+
path58 !== null && scheduleUpdateOnFiber(path58, fiber, 2);
|
|
111520
111563
|
};
|
|
111521
111564
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
111522
111565
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -117819,7 +117862,7 @@ var parsePin = (pinString) => {
|
|
|
117819
117862
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
117820
117863
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
117821
117864
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
117822
|
-
const
|
|
117865
|
+
const path58 = pathMatch ? pathMatch[1] : "";
|
|
117823
117866
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
117824
117867
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
117825
117868
|
const r2 = Number.parseFloat(rotation4);
|
|
@@ -117833,7 +117876,7 @@ var parsePin = (pinString) => {
|
|
|
117833
117876
|
rotation: Number.isNaN(r2) ? 0 : r2,
|
|
117834
117877
|
label,
|
|
117835
117878
|
labelColor,
|
|
117836
|
-
path:
|
|
117879
|
+
path: path58,
|
|
117837
117880
|
arrow
|
|
117838
117881
|
};
|
|
117839
117882
|
};
|
|
@@ -118273,15 +118316,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
118273
118316
|
}
|
|
118274
118317
|
}
|
|
118275
118318
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
118276
|
-
const
|
|
118319
|
+
const path58 = [];
|
|
118277
118320
|
for (let i22 = 0;i22 <= numPoints; i22++) {
|
|
118278
118321
|
const t3 = i22 / numPoints;
|
|
118279
118322
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
118280
118323
|
const x22 = centerX + radius * Math.cos(angle2);
|
|
118281
118324
|
const y22 = centerY + radius * Math.sin(angle2);
|
|
118282
|
-
|
|
118325
|
+
path58.push({ x: x22, y: y22 });
|
|
118283
118326
|
}
|
|
118284
|
-
return
|
|
118327
|
+
return path58;
|
|
118285
118328
|
}
|
|
118286
118329
|
var __defProp4 = Object.defineProperty;
|
|
118287
118330
|
var __export22 = (target, all) => {
|
|
@@ -127360,17 +127403,17 @@ var ObstacleList = class {
|
|
|
127360
127403
|
return obstacles;
|
|
127361
127404
|
}
|
|
127362
127405
|
};
|
|
127363
|
-
function removePathLoops(
|
|
127364
|
-
if (
|
|
127365
|
-
return
|
|
127366
|
-
const result = [{ ...
|
|
127367
|
-
let currentLayer =
|
|
127368
|
-
for (let i22 = 1;i22 <
|
|
127369
|
-
const currentSegment = { start:
|
|
127370
|
-
const isVia =
|
|
127371
|
-
if (
|
|
127372
|
-
result.push({ ...
|
|
127373
|
-
currentLayer =
|
|
127406
|
+
function removePathLoops(path58) {
|
|
127407
|
+
if (path58.length < 4)
|
|
127408
|
+
return path58;
|
|
127409
|
+
const result = [{ ...path58[0] }];
|
|
127410
|
+
let currentLayer = path58[0].layer;
|
|
127411
|
+
for (let i22 = 1;i22 < path58.length; i22++) {
|
|
127412
|
+
const currentSegment = { start: path58[i22 - 1], end: path58[i22] };
|
|
127413
|
+
const isVia = path58[i22].route_type === "via" || path58[i22 - 1].route_type === "via";
|
|
127414
|
+
if (path58[i22].layer !== currentLayer || isVia) {
|
|
127415
|
+
result.push({ ...path58[i22] });
|
|
127416
|
+
currentLayer = path58[i22].layer;
|
|
127374
127417
|
continue;
|
|
127375
127418
|
}
|
|
127376
127419
|
let intersectionFound = false;
|
|
@@ -127399,8 +127442,8 @@ function removePathLoops(path57) {
|
|
|
127399
127442
|
result.push(intersectionPoint);
|
|
127400
127443
|
}
|
|
127401
127444
|
const lastPoint = result[result.length - 1];
|
|
127402
|
-
if (lastPoint.x !==
|
|
127403
|
-
result.push(
|
|
127445
|
+
if (lastPoint.x !== path58[i22].x || lastPoint.y !== path58[i22].y) {
|
|
127446
|
+
result.push(path58[i22]);
|
|
127404
127447
|
}
|
|
127405
127448
|
}
|
|
127406
127449
|
return result;
|
|
@@ -127889,10 +127932,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
127889
127932
|
});
|
|
127890
127933
|
}
|
|
127891
127934
|
if (current2.parent) {
|
|
127892
|
-
const
|
|
127935
|
+
const path58 = [];
|
|
127893
127936
|
let p22 = current2;
|
|
127894
127937
|
while (p22) {
|
|
127895
|
-
|
|
127938
|
+
path58.unshift(p22);
|
|
127896
127939
|
p22 = p22.parent;
|
|
127897
127940
|
}
|
|
127898
127941
|
debugSolution.push({
|
|
@@ -127900,7 +127943,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
127900
127943
|
pcb_component_id: "",
|
|
127901
127944
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
127902
127945
|
layer: "top",
|
|
127903
|
-
route:
|
|
127946
|
+
route: path58,
|
|
127904
127947
|
stroke_width: 0.01
|
|
127905
127948
|
});
|
|
127906
127949
|
}
|
|
@@ -152345,10 +152388,10 @@ var findFirstCollision = (pts, rects, opts = {}) => {
|
|
|
152345
152388
|
}
|
|
152346
152389
|
return null;
|
|
152347
152390
|
};
|
|
152348
|
-
var isPathCollidingWithObstacles = (
|
|
152349
|
-
for (let i22 = 0;i22 <
|
|
152391
|
+
var isPathCollidingWithObstacles = (path58, obstacles) => {
|
|
152392
|
+
for (let i22 = 0;i22 < path58.length - 1; i22++) {
|
|
152350
152393
|
for (const obstacle of obstacles) {
|
|
152351
|
-
if (segmentIntersectsRect(
|
|
152394
|
+
if (segmentIntersectsRect(path58[i22], path58[i22 + 1], obstacle)) {
|
|
152352
152395
|
return true;
|
|
152353
152396
|
}
|
|
152354
152397
|
}
|
|
@@ -152542,36 +152585,36 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152542
152585
|
this.error = "No collision-free path found";
|
|
152543
152586
|
return;
|
|
152544
152587
|
}
|
|
152545
|
-
const { path:
|
|
152588
|
+
const { path: path58, collisionChipIds } = state;
|
|
152546
152589
|
const [PA, PB] = this.pins;
|
|
152547
|
-
const collision = findFirstCollision(
|
|
152590
|
+
const collision = findFirstCollision(path58, this.obstacles);
|
|
152548
152591
|
if (!collision) {
|
|
152549
|
-
const first =
|
|
152550
|
-
const last =
|
|
152592
|
+
const first = path58[0];
|
|
152593
|
+
const last = path58[path58.length - 1];
|
|
152551
152594
|
const EPS42 = 0.000000001;
|
|
152552
152595
|
const samePoint = (p22, q22) => Math.abs(p22.x - q22.x) < EPS42 && Math.abs(p22.y - q22.y) < EPS42;
|
|
152553
152596
|
if (samePoint(first, { x: PA.x, y: PA.y }) && samePoint(last, { x: PB.x, y: PB.y })) {
|
|
152554
|
-
this.solvedTracePath =
|
|
152597
|
+
this.solvedTracePath = path58;
|
|
152555
152598
|
this.solved = true;
|
|
152556
152599
|
}
|
|
152557
152600
|
return;
|
|
152558
152601
|
}
|
|
152559
152602
|
let { segIndex, rect } = collision;
|
|
152560
152603
|
const isFirstSegment = segIndex === 0;
|
|
152561
|
-
const isLastSegment = segIndex ===
|
|
152604
|
+
const isLastSegment = segIndex === path58.length - 2;
|
|
152562
152605
|
if (isFirstSegment) {
|
|
152563
|
-
if (
|
|
152606
|
+
if (path58.length < 3) {
|
|
152564
152607
|
return;
|
|
152565
152608
|
}
|
|
152566
152609
|
segIndex = 1;
|
|
152567
152610
|
} else if (isLastSegment) {
|
|
152568
|
-
if (
|
|
152611
|
+
if (path58.length < 3) {
|
|
152569
152612
|
return;
|
|
152570
152613
|
}
|
|
152571
|
-
segIndex =
|
|
152614
|
+
segIndex = path58.length - 3;
|
|
152572
152615
|
}
|
|
152573
|
-
const a22 =
|
|
152574
|
-
const b22 =
|
|
152616
|
+
const a22 = path58[segIndex];
|
|
152617
|
+
const b22 = path58[segIndex + 1];
|
|
152575
152618
|
const axis = this.axisOfSegment(a22, b22);
|
|
152576
152619
|
if (!axis) {
|
|
152577
152620
|
return;
|
|
@@ -152589,7 +152632,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152589
152632
|
}
|
|
152590
152633
|
const newStates = [];
|
|
152591
152634
|
for (const coord of candidates) {
|
|
152592
|
-
const newPath = shiftSegmentOrth(
|
|
152635
|
+
const newPath = shiftSegmentOrth(path58, segIndex, axis, coord);
|
|
152593
152636
|
if (!newPath)
|
|
152594
152637
|
continue;
|
|
152595
152638
|
const key = pathKey(newPath);
|
|
@@ -152625,8 +152668,8 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152625
152668
|
strokeColor: "blue",
|
|
152626
152669
|
strokeDash: "5 5"
|
|
152627
152670
|
});
|
|
152628
|
-
for (const { path:
|
|
152629
|
-
g22.lines.push({ points:
|
|
152671
|
+
for (const { path: path58, collisionChipIds: collisionRectIds } of this.queue) {
|
|
152672
|
+
g22.lines.push({ points: path58, strokeColor: "teal", strokeDash: "2 2" });
|
|
152630
152673
|
}
|
|
152631
152674
|
if (this.solvedTracePath) {
|
|
152632
152675
|
g22.lines.push({ points: this.solvedTracePath, strokeColor: "green" });
|
|
@@ -152863,9 +152906,9 @@ var TraceOverlapIssueSolver = class extends BaseSolver3 {
|
|
|
152863
152906
|
solvedTracePathIndex,
|
|
152864
152907
|
traceSegmentIndex
|
|
152865
152908
|
} of group.pathsWithOverlap) {
|
|
152866
|
-
const
|
|
152867
|
-
const segStart =
|
|
152868
|
-
const segEnd =
|
|
152909
|
+
const path58 = this.traceNetIslands[group.connNetId][solvedTracePathIndex];
|
|
152910
|
+
const segStart = path58.tracePath[traceSegmentIndex];
|
|
152911
|
+
const segEnd = path58.tracePath[traceSegmentIndex + 1];
|
|
152869
152912
|
graphics.lines.push({
|
|
152870
152913
|
points: [segStart, segEnd],
|
|
152871
152914
|
strokeColor: "red"
|
|
@@ -152909,11 +152952,11 @@ var TraceOverlapShiftSolver = class extends BaseSolver3 {
|
|
|
152909
152952
|
computeTraceNetIslands() {
|
|
152910
152953
|
const islands = {};
|
|
152911
152954
|
for (const original of this.inputTracePaths) {
|
|
152912
|
-
const
|
|
152913
|
-
const key =
|
|
152955
|
+
const path58 = this.correctedTraceMap[original.mspPairId] ?? original;
|
|
152956
|
+
const key = path58.globalConnNetId;
|
|
152914
152957
|
if (!islands[key])
|
|
152915
152958
|
islands[key] = [];
|
|
152916
|
-
islands[key].push(
|
|
152959
|
+
islands[key].push(path58);
|
|
152917
152960
|
}
|
|
152918
152961
|
return islands;
|
|
152919
152962
|
}
|
|
@@ -153161,9 +153204,9 @@ function rectIntersectsAnyTrace(bounds, inputTraceMap, hostPathId, hostSegIndex)
|
|
|
153161
153204
|
}
|
|
153162
153205
|
return { hasIntersection: false };
|
|
153163
153206
|
}
|
|
153164
|
-
function lengthOfTrace(
|
|
153207
|
+
function lengthOfTrace(path58) {
|
|
153165
153208
|
let sum = 0;
|
|
153166
|
-
const pts =
|
|
153209
|
+
const pts = path58.tracePath;
|
|
153167
153210
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
153168
153211
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
153169
153212
|
}
|
|
@@ -153692,9 +153735,9 @@ var NetLabelPlacementSolver = class extends BaseSolver3 {
|
|
|
153692
153735
|
}
|
|
153693
153736
|
const compTraces = (byGlobal[globalConnNetId] ?? []).filter((t3) => component.has(t3.pins[0].pinId) && component.has(t3.pins[1].pinId));
|
|
153694
153737
|
if (compTraces.length > 0) {
|
|
153695
|
-
const lengthOf = (
|
|
153738
|
+
const lengthOf = (path58) => {
|
|
153696
153739
|
let sum = 0;
|
|
153697
|
-
const pts =
|
|
153740
|
+
const pts = path58.tracePath;
|
|
153698
153741
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
153699
153742
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
153700
153743
|
}
|
|
@@ -153839,12 +153882,12 @@ var detectTraceLabelOverlap = (traces, netLabels) => {
|
|
|
153839
153882
|
}
|
|
153840
153883
|
return overlaps;
|
|
153841
153884
|
};
|
|
153842
|
-
var findTraceViolationZone = (
|
|
153885
|
+
var findTraceViolationZone = (path58, labelBounds) => {
|
|
153843
153886
|
const isPointInside = (p22) => p22.x > labelBounds.minX && p22.x < labelBounds.maxX && p22.y > labelBounds.minY && p22.y < labelBounds.maxY;
|
|
153844
153887
|
let firstInsideIndex = -1;
|
|
153845
153888
|
let lastInsideIndex = -1;
|
|
153846
|
-
for (let i22 = 0;i22 <
|
|
153847
|
-
if (isPointInside(
|
|
153889
|
+
for (let i22 = 0;i22 < path58.length; i22++) {
|
|
153890
|
+
if (isPointInside(path58[i22])) {
|
|
153848
153891
|
if (firstInsideIndex === -1) {
|
|
153849
153892
|
firstInsideIndex = i22;
|
|
153850
153893
|
}
|
|
@@ -153853,20 +153896,20 @@ var findTraceViolationZone = (path57, labelBounds) => {
|
|
|
153853
153896
|
}
|
|
153854
153897
|
return { firstInsideIndex, lastInsideIndex };
|
|
153855
153898
|
};
|
|
153856
|
-
var simplifyPath = (
|
|
153857
|
-
if (
|
|
153858
|
-
return
|
|
153859
|
-
const newPath = [
|
|
153860
|
-
for (let i22 = 1;i22 <
|
|
153899
|
+
var simplifyPath = (path58) => {
|
|
153900
|
+
if (path58.length < 3)
|
|
153901
|
+
return path58;
|
|
153902
|
+
const newPath = [path58[0]];
|
|
153903
|
+
for (let i22 = 1;i22 < path58.length - 1; i22++) {
|
|
153861
153904
|
const p12 = newPath[newPath.length - 1];
|
|
153862
|
-
const p22 =
|
|
153863
|
-
const p32 =
|
|
153905
|
+
const p22 = path58[i22];
|
|
153906
|
+
const p32 = path58[i22 + 1];
|
|
153864
153907
|
if (isVertical(p12, p22) && isVertical(p22, p32) || isHorizontal(p12, p22) && isHorizontal(p22, p32)) {
|
|
153865
153908
|
continue;
|
|
153866
153909
|
}
|
|
153867
153910
|
newPath.push(p22);
|
|
153868
153911
|
}
|
|
153869
|
-
newPath.push(
|
|
153912
|
+
newPath.push(path58[path58.length - 1]);
|
|
153870
153913
|
if (newPath.length < 3)
|
|
153871
153914
|
return newPath;
|
|
153872
153915
|
const finalPath = [newPath[0]];
|
|
@@ -154126,12 +154169,12 @@ var hasCollisionsWithLabels = (pathSegments, labels) => {
|
|
|
154126
154169
|
return false;
|
|
154127
154170
|
};
|
|
154128
154171
|
var minimizeTurns = ({
|
|
154129
|
-
path:
|
|
154172
|
+
path: path58,
|
|
154130
154173
|
obstacles,
|
|
154131
154174
|
labelBounds
|
|
154132
154175
|
}) => {
|
|
154133
|
-
if (
|
|
154134
|
-
return
|
|
154176
|
+
if (path58.length <= 2) {
|
|
154177
|
+
return path58;
|
|
154135
154178
|
}
|
|
154136
154179
|
const recognizeStairStepPattern = (pathToCheck, startIdx) => {
|
|
154137
154180
|
if (startIdx >= pathToCheck.length - 3)
|
|
@@ -154163,7 +154206,7 @@ var minimizeTurns = ({
|
|
|
154163
154206
|
}
|
|
154164
154207
|
return isStairStep && endIdx - startIdx >= 3 ? endIdx : -1;
|
|
154165
154208
|
};
|
|
154166
|
-
let optimizedPath = [...
|
|
154209
|
+
let optimizedPath = [...path58];
|
|
154167
154210
|
let currentTurns = countTurns(optimizedPath);
|
|
154168
154211
|
let improved = true;
|
|
154169
154212
|
while (improved) {
|
|
@@ -161768,9 +161811,9 @@ var getFileExtension = (filename) => {
|
|
|
161768
161811
|
const extension = lastSegment.split(".").pop();
|
|
161769
161812
|
return extension?.toLowerCase() ?? null;
|
|
161770
161813
|
};
|
|
161771
|
-
var joinUrlPath = (base,
|
|
161814
|
+
var joinUrlPath = (base, path58) => {
|
|
161772
161815
|
const trimmedBase = base.replace(/\/+$/, "");
|
|
161773
|
-
const trimmedPath =
|
|
161816
|
+
const trimmedPath = path58.replace(/^\/+/, "");
|
|
161774
161817
|
return `${trimmedBase}/${trimmedPath}`;
|
|
161775
161818
|
};
|
|
161776
161819
|
var constructAssetUrl = (targetUrl, baseUrl) => {
|
|
@@ -163084,7 +163127,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163084
163127
|
for (let i22 = 0;i22 < portsWithPosition.length - 1; i22++) {
|
|
163085
163128
|
const start = portsWithPosition[i22];
|
|
163086
163129
|
const end = portsWithPosition[i22 + 1];
|
|
163087
|
-
const
|
|
163130
|
+
const path58 = calculateElbow({
|
|
163088
163131
|
x: start.position.x,
|
|
163089
163132
|
y: start.position.y,
|
|
163090
163133
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -163093,8 +163136,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163093
163136
|
y: end.position.y,
|
|
163094
163137
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
163095
163138
|
});
|
|
163096
|
-
for (let j22 = 0;j22 <
|
|
163097
|
-
elbowEdges.push({ from:
|
|
163139
|
+
for (let j22 = 0;j22 < path58.length - 1; j22++) {
|
|
163140
|
+
elbowEdges.push({ from: path58[j22], to: path58[j22 + 1] });
|
|
163098
163141
|
}
|
|
163099
163142
|
}
|
|
163100
163143
|
const doesSegmentIntersectRect2 = (edge, rect) => {
|
|
@@ -164287,20 +164330,20 @@ var parseLibraryFootprintRef = (s22) => {
|
|
|
164287
164330
|
};
|
|
164288
164331
|
var isStaticAssetPath = (s22) => s22.startsWith("/");
|
|
164289
164332
|
var resolveStaticFileImportDebug = (0, import_debug92.default)("tscircuit:core:resolveStaticFileImport");
|
|
164290
|
-
async function resolveStaticFileImport(
|
|
164291
|
-
if (!
|
|
164292
|
-
return
|
|
164333
|
+
async function resolveStaticFileImport(path58, platform) {
|
|
164334
|
+
if (!path58)
|
|
164335
|
+
return path58;
|
|
164293
164336
|
const resolver = platform?.resolveProjectStaticFileImportUrl;
|
|
164294
|
-
if (resolver &&
|
|
164337
|
+
if (resolver && path58.startsWith("/")) {
|
|
164295
164338
|
try {
|
|
164296
|
-
const resolved = await resolver(
|
|
164339
|
+
const resolved = await resolver(path58);
|
|
164297
164340
|
if (resolved)
|
|
164298
164341
|
return resolved;
|
|
164299
164342
|
} catch (error) {
|
|
164300
164343
|
resolveStaticFileImportDebug("failed to resolve static file via platform resolver", error);
|
|
164301
164344
|
}
|
|
164302
164345
|
}
|
|
164303
|
-
return constructAssetUrl(
|
|
164346
|
+
return constructAssetUrl(path58, platform?.projectBaseUrl);
|
|
164304
164347
|
}
|
|
164305
164348
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
164306
164349
|
let { footprint } = component.props;
|
|
@@ -171947,7 +171990,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
171947
171990
|
}
|
|
171948
171991
|
const portPos = port._getGlobalSchematicPositionAfterLayout();
|
|
171949
171992
|
const portFacing = convertFacingDirectionToElbowDirection(port.facingDirection ?? "right") ?? "x+";
|
|
171950
|
-
const
|
|
171993
|
+
const path58 = calculateElbow({
|
|
171951
171994
|
x: portPos.x,
|
|
171952
171995
|
y: portPos.y,
|
|
171953
171996
|
facingDirection: portFacing
|
|
@@ -171956,13 +171999,13 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
171956
171999
|
y: anchorPos.y,
|
|
171957
172000
|
facingDirection: anchorFacing
|
|
171958
172001
|
});
|
|
171959
|
-
if (!Array.isArray(
|
|
172002
|
+
if (!Array.isArray(path58) || path58.length < 2)
|
|
171960
172003
|
continue;
|
|
171961
172004
|
const edges = [];
|
|
171962
|
-
for (let i22 = 0;i22 <
|
|
172005
|
+
for (let i22 = 0;i22 < path58.length - 1; i22++) {
|
|
171963
172006
|
edges.push({
|
|
171964
|
-
from: { x:
|
|
171965
|
-
to: { x:
|
|
172007
|
+
from: { x: path58[i22].x, y: path58[i22].y },
|
|
172008
|
+
to: { x: path58[i22 + 1].x, y: path58[i22 + 1].y }
|
|
171966
172009
|
});
|
|
171967
172010
|
}
|
|
171968
172011
|
let source_trace_id;
|
|
@@ -174275,7 +174318,7 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
174275
174318
|
|
|
174276
174319
|
// lib/import/import-component-from-jlcpcb.ts
|
|
174277
174320
|
import fs56 from "node:fs/promises";
|
|
174278
|
-
import
|
|
174321
|
+
import path58 from "node:path";
|
|
174279
174322
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
174280
174323
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
174281
174324
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -174283,9 +174326,9 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
174283
174326
|
if (!fileName) {
|
|
174284
174327
|
throw new Error("Could not determine file name of converted component");
|
|
174285
174328
|
}
|
|
174286
|
-
const importsDir =
|
|
174329
|
+
const importsDir = path58.join(projectDir, "imports");
|
|
174287
174330
|
await fs56.mkdir(importsDir, { recursive: true });
|
|
174288
|
-
const filePath =
|
|
174331
|
+
const filePath = path58.join(importsDir, `${fileName}.tsx`);
|
|
174289
174332
|
await fs56.writeFile(filePath, tsx);
|
|
174290
174333
|
return { filePath };
|
|
174291
174334
|
};
|
|
@@ -175631,12 +175674,12 @@ var registerImport = (program2) => {
|
|
|
175631
175674
|
|
|
175632
175675
|
// cli/init/register.ts
|
|
175633
175676
|
import * as fs58 from "node:fs";
|
|
175634
|
-
import * as
|
|
175677
|
+
import * as path61 from "node:path";
|
|
175635
175678
|
|
|
175636
175679
|
// lib/shared/generate-gitignore-file.ts
|
|
175637
|
-
import
|
|
175680
|
+
import path59 from "node:path";
|
|
175638
175681
|
var generateGitIgnoreFile = (dir) => {
|
|
175639
|
-
const gitignorePath =
|
|
175682
|
+
const gitignorePath = path59.join(dir, ".gitignore");
|
|
175640
175683
|
const gitignoreContent = `# Dependencies
|
|
175641
175684
|
node_modules/
|
|
175642
175685
|
|
|
@@ -175672,7 +175715,7 @@ yarn-error.log*
|
|
|
175672
175715
|
|
|
175673
175716
|
// lib/shared/setup-tscircuit-skill.ts
|
|
175674
175717
|
import * as fs57 from "node:fs";
|
|
175675
|
-
import * as
|
|
175718
|
+
import * as path60 from "node:path";
|
|
175676
175719
|
var SKILL_REPO_API_URL = "https://api.github.com/repos/tscircuit/skill/contents";
|
|
175677
175720
|
var SKILL_INSTALL_PATHS = [
|
|
175678
175721
|
".claude/skills/tscircuit",
|
|
@@ -175695,7 +175738,7 @@ async function fetchFileContent(downloadUrl) {
|
|
|
175695
175738
|
async function downloadDirectory(apiUrl, targetDir) {
|
|
175696
175739
|
const contents = await fetchGitHubContents(apiUrl);
|
|
175697
175740
|
for (const item of contents) {
|
|
175698
|
-
const targetPath =
|
|
175741
|
+
const targetPath = path60.join(targetDir, item.name);
|
|
175699
175742
|
if (item.type === "dir") {
|
|
175700
175743
|
fs57.mkdirSync(targetPath, { recursive: true });
|
|
175701
175744
|
await downloadDirectory(`${apiUrl}/${item.name}`, targetPath);
|
|
@@ -175712,7 +175755,7 @@ async function downloadSkillRepo(targetDir) {
|
|
|
175712
175755
|
if (item.name === ".git" || item.name === ".github") {
|
|
175713
175756
|
continue;
|
|
175714
175757
|
}
|
|
175715
|
-
const targetPath =
|
|
175758
|
+
const targetPath = path60.join(targetDir, item.name);
|
|
175716
175759
|
if (item.type === "dir") {
|
|
175717
175760
|
fs57.mkdirSync(targetPath, { recursive: true });
|
|
175718
175761
|
await downloadDirectory(`${SKILL_REPO_API_URL}/${item.name}`, targetPath);
|
|
@@ -175723,7 +175766,7 @@ async function downloadSkillRepo(targetDir) {
|
|
|
175723
175766
|
}
|
|
175724
175767
|
}
|
|
175725
175768
|
async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
175726
|
-
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs57.existsSync(
|
|
175769
|
+
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs57.existsSync(path60.join(projectDir, skillPath, "SKILL.md")));
|
|
175727
175770
|
if (missingSkillPaths.length === 0) {
|
|
175728
175771
|
console.log("TSCircuit AI skills already exist, skipping...");
|
|
175729
175772
|
return true;
|
|
@@ -175743,7 +175786,7 @@ async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
|
175743
175786
|
console.info("Setting up tscircuit AI skills...");
|
|
175744
175787
|
try {
|
|
175745
175788
|
for (const skillPath of missingSkillPaths) {
|
|
175746
|
-
const targetDir =
|
|
175789
|
+
const targetDir = path60.join(projectDir, skillPath);
|
|
175747
175790
|
await downloadSkillRepo(targetDir);
|
|
175748
175791
|
console.info(`tscircuit skill installed at ${skillPath}`);
|
|
175749
175792
|
}
|
|
@@ -175847,7 +175890,7 @@ var registerInit = (program3) => {
|
|
|
175847
175890
|
}
|
|
175848
175891
|
}
|
|
175849
175892
|
}
|
|
175850
|
-
const projectDir = directory ?
|
|
175893
|
+
const projectDir = directory ? path61.resolve(process.cwd(), directory) : process.cwd();
|
|
175851
175894
|
let tsciHandle = null;
|
|
175852
175895
|
const token = getSessionToken();
|
|
175853
175896
|
if (token) {
|
|
@@ -175858,7 +175901,7 @@ var registerInit = (program3) => {
|
|
|
175858
175901
|
}
|
|
175859
175902
|
} catch {}
|
|
175860
175903
|
}
|
|
175861
|
-
const dirName =
|
|
175904
|
+
const dirName = path61.basename(projectDir);
|
|
175862
175905
|
let defaultPackageName = dirName;
|
|
175863
175906
|
if (tsciHandle) {
|
|
175864
175907
|
defaultPackageName = `@tsci/${tsciHandle}.${dirName}`;
|
|
@@ -175877,7 +175920,7 @@ var registerInit = (program3) => {
|
|
|
175877
175920
|
}
|
|
175878
175921
|
}
|
|
175879
175922
|
fs58.mkdirSync(projectDir, { recursive: true });
|
|
175880
|
-
writeFileIfNotExists(
|
|
175923
|
+
writeFileIfNotExists(path61.join(projectDir, "index.circuit.tsx"), `
|
|
175881
175924
|
export default () => (
|
|
175882
175925
|
<board>
|
|
175883
175926
|
<resistor resistance="1k" footprint="0402" name="R1" />
|
|
@@ -175889,7 +175932,7 @@ export default () => (
|
|
|
175889
175932
|
if (saveProjectConfig(null, projectDir)) {
|
|
175890
175933
|
console.log("Created tscircuit.config.json with schema");
|
|
175891
175934
|
}
|
|
175892
|
-
writeFileIfNotExists(
|
|
175935
|
+
writeFileIfNotExists(path61.join(projectDir, ".npmrc"), `
|
|
175893
175936
|
@tsci:registry=https://npm.tscircuit.com
|
|
175894
175937
|
`);
|
|
175895
175938
|
console.log("Generating package.json");
|
|
@@ -176040,14 +176083,14 @@ class KeyStore {
|
|
|
176040
176083
|
}
|
|
176041
176084
|
}
|
|
176042
176085
|
function createKey(key) {
|
|
176043
|
-
let
|
|
176086
|
+
let path62 = null;
|
|
176044
176087
|
let id = null;
|
|
176045
176088
|
let src = null;
|
|
176046
176089
|
let weight = 1;
|
|
176047
176090
|
let getFn = null;
|
|
176048
176091
|
if (isString2(key) || isArray(key)) {
|
|
176049
176092
|
src = key;
|
|
176050
|
-
|
|
176093
|
+
path62 = createKeyPath(key);
|
|
176051
176094
|
id = createKeyId(key);
|
|
176052
176095
|
} else {
|
|
176053
176096
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -176061,11 +176104,11 @@ function createKey(key) {
|
|
|
176061
176104
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
176062
176105
|
}
|
|
176063
176106
|
}
|
|
176064
|
-
|
|
176107
|
+
path62 = createKeyPath(name);
|
|
176065
176108
|
id = createKeyId(name);
|
|
176066
176109
|
getFn = key.getFn;
|
|
176067
176110
|
}
|
|
176068
|
-
return { path:
|
|
176111
|
+
return { path: path62, id, weight, src, getFn };
|
|
176069
176112
|
}
|
|
176070
176113
|
function createKeyPath(key) {
|
|
176071
176114
|
return isArray(key) ? key : key.split(".");
|
|
@@ -176073,34 +176116,34 @@ function createKeyPath(key) {
|
|
|
176073
176116
|
function createKeyId(key) {
|
|
176074
176117
|
return isArray(key) ? key.join(".") : key;
|
|
176075
176118
|
}
|
|
176076
|
-
function get(obj,
|
|
176119
|
+
function get(obj, path62) {
|
|
176077
176120
|
let list = [];
|
|
176078
176121
|
let arr = false;
|
|
176079
|
-
const deepGet = (obj2,
|
|
176122
|
+
const deepGet = (obj2, path63, index) => {
|
|
176080
176123
|
if (!isDefined(obj2)) {
|
|
176081
176124
|
return;
|
|
176082
176125
|
}
|
|
176083
|
-
if (!
|
|
176126
|
+
if (!path63[index]) {
|
|
176084
176127
|
list.push(obj2);
|
|
176085
176128
|
} else {
|
|
176086
|
-
let key =
|
|
176129
|
+
let key = path63[index];
|
|
176087
176130
|
const value = obj2[key];
|
|
176088
176131
|
if (!isDefined(value)) {
|
|
176089
176132
|
return;
|
|
176090
176133
|
}
|
|
176091
|
-
if (index ===
|
|
176134
|
+
if (index === path63.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
|
|
176092
176135
|
list.push(toString(value));
|
|
176093
176136
|
} else if (isArray(value)) {
|
|
176094
176137
|
arr = true;
|
|
176095
176138
|
for (let i3 = 0, len = value.length;i3 < len; i3 += 1) {
|
|
176096
|
-
deepGet(value[i3],
|
|
176139
|
+
deepGet(value[i3], path63, index + 1);
|
|
176097
176140
|
}
|
|
176098
|
-
} else if (
|
|
176099
|
-
deepGet(value,
|
|
176141
|
+
} else if (path63.length) {
|
|
176142
|
+
deepGet(value, path63, index + 1);
|
|
176100
176143
|
}
|
|
176101
176144
|
}
|
|
176102
176145
|
};
|
|
176103
|
-
deepGet(obj, isString2(
|
|
176146
|
+
deepGet(obj, isString2(path62) ? path62.split(".") : path62, 0);
|
|
176104
176147
|
return arr ? list : list[0];
|
|
176105
176148
|
}
|
|
176106
176149
|
var MatchOptions = {
|
|
@@ -177264,7 +177307,7 @@ Fuse2.config = Config;
|
|
|
177264
177307
|
|
|
177265
177308
|
// cli/search/register.ts
|
|
177266
177309
|
var registerSearch = (program3) => {
|
|
177267
|
-
program3.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--tscircuit", "Search tscircuit registry packages").action(async (query, opts) => {
|
|
177310
|
+
program3.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--tscircuit", "Search tscircuit registry packages").option("--json", "Output search results as JSON").action(async (query, opts) => {
|
|
177268
177311
|
const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.tscircuit;
|
|
177269
177312
|
const searchKicad = opts.kicad || !hasFilters;
|
|
177270
177313
|
const searchJlc = opts.jlcpcb || opts.lcsc || !hasFilters;
|
|
@@ -177293,6 +177336,27 @@ var registerSearch = (program3) => {
|
|
|
177293
177336
|
console.error(kleur_default.red("Failed to search registry:"), error instanceof Error ? error.message : error);
|
|
177294
177337
|
process.exit(1);
|
|
177295
177338
|
}
|
|
177339
|
+
if (opts.json) {
|
|
177340
|
+
const unifiedResults = [
|
|
177341
|
+
...kicadResults.map((path62) => ({
|
|
177342
|
+
source: "kicad",
|
|
177343
|
+
path: path62
|
|
177344
|
+
})),
|
|
177345
|
+
...results.packages.map((pkg) => ({
|
|
177346
|
+
source: "tscircuit",
|
|
177347
|
+
...pkg
|
|
177348
|
+
})),
|
|
177349
|
+
...jlcResults.map((comp) => ({
|
|
177350
|
+
source: "jlcpcb",
|
|
177351
|
+
...comp
|
|
177352
|
+
}))
|
|
177353
|
+
];
|
|
177354
|
+
console.log(JSON.stringify({
|
|
177355
|
+
query,
|
|
177356
|
+
results: unifiedResults
|
|
177357
|
+
}, null, 2));
|
|
177358
|
+
return;
|
|
177359
|
+
}
|
|
177296
177360
|
if (!kicadResults.length && !results.packages.length && !jlcResults.length) {
|
|
177297
177361
|
const sources = [
|
|
177298
177362
|
searchTscircuit && "tscircuit registry",
|
|
@@ -177304,8 +177368,8 @@ var registerSearch = (program3) => {
|
|
|
177304
177368
|
}
|
|
177305
177369
|
if (kicadResults.length) {
|
|
177306
177370
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
177307
|
-
kicadResults.forEach((
|
|
177308
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
177371
|
+
kicadResults.forEach((path62, idx) => {
|
|
177372
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path62.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
177309
177373
|
});
|
|
177310
177374
|
}
|
|
177311
177375
|
if (results.packages.length) {
|
|
@@ -177330,20 +177394,20 @@ var registerSearch = (program3) => {
|
|
|
177330
177394
|
|
|
177331
177395
|
// lib/shared/setup-github-actions.ts
|
|
177332
177396
|
import fs59 from "node:fs";
|
|
177333
|
-
import
|
|
177397
|
+
import path62 from "node:path";
|
|
177334
177398
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
177335
177399
|
const findGitRoot = (startDir) => {
|
|
177336
|
-
let dir =
|
|
177337
|
-
while (dir !==
|
|
177338
|
-
if (fs59.existsSync(
|
|
177400
|
+
let dir = path62.resolve(startDir);
|
|
177401
|
+
while (dir !== path62.parse(dir).root) {
|
|
177402
|
+
if (fs59.existsSync(path62.join(dir, ".git"))) {
|
|
177339
177403
|
return dir;
|
|
177340
177404
|
}
|
|
177341
|
-
dir =
|
|
177405
|
+
dir = path62.dirname(dir);
|
|
177342
177406
|
}
|
|
177343
177407
|
return null;
|
|
177344
177408
|
};
|
|
177345
177409
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
177346
|
-
const workflowsDir =
|
|
177410
|
+
const workflowsDir = path62.join(gitRoot, ".github", "workflows");
|
|
177347
177411
|
fs59.mkdirSync(workflowsDir, { recursive: true });
|
|
177348
177412
|
const buildWorkflow = `name: tscircuit Build
|
|
177349
177413
|
|
|
@@ -177383,8 +177447,8 @@ jobs:
|
|
|
177383
177447
|
- run: bun install
|
|
177384
177448
|
- run: bunx tsci snapshot
|
|
177385
177449
|
`;
|
|
177386
|
-
writeFileIfNotExists(
|
|
177387
|
-
writeFileIfNotExists(
|
|
177450
|
+
writeFileIfNotExists(path62.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
177451
|
+
writeFileIfNotExists(path62.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
177388
177452
|
};
|
|
177389
177453
|
|
|
177390
177454
|
// cli/setup/register.ts
|
|
@@ -177551,21 +177615,21 @@ function applyCameraPreset(preset, cam) {
|
|
|
177551
177615
|
}
|
|
177552
177616
|
|
|
177553
177617
|
// lib/shared/snapshot-project.ts
|
|
177554
|
-
import
|
|
177618
|
+
import path65 from "node:path";
|
|
177555
177619
|
|
|
177556
177620
|
// cli/snapshot/worker-pool.ts
|
|
177557
177621
|
import fs60 from "node:fs";
|
|
177558
|
-
import
|
|
177622
|
+
import path63 from "node:path";
|
|
177559
177623
|
var getWorkerEntrypointPath2 = () => {
|
|
177560
|
-
const tsPath =
|
|
177624
|
+
const tsPath = path63.join(import.meta.dir, "snapshot.worker.ts");
|
|
177561
177625
|
if (fs60.existsSync(tsPath)) {
|
|
177562
177626
|
return tsPath;
|
|
177563
177627
|
}
|
|
177564
|
-
const jsBundledPath =
|
|
177628
|
+
const jsBundledPath = path63.join(import.meta.dir, "snapshot", "snapshot.worker.js");
|
|
177565
177629
|
if (fs60.existsSync(jsBundledPath)) {
|
|
177566
177630
|
return jsBundledPath;
|
|
177567
177631
|
}
|
|
177568
|
-
return
|
|
177632
|
+
return path63.join(import.meta.dir, "snapshot.worker.js");
|
|
177569
177633
|
};
|
|
177570
177634
|
var snapshotFilesWithWorkerPool = async (options) => {
|
|
177571
177635
|
const cancellationError = new Error("Snapshot cancelled due to file failure");
|
|
@@ -177633,7 +177697,7 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
177633
177697
|
|
|
177634
177698
|
// lib/shared/process-snapshot-file.ts
|
|
177635
177699
|
import fs62 from "node:fs";
|
|
177636
|
-
import
|
|
177700
|
+
import path64 from "node:path";
|
|
177637
177701
|
import {
|
|
177638
177702
|
convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
|
|
177639
177703
|
getBestCameraPosition
|
|
@@ -177686,7 +177750,7 @@ var processSnapshotFile = async ({
|
|
|
177686
177750
|
createDiff,
|
|
177687
177751
|
cameraPreset
|
|
177688
177752
|
}) => {
|
|
177689
|
-
const relativeFilePath =
|
|
177753
|
+
const relativeFilePath = path64.relative(projectDir, file);
|
|
177690
177754
|
const successPaths = [];
|
|
177691
177755
|
const warningMessages = [];
|
|
177692
177756
|
const mismatches = [];
|
|
@@ -177767,11 +177831,11 @@ var processSnapshotFile = async ({
|
|
|
177767
177831
|
} catch (error) {
|
|
177768
177832
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
177769
177833
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
177770
|
-
const fileDir =
|
|
177771
|
-
const relativeDir =
|
|
177772
|
-
const snapDir2 = snapshotsDirName ?
|
|
177773
|
-
const base2 =
|
|
177774
|
-
const snap3dPath =
|
|
177834
|
+
const fileDir = path64.dirname(file);
|
|
177835
|
+
const relativeDir = path64.relative(projectDir, fileDir);
|
|
177836
|
+
const snapDir2 = snapshotsDirName ? path64.join(projectDir, snapshotsDirName, relativeDir) : path64.join(fileDir, "__snapshots__");
|
|
177837
|
+
const base2 = path64.basename(file).replace(/\.[^.]+$/, "");
|
|
177838
|
+
const snap3dPath = path64.join(snapDir2, `${base2}-3d.snap.png`);
|
|
177775
177839
|
const existing3dSnapshot = fs62.existsSync(snap3dPath);
|
|
177776
177840
|
if (existing3dSnapshot) {
|
|
177777
177841
|
return {
|
|
@@ -177783,7 +177847,7 @@ var processSnapshotFile = async ({
|
|
|
177783
177847
|
errorMessage: kleur_default.red(`
|
|
177784
177848
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
177785
177849
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
177786
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
177850
|
+
`) + kleur_default.red(` Existing snapshot: ${path64.relative(projectDir, snap3dPath)}
|
|
177787
177851
|
`)
|
|
177788
177852
|
};
|
|
177789
177853
|
}
|
|
@@ -177804,9 +177868,9 @@ var processSnapshotFile = async ({
|
|
|
177804
177868
|
}
|
|
177805
177869
|
}
|
|
177806
177870
|
}
|
|
177807
|
-
const snapDir = snapshotsDirName ?
|
|
177871
|
+
const snapDir = snapshotsDirName ? path64.join(projectDir, snapshotsDirName, path64.relative(projectDir, path64.dirname(file))) : path64.join(path64.dirname(file), "__snapshots__");
|
|
177808
177872
|
fs62.mkdirSync(snapDir, { recursive: true });
|
|
177809
|
-
const base =
|
|
177873
|
+
const base = path64.basename(file).replace(/\.[^.]+$/, "");
|
|
177810
177874
|
const snapshots = [];
|
|
177811
177875
|
if (pcbOnly || !schematicOnly) {
|
|
177812
177876
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -177820,13 +177884,13 @@ var processSnapshotFile = async ({
|
|
|
177820
177884
|
for (const snapshot of snapshots) {
|
|
177821
177885
|
const { type } = snapshot;
|
|
177822
177886
|
const is3d = type === "3d";
|
|
177823
|
-
const snapPath =
|
|
177887
|
+
const snapPath = path64.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
177824
177888
|
const existing = fs62.existsSync(snapPath);
|
|
177825
177889
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
177826
177890
|
const newContentForFile = snapshot.content;
|
|
177827
177891
|
if (!existing) {
|
|
177828
177892
|
fs62.writeFileSync(snapPath, newContentForFile);
|
|
177829
|
-
successPaths.push(
|
|
177893
|
+
successPaths.push(path64.relative(projectDir, snapPath));
|
|
177830
177894
|
didUpdate = true;
|
|
177831
177895
|
continue;
|
|
177832
177896
|
}
|
|
@@ -177835,16 +177899,16 @@ var processSnapshotFile = async ({
|
|
|
177835
177899
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
|
|
177836
177900
|
if (update) {
|
|
177837
177901
|
if (!forceUpdate && equal2) {
|
|
177838
|
-
successPaths.push(
|
|
177902
|
+
successPaths.push(path64.relative(projectDir, snapPath));
|
|
177839
177903
|
} else {
|
|
177840
177904
|
fs62.writeFileSync(snapPath, newContentForFile);
|
|
177841
|
-
successPaths.push(
|
|
177905
|
+
successPaths.push(path64.relative(projectDir, snapPath));
|
|
177842
177906
|
didUpdate = true;
|
|
177843
177907
|
}
|
|
177844
177908
|
} else if (!equal2) {
|
|
177845
177909
|
mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
177846
177910
|
} else {
|
|
177847
|
-
successPaths.push(
|
|
177911
|
+
successPaths.push(path64.relative(projectDir, snapPath));
|
|
177848
177912
|
}
|
|
177849
177913
|
}
|
|
177850
177914
|
return {
|
|
@@ -177881,7 +177945,7 @@ var snapshotProject = async ({
|
|
|
177881
177945
|
...DEFAULT_IGNORED_PATTERNS,
|
|
177882
177946
|
...ignored.map(normalizeIgnorePattern)
|
|
177883
177947
|
];
|
|
177884
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
177948
|
+
const resolvedPaths = filePaths.map((f2) => path65.resolve(projectDir, f2));
|
|
177885
177949
|
const boardFiles = findBoardFiles({
|
|
177886
177950
|
projectDir,
|
|
177887
177951
|
ignore,
|
|
@@ -178011,7 +178075,7 @@ var registerSnapshot = (program3) => {
|
|
|
178011
178075
|
};
|
|
178012
178076
|
|
|
178013
178077
|
// cli/transpile/register.ts
|
|
178014
|
-
import
|
|
178078
|
+
import path66 from "node:path";
|
|
178015
178079
|
var registerTranspile = (program3) => {
|
|
178016
178080
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
178017
178081
|
try {
|
|
@@ -178019,7 +178083,7 @@ var registerTranspile = (program3) => {
|
|
|
178019
178083
|
fileOrDir: file,
|
|
178020
178084
|
includeBoardFiles: false
|
|
178021
178085
|
});
|
|
178022
|
-
const distDir =
|
|
178086
|
+
const distDir = path66.join(projectDir, "dist");
|
|
178023
178087
|
validateMainInDist(projectDir, distDir);
|
|
178024
178088
|
console.log("Transpiling entry file...");
|
|
178025
178089
|
const entryFile = mainEntrypoint || circuitFiles[0];
|