@tscircuit/cli 0.1.1093 → 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 +624 -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"
|
|
@@ -83050,9 +83050,76 @@ var registerCheckNetlist = (program2) => {
|
|
|
83050
83050
|
});
|
|
83051
83051
|
};
|
|
83052
83052
|
|
|
83053
|
-
// cli/check/
|
|
83053
|
+
// cli/check/pin-specification/register.ts
|
|
83054
83054
|
import fs38 from "node:fs";
|
|
83055
|
+
import { runAllPinSpecificationChecks } from "@tscircuit/checks";
|
|
83055
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";
|
|
83056
83123
|
|
|
83057
83124
|
// node_modules/@tscircuit/circuit-json-placement-analysis/dist/index.js
|
|
83058
83125
|
var CENTER_ANCHOR = "center";
|
|
@@ -83579,13 +83646,13 @@ var analyzeAllPlacements = (circuitJson) => {
|
|
|
83579
83646
|
};
|
|
83580
83647
|
|
|
83581
83648
|
// cli/check/placement/register.ts
|
|
83582
|
-
var
|
|
83649
|
+
var isPrebuiltCircuitJsonFile2 = (filePath) => {
|
|
83583
83650
|
const normalizedInputPath = filePath.toLowerCase().replaceAll("\\", "/");
|
|
83584
83651
|
return normalizedInputPath.endsWith(".circuit.json") || normalizedInputPath.endsWith("/circuit.json");
|
|
83585
83652
|
};
|
|
83586
|
-
var
|
|
83653
|
+
var resolveInputFilePath3 = async (file) => {
|
|
83587
83654
|
if (file) {
|
|
83588
|
-
return
|
|
83655
|
+
return path42.isAbsolute(file) ? file : path42.resolve(process.cwd(), file);
|
|
83589
83656
|
}
|
|
83590
83657
|
const entrypoint = await getEntrypoint({
|
|
83591
83658
|
projectDir: process.cwd()
|
|
@@ -83596,8 +83663,8 @@ var resolveInputFilePath2 = async (file) => {
|
|
|
83596
83663
|
return entrypoint;
|
|
83597
83664
|
};
|
|
83598
83665
|
var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
83599
|
-
if (
|
|
83600
|
-
const parsedJson = JSON.parse(
|
|
83666
|
+
if (isPrebuiltCircuitJsonFile2(filePath)) {
|
|
83667
|
+
const parsedJson = JSON.parse(fs39.readFileSync(filePath, "utf-8"));
|
|
83601
83668
|
return Array.isArray(parsedJson) ? parsedJson : [];
|
|
83602
83669
|
}
|
|
83603
83670
|
const completePlatformConfig = getCompletePlatformConfig({
|
|
@@ -83611,7 +83678,7 @@ var getCircuitJsonForPlacementCheck = async (filePath) => {
|
|
|
83611
83678
|
return circuitJson;
|
|
83612
83679
|
};
|
|
83613
83680
|
var checkPlacement = async (file, refdes) => {
|
|
83614
|
-
const resolvedInputFilePath = await
|
|
83681
|
+
const resolvedInputFilePath = await resolveInputFilePath3(file);
|
|
83615
83682
|
const circuitJson = await getCircuitJsonForPlacementCheck(resolvedInputFilePath);
|
|
83616
83683
|
const analysis = refdes ? analyzeComponentPlacement(circuitJson, refdes) : analyzeAllPlacements(circuitJson);
|
|
83617
83684
|
return analysis.getString();
|
|
@@ -83641,26 +83708,26 @@ var registerCheckRouting = (program2) => {
|
|
|
83641
83708
|
};
|
|
83642
83709
|
|
|
83643
83710
|
// cli/clone/register.ts
|
|
83644
|
-
import * as
|
|
83645
|
-
import * as
|
|
83711
|
+
import * as fs42 from "node:fs";
|
|
83712
|
+
import * as path45 from "node:path";
|
|
83646
83713
|
|
|
83647
83714
|
// cli/clone/clone-bug-report.ts
|
|
83648
83715
|
var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
83649
83716
|
var import_prompts4 = __toESM2(require_prompts3(), 1);
|
|
83650
|
-
import * as
|
|
83651
|
-
import * as
|
|
83717
|
+
import * as fs41 from "node:fs";
|
|
83718
|
+
import * as path44 from "node:path";
|
|
83652
83719
|
|
|
83653
83720
|
// cli/clone/handle-existing-directory.ts
|
|
83654
83721
|
var import_prompts3 = __toESM2(require_prompts3(), 1);
|
|
83655
|
-
import * as
|
|
83656
|
-
import * as
|
|
83722
|
+
import * as fs40 from "node:fs";
|
|
83723
|
+
import * as path43 from "node:path";
|
|
83657
83724
|
var handleExistingDirectory = async (dirPath) => {
|
|
83658
|
-
if (!
|
|
83725
|
+
if (!fs40.existsSync(dirPath))
|
|
83659
83726
|
return;
|
|
83660
83727
|
const response = await import_prompts3.default({
|
|
83661
83728
|
type: "select",
|
|
83662
83729
|
name: "action",
|
|
83663
|
-
message: `Directory "${
|
|
83730
|
+
message: `Directory "${path43.basename(dirPath)}" already exists. What would you like to do?`,
|
|
83664
83731
|
choices: [
|
|
83665
83732
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
83666
83733
|
{
|
|
@@ -83675,7 +83742,7 @@ var handleExistingDirectory = async (dirPath) => {
|
|
|
83675
83742
|
process.exit(0);
|
|
83676
83743
|
}
|
|
83677
83744
|
if (response.action === "delete") {
|
|
83678
|
-
|
|
83745
|
+
fs40.rmSync(dirPath, { recursive: true, force: true });
|
|
83679
83746
|
console.log(`Deleted existing directory: ${dirPath}`);
|
|
83680
83747
|
} else if (response.action === "merge") {
|
|
83681
83748
|
console.log(`Merging files into existing directory: ${dirPath}`);
|
|
@@ -83701,12 +83768,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
83701
83768
|
return commonSegments.join("/");
|
|
83702
83769
|
};
|
|
83703
83770
|
var sanitizeRelativePath = (relativePath) => {
|
|
83704
|
-
const normalizedPath =
|
|
83771
|
+
const normalizedPath = path44.normalize(relativePath);
|
|
83705
83772
|
if (!normalizedPath)
|
|
83706
83773
|
return null;
|
|
83707
|
-
if (
|
|
83774
|
+
if (path44.isAbsolute(normalizedPath))
|
|
83708
83775
|
return null;
|
|
83709
|
-
const segments = normalizedPath.split(
|
|
83776
|
+
const segments = normalizedPath.split(path44.sep);
|
|
83710
83777
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
83711
83778
|
return null;
|
|
83712
83779
|
}
|
|
@@ -83721,7 +83788,7 @@ var cloneBugReport = async ({
|
|
|
83721
83788
|
console.error("Bug report ID must not be empty.");
|
|
83722
83789
|
process.exit(1);
|
|
83723
83790
|
}
|
|
83724
|
-
let dirPath =
|
|
83791
|
+
let dirPath = path44.resolve(`bug-report-${trimmedBugReportId}`);
|
|
83725
83792
|
await handleExistingDirectory(dirPath);
|
|
83726
83793
|
const ky2 = getRegistryApiKy();
|
|
83727
83794
|
let zipBuffer;
|
|
@@ -83739,7 +83806,7 @@ var cloneBugReport = async ({
|
|
|
83739
83806
|
}
|
|
83740
83807
|
process.exit(1);
|
|
83741
83808
|
}
|
|
83742
|
-
|
|
83809
|
+
fs41.mkdirSync(dirPath, { recursive: true });
|
|
83743
83810
|
const zip = await import_jszip2.default.loadAsync(zipBuffer);
|
|
83744
83811
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
83745
83812
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
@@ -83751,29 +83818,29 @@ var cloneBugReport = async ({
|
|
|
83751
83818
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
83752
83819
|
continue;
|
|
83753
83820
|
}
|
|
83754
|
-
const fullPath =
|
|
83755
|
-
|
|
83821
|
+
const fullPath = path44.join(dirPath, sanitizedRelativePath);
|
|
83822
|
+
fs41.mkdirSync(path44.dirname(fullPath), { recursive: true });
|
|
83756
83823
|
const fileContent = await entry.async("nodebuffer");
|
|
83757
|
-
|
|
83824
|
+
fs41.writeFileSync(fullPath, fileContent);
|
|
83758
83825
|
}
|
|
83759
|
-
const packageJsonPath =
|
|
83760
|
-
if (
|
|
83826
|
+
const packageJsonPath = path44.join(dirPath, "package.json");
|
|
83827
|
+
if (fs41.existsSync(packageJsonPath)) {
|
|
83761
83828
|
try {
|
|
83762
|
-
const packageJson = JSON.parse(
|
|
83829
|
+
const packageJson = JSON.parse(fs41.readFileSync(packageJsonPath, "utf-8"));
|
|
83763
83830
|
const packageName = packageJson?.name;
|
|
83764
83831
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
83765
83832
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
83766
|
-
const suggestedDirPath =
|
|
83833
|
+
const suggestedDirPath = path44.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
83767
83834
|
if (suggestedDirPath !== dirPath) {
|
|
83768
83835
|
const response = await import_prompts4.default({
|
|
83769
83836
|
type: "confirm",
|
|
83770
83837
|
name: "rename",
|
|
83771
83838
|
initial: true,
|
|
83772
|
-
message: `Rename the directory to "${
|
|
83839
|
+
message: `Rename the directory to "${path44.basename(suggestedDirPath)}"?`
|
|
83773
83840
|
});
|
|
83774
83841
|
if (response.rename) {
|
|
83775
83842
|
await handleExistingDirectory(suggestedDirPath);
|
|
83776
|
-
|
|
83843
|
+
fs41.renameSync(dirPath, suggestedDirPath);
|
|
83777
83844
|
dirPath = suggestedDirPath;
|
|
83778
83845
|
}
|
|
83779
83846
|
}
|
|
@@ -83782,9 +83849,9 @@ var cloneBugReport = async ({
|
|
|
83782
83849
|
console.warn("Unable to read package name for renaming:", error);
|
|
83783
83850
|
}
|
|
83784
83851
|
}
|
|
83785
|
-
|
|
83852
|
+
fs41.writeFileSync(path44.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83786
83853
|
generateTsConfig(dirPath);
|
|
83787
|
-
const relativeDirPath =
|
|
83854
|
+
const relativeDirPath = path44.relative(originalCwd, dirPath);
|
|
83788
83855
|
console.log(kleur_default.green(`
|
|
83789
83856
|
Successfully cloned bug report to:`));
|
|
83790
83857
|
console.log(` ${dirPath}/
|
|
@@ -83823,7 +83890,7 @@ var registerClone = (program2) => {
|
|
|
83823
83890
|
const [, author, packageName] = match;
|
|
83824
83891
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
83825
83892
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
83826
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
83893
|
+
const dirPath = userSettingToIncludeAuthor ? path45.resolve(`${author}.${packageName}`) : path45.resolve(packageName);
|
|
83827
83894
|
await handleExistingDirectory(dirPath);
|
|
83828
83895
|
const ky2 = getRegistryApiKy();
|
|
83829
83896
|
let packageFileList = {
|
|
@@ -83844,13 +83911,13 @@ var registerClone = (program2) => {
|
|
|
83844
83911
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
83845
83912
|
process.exit(1);
|
|
83846
83913
|
}
|
|
83847
|
-
|
|
83914
|
+
fs42.mkdirSync(dirPath, { recursive: true });
|
|
83848
83915
|
for (const fileInfo of packageFileList.package_files) {
|
|
83849
83916
|
const filePath = fileInfo.file_path.replace(/^\/+/, "");
|
|
83850
83917
|
if (!filePath)
|
|
83851
83918
|
continue;
|
|
83852
|
-
const fullPath =
|
|
83853
|
-
|
|
83919
|
+
const fullPath = path45.join(dirPath, filePath);
|
|
83920
|
+
fs42.mkdirSync(path45.dirname(fullPath), { recursive: true });
|
|
83854
83921
|
try {
|
|
83855
83922
|
const fileContent = await ky2.get("package_files/get", {
|
|
83856
83923
|
searchParams: {
|
|
@@ -83861,14 +83928,14 @@ var registerClone = (program2) => {
|
|
|
83861
83928
|
}).json();
|
|
83862
83929
|
const { is_text: isText, content_text: contentText } = fileContent.package_file;
|
|
83863
83930
|
if (isText && typeof contentText === "string") {
|
|
83864
|
-
|
|
83931
|
+
fs42.writeFileSync(fullPath, contentText);
|
|
83865
83932
|
} else if (!isText) {
|
|
83866
83933
|
const fileBuffer = await ky2.get("package_files/download", {
|
|
83867
83934
|
searchParams: {
|
|
83868
83935
|
package_file_id: fileContent.package_file.package_file_id
|
|
83869
83936
|
}
|
|
83870
83937
|
}).arrayBuffer();
|
|
83871
|
-
|
|
83938
|
+
fs42.writeFileSync(fullPath, Buffer.from(fileBuffer));
|
|
83872
83939
|
} else {
|
|
83873
83940
|
console.warn(`Skipping ${filePath} due to empty content.`);
|
|
83874
83941
|
}
|
|
@@ -83876,10 +83943,10 @@ var registerClone = (program2) => {
|
|
|
83876
83943
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
83877
83944
|
}
|
|
83878
83945
|
}
|
|
83879
|
-
|
|
83946
|
+
fs42.writeFileSync(path45.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
83880
83947
|
generateTsConfig(dirPath);
|
|
83881
83948
|
await setupTsciProject(dirPath);
|
|
83882
|
-
const relativeDirPath =
|
|
83949
|
+
const relativeDirPath = path45.relative(originalCwd, dirPath);
|
|
83883
83950
|
console.log(kleur_default.green(`
|
|
83884
83951
|
Successfully cloned to:`));
|
|
83885
83952
|
console.log(` ${dirPath}/
|
|
@@ -83946,8 +84013,8 @@ var registerConfigSet = (program2) => {
|
|
|
83946
84013
|
};
|
|
83947
84014
|
|
|
83948
84015
|
// cli/convert/register.ts
|
|
83949
|
-
import
|
|
83950
|
-
import
|
|
84016
|
+
import fs43 from "node:fs/promises";
|
|
84017
|
+
import path46 from "node:path";
|
|
83951
84018
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
83952
84019
|
|
|
83953
84020
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -84068,15 +84135,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
84068
84135
|
var registerConvert = (program2) => {
|
|
84069
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) => {
|
|
84070
84137
|
try {
|
|
84071
|
-
const inputPath =
|
|
84072
|
-
const modContent = await
|
|
84138
|
+
const inputPath = path46.resolve(file);
|
|
84139
|
+
const modContent = await fs43.readFile(inputPath, "utf-8");
|
|
84073
84140
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
84074
|
-
const componentName = options.name ??
|
|
84141
|
+
const componentName = options.name ?? path46.basename(inputPath, ".kicad_mod");
|
|
84075
84142
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
84076
84143
|
componentName
|
|
84077
84144
|
});
|
|
84078
|
-
const outputPath = options.output ?
|
|
84079
|
-
await
|
|
84145
|
+
const outputPath = options.output ? path46.resolve(options.output) : path46.join(path46.dirname(inputPath), `${componentName}.tsx`);
|
|
84146
|
+
await fs43.writeFile(outputPath, tsx);
|
|
84080
84147
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
84081
84148
|
} catch (error) {
|
|
84082
84149
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -84086,13 +84153,13 @@ var registerConvert = (program2) => {
|
|
|
84086
84153
|
};
|
|
84087
84154
|
|
|
84088
84155
|
// cli/dev/register.ts
|
|
84089
|
-
import * as
|
|
84156
|
+
import * as fs50 from "node:fs";
|
|
84090
84157
|
import * as net from "node:net";
|
|
84091
|
-
import * as
|
|
84158
|
+
import * as path54 from "node:path";
|
|
84092
84159
|
|
|
84093
84160
|
// cli/dev/DevServer.ts
|
|
84094
|
-
import
|
|
84095
|
-
import
|
|
84161
|
+
import fs48 from "node:fs";
|
|
84162
|
+
import path52 from "node:path";
|
|
84096
84163
|
|
|
84097
84164
|
// node_modules/chokidar/esm/index.js
|
|
84098
84165
|
import { stat as statcb } from "fs";
|
|
@@ -84171,7 +84238,7 @@ class ReaddirpStream extends Readable {
|
|
|
84171
84238
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
84172
84239
|
const statMethod = opts.lstat ? lstat : stat;
|
|
84173
84240
|
if (wantBigintFsStats) {
|
|
84174
|
-
this._stat = (
|
|
84241
|
+
this._stat = (path47) => statMethod(path47, { bigint: true });
|
|
84175
84242
|
} else {
|
|
84176
84243
|
this._stat = statMethod;
|
|
84177
84244
|
}
|
|
@@ -84196,8 +84263,8 @@ class ReaddirpStream extends Readable {
|
|
|
84196
84263
|
const par = this.parent;
|
|
84197
84264
|
const fil = par && par.files;
|
|
84198
84265
|
if (fil && fil.length > 0) {
|
|
84199
|
-
const { path:
|
|
84200
|
-
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));
|
|
84201
84268
|
const awaited = await Promise.all(slice);
|
|
84202
84269
|
for (const entry of awaited) {
|
|
84203
84270
|
if (!entry)
|
|
@@ -84237,20 +84304,20 @@ class ReaddirpStream extends Readable {
|
|
|
84237
84304
|
this.reading = false;
|
|
84238
84305
|
}
|
|
84239
84306
|
}
|
|
84240
|
-
async _exploreDir(
|
|
84307
|
+
async _exploreDir(path47, depth) {
|
|
84241
84308
|
let files;
|
|
84242
84309
|
try {
|
|
84243
|
-
files = await readdir(
|
|
84310
|
+
files = await readdir(path47, this._rdOptions);
|
|
84244
84311
|
} catch (error) {
|
|
84245
84312
|
this._onError(error);
|
|
84246
84313
|
}
|
|
84247
|
-
return { files, depth, path:
|
|
84314
|
+
return { files, depth, path: path47 };
|
|
84248
84315
|
}
|
|
84249
|
-
async _formatEntry(dirent,
|
|
84316
|
+
async _formatEntry(dirent, path47) {
|
|
84250
84317
|
let entry;
|
|
84251
84318
|
const basename4 = this._isDirent ? dirent.name : dirent;
|
|
84252
84319
|
try {
|
|
84253
|
-
const fullPath = presolve(pjoin(
|
|
84320
|
+
const fullPath = presolve(pjoin(path47, basename4));
|
|
84254
84321
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename4 };
|
|
84255
84322
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
84256
84323
|
} catch (err) {
|
|
@@ -84648,16 +84715,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
84648
84715
|
};
|
|
84649
84716
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
84650
84717
|
var FsWatchInstances = new Map;
|
|
84651
|
-
function createFsWatchInstance(
|
|
84718
|
+
function createFsWatchInstance(path47, options, listener, errHandler, emitRaw) {
|
|
84652
84719
|
const handleEvent = (rawEvent, evPath) => {
|
|
84653
|
-
listener(
|
|
84654
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
84655
|
-
if (evPath &&
|
|
84656
|
-
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));
|
|
84657
84724
|
}
|
|
84658
84725
|
};
|
|
84659
84726
|
try {
|
|
84660
|
-
return fs_watch(
|
|
84727
|
+
return fs_watch(path47, {
|
|
84661
84728
|
persistent: options.persistent
|
|
84662
84729
|
}, handleEvent);
|
|
84663
84730
|
} catch (error) {
|
|
@@ -84673,12 +84740,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
84673
84740
|
listener(val1, val2, val3);
|
|
84674
84741
|
});
|
|
84675
84742
|
};
|
|
84676
|
-
var setFsWatchListener = (
|
|
84743
|
+
var setFsWatchListener = (path47, fullPath, options, handlers) => {
|
|
84677
84744
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
84678
84745
|
let cont = FsWatchInstances.get(fullPath);
|
|
84679
84746
|
let watcher;
|
|
84680
84747
|
if (!options.persistent) {
|
|
84681
|
-
watcher = createFsWatchInstance(
|
|
84748
|
+
watcher = createFsWatchInstance(path47, options, listener, errHandler, rawEmitter);
|
|
84682
84749
|
if (!watcher)
|
|
84683
84750
|
return;
|
|
84684
84751
|
return watcher.close.bind(watcher);
|
|
@@ -84688,7 +84755,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84688
84755
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
84689
84756
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
84690
84757
|
} else {
|
|
84691
|
-
watcher = createFsWatchInstance(
|
|
84758
|
+
watcher = createFsWatchInstance(path47, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
84692
84759
|
if (!watcher)
|
|
84693
84760
|
return;
|
|
84694
84761
|
watcher.on(EV.ERROR, async (error) => {
|
|
@@ -84697,7 +84764,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84697
84764
|
cont.watcherUnusable = true;
|
|
84698
84765
|
if (isWindows && error.code === "EPERM") {
|
|
84699
84766
|
try {
|
|
84700
|
-
const fd = await open(
|
|
84767
|
+
const fd = await open(path47, "r");
|
|
84701
84768
|
await fd.close();
|
|
84702
84769
|
broadcastErr(error);
|
|
84703
84770
|
} catch (err) {}
|
|
@@ -84727,7 +84794,7 @@ var setFsWatchListener = (path46, fullPath, options, handlers) => {
|
|
|
84727
84794
|
};
|
|
84728
84795
|
};
|
|
84729
84796
|
var FsWatchFileInstances = new Map;
|
|
84730
|
-
var setFsWatchFileListener = (
|
|
84797
|
+
var setFsWatchFileListener = (path47, fullPath, options, handlers) => {
|
|
84731
84798
|
const { listener, rawEmitter } = handlers;
|
|
84732
84799
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
84733
84800
|
const copts = cont && cont.options;
|
|
@@ -84749,7 +84816,7 @@ var setFsWatchFileListener = (path46, fullPath, options, handlers) => {
|
|
|
84749
84816
|
});
|
|
84750
84817
|
const currmtime = curr.mtimeMs;
|
|
84751
84818
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
84752
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
84819
|
+
foreach(cont.listeners, (listener2) => listener2(path47, curr));
|
|
84753
84820
|
}
|
|
84754
84821
|
})
|
|
84755
84822
|
};
|
|
@@ -84772,13 +84839,13 @@ class NodeFsHandler {
|
|
|
84772
84839
|
this.fsw = fsW;
|
|
84773
84840
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
84774
84841
|
}
|
|
84775
|
-
_watchWithNodeFs(
|
|
84842
|
+
_watchWithNodeFs(path47, listener) {
|
|
84776
84843
|
const opts = this.fsw.options;
|
|
84777
|
-
const directory = sysPath.dirname(
|
|
84778
|
-
const basename5 = sysPath.basename(
|
|
84844
|
+
const directory = sysPath.dirname(path47);
|
|
84845
|
+
const basename5 = sysPath.basename(path47);
|
|
84779
84846
|
const parent = this.fsw._getWatchedDir(directory);
|
|
84780
84847
|
parent.add(basename5);
|
|
84781
|
-
const absolutePath = sysPath.resolve(
|
|
84848
|
+
const absolutePath = sysPath.resolve(path47);
|
|
84782
84849
|
const options = {
|
|
84783
84850
|
persistent: opts.persistent
|
|
84784
84851
|
};
|
|
@@ -84788,12 +84855,12 @@ class NodeFsHandler {
|
|
|
84788
84855
|
if (opts.usePolling) {
|
|
84789
84856
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
84790
84857
|
options.interval = enableBin && isBinaryPath(basename5) ? opts.binaryInterval : opts.interval;
|
|
84791
|
-
closer = setFsWatchFileListener(
|
|
84858
|
+
closer = setFsWatchFileListener(path47, absolutePath, options, {
|
|
84792
84859
|
listener,
|
|
84793
84860
|
rawEmitter: this.fsw._emitRaw
|
|
84794
84861
|
});
|
|
84795
84862
|
} else {
|
|
84796
|
-
closer = setFsWatchListener(
|
|
84863
|
+
closer = setFsWatchListener(path47, absolutePath, options, {
|
|
84797
84864
|
listener,
|
|
84798
84865
|
errHandler: this._boundHandleError,
|
|
84799
84866
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -84811,7 +84878,7 @@ class NodeFsHandler {
|
|
|
84811
84878
|
let prevStats = stats;
|
|
84812
84879
|
if (parent.has(basename5))
|
|
84813
84880
|
return;
|
|
84814
|
-
const listener = async (
|
|
84881
|
+
const listener = async (path47, newStats) => {
|
|
84815
84882
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
84816
84883
|
return;
|
|
84817
84884
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -84825,11 +84892,11 @@ class NodeFsHandler {
|
|
|
84825
84892
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
84826
84893
|
}
|
|
84827
84894
|
if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
|
|
84828
|
-
this.fsw._closeFile(
|
|
84895
|
+
this.fsw._closeFile(path47);
|
|
84829
84896
|
prevStats = newStats2;
|
|
84830
84897
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
84831
84898
|
if (closer2)
|
|
84832
|
-
this.fsw._addPathCloser(
|
|
84899
|
+
this.fsw._addPathCloser(path47, closer2);
|
|
84833
84900
|
} else {
|
|
84834
84901
|
prevStats = newStats2;
|
|
84835
84902
|
}
|
|
@@ -84853,7 +84920,7 @@ class NodeFsHandler {
|
|
|
84853
84920
|
}
|
|
84854
84921
|
return closer;
|
|
84855
84922
|
}
|
|
84856
|
-
async _handleSymlink(entry, directory,
|
|
84923
|
+
async _handleSymlink(entry, directory, path47, item) {
|
|
84857
84924
|
if (this.fsw.closed) {
|
|
84858
84925
|
return;
|
|
84859
84926
|
}
|
|
@@ -84863,7 +84930,7 @@ class NodeFsHandler {
|
|
|
84863
84930
|
this.fsw._incrReadyCount();
|
|
84864
84931
|
let linkPath;
|
|
84865
84932
|
try {
|
|
84866
|
-
linkPath = await fsrealpath(
|
|
84933
|
+
linkPath = await fsrealpath(path47);
|
|
84867
84934
|
} catch (e) {
|
|
84868
84935
|
this.fsw._emitReady();
|
|
84869
84936
|
return true;
|
|
@@ -84873,12 +84940,12 @@ class NodeFsHandler {
|
|
|
84873
84940
|
if (dir.has(item)) {
|
|
84874
84941
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
84875
84942
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84876
|
-
this.fsw._emit(EV.CHANGE,
|
|
84943
|
+
this.fsw._emit(EV.CHANGE, path47, entry.stats);
|
|
84877
84944
|
}
|
|
84878
84945
|
} else {
|
|
84879
84946
|
dir.add(item);
|
|
84880
84947
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
84881
|
-
this.fsw._emit(EV.ADD,
|
|
84948
|
+
this.fsw._emit(EV.ADD, path47, entry.stats);
|
|
84882
84949
|
}
|
|
84883
84950
|
this.fsw._emitReady();
|
|
84884
84951
|
return true;
|
|
@@ -84907,9 +84974,9 @@ class NodeFsHandler {
|
|
|
84907
84974
|
return;
|
|
84908
84975
|
}
|
|
84909
84976
|
const item = entry.path;
|
|
84910
|
-
let
|
|
84977
|
+
let path47 = sysPath.join(directory, item);
|
|
84911
84978
|
current.add(item);
|
|
84912
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
84979
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path47, item)) {
|
|
84913
84980
|
return;
|
|
84914
84981
|
}
|
|
84915
84982
|
if (this.fsw.closed) {
|
|
@@ -84918,8 +84985,8 @@ class NodeFsHandler {
|
|
|
84918
84985
|
}
|
|
84919
84986
|
if (item === target || !target && !previous.has(item)) {
|
|
84920
84987
|
this.fsw._incrReadyCount();
|
|
84921
|
-
|
|
84922
|
-
this._addToNodeFs(
|
|
84988
|
+
path47 = sysPath.join(dir, sysPath.relative(dir, path47));
|
|
84989
|
+
this._addToNodeFs(path47, initialAdd, wh, depth + 1);
|
|
84923
84990
|
}
|
|
84924
84991
|
}).on(EV.ERROR, this._boundHandleError);
|
|
84925
84992
|
return new Promise((resolve7, reject) => {
|
|
@@ -84968,13 +85035,13 @@ class NodeFsHandler {
|
|
|
84968
85035
|
}
|
|
84969
85036
|
return closer;
|
|
84970
85037
|
}
|
|
84971
|
-
async _addToNodeFs(
|
|
85038
|
+
async _addToNodeFs(path47, initialAdd, priorWh, depth, target) {
|
|
84972
85039
|
const ready = this.fsw._emitReady;
|
|
84973
|
-
if (this.fsw._isIgnored(
|
|
85040
|
+
if (this.fsw._isIgnored(path47) || this.fsw.closed) {
|
|
84974
85041
|
ready();
|
|
84975
85042
|
return false;
|
|
84976
85043
|
}
|
|
84977
|
-
const wh = this.fsw._getWatchHelpers(
|
|
85044
|
+
const wh = this.fsw._getWatchHelpers(path47);
|
|
84978
85045
|
if (priorWh) {
|
|
84979
85046
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
84980
85047
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -84990,8 +85057,8 @@ class NodeFsHandler {
|
|
|
84990
85057
|
const follow = this.fsw.options.followSymlinks;
|
|
84991
85058
|
let closer;
|
|
84992
85059
|
if (stats.isDirectory()) {
|
|
84993
|
-
const absPath = sysPath.resolve(
|
|
84994
|
-
const targetPath = follow ? await fsrealpath(
|
|
85060
|
+
const absPath = sysPath.resolve(path47);
|
|
85061
|
+
const targetPath = follow ? await fsrealpath(path47) : path47;
|
|
84995
85062
|
if (this.fsw.closed)
|
|
84996
85063
|
return;
|
|
84997
85064
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -85001,29 +85068,29 @@ class NodeFsHandler {
|
|
|
85001
85068
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
85002
85069
|
}
|
|
85003
85070
|
} else if (stats.isSymbolicLink()) {
|
|
85004
|
-
const targetPath = follow ? await fsrealpath(
|
|
85071
|
+
const targetPath = follow ? await fsrealpath(path47) : path47;
|
|
85005
85072
|
if (this.fsw.closed)
|
|
85006
85073
|
return;
|
|
85007
85074
|
const parent = sysPath.dirname(wh.watchPath);
|
|
85008
85075
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
85009
85076
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
85010
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
85077
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path47, wh, targetPath);
|
|
85011
85078
|
if (this.fsw.closed)
|
|
85012
85079
|
return;
|
|
85013
85080
|
if (targetPath !== undefined) {
|
|
85014
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
85081
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path47), targetPath);
|
|
85015
85082
|
}
|
|
85016
85083
|
} else {
|
|
85017
85084
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
85018
85085
|
}
|
|
85019
85086
|
ready();
|
|
85020
85087
|
if (closer)
|
|
85021
|
-
this.fsw._addPathCloser(
|
|
85088
|
+
this.fsw._addPathCloser(path47, closer);
|
|
85022
85089
|
return false;
|
|
85023
85090
|
} catch (error) {
|
|
85024
85091
|
if (this.fsw._handleError(error)) {
|
|
85025
85092
|
ready();
|
|
85026
|
-
return
|
|
85093
|
+
return path47;
|
|
85027
85094
|
}
|
|
85028
85095
|
}
|
|
85029
85096
|
}
|
|
@@ -85066,26 +85133,26 @@ function createPattern(matcher) {
|
|
|
85066
85133
|
}
|
|
85067
85134
|
return () => false;
|
|
85068
85135
|
}
|
|
85069
|
-
function normalizePath(
|
|
85070
|
-
if (typeof
|
|
85136
|
+
function normalizePath(path47) {
|
|
85137
|
+
if (typeof path47 !== "string")
|
|
85071
85138
|
throw new Error("string expected");
|
|
85072
|
-
|
|
85073
|
-
|
|
85139
|
+
path47 = sysPath2.normalize(path47);
|
|
85140
|
+
path47 = path47.replace(/\\/g, "/");
|
|
85074
85141
|
let prepend = false;
|
|
85075
|
-
if (
|
|
85142
|
+
if (path47.startsWith("//"))
|
|
85076
85143
|
prepend = true;
|
|
85077
85144
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
85078
|
-
while (
|
|
85079
|
-
|
|
85145
|
+
while (path47.match(DOUBLE_SLASH_RE2))
|
|
85146
|
+
path47 = path47.replace(DOUBLE_SLASH_RE2, "/");
|
|
85080
85147
|
if (prepend)
|
|
85081
|
-
|
|
85082
|
-
return
|
|
85148
|
+
path47 = "/" + path47;
|
|
85149
|
+
return path47;
|
|
85083
85150
|
}
|
|
85084
85151
|
function matchPatterns(patterns, testString, stats) {
|
|
85085
|
-
const
|
|
85152
|
+
const path47 = normalizePath(testString);
|
|
85086
85153
|
for (let index = 0;index < patterns.length; index++) {
|
|
85087
85154
|
const pattern = patterns[index];
|
|
85088
|
-
if (pattern(
|
|
85155
|
+
if (pattern(path47, stats)) {
|
|
85089
85156
|
return true;
|
|
85090
85157
|
}
|
|
85091
85158
|
}
|
|
@@ -85125,19 +85192,19 @@ var toUnix = (string) => {
|
|
|
85125
85192
|
}
|
|
85126
85193
|
return str;
|
|
85127
85194
|
};
|
|
85128
|
-
var normalizePathToUnix = (
|
|
85129
|
-
var normalizeIgnored = (cwd = "") => (
|
|
85130
|
-
if (typeof
|
|
85131
|
-
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));
|
|
85132
85199
|
} else {
|
|
85133
|
-
return
|
|
85200
|
+
return path47;
|
|
85134
85201
|
}
|
|
85135
85202
|
};
|
|
85136
|
-
var getAbsolutePath = (
|
|
85137
|
-
if (sysPath2.isAbsolute(
|
|
85138
|
-
return
|
|
85203
|
+
var getAbsolutePath = (path47, cwd) => {
|
|
85204
|
+
if (sysPath2.isAbsolute(path47)) {
|
|
85205
|
+
return path47;
|
|
85139
85206
|
}
|
|
85140
|
-
return sysPath2.join(cwd,
|
|
85207
|
+
return sysPath2.join(cwd, path47);
|
|
85141
85208
|
};
|
|
85142
85209
|
var EMPTY_SET = Object.freeze(new Set);
|
|
85143
85210
|
|
|
@@ -85194,10 +85261,10 @@ var STAT_METHOD_F = "stat";
|
|
|
85194
85261
|
var STAT_METHOD_L = "lstat";
|
|
85195
85262
|
|
|
85196
85263
|
class WatchHelper {
|
|
85197
|
-
constructor(
|
|
85264
|
+
constructor(path47, follow, fsw) {
|
|
85198
85265
|
this.fsw = fsw;
|
|
85199
|
-
const watchPath =
|
|
85200
|
-
this.path =
|
|
85266
|
+
const watchPath = path47;
|
|
85267
|
+
this.path = path47 = path47.replace(REPLACER_RE, "");
|
|
85201
85268
|
this.watchPath = watchPath;
|
|
85202
85269
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
85203
85270
|
this.dirParts = [];
|
|
@@ -85310,20 +85377,20 @@ class FSWatcher extends EventEmitter {
|
|
|
85310
85377
|
this._closePromise = undefined;
|
|
85311
85378
|
let paths = unifyPaths(paths_);
|
|
85312
85379
|
if (cwd) {
|
|
85313
|
-
paths = paths.map((
|
|
85314
|
-
const absPath = getAbsolutePath(
|
|
85380
|
+
paths = paths.map((path47) => {
|
|
85381
|
+
const absPath = getAbsolutePath(path47, cwd);
|
|
85315
85382
|
return absPath;
|
|
85316
85383
|
});
|
|
85317
85384
|
}
|
|
85318
|
-
paths.forEach((
|
|
85319
|
-
this._removeIgnoredPath(
|
|
85385
|
+
paths.forEach((path47) => {
|
|
85386
|
+
this._removeIgnoredPath(path47);
|
|
85320
85387
|
});
|
|
85321
85388
|
this._userIgnored = undefined;
|
|
85322
85389
|
if (!this._readyCount)
|
|
85323
85390
|
this._readyCount = 0;
|
|
85324
85391
|
this._readyCount += paths.length;
|
|
85325
|
-
Promise.all(paths.map(async (
|
|
85326
|
-
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);
|
|
85327
85394
|
if (res)
|
|
85328
85395
|
this._emitReady();
|
|
85329
85396
|
return res;
|
|
@@ -85342,17 +85409,17 @@ class FSWatcher extends EventEmitter {
|
|
|
85342
85409
|
return this;
|
|
85343
85410
|
const paths = unifyPaths(paths_);
|
|
85344
85411
|
const { cwd } = this.options;
|
|
85345
|
-
paths.forEach((
|
|
85346
|
-
if (!sysPath2.isAbsolute(
|
|
85412
|
+
paths.forEach((path47) => {
|
|
85413
|
+
if (!sysPath2.isAbsolute(path47) && !this._closers.has(path47)) {
|
|
85347
85414
|
if (cwd)
|
|
85348
|
-
|
|
85349
|
-
|
|
85415
|
+
path47 = sysPath2.join(cwd, path47);
|
|
85416
|
+
path47 = sysPath2.resolve(path47);
|
|
85350
85417
|
}
|
|
85351
|
-
this._closePath(
|
|
85352
|
-
this._addIgnoredPath(
|
|
85353
|
-
if (this._watched.has(
|
|
85418
|
+
this._closePath(path47);
|
|
85419
|
+
this._addIgnoredPath(path47);
|
|
85420
|
+
if (this._watched.has(path47)) {
|
|
85354
85421
|
this._addIgnoredPath({
|
|
85355
|
-
path:
|
|
85422
|
+
path: path47,
|
|
85356
85423
|
recursive: true
|
|
85357
85424
|
});
|
|
85358
85425
|
}
|
|
@@ -85401,38 +85468,38 @@ class FSWatcher extends EventEmitter {
|
|
|
85401
85468
|
if (event !== EVENTS.ERROR)
|
|
85402
85469
|
this.emit(EVENTS.ALL, ...args);
|
|
85403
85470
|
}
|
|
85404
|
-
async _emit(event,
|
|
85471
|
+
async _emit(event, path47, stats) {
|
|
85405
85472
|
if (this.closed)
|
|
85406
85473
|
return;
|
|
85407
85474
|
const opts = this.options;
|
|
85408
85475
|
if (isWindows)
|
|
85409
|
-
|
|
85476
|
+
path47 = sysPath2.normalize(path47);
|
|
85410
85477
|
if (opts.cwd)
|
|
85411
|
-
|
|
85412
|
-
const args = [event,
|
|
85478
|
+
path47 = sysPath2.relative(opts.cwd, path47);
|
|
85479
|
+
const args = [event, path47];
|
|
85413
85480
|
if (stats != null)
|
|
85414
85481
|
args.push(stats);
|
|
85415
85482
|
const awf = opts.awaitWriteFinish;
|
|
85416
85483
|
let pw;
|
|
85417
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
85484
|
+
if (awf && (pw = this._pendingWrites.get(path47))) {
|
|
85418
85485
|
pw.lastChange = new Date;
|
|
85419
85486
|
return this;
|
|
85420
85487
|
}
|
|
85421
85488
|
if (opts.atomic) {
|
|
85422
85489
|
if (event === EVENTS.UNLINK) {
|
|
85423
|
-
this._pendingUnlinks.set(
|
|
85490
|
+
this._pendingUnlinks.set(path47, args);
|
|
85424
85491
|
setTimeout(() => {
|
|
85425
|
-
this._pendingUnlinks.forEach((entry,
|
|
85492
|
+
this._pendingUnlinks.forEach((entry, path48) => {
|
|
85426
85493
|
this.emit(...entry);
|
|
85427
85494
|
this.emit(EVENTS.ALL, ...entry);
|
|
85428
|
-
this._pendingUnlinks.delete(
|
|
85495
|
+
this._pendingUnlinks.delete(path48);
|
|
85429
85496
|
});
|
|
85430
85497
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
85431
85498
|
return this;
|
|
85432
85499
|
}
|
|
85433
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
85500
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path47)) {
|
|
85434
85501
|
event = args[0] = EVENTS.CHANGE;
|
|
85435
|
-
this._pendingUnlinks.delete(
|
|
85502
|
+
this._pendingUnlinks.delete(path47);
|
|
85436
85503
|
}
|
|
85437
85504
|
}
|
|
85438
85505
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -85450,16 +85517,16 @@ class FSWatcher extends EventEmitter {
|
|
|
85450
85517
|
this.emitWithAll(event, args);
|
|
85451
85518
|
}
|
|
85452
85519
|
};
|
|
85453
|
-
this._awaitWriteFinish(
|
|
85520
|
+
this._awaitWriteFinish(path47, awf.stabilityThreshold, event, awfEmit);
|
|
85454
85521
|
return this;
|
|
85455
85522
|
}
|
|
85456
85523
|
if (event === EVENTS.CHANGE) {
|
|
85457
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
85524
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path47, 50);
|
|
85458
85525
|
if (isThrottled)
|
|
85459
85526
|
return this;
|
|
85460
85527
|
}
|
|
85461
85528
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
85462
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
85529
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path47) : path47;
|
|
85463
85530
|
let stats2;
|
|
85464
85531
|
try {
|
|
85465
85532
|
stats2 = await stat3(fullPath);
|
|
@@ -85478,23 +85545,23 @@ class FSWatcher extends EventEmitter {
|
|
|
85478
85545
|
}
|
|
85479
85546
|
return error || this.closed;
|
|
85480
85547
|
}
|
|
85481
|
-
_throttle(actionType,
|
|
85548
|
+
_throttle(actionType, path47, timeout2) {
|
|
85482
85549
|
if (!this._throttled.has(actionType)) {
|
|
85483
85550
|
this._throttled.set(actionType, new Map);
|
|
85484
85551
|
}
|
|
85485
85552
|
const action = this._throttled.get(actionType);
|
|
85486
85553
|
if (!action)
|
|
85487
85554
|
throw new Error("invalid throttle");
|
|
85488
|
-
const actionPath = action.get(
|
|
85555
|
+
const actionPath = action.get(path47);
|
|
85489
85556
|
if (actionPath) {
|
|
85490
85557
|
actionPath.count++;
|
|
85491
85558
|
return false;
|
|
85492
85559
|
}
|
|
85493
85560
|
let timeoutObject;
|
|
85494
85561
|
const clear = () => {
|
|
85495
|
-
const item = action.get(
|
|
85562
|
+
const item = action.get(path47);
|
|
85496
85563
|
const count = item ? item.count : 0;
|
|
85497
|
-
action.delete(
|
|
85564
|
+
action.delete(path47);
|
|
85498
85565
|
clearTimeout(timeoutObject);
|
|
85499
85566
|
if (item)
|
|
85500
85567
|
clearTimeout(item.timeoutObject);
|
|
@@ -85502,50 +85569,50 @@ class FSWatcher extends EventEmitter {
|
|
|
85502
85569
|
};
|
|
85503
85570
|
timeoutObject = setTimeout(clear, timeout2);
|
|
85504
85571
|
const thr = { timeoutObject, clear, count: 0 };
|
|
85505
|
-
action.set(
|
|
85572
|
+
action.set(path47, thr);
|
|
85506
85573
|
return thr;
|
|
85507
85574
|
}
|
|
85508
85575
|
_incrReadyCount() {
|
|
85509
85576
|
return this._readyCount++;
|
|
85510
85577
|
}
|
|
85511
|
-
_awaitWriteFinish(
|
|
85578
|
+
_awaitWriteFinish(path47, threshold, event, awfEmit) {
|
|
85512
85579
|
const awf = this.options.awaitWriteFinish;
|
|
85513
85580
|
if (typeof awf !== "object")
|
|
85514
85581
|
return;
|
|
85515
85582
|
const pollInterval = awf.pollInterval;
|
|
85516
85583
|
let timeoutHandler;
|
|
85517
|
-
let fullPath =
|
|
85518
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
85519
|
-
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);
|
|
85520
85587
|
}
|
|
85521
85588
|
const now = new Date;
|
|
85522
85589
|
const writes = this._pendingWrites;
|
|
85523
85590
|
function awaitWriteFinishFn(prevStat) {
|
|
85524
85591
|
statcb(fullPath, (err, curStat) => {
|
|
85525
|
-
if (err || !writes.has(
|
|
85592
|
+
if (err || !writes.has(path47)) {
|
|
85526
85593
|
if (err && err.code !== "ENOENT")
|
|
85527
85594
|
awfEmit(err);
|
|
85528
85595
|
return;
|
|
85529
85596
|
}
|
|
85530
85597
|
const now2 = Number(new Date);
|
|
85531
85598
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
85532
|
-
writes.get(
|
|
85599
|
+
writes.get(path47).lastChange = now2;
|
|
85533
85600
|
}
|
|
85534
|
-
const pw = writes.get(
|
|
85601
|
+
const pw = writes.get(path47);
|
|
85535
85602
|
const df = now2 - pw.lastChange;
|
|
85536
85603
|
if (df >= threshold) {
|
|
85537
|
-
writes.delete(
|
|
85604
|
+
writes.delete(path47);
|
|
85538
85605
|
awfEmit(undefined, curStat);
|
|
85539
85606
|
} else {
|
|
85540
85607
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
85541
85608
|
}
|
|
85542
85609
|
});
|
|
85543
85610
|
}
|
|
85544
|
-
if (!writes.has(
|
|
85545
|
-
writes.set(
|
|
85611
|
+
if (!writes.has(path47)) {
|
|
85612
|
+
writes.set(path47, {
|
|
85546
85613
|
lastChange: now,
|
|
85547
85614
|
cancelWait: () => {
|
|
85548
|
-
writes.delete(
|
|
85615
|
+
writes.delete(path47);
|
|
85549
85616
|
clearTimeout(timeoutHandler);
|
|
85550
85617
|
return event;
|
|
85551
85618
|
}
|
|
@@ -85553,8 +85620,8 @@ class FSWatcher extends EventEmitter {
|
|
|
85553
85620
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
85554
85621
|
}
|
|
85555
85622
|
}
|
|
85556
|
-
_isIgnored(
|
|
85557
|
-
if (this.options.atomic && DOT_RE.test(
|
|
85623
|
+
_isIgnored(path47, stats) {
|
|
85624
|
+
if (this.options.atomic && DOT_RE.test(path47))
|
|
85558
85625
|
return true;
|
|
85559
85626
|
if (!this._userIgnored) {
|
|
85560
85627
|
const { cwd } = this.options;
|
|
@@ -85564,13 +85631,13 @@ class FSWatcher extends EventEmitter {
|
|
|
85564
85631
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
85565
85632
|
this._userIgnored = anymatch(list, undefined);
|
|
85566
85633
|
}
|
|
85567
|
-
return this._userIgnored(
|
|
85634
|
+
return this._userIgnored(path47, stats);
|
|
85568
85635
|
}
|
|
85569
|
-
_isntIgnored(
|
|
85570
|
-
return !this._isIgnored(
|
|
85636
|
+
_isntIgnored(path47, stat4) {
|
|
85637
|
+
return !this._isIgnored(path47, stat4);
|
|
85571
85638
|
}
|
|
85572
|
-
_getWatchHelpers(
|
|
85573
|
-
return new WatchHelper(
|
|
85639
|
+
_getWatchHelpers(path47) {
|
|
85640
|
+
return new WatchHelper(path47, this.options.followSymlinks, this);
|
|
85574
85641
|
}
|
|
85575
85642
|
_getWatchedDir(directory) {
|
|
85576
85643
|
const dir = sysPath2.resolve(directory);
|
|
@@ -85584,57 +85651,57 @@ class FSWatcher extends EventEmitter {
|
|
|
85584
85651
|
return Boolean(Number(stats.mode) & 256);
|
|
85585
85652
|
}
|
|
85586
85653
|
_remove(directory, item, isDirectory2) {
|
|
85587
|
-
const
|
|
85588
|
-
const fullPath = sysPath2.resolve(
|
|
85589
|
-
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(
|
|
85590
|
-
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))
|
|
85591
85658
|
return;
|
|
85592
85659
|
if (!isDirectory2 && this._watched.size === 1) {
|
|
85593
85660
|
this.add(directory, item, true);
|
|
85594
85661
|
}
|
|
85595
|
-
const wp = this._getWatchedDir(
|
|
85662
|
+
const wp = this._getWatchedDir(path47);
|
|
85596
85663
|
const nestedDirectoryChildren = wp.getChildren();
|
|
85597
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
85664
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path47, nested));
|
|
85598
85665
|
const parent = this._getWatchedDir(directory);
|
|
85599
85666
|
const wasTracked = parent.has(item);
|
|
85600
85667
|
parent.remove(item);
|
|
85601
85668
|
if (this._symlinkPaths.has(fullPath)) {
|
|
85602
85669
|
this._symlinkPaths.delete(fullPath);
|
|
85603
85670
|
}
|
|
85604
|
-
let relPath =
|
|
85671
|
+
let relPath = path47;
|
|
85605
85672
|
if (this.options.cwd)
|
|
85606
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
85673
|
+
relPath = sysPath2.relative(this.options.cwd, path47);
|
|
85607
85674
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
85608
85675
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
85609
85676
|
if (event === EVENTS.ADD)
|
|
85610
85677
|
return;
|
|
85611
85678
|
}
|
|
85612
|
-
this._watched.delete(
|
|
85679
|
+
this._watched.delete(path47);
|
|
85613
85680
|
this._watched.delete(fullPath);
|
|
85614
85681
|
const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
85615
|
-
if (wasTracked && !this._isIgnored(
|
|
85616
|
-
this._emit(eventName,
|
|
85617
|
-
this._closePath(
|
|
85682
|
+
if (wasTracked && !this._isIgnored(path47))
|
|
85683
|
+
this._emit(eventName, path47);
|
|
85684
|
+
this._closePath(path47);
|
|
85618
85685
|
}
|
|
85619
|
-
_closePath(
|
|
85620
|
-
this._closeFile(
|
|
85621
|
-
const dir = sysPath2.dirname(
|
|
85622
|
-
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));
|
|
85623
85690
|
}
|
|
85624
|
-
_closeFile(
|
|
85625
|
-
const closers = this._closers.get(
|
|
85691
|
+
_closeFile(path47) {
|
|
85692
|
+
const closers = this._closers.get(path47);
|
|
85626
85693
|
if (!closers)
|
|
85627
85694
|
return;
|
|
85628
85695
|
closers.forEach((closer) => closer());
|
|
85629
|
-
this._closers.delete(
|
|
85696
|
+
this._closers.delete(path47);
|
|
85630
85697
|
}
|
|
85631
|
-
_addPathCloser(
|
|
85698
|
+
_addPathCloser(path47, closer) {
|
|
85632
85699
|
if (!closer)
|
|
85633
85700
|
return;
|
|
85634
|
-
let list = this._closers.get(
|
|
85701
|
+
let list = this._closers.get(path47);
|
|
85635
85702
|
if (!list) {
|
|
85636
85703
|
list = [];
|
|
85637
|
-
this._closers.set(
|
|
85704
|
+
this._closers.set(path47, list);
|
|
85638
85705
|
}
|
|
85639
85706
|
list.push(closer);
|
|
85640
85707
|
}
|
|
@@ -85667,16 +85734,16 @@ import Debug3 from "debug";
|
|
|
85667
85734
|
|
|
85668
85735
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
85669
85736
|
import * as ts from "typescript";
|
|
85670
|
-
import * as
|
|
85671
|
-
import * as
|
|
85737
|
+
import * as path47 from "path";
|
|
85738
|
+
import * as fs44 from "fs";
|
|
85672
85739
|
function getAllDependencyPackages(projectDir) {
|
|
85673
|
-
const packageJsonPath =
|
|
85740
|
+
const packageJsonPath = path47.join(projectDir, "package.json");
|
|
85674
85741
|
const allPackages = new Set;
|
|
85675
|
-
if (!
|
|
85742
|
+
if (!fs44.existsSync(packageJsonPath)) {
|
|
85676
85743
|
return allPackages;
|
|
85677
85744
|
}
|
|
85678
85745
|
try {
|
|
85679
|
-
const packageJson = JSON.parse(
|
|
85746
|
+
const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
|
|
85680
85747
|
const deps = packageJson.dependencies || {};
|
|
85681
85748
|
const devDeps = packageJson.devDependencies || {};
|
|
85682
85749
|
for (const packageName of Object.keys(deps)) {
|
|
@@ -85691,11 +85758,11 @@ function getAllDependencyPackages(projectDir) {
|
|
|
85691
85758
|
return allPackages;
|
|
85692
85759
|
}
|
|
85693
85760
|
function getNodeModuleImports(filePath) {
|
|
85694
|
-
const absolutePath =
|
|
85695
|
-
if (!
|
|
85761
|
+
const absolutePath = path47.resolve(filePath);
|
|
85762
|
+
if (!fs44.existsSync(absolutePath)) {
|
|
85696
85763
|
return [];
|
|
85697
85764
|
}
|
|
85698
|
-
const content =
|
|
85765
|
+
const content = fs44.readFileSync(absolutePath, "utf-8");
|
|
85699
85766
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
85700
85767
|
const imports = new Set;
|
|
85701
85768
|
function visit(node) {
|
|
@@ -85745,17 +85812,17 @@ function resolveNodeModuleImport({
|
|
|
85745
85812
|
}) {
|
|
85746
85813
|
const packageName = getPackageNameFromImport(importPath);
|
|
85747
85814
|
const searchPaths = [
|
|
85748
|
-
|
|
85815
|
+
path47.join(projectDir, "node_modules", packageName)
|
|
85749
85816
|
];
|
|
85750
85817
|
if (searchFromDir) {
|
|
85751
|
-
let currentDir =
|
|
85752
|
-
const projectDirNormalized =
|
|
85818
|
+
let currentDir = path47.dirname(searchFromDir);
|
|
85819
|
+
const projectDirNormalized = path47.normalize(projectDir);
|
|
85753
85820
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
85754
|
-
const candidatePath =
|
|
85821
|
+
const candidatePath = path47.join(currentDir, "node_modules", packageName);
|
|
85755
85822
|
if (!searchPaths.includes(candidatePath)) {
|
|
85756
85823
|
searchPaths.push(candidatePath);
|
|
85757
85824
|
}
|
|
85758
|
-
const parentDir =
|
|
85825
|
+
const parentDir = path47.dirname(currentDir);
|
|
85759
85826
|
if (parentDir === currentDir)
|
|
85760
85827
|
break;
|
|
85761
85828
|
currentDir = parentDir;
|
|
@@ -85763,7 +85830,7 @@ function resolveNodeModuleImport({
|
|
|
85763
85830
|
}
|
|
85764
85831
|
let packageDir;
|
|
85765
85832
|
for (const candidatePath of searchPaths) {
|
|
85766
|
-
if (
|
|
85833
|
+
if (fs44.existsSync(candidatePath)) {
|
|
85767
85834
|
packageDir = candidatePath;
|
|
85768
85835
|
break;
|
|
85769
85836
|
}
|
|
@@ -85771,25 +85838,25 @@ function resolveNodeModuleImport({
|
|
|
85771
85838
|
if (!packageDir) {
|
|
85772
85839
|
return [];
|
|
85773
85840
|
}
|
|
85774
|
-
const packageJsonPath =
|
|
85775
|
-
const hasPackageJson =
|
|
85776
|
-
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;
|
|
85777
85844
|
const resolvedFiles = [];
|
|
85778
85845
|
if (importPath !== packageName) {
|
|
85779
85846
|
const subpath = importPath.slice(packageName.length + 1);
|
|
85780
85847
|
const possiblePaths = [
|
|
85781
|
-
|
|
85782
|
-
|
|
85783
|
-
|
|
85784
|
-
|
|
85785
|
-
|
|
85786
|
-
|
|
85787
|
-
|
|
85788
|
-
|
|
85789
|
-
|
|
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")
|
|
85790
85857
|
];
|
|
85791
85858
|
for (const p of possiblePaths) {
|
|
85792
|
-
if (
|
|
85859
|
+
if (fs44.existsSync(p) && fs44.statSync(p).isFile()) {
|
|
85793
85860
|
resolvedFiles.push(p);
|
|
85794
85861
|
break;
|
|
85795
85862
|
}
|
|
@@ -85821,25 +85888,25 @@ function resolveNodeModuleImport({
|
|
|
85821
85888
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
85822
85889
|
].filter((entry) => typeof entry === "string");
|
|
85823
85890
|
for (const entry of entryPoints) {
|
|
85824
|
-
const entryPath =
|
|
85825
|
-
if (
|
|
85891
|
+
const entryPath = path47.join(packageDir, entry);
|
|
85892
|
+
if (fs44.existsSync(entryPath) && fs44.statSync(entryPath).isFile()) {
|
|
85826
85893
|
resolvedFiles.push(entryPath);
|
|
85827
85894
|
}
|
|
85828
85895
|
}
|
|
85829
85896
|
if (resolvedFiles.length === 0) {
|
|
85830
85897
|
const fallbackPaths = [
|
|
85831
|
-
|
|
85832
|
-
|
|
85833
|
-
|
|
85834
|
-
|
|
85835
|
-
|
|
85836
|
-
|
|
85837
|
-
|
|
85838
|
-
|
|
85839
|
-
|
|
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")
|
|
85840
85907
|
];
|
|
85841
85908
|
for (const p of fallbackPaths) {
|
|
85842
|
-
if (
|
|
85909
|
+
if (fs44.existsSync(p) && fs44.statSync(p).isFile()) {
|
|
85843
85910
|
resolvedFiles.push(p);
|
|
85844
85911
|
break;
|
|
85845
85912
|
}
|
|
@@ -85877,12 +85944,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85877
85944
|
}
|
|
85878
85945
|
}
|
|
85879
85946
|
function getLocalDependencies(filePath) {
|
|
85880
|
-
const absolutePath =
|
|
85881
|
-
const baseDir =
|
|
85882
|
-
if (!
|
|
85947
|
+
const absolutePath = path47.resolve(filePath);
|
|
85948
|
+
const baseDir = path47.dirname(absolutePath);
|
|
85949
|
+
if (!fs44.existsSync(absolutePath)) {
|
|
85883
85950
|
return [];
|
|
85884
85951
|
}
|
|
85885
|
-
const content =
|
|
85952
|
+
const content = fs44.readFileSync(absolutePath, "utf-8");
|
|
85886
85953
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
85887
85954
|
const dependencies = [];
|
|
85888
85955
|
function visit(node) {
|
|
@@ -85904,20 +85971,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
85904
85971
|
}
|
|
85905
85972
|
function resolveLocalImport(importPath, baseDir) {
|
|
85906
85973
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
85907
|
-
const resolvedPath =
|
|
85908
|
-
if (
|
|
85974
|
+
const resolvedPath = path47.resolve(baseDir, importPath);
|
|
85975
|
+
if (fs44.existsSync(resolvedPath) && fs44.statSync(resolvedPath).isFile()) {
|
|
85909
85976
|
return resolvedPath;
|
|
85910
85977
|
}
|
|
85911
85978
|
for (const ext of extensions) {
|
|
85912
85979
|
const pathWithExt = resolvedPath + ext;
|
|
85913
|
-
if (
|
|
85980
|
+
if (fs44.existsSync(pathWithExt)) {
|
|
85914
85981
|
return pathWithExt;
|
|
85915
85982
|
}
|
|
85916
85983
|
}
|
|
85917
|
-
if (
|
|
85984
|
+
if (fs44.existsSync(resolvedPath) && fs44.statSync(resolvedPath).isDirectory()) {
|
|
85918
85985
|
for (const ext of extensions) {
|
|
85919
|
-
const indexPath =
|
|
85920
|
-
if (
|
|
85986
|
+
const indexPath = path47.join(resolvedPath, `index${ext}`);
|
|
85987
|
+
if (fs44.existsSync(indexPath)) {
|
|
85921
85988
|
return indexPath;
|
|
85922
85989
|
}
|
|
85923
85990
|
}
|
|
@@ -85942,12 +86009,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
85942
86009
|
function collectLocalPackageFiles(packageDir) {
|
|
85943
86010
|
const buildDirs = ["dist", "build"];
|
|
85944
86011
|
for (const dirName of buildDirs) {
|
|
85945
|
-
const dirPath =
|
|
85946
|
-
if (
|
|
86012
|
+
const dirPath = path47.join(packageDir, dirName);
|
|
86013
|
+
if (fs44.existsSync(dirPath)) {
|
|
85947
86014
|
const files = walkDirectory(dirPath, new Set);
|
|
85948
86015
|
if (files.length > 0) {
|
|
85949
|
-
const packageJsonPath =
|
|
85950
|
-
if (
|
|
86016
|
+
const packageJsonPath = path47.join(packageDir, "package.json");
|
|
86017
|
+
if (fs44.existsSync(packageJsonPath)) {
|
|
85951
86018
|
files.push(packageJsonPath);
|
|
85952
86019
|
}
|
|
85953
86020
|
return files;
|
|
@@ -85958,11 +86025,11 @@ function collectLocalPackageFiles(packageDir) {
|
|
|
85958
86025
|
}
|
|
85959
86026
|
function walkDirectory(dir, excludedDirs) {
|
|
85960
86027
|
const files = [];
|
|
85961
|
-
if (!
|
|
86028
|
+
if (!fs44.existsSync(dir))
|
|
85962
86029
|
return files;
|
|
85963
|
-
const entries =
|
|
86030
|
+
const entries = fs44.readdirSync(dir, { withFileTypes: true });
|
|
85964
86031
|
for (const entry of entries) {
|
|
85965
|
-
const fullPath =
|
|
86032
|
+
const fullPath = path47.join(dir, entry.name);
|
|
85966
86033
|
if (entry.isDirectory()) {
|
|
85967
86034
|
if (excludedDirs.has(entry.name)) {
|
|
85968
86035
|
continue;
|
|
@@ -86023,13 +86090,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
86023
86090
|
processedPackages.add(packageName);
|
|
86024
86091
|
if (resolvedFiles.length > 0) {
|
|
86025
86092
|
const firstResolvedFile = resolvedFiles[0];
|
|
86026
|
-
let packageDir =
|
|
86093
|
+
let packageDir = path47.dirname(firstResolvedFile);
|
|
86027
86094
|
let hasPackageJson = false;
|
|
86028
86095
|
while (packageDir.includes("node_modules")) {
|
|
86029
|
-
const packageJsonPath =
|
|
86030
|
-
if (
|
|
86096
|
+
const packageJsonPath = path47.join(packageDir, "package.json");
|
|
86097
|
+
if (fs44.existsSync(packageJsonPath)) {
|
|
86031
86098
|
try {
|
|
86032
|
-
const pkgJson = JSON.parse(
|
|
86099
|
+
const pkgJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
|
|
86033
86100
|
if (pkgJson.name === packageName) {
|
|
86034
86101
|
hasPackageJson = true;
|
|
86035
86102
|
break;
|
|
@@ -86037,15 +86104,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
86037
86104
|
} catch {}
|
|
86038
86105
|
}
|
|
86039
86106
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
86040
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
86107
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path47.sep))) {
|
|
86041
86108
|
break;
|
|
86042
86109
|
}
|
|
86043
|
-
const parentDir =
|
|
86110
|
+
const parentDir = path47.dirname(packageDir);
|
|
86044
86111
|
if (parentDir === packageDir)
|
|
86045
86112
|
break;
|
|
86046
86113
|
packageDir = parentDir;
|
|
86047
86114
|
}
|
|
86048
|
-
if (
|
|
86115
|
+
if (fs44.existsSync(packageDir)) {
|
|
86049
86116
|
if (hasPackageJson) {
|
|
86050
86117
|
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
86051
86118
|
packageFiles.forEach((file) => allFiles.add(file));
|
|
@@ -86111,7 +86178,7 @@ class EventsWatcher extends EventEmitter2 {
|
|
|
86111
86178
|
}
|
|
86112
86179
|
|
|
86113
86180
|
// lib/server/createHttpServer.ts
|
|
86114
|
-
import * as
|
|
86181
|
+
import * as fs46 from "node:fs";
|
|
86115
86182
|
import * as http from "node:http";
|
|
86116
86183
|
|
|
86117
86184
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
@@ -86814,10 +86881,10 @@ var databaseSchema = z5.object({
|
|
|
86814
86881
|
files: z5.array(fileSchema).default([]),
|
|
86815
86882
|
events: z5.array(eventSchema).default([])
|
|
86816
86883
|
});
|
|
86817
|
-
function normalizePath2(
|
|
86818
|
-
if (!
|
|
86884
|
+
function normalizePath2(path48) {
|
|
86885
|
+
if (!path48 || path48 === "/")
|
|
86819
86886
|
return "";
|
|
86820
|
-
let normalized =
|
|
86887
|
+
let normalized = path48.replace(/\\+/g, "/").replace(/\/\/+/, "/");
|
|
86821
86888
|
if (normalized.startsWith("/")) {
|
|
86822
86889
|
normalized = normalized.slice(1);
|
|
86823
86890
|
}
|
|
@@ -87674,14 +87741,14 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
87674
87741
|
};
|
|
87675
87742
|
|
|
87676
87743
|
// lib/server/kicad-pcm-proxy.ts
|
|
87677
|
-
import * as
|
|
87678
|
-
import * as
|
|
87744
|
+
import * as fs45 from "node:fs";
|
|
87745
|
+
import * as path48 from "node:path";
|
|
87679
87746
|
var getSourceFilesChecksum = (projectDir) => {
|
|
87680
87747
|
const sourceFiles = globbySync(["**/*.tsx", "**/*.ts", "**/*.json", "!node_modules/**", "!dist/**"], { cwd: projectDir });
|
|
87681
87748
|
let checksum = "";
|
|
87682
87749
|
for (const file of sourceFiles) {
|
|
87683
87750
|
try {
|
|
87684
|
-
const stat4 =
|
|
87751
|
+
const stat4 = fs45.statSync(path48.join(projectDir, file));
|
|
87685
87752
|
checksum += `${file}:${stat4.mtimeMs};`;
|
|
87686
87753
|
} catch {}
|
|
87687
87754
|
}
|
|
@@ -87701,9 +87768,9 @@ var createKicadPcmProxy = ({
|
|
|
87701
87768
|
};
|
|
87702
87769
|
const handleRequest = async (url, res) => {
|
|
87703
87770
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
87704
|
-
const distDir =
|
|
87705
|
-
const pcmDir =
|
|
87706
|
-
const filePath =
|
|
87771
|
+
const distDir = path48.join(projectDir, "dist");
|
|
87772
|
+
const pcmDir = path48.join(distDir, "pcm");
|
|
87773
|
+
const filePath = path48.join(pcmDir, requestedFile);
|
|
87707
87774
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
87708
87775
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
87709
87776
|
if (needsRebuild) {
|
|
@@ -87748,12 +87815,12 @@ Rebuilding KiCad PCM assets...`));
|
|
|
87748
87815
|
}
|
|
87749
87816
|
}
|
|
87750
87817
|
}
|
|
87751
|
-
if (!
|
|
87818
|
+
if (!fs45.existsSync(filePath)) {
|
|
87752
87819
|
res.writeHead(404);
|
|
87753
87820
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
87754
87821
|
return;
|
|
87755
87822
|
}
|
|
87756
|
-
const ext =
|
|
87823
|
+
const ext = path48.extname(filePath).toLowerCase();
|
|
87757
87824
|
let contentType = "application/octet-stream";
|
|
87758
87825
|
if (ext === ".json") {
|
|
87759
87826
|
contentType = "application/json";
|
|
@@ -87761,7 +87828,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
87761
87828
|
contentType = "application/zip";
|
|
87762
87829
|
}
|
|
87763
87830
|
try {
|
|
87764
|
-
const content =
|
|
87831
|
+
const content = fs45.readFileSync(filePath);
|
|
87765
87832
|
res.writeHead(200, { "Content-Type": contentType });
|
|
87766
87833
|
res.end(content);
|
|
87767
87834
|
} catch (error) {
|
|
@@ -87841,7 +87908,7 @@ var createHttpServer = async ({
|
|
|
87841
87908
|
return;
|
|
87842
87909
|
}
|
|
87843
87910
|
try {
|
|
87844
|
-
const content =
|
|
87911
|
+
const content = fs46.readFileSync(standaloneFilePath, "utf8");
|
|
87845
87912
|
res.writeHead(200, {
|
|
87846
87913
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
87847
87914
|
});
|
|
@@ -87884,8 +87951,8 @@ var createHttpServer = async ({
|
|
|
87884
87951
|
|
|
87885
87952
|
// lib/shared/push-snippet.ts
|
|
87886
87953
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
87887
|
-
import * as
|
|
87888
|
-
import * as
|
|
87954
|
+
import * as fs47 from "node:fs";
|
|
87955
|
+
import * as path51 from "node:path";
|
|
87889
87956
|
import Debug2 from "debug";
|
|
87890
87957
|
|
|
87891
87958
|
// lib/utils/validate-package-name.ts
|
|
@@ -87903,7 +87970,7 @@ var validatePackageName = (name) => {
|
|
|
87903
87970
|
};
|
|
87904
87971
|
|
|
87905
87972
|
// cli/dev/get-package-file-paths.ts
|
|
87906
|
-
import * as
|
|
87973
|
+
import * as path49 from "node:path";
|
|
87907
87974
|
var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
87908
87975
|
const ignorePatterns = [
|
|
87909
87976
|
...DEFAULT_IGNORED_PATTERNS,
|
|
@@ -87914,7 +87981,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
87914
87981
|
ignore: ignorePatterns
|
|
87915
87982
|
});
|
|
87916
87983
|
fileNames.sort();
|
|
87917
|
-
return fileNames.map((fileName) =>
|
|
87984
|
+
return fileNames.map((fileName) => path49.join(projectDir, fileName));
|
|
87918
87985
|
};
|
|
87919
87986
|
|
|
87920
87987
|
// lib/utils/check-org-access.ts
|
|
@@ -87930,7 +87997,7 @@ var checkOrgAccess = async (ky2, orgTscircuitHandle) => {
|
|
|
87930
87997
|
};
|
|
87931
87998
|
|
|
87932
87999
|
// lib/shared/is-binary-file.ts
|
|
87933
|
-
import * as
|
|
88000
|
+
import * as path50 from "node:path";
|
|
87934
88001
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
87935
88002
|
".glb",
|
|
87936
88003
|
".gltf",
|
|
@@ -87946,7 +88013,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
87946
88013
|
".tar"
|
|
87947
88014
|
]);
|
|
87948
88015
|
var isBinaryFile = (filePath) => {
|
|
87949
|
-
const ext =
|
|
88016
|
+
const ext = path50.extname(filePath).toLowerCase();
|
|
87950
88017
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
87951
88018
|
};
|
|
87952
88019
|
|
|
@@ -87972,8 +88039,8 @@ var debug2 = Debug2("tsci:push-snippet");
|
|
|
87972
88039
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
87973
88040
|
const zip = new import_jszip3.default;
|
|
87974
88041
|
for (const fullFilePath of filePaths) {
|
|
87975
|
-
const relativeFilePath =
|
|
87976
|
-
zip.file(relativeFilePath,
|
|
88042
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88043
|
+
zip.file(relativeFilePath, fs47.readFileSync(fullFilePath));
|
|
87977
88044
|
}
|
|
87978
88045
|
const archive = await zip.generateAsync({
|
|
87979
88046
|
type: "uint8array",
|
|
@@ -88011,24 +88078,24 @@ var pushSnippet = async ({
|
|
|
88011
88078
|
return onExit(1);
|
|
88012
88079
|
}
|
|
88013
88080
|
const packageJsonPath = [
|
|
88014
|
-
|
|
88015
|
-
|
|
88016
|
-
].find((
|
|
88017
|
-
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);
|
|
88018
88085
|
if (!packageJsonPath) {
|
|
88019
88086
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
88020
88087
|
return onExit(1);
|
|
88021
88088
|
}
|
|
88022
88089
|
let packageJson = {};
|
|
88023
|
-
if (
|
|
88090
|
+
if (fs47.existsSync(packageJsonPath)) {
|
|
88024
88091
|
try {
|
|
88025
|
-
packageJson = JSON.parse(
|
|
88092
|
+
packageJson = JSON.parse(fs47.readFileSync(packageJsonPath).toString());
|
|
88026
88093
|
} catch {
|
|
88027
88094
|
onError("Invalid package.json");
|
|
88028
88095
|
return onExit(1);
|
|
88029
88096
|
}
|
|
88030
88097
|
}
|
|
88031
|
-
if (!
|
|
88098
|
+
if (!fs47.existsSync(snippetFilePath)) {
|
|
88032
88099
|
onError(`File not found: ${snippetFilePath}`);
|
|
88033
88100
|
return onExit(1);
|
|
88034
88101
|
}
|
|
@@ -88069,7 +88136,7 @@ var pushSnippet = async ({
|
|
|
88069
88136
|
}
|
|
88070
88137
|
unscopedPackageName = inputName;
|
|
88071
88138
|
packageJson.name = `@tsci/${currentUsername}.${unscopedPackageName}`;
|
|
88072
|
-
|
|
88139
|
+
fs47.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88073
88140
|
}
|
|
88074
88141
|
let accountName = currentUsername;
|
|
88075
88142
|
if (packageJsonAuthor && currentUsername !== packageJsonAuthor) {
|
|
@@ -88100,7 +88167,7 @@ var pushSnippet = async ({
|
|
|
88100
88167
|
const updatePackageJsonVersion = (newVersion) => {
|
|
88101
88168
|
try {
|
|
88102
88169
|
packageJson.version = newVersion ?? `${packageVersion}`;
|
|
88103
|
-
|
|
88170
|
+
fs47.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88104
88171
|
} catch (error) {
|
|
88105
88172
|
onError(`Failed to update package.json version: ${error}`);
|
|
88106
88173
|
}
|
|
@@ -88208,7 +88275,7 @@ var pushSnippet = async ({
|
|
|
88208
88275
|
json: archivePayload
|
|
88209
88276
|
});
|
|
88210
88277
|
for (const fullFilePath of filePaths) {
|
|
88211
|
-
const relativeFilePath =
|
|
88278
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88212
88279
|
uploadResults.succeeded.push(relativeFilePath);
|
|
88213
88280
|
}
|
|
88214
88281
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -88218,8 +88285,8 @@ var pushSnippet = async ({
|
|
|
88218
88285
|
}
|
|
88219
88286
|
if (uploadResults.succeeded.length === 0) {
|
|
88220
88287
|
for (const fullFilePath of filePaths) {
|
|
88221
|
-
const relativeFilePath =
|
|
88222
|
-
const fileBuffer =
|
|
88288
|
+
const relativeFilePath = path51.relative(projectDir, fullFilePath);
|
|
88289
|
+
const fileBuffer = fs47.readFileSync(fullFilePath);
|
|
88223
88290
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
88224
88291
|
const payload = {
|
|
88225
88292
|
file_path: relativeFilePath,
|
|
@@ -88308,7 +88375,7 @@ class DevServer {
|
|
|
88308
88375
|
}) {
|
|
88309
88376
|
this.port = port;
|
|
88310
88377
|
this.componentFilePath = componentFilePath;
|
|
88311
|
-
this.projectDir = projectDir ??
|
|
88378
|
+
this.projectDir = projectDir ?? path52.dirname(componentFilePath);
|
|
88312
88379
|
this.kicadPcm = kicadPcm ?? false;
|
|
88313
88380
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
88314
88381
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
@@ -88319,7 +88386,7 @@ class DevServer {
|
|
|
88319
88386
|
async start() {
|
|
88320
88387
|
const { server } = await createHttpServer({
|
|
88321
88388
|
port: this.port,
|
|
88322
|
-
defaultMainComponentPath:
|
|
88389
|
+
defaultMainComponentPath: path52.relative(this.projectDir, this.componentFilePath),
|
|
88323
88390
|
kicadPcm: this.kicadPcm,
|
|
88324
88391
|
projectDir: this.projectDir,
|
|
88325
88392
|
entryFile: this.componentFilePath
|
|
@@ -88335,7 +88402,7 @@ class DevServer {
|
|
|
88335
88402
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
88336
88403
|
persistent: true,
|
|
88337
88404
|
ignoreInitial: true,
|
|
88338
|
-
ignored: (p) => shouldIgnorePath(
|
|
88405
|
+
ignored: (p) => shouldIgnorePath(path52.relative(this.projectDir, p), this.ignoredFiles)
|
|
88339
88406
|
});
|
|
88340
88407
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
88341
88408
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -88350,27 +88417,27 @@ class DevServer {
|
|
|
88350
88417
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
88351
88418
|
searchParams: { file_path: ev.file_path }
|
|
88352
88419
|
}).json();
|
|
88353
|
-
const fullPath =
|
|
88354
|
-
const dirPath =
|
|
88355
|
-
if (!
|
|
88356
|
-
|
|
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 });
|
|
88357
88424
|
}
|
|
88358
88425
|
if (file.binary_content_b64) {
|
|
88359
88426
|
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
88360
|
-
|
|
88427
|
+
fs48.writeFileSync(fullPath, decodedContent);
|
|
88361
88428
|
} else {
|
|
88362
|
-
|
|
88429
|
+
fs48.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
88363
88430
|
}
|
|
88364
88431
|
}
|
|
88365
88432
|
async handleFileDeletedEventFromServer(ev) {
|
|
88366
|
-
const fullPath =
|
|
88367
|
-
if (
|
|
88433
|
+
const fullPath = path52.join(this.projectDir, ev.file_path);
|
|
88434
|
+
if (fs48.existsSync(fullPath)) {
|
|
88368
88435
|
debug3(`Deleting file ${ev.file_path} from filesystem`);
|
|
88369
|
-
|
|
88436
|
+
fs48.unlinkSync(fullPath);
|
|
88370
88437
|
}
|
|
88371
88438
|
}
|
|
88372
88439
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
88373
|
-
const relativeFilePath =
|
|
88440
|
+
const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
|
|
88374
88441
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
88375
88442
|
return;
|
|
88376
88443
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -88385,14 +88452,14 @@ class DevServer {
|
|
|
88385
88452
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
88386
88453
|
}
|
|
88387
88454
|
async checkAndUploadNewNodeModules(filePath) {
|
|
88388
|
-
const ext =
|
|
88455
|
+
const ext = path52.extname(filePath).toLowerCase();
|
|
88389
88456
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
88390
88457
|
if (!isSourceFile)
|
|
88391
88458
|
return;
|
|
88392
88459
|
try {
|
|
88393
88460
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
88394
88461
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
88395
|
-
const relativePath =
|
|
88462
|
+
const relativePath = path52.relative(this.projectDir, file);
|
|
88396
88463
|
return !this.uploadedNodeModules.has(relativePath);
|
|
88397
88464
|
});
|
|
88398
88465
|
if (newFiles.length === 0)
|
|
@@ -88405,7 +88472,7 @@ class DevServer {
|
|
|
88405
88472
|
}
|
|
88406
88473
|
}
|
|
88407
88474
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
88408
|
-
const relativeFilePath =
|
|
88475
|
+
const relativeFilePath = path52.relative(this.projectDir, absoluteFilePath);
|
|
88409
88476
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
88410
88477
|
return;
|
|
88411
88478
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -88443,8 +88510,8 @@ class DevServer {
|
|
|
88443
88510
|
debug3(`Successfully deleted file ${relativeFilePath} from server`);
|
|
88444
88511
|
}
|
|
88445
88512
|
async handleFileRename(oldPath, newPath) {
|
|
88446
|
-
const oldRelativePath =
|
|
88447
|
-
const newRelativePath =
|
|
88513
|
+
const oldRelativePath = path52.relative(this.projectDir, oldPath);
|
|
88514
|
+
const newRelativePath = path52.relative(this.projectDir, newPath);
|
|
88448
88515
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
88449
88516
|
return;
|
|
88450
88517
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -88462,7 +88529,7 @@ class DevServer {
|
|
|
88462
88529
|
});
|
|
88463
88530
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
88464
88531
|
for (const filePath of filePaths) {
|
|
88465
|
-
const relativeFilePath =
|
|
88532
|
+
const relativeFilePath = path52.relative(this.projectDir, filePath);
|
|
88466
88533
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
88467
88534
|
await this.postFileUpsert({
|
|
88468
88535
|
filePath: relativeFilePath,
|
|
@@ -88494,7 +88561,7 @@ class DevServer {
|
|
|
88494
88561
|
}
|
|
88495
88562
|
async uploadNodeModuleFiles(files) {
|
|
88496
88563
|
for (const nodeModuleFile of files) {
|
|
88497
|
-
const relativeFilePath =
|
|
88564
|
+
const relativeFilePath = path52.relative(this.projectDir, nodeModuleFile);
|
|
88498
88565
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
88499
88566
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
88500
88567
|
await this.postFileUpsert({
|
|
@@ -88539,7 +88606,7 @@ class DevServer {
|
|
|
88539
88606
|
formData.set("file_path", filePath);
|
|
88540
88607
|
formData.set("initiator", initiator);
|
|
88541
88608
|
const binaryBytes = Uint8Array.from(binaryContent);
|
|
88542
|
-
formData.set("binary_file", new Blob([binaryBytes]),
|
|
88609
|
+
formData.set("binary_file", new Blob([binaryBytes]), path52.basename(filePath));
|
|
88543
88610
|
const response = await fetch(`http://localhost:${this.port}/api/files/upsert-multipart`, {
|
|
88544
88611
|
method: "POST",
|
|
88545
88612
|
body: formData
|
|
@@ -88579,12 +88646,12 @@ class DevServer {
|
|
|
88579
88646
|
await this.filesystemWatcher?.close();
|
|
88580
88647
|
}
|
|
88581
88648
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
88582
|
-
const ext =
|
|
88649
|
+
const ext = path52.extname(relativeFilePath).toLowerCase();
|
|
88583
88650
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
88584
|
-
const fileBuffer =
|
|
88651
|
+
const fileBuffer = fs48.readFileSync(absoluteFilePath);
|
|
88585
88652
|
return { binary_content: fileBuffer };
|
|
88586
88653
|
}
|
|
88587
|
-
return { text_content:
|
|
88654
|
+
return { text_content: fs48.readFileSync(absoluteFilePath, "utf-8") };
|
|
88588
88655
|
}
|
|
88589
88656
|
async handleInstallPackage(full_package_name) {
|
|
88590
88657
|
const postEvent = async (event, message) => {
|
|
@@ -88614,10 +88681,10 @@ class DevServer {
|
|
|
88614
88681
|
}
|
|
88615
88682
|
|
|
88616
88683
|
// cli/dev/resolve-dev-target.ts
|
|
88617
|
-
import * as
|
|
88618
|
-
import * as
|
|
88684
|
+
import * as fs49 from "node:fs";
|
|
88685
|
+
import * as path53 from "node:path";
|
|
88619
88686
|
var findSelectableFiles = (projectDir) => {
|
|
88620
|
-
const boardFiles = findBoardFiles({ projectDir }).filter((file) =>
|
|
88687
|
+
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs49.existsSync(file)).sort();
|
|
88621
88688
|
if (boardFiles.length > 0) {
|
|
88622
88689
|
return boardFiles;
|
|
88623
88690
|
}
|
|
@@ -88625,7 +88692,7 @@ var findSelectableFiles = (projectDir) => {
|
|
|
88625
88692
|
cwd: projectDir,
|
|
88626
88693
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
88627
88694
|
});
|
|
88628
|
-
return files.map((file) =>
|
|
88695
|
+
return files.map((file) => path53.resolve(projectDir, file)).filter((file) => fs49.existsSync(file)).sort();
|
|
88629
88696
|
};
|
|
88630
88697
|
var isValidDevFile = (filePath) => {
|
|
88631
88698
|
return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
|
|
@@ -88633,18 +88700,18 @@ var isValidDevFile = (filePath) => {
|
|
|
88633
88700
|
var resolveDevTarget = async (file) => {
|
|
88634
88701
|
let projectDir = process.cwd();
|
|
88635
88702
|
if (file) {
|
|
88636
|
-
const resolvedPath =
|
|
88637
|
-
if (
|
|
88703
|
+
const resolvedPath = path53.resolve(file);
|
|
88704
|
+
if (fs49.existsSync(resolvedPath) && fs49.statSync(resolvedPath).isDirectory()) {
|
|
88638
88705
|
projectDir = resolvedPath;
|
|
88639
88706
|
const availableFiles2 = findSelectableFiles(projectDir);
|
|
88640
88707
|
if (availableFiles2.length === 0) {
|
|
88641
88708
|
console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
|
|
88642
88709
|
return null;
|
|
88643
88710
|
}
|
|
88644
|
-
console.log("Selected file:",
|
|
88711
|
+
console.log("Selected file:", path53.relative(projectDir, availableFiles2[0]));
|
|
88645
88712
|
return { absolutePath: availableFiles2[0], projectDir };
|
|
88646
88713
|
}
|
|
88647
|
-
if (!
|
|
88714
|
+
if (!fs49.existsSync(resolvedPath)) {
|
|
88648
88715
|
console.error(`Error: File not found: ${file}`);
|
|
88649
88716
|
return null;
|
|
88650
88717
|
}
|
|
@@ -88655,7 +88722,7 @@ var resolveDevTarget = async (file) => {
|
|
|
88655
88722
|
return { absolutePath: resolvedPath, projectDir };
|
|
88656
88723
|
}
|
|
88657
88724
|
const entrypointPath = await getEntrypoint({ onError: () => {} });
|
|
88658
|
-
if (entrypointPath &&
|
|
88725
|
+
if (entrypointPath && fs49.existsSync(entrypointPath)) {
|
|
88659
88726
|
console.log("Found entrypoint at:", entrypointPath);
|
|
88660
88727
|
return { absolutePath: entrypointPath, projectDir };
|
|
88661
88728
|
}
|
|
@@ -88664,7 +88731,7 @@ var resolveDevTarget = async (file) => {
|
|
|
88664
88731
|
console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
|
|
88665
88732
|
return null;
|
|
88666
88733
|
}
|
|
88667
|
-
console.log("Selected file:",
|
|
88734
|
+
console.log("Selected file:", path53.relative(projectDir, availableFiles[0]));
|
|
88668
88735
|
return { absolutePath: availableFiles[0], projectDir };
|
|
88669
88736
|
};
|
|
88670
88737
|
|
|
@@ -88680,12 +88747,12 @@ var isPortAvailable = (port) => {
|
|
|
88680
88747
|
});
|
|
88681
88748
|
};
|
|
88682
88749
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
88683
|
-
const tsconfigPath =
|
|
88684
|
-
if (!
|
|
88750
|
+
const tsconfigPath = path54.join(projectDir, "tsconfig.json");
|
|
88751
|
+
if (!fs50.existsSync(tsconfigPath)) {
|
|
88685
88752
|
return;
|
|
88686
88753
|
}
|
|
88687
88754
|
try {
|
|
88688
|
-
const tsconfig = JSON.parse(
|
|
88755
|
+
const tsconfig = JSON.parse(fs50.readFileSync(tsconfigPath, "utf-8"));
|
|
88689
88756
|
const types = tsconfig?.compilerOptions?.types;
|
|
88690
88757
|
if (!Array.isArray(types) || !types.includes("tscircuit")) {
|
|
88691
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.'));
|
|
@@ -88717,7 +88784,7 @@ var registerDev = (program2) => {
|
|
|
88717
88784
|
|
|
88718
88785
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
88719
88786
|
console.log(`
|
|
88720
|
-
${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("\\", "/"))}`)) : ""}
|
|
88721
88788
|
|
|
88722
88789
|
`);
|
|
88723
88790
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -88745,15 +88812,15 @@ var checkLoggedIn = () => {
|
|
|
88745
88812
|
|
|
88746
88813
|
// cli/doctor/checks/check-npmrc-registry.ts
|
|
88747
88814
|
import { spawnSync } from "node:child_process";
|
|
88748
|
-
import
|
|
88815
|
+
import fs51 from "node:fs";
|
|
88749
88816
|
import os5 from "node:os";
|
|
88750
|
-
import
|
|
88817
|
+
import path55 from "node:path";
|
|
88751
88818
|
var hasBunInstalled = () => {
|
|
88752
88819
|
const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
|
|
88753
88820
|
return result.status === 0;
|
|
88754
88821
|
};
|
|
88755
88822
|
var createTempProject = (tempDir) => {
|
|
88756
|
-
const packageJsonPath =
|
|
88823
|
+
const packageJsonPath = path55.join(tempDir, "package.json");
|
|
88757
88824
|
const packageJson = {
|
|
88758
88825
|
name: "tsci-doctor-check",
|
|
88759
88826
|
version: "0.0.0",
|
|
@@ -88762,7 +88829,7 @@ var createTempProject = (tempDir) => {
|
|
|
88762
88829
|
"@tsci/does-not-exist": "0.0.0"
|
|
88763
88830
|
}
|
|
88764
88831
|
};
|
|
88765
|
-
|
|
88832
|
+
fs51.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
88766
88833
|
};
|
|
88767
88834
|
var checkGlobalNpmrcRegistry = async () => {
|
|
88768
88835
|
const name = "Global .npmrc configured for tscircuit NPM registry?";
|
|
@@ -88773,7 +88840,7 @@ var checkGlobalNpmrcRegistry = async () => {
|
|
|
88773
88840
|
details: "Bun is required to verify registry settings. Install Bun and rerun `tsci doctor`."
|
|
88774
88841
|
};
|
|
88775
88842
|
}
|
|
88776
|
-
const tempDir =
|
|
88843
|
+
const tempDir = fs51.mkdtempSync(path55.join(os5.tmpdir(), "tsci-doctor-"));
|
|
88777
88844
|
try {
|
|
88778
88845
|
createTempProject(tempDir);
|
|
88779
88846
|
const result = spawnSync("bun", ["install"], {
|
|
@@ -88811,7 +88878,7 @@ ${result.stderr ?? ""}`;
|
|
|
88811
88878
|
}
|
|
88812
88879
|
return { name, success: true };
|
|
88813
88880
|
} finally {
|
|
88814
|
-
|
|
88881
|
+
fs51.rmSync(tempDir, { recursive: true, force: true });
|
|
88815
88882
|
}
|
|
88816
88883
|
};
|
|
88817
88884
|
|
|
@@ -88844,8 +88911,8 @@ var registerDoctor = (program2) => {
|
|
|
88844
88911
|
};
|
|
88845
88912
|
|
|
88846
88913
|
// lib/shared/export-snippet.ts
|
|
88847
|
-
import
|
|
88848
|
-
import
|
|
88914
|
+
import fs52 from "node:fs";
|
|
88915
|
+
import path56 from "node:path";
|
|
88849
88916
|
import { promisify as promisify3 } from "node:util";
|
|
88850
88917
|
import { convertCircuitJsonToGltf as convertCircuitJsonToGltf4 } from "circuit-json-to-gltf";
|
|
88851
88918
|
import {
|
|
@@ -89684,9 +89751,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
89684
89751
|
const stringifyCoordinates = (coordinates) => {
|
|
89685
89752
|
return coordinates.join(" ");
|
|
89686
89753
|
};
|
|
89687
|
-
const stringifyPath = (
|
|
89754
|
+
const stringifyPath = (path56, level) => {
|
|
89688
89755
|
const padding = indent.repeat(level);
|
|
89689
|
-
return `${padding}(path ${
|
|
89756
|
+
return `${padding}(path ${path56.layer} ${path56.width} ${stringifyCoordinates(path56.coordinates)})`;
|
|
89690
89757
|
};
|
|
89691
89758
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
89692
89759
|
`;
|
|
@@ -89876,7 +89943,7 @@ var isCircuitJsonFile = (filePath) => {
|
|
|
89876
89943
|
};
|
|
89877
89944
|
|
|
89878
89945
|
// lib/shared/export-snippet.ts
|
|
89879
|
-
var writeFileAsync = promisify3(
|
|
89946
|
+
var writeFileAsync = promisify3(fs52.writeFile);
|
|
89880
89947
|
var ALLOWED_EXPORT_FORMATS = [
|
|
89881
89948
|
"json",
|
|
89882
89949
|
"circuit-json",
|
|
@@ -89923,10 +89990,10 @@ var exportSnippet = async ({
|
|
|
89923
89990
|
onError(`Invalid format: ${format}`);
|
|
89924
89991
|
return onExit(1);
|
|
89925
89992
|
}
|
|
89926
|
-
const projectDir =
|
|
89927
|
-
const outputBaseName =
|
|
89993
|
+
const projectDir = path56.dirname(filePath);
|
|
89994
|
+
const outputBaseName = path56.basename(filePath).replace(/\.[^.]+$/, "");
|
|
89928
89995
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
89929
|
-
const outputDestination =
|
|
89996
|
+
const outputDestination = path56.join(projectDir, outputPath ?? outputFileName);
|
|
89930
89997
|
if (format === "kicad-library") {
|
|
89931
89998
|
try {
|
|
89932
89999
|
const result = await convertToKicadLibrary({
|
|
@@ -89945,7 +90012,7 @@ var exportSnippet = async ({
|
|
|
89945
90012
|
}
|
|
89946
90013
|
let circuitJson;
|
|
89947
90014
|
if (isCircuitJsonFile(filePath)) {
|
|
89948
|
-
const rawCircuitJson = await
|
|
90015
|
+
const rawCircuitJson = await fs52.promises.readFile(filePath, "utf-8").catch((err) => {
|
|
89949
90016
|
onError(`Error reading circuit JSON file: ${err}`);
|
|
89950
90017
|
return null;
|
|
89951
90018
|
});
|
|
@@ -90152,12 +90219,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
90152
90219
|
};
|
|
90153
90220
|
|
|
90154
90221
|
// lib/eecircuit-engine/run-simulation.ts
|
|
90155
|
-
import { promises as
|
|
90156
|
-
import
|
|
90222
|
+
import { promises as fs53, existsSync as existsSync13 } from "node:fs";
|
|
90223
|
+
import path57 from "node:path";
|
|
90157
90224
|
import os6 from "node:os";
|
|
90158
90225
|
var sim = null;
|
|
90159
90226
|
var fetchSimulation = async () => {
|
|
90160
|
-
const tempFilePath =
|
|
90227
|
+
const tempFilePath = path57.join(os6.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
90161
90228
|
if (!existsSync13(tempFilePath)) {
|
|
90162
90229
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
90163
90230
|
const response = await fetch(url);
|
|
@@ -90165,7 +90232,7 @@ var fetchSimulation = async () => {
|
|
|
90165
90232
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
90166
90233
|
}
|
|
90167
90234
|
const scriptContent = await response.text();
|
|
90168
|
-
await
|
|
90235
|
+
await fs53.writeFile(tempFilePath, scriptContent);
|
|
90169
90236
|
}
|
|
90170
90237
|
const module2 = await import(tempFilePath);
|
|
90171
90238
|
return module2.Simulation;
|
|
@@ -90254,8 +90321,8 @@ var resultToCsv = (result) => {
|
|
|
90254
90321
|
};
|
|
90255
90322
|
|
|
90256
90323
|
// cli/export/register.ts
|
|
90257
|
-
import
|
|
90258
|
-
import { promises as
|
|
90324
|
+
import path58 from "node:path";
|
|
90325
|
+
import { promises as fs54 } from "node:fs";
|
|
90259
90326
|
var registerExport = (program2) => {
|
|
90260
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) => {
|
|
90261
90328
|
const formatOption = options.format ?? "json";
|
|
@@ -90267,12 +90334,12 @@ var registerExport = (program2) => {
|
|
|
90267
90334
|
});
|
|
90268
90335
|
if (circuitJson) {
|
|
90269
90336
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
90270
|
-
const outputSpicePath = options.output ??
|
|
90271
|
-
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);
|
|
90272
90339
|
const { result } = await runSimulation(spiceString);
|
|
90273
90340
|
const csvContent = resultToCsv(result);
|
|
90274
90341
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
90275
|
-
await
|
|
90342
|
+
await fs54.writeFile(outputCsvPath, csvContent);
|
|
90276
90343
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
90277
90344
|
}
|
|
90278
90345
|
process.exit(0);
|
|
@@ -91743,8 +91810,8 @@ function getErrorMap() {
|
|
|
91743
91810
|
return overrideErrorMap;
|
|
91744
91811
|
}
|
|
91745
91812
|
var makeIssue = (params2) => {
|
|
91746
|
-
const { data, path:
|
|
91747
|
-
const fullPath = [...
|
|
91813
|
+
const { data, path: path59, errorMaps, issueData } = params2;
|
|
91814
|
+
const fullPath = [...path59, ...issueData.path || []];
|
|
91748
91815
|
const fullIssue = {
|
|
91749
91816
|
...issueData,
|
|
91750
91817
|
path: fullPath
|
|
@@ -91852,11 +91919,11 @@ var errorUtil;
|
|
|
91852
91919
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
91853
91920
|
})(errorUtil || (errorUtil = {}));
|
|
91854
91921
|
var ParseInputLazyPath = class {
|
|
91855
|
-
constructor(parent, value,
|
|
91922
|
+
constructor(parent, value, path59, key) {
|
|
91856
91923
|
this._cachedPath = [];
|
|
91857
91924
|
this.parent = parent;
|
|
91858
91925
|
this.data = value;
|
|
91859
|
-
this._path =
|
|
91926
|
+
this._path = path59;
|
|
91860
91927
|
this._key = key;
|
|
91861
91928
|
}
|
|
91862
91929
|
get path() {
|
|
@@ -100043,7 +100110,7 @@ var ss = ys;
|
|
|
100043
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: {} };
|
|
100044
100111
|
var { paths: Yd, bounds: ns, refblocks: Xd } = ms2;
|
|
100045
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();
|
|
100046
|
-
var
|
|
100113
|
+
var fs55 = r(U, "down");
|
|
100047
100114
|
var hs = r(U, "left");
|
|
100048
100115
|
var cs = r(U, "up");
|
|
100049
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 } } };
|
|
@@ -100646,7 +100713,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
100646
100713
|
Vb.anchor = "middle_left";
|
|
100647
100714
|
jb.anchor = "middle_right";
|
|
100648
100715
|
var tf = Il;
|
|
100649
|
-
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 };
|
|
100650
100717
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
100651
100718
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
100652
100719
|
lineThickness = 0
|
|
@@ -102954,11 +103021,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102954
103021
|
fiber = fiber.next, id--;
|
|
102955
103022
|
return fiber;
|
|
102956
103023
|
}
|
|
102957
|
-
function copyWithSetImpl(obj,
|
|
102958
|
-
if (index >=
|
|
103024
|
+
function copyWithSetImpl(obj, path59, index, value) {
|
|
103025
|
+
if (index >= path59.length)
|
|
102959
103026
|
return value;
|
|
102960
|
-
var key =
|
|
102961
|
-
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);
|
|
102962
103029
|
return updated;
|
|
102963
103030
|
}
|
|
102964
103031
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -102978,11 +103045,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
102978
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);
|
|
102979
103046
|
return updated;
|
|
102980
103047
|
}
|
|
102981
|
-
function copyWithDeleteImpl(obj,
|
|
102982
|
-
var key =
|
|
102983
|
-
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)
|
|
102984
103051
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
102985
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
103052
|
+
updated[key] = copyWithDeleteImpl(obj[key], path59, index + 1);
|
|
102986
103053
|
return updated;
|
|
102987
103054
|
}
|
|
102988
103055
|
function shouldSuspendImpl() {
|
|
@@ -112008,29 +112075,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
112008
112075
|
var didWarnAboutNestedUpdates = false;
|
|
112009
112076
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
112010
112077
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
112011
|
-
overrideHookState = function(fiber, id,
|
|
112078
|
+
overrideHookState = function(fiber, id, path59, value) {
|
|
112012
112079
|
id = findHook(fiber, id);
|
|
112013
|
-
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));
|
|
112014
112081
|
};
|
|
112015
|
-
overrideHookStateDeletePath = function(fiber, id,
|
|
112082
|
+
overrideHookStateDeletePath = function(fiber, id, path59) {
|
|
112016
112083
|
id = findHook(fiber, id);
|
|
112017
|
-
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));
|
|
112018
112085
|
};
|
|
112019
112086
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
112020
112087
|
id = findHook(fiber, id);
|
|
112021
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));
|
|
112022
112089
|
};
|
|
112023
|
-
overrideProps = function(fiber,
|
|
112024
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
112090
|
+
overrideProps = function(fiber, path59, value) {
|
|
112091
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path59, 0, value);
|
|
112025
112092
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
112026
|
-
|
|
112027
|
-
|
|
112093
|
+
path59 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
112094
|
+
path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2);
|
|
112028
112095
|
};
|
|
112029
|
-
overridePropsDeletePath = function(fiber,
|
|
112030
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
112096
|
+
overridePropsDeletePath = function(fiber, path59) {
|
|
112097
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path59, 0);
|
|
112031
112098
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
112032
|
-
|
|
112033
|
-
|
|
112099
|
+
path59 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
112100
|
+
path59 !== null && scheduleUpdateOnFiber(path59, fiber, 2);
|
|
112034
112101
|
};
|
|
112035
112102
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
112036
112103
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -118333,7 +118400,7 @@ var parsePin = (pinString) => {
|
|
|
118333
118400
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
118334
118401
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
118335
118402
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
118336
|
-
const
|
|
118403
|
+
const path59 = pathMatch ? pathMatch[1] : "";
|
|
118337
118404
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
118338
118405
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
118339
118406
|
const r2 = Number.parseFloat(rotation4);
|
|
@@ -118347,7 +118414,7 @@ var parsePin = (pinString) => {
|
|
|
118347
118414
|
rotation: Number.isNaN(r2) ? 0 : r2,
|
|
118348
118415
|
label,
|
|
118349
118416
|
labelColor,
|
|
118350
|
-
path:
|
|
118417
|
+
path: path59,
|
|
118351
118418
|
arrow
|
|
118352
118419
|
};
|
|
118353
118420
|
};
|
|
@@ -118787,15 +118854,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
118787
118854
|
}
|
|
118788
118855
|
}
|
|
118789
118856
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
118790
|
-
const
|
|
118857
|
+
const path59 = [];
|
|
118791
118858
|
for (let i22 = 0;i22 <= numPoints; i22++) {
|
|
118792
118859
|
const t3 = i22 / numPoints;
|
|
118793
118860
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
118794
118861
|
const x22 = centerX + radius * Math.cos(angle2);
|
|
118795
118862
|
const y22 = centerY + radius * Math.sin(angle2);
|
|
118796
|
-
|
|
118863
|
+
path59.push({ x: x22, y: y22 });
|
|
118797
118864
|
}
|
|
118798
|
-
return
|
|
118865
|
+
return path59;
|
|
118799
118866
|
}
|
|
118800
118867
|
var __defProp4 = Object.defineProperty;
|
|
118801
118868
|
var __export22 = (target, all) => {
|
|
@@ -127874,17 +127941,17 @@ var ObstacleList = class {
|
|
|
127874
127941
|
return obstacles;
|
|
127875
127942
|
}
|
|
127876
127943
|
};
|
|
127877
|
-
function removePathLoops(
|
|
127878
|
-
if (
|
|
127879
|
-
return
|
|
127880
|
-
const result = [{ ...
|
|
127881
|
-
let currentLayer =
|
|
127882
|
-
for (let i22 = 1;i22 <
|
|
127883
|
-
const currentSegment = { start:
|
|
127884
|
-
const isVia =
|
|
127885
|
-
if (
|
|
127886
|
-
result.push({ ...
|
|
127887
|
-
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;
|
|
127888
127955
|
continue;
|
|
127889
127956
|
}
|
|
127890
127957
|
let intersectionFound = false;
|
|
@@ -127913,8 +127980,8 @@ function removePathLoops(path58) {
|
|
|
127913
127980
|
result.push(intersectionPoint);
|
|
127914
127981
|
}
|
|
127915
127982
|
const lastPoint = result[result.length - 1];
|
|
127916
|
-
if (lastPoint.x !==
|
|
127917
|
-
result.push(
|
|
127983
|
+
if (lastPoint.x !== path59[i22].x || lastPoint.y !== path59[i22].y) {
|
|
127984
|
+
result.push(path59[i22]);
|
|
127918
127985
|
}
|
|
127919
127986
|
}
|
|
127920
127987
|
return result;
|
|
@@ -128403,10 +128470,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
128403
128470
|
});
|
|
128404
128471
|
}
|
|
128405
128472
|
if (current2.parent) {
|
|
128406
|
-
const
|
|
128473
|
+
const path59 = [];
|
|
128407
128474
|
let p22 = current2;
|
|
128408
128475
|
while (p22) {
|
|
128409
|
-
|
|
128476
|
+
path59.unshift(p22);
|
|
128410
128477
|
p22 = p22.parent;
|
|
128411
128478
|
}
|
|
128412
128479
|
debugSolution.push({
|
|
@@ -128414,7 +128481,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
128414
128481
|
pcb_component_id: "",
|
|
128415
128482
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
128416
128483
|
layer: "top",
|
|
128417
|
-
route:
|
|
128484
|
+
route: path59,
|
|
128418
128485
|
stroke_width: 0.01
|
|
128419
128486
|
});
|
|
128420
128487
|
}
|
|
@@ -136765,7 +136832,7 @@ var ps2 = class extends e3 {
|
|
|
136765
136832
|
return t3;
|
|
136766
136833
|
}
|
|
136767
136834
|
};
|
|
136768
|
-
var
|
|
136835
|
+
var fs56 = (t3) => {
|
|
136769
136836
|
const e22 = [], s22 = [], n22 = [], i22 = ht2(t3);
|
|
136770
136837
|
if (t3.connections)
|
|
136771
136838
|
for (const e32 of t3.connections)
|
|
@@ -139388,7 +139455,7 @@ var Tn2 = class extends e3 {
|
|
|
139388
139455
|
const t3 = M22.map((t42) => ({ x: t42.x, y: t42.y }));
|
|
139389
139456
|
t3.push({ ...t3[0] }), v22.push({ points: t3, strokeColor: "rgba(0, 136, 255, 0.95)" });
|
|
139390
139457
|
}
|
|
139391
|
-
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);
|
|
139392
139459
|
return t(...b22);
|
|
139393
139460
|
}
|
|
139394
139461
|
preview() {
|
|
@@ -152859,10 +152926,10 @@ var findFirstCollision = (pts, rects, opts = {}) => {
|
|
|
152859
152926
|
}
|
|
152860
152927
|
return null;
|
|
152861
152928
|
};
|
|
152862
|
-
var isPathCollidingWithObstacles = (
|
|
152863
|
-
for (let i22 = 0;i22 <
|
|
152929
|
+
var isPathCollidingWithObstacles = (path59, obstacles) => {
|
|
152930
|
+
for (let i22 = 0;i22 < path59.length - 1; i22++) {
|
|
152864
152931
|
for (const obstacle of obstacles) {
|
|
152865
|
-
if (segmentIntersectsRect(
|
|
152932
|
+
if (segmentIntersectsRect(path59[i22], path59[i22 + 1], obstacle)) {
|
|
152866
152933
|
return true;
|
|
152867
152934
|
}
|
|
152868
152935
|
}
|
|
@@ -153056,36 +153123,36 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
153056
153123
|
this.error = "No collision-free path found";
|
|
153057
153124
|
return;
|
|
153058
153125
|
}
|
|
153059
|
-
const { path:
|
|
153126
|
+
const { path: path59, collisionChipIds } = state;
|
|
153060
153127
|
const [PA, PB] = this.pins;
|
|
153061
|
-
const collision = findFirstCollision(
|
|
153128
|
+
const collision = findFirstCollision(path59, this.obstacles);
|
|
153062
153129
|
if (!collision) {
|
|
153063
|
-
const first =
|
|
153064
|
-
const last =
|
|
153130
|
+
const first = path59[0];
|
|
153131
|
+
const last = path59[path59.length - 1];
|
|
153065
153132
|
const EPS42 = 0.000000001;
|
|
153066
153133
|
const samePoint = (p22, q22) => Math.abs(p22.x - q22.x) < EPS42 && Math.abs(p22.y - q22.y) < EPS42;
|
|
153067
153134
|
if (samePoint(first, { x: PA.x, y: PA.y }) && samePoint(last, { x: PB.x, y: PB.y })) {
|
|
153068
|
-
this.solvedTracePath =
|
|
153135
|
+
this.solvedTracePath = path59;
|
|
153069
153136
|
this.solved = true;
|
|
153070
153137
|
}
|
|
153071
153138
|
return;
|
|
153072
153139
|
}
|
|
153073
153140
|
let { segIndex, rect } = collision;
|
|
153074
153141
|
const isFirstSegment = segIndex === 0;
|
|
153075
|
-
const isLastSegment = segIndex ===
|
|
153142
|
+
const isLastSegment = segIndex === path59.length - 2;
|
|
153076
153143
|
if (isFirstSegment) {
|
|
153077
|
-
if (
|
|
153144
|
+
if (path59.length < 3) {
|
|
153078
153145
|
return;
|
|
153079
153146
|
}
|
|
153080
153147
|
segIndex = 1;
|
|
153081
153148
|
} else if (isLastSegment) {
|
|
153082
|
-
if (
|
|
153149
|
+
if (path59.length < 3) {
|
|
153083
153150
|
return;
|
|
153084
153151
|
}
|
|
153085
|
-
segIndex =
|
|
153152
|
+
segIndex = path59.length - 3;
|
|
153086
153153
|
}
|
|
153087
|
-
const a22 =
|
|
153088
|
-
const b22 =
|
|
153154
|
+
const a22 = path59[segIndex];
|
|
153155
|
+
const b22 = path59[segIndex + 1];
|
|
153089
153156
|
const axis = this.axisOfSegment(a22, b22);
|
|
153090
153157
|
if (!axis) {
|
|
153091
153158
|
return;
|
|
@@ -153103,7 +153170,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
153103
153170
|
}
|
|
153104
153171
|
const newStates = [];
|
|
153105
153172
|
for (const coord of candidates) {
|
|
153106
|
-
const newPath = shiftSegmentOrth(
|
|
153173
|
+
const newPath = shiftSegmentOrth(path59, segIndex, axis, coord);
|
|
153107
153174
|
if (!newPath)
|
|
153108
153175
|
continue;
|
|
153109
153176
|
const key = pathKey(newPath);
|
|
@@ -153139,8 +153206,8 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
153139
153206
|
strokeColor: "blue",
|
|
153140
153207
|
strokeDash: "5 5"
|
|
153141
153208
|
});
|
|
153142
|
-
for (const { path:
|
|
153143
|
-
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" });
|
|
153144
153211
|
}
|
|
153145
153212
|
if (this.solvedTracePath) {
|
|
153146
153213
|
g22.lines.push({ points: this.solvedTracePath, strokeColor: "green" });
|
|
@@ -153377,9 +153444,9 @@ var TraceOverlapIssueSolver = class extends BaseSolver3 {
|
|
|
153377
153444
|
solvedTracePathIndex,
|
|
153378
153445
|
traceSegmentIndex
|
|
153379
153446
|
} of group.pathsWithOverlap) {
|
|
153380
|
-
const
|
|
153381
|
-
const segStart =
|
|
153382
|
-
const segEnd =
|
|
153447
|
+
const path59 = this.traceNetIslands[group.connNetId][solvedTracePathIndex];
|
|
153448
|
+
const segStart = path59.tracePath[traceSegmentIndex];
|
|
153449
|
+
const segEnd = path59.tracePath[traceSegmentIndex + 1];
|
|
153383
153450
|
graphics.lines.push({
|
|
153384
153451
|
points: [segStart, segEnd],
|
|
153385
153452
|
strokeColor: "red"
|
|
@@ -153423,11 +153490,11 @@ var TraceOverlapShiftSolver = class extends BaseSolver3 {
|
|
|
153423
153490
|
computeTraceNetIslands() {
|
|
153424
153491
|
const islands = {};
|
|
153425
153492
|
for (const original of this.inputTracePaths) {
|
|
153426
|
-
const
|
|
153427
|
-
const key =
|
|
153493
|
+
const path59 = this.correctedTraceMap[original.mspPairId] ?? original;
|
|
153494
|
+
const key = path59.globalConnNetId;
|
|
153428
153495
|
if (!islands[key])
|
|
153429
153496
|
islands[key] = [];
|
|
153430
|
-
islands[key].push(
|
|
153497
|
+
islands[key].push(path59);
|
|
153431
153498
|
}
|
|
153432
153499
|
return islands;
|
|
153433
153500
|
}
|
|
@@ -153675,9 +153742,9 @@ function rectIntersectsAnyTrace(bounds, inputTraceMap, hostPathId, hostSegIndex)
|
|
|
153675
153742
|
}
|
|
153676
153743
|
return { hasIntersection: false };
|
|
153677
153744
|
}
|
|
153678
|
-
function lengthOfTrace(
|
|
153745
|
+
function lengthOfTrace(path59) {
|
|
153679
153746
|
let sum = 0;
|
|
153680
|
-
const pts =
|
|
153747
|
+
const pts = path59.tracePath;
|
|
153681
153748
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
153682
153749
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
153683
153750
|
}
|
|
@@ -154206,9 +154273,9 @@ var NetLabelPlacementSolver = class extends BaseSolver3 {
|
|
|
154206
154273
|
}
|
|
154207
154274
|
const compTraces = (byGlobal[globalConnNetId] ?? []).filter((t3) => component.has(t3.pins[0].pinId) && component.has(t3.pins[1].pinId));
|
|
154208
154275
|
if (compTraces.length > 0) {
|
|
154209
|
-
const lengthOf = (
|
|
154276
|
+
const lengthOf = (path59) => {
|
|
154210
154277
|
let sum = 0;
|
|
154211
|
-
const pts =
|
|
154278
|
+
const pts = path59.tracePath;
|
|
154212
154279
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
154213
154280
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
154214
154281
|
}
|
|
@@ -154353,12 +154420,12 @@ var detectTraceLabelOverlap = (traces, netLabels) => {
|
|
|
154353
154420
|
}
|
|
154354
154421
|
return overlaps;
|
|
154355
154422
|
};
|
|
154356
|
-
var findTraceViolationZone = (
|
|
154423
|
+
var findTraceViolationZone = (path59, labelBounds) => {
|
|
154357
154424
|
const isPointInside = (p22) => p22.x > labelBounds.minX && p22.x < labelBounds.maxX && p22.y > labelBounds.minY && p22.y < labelBounds.maxY;
|
|
154358
154425
|
let firstInsideIndex = -1;
|
|
154359
154426
|
let lastInsideIndex = -1;
|
|
154360
|
-
for (let i22 = 0;i22 <
|
|
154361
|
-
if (isPointInside(
|
|
154427
|
+
for (let i22 = 0;i22 < path59.length; i22++) {
|
|
154428
|
+
if (isPointInside(path59[i22])) {
|
|
154362
154429
|
if (firstInsideIndex === -1) {
|
|
154363
154430
|
firstInsideIndex = i22;
|
|
154364
154431
|
}
|
|
@@ -154367,20 +154434,20 @@ var findTraceViolationZone = (path58, labelBounds) => {
|
|
|
154367
154434
|
}
|
|
154368
154435
|
return { firstInsideIndex, lastInsideIndex };
|
|
154369
154436
|
};
|
|
154370
|
-
var simplifyPath = (
|
|
154371
|
-
if (
|
|
154372
|
-
return
|
|
154373
|
-
const newPath = [
|
|
154374
|
-
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++) {
|
|
154375
154442
|
const p12 = newPath[newPath.length - 1];
|
|
154376
|
-
const p22 =
|
|
154377
|
-
const p32 =
|
|
154443
|
+
const p22 = path59[i22];
|
|
154444
|
+
const p32 = path59[i22 + 1];
|
|
154378
154445
|
if (isVertical(p12, p22) && isVertical(p22, p32) || isHorizontal(p12, p22) && isHorizontal(p22, p32)) {
|
|
154379
154446
|
continue;
|
|
154380
154447
|
}
|
|
154381
154448
|
newPath.push(p22);
|
|
154382
154449
|
}
|
|
154383
|
-
newPath.push(
|
|
154450
|
+
newPath.push(path59[path59.length - 1]);
|
|
154384
154451
|
if (newPath.length < 3)
|
|
154385
154452
|
return newPath;
|
|
154386
154453
|
const finalPath = [newPath[0]];
|
|
@@ -154640,12 +154707,12 @@ var hasCollisionsWithLabels = (pathSegments, labels) => {
|
|
|
154640
154707
|
return false;
|
|
154641
154708
|
};
|
|
154642
154709
|
var minimizeTurns = ({
|
|
154643
|
-
path:
|
|
154710
|
+
path: path59,
|
|
154644
154711
|
obstacles,
|
|
154645
154712
|
labelBounds
|
|
154646
154713
|
}) => {
|
|
154647
|
-
if (
|
|
154648
|
-
return
|
|
154714
|
+
if (path59.length <= 2) {
|
|
154715
|
+
return path59;
|
|
154649
154716
|
}
|
|
154650
154717
|
const recognizeStairStepPattern = (pathToCheck, startIdx) => {
|
|
154651
154718
|
if (startIdx >= pathToCheck.length - 3)
|
|
@@ -154677,7 +154744,7 @@ var minimizeTurns = ({
|
|
|
154677
154744
|
}
|
|
154678
154745
|
return isStairStep && endIdx - startIdx >= 3 ? endIdx : -1;
|
|
154679
154746
|
};
|
|
154680
|
-
let optimizedPath = [...
|
|
154747
|
+
let optimizedPath = [...path59];
|
|
154681
154748
|
let currentTurns = countTurns(optimizedPath);
|
|
154682
154749
|
let improved = true;
|
|
154683
154750
|
while (improved) {
|
|
@@ -162282,9 +162349,9 @@ var getFileExtension = (filename) => {
|
|
|
162282
162349
|
const extension = lastSegment.split(".").pop();
|
|
162283
162350
|
return extension?.toLowerCase() ?? null;
|
|
162284
162351
|
};
|
|
162285
|
-
var joinUrlPath = (base,
|
|
162352
|
+
var joinUrlPath = (base, path59) => {
|
|
162286
162353
|
const trimmedBase = base.replace(/\/+$/, "");
|
|
162287
|
-
const trimmedPath =
|
|
162354
|
+
const trimmedPath = path59.replace(/^\/+/, "");
|
|
162288
162355
|
return `${trimmedBase}/${trimmedPath}`;
|
|
162289
162356
|
};
|
|
162290
162357
|
var constructAssetUrl = (targetUrl, baseUrl) => {
|
|
@@ -163598,7 +163665,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163598
163665
|
for (let i22 = 0;i22 < portsWithPosition.length - 1; i22++) {
|
|
163599
163666
|
const start = portsWithPosition[i22];
|
|
163600
163667
|
const end = portsWithPosition[i22 + 1];
|
|
163601
|
-
const
|
|
163668
|
+
const path59 = calculateElbow({
|
|
163602
163669
|
x: start.position.x,
|
|
163603
163670
|
y: start.position.y,
|
|
163604
163671
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -163607,8 +163674,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
163607
163674
|
y: end.position.y,
|
|
163608
163675
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
163609
163676
|
});
|
|
163610
|
-
for (let j22 = 0;j22 <
|
|
163611
|
-
elbowEdges.push({ from:
|
|
163677
|
+
for (let j22 = 0;j22 < path59.length - 1; j22++) {
|
|
163678
|
+
elbowEdges.push({ from: path59[j22], to: path59[j22 + 1] });
|
|
163612
163679
|
}
|
|
163613
163680
|
}
|
|
163614
163681
|
const doesSegmentIntersectRect2 = (edge, rect) => {
|
|
@@ -164801,20 +164868,20 @@ var parseLibraryFootprintRef = (s22) => {
|
|
|
164801
164868
|
};
|
|
164802
164869
|
var isStaticAssetPath = (s22) => s22.startsWith("/");
|
|
164803
164870
|
var resolveStaticFileImportDebug = (0, import_debug92.default)("tscircuit:core:resolveStaticFileImport");
|
|
164804
|
-
async function resolveStaticFileImport(
|
|
164805
|
-
if (!
|
|
164806
|
-
return
|
|
164871
|
+
async function resolveStaticFileImport(path59, platform) {
|
|
164872
|
+
if (!path59)
|
|
164873
|
+
return path59;
|
|
164807
164874
|
const resolver = platform?.resolveProjectStaticFileImportUrl;
|
|
164808
|
-
if (resolver &&
|
|
164875
|
+
if (resolver && path59.startsWith("/")) {
|
|
164809
164876
|
try {
|
|
164810
|
-
const resolved = await resolver(
|
|
164877
|
+
const resolved = await resolver(path59);
|
|
164811
164878
|
if (resolved)
|
|
164812
164879
|
return resolved;
|
|
164813
164880
|
} catch (error) {
|
|
164814
164881
|
resolveStaticFileImportDebug("failed to resolve static file via platform resolver", error);
|
|
164815
164882
|
}
|
|
164816
164883
|
}
|
|
164817
|
-
return constructAssetUrl(
|
|
164884
|
+
return constructAssetUrl(path59, platform?.projectBaseUrl);
|
|
164818
164885
|
}
|
|
164819
164886
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
164820
164887
|
let { footprint } = component.props;
|
|
@@ -169902,7 +169969,7 @@ var Group6 = class extends NormalComponent3 {
|
|
|
169902
169969
|
});
|
|
169903
169970
|
}
|
|
169904
169971
|
if (debug112.enabled) {
|
|
169905
|
-
const graphicsObject =
|
|
169972
|
+
const graphicsObject = fs56(simpleRouteJson);
|
|
169906
169973
|
graphicsObject.title = `autorouting-${this.props.name}`;
|
|
169907
169974
|
global.debugGraphics?.push(graphicsObject);
|
|
169908
169975
|
}
|
|
@@ -172461,7 +172528,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
172461
172528
|
}
|
|
172462
172529
|
const portPos = port._getGlobalSchematicPositionAfterLayout();
|
|
172463
172530
|
const portFacing = convertFacingDirectionToElbowDirection(port.facingDirection ?? "right") ?? "x+";
|
|
172464
|
-
const
|
|
172531
|
+
const path59 = calculateElbow({
|
|
172465
172532
|
x: portPos.x,
|
|
172466
172533
|
y: portPos.y,
|
|
172467
172534
|
facingDirection: portFacing
|
|
@@ -172470,13 +172537,13 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
172470
172537
|
y: anchorPos.y,
|
|
172471
172538
|
facingDirection: anchorFacing
|
|
172472
172539
|
});
|
|
172473
|
-
if (!Array.isArray(
|
|
172540
|
+
if (!Array.isArray(path59) || path59.length < 2)
|
|
172474
172541
|
continue;
|
|
172475
172542
|
const edges = [];
|
|
172476
|
-
for (let i22 = 0;i22 <
|
|
172543
|
+
for (let i22 = 0;i22 < path59.length - 1; i22++) {
|
|
172477
172544
|
edges.push({
|
|
172478
|
-
from: { x:
|
|
172479
|
-
to: { x:
|
|
172545
|
+
from: { x: path59[i22].x, y: path59[i22].y },
|
|
172546
|
+
to: { x: path59[i22 + 1].x, y: path59[i22 + 1].y }
|
|
172480
172547
|
});
|
|
172481
172548
|
}
|
|
172482
172549
|
let source_trace_id;
|
|
@@ -174788,8 +174855,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
174788
174855
|
*/
|
|
174789
174856
|
|
|
174790
174857
|
// lib/import/import-component-from-jlcpcb.ts
|
|
174791
|
-
import
|
|
174792
|
-
import
|
|
174858
|
+
import fs57 from "node:fs/promises";
|
|
174859
|
+
import path59 from "node:path";
|
|
174793
174860
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
174794
174861
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
174795
174862
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -174797,10 +174864,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
174797
174864
|
if (!fileName) {
|
|
174798
174865
|
throw new Error("Could not determine file name of converted component");
|
|
174799
174866
|
}
|
|
174800
|
-
const importsDir =
|
|
174801
|
-
await
|
|
174802
|
-
const filePath =
|
|
174803
|
-
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);
|
|
174804
174871
|
return { filePath };
|
|
174805
174872
|
};
|
|
174806
174873
|
|
|
@@ -176145,13 +176212,13 @@ var registerImport = (program2) => {
|
|
|
176145
176212
|
};
|
|
176146
176213
|
|
|
176147
176214
|
// cli/init/register.ts
|
|
176148
|
-
import * as
|
|
176149
|
-
import * as
|
|
176215
|
+
import * as fs59 from "node:fs";
|
|
176216
|
+
import * as path62 from "node:path";
|
|
176150
176217
|
|
|
176151
176218
|
// lib/shared/generate-gitignore-file.ts
|
|
176152
|
-
import
|
|
176219
|
+
import path60 from "node:path";
|
|
176153
176220
|
var generateGitIgnoreFile = (dir) => {
|
|
176154
|
-
const gitignorePath =
|
|
176221
|
+
const gitignorePath = path60.join(dir, ".gitignore");
|
|
176155
176222
|
const gitignoreContent = `# Dependencies
|
|
176156
176223
|
node_modules/
|
|
176157
176224
|
|
|
@@ -176186,8 +176253,8 @@ yarn-error.log*
|
|
|
176186
176253
|
};
|
|
176187
176254
|
|
|
176188
176255
|
// lib/shared/setup-tscircuit-skill.ts
|
|
176189
|
-
import * as
|
|
176190
|
-
import * as
|
|
176256
|
+
import * as fs58 from "node:fs";
|
|
176257
|
+
import * as path61 from "node:path";
|
|
176191
176258
|
var SKILL_REPO_API_URL = "https://api.github.com/repos/tscircuit/skill/contents";
|
|
176192
176259
|
var SKILL_INSTALL_PATHS = [
|
|
176193
176260
|
".claude/skills/tscircuit",
|
|
@@ -176210,35 +176277,35 @@ async function fetchFileContent(downloadUrl) {
|
|
|
176210
176277
|
async function downloadDirectory(apiUrl, targetDir) {
|
|
176211
176278
|
const contents = await fetchGitHubContents(apiUrl);
|
|
176212
176279
|
for (const item of contents) {
|
|
176213
|
-
const targetPath =
|
|
176280
|
+
const targetPath = path61.join(targetDir, item.name);
|
|
176214
176281
|
if (item.type === "dir") {
|
|
176215
|
-
|
|
176282
|
+
fs58.mkdirSync(targetPath, { recursive: true });
|
|
176216
176283
|
await downloadDirectory(`${apiUrl}/${item.name}`, targetPath);
|
|
176217
176284
|
} else if (item.type === "file" && item.download_url) {
|
|
176218
176285
|
const content = await fetchFileContent(item.download_url);
|
|
176219
|
-
|
|
176286
|
+
fs58.writeFileSync(targetPath, content, "utf-8");
|
|
176220
176287
|
}
|
|
176221
176288
|
}
|
|
176222
176289
|
}
|
|
176223
176290
|
async function downloadSkillRepo(targetDir) {
|
|
176224
|
-
|
|
176291
|
+
fs58.mkdirSync(targetDir, { recursive: true });
|
|
176225
176292
|
const rootContents = await fetchGitHubContents(SKILL_REPO_API_URL);
|
|
176226
176293
|
for (const item of rootContents) {
|
|
176227
176294
|
if (item.name === ".git" || item.name === ".github") {
|
|
176228
176295
|
continue;
|
|
176229
176296
|
}
|
|
176230
|
-
const targetPath =
|
|
176297
|
+
const targetPath = path61.join(targetDir, item.name);
|
|
176231
176298
|
if (item.type === "dir") {
|
|
176232
|
-
|
|
176299
|
+
fs58.mkdirSync(targetPath, { recursive: true });
|
|
176233
176300
|
await downloadDirectory(`${SKILL_REPO_API_URL}/${item.name}`, targetPath);
|
|
176234
176301
|
} else if (item.type === "file" && item.download_url) {
|
|
176235
176302
|
const content = await fetchFileContent(item.download_url);
|
|
176236
|
-
|
|
176303
|
+
fs58.writeFileSync(targetPath, content, "utf-8");
|
|
176237
176304
|
}
|
|
176238
176305
|
}
|
|
176239
176306
|
}
|
|
176240
176307
|
async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
176241
|
-
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !
|
|
176308
|
+
const missingSkillPaths = SKILL_INSTALL_PATHS.filter((skillPath) => !fs58.existsSync(path61.join(projectDir, skillPath, "SKILL.md")));
|
|
176242
176309
|
if (missingSkillPaths.length === 0) {
|
|
176243
176310
|
console.log("TSCircuit AI skills already exist, skipping...");
|
|
176244
176311
|
return true;
|
|
@@ -176258,7 +176325,7 @@ async function setupTscircuitSkill(projectDir, skipPrompt = false) {
|
|
|
176258
176325
|
console.info("Setting up tscircuit AI skills...");
|
|
176259
176326
|
try {
|
|
176260
176327
|
for (const skillPath of missingSkillPaths) {
|
|
176261
|
-
const targetDir =
|
|
176328
|
+
const targetDir = path61.join(projectDir, skillPath);
|
|
176262
176329
|
await downloadSkillRepo(targetDir);
|
|
176263
176330
|
console.info(`tscircuit skill installed at ${skillPath}`);
|
|
176264
176331
|
}
|
|
@@ -176362,7 +176429,7 @@ var registerInit = (program3) => {
|
|
|
176362
176429
|
}
|
|
176363
176430
|
}
|
|
176364
176431
|
}
|
|
176365
|
-
const projectDir = directory ?
|
|
176432
|
+
const projectDir = directory ? path62.resolve(process.cwd(), directory) : process.cwd();
|
|
176366
176433
|
let tsciHandle = null;
|
|
176367
176434
|
const token = getSessionToken();
|
|
176368
176435
|
if (token) {
|
|
@@ -176373,7 +176440,7 @@ var registerInit = (program3) => {
|
|
|
176373
176440
|
}
|
|
176374
176441
|
} catch {}
|
|
176375
176442
|
}
|
|
176376
|
-
const dirName =
|
|
176443
|
+
const dirName = path62.basename(projectDir);
|
|
176377
176444
|
let defaultPackageName = dirName;
|
|
176378
176445
|
if (tsciHandle) {
|
|
176379
176446
|
defaultPackageName = `@tsci/${tsciHandle}.${dirName}`;
|
|
@@ -176391,8 +176458,8 @@ var registerInit = (program3) => {
|
|
|
176391
176458
|
authorName = account.tscircuit_handle;
|
|
176392
176459
|
}
|
|
176393
176460
|
}
|
|
176394
|
-
|
|
176395
|
-
writeFileIfNotExists(
|
|
176461
|
+
fs59.mkdirSync(projectDir, { recursive: true });
|
|
176462
|
+
writeFileIfNotExists(path62.join(projectDir, "index.circuit.tsx"), `
|
|
176396
176463
|
export default () => (
|
|
176397
176464
|
<board>
|
|
176398
176465
|
<resistor resistance="1k" footprint="0402" name="R1" />
|
|
@@ -176404,7 +176471,7 @@ export default () => (
|
|
|
176404
176471
|
if (saveProjectConfig(null, projectDir)) {
|
|
176405
176472
|
console.log("Created tscircuit.config.json with schema");
|
|
176406
176473
|
}
|
|
176407
|
-
writeFileIfNotExists(
|
|
176474
|
+
writeFileIfNotExists(path62.join(projectDir, ".npmrc"), `
|
|
176408
176475
|
@tsci:registry=https://npm.tscircuit.com
|
|
176409
176476
|
`);
|
|
176410
176477
|
console.log("Generating package.json");
|
|
@@ -176657,14 +176724,14 @@ class KeyStore {
|
|
|
176657
176724
|
}
|
|
176658
176725
|
}
|
|
176659
176726
|
function createKey(key) {
|
|
176660
|
-
let
|
|
176727
|
+
let path63 = null;
|
|
176661
176728
|
let id = null;
|
|
176662
176729
|
let src = null;
|
|
176663
176730
|
let weight = 1;
|
|
176664
176731
|
let getFn = null;
|
|
176665
176732
|
if (isString2(key) || isArray(key)) {
|
|
176666
176733
|
src = key;
|
|
176667
|
-
|
|
176734
|
+
path63 = createKeyPath(key);
|
|
176668
176735
|
id = createKeyId(key);
|
|
176669
176736
|
} else {
|
|
176670
176737
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -176678,11 +176745,11 @@ function createKey(key) {
|
|
|
176678
176745
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
176679
176746
|
}
|
|
176680
176747
|
}
|
|
176681
|
-
|
|
176748
|
+
path63 = createKeyPath(name);
|
|
176682
176749
|
id = createKeyId(name);
|
|
176683
176750
|
getFn = key.getFn;
|
|
176684
176751
|
}
|
|
176685
|
-
return { path:
|
|
176752
|
+
return { path: path63, id, weight, src, getFn };
|
|
176686
176753
|
}
|
|
176687
176754
|
function createKeyPath(key) {
|
|
176688
176755
|
return isArray(key) ? key : key.split(".");
|
|
@@ -176690,34 +176757,34 @@ function createKeyPath(key) {
|
|
|
176690
176757
|
function createKeyId(key) {
|
|
176691
176758
|
return isArray(key) ? key.join(".") : key;
|
|
176692
176759
|
}
|
|
176693
|
-
function get(obj,
|
|
176760
|
+
function get(obj, path63) {
|
|
176694
176761
|
let list = [];
|
|
176695
176762
|
let arr = false;
|
|
176696
|
-
const deepGet = (obj2,
|
|
176763
|
+
const deepGet = (obj2, path64, index) => {
|
|
176697
176764
|
if (!isDefined(obj2)) {
|
|
176698
176765
|
return;
|
|
176699
176766
|
}
|
|
176700
|
-
if (!
|
|
176767
|
+
if (!path64[index]) {
|
|
176701
176768
|
list.push(obj2);
|
|
176702
176769
|
} else {
|
|
176703
|
-
let key =
|
|
176770
|
+
let key = path64[index];
|
|
176704
176771
|
const value = obj2[key];
|
|
176705
176772
|
if (!isDefined(value)) {
|
|
176706
176773
|
return;
|
|
176707
176774
|
}
|
|
176708
|
-
if (index ===
|
|
176775
|
+
if (index === path64.length - 1 && (isString2(value) || isNumber2(value) || isBoolean(value))) {
|
|
176709
176776
|
list.push(toString(value));
|
|
176710
176777
|
} else if (isArray(value)) {
|
|
176711
176778
|
arr = true;
|
|
176712
176779
|
for (let i3 = 0, len = value.length;i3 < len; i3 += 1) {
|
|
176713
|
-
deepGet(value[i3],
|
|
176780
|
+
deepGet(value[i3], path64, index + 1);
|
|
176714
176781
|
}
|
|
176715
|
-
} else if (
|
|
176716
|
-
deepGet(value,
|
|
176782
|
+
} else if (path64.length) {
|
|
176783
|
+
deepGet(value, path64, index + 1);
|
|
176717
176784
|
}
|
|
176718
176785
|
}
|
|
176719
176786
|
};
|
|
176720
|
-
deepGet(obj, isString2(
|
|
176787
|
+
deepGet(obj, isString2(path63) ? path63.split(".") : path63, 0);
|
|
176721
176788
|
return arr ? list : list[0];
|
|
176722
176789
|
}
|
|
176723
176790
|
var MatchOptions = {
|
|
@@ -177913,9 +177980,9 @@ var registerSearch = (program3) => {
|
|
|
177913
177980
|
}
|
|
177914
177981
|
if (opts.json) {
|
|
177915
177982
|
const unifiedResults = [
|
|
177916
|
-
...kicadResults.map((
|
|
177983
|
+
...kicadResults.map((path63) => ({
|
|
177917
177984
|
source: "kicad",
|
|
177918
|
-
path:
|
|
177985
|
+
path: path63
|
|
177919
177986
|
})),
|
|
177920
177987
|
...results.packages.map((pkg) => ({
|
|
177921
177988
|
source: "tscircuit",
|
|
@@ -177943,8 +178010,8 @@ var registerSearch = (program3) => {
|
|
|
177943
178010
|
}
|
|
177944
178011
|
if (kicadResults.length) {
|
|
177945
178012
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
177946
|
-
kicadResults.forEach((
|
|
177947
|
-
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", "")}`);
|
|
177948
178015
|
});
|
|
177949
178016
|
}
|
|
177950
178017
|
if (results.packages.length) {
|
|
@@ -177968,22 +178035,22 @@ var registerSearch = (program3) => {
|
|
|
177968
178035
|
};
|
|
177969
178036
|
|
|
177970
178037
|
// lib/shared/setup-github-actions.ts
|
|
177971
|
-
import
|
|
177972
|
-
import
|
|
178038
|
+
import fs60 from "node:fs";
|
|
178039
|
+
import path63 from "node:path";
|
|
177973
178040
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
177974
178041
|
const findGitRoot = (startDir) => {
|
|
177975
|
-
let dir =
|
|
177976
|
-
while (dir !==
|
|
177977
|
-
if (
|
|
178042
|
+
let dir = path63.resolve(startDir);
|
|
178043
|
+
while (dir !== path63.parse(dir).root) {
|
|
178044
|
+
if (fs60.existsSync(path63.join(dir, ".git"))) {
|
|
177978
178045
|
return dir;
|
|
177979
178046
|
}
|
|
177980
|
-
dir =
|
|
178047
|
+
dir = path63.dirname(dir);
|
|
177981
178048
|
}
|
|
177982
178049
|
return null;
|
|
177983
178050
|
};
|
|
177984
178051
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
177985
|
-
const workflowsDir =
|
|
177986
|
-
|
|
178052
|
+
const workflowsDir = path63.join(gitRoot, ".github", "workflows");
|
|
178053
|
+
fs60.mkdirSync(workflowsDir, { recursive: true });
|
|
177987
178054
|
const buildWorkflow = `name: tscircuit Build
|
|
177988
178055
|
|
|
177989
178056
|
on:
|
|
@@ -178022,8 +178089,8 @@ jobs:
|
|
|
178022
178089
|
- run: bun install
|
|
178023
178090
|
- run: bunx tsci snapshot
|
|
178024
178091
|
`;
|
|
178025
|
-
writeFileIfNotExists(
|
|
178026
|
-
writeFileIfNotExists(
|
|
178092
|
+
writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
178093
|
+
writeFileIfNotExists(path63.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
178027
178094
|
};
|
|
178028
178095
|
|
|
178029
178096
|
// cli/setup/register.ts
|
|
@@ -178190,21 +178257,21 @@ function applyCameraPreset(preset, cam) {
|
|
|
178190
178257
|
}
|
|
178191
178258
|
|
|
178192
178259
|
// lib/shared/snapshot-project.ts
|
|
178193
|
-
import
|
|
178260
|
+
import path66 from "node:path";
|
|
178194
178261
|
|
|
178195
178262
|
// cli/snapshot/worker-pool.ts
|
|
178196
|
-
import
|
|
178197
|
-
import
|
|
178263
|
+
import fs61 from "node:fs";
|
|
178264
|
+
import path64 from "node:path";
|
|
178198
178265
|
var getWorkerEntrypointPath2 = () => {
|
|
178199
|
-
const tsPath =
|
|
178200
|
-
if (
|
|
178266
|
+
const tsPath = path64.join(import.meta.dir, "snapshot.worker.ts");
|
|
178267
|
+
if (fs61.existsSync(tsPath)) {
|
|
178201
178268
|
return tsPath;
|
|
178202
178269
|
}
|
|
178203
|
-
const jsBundledPath =
|
|
178204
|
-
if (
|
|
178270
|
+
const jsBundledPath = path64.join(import.meta.dir, "snapshot", "snapshot.worker.js");
|
|
178271
|
+
if (fs61.existsSync(jsBundledPath)) {
|
|
178205
178272
|
return jsBundledPath;
|
|
178206
178273
|
}
|
|
178207
|
-
return
|
|
178274
|
+
return path64.join(import.meta.dir, "snapshot.worker.js");
|
|
178208
178275
|
};
|
|
178209
178276
|
var snapshotFilesWithWorkerPool = async (options) => {
|
|
178210
178277
|
const cancellationError = new Error("Snapshot cancelled due to file failure");
|
|
@@ -178271,8 +178338,8 @@ var snapshotFilesWithWorkerPool = async (options) => {
|
|
|
178271
178338
|
};
|
|
178272
178339
|
|
|
178273
178340
|
// lib/shared/process-snapshot-file.ts
|
|
178274
|
-
import
|
|
178275
|
-
import
|
|
178341
|
+
import fs63 from "node:fs";
|
|
178342
|
+
import path65 from "node:path";
|
|
178276
178343
|
import {
|
|
178277
178344
|
convertCircuitJsonToGltf as convertCircuitJsonToGltf5,
|
|
178278
178345
|
getBestCameraPosition
|
|
@@ -178285,7 +178352,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
178285
178352
|
|
|
178286
178353
|
// lib/shared/compare-images.ts
|
|
178287
178354
|
import looksSame from "looks-same";
|
|
178288
|
-
import
|
|
178355
|
+
import fs62 from "node:fs/promises";
|
|
178289
178356
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true) => {
|
|
178290
178357
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
178291
178358
|
strict: false,
|
|
@@ -178301,7 +178368,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath, createDiff = true)
|
|
|
178301
178368
|
tolerance: 2
|
|
178302
178369
|
});
|
|
178303
178370
|
} else {
|
|
178304
|
-
await
|
|
178371
|
+
await fs62.writeFile(diffPath, buffer2);
|
|
178305
178372
|
}
|
|
178306
178373
|
}
|
|
178307
178374
|
return { equal: equal2 };
|
|
@@ -178321,7 +178388,7 @@ var processSnapshotFile = async ({
|
|
|
178321
178388
|
createDiff,
|
|
178322
178389
|
cameraPreset
|
|
178323
178390
|
}) => {
|
|
178324
|
-
const relativeFilePath =
|
|
178391
|
+
const relativeFilePath = path65.relative(projectDir, file);
|
|
178325
178392
|
const successPaths = [];
|
|
178326
178393
|
const warningMessages = [];
|
|
178327
178394
|
const mismatches = [];
|
|
@@ -178331,7 +178398,7 @@ var processSnapshotFile = async ({
|
|
|
178331
178398
|
let schSvg;
|
|
178332
178399
|
try {
|
|
178333
178400
|
if (isCircuitJsonFile(file)) {
|
|
178334
|
-
const parsed = JSON.parse(
|
|
178401
|
+
const parsed = JSON.parse(fs63.readFileSync(file, "utf-8"));
|
|
178335
178402
|
circuitJson = Array.isArray(parsed) ? parsed : [];
|
|
178336
178403
|
} else {
|
|
178337
178404
|
const completePlatformConfig = getCompletePlatformConfig(platformConfig2);
|
|
@@ -178402,12 +178469,12 @@ var processSnapshotFile = async ({
|
|
|
178402
178469
|
} catch (error) {
|
|
178403
178470
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
178404
178471
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
178405
|
-
const fileDir =
|
|
178406
|
-
const relativeDir =
|
|
178407
|
-
const snapDir2 = snapshotsDirName ?
|
|
178408
|
-
const base2 =
|
|
178409
|
-
const snap3dPath =
|
|
178410
|
-
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);
|
|
178411
178478
|
if (existing3dSnapshot) {
|
|
178412
178479
|
return {
|
|
178413
178480
|
ok: false,
|
|
@@ -178418,7 +178485,7 @@ var processSnapshotFile = async ({
|
|
|
178418
178485
|
errorMessage: kleur_default.red(`
|
|
178419
178486
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
178420
178487
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
178421
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
178488
|
+
`) + kleur_default.red(` Existing snapshot: ${path65.relative(projectDir, snap3dPath)}
|
|
178422
178489
|
`)
|
|
178423
178490
|
};
|
|
178424
178491
|
}
|
|
@@ -178439,9 +178506,9 @@ var processSnapshotFile = async ({
|
|
|
178439
178506
|
}
|
|
178440
178507
|
}
|
|
178441
178508
|
}
|
|
178442
|
-
const snapDir = snapshotsDirName ?
|
|
178443
|
-
|
|
178444
|
-
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(/\.[^.]+$/, "");
|
|
178445
178512
|
const snapshots = [];
|
|
178446
178513
|
if (pcbOnly || !schematicOnly) {
|
|
178447
178514
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -178455,31 +178522,31 @@ var processSnapshotFile = async ({
|
|
|
178455
178522
|
for (const snapshot of snapshots) {
|
|
178456
178523
|
const { type } = snapshot;
|
|
178457
178524
|
const is3d = type === "3d";
|
|
178458
|
-
const snapPath =
|
|
178459
|
-
const existing =
|
|
178525
|
+
const snapPath = path65.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
178526
|
+
const existing = fs63.existsSync(snapPath);
|
|
178460
178527
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
178461
178528
|
const newContentForFile = snapshot.content;
|
|
178462
178529
|
if (!existing) {
|
|
178463
|
-
|
|
178464
|
-
successPaths.push(
|
|
178530
|
+
fs63.writeFileSync(snapPath, newContentForFile);
|
|
178531
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178465
178532
|
didUpdate = true;
|
|
178466
178533
|
continue;
|
|
178467
178534
|
}
|
|
178468
|
-
const oldContentBuffer =
|
|
178535
|
+
const oldContentBuffer = fs63.readFileSync(snapPath);
|
|
178469
178536
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
178470
178537
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath, createDiff);
|
|
178471
178538
|
if (update) {
|
|
178472
178539
|
if (!forceUpdate && equal2) {
|
|
178473
|
-
successPaths.push(
|
|
178540
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178474
178541
|
} else {
|
|
178475
|
-
|
|
178476
|
-
successPaths.push(
|
|
178542
|
+
fs63.writeFileSync(snapPath, newContentForFile);
|
|
178543
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178477
178544
|
didUpdate = true;
|
|
178478
178545
|
}
|
|
178479
178546
|
} else if (!equal2) {
|
|
178480
178547
|
mismatches.push(createDiff ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
178481
178548
|
} else {
|
|
178482
|
-
successPaths.push(
|
|
178549
|
+
successPaths.push(path65.relative(projectDir, snapPath));
|
|
178483
178550
|
}
|
|
178484
178551
|
}
|
|
178485
178552
|
return {
|
|
@@ -178516,7 +178583,7 @@ var snapshotProject = async ({
|
|
|
178516
178583
|
...DEFAULT_IGNORED_PATTERNS,
|
|
178517
178584
|
...ignored.map(normalizeIgnorePattern)
|
|
178518
178585
|
];
|
|
178519
|
-
const resolvedPaths = filePaths.map((f2) =>
|
|
178586
|
+
const resolvedPaths = filePaths.map((f2) => path66.resolve(projectDir, f2));
|
|
178520
178587
|
const boardFiles = findBoardFiles({
|
|
178521
178588
|
projectDir,
|
|
178522
178589
|
ignore,
|
|
@@ -178646,7 +178713,7 @@ var registerSnapshot = (program3) => {
|
|
|
178646
178713
|
};
|
|
178647
178714
|
|
|
178648
178715
|
// cli/transpile/register.ts
|
|
178649
|
-
import
|
|
178716
|
+
import path67 from "node:path";
|
|
178650
178717
|
var registerTranspile = (program3) => {
|
|
178651
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) => {
|
|
178652
178719
|
try {
|
|
@@ -178654,7 +178721,7 @@ var registerTranspile = (program3) => {
|
|
|
178654
178721
|
fileOrDir: file,
|
|
178655
178722
|
includeBoardFiles: false
|
|
178656
178723
|
});
|
|
178657
|
-
const distDir =
|
|
178724
|
+
const distDir = path67.join(projectDir, "dist");
|
|
178658
178725
|
validateMainInDist(projectDir, distDir);
|
|
178659
178726
|
console.log("Transpiling entry file...");
|
|
178660
178727
|
const entryFile = mainEntrypoint || circuitFiles[0];
|
|
@@ -178721,6 +178788,7 @@ registerUpgradeCommand(program2);
|
|
|
178721
178788
|
registerDoctor(program2);
|
|
178722
178789
|
registerCheck(program2);
|
|
178723
178790
|
registerCheckNetlist(program2);
|
|
178791
|
+
registerCheckPinSpecification(program2);
|
|
178724
178792
|
registerCheckPlacement(program2);
|
|
178725
178793
|
registerCheckRouting(program2);
|
|
178726
178794
|
registerRegistry(program2);
|