@tscircuit/cli 0.1.594 → 0.1.596
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +557 -489
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -60652,8 +60652,8 @@ var require_utils6 = __commonJS((exports2) => {
|
|
|
60652
60652
|
var result = transform[inputType][outputType](input);
|
|
60653
60653
|
return result;
|
|
60654
60654
|
};
|
|
60655
|
-
exports2.resolve = function(
|
|
60656
|
-
var parts =
|
|
60655
|
+
exports2.resolve = function(path24) {
|
|
60656
|
+
var parts = path24.split("/");
|
|
60657
60657
|
var result = [];
|
|
60658
60658
|
for (var index = 0;index < parts.length; index++) {
|
|
60659
60659
|
var part = parts[index];
|
|
@@ -66103,18 +66103,18 @@ var require_object = __commonJS((exports2, module2) => {
|
|
|
66103
66103
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
66104
66104
|
this.files[name] = object;
|
|
66105
66105
|
};
|
|
66106
|
-
var parentFolder = function(
|
|
66107
|
-
if (
|
|
66108
|
-
|
|
66106
|
+
var parentFolder = function(path24) {
|
|
66107
|
+
if (path24.slice(-1) === "/") {
|
|
66108
|
+
path24 = path24.substring(0, path24.length - 1);
|
|
66109
66109
|
}
|
|
66110
|
-
var lastSlash =
|
|
66111
|
-
return lastSlash > 0 ?
|
|
66110
|
+
var lastSlash = path24.lastIndexOf("/");
|
|
66111
|
+
return lastSlash > 0 ? path24.substring(0, lastSlash) : "";
|
|
66112
66112
|
};
|
|
66113
|
-
var forceTrailingSlash = function(
|
|
66114
|
-
if (
|
|
66115
|
-
|
|
66113
|
+
var forceTrailingSlash = function(path24) {
|
|
66114
|
+
if (path24.slice(-1) !== "/") {
|
|
66115
|
+
path24 += "/";
|
|
66116
66116
|
}
|
|
66117
|
-
return
|
|
66117
|
+
return path24;
|
|
66118
66118
|
};
|
|
66119
66119
|
var folderAdd = function(name, createFolders) {
|
|
66120
66120
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -67193,7 +67193,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67193
67193
|
});
|
|
67194
67194
|
};
|
|
67195
67195
|
traverse(program3, []);
|
|
67196
|
-
return allCommandPaths.filter((
|
|
67196
|
+
return allCommandPaths.filter((path27) => path27 !== "");
|
|
67197
67197
|
};
|
|
67198
67198
|
var normalizeCommandName = (s) => s.replace(/_/g, "-").toLowerCase();
|
|
67199
67199
|
var getCommandFromPath = (program3, commandPathAndPositionalArgs) => {
|
|
@@ -67201,7 +67201,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67201
67201
|
return commandPath.reduce((curr, nextCommandName) => !curr ? null : curr.commands.find((c) => normalizeCommandName(c.name()) === normalizeCommandName(nextCommandName)), program3);
|
|
67202
67202
|
};
|
|
67203
67203
|
var getCommandPathOnly = (program3, commandPathAndPositionalArgs) => {
|
|
67204
|
-
const allLeafCommandPaths = getAllLeafCommandPaths(program3).map((
|
|
67204
|
+
const allLeafCommandPaths = getAllLeafCommandPaths(program3).map((path27) => normalizeCommandName(path27));
|
|
67205
67205
|
const commandPath = [];
|
|
67206
67206
|
for (const elm of commandPathAndPositionalArgs) {
|
|
67207
67207
|
if (elm.startsWith("-"))
|
|
@@ -67973,8 +67973,8 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67973
67973
|
return new Minimatch(pattern, options).match(p);
|
|
67974
67974
|
};
|
|
67975
67975
|
module22.exports = minimatch;
|
|
67976
|
-
var
|
|
67977
|
-
minimatch.sep =
|
|
67976
|
+
var path27 = require_path2();
|
|
67977
|
+
minimatch.sep = path27.sep;
|
|
67978
67978
|
var GLOBSTAR = Symbol("globstar **");
|
|
67979
67979
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
67980
67980
|
var expand = require_brace_expansion();
|
|
@@ -68465,8 +68465,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68465
68465
|
if (f === "/" && partial)
|
|
68466
68466
|
return true;
|
|
68467
68467
|
const options = this.options;
|
|
68468
|
-
if (
|
|
68469
|
-
f = f.split(
|
|
68468
|
+
if (path27.sep !== "/") {
|
|
68469
|
+
f = f.split(path27.sep).join("/");
|
|
68470
68470
|
}
|
|
68471
68471
|
f = f.split(slashSplit);
|
|
68472
68472
|
this.debug(this.pattern, "split", f);
|
|
@@ -68557,7 +68557,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68557
68557
|
return Object.prototype.hasOwnProperty.call(obj, field);
|
|
68558
68558
|
}
|
|
68559
68559
|
var fs26 = __require("fs");
|
|
68560
|
-
var
|
|
68560
|
+
var path27 = __require("path");
|
|
68561
68561
|
var minimatch = require_minimatch();
|
|
68562
68562
|
var isAbsolute3 = __require("path").isAbsolute;
|
|
68563
68563
|
var Minimatch = minimatch.Minimatch;
|
|
@@ -68620,13 +68620,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68620
68620
|
self2.changedCwd = false;
|
|
68621
68621
|
var cwd = process.cwd();
|
|
68622
68622
|
if (!ownProp(options, "cwd"))
|
|
68623
|
-
self2.cwd =
|
|
68623
|
+
self2.cwd = path27.resolve(cwd);
|
|
68624
68624
|
else {
|
|
68625
|
-
self2.cwd =
|
|
68625
|
+
self2.cwd = path27.resolve(options.cwd);
|
|
68626
68626
|
self2.changedCwd = self2.cwd !== cwd;
|
|
68627
68627
|
}
|
|
68628
|
-
self2.root = options.root ||
|
|
68629
|
-
self2.root =
|
|
68628
|
+
self2.root = options.root || path27.resolve(self2.cwd, "/");
|
|
68629
|
+
self2.root = path27.resolve(self2.root);
|
|
68630
68630
|
self2.cwdAbs = isAbsolute3(self2.cwd) ? self2.cwd : makeAbs(self2, self2.cwd);
|
|
68631
68631
|
self2.nomount = !!options.nomount;
|
|
68632
68632
|
if (process.platform === "win32") {
|
|
@@ -68709,13 +68709,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68709
68709
|
function makeAbs(self2, f) {
|
|
68710
68710
|
var abs = f;
|
|
68711
68711
|
if (f.charAt(0) === "/") {
|
|
68712
|
-
abs =
|
|
68712
|
+
abs = path27.join(self2.root, f);
|
|
68713
68713
|
} else if (isAbsolute3(f) || f === "") {
|
|
68714
68714
|
abs = f;
|
|
68715
68715
|
} else if (self2.changedCwd) {
|
|
68716
|
-
abs =
|
|
68716
|
+
abs = path27.resolve(self2.cwd, f);
|
|
68717
68717
|
} else {
|
|
68718
|
-
abs =
|
|
68718
|
+
abs = path27.resolve(f);
|
|
68719
68719
|
}
|
|
68720
68720
|
if (process.platform === "win32")
|
|
68721
68721
|
abs = abs.replace(/\\/g, "/");
|
|
@@ -68746,7 +68746,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68746
68746
|
var Minimatch = minimatch.Minimatch;
|
|
68747
68747
|
var Glob = require_glob().Glob;
|
|
68748
68748
|
var util = __require("util");
|
|
68749
|
-
var
|
|
68749
|
+
var path27 = __require("path");
|
|
68750
68750
|
var assert2 = __require("assert");
|
|
68751
68751
|
var isAbsolute3 = __require("path").isAbsolute;
|
|
68752
68752
|
var common = require_common4();
|
|
@@ -68876,7 +68876,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
68876
68876
|
e = prefix + e;
|
|
68877
68877
|
}
|
|
68878
68878
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
68879
|
-
e =
|
|
68879
|
+
e = path27.join(this.root, e);
|
|
68880
68880
|
}
|
|
68881
68881
|
this._emitMatch(index, e);
|
|
68882
68882
|
}
|
|
@@ -69025,9 +69025,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
69025
69025
|
if (prefix && isAbsolute3(prefix) && !this.nomount) {
|
|
69026
69026
|
var trail = /[\/\\]$/.test(prefix);
|
|
69027
69027
|
if (prefix.charAt(0) === "/") {
|
|
69028
|
-
prefix =
|
|
69028
|
+
prefix = path27.join(this.root, prefix);
|
|
69029
69029
|
} else {
|
|
69030
|
-
prefix =
|
|
69030
|
+
prefix = path27.resolve(this.root, prefix);
|
|
69031
69031
|
if (trail)
|
|
69032
69032
|
prefix += "/";
|
|
69033
69033
|
}
|
|
@@ -69214,7 +69214,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
69214
69214
|
var Minimatch = minimatch.Minimatch;
|
|
69215
69215
|
var inherits = require_inherits2();
|
|
69216
69216
|
var EE = __require("events").EventEmitter;
|
|
69217
|
-
var
|
|
69217
|
+
var path27 = __require("path");
|
|
69218
69218
|
var assert2 = __require("assert");
|
|
69219
69219
|
var isAbsolute3 = __require("path").isAbsolute;
|
|
69220
69220
|
var globSync = require_sync7();
|
|
@@ -69497,7 +69497,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
69497
69497
|
e = prefix + e;
|
|
69498
69498
|
}
|
|
69499
69499
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
69500
|
-
e =
|
|
69500
|
+
e = path27.join(this.root, e);
|
|
69501
69501
|
}
|
|
69502
69502
|
this._emitMatch(index, e);
|
|
69503
69503
|
}
|
|
@@ -69684,9 +69684,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
69684
69684
|
if (prefix && isAbsolute3(prefix) && !this.nomount) {
|
|
69685
69685
|
var trail = /[\/\\]$/.test(prefix);
|
|
69686
69686
|
if (prefix.charAt(0) === "/") {
|
|
69687
|
-
prefix =
|
|
69687
|
+
prefix = path27.join(this.root, prefix);
|
|
69688
69688
|
} else {
|
|
69689
|
-
prefix =
|
|
69689
|
+
prefix = path27.resolve(this.root, prefix);
|
|
69690
69690
|
if (trail)
|
|
69691
69691
|
prefix += "/";
|
|
69692
69692
|
}
|
|
@@ -69870,7 +69870,7 @@ export default {
|
|
|
69870
69870
|
}
|
|
69871
69871
|
case "export-pathlist": {
|
|
69872
69872
|
return `export default [
|
|
69873
|
-
` + Object.keys(vfs).map((
|
|
69873
|
+
` + Object.keys(vfs).map((path27) => ` "${path27}"`).join(`,
|
|
69874
69874
|
`) + `
|
|
69875
69875
|
]`;
|
|
69876
69876
|
}
|
|
@@ -72718,7 +72718,7 @@ export default () => (
|
|
|
72718
72718
|
// cli/dev/register.ts
|
|
72719
72719
|
import * as fs22 from "node:fs";
|
|
72720
72720
|
import * as net from "node:net";
|
|
72721
|
-
import * as
|
|
72721
|
+
import * as path23 from "node:path";
|
|
72722
72722
|
|
|
72723
72723
|
// lib/dependency-analysis/installNodeModuleTypesForSnippet.ts
|
|
72724
72724
|
import * as fs8 from "node:fs";
|
|
@@ -74438,7 +74438,7 @@ class EventsWatcher extends EventEmitter {
|
|
|
74438
74438
|
}
|
|
74439
74439
|
|
|
74440
74440
|
// cli/dev/DevServer.ts
|
|
74441
|
-
import
|
|
74441
|
+
import path21 from "node:path";
|
|
74442
74442
|
import fs20 from "node:fs";
|
|
74443
74443
|
|
|
74444
74444
|
// node_modules/chokidar/esm/index.js
|
|
@@ -76143,7 +76143,7 @@ var getRegistryApiKy = ({
|
|
|
76143
76143
|
// lib/shared/push-snippet.ts
|
|
76144
76144
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
76145
76145
|
import * as fs16 from "node:fs";
|
|
76146
|
-
import * as
|
|
76146
|
+
import * as path17 from "node:path";
|
|
76147
76147
|
import Debug from "debug";
|
|
76148
76148
|
|
|
76149
76149
|
// lib/shared/get-entrypoint.ts
|
|
@@ -76844,6 +76844,44 @@ var checkOrgAccess = async (ky2, accountName) => {
|
|
|
76844
76844
|
}
|
|
76845
76845
|
};
|
|
76846
76846
|
|
|
76847
|
+
// lib/shared/is-binary-file.ts
|
|
76848
|
+
import * as path16 from "node:path";
|
|
76849
|
+
var BINARY_FILE_EXTENSIONS = new Set([
|
|
76850
|
+
".glb",
|
|
76851
|
+
".gltf",
|
|
76852
|
+
".obj",
|
|
76853
|
+
".stl",
|
|
76854
|
+
".step",
|
|
76855
|
+
".png",
|
|
76856
|
+
".jpg",
|
|
76857
|
+
".jpeg",
|
|
76858
|
+
".gif",
|
|
76859
|
+
".webp",
|
|
76860
|
+
".zip",
|
|
76861
|
+
".gz",
|
|
76862
|
+
".tar"
|
|
76863
|
+
]);
|
|
76864
|
+
var isBinaryFile = (filePath) => {
|
|
76865
|
+
const ext = path16.extname(filePath).toLowerCase();
|
|
76866
|
+
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
76867
|
+
};
|
|
76868
|
+
|
|
76869
|
+
// lib/shared/has-binary-content.ts
|
|
76870
|
+
var hasBinaryContent = (content) => {
|
|
76871
|
+
const checkLength = Math.min(content.length, 8192);
|
|
76872
|
+
const slice = content.subarray(0, checkLength);
|
|
76873
|
+
const decoded = slice.toString("utf-8");
|
|
76874
|
+
if (decoded.includes("�")) {
|
|
76875
|
+
return true;
|
|
76876
|
+
}
|
|
76877
|
+
for (let i = 0;i < checkLength; i++) {
|
|
76878
|
+
if (content[i] === 0) {
|
|
76879
|
+
return true;
|
|
76880
|
+
}
|
|
76881
|
+
}
|
|
76882
|
+
return false;
|
|
76883
|
+
};
|
|
76884
|
+
|
|
76847
76885
|
// lib/shared/push-snippet.ts
|
|
76848
76886
|
var debug = Debug("tsci:push-snippet");
|
|
76849
76887
|
var pushSnippet = async ({
|
|
@@ -76869,10 +76907,10 @@ var pushSnippet = async ({
|
|
|
76869
76907
|
return onExit(1);
|
|
76870
76908
|
}
|
|
76871
76909
|
const packageJsonPath = [
|
|
76872
|
-
|
|
76873
|
-
|
|
76874
|
-
].find((
|
|
76875
|
-
const projectDir = packageJsonPath ?
|
|
76910
|
+
path17.resolve(path17.join(path17.dirname(snippetFilePath), "package.json")),
|
|
76911
|
+
path17.resolve(path17.join(process.cwd(), "package.json"))
|
|
76912
|
+
].find((path18) => fs16.existsSync(path18));
|
|
76913
|
+
const projectDir = packageJsonPath ? path17.dirname(packageJsonPath) : path17.dirname(snippetFilePath);
|
|
76876
76914
|
if (!packageJsonPath) {
|
|
76877
76915
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
76878
76916
|
return onExit(1);
|
|
@@ -77043,18 +77081,33 @@ var pushSnippet = async ({
|
|
|
77043
77081
|
`);
|
|
77044
77082
|
const filePaths = getPackageFilePaths(projectDir);
|
|
77045
77083
|
for (const fullFilePath of filePaths) {
|
|
77046
|
-
const relativeFilePath =
|
|
77047
|
-
const
|
|
77084
|
+
const relativeFilePath = path17.relative(projectDir, fullFilePath);
|
|
77085
|
+
const fileBuffer = fs16.readFileSync(fullFilePath);
|
|
77086
|
+
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
77087
|
+
const payload = {
|
|
77088
|
+
file_path: relativeFilePath,
|
|
77089
|
+
package_name_with_version: `${scopedPackageName}@${releaseVersion}`
|
|
77090
|
+
};
|
|
77091
|
+
if (isBinary) {
|
|
77092
|
+
payload.content_base64 = fileBuffer.toString("base64");
|
|
77093
|
+
} else {
|
|
77094
|
+
payload.content_text = fileBuffer.toString("utf-8");
|
|
77095
|
+
}
|
|
77048
77096
|
await ky2.post("package_files/create", {
|
|
77049
|
-
json:
|
|
77050
|
-
file_path: relativeFilePath,
|
|
77051
|
-
content_text: fileContent,
|
|
77052
|
-
package_name_with_version: `${scopedPackageName}@${releaseVersion}`
|
|
77053
|
-
}
|
|
77097
|
+
json: payload
|
|
77054
77098
|
}).json().then((response) => {
|
|
77055
|
-
|
|
77056
|
-
|
|
77057
|
-
|
|
77099
|
+
const icon = isBinary ? "\uD83D\uDCE6" : "⬆︎";
|
|
77100
|
+
console.log(kleur_default.gray(`${icon} ${relativeFilePath}`));
|
|
77101
|
+
}).catch(async (error) => {
|
|
77102
|
+
let errorDetails = "";
|
|
77103
|
+
try {
|
|
77104
|
+
const errorResponse = await error.response?.json();
|
|
77105
|
+
if (errorResponse?.error?.message) {
|
|
77106
|
+
errorDetails = `: ${errorResponse.error.message}`;
|
|
77107
|
+
}
|
|
77108
|
+
} catch {}
|
|
77109
|
+
onError(`Error uploading file "${relativeFilePath}"${errorDetails}
|
|
77110
|
+
` + ` Full path: ${fullFilePath}`);
|
|
77058
77111
|
return onExit(1);
|
|
77059
77112
|
});
|
|
77060
77113
|
}
|
|
@@ -77074,7 +77127,7 @@ var pushSnippet = async ({
|
|
|
77074
77127
|
|
|
77075
77128
|
// lib/shared/add-package.ts
|
|
77076
77129
|
import * as fs18 from "node:fs";
|
|
77077
|
-
import * as
|
|
77130
|
+
import * as path19 from "node:path";
|
|
77078
77131
|
|
|
77079
77132
|
// lib/shared/resolve-tarball-url-from-registry.ts
|
|
77080
77133
|
async function resolveTarballUrlFromRegistry(packageName) {
|
|
@@ -77104,7 +77157,7 @@ async function resolveTarballUrlFromRegistry(packageName) {
|
|
|
77104
77157
|
|
|
77105
77158
|
// lib/shared/detect-and-setup-kicad-library.ts
|
|
77106
77159
|
import * as fs17 from "node:fs";
|
|
77107
|
-
import * as
|
|
77160
|
+
import * as path18 from "node:path";
|
|
77108
77161
|
var import_strip_json_comments = __toESM2(require_strip_json_comments(), 1);
|
|
77109
77162
|
function extractPackageName(packageSpec) {
|
|
77110
77163
|
if (packageSpec.startsWith("http")) {
|
|
@@ -77133,7 +77186,7 @@ function extractPackageName(packageSpec) {
|
|
|
77133
77186
|
async function detectAndSetupKicadLibrary(packageSpec, projectDir = process.cwd()) {
|
|
77134
77187
|
try {
|
|
77135
77188
|
const packageName = extractPackageName(packageSpec);
|
|
77136
|
-
const nodeModulesPath =
|
|
77189
|
+
const nodeModulesPath = path18.join(projectDir, "node_modules", packageName);
|
|
77137
77190
|
if (!fs17.existsSync(nodeModulesPath)) {
|
|
77138
77191
|
return false;
|
|
77139
77192
|
}
|
|
@@ -77156,10 +77209,10 @@ async function detectAndSetupKicadLibrary(packageSpec, projectDir = process.cwd(
|
|
|
77156
77209
|
}
|
|
77157
77210
|
}
|
|
77158
77211
|
async function generateKicadTypes(projectDir, packageName, kicadModFiles) {
|
|
77159
|
-
const typesDir =
|
|
77212
|
+
const typesDir = path18.join(projectDir, "types");
|
|
77160
77213
|
fs17.mkdirSync(typesDir, { recursive: true });
|
|
77161
77214
|
const typeFileName = `${packageName.replace(/[@/]/g, "-")}.d.ts`;
|
|
77162
|
-
const typesFilePath =
|
|
77215
|
+
const typesFilePath = path18.join(typesDir, typeFileName);
|
|
77163
77216
|
const declarations = kicadModFiles.map((filePath) => {
|
|
77164
77217
|
const modulePath = `${packageName}/${filePath}`;
|
|
77165
77218
|
return `declare module "${modulePath}" {
|
|
@@ -77173,7 +77226,7 @@ async function generateKicadTypes(projectDir, packageName, kicadModFiles) {
|
|
|
77173
77226
|
console.log(kleur_default.green(`✓ Generated types at ${kleur_default.cyan(`types/${typeFileName}`)}`));
|
|
77174
77227
|
}
|
|
77175
77228
|
async function setupTsConfig(projectDir) {
|
|
77176
|
-
const tsconfigPath =
|
|
77229
|
+
const tsconfigPath = path18.join(projectDir, "tsconfig.json");
|
|
77177
77230
|
if (!fs17.existsSync(tsconfigPath)) {
|
|
77178
77231
|
console.log(kleur_default.dim("Creating tsconfig.json..."));
|
|
77179
77232
|
generateTsConfig(projectDir);
|
|
@@ -77221,7 +77274,7 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
77221
77274
|
let installTarget = normalizedName || packageSpec;
|
|
77222
77275
|
console.log(kleur_default.cyan(`Adding ${kleur_default.bold(displayName)}...`));
|
|
77223
77276
|
if (normalizedName && normalizedName.startsWith("@tsci/")) {
|
|
77224
|
-
const npmrcPath =
|
|
77277
|
+
const npmrcPath = path19.join(projectDir, ".npmrc");
|
|
77225
77278
|
const npmrcContent = fs18.existsSync(npmrcPath) ? fs18.readFileSync(npmrcPath, "utf-8") : "";
|
|
77226
77279
|
let hasTsciRegistry = /@tsci[/:]/.test(npmrcContent);
|
|
77227
77280
|
if (!hasTsciRegistry) {
|
|
@@ -77264,10 +77317,10 @@ import Debug2 from "debug";
|
|
|
77264
77317
|
|
|
77265
77318
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
77266
77319
|
import * as ts3 from "typescript";
|
|
77267
|
-
import * as
|
|
77320
|
+
import * as path20 from "path";
|
|
77268
77321
|
import * as fs19 from "fs";
|
|
77269
77322
|
function getLocalPackages(projectDir) {
|
|
77270
|
-
const packageJsonPath =
|
|
77323
|
+
const packageJsonPath = path20.join(projectDir, "package.json");
|
|
77271
77324
|
const localPackages = new Set;
|
|
77272
77325
|
if (!fs19.existsSync(packageJsonPath)) {
|
|
77273
77326
|
return localPackages;
|
|
@@ -77291,7 +77344,7 @@ function getLocalPackages(projectDir) {
|
|
|
77291
77344
|
return localPackages;
|
|
77292
77345
|
}
|
|
77293
77346
|
function getAllDependencyPackages(projectDir) {
|
|
77294
|
-
const packageJsonPath =
|
|
77347
|
+
const packageJsonPath = path20.join(projectDir, "package.json");
|
|
77295
77348
|
const allPackages = new Set;
|
|
77296
77349
|
if (!fs19.existsSync(packageJsonPath)) {
|
|
77297
77350
|
return allPackages;
|
|
@@ -77308,7 +77361,7 @@ function getAllDependencyPackages(projectDir) {
|
|
|
77308
77361
|
return allPackages;
|
|
77309
77362
|
}
|
|
77310
77363
|
function getNodeModuleImports(filePath) {
|
|
77311
|
-
const absolutePath =
|
|
77364
|
+
const absolutePath = path20.resolve(filePath);
|
|
77312
77365
|
if (!fs19.existsSync(absolutePath)) {
|
|
77313
77366
|
return [];
|
|
77314
77367
|
}
|
|
@@ -77362,17 +77415,17 @@ function resolveNodeModuleImport({
|
|
|
77362
77415
|
}) {
|
|
77363
77416
|
const packageName = getPackageNameFromImport(importPath);
|
|
77364
77417
|
const searchPaths = [
|
|
77365
|
-
|
|
77418
|
+
path20.join(projectDir, "node_modules", packageName)
|
|
77366
77419
|
];
|
|
77367
77420
|
if (searchFromDir) {
|
|
77368
|
-
let currentDir =
|
|
77369
|
-
const projectDirNormalized =
|
|
77421
|
+
let currentDir = path20.dirname(searchFromDir);
|
|
77422
|
+
const projectDirNormalized = path20.normalize(projectDir);
|
|
77370
77423
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
77371
|
-
const candidatePath =
|
|
77424
|
+
const candidatePath = path20.join(currentDir, "node_modules", packageName);
|
|
77372
77425
|
if (!searchPaths.includes(candidatePath)) {
|
|
77373
77426
|
searchPaths.push(candidatePath);
|
|
77374
77427
|
}
|
|
77375
|
-
const parentDir =
|
|
77428
|
+
const parentDir = path20.dirname(currentDir);
|
|
77376
77429
|
if (parentDir === currentDir)
|
|
77377
77430
|
break;
|
|
77378
77431
|
currentDir = parentDir;
|
|
@@ -77388,7 +77441,7 @@ function resolveNodeModuleImport({
|
|
|
77388
77441
|
if (!packageDir) {
|
|
77389
77442
|
return [];
|
|
77390
77443
|
}
|
|
77391
|
-
const packageJsonPath =
|
|
77444
|
+
const packageJsonPath = path20.join(packageDir, "package.json");
|
|
77392
77445
|
if (!fs19.existsSync(packageJsonPath)) {
|
|
77393
77446
|
return [];
|
|
77394
77447
|
}
|
|
@@ -77397,15 +77450,15 @@ function resolveNodeModuleImport({
|
|
|
77397
77450
|
if (importPath !== packageName) {
|
|
77398
77451
|
const subpath = importPath.slice(packageName.length + 1);
|
|
77399
77452
|
const possiblePaths = [
|
|
77400
|
-
|
|
77401
|
-
|
|
77402
|
-
|
|
77403
|
-
|
|
77404
|
-
|
|
77405
|
-
|
|
77406
|
-
|
|
77407
|
-
|
|
77408
|
-
|
|
77453
|
+
path20.join(packageDir, subpath),
|
|
77454
|
+
path20.join(packageDir, `${subpath}.js`),
|
|
77455
|
+
path20.join(packageDir, `${subpath}.mjs`),
|
|
77456
|
+
path20.join(packageDir, `${subpath}.ts`),
|
|
77457
|
+
path20.join(packageDir, `${subpath}.tsx`),
|
|
77458
|
+
path20.join(packageDir, subpath, "index.js"),
|
|
77459
|
+
path20.join(packageDir, subpath, "index.mjs"),
|
|
77460
|
+
path20.join(packageDir, subpath, "index.ts"),
|
|
77461
|
+
path20.join(packageDir, subpath, "index.tsx")
|
|
77409
77462
|
];
|
|
77410
77463
|
for (const p of possiblePaths) {
|
|
77411
77464
|
if (fs19.existsSync(p) && fs19.statSync(p).isFile()) {
|
|
@@ -77414,30 +77467,45 @@ function resolveNodeModuleImport({
|
|
|
77414
77467
|
}
|
|
77415
77468
|
}
|
|
77416
77469
|
}
|
|
77470
|
+
const resolveExportValue = (value) => {
|
|
77471
|
+
if (typeof value === "string")
|
|
77472
|
+
return value;
|
|
77473
|
+
if (value && typeof value === "object" && "default" in value) {
|
|
77474
|
+
const defaultVal = value.default;
|
|
77475
|
+
if (typeof defaultVal === "string")
|
|
77476
|
+
return defaultVal;
|
|
77477
|
+
if (defaultVal && typeof defaultVal === "object" && "default" in defaultVal) {
|
|
77478
|
+
const nestedDefault = defaultVal.default;
|
|
77479
|
+
if (typeof nestedDefault === "string")
|
|
77480
|
+
return nestedDefault;
|
|
77481
|
+
}
|
|
77482
|
+
}
|
|
77483
|
+
return;
|
|
77484
|
+
};
|
|
77417
77485
|
const entryPoints = [
|
|
77418
77486
|
packageJson.main,
|
|
77419
77487
|
packageJson.module,
|
|
77420
|
-
packageJson.exports?.["."]?.default,
|
|
77421
|
-
packageJson.exports?.["."]?.import,
|
|
77422
|
-
packageJson.exports?.["."]?.require
|
|
77423
|
-
].filter(
|
|
77488
|
+
resolveExportValue(packageJson.exports?.["."]?.default),
|
|
77489
|
+
resolveExportValue(packageJson.exports?.["."]?.import),
|
|
77490
|
+
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
77491
|
+
].filter((entry) => typeof entry === "string");
|
|
77424
77492
|
for (const entry of entryPoints) {
|
|
77425
|
-
const entryPath =
|
|
77493
|
+
const entryPath = path20.join(packageDir, entry);
|
|
77426
77494
|
if (fs19.existsSync(entryPath) && fs19.statSync(entryPath).isFile()) {
|
|
77427
77495
|
resolvedFiles.push(entryPath);
|
|
77428
77496
|
}
|
|
77429
77497
|
}
|
|
77430
77498
|
if (resolvedFiles.length === 0) {
|
|
77431
77499
|
const fallbackPaths = [
|
|
77432
|
-
|
|
77433
|
-
|
|
77434
|
-
|
|
77435
|
-
|
|
77436
|
-
|
|
77437
|
-
|
|
77438
|
-
|
|
77439
|
-
|
|
77440
|
-
|
|
77500
|
+
path20.join(packageDir, "index.js"),
|
|
77501
|
+
path20.join(packageDir, "index.mjs"),
|
|
77502
|
+
path20.join(packageDir, "index.ts"),
|
|
77503
|
+
path20.join(packageDir, "index.tsx"),
|
|
77504
|
+
path20.join(packageDir, "dist", "index.js"),
|
|
77505
|
+
path20.join(packageDir, "dist", "index.mjs"),
|
|
77506
|
+
path20.join(packageDir, "lib", "index.js"),
|
|
77507
|
+
path20.join(packageDir, "src", "index.ts"),
|
|
77508
|
+
path20.join(packageDir, "src", "index.tsx")
|
|
77441
77509
|
];
|
|
77442
77510
|
for (const p of fallbackPaths) {
|
|
77443
77511
|
if (fs19.existsSync(p) && fs19.statSync(p).isFile()) {
|
|
@@ -77478,8 +77546,8 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
77478
77546
|
}
|
|
77479
77547
|
}
|
|
77480
77548
|
function getLocalDependencies(filePath) {
|
|
77481
|
-
const absolutePath =
|
|
77482
|
-
const baseDir =
|
|
77549
|
+
const absolutePath = path20.resolve(filePath);
|
|
77550
|
+
const baseDir = path20.dirname(absolutePath);
|
|
77483
77551
|
if (!fs19.existsSync(absolutePath)) {
|
|
77484
77552
|
return [];
|
|
77485
77553
|
}
|
|
@@ -77505,7 +77573,7 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
77505
77573
|
}
|
|
77506
77574
|
function resolveLocalImport(importPath, baseDir) {
|
|
77507
77575
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
77508
|
-
const resolvedPath =
|
|
77576
|
+
const resolvedPath = path20.resolve(baseDir, importPath);
|
|
77509
77577
|
if (fs19.existsSync(resolvedPath) && fs19.statSync(resolvedPath).isFile()) {
|
|
77510
77578
|
return resolvedPath;
|
|
77511
77579
|
}
|
|
@@ -77517,7 +77585,7 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
77517
77585
|
}
|
|
77518
77586
|
if (fs19.existsSync(resolvedPath) && fs19.statSync(resolvedPath).isDirectory()) {
|
|
77519
77587
|
for (const ext of extensions) {
|
|
77520
|
-
const indexPath =
|
|
77588
|
+
const indexPath = path20.join(resolvedPath, `index${ext}`);
|
|
77521
77589
|
if (fs19.existsSync(indexPath)) {
|
|
77522
77590
|
return indexPath;
|
|
77523
77591
|
}
|
|
@@ -77543,11 +77611,11 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
77543
77611
|
function collectLocalPackageFiles(packageDir) {
|
|
77544
77612
|
const buildDirs = ["dist", "build"];
|
|
77545
77613
|
for (const dirName of buildDirs) {
|
|
77546
|
-
const dirPath =
|
|
77614
|
+
const dirPath = path20.join(packageDir, dirName);
|
|
77547
77615
|
if (fs19.existsSync(dirPath)) {
|
|
77548
77616
|
const files = walkDirectory(dirPath, new Set);
|
|
77549
77617
|
if (files.length > 0) {
|
|
77550
|
-
const packageJsonPath =
|
|
77618
|
+
const packageJsonPath = path20.join(packageDir, "package.json");
|
|
77551
77619
|
if (fs19.existsSync(packageJsonPath)) {
|
|
77552
77620
|
files.push(packageJsonPath);
|
|
77553
77621
|
}
|
|
@@ -77563,7 +77631,7 @@ function walkDirectory(dir, excludedDirs) {
|
|
|
77563
77631
|
return files;
|
|
77564
77632
|
const entries = fs19.readdirSync(dir, { withFileTypes: true });
|
|
77565
77633
|
for (const entry of entries) {
|
|
77566
|
-
const fullPath =
|
|
77634
|
+
const fullPath = path20.join(dir, entry.name);
|
|
77567
77635
|
if (entry.isDirectory()) {
|
|
77568
77636
|
if (excludedDirs.has(entry.name)) {
|
|
77569
77637
|
continue;
|
|
@@ -77631,9 +77699,9 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
77631
77699
|
processedPackages.add(packageName);
|
|
77632
77700
|
if (resolvedFiles.length > 0) {
|
|
77633
77701
|
const firstResolvedFile = resolvedFiles[0];
|
|
77634
|
-
let packageDir =
|
|
77702
|
+
let packageDir = path20.dirname(firstResolvedFile);
|
|
77635
77703
|
while (packageDir.includes("node_modules")) {
|
|
77636
|
-
const packageJsonPath =
|
|
77704
|
+
const packageJsonPath = path20.join(packageDir, "package.json");
|
|
77637
77705
|
if (fs19.existsSync(packageJsonPath)) {
|
|
77638
77706
|
try {
|
|
77639
77707
|
const pkgJson = JSON.parse(fs19.readFileSync(packageJsonPath, "utf-8"));
|
|
@@ -77642,7 +77710,7 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
77642
77710
|
}
|
|
77643
77711
|
} catch {}
|
|
77644
77712
|
}
|
|
77645
|
-
const parentDir =
|
|
77713
|
+
const parentDir = path20.dirname(packageDir);
|
|
77646
77714
|
if (parentDir === packageDir)
|
|
77647
77715
|
break;
|
|
77648
77716
|
packageDir = parentDir;
|
|
@@ -77659,7 +77727,7 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
77659
77727
|
|
|
77660
77728
|
// cli/dev/DevServer.ts
|
|
77661
77729
|
var debug2 = Debug2("tscircuit:devserver");
|
|
77662
|
-
var
|
|
77730
|
+
var BINARY_FILE_EXTENSIONS2 = new Set([".glb", ".png", ".jpeg", ".jpg"]);
|
|
77663
77731
|
|
|
77664
77732
|
class DevServer {
|
|
77665
77733
|
port;
|
|
@@ -77679,7 +77747,7 @@ class DevServer {
|
|
|
77679
77747
|
}) {
|
|
77680
77748
|
this.port = port;
|
|
77681
77749
|
this.componentFilePath = componentFilePath;
|
|
77682
|
-
this.projectDir = projectDir ??
|
|
77750
|
+
this.projectDir = projectDir ?? path21.dirname(componentFilePath);
|
|
77683
77751
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
77684
77752
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
77685
77753
|
this.fsKy = distribution_default.create({
|
|
@@ -77690,7 +77758,7 @@ class DevServer {
|
|
|
77690
77758
|
async start() {
|
|
77691
77759
|
const { server } = await createHttpServer({
|
|
77692
77760
|
port: this.port,
|
|
77693
|
-
defaultMainComponentPath:
|
|
77761
|
+
defaultMainComponentPath: path21.relative(this.projectDir, this.componentFilePath)
|
|
77694
77762
|
});
|
|
77695
77763
|
this.httpServer = server;
|
|
77696
77764
|
this.eventsWatcher = new EventsWatcher(`http://localhost:${this.port}`);
|
|
@@ -77703,7 +77771,7 @@ class DevServer {
|
|
|
77703
77771
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
77704
77772
|
persistent: true,
|
|
77705
77773
|
ignoreInitial: true,
|
|
77706
|
-
ignored: (p) => shouldIgnorePath(
|
|
77774
|
+
ignored: (p) => shouldIgnorePath(path21.relative(this.projectDir, p), this.ignoredFiles)
|
|
77707
77775
|
});
|
|
77708
77776
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
77709
77777
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -77719,8 +77787,8 @@ class DevServer {
|
|
|
77719
77787
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
77720
77788
|
searchParams: { file_path: ev.file_path }
|
|
77721
77789
|
}).json();
|
|
77722
|
-
const fullPath =
|
|
77723
|
-
const dirPath =
|
|
77790
|
+
const fullPath = path21.join(this.projectDir, ev.file_path);
|
|
77791
|
+
const dirPath = path21.dirname(fullPath);
|
|
77724
77792
|
if (!fs20.existsSync(dirPath)) {
|
|
77725
77793
|
fs20.mkdirSync(dirPath, { recursive: true });
|
|
77726
77794
|
}
|
|
@@ -77732,14 +77800,14 @@ class DevServer {
|
|
|
77732
77800
|
}
|
|
77733
77801
|
}
|
|
77734
77802
|
async handleFileDeletedEventFromServer(ev) {
|
|
77735
|
-
const fullPath =
|
|
77803
|
+
const fullPath = path21.join(this.projectDir, ev.file_path);
|
|
77736
77804
|
if (fs20.existsSync(fullPath)) {
|
|
77737
77805
|
debug2(`Deleting file ${ev.file_path} from filesystem`);
|
|
77738
77806
|
fs20.unlinkSync(fullPath);
|
|
77739
77807
|
}
|
|
77740
77808
|
}
|
|
77741
77809
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
77742
|
-
const relativeFilePath =
|
|
77810
|
+
const relativeFilePath = path21.relative(this.projectDir, absoluteFilePath);
|
|
77743
77811
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
77744
77812
|
return;
|
|
77745
77813
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -77757,14 +77825,14 @@ class DevServer {
|
|
|
77757
77825
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
77758
77826
|
}
|
|
77759
77827
|
async checkAndUploadNewNodeModules(filePath) {
|
|
77760
|
-
const ext =
|
|
77828
|
+
const ext = path21.extname(filePath).toLowerCase();
|
|
77761
77829
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
77762
77830
|
if (!isSourceFile)
|
|
77763
77831
|
return;
|
|
77764
77832
|
try {
|
|
77765
77833
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
77766
77834
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
77767
|
-
const relativePath =
|
|
77835
|
+
const relativePath = path21.relative(this.projectDir, file);
|
|
77768
77836
|
return !this.uploadedNodeModules.has(relativePath);
|
|
77769
77837
|
});
|
|
77770
77838
|
if (newFiles.length === 0)
|
|
@@ -77777,7 +77845,7 @@ class DevServer {
|
|
|
77777
77845
|
}
|
|
77778
77846
|
}
|
|
77779
77847
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
77780
|
-
const relativeFilePath =
|
|
77848
|
+
const relativeFilePath = path21.relative(this.projectDir, absoluteFilePath);
|
|
77781
77849
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
77782
77850
|
return;
|
|
77783
77851
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -77815,8 +77883,8 @@ class DevServer {
|
|
|
77815
77883
|
debug2(`Successfully deleted file ${relativeFilePath} from server`);
|
|
77816
77884
|
}
|
|
77817
77885
|
async handleFileRename(oldPath, newPath) {
|
|
77818
|
-
const oldRelativePath =
|
|
77819
|
-
const newRelativePath =
|
|
77886
|
+
const oldRelativePath = path21.relative(this.projectDir, oldPath);
|
|
77887
|
+
const newRelativePath = path21.relative(this.projectDir, newPath);
|
|
77820
77888
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
77821
77889
|
return;
|
|
77822
77890
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -77836,7 +77904,7 @@ class DevServer {
|
|
|
77836
77904
|
});
|
|
77837
77905
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
77838
77906
|
for (const filePath of filePaths) {
|
|
77839
|
-
const relativeFilePath =
|
|
77907
|
+
const relativeFilePath = path21.relative(this.projectDir, filePath);
|
|
77840
77908
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
77841
77909
|
await this.fsKy.post("api/files/upsert", {
|
|
77842
77910
|
json: {
|
|
@@ -77870,7 +77938,7 @@ class DevServer {
|
|
|
77870
77938
|
}
|
|
77871
77939
|
async uploadNodeModuleFiles(files) {
|
|
77872
77940
|
for (const nodeModuleFile of files) {
|
|
77873
|
-
const relativeFilePath =
|
|
77941
|
+
const relativeFilePath = path21.relative(this.projectDir, nodeModuleFile);
|
|
77874
77942
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
77875
77943
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
77876
77944
|
await this.fsKy.post("api/files/upsert", {
|
|
@@ -77906,8 +77974,8 @@ class DevServer {
|
|
|
77906
77974
|
await this.filesystemWatcher?.close();
|
|
77907
77975
|
}
|
|
77908
77976
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
77909
|
-
const ext =
|
|
77910
|
-
if (
|
|
77977
|
+
const ext = path21.extname(relativeFilePath).toLowerCase();
|
|
77978
|
+
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
77911
77979
|
const fileBuffer = fs20.readFileSync(absoluteFilePath);
|
|
77912
77980
|
return { binary_content_b64: fileBuffer.toString("base64") };
|
|
77913
77981
|
}
|
|
@@ -77948,10 +78016,10 @@ var getVersion = () => {
|
|
|
77948
78016
|
|
|
77949
78017
|
// lib/shared/find-board-files.ts
|
|
77950
78018
|
import fs21 from "node:fs";
|
|
77951
|
-
import
|
|
78019
|
+
import path22 from "node:path";
|
|
77952
78020
|
var isSubPath = (maybeChild, maybeParent) => {
|
|
77953
|
-
const relative5 =
|
|
77954
|
-
return relative5 === "" || !relative5.startsWith("..") && !
|
|
78021
|
+
const relative5 = path22.relative(maybeParent, maybeChild);
|
|
78022
|
+
return relative5 === "" || !relative5.startsWith("..") && !path22.isAbsolute(relative5);
|
|
77955
78023
|
};
|
|
77956
78024
|
var isGlobPattern = (str) => {
|
|
77957
78025
|
return /[*?[\]{}]/.test(str);
|
|
@@ -77961,13 +78029,13 @@ var findBoardFiles = ({
|
|
|
77961
78029
|
ignore = DEFAULT_IGNORED_PATTERNS,
|
|
77962
78030
|
filePaths = []
|
|
77963
78031
|
} = {}) => {
|
|
77964
|
-
const resolvedProjectDir =
|
|
78032
|
+
const resolvedProjectDir = path22.resolve(projectDir);
|
|
77965
78033
|
const boardFilePatterns = getBoardFilePatterns(resolvedProjectDir);
|
|
77966
78034
|
const relativeBoardFiles = globbySync(boardFilePatterns, {
|
|
77967
78035
|
cwd: resolvedProjectDir,
|
|
77968
78036
|
ignore
|
|
77969
78037
|
});
|
|
77970
|
-
const absoluteBoardFiles = relativeBoardFiles.map((f) =>
|
|
78038
|
+
const absoluteBoardFiles = relativeBoardFiles.map((f) => path22.join(resolvedProjectDir, f));
|
|
77971
78039
|
const boardFileSet = new Set;
|
|
77972
78040
|
if (filePaths.length > 0) {
|
|
77973
78041
|
for (const inputPath of filePaths) {
|
|
@@ -77981,13 +78049,13 @@ var findBoardFiles = ({
|
|
|
77981
78049
|
boardFileSet.add(match);
|
|
77982
78050
|
}
|
|
77983
78051
|
} else {
|
|
77984
|
-
const targetPath =
|
|
78052
|
+
const targetPath = path22.resolve(resolvedProjectDir, inputPath);
|
|
77985
78053
|
if (!fs21.existsSync(targetPath)) {
|
|
77986
78054
|
continue;
|
|
77987
78055
|
}
|
|
77988
78056
|
const stat4 = fs21.statSync(targetPath);
|
|
77989
78057
|
if (stat4.isDirectory()) {
|
|
77990
|
-
const resolvedDir =
|
|
78058
|
+
const resolvedDir = path22.resolve(targetPath);
|
|
77991
78059
|
if (isSubPath(resolvedDir, resolvedProjectDir)) {
|
|
77992
78060
|
for (const boardFile of absoluteBoardFiles) {
|
|
77993
78061
|
if (isSubPath(boardFile, resolvedDir)) {
|
|
@@ -77998,7 +78066,7 @@ var findBoardFiles = ({
|
|
|
77998
78066
|
const externalMatches = globbySync(boardFilePatterns, {
|
|
77999
78067
|
cwd: resolvedDir,
|
|
78000
78068
|
ignore
|
|
78001
|
-
}).map((f) =>
|
|
78069
|
+
}).map((f) => path22.join(resolvedDir, f));
|
|
78002
78070
|
for (const match of externalMatches) {
|
|
78003
78071
|
boardFileSet.add(match);
|
|
78004
78072
|
}
|
|
@@ -78026,10 +78094,10 @@ var findSelectableTsxFiles = (projectDir) => {
|
|
|
78026
78094
|
cwd: projectDir,
|
|
78027
78095
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
78028
78096
|
});
|
|
78029
|
-
return files.map((file) =>
|
|
78097
|
+
return files.map((file) => path23.resolve(projectDir, file)).filter((file) => fs22.existsSync(file)).sort();
|
|
78030
78098
|
};
|
|
78031
78099
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
78032
|
-
const tsconfigPath =
|
|
78100
|
+
const tsconfigPath = path23.join(projectDir, "tsconfig.json");
|
|
78033
78101
|
if (!fs22.existsSync(tsconfigPath)) {
|
|
78034
78102
|
return;
|
|
78035
78103
|
}
|
|
@@ -78061,7 +78129,7 @@ var registerDev = (program3) => {
|
|
|
78061
78129
|
}
|
|
78062
78130
|
let absolutePath;
|
|
78063
78131
|
if (file) {
|
|
78064
|
-
absolutePath =
|
|
78132
|
+
absolutePath = path23.resolve(file);
|
|
78065
78133
|
if (!absolutePath.endsWith(".tsx") && !absolutePath.endsWith(".ts")) {
|
|
78066
78134
|
console.error("Error: Only .tsx files are supported");
|
|
78067
78135
|
return;
|
|
@@ -78080,7 +78148,7 @@ var registerDev = (program3) => {
|
|
|
78080
78148
|
return;
|
|
78081
78149
|
}
|
|
78082
78150
|
absolutePath = availableFiles[0];
|
|
78083
|
-
console.log("Selected file:",
|
|
78151
|
+
console.log("Selected file:", path23.relative(process.cwd(), absolutePath));
|
|
78084
78152
|
}
|
|
78085
78153
|
}
|
|
78086
78154
|
warnIfTsconfigMissingTscircuitType(process.cwd());
|
|
@@ -78102,7 +78170,7 @@ var registerDev = (program3) => {
|
|
|
78102
78170
|
|
|
78103
78171
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
78104
78172
|
console.log(`
|
|
78105
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
78173
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path23.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
78106
78174
|
|
|
78107
78175
|
`);
|
|
78108
78176
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -78238,25 +78306,25 @@ var registerConfigPrint = (program3) => {
|
|
|
78238
78306
|
|
|
78239
78307
|
// cli/clone/register.ts
|
|
78240
78308
|
import * as fs25 from "node:fs";
|
|
78241
|
-
import * as
|
|
78309
|
+
import * as path26 from "node:path";
|
|
78242
78310
|
|
|
78243
78311
|
// cli/clone/clone-bug-report.ts
|
|
78244
78312
|
var import_jszip = __toESM2(require_lib4(), 1);
|
|
78245
78313
|
var import_prompts7 = __toESM2(require_prompts3(), 1);
|
|
78246
78314
|
import * as fs24 from "node:fs";
|
|
78247
|
-
import * as
|
|
78315
|
+
import * as path25 from "node:path";
|
|
78248
78316
|
|
|
78249
78317
|
// cli/clone/handle-existing-directory.ts
|
|
78250
78318
|
var import_prompts6 = __toESM2(require_prompts3(), 1);
|
|
78251
78319
|
import * as fs23 from "node:fs";
|
|
78252
|
-
import * as
|
|
78320
|
+
import * as path24 from "node:path";
|
|
78253
78321
|
var handleExistingDirectory = async (dirPath) => {
|
|
78254
78322
|
if (!fs23.existsSync(dirPath))
|
|
78255
78323
|
return;
|
|
78256
78324
|
const response = await import_prompts6.default({
|
|
78257
78325
|
type: "select",
|
|
78258
78326
|
name: "action",
|
|
78259
|
-
message: `Directory "${
|
|
78327
|
+
message: `Directory "${path24.basename(dirPath)}" already exists. What would you like to do?`,
|
|
78260
78328
|
choices: [
|
|
78261
78329
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
78262
78330
|
{
|
|
@@ -78297,12 +78365,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
78297
78365
|
return commonSegments.join("/");
|
|
78298
78366
|
};
|
|
78299
78367
|
var sanitizeRelativePath = (relativePath) => {
|
|
78300
|
-
const normalizedPath =
|
|
78368
|
+
const normalizedPath = path25.normalize(relativePath);
|
|
78301
78369
|
if (!normalizedPath)
|
|
78302
78370
|
return null;
|
|
78303
|
-
if (
|
|
78371
|
+
if (path25.isAbsolute(normalizedPath))
|
|
78304
78372
|
return null;
|
|
78305
|
-
const segments = normalizedPath.split(
|
|
78373
|
+
const segments = normalizedPath.split(path25.sep);
|
|
78306
78374
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
78307
78375
|
return null;
|
|
78308
78376
|
}
|
|
@@ -78317,7 +78385,7 @@ var cloneBugReport = async ({
|
|
|
78317
78385
|
console.error("Bug report ID must not be empty.");
|
|
78318
78386
|
process.exit(1);
|
|
78319
78387
|
}
|
|
78320
|
-
let dirPath =
|
|
78388
|
+
let dirPath = path25.resolve(`bug-report-${trimmedBugReportId}`);
|
|
78321
78389
|
await handleExistingDirectory(dirPath);
|
|
78322
78390
|
const ky2 = getRegistryApiKy();
|
|
78323
78391
|
let zipBuffer;
|
|
@@ -78347,25 +78415,25 @@ var cloneBugReport = async ({
|
|
|
78347
78415
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
78348
78416
|
continue;
|
|
78349
78417
|
}
|
|
78350
|
-
const fullPath =
|
|
78351
|
-
fs24.mkdirSync(
|
|
78418
|
+
const fullPath = path25.join(dirPath, sanitizedRelativePath);
|
|
78419
|
+
fs24.mkdirSync(path25.dirname(fullPath), { recursive: true });
|
|
78352
78420
|
const fileContent = await entry.async("nodebuffer");
|
|
78353
78421
|
fs24.writeFileSync(fullPath, fileContent);
|
|
78354
78422
|
}
|
|
78355
|
-
const packageJsonPath =
|
|
78423
|
+
const packageJsonPath = path25.join(dirPath, "package.json");
|
|
78356
78424
|
if (fs24.existsSync(packageJsonPath)) {
|
|
78357
78425
|
try {
|
|
78358
78426
|
const packageJson = JSON.parse(fs24.readFileSync(packageJsonPath, "utf-8"));
|
|
78359
78427
|
const packageName = packageJson?.name;
|
|
78360
78428
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
78361
78429
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
78362
|
-
const suggestedDirPath =
|
|
78430
|
+
const suggestedDirPath = path25.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
78363
78431
|
if (suggestedDirPath !== dirPath) {
|
|
78364
78432
|
const response = await import_prompts7.default({
|
|
78365
78433
|
type: "confirm",
|
|
78366
78434
|
name: "rename",
|
|
78367
78435
|
initial: true,
|
|
78368
|
-
message: `Rename the directory to "${
|
|
78436
|
+
message: `Rename the directory to "${path25.basename(suggestedDirPath)}"?`
|
|
78369
78437
|
});
|
|
78370
78438
|
if (response.rename) {
|
|
78371
78439
|
await handleExistingDirectory(suggestedDirPath);
|
|
@@ -78378,9 +78446,9 @@ var cloneBugReport = async ({
|
|
|
78378
78446
|
console.warn("Unable to read package name for renaming:", error);
|
|
78379
78447
|
}
|
|
78380
78448
|
}
|
|
78381
|
-
fs24.writeFileSync(
|
|
78449
|
+
fs24.writeFileSync(path25.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
78382
78450
|
generateTsConfig(dirPath);
|
|
78383
|
-
const relativeDirPath =
|
|
78451
|
+
const relativeDirPath = path25.relative(originalCwd, dirPath);
|
|
78384
78452
|
console.log(kleur_default.green(`
|
|
78385
78453
|
Successfully cloned bug report to:`));
|
|
78386
78454
|
console.log(` ${dirPath}/
|
|
@@ -78419,7 +78487,7 @@ var registerClone = (program3) => {
|
|
|
78419
78487
|
const [, author, packageName] = match;
|
|
78420
78488
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
78421
78489
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
78422
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
78490
|
+
const dirPath = userSettingToIncludeAuthor ? path26.resolve(`${author}.${packageName}`) : path26.resolve(packageName);
|
|
78423
78491
|
await handleExistingDirectory(dirPath);
|
|
78424
78492
|
const ky2 = getRegistryApiKy();
|
|
78425
78493
|
let packageFileList = {
|
|
@@ -78445,8 +78513,8 @@ var registerClone = (program3) => {
|
|
|
78445
78513
|
const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "");
|
|
78446
78514
|
if (!filePath)
|
|
78447
78515
|
continue;
|
|
78448
|
-
const fullPath =
|
|
78449
|
-
fs25.mkdirSync(
|
|
78516
|
+
const fullPath = path26.join(dirPath, filePath);
|
|
78517
|
+
fs25.mkdirSync(path26.dirname(fullPath), { recursive: true });
|
|
78450
78518
|
try {
|
|
78451
78519
|
const fileContent = await ky2.get("package_files/get", {
|
|
78452
78520
|
searchParams: {
|
|
@@ -78460,10 +78528,10 @@ var registerClone = (program3) => {
|
|
|
78460
78528
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
78461
78529
|
}
|
|
78462
78530
|
}
|
|
78463
|
-
fs25.writeFileSync(
|
|
78531
|
+
fs25.writeFileSync(path26.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
78464
78532
|
generateTsConfig(dirPath);
|
|
78465
78533
|
await setupTsciProject(dirPath);
|
|
78466
|
-
const relativeDirPath =
|
|
78534
|
+
const relativeDirPath = path26.relative(originalCwd, dirPath);
|
|
78467
78535
|
console.log(kleur_default.green(`
|
|
78468
78536
|
Successfully cloned to:`));
|
|
78469
78537
|
console.log(` ${dirPath}/
|
|
@@ -78480,7 +78548,7 @@ var import_perfect_cli = __toESM2(require_dist7(), 1);
|
|
|
78480
78548
|
|
|
78481
78549
|
// lib/shared/export-snippet.ts
|
|
78482
78550
|
import fs27 from "node:fs";
|
|
78483
|
-
import
|
|
78551
|
+
import path28 from "node:path";
|
|
78484
78552
|
import { promisify as promisify3 } from "node:util";
|
|
78485
78553
|
|
|
78486
78554
|
// node_modules/circuit-json-to-readable-netlist/dist/index.js
|
|
@@ -79659,9 +79727,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
79659
79727
|
const stringifyCoordinates = (coordinates) => {
|
|
79660
79728
|
return coordinates.join(" ");
|
|
79661
79729
|
};
|
|
79662
|
-
const stringifyPath = (
|
|
79730
|
+
const stringifyPath = (path27, level) => {
|
|
79663
79731
|
const padding = indent.repeat(level);
|
|
79664
|
-
return `${padding}(path ${
|
|
79732
|
+
return `${padding}(path ${path27.layer} ${path27.width} ${stringifyCoordinates(path27.coordinates)})`;
|
|
79665
79733
|
};
|
|
79666
79734
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
79667
79735
|
`;
|
|
@@ -80359,10 +80427,10 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
80359
80427
|
}
|
|
80360
80428
|
const instances = new SymbolInstances;
|
|
80361
80429
|
const project = new SymbolInstancesProject("");
|
|
80362
|
-
const
|
|
80363
|
-
|
|
80364
|
-
|
|
80365
|
-
project.paths.push(
|
|
80430
|
+
const path27 = new SymbolInstancePath(`/${kicadSch?.uuid?.value || ""}`);
|
|
80431
|
+
path27.reference = reference;
|
|
80432
|
+
path27.unit = 1;
|
|
80433
|
+
project.paths.push(path27);
|
|
80366
80434
|
instances.projects.push(project);
|
|
80367
80435
|
symbol._sxInstances = instances;
|
|
80368
80436
|
symbols3.push(symbol);
|
|
@@ -80570,11 +80638,11 @@ var AddSheetInstancesStage = class extends ConverterStage {
|
|
|
80570
80638
|
throw new Error("KicadSch instance not initialized in context");
|
|
80571
80639
|
}
|
|
80572
80640
|
const sheetInstances = new SheetInstances;
|
|
80573
|
-
const
|
|
80574
|
-
|
|
80641
|
+
const path27 = new SheetInstancesRootPath;
|
|
80642
|
+
path27.value = "/";
|
|
80575
80643
|
const page = new SheetInstancesRootPage("1");
|
|
80576
|
-
|
|
80577
|
-
sheetInstances.paths = [
|
|
80644
|
+
path27.pages = [page];
|
|
80645
|
+
sheetInstances.paths = [path27];
|
|
80578
80646
|
kicadSch.sheetInstances = sheetInstances;
|
|
80579
80647
|
kicadSch.embeddedFonts = new EmbeddedFonts3(false);
|
|
80580
80648
|
this.finished = true;
|
|
@@ -80929,12 +80997,12 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
80929
80997
|
throw new Error("PCB transformation matrix not initialized in context");
|
|
80930
80998
|
}
|
|
80931
80999
|
const pcbSilkscreenPaths = this.ctx.db.pcb_silkscreen_path?.list() || [];
|
|
80932
|
-
for (const
|
|
80933
|
-
if (!
|
|
81000
|
+
for (const path27 of pcbSilkscreenPaths) {
|
|
81001
|
+
if (!path27.route || path27.route.length < 2)
|
|
80934
81002
|
continue;
|
|
80935
|
-
for (let i = 0;i <
|
|
80936
|
-
const startPoint =
|
|
80937
|
-
const endPoint =
|
|
81003
|
+
for (let i = 0;i < path27.route.length - 1; i++) {
|
|
81004
|
+
const startPoint = path27.route[i];
|
|
81005
|
+
const endPoint = path27.route[i + 1];
|
|
80938
81006
|
if (!startPoint || !endPoint)
|
|
80939
81007
|
continue;
|
|
80940
81008
|
const transformedStart = applyToPoint62(c2kMatPcb, {
|
|
@@ -80949,12 +81017,12 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
80949
81017
|
top: "F.SilkS",
|
|
80950
81018
|
bottom: "B.SilkS"
|
|
80951
81019
|
};
|
|
80952
|
-
const kicadLayer = layerMap[
|
|
81020
|
+
const kicadLayer = layerMap[path27.layer] || path27.layer || "F.SilkS";
|
|
80953
81021
|
const grLine = new GrLine({
|
|
80954
81022
|
start: { x: transformedStart.x, y: transformedStart.y },
|
|
80955
81023
|
end: { x: transformedEnd.x, y: transformedEnd.y },
|
|
80956
81024
|
layer: kicadLayer,
|
|
80957
|
-
width:
|
|
81025
|
+
width: path27.stroke_width || 0.15
|
|
80958
81026
|
});
|
|
80959
81027
|
const graphicLines = kicadPcb.graphicLines;
|
|
80960
81028
|
graphicLines.push(grLine);
|
|
@@ -81062,7 +81130,7 @@ var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
|
81062
81130
|
|
|
81063
81131
|
// lib/shared/generate-circuit-json.tsx
|
|
81064
81132
|
var import_make_vfs2 = __toESM2(require_dist8(), 1);
|
|
81065
|
-
import
|
|
81133
|
+
import path27 from "node:path";
|
|
81066
81134
|
import fs26 from "node:fs";
|
|
81067
81135
|
import { pathToFileURL } from "node:url";
|
|
81068
81136
|
import Debug11 from "debug";
|
|
@@ -81126,12 +81194,12 @@ async function generateCircuitJson({
|
|
|
81126
81194
|
const runner = new userLandTscircuit.RootCircuit({
|
|
81127
81195
|
platform: platformConfig
|
|
81128
81196
|
});
|
|
81129
|
-
const absoluteFilePath =
|
|
81130
|
-
const projectDir =
|
|
81197
|
+
const absoluteFilePath = path27.isAbsolute(filePath) ? filePath : path27.resolve(process.cwd(), filePath);
|
|
81198
|
+
const projectDir = path27.dirname(absoluteFilePath);
|
|
81131
81199
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
81132
|
-
const relativeComponentPath =
|
|
81133
|
-
const baseFileName = outputFileName ||
|
|
81134
|
-
const outputPath =
|
|
81200
|
+
const relativeComponentPath = path27.relative(projectDir, absoluteFilePath);
|
|
81201
|
+
const baseFileName = outputFileName || path27.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
81202
|
+
const outputPath = path27.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
81135
81203
|
debug11(`Project directory: ${projectDir}`);
|
|
81136
81204
|
debug11(`Relative component path: ${relativeComponentPath}`);
|
|
81137
81205
|
debug11(`Output path: ${outputPath}`);
|
|
@@ -81151,7 +81219,7 @@ async function generateCircuitJson({
|
|
|
81151
81219
|
return false;
|
|
81152
81220
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
81153
81221
|
return false;
|
|
81154
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
81222
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path27.extname(normalizedFilePath)))
|
|
81155
81223
|
return false;
|
|
81156
81224
|
return true;
|
|
81157
81225
|
},
|
|
@@ -81221,10 +81289,10 @@ var exportSnippet = async ({
|
|
|
81221
81289
|
onError(`Invalid format: ${format}`);
|
|
81222
81290
|
return onExit(1);
|
|
81223
81291
|
}
|
|
81224
|
-
const projectDir =
|
|
81225
|
-
const outputBaseName =
|
|
81292
|
+
const projectDir = path28.dirname(filePath);
|
|
81293
|
+
const outputBaseName = path28.basename(filePath).replace(/\.[^.]+$/, "");
|
|
81226
81294
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
81227
|
-
const outputDestination =
|
|
81295
|
+
const outputDestination = path28.join(projectDir, outputPath ?? outputFileName);
|
|
81228
81296
|
const circuitData = await generateCircuitJson({
|
|
81229
81297
|
filePath,
|
|
81230
81298
|
saveToFile: format === "circuit-json",
|
|
@@ -81410,11 +81478,11 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
81410
81478
|
|
|
81411
81479
|
// lib/eecircuit-engine/run-simulation.ts
|
|
81412
81480
|
import { promises as fs28, existsSync as existsSync12 } from "node:fs";
|
|
81413
|
-
import
|
|
81481
|
+
import path29 from "node:path";
|
|
81414
81482
|
import os2 from "node:os";
|
|
81415
81483
|
var sim = null;
|
|
81416
81484
|
var fetchSimulation = async () => {
|
|
81417
|
-
const tempFilePath =
|
|
81485
|
+
const tempFilePath = path29.join(os2.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
81418
81486
|
if (!existsSync12(tempFilePath)) {
|
|
81419
81487
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
81420
81488
|
const response = await fetch(url);
|
|
@@ -81511,7 +81579,7 @@ var resultToCsv = (result) => {
|
|
|
81511
81579
|
};
|
|
81512
81580
|
|
|
81513
81581
|
// cli/export/register.ts
|
|
81514
|
-
import
|
|
81582
|
+
import path30 from "node:path";
|
|
81515
81583
|
import { promises as fs29 } from "node:fs";
|
|
81516
81584
|
var registerExport = (program3) => {
|
|
81517
81585
|
program3.command("export").description("Export tscircuit code to various formats").argument("<file>", "Path to the package file").option("-f, --format <format>", `Output format (${ALLOWED_EXPORT_FORMATS.join(", ")})`).option("-o, --output <path>", "Output file path").option("--disable-parts-engine", "Disable the parts engine").action(async (file, options) => {
|
|
@@ -81524,7 +81592,7 @@ var registerExport = (program3) => {
|
|
|
81524
81592
|
});
|
|
81525
81593
|
if (circuitJson) {
|
|
81526
81594
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
81527
|
-
const outputSpicePath = options.output ??
|
|
81595
|
+
const outputSpicePath = options.output ?? path30.join(path30.dirname(file), `${path30.basename(file, path30.extname(file))}.spice.cir`);
|
|
81528
81596
|
await fs29.writeFile(outputSpicePath, spiceString);
|
|
81529
81597
|
const { result } = await runSimulation(spiceString);
|
|
81530
81598
|
const csvContent = resultToCsv(result);
|
|
@@ -81761,14 +81829,14 @@ class KeyStore {
|
|
|
81761
81829
|
}
|
|
81762
81830
|
}
|
|
81763
81831
|
function createKey(key) {
|
|
81764
|
-
let
|
|
81832
|
+
let path31 = null;
|
|
81765
81833
|
let id = null;
|
|
81766
81834
|
let src = null;
|
|
81767
81835
|
let weight = 1;
|
|
81768
81836
|
let getFn = null;
|
|
81769
81837
|
if (isString2(key) || isArray(key)) {
|
|
81770
81838
|
src = key;
|
|
81771
|
-
|
|
81839
|
+
path31 = createKeyPath(key);
|
|
81772
81840
|
id = createKeyId(key);
|
|
81773
81841
|
} else {
|
|
81774
81842
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -81782,11 +81850,11 @@ function createKey(key) {
|
|
|
81782
81850
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
81783
81851
|
}
|
|
81784
81852
|
}
|
|
81785
|
-
|
|
81853
|
+
path31 = createKeyPath(name);
|
|
81786
81854
|
id = createKeyId(name);
|
|
81787
81855
|
getFn = key.getFn;
|
|
81788
81856
|
}
|
|
81789
|
-
return { path:
|
|
81857
|
+
return { path: path31, id, weight, src, getFn };
|
|
81790
81858
|
}
|
|
81791
81859
|
function createKeyPath(key) {
|
|
81792
81860
|
return isArray(key) ? key : key.split(".");
|
|
@@ -81794,34 +81862,34 @@ function createKeyPath(key) {
|
|
|
81794
81862
|
function createKeyId(key) {
|
|
81795
81863
|
return isArray(key) ? key.join(".") : key;
|
|
81796
81864
|
}
|
|
81797
|
-
function get(obj,
|
|
81865
|
+
function get(obj, path31) {
|
|
81798
81866
|
let list = [];
|
|
81799
81867
|
let arr = false;
|
|
81800
|
-
const deepGet = (obj2,
|
|
81868
|
+
const deepGet = (obj2, path32, index) => {
|
|
81801
81869
|
if (!isDefined(obj2)) {
|
|
81802
81870
|
return;
|
|
81803
81871
|
}
|
|
81804
|
-
if (!
|
|
81872
|
+
if (!path32[index]) {
|
|
81805
81873
|
list.push(obj2);
|
|
81806
81874
|
} else {
|
|
81807
|
-
let key =
|
|
81875
|
+
let key = path32[index];
|
|
81808
81876
|
const value = obj2[key];
|
|
81809
81877
|
if (!isDefined(value)) {
|
|
81810
81878
|
return;
|
|
81811
81879
|
}
|
|
81812
|
-
if (index ===
|
|
81880
|
+
if (index === path32.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
|
|
81813
81881
|
list.push(toString(value));
|
|
81814
81882
|
} else if (isArray(value)) {
|
|
81815
81883
|
arr = true;
|
|
81816
81884
|
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
81817
|
-
deepGet(value[i],
|
|
81885
|
+
deepGet(value[i], path32, index + 1);
|
|
81818
81886
|
}
|
|
81819
|
-
} else if (
|
|
81820
|
-
deepGet(value,
|
|
81887
|
+
} else if (path32.length) {
|
|
81888
|
+
deepGet(value, path32, index + 1);
|
|
81821
81889
|
}
|
|
81822
81890
|
}
|
|
81823
81891
|
};
|
|
81824
|
-
deepGet(obj, isString2(
|
|
81892
|
+
deepGet(obj, isString2(path31) ? path31.split(".") : path31, 0);
|
|
81825
81893
|
return arr ? list : list[0];
|
|
81826
81894
|
}
|
|
81827
81895
|
var MatchOptions = {
|
|
@@ -83013,8 +83081,8 @@ var registerSearch = (program3) => {
|
|
|
83013
83081
|
}
|
|
83014
83082
|
if (kicadResults.length) {
|
|
83015
83083
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
83016
|
-
kicadResults.forEach((
|
|
83017
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
83084
|
+
kicadResults.forEach((path31, idx) => {
|
|
83085
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path31.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
83018
83086
|
});
|
|
83019
83087
|
}
|
|
83020
83088
|
if (!onlyKicad && results.packages.length) {
|
|
@@ -90791,11 +90859,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
90791
90859
|
fiber = fiber.next, id2--;
|
|
90792
90860
|
return fiber;
|
|
90793
90861
|
}
|
|
90794
|
-
function copyWithSetImpl(obj,
|
|
90795
|
-
if (index >=
|
|
90862
|
+
function copyWithSetImpl(obj, path31, index, value) {
|
|
90863
|
+
if (index >= path31.length)
|
|
90796
90864
|
return value;
|
|
90797
|
-
var key =
|
|
90798
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
90865
|
+
var key = path31[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
90866
|
+
updated[key] = copyWithSetImpl(obj[key], path31, index + 1, value);
|
|
90799
90867
|
return updated;
|
|
90800
90868
|
}
|
|
90801
90869
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -90815,11 +90883,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
90815
90883
|
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);
|
|
90816
90884
|
return updated;
|
|
90817
90885
|
}
|
|
90818
|
-
function copyWithDeleteImpl(obj,
|
|
90819
|
-
var key =
|
|
90820
|
-
if (index + 1 ===
|
|
90886
|
+
function copyWithDeleteImpl(obj, path31, index) {
|
|
90887
|
+
var key = path31[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
90888
|
+
if (index + 1 === path31.length)
|
|
90821
90889
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
90822
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
90890
|
+
updated[key] = copyWithDeleteImpl(obj[key], path31, index + 1);
|
|
90823
90891
|
return updated;
|
|
90824
90892
|
}
|
|
90825
90893
|
function shouldSuspendImpl() {
|
|
@@ -99850,29 +99918,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
99850
99918
|
var didWarnAboutNestedUpdates = false;
|
|
99851
99919
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
99852
99920
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
99853
|
-
overrideHookState = function(fiber, id2,
|
|
99921
|
+
overrideHookState = function(fiber, id2, path31, value) {
|
|
99854
99922
|
id2 = findHook(fiber, id2);
|
|
99855
|
-
id2 !== null && (
|
|
99923
|
+
id2 !== null && (path31 = copyWithSetImpl(id2.memoizedState, path31, 0, value), id2.memoizedState = path31, id2.baseState = path31, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path31 = enqueueConcurrentRenderForLane(fiber, 2), path31 !== null && scheduleUpdateOnFiber(path31, fiber, 2));
|
|
99856
99924
|
};
|
|
99857
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
99925
|
+
overrideHookStateDeletePath = function(fiber, id2, path31) {
|
|
99858
99926
|
id2 = findHook(fiber, id2);
|
|
99859
|
-
id2 !== null && (
|
|
99927
|
+
id2 !== null && (path31 = copyWithDeleteImpl(id2.memoizedState, path31, 0), id2.memoizedState = path31, id2.baseState = path31, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path31 = enqueueConcurrentRenderForLane(fiber, 2), path31 !== null && scheduleUpdateOnFiber(path31, fiber, 2));
|
|
99860
99928
|
};
|
|
99861
99929
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
99862
99930
|
id2 = findHook(fiber, id2);
|
|
99863
99931
|
id2 !== null && (oldPath = copyWithRename(id2.memoizedState, oldPath, newPath), id2.memoizedState = oldPath, id2.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
99864
99932
|
};
|
|
99865
|
-
overrideProps = function(fiber,
|
|
99866
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
99933
|
+
overrideProps = function(fiber, path31, value) {
|
|
99934
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path31, 0, value);
|
|
99867
99935
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
99868
|
-
|
|
99869
|
-
|
|
99936
|
+
path31 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
99937
|
+
path31 !== null && scheduleUpdateOnFiber(path31, fiber, 2);
|
|
99870
99938
|
};
|
|
99871
|
-
overridePropsDeletePath = function(fiber,
|
|
99872
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
99939
|
+
overridePropsDeletePath = function(fiber, path31) {
|
|
99940
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path31, 0);
|
|
99873
99941
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
99874
|
-
|
|
99875
|
-
|
|
99942
|
+
path31 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
99943
|
+
path31 !== null && scheduleUpdateOnFiber(path31, fiber, 2);
|
|
99876
99944
|
};
|
|
99877
99945
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
99878
99946
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -115209,10 +115277,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115209
115277
|
var setErrorHandler = null;
|
|
115210
115278
|
var setSuspenseHandler = null;
|
|
115211
115279
|
{
|
|
115212
|
-
var copyWithDeleteImpl = function(obj,
|
|
115213
|
-
var key =
|
|
115280
|
+
var copyWithDeleteImpl = function(obj, path31, index2) {
|
|
115281
|
+
var key = path31[index2];
|
|
115214
115282
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
115215
|
-
if (index2 + 1 ===
|
|
115283
|
+
if (index2 + 1 === path31.length) {
|
|
115216
115284
|
if (isArray2(updated)) {
|
|
115217
115285
|
updated.splice(key, 1);
|
|
115218
115286
|
} else {
|
|
@@ -115220,11 +115288,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115220
115288
|
}
|
|
115221
115289
|
return updated;
|
|
115222
115290
|
}
|
|
115223
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
115291
|
+
updated[key] = copyWithDeleteImpl(obj[key], path31, index2 + 1);
|
|
115224
115292
|
return updated;
|
|
115225
115293
|
};
|
|
115226
|
-
var copyWithDelete = function(obj,
|
|
115227
|
-
return copyWithDeleteImpl(obj,
|
|
115294
|
+
var copyWithDelete = function(obj, path31) {
|
|
115295
|
+
return copyWithDeleteImpl(obj, path31, 0);
|
|
115228
115296
|
};
|
|
115229
115297
|
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
|
115230
115298
|
var oldKey = oldPath[index2];
|
|
@@ -115256,17 +115324,17 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115256
115324
|
}
|
|
115257
115325
|
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
|
115258
115326
|
};
|
|
115259
|
-
var copyWithSetImpl = function(obj,
|
|
115260
|
-
if (index2 >=
|
|
115327
|
+
var copyWithSetImpl = function(obj, path31, index2, value) {
|
|
115328
|
+
if (index2 >= path31.length) {
|
|
115261
115329
|
return value;
|
|
115262
115330
|
}
|
|
115263
|
-
var key =
|
|
115331
|
+
var key = path31[index2];
|
|
115264
115332
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
115265
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
115333
|
+
updated[key] = copyWithSetImpl(obj[key], path31, index2 + 1, value);
|
|
115266
115334
|
return updated;
|
|
115267
115335
|
};
|
|
115268
|
-
var copyWithSet = function(obj,
|
|
115269
|
-
return copyWithSetImpl(obj,
|
|
115336
|
+
var copyWithSet = function(obj, path31, value) {
|
|
115337
|
+
return copyWithSetImpl(obj, path31, 0, value);
|
|
115270
115338
|
};
|
|
115271
115339
|
var findHook = function(fiber, id2) {
|
|
115272
115340
|
var currentHook2 = fiber.memoizedState;
|
|
@@ -115276,10 +115344,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115276
115344
|
}
|
|
115277
115345
|
return currentHook2;
|
|
115278
115346
|
};
|
|
115279
|
-
overrideHookState = function(fiber, id2,
|
|
115347
|
+
overrideHookState = function(fiber, id2, path31, value) {
|
|
115280
115348
|
var hook = findHook(fiber, id2);
|
|
115281
115349
|
if (hook !== null) {
|
|
115282
|
-
var newState = copyWithSet(hook.memoizedState,
|
|
115350
|
+
var newState = copyWithSet(hook.memoizedState, path31, value);
|
|
115283
115351
|
hook.memoizedState = newState;
|
|
115284
115352
|
hook.baseState = newState;
|
|
115285
115353
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -115289,10 +115357,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115289
115357
|
}
|
|
115290
115358
|
}
|
|
115291
115359
|
};
|
|
115292
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
115360
|
+
overrideHookStateDeletePath = function(fiber, id2, path31) {
|
|
115293
115361
|
var hook = findHook(fiber, id2);
|
|
115294
115362
|
if (hook !== null) {
|
|
115295
|
-
var newState = copyWithDelete(hook.memoizedState,
|
|
115363
|
+
var newState = copyWithDelete(hook.memoizedState, path31);
|
|
115296
115364
|
hook.memoizedState = newState;
|
|
115297
115365
|
hook.baseState = newState;
|
|
115298
115366
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -115315,8 +115383,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115315
115383
|
}
|
|
115316
115384
|
}
|
|
115317
115385
|
};
|
|
115318
|
-
overrideProps = function(fiber,
|
|
115319
|
-
fiber.pendingProps = copyWithSet(fiber.memoizedProps,
|
|
115386
|
+
overrideProps = function(fiber, path31, value) {
|
|
115387
|
+
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path31, value);
|
|
115320
115388
|
if (fiber.alternate) {
|
|
115321
115389
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
115322
115390
|
}
|
|
@@ -115325,8 +115393,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
115325
115393
|
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
|
115326
115394
|
}
|
|
115327
115395
|
};
|
|
115328
|
-
overridePropsDeletePath = function(fiber,
|
|
115329
|
-
fiber.pendingProps = copyWithDelete(fiber.memoizedProps,
|
|
115396
|
+
overridePropsDeletePath = function(fiber, path31) {
|
|
115397
|
+
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path31);
|
|
115330
115398
|
if (fiber.alternate) {
|
|
115331
115399
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
115332
115400
|
}
|
|
@@ -121377,7 +121445,7 @@ var parsePin = (pinString) => {
|
|
|
121377
121445
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
121378
121446
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
121379
121447
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
121380
|
-
const
|
|
121448
|
+
const path31 = pathMatch ? pathMatch[1] : "";
|
|
121381
121449
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
121382
121450
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
121383
121451
|
const r3 = Number.parseFloat(rotation2);
|
|
@@ -121391,7 +121459,7 @@ var parsePin = (pinString) => {
|
|
|
121391
121459
|
rotation: Number.isNaN(r3) ? 0 : r3,
|
|
121392
121460
|
label,
|
|
121393
121461
|
labelColor,
|
|
121394
|
-
path:
|
|
121462
|
+
path: path31,
|
|
121395
121463
|
arrow
|
|
121396
121464
|
};
|
|
121397
121465
|
};
|
|
@@ -121831,15 +121899,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
121831
121899
|
}
|
|
121832
121900
|
}
|
|
121833
121901
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
121834
|
-
const
|
|
121902
|
+
const path31 = [];
|
|
121835
121903
|
for (let i = 0;i <= numPoints; i++) {
|
|
121836
121904
|
const t3 = i / numPoints;
|
|
121837
121905
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
121838
121906
|
const x = centerX + radius * Math.cos(angle2);
|
|
121839
121907
|
const y = centerY + radius * Math.sin(angle2);
|
|
121840
|
-
|
|
121908
|
+
path31.push({ x, y });
|
|
121841
121909
|
}
|
|
121842
|
-
return
|
|
121910
|
+
return path31;
|
|
121843
121911
|
}
|
|
121844
121912
|
var __defProp4 = Object.defineProperty;
|
|
121845
121913
|
var __export22 = (target, all) => {
|
|
@@ -130916,17 +130984,17 @@ var ObstacleList = class {
|
|
|
130916
130984
|
return obstacles;
|
|
130917
130985
|
}
|
|
130918
130986
|
};
|
|
130919
|
-
function removePathLoops(
|
|
130920
|
-
if (
|
|
130921
|
-
return
|
|
130922
|
-
const result = [{ ...
|
|
130923
|
-
let currentLayer =
|
|
130924
|
-
for (let i = 1;i <
|
|
130925
|
-
const currentSegment = { start:
|
|
130926
|
-
const isVia =
|
|
130927
|
-
if (
|
|
130928
|
-
result.push({ ...
|
|
130929
|
-
currentLayer =
|
|
130987
|
+
function removePathLoops(path31) {
|
|
130988
|
+
if (path31.length < 4)
|
|
130989
|
+
return path31;
|
|
130990
|
+
const result = [{ ...path31[0] }];
|
|
130991
|
+
let currentLayer = path31[0].layer;
|
|
130992
|
+
for (let i = 1;i < path31.length; i++) {
|
|
130993
|
+
const currentSegment = { start: path31[i - 1], end: path31[i] };
|
|
130994
|
+
const isVia = path31[i].route_type === "via" || path31[i - 1].route_type === "via";
|
|
130995
|
+
if (path31[i].layer !== currentLayer || isVia) {
|
|
130996
|
+
result.push({ ...path31[i] });
|
|
130997
|
+
currentLayer = path31[i].layer;
|
|
130930
130998
|
continue;
|
|
130931
130999
|
}
|
|
130932
131000
|
let intersectionFound = false;
|
|
@@ -130955,8 +131023,8 @@ function removePathLoops(path30) {
|
|
|
130955
131023
|
result.push(intersectionPoint);
|
|
130956
131024
|
}
|
|
130957
131025
|
const lastPoint = result[result.length - 1];
|
|
130958
|
-
if (lastPoint.x !==
|
|
130959
|
-
result.push(
|
|
131026
|
+
if (lastPoint.x !== path31[i].x || lastPoint.y !== path31[i].y) {
|
|
131027
|
+
result.push(path31[i]);
|
|
130960
131028
|
}
|
|
130961
131029
|
}
|
|
130962
131030
|
return result;
|
|
@@ -131445,10 +131513,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
131445
131513
|
});
|
|
131446
131514
|
}
|
|
131447
131515
|
if (current2.parent) {
|
|
131448
|
-
const
|
|
131516
|
+
const path31 = [];
|
|
131449
131517
|
let p = current2;
|
|
131450
131518
|
while (p) {
|
|
131451
|
-
|
|
131519
|
+
path31.unshift(p);
|
|
131452
131520
|
p = p.parent;
|
|
131453
131521
|
}
|
|
131454
131522
|
debugSolution.push({
|
|
@@ -131456,7 +131524,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
131456
131524
|
pcb_component_id: "",
|
|
131457
131525
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
131458
131526
|
layer: "top",
|
|
131459
|
-
route:
|
|
131527
|
+
route: path31,
|
|
131460
131528
|
stroke_width: 0.01
|
|
131461
131529
|
});
|
|
131462
131530
|
}
|
|
@@ -136378,13 +136446,13 @@ var RBush = class {
|
|
|
136378
136446
|
return this;
|
|
136379
136447
|
let node = this.data;
|
|
136380
136448
|
const bbox = this.toBBox(item);
|
|
136381
|
-
const
|
|
136449
|
+
const path31 = [];
|
|
136382
136450
|
const indexes = [];
|
|
136383
136451
|
let i, parent, goingUp;
|
|
136384
|
-
while (node ||
|
|
136452
|
+
while (node || path31.length) {
|
|
136385
136453
|
if (!node) {
|
|
136386
|
-
node =
|
|
136387
|
-
parent =
|
|
136454
|
+
node = path31.pop();
|
|
136455
|
+
parent = path31[path31.length - 1];
|
|
136388
136456
|
i = indexes.pop();
|
|
136389
136457
|
goingUp = true;
|
|
136390
136458
|
}
|
|
@@ -136392,13 +136460,13 @@ var RBush = class {
|
|
|
136392
136460
|
const index = findItem(item, node.children, equalsFn);
|
|
136393
136461
|
if (index !== -1) {
|
|
136394
136462
|
node.children.splice(index, 1);
|
|
136395
|
-
|
|
136396
|
-
this._condense(
|
|
136463
|
+
path31.push(node);
|
|
136464
|
+
this._condense(path31);
|
|
136397
136465
|
return this;
|
|
136398
136466
|
}
|
|
136399
136467
|
}
|
|
136400
136468
|
if (!goingUp && !node.leaf && contains(node, bbox)) {
|
|
136401
|
-
|
|
136469
|
+
path31.push(node);
|
|
136402
136470
|
indexes.push(i);
|
|
136403
136471
|
i = 0;
|
|
136404
136472
|
parent = node;
|
|
@@ -136469,10 +136537,10 @@ var RBush = class {
|
|
|
136469
136537
|
calcBBox(node, this.toBBox);
|
|
136470
136538
|
return node;
|
|
136471
136539
|
}
|
|
136472
|
-
_chooseSubtree(bbox, node, level,
|
|
136540
|
+
_chooseSubtree(bbox, node, level, path31) {
|
|
136473
136541
|
while (true) {
|
|
136474
|
-
|
|
136475
|
-
if (node.leaf ||
|
|
136542
|
+
path31.push(node);
|
|
136543
|
+
if (node.leaf || path31.length - 1 === level)
|
|
136476
136544
|
break;
|
|
136477
136545
|
let minArea = Infinity;
|
|
136478
136546
|
let minEnlargement = Infinity;
|
|
@@ -136581,21 +136649,21 @@ var RBush = class {
|
|
|
136581
136649
|
}
|
|
136582
136650
|
return margin;
|
|
136583
136651
|
}
|
|
136584
|
-
_adjustParentBBoxes(bbox,
|
|
136652
|
+
_adjustParentBBoxes(bbox, path31, level) {
|
|
136585
136653
|
for (let i = level;i >= 0; i--) {
|
|
136586
|
-
extend(
|
|
136654
|
+
extend(path31[i], bbox);
|
|
136587
136655
|
}
|
|
136588
136656
|
}
|
|
136589
|
-
_condense(
|
|
136590
|
-
for (let i =
|
|
136591
|
-
if (
|
|
136657
|
+
_condense(path31) {
|
|
136658
|
+
for (let i = path31.length - 1, siblings;i >= 0; i--) {
|
|
136659
|
+
if (path31[i].children.length === 0) {
|
|
136592
136660
|
if (i > 0) {
|
|
136593
|
-
siblings =
|
|
136594
|
-
siblings.splice(siblings.indexOf(
|
|
136661
|
+
siblings = path31[i - 1].children;
|
|
136662
|
+
siblings.splice(siblings.indexOf(path31[i]), 1);
|
|
136595
136663
|
} else
|
|
136596
136664
|
this.clear();
|
|
136597
136665
|
} else
|
|
136598
|
-
calcBBox(
|
|
136666
|
+
calcBBox(path31[i], this.toBBox);
|
|
136599
136667
|
}
|
|
136600
136668
|
}
|
|
136601
136669
|
};
|
|
@@ -137740,7 +137808,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
137740
137808
|
this.capacityPaths = capacityPaths;
|
|
137741
137809
|
this.colorMap = colorMap ?? {};
|
|
137742
137810
|
this.unprocessedNodeIds = [
|
|
137743
|
-
...new Set(capacityPaths.flatMap((
|
|
137811
|
+
...new Set(capacityPaths.flatMap((path31) => path31.nodeIds))
|
|
137744
137812
|
];
|
|
137745
137813
|
this.nodePortSegments = /* @__PURE__ */ new Map;
|
|
137746
137814
|
}
|
|
@@ -137751,17 +137819,17 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
137751
137819
|
return;
|
|
137752
137820
|
}
|
|
137753
137821
|
const pathsGoingThroughNode = [];
|
|
137754
|
-
for (const
|
|
137755
|
-
const indexOfNodeInPath =
|
|
137822
|
+
for (const path31 of this.capacityPaths) {
|
|
137823
|
+
const indexOfNodeInPath = path31.nodeIds.indexOf(nodeId);
|
|
137756
137824
|
if (indexOfNodeInPath !== -1) {
|
|
137757
|
-
pathsGoingThroughNode.push({ path:
|
|
137825
|
+
pathsGoingThroughNode.push({ path: path31, indexOfNodeInPath });
|
|
137758
137826
|
}
|
|
137759
137827
|
}
|
|
137760
137828
|
const node = this.nodeMap.get(nodeId);
|
|
137761
137829
|
const nodePortSegments = [];
|
|
137762
|
-
for (const { path:
|
|
137763
|
-
const entryNodeId =
|
|
137764
|
-
const exitNodeId =
|
|
137830
|
+
for (const { path: path31, indexOfNodeInPath } of pathsGoingThroughNode) {
|
|
137831
|
+
const entryNodeId = path31.nodeIds[indexOfNodeInPath - 1];
|
|
137832
|
+
const exitNodeId = path31.nodeIds[indexOfNodeInPath + 1];
|
|
137765
137833
|
for (const adjNodeId of [entryNodeId, exitNodeId]) {
|
|
137766
137834
|
const adjNode = this.nodeMap.get(adjNodeId);
|
|
137767
137835
|
if (!adjNode)
|
|
@@ -137774,7 +137842,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
137774
137842
|
capacityMeshNodeId: nodeId,
|
|
137775
137843
|
start: segment2.start,
|
|
137776
137844
|
end: segment2.end,
|
|
137777
|
-
connectionNames: [
|
|
137845
|
+
connectionNames: [path31.connectionName],
|
|
137778
137846
|
availableZ: mutuallyAvailableZ
|
|
137779
137847
|
};
|
|
137780
137848
|
nodePortSegments.push(portSegment);
|
|
@@ -138580,37 +138648,37 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
|
|
|
138580
138648
|
return neighbors;
|
|
138581
138649
|
}
|
|
138582
138650
|
getNodePath(node) {
|
|
138583
|
-
const
|
|
138651
|
+
const path31 = [];
|
|
138584
138652
|
while (node) {
|
|
138585
|
-
|
|
138653
|
+
path31.push(node);
|
|
138586
138654
|
node = node.parent;
|
|
138587
138655
|
}
|
|
138588
|
-
return
|
|
138656
|
+
return path31;
|
|
138589
138657
|
}
|
|
138590
138658
|
getViasInNodePath(node) {
|
|
138591
|
-
const
|
|
138659
|
+
const path31 = this.getNodePath(node);
|
|
138592
138660
|
const vias = [];
|
|
138593
|
-
for (let i = 0;i <
|
|
138594
|
-
if (
|
|
138595
|
-
vias.push({ x:
|
|
138661
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
138662
|
+
if (path31[i].z !== path31[i + 1].z) {
|
|
138663
|
+
vias.push({ x: path31[i].x, y: path31[i].y });
|
|
138596
138664
|
}
|
|
138597
138665
|
}
|
|
138598
138666
|
return vias;
|
|
138599
138667
|
}
|
|
138600
138668
|
setSolvedPath(node) {
|
|
138601
|
-
const
|
|
138602
|
-
|
|
138669
|
+
const path31 = this.getNodePath(node);
|
|
138670
|
+
path31.reverse();
|
|
138603
138671
|
const vias = [];
|
|
138604
|
-
for (let i = 0;i <
|
|
138605
|
-
if (
|
|
138606
|
-
vias.push({ x:
|
|
138672
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
138673
|
+
if (path31[i].z !== path31[i + 1].z) {
|
|
138674
|
+
vias.push({ x: path31[i].x, y: path31[i].y });
|
|
138607
138675
|
}
|
|
138608
138676
|
}
|
|
138609
138677
|
this.solvedPath = {
|
|
138610
138678
|
connectionName: this.connectionName,
|
|
138611
138679
|
traceThickness: this.traceThickness,
|
|
138612
138680
|
viaDiameter: this.viaDiameter,
|
|
138613
|
-
route:
|
|
138681
|
+
route: path31.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
|
|
138614
138682
|
vias
|
|
138615
138683
|
};
|
|
138616
138684
|
}
|
|
@@ -139418,12 +139486,12 @@ function computeDumbbellPaths({
|
|
|
139418
139486
|
specialType: circleCenter === A3 ? "A" : "B"
|
|
139419
139487
|
};
|
|
139420
139488
|
};
|
|
139421
|
-
const subdivideOptimalPath = (
|
|
139422
|
-
if (
|
|
139423
|
-
return
|
|
139424
|
-
const result = [
|
|
139425
|
-
for (let i = 0;i <
|
|
139426
|
-
const segment2 = { start:
|
|
139489
|
+
const subdivideOptimalPath = (path31, numSubdivisions) => {
|
|
139490
|
+
if (path31.length < 2)
|
|
139491
|
+
return path31;
|
|
139492
|
+
const result = [path31[0]];
|
|
139493
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
139494
|
+
const segment2 = { start: path31[i], end: path31[i + 1] };
|
|
139427
139495
|
const segmentMidpoint = {
|
|
139428
139496
|
x: (segment2.start.x + segment2.end.x) / 2,
|
|
139429
139497
|
y: (segment2.start.y + segment2.end.y) / 2
|
|
@@ -139485,7 +139553,7 @@ function computeDumbbellPaths({
|
|
|
139485
139553
|
}
|
|
139486
139554
|
subdivisionPoints.forEach((p) => result.push(p));
|
|
139487
139555
|
}
|
|
139488
|
-
result.push(
|
|
139556
|
+
result.push(path31[i + 1]);
|
|
139489
139557
|
}
|
|
139490
139558
|
if (result.length > 1) {
|
|
139491
139559
|
const filteredResult = [result[0]];
|
|
@@ -139720,13 +139788,13 @@ function computeDumbbellPaths({
|
|
|
139720
139788
|
].map((l, index) => ({ ...l, index }));
|
|
139721
139789
|
};
|
|
139722
139790
|
const subdivideJLinePath = (jLine, oppositePoint, r3, m2, numSubdivisions) => {
|
|
139723
|
-
const
|
|
139724
|
-
if (
|
|
139725
|
-
return
|
|
139791
|
+
const path31 = jLine.points;
|
|
139792
|
+
if (path31.length < 2)
|
|
139793
|
+
return path31;
|
|
139726
139794
|
const minDistThreshold = r3 + m2;
|
|
139727
|
-
const result = [
|
|
139728
|
-
for (let i = 0;i <
|
|
139729
|
-
const segment2 = { start:
|
|
139795
|
+
const result = [path31[0]];
|
|
139796
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
139797
|
+
const segment2 = { start: path31[i], end: path31[i + 1] };
|
|
139730
139798
|
const distToOpposite = pointToSegmentDistance22(oppositePoint, segment2.start, segment2.end);
|
|
139731
139799
|
if (distToOpposite < minDistThreshold) {
|
|
139732
139800
|
const closestPt = closestPointOnSegment(segment2, oppositePoint);
|
|
@@ -139795,26 +139863,26 @@ function computeDumbbellPaths({
|
|
|
139795
139863
|
return { index: 0, path: [] };
|
|
139796
139864
|
}
|
|
139797
139865
|
const optimalPath2 = validPaths.sort((a, b3) => a.length - b3.length)[0];
|
|
139798
|
-
const
|
|
139799
|
-
const firstPoint =
|
|
139800
|
-
const dist3 = distance3(firstPoint,
|
|
139801
|
-
const dist4 = distance3(firstPoint,
|
|
139866
|
+
const path31 = [...optimalPath2.path];
|
|
139867
|
+
const firstPoint = path31[0];
|
|
139868
|
+
const dist3 = distance3(firstPoint, path31[2]);
|
|
139869
|
+
const dist4 = distance3(firstPoint, path31[3]);
|
|
139802
139870
|
const closerIdx = dist3 < dist4 ? 2 : 3;
|
|
139803
|
-
if (dist3 < distance3(firstPoint,
|
|
139804
|
-
|
|
139871
|
+
if (dist3 < distance3(firstPoint, path31[1]) || dist4 < distance3(firstPoint, path31[1])) {
|
|
139872
|
+
path31.splice(1, closerIdx - 1);
|
|
139805
139873
|
}
|
|
139806
|
-
const lastPoint =
|
|
139807
|
-
const distM3 = distance3(lastPoint,
|
|
139808
|
-
const distM4 = distance3(lastPoint,
|
|
139809
|
-
const closerLastIdx = distM3 < distM4 ?
|
|
139810
|
-
if (distM3 < distance3(lastPoint,
|
|
139811
|
-
|
|
139874
|
+
const lastPoint = path31[path31.length - 1];
|
|
139875
|
+
const distM3 = distance3(lastPoint, path31[path31.length - 3]);
|
|
139876
|
+
const distM4 = distance3(lastPoint, path31[path31.length - 4]);
|
|
139877
|
+
const closerLastIdx = distM3 < distM4 ? path31.length - 3 : path31.length - 4;
|
|
139878
|
+
if (distM3 < distance3(lastPoint, path31[path31.length - 2]) || distM4 < distance3(lastPoint, path31[path31.length - 2])) {
|
|
139879
|
+
path31.splice(closerLastIdx + 1, path31.length - closerLastIdx - 2);
|
|
139812
139880
|
}
|
|
139813
139881
|
return {
|
|
139814
139882
|
index: optimalPath2.index,
|
|
139815
|
-
path:
|
|
139816
|
-
startsAt:
|
|
139817
|
-
goesTo:
|
|
139883
|
+
path: path31,
|
|
139884
|
+
startsAt: path31[0] === C2 ? "C" : "D",
|
|
139885
|
+
goesTo: path31[path31.length - 1] === C2 ? "C" : "D"
|
|
139818
139886
|
};
|
|
139819
139887
|
};
|
|
139820
139888
|
const optimalPath = findOptimalPath();
|
|
@@ -141234,9 +141302,9 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
141234
141302
|
let closestIntersection = null;
|
|
141235
141303
|
let intersectedSegmentZ = null;
|
|
141236
141304
|
const checkIntersectionsWithPathMap = (pathMap) => {
|
|
141237
|
-
for (const
|
|
141238
|
-
for (let i = 0;i <
|
|
141239
|
-
const segment2 = [
|
|
141305
|
+
for (const path31 of pathMap.values()) {
|
|
141306
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
141307
|
+
const segment2 = [path31[i], path31[i + 1]];
|
|
141240
141308
|
if (segment2[0].x === segment2[1].x && segment2[0].y === segment2[1].y) {
|
|
141241
141309
|
continue;
|
|
141242
141310
|
}
|
|
@@ -141366,11 +141434,11 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
141366
141434
|
});
|
|
141367
141435
|
}
|
|
141368
141436
|
const drawPath = (pathMap, labelPrefix) => {
|
|
141369
|
-
for (const [connectionName,
|
|
141437
|
+
for (const [connectionName, path31] of pathMap.entries()) {
|
|
141370
141438
|
const color = colorMap[connectionName] ?? "black";
|
|
141371
|
-
for (let i = 0;i <
|
|
141372
|
-
const p12 =
|
|
141373
|
-
const p2 =
|
|
141439
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
141440
|
+
const p12 = path31[i];
|
|
141441
|
+
const p2 = path31[i + 1];
|
|
141374
141442
|
if (p12.x === p2.x && p12.y === p2.y && p12.z !== p2.z) {
|
|
141375
141443
|
graphics.circles.push({
|
|
141376
141444
|
center: { x: p12.x, y: p12.y },
|
|
@@ -141968,10 +142036,10 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
141968
142036
|
const allSegments = [];
|
|
141969
142037
|
const viaPoints = /* @__PURE__ */ new Map;
|
|
141970
142038
|
for (const polyLine of polyLines) {
|
|
141971
|
-
const
|
|
141972
|
-
for (let i = 0;i <
|
|
141973
|
-
const p12 =
|
|
141974
|
-
const p2 =
|
|
142039
|
+
const path31 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
142040
|
+
for (let i = 0;i < path31.length - 1; i++) {
|
|
142041
|
+
const p12 = path31[i];
|
|
142042
|
+
const p2 = path31[i + 1];
|
|
141975
142043
|
const layer = p12.z2;
|
|
141976
142044
|
allSegments.push({
|
|
141977
142045
|
start: { x: p12.x, y: p12.y },
|
|
@@ -141989,7 +142057,7 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
141989
142057
|
}
|
|
141990
142058
|
}
|
|
141991
142059
|
}
|
|
141992
|
-
const lastPoint =
|
|
142060
|
+
const lastPoint = path31[path31.length - 1];
|
|
141993
142061
|
if (lastPoint.z1 !== lastPoint.z2) {
|
|
141994
142062
|
const key = pointKey2(lastPoint);
|
|
141995
142063
|
if (!viaPoints.has(key)) {
|
|
@@ -142288,14 +142356,14 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
|
|
|
142288
142356
|
const polyLineVias = [];
|
|
142289
142357
|
for (let i = 0;i < polyLines.length; i++) {
|
|
142290
142358
|
const polyLine = polyLines[i];
|
|
142291
|
-
const
|
|
142359
|
+
const path31 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
142292
142360
|
const segmentsByLayer = new Map(this.availableZ.map((z852) => [z852, []]));
|
|
142293
|
-
for (let i22 = 0;i22 <
|
|
142294
|
-
const segment2 = [
|
|
142361
|
+
for (let i22 = 0;i22 < path31.length - 1; i22++) {
|
|
142362
|
+
const segment2 = [path31[i22], path31[i22 + 1]];
|
|
142295
142363
|
segmentsByLayer.get(segment2[0].z2).push(segment2);
|
|
142296
142364
|
}
|
|
142297
142365
|
polyLineSegmentsByLayer.push(segmentsByLayer);
|
|
142298
|
-
polyLineVias.push(
|
|
142366
|
+
polyLineVias.push(path31.filter((p) => p.z1 !== p.z2));
|
|
142299
142367
|
}
|
|
142300
142368
|
for (let i = 0;i < polyLines.length; i++) {
|
|
142301
142369
|
const path1SegmentsByLayer = polyLineSegmentsByLayer[i];
|
|
@@ -146505,13 +146573,13 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
146505
146573
|
return this.getDistanceBetweenNodes(node, endGoal);
|
|
146506
146574
|
}
|
|
146507
146575
|
getBacktrackedPath(candidate) {
|
|
146508
|
-
const
|
|
146576
|
+
const path31 = [];
|
|
146509
146577
|
let currentCandidate = candidate;
|
|
146510
146578
|
while (currentCandidate) {
|
|
146511
|
-
|
|
146579
|
+
path31.push(currentCandidate.node);
|
|
146512
146580
|
currentCandidate = currentCandidate.prevCandidate;
|
|
146513
146581
|
}
|
|
146514
|
-
return
|
|
146582
|
+
return path31;
|
|
146515
146583
|
}
|
|
146516
146584
|
getNeighboringNodes(node) {
|
|
146517
146585
|
return this.nodeEdgeMap.get(node.capacityMeshNodeId).flatMap((edge) => edge.nodeIds.filter((n3) => n3 !== node.capacityMeshNodeId)).map((n3) => this.nodeMap.get(n3));
|
|
@@ -146519,12 +146587,12 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
146519
146587
|
getCapacityPaths() {
|
|
146520
146588
|
const capacityPaths = [];
|
|
146521
146589
|
for (const connection of this.connectionsWithNodes) {
|
|
146522
|
-
const
|
|
146523
|
-
if (
|
|
146590
|
+
const path31 = connection.path;
|
|
146591
|
+
if (path31) {
|
|
146524
146592
|
capacityPaths.push({
|
|
146525
146593
|
capacityPathId: connection.connection.name,
|
|
146526
146594
|
connectionName: connection.connection.name,
|
|
146527
|
-
nodeIds:
|
|
146595
|
+
nodeIds: path31.map((node) => node.capacityMeshNodeId)
|
|
146528
146596
|
});
|
|
146529
146597
|
}
|
|
146530
146598
|
}
|
|
@@ -147209,10 +147277,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
147209
147277
|
return this.getDistanceBetweenNodes(node, endGoal) + this.getNodeCapacityPenalty(node);
|
|
147210
147278
|
}
|
|
147211
147279
|
getBacktrackedPath(candidate) {
|
|
147212
|
-
const
|
|
147280
|
+
const path31 = [];
|
|
147213
147281
|
let currentCandidate = candidate;
|
|
147214
147282
|
while (currentCandidate) {
|
|
147215
|
-
|
|
147283
|
+
path31.push(currentCandidate.node);
|
|
147216
147284
|
if (this.nodeMap.has(currentCandidate.node.capacityMeshNodeId)) {
|
|
147217
147285
|
currentCandidate = currentCandidate.prevCandidate;
|
|
147218
147286
|
} else {
|
|
@@ -147220,7 +147288,7 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
147220
147288
|
break;
|
|
147221
147289
|
}
|
|
147222
147290
|
}
|
|
147223
|
-
return
|
|
147291
|
+
return path31.reverse();
|
|
147224
147292
|
}
|
|
147225
147293
|
getNeighboringNodes(node) {
|
|
147226
147294
|
if (!this.nodeMap.has(node.capacityMeshNodeId))
|
|
@@ -147235,8 +147303,8 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
147235
147303
|
doesNodeHaveCapacityForTrace(node, prevNode) {
|
|
147236
147304
|
return true;
|
|
147237
147305
|
}
|
|
147238
|
-
reduceCapacityAlongPath(
|
|
147239
|
-
for (const pathNode of
|
|
147306
|
+
reduceCapacityAlongPath(path31) {
|
|
147307
|
+
for (const pathNode of path31) {
|
|
147240
147308
|
if (this.usedNodeCapacityMap.has(pathNode.capacityMeshNodeId)) {
|
|
147241
147309
|
const nodeId = pathNode.capacityMeshNodeId;
|
|
147242
147310
|
const nodeInSection = this.nodeMap.get(nodeId);
|
|
@@ -147365,9 +147433,9 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
147365
147433
|
this.queuedNodes = null;
|
|
147366
147434
|
}
|
|
147367
147435
|
_handleGoalReached(currentCandidate, currentTerminal, endNode) {
|
|
147368
|
-
const
|
|
147369
|
-
currentTerminal.path =
|
|
147370
|
-
this.reduceCapacityAlongPath(
|
|
147436
|
+
const path31 = this.getBacktrackedPath(currentCandidate);
|
|
147437
|
+
currentTerminal.path = path31;
|
|
147438
|
+
this.reduceCapacityAlongPath(path31);
|
|
147371
147439
|
this.currentConnectionIndex++;
|
|
147372
147440
|
this.candidates = null;
|
|
147373
147441
|
this.visitedNodes = null;
|
|
@@ -147416,10 +147484,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
147416
147484
|
const connectionColor = this.colorMap[connectionName] ?? "purple";
|
|
147417
147485
|
topCandidates.forEach((candidate, index) => {
|
|
147418
147486
|
const opacity = 0.8 * (1 - index / 5);
|
|
147419
|
-
const
|
|
147420
|
-
if (
|
|
147487
|
+
const path31 = this.getBacktrackedPath(candidate);
|
|
147488
|
+
if (path31.length > 0) {
|
|
147421
147489
|
baseGraphics.lines.push({
|
|
147422
|
-
points:
|
|
147490
|
+
points: path31.map(({ center: { x, y } }) => ({ x, y })),
|
|
147423
147491
|
strokeColor: safeTransparentize(connectionColor, 1 - opacity),
|
|
147424
147492
|
strokeWidth: 0.05
|
|
147425
147493
|
});
|
|
@@ -148108,12 +148176,12 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
|
|
|
148108
148176
|
getCapacityPaths() {
|
|
148109
148177
|
const capacityPaths = [];
|
|
148110
148178
|
for (const connection of this.connectionsWithNodes) {
|
|
148111
|
-
const
|
|
148112
|
-
if (
|
|
148179
|
+
const path31 = connection.path;
|
|
148180
|
+
if (path31) {
|
|
148113
148181
|
capacityPaths.push({
|
|
148114
148182
|
capacityPathId: connection.connection.name,
|
|
148115
148183
|
connectionName: connection.connection.name,
|
|
148116
|
-
nodeIds:
|
|
148184
|
+
nodeIds: path31.map((node) => node.capacityMeshNodeId)
|
|
148117
148185
|
});
|
|
148118
148186
|
}
|
|
148119
148187
|
}
|
|
@@ -149134,22 +149202,22 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
|
|
|
149134
149202
|
return null;
|
|
149135
149203
|
}
|
|
149136
149204
|
const possiblePaths = calculate45DegreePaths({ x: start.x, y: start.y }, { x: end.x, y: end.y });
|
|
149137
|
-
for (const
|
|
149138
|
-
const fullPath =
|
|
149205
|
+
for (const path31 of possiblePaths) {
|
|
149206
|
+
const fullPath = path31.map((p) => ({ x: p.x, y: p.y, z: start.z }));
|
|
149139
149207
|
if (this.isValidPath(fullPath)) {
|
|
149140
149208
|
return fullPath;
|
|
149141
149209
|
}
|
|
149142
149210
|
}
|
|
149143
149211
|
return null;
|
|
149144
149212
|
}
|
|
149145
|
-
addPathToResult(
|
|
149146
|
-
if (
|
|
149213
|
+
addPathToResult(path31) {
|
|
149214
|
+
if (path31.length === 0)
|
|
149147
149215
|
return;
|
|
149148
|
-
for (let i = 0;i <
|
|
149149
|
-
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1],
|
|
149216
|
+
for (let i = 0;i < path31.length; i++) {
|
|
149217
|
+
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path31[i])) {
|
|
149150
149218
|
continue;
|
|
149151
149219
|
}
|
|
149152
|
-
this.newRoute.push(
|
|
149220
|
+
this.newRoute.push(path31[i]);
|
|
149153
149221
|
}
|
|
149154
149222
|
this.currentStepSize = this.maxStepSize;
|
|
149155
149223
|
}
|
|
@@ -176556,7 +176624,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
176556
176624
|
for (let i = 0;i < portsWithPosition.length - 1; i++) {
|
|
176557
176625
|
const start = portsWithPosition[i];
|
|
176558
176626
|
const end = portsWithPosition[i + 1];
|
|
176559
|
-
const
|
|
176627
|
+
const path31 = calculateElbow({
|
|
176560
176628
|
x: start.position.x,
|
|
176561
176629
|
y: start.position.y,
|
|
176562
176630
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -176565,8 +176633,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
176565
176633
|
y: end.position.y,
|
|
176566
176634
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
176567
176635
|
});
|
|
176568
|
-
for (let j4 = 0;j4 <
|
|
176569
|
-
elbowEdges.push({ from:
|
|
176636
|
+
for (let j4 = 0;j4 < path31.length - 1; j4++) {
|
|
176637
|
+
elbowEdges.push({ from: path31[j4], to: path31[j4 + 1] });
|
|
176570
176638
|
}
|
|
176571
176639
|
}
|
|
176572
176640
|
const doesSegmentIntersectRect = (edge, rect) => {
|
|
@@ -182755,7 +182823,7 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
182755
182823
|
|
|
182756
182824
|
// lib/import/import-component-from-jlcpcb.ts
|
|
182757
182825
|
import fs31 from "node:fs/promises";
|
|
182758
|
-
import
|
|
182826
|
+
import path31 from "node:path";
|
|
182759
182827
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
182760
182828
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
182761
182829
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -182763,9 +182831,9 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
182763
182831
|
if (!fileName) {
|
|
182764
182832
|
throw new Error("Could not determine file name of converted component");
|
|
182765
182833
|
}
|
|
182766
|
-
const importsDir =
|
|
182834
|
+
const importsDir = path31.join(projectDir, "imports");
|
|
182767
182835
|
await fs31.mkdir(importsDir, { recursive: true });
|
|
182768
|
-
const filePath =
|
|
182836
|
+
const filePath = path31.join(importsDir, `${fileName}.tsx`);
|
|
182769
182837
|
await fs31.writeFile(filePath, tsx);
|
|
182770
182838
|
return { filePath };
|
|
182771
182839
|
};
|
|
@@ -182868,11 +182936,11 @@ var registerRemove = (program3) => {
|
|
|
182868
182936
|
};
|
|
182869
182937
|
|
|
182870
182938
|
// cli/build/register.ts
|
|
182871
|
-
import
|
|
182939
|
+
import path40 from "node:path";
|
|
182872
182940
|
import fs40 from "node:fs";
|
|
182873
182941
|
|
|
182874
182942
|
// cli/build/build-file.ts
|
|
182875
|
-
import
|
|
182943
|
+
import path32 from "node:path";
|
|
182876
182944
|
import fs32 from "node:fs";
|
|
182877
182945
|
|
|
182878
182946
|
// lib/shared/circuit-json-diagnostics.ts
|
|
@@ -182935,9 +183003,9 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
182935
183003
|
filePath: input,
|
|
182936
183004
|
platformConfig: completePlatformConfig
|
|
182937
183005
|
});
|
|
182938
|
-
fs32.mkdirSync(
|
|
183006
|
+
fs32.mkdirSync(path32.dirname(output), { recursive: true });
|
|
182939
183007
|
fs32.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
|
|
182940
|
-
console.log(`Circuit JSON written to ${
|
|
183008
|
+
console.log(`Circuit JSON written to ${path32.relative(projectDir, output)}`);
|
|
182941
183009
|
const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
|
|
182942
183010
|
if (!options?.ignoreWarnings) {
|
|
182943
183011
|
for (const warn of warnings) {
|
|
@@ -182975,7 +183043,7 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
182975
183043
|
if (!match)
|
|
182976
183044
|
return;
|
|
182977
183045
|
const [, exportName, fromSpecifier] = match;
|
|
182978
|
-
const entryFileName =
|
|
183046
|
+
const entryFileName = path32.basename(entryFilePath);
|
|
182979
183047
|
console.error([
|
|
182980
183048
|
"",
|
|
182981
183049
|
`It looks like "${entryFileName}" re-exports the type-only symbol "${exportName}" from "${fromSpecifier}" without the "type" modifier.`,
|
|
@@ -182989,19 +183057,19 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
182989
183057
|
|
|
182990
183058
|
// cli/build/get-build-entrypoints.ts
|
|
182991
183059
|
import fs33 from "node:fs";
|
|
182992
|
-
import
|
|
183060
|
+
import path33 from "node:path";
|
|
182993
183061
|
var isSubPath2 = (maybeChild, maybeParent) => {
|
|
182994
|
-
const relative9 =
|
|
182995
|
-
return relative9 === "" || !relative9.startsWith("..") && !
|
|
183062
|
+
const relative9 = path33.relative(maybeParent, maybeChild);
|
|
183063
|
+
return relative9 === "" || !relative9.startsWith("..") && !path33.isAbsolute(relative9);
|
|
182996
183064
|
};
|
|
182997
183065
|
var findProjectRoot = (startDir) => {
|
|
182998
183066
|
let currentDir = startDir;
|
|
182999
|
-
while (currentDir !==
|
|
183000
|
-
const packageJsonPath =
|
|
183067
|
+
while (currentDir !== path33.dirname(currentDir)) {
|
|
183068
|
+
const packageJsonPath = path33.join(currentDir, "package.json");
|
|
183001
183069
|
if (fs33.existsSync(packageJsonPath)) {
|
|
183002
183070
|
return currentDir;
|
|
183003
183071
|
}
|
|
183004
|
-
currentDir =
|
|
183072
|
+
currentDir = path33.dirname(currentDir);
|
|
183005
183073
|
}
|
|
183006
183074
|
return startDir;
|
|
183007
183075
|
};
|
|
@@ -183009,7 +183077,7 @@ async function getBuildEntrypoints({
|
|
|
183009
183077
|
fileOrDir,
|
|
183010
183078
|
rootDir = process.cwd()
|
|
183011
183079
|
}) {
|
|
183012
|
-
const resolvedRoot =
|
|
183080
|
+
const resolvedRoot = path33.resolve(rootDir);
|
|
183013
183081
|
const includeBoardFiles = getBoardFilePatterns(resolvedRoot);
|
|
183014
183082
|
const buildFromProjectDir = async () => {
|
|
183015
183083
|
const files = findBoardFiles({ projectDir: resolvedRoot });
|
|
@@ -183041,7 +183109,7 @@ async function getBuildEntrypoints({
|
|
|
183041
183109
|
};
|
|
183042
183110
|
};
|
|
183043
183111
|
if (fileOrDir) {
|
|
183044
|
-
const resolved =
|
|
183112
|
+
const resolved = path33.resolve(resolvedRoot, fileOrDir);
|
|
183045
183113
|
if (fs33.existsSync(resolved) && fs33.statSync(resolved).isDirectory()) {
|
|
183046
183114
|
const circuitFiles = findBoardFiles({
|
|
183047
183115
|
projectDir: resolvedRoot,
|
|
@@ -183055,7 +183123,7 @@ async function getBuildEntrypoints({
|
|
|
183055
183123
|
circuitFiles
|
|
183056
183124
|
};
|
|
183057
183125
|
}
|
|
183058
|
-
const fileDir =
|
|
183126
|
+
const fileDir = path33.dirname(resolved);
|
|
183059
183127
|
const projectDir = findProjectRoot(fileDir);
|
|
183060
183128
|
return { projectDir, circuitFiles: [resolved] };
|
|
183061
183129
|
}
|
|
@@ -183092,7 +183160,7 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
|
|
|
183092
183160
|
|
|
183093
183161
|
// cli/build/build-preview-images.ts
|
|
183094
183162
|
import fs34 from "node:fs";
|
|
183095
|
-
import
|
|
183163
|
+
import path34 from "node:path";
|
|
183096
183164
|
import {
|
|
183097
183165
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
183098
183166
|
convertCircuitJsonToSchematicSvg as convertCircuitJsonToSchematicSvg2
|
|
@@ -183137,7 +183205,7 @@ var generatePreviewAssets = async ({
|
|
|
183137
183205
|
outputDir,
|
|
183138
183206
|
distDir
|
|
183139
183207
|
}) => {
|
|
183140
|
-
const prefixRelative =
|
|
183208
|
+
const prefixRelative = path34.relative(distDir, outputDir) || ".";
|
|
183141
183209
|
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
183142
183210
|
try {
|
|
183143
183211
|
const circuitJsonRaw = fs34.readFileSync(build.outputPath, "utf-8");
|
|
@@ -183157,11 +183225,11 @@ var generatePreviewAssets = async ({
|
|
|
183157
183225
|
lookAt: [0, 0, 0]
|
|
183158
183226
|
});
|
|
183159
183227
|
fs34.mkdirSync(outputDir, { recursive: true });
|
|
183160
|
-
fs34.writeFileSync(
|
|
183228
|
+
fs34.writeFileSync(path34.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
183161
183229
|
console.log(`${prefix}Written pcb.svg`);
|
|
183162
|
-
fs34.writeFileSync(
|
|
183230
|
+
fs34.writeFileSync(path34.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
183163
183231
|
console.log(`${prefix}Written schematic.svg`);
|
|
183164
|
-
fs34.writeFileSync(
|
|
183232
|
+
fs34.writeFileSync(path34.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
|
|
183165
183233
|
console.log(`${prefix}Written 3d.png`);
|
|
183166
183234
|
} catch (error) {
|
|
183167
183235
|
console.error(`${prefix}Failed to generate preview images:`, error);
|
|
@@ -183174,14 +183242,14 @@ var buildPreviewImages = async ({
|
|
|
183174
183242
|
allImages
|
|
183175
183243
|
}) => {
|
|
183176
183244
|
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
183177
|
-
const normalizedMainEntrypoint = mainEntrypoint ?
|
|
183245
|
+
const normalizedMainEntrypoint = mainEntrypoint ? path34.resolve(mainEntrypoint) : undefined;
|
|
183178
183246
|
if (allImages) {
|
|
183179
183247
|
if (successfulBuilds.length === 0) {
|
|
183180
183248
|
console.warn("No successful build output available for preview image generation.");
|
|
183181
183249
|
return;
|
|
183182
183250
|
}
|
|
183183
183251
|
for (const build of successfulBuilds) {
|
|
183184
|
-
const outputDir =
|
|
183252
|
+
const outputDir = path34.dirname(build.outputPath);
|
|
183185
183253
|
await generatePreviewAssets({
|
|
183186
183254
|
build,
|
|
183187
183255
|
outputDir,
|
|
@@ -183192,7 +183260,7 @@ var buildPreviewImages = async ({
|
|
|
183192
183260
|
}
|
|
183193
183261
|
const previewBuild = (() => {
|
|
183194
183262
|
if (normalizedMainEntrypoint) {
|
|
183195
|
-
const match = successfulBuilds.find((built) =>
|
|
183263
|
+
const match = successfulBuilds.find((built) => path34.resolve(built.sourcePath) === normalizedMainEntrypoint);
|
|
183196
183264
|
if (match)
|
|
183197
183265
|
return match;
|
|
183198
183266
|
}
|
|
@@ -183211,7 +183279,7 @@ var buildPreviewImages = async ({
|
|
|
183211
183279
|
|
|
183212
183280
|
// cli/build/generate-kicad-project.ts
|
|
183213
183281
|
import fs35 from "node:fs";
|
|
183214
|
-
import
|
|
183282
|
+
import path35 from "node:path";
|
|
183215
183283
|
var createKicadProContent = ({
|
|
183216
183284
|
projectName,
|
|
183217
183285
|
schematicFileName,
|
|
@@ -183252,9 +183320,9 @@ var generateKicadProject = async ({
|
|
|
183252
183320
|
});
|
|
183253
183321
|
if (writeFiles) {
|
|
183254
183322
|
fs35.mkdirSync(outputDir, { recursive: true });
|
|
183255
|
-
fs35.writeFileSync(
|
|
183256
|
-
fs35.writeFileSync(
|
|
183257
|
-
fs35.writeFileSync(
|
|
183323
|
+
fs35.writeFileSync(path35.join(outputDir, schematicFileName), schContent);
|
|
183324
|
+
fs35.writeFileSync(path35.join(outputDir, boardFileName), pcbContent);
|
|
183325
|
+
fs35.writeFileSync(path35.join(outputDir, projectFileName), proContent);
|
|
183258
183326
|
}
|
|
183259
183327
|
return {
|
|
183260
183328
|
pcbContent,
|
|
@@ -183267,7 +183335,7 @@ var generateKicadProject = async ({
|
|
|
183267
183335
|
|
|
183268
183336
|
// cli/build/generate-kicad-footprint-library.ts
|
|
183269
183337
|
import fs36 from "node:fs";
|
|
183270
|
-
import
|
|
183338
|
+
import path36 from "node:path";
|
|
183271
183339
|
import { At as At2, KicadPcb as KicadPcb2, parseKicadSexpr } from "kicadts";
|
|
183272
183340
|
var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
183273
183341
|
if (!libraryLink) {
|
|
@@ -183327,7 +183395,7 @@ var generateKicadFootprintLibrary = async ({
|
|
|
183327
183395
|
projects,
|
|
183328
183396
|
distDir
|
|
183329
183397
|
}) => {
|
|
183330
|
-
const libraryRoot =
|
|
183398
|
+
const libraryRoot = path36.join(distDir, "kicad-footprints");
|
|
183331
183399
|
fs36.mkdirSync(libraryRoot, { recursive: true });
|
|
183332
183400
|
const uniqueFootprints = new Map;
|
|
183333
183401
|
for (const project of projects) {
|
|
@@ -183351,9 +183419,9 @@ var generateKicadFootprintLibrary = async ({
|
|
|
183351
183419
|
const libraryNames = new Set;
|
|
183352
183420
|
for (const entry of uniqueFootprints.values()) {
|
|
183353
183421
|
libraryNames.add(entry.libraryName);
|
|
183354
|
-
const libraryDir =
|
|
183422
|
+
const libraryDir = path36.join(libraryRoot, `${entry.libraryName}.pretty`);
|
|
183355
183423
|
fs36.mkdirSync(libraryDir, { recursive: true });
|
|
183356
|
-
const footprintPath =
|
|
183424
|
+
const footprintPath = path36.join(libraryDir, `${entry.footprintName}.kicad_mod`);
|
|
183357
183425
|
fs36.writeFileSync(footprintPath, `${entry.content}
|
|
183358
183426
|
`);
|
|
183359
183427
|
}
|
|
@@ -183364,12 +183432,12 @@ ${libTableEntries.join(`
|
|
|
183364
183432
|
`)}
|
|
183365
183433
|
)
|
|
183366
183434
|
`;
|
|
183367
|
-
fs36.writeFileSync(
|
|
183435
|
+
fs36.writeFileSync(path36.join(libraryRoot, "fp-lib-table"), libTableContent);
|
|
183368
183436
|
}
|
|
183369
183437
|
};
|
|
183370
183438
|
|
|
183371
183439
|
// cli/build/transpile/index.ts
|
|
183372
|
-
import
|
|
183440
|
+
import path38 from "node:path";
|
|
183373
183441
|
import fs38 from "node:fs";
|
|
183374
183442
|
import { rollup } from "rollup";
|
|
183375
183443
|
import typescript from "@rollup/plugin-typescript";
|
|
@@ -183380,10 +183448,10 @@ import dts from "rollup-plugin-dts";
|
|
|
183380
183448
|
|
|
183381
183449
|
// cli/build/transpile/static-asset-plugin.ts
|
|
183382
183450
|
import fs37 from "node:fs";
|
|
183383
|
-
import
|
|
183451
|
+
import path37 from "node:path";
|
|
183384
183452
|
import { createHash } from "node:crypto";
|
|
183385
183453
|
function normalizePathSeparators(filePath) {
|
|
183386
|
-
return filePath.split(
|
|
183454
|
+
return filePath.split(path37.sep).join("/");
|
|
183387
183455
|
}
|
|
183388
183456
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
183389
183457
|
".glb",
|
|
@@ -183414,15 +183482,15 @@ var createStaticAssetPlugin = ({
|
|
|
183414
183482
|
return {
|
|
183415
183483
|
name: "tsci-static-assets",
|
|
183416
183484
|
resolveId(source, importer) {
|
|
183417
|
-
const ext =
|
|
183485
|
+
const ext = path37.extname(source).toLowerCase();
|
|
183418
183486
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
183419
183487
|
return null;
|
|
183420
|
-
if (
|
|
183488
|
+
if (path37.isAbsolute(source)) {
|
|
183421
183489
|
return fs37.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
183422
183490
|
}
|
|
183423
183491
|
if (importer) {
|
|
183424
|
-
const importerNative = importer.split("/").join(
|
|
183425
|
-
const resolvedFromImporter =
|
|
183492
|
+
const importerNative = importer.split("/").join(path37.sep);
|
|
183493
|
+
const resolvedFromImporter = path37.resolve(path37.dirname(importerNative), source);
|
|
183426
183494
|
if (fs37.existsSync(resolvedFromImporter)) {
|
|
183427
183495
|
return {
|
|
183428
183496
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
@@ -183430,7 +183498,7 @@ var createStaticAssetPlugin = ({
|
|
|
183430
183498
|
};
|
|
183431
183499
|
}
|
|
183432
183500
|
}
|
|
183433
|
-
const resolvedFromProject =
|
|
183501
|
+
const resolvedFromProject = path37.resolve(resolvedBaseUrl, source);
|
|
183434
183502
|
if (fs37.existsSync(resolvedFromProject)) {
|
|
183435
183503
|
return {
|
|
183436
183504
|
id: normalizePathSeparators(resolvedFromProject),
|
|
@@ -183444,7 +183512,7 @@ var createStaticAssetPlugin = ({
|
|
|
183444
183512
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
183445
183513
|
for (const target of targets) {
|
|
183446
183514
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
183447
|
-
const resolvedTarget =
|
|
183515
|
+
const resolvedTarget = path37.resolve(resolvedBaseUrl, targetPath);
|
|
183448
183516
|
if (fs37.existsSync(resolvedTarget)) {
|
|
183449
183517
|
return {
|
|
183450
183518
|
id: normalizePathSeparators(resolvedTarget),
|
|
@@ -183471,17 +183539,17 @@ var createStaticAssetPlugin = ({
|
|
|
183471
183539
|
if (chunk.type !== "chunk")
|
|
183472
183540
|
continue;
|
|
183473
183541
|
for (const importedId of chunk.imports) {
|
|
183474
|
-
const ext =
|
|
183542
|
+
const ext = path37.extname(importedId).toLowerCase();
|
|
183475
183543
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
183476
183544
|
continue;
|
|
183477
183545
|
if (!copiedAssets.has(importedId)) {
|
|
183478
|
-
const assetDir =
|
|
183546
|
+
const assetDir = path37.join(outputDir, "assets");
|
|
183479
183547
|
fs37.mkdirSync(assetDir, { recursive: true });
|
|
183480
|
-
const nativePath = importedId.split("/").join(
|
|
183548
|
+
const nativePath = importedId.split("/").join(path37.sep);
|
|
183481
183549
|
const fileBuffer = fs37.readFileSync(nativePath);
|
|
183482
183550
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
183483
|
-
const fileName = `${
|
|
183484
|
-
const outputFilePath =
|
|
183551
|
+
const fileName = `${path37.basename(importedId, ext)}-${hash}${ext}`;
|
|
183552
|
+
const outputFilePath = path37.join(assetDir, fileName);
|
|
183485
183553
|
fs37.writeFileSync(outputFilePath, fileBuffer);
|
|
183486
183554
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
183487
183555
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
@@ -183504,7 +183572,7 @@ function escapeRegExp(string) {
|
|
|
183504
183572
|
|
|
183505
183573
|
// cli/build/transpile/index.ts
|
|
183506
183574
|
var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
183507
|
-
if (id2.startsWith(".") || id2.startsWith("/") ||
|
|
183575
|
+
if (id2.startsWith(".") || id2.startsWith("/") || path38.isAbsolute(id2)) {
|
|
183508
183576
|
return false;
|
|
183509
183577
|
}
|
|
183510
183578
|
let baseUrl = projectDir;
|
|
@@ -183514,7 +183582,7 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
|
183514
183582
|
const tsconfigContent = fs38.readFileSync(tsconfigPath, "utf-8");
|
|
183515
183583
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
183516
183584
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
183517
|
-
baseUrl =
|
|
183585
|
+
baseUrl = path38.resolve(path38.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
183518
183586
|
}
|
|
183519
183587
|
if (tsconfig.compilerOptions?.paths) {
|
|
183520
183588
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -183528,15 +183596,15 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
|
183528
183596
|
}
|
|
183529
183597
|
}
|
|
183530
183598
|
const potentialPaths = [
|
|
183531
|
-
|
|
183532
|
-
|
|
183533
|
-
|
|
183534
|
-
|
|
183535
|
-
|
|
183536
|
-
|
|
183537
|
-
|
|
183538
|
-
|
|
183539
|
-
|
|
183599
|
+
path38.join(baseUrl, id2),
|
|
183600
|
+
path38.join(baseUrl, `${id2}.ts`),
|
|
183601
|
+
path38.join(baseUrl, `${id2}.tsx`),
|
|
183602
|
+
path38.join(baseUrl, `${id2}.js`),
|
|
183603
|
+
path38.join(baseUrl, `${id2}.jsx`),
|
|
183604
|
+
path38.join(baseUrl, id2, "index.ts"),
|
|
183605
|
+
path38.join(baseUrl, id2, "index.tsx"),
|
|
183606
|
+
path38.join(baseUrl, id2, "index.js"),
|
|
183607
|
+
path38.join(baseUrl, id2, "index.jsx")
|
|
183540
183608
|
];
|
|
183541
183609
|
if (potentialPaths.some((p) => fs38.existsSync(p))) {
|
|
183542
183610
|
return false;
|
|
@@ -183550,7 +183618,7 @@ var transpileFile = async ({
|
|
|
183550
183618
|
}) => {
|
|
183551
183619
|
try {
|
|
183552
183620
|
fs38.mkdirSync(outputDir, { recursive: true });
|
|
183553
|
-
const tsconfigPath =
|
|
183621
|
+
const tsconfigPath = path38.join(projectDir, "tsconfig.json");
|
|
183554
183622
|
const hasTsConfig = fs38.existsSync(tsconfigPath);
|
|
183555
183623
|
let tsconfigBaseUrl = projectDir;
|
|
183556
183624
|
let tsconfigPathMappings;
|
|
@@ -183559,7 +183627,7 @@ var transpileFile = async ({
|
|
|
183559
183627
|
const tsconfigContent = fs38.readFileSync(tsconfigPath, "utf-8");
|
|
183560
183628
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
183561
183629
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
183562
|
-
tsconfigBaseUrl =
|
|
183630
|
+
tsconfigBaseUrl = path38.resolve(path38.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
183563
183631
|
}
|
|
183564
183632
|
if (tsconfig.compilerOptions?.paths) {
|
|
183565
183633
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -183614,27 +183682,27 @@ var transpileFile = async ({
|
|
|
183614
183682
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
183615
183683
|
plugins: getPlugins()
|
|
183616
183684
|
});
|
|
183617
|
-
const esmOutputPath =
|
|
183685
|
+
const esmOutputPath = path38.join(outputDir, "index.js");
|
|
183618
183686
|
await esmBundle.write({
|
|
183619
183687
|
file: esmOutputPath,
|
|
183620
183688
|
format: "es",
|
|
183621
183689
|
sourcemap: false
|
|
183622
183690
|
});
|
|
183623
|
-
console.log(`ESM bundle written to ${
|
|
183691
|
+
console.log(`ESM bundle written to ${path38.relative(projectDir, esmOutputPath)}`);
|
|
183624
183692
|
console.log("Building CommonJS bundle...");
|
|
183625
183693
|
const cjsBundle = await rollup({
|
|
183626
183694
|
input,
|
|
183627
183695
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
183628
183696
|
plugins: getPlugins()
|
|
183629
183697
|
});
|
|
183630
|
-
const cjsOutputPath =
|
|
183698
|
+
const cjsOutputPath = path38.join(outputDir, "index.cjs");
|
|
183631
183699
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
183632
183700
|
await cjsBundle.write({
|
|
183633
183701
|
file: cjsOutputPath,
|
|
183634
183702
|
format: "cjs",
|
|
183635
183703
|
sourcemap: false
|
|
183636
183704
|
});
|
|
183637
|
-
console.log(`CommonJS bundle written to ${
|
|
183705
|
+
console.log(`CommonJS bundle written to ${path38.relative(projectDir, cjsOutputPath)}`);
|
|
183638
183706
|
console.log("Generating type declarations...");
|
|
183639
183707
|
const dtsBundle = await rollup({
|
|
183640
183708
|
input,
|
|
@@ -183659,9 +183727,9 @@ var transpileFile = async ({
|
|
|
183659
183727
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
183660
183728
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
183661
183729
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
183662
|
-
const dtsOutputPath =
|
|
183730
|
+
const dtsOutputPath = path38.join(outputDir, "index.d.ts");
|
|
183663
183731
|
fs38.writeFileSync(dtsOutputPath, dtsContent);
|
|
183664
|
-
console.log(`Type declarations written to ${
|
|
183732
|
+
console.log(`Type declarations written to ${path38.relative(projectDir, dtsOutputPath)}`);
|
|
183665
183733
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
183666
183734
|
return true;
|
|
183667
183735
|
} catch (err) {
|
|
@@ -183675,16 +183743,16 @@ var transpileFile = async ({
|
|
|
183675
183743
|
|
|
183676
183744
|
// cli/utils/validate-main-in-dist.ts
|
|
183677
183745
|
import fs39 from "node:fs";
|
|
183678
|
-
import
|
|
183746
|
+
import path39 from "node:path";
|
|
183679
183747
|
var validateMainInDist = (projectDir, distDir) => {
|
|
183680
|
-
const packageJsonPath =
|
|
183748
|
+
const packageJsonPath = path39.join(projectDir, "package.json");
|
|
183681
183749
|
if (!fs39.existsSync(packageJsonPath))
|
|
183682
183750
|
return;
|
|
183683
183751
|
const packageJson = JSON.parse(fs39.readFileSync(packageJsonPath, "utf-8"));
|
|
183684
183752
|
if (typeof packageJson.main !== "string")
|
|
183685
183753
|
return;
|
|
183686
|
-
const resolvedMainPath =
|
|
183687
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
183754
|
+
const resolvedMainPath = path39.resolve(projectDir, packageJson.main);
|
|
183755
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path39.sep}`);
|
|
183688
183756
|
if (!isMainInDist) {
|
|
183689
183757
|
throw new Error('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
183690
183758
|
}
|
|
@@ -183709,7 +183777,7 @@ var registerBuild = (program3) => {
|
|
|
183709
183777
|
}
|
|
183710
183778
|
return config;
|
|
183711
183779
|
})();
|
|
183712
|
-
const distDir =
|
|
183780
|
+
const distDir = path40.join(projectDir, "dist");
|
|
183713
183781
|
fs40.mkdirSync(distDir, { recursive: true });
|
|
183714
183782
|
console.log(`Building ${circuitFiles.length} file(s)...`);
|
|
183715
183783
|
let hasErrors = false;
|
|
@@ -183718,10 +183786,10 @@ var registerBuild = (program3) => {
|
|
|
183718
183786
|
const kicadProjects = [];
|
|
183719
183787
|
const shouldGenerateKicad = options?.kicad || options?.kicadFootprintLibrary;
|
|
183720
183788
|
for (const filePath of circuitFiles) {
|
|
183721
|
-
const relative9 =
|
|
183789
|
+
const relative9 = path40.relative(projectDir, filePath);
|
|
183722
183790
|
console.log(`Building ${relative9}...`);
|
|
183723
183791
|
const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
183724
|
-
const outputPath =
|
|
183792
|
+
const outputPath = path40.join(distDir, outputDirName, "circuit.json");
|
|
183725
183793
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, {
|
|
183726
183794
|
ignoreErrors: options?.ignoreErrors,
|
|
183727
183795
|
ignoreWarnings: options?.ignoreWarnings,
|
|
@@ -183735,17 +183803,17 @@ var registerBuild = (program3) => {
|
|
|
183735
183803
|
if (!buildOutcome.ok) {
|
|
183736
183804
|
hasErrors = true;
|
|
183737
183805
|
} else if (options?.site) {
|
|
183738
|
-
const normalizedSourcePath = relative9.split(
|
|
183739
|
-
const relativeOutputPath =
|
|
183740
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
183806
|
+
const normalizedSourcePath = relative9.split(path40.sep).join("/");
|
|
183807
|
+
const relativeOutputPath = path40.join(outputDirName, "circuit.json");
|
|
183808
|
+
const normalizedOutputPath = relativeOutputPath.split(path40.sep).join("/");
|
|
183741
183809
|
staticFileReferences.push({
|
|
183742
183810
|
filePath: normalizedSourcePath,
|
|
183743
183811
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
183744
183812
|
});
|
|
183745
183813
|
}
|
|
183746
183814
|
if (buildOutcome.ok && shouldGenerateKicad && buildOutcome.circuitJson) {
|
|
183747
|
-
const projectOutputDir =
|
|
183748
|
-
const projectName =
|
|
183815
|
+
const projectOutputDir = path40.join(distDir, outputDirName, "kicad");
|
|
183816
|
+
const projectName = path40.basename(outputDirName);
|
|
183749
183817
|
const project = await generateKicadProject({
|
|
183750
183818
|
circuitJson: buildOutcome.circuitJson,
|
|
183751
183819
|
outputDir: projectOutputDir,
|
|
@@ -183794,8 +183862,8 @@ var registerBuild = (program3) => {
|
|
|
183794
183862
|
files: staticFileReferences,
|
|
183795
183863
|
standaloneScriptSrc: "./standalone.min.js"
|
|
183796
183864
|
});
|
|
183797
|
-
fs40.writeFileSync(
|
|
183798
|
-
fs40.writeFileSync(
|
|
183865
|
+
fs40.writeFileSync(path40.join(distDir, "index.html"), indexHtml);
|
|
183866
|
+
fs40.writeFileSync(path40.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
183799
183867
|
}
|
|
183800
183868
|
if (options?.kicadFootprintLibrary) {
|
|
183801
183869
|
if (kicadProjects.length === 0) {
|
|
@@ -183819,7 +183887,7 @@ var registerBuild = (program3) => {
|
|
|
183819
183887
|
|
|
183820
183888
|
// lib/shared/snapshot-project.ts
|
|
183821
183889
|
import fs42 from "node:fs";
|
|
183822
|
-
import
|
|
183890
|
+
import path41 from "node:path";
|
|
183823
183891
|
import looksSame2 from "looks-same";
|
|
183824
183892
|
import {
|
|
183825
183893
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
@@ -183871,7 +183939,7 @@ var snapshotProject = async ({
|
|
|
183871
183939
|
...DEFAULT_IGNORED_PATTERNS,
|
|
183872
183940
|
...ignored.map(normalizeIgnorePattern)
|
|
183873
183941
|
];
|
|
183874
|
-
const resolvedPaths = filePaths.map((f) =>
|
|
183942
|
+
const resolvedPaths = filePaths.map((f) => path41.resolve(projectDir, f));
|
|
183875
183943
|
const boardFiles = findBoardFiles({
|
|
183876
183944
|
projectDir,
|
|
183877
183945
|
ignore,
|
|
@@ -183885,7 +183953,7 @@ var snapshotProject = async ({
|
|
|
183885
183953
|
const mismatches = [];
|
|
183886
183954
|
let didUpdate = false;
|
|
183887
183955
|
for (const file of boardFiles) {
|
|
183888
|
-
const relativeFilePath =
|
|
183956
|
+
const relativeFilePath = path41.relative(projectDir, file);
|
|
183889
183957
|
let circuitJson;
|
|
183890
183958
|
let pcbSvg;
|
|
183891
183959
|
let schSvg;
|
|
@@ -183940,17 +184008,17 @@ var snapshotProject = async ({
|
|
|
183940
184008
|
} catch (error) {
|
|
183941
184009
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
183942
184010
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
183943
|
-
const fileDir =
|
|
183944
|
-
const relativeDir =
|
|
183945
|
-
const snapDir2 = snapshotsDirName ?
|
|
183946
|
-
const base2 =
|
|
183947
|
-
const snap3dPath =
|
|
184011
|
+
const fileDir = path41.dirname(file);
|
|
184012
|
+
const relativeDir = path41.relative(projectDir, fileDir);
|
|
184013
|
+
const snapDir2 = snapshotsDirName ? path41.join(projectDir, snapshotsDirName, relativeDir) : path41.join(fileDir, "__snapshots__");
|
|
184014
|
+
const base2 = path41.basename(file).replace(/\.tsx$/, "");
|
|
184015
|
+
const snap3dPath = path41.join(snapDir2, `${base2}-3d.snap.png`);
|
|
183948
184016
|
const existing3dSnapshot = fs42.existsSync(snap3dPath);
|
|
183949
184017
|
if (existing3dSnapshot) {
|
|
183950
184018
|
onError(kleur_default.red(`
|
|
183951
184019
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
183952
184020
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
183953
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
184021
|
+
`) + kleur_default.red(` Existing snapshot: ${path41.relative(projectDir, snap3dPath)}
|
|
183954
184022
|
`));
|
|
183955
184023
|
return onExit(1);
|
|
183956
184024
|
} else {
|
|
@@ -183966,9 +184034,9 @@ var snapshotProject = async ({
|
|
|
183966
184034
|
}
|
|
183967
184035
|
}
|
|
183968
184036
|
}
|
|
183969
|
-
const snapDir = snapshotsDirName ?
|
|
184037
|
+
const snapDir = snapshotsDirName ? path41.join(projectDir, snapshotsDirName, path41.relative(projectDir, path41.dirname(file))) : path41.join(path41.dirname(file), "__snapshots__");
|
|
183970
184038
|
fs42.mkdirSync(snapDir, { recursive: true });
|
|
183971
|
-
const base =
|
|
184039
|
+
const base = path41.basename(file).replace(/\.tsx$/, "");
|
|
183972
184040
|
const snapshots = [];
|
|
183973
184041
|
if (pcbOnly || !schematicOnly) {
|
|
183974
184042
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -183986,13 +184054,13 @@ var snapshotProject = async ({
|
|
|
183986
184054
|
for (const snapshot of snapshots) {
|
|
183987
184055
|
const { type } = snapshot;
|
|
183988
184056
|
const is3d = type === "3d";
|
|
183989
|
-
const snapPath =
|
|
184057
|
+
const snapPath = path41.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
183990
184058
|
const existing = fs42.existsSync(snapPath);
|
|
183991
184059
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
183992
184060
|
const newContentForFile = snapshot.content;
|
|
183993
184061
|
if (!existing) {
|
|
183994
184062
|
fs42.writeFileSync(snapPath, newContentForFile);
|
|
183995
|
-
console.log("✅", kleur_default.gray(
|
|
184063
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
183996
184064
|
didUpdate = true;
|
|
183997
184065
|
continue;
|
|
183998
184066
|
}
|
|
@@ -184001,16 +184069,16 @@ var snapshotProject = async ({
|
|
|
184001
184069
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
184002
184070
|
if (update) {
|
|
184003
184071
|
if (!forceUpdate && equal2) {
|
|
184004
|
-
console.log("✅", kleur_default.gray(
|
|
184072
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
184005
184073
|
} else {
|
|
184006
184074
|
fs42.writeFileSync(snapPath, newContentForFile);
|
|
184007
|
-
console.log("✅", kleur_default.gray(
|
|
184075
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
184008
184076
|
didUpdate = true;
|
|
184009
184077
|
}
|
|
184010
184078
|
} else if (!equal2) {
|
|
184011
184079
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
184012
184080
|
} else {
|
|
184013
|
-
console.log("✅", kleur_default.gray(
|
|
184081
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
184014
184082
|
}
|
|
184015
184083
|
}
|
|
184016
184084
|
}
|
|
@@ -184050,20 +184118,20 @@ var registerSnapshot = (program3) => {
|
|
|
184050
184118
|
|
|
184051
184119
|
// lib/shared/setup-github-actions.ts
|
|
184052
184120
|
import fs43 from "node:fs";
|
|
184053
|
-
import
|
|
184121
|
+
import path42 from "node:path";
|
|
184054
184122
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
184055
184123
|
const findGitRoot = (startDir) => {
|
|
184056
|
-
let dir =
|
|
184057
|
-
while (dir !==
|
|
184058
|
-
if (fs43.existsSync(
|
|
184124
|
+
let dir = path42.resolve(startDir);
|
|
184125
|
+
while (dir !== path42.parse(dir).root) {
|
|
184126
|
+
if (fs43.existsSync(path42.join(dir, ".git"))) {
|
|
184059
184127
|
return dir;
|
|
184060
184128
|
}
|
|
184061
|
-
dir =
|
|
184129
|
+
dir = path42.dirname(dir);
|
|
184062
184130
|
}
|
|
184063
184131
|
return null;
|
|
184064
184132
|
};
|
|
184065
184133
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
184066
|
-
const workflowsDir =
|
|
184134
|
+
const workflowsDir = path42.join(gitRoot, ".github", "workflows");
|
|
184067
184135
|
fs43.mkdirSync(workflowsDir, { recursive: true });
|
|
184068
184136
|
const buildWorkflow = `name: tscircuit Build
|
|
184069
184137
|
|
|
@@ -184103,8 +184171,8 @@ jobs:
|
|
|
184103
184171
|
- run: bun install
|
|
184104
184172
|
- run: bunx tsci snapshot
|
|
184105
184173
|
`;
|
|
184106
|
-
writeFileIfNotExists(
|
|
184107
|
-
writeFileIfNotExists(
|
|
184174
|
+
writeFileIfNotExists(path42.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
184175
|
+
writeFileIfNotExists(path42.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
184108
184176
|
};
|
|
184109
184177
|
|
|
184110
184178
|
// cli/setup/register.ts
|
|
@@ -184131,7 +184199,7 @@ var registerSetup = (program3) => {
|
|
|
184131
184199
|
|
|
184132
184200
|
// cli/convert/register.ts
|
|
184133
184201
|
import fs44 from "node:fs/promises";
|
|
184134
|
-
import
|
|
184202
|
+
import path43 from "node:path";
|
|
184135
184203
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
184136
184204
|
|
|
184137
184205
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -184251,14 +184319,14 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
184251
184319
|
var registerConvert = (program3) => {
|
|
184252
184320
|
program3.command("convert").description("Convert a .kicad_mod footprint to a tscircuit component").argument("<file>", "Path to the .kicad_mod file").option("-o, --output <path>", "Output TSX file path").option("-n, --name <component>", "Component name for export").action(async (file, options) => {
|
|
184253
184321
|
try {
|
|
184254
|
-
const inputPath =
|
|
184322
|
+
const inputPath = path43.resolve(file);
|
|
184255
184323
|
const modContent = await fs44.readFile(inputPath, "utf-8");
|
|
184256
184324
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
184257
|
-
const componentName = options.name ??
|
|
184325
|
+
const componentName = options.name ?? path43.basename(inputPath, ".kicad_mod");
|
|
184258
184326
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
184259
184327
|
componentName
|
|
184260
184328
|
});
|
|
184261
|
-
const outputPath = options.output ?
|
|
184329
|
+
const outputPath = options.output ? path43.resolve(options.output) : path43.join(path43.dirname(inputPath), `${componentName}.tsx`);
|
|
184262
184330
|
await fs44.writeFile(outputPath, tsx);
|
|
184263
184331
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
184264
184332
|
} catch (error) {
|
|
@@ -184356,11 +184424,11 @@ var registerSimulate = (program3) => {
|
|
|
184356
184424
|
|
|
184357
184425
|
// lib/shared/install-project-dependencies.ts
|
|
184358
184426
|
import fs46 from "node:fs";
|
|
184359
|
-
import
|
|
184427
|
+
import path45 from "node:path";
|
|
184360
184428
|
|
|
184361
184429
|
// lib/shared/collect-tsci-dependencies.ts
|
|
184362
184430
|
import fs45 from "node:fs";
|
|
184363
|
-
import
|
|
184431
|
+
import path44 from "node:path";
|
|
184364
184432
|
var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
|
|
184365
184433
|
var DEFAULT_IGNORES = [
|
|
184366
184434
|
"**/node_modules/**",
|
|
@@ -184375,7 +184443,7 @@ function collectTsciDependencies({
|
|
|
184375
184443
|
patterns = DEFAULT_PATTERNS,
|
|
184376
184444
|
ignore = DEFAULT_IGNORES
|
|
184377
184445
|
} = {}) {
|
|
184378
|
-
const searchRoot =
|
|
184446
|
+
const searchRoot = path44.resolve(cwd);
|
|
184379
184447
|
const files = globbySync(patterns, {
|
|
184380
184448
|
cwd: searchRoot,
|
|
184381
184449
|
absolute: true,
|
|
@@ -184402,9 +184470,9 @@ function collectTsciDependencies({
|
|
|
184402
184470
|
async function installProjectDependencies({
|
|
184403
184471
|
cwd = process.cwd()
|
|
184404
184472
|
} = {}) {
|
|
184405
|
-
const projectRoot =
|
|
184406
|
-
const packageJsonPath =
|
|
184407
|
-
const npmrcPath =
|
|
184473
|
+
const projectRoot = path45.resolve(cwd);
|
|
184474
|
+
const packageJsonPath = path45.join(projectRoot, "package.json");
|
|
184475
|
+
const npmrcPath = path45.join(projectRoot, ".npmrc");
|
|
184408
184476
|
const packageManager = getPackageManager();
|
|
184409
184477
|
if (!fs46.existsSync(projectRoot)) {
|
|
184410
184478
|
throw new Error(`Directory not found: ${projectRoot}`);
|
|
@@ -184470,14 +184538,14 @@ var registerInstall = (program3) => {
|
|
|
184470
184538
|
};
|
|
184471
184539
|
|
|
184472
184540
|
// cli/transpile/register.ts
|
|
184473
|
-
import
|
|
184541
|
+
import path46 from "node:path";
|
|
184474
184542
|
var registerTranspile = (program3) => {
|
|
184475
184543
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
184476
184544
|
try {
|
|
184477
184545
|
const { projectDir, circuitFiles, mainEntrypoint } = await getBuildEntrypoints({
|
|
184478
184546
|
fileOrDir: file
|
|
184479
184547
|
});
|
|
184480
|
-
const distDir =
|
|
184548
|
+
const distDir = path46.join(projectDir, "dist");
|
|
184481
184549
|
validateMainInDist(projectDir, distDir);
|
|
184482
184550
|
console.log("Transpiling entry file...");
|
|
184483
184551
|
const entryFile = mainEntrypoint || circuitFiles[0];
|