@tscircuit/cli 0.1.1092 → 0.1.1094
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 +685 -556
- package/dist/lib/index.js +3 -3
- package/package.json +3 -3
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, path48) {
|
|
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(path48) || !!(item.gmatcher && item.gmatcher.match(path48));
|
|
68613
68613
|
});
|
|
68614
68614
|
}
|
|
68615
|
-
function childrenIgnored(self2,
|
|
68615
|
+
function childrenIgnored(self2, path48) {
|
|
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(path48));
|
|
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.1093";
|
|
71668
71668
|
var package_default = {
|
|
71669
71669
|
name: "@tscircuit/cli",
|
|
71670
71670
|
version,
|
|
@@ -71693,7 +71693,7 @@ var package_default = {
|
|
|
71693
71693
|
"@types/semver": "^7.5.8",
|
|
71694
71694
|
"bun-match-svg": "^0.0.12",
|
|
71695
71695
|
chokidar: "4.0.1",
|
|
71696
|
-
"circuit-json": "^0.0.
|
|
71696
|
+
"circuit-json": "^0.0.400",
|
|
71697
71697
|
"circuit-json-to-kicad": "^0.0.84",
|
|
71698
71698
|
"circuit-json-to-readable-netlist": "^0.0.14",
|
|
71699
71699
|
"circuit-json-to-spice": "^0.0.10",
|
|
@@ -71728,7 +71728,7 @@ var package_default = {
|
|
|
71728
71728
|
semver: "^7.6.3",
|
|
71729
71729
|
sharp: "0.32.6",
|
|
71730
71730
|
tempy: "^3.1.0",
|
|
71731
|
-
tscircuit: "0.0.
|
|
71731
|
+
tscircuit: "0.0.1488-libonly",
|
|
71732
71732
|
tsx: "^4.7.1",
|
|
71733
71733
|
"typed-ky": "^0.0.4",
|
|
71734
71734
|
zod: "^3.23.8"
|
|
@@ -81960,6 +81960,7 @@ class ThreadWorkerPool {
|
|
|
81960
81960
|
initialized = false;
|
|
81961
81961
|
stopped = false;
|
|
81962
81962
|
stopReason = null;
|
|
81963
|
+
heartbeatIntervalId = null;
|
|
81963
81964
|
constructor(options) {
|
|
81964
81965
|
this.options = options;
|
|
81965
81966
|
this.concurrency = options.concurrency;
|
|
@@ -81970,13 +81971,68 @@ class ThreadWorkerPool {
|
|
|
81970
81971
|
for (let i = 0;i < this.concurrency; i++) {
|
|
81971
81972
|
this.workers.push(this.createThreadWorker());
|
|
81972
81973
|
}
|
|
81974
|
+
this.startHeartbeat();
|
|
81973
81975
|
this.initialized = true;
|
|
81974
81976
|
}
|
|
81977
|
+
describeJob(job) {
|
|
81978
|
+
if (this.options.describeJob) {
|
|
81979
|
+
return this.options.describeJob(job);
|
|
81980
|
+
}
|
|
81981
|
+
if (typeof job === "object" && job !== null) {
|
|
81982
|
+
const jobCandidate = job;
|
|
81983
|
+
if (typeof jobCandidate.filePath === "string") {
|
|
81984
|
+
return jobCandidate.filePath;
|
|
81985
|
+
}
|
|
81986
|
+
if (typeof jobCandidate.id === "string") {
|
|
81987
|
+
return jobCandidate.id;
|
|
81988
|
+
}
|
|
81989
|
+
if (typeof jobCandidate.outputPath === "string") {
|
|
81990
|
+
return jobCandidate.outputPath;
|
|
81991
|
+
}
|
|
81992
|
+
}
|
|
81993
|
+
return "unknown-job";
|
|
81994
|
+
}
|
|
81995
|
+
startHeartbeat() {
|
|
81996
|
+
if (!this.options.onLog || this.heartbeatIntervalId) {
|
|
81997
|
+
return;
|
|
81998
|
+
}
|
|
81999
|
+
const heartbeatIntervalMs = this.options.heartbeatIntervalMs ?? 5000;
|
|
82000
|
+
if (heartbeatIntervalMs <= 0) {
|
|
82001
|
+
return;
|
|
82002
|
+
}
|
|
82003
|
+
this.heartbeatIntervalId = setInterval(() => {
|
|
82004
|
+
const busyWorkers = this.workers.filter((worker) => worker.busy).length;
|
|
82005
|
+
const totalWorkers = this.workers.length;
|
|
82006
|
+
const idleWorkers = totalWorkers - busyWorkers;
|
|
82007
|
+
const queuedJobs = this.jobQueue.length;
|
|
82008
|
+
const now = Date.now();
|
|
82009
|
+
const workerDetails = this.workers.map((worker, index) => {
|
|
82010
|
+
if (!worker.busy || !worker.currentJob || !worker.currentJobStartedAt) {
|
|
82011
|
+
return `w${index}:idle`;
|
|
82012
|
+
}
|
|
82013
|
+
const runningForMs = now - worker.currentJobStartedAt;
|
|
82014
|
+
const jobDescription = this.describeJob(worker.currentJob.job);
|
|
82015
|
+
return `w${index}:busy task=${jobDescription} running_ms=${runningForMs}`;
|
|
82016
|
+
});
|
|
82017
|
+
this.options.onLog?.([
|
|
82018
|
+
`[worker-pool] heartbeat: workers busy=${busyWorkers}/${totalWorkers}, idle=${idleWorkers}, queued_jobs=${queuedJobs} | ${workerDetails.join(" | ")}`
|
|
82019
|
+
]);
|
|
82020
|
+
}, heartbeatIntervalMs);
|
|
82021
|
+
this.heartbeatIntervalId.unref?.();
|
|
82022
|
+
}
|
|
82023
|
+
stopHeartbeat() {
|
|
82024
|
+
if (!this.heartbeatIntervalId) {
|
|
82025
|
+
return;
|
|
82026
|
+
}
|
|
82027
|
+
clearInterval(this.heartbeatIntervalId);
|
|
82028
|
+
this.heartbeatIntervalId = null;
|
|
82029
|
+
}
|
|
81975
82030
|
createThreadWorker() {
|
|
81976
82031
|
const threadWorker = {
|
|
81977
82032
|
worker: new Worker(this.options.workerEntrypointPath),
|
|
81978
82033
|
busy: false,
|
|
81979
82034
|
currentJob: null,
|
|
82035
|
+
currentJobStartedAt: null,
|
|
81980
82036
|
timeoutId: null
|
|
81981
82037
|
};
|
|
81982
82038
|
this.attachWorkerHandlers(threadWorker);
|
|
@@ -82016,6 +82072,7 @@ class ThreadWorkerPool {
|
|
|
82016
82072
|
threadWorker.worker = new Worker(this.options.workerEntrypointPath);
|
|
82017
82073
|
threadWorker.busy = false;
|
|
82018
82074
|
threadWorker.currentJob = null;
|
|
82075
|
+
threadWorker.currentJobStartedAt = null;
|
|
82019
82076
|
this.attachWorkerHandlers(threadWorker);
|
|
82020
82077
|
}
|
|
82021
82078
|
finishJob(threadWorker, action) {
|
|
@@ -82025,6 +82082,7 @@ class ThreadWorkerPool {
|
|
|
82025
82082
|
}
|
|
82026
82083
|
this.clearWorkerTimeout(threadWorker);
|
|
82027
82084
|
threadWorker.currentJob = null;
|
|
82085
|
+
threadWorker.currentJobStartedAt = null;
|
|
82028
82086
|
threadWorker.busy = false;
|
|
82029
82087
|
action(job);
|
|
82030
82088
|
this.processQueue();
|
|
@@ -82089,6 +82147,7 @@ class ThreadWorkerPool {
|
|
|
82089
82147
|
}
|
|
82090
82148
|
availableWorker.busy = true;
|
|
82091
82149
|
availableWorker.currentJob = queuedJob;
|
|
82150
|
+
availableWorker.currentJobStartedAt = Date.now();
|
|
82092
82151
|
this.startJobTimeout(availableWorker);
|
|
82093
82152
|
availableWorker.worker.postMessage(this.options.createMessage(queuedJob.job));
|
|
82094
82153
|
}
|
|
@@ -82106,6 +82165,7 @@ class ThreadWorkerPool {
|
|
|
82106
82165
|
if (this.stopped)
|
|
82107
82166
|
return;
|
|
82108
82167
|
this.stopped = true;
|
|
82168
|
+
this.stopHeartbeat();
|
|
82109
82169
|
this.stopReason = reason;
|
|
82110
82170
|
for (const queuedJob of this.jobQueue) {
|
|
82111
82171
|
queuedJob.reject(reason);
|
|
@@ -82113,6 +82173,7 @@ class ThreadWorkerPool {
|
|
|
82113
82173
|
this.jobQueue = [];
|
|
82114
82174
|
}
|
|
82115
82175
|
async terminate() {
|
|
82176
|
+
this.stopHeartbeat();
|
|
82116
82177
|
await Promise.all(this.workers.map((worker) => {
|
|
82117
82178
|
this.clearWorkerTimeout(worker);
|
|
82118
82179
|
return worker.worker.terminate();
|
|
@@ -82989,9 +83050,76 @@ var registerCheckNetlist = (program2) => {
|
|
|
82989
83050
|
});
|
|
82990
83051
|
};
|
|
82991
83052
|
|
|
82992
|
-
// cli/check/
|
|
83053
|
+
// cli/check/pin-specification/register.ts
|
|
82993
83054
|
import fs38 from "node:fs";
|
|
83055
|
+
import { runAllPinSpecificationChecks } from "@tscircuit/checks";
|
|
82994
83056
|
import path41 from "node:path";
|
|
83057
|
+
var resolveInputFilePath2 = async (file) => {
|
|
83058
|
+
if (file) {
|
|
83059
|
+
return path41.isAbsolute(file) ? file : path41.resolve(process.cwd(), file);
|
|
83060
|
+
}
|
|
83061
|
+
const entrypoint = await getEntrypoint({
|
|
83062
|
+
projectDir: process.cwd()
|
|
83063
|
+
});
|
|
83064
|
+
if (!entrypoint) {
|
|
83065
|
+
throw new Error("No input file provided and no entrypoint found");
|
|
83066
|
+
}
|
|
83067
|
+
return entrypoint;
|
|
83068
|
+
};
|
|
83069
|
+
var isPrebuiltCircuitJsonFile = (filePath) => {
|
|
83070
|
+
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
83071
|
+
return normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
83072
|
+
};
|
|
83073
|
+
var getCircuitJsonForPinSpecificationCheck = async (filePath) => {
|
|
83074
|
+
if (isPrebuiltCircuitJsonFile(filePath)) {
|
|
83075
|
+
const parsedJson = JSON.parse(fs38.readFileSync(filePath, "utf-8"));
|
|
83076
|
+
return Array.isArray(parsedJson) ? parsedJson : [];
|
|
83077
|
+
}
|
|
83078
|
+
const completePlatformConfig = getCompletePlatformConfig({
|
|
83079
|
+
pcbDisabled: true,
|
|
83080
|
+
routingDisabled: true,
|
|
83081
|
+
placementDrcChecksDisabled: true
|
|
83082
|
+
});
|
|
83083
|
+
const { circuitJson } = await generateCircuitJson({
|
|
83084
|
+
filePath,
|
|
83085
|
+
platformConfig: completePlatformConfig
|
|
83086
|
+
});
|
|
83087
|
+
return circuitJson;
|
|
83088
|
+
};
|
|
83089
|
+
var checkPinSpecification = async (file) => {
|
|
83090
|
+
const resolvedInputFilePath = await resolveInputFilePath2(file);
|
|
83091
|
+
const typedCircuitJson = await getCircuitJsonForPinSpecificationCheck(resolvedInputFilePath);
|
|
83092
|
+
const pinSpecificationIssues = await runAllPinSpecificationChecks(typedCircuitJson);
|
|
83093
|
+
const errors = pinSpecificationIssues.filter((issue) => ("error_type" in issue));
|
|
83094
|
+
const warnings = pinSpecificationIssues.filter((issue) => ("warning_type" in issue) || issue.type?.endsWith("_warning"));
|
|
83095
|
+
const diagnosticsLines = [
|
|
83096
|
+
`Errors: ${errors.length}`,
|
|
83097
|
+
`Warnings: ${warnings.length}`
|
|
83098
|
+
];
|
|
83099
|
+
if (pinSpecificationIssues.length > 0) {
|
|
83100
|
+
diagnosticsLines.push(...pinSpecificationIssues.map((issue) => {
|
|
83101
|
+
const issueType = issue.warning_type ?? issue.error_type ?? issue.type;
|
|
83102
|
+
return `- ${issueType}: ${issue.message ?? ""}`;
|
|
83103
|
+
}));
|
|
83104
|
+
}
|
|
83105
|
+
return diagnosticsLines.join(`
|
|
83106
|
+
`);
|
|
83107
|
+
};
|
|
83108
|
+
var registerCheckPinSpecification = (program2) => {
|
|
83109
|
+
program2.commands.find((c) => c.name() === "check").command("pin_specification").description("Partially build and validate pin specification checks").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
83110
|
+
try {
|
|
83111
|
+
const output = await checkPinSpecification(file);
|
|
83112
|
+
console.log(output);
|
|
83113
|
+
} catch (error) {
|
|
83114
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
83115
|
+
process.exit(1);
|
|
83116
|
+
}
|
|
83117
|
+
});
|
|
83118
|
+
};
|
|
83119
|
+
|
|
83120
|
+
// cli/check/placement/register.ts
|
|
83121
|
+
import fs39 from "node:fs";
|
|
83122
|
+
import path42 from "node:path";
|
|
82995
83123
|
|
|
82996
83124
|
// node_modules/@tscircuit/circuit-json-placement-analysis/dist/index.js
|
|
82997
83125
|
var CENTER_ANCHOR = "center";
|
|
@@ -83518,13 +83646,13 @@ var analyzeAllPlacements = (circuitJson) => {
|
|
|
83518
83646
|
};
|
|
83519
83647
|
|
|
83520
83648
|
// cli/check/placement/register.ts
|
|
83521
|
-
var
|
|
83649
|
+
var isPrebuiltCircuitJsonFile2 = (filePath) => {
|
|
83522
83650
|
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
83523
83651
|
return normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
83524
83652
|
};
|
|
83525
|
-
var
|
|
83653
|
+
var resolveInputFilePath3 = async (file) => {
|
|
83526
83654
|
if (file) {
|
|
83527
|
-
return
|
|
83655
|
+
return path42.isAbsolute(file) ? file : path42.resolve(process.cwd(), file);
|
|
83528
83656
|
}
|
|
83529
83657
|
const entrypoint = await getEntrypoint({
|
|
83530
83658
|
projectDir: process.cwd()
|
|
@@ -83535,8 +83663,8 @@ var resolveInputFilePath2 = async (file) => {
|
|
|
83535
83663
|
return entrypoint;
|
|
83536
83664
|
};
|
|
83537
83665
|
var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
83538
|
-
if (
|
|
83539
|
-
const parsedJson = JSON.parse(
|
|
83666
|
+
if (isPrebuiltCircuitJsonFile2(filePath)) {
|
|
83667
|
+
const parsedJson = JSON.parse(fs39.readFileSync(filePath, "utf-8"));
|
|
83540
83668
|
return Array.isArray(parsedJson) ? parsedJson : [];
|
|
83541
83669
|
}
|
|
83542
83670
|
const completePlatformConfig = getCompletePlatformConfig({
|
|
@@ -83550,7 +83678,7 @@ var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
|
83550
83678
|
return circuitJson;
|
|
83551
83679
|
};
|
|
83552
83680
|
var checkPlacement = async (file, refdes) => {
|
|
83553
|
-
const resolvedInputFilePath = await
|
|
83681
|
+
const resolvedInputFilePath = await resolveInputFilePath3(file);
|
|
83554
83682
|
const circuitJson = await getCircuitJsonForPlacementCheck(resolvedInputFilePath);
|
|
83555
83683
|
const analysis = refdes ? analyzeComponentPlacement(circuitJson, refdes) : analyzeAllPlacements(circuitJson);
|
|
83556
83684
|
return analysis.getString();
|
|
@@ -83580,26 +83708,26 @@ var registerCheckRouting = (program2) => {
|
|
|
83580
83708
|
};
|
|
83581
83709
|
|
|
83582
83710
|
// cli/clone/register.ts
|
|
83583
|
-
import * as
|
|
83584
|
-
import * as
|
|
83711
|
+
import * as fs42 from "node:fs";
|
|
83712
|
+
import * as path45 from "node:path";
|
|
83585
83713
|
|
|
83586
83714
|
// cli/clone/clone-bug-report.ts
|
|
83587
83715
|
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
83588
83716
|
var import_prompts4 = __toESM2(require_prompts3(), 1);
|
|
83589
|
-
import * as
|
|
83590
|
-
import * as
|
|
83717
|
+
import * as fs41 from "node:fs";
|
|
83718
|
+
import * as path44 from "node:path";
|
|
83591
83719
|
|
|
83592
83720
|
// cli/clone/handle-existing-directory.ts
|
|
83593
83721
|
var import_prompts3 = __toESM2(require_prompts3(), 1);
|
|
83594
|
-
import * as
|
|
83595
|
-
import * as
|
|
83722
|
+
import * as fs40 from "node:fs";
|
|
83723
|
+
import * as path43 from "node:path";
|
|
83596
83724
|
var handleExistingDirectory = async (dirPath) => {
|
|
83597
|
-
if (!
|
|
83725
|
+
if (!fs40.existsSync(dirPath))
|
|
83598
83726
|
return;
|
|
83599
83727
|
const response = await import_prompts3.default({
|
|
83600
83728
|
type: "select",
|
|
83601
83729
|
name: "action",
|
|
83602
|
-
message: `Directory "${
|
|
83730
|
+
message: `Directory "${path43.basename(dirPath)}" already exists. What would you like to do?`,
|
|
83603
83731
|
choices: [
|
|
83604
83732
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
83605
83733
|
{
|
|
@@ -83614,7 +83742,7 @@ var handleExistingDirectory = async (dirPath) => {
|
|
|
83614
83742
|
process.exit(0);
|
|
83615
83743
|
}
|
|
83616
83744
|
if (response.action === "delete") {
|
|
83617
|
-
|
|
83745
|
+
fs40.rmSync(dirPath, { recursive: true, force: true });
|
|
83618
83746
|
console.log(`Deleted existing directory: ${dirPath}`);
|
|
83619
83747
|
} else if (response.action === "merge") {
|
|
83620
83748
|
console.log(`Merging files into existing directory: ${dirPath}`);
|
|
@@ -83640,12 +83768,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
83640
83768
|
return commonSegments.join("/");
|
|
83641
83769
|
};
|
|
83642
83770
|
var sanitizeRelativePath = (relativePath) => {
|
|
83643
|
-
const normalizedPath =
|
|
83771
|
+
const normalizedPath = path44.normalize(relativePath);
|
|
83644
83772
|
if (!normalizedPath)
|
|
83645
83773
|
return null;
|
|
83646
|
-
if (
|
|
83774
|
+
if (path44.isAbsolute(normalizedPath))
|
|
83647
83775
|
return null;
|
|
83648
|
-
const segments = normalizedPath.split(
|
|
83776
|
+
const segments = normalizedPath.split(path44.sep);
|
|
83649
83777
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
83650
83778
|
return null;
|
|
83651
83779
|
}
|
|
@@ -83660,7 +83788,7 @@ var cloneBugReport = async ({
|
|
|
83660
83788
|
console.error("Bug report ID must not be empty.");
|
|
83661
83789
|
process.exit(1);
|
|
83662
83790
|
}
|
|
83663
|
-
let dirPath =
|
|
83791
|
+
let dirPath = path44.resolve(`bug-report-${trimmedBugReportId}`);
|
|
83664
83792
|
await handleExistingDirectory(dirPath);
|
|
83665
83793
|
const ky2 = getRegistryApiKy();
|
|
83666
83794
|
let zipBuffer;
|
|
@@ -83678,7 +83806,7 @@ var cloneBugReport = async ({
|
|
|
83678
83806
|
}
|
|
83679
83807
|
process.exit(1);
|
|
83680
83808
|
}
|
|
83681
|
-
|
|
83809
|
+
fs41.mkdirSync(dirPath, { recursive: true });
|
|
83682
83810
|
const zip = await import_jszip2.default.loadAsync(zipBuffer);
|
|
83683
83811
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
83684
83812
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
@@ -83690,29 +83818,29 @@ var cloneBugReport = async ({
|
|
|
83690
83818
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
83691
83819
|
continue;
|
|
83692
83820
|
}
|
|
83693
|
-
const fullPath =
|
|
83694
|
-
|
|
83821
|
+
const fullPath = path44.join(dirPath, sanitizedRelativePath);
|
|
83822
|
+
fs41.mkdirSync(path44.dirname(fullPath), { recursive: true });
|
|
83695
83823
|
const fileContent = await entry.async("nodebuffer");
|
|
83696
|
-
|
|
83824
|
+
fs41.writeFileSync(fullPath, fileContent);
|
|
83697
83825
|
}
|
|
83698
|
-
const packageJsonPath =
|
|
83699
|
-
if (
|
|
83826
|
+
const packageJsonPath = path44.join(dirPath, "package.json");
|
|
83827
|
+
if (fs41.existsSync(packageJsonPath)) {
|
|
83700
83828
|
try {
|
|
83701
|
-
const packageJson = JSON.parse(
|
|
83829
|
+
const packageJson = JSON.parse(fs41.readFileSync(packageJsonPath, "utf-8"));
|
|
83702
83830
|
const packageName = packageJson?.name;
|
|
83703
83831
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
83704
83832
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
83705
|
-
const suggestedDirPath =
|
|
83833
|
+
const suggestedDirPath = path44.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
83706
83834
|
if (suggestedDirPath !== dirPath) {
|
|
83707
83835
|
const response = await import_prompts4.default({
|
|
83708
83836
|
type: "confirm",
|
|
83709
83837
|
name: "rename",
|
|
83710
83838
|
initial: true,
|
|
83711
|
-
message: `Rename the directory to "${
|
|
83839
|
+
message: `Rename the directory to "${path44.basename(suggestedDirPath)}"?`
|
|
83712
83840
|
});
|
|
83713
83841
|
if (response.rename) {
|
|
83714
83842
|
await handleExistingDirectory(suggestedDirPath);
|
|
83715
|
-
|
|
83843
|
+
fs41.renameSync(dirPath, suggestedDirPath);
|
|
83716
83844
|
dirPath = suggestedDirPath;
|
|
83717
83845
|
}
|
|
83718
83846
|
}
|
|
@@ -83721,9 +83849,9 @@ var cloneBugReport = async ({
|
|
|
83721
83849
|
console.warn("Unable to read package name for renaming:", error);
|
|
83722
83850
|
}
|
|
83723
83851
|
}
|
|
83724
|
-
|
|
83852
|
+
fs41.writeFileSync(path44.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83725
83853
|
generateTsConfig(dirPath);
|
|
83726
|
-
const relativeDirPath =
|
|
83854
|
+
const relativeDirPath = path44.relative(originalCwd, dirPath);
|
|
83727
83855
|
console.log(kleur_default.green(`
|
|
83728
83856
|
Successfully cloned bug report to:`));
|
|
83729
83857
|
console.log(` ${dirPath}/
|
|
@@ -83762,7 +83890,7 @@ var registerClone = (program2) => {
|
|
|
83762
83890
|
const [, author, packageName] = match;
|
|
83763
83891
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
83764
83892
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
83765
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
83893
|
+
const dirPath = userSettingToIncludeAuthor ? path45.resolve(`${author}.${packageName}`) : path45.resolve(packageName);
|
|
83766
83894
|
await handleExistingDirectory(dirPath);
|
|
83767
83895
|
const ky2 = getRegistryApiKy();
|
|
83768
83896
|
let packageFileList = {
|
|
@@ -83783,13 +83911,13 @@ var registerClone = (program2) => {
|
|
|
83783
83911
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
83784
83912
|
process.exit(1);
|
|
83785
83913
|
}
|
|
83786
|
-
|
|
83914
|
+
fs42.mkdirSync(dirPath, { recursive: true });
|
|
83787
83915
|
for (const fileInfo of packageFileList.package_files) {
|
|
83788
83916
|
const filePath = fileInfo.file_path.replace(/^\/+/, "");
|
|
83789
83917
|
if (!filePath)
|
|
83790
83918
|
continue;
|
|
83791
|
-
const fullPath =
|
|
83792
|
-
|
|
83919
|
+
const fullPath = path45.join(dirPath, filePath);
|
|
83920
|
+
fs42.mkdirSync(path45.dirname(fullPath), { recursive: true });
|
|
83793
83921
|
try {
|
|
83794
83922
|
const fileContent = await ky2.get("package_files/get", {
|
|
83795
83923
|
searchParams: {
|
|
@@ -83800,14 +83928,14 @@ var registerClone = (program2) => {
|
|
|
83800
83928
|
}).json();
|
|
83801
83929
|
const { is_text: isText, content_text: contentText } = fileContent.package_file;
|
|
83802
83930
|
if (isText && typeof contentText === "string") {
|
|
83803
|
-
|
|
83931
|
+
fs42.writeFileSync(fullPath, contentText);
|
|
83804
83932
|
} else if (!isText) {
|
|
83805
83933
|
const fileBuffer = await ky2.get("package_files/download", {
|
|
83806
83934
|
searchParams: {
|
|
83807
83935
|
package_file_id: fileContent.package_file.package_file_id
|
|
83808
83936
|
}
|
|
83809
83937
|
}).arrayBuffer();
|
|
83810
|
-
|
|
83938
|
+
fs42.writeFileSync(fullPath, Buffer.from(fileBuffer));
|
|
83811
83939
|
} else {
|
|
83812
83940
|
console.warn(`Skipping ${filePath} due to empty content.`);
|
|
83813
83941
|
}
|
|
@@ -83815,10 +83943,10 @@ var registerClone = (program2) => {
|
|
|
83815
83943
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
83816
83944
|
}
|
|
83817
83945
|
}
|
|
83818
|
-
|
|
83946
|
+
fs42.writeFileSync(path45.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83819
83947
|
generateTsConfig(dirPath);
|
|
83820
83948
|
await setupTsciProject(dirPath);
|
|
83821
|
-
const relativeDirPath =
|
|
83949
|
+
const relativeDirPath = path45.relative(originalCwd, dirPath);
|
|
83822
83950
|
console.log(kleur_default.green(`
|
|
83823
83951
|
Successfully cloned to:`));
|
|
83824
83952
|
console.log(` ${dirPath}/
|
|
@@ -83885,8 +84013,8 @@ var registerConfigSet = (program2) => {
|
|
|
83885
84013
|
};
|
|
83886
84014
|
|
|
83887
84015
|
// cli/convert/register.ts
|
|
83888
|
-
import
|
|
83889
|
-
import
|
|
84016
|
+
import fs43 from "node:fs/promises";
|
|
84017
|
+
import path46 from "node:path";
|
|
83890
84018
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
83891
84019
|
|
|
83892
84020
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -84007,15 +84135,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
84007
84135
|
var registerConvert = (program2) => {
|
|
84008
84136
|
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) => {
|
|
84009
84137
|
try {
|
|
84010
|
-
const inputPath =
|
|
84011
|
-
const modContent = await
|
|
84138
|
+
const inputPath = path46.resolve(file);
|
|
84139
|
+
const modContent = await fs43.readFile(inputPath, "utf-8");
|
|
84012
84140
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
84013
|
-
const componentName = options.name ??
|
|
84141
|
+
const componentName = options.name ?? path46.basename(inputPath, ".kicad_mod");
|
|
84014
84142
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
84015
84143
|
componentName
|
|
84016
84144
|
});
|
|
84017
|
-
const outputPath = options.output ?
|
|
84018
|
-
await
|
|
84145
|
+
const outputPath = options.output ? path46.resolve(options.output) : path46.join(path46.dirname(inputPath), `${componentName}.tsx`);
|
|
84146
|
+
await fs43.writeFile(outputPath, tsx);
|
|
84019
84147
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
84020
84148
|
} catch (error) {
|
|
84021
84149
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -84025,13 +84153,13 @@ var registerConvert = (program2) => {
|
|
|
84025
84153
|
};
|
|
84026
84154
|
|
|
84027
84155
|
// cli/dev/register.ts
|
|
84028
|
-
import * as
|
|
84156
|
+
import * as fs50 from "node:fs";
|
|
84029
84157
|
import * as net from "node:net";
|
|
84030
|
-
import * as
|
|
84158
|
+
import * as path54 from "node:path";
|
|
84031
84159
|
|
|
84032
84160
|
// cli/dev/DevServer.ts
|
|
84033
|
-
import
|
|
84034
|
-
import
|
|
84161
|
+
import fs48 from "node:fs";
|
|
84162
|
+
import path52 from "node:path";
|
|
84035
84163
|
|
|
84036
84164
|
// node_modules/chokidar/esm/index.js
|
|
84037
84165
|
import { stat as statcb } from "fs";
|
|
@@ -84110,7 +84238,7 @@ class ReaddirpStream extends Readable {
|
|
|
84110
84238
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
84111
84239
|
const statMethod = opts.lstat ? lstat : stat;
|
|
84112
84240
|
if (wantBigintFsStats) {
|
|
84113
|
-
this._stat = (
|
|
84241
|
+
this._stat = (path47) => statMethod(path47, { bigint: true });
|
|
84114
84242
|
} else {
|
|
84115
84243
|
this._stat = statMethod;
|
|
84116
84244
|
}
|
|
@@ -84135,8 +84263,8 @@ class ReaddirpStream extends Readable {
|
|
|
84135
84263
|
const par = this.parent;
|
|
84136
84264
|
const fil = par && par.files;
|
|
84137
84265
|
if (fil && fil.length > 0) {
|
|
84138
|
-
const { path:
|
|
84139
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
84266
|
+
const { path: path47, depth } = par;
|
|
84267
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path47));
|
|
84140
84268
|
const awaited = await Promise.all(slice);
|
|
84141
84269
|
for (const entry of awaited) {
|
|
84142
84270
|
if (!entry)
|
|
@@ -84176,20 +84304,20 @@ class ReaddirpStream extends Readable {
|
|
|
84176
84304
|
this.reading = false;
|
|
84177
84305
|
}
|
|
84178
84306
|
}
|
|
84179
|
-
async _exploreDir(
|
|
84307
|
+
async _exploreDir(path47, depth) {
|
|
84180
84308
|
let files;
|
|
84181
84309
|
try {
|
|
84182
|
-
files = await readdir(
|
|
84310
|
+
files = await readdir(path47, this._rdOptions);
|
|
84183
84311
|
} catch (error) {
|
|
84184
84312
|
this._onError(error);
|
|
84185
84313
|
}
|
|
84186
|
-
return { files, depth, path:
|
|
84314
|
+
return { files, depth, path: path47 };
|
|
84187
84315
|
}
|
|
84188
|
-
async _formatEntry(dirent,
|
|
84316
|
+
async _formatEntry(dirent, path47) {
|
|
84189
84317
|
let entry;
|
|
84190
84318
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
84191
84319
|
try {
|
|
84192
|
-
const fullPath = presolve(pjoin(
|
|
84320
|
+
const fullPath = presolve(pjoin(path47, basename4));
|
|
84193
84321
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
|
|
84194
84322
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
84195
84323
|
} catch (err) {
|
|
@@ -84587,16 +84715,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
84587
84715
|
};
|
|
84588
84716
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
84589
84717
|
var FsWatchInstances = new Map;
|
|
84590
|
-
function createFsWatchInstance(
|
|
84718
|
+
function createFsWatchInstance(path47, options, listener, errHandler, emitRaw) {
|
|
84591
84719
|
const handleEvent = (rawEvent, evPath) => {
|
|
84592
|
-
listener(
|
|
84593
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
84594
|
-
if (evPath &&
|
|
84595
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
84720
|
+
listener(path47);
|
|
84721
|
+
emitRaw(rawEvent, evPath, { watchedPath: path47 });
|
|
84722
|
+
if (evPath && path47 !== evPath) {
|
|
84723
|
+
fsWatchBroadcast(sysPath.resolve(path47, evPath), KEY_LISTENERS, sysPath.join(path47, evPath));
|
|
84596
84724
|
}
|
|
84597
84725
|
};
|
|
84598
84726
|
try {
|
|
84599
|
-
return fs_watch(
|
|
84727
|
+
return fs_watch(path47, {
|
|
84600
84728
|
persistent: options.persistent
|
|
84601
84729
|
}, handleEvent);
|
|
84602
84730
|
} catch (error) {
|
|
@@ -84612,12 +84740,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
84612
84740
|
listener(val1, val2, val3);
|
|
84613
84741
|
});
|
|
84614
84742
|
};
|
|
84615
|
-
var setFsWatchListener = (
|
|
84743
|
+
var setFsWatchListener = (path47, fullPath, options, handlers) => {
|
|
84616
84744
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
84617
84745
|
let cont = FsWatchInstances.get(fullPath);
|
|
84618
84746
|
let watcher;
|
|
84619
84747
|
if (!options.persistent) {
|
|
84620
|
-
watcher = createFsWatchInstance(
|
|
84748
|
+
watcher = createFsWatchInstance(path47, options, listener, errHandler, rawEmitter);
|
|
84621
84749
|
if (!watcher)
|
|
84622
84750
|
return;
|
|
84623
84751
|
return watcher.close.bind(watcher);
|
|
@@ -84627,7 +84755,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84627
84755
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
84628
84756
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
84629
84757
|
} else {
|
|
84630
|
-
watcher = createFsWatchInstance(
|
|
84758
|
+
watcher = createFsWatchInstance(path47, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
84631
84759
|
if (!watcher)
|
|
84632
84760
|
return;
|
|
84633
84761
|
watcher.on(EV.ERROR, async (error) => {
|
|
@@ -84636,7 +84764,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84636
84764
|
cont.watcherUnusable = true;
|
|
84637
84765
|
if (isWindows && error.code === "EPERM") {
|
|
84638
84766
|
try {
|
|
84639
|
-
const fd = await open(
|
|
84767
|
+
const fd = await open(path47, "r");
|
|
84640
84768
|
await fd.close();
|
|
84641
84769
|
broadcastErr(error);
|
|
84642
84770
|
} catch (err) {}
|
|
@@ -84666,7 +84794,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84666
84794
|
};
|
|
84667
84795
|
};
|
|
84668
84796
|
var FsWatchFileInstances = new Map;
|
|
84669
|
-
var setFsWatchFileListener = (
|
|
84797
|
+
var setFsWatchFileListener = (path47, fullPath, options, handlers) => {
|
|
84670
84798
|
const { listener, rawEmitter } = handlers;
|
|
84671
84799
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
84672
84800
|
const copts = cont && cont.options;
|
|
@@ -84688,7 +84816,7 @@ var setFsWatchFileListener = (path46, fullPath, options, handlers) => {
|
|
|
84688
84816
|
});
|
|
84689
84817
|
const currmtime = curr.mtimeMs;
|
|
84690
84818
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
84691
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
84819
|
+
foreach(cont.listeners, (listener2) => listener2(path47, curr));
|
|
84692
84820
|
}
|
|
84693
84821
|
})
|
|
84694
84822
|
};
|
|
@@ -84711,13 +84839,13 @@ class NodeFsHandler {
|
|
|
84711
84839
|
this.fsw = fsW;
|
|
84712
84840
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
84713
84841
|
}
|
|
84714
|
-
_watchWithNodeFs(
|
|
84842
|
+
_watchWithNodeFs(path47, listener) {
|
|
84715
84843
|
const opts = this.fsw.options;
|
|
84716
|
-
const directory = sysPath.dirname(
|
|
84717
|
-
const basename5 = sysPath.basename(
|
|
84844
|
+
const directory = sysPath.dirname(path47);
|
|
84845
|
+
const basename5 = sysPath.basename(path47);
|
|
84718
84846
|
const parent = this.fsw._getWatchedDir(directory);
|
|
84719
84847
|
parent.add(basename5);
|
|
84720
|
-
const absolutePath = sysPath.resolve(
|
|
84848
|
+
const absolutePath = sysPath.resolve(path47);
|
|
84721
84849
|
const options = {
|
|
84722
84850
|
persistent: opts.persistent
|
|
84723
84851
|
};
|
|
@@ -84727,12 +84855,12 @@ class NodeFsHandler {
|
|
|
84727
84855
|
if (opts.usePolling) {
|
|
84728
84856
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
84729
84857
|
options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
|
|
84730
|
-
closer = setFsWatchFileListener(
|
|
84858
|
+
closer = setFsWatchFileListener(path47, absolutePath, options, {
|
|
84731
84859
|
listener,
|
|
84732
84860
|
rawEmitter: this.fsw._emitRaw
|
|
84733
84861
|
});
|
|
84734
84862
|
} else {
|
|
84735
|
-
closer = setFsWatchListener(
|
|
84863
|
+
closer = setFsWatchListener(path47, absolutePath, options, {
|
|
84736
84864
|
listener,
|
|
84737
84865
|
errHandler: this._boundHandleError,
|
|
84738
84866
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -84750,7 +84878,7 @@ class NodeFsHandler {
|
|
|
84750
84878
|
let prevStats = stats;
|
|
84751
84879
|
if (parent.has(basename5))
|
|
84752
84880
|
return;
|
|
84753
|
-
const listener = async (
|
|
84881
|
+
const listener = async (path47, newStats) => {
|
|
84754
84882
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
84755
84883
|
return;
|
|
84756
84884
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -84764,11 +84892,11 @@ class NodeFsHandler {
|
|
|
84764
84892
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
84765
84893
|
}
|
|
84766
84894
|
if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
|
|
84767
|
-
this.fsw._closeFile(
|
|
84895
|
+
this.fsw._closeFile(path47);
|
|
84768
84896
|
prevStats = newStats2;
|
|
84769
84897
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
84770
84898
|
if (closer2)
|
|
84771
|
-
this.fsw._addPathCloser(
|
|
84899
|
+
this.fsw._addPathCloser(path47, closer2);
|
|
84772
84900
|
} else {
|
|
84773
84901
|
prevStats = newStats2;
|
|
84774
84902
|
}
|
|
@@ -84792,7 +84920,7 @@ class NodeFsHandler {
|
|
|
84792
84920
|
}
|
|
84793
84921
|
return closer;
|
|
84794
84922
|
}
|
|
84795
|
-
async _handleSymlink(entry, directory,
|
|
84923
|
+
async _handleSymlink(entry, directory, path47, item) {
|
|
84796
84924
|
if (this.fsw.closed) {
|
|
84797
84925
|
return;
|
|
84798
84926
|
}
|
|
@@ -84802,7 +84930,7 @@ class NodeFsHandler {
|
|
|
84802
84930
|
this.fsw._incrReadyCount();
|
|
84803
84931
|
let linkPath;
|
|
84804
84932
|
try {
|
|
84805
|
-
linkPath = await fsrealpath(
|
|
84933
|
+
linkPath = await fsrealpath(path47);
|
|
84806
84934
|
} catch (e) {
|
|
84807
84935
|
this.fsw._emitReady();
|
|
84808
84936
|
return true;
|
|
@@ -84812,12 +84940,12 @@ class NodeFsHandler {
|
|
|
84812
84940
|
if (dir.has(item)) {
|
|
84813
84941
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
84814
84942
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84815
|
-
this.fsw._emit(EV.CHANGE,
|
|
84943
|
+
this.fsw._emit(EV.CHANGE, path47, entry.stats);
|
|
84816
84944
|
}
|
|
84817
84945
|
} else {
|
|
84818
84946
|
dir.add(item);
|
|
84819
84947
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84820
|
-
this.fsw._emit(EV.ADD,
|
|
84948
|
+
this.fsw._emit(EV.ADD, path47, entry.stats);
|
|
84821
84949
|
}
|
|
84822
84950
|
this.fsw._emitReady();
|
|
84823
84951
|
return true;
|
|
@@ -84846,9 +84974,9 @@ class NodeFsHandler {
|
|
|
84846
84974
|
return;
|
|
84847
84975
|
}
|
|
84848
84976
|
const item = entry.path;
|
|
84849
|
-
let
|
|
84977
|
+
let path47 = sysPath.join(directory, item);
|
|
84850
84978
|
current.add(item);
|
|
84851
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
84979
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path47, item)) {
|
|
84852
84980
|
return;
|
|
84853
84981
|
}
|
|
84854
84982
|
if (this.fsw.closed) {
|
|
@@ -84857,8 +84985,8 @@ class NodeFsHandler {
|
|
|
84857
84985
|
}
|
|
84858
84986
|
if (item === target || !target && !previous.has(item)) {
|
|
84859
84987
|
this.fsw._incrReadyCount();
|
|
84860
|
-
|
|
84861
|
-
this._addToNodeFs(
|
|
84988
|
+
path47 = sysPath.join(dir, sysPath.relative(dir, path47));
|
|
84989
|
+
this._addToNodeFs(path47, initialAdd, wh, depth + 1);
|
|
84862
84990
|
}
|
|
84863
84991
|
}).on(EV.ERROR, this._boundHandleError);
|
|
84864
84992
|
return new Promise((resolve7, reject) => {
|
|
@@ -84907,13 +85035,13 @@ class NodeFsHandler {
|
|
|
84907
85035
|
}
|
|
84908
85036
|
return closer;
|
|
84909
85037
|
}
|
|
84910
|
-
async _addToNodeFs(
|
|
85038
|
+
async _addToNodeFs(path47, initialAdd, priorWh, depth, target) {
|
|
84911
85039
|
const ready = this.fsw._emitReady;
|
|
84912
|
-
if (this.fsw._isIgnored(
|
|
85040
|
+
if (this.fsw._isIgnored(path47) || this.fsw.closed) {
|
|
84913
85041
|
ready();
|
|
84914
85042
|
return false;
|
|
84915
85043
|
}
|
|
84916
|
-
const wh = this.fsw._getWatchHelpers(
|
|
85044
|
+
const wh = this.fsw._getWatchHelpers(path47);
|
|
84917
85045
|
if (priorWh) {
|
|
84918
85046
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
84919
85047
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -84929,8 +85057,8 @@ class NodeFsHandler {
|
|
|
84929
85057
|
const follow = this.fsw.options.followSymlinks;
|
|
84930
85058
|
let closer;
|
|
84931
85059
|
if (stats.isDirectory()) {
|
|
84932
|
-
const absPath = sysPath.resolve(
|
|
84933
|
-
const targetPath = follow ? await fsrealpath(
|
|
85060
|
+
const absPath = sysPath.resolve(path47);
|
|
85061
|
+
const targetPath = follow ? await fsrealpath(path47) : path47;
|
|
84934
85062
|
if (this.fsw.closed)
|
|
84935
85063
|
return;
|
|
84936
85064
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -84940,29 +85068,29 @@ class NodeFsHandler {
|
|
|
84940
85068
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
84941
85069
|
}
|
|
84942
85070
|
} else if (stats.isSymbolicLink()) {
|
|
84943
|
-
const targetPath = follow ? await fsrealpath(
|
|
85071
|
+
const targetPath = follow ? await fsrealpath(path47) : path47;
|
|
84944
85072
|
if (this.fsw.closed)
|
|
84945
85073
|
return;
|
|
84946
85074
|
const parent = sysPath.dirname(wh.watchPath);
|
|
84947
85075
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
84948
85076
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
84949
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
85077
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path47, wh, targetPath);
|
|
84950
85078
|
if (this.fsw.closed)
|
|
84951
85079
|
return;
|
|
84952
85080
|
if (targetPath !== undefined) {
|
|
84953
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
85081
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path47), targetPath);
|
|
84954
85082
|
}
|
|
84955
85083
|
} else {
|
|
84956
85084
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
84957
85085
|
}
|
|
84958
85086
|
ready();
|
|
84959
85087
|
if (closer)
|
|
84960
|
-
this.fsw._addPathCloser(
|
|
85088
|
+
this.fsw._addPathCloser(path47, closer);
|
|
84961
85089
|
return false;
|
|
84962
85090
|
} catch (error) {
|
|
84963
85091
|
if (this.fsw._handleError(error)) {
|
|
84964
85092
|
ready();
|
|
84965
|
-
return
|
|
85093
|
+
return path47;
|
|
84966
85094
|
}
|
|
84967
85095
|
}
|
|
84968
85096
|
}
|
|
@@ -85005,26 +85133,26 @@ function createPattern(matcher) {
|
|
|
85005
85133
|
}
|
|
85006
85134
|
return () => false;
|
|
85007
85135
|
}
|
|
85008
|
-
function normalizePath(
|
|
85009
|
-
if (typeof
|
|
85136
|
+
function normalizePath(path47) {
|
|
85137
|
+
if (typeof path47 !== "string")
|
|
85010
85138
|
throw new Error("string expected");
|
|
85011
|
-
|
|
85012
|
-
|
|
85139
|
+
path47 = sysPath2.normalize(path47);
|
|
85140
|
+
path47 = path47.replace(/\\/g, "/");
|
|
85013
85141
|
let prepend = false;
|
|
85014
|
-
if (
|
|
85142
|
+
if (path47.startsWith("//"))
|
|
85015
85143
|
prepend = true;
|
|
85016
85144
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
85017
|
-
while (
|
|
85018
|
-
|
|
85145
|
+
while (path47.match(DOUBLE_SLASH_RE2))
|
|
85146
|
+
path47 = path47.replace(DOUBLE_SLASH_RE2, "/");
|
|
85019
85147
|
if (prepend)
|
|
85020
|
-
|
|
85021
|
-
return
|
|
85148
|
+
path47 = "/" + path47;
|
|
85149
|
+
return path47;
|
|
85022
85150
|
}
|
|
85023
85151
|
function matchPatterns(patterns, testString, stats) {
|
|
85024
|
-
const
|
|
85152
|
+
const path47 = normalizePath(testString);
|
|
85025
85153
|
for (let index = 0;index < patterns.length; index++) {
|
|
85026
85154
|
const pattern = patterns[index];
|
|
85027
|
-
if (pattern(
|
|
85155
|
+
if (pattern(path47, stats)) {
|
|
85028
85156
|
return true;
|
|
85029
85157
|
}
|
|
85030
85158
|
}
|
|
@@ -85064,19 +85192,19 @@ var toUnix = (string) => {
|
|
|
85064
85192
|
}
|
|
85065
85193
|
return str;
|
|
85066
85194
|
};
|
|
85067
|
-
var normalizePathToUnix = (
|
|
85068
|
-
var normalizeIgnored = (cwd = "") => (
|
|
85069
|
-
if (typeof
|
|
85070
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
85195
|
+
var normalizePathToUnix = (path47) => toUnix(sysPath2.normalize(toUnix(path47)));
|
|
85196
|
+
var normalizeIgnored = (cwd = "") => (path47) => {
|
|
85197
|
+
if (typeof path47 === "string") {
|
|
85198
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path47) ? path47 : sysPath2.join(cwd, path47));
|
|
85071
85199
|
} else {
|
|
85072
|
-
return
|
|
85200
|
+
return path47;
|
|
85073
85201
|
}
|
|
85074
85202
|
};
|
|
85075
|
-
var getAbsolutePath = (
|
|
85076
|
-
if (sysPath2.isAbsolute(
|
|
85077
|
-
return
|
|
85203
|
+
var getAbsolutePath = (path47, cwd) => {
|
|
85204
|
+
if (sysPath2.isAbsolute(path47)) {
|
|
85205
|
+
return path47;
|
|
85078
85206
|
}
|
|
85079
|
-
return sysPath2.join(cwd,
|
|
85207
|
+
return sysPath2.join(cwd, path47);
|
|
85080
85208
|
};
|
|
85081
85209
|
var EMPTY_SET = Object.freeze(new Set);
|
|
85082
85210
|
|
|
@@ -85133,10 +85261,10 @@ var STAT_METHOD_F = "stat";
|
|
|
85133
85261
|
var STAT_METHOD_L = "lstat";
|
|
85134
85262
|
|
|
85135
85263
|
class WatchHelper {
|
|
85136
|
-
constructor(
|
|
85264
|
+
constructor(path47, follow, fsw) {
|
|
85137
85265
|
this.fsw = fsw;
|
|
85138
|
-
const watchPath =
|
|
85139
|
-
this.path =
|
|
85266
|
+
const watchPath = path47;
|
|
85267
|
+
this.path = path47 = path47.replace(REPLACER_RE, "");
|
|
85140
85268
|
this.watchPath = watchPath;
|
|
85141
85269
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
85142
85270
|
this.dirParts = [];
|
|
@@ -85249,20 +85377,20 @@ class FSWatcher extends EventEmitter {
|
|
|
85249
85377
|
this._closePromise = undefined;
|
|
85250
85378
|
let paths = unifyPaths(paths_);
|
|
85251
85379
|
if (cwd) {
|
|
85252
|
-
paths = paths.map((
|
|
85253
|
-
const absPath = getAbsolutePath(
|
|
85380
|
+
paths = paths.map((path47) => {
|
|
85381
|
+
const absPath = getAbsolutePath(path47, cwd);
|
|
85254
85382
|
return absPath;
|
|
85255
85383
|
});
|
|
85256
85384
|
}
|
|
85257
|
-
paths.forEach((
|
|
85258
|
-
this._removeIgnoredPath(
|
|
85385
|
+
paths.forEach((path47) => {
|
|
85386
|
+
this._removeIgnoredPath(path47);
|
|
85259
85387
|
});
|
|
85260
85388
|
this._userIgnored = undefined;
|
|
85261
85389
|
if (!this._readyCount)
|
|
85262
85390
|
this._readyCount = 0;
|
|
85263
85391
|
this._readyCount += paths.length;
|
|
85264
|
-
Promise.all(paths.map(async (
|
|
85265
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
85392
|
+
Promise.all(paths.map(async (path47) => {
|
|
85393
|
+
const res = await this._nodeFsHandler._addToNodeFs(path47, !_internal, undefined, 0, _origAdd);
|
|
85266
85394
|
if (res)
|
|
85267
85395
|
this._emitReady();
|
|
85268
85396
|
return res;
|
|
@@ -85281,17 +85409,17 @@ class FSWatcher extends EventEmitter {
|
|
|
85281
85409
|
return this;
|
|
85282
85410
|
const paths = unifyPaths(paths_);
|
|
85283
85411
|
const { cwd } = this.options;
|
|
85284
|
-
paths.forEach((
|
|
85285
|
-
if (!sysPath2.isAbsolute(
|
|
85412
|
+
paths.forEach((path47) => {
|
|
85413
|
+
if (!sysPath2.isAbsolute(path47) && !this._closers.has(path47)) {
|
|
85286
85414
|
if (cwd)
|
|
85287
|
-
|
|
85288
|
-
|
|
85415
|
+
path47 = sysPath2.join(cwd, path47);
|
|
85416
|
+
path47 = sysPath2.resolve(path47);
|
|
85289
85417
|
}
|
|
85290
|
-
this._closePath(
|
|
85291
|
-
this._addIgnoredPath(
|
|
85292
|
-
if (this._watched.has(
|
|
85418
|
+
this._closePath(path47);
|
|
85419
|
+
this._addIgnoredPath(path47);
|
|
85420
|
+
if (this._watched.has(path47)) {
|
|
85293
85421
|
this._addIgnoredPath({
|
|
85294
|
-
path:
|
|
85422
|
+
path: path47,
|
|
85295
85423
|
recursive: true
|
|
85296
85424
|
});
|
|
85297
85425
|
}
|
|
@@ -85340,38 +85468,38 @@ class FSWatcher extends EventEmitter {
|
|
|
85340
85468
|
if (event !== EVENTS.ERROR)
|
|
85341
85469
|
this.emit(EVENTS.ALL, ...args);
|
|
85342
85470
|
}
|
|
85343
|
-
async _emit(event,
|
|
85471
|
+
async _emit(event, path47, stats) {
|
|
85344
85472
|
if (this.closed)
|
|
85345
85473
|
return;
|
|
85346
85474
|
const opts = this.options;
|
|
85347
85475
|
if (isWindows)
|
|
85348
|
-
|
|
85476
|
+
path47 = sysPath2.normalize(path47);
|
|
85349
85477
|
if (opts.cwd)
|
|
85350
|
-
|
|
85351
|
-
const args = [event,
|
|
85478
|
+
path47 = sysPath2.relative(opts.cwd, path47);
|
|
85479
|
+
const args = [event, path47];
|
|
85352
85480
|
if (stats != null)
|
|
85353
85481
|
args.push(stats);
|
|
85354
85482
|
const awf = opts.awaitWriteFinish;
|
|
85355
85483
|
let pw;
|
|
85356
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
85484
|
+
if (awf && (pw = this._pendingWrites.get(path47))) {
|
|
85357
85485
|
pw.lastChange = new Date;
|
|
85358
85486
|
return this;
|
|
85359
85487
|
}
|
|
85360
85488
|
if (opts.atomic) {
|
|
85361
85489
|
if (event === EVENTS.UNLINK) {
|
|
85362
|
-
this._pendingUnlinks.set(
|
|
85490
|
+
this._pendingUnlinks.set(path47, args);
|
|
85363
85491
|
setTimeout(() => {
|
|
85364
|
-
this._pendingUnlinks.forEach((entry,
|
|
85492
|
+
this._pendingUnlinks.forEach((entry, path48) => {
|
|
85365
85493
|
this.emit(...entry);
|
|
85366
85494
|
this.emit(EVENTS.ALL, ...entry);
|
|
85367
|
-
this._pendingUnlinks.delete(
|
|
85495
|
+
this._pendingUnlinks.delete(path48);
|
|
85368
85496
|
});
|
|
85369
85497
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
85370
85498
|
return this;
|
|
85371
85499
|
}
|
|
85372
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
85500
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path47)) {
|
|
85373
85501
|
event = args[0] = EVENTS.CHANGE;
|
|
85374
|
-
this._pendingUnlinks.delete(
|
|
85502
|
+
this._pendingUnlinks.delete(path47);
|
|
85375
85503
|
}
|
|
85376
85504
|
}
|
|
85377
85505
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -85389,16 +85517,16 @@ class FSWatcher extends EventEmitter {
|
|
|
85389
85517
|
this.emitWithAll(event, args);
|
|
85390
85518
|
}
|
|
85391
85519
|
};
|
|
85392
|
-
this._awaitWriteFinish(
|
|
85520
|
+
this._awaitWriteFinish(path47, awf.stabilityThreshold, event, awfEmit);
|
|
85393
85521
|
return this;
|
|
85394
85522
|
}
|
|
85395
85523
|
if (event === EVENTS.CHANGE) {
|
|
85396
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
85524
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path47, 50);
|
|
85397
85525
|
if (isThrottled)
|
|
85398
85526
|
return this;
|
|
85399
85527
|
}
|
|
85400
85528
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
85401
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
85529
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path47) : path47;
|
|
85402
85530
|
let stats2;
|
|
85403
85531
|
try {
|
|
85404
85532
|
stats2 = await stat3(fullPath);
|
|
@@ -85417,23 +85545,23 @@ class FSWatcher extends EventEmitter {
|
|
|
85417
85545
|
}
|
|
85418
85546
|
return error || this.closed;
|
|
85419
85547
|
}
|
|
85420
|
-
_throttle(actionType,
|
|
85548
|
+
_throttle(actionType, path47, timeout2) {
|
|
85421
85549
|
if (!this._throttled.has(actionType)) {
|
|
85422
85550
|
this._throttled.set(actionType, new Map);
|
|
85423
85551
|
}
|
|
85424
85552
|
const action = this._throttled.get(actionType);
|
|
85425
85553
|
if (!action)
|
|
85426
85554
|
throw new Error("invalid throttle");
|
|
85427
|
-
const actionPath = action.get(
|
|
85555
|
+
const actionPath = action.get(path47);
|
|
85428
85556
|
if (actionPath) {
|
|
85429
85557
|
actionPath.count++;
|
|
85430
85558
|
return false;
|
|
85431
85559
|
}
|
|
85432
85560
|
let timeoutObject;
|
|
85433
85561
|
const clear = () => {
|
|
85434
|
-
const item = action.get(
|
|
85562
|
+
const item = action.get(path47);
|
|
85435
85563
|
const count = item ? item.count : 0;
|
|
85436
|
-
action.delete(
|
|
85564
|
+
action.delete(path47);
|
|
85437
85565
|
clearTimeout(timeoutObject);
|
|
85438
85566
|
if (item)
|
|
85439
85567
|
clearTimeout(item.timeoutObject);
|
|
@@ -85441,50 +85569,50 @@ class FSWatcher extends EventEmitter {
|
|
|
85441
85569
|
};
|
|
85442
85570
|
timeoutObject = setTimeout(clear, timeout2);
|
|
85443
85571
|
const thr = { timeoutObject, clear, count: 0 };
|
|
85444
|
-
action.set(
|
|
85572
|
+
action.set(path47, thr);
|
|
85445
85573
|
return thr;
|
|
85446
85574
|
}
|
|
85447
85575
|
_incrReadyCount() {
|
|
85448
85576
|
return this._readyCount++;
|
|
85449
85577
|
}
|
|
85450
|
-
_awaitWriteFinish(
|
|
85578
|
+
_awaitWriteFinish(path47, threshold, event, awfEmit) {
|
|
85451
85579
|
const awf = this.options.awaitWriteFinish;
|
|
85452
85580
|
if (typeof awf !== "object")
|
|
85453
85581
|
return;
|
|
85454
85582
|
const pollInterval = awf.pollInterval;
|
|
85455
85583
|
let timeoutHandler;
|
|
85456
|
-
let fullPath =
|
|
85457
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
85458
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
85584
|
+
let fullPath = path47;
|
|
85585
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path47)) {
|
|
85586
|
+
fullPath = sysPath2.join(this.options.cwd, path47);
|
|
85459
85587
|
}
|
|
85460
85588
|
const now = new Date;
|
|
85461
85589
|
const writes = this._pendingWrites;
|
|
85462
85590
|
function awaitWriteFinishFn(prevStat) {
|
|
85463
85591
|
statcb(fullPath, (err, curStat) => {
|
|
85464
|
-
if (err || !writes.has(
|
|
85592
|
+
if (err || !writes.has(path47)) {
|
|
85465
85593
|
if (err && err.code !== "ENOENT")
|
|
85466
85594
|
awfEmit(err);
|
|
85467
85595
|
return;
|
|
85468
85596
|
}
|
|
85469
85597
|
const now2 = Number(new Date);
|
|
85470
85598
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
85471
|
-
writes.get(
|
|
85599
|
+
writes.get(path47).lastChange = now2;
|
|
85472
85600
|
}
|
|
85473
|
-
const pw = writes.get(
|
|
85601
|
+
const pw = writes.get(path47);
|
|
85474
85602
|
const df = now2 - pw.lastChange;
|
|
85475
85603
|
if (df >= threshold) {
|
|
85476
|
-
writes.delete(
|
|
85604
|
+
writes.delete(path47);
|
|
85477
85605
|
awfEmit(undefined, curStat);
|
|
85478
85606
|
} else {
|
|
85479
85607
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
85480
85608
|
}
|
|
85481
85609
|
});
|
|
85482
85610
|
}
|
|
85483
|
-
if (!writes.has(
|
|
85484
|
-
writes.set(
|
|
85611
|
+
if (!writes.has(path47)) {
|
|
85612
|
+
writes.set(path47, {
|
|
85485
85613
|
lastChange: now,
|
|
85486
85614
|
cancelWait: () => {
|
|
85487
|
-
writes.delete(
|
|
85615
|
+
writes.delete(path47);
|
|
85488
85616
|
clearTimeout(timeoutHandler);
|
|
85489
85617
|
return event;
|
|
85490
85618
|
}
|
|
@@ -85492,8 +85620,8 @@ class FSWatcher extends EventEmitter {
|
|
|
85492
85620
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
85493
85621
|
}
|
|
85494
85622
|
}
|
|
85495
|
-
_isIgnored(
|
|
85496
|
-
if (this.options.atomic && DOT_RE.test(
|
|
85623
|
+
_isIgnored(path47, stats) {
|
|
85624
|
+
if (this.options.atomic && DOT_RE.test(path47))
|
|
85497
85625
|
return true;
|
|
85498
85626
|
if (!this._userIgnored) {
|
|
85499
85627
|
const { cwd } = this.options;
|
|
@@ -85503,13 +85631,13 @@ class FSWatcher extends EventEmitter {
|
|
|
85503
85631
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
85504
85632
|
this._userIgnored = anymatch(list, undefined);
|
|
85505
85633
|
}
|
|
85506
|
-
return this._userIgnored(
|
|
85634
|
+
return this._userIgnored(path47, stats);
|
|
85507
85635
|
}
|
|
85508
|
-
_isntIgnored(
|
|
85509
|
-
return !this._isIgnored(
|
|
85636
|
+
_isntIgnored(path47, stat4) {
|
|
85637
|
+
return !this._isIgnored(path47, stat4);
|
|
85510
85638
|
}
|
|
85511
|
-
_getWatchHelpers(
|
|
85512
|
-
return new WatchHelper(
|
|
85639
|
+
_getWatchHelpers(path47) {
|
|
85640
|
+
return new WatchHelper(path47, this.options.followSymlinks, this);
|
|
85513
85641
|
}
|
|
85514
85642
|
_getWatchedDir(directory) {
|
|
85515
85643
|
const dir = sysPath2.resolve(directory);
|
|
@@ -85523,57 +85651,57 @@ class FSWatcher extends EventEmitter {
|
|
|
85523
85651
|
return Boolean(Number(stats.mode) & 256);
|
|
85524
85652
|
}
|
|
85525
85653
|
_remove(directory, item, isDirectory2) {
|
|
85526
|
-
const
|
|
85527
|
-
const fullPath = sysPath2.resolve(
|
|
85528
|
-
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(
|
|
85529
|
-
if (!this._throttle("remove",
|
|
85654
|
+
const path47 = sysPath2.join(directory, item);
|
|
85655
|
+
const fullPath = sysPath2.resolve(path47);
|
|
85656
|
+
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path47) || this._watched.has(fullPath);
|
|
85657
|
+
if (!this._throttle("remove", path47, 100))
|
|
85530
85658
|
return;
|
|
85531
85659
|
if (!isDirectory2 && this._watched.size === 1) {
|
|
85532
85660
|
this.add(directory, item, true);
|
|
85533
85661
|
}
|
|
85534
|
-
const wp = this._getWatchedDir(
|
|
85662
|
+
const wp = this._getWatchedDir(path47);
|
|
85535
85663
|
const nestedDirectoryChildren = wp.getChildren();
|
|
85536
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
85664
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path47, nested));
|
|
85537
85665
|
const parent = this._getWatchedDir(directory);
|
|
85538
85666
|
const wasTracked = parent.has(item);
|
|
85539
85667
|
parent.remove(item);
|
|
85540
85668
|
if (this._symlinkPaths.has(fullPath)) {
|
|
85541
85669
|
this._symlinkPaths.delete(fullPath);
|
|
85542
85670
|
}
|
|
85543
|
-
let relPath =
|
|
85671
|
+
let relPath = path47;
|
|
85544
85672
|
if (this.options.cwd)
|
|
85545
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
85673
|
+
relPath = sysPath2.relative(this.options.cwd, path47);
|
|
85546
85674
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
85547
85675
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
85548
85676
|
if (event === EVENTS.ADD)
|
|
85549
85677
|
return;
|
|
85550
85678
|
}
|
|
85551
|
-
this._watched.delete(
|
|
85679
|
+
this._watched.delete(path47);
|
|
85552
85680
|
this._watched.delete(fullPath);
|
|
85553
85681
|
const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
85554
|
-
if (wasTracked && !this._isIgnored(
|
|
85555
|
-
this._emit(eventName,
|
|
85556
|
-
this._closePath(
|
|
85682
|
+
if (wasTracked && !this._isIgnored(path47))
|
|
85683
|
+
this._emit(eventName, path47);
|
|
85684
|
+
this._closePath(path47);
|
|
85557
85685
|
}
|
|
85558
|
-
_closePath(
|
|
85559
|
-
this._closeFile(
|
|
85560
|
-
const dir = sysPath2.dirname(
|
|
85561
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
85686
|
+
_closePath(path47) {
|
|
85687
|
+
this._closeFile(path47);
|
|
85688
|
+
const dir = sysPath2.dirname(path47);
|
|
85689
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path47));
|
|
85562
85690
|
}
|
|
85563
|
-
_closeFile(
|
|
85564
|
-
const closers = this._closers.get(
|
|
85691
|
+
_closeFile(path47) {
|
|
85692
|
+
const closers = this._closers.get(path47);
|
|
85565
85693
|
if (!closers)
|
|
85566
85694
|
return;
|
|
85567
85695
|
closers.forEach((closer) => closer());
|
|
85568
|
-
this._closers.delete(
|
|
85696
|
+
this._closers.delete(path47);
|
|
85569
85697
|
}
|
|
85570
|
-
_addPathCloser(
|
|
85698
|
+
_addPathCloser(path47, closer) {
|
|
85571
85699
|
if (!closer)
|
|
85572
85700
|
return;
|
|
85573
|
-
let list = this._closers.get(
|
|
85701
|
+
let list = this._closers.get(path47);
|
|
85574
85702
|
if (!list) {
|
|
85575
85703
|
list = [];
|
|
85576
|
-
this._closers.set(
|
|
85704
|
+
this._closers.set(path47, list);
|
|
85577
85705
|
}
|
|
85578
85706
|
list.push(closer);
|
|
85579
85707
|
}
|
|
@@ -85606,16 +85734,16 @@ import Debug3 from "debug";
|
|
|
85606
85734
|
|
|
85607
85735
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
85608
85736
|
import * as ts from "typescript";
|
|
85609
|
-
import * as
|
|
85610
|
-
import * as
|
|
85737
|
+
import * as path47 from "path";
|
|
85738
|
+
import * as fs44 from "fs";
|
|
85611
85739
|
function getAllDependencyPackages(projectDir) {
|
|
85612
|
-
const packageJsonPath =
|
|
85740
|
+
const packageJsonPath = path47.join(projectDir, "package.json");
|
|
85613
85741
|
const allPackages = new Set;
|
|
85614
|
-
if (!
|
|
85742
|
+
if (!fs44.existsSync(packageJsonPath)) {
|
|
85615
85743
|
return allPackages;
|
|
85616
85744
|
}
|
|
85617
85745
|
try {
|
|
85618
|
-
const packageJson = JSON.parse(
|
|
85746
|
+
const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
|
|
85619
85747
|
const deps = packageJson.dependencies || {};
|
|
85620
85748
|
const devDeps = packageJson.devDependencies || {};
|
|
85621
85749
|
for (const packageName of Object.keys(deps)) {
|
|
@@ -85630,11 +85758,11 @@ function getAllDependencyPackages(projectDir) {
|
|
|
85630
85758
|
return allPackages;
|
|
85631
85759
|
}
|
|
85632
85760
|
function getNodeModuleImports(filePath) {
|
|
85633
|
-
const absolutePath =
|
|
85634
|
-
if (!
|
|
85761
|
+
const absolutePath = path47.resolve(filePath);
|
|
85762
|
+
if (!fs44.existsSync(absolutePath)) {
|
|
85635
85763
|
return [];
|
|
85636
85764
|
}
|
|
85637
|
-
const content =
|
|
85765
|
+
const content = fs44.readFileSync(absolutePath, "utf-8");
|
|
85638
85766
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
85639
85767
|
const imports = new Set;
|
|
85640
85768
|
function visit(node) {
|
|
@@ -85684,17 +85812,17 @@ function resolveNodeModuleImport({
|
|
|
85684
85812
|
}) {
|
|
85685
85813
|
const packageName = getPackageNameFromImport(importPath);
|
|
85686
85814
|
const searchPaths = [
|
|
85687
|
-
|
|
85815
|
+
path47.join(projectDir, "node_modules", packageName)
|
|
85688
85816
|
];
|
|
85689
85817
|
if (searchFromDir) {
|
|
85690
|
-
let currentDir =
|
|
85691
|
-
const projectDirNormalized =
|
|
85818
|
+
let currentDir = path47.dirname(searchFromDir);
|
|
85819
|
+
const projectDirNormalized = path47.normalize(projectDir);
|
|
85692
85820
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
85693
|
-
const candidatePath =
|
|
85821
|
+
const candidatePath = path47.join(currentDir, "node_modules", packageName);
|
|
85694
85822
|
if (!searchPaths.includes(candidatePath)) {
|
|
85695
85823
|
searchPaths.push(candidatePath);
|
|
85696
85824
|
}
|
|
85697
|
-
const parentDir =
|
|
85825
|
+
const parentDir = path47.dirname(currentDir);
|
|
85698
85826
|
if (parentDir === currentDir)
|
|
85699
85827
|
break;
|
|
85700
85828
|
currentDir = parentDir;
|
|
@@ -85702,7 +85830,7 @@ function resolveNodeModuleImport({
|
|
|
85702
85830
|
}
|
|
85703
85831
|
let packageDir;
|
|
85704
85832
|
for (const candidatePath of searchPaths) {
|
|
85705
|
-
if (
|
|
85833
|
+
if (fs44.existsSync(candidatePath)) {
|
|
85706
85834
|
packageDir = candidatePath;
|
|
85707
85835
|
break;
|
|
85708
85836
|
}
|
|
@@ -85710,25 +85838,25 @@ function resolveNodeModuleImport({
|
|
|
85710
85838
|
if (!packageDir) {
|
|
85711
85839
|
return [];
|
|
85712
85840
|
}
|
|
85713
|
-
const packageJsonPath =
|
|
85714
|
-
const hasPackageJson =
|
|
85715
|
-
const packageJson = hasPackageJson ? JSON.parse(
|
|
85841
|
+
const packageJsonPath = path47.join(packageDir, "package.json");
|
|
85842
|
+
const hasPackageJson = fs44.existsSync(packageJsonPath);
|
|
85843
|
+
const packageJson = hasPackageJson ? JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8")) : null;
|
|
85716
85844
|
const resolvedFiles = [];
|
|
85717
85845
|
if (importPath !== packageName) {
|
|
85718
85846
|
const subpath = importPath.slice(packageName.length + 1);
|
|
85719
85847
|
const possiblePaths = [
|
|
85720
|
-
|
|
85721
|
-
|
|
85722
|
-
|
|
85723
|
-
|
|
85724
|
-
|
|
85725
|
-
|
|
85726
|
-
|
|
85727
|
-
|
|
85728
|
-
|
|
85848
|
+
path47.join(packageDir, subpath),
|
|
85849
|
+
path47.join(packageDir, `${subpath}.js`),
|
|
85850
|
+
path47.join(packageDir, `${subpath}.mjs`),
|
|
85851
|
+
path47.join(packageDir, `${subpath}.ts`),
|
|
85852
|
+
path47.join(packageDir, `${subpath}.tsx`),
|
|
85853
|
+
path47.join(packageDir, subpath, "index.js"),
|
|
85854
|
+
path47.join(packageDir, subpath, "index.mjs"),
|
|
85855
|
+
path47.join(packageDir, subpath, "index.ts"),
|
|
85856
|
+
path47.join(packageDir, subpath, "index.tsx")
|
|
85729
85857
|
];
|
|
85730
85858
|
for (const p of possiblePaths) {
|
|
85731
|
-
if (
|
|
85859
|
+
if (fs44.existsSync(p) && fs44.statSync(p).isFile()) {
|
|
85732
85860
|
resolvedFiles.push(p);
|
|
85733
85861
|
break;
|
|
85734
85862
|
}
|
|
@@ -85760,25 +85888,25 @@ function resolveNodeModuleImport({
|
|
|
85760
85888
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
85761
85889
|
].filter((entry) => typeof entry === "string");
|
|
85762
85890
|
for (const entry of entryPoints) {
|
|
85763
|
-
const entryPath =
|
|
85764
|
-
if (
|
|
85891
|
+
const entryPath = path47.join(packageDir, entry);
|
|
85892
|
+
if (fs44.existsSync(entryPath) && fs44.statSync(entryPath).isFile()) {
|
|
85765
85893
|
resolvedFiles.push(entryPath);
|
|
85766
85894
|
}
|
|
85767
85895
|
}
|
|
85768
85896
|
if (resolvedFiles.length === 0) {
|
|
85769
85897
|
const fallbackPaths = [
|
|
85770
|
-
|
|
85771
|
-
|
|
85772
|
-
|
|
85773
|
-
|
|
85774
|
-
|
|
85775
|
-
|
|
85776
|
-
|
|
85777
|
-
|
|
85778
|
-
|
|
85898
|
+
path47.join(packageDir, "index.js"),
|
|
85899
|
+
path47.join(packageDir, "index.mjs"),
|
|
85900
|
+
path47.join(packageDir, "index.ts"),
|
|
85901
|
+
path47.join(packageDir, "index.tsx"),
|
|
85902
|
+
path47.join(packageDir, "dist", "index.js"),
|
|
85903
|
+
path47.join(packageDir, "dist", "index.mjs"),
|
|
85904
|
+
path47.join(packageDir, "lib", "index.js"),
|
|
85905
|
+
path47.join(packageDir, "src", "index.ts"),
|
|
85906
|
+
path47.join(packageDir, "src", "index.tsx")
|
|
85779
85907
|
];
|
|
85780
85908
|
for (const p of fallbackPaths) {
|
|
85781
|
-
if (
|
|
85909
|
+
if (fs44.existsSync(p) && fs44.statSync(p).isFile()) {
|
|
85782
85910
|
resolvedFiles.push(p);
|
|
85783
85911
|
break;
|
|
85784
85912
|
}
|
|
@@ -85816,12 +85944,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85816
85944
|
}
|
|
85817
85945
|
}
|
|
85818
85946
|
function getLocalDependencies(filePath) {
|
|
85819
|
-
const absolutePath =
|
|
85820
|
-
const baseDir =
|
|
85821
|
-
if (!
|
|
85947
|
+
const absolutePath = path47.resolve(filePath);
|
|
85948
|
+
const baseDir = path47.dirname(absolutePath);
|
|
85949
|
+
if (!fs44.existsSync(absolutePath)) {
|
|
85822
85950
|
return [];
|
|
85823
85951
|
}
|
|
85824
|
-
const content =
|
|
85952
|
+
const content = fs44.readFileSync(absolutePath, "utf-8");
|
|
85825
85953
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
85826
85954
|
const dependencies = [];
|
|
85827
85955
|
function visit(node) {
|
|
@@ -85843,20 +85971,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85843
85971
|
}
|
|
85844
85972
|
function resolveLocalImport(importPath, baseDir) {
|
|
85845
85973
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
85846
|
-
const resolvedPath =
|
|
85847
|
-
if (
|
|
85974
|
+
const resolvedPath = path47.resolve(baseDir, importPath);
|
|
85975
|
+
if (fs44.existsSync(resolvedPath) && fs44.statSync(resolvedPath).isFile()) {
|
|
85848
85976
|
return resolvedPath;
|
|
85849
85977
|
}
|
|
85850
85978
|
for (const ext of extensions) {
|
|
85851
85979
|
const pathWithExt = resolvedPath + ext;
|
|
85852
|
-
if (
|
|
85980
|
+
if (fs44.existsSync(pathWithExt)) {
|
|
85853
85981
|
return pathWithExt;
|
|
85854
85982
|
}
|
|
85855
85983
|
}
|
|
85856
|
-
if (
|
|
85984
|
+
if (fs44.existsSync(resolvedPath) && fs44.statSync(resolvedPath).isDirectory()) {
|
|
85857
85985
|
for (const ext of extensions) {
|
|
85858
|
-
const indexPath =
|
|
85859
|
-
if (
|
|
85986
|
+
const indexPath = path47.join(resolvedPath, `index${ext}`);
|
|
85987
|
+
if (fs44.existsSync(indexPath)) {
|
|
85860
85988
|
return indexPath;
|
|
85861
85989
|
}
|
|
85862
85990
|
}
|
|
@@ -85881,12 +86009,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
85881
86009
|
function collectLocalPackageFiles(packageDir) {
|
|
85882
86010
|
const buildDirs = ["dist", "build"];
|
|
85883
86011
|
for (const dirName of buildDirs) {
|
|
85884
|
-
const dirPath =
|
|
85885
|
-
if (
|
|
86012
|
+
const dirPath = path47.join(packageDir, dirName);
|
|
86013
|
+
if (fs44.existsSync(dirPath)) {
|
|
85886
86014
|
const files = walkDirectory(dirPath, new Set);
|
|
85887
86015
|
if (files.length > 0) {
|
|
85888
|
-
const packageJsonPath =
|
|
85889
|
-
if (
|
|
86016
|
+
const packageJsonPath = path47.join(packageDir, "package.json");
|
|
86017
|
+
if (fs44.existsSync(packageJsonPath)) {
|
|
85890
86018
|
files.push(packageJsonPath);
|
|
85891
86019
|
}
|
|
85892
86020
|
return files;
|
|
@@ -85897,11 +86025,11 @@ function collectLocalPackageFiles(packageDir) {
|
|
|
85897
86025
|
}
|
|
85898
86026
|
function walkDirectory(dir, excludedDirs) {
|
|
85899
86027
|
const files = [];
|
|
85900
|
-
if (!
|
|
86028
|
+
if (!fs44.existsSync(dir))
|
|
85901
86029
|
return files;
|
|
85902
|
-
const entries =
|
|
86030
|
+
const entries = fs44.readdirSync(dir, { withFileTypes: true });
|
|
85903
86031
|
for (const entry of entries) {
|
|
85904
|
-
const fullPath =
|
|
86032
|
+
const fullPath = path47.join(dir, entry.name);
|
|
85905
86033
|
if (entry.isDirectory()) {
|
|
85906
86034
|
if (excludedDirs.has(entry.name)) {
|
|
85907
86035
|
continue;
|
|
@@ -85962,13 +86090,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
85962
86090
|
processedPackages.add(packageName);
|
|
85963
86091
|
if (resolvedFiles.length > 0) {
|
|
85964
86092
|
const firstResolvedFile = resolvedFiles[0];
|
|
85965
|
-
let packageDir =
|
|
86093
|
+
let packageDir = path47.dirname(firstResolvedFile);
|
|
85966
86094
|
let hasPackageJson = false;
|
|
85967
86095
|
while (packageDir.includes("node_modules")) {
|
|
85968
|
-
const packageJsonPath =
|
|
85969
|
-
if (
|
|
86096
|
+
const packageJsonPath = path47.join(packageDir, "package.json");
|
|
86097
|
+
if (fs44.existsSync(packageJsonPath)) {
|
|
85970
86098
|
try {
|
|
85971
|
-
const pkgJson = JSON.parse(
|
|
86099
|
+
const pkgJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
|
|
85972
86100
|
if (pkgJson.name === packageName) {
|
|
85973
86101
|
hasPackageJson = true;
|
|
85974
86102
|
break;
|
|
@@ -85976,15 +86104,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
85976
86104
|
} catch {}
|
|
85977
86105
|
}
|
|
85978
86106
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
85979
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
86107
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path47.sep))) {
|
|
85980
86108
|
break;
|
|
85981
86109
|
}
|
|
85982
|
-
const parentDir =
|
|
86110
|
+
const parentDir = path47.dirname(packageDir);
|
|
85983
86111
|
if (parentDir === packageDir)
|
|
85984
86112
|
break;
|
|
85985
86113
|
packageDir = parentDir;
|
|
85986
86114
|
}
|
|
85987
|
-
if (
|
|
86115
|
+
if (fs44.existsSync(packageDir)) {
|
|
85988
86116
|
if (hasPackageJson) {
|
|
85989
86117
|
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
85990
86118
|
packageFiles.forEach((file) => allFiles.add(file));
|
|
@@ -86050,7 +86178,7 @@ class EventsWatcher extends EventEmitter2 {
|
|
|
86050
86178
|
}
|
|
86051
86179
|
|
|
86052
86180
|
// lib/server/createHttpServer.ts
|
|
86053
|
-
import * as
|
|
86181
|
+
import * as fs46 from "node:fs";
|
|
86054
86182
|
import * as http from "node:http";
|
|
86055
86183
|
|
|
86056
86184
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
@@ -86753,10 +86881,10 @@ var databaseSchema = z5.object({
|
|
|
86753
86881
|
files: z5.array(fileSchema).default([]),
|
|
86754
86882
|
events: z5.array(eventSchema).default([])
|
|
86755
86883
|
});
|
|
86756
|
-
function normalizePath2(
|
|
86757
|
-
if (!
|
|
86884
|
+
function normalizePath2(path48) {
|
|
86885
|
+
if (!path48 || path48 === "/")
|
|
86758
86886
|
return "";
|
|
86759
|
-
let normalized =
|
|
86887
|
+
let normalized = path48.replace(/\\+/g, "/").replace(/\/\/+/, "/");
|
|
86760
86888
|
if (normalized.startsWith("/")) {
|
|
86761
86889
|
normalized = normalized.slice(1);
|
|
86762
86890
|
}
|
|
@@ -87613,14 +87741,14 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
87613
87741
|
};
|
|
87614
87742
|
|
|
87615
87743
|
// lib/server/kicad-pcm-proxy.ts
|
|
87616
|
-
import * as
|
|
87617
|
-
import * as
|
|
87744
|
+
import * as fs45 from "node:fs";
|
|
87745
|
+
import * as path48 from "node:path";
|
|
87618
87746
|
var getSourceFilesChecksum = (projectDir) => {
|
|
87619
87747
|
const sourceFiles = globbySync(["**/*.tsx", "**/*.ts", "**/*.json", "!node_modules/**", "!dist/**"], { cwd: projectDir });
|
|
87620
87748
|
let checksum = "";
|
|
87621
87749
|
for (const file of sourceFiles) {
|
|
87622
87750
|
try {
|
|
87623
|
-
const stat4 =
|
|
87751
|
+
const stat4 = fs45.statSync(path48.join(projectDir, file));
|
|
87624
87752
|
checksum += `${file}:${stat4.mtimeMs};`;
|
|
87625
87753
|
} catch {}
|
|
87626
87754
|
}
|
|
@@ -87640,9 +87768,9 @@ var createKicadPcmProxy = ({
|
|
|
87640
87768
|
};
|
|
87641
87769
|
const handleRequest = async (url, res) => {
|
|
87642
87770
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
87643
|
-
const distDir =
|
|
87644
|
-
const pcmDir =
|
|
87645
|
-
const filePath =
|
|
87771
|
+
const distDir = path48.join(projectDir, "dist");
|
|
87772
|
+
const pcmDir = path48.join(distDir, "pcm");
|
|
87773
|
+
const filePath = path48.join(pcmDir, requestedFile);
|
|
87646
87774
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
87647
87775
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
87648
87776
|
if (needsRebuild) {
|
|
@@ -87687,12 +87815,12 @@ Rebuilding KiCad PCM assets...`));
|
|
|
87687
87815
|
}
|
|
87688
87816
|
}
|
|
87689
87817
|
}
|
|
87690
|
-
if (!
|
|
87818
|
+
if (!fs45.existsSync(filePath)) {
|
|
87691
87819
|
res.writeHead(404);
|
|
87692
87820
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
87693
87821
|
return;
|
|
87694
87822
|
}
|
|
87695
|
-
const ext =
|
|
87823
|
+
const ext = path48.extname(filePath).toLowerCase();
|
|
87696
87824
|
let contentType = "application/octet-stream";
|
|
87697
87825
|
if (ext === ".json") {
|
|
87698
87826
|
contentType = "application/json";
|
|
@@ -87700,7 +87828,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
87700
87828
|
contentType = "application/zip";
|
|
87701
87829
|
}
|
|
87702
87830
|
try {
|
|
87703
|
-
const content =
|
|
87831
|
+
const content = fs45.readFileSync(filePath);
|
|
87704
87832
|
res.writeHead(200, { "Content-Type": contentType });
|
|
87705
87833
|
res.end(content);
|
|
87706
87834
|
} catch (error) {
|
|
@@ -87780,7 +87908,7 @@ var createHttpServer = async ({
|
|
|
87780
87908
|
return;
|
|
87781
87909
|
}
|
|
87782
87910
|
try {
|
|
87783
|
-
const content =
|
|
87911
|
+
const content = fs46.readFileSync(standaloneFilePath, "utf8");
|
|
87784
87912
|
res.writeHead(200, {
|
|
87785
87913
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
87786
87914
|
});
|
|
@@ -87823,8 +87951,8 @@ var createHttpServer = async ({
|
|
|
87823
87951
|
|
|
87824
87952
|
// lib/shared/push-snippet.ts
|
|
87825
87953
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
87826
|
-
import * as
|
|
87827
|
-
import * as
|
|
87954
|
+
import * as fs47 from "node:fs";
|
|
87955
|
+
import * as path51 from "node:path";
|
|
87828
87956
|
import Debug2 from "debug";
|
|
87829
87957
|
|
|
87830
87958
|
// lib/utils/validate-package-name.ts
|
|
@@ -87842,7 +87970,7 @@ var validatePackageName = (name) => {
|
|
|
87842
87970
|
};
|
|
87843
87971
|
|
|
87844
87972
|
// cli/dev/get-package-file-paths.ts
|
|
87845
|
-
import * as
|
|
87973
|
+
import * as path49 from "node:path";
|
|
87846
87974
|
var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
87847
87975
|
const ignorePatterns = [
|
|
87848
87976
|
...DEFAULT_IGNORED_PATTERNS,
|
|
@@ -87853,7 +87981,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
87853
87981
|
ignore: ignorePatterns
|
|
87854
87982
|
});
|
|
87855
87983
|
fileNames.sort();
|
|
87856
|
-
return fileNames.map((fileName) =>
|
|
87984
|
+
return fileNames.map((fileName) => path49.join(projectDir, fileName));
|
|
87857
87985
|
};
|
|
87858
87986
|
|
|
87859
87987
|
// lib/utils/check-org-access.ts
|
|
@@ -87869,7 +87997,7 @@ var checkOrgAccess = async (ky2, orgTscircuitHandle) => {
|
|
|
87869
87997
|
};
|
|
87870
87998
|
|
|
87871
87999
|
// lib/shared/is-binary-file.ts
|
|
87872
|
-
import * as
|
|
88000
|
+
import * as path50 from "node:path";
|
|
87873
88001
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
87874
88002
|
".glb",
|
|
87875
88003
|
".gltf",
|
|
@@ -87885,7 +88013,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
87885
88013
|
".tar"
|
|
87886
88014
|
]);
|
|
87887
88015
|
var isBinaryFile = (filePath) => {
|
|
87888
|
-
const ext =
|
|
88016
|
+
const ext = path50.extname(filePath).toLowerCase();
|
|
87889
88017
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
87890
88018
|
};
|
|
87891
88019
|
|
|
@@ -87911,8 +88039,8 @@ var debug2 = Debug2("tsci:push-snippet");
|
|
|
87911
88039
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
87912
88040
|
const zip = new import_jszip3.default;
|
|
87913
88041
|
for (const fullFilePath of filePaths) {
|
|
87914
|
-
const relativeFilePath =
|
|
87915
|
-
zip.file(relativeFilePath,
|
|
88042
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88043
|
+
zip.file(relativeFilePath, fs47.readFileSync(fullFilePath));
|
|
87916
88044
|
}
|
|
87917
88045
|
const archive = await zip.generateAsync({
|
|
87918
88046
|
type: "uint8array",
|
|
@@ -87950,24 +88078,24 @@ var pushSnippet = async ({
|
|
|
87950
88078
|
return onExit(1);
|
|
87951
88079
|
}
|
|
87952
88080
|
const packageJsonPath = [
|
|
87953
|
-
|
|
87954
|
-
|
|
87955
|
-
].find((
|
|
87956
|
-
const projectDir = packageJsonPath ?
|
|
88081
|
+
path51.resolve(path51.join(path51.dirname(snippetFilePath), "package.json")),
|
|
88082
|
+
path51.resolve(path51.join(process.cwd(), "package.json"))
|
|
88083
|
+
].find((path52) => fs47.existsSync(path52));
|
|
88084
|
+
const projectDir = packageJsonPath ? path51.dirname(packageJsonPath) : path51.dirname(snippetFilePath);
|
|
87957
88085
|
if (!packageJsonPath) {
|
|
87958
88086
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
87959
88087
|
return onExit(1);
|
|
87960
88088
|
}
|
|
87961
88089
|
let packageJson = {};
|
|
87962
|
-
if (
|
|
88090
|
+
if (fs47.existsSync(packageJsonPath)) {
|
|
87963
88091
|
try {
|
|
87964
|
-
packageJson = JSON.parse(
|
|
88092
|
+
packageJson = JSON.parse(fs47.readFileSync(packageJsonPath).toString());
|
|
87965
88093
|
} catch {
|
|
87966
88094
|
onError("Invalid package.json");
|
|
87967
88095
|
return onExit(1);
|
|
87968
88096
|
}
|
|
87969
88097
|
}
|
|
87970
|
-
if (!
|
|
88098
|
+
if (!fs47.existsSync(snippetFilePath)) {
|
|
87971
88099
|
onError(`File not found: ${snippetFilePath}`);
|
|
87972
88100
|
return onExit(1);
|
|
87973
88101
|
}
|
|
@@ -88008,7 +88136,7 @@ var pushSnippet = async ({
|
|
|
88008
88136
|
}
|
|
88009
88137
|
unscopedPackageName = inputName;
|
|
88010
88138
|
packageJson.name = `@tsci/${currentUsername}.${unscopedPackageName}`;
|
|
88011
|
-
|
|
88139
|
+
fs47.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88012
88140
|
}
|
|
88013
88141
|
let accountName = currentUsername;
|
|
88014
88142
|
if (packageJsonAuthor && currentUsername !== packageJsonAuthor) {
|
|
@@ -88039,7 +88167,7 @@ var pushSnippet = async ({
|
|
|
88039
88167
|
const updatePackageJsonVersion = (newVersion) => {
|
|
88040
88168
|
try {
|
|
88041
88169
|
packageJson.version = newVersion ?? `${packageVersion}`;
|
|
88042
|
-
|
|
88170
|
+
fs47.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88043
88171
|
} catch (error) {
|
|
88044
88172
|
onError(`Failed to update package.json version: ${error}`);
|
|
88045
88173
|
}
|
|
@@ -88147,7 +88275,7 @@ var pushSnippet = async ({
|
|
|
88147
88275
|
json: archivePayload
|
|
88148
88276
|
});
|
|
88149
88277
|
for (const fullFilePath of filePaths) {
|
|
88150
|
-
const relativeFilePath =
|
|
88278
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88151
88279
|
uploadResults.succeeded.push(relativeFilePath);
|
|
88152
88280
|
}
|
|
88153
88281
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -88157,8 +88285,8 @@ var pushSnippet = async ({
|
|
|
88157
88285
|
}
|
|
88158
88286
|
if (uploadResults.succeeded.length === 0) {
|
|
88159
88287
|
for (const fullFilePath of filePaths) {
|
|
88160
|
-
const relativeFilePath =
|
|
88161
|
-
const fileBuffer =
|
|
88288
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88289
|
+
const fileBuffer = fs47.readFileSync(fullFilePath);
|
|
88162
88290
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
88163
88291
|
const payload = {
|
|
88164
88292
|
file_path: relativeFilePath,
|
|
@@ -88247,7 +88375,7 @@ class DevServer {
|
|
|
88247
88375
|
}) {
|
|
88248
88376
|
this.port = port;
|
|
88249
88377
|
this.componentFilePath = componentFilePath;
|
|
88250
|
-
this.projectDir = projectDir ??
|
|
88378
|
+
this.projectDir = projectDir ?? path52.dirname(componentFilePath);
|
|
88251
88379
|
this.kicadPcm = kicadPcm ?? false;
|
|
88252
88380
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
88253
88381
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
@@ -88258,7 +88386,7 @@ class DevServer {
|
|
|
88258
88386
|
async start() {
|
|
88259
88387
|
const { server } = await createHttpServer({
|
|
88260
88388
|
port: this.port,
|
|
88261
|
-
defaultMainComponentPath:
|
|
88389
|
+
defaultMainComponentPath: path52.relative(this.projectDir, this.componentFilePath),
|
|
88262
88390
|
kicadPcm: this.kicadPcm,
|
|
88263
88391
|
projectDir: this.projectDir,
|
|
88264
88392
|
entryFile: this.componentFilePath
|
|
@@ -88274,7 +88402,7 @@ class DevServer {
|
|
|
88274
88402
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
88275
88403
|
persistent: true,
|
|
88276
88404
|
ignoreInitial: true,
|
|
88277
|
-
ignored: (p) => shouldIgnorePath(
|
|
88405
|
+
ignored: (p) => shouldIgnorePath(path52.relative(this.projectDir, p), this.ignoredFiles)
|
|
88278
88406
|
});
|
|
88279
88407
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
88280
88408
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -88289,27 +88417,27 @@ class DevServer {
|
|
|
88289
88417
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
88290
88418
|
searchParams: { file_path: ev.file_path }
|
|
88291
88419
|
}).json();
|
|
88292
|
-
const fullPath =
|
|
88293
|
-
const dirPath =
|
|
88294
|
-
if (!
|
|
88295
|
-
|
|
88420
|
+
const fullPath = path52.join(this.projectDir, ev.file_path);
|
|
88421
|
+
const dirPath = path52.dirname(fullPath);
|
|
88422
|
+
if (!fs48.existsSync(dirPath)) {
|
|
88423
|
+
fs48.mkdirSync(dirPath, { recursive: true });
|
|
88296
88424
|
}
|
|
88297
88425
|
if (file.binary_content_b64) {
|
|
88298
88426
|
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
88299
|
-
|
|
88427
|
+
fs48.writeFileSync(fullPath, decodedContent);
|
|
88300
88428
|
} else {
|
|
88301
|
-
|
|
88429
|
+
fs48.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
88302
88430
|
}
|
|
88303
88431
|
}
|
|
88304
88432
|
async handleFileDeletedEventFromServer(ev) {
|
|
88305
|
-
const fullPath =
|
|
88306
|
-
if (
|
|
88433
|
+
const fullPath = path52.join(this.projectDir, ev.file_path);
|
|
88434
|
+
if (fs48.existsSync(fullPath)) {
|
|
88307
88435
|
debug3(`Deleting file ${ev.file_path} from filesystem`);
|
|
88308
|
-
|
|
88436
|
+
fs48.unlinkSync(fullPath);
|
|
88309
88437
|
}
|
|
88310
88438
|
}
|
|
88311
88439
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
88312
|
-
const relativeFilePath =
|
|
88440
|
+
const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
|
|
88313
88441
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
88314
88442
|
return;
|
|
88315
88443
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -88324,14 +88452,14 @@ class DevServer {
|
|
|
88324
88452
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
88325
88453
|
}
|
|
88326
88454
|
async checkAndUploadNewNodeModules(filePath) {
|
|
88327
|
-
const ext =
|
|
88455
|
+
const ext = path52.extname(filePath).toLowerCase();
|
|
88328
88456
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
88329
88457
|
if (!isSourceFile)
|
|
88330
88458
|
return;
|
|
88331
88459
|
try {
|
|
88332
88460
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
88333
88461
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
88334
|
-
const relativePath =
|
|
88462
|
+
const relativePath = path52.relative(this.projectDir, file);
|
|
88335
88463
|
return !this.uploadedNodeModules.has(relativePath);
|
|
88336
88464
|
});
|
|
88337
88465
|
if (newFiles.length === 0)
|
|
@@ -88344,7 +88472,7 @@ class DevServer {
|
|
|
88344
88472
|
}
|
|
88345
88473
|
}
|
|
88346
88474
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
88347
|
-
const relativeFilePath =
|
|
88475
|
+
const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
|
|
88348
88476
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
88349
88477
|
return;
|
|
88350
88478
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -88382,8 +88510,8 @@ class DevServer {
|
|
|
88382
88510
|
debug3(`Successfully deleted file ${relativeFilePath} from server`);
|
|
88383
88511
|
}
|
|
88384
88512
|
async handleFileRename(oldPath, newPath) {
|
|
88385
|
-
const oldRelativePath =
|
|
88386
|
-
const newRelativePath =
|
|
88513
|
+
const oldRelativePath = path52.relative(this.projectDir, oldPath);
|
|
88514
|
+
const newRelativePath = path52.relative(this.projectDir, newPath);
|
|
88387
88515
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
88388
88516
|
return;
|
|
88389
88517
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -88401,7 +88529,7 @@ class DevServer {
|
|
|
88401
88529
|
});
|
|
88402
88530
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
88403
88531
|
for (const filePath of filePaths) {
|
|
88404
|
-
const relativeFilePath =
|
|
88532
|
+
const relativeFilePath = path52.relative(this.projectDir, filePath);
|
|
88405
88533
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
88406
88534
|
await this.postFileUpsert({
|
|
88407
88535
|
filePath: relativeFilePath,
|
|
@@ -88433,7 +88561,7 @@ class DevServer {
|
|
|
88433
88561
|
}
|
|
88434
88562
|
async uploadNodeModuleFiles(files) {
|
|
88435
88563
|
for (const nodeModuleFile of files) {
|
|
88436
|
-
const relativeFilePath =
|
|
88564
|
+
const relativeFilePath = path52.relative(this.projectDir, nodeModuleFile);
|
|
88437
88565
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
88438
88566
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
88439
88567
|
await this.postFileUpsert({
|
|
@@ -88478,7 +88606,7 @@ class DevServer {
|
|
|
88478
88606
|
formData.set("file_path", filePath);
|
|
88479
88607
|
formData.set("initiator", initiator);
|
|
88480
88608
|
const binaryBytes = Uint8Array.from(binaryContent);
|
|
88481
|
-
formData.set("binary_file", new Blob([binaryBytes]),
|
|
88609
|
+
formData.set("binary_file", new Blob([binaryBytes]), path52.basename(filePath));
|
|
88482
88610
|
const response = await fetch(`http://localhost:${this.port}/api/files/upsert-multipart`, {
|
|
88483
88611
|
method: "POST",
|
|
88484
88612
|
body: formData
|
|
@@ -88518,12 +88646,12 @@ class DevServer {
|
|
|
88518
88646
|
await this.filesystemWatcher?.close();
|
|
88519
88647
|
}
|
|
88520
88648
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
88521
|
-
const ext =
|
|
88649
|
+
const ext = path52.extname(relativeFilePath).toLowerCase();
|
|
88522
88650
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
88523
|
-
const fileBuffer =
|
|
88651
|
+
const fileBuffer = fs48.readFileSync(absoluteFilePath);
|
|
88524
88652
|
return { binary_content: fileBuffer };
|
|
88525
88653
|
}
|
|
88526
|
-
return { text_content:
|
|
88654
|
+
return { text_content: fs48.readFileSync(absoluteFilePath, "utf-8") };
|
|
88527
88655
|
}
|
|
88528
88656
|
async handleInstallPackage(full_package_name) {
|
|
88529
88657
|
const postEvent = async (event, message) => {
|
|
@@ -88553,10 +88681,10 @@ class DevServer {
|
|
|
88553
88681
|
}
|
|
88554
88682
|
|
|
88555
88683
|
// cli/dev/resolve-dev-target.ts
|
|
88556
|
-
import * as
|
|
88557
|
-
import * as
|
|
88684
|
+
import * as fs49 from "node:fs";
|
|
88685
|
+
import * as path53 from "node:path";
|
|
88558
88686
|
var findSelectableFiles = (projectDir) => {
|
|
88559
|
-
const boardFiles = findBoardFiles({ projectDir }).filter((file) =>
|
|
88687
|
+
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs49.existsSync(file)).sort();
|
|
88560
88688
|
if (boardFiles.length > 0) {
|
|
88561
88689
|
return boardFiles;
|
|
88562
88690
|
}
|
|
@@ -88564,7 +88692,7 @@ var findSelectableFiles = (projectDir) => {
|
|
|
88564
88692
|
cwd: projectDir,
|
|
88565
88693
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
88566
88694
|
});
|
|
88567
|
-
return files.map((file) =>
|
|
88695
|
+
return files.map((file) => path53.resolve(projectDir, file)).filter((file) => fs49.existsSync(file)).sort();
|
|
88568
88696
|
};
|
|
88569
88697
|
var isValidDevFile = (filePath) => {
|
|
88570
88698
|
return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
|
|
@@ -88572,18 +88700,18 @@ var isValidDevFile = (filePath) => {
|
|
|
88572
88700
|
var resolveDevTarget = async (file) => {
|
|
88573
88701
|
let projectDir = process.cwd();
|
|
88574
88702
|
if (file) {
|
|
88575
|
-
const resolvedPath =
|
|
88576
|
-
if (
|
|
88703
|
+
const resolvedPath = path53.resolve(file);
|
|
88704
|
+
if (fs49.existsSync(resolvedPath) && fs49.statSync(resolvedPath).isDirectory()) {
|
|
88577
88705
|
projectDir = resolvedPath;
|
|
88578
88706
|
const availableFiles2 = findSelectableFiles(projectDir);
|
|
88579
88707
|
if (availableFiles2.length === 0) {
|
|
88580
88708
|
console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
|
|
88581
88709
|
return null;
|
|
88582
88710
|
}
|
|
88583
|
-
console.log("Selected file:",
|
|
88711
|
+
console.log("Selected file:", path53.relative(projectDir, availableFiles2[0]));
|
|
88584
88712
|
return { absolutePath: availableFiles2[0], projectDir };
|
|
88585
88713
|
}
|
|
88586
|
-
if (!
|
|
88714
|
+
if (!fs49.existsSync(resolvedPath)) {
|
|
88587
88715
|
console.error(`Error: File not found: ${file}`);
|
|
88588
88716
|
return null;
|
|
88589
88717
|
}
|
|
@@ -88594,7 +88722,7 @@ var resolveDevTarget = async (file) => {
|
|
|
88594
88722
|
return { absolutePath: resolvedPath, projectDir };
|
|
88595
88723
|
}
|
|
88596
88724
|
const entrypointPath = await getEntrypoint({ onError: () => {} });
|
|
88597
|
-
if (entrypointPath &&
|
|
88725
|
+
if (entrypointPath && fs49.existsSync(entrypointPath)) {
|
|
88598
88726
|
console.log("Found entrypoint at:", entrypointPath);
|
|
88599
88727
|
return { absolutePath: entrypointPath, projectDir };
|
|
88600
88728
|
}
|
|
@@ -88603,7 +88731,7 @@ var resolveDevTarget = async (file) => {
|
|
|
88603
88731
|
console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
|
|
88604
88732
|
return null;
|
|
88605
88733
|
}
|
|
88606
|
-
console.log("Selected file:",
|
|
88734
|
+
console.log("Selected file:", path53.relative(projectDir, availableFiles[0]));
|
|
88607
88735
|
return { absolutePath: availableFiles[0], projectDir };
|
|
88608
88736
|
};
|
|
88609
88737
|
|
|
@@ -88619,12 +88747,12 @@ var isPortAvailable = (port) => {
|
|
|
88619
88747
|
});
|
|
88620
88748
|
};
|
|
88621
88749
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
88622
|
-
const tsconfigPath =
|
|
88623
|
-
if (!
|
|
88750
|
+
const tsconfigPath = path54.join(projectDir, "tsconfig.json");
|
|
88751
|
+
if (!fs50.existsSync(tsconfigPath)) {
|
|
88624
88752
|
return;
|
|
88625
88753
|
}
|
|
88626
88754
|
try {
|
|
88627
|
-
const tsconfig = JSON.parse(
|
|
88755
|
+
const tsconfig = JSON.parse(fs50.readFileSync(tsconfigPath, "utf-8"));
|
|
88628
88756
|
const types = tsconfig?.compilerOptions?.types;
|
|
88629
88757
|
if (!Array.isArray(types) || !types.includes("tscircuit")) {
|
|
88630
88758
|
console.warn(kleur_default.yellow('Warning: "tscircuit" is missing from tsconfig.json compilerOptions.types. Add it (e.g. "types": ["tscircuit"]) to ensure CLI-provided types work correctly.'));
|
|
@@ -88656,7 +88784,7 @@ var registerDev = (program2) => {
|
|
|
88656
88784
|
|
|
88657
88785
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
88658
88786
|
console.log(`
|
|
88659
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
88787
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path54.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
88660
88788
|
|
|
88661
88789
|
`);
|
|
88662
88790
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -88684,15 +88812,15 @@ var checkLoggedIn = () => {
|
|
|
88684
88812
|
|
|
88685
88813
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
88686
88814
|
import { spawnSync } from "node:child_process";
|
|
88687
|
-
import
|
|
88815
|
+
import fs51 from "node:fs";
|
|
88688
88816
|
import os5 from "node:os";
|
|
88689
|
-
import
|
|
88817
|
+
import path55 from "node:path";
|
|
88690
88818
|
var hasBunInstalled = () => {
|
|
88691
88819
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
88692
88820
|
return result.status === 0;
|
|
88693
88821
|
};
|
|
88694
88822
|
var createTempProject = (tempDir) => {
|
|
88695
|
-
const packageJsonPath =
|
|
88823
|
+
const packageJsonPath = path55.join(tempDir, "package.json");
|
|
88696
88824
|
const packageJson = {
|
|
88697
88825
|
name: "tsci-doctor-check",
|
|
88698
88826
|
version: "0.0.0",
|
|
@@ -88701,7 +88829,7 @@ var createTempProject = (tempDir) => {
|
|
|
88701
88829
|
"@tsci/does-not-exist": "0.0.0"
|
|
88702
88830
|
}
|
|
88703
88831
|
};
|
|
88704
|
-
|
|
88832
|
+
fs51.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88705
88833
|
};
|
|
88706
88834
|
var checkGlobalNpmrcRegistry = async () => {
|
|
88707
88835
|
const name = "Global .npmrc configured for tscircuit NPM registry?";
|
|
@@ -88712,7 +88840,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
88712
88840
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
88713
88841
|
};
|
|
88714
88842
|
}
|
|
88715
|
-
const tempDir =
|
|
88843
|
+
const tempDir = fs51.mkdtempSync(path55.join(os5.tmpdir(), "tsci-doctor-"));
|
|
88716
88844
|
try {
|
|
88717
88845
|
createTempProject(tempDir);
|
|
88718
88846
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -88750,7 +88878,7 @@ ${result.stderr ?? ""}`;
|
|
|
88750
88878
|
}
|
|
88751
88879
|
return { name, success: true };
|
|
88752
88880
|
} finally {
|
|
88753
|
-
|
|
88881
|
+
fs51.rmSync(tempDir, { recursive: true, force: true });
|
|
88754
88882
|
}
|
|
88755
88883
|
};
|
|
88756
88884
|
|
|
@@ -88783,8 +88911,8 @@ var registerDoctor = (program2) => {
|
|
|
88783
88911
|
};
|
|
88784
88912
|
|
|
88785
88913
|
// lib/shared/export-snippet.ts
|
|
88786
|
-
import
|
|
88787
|
-
import
|
|
88914
|
+
import fs52 from "node:fs";
|
|
88915
|
+
import path56 from "node:path";
|
|
88788
88916
|
import { promisify as promisify3 } from "node:util";
|
|
88789
88917
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
88790
88918
|
import {
|
|
@@ -89623,9 +89751,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
89623
89751
|
const stringifyCoordinates = (coordinates) => {
|
|
89624
89752
|
return coordinates.join(" ");
|
|
89625
89753
|
};
|
|
89626
|
-
const stringifyPath = (
|
|
89754
|
+
const stringifyPath = (path56, level) => {
|
|
89627
89755
|
const padding = indent.repeat(level);
|
|
89628
|
-
return `${padding}(path ${
|
|
89756
|
+
return `${padding}(path ${path56.layer} ${path56.width} ${stringifyCoordinates(path56.coordinates)})`;
|
|
89629
89757
|
};
|
|
89630
89758
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
89631
89759
|
`;
|
|
@@ -89815,7 +89943,7 @@ var isCircuitJsonFile = (filePath) => {
|
|
|
89815
89943
|
};
|
|
89816
89944
|
|
|
89817
89945
|
// lib/shared/export-snippet.ts
|
|
89818
|
-
var writeFileAsync = promisify3(
|
|
89946
|
+
var writeFileAsync = promisify3(fs52.writeFile);
|
|
89819
89947
|
var ALLOWED_EXPORT_FORMATS = [
|
|
89820
89948
|
"json",
|
|
89821
89949
|
"circuit-json",
|
|
@@ -89862,10 +89990,10 @@ var exportSnippet = async ({
|
|
|
89862
89990
|
onError(`Invalid format: ${format}`);
|
|
89863
89991
|
return onExit(1);
|
|
89864
89992
|
}
|
|
89865
|
-
const projectDir =
|
|
89866
|
-
const outputBaseName =
|
|
89993
|
+
const projectDir = path56.dirname(filePath);
|
|
89994
|
+
const outputBaseName = path56.basename(filePath).replace(/\.[^.]+$/, "");
|
|
89867
89995
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
89868
|
-
const outputDestination =
|
|
89996
|
+
const outputDestination = path56.join(projectDir, outputPath ?? outputFileName);
|
|
89869
89997
|
if (format === "kicad-library") {
|
|
89870
89998
|
try {
|
|
89871
89999
|
const result = await convertToKicadLibrary({
|
|
@@ -89884,7 +90012,7 @@ var exportSnippet = async ({
|
|
|
89884
90012
|
}
|
|
89885
90013
|
let circuitJson;
|
|
89886
90014
|
if (isCircuitJsonFile(filePath)) {
|
|
89887
|
-
const rawCircuitJson = await
|
|
90015
|
+
const rawCircuitJson = await fs52.promises.readFile(filePath, "utf-8").catch((err) => {
|
|
89888
90016
|
onError(`Error reading circuit JSON file: ${err}`);
|
|
89889
90017
|
return null;
|
|
89890
90018
|
});
|
|
@@ -90091,12 +90219,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
90091
90219
|
};
|
|
90092
90220
|
|
|
90093
90221
|
// lib/eecircuit-engine/run-simulation.ts
|
|
90094
|
-
import { promises as
|
|
90095
|
-
import
|
|
90222
|
+
import { promises as fs53, existsSync as existsSync13 } from "node:fs";
|
|
90223
|
+
import path57 from "node:path";
|
|
90096
90224
|
import os6 from "node:os";
|
|
90097
90225
|
var sim = null;
|
|
90098
90226
|
var fetchSimulation = async () => {
|
|
90099
|
-
const tempFilePath =
|
|
90227
|
+
const tempFilePath = path57.join(os6.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
90100
90228
|
if (!existsSync13(tempFilePath)) {
|
|
90101
90229
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
90102
90230
|
const response = await fetch(url);
|
|
@@ -90104,7 +90232,7 @@ var fetchSimulation = async () => {
|
|
|
90104
90232
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
90105
90233
|
}
|
|
90106
90234
|
const scriptContent = await response.text();
|
|
90107
|
-
await
|
|
90235
|
+
await fs53.writeFile(tempFilePath, scriptContent);
|
|
90108
90236
|
}
|
|
90109
90237
|
const module2 = await import(tempFilePath);
|
|
90110
90238
|
return module2.Simulation;
|
|
@@ -90193,8 +90321,8 @@ var resultToCsv = (result) => {
|
|
|
90193
90321
|
};
|
|
90194
90322
|
|
|
90195
90323
|
// cli/export/register.ts
|
|
90196
|
-
import
|
|
90197
|
-
import { promises as
|
|
90324
|
+
import path58 from "node:path";
|
|
90325
|
+
import { promises as fs54 } from "node:fs";
|
|
90198
90326
|
var registerExport = (program2) => {
|
|
90199
90327
|
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) => {
|
|
90200
90328
|
const formatOption = options.format ?? "json";
|
|
@@ -90206,12 +90334,12 @@ var registerExport = (program2) => {
|
|
|
90206
90334
|
});
|
|
90207
90335
|
if (circuitJson) {
|
|
90208
90336
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
90209
|
-
const outputSpicePath = options.output ??
|
|
90210
|
-
await
|
|
90337
|
+
const outputSpicePath = options.output ?? path58.join(path58.dirname(file), `${path58.basename(file, path58.extname(file))}.spice.cir`);
|
|
90338
|
+
await fs54.writeFile(outputSpicePath, spiceString);
|
|
90211
90339
|
const { result } = await runSimulation(spiceString);
|
|
90212
90340
|
const csvContent = resultToCsv(result);
|
|
90213
90341
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
90214
|
-
await
|
|
90342
|
+
await fs54.writeFile(outputCsvPath, csvContent);
|
|
90215
90343
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
90216
90344
|
}
|
|
90217
90345
|
process.exit(0);
|
|
@@ -91682,8 +91810,8 @@ function getErrorMap() {
|
|
|
91682
91810
|
return overrideErrorMap;
|
|
91683
91811
|
}
|
|
91684
91812
|
var makeIssue = (params2) => {
|
|
91685
|
-
const { data, path:
|
|
91686
|
-
const fullPath = [...
|
|
91813
|
+
const { data, path: path59, errorMaps, issueData } = params2;
|
|
91814
|
+
const fullPath = [...path59, ...issueData.path || []];
|
|
91687
91815
|
const fullIssue = {
|
|
91688
91816
|
...issueData,
|
|
91689
91817
|
path: fullPath
|
|
@@ -91791,11 +91919,11 @@ var errorUtil;
|
|
|
91791
91919
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
91792
91920
|
})(errorUtil || (errorUtil = {}));
|
|
91793
91921
|
var ParseInputLazyPath = class {
|
|
91794
|
-
constructor(parent, value,
|
|
91922
|
+
constructor(parent, value, path59, key) {
|
|
91795
91923
|
this._cachedPath = [];
|
|
91796
91924
|
this.parent = parent;
|
|
91797
91925
|
this.data = value;
|
|
91798
|
-
this._path =
|
|
91926
|
+
this._path = path59;
|
|
91799
91927
|
this._key = key;
|
|
91800
91928
|
}
|
|
91801
91929
|
get path() {
|
|
@@ -99982,7 +100110,7 @@ var ss = ys;
|
|
|
99982
100110
|
var ms2 = { paths: { diag1: { type: "path", points: [{ x: -0.1, y: -0.1 }, { x: 0.1, y: 0.1 }], color: "primary", fill: false }, diag2: { type: "path", points: [{ x: -0.1, y: 0.1 }, { x: 0.1, y: -0.1 }], color: "primary", fill: false }, stem: { type: "path", points: [{ x: -0.2, y: 0 }, { x: 0, y: 0 }], color: "primary", fill: false } }, texts: {}, refblocks: { left1: { x: -0.2, y: 0 } }, bounds: { minX: -0.19, maxX: 0.2, minY: -0.12, maxY: 0.12, width: 0.39, height: 0.24, centerX: 0, centerY: 0 }, circles: {} };
|
|
99983
100111
|
var { paths: Yd, bounds: ns, refblocks: Xd } = ms2;
|
|
99984
100112
|
var U = e({ primitives: [...Object.values(Yd)], ports: [{ ...Xd.left1, labels: ["1"] }], center: { x: ns.centerX, y: ns.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
|
|
99985
|
-
var
|
|
100113
|
+
var fs55 = r(U, "down");
|
|
99986
100114
|
var hs = r(U, "left");
|
|
99987
100115
|
var cs = r(U, "up");
|
|
99988
100116
|
var g = { paths: { path11: { type: "path", points: [{ x: -0.4, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.55 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.55 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
@@ -100585,7 +100713,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
100585
100713
|
Vb.anchor = "middle_left";
|
|
100586
100714
|
jb.anchor = "middle_right";
|
|
100587
100715
|
var tf = Il;
|
|
100588
|
-
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down:
|
|
100716
|
+
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down: fs55, not_connected_left: hs, not_connected_right: U, not_connected_up: cs, npn_bipolar_transistor_down: ds, npn_bipolar_transistor_horz: bs, npn_bipolar_transistor_left: _s, npn_bipolar_transistor_right: gs, npn_bipolar_transistor_up: us, npn_bipolar_transistor_vert: vs, opamp_no_power_down: As, opamp_no_power_left: Ps, opamp_no_power_right: W, opamp_no_power_up: Ss, opamp_with_power_down: Rs, opamp_with_power_left: Ts, opamp_with_power_right: H, opamp_with_power_up: Es, p_channel_d_mosfet_transistor_horz: x0, p_channel_d_mosfet_transistor_vert: js, p_channel_e_mosfet_transistor_horz: m0, p_channel_e_mosfet_transistor_vert: $s, photodiode_horz: n0, photodiode_vert: Is, pjfet_transistor_horz: h0, pjfet_transistor_vert: Us, pnp_bipolar_transistor_down: Ws, pnp_bipolar_transistor_horz: Hs, pnp_bipolar_transistor_left: Zs, pnp_bipolar_transistor_right: Qs, pnp_bipolar_transistor_up: Ks, pnp_bipolar_transistor_vert: tm, potentiometer_horz: v0, potentiometer_vert: im, potentiometer2_down: ym, potentiometer2_left: xm, potentiometer2_right: Z, potentiometer2_up: sm, potentiometer3_down: mm2, potentiometer3_left: nm, potentiometer3_right: fm, potentiometer3_up: hm, power_factor_meter_horz: R0, power_factor_meter_vert: _m, push_button_normally_closed_momentary_horz: E0, push_button_normally_closed_momentary_vert: wm, push_button_normally_open_momentary_horz: X0, push_button_normally_open_momentary_vert: Fm, rail_down: Tm, rail_left: Ym, rail_right: Lm, rail_up: jm, rectifier_diode_horz: j0, rectifier_diode_vert: Om, resistor_down: $m, resistor_left: Cm, resistor_right: Im, resistor_up: qm, resonator_down: Gm, resonator_horz: N0, resonator_left: Um, resonator_right: et, resonator_up: Wm, resonator_vert: Hm, schottky_diode_down: Qm, schottky_diode_left: Km, schottky_diode_right: rt, schottky_diode_up: tn, silicon_controlled_rectifier_horz: I0, silicon_controlled_rectifier_vert: on2, solderjumper2_bridged12_down: ln, solderjumper2_bridged12_left: pn, solderjumper2_bridged12_right: an, solderjumper2_bridged12_up: yn, solderjumper2_down: xn, solderjumper2_left: sn, solderjumper2_right: mn, solderjumper2_up: nn, solderjumper3_bridged12_down: fn, solderjumper3_bridged12_left: hn, solderjumper3_bridged12_right: cn, solderjumper3_bridged12_up: dn, solderjumper3_bridged123_down: bn, solderjumper3_bridged123_left: _n, solderjumper3_bridged123_right: gn, solderjumper3_bridged123_up: un, solderjumper3_bridged23_down: vn, solderjumper3_bridged23_left: wn, solderjumper3_bridged23_right: An, solderjumper3_bridged23_up: Pn, solderjumper3_down: Sn, solderjumper3_left: Fn, solderjumper3_right: Rn, solderjumper3_up: Tn, spdt_normally_closed_switch_down: Yn, spdt_normally_closed_switch_left: Xn, spdt_normally_closed_switch_right: xt, spdt_normally_closed_switch_up: Ln, spdt_switch_down: jn, spdt_switch_left: kn, spdt_switch_right: st, spdt_switch_up: zn, spst_normally_closed_switch_down: On, spst_normally_closed_switch_left: Jn, spst_normally_closed_switch_right: mt, spst_normally_closed_switch_up: $n, spst_switch_down: Mn, spst_switch_left: Cn, spst_switch_right: nt, spst_switch_up: Nn, square_wave_down: In, square_wave_left: Bn, square_wave_right: qn, square_wave_up: Dn, step_recovery_diode_horz: B0, step_recovery_diode_vert: Gn, tachometer_horz: Yt, tachometer_vert: Zn, testpoint_down: t1, testpoint_left: e1, testpoint_right: ht, testpoint_up: i1, tilted_ground_down: p1, tilted_ground_left: a1, tilted_ground_right: wt, tilted_ground_up: D0, triac_horz: G0, triac_vert: s1, tunnel_diode_horz: W0, tunnel_diode_vert: h1, unijunction_transistor_horz: Z0, unijunction_transistor_vert: u1, usbc: w1, var_meter_horz: K0, var_meter_vert: S1, varactor_diode_horz: er, varactor_diode_vert: E1, varistor_horz: or, varistor_vert: V1, varmeter_horz: Xt, varmeter_vert: O1, vcc_down: J1, vcc_left: $1, vcc_right: M1, vcc_up: C1, volt_meter_horz: lr, volt_meter_vert: N1, watt_hour_meter_horz: Lt, watt_hour_meter_vert: D1, wattmeter_horz: Vt, wattmeter_vert: H1, zener_diode_horz: xr, zener_diode_vert: tf };
|
|
100589
100717
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
100590
100718
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
100591
100719
|
lineThickness = 0
|
|
@@ -102893,11 +103021,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102893
103021
|
fiber = fiber.next, id--;
|
|
102894
103022
|
return fiber;
|
|
102895
103023
|
}
|
|
102896
|
-
function copyWithSetImpl(obj,
|
|
102897
|
-
if (index >=
|
|
103024
|
+
function copyWithSetImpl(obj, path59, index, value) {
|
|
103025
|
+
if (index >= path59.length)
|
|
102898
103026
|
return value;
|
|
102899
|
-
var key =
|
|
102900
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
103027
|
+
var key = path59[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
103028
|
+
updated[key] = copyWithSetImpl(obj[key], path59, index + 1, value);
|
|
102901
103029
|
return updated;
|
|
102902
103030
|
}
|
|
102903
103031
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -102917,11 +103045,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102917
103045
|
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);
|
|
102918
103046
|
return updated;
|
|
102919
103047
|
}
|
|
102920
|
-
function copyWithDeleteImpl(obj,
|
|
102921
|
-
var key =
|
|
102922
|
-
if (index + 1 ===
|
|
103048
|
+
function copyWithDeleteImpl(obj, path59, index) {
|
|
103049
|
+
var key = path59[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
103050
|
+
if (index + 1 === path59.length)
|
|
102923
103051
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
102924
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
103052
|
+
updated[key] = copyWithDeleteImpl(obj[key], path59, index + 1);
|
|
102925
103053
|
return updated;
|
|
102926
103054
|
}
|
|
102927
103055
|
function shouldSuspendImpl() {
|
|
@@ -111947,29 +112075,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
111947
112075
|
var didWarnAboutNestedUpdates = false;
|
|
111948
112076
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
111949
112077
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
111950
|
-
overrideHookState = function(fiber, id,
|
|
112078
|
+
overrideHookState = function(fiber, id, path59, value) {
|
|
111951
112079
|
id = findHook(fiber, id);
|
|
111952
|
-
id !== null && (
|
|
112080
|
+
id !== null && (path59 = copyWithSetImpl(id.memoizedState, path59, 0, value), id.memoizedState = path59, id.baseState = path59, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path59 = enqueueConcurrentRenderForLane(fiber, 2), path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2));
|
|
111953
112081
|
};
|
|
111954
|
-
overrideHookStateDeletePath = function(fiber, id,
|
|
112082
|
+
overrideHookStateDeletePath = function(fiber, id, path59) {
|
|
111955
112083
|
id = findHook(fiber, id);
|
|
111956
|
-
id !== null && (
|
|
112084
|
+
id !== null && (path59 = copyWithDeleteImpl(id.memoizedState, path59, 0), id.memoizedState = path59, id.baseState = path59, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path59 = enqueueConcurrentRenderForLane(fiber, 2), path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2));
|
|
111957
112085
|
};
|
|
111958
112086
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
111959
112087
|
id = findHook(fiber, id);
|
|
111960
112088
|
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));
|
|
111961
112089
|
};
|
|
111962
|
-
overrideProps = function(fiber,
|
|
111963
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
112090
|
+
overrideProps = function(fiber, path59, value) {
|
|
112091
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path59, 0, value);
|
|
111964
112092
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
111965
|
-
|
|
111966
|
-
|
|
112093
|
+
path59 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
112094
|
+
path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2);
|
|
111967
112095
|
};
|
|
111968
|
-
overridePropsDeletePath = function(fiber,
|
|
111969
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
112096
|
+
overridePropsDeletePath = function(fiber, path59) {
|
|
112097
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path59, 0);
|
|
111970
112098
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
111971
|
-
|
|
111972
|
-
|
|
112099
|
+
path59 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
112100
|
+
path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2);
|
|
111973
112101
|
};
|
|
111974
112102
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
111975
112103
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -118272,7 +118400,7 @@ var parsePin = (pinString) => {
|
|
|
118272
118400
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
118273
118401
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
118274
118402
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
118275
|
-
const
|
|
118403
|
+
const path59 = pathMatch ? pathMatch[1] : "";
|
|
118276
118404
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
118277
118405
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
118278
118406
|
const r2 = Number.parseFloat(rotation4);
|
|
@@ -118286,7 +118414,7 @@ var parsePin = (pinString) => {
|
|
|
118286
118414
|
rotation: Number.isNaN(r2) ? 0 : r2,
|
|
118287
118415
|
label,
|
|
118288
118416
|
labelColor,
|
|
118289
|
-
path:
|
|
118417
|
+
path: path59,
|
|
118290
118418
|
arrow
|
|
118291
118419
|
};
|
|
118292
118420
|
};
|
|
@@ -118726,15 +118854,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
118726
118854
|
}
|
|
118727
118855
|
}
|
|
118728
118856
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
118729
|
-
const
|
|
118857
|
+
const path59 = [];
|
|
118730
118858
|
for (let i22 = 0;i22 <= numPoints; i22++) {
|
|
118731
118859
|
const t3 = i22 / numPoints;
|
|
118732
118860
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
118733
118861
|
const x22 = centerX + radius * Math.cos(angle2);
|
|
118734
118862
|
const y22 = centerY + radius * Math.sin(angle2);
|
|
118735
|
-
|
|
118863
|
+
path59.push({ x: x22, y: y22 });
|
|
118736
118864
|
}
|
|
118737
|
-
return
|
|
118865
|
+
return path59;
|
|
118738
118866
|
}
|
|
118739
118867
|
var __defProp4 = Object.defineProperty;
|
|
118740
118868
|
var __export22 = (target, all) => {
|
|
@@ -127813,17 +127941,17 @@ var ObstacleList = class {
|
|
|
127813
127941
|
return obstacles;
|
|
127814
127942
|
}
|
|
127815
127943
|
};
|
|
127816
|
-
function removePathLoops(
|
|
127817
|
-
if (
|
|
127818
|
-
return
|
|
127819
|
-
const result = [{ ...
|
|
127820
|
-
let currentLayer =
|
|
127821
|
-
for (let i22 = 1;i22 <
|
|
127822
|
-
const currentSegment = { start:
|
|
127823
|
-
const isVia =
|
|
127824
|
-
if (
|
|
127825
|
-
result.push({ ...
|
|
127826
|
-
currentLayer =
|
|
127944
|
+
function removePathLoops(path59) {
|
|
127945
|
+
if (path59.length < 4)
|
|
127946
|
+
return path59;
|
|
127947
|
+
const result = [{ ...path59[0] }];
|
|
127948
|
+
let currentLayer = path59[0].layer;
|
|
127949
|
+
for (let i22 = 1;i22 < path59.length; i22++) {
|
|
127950
|
+
const currentSegment = { start: path59[i22 - 1], end: path59[i22] };
|
|
127951
|
+
const isVia = path59[i22].route_type === "via" || path59[i22 - 1].route_type === "via";
|
|
127952
|
+
if (path59[i22].layer !== currentLayer || isVia) {
|
|
127953
|
+
result.push({ ...path59[i22] });
|
|
127954
|
+
currentLayer = path59[i22].layer;
|
|
127827
127955
|
continue;
|
|
127828
127956
|
}
|
|
127829
127957
|
let intersectionFound = false;
|
|
@@ -127852,8 +127980,8 @@ function removePathLoops(path58) {
|
|
|
127852
127980
|
result.push(intersectionPoint);
|
|
127853
127981
|
}
|
|
127854
127982
|
const lastPoint = result[result.length - 1];
|
|
127855
|
-
if (lastPoint.x !==
|
|
127856
|
-
result.push(
|
|
127983
|
+
if (lastPoint.x !== path59[i22].x || lastPoint.y !== path59[i22].y) {
|
|
127984
|
+
result.push(path59[i22]);
|
|
127857
127985
|
}
|
|
127858
127986
|
}
|
|
127859
127987
|
return result;
|
|
@@ -128342,10 +128470,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
128342
128470
|
});
|
|
128343
128471
|
}
|
|
128344
128472
|
if (current2.parent) {
|
|
128345
|
-
const
|
|
128473
|
+
const path59 = [];
|
|
128346
128474
|
let p22 = current2;
|
|
128347
128475
|
while (p22) {
|
|
128348
|
-
|
|
128476
|
+
path59.unshift(p22);
|
|
128349
128477
|
p22 = p22.parent;
|
|
128350
128478
|
}
|
|
128351
128479
|
debugSolution.push({
|
|
@@ -128353,7 +128481,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
128353
128481
|
pcb_component_id: "",
|
|
128354
128482
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
128355
128483
|
layer: "top",
|
|
128356
|
-
route:
|
|
128484
|
+
route: path59,
|
|
128357
128485
|
stroke_width: 0.01
|
|
128358
128486
|
});
|
|
128359
128487
|
}
|
|
@@ -136704,7 +136832,7 @@ var ps2 = class extends e3 {
|
|
|
136704
136832
|
return t3;
|
|
136705
136833
|
}
|
|
136706
136834
|
};
|
|
136707
|
-
var
|
|
136835
|
+
var fs56 = (t3) => {
|
|
136708
136836
|
const e22 = [], s22 = [], n22 = [], i22 = ht2(t3);
|
|
136709
136837
|
if (t3.connections)
|
|
136710
136838
|
for (const e32 of t3.connections)
|
|
@@ -139327,7 +139455,7 @@ var Tn2 = class extends e3 {
|
|
|
139327
139455
|
const t3 = M22.map((t42) => ({ x: t42.x, y: t42.y }));
|
|
139328
139456
|
t3.push({ ...t3[0] }), v22.push({ points: t3, strokeColor: "rgba(0, 136, 255, 0.95)" });
|
|
139329
139457
|
}
|
|
139330
|
-
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22,
|
|
139458
|
+
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22, fs56(this.getOutputSimpleRouteJson())) : null].filter(Boolean);
|
|
139331
139459
|
return t(...b22);
|
|
139332
139460
|
}
|
|
139333
139461
|
preview() {
|
|
@@ -152798,10 +152926,10 @@ var findFirstCollision = (pts, rects, opts = {}) => {
|
|
|
152798
152926
|
}
|
|
152799
152927
|
return null;
|
|
152800
152928
|
};
|
|
152801
|
-
var isPathCollidingWithObstacles = (
|
|
152802
|
-
for (let i22 = 0;i22 <
|
|
152929
|
+
var isPathCollidingWithObstacles = (path59, obstacles) => {
|
|
152930
|
+
for (let i22 = 0;i22 < path59.length - 1; i22++) {
|
|
152803
152931
|
for (const obstacle of obstacles) {
|
|
152804
|
-
if (segmentIntersectsRect(
|
|
152932
|
+
if (segmentIntersectsRect(path59[i22], path59[i22 + 1], obstacle)) {
|
|
152805
152933
|
return true;
|
|
152806
152934
|
}
|
|
152807
152935
|
}
|
|
@@ -152995,36 +153123,36 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
152995
153123
|
this.error = "No collision-free path found";
|
|
152996
153124
|
return;
|
|
152997
153125
|
}
|
|
152998
|
-
const { path:
|
|
153126
|
+
const { path: path59, collisionChipIds } = state;
|
|
152999
153127
|
const [PA, PB] = this.pins;
|
|
153000
|
-
const collision = findFirstCollision(
|
|
153128
|
+
const collision = findFirstCollision(path59, this.obstacles);
|
|
153001
153129
|
if (!collision) {
|
|
153002
|
-
const first =
|
|
153003
|
-
const last =
|
|
153130
|
+
const first = path59[0];
|
|
153131
|
+
const last = path59[path59.length - 1];
|
|
153004
153132
|
const EPS42 = 0.000000001;
|
|
153005
153133
|
const samePoint = (p22, q22) => Math.abs(p22.x - q22.x) < EPS42 && Math.abs(p22.y - q22.y) < EPS42;
|
|
153006
153134
|
if (samePoint(first, { x: PA.x, y: PA.y }) && samePoint(last, { x: PB.x, y: PB.y })) {
|
|
153007
|
-
this.solvedTracePath =
|
|
153135
|
+
this.solvedTracePath = path59;
|
|
153008
153136
|
this.solved = true;
|
|
153009
153137
|
}
|
|
153010
153138
|
return;
|
|
153011
153139
|
}
|
|
153012
153140
|
let { segIndex, rect } = collision;
|
|
153013
153141
|
const isFirstSegment = segIndex === 0;
|
|
153014
|
-
const isLastSegment = segIndex ===
|
|
153142
|
+
const isLastSegment = segIndex === path59.length - 2;
|
|
153015
153143
|
if (isFirstSegment) {
|
|
153016
|
-
if (
|
|
153144
|
+
if (path59.length < 3) {
|
|
153017
153145
|
return;
|
|
153018
153146
|
}
|
|
153019
153147
|
segIndex = 1;
|
|
153020
153148
|
} else if (isLastSegment) {
|
|
153021
|
-
if (
|
|
153149
|
+
if (path59.length < 3) {
|
|
153022
153150
|
return;
|
|
153023
153151
|
}
|
|
153024
|
-
segIndex =
|
|
153152
|
+
segIndex = path59.length - 3;
|
|
153025
153153
|
}
|
|
153026
|
-
const a22 =
|
|
153027
|
-
const b22 =
|
|
153154
|
+
const a22 = path59[segIndex];
|
|
153155
|
+
const b22 = path59[segIndex + 1];
|
|
153028
153156
|
const axis = this.axisOfSegment(a22, b22);
|
|
153029
153157
|
if (!axis) {
|
|
153030
153158
|
return;
|
|
@@ -153042,7 +153170,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
153042
153170
|
}
|
|
153043
153171
|
const newStates = [];
|
|
153044
153172
|
for (const coord of candidates) {
|
|
153045
|
-
const newPath = shiftSegmentOrth(
|
|
153173
|
+
const newPath = shiftSegmentOrth(path59, segIndex, axis, coord);
|
|
153046
153174
|
if (!newPath)
|
|
153047
153175
|
continue;
|
|
153048
153176
|
const key = pathKey(newPath);
|
|
@@ -153078,8 +153206,8 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
153078
153206
|
strokeColor: "blue",
|
|
153079
153207
|
strokeDash: "5 5"
|
|
153080
153208
|
});
|
|
153081
|
-
for (const { path:
|
|
153082
|
-
g22.lines.push({ points:
|
|
153209
|
+
for (const { path: path59, collisionChipIds: collisionRectIds } of this.queue) {
|
|
153210
|
+
g22.lines.push({ points: path59, strokeColor: "teal", strokeDash: "2 2" });
|
|
153083
153211
|
}
|
|
153084
153212
|
if (this.solvedTracePath) {
|
|
153085
153213
|
g22.lines.push({ points: this.solvedTracePath, strokeColor: "green" });
|
|
@@ -153316,9 +153444,9 @@ var TraceOverlapIssueSolver = class extends BaseSolver3 {
|
|
|
153316
153444
|
solvedTracePathIndex,
|
|
153317
153445
|
traceSegmentIndex
|
|
153318
153446
|
} of group.pathsWithOverlap) {
|
|
153319
|
-
const
|
|
153320
|
-
const segStart =
|
|
153321
|
-
const segEnd =
|
|
153447
|
+
const path59 = this.traceNetIslands[group.connNetId][solvedTracePathIndex];
|
|
153448
|
+
const segStart = path59.tracePath[traceSegmentIndex];
|
|
153449
|
+
const segEnd = path59.tracePath[traceSegmentIndex + 1];
|
|
153322
153450
|
graphics.lines.push({
|
|
153323
153451
|
points: [segStart, segEnd],
|
|
153324
153452
|
strokeColor: "red"
|
|
@@ -153362,11 +153490,11 @@ var TraceOverlapShiftSolver = class extends BaseSolver3 {
|
|
|
153362
153490
|
computeTraceNetIslands() {
|
|
153363
153491
|
const islands = {};
|
|
153364
153492
|
for (const original of this.inputTracePaths) {
|
|
153365
|
-
const
|
|
153366
|
-
const key =
|
|
153493
|
+
const path59 = this.correctedTraceMap[original.mspPairId] ?? original;
|
|
153494
|
+
const key = path59.globalConnNetId;
|
|
153367
153495
|
if (!islands[key])
|
|
153368
153496
|
islands[key] = [];
|
|
153369
|
-
islands[key].push(
|
|
153497
|
+
islands[key].push(path59);
|
|
153370
153498
|
}
|
|
153371
153499
|
return islands;
|
|
153372
153500
|
}
|
|
@@ -153614,9 +153742,9 @@ function rectIntersectsAnyTrace(bounds, inputTraceMap, hostPathId, hostSegIndex)
|
|
|
153614
153742
|
}
|
|
153615
153743
|
return { hasIntersection: false };
|
|
153616
153744
|
}
|
|
153617
|
-
function lengthOfTrace(
|
|
153745
|
+
function lengthOfTrace(path59) {
|
|
153618
153746
|
let sum = 0;
|
|
153619
|
-
const pts =
|
|
153747
|
+
const pts = path59.tracePath;
|
|
153620
153748
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
153621
153749
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
153622
153750
|
}
|
|
@@ -154145,9 +154273,9 @@ var NetLabelPlacementSolver = class extends BaseSolver3 {
|
|
|
154145
154273
|
}
|
|
154146
154274
|
const compTraces = (byGlobal[globalConnNetId] ?? []).filter((t3) => component.has(t3.pins[0].pinId) && component.has(t3.pins[1].pinId));
|
|
154147
154275
|
if (compTraces.length > 0) {
|
|
154148
|
-
const lengthOf = (
|
|
154276
|
+
const lengthOf = (path59) => {
|
|
154149
154277
|
let sum = 0;
|
|
154150
|
-
const pts =
|
|
154278
|
+
const pts = path59.tracePath;
|
|
154151
154279
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
154152
154280
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
154153
154281
|
}
|
|
@@ -154292,12 +154420,12 @@ var detectTraceLabelOverlap = (traces, netLabels) => {
|
|
|
154292
154420
|
}
|
|
154293
154421
|
return overlaps;
|
|
154294
154422
|
};
|
|
154295
|
-
var findTraceViolationZone = (
|
|
154423
|
+
var findTraceViolationZone = (path59, labelBounds) => {
|
|
154296
154424
|
const isPointInside = (p22) => p22.x > labelBounds.minX && p22.x < labelBounds.maxX && p22.y > labelBounds.minY && p22.y < labelBounds.maxY;
|
|
154297
154425
|
let firstInsideIndex = -1;
|
|
154298
154426
|
let lastInsideIndex = -1;
|
|
154299
|
-
for (let i22 = 0;i22 <
|
|
154300
|
-
if (isPointInside(
|
|
154427
|
+
for (let i22 = 0;i22 < path59.length; i22++) {
|
|
154428
|
+
if (isPointInside(path59[i22])) {
|
|
154301
154429
|
if (firstInsideIndex === -1) {
|
|
154302
154430
|
firstInsideIndex = i22;
|
|
154303
154431
|
}
|
|
@@ -154306,20 +154434,20 @@ var findTraceViolationZone = (path58, labelBounds) => {
|
|
|
154306
154434
|
}
|
|
154307
154435
|
return { firstInsideIndex, lastInsideIndex };
|
|
154308
154436
|
};
|
|
154309
|
-
var simplifyPath = (
|
|
154310
|
-
if (
|
|
154311
|
-
return
|
|
154312
|
-
const newPath = [
|
|
154313
|
-
for (let i22 = 1;i22 <
|
|
154437
|
+
var simplifyPath = (path59) => {
|
|
154438
|
+
if (path59.length < 3)
|
|
154439
|
+
return path59;
|
|
154440
|
+
const newPath = [path59[0]];
|
|
154441
|
+
for (let i22 = 1;i22 < path59.length - 1; i22++) {
|
|
154314
154442
|
const p12 = newPath[newPath.length - 1];
|
|
154315
|
-
const p22 =
|
|
154316
|
-
const p32 =
|
|
154443
|
+
const p22 = path59[i22];
|
|
154444
|
+
const p32 = path59[i22 + 1];
|
|
154317
154445
|
if (isVertical(p12, p22) && isVertical(p22, p32) || isHorizontal(p12, p22) && isHorizontal(p22, p32)) {
|
|
154318
154446
|
continue;
|
|
154319
154447
|
}
|
|
154320
154448
|
newPath.push(p22);
|
|
154321
154449
|
}
|
|
154322
|
-
newPath.push(
|
|
154450
|
+
newPath.push(path59[path59.length - 1]);
|
|
154323
154451
|
if (newPath.length < 3)
|
|
154324
154452
|
return newPath;
|
|
154325
154453
|
const finalPath = [newPath[0]];
|
|
@@ -154579,12 +154707,12 @@ var hasCollisionsWithLabels = (pathSegments, labels) => {
|
|
|
154579
154707
|
return false;
|
|
154580
154708
|
};
|
|
154581
154709
|
var minimizeTurns = ({
|
|
154582
|
-
path:
|
|
154710
|
+
path: path59,
|
|
154583
154711
|
obstacles,
|
|
154584
154712
|
labelBounds
|
|
154585
154713
|
}) => {
|
|
154586
|
-
if (
|
|
154587
|
-
return
|
|
154714
|
+
if (path59.length <= 2) {
|
|
154715
|
+
return path59;
|
|
154588
154716
|
}
|
|
154589
154717
|
const recognizeStairStepPattern = (pathToCheck, startIdx) => {
|
|
154590
154718
|
if (startIdx >= pathToCheck.length - 3)
|
|
@@ -154616,7 +154744,7 @@ var minimizeTurns = ({
|
|
|
154616
154744
|
}
|
|
154617
154745
|
return isStairStep && endIdx - startIdx >= 3 ? endIdx : -1;
|
|
154618
154746
|
};
|
|
154619
|
-
let optimizedPath = [...
|
|
154747
|
+
let optimizedPath = [...path59];
|
|
154620
154748
|
let currentTurns = countTurns(optimizedPath);
|
|
154621
154749
|
let improved = true;
|
|
154622
154750
|
while (improved) {
|
|
@@ -162221,9 +162349,9 @@ var getFileExtension = (filename) => {
|
|
|
162221
162349
|
const extension = lastSegment.split(".").pop();
|
|
162222
162350
|
return extension?.toLowerCase() ?? null;
|
|
162223
162351
|
};
|
|
162224
|
-
var joinUrlPath = (base,
|
|
162352
|
+
var joinUrlPath = (base, path59) => {
|
|
162225
162353
|
const trimmedBase = base.replace(/\/+$/, "");
|
|
162226
|
-
const trimmedPath =
|
|
162354
|
+
const trimmedPath = path59.replace(/^\/+/, "");
|
|
162227
162355
|
return `${trimmedBase}/${trimmedPath}`;
|
|
162228
162356
|
};
|
|
162229
162357
|
var constructAssetUrl = (targetUrl, baseUrl) => {
|
|
@@ -163537,7 +163665,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163537
163665
|
for (let i22 = 0;i22 < portsWithPosition.length - 1; i22++) {
|
|
163538
163666
|
const start = portsWithPosition[i22];
|
|
163539
163667
|
const end = portsWithPosition[i22 + 1];
|
|
163540
|
-
const
|
|
163668
|
+
const path59 = calculateElbow({
|
|
163541
163669
|
x: start.position.x,
|
|
163542
163670
|
y: start.position.y,
|
|
163543
163671
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -163546,8 +163674,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163546
163674
|
y: end.position.y,
|
|
163547
163675
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
163548
163676
|
});
|
|
163549
|
-
for (let j22 = 0;j22 <
|
|
163550
|
-
elbowEdges.push({ from:
|
|
163677
|
+
for (let j22 = 0;j22 < path59.length - 1; j22++) {
|
|
163678
|
+
elbowEdges.push({ from: path59[j22], to: path59[j22 + 1] });
|
|
163551
163679
|
}
|
|
163552
163680
|
}
|
|
163553
163681
|
const doesSegmentIntersectRect2 = (edge, rect) => {
|
|
@@ -164740,20 +164868,20 @@ var parseLibraryFootprintRef = (s22) => {
|
|
|
164740
164868
|
};
|
|
164741
164869
|
var isStaticAssetPath = (s22) => s22.startsWith("/");
|
|
164742
164870
|
var resolveStaticFileImportDebug = (0, import_debug92.default)("tscircuit:core:resolveStaticFileImport");
|
|
164743
|
-
async function resolveStaticFileImport(
|
|
164744
|
-
if (!
|
|
164745
|
-
return
|
|
164871
|
+
async function resolveStaticFileImport(path59, platform) {
|
|
164872
|
+
if (!path59)
|
|
164873
|
+
return path59;
|
|
164746
164874
|
const resolver = platform?.resolveProjectStaticFileImportUrl;
|
|
164747
|
-
if (resolver &&
|
|
164875
|
+
if (resolver && path59.startsWith("/")) {
|
|
164748
164876
|
try {
|
|
164749
|
-
const resolved = await resolver(
|
|
164877
|
+
const resolved = await resolver(path59);
|
|
164750
164878
|
if (resolved)
|
|
164751
164879
|
return resolved;
|
|
164752
164880
|
} catch (error) {
|
|
164753
164881
|
resolveStaticFileImportDebug("failed to resolve static file via platform resolver", error);
|
|
164754
164882
|
}
|
|
164755
164883
|
}
|
|
164756
|
-
return constructAssetUrl(
|
|
164884
|
+
return constructAssetUrl(path59, platform?.projectBaseUrl);
|
|
164757
164885
|
}
|
|
164758
164886
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
164759
164887
|
let { footprint } = component.props;
|
|
@@ -169841,7 +169969,7 @@ var Group6 = class extends NormalComponent3 {
|
|
|
169841
169969
|
});
|
|
169842
169970
|
}
|
|
169843
169971
|
if (debug112.enabled) {
|
|
169844
|
-
const graphicsObject =
|
|
169972
|
+
const graphicsObject = fs56(simpleRouteJson);
|
|
169845
169973
|
graphicsObject.title = `autorouting-${this.props.name}`;
|
|
169846
169974
|
global.debugGraphics?.push(graphicsObject);
|
|
169847
169975
|
}
|
|
@@ -172400,7 +172528,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
172400
172528
|
}
|
|
172401
172529
|
const portPos = port._getGlobalSchematicPositionAfterLayout();
|
|
172402
172530
|
const portFacing = convertFacingDirectionToElbowDirection(port.facingDirection ?? "right") ?? "x+";
|
|
172403
|
-
const
|
|
172531
|
+
const path59 = calculateElbow({
|
|
172404
172532
|
x: portPos.x,
|
|
172405
172533
|
y: portPos.y,
|
|
172406
172534
|
facingDirection: portFacing
|
|
@@ -172409,13 +172537,13 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
172409
172537
|
y: anchorPos.y,
|
|
172410
172538
|
facingDirection: anchorFacing
|
|
172411
172539
|
});
|
|
172412
|
-
if (!Array.isArray(
|
|
172540
|
+
if (!Array.isArray(path59) || path59.length < 2)
|
|
172413
172541
|
continue;
|
|
172414
172542
|
const edges = [];
|
|
172415
|
-
for (let i22 = 0;i22 <
|
|
172543
|
+
for (let i22 = 0;i22 < path59.length - 1; i22++) {
|
|
172416
172544
|
edges.push({
|
|
172417
|
-
from: { x:
|
|
172418
|
-
to: { x:
|
|
172545
|
+
from: { x: path59[i22].x, y: path59[i22].y },
|
|
172546
|
+
to: { x: path59[i22 + 1].x, y: path59[i22 + 1].y }
|
|
172419
172547
|
});
|
|
172420
172548
|
}
|
|
172421
172549
|
let source_trace_id;
|
|
@@ -174727,8 +174855,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
174727
174855
|
*/
|
|
174728
174856
|
|
|
174729
174857
|
// lib/import/import-component-from-jlcpcb.ts
|
|
174730
|
-
import
|
|
174731
|
-
import
|
|
174858
|
+
import fs57 from "node:fs/promises";
|
|
174859
|
+
import path59 from "node:path";
|
|
174732
174860
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
174733
174861
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
174734
174862
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -174736,10 +174864,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
174736
174864
|
if (!fileName) {
|
|
174737
174865
|
throw new Error("Could not determine file name of converted component");
|
|
174738
174866
|
}
|
|
174739
|
-
const importsDir =
|
|
174740
|
-
await
|
|
174741
|
-
const filePath =
|
|
174742
|
-
await
|
|
174867
|
+
const importsDir = path59.join(projectDir, "imports");
|
|
174868
|
+
await fs57.mkdir(importsDir, { recursive: true });
|
|
174869
|
+
const filePath = path59.join(importsDir, `${fileName}.tsx`);
|
|
174870
|
+
await fs57.writeFile(filePath, tsx);
|
|
174743
174871
|
return { filePath };
|
|
174744
174872
|
};
|
|
174745
174873
|
|
|
@@ -176084,13 +176212,13 @@ var registerImport = (program2) => {
|
|
|
176084
176212
|
};
|
|
176085
176213
|
|
|
176086
176214
|
// cli/init/register.ts
|
|
176087
|
-
import * as
|
|
176088
|
-
import * as
|
|
176215
|
+
import * as fs59 from "node:fs";
|
|
176216
|
+
import * as path62 from "node:path";
|
|
176089
176217
|
|
|
176090
176218
|
// lib/shared/generate-gitignore-file.ts
|
|
176091
|
-
import
|
|
176219
|
+
import path60 from "node:path";
|
|
176092
176220
|
var generateGitIgnoreFile = (dir) => {
|
|
176093
|
-
const gitignorePath =
|
|
176221
|
+
const gitignorePath = path60.join(dir, ".gitignore");
|
|
176094
176222
|
const gitignoreContent = `# Dependencies
|
|
176095
176223
|
node_modules/
|
|
176096
176224
|
|
|
@@ -176125,8 +176253,8 @@ yarn-error.log*
|
|
|
176125
176253
|
};
|
|
176126
176254
|
|
|
176127
176255
|
// lib/shared/setup-tscircuit-skill.ts
|
|
176128
|
-
import * as
|
|
176129
|
-
import * as
|
|
176256
|
+
import * as fs58 from "node:fs";
|
|
176257
|
+
import * as path61 from "node:path";
|
|
176130
176258
|
var SKILL_REPO_API_URL = "https://api.github.com/repos/tscircuit/skill/contents";
|
|
176131
176259
|
var SKILL_INSTALL_PATHS = [
|
|
176132
176260
|
".claude/skills/tscircuit",
|
|
@@ -176149,35 +176277,35 @@ async function fetchFileContent(downloadUrl) {
|
|
|
176149
176277
|
async function downloadDirectory(apiUrl, targetDir) {
|
|
176150
176278
|
const contents = await fetchGitHubContents(apiUrl);
|
|
176151
176279
|
for (const item of contents) {
|
|
176152
|
-
const targetPath =
|
|
176280
|
+
const targetPath = path61.join(targetDir, item.name);
|
|
176153
176281
|
if (item.type === "dir") {
|
|
176154
|
-
|
|
176282
|
+
fs58.mkdirSync(targetPath, { recursive: true });
|
|
176155
176283
|
await downloadDirectory(`${apiUrl}/${item.name}`, targetPath);
|
|
176156
176284
|
} else if (item.type === "file" && item.download_url) {
|
|
176157
176285
|
const content = await fetchFileContent(item.download_url);
|
|
176158
|
-
|
|
176286
|
+
fs58.writeFileSync(targetPath, content, "utf-8");
|
|
176159
176287
|
}
|
|
176160
176288
|
}
|
|
176161
176289
|
}
|
|
176162
176290
|
async function downloadSkillRepo(targetDir) {
|
|
176163
|
-
|
|
176291
|
+
fs58.mkdirSync(targetDir, { recursive: true });
|
|
176164
176292
|
const rootContents = await fetchGitHubContents(SKILL_REPO_API_URL);
|
|
176165
176293
|
for (const item of rootContents) {
|
|
176166
176294
|
if (item.name === ".git" || item.name === ".github") {
|
|
176167
176295
|
continue;
|
|
176168
176296
|
}
|
|
176169
|
-
const targetPath =
|
|
176297
|
+
const targetPath = path61.join(targetDir, item.name);
|
|
176170
176298
|
if (item.type === "dir") {
|
|
176171
|
-
|
|
176299
|
+
fs58.mkdirSync(targetPath, { recursive: true });
|
|
176172
176300
|
await downloadDirectory(`${SKILL_REPO_API_URL}/${item.name}`, targetPath);
|
|
176173
176301
|
} else if (item.type === "file" && item.download_url) {
|
|
176174
176302
|
const content = await fetchFileContent(item.download_url);
|
|
176175
|
-
|
|
176303
|
+
fs58.writeFileSync(targetPath, content, "utf-8");
|
|
176176
176304
|
}
|
|
176177
176305
|
}
|
|
176178
176306
|
}
|
|
176179
176307
|
async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
176180
|
-
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !
|
|
176308
|
+
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs58.existsSync(path61.join(projectDir, skillPath, "SKILL.md")));
|
|
176181
176309
|
if (missingSkillPaths.length === 0) {
|
|
176182
176310
|
console.log("TSCircuit AI skills already exist, skipping...");
|
|
176183
176311
|
return true;
|
|
@@ -176197,7 +176325,7 @@ async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
|
176197
176325
|
console.info("Setting up tscircuit AI skills...");
|
|
176198
176326
|
try {
|
|
176199
176327
|
for (const skillPath of missingSkillPaths) {
|
|
176200
|
-
const targetDir =
|
|
176328
|
+
const targetDir = path61.join(projectDir, skillPath);
|
|
176201
176329
|
await downloadSkillRepo(targetDir);
|
|
176202
176330
|
console.info(`tscircuit skill installed at ${skillPath}`);
|
|
176203
176331
|
}
|
|
@@ -176301,7 +176429,7 @@ var registerInit = (program3) => {
|
|
|
176301
176429
|
}
|
|
176302
176430
|
}
|
|
176303
176431
|
}
|
|
176304
|
-
const projectDir = directory ?
|
|
176432
|
+
const projectDir = directory ? path62.resolve(process.cwd(), directory) : process.cwd();
|
|
176305
176433
|
let tsciHandle = null;
|
|
176306
176434
|
const token = getSessionToken();
|
|
176307
176435
|
if (token) {
|
|
@@ -176312,7 +176440,7 @@ var registerInit = (program3) => {
|
|
|
176312
176440
|
}
|
|
176313
176441
|
} catch {}
|
|
176314
176442
|
}
|
|
176315
|
-
const dirName =
|
|
176443
|
+
const dirName = path62.basename(projectDir);
|
|
176316
176444
|
let defaultPackageName = dirName;
|
|
176317
176445
|
if (tsciHandle) {
|
|
176318
176446
|
defaultPackageName = `@tsci/${tsciHandle}.${dirName}`;
|
|
@@ -176330,8 +176458,8 @@ var registerInit = (program3) => {
|
|
|
176330
176458
|
authorName = account.tscircuit_handle;
|
|
176331
176459
|
}
|
|
176332
176460
|
}
|
|
176333
|
-
|
|
176334
|
-
writeFileIfNotExists(
|
|
176461
|
+
fs59.mkdirSync(projectDir, { recursive: true });
|
|
176462
|
+
writeFileIfNotExists(path62.join(projectDir, "index.circuit.tsx"), `
|
|
176335
176463
|
export default () => (
|
|
176336
176464
|
<board>
|
|
176337
176465
|
<resistor resistance="1k" footprint="0402" name="R1" />
|
|
@@ -176343,7 +176471,7 @@ export default () => (
|
|
|
176343
176471
|
if (saveProjectConfig(null, projectDir)) {
|
|
176344
176472
|
console.log("Created tscircuit.config.json with schema");
|
|
176345
176473
|
}
|
|
176346
|
-
writeFileIfNotExists(
|
|
176474
|
+
writeFileIfNotExists(path62.join(projectDir, ".npmrc"), `
|
|
176347
176475
|
@tsci:registry=https://npm.tscircuit.com
|
|
176348
176476
|
`);
|
|
176349
176477
|
console.log("Generating package.json");
|
|
@@ -176596,14 +176724,14 @@ class KeyStore {
|
|
|
176596
176724
|
}
|
|
176597
176725
|
}
|
|
176598
176726
|
function createKey(key) {
|
|
176599
|
-
let
|
|
176727
|
+
let path63 = null;
|
|
176600
176728
|
let id = null;
|
|
176601
176729
|
let src = null;
|
|
176602
176730
|
let weight = 1;
|
|
176603
176731
|
let getFn = null;
|
|
176604
176732
|
if (isString2(key) || isArray(key)) {
|
|
176605
176733
|
src = key;
|
|
176606
|
-
|
|
176734
|
+
path63 = createKeyPath(key);
|
|
176607
176735
|
id = createKeyId(key);
|
|
176608
176736
|
} else {
|
|
176609
176737
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -176617,11 +176745,11 @@ function createKey(key) {
|
|
|
176617
176745
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
176618
176746
|
}
|
|
176619
176747
|
}
|
|
176620
|
-
|
|
176748
|
+
path63 = createKeyPath(name);
|
|
176621
176749
|
id = createKeyId(name);
|
|
176622
176750
|
getFn = key.getFn;
|
|
176623
176751
|
}
|
|
176624
|
-
return { path:
|
|
176752
|
+
return { path: path63, id, weight, src, getFn };
|
|
176625
176753
|
}
|
|
176626
176754
|
function createKeyPath(key) {
|
|
176627
176755
|
return isArray(key) ? key : key.split(".");
|
|
@@ -176629,34 +176757,34 @@ function createKeyPath(key) {
|
|
|
176629
176757
|
function createKeyId(key) {
|
|
176630
176758
|
return isArray(key) ? key.join(".") : key;
|
|
176631
176759
|
}
|
|
176632
|
-
function get(obj,
|
|
176760
|
+
function get(obj, path63) {
|
|
176633
176761
|
let list = [];
|
|
176634
176762
|
let arr = false;
|
|
176635
|
-
const deepGet = (obj2,
|
|
176763
|
+
const deepGet = (obj2, path64, index) => {
|
|
176636
176764
|
if (!isDefined(obj2)) {
|
|
176637
176765
|
return;
|
|
176638
176766
|
}
|
|
176639
|
-
if (!
|
|
176767
|
+
if (!path64[index]) {
|
|
176640
176768
|
list.push(obj2);
|
|
176641
176769
|
} else {
|
|
176642
|
-
let key =
|
|
176770
|
+
let key = path64[index];
|
|
176643
176771
|
const value = obj2[key];
|
|
176644
176772
|
if (!isDefined(value)) {
|
|
176645
176773
|
return;
|
|
176646
176774
|
}
|
|
176647
|
-
if (index ===
|
|
176775
|
+
if (index === path64.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
|
|
176648
176776
|
list.push(toString(value));
|
|
176649
176777
|
} else if (isArray(value)) {
|
|
176650
176778
|
arr = true;
|
|
176651
176779
|
for (let i3 = 0, len = value.length;i3 < len; i3 += 1) {
|
|
176652
|
-
deepGet(value[i3],
|
|
176780
|
+
deepGet(value[i3], path64, index + 1);
|
|
176653
176781
|
}
|
|
176654
|
-
} else if (
|
|
176655
|
-
deepGet(value,
|
|
176782
|
+
} else if (path64.length) {
|
|
176783
|
+
deepGet(value, path64, index + 1);
|
|
176656
176784
|
}
|
|
176657
176785
|
}
|
|
176658
176786
|
};
|
|
176659
|
-
deepGet(obj, isString2(
|
|
176787
|
+
deepGet(obj, isString2(path63) ? path63.split(".") : path63, 0);
|
|
176660
176788
|
return arr ? list : list[0];
|
|
176661
176789
|
}
|
|
176662
176790
|
var MatchOptions = {
|
|
@@ -177852,9 +177980,9 @@ var registerSearch = (program3) => {
|
|
|
177852
177980
|
}
|
|
177853
177981
|
if (opts.json) {
|
|
177854
177982
|
const unifiedResults = [
|
|
177855
|
-
...kicadResults.map((
|
|
177983
|
+
...kicadResults.map((path63) => ({
|
|
177856
177984
|
source: "kicad",
|
|
177857
|
-
path:
|
|
177985
|
+
path: path63
|
|
177858
177986
|
})),
|
|
177859
177987
|
...results.packages.map((pkg) => ({
|
|
177860
177988
|
source: "tscircuit",
|
|
@@ -177882,8 +178010,8 @@ var registerSearch = (program3) => {
|
|
|
177882
178010
|
}
|
|
177883
178011
|
if (kicadResults.length) {
|
|
177884
178012
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
177885
|
-
kicadResults.forEach((
|
|
177886
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
178013
|
+
kicadResults.forEach((path63, idx) => {
|
|
178014
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path63.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
177887
178015
|
});
|
|
177888
178016
|
}
|
|
177889
178017
|
if (results.packages.length) {
|
|
@@ -177907,22 +178035,22 @@ var registerSearch = (program3) => {
|
|
|
177907
178035
|
};
|
|
177908
178036
|
|
|
177909
178037
|
// lib/shared/setup-github-actions.ts
|
|
177910
|
-
import
|
|
177911
|
-
import
|
|
178038
|
+
import fs60 from "node:fs";
|
|
178039
|
+
import path63 from "node:path";
|
|
177912
178040
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
177913
178041
|
const findGitRoot = (startDir) => {
|
|
177914
|
-
let dir =
|
|
177915
|
-
while (dir !==
|
|
177916
|
-
if (
|
|
178042
|
+
let dir = path63.resolve(startDir);
|
|
178043
|
+
while (dir !== path63.parse(dir).root) {
|
|
178044
|
+
if (fs60.existsSync(path63.join(dir, ".git"))) {
|
|
177917
178045
|
return dir;
|
|
177918
178046
|
}
|
|
177919
|
-
dir =
|
|
178047
|
+
dir = path63.dirname(dir);
|
|
177920
178048
|
}
|
|
177921
178049
|
return null;
|
|
177922
178050
|
};
|
|
177923
178051
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
177924
|
-
const workflowsDir =
|
|
177925
|
-
|
|
178052
|
+
const workflowsDir = path63.join(gitRoot, ".github", "workflows");
|
|
178053
|
+
fs60.mkdirSync(workflowsDir, { recursive: true });
|
|
177926
178054
|
const buildWorkflow = `name: tscircuit Build
|
|
177927
178055
|
|
|
177928
178056
|
on:
|
|
@@ -177961,8 +178089,8 @@ jobs:
|
|
|
177961
178089
|
- run: bun install
|
|
177962
178090
|
- run: bunx tsci snapshot
|
|
177963
178091
|
`;
|
|
177964
|
-
writeFileIfNotExists(
|
|
177965
|
-
writeFileIfNotExists(
|
|
178092
|
+
writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
178093
|
+
writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
177966
178094
|
};
|
|
177967
178095
|
|
|
177968
178096
|
// cli/setup/register.ts
|
|
@@ -178129,21 +178257,21 @@ function applyCameraPreset(preset, cam) {
|
|
|
178129
178257
|
}
|
|
178130
178258
|
|
|
178131
178259
|
// lib/shared/snapshot-project.ts
|
|
178132
|
-
import
|
|
178260
|
+
import path66 from "node:path";
|
|
178133
178261
|
|
|
178134
178262
|
// cli/snapshot/worker-pool.ts
|
|
178135
|
-
import
|
|
178136
|
-
import
|
|
178263
|
+
import fs61 from "node:fs";
|
|
178264
|
+
import path64 from "node:path";
|
|
178137
178265
|
var getWorkerEntrypointPath2 = () => {
|
|
178138
|
-
const tsPath =
|
|
178139
|
-
if (
|
|
178266
|
+
const tsPath = path64.join(import.meta.dir, "snapshot.worker.ts");
|
|
178267
|
+
if (fs61.existsSync(tsPath)) {
|
|
178140
178268
|
return tsPath;
|
|
178141
178269
|
}
|
|
178142
|
-
const jsBundledPath =
|
|
178143
|
-
if (
|
|
178270
|
+
const jsBundledPath = path64.join(import.meta.dir, "snapshot", "snapshot.worker.js");
|
|
178271
|
+
if (fs61.existsSync(jsBundledPath)) {
|
|
178144
178272
|
return jsBundledPath;
|
|
178145
178273
|
}
|
|
178146
|
-
return
|
|
178274
|
+
return path64.join(import.meta.dir, "snapshot.worker.js");
|
|
178147
178275
|
};
|
|
178148
178276
|
var snapshotFilesWithWorkerPool = async (options) => {
|
|
178149
178277
|
const cancellationError = new Error("Snapshot cancelled due to file failure");
|
|
@@ -178210,8 +178338,8 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
178210
178338
|
};
|
|
178211
178339
|
|
|
178212
178340
|
// lib/shared/process-snapshot-file.ts
|
|
178213
|
-
import
|
|
178214
|
-
import
|
|
178341
|
+
import fs63 from "node:fs";
|
|
178342
|
+
import path65 from "node:path";
|
|
178215
178343
|
import {
|
|
178216
178344
|
convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
|
|
178217
178345
|
getBestCameraPosition
|
|
@@ -178224,7 +178352,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
178224
178352
|
|
|
178225
178353
|
// lib/shared/compare-images.ts
|
|
178226
178354
|
import looksSame from "looks-same";
|
|
178227
|
-
import
|
|
178355
|
+
import fs62 from "node:fs/promises";
|
|
178228
178356
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
178229
178357
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
178230
178358
|
strict: false,
|
|
@@ -178240,7 +178368,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
178240
178368
|
tolerance: 2
|
|
178241
178369
|
});
|
|
178242
178370
|
} else {
|
|
178243
|
-
await
|
|
178371
|
+
await fs62.writeFile(diffPath, buffer2);
|
|
178244
178372
|
}
|
|
178245
178373
|
}
|
|
178246
178374
|
return { equal: equal2 };
|
|
@@ -178260,7 +178388,7 @@ var processSnapshotFile = async ({
|
|
|
178260
178388
|
createDiff,
|
|
178261
178389
|
cameraPreset
|
|
178262
178390
|
}) => {
|
|
178263
|
-
const relativeFilePath =
|
|
178391
|
+
const relativeFilePath = path65.relative(projectDir, file);
|
|
178264
178392
|
const successPaths = [];
|
|
178265
178393
|
const warningMessages = [];
|
|
178266
178394
|
const mismatches = [];
|
|
@@ -178270,7 +178398,7 @@ var processSnapshotFile = async ({
|
|
|
178270
178398
|
let schSvg;
|
|
178271
178399
|
try {
|
|
178272
178400
|
if (isCircuitJsonFile(file)) {
|
|
178273
|
-
const parsed = JSON.parse(
|
|
178401
|
+
const parsed = JSON.parse(fs63.readFileSync(file, "utf-8"));
|
|
178274
178402
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
178275
178403
|
} else {
|
|
178276
178404
|
const completePlatformConfig = getCompletePlatformConfig(platformConfig2);
|
|
@@ -178341,12 +178469,12 @@ var processSnapshotFile = async ({
|
|
|
178341
178469
|
} catch (error) {
|
|
178342
178470
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
178343
178471
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
178344
|
-
const fileDir =
|
|
178345
|
-
const relativeDir =
|
|
178346
|
-
const snapDir2 = snapshotsDirName ?
|
|
178347
|
-
const base2 =
|
|
178348
|
-
const snap3dPath =
|
|
178349
|
-
const existing3dSnapshot =
|
|
178472
|
+
const fileDir = path65.dirname(file);
|
|
178473
|
+
const relativeDir = path65.relative(projectDir, fileDir);
|
|
178474
|
+
const snapDir2 = snapshotsDirName ? path65.join(projectDir, snapshotsDirName, relativeDir) : path65.join(fileDir, "__snapshots__");
|
|
178475
|
+
const base2 = path65.basename(file).replace(/\.[^.]+$/, "");
|
|
178476
|
+
const snap3dPath = path65.join(snapDir2, `${base2}-3d.snap.png`);
|
|
178477
|
+
const existing3dSnapshot = fs63.existsSync(snap3dPath);
|
|
178350
178478
|
if (existing3dSnapshot) {
|
|
178351
178479
|
return {
|
|
178352
178480
|
ok: false,
|
|
@@ -178357,7 +178485,7 @@ var processSnapshotFile = async ({
|
|
|
178357
178485
|
errorMessage: kleur_default.red(`
|
|
178358
178486
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
178359
178487
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
178360
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
178488
|
+
`) + kleur_default.red(` Existing snapshot: ${path65.relative(projectDir, snap3dPath)}
|
|
178361
178489
|
`)
|
|
178362
178490
|
};
|
|
178363
178491
|
}
|
|
@@ -178378,9 +178506,9 @@ var processSnapshotFile = async ({
|
|
|
178378
178506
|
}
|
|
178379
178507
|
}
|
|
178380
178508
|
}
|
|
178381
|
-
const snapDir = snapshotsDirName ?
|
|
178382
|
-
|
|
178383
|
-
const base =
|
|
178509
|
+
const snapDir = snapshotsDirName ? path65.join(projectDir, snapshotsDirName, path65.relative(projectDir, path65.dirname(file))) : path65.join(path65.dirname(file), "__snapshots__");
|
|
178510
|
+
fs63.mkdirSync(snapDir, { recursive: true });
|
|
178511
|
+
const base = path65.basename(file).replace(/\.[^.]+$/, "");
|
|
178384
178512
|
const snapshots = [];
|
|
178385
178513
|
if (pcbOnly || !schematicOnly) {
|
|
178386
178514
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -178394,31 +178522,31 @@ var processSnapshotFile = async ({
|
|
|
178394
178522
|
for (const snapshot of snapshots) {
|
|
178395
178523
|
const { type } = snapshot;
|
|
178396
178524
|
const is3d = type === "3d";
|
|
178397
|
-
const snapPath =
|
|
178398
|
-
const existing =
|
|
178525
|
+
const snapPath = path65.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
178526
|
+
const existing = fs63.existsSync(snapPath);
|
|
178399
178527
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
178400
178528
|
const newContentForFile = snapshot.content;
|
|
178401
178529
|
if (!existing) {
|
|
178402
|
-
|
|
178403
|
-
successPaths.push(
|
|
178530
|
+
fs63.writeFileSync(snapPath, newContentForFile);
|
|
178531
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178404
178532
|
didUpdate = true;
|
|
178405
178533
|
continue;
|
|
178406
178534
|
}
|
|
178407
|
-
const oldContentBuffer =
|
|
178535
|
+
const oldContentBuffer = fs63.readFileSync(snapPath);
|
|
178408
178536
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
178409
178537
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
|
|
178410
178538
|
if (update) {
|
|
178411
178539
|
if (!forceUpdate && equal2) {
|
|
178412
|
-
successPaths.push(
|
|
178540
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178413
178541
|
} else {
|
|
178414
|
-
|
|
178415
|
-
successPaths.push(
|
|
178542
|
+
fs63.writeFileSync(snapPath, newContentForFile);
|
|
178543
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178416
178544
|
didUpdate = true;
|
|
178417
178545
|
}
|
|
178418
178546
|
} else if (!equal2) {
|
|
178419
178547
|
mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
178420
178548
|
} else {
|
|
178421
|
-
successPaths.push(
|
|
178549
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178422
178550
|
}
|
|
178423
178551
|
}
|
|
178424
178552
|
return {
|
|
@@ -178455,7 +178583,7 @@ var snapshotProject = async ({
|
|
|
178455
178583
|
...DEFAULT_IGNORED_PATTERNS,
|
|
178456
178584
|
...ignored.map(normalizeIgnorePattern)
|
|
178457
178585
|
];
|
|
178458
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
178586
|
+
const resolvedPaths = filePaths.map((f2) => path66.resolve(projectDir, f2));
|
|
178459
178587
|
const boardFiles = findBoardFiles({
|
|
178460
178588
|
projectDir,
|
|
178461
178589
|
ignore,
|
|
@@ -178585,7 +178713,7 @@ var registerSnapshot = (program3) => {
|
|
|
178585
178713
|
};
|
|
178586
178714
|
|
|
178587
178715
|
// cli/transpile/register.ts
|
|
178588
|
-
import
|
|
178716
|
+
import path67 from "node:path";
|
|
178589
178717
|
var registerTranspile = (program3) => {
|
|
178590
178718
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
178591
178719
|
try {
|
|
@@ -178593,7 +178721,7 @@ var registerTranspile = (program3) => {
|
|
|
178593
178721
|
fileOrDir: file,
|
|
178594
178722
|
includeBoardFiles: false
|
|
178595
178723
|
});
|
|
178596
|
-
const distDir =
|
|
178724
|
+
const distDir = path67.join(projectDir, "dist");
|
|
178597
178725
|
validateMainInDist(projectDir, distDir);
|
|
178598
178726
|
console.log("Transpiling entry file...");
|
|
178599
178727
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -178660,6 +178788,7 @@ registerUpgradeCommand(program2);
|
|
|
178660
178788
|
registerDoctor(program2);
|
|
178661
178789
|
registerCheck(program2);
|
|
178662
178790
|
registerCheckNetlist(program2);
|
|
178791
|
+
registerCheckPinSpecification(program2);
|
|
178663
178792
|
registerCheckPlacement(program2);
|
|
178664
178793
|
registerCheckRouting(program2);
|
|
178665
178794
|
registerRegistry(program2);
|