@tscircuit/cli 0.1.650 → 0.1.651
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 +695 -634
- 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("-"))
|
|
@@ -67488,7 +67488,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67488
67488
|
"node_modules/fs.realpath/old.js"(exports3) {
|
|
67489
67489
|
var pathModule = __require("path");
|
|
67490
67490
|
var isWindows2 = process.platform === "win32";
|
|
67491
|
-
var
|
|
67491
|
+
var fs25 = __require("fs");
|
|
67492
67492
|
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
|
67493
67493
|
function rethrow() {
|
|
67494
67494
|
var callback;
|
|
@@ -67553,7 +67553,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67553
67553
|
base = m2[0];
|
|
67554
67554
|
previous = "";
|
|
67555
67555
|
if (isWindows2 && !knownHard[base]) {
|
|
67556
|
-
|
|
67556
|
+
fs25.lstatSync(base);
|
|
67557
67557
|
knownHard[base] = true;
|
|
67558
67558
|
}
|
|
67559
67559
|
}
|
|
@@ -67571,7 +67571,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67571
67571
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
67572
67572
|
resolvedLink = cache[base];
|
|
67573
67573
|
} else {
|
|
67574
|
-
var stat4 =
|
|
67574
|
+
var stat4 = fs25.lstatSync(base);
|
|
67575
67575
|
if (!stat4.isSymbolicLink()) {
|
|
67576
67576
|
knownHard[base] = true;
|
|
67577
67577
|
if (cache)
|
|
@@ -67586,8 +67586,8 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67586
67586
|
}
|
|
67587
67587
|
}
|
|
67588
67588
|
if (linkTarget === null) {
|
|
67589
|
-
|
|
67590
|
-
linkTarget =
|
|
67589
|
+
fs25.statSync(base);
|
|
67590
|
+
linkTarget = fs25.readlinkSync(base);
|
|
67591
67591
|
}
|
|
67592
67592
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
67593
67593
|
if (cache)
|
|
@@ -67624,7 +67624,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67624
67624
|
base = m2[0];
|
|
67625
67625
|
previous = "";
|
|
67626
67626
|
if (isWindows2 && !knownHard[base]) {
|
|
67627
|
-
|
|
67627
|
+
fs25.lstat(base, function(err) {
|
|
67628
67628
|
if (err)
|
|
67629
67629
|
return cb(err);
|
|
67630
67630
|
knownHard[base] = true;
|
|
@@ -67652,7 +67652,7 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67652
67652
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
67653
67653
|
return gotResolvedLink(cache[base]);
|
|
67654
67654
|
}
|
|
67655
|
-
return
|
|
67655
|
+
return fs25.lstat(base, gotStat);
|
|
67656
67656
|
}
|
|
67657
67657
|
function gotStat(err, stat4) {
|
|
67658
67658
|
if (err)
|
|
@@ -67669,10 +67669,10 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67669
67669
|
return gotTarget(null, seenLinks[id], base);
|
|
67670
67670
|
}
|
|
67671
67671
|
}
|
|
67672
|
-
|
|
67672
|
+
fs25.stat(base, function(err2) {
|
|
67673
67673
|
if (err2)
|
|
67674
67674
|
return cb(err2);
|
|
67675
|
-
|
|
67675
|
+
fs25.readlink(base, function(err3, target) {
|
|
67676
67676
|
if (!isWindows2)
|
|
67677
67677
|
seenLinks[id] = target;
|
|
67678
67678
|
gotTarget(err3, target);
|
|
@@ -67702,9 +67702,9 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67702
67702
|
realpath2.realpathSync = realpathSync;
|
|
67703
67703
|
realpath2.monkeypatch = monkeypatch;
|
|
67704
67704
|
realpath2.unmonkeypatch = unmonkeypatch;
|
|
67705
|
-
var
|
|
67706
|
-
var origRealpath =
|
|
67707
|
-
var origRealpathSync =
|
|
67705
|
+
var fs25 = __require("fs");
|
|
67706
|
+
var origRealpath = fs25.realpath;
|
|
67707
|
+
var origRealpathSync = fs25.realpathSync;
|
|
67708
67708
|
var version2 = process.version;
|
|
67709
67709
|
var ok = /^v[0-5]\./.test(version2);
|
|
67710
67710
|
var old = require_old();
|
|
@@ -67742,12 +67742,12 @@ var require_dist8 = __commonJS((exports2, module2) => {
|
|
|
67742
67742
|
}
|
|
67743
67743
|
}
|
|
67744
67744
|
function monkeypatch() {
|
|
67745
|
-
|
|
67746
|
-
|
|
67745
|
+
fs25.realpath = realpath2;
|
|
67746
|
+
fs25.realpathSync = realpathSync;
|
|
67747
67747
|
}
|
|
67748
67748
|
function unmonkeypatch() {
|
|
67749
|
-
|
|
67750
|
-
|
|
67749
|
+
fs25.realpath = origRealpath;
|
|
67750
|
+
fs25.realpathSync = origRealpathSync;
|
|
67751
67751
|
}
|
|
67752
67752
|
}
|
|
67753
67753
|
});
|
|
@@ -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);
|
|
@@ -68556,8 +68556,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68556
68556
|
function ownProp(obj, field) {
|
|
68557
68557
|
return Object.prototype.hasOwnProperty.call(obj, field);
|
|
68558
68558
|
}
|
|
68559
|
-
var
|
|
68560
|
-
var
|
|
68559
|
+
var fs25 = __require("fs");
|
|
68560
|
+
var path27 = __require("path");
|
|
68561
68561
|
var minimatch = require_minimatch();
|
|
68562
68562
|
var isAbsolute3 = __require("path").isAbsolute;
|
|
68563
68563
|
var Minimatch = minimatch.Minimatch;
|
|
@@ -68611,7 +68611,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68611
68611
|
self2.stat = !!options.stat;
|
|
68612
68612
|
self2.noprocess = !!options.noprocess;
|
|
68613
68613
|
self2.absolute = !!options.absolute;
|
|
68614
|
-
self2.fs = options.fs ||
|
|
68614
|
+
self2.fs = options.fs || fs25;
|
|
68615
68615
|
self2.maxLength = options.maxLength || Infinity;
|
|
68616
68616
|
self2.cache = options.cache || /* @__PURE__ */ Object.create(null);
|
|
68617
68617
|
self2.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
|
|
@@ -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
|
}
|
|
@@ -71724,7 +71724,13 @@ function getPackageManager() {
|
|
|
71724
71724
|
installCommand = `npm install ${name}`;
|
|
71725
71725
|
}
|
|
71726
71726
|
console.log(kleur_default.gray(`> ${installCommand}`));
|
|
71727
|
-
execSync(installCommand, {
|
|
71727
|
+
const output = execSync(installCommand, {
|
|
71728
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
71729
|
+
cwd
|
|
71730
|
+
});
|
|
71731
|
+
if (output) {
|
|
71732
|
+
process.stdout.write(output);
|
|
71733
|
+
}
|
|
71728
71734
|
},
|
|
71729
71735
|
init: ({ cwd }) => {
|
|
71730
71736
|
const initCommand = getInitCommand();
|
|
@@ -71739,7 +71745,13 @@ function getPackageManager() {
|
|
|
71739
71745
|
installAll: ({ cwd }) => {
|
|
71740
71746
|
const installCommand = getInstallAllCommand();
|
|
71741
71747
|
console.log(kleur_default.gray(`> ${installCommand}`));
|
|
71742
|
-
execSync(installCommand, {
|
|
71748
|
+
const output = execSync(installCommand, {
|
|
71749
|
+
stdio: ["inherit", "pipe", "pipe"],
|
|
71750
|
+
cwd
|
|
71751
|
+
});
|
|
71752
|
+
if (output) {
|
|
71753
|
+
process.stdout.write(output);
|
|
71754
|
+
}
|
|
71743
71755
|
},
|
|
71744
71756
|
getInstallAllCommand
|
|
71745
71757
|
};
|
|
@@ -74100,7 +74112,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74100
74112
|
import { execSync as execSync2 } from "node:child_process";
|
|
74101
74113
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74102
74114
|
// package.json
|
|
74103
|
-
var version = "0.1.
|
|
74115
|
+
var version = "0.1.650";
|
|
74104
74116
|
var package_default = {
|
|
74105
74117
|
name: "@tscircuit/cli",
|
|
74106
74118
|
version,
|
|
@@ -74377,9 +74389,9 @@ export default () => (
|
|
|
74377
74389
|
};
|
|
74378
74390
|
|
|
74379
74391
|
// cli/dev/register.ts
|
|
74380
|
-
import * as
|
|
74392
|
+
import * as fs20 from "node:fs";
|
|
74381
74393
|
import * as net from "node:net";
|
|
74382
|
-
import * as
|
|
74394
|
+
import * as path22 from "node:path";
|
|
74383
74395
|
|
|
74384
74396
|
// lib/server/createHttpServer.ts
|
|
74385
74397
|
import * as http from "node:http";
|
|
@@ -76052,8 +76064,8 @@ class EventsWatcher extends EventEmitter {
|
|
|
76052
76064
|
}
|
|
76053
76065
|
|
|
76054
76066
|
// cli/dev/DevServer.ts
|
|
76055
|
-
import
|
|
76056
|
-
import
|
|
76067
|
+
import path20 from "node:path";
|
|
76068
|
+
import fs18 from "node:fs";
|
|
76057
76069
|
|
|
76058
76070
|
// node_modules/chokidar/esm/index.js
|
|
76059
76071
|
import { stat as statcb } from "fs";
|
|
@@ -78687,8 +78699,8 @@ var pushSnippet = async ({
|
|
|
78687
78699
|
};
|
|
78688
78700
|
|
|
78689
78701
|
// lib/shared/add-package.ts
|
|
78690
|
-
import * as
|
|
78691
|
-
import * as
|
|
78702
|
+
import * as fs16 from "node:fs";
|
|
78703
|
+
import * as path18 from "node:path";
|
|
78692
78704
|
|
|
78693
78705
|
// lib/shared/resolve-tarball-url-from-registry.ts
|
|
78694
78706
|
async function resolveTarballUrlFromRegistry(packageName) {
|
|
@@ -78808,6 +78820,53 @@ async function setupTsConfig(projectDir) {
|
|
|
78808
78820
|
}
|
|
78809
78821
|
}
|
|
78810
78822
|
|
|
78823
|
+
// lib/shared/handle-registry-auth-error.ts
|
|
78824
|
+
import fs15 from "node:fs";
|
|
78825
|
+
import os2 from "node:os";
|
|
78826
|
+
import path17 from "node:path";
|
|
78827
|
+
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=.+$/m;
|
|
78828
|
+
function isUnauthorizedError(error) {
|
|
78829
|
+
const output = [
|
|
78830
|
+
error instanceof Error ? error.message : "",
|
|
78831
|
+
error?.stderr?.toString?.() ?? "",
|
|
78832
|
+
error?.stdout?.toString?.() ?? ""
|
|
78833
|
+
].join(`
|
|
78834
|
+
`);
|
|
78835
|
+
const registryErrorMatch = output.match(/error:\s*(\{[\s\S]*?\})/i);
|
|
78836
|
+
if (registryErrorMatch) {
|
|
78837
|
+
const errorBody = registryErrorMatch[1];
|
|
78838
|
+
const errorCode = errorBody.match(/error_code\s*:\s*['"]?([^,'"}\s]+)/i)?.[1] ?? "";
|
|
78839
|
+
const message = errorBody.match(/message\s*:\s*['"]?([^'"}]+)/i)?.[1] ?? "";
|
|
78840
|
+
if (/unauth|token|auth/i.test(errorCode) || /unauth|token|auth/i.test(message)) {
|
|
78841
|
+
return true;
|
|
78842
|
+
}
|
|
78843
|
+
}
|
|
78844
|
+
return /\b(401|E401)\b/i.test(output) || /unauthorized/i.test(output);
|
|
78845
|
+
}
|
|
78846
|
+
function hasTsciAuthToken(npmrcPath) {
|
|
78847
|
+
if (!fs15.existsSync(npmrcPath))
|
|
78848
|
+
return false;
|
|
78849
|
+
const content = fs15.readFileSync(npmrcPath, "utf-8");
|
|
78850
|
+
return AUTH_TOKEN_REGEX.test(content);
|
|
78851
|
+
}
|
|
78852
|
+
function handleRegistryAuthError({
|
|
78853
|
+
error,
|
|
78854
|
+
projectDir
|
|
78855
|
+
}) {
|
|
78856
|
+
if (!isUnauthorizedError(error))
|
|
78857
|
+
return;
|
|
78858
|
+
const npmrcPaths = [
|
|
78859
|
+
path17.join(projectDir, ".npmrc"),
|
|
78860
|
+
path17.join(os2.homedir(), ".npmrc")
|
|
78861
|
+
];
|
|
78862
|
+
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
78863
|
+
if (hasToken) {
|
|
78864
|
+
console.warn(kleur_default.yellow("Your tscircuit session token appears to be missing or expired. Run `tsci auth setup-npmrc` to refresh it before retrying."));
|
|
78865
|
+
} else {
|
|
78866
|
+
console.warn(kleur_default.yellow("No tscircuit session token is loaded in your .npmrc files. Run `tsci auth setup-npmrc` to add one and retry the install."));
|
|
78867
|
+
}
|
|
78868
|
+
}
|
|
78869
|
+
|
|
78811
78870
|
// lib/shared/add-package.ts
|
|
78812
78871
|
function normalizeTscircuitPackageName(packageSpec) {
|
|
78813
78872
|
if (packageSpec.startsWith("@tscircuit/") || packageSpec.startsWith("@tsci/")) {
|
|
@@ -78834,9 +78893,9 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
78834
78893
|
const displayName = normalizedName || packageSpec;
|
|
78835
78894
|
let installTarget = normalizedName || packageSpec;
|
|
78836
78895
|
console.log(kleur_default.cyan(`Adding ${kleur_default.bold(displayName)}...`));
|
|
78837
|
-
if (normalizedName
|
|
78838
|
-
const npmrcPath =
|
|
78839
|
-
const npmrcContent =
|
|
78896
|
+
if (normalizedName?.startsWith("@tsci/")) {
|
|
78897
|
+
const npmrcPath = path18.join(projectDir, ".npmrc");
|
|
78898
|
+
const npmrcContent = fs16.existsSync(npmrcPath) ? fs16.readFileSync(npmrcPath, "utf-8") : "";
|
|
78840
78899
|
let hasTsciRegistry = /@tsci[/:]/.test(npmrcContent);
|
|
78841
78900
|
if (!hasTsciRegistry) {
|
|
78842
78901
|
const { addRegistry } = await prompts({
|
|
@@ -78847,10 +78906,10 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
78847
78906
|
});
|
|
78848
78907
|
if (addRegistry) {
|
|
78849
78908
|
const trimmedContent = npmrcContent.trimEnd();
|
|
78850
|
-
const newContent =
|
|
78851
|
-
` : ""
|
|
78909
|
+
const newContent = `${trimmedContent.length > 0 ? `${trimmedContent}
|
|
78910
|
+
` : ""}@tsci:registry=https://npm.tscircuit.com
|
|
78852
78911
|
`;
|
|
78853
|
-
|
|
78912
|
+
fs16.writeFileSync(npmrcPath, newContent);
|
|
78854
78913
|
console.log(kleur_default.green("✓ Updated .npmrc with tscircuit registry"));
|
|
78855
78914
|
hasTsciRegistry = true;
|
|
78856
78915
|
} else {
|
|
@@ -78869,6 +78928,7 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
78869
78928
|
} catch (error) {
|
|
78870
78929
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
78871
78930
|
console.error(kleur_default.red(`✗ Failed to add ${displayName}:`), errorMessage);
|
|
78931
|
+
handleRegistryAuthError({ error, projectDir });
|
|
78872
78932
|
throw new Error(`Failed to add ${displayName}: ${errorMessage}`);
|
|
78873
78933
|
}
|
|
78874
78934
|
}
|
|
@@ -78878,16 +78938,16 @@ import Debug2 from "debug";
|
|
|
78878
78938
|
|
|
78879
78939
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
78880
78940
|
import * as ts from "typescript";
|
|
78881
|
-
import * as
|
|
78882
|
-
import * as
|
|
78941
|
+
import * as path19 from "path";
|
|
78942
|
+
import * as fs17 from "fs";
|
|
78883
78943
|
function getAllDependencyPackages(projectDir) {
|
|
78884
|
-
const packageJsonPath =
|
|
78944
|
+
const packageJsonPath = path19.join(projectDir, "package.json");
|
|
78885
78945
|
const allPackages = new Set;
|
|
78886
|
-
if (!
|
|
78946
|
+
if (!fs17.existsSync(packageJsonPath)) {
|
|
78887
78947
|
return allPackages;
|
|
78888
78948
|
}
|
|
78889
78949
|
try {
|
|
78890
|
-
const packageJson = JSON.parse(
|
|
78950
|
+
const packageJson = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
|
|
78891
78951
|
const deps = packageJson.dependencies || {};
|
|
78892
78952
|
for (const packageName of Object.keys(deps)) {
|
|
78893
78953
|
allPackages.add(packageName);
|
|
@@ -78898,11 +78958,11 @@ function getAllDependencyPackages(projectDir) {
|
|
|
78898
78958
|
return allPackages;
|
|
78899
78959
|
}
|
|
78900
78960
|
function getNodeModuleImports(filePath) {
|
|
78901
|
-
const absolutePath =
|
|
78902
|
-
if (!
|
|
78961
|
+
const absolutePath = path19.resolve(filePath);
|
|
78962
|
+
if (!fs17.existsSync(absolutePath)) {
|
|
78903
78963
|
return [];
|
|
78904
78964
|
}
|
|
78905
|
-
const content =
|
|
78965
|
+
const content = fs17.readFileSync(absolutePath, "utf-8");
|
|
78906
78966
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
78907
78967
|
const imports = new Set;
|
|
78908
78968
|
function visit(node) {
|
|
@@ -78952,17 +79012,17 @@ function resolveNodeModuleImport({
|
|
|
78952
79012
|
}) {
|
|
78953
79013
|
const packageName = getPackageNameFromImport(importPath);
|
|
78954
79014
|
const searchPaths = [
|
|
78955
|
-
|
|
79015
|
+
path19.join(projectDir, "node_modules", packageName)
|
|
78956
79016
|
];
|
|
78957
79017
|
if (searchFromDir) {
|
|
78958
|
-
let currentDir =
|
|
78959
|
-
const projectDirNormalized =
|
|
79018
|
+
let currentDir = path19.dirname(searchFromDir);
|
|
79019
|
+
const projectDirNormalized = path19.normalize(projectDir);
|
|
78960
79020
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
78961
|
-
const candidatePath =
|
|
79021
|
+
const candidatePath = path19.join(currentDir, "node_modules", packageName);
|
|
78962
79022
|
if (!searchPaths.includes(candidatePath)) {
|
|
78963
79023
|
searchPaths.push(candidatePath);
|
|
78964
79024
|
}
|
|
78965
|
-
const parentDir =
|
|
79025
|
+
const parentDir = path19.dirname(currentDir);
|
|
78966
79026
|
if (parentDir === currentDir)
|
|
78967
79027
|
break;
|
|
78968
79028
|
currentDir = parentDir;
|
|
@@ -78970,7 +79030,7 @@ function resolveNodeModuleImport({
|
|
|
78970
79030
|
}
|
|
78971
79031
|
let packageDir;
|
|
78972
79032
|
for (const candidatePath of searchPaths) {
|
|
78973
|
-
if (
|
|
79033
|
+
if (fs17.existsSync(candidatePath)) {
|
|
78974
79034
|
packageDir = candidatePath;
|
|
78975
79035
|
break;
|
|
78976
79036
|
}
|
|
@@ -78978,25 +79038,25 @@ function resolveNodeModuleImport({
|
|
|
78978
79038
|
if (!packageDir) {
|
|
78979
79039
|
return [];
|
|
78980
79040
|
}
|
|
78981
|
-
const packageJsonPath =
|
|
78982
|
-
const hasPackageJson =
|
|
78983
|
-
const packageJson = hasPackageJson ? JSON.parse(
|
|
79041
|
+
const packageJsonPath = path19.join(packageDir, "package.json");
|
|
79042
|
+
const hasPackageJson = fs17.existsSync(packageJsonPath);
|
|
79043
|
+
const packageJson = hasPackageJson ? JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8")) : null;
|
|
78984
79044
|
const resolvedFiles = [];
|
|
78985
79045
|
if (importPath !== packageName) {
|
|
78986
79046
|
const subpath = importPath.slice(packageName.length + 1);
|
|
78987
79047
|
const possiblePaths = [
|
|
78988
|
-
|
|
78989
|
-
|
|
78990
|
-
|
|
78991
|
-
|
|
78992
|
-
|
|
78993
|
-
|
|
78994
|
-
|
|
78995
|
-
|
|
78996
|
-
|
|
79048
|
+
path19.join(packageDir, subpath),
|
|
79049
|
+
path19.join(packageDir, `${subpath}.js`),
|
|
79050
|
+
path19.join(packageDir, `${subpath}.mjs`),
|
|
79051
|
+
path19.join(packageDir, `${subpath}.ts`),
|
|
79052
|
+
path19.join(packageDir, `${subpath}.tsx`),
|
|
79053
|
+
path19.join(packageDir, subpath, "index.js"),
|
|
79054
|
+
path19.join(packageDir, subpath, "index.mjs"),
|
|
79055
|
+
path19.join(packageDir, subpath, "index.ts"),
|
|
79056
|
+
path19.join(packageDir, subpath, "index.tsx")
|
|
78997
79057
|
];
|
|
78998
79058
|
for (const p of possiblePaths) {
|
|
78999
|
-
if (
|
|
79059
|
+
if (fs17.existsSync(p) && fs17.statSync(p).isFile()) {
|
|
79000
79060
|
resolvedFiles.push(p);
|
|
79001
79061
|
break;
|
|
79002
79062
|
}
|
|
@@ -79028,25 +79088,25 @@ function resolveNodeModuleImport({
|
|
|
79028
79088
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
79029
79089
|
].filter((entry) => typeof entry === "string");
|
|
79030
79090
|
for (const entry of entryPoints) {
|
|
79031
|
-
const entryPath =
|
|
79032
|
-
if (
|
|
79091
|
+
const entryPath = path19.join(packageDir, entry);
|
|
79092
|
+
if (fs17.existsSync(entryPath) && fs17.statSync(entryPath).isFile()) {
|
|
79033
79093
|
resolvedFiles.push(entryPath);
|
|
79034
79094
|
}
|
|
79035
79095
|
}
|
|
79036
79096
|
if (resolvedFiles.length === 0) {
|
|
79037
79097
|
const fallbackPaths = [
|
|
79038
|
-
|
|
79039
|
-
|
|
79040
|
-
|
|
79041
|
-
|
|
79042
|
-
|
|
79043
|
-
|
|
79044
|
-
|
|
79045
|
-
|
|
79046
|
-
|
|
79098
|
+
path19.join(packageDir, "index.js"),
|
|
79099
|
+
path19.join(packageDir, "index.mjs"),
|
|
79100
|
+
path19.join(packageDir, "index.ts"),
|
|
79101
|
+
path19.join(packageDir, "index.tsx"),
|
|
79102
|
+
path19.join(packageDir, "dist", "index.js"),
|
|
79103
|
+
path19.join(packageDir, "dist", "index.mjs"),
|
|
79104
|
+
path19.join(packageDir, "lib", "index.js"),
|
|
79105
|
+
path19.join(packageDir, "src", "index.ts"),
|
|
79106
|
+
path19.join(packageDir, "src", "index.tsx")
|
|
79047
79107
|
];
|
|
79048
79108
|
for (const p of fallbackPaths) {
|
|
79049
|
-
if (
|
|
79109
|
+
if (fs17.existsSync(p) && fs17.statSync(p).isFile()) {
|
|
79050
79110
|
resolvedFiles.push(p);
|
|
79051
79111
|
break;
|
|
79052
79112
|
}
|
|
@@ -79084,12 +79144,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
79084
79144
|
}
|
|
79085
79145
|
}
|
|
79086
79146
|
function getLocalDependencies(filePath) {
|
|
79087
|
-
const absolutePath =
|
|
79088
|
-
const baseDir =
|
|
79089
|
-
if (!
|
|
79147
|
+
const absolutePath = path19.resolve(filePath);
|
|
79148
|
+
const baseDir = path19.dirname(absolutePath);
|
|
79149
|
+
if (!fs17.existsSync(absolutePath)) {
|
|
79090
79150
|
return [];
|
|
79091
79151
|
}
|
|
79092
|
-
const content =
|
|
79152
|
+
const content = fs17.readFileSync(absolutePath, "utf-8");
|
|
79093
79153
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
79094
79154
|
const dependencies2 = [];
|
|
79095
79155
|
function visit(node) {
|
|
@@ -79111,20 +79171,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
79111
79171
|
}
|
|
79112
79172
|
function resolveLocalImport(importPath, baseDir) {
|
|
79113
79173
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
79114
|
-
const resolvedPath =
|
|
79115
|
-
if (
|
|
79174
|
+
const resolvedPath = path19.resolve(baseDir, importPath);
|
|
79175
|
+
if (fs17.existsSync(resolvedPath) && fs17.statSync(resolvedPath).isFile()) {
|
|
79116
79176
|
return resolvedPath;
|
|
79117
79177
|
}
|
|
79118
79178
|
for (const ext of extensions) {
|
|
79119
79179
|
const pathWithExt = resolvedPath + ext;
|
|
79120
|
-
if (
|
|
79180
|
+
if (fs17.existsSync(pathWithExt)) {
|
|
79121
79181
|
return pathWithExt;
|
|
79122
79182
|
}
|
|
79123
79183
|
}
|
|
79124
|
-
if (
|
|
79184
|
+
if (fs17.existsSync(resolvedPath) && fs17.statSync(resolvedPath).isDirectory()) {
|
|
79125
79185
|
for (const ext of extensions) {
|
|
79126
|
-
const indexPath =
|
|
79127
|
-
if (
|
|
79186
|
+
const indexPath = path19.join(resolvedPath, `index${ext}`);
|
|
79187
|
+
if (fs17.existsSync(indexPath)) {
|
|
79128
79188
|
return indexPath;
|
|
79129
79189
|
}
|
|
79130
79190
|
}
|
|
@@ -79149,12 +79209,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
79149
79209
|
function collectLocalPackageFiles(packageDir) {
|
|
79150
79210
|
const buildDirs = ["dist", "build"];
|
|
79151
79211
|
for (const dirName of buildDirs) {
|
|
79152
|
-
const dirPath =
|
|
79153
|
-
if (
|
|
79212
|
+
const dirPath = path19.join(packageDir, dirName);
|
|
79213
|
+
if (fs17.existsSync(dirPath)) {
|
|
79154
79214
|
const files = walkDirectory(dirPath, new Set);
|
|
79155
79215
|
if (files.length > 0) {
|
|
79156
|
-
const packageJsonPath =
|
|
79157
|
-
if (
|
|
79216
|
+
const packageJsonPath = path19.join(packageDir, "package.json");
|
|
79217
|
+
if (fs17.existsSync(packageJsonPath)) {
|
|
79158
79218
|
files.push(packageJsonPath);
|
|
79159
79219
|
}
|
|
79160
79220
|
return files;
|
|
@@ -79165,11 +79225,11 @@ function collectLocalPackageFiles(packageDir) {
|
|
|
79165
79225
|
}
|
|
79166
79226
|
function walkDirectory(dir, excludedDirs) {
|
|
79167
79227
|
const files = [];
|
|
79168
|
-
if (!
|
|
79228
|
+
if (!fs17.existsSync(dir))
|
|
79169
79229
|
return files;
|
|
79170
|
-
const entries =
|
|
79230
|
+
const entries = fs17.readdirSync(dir, { withFileTypes: true });
|
|
79171
79231
|
for (const entry of entries) {
|
|
79172
|
-
const fullPath =
|
|
79232
|
+
const fullPath = path19.join(dir, entry.name);
|
|
79173
79233
|
if (entry.isDirectory()) {
|
|
79174
79234
|
if (excludedDirs.has(entry.name)) {
|
|
79175
79235
|
continue;
|
|
@@ -79230,13 +79290,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
79230
79290
|
processedPackages.add(packageName);
|
|
79231
79291
|
if (resolvedFiles.length > 0) {
|
|
79232
79292
|
const firstResolvedFile = resolvedFiles[0];
|
|
79233
|
-
let packageDir =
|
|
79293
|
+
let packageDir = path19.dirname(firstResolvedFile);
|
|
79234
79294
|
let hasPackageJson = false;
|
|
79235
79295
|
while (packageDir.includes("node_modules")) {
|
|
79236
|
-
const packageJsonPath =
|
|
79237
|
-
if (
|
|
79296
|
+
const packageJsonPath = path19.join(packageDir, "package.json");
|
|
79297
|
+
if (fs17.existsSync(packageJsonPath)) {
|
|
79238
79298
|
try {
|
|
79239
|
-
const pkgJson = JSON.parse(
|
|
79299
|
+
const pkgJson = JSON.parse(fs17.readFileSync(packageJsonPath, "utf-8"));
|
|
79240
79300
|
if (pkgJson.name === packageName) {
|
|
79241
79301
|
hasPackageJson = true;
|
|
79242
79302
|
break;
|
|
@@ -79244,15 +79304,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
79244
79304
|
} catch {}
|
|
79245
79305
|
}
|
|
79246
79306
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
79247
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
79307
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path19.sep))) {
|
|
79248
79308
|
break;
|
|
79249
79309
|
}
|
|
79250
|
-
const parentDir =
|
|
79310
|
+
const parentDir = path19.dirname(packageDir);
|
|
79251
79311
|
if (parentDir === packageDir)
|
|
79252
79312
|
break;
|
|
79253
79313
|
packageDir = parentDir;
|
|
79254
79314
|
}
|
|
79255
|
-
if (
|
|
79315
|
+
if (fs17.existsSync(packageDir)) {
|
|
79256
79316
|
if (hasPackageJson) {
|
|
79257
79317
|
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
79258
79318
|
packageFiles.forEach((file) => allFiles.add(file));
|
|
@@ -79295,7 +79355,7 @@ class DevServer {
|
|
|
79295
79355
|
}) {
|
|
79296
79356
|
this.port = port;
|
|
79297
79357
|
this.componentFilePath = componentFilePath;
|
|
79298
|
-
this.projectDir = projectDir ??
|
|
79358
|
+
this.projectDir = projectDir ?? path20.dirname(componentFilePath);
|
|
79299
79359
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
79300
79360
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
79301
79361
|
this.fsKy = distribution_default.create({
|
|
@@ -79305,7 +79365,7 @@ class DevServer {
|
|
|
79305
79365
|
async start() {
|
|
79306
79366
|
const { server } = await createHttpServer({
|
|
79307
79367
|
port: this.port,
|
|
79308
|
-
defaultMainComponentPath:
|
|
79368
|
+
defaultMainComponentPath: path20.relative(this.projectDir, this.componentFilePath)
|
|
79309
79369
|
});
|
|
79310
79370
|
this.httpServer = server;
|
|
79311
79371
|
this.eventsWatcher = new EventsWatcher(`http://localhost:${this.port}`);
|
|
@@ -79318,7 +79378,7 @@ class DevServer {
|
|
|
79318
79378
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
79319
79379
|
persistent: true,
|
|
79320
79380
|
ignoreInitial: true,
|
|
79321
|
-
ignored: (p) => shouldIgnorePath(
|
|
79381
|
+
ignored: (p) => shouldIgnorePath(path20.relative(this.projectDir, p), this.ignoredFiles)
|
|
79322
79382
|
});
|
|
79323
79383
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
79324
79384
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -79333,27 +79393,27 @@ class DevServer {
|
|
|
79333
79393
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
79334
79394
|
searchParams: { file_path: ev.file_path }
|
|
79335
79395
|
}).json();
|
|
79336
|
-
const fullPath =
|
|
79337
|
-
const dirPath =
|
|
79338
|
-
if (!
|
|
79339
|
-
|
|
79396
|
+
const fullPath = path20.join(this.projectDir, ev.file_path);
|
|
79397
|
+
const dirPath = path20.dirname(fullPath);
|
|
79398
|
+
if (!fs18.existsSync(dirPath)) {
|
|
79399
|
+
fs18.mkdirSync(dirPath, { recursive: true });
|
|
79340
79400
|
}
|
|
79341
79401
|
if (file.binary_content_b64) {
|
|
79342
79402
|
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
79343
|
-
|
|
79403
|
+
fs18.writeFileSync(fullPath, decodedContent);
|
|
79344
79404
|
} else {
|
|
79345
|
-
|
|
79405
|
+
fs18.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
79346
79406
|
}
|
|
79347
79407
|
}
|
|
79348
79408
|
async handleFileDeletedEventFromServer(ev) {
|
|
79349
|
-
const fullPath =
|
|
79350
|
-
if (
|
|
79409
|
+
const fullPath = path20.join(this.projectDir, ev.file_path);
|
|
79410
|
+
if (fs18.existsSync(fullPath)) {
|
|
79351
79411
|
debug2(`Deleting file ${ev.file_path} from filesystem`);
|
|
79352
|
-
|
|
79412
|
+
fs18.unlinkSync(fullPath);
|
|
79353
79413
|
}
|
|
79354
79414
|
}
|
|
79355
79415
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
79356
|
-
const relativeFilePath =
|
|
79416
|
+
const relativeFilePath = path20.relative(this.projectDir, absoluteFilePath);
|
|
79357
79417
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
79358
79418
|
return;
|
|
79359
79419
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -79370,14 +79430,14 @@ class DevServer {
|
|
|
79370
79430
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
79371
79431
|
}
|
|
79372
79432
|
async checkAndUploadNewNodeModules(filePath) {
|
|
79373
|
-
const ext =
|
|
79433
|
+
const ext = path20.extname(filePath).toLowerCase();
|
|
79374
79434
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
79375
79435
|
if (!isSourceFile)
|
|
79376
79436
|
return;
|
|
79377
79437
|
try {
|
|
79378
79438
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
79379
79439
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
79380
|
-
const relativePath =
|
|
79440
|
+
const relativePath = path20.relative(this.projectDir, file);
|
|
79381
79441
|
return !this.uploadedNodeModules.has(relativePath);
|
|
79382
79442
|
});
|
|
79383
79443
|
if (newFiles.length === 0)
|
|
@@ -79390,7 +79450,7 @@ class DevServer {
|
|
|
79390
79450
|
}
|
|
79391
79451
|
}
|
|
79392
79452
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
79393
|
-
const relativeFilePath =
|
|
79453
|
+
const relativeFilePath = path20.relative(this.projectDir, absoluteFilePath);
|
|
79394
79454
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
79395
79455
|
return;
|
|
79396
79456
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -79428,8 +79488,8 @@ class DevServer {
|
|
|
79428
79488
|
debug2(`Successfully deleted file ${relativeFilePath} from server`);
|
|
79429
79489
|
}
|
|
79430
79490
|
async handleFileRename(oldPath, newPath) {
|
|
79431
|
-
const oldRelativePath =
|
|
79432
|
-
const newRelativePath =
|
|
79491
|
+
const oldRelativePath = path20.relative(this.projectDir, oldPath);
|
|
79492
|
+
const newRelativePath = path20.relative(this.projectDir, newPath);
|
|
79433
79493
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
79434
79494
|
return;
|
|
79435
79495
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -79449,7 +79509,7 @@ class DevServer {
|
|
|
79449
79509
|
});
|
|
79450
79510
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
79451
79511
|
for (const filePath of filePaths) {
|
|
79452
|
-
const relativeFilePath =
|
|
79512
|
+
const relativeFilePath = path20.relative(this.projectDir, filePath);
|
|
79453
79513
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
79454
79514
|
await this.fsKy.post("api/files/upsert", {
|
|
79455
79515
|
json: {
|
|
@@ -79483,7 +79543,7 @@ class DevServer {
|
|
|
79483
79543
|
}
|
|
79484
79544
|
async uploadNodeModuleFiles(files) {
|
|
79485
79545
|
for (const nodeModuleFile of files) {
|
|
79486
|
-
const relativeFilePath =
|
|
79546
|
+
const relativeFilePath = path20.relative(this.projectDir, nodeModuleFile);
|
|
79487
79547
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
79488
79548
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
79489
79549
|
await this.fsKy.post("api/files/upsert", {
|
|
@@ -79519,12 +79579,12 @@ class DevServer {
|
|
|
79519
79579
|
await this.filesystemWatcher?.close();
|
|
79520
79580
|
}
|
|
79521
79581
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
79522
|
-
const ext =
|
|
79582
|
+
const ext = path20.extname(relativeFilePath).toLowerCase();
|
|
79523
79583
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
79524
|
-
const fileBuffer =
|
|
79584
|
+
const fileBuffer = fs18.readFileSync(absoluteFilePath);
|
|
79525
79585
|
return { binary_content_b64: fileBuffer.toString("base64") };
|
|
79526
79586
|
}
|
|
79527
|
-
return { text_content:
|
|
79587
|
+
return { text_content: fs18.readFileSync(absoluteFilePath, "utf-8") };
|
|
79528
79588
|
}
|
|
79529
79589
|
async handleInstallPackage(full_package_name) {
|
|
79530
79590
|
const postEvent = async (event, message) => {
|
|
@@ -79560,11 +79620,11 @@ var getVersion = () => {
|
|
|
79560
79620
|
};
|
|
79561
79621
|
|
|
79562
79622
|
// lib/shared/find-board-files.ts
|
|
79563
|
-
import
|
|
79564
|
-
import
|
|
79623
|
+
import fs19 from "node:fs";
|
|
79624
|
+
import path21 from "node:path";
|
|
79565
79625
|
var isSubPath = (maybeChild, maybeParent) => {
|
|
79566
|
-
const relative5 =
|
|
79567
|
-
return relative5 === "" || !relative5.startsWith("..") && !
|
|
79626
|
+
const relative5 = path21.relative(maybeParent, maybeChild);
|
|
79627
|
+
return relative5 === "" || !relative5.startsWith("..") && !path21.isAbsolute(relative5);
|
|
79568
79628
|
};
|
|
79569
79629
|
var isGlobPattern = (str) => {
|
|
79570
79630
|
return /[*?[\]{}]/.test(str);
|
|
@@ -79574,13 +79634,13 @@ var findBoardFiles = ({
|
|
|
79574
79634
|
ignore = DEFAULT_IGNORED_PATTERNS,
|
|
79575
79635
|
filePaths = []
|
|
79576
79636
|
} = {}) => {
|
|
79577
|
-
const resolvedProjectDir =
|
|
79637
|
+
const resolvedProjectDir = path21.resolve(projectDir);
|
|
79578
79638
|
const boardFilePatterns = getBoardFilePatterns(resolvedProjectDir);
|
|
79579
79639
|
const relativeBoardFiles = globbySync(boardFilePatterns, {
|
|
79580
79640
|
cwd: resolvedProjectDir,
|
|
79581
79641
|
ignore
|
|
79582
79642
|
});
|
|
79583
|
-
const absoluteBoardFiles = relativeBoardFiles.map((f) =>
|
|
79643
|
+
const absoluteBoardFiles = relativeBoardFiles.map((f) => path21.join(resolvedProjectDir, f));
|
|
79584
79644
|
const boardFileSet = new Set;
|
|
79585
79645
|
if (filePaths.length > 0) {
|
|
79586
79646
|
for (const inputPath of filePaths) {
|
|
@@ -79594,13 +79654,13 @@ var findBoardFiles = ({
|
|
|
79594
79654
|
boardFileSet.add(match);
|
|
79595
79655
|
}
|
|
79596
79656
|
} else {
|
|
79597
|
-
const targetPath =
|
|
79598
|
-
if (!
|
|
79657
|
+
const targetPath = path21.resolve(resolvedProjectDir, inputPath);
|
|
79658
|
+
if (!fs19.existsSync(targetPath)) {
|
|
79599
79659
|
continue;
|
|
79600
79660
|
}
|
|
79601
|
-
const stat4 =
|
|
79661
|
+
const stat4 = fs19.statSync(targetPath);
|
|
79602
79662
|
if (stat4.isDirectory()) {
|
|
79603
|
-
const resolvedDir =
|
|
79663
|
+
const resolvedDir = path21.resolve(targetPath);
|
|
79604
79664
|
if (isSubPath(resolvedDir, resolvedProjectDir)) {
|
|
79605
79665
|
for (const boardFile of absoluteBoardFiles) {
|
|
79606
79666
|
if (isSubPath(boardFile, resolvedDir)) {
|
|
@@ -79611,7 +79671,7 @@ var findBoardFiles = ({
|
|
|
79611
79671
|
const externalMatches = globbySync(boardFilePatterns, {
|
|
79612
79672
|
cwd: resolvedDir,
|
|
79613
79673
|
ignore
|
|
79614
|
-
}).map((f) =>
|
|
79674
|
+
}).map((f) => path21.join(resolvedDir, f));
|
|
79615
79675
|
for (const match of externalMatches) {
|
|
79616
79676
|
boardFileSet.add(match);
|
|
79617
79677
|
}
|
|
@@ -79631,7 +79691,7 @@ var findBoardFiles = ({
|
|
|
79631
79691
|
|
|
79632
79692
|
// cli/dev/register.ts
|
|
79633
79693
|
var findSelectableTsxFiles = (projectDir) => {
|
|
79634
|
-
const boardFiles = findBoardFiles({ projectDir }).filter((file) =>
|
|
79694
|
+
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs20.existsSync(file)).sort();
|
|
79635
79695
|
if (boardFiles.length > 0) {
|
|
79636
79696
|
return boardFiles;
|
|
79637
79697
|
}
|
|
@@ -79639,15 +79699,15 @@ var findSelectableTsxFiles = (projectDir) => {
|
|
|
79639
79699
|
cwd: projectDir,
|
|
79640
79700
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
79641
79701
|
});
|
|
79642
|
-
return files.map((file) =>
|
|
79702
|
+
return files.map((file) => path22.resolve(projectDir, file)).filter((file) => fs20.existsSync(file)).sort();
|
|
79643
79703
|
};
|
|
79644
79704
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
79645
|
-
const tsconfigPath =
|
|
79646
|
-
if (!
|
|
79705
|
+
const tsconfigPath = path22.join(projectDir, "tsconfig.json");
|
|
79706
|
+
if (!fs20.existsSync(tsconfigPath)) {
|
|
79647
79707
|
return;
|
|
79648
79708
|
}
|
|
79649
79709
|
try {
|
|
79650
|
-
const tsconfig = JSON.parse(
|
|
79710
|
+
const tsconfig = JSON.parse(fs20.readFileSync(tsconfigPath, "utf-8"));
|
|
79651
79711
|
const types = tsconfig?.compilerOptions?.types;
|
|
79652
79712
|
if (!Array.isArray(types) || !types.includes("tscircuit")) {
|
|
79653
79713
|
console.warn(kleur_default.yellow('Warning: "tscircuit" is missing from tsconfig.json compilerOptions.types. Add it (e.g. "types": ["tscircuit"]) to ensure CLI-provided types work correctly.'));
|
|
@@ -79674,7 +79734,7 @@ var registerDev = (program3) => {
|
|
|
79674
79734
|
}
|
|
79675
79735
|
let absolutePath;
|
|
79676
79736
|
if (file) {
|
|
79677
|
-
absolutePath =
|
|
79737
|
+
absolutePath = path22.resolve(file);
|
|
79678
79738
|
if (!absolutePath.endsWith(".tsx") && !absolutePath.endsWith(".ts")) {
|
|
79679
79739
|
console.error("Error: Only .tsx files are supported");
|
|
79680
79740
|
return;
|
|
@@ -79683,7 +79743,7 @@ var registerDev = (program3) => {
|
|
|
79683
79743
|
const entrypointPath = await getEntrypoint({
|
|
79684
79744
|
onError: () => {}
|
|
79685
79745
|
});
|
|
79686
|
-
if (entrypointPath &&
|
|
79746
|
+
if (entrypointPath && fs20.existsSync(entrypointPath)) {
|
|
79687
79747
|
absolutePath = entrypointPath;
|
|
79688
79748
|
console.log("Found entrypoint at:", entrypointPath);
|
|
79689
79749
|
} else {
|
|
@@ -79693,7 +79753,7 @@ var registerDev = (program3) => {
|
|
|
79693
79753
|
return;
|
|
79694
79754
|
}
|
|
79695
79755
|
absolutePath = availableFiles[0];
|
|
79696
|
-
console.log("Selected file:",
|
|
79756
|
+
console.log("Selected file:", path22.relative(process.cwd(), absolutePath));
|
|
79697
79757
|
}
|
|
79698
79758
|
}
|
|
79699
79759
|
warnIfTsconfigMissingTscircuitType(process.cwd());
|
|
@@ -79708,7 +79768,7 @@ var registerDev = (program3) => {
|
|
|
79708
79768
|
|
|
79709
79769
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
79710
79770
|
console.log(`
|
|
79711
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
79771
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path22.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
79712
79772
|
|
|
79713
79773
|
`);
|
|
79714
79774
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -79779,21 +79839,21 @@ var fetchAccount = async () => {
|
|
|
79779
79839
|
};
|
|
79780
79840
|
|
|
79781
79841
|
// cli/auth/setup-npmrc/setup-npmrc.ts
|
|
79782
|
-
import * as
|
|
79783
|
-
import * as
|
|
79784
|
-
import * as
|
|
79842
|
+
import * as fs21 from "node:fs";
|
|
79843
|
+
import * as path23 from "node:path";
|
|
79844
|
+
import * as os3 from "node:os";
|
|
79785
79845
|
var REGISTRY_URL = "npm.tscircuit.com";
|
|
79786
79846
|
function findGlobalNpmrc() {
|
|
79787
79847
|
const possiblePaths = [
|
|
79788
|
-
|
|
79789
|
-
process.env.USERPROFILE ?
|
|
79848
|
+
path23.join(os3.homedir(), ".npmrc"),
|
|
79849
|
+
process.env.USERPROFILE ? path23.join(process.env.USERPROFILE, ".npmrc") : null
|
|
79790
79850
|
].filter(Boolean);
|
|
79791
79851
|
for (const npmrcPath of possiblePaths) {
|
|
79792
|
-
if (
|
|
79852
|
+
if (fs21.existsSync(npmrcPath)) {
|
|
79793
79853
|
return npmrcPath;
|
|
79794
79854
|
}
|
|
79795
79855
|
}
|
|
79796
|
-
return
|
|
79856
|
+
return path23.join(os3.homedir(), ".npmrc");
|
|
79797
79857
|
}
|
|
79798
79858
|
function printManualInstructions(sessionToken) {
|
|
79799
79859
|
console.log(kleur_default.yellow(`
|
|
@@ -79801,7 +79861,7 @@ Manual setup instructions:`));
|
|
|
79801
79861
|
console.log(kleur_default.gray("─".repeat(50)));
|
|
79802
79862
|
console.log(`
|
|
79803
79863
|
1. Open or create your global .npmrc file:`);
|
|
79804
|
-
console.log(kleur_default.cyan(` ${
|
|
79864
|
+
console.log(kleur_default.cyan(` ${path23.join(os3.homedir(), ".npmrc")}`));
|
|
79805
79865
|
console.log(`
|
|
79806
79866
|
2. Add the following line:`);
|
|
79807
79867
|
console.log(kleur_default.cyan(` //${REGISTRY_URL}/:_authToken=${sessionToken}`));
|
|
@@ -79816,12 +79876,12 @@ function setupNpmrc(sessionToken) {
|
|
|
79816
79876
|
}
|
|
79817
79877
|
try {
|
|
79818
79878
|
let existingContent = "";
|
|
79819
|
-
if (
|
|
79820
|
-
existingContent =
|
|
79879
|
+
if (fs21.existsSync(npmrcPath)) {
|
|
79880
|
+
existingContent = fs21.readFileSync(npmrcPath, "utf-8");
|
|
79821
79881
|
const authLineRegex = new RegExp(`^//${REGISTRY_URL.replace(/\./g, "\\.")}/:_authToken=.+$`, "m");
|
|
79822
79882
|
if (authLineRegex.test(existingContent)) {
|
|
79823
79883
|
const updatedContent = existingContent.replace(authLineRegex, authLine);
|
|
79824
|
-
|
|
79884
|
+
fs21.writeFileSync(npmrcPath, updatedContent, "utf-8");
|
|
79825
79885
|
console.log(kleur_default.green(`Updated authentication token in ${npmrcPath}`));
|
|
79826
79886
|
return true;
|
|
79827
79887
|
}
|
|
@@ -79832,7 +79892,7 @@ function setupNpmrc(sessionToken) {
|
|
|
79832
79892
|
${authLine}
|
|
79833
79893
|
` : `${authLine}
|
|
79834
79894
|
`;
|
|
79835
|
-
|
|
79895
|
+
fs21.writeFileSync(npmrcPath, newContent, "utf-8");
|
|
79836
79896
|
console.log(kleur_default.green(`Added authentication token to ${npmrcPath}`));
|
|
79837
79897
|
return true;
|
|
79838
79898
|
} catch (error) {
|
|
@@ -79926,26 +79986,26 @@ var registerConfigPrint = (program3) => {
|
|
|
79926
79986
|
};
|
|
79927
79987
|
|
|
79928
79988
|
// cli/clone/register.ts
|
|
79929
|
-
import * as
|
|
79930
|
-
import * as
|
|
79989
|
+
import * as fs24 from "node:fs";
|
|
79990
|
+
import * as path26 from "node:path";
|
|
79931
79991
|
|
|
79932
79992
|
// cli/clone/clone-bug-report.ts
|
|
79933
79993
|
var import_jszip = __toESM2(require_lib4(), 1);
|
|
79934
79994
|
var import_prompts7 = __toESM2(require_prompts3(), 1);
|
|
79935
|
-
import * as
|
|
79936
|
-
import * as
|
|
79995
|
+
import * as fs23 from "node:fs";
|
|
79996
|
+
import * as path25 from "node:path";
|
|
79937
79997
|
|
|
79938
79998
|
// cli/clone/handle-existing-directory.ts
|
|
79939
79999
|
var import_prompts6 = __toESM2(require_prompts3(), 1);
|
|
79940
|
-
import * as
|
|
79941
|
-
import * as
|
|
80000
|
+
import * as fs22 from "node:fs";
|
|
80001
|
+
import * as path24 from "node:path";
|
|
79942
80002
|
var handleExistingDirectory = async (dirPath) => {
|
|
79943
|
-
if (!
|
|
80003
|
+
if (!fs22.existsSync(dirPath))
|
|
79944
80004
|
return;
|
|
79945
80005
|
const response = await import_prompts6.default({
|
|
79946
80006
|
type: "select",
|
|
79947
80007
|
name: "action",
|
|
79948
|
-
message: `Directory "${
|
|
80008
|
+
message: `Directory "${path24.basename(dirPath)}" already exists. What would you like to do?`,
|
|
79949
80009
|
choices: [
|
|
79950
80010
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
79951
80011
|
{
|
|
@@ -79960,7 +80020,7 @@ var handleExistingDirectory = async (dirPath) => {
|
|
|
79960
80020
|
process.exit(0);
|
|
79961
80021
|
}
|
|
79962
80022
|
if (response.action === "delete") {
|
|
79963
|
-
|
|
80023
|
+
fs22.rmSync(dirPath, { recursive: true, force: true });
|
|
79964
80024
|
console.log(`Deleted existing directory: ${dirPath}`);
|
|
79965
80025
|
} else if (response.action === "merge") {
|
|
79966
80026
|
console.log(`Merging files into existing directory: ${dirPath}`);
|
|
@@ -79986,12 +80046,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
79986
80046
|
return commonSegments.join("/");
|
|
79987
80047
|
};
|
|
79988
80048
|
var sanitizeRelativePath = (relativePath) => {
|
|
79989
|
-
const normalizedPath =
|
|
80049
|
+
const normalizedPath = path25.normalize(relativePath);
|
|
79990
80050
|
if (!normalizedPath)
|
|
79991
80051
|
return null;
|
|
79992
|
-
if (
|
|
80052
|
+
if (path25.isAbsolute(normalizedPath))
|
|
79993
80053
|
return null;
|
|
79994
|
-
const segments = normalizedPath.split(
|
|
80054
|
+
const segments = normalizedPath.split(path25.sep);
|
|
79995
80055
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
79996
80056
|
return null;
|
|
79997
80057
|
}
|
|
@@ -80006,7 +80066,7 @@ var cloneBugReport = async ({
|
|
|
80006
80066
|
console.error("Bug report ID must not be empty.");
|
|
80007
80067
|
process.exit(1);
|
|
80008
80068
|
}
|
|
80009
|
-
let dirPath =
|
|
80069
|
+
let dirPath = path25.resolve(`bug-report-${trimmedBugReportId}`);
|
|
80010
80070
|
await handleExistingDirectory(dirPath);
|
|
80011
80071
|
const ky2 = getRegistryApiKy();
|
|
80012
80072
|
let zipBuffer;
|
|
@@ -80024,7 +80084,7 @@ var cloneBugReport = async ({
|
|
|
80024
80084
|
}
|
|
80025
80085
|
process.exit(1);
|
|
80026
80086
|
}
|
|
80027
|
-
|
|
80087
|
+
fs23.mkdirSync(dirPath, { recursive: true });
|
|
80028
80088
|
const zip = await import_jszip.default.loadAsync(zipBuffer);
|
|
80029
80089
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
80030
80090
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
@@ -80036,29 +80096,29 @@ var cloneBugReport = async ({
|
|
|
80036
80096
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
80037
80097
|
continue;
|
|
80038
80098
|
}
|
|
80039
|
-
const fullPath =
|
|
80040
|
-
|
|
80099
|
+
const fullPath = path25.join(dirPath, sanitizedRelativePath);
|
|
80100
|
+
fs23.mkdirSync(path25.dirname(fullPath), { recursive: true });
|
|
80041
80101
|
const fileContent = await entry.async("nodebuffer");
|
|
80042
|
-
|
|
80102
|
+
fs23.writeFileSync(fullPath, fileContent);
|
|
80043
80103
|
}
|
|
80044
|
-
const packageJsonPath =
|
|
80045
|
-
if (
|
|
80104
|
+
const packageJsonPath = path25.join(dirPath, "package.json");
|
|
80105
|
+
if (fs23.existsSync(packageJsonPath)) {
|
|
80046
80106
|
try {
|
|
80047
|
-
const packageJson = JSON.parse(
|
|
80107
|
+
const packageJson = JSON.parse(fs23.readFileSync(packageJsonPath, "utf-8"));
|
|
80048
80108
|
const packageName = packageJson?.name;
|
|
80049
80109
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
80050
80110
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
80051
|
-
const suggestedDirPath =
|
|
80111
|
+
const suggestedDirPath = path25.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
80052
80112
|
if (suggestedDirPath !== dirPath) {
|
|
80053
80113
|
const response = await import_prompts7.default({
|
|
80054
80114
|
type: "confirm",
|
|
80055
80115
|
name: "rename",
|
|
80056
80116
|
initial: true,
|
|
80057
|
-
message: `Rename the directory to "${
|
|
80117
|
+
message: `Rename the directory to "${path25.basename(suggestedDirPath)}"?`
|
|
80058
80118
|
});
|
|
80059
80119
|
if (response.rename) {
|
|
80060
80120
|
await handleExistingDirectory(suggestedDirPath);
|
|
80061
|
-
|
|
80121
|
+
fs23.renameSync(dirPath, suggestedDirPath);
|
|
80062
80122
|
dirPath = suggestedDirPath;
|
|
80063
80123
|
}
|
|
80064
80124
|
}
|
|
@@ -80067,9 +80127,9 @@ var cloneBugReport = async ({
|
|
|
80067
80127
|
console.warn("Unable to read package name for renaming:", error);
|
|
80068
80128
|
}
|
|
80069
80129
|
}
|
|
80070
|
-
|
|
80130
|
+
fs23.writeFileSync(path25.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
80071
80131
|
generateTsConfig(dirPath);
|
|
80072
|
-
const relativeDirPath =
|
|
80132
|
+
const relativeDirPath = path25.relative(originalCwd, dirPath);
|
|
80073
80133
|
console.log(kleur_default.green(`
|
|
80074
80134
|
Successfully cloned bug report to:`));
|
|
80075
80135
|
console.log(` ${dirPath}/
|
|
@@ -80108,7 +80168,7 @@ var registerClone = (program3) => {
|
|
|
80108
80168
|
const [, author, packageName] = match;
|
|
80109
80169
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
80110
80170
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
80111
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
80171
|
+
const dirPath = userSettingToIncludeAuthor ? path26.resolve(`${author}.${packageName}`) : path26.resolve(packageName);
|
|
80112
80172
|
await handleExistingDirectory(dirPath);
|
|
80113
80173
|
const ky2 = getRegistryApiKy();
|
|
80114
80174
|
let packageFileList = {
|
|
@@ -80129,13 +80189,13 @@ var registerClone = (program3) => {
|
|
|
80129
80189
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
80130
80190
|
process.exit(1);
|
|
80131
80191
|
}
|
|
80132
|
-
|
|
80192
|
+
fs24.mkdirSync(dirPath, { recursive: true });
|
|
80133
80193
|
for (const fileInfo of packageFileList.package_files) {
|
|
80134
80194
|
const filePath = fileInfo.file_path.replace(/^\/|dist\//g, "");
|
|
80135
80195
|
if (!filePath)
|
|
80136
80196
|
continue;
|
|
80137
|
-
const fullPath =
|
|
80138
|
-
|
|
80197
|
+
const fullPath = path26.join(dirPath, filePath);
|
|
80198
|
+
fs24.mkdirSync(path26.dirname(fullPath), { recursive: true });
|
|
80139
80199
|
try {
|
|
80140
80200
|
const fileContent = await ky2.get("package_files/get", {
|
|
80141
80201
|
searchParams: {
|
|
@@ -80144,15 +80204,15 @@ var registerClone = (program3) => {
|
|
|
80144
80204
|
file_path: fileInfo.file_path
|
|
80145
80205
|
}
|
|
80146
80206
|
}).json();
|
|
80147
|
-
|
|
80207
|
+
fs24.writeFileSync(fullPath, fileContent.package_file.content_text);
|
|
80148
80208
|
} catch (error) {
|
|
80149
80209
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
80150
80210
|
}
|
|
80151
80211
|
}
|
|
80152
|
-
|
|
80212
|
+
fs24.writeFileSync(path26.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
80153
80213
|
generateTsConfig(dirPath);
|
|
80154
80214
|
await setupTsciProject(dirPath);
|
|
80155
|
-
const relativeDirPath =
|
|
80215
|
+
const relativeDirPath = path26.relative(originalCwd, dirPath);
|
|
80156
80216
|
console.log(kleur_default.green(`
|
|
80157
80217
|
Successfully cloned to:`));
|
|
80158
80218
|
console.log(` ${dirPath}/
|
|
@@ -80168,8 +80228,8 @@ Successfully cloned to:`));
|
|
|
80168
80228
|
var import_perfect_cli = __toESM2(require_dist7(), 1);
|
|
80169
80229
|
|
|
80170
80230
|
// lib/shared/export-snippet.ts
|
|
80171
|
-
import
|
|
80172
|
-
import
|
|
80231
|
+
import fs27 from "node:fs";
|
|
80232
|
+
import path29 from "node:path";
|
|
80173
80233
|
import { promisify as promisify3 } from "node:util";
|
|
80174
80234
|
|
|
80175
80235
|
// node_modules/circuit-json-to-readable-netlist/dist/index.js
|
|
@@ -81348,9 +81408,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
81348
81408
|
const stringifyCoordinates = (coordinates) => {
|
|
81349
81409
|
return coordinates.join(" ");
|
|
81350
81410
|
};
|
|
81351
|
-
const stringifyPath = (
|
|
81411
|
+
const stringifyPath = (path27, level) => {
|
|
81352
81412
|
const padding = indent.repeat(level);
|
|
81353
|
-
return `${padding}(path ${
|
|
81413
|
+
return `${padding}(path ${path27.layer} ${path27.width} ${stringifyCoordinates(path27.coordinates)})`;
|
|
81354
81414
|
};
|
|
81355
81415
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
81356
81416
|
`;
|
|
@@ -82048,10 +82108,10 @@ var AddSchematicSymbolsStage = class extends ConverterStage {
|
|
|
82048
82108
|
}
|
|
82049
82109
|
const instances = new SymbolInstances;
|
|
82050
82110
|
const project = new SymbolInstancesProject("");
|
|
82051
|
-
const
|
|
82052
|
-
|
|
82053
|
-
|
|
82054
|
-
project.paths.push(
|
|
82111
|
+
const path27 = new SymbolInstancePath(`/${kicadSch?.uuid?.value || ""}`);
|
|
82112
|
+
path27.reference = reference;
|
|
82113
|
+
path27.unit = 1;
|
|
82114
|
+
project.paths.push(path27);
|
|
82055
82115
|
instances.projects.push(project);
|
|
82056
82116
|
symbol._sxInstances = instances;
|
|
82057
82117
|
symbols3.push(symbol);
|
|
@@ -82259,11 +82319,11 @@ var AddSheetInstancesStage = class extends ConverterStage {
|
|
|
82259
82319
|
throw new Error("KicadSch instance not initialized in context");
|
|
82260
82320
|
}
|
|
82261
82321
|
const sheetInstances = new SheetInstances;
|
|
82262
|
-
const
|
|
82263
|
-
|
|
82322
|
+
const path27 = new SheetInstancesRootPath;
|
|
82323
|
+
path27.value = "/";
|
|
82264
82324
|
const page = new SheetInstancesRootPage("1");
|
|
82265
|
-
|
|
82266
|
-
sheetInstances.paths = [
|
|
82325
|
+
path27.pages = [page];
|
|
82326
|
+
sheetInstances.paths = [path27];
|
|
82267
82327
|
kicadSch.sheetInstances = sheetInstances;
|
|
82268
82328
|
kicadSch.embeddedFonts = new EmbeddedFonts3(false);
|
|
82269
82329
|
this.finished = true;
|
|
@@ -82618,12 +82678,12 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82618
82678
|
throw new Error("PCB transformation matrix not initialized in context");
|
|
82619
82679
|
}
|
|
82620
82680
|
const pcbSilkscreenPaths = this.ctx.db.pcb_silkscreen_path?.list() || [];
|
|
82621
|
-
for (const
|
|
82622
|
-
if (!
|
|
82681
|
+
for (const path27 of pcbSilkscreenPaths) {
|
|
82682
|
+
if (!path27.route || path27.route.length < 2)
|
|
82623
82683
|
continue;
|
|
82624
|
-
for (let i = 0;i <
|
|
82625
|
-
const startPoint =
|
|
82626
|
-
const endPoint =
|
|
82684
|
+
for (let i = 0;i < path27.route.length - 1; i++) {
|
|
82685
|
+
const startPoint = path27.route[i];
|
|
82686
|
+
const endPoint = path27.route[i + 1];
|
|
82627
82687
|
if (!startPoint || !endPoint)
|
|
82628
82688
|
continue;
|
|
82629
82689
|
const transformedStart = applyToPoint62(c2kMatPcb, {
|
|
@@ -82638,12 +82698,12 @@ var AddGraphicsStage = class extends ConverterStage {
|
|
|
82638
82698
|
top: "F.SilkS",
|
|
82639
82699
|
bottom: "B.SilkS"
|
|
82640
82700
|
};
|
|
82641
|
-
const kicadLayer = layerMap[
|
|
82701
|
+
const kicadLayer = layerMap[path27.layer] || path27.layer || "F.SilkS";
|
|
82642
82702
|
const grLine = new GrLine({
|
|
82643
82703
|
start: { x: transformedStart.x, y: transformedStart.y },
|
|
82644
82704
|
end: { x: transformedEnd.x, y: transformedEnd.y },
|
|
82645
82705
|
layer: kicadLayer,
|
|
82646
|
-
width:
|
|
82706
|
+
width: path27.stroke_width || 0.15
|
|
82647
82707
|
});
|
|
82648
82708
|
const graphicLines = kicadPcb.graphicLines;
|
|
82649
82709
|
graphicLines.push(grLine);
|
|
@@ -82751,8 +82811,8 @@ var import_jszip2 = __toESM2(require_lib4(), 1);
|
|
|
82751
82811
|
|
|
82752
82812
|
// lib/shared/generate-circuit-json.tsx
|
|
82753
82813
|
var import_make_vfs2 = __toESM2(require_dist8(), 1);
|
|
82754
|
-
import
|
|
82755
|
-
import
|
|
82814
|
+
import path27 from "node:path";
|
|
82815
|
+
import fs25 from "node:fs";
|
|
82756
82816
|
import { pathToFileURL } from "node:url";
|
|
82757
82817
|
import Debug11 from "debug";
|
|
82758
82818
|
|
|
@@ -82815,12 +82875,12 @@ async function generateCircuitJson({
|
|
|
82815
82875
|
const runner = new userLandTscircuit.RootCircuit({
|
|
82816
82876
|
platform: platformConfig
|
|
82817
82877
|
});
|
|
82818
|
-
const absoluteFilePath =
|
|
82819
|
-
const projectDir =
|
|
82878
|
+
const absoluteFilePath = path27.isAbsolute(filePath) ? filePath : path27.resolve(process.cwd(), filePath);
|
|
82879
|
+
const projectDir = path27.dirname(absoluteFilePath);
|
|
82820
82880
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
82821
|
-
const relativeComponentPath =
|
|
82822
|
-
const baseFileName = outputFileName ||
|
|
82823
|
-
const outputPath =
|
|
82881
|
+
const relativeComponentPath = path27.relative(projectDir, absoluteFilePath);
|
|
82882
|
+
const baseFileName = outputFileName || path27.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
82883
|
+
const outputPath = path27.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
82824
82884
|
debug11(`Project directory: ${projectDir}`);
|
|
82825
82885
|
debug11(`Relative component path: ${relativeComponentPath}`);
|
|
82826
82886
|
debug11(`Output path: ${outputPath}`);
|
|
@@ -82840,7 +82900,7 @@ async function generateCircuitJson({
|
|
|
82840
82900
|
return false;
|
|
82841
82901
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
82842
82902
|
return false;
|
|
82843
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
82903
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path27.extname(normalizedFilePath)))
|
|
82844
82904
|
return false;
|
|
82845
82905
|
return true;
|
|
82846
82906
|
},
|
|
@@ -82858,7 +82918,7 @@ async function generateCircuitJson({
|
|
|
82858
82918
|
const circuitJson = await runner.getCircuitJson();
|
|
82859
82919
|
if (saveToFile) {
|
|
82860
82920
|
debug11(`Saving circuit JSON to ${outputPath}`);
|
|
82861
|
-
|
|
82921
|
+
fs25.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
82862
82922
|
}
|
|
82863
82923
|
return {
|
|
82864
82924
|
circuitJson,
|
|
@@ -82867,8 +82927,8 @@ async function generateCircuitJson({
|
|
|
82867
82927
|
}
|
|
82868
82928
|
|
|
82869
82929
|
// cli/build/generate-kicad-footprint-library.ts
|
|
82870
|
-
import
|
|
82871
|
-
import
|
|
82930
|
+
import fs26 from "node:fs";
|
|
82931
|
+
import path28 from "node:path";
|
|
82872
82932
|
import { At, KicadPcb as KicadPcb2, parseKicadSexpr } from "kicadts";
|
|
82873
82933
|
var sanitizeLibraryAndFootprintName = (libraryLink) => {
|
|
82874
82934
|
if (!libraryLink) {
|
|
@@ -82928,8 +82988,8 @@ var generateKicadFootprintLibrary = async ({
|
|
|
82928
82988
|
projects,
|
|
82929
82989
|
distDir
|
|
82930
82990
|
}) => {
|
|
82931
|
-
const libraryRoot =
|
|
82932
|
-
|
|
82991
|
+
const libraryRoot = path28.join(distDir, "kicad-footprints");
|
|
82992
|
+
fs26.mkdirSync(libraryRoot, { recursive: true });
|
|
82933
82993
|
const uniqueFootprints = new Map;
|
|
82934
82994
|
for (const project of projects) {
|
|
82935
82995
|
try {
|
|
@@ -82952,10 +83012,10 @@ var generateKicadFootprintLibrary = async ({
|
|
|
82952
83012
|
const libraryNames = new Set;
|
|
82953
83013
|
for (const entry of uniqueFootprints.values()) {
|
|
82954
83014
|
libraryNames.add(entry.libraryName);
|
|
82955
|
-
const libraryDir =
|
|
82956
|
-
|
|
82957
|
-
const footprintPath =
|
|
82958
|
-
|
|
83015
|
+
const libraryDir = path28.join(libraryRoot, `${entry.libraryName}.pretty`);
|
|
83016
|
+
fs26.mkdirSync(libraryDir, { recursive: true });
|
|
83017
|
+
const footprintPath = path28.join(libraryDir, `${entry.footprintName}.kicad_mod`);
|
|
83018
|
+
fs26.writeFileSync(footprintPath, `${entry.content}
|
|
82959
83019
|
`);
|
|
82960
83020
|
}
|
|
82961
83021
|
if (libraryNames.size > 0) {
|
|
@@ -82965,7 +83025,7 @@ ${libTableEntries.join(`
|
|
|
82965
83025
|
`)}
|
|
82966
83026
|
)
|
|
82967
83027
|
`;
|
|
82968
|
-
|
|
83028
|
+
fs26.writeFileSync(path28.join(libraryRoot, "fp-lib-table"), libTableContent);
|
|
82969
83029
|
}
|
|
82970
83030
|
};
|
|
82971
83031
|
var extractFootprintsFromPcb = (pcbContent) => {
|
|
@@ -82990,7 +83050,7 @@ var extractFootprintsFromPcb = (pcbContent) => {
|
|
|
82990
83050
|
};
|
|
82991
83051
|
|
|
82992
83052
|
// lib/shared/export-snippet.ts
|
|
82993
|
-
var writeFileAsync = promisify3(
|
|
83053
|
+
var writeFileAsync = promisify3(fs27.writeFile);
|
|
82994
83054
|
var ALLOWED_EXPORT_FORMATS = [
|
|
82995
83055
|
"json",
|
|
82996
83056
|
"circuit-json",
|
|
@@ -83035,10 +83095,10 @@ var exportSnippet = async ({
|
|
|
83035
83095
|
onError(`Invalid format: ${format}`);
|
|
83036
83096
|
return onExit(1);
|
|
83037
83097
|
}
|
|
83038
|
-
const projectDir =
|
|
83039
|
-
const outputBaseName =
|
|
83098
|
+
const projectDir = path29.dirname(filePath);
|
|
83099
|
+
const outputBaseName = path29.basename(filePath).replace(/\.[^.]+$/, "");
|
|
83040
83100
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
83041
|
-
const outputDestination =
|
|
83101
|
+
const outputDestination = path29.join(projectDir, outputPath ?? outputFileName);
|
|
83042
83102
|
const circuitData = await generateCircuitJson({
|
|
83043
83103
|
filePath,
|
|
83044
83104
|
saveToFile: format === "circuit-json",
|
|
@@ -83250,12 +83310,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
83250
83310
|
};
|
|
83251
83311
|
|
|
83252
83312
|
// lib/eecircuit-engine/run-simulation.ts
|
|
83253
|
-
import { promises as
|
|
83254
|
-
import
|
|
83255
|
-
import
|
|
83313
|
+
import { promises as fs28, existsSync as existsSync11 } from "node:fs";
|
|
83314
|
+
import path30 from "node:path";
|
|
83315
|
+
import os4 from "node:os";
|
|
83256
83316
|
var sim = null;
|
|
83257
83317
|
var fetchSimulation = async () => {
|
|
83258
|
-
const tempFilePath =
|
|
83318
|
+
const tempFilePath = path30.join(os4.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
83259
83319
|
if (!existsSync11(tempFilePath)) {
|
|
83260
83320
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
83261
83321
|
const response = await fetch(url);
|
|
@@ -83263,7 +83323,7 @@ var fetchSimulation = async () => {
|
|
|
83263
83323
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
83264
83324
|
}
|
|
83265
83325
|
const scriptContent = await response.text();
|
|
83266
|
-
await
|
|
83326
|
+
await fs28.writeFile(tempFilePath, scriptContent);
|
|
83267
83327
|
}
|
|
83268
83328
|
const module2 = await import(tempFilePath);
|
|
83269
83329
|
return module2.Simulation;
|
|
@@ -83352,8 +83412,8 @@ var resultToCsv = (result) => {
|
|
|
83352
83412
|
};
|
|
83353
83413
|
|
|
83354
83414
|
// cli/export/register.ts
|
|
83355
|
-
import
|
|
83356
|
-
import { promises as
|
|
83415
|
+
import path31 from "node:path";
|
|
83416
|
+
import { promises as fs29 } from "node:fs";
|
|
83357
83417
|
var registerExport = (program3) => {
|
|
83358
83418
|
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) => {
|
|
83359
83419
|
const formatOption = options.format ?? "json";
|
|
@@ -83365,12 +83425,12 @@ var registerExport = (program3) => {
|
|
|
83365
83425
|
});
|
|
83366
83426
|
if (circuitJson) {
|
|
83367
83427
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
83368
|
-
const outputSpicePath = options.output ??
|
|
83369
|
-
await
|
|
83428
|
+
const outputSpicePath = options.output ?? path31.join(path31.dirname(file), `${path31.basename(file, path31.extname(file))}.spice.cir`);
|
|
83429
|
+
await fs29.writeFile(outputSpicePath, spiceString);
|
|
83370
83430
|
const { result } = await runSimulation(spiceString);
|
|
83371
83431
|
const csvContent = resultToCsv(result);
|
|
83372
83432
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
83373
|
-
await
|
|
83433
|
+
await fs29.writeFile(outputCsvPath, csvContent);
|
|
83374
83434
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
83375
83435
|
}
|
|
83376
83436
|
process.exit(0);
|
|
@@ -83594,14 +83654,14 @@ class KeyStore {
|
|
|
83594
83654
|
}
|
|
83595
83655
|
}
|
|
83596
83656
|
function createKey(key) {
|
|
83597
|
-
let
|
|
83657
|
+
let path32 = null;
|
|
83598
83658
|
let id = null;
|
|
83599
83659
|
let src = null;
|
|
83600
83660
|
let weight = 1;
|
|
83601
83661
|
let getFn = null;
|
|
83602
83662
|
if (isString2(key) || isArray(key)) {
|
|
83603
83663
|
src = key;
|
|
83604
|
-
|
|
83664
|
+
path32 = createKeyPath(key);
|
|
83605
83665
|
id = createKeyId(key);
|
|
83606
83666
|
} else {
|
|
83607
83667
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -83615,11 +83675,11 @@ function createKey(key) {
|
|
|
83615
83675
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
83616
83676
|
}
|
|
83617
83677
|
}
|
|
83618
|
-
|
|
83678
|
+
path32 = createKeyPath(name);
|
|
83619
83679
|
id = createKeyId(name);
|
|
83620
83680
|
getFn = key.getFn;
|
|
83621
83681
|
}
|
|
83622
|
-
return { path:
|
|
83682
|
+
return { path: path32, id, weight, src, getFn };
|
|
83623
83683
|
}
|
|
83624
83684
|
function createKeyPath(key) {
|
|
83625
83685
|
return isArray(key) ? key : key.split(".");
|
|
@@ -83627,34 +83687,34 @@ function createKeyPath(key) {
|
|
|
83627
83687
|
function createKeyId(key) {
|
|
83628
83688
|
return isArray(key) ? key.join(".") : key;
|
|
83629
83689
|
}
|
|
83630
|
-
function get(obj,
|
|
83690
|
+
function get(obj, path32) {
|
|
83631
83691
|
let list = [];
|
|
83632
83692
|
let arr = false;
|
|
83633
|
-
const deepGet = (obj2,
|
|
83693
|
+
const deepGet = (obj2, path33, index) => {
|
|
83634
83694
|
if (!isDefined(obj2)) {
|
|
83635
83695
|
return;
|
|
83636
83696
|
}
|
|
83637
|
-
if (!
|
|
83697
|
+
if (!path33[index]) {
|
|
83638
83698
|
list.push(obj2);
|
|
83639
83699
|
} else {
|
|
83640
|
-
let key =
|
|
83700
|
+
let key = path33[index];
|
|
83641
83701
|
const value = obj2[key];
|
|
83642
83702
|
if (!isDefined(value)) {
|
|
83643
83703
|
return;
|
|
83644
83704
|
}
|
|
83645
|
-
if (index ===
|
|
83705
|
+
if (index === path33.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
|
|
83646
83706
|
list.push(toString(value));
|
|
83647
83707
|
} else if (isArray(value)) {
|
|
83648
83708
|
arr = true;
|
|
83649
83709
|
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
83650
|
-
deepGet(value[i],
|
|
83710
|
+
deepGet(value[i], path33, index + 1);
|
|
83651
83711
|
}
|
|
83652
|
-
} else if (
|
|
83653
|
-
deepGet(value,
|
|
83712
|
+
} else if (path33.length) {
|
|
83713
|
+
deepGet(value, path33, index + 1);
|
|
83654
83714
|
}
|
|
83655
83715
|
}
|
|
83656
83716
|
};
|
|
83657
|
-
deepGet(obj, isString2(
|
|
83717
|
+
deepGet(obj, isString2(path32) ? path32.split(".") : path32, 0);
|
|
83658
83718
|
return arr ? list : list[0];
|
|
83659
83719
|
}
|
|
83660
83720
|
var MatchOptions = {
|
|
@@ -84846,8 +84906,8 @@ var registerSearch = (program3) => {
|
|
|
84846
84906
|
}
|
|
84847
84907
|
if (kicadResults.length) {
|
|
84848
84908
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
84849
|
-
kicadResults.forEach((
|
|
84850
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
84909
|
+
kicadResults.forEach((path32, idx) => {
|
|
84910
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path32.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
84851
84911
|
});
|
|
84852
84912
|
}
|
|
84853
84913
|
if (!onlyKicad && results.packages.length) {
|
|
@@ -90006,7 +90066,7 @@ var zo = rs.find((t2) => t2.text === "{REF}");
|
|
|
90006
90066
|
zo.y = 0;
|
|
90007
90067
|
zo.x = 0.35;
|
|
90008
90068
|
zo.anchor = "middle_left";
|
|
90009
|
-
var
|
|
90069
|
+
var os5 = es;
|
|
90010
90070
|
var is = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, path40: { type: "path", points: [{ x: 0.07, y: 0.19 }, { x: 0.07, y: -0.18 }], color: "primary", fill: false }, "path12-1": { type: "path", points: [{ x: 0.28, y: 0.53 }, { x: 0.28, y: 0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: -0.53 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path2: { type: "path", points: [{ x: 0.07, y: 0.11 }, { x: 0.29, y: 0.11 }], color: "primary", fill: false }, "path2-5": { type: "path", points: [{ x: 0.07, y: -0.1 }, { x: 0.29, y: -0.1 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: -0.08, y: 0.06 }, { x: -0.08, y: -0.07 }, { x: 0.01, y: 0 }, { x: -0.08, y: 0.06 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.15, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: 0.04, y: -0.42 } }, refblocks: { top1: { x: 0.28, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { path1: { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
90011
90071
|
var { paths: ud, texts: ls, bounds: Ke, refblocks: Oo, circles: vd } = is;
|
|
90012
90072
|
var t0 = s({ primitives: [...Object.values(ud), ...Object.values(vd), { ...ls.top1, anchor: "middle_right", x: 0 }, { ...ls.bottom1, anchor: "middle_right", x: 0 }], ports: [{ ...Oo.top1, labels: ["1", "drain"] }, { ...Oo.bottom1, labels: ["2", "source"] }, { ...Oo.left1, labels: ["3", "gate"] }], size: { width: Ke.width, height: Ke.height }, center: { x: Ke.centerX, y: Ke.centerY } });
|
|
@@ -90026,7 +90086,7 @@ var { paths: Ad, bounds: ss, refblocks: Pd } = xs;
|
|
|
90026
90086
|
var U = e({ primitives: [...Object.values(Ad)], ports: [{ ...Pd.left1, labels: ["1"] }], center: { x: ss.centerX, y: ss.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
|
|
90027
90087
|
var ms = r(U, "down");
|
|
90028
90088
|
var ns = r(U, "left");
|
|
90029
|
-
var
|
|
90089
|
+
var fs30 = r(U, "up");
|
|
90030
90090
|
var g = { paths: { path11: { type: "path", points: [{ x: -0.39, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.54 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.54 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
90031
90091
|
var { paths: Fd, texts: XA, bounds: e0, refblocks: Mo, circles: Rd } = g;
|
|
90032
90092
|
var hs = e({ primitives: [...Object.values(Fd), ...Object.values(Rd), { type: "text", text: "{REF}", x: -0.1, y: 0.3094553499999995 }, { type: "text", text: "{VAL}", x: -0.1, y: -0.3094553499999995 }], ports: [{ ...Mo.top1, labels: ["1", "collector"] }, { ...Mo.bottom1, labels: ["2", "emitter"] }, { ...Mo.left1, labels: ["3", "base"] }], size: { width: e0.width, height: e0.height }, center: { x: e0.centerX, y: e0.centerY } }).rotateRightFacingSymbol("right").changeTextAnchor("{REF}", "middle_right").changeTextAnchor("{VAL}", "middle_right").build();
|
|
@@ -90595,7 +90655,7 @@ var mb = Cl.primitives.find((t3) => t3.type === "text" && t3.text === "{VAL}");
|
|
|
90595
90655
|
sb.anchor = "middle_left";
|
|
90596
90656
|
mb.anchor = "middle_right";
|
|
90597
90657
|
var B1 = Cl;
|
|
90598
|
-
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At2, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert:
|
|
90658
|
+
var q1 = { ac_voltmeter_down: Ul, ac_voltmeter_horz: Wl, ac_voltmeter_left: Zl, ac_voltmeter_right: Kl, ac_voltmeter_up: ep, ac_voltmeter_vert: op, avalanche_diode_down: lp, avalanche_diode_horz: pp, avalanche_diode_left: yp, avalanche_diode_right: xp, avalanche_diode_up: mp, avalanche_diode_vert: fp, backward_diode_down: cp, backward_diode_left: Dt, backward_diode_right: _p, backward_diode_up: gp, battery_horz: Wt, battery_vert: Ap, boxresistor_down: Fp, boxresistor_left: Ep, boxresistor_right: Lp, boxresistor_small_down: jp, boxresistor_small_left: zp, boxresistor_small_right: Jp, boxresistor_small_up: Mp, boxresistor_up: Ip, bridged_ground_down: Dp, bridged_ground_left: Wp, bridged_ground_right: te, bridged_ground_up: Qp, capacitor_down: ta, capacitor_left: ea, capacitor_polarized_down: oa, capacitor_polarized_left: ia, capacitor_polarized_right: pa, capacitor_polarized_up: ya, capacitor_right: xa, capacitor_up: ma, constant_current_diode_down: fa, constant_current_diode_horz: ha, constant_current_diode_left: da, constant_current_diode_right: ba, constant_current_diode_up: ga, constant_current_diode_vert: va, crystal_4pin_down: wa, crystal_4pin_left: Aa, crystal_4pin_right: Pa, crystal_4pin_up: Sa, crystal_down: Ra, crystal_left: Ta, crystal_right: Ea, crystal_up: Xa, darlington_pair_transistor_down: La, darlington_pair_transistor_horz: Va, darlington_pair_transistor_left: ja, darlington_pair_transistor_right: ka, darlington_pair_transistor_up: za, darlington_pair_transistor_vert: Oa, dc_ammeter_horz: wt, dc_ammeter_vert: Ca, dc_voltmeter_down: Ia, dc_voltmeter_horz: qa, dc_voltmeter_left: Ua, dc_voltmeter_right: Wa, dc_voltmeter_up: Za, dc_voltmeter_vert: Ka, diac_down: ty, diac_horz: ey, diac_left: ry, diac_right: oy, diac_up: iy, diac_vert: ly, diode_down: ay, diode_left: yy, diode_right: $2, diode_up: xy, dpdt_normally_closed_switch_down: my, dpdt_normally_closed_switch_left: ny, dpdt_normally_closed_switch_right: M, dpdt_normally_closed_switch_up: fy, dpdt_switch_down: cy, dpdt_switch_left: dy, dpdt_switch_right: C, dpdt_switch_up: by, dpst_normally_closed_switch_down: gy, dpst_normally_closed_switch_left: uy, dpst_normally_closed_switch_right: N, dpst_normally_closed_switch_up: vy, dpst_switch_down: Ay, dpst_switch_left: Py, dpst_switch_right: I, dpst_switch_up: Sy, ferrite_bead_down: Ry, ferrite_bead_left: Ty, ferrite_bead_right: Fe, ferrite_bead_up: Se, filled_diode_down: Yy, filled_diode_horz: Ly, filled_diode_left: jy, filled_diode_right: zy, filled_diode_up: Jy, filled_diode_vert: My, frequency_meter_horz: At2, frequency_meter_vert: By, fuse_horz: ke, fuse_vert: Uy, ground_down: Gy, ground_horz: Wy, ground_left: Hy, ground_right: Zy, ground_up: Qy, ground_vert: Ky2, ground2_down: ex, ground2_left: ox, ground2_right: lx, ground2_up: ax, gunn_diode_horz: yx, gunn_diode_vert: xx, icled_down: mx, icled_left: nx, icled_right: q, icled_up: fx, igbt_transistor_horz: ze, igbt_transistor_vert: dx, illuminated_push_button_normally_open_horz: Oe, illuminated_push_button_normally_open_vert: ux, inductor_down: Px, inductor_left: Sx, inductor_right: _t, inductor_up: $e, laser_diode_down: Fx, laser_diode_left: Rx, laser_diode_right: D, laser_diode_up: Tx, led_down: Lx, led_left: Vx, led_right: gt, led_up: Ce, light_dependent_resistor_horz: Ie, light_dependent_resistor_vert: $x, mosfet_depletion_normally_on_horz: qe, mosfet_depletion_normally_on_vert: Ix, mushroom_head_normally_open_momentary_horz: Ue, mushroom_head_normally_open_momentary_vert: Ux, n_channel_d_mosfet_transistor_horz: He, n_channel_d_mosfet_transistor_vert: Qx, n_channel_e_mosfet_transistor_horz: Qe, n_channel_e_mosfet_transistor_vert: os5, njfet_transistor_horz: t0, njfet_transistor_vert: ys, not_connected_down: ms, not_connected_left: ns, not_connected_right: U, not_connected_up: fs30, npn_bipolar_transistor_down: hs, npn_bipolar_transistor_horz: cs, npn_bipolar_transistor_left: ds, npn_bipolar_transistor_right: bs, npn_bipolar_transistor_up: _s, npn_bipolar_transistor_vert: gs, opamp_no_power_down: vs, opamp_no_power_left: ws, opamp_no_power_right: G, opamp_no_power_up: As, opamp_with_power_down: Ss, opamp_with_power_left: Fs, opamp_with_power_right: W, opamp_with_power_up: Rs, p_channel_d_mosfet_transistor_horz: a0, p_channel_d_mosfet_transistor_vert: Ls, p_channel_e_mosfet_transistor_horz: x0, p_channel_e_mosfet_transistor_vert: Os, photodiode_horz: s0, photodiode_vert: Cs, pjfet_transistor_horz: n0, pjfet_transistor_vert: Ds, pnp_bipolar_transistor_down: Us, pnp_bipolar_transistor_horz: Gs, pnp_bipolar_transistor_left: Ws, pnp_bipolar_transistor_right: Hs, pnp_bipolar_transistor_up: Zs, pnp_bipolar_transistor_vert: Qs, potentiometer_horz: g0, potentiometer_vert: rm, potentiometer2_down: pm, potentiometer2_left: am, potentiometer2_right: H, potentiometer2_up: ym, potentiometer3_down: xm, potentiometer3_left: sm, potentiometer3_right: mm, potentiometer3_up: nm, power_factor_meter_horz: S0, power_factor_meter_vert: dm, push_button_normally_closed_momentary_horz: R0, push_button_normally_closed_momentary_vert: um, push_button_normally_open_momentary_horz: E0, push_button_normally_open_momentary_vert: Pm, rectifier_diode_horz: L0, rectifier_diode_vert: Rm, resistor_down: Em, resistor_left: Xm, resistor_right: Vm, resistor_up: km, resonator_down: Om, resonator_horz: M0, resonator_left: Jm, resonator_right: K, resonator_up: $m, resonator_vert: Mm, schottky_diode_down: Nm, schottky_diode_left: Im, schottky_diode_right: tt, schottky_diode_up: Bm, silicon_controlled_rectifier_horz: C0, silicon_controlled_rectifier_vert: Um, solderjumper2_bridged12_down: Gm, solderjumper2_bridged12_left: Wm, solderjumper2_bridged12_right: Hm, solderjumper2_bridged12_up: Zm, solderjumper2_down: Qm, solderjumper2_left: Km, solderjumper2_right: tn, solderjumper2_up: en, solderjumper3_bridged12_down: rn, solderjumper3_bridged12_left: on2, solderjumper3_bridged12_right: ln, solderjumper3_bridged12_up: pn, solderjumper3_bridged123_down: an, solderjumper3_bridged123_left: yn, solderjumper3_bridged123_right: xn, solderjumper3_bridged123_up: sn, solderjumper3_bridged23_down: mn, solderjumper3_bridged23_left: nn, solderjumper3_bridged23_right: fn, solderjumper3_bridged23_up: hn, solderjumper3_down: cn, solderjumper3_left: dn, solderjumper3_right: bn, solderjumper3_up: _n, spdt_normally_closed_switch_down: un, spdt_normally_closed_switch_left: vn, spdt_normally_closed_switch_right: at, spdt_normally_closed_switch_up: wn, spdt_switch_down: Pn, spdt_switch_left: Sn, spdt_switch_right: yt, spdt_switch_up: Fn, spst_normally_closed_switch_down: Rn, spst_normally_closed_switch_left: Tn, spst_normally_closed_switch_right: xt, spst_normally_closed_switch_up: En, spst_switch_down: Yn, spst_switch_left: Xn, spst_switch_right: st, spst_switch_up: Ln, square_wave_down: Vn, square_wave_left: jn, square_wave_right: kn, square_wave_up: zn, step_recovery_diode_horz: N0, step_recovery_diode_vert: On, tachometer_horz: Tt, tachometer_vert: Cn, testpoint_down: Bn, testpoint_left: qn, testpoint_right: nt, testpoint_up: Gn, tilted_ground_down: Hn, tilted_ground_left: Zn, tilted_ground_right: ut, tilted_ground_up: B0, triac_horz: q0, triac_vert: t1, tunnel_diode_horz: U0, tunnel_diode_vert: i1, unijunction_transistor_horz: W0, unijunction_transistor_vert: s1, usbc: n1, var_meter_horz: Z0, var_meter_vert: c1, varactor_diode_horz: K0, varactor_diode_vert: g1, varistor_horz: er, varistor_vert: A1, varmeter_horz: Et, varmeter_vert: R1, vcc_down: T1, vcc_left: E1, vcc_right: Y1, vcc_up: X1, volt_meter_horz: or, volt_meter_vert: L1, watt_hour_meter_horz: Yt, watt_hour_meter_vert: z1, wattmeter_horz: Xt, wattmeter_vert: M1, zener_diode_horz: ar, zener_diode_vert: B1 };
|
|
90599
90659
|
var Y$ = Object.fromEntries(Object.keys(q1).map((t3) => [t3, t3]));
|
|
90600
90660
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
90601
90661
|
lineThickness = 0
|
|
@@ -92625,11 +92685,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
92625
92685
|
fiber = fiber.next, id2--;
|
|
92626
92686
|
return fiber;
|
|
92627
92687
|
}
|
|
92628
|
-
function copyWithSetImpl(obj,
|
|
92629
|
-
if (index >=
|
|
92688
|
+
function copyWithSetImpl(obj, path32, index, value) {
|
|
92689
|
+
if (index >= path32.length)
|
|
92630
92690
|
return value;
|
|
92631
|
-
var key =
|
|
92632
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
92691
|
+
var key = path32[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
92692
|
+
updated[key] = copyWithSetImpl(obj[key], path32, index + 1, value);
|
|
92633
92693
|
return updated;
|
|
92634
92694
|
}
|
|
92635
92695
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -92649,11 +92709,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
92649
92709
|
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);
|
|
92650
92710
|
return updated;
|
|
92651
92711
|
}
|
|
92652
|
-
function copyWithDeleteImpl(obj,
|
|
92653
|
-
var key =
|
|
92654
|
-
if (index + 1 ===
|
|
92712
|
+
function copyWithDeleteImpl(obj, path32, index) {
|
|
92713
|
+
var key = path32[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
92714
|
+
if (index + 1 === path32.length)
|
|
92655
92715
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
92656
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
92716
|
+
updated[key] = copyWithDeleteImpl(obj[key], path32, index + 1);
|
|
92657
92717
|
return updated;
|
|
92658
92718
|
}
|
|
92659
92719
|
function shouldSuspendImpl() {
|
|
@@ -101684,29 +101744,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
101684
101744
|
var didWarnAboutNestedUpdates = false;
|
|
101685
101745
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
101686
101746
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
101687
|
-
overrideHookState = function(fiber, id2,
|
|
101747
|
+
overrideHookState = function(fiber, id2, path32, value) {
|
|
101688
101748
|
id2 = findHook(fiber, id2);
|
|
101689
|
-
id2 !== null && (
|
|
101749
|
+
id2 !== null && (path32 = copyWithSetImpl(id2.memoizedState, path32, 0, value), id2.memoizedState = path32, id2.baseState = path32, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path32 = enqueueConcurrentRenderForLane(fiber, 2), path32 !== null && scheduleUpdateOnFiber(path32, fiber, 2));
|
|
101690
101750
|
};
|
|
101691
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
101751
|
+
overrideHookStateDeletePath = function(fiber, id2, path32) {
|
|
101692
101752
|
id2 = findHook(fiber, id2);
|
|
101693
|
-
id2 !== null && (
|
|
101753
|
+
id2 !== null && (path32 = copyWithDeleteImpl(id2.memoizedState, path32, 0), id2.memoizedState = path32, id2.baseState = path32, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path32 = enqueueConcurrentRenderForLane(fiber, 2), path32 !== null && scheduleUpdateOnFiber(path32, fiber, 2));
|
|
101694
101754
|
};
|
|
101695
101755
|
overrideHookStateRenamePath = function(fiber, id2, oldPath, newPath) {
|
|
101696
101756
|
id2 = findHook(fiber, id2);
|
|
101697
101757
|
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));
|
|
101698
101758
|
};
|
|
101699
|
-
overrideProps = function(fiber,
|
|
101700
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
101759
|
+
overrideProps = function(fiber, path32, value) {
|
|
101760
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path32, 0, value);
|
|
101701
101761
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
101702
|
-
|
|
101703
|
-
|
|
101762
|
+
path32 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
101763
|
+
path32 !== null && scheduleUpdateOnFiber(path32, fiber, 2);
|
|
101704
101764
|
};
|
|
101705
|
-
overridePropsDeletePath = function(fiber,
|
|
101706
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
101765
|
+
overridePropsDeletePath = function(fiber, path32) {
|
|
101766
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path32, 0);
|
|
101707
101767
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
101708
|
-
|
|
101709
|
-
|
|
101768
|
+
path32 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
101769
|
+
path32 !== null && scheduleUpdateOnFiber(path32, fiber, 2);
|
|
101710
101770
|
};
|
|
101711
101771
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
101712
101772
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -117043,10 +117103,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117043
117103
|
var setErrorHandler = null;
|
|
117044
117104
|
var setSuspenseHandler = null;
|
|
117045
117105
|
{
|
|
117046
|
-
var copyWithDeleteImpl = function(obj,
|
|
117047
|
-
var key =
|
|
117106
|
+
var copyWithDeleteImpl = function(obj, path32, index2) {
|
|
117107
|
+
var key = path32[index2];
|
|
117048
117108
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
117049
|
-
if (index2 + 1 ===
|
|
117109
|
+
if (index2 + 1 === path32.length) {
|
|
117050
117110
|
if (isArray2(updated)) {
|
|
117051
117111
|
updated.splice(key, 1);
|
|
117052
117112
|
} else {
|
|
@@ -117054,11 +117114,11 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117054
117114
|
}
|
|
117055
117115
|
return updated;
|
|
117056
117116
|
}
|
|
117057
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
117117
|
+
updated[key] = copyWithDeleteImpl(obj[key], path32, index2 + 1);
|
|
117058
117118
|
return updated;
|
|
117059
117119
|
};
|
|
117060
|
-
var copyWithDelete = function(obj,
|
|
117061
|
-
return copyWithDeleteImpl(obj,
|
|
117120
|
+
var copyWithDelete = function(obj, path32) {
|
|
117121
|
+
return copyWithDeleteImpl(obj, path32, 0);
|
|
117062
117122
|
};
|
|
117063
117123
|
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
|
117064
117124
|
var oldKey = oldPath[index2];
|
|
@@ -117090,17 +117150,17 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117090
117150
|
}
|
|
117091
117151
|
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
|
117092
117152
|
};
|
|
117093
|
-
var copyWithSetImpl = function(obj,
|
|
117094
|
-
if (index2 >=
|
|
117153
|
+
var copyWithSetImpl = function(obj, path32, index2, value) {
|
|
117154
|
+
if (index2 >= path32.length) {
|
|
117095
117155
|
return value;
|
|
117096
117156
|
}
|
|
117097
|
-
var key =
|
|
117157
|
+
var key = path32[index2];
|
|
117098
117158
|
var updated = isArray2(obj) ? obj.slice() : assign2({}, obj);
|
|
117099
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
117159
|
+
updated[key] = copyWithSetImpl(obj[key], path32, index2 + 1, value);
|
|
117100
117160
|
return updated;
|
|
117101
117161
|
};
|
|
117102
|
-
var copyWithSet = function(obj,
|
|
117103
|
-
return copyWithSetImpl(obj,
|
|
117162
|
+
var copyWithSet = function(obj, path32, value) {
|
|
117163
|
+
return copyWithSetImpl(obj, path32, 0, value);
|
|
117104
117164
|
};
|
|
117105
117165
|
var findHook = function(fiber, id2) {
|
|
117106
117166
|
var currentHook2 = fiber.memoizedState;
|
|
@@ -117110,10 +117170,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117110
117170
|
}
|
|
117111
117171
|
return currentHook2;
|
|
117112
117172
|
};
|
|
117113
|
-
overrideHookState = function(fiber, id2,
|
|
117173
|
+
overrideHookState = function(fiber, id2, path32, value) {
|
|
117114
117174
|
var hook = findHook(fiber, id2);
|
|
117115
117175
|
if (hook !== null) {
|
|
117116
|
-
var newState = copyWithSet(hook.memoizedState,
|
|
117176
|
+
var newState = copyWithSet(hook.memoizedState, path32, value);
|
|
117117
117177
|
hook.memoizedState = newState;
|
|
117118
117178
|
hook.baseState = newState;
|
|
117119
117179
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -117123,10 +117183,10 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117123
117183
|
}
|
|
117124
117184
|
}
|
|
117125
117185
|
};
|
|
117126
|
-
overrideHookStateDeletePath = function(fiber, id2,
|
|
117186
|
+
overrideHookStateDeletePath = function(fiber, id2, path32) {
|
|
117127
117187
|
var hook = findHook(fiber, id2);
|
|
117128
117188
|
if (hook !== null) {
|
|
117129
|
-
var newState = copyWithDelete(hook.memoizedState,
|
|
117189
|
+
var newState = copyWithDelete(hook.memoizedState, path32);
|
|
117130
117190
|
hook.memoizedState = newState;
|
|
117131
117191
|
hook.baseState = newState;
|
|
117132
117192
|
fiber.memoizedProps = assign2({}, fiber.memoizedProps);
|
|
@@ -117149,8 +117209,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117149
117209
|
}
|
|
117150
117210
|
}
|
|
117151
117211
|
};
|
|
117152
|
-
overrideProps = function(fiber,
|
|
117153
|
-
fiber.pendingProps = copyWithSet(fiber.memoizedProps,
|
|
117212
|
+
overrideProps = function(fiber, path32, value) {
|
|
117213
|
+
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path32, value);
|
|
117154
117214
|
if (fiber.alternate) {
|
|
117155
117215
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
117156
117216
|
}
|
|
@@ -117159,8 +117219,8 @@ Check the render method of %s.`, getComponentNameFromFiber(current2) || "Unknown
|
|
|
117159
117219
|
scheduleUpdateOnFiber(root, fiber, SyncLane, NoTimestamp);
|
|
117160
117220
|
}
|
|
117161
117221
|
};
|
|
117162
|
-
overridePropsDeletePath = function(fiber,
|
|
117163
|
-
fiber.pendingProps = copyWithDelete(fiber.memoizedProps,
|
|
117222
|
+
overridePropsDeletePath = function(fiber, path32) {
|
|
117223
|
+
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path32);
|
|
117164
117224
|
if (fiber.alternate) {
|
|
117165
117225
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
117166
117226
|
}
|
|
@@ -123211,7 +123271,7 @@ var parsePin = (pinString) => {
|
|
|
123211
123271
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
123212
123272
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
123213
123273
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
123214
|
-
const
|
|
123274
|
+
const path32 = pathMatch ? pathMatch[1] : "";
|
|
123215
123275
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
123216
123276
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
123217
123277
|
const r3 = Number.parseFloat(rotation2);
|
|
@@ -123225,7 +123285,7 @@ var parsePin = (pinString) => {
|
|
|
123225
123285
|
rotation: Number.isNaN(r3) ? 0 : r3,
|
|
123226
123286
|
label,
|
|
123227
123287
|
labelColor,
|
|
123228
|
-
path:
|
|
123288
|
+
path: path32,
|
|
123229
123289
|
arrow
|
|
123230
123290
|
};
|
|
123231
123291
|
};
|
|
@@ -123665,15 +123725,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
123665
123725
|
}
|
|
123666
123726
|
}
|
|
123667
123727
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
123668
|
-
const
|
|
123728
|
+
const path32 = [];
|
|
123669
123729
|
for (let i = 0;i <= numPoints; i++) {
|
|
123670
123730
|
const t3 = i / numPoints;
|
|
123671
123731
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
123672
123732
|
const x = centerX + radius * Math.cos(angle2);
|
|
123673
123733
|
const y = centerY + radius * Math.sin(angle2);
|
|
123674
|
-
|
|
123734
|
+
path32.push({ x, y });
|
|
123675
123735
|
}
|
|
123676
|
-
return
|
|
123736
|
+
return path32;
|
|
123677
123737
|
}
|
|
123678
123738
|
var __defProp4 = Object.defineProperty;
|
|
123679
123739
|
var __export22 = (target, all) => {
|
|
@@ -125091,7 +125151,7 @@ var platedHoleWithRectPad = (pn2, x, y, holeDiameter, rectPadWidth, rectPadHeigh
|
|
|
125091
125151
|
};
|
|
125092
125152
|
};
|
|
125093
125153
|
var silkscreenPin = ({
|
|
125094
|
-
fs:
|
|
125154
|
+
fs: fs31,
|
|
125095
125155
|
pn: pn2,
|
|
125096
125156
|
anchor_x,
|
|
125097
125157
|
anchor_y,
|
|
@@ -125134,7 +125194,7 @@ var silkscreenPin = ({
|
|
|
125134
125194
|
type: "pcb_silkscreen_text",
|
|
125135
125195
|
pcb_silkscreen_text_id: "silkscreen_text_1",
|
|
125136
125196
|
font: "tscircuit2024",
|
|
125137
|
-
font_size:
|
|
125197
|
+
font_size: fs31,
|
|
125138
125198
|
pcb_component_id: "pcb_component_1",
|
|
125139
125199
|
text: `{PIN${pn2}}`,
|
|
125140
125200
|
layer,
|
|
@@ -132750,17 +132810,17 @@ var ObstacleList = class {
|
|
|
132750
132810
|
return obstacles;
|
|
132751
132811
|
}
|
|
132752
132812
|
};
|
|
132753
|
-
function removePathLoops(
|
|
132754
|
-
if (
|
|
132755
|
-
return
|
|
132756
|
-
const result = [{ ...
|
|
132757
|
-
let currentLayer =
|
|
132758
|
-
for (let i = 1;i <
|
|
132759
|
-
const currentSegment = { start:
|
|
132760
|
-
const isVia =
|
|
132761
|
-
if (
|
|
132762
|
-
result.push({ ...
|
|
132763
|
-
currentLayer =
|
|
132813
|
+
function removePathLoops(path32) {
|
|
132814
|
+
if (path32.length < 4)
|
|
132815
|
+
return path32;
|
|
132816
|
+
const result = [{ ...path32[0] }];
|
|
132817
|
+
let currentLayer = path32[0].layer;
|
|
132818
|
+
for (let i = 1;i < path32.length; i++) {
|
|
132819
|
+
const currentSegment = { start: path32[i - 1], end: path32[i] };
|
|
132820
|
+
const isVia = path32[i].route_type === "via" || path32[i - 1].route_type === "via";
|
|
132821
|
+
if (path32[i].layer !== currentLayer || isVia) {
|
|
132822
|
+
result.push({ ...path32[i] });
|
|
132823
|
+
currentLayer = path32[i].layer;
|
|
132764
132824
|
continue;
|
|
132765
132825
|
}
|
|
132766
132826
|
let intersectionFound = false;
|
|
@@ -132789,8 +132849,8 @@ function removePathLoops(path31) {
|
|
|
132789
132849
|
result.push(intersectionPoint);
|
|
132790
132850
|
}
|
|
132791
132851
|
const lastPoint = result[result.length - 1];
|
|
132792
|
-
if (lastPoint.x !==
|
|
132793
|
-
result.push(
|
|
132852
|
+
if (lastPoint.x !== path32[i].x || lastPoint.y !== path32[i].y) {
|
|
132853
|
+
result.push(path32[i]);
|
|
132794
132854
|
}
|
|
132795
132855
|
}
|
|
132796
132856
|
return result;
|
|
@@ -133279,10 +133339,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
133279
133339
|
});
|
|
133280
133340
|
}
|
|
133281
133341
|
if (current2.parent) {
|
|
133282
|
-
const
|
|
133342
|
+
const path32 = [];
|
|
133283
133343
|
let p = current2;
|
|
133284
133344
|
while (p) {
|
|
133285
|
-
|
|
133345
|
+
path32.unshift(p);
|
|
133286
133346
|
p = p.parent;
|
|
133287
133347
|
}
|
|
133288
133348
|
debugSolution.push({
|
|
@@ -133290,7 +133350,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
133290
133350
|
pcb_component_id: "",
|
|
133291
133351
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
133292
133352
|
layer: "top",
|
|
133293
|
-
route:
|
|
133353
|
+
route: path32,
|
|
133294
133354
|
stroke_width: 0.01
|
|
133295
133355
|
});
|
|
133296
133356
|
}
|
|
@@ -138212,13 +138272,13 @@ var RBush = class {
|
|
|
138212
138272
|
return this;
|
|
138213
138273
|
let node = this.data;
|
|
138214
138274
|
const bbox = this.toBBox(item);
|
|
138215
|
-
const
|
|
138275
|
+
const path32 = [];
|
|
138216
138276
|
const indexes = [];
|
|
138217
138277
|
let i, parent, goingUp;
|
|
138218
|
-
while (node ||
|
|
138278
|
+
while (node || path32.length) {
|
|
138219
138279
|
if (!node) {
|
|
138220
|
-
node =
|
|
138221
|
-
parent =
|
|
138280
|
+
node = path32.pop();
|
|
138281
|
+
parent = path32[path32.length - 1];
|
|
138222
138282
|
i = indexes.pop();
|
|
138223
138283
|
goingUp = true;
|
|
138224
138284
|
}
|
|
@@ -138226,13 +138286,13 @@ var RBush = class {
|
|
|
138226
138286
|
const index = findItem(item, node.children, equalsFn);
|
|
138227
138287
|
if (index !== -1) {
|
|
138228
138288
|
node.children.splice(index, 1);
|
|
138229
|
-
|
|
138230
|
-
this._condense(
|
|
138289
|
+
path32.push(node);
|
|
138290
|
+
this._condense(path32);
|
|
138231
138291
|
return this;
|
|
138232
138292
|
}
|
|
138233
138293
|
}
|
|
138234
138294
|
if (!goingUp && !node.leaf && contains(node, bbox)) {
|
|
138235
|
-
|
|
138295
|
+
path32.push(node);
|
|
138236
138296
|
indexes.push(i);
|
|
138237
138297
|
i = 0;
|
|
138238
138298
|
parent = node;
|
|
@@ -138303,10 +138363,10 @@ var RBush = class {
|
|
|
138303
138363
|
calcBBox(node, this.toBBox);
|
|
138304
138364
|
return node;
|
|
138305
138365
|
}
|
|
138306
|
-
_chooseSubtree(bbox, node, level,
|
|
138366
|
+
_chooseSubtree(bbox, node, level, path32) {
|
|
138307
138367
|
while (true) {
|
|
138308
|
-
|
|
138309
|
-
if (node.leaf ||
|
|
138368
|
+
path32.push(node);
|
|
138369
|
+
if (node.leaf || path32.length - 1 === level)
|
|
138310
138370
|
break;
|
|
138311
138371
|
let minArea = Infinity;
|
|
138312
138372
|
let minEnlargement = Infinity;
|
|
@@ -138415,21 +138475,21 @@ var RBush = class {
|
|
|
138415
138475
|
}
|
|
138416
138476
|
return margin;
|
|
138417
138477
|
}
|
|
138418
|
-
_adjustParentBBoxes(bbox,
|
|
138478
|
+
_adjustParentBBoxes(bbox, path32, level) {
|
|
138419
138479
|
for (let i = level;i >= 0; i--) {
|
|
138420
|
-
extend(
|
|
138480
|
+
extend(path32[i], bbox);
|
|
138421
138481
|
}
|
|
138422
138482
|
}
|
|
138423
|
-
_condense(
|
|
138424
|
-
for (let i =
|
|
138425
|
-
if (
|
|
138483
|
+
_condense(path32) {
|
|
138484
|
+
for (let i = path32.length - 1, siblings;i >= 0; i--) {
|
|
138485
|
+
if (path32[i].children.length === 0) {
|
|
138426
138486
|
if (i > 0) {
|
|
138427
|
-
siblings =
|
|
138428
|
-
siblings.splice(siblings.indexOf(
|
|
138487
|
+
siblings = path32[i - 1].children;
|
|
138488
|
+
siblings.splice(siblings.indexOf(path32[i]), 1);
|
|
138429
138489
|
} else
|
|
138430
138490
|
this.clear();
|
|
138431
138491
|
} else
|
|
138432
|
-
calcBBox(
|
|
138492
|
+
calcBBox(path32[i], this.toBBox);
|
|
138433
138493
|
}
|
|
138434
138494
|
}
|
|
138435
138495
|
};
|
|
@@ -139574,7 +139634,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139574
139634
|
this.capacityPaths = capacityPaths;
|
|
139575
139635
|
this.colorMap = colorMap ?? {};
|
|
139576
139636
|
this.unprocessedNodeIds = [
|
|
139577
|
-
...new Set(capacityPaths.flatMap((
|
|
139637
|
+
...new Set(capacityPaths.flatMap((path32) => path32.nodeIds))
|
|
139578
139638
|
];
|
|
139579
139639
|
this.nodePortSegments = /* @__PURE__ */ new Map;
|
|
139580
139640
|
}
|
|
@@ -139585,17 +139645,17 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139585
139645
|
return;
|
|
139586
139646
|
}
|
|
139587
139647
|
const pathsGoingThroughNode = [];
|
|
139588
|
-
for (const
|
|
139589
|
-
const indexOfNodeInPath =
|
|
139648
|
+
for (const path32 of this.capacityPaths) {
|
|
139649
|
+
const indexOfNodeInPath = path32.nodeIds.indexOf(nodeId);
|
|
139590
139650
|
if (indexOfNodeInPath !== -1) {
|
|
139591
|
-
pathsGoingThroughNode.push({ path:
|
|
139651
|
+
pathsGoingThroughNode.push({ path: path32, indexOfNodeInPath });
|
|
139592
139652
|
}
|
|
139593
139653
|
}
|
|
139594
139654
|
const node = this.nodeMap.get(nodeId);
|
|
139595
139655
|
const nodePortSegments = [];
|
|
139596
|
-
for (const { path:
|
|
139597
|
-
const entryNodeId =
|
|
139598
|
-
const exitNodeId =
|
|
139656
|
+
for (const { path: path32, indexOfNodeInPath } of pathsGoingThroughNode) {
|
|
139657
|
+
const entryNodeId = path32.nodeIds[indexOfNodeInPath - 1];
|
|
139658
|
+
const exitNodeId = path32.nodeIds[indexOfNodeInPath + 1];
|
|
139599
139659
|
for (const adjNodeId of [entryNodeId, exitNodeId]) {
|
|
139600
139660
|
const adjNode = this.nodeMap.get(adjNodeId);
|
|
139601
139661
|
if (!adjNode)
|
|
@@ -139608,7 +139668,7 @@ var CapacityEdgeToPortSegmentSolver = class extends BaseSolver {
|
|
|
139608
139668
|
capacityMeshNodeId: nodeId,
|
|
139609
139669
|
start: segment2.start,
|
|
139610
139670
|
end: segment2.end,
|
|
139611
|
-
connectionNames: [
|
|
139671
|
+
connectionNames: [path32.connectionName],
|
|
139612
139672
|
availableZ: mutuallyAvailableZ
|
|
139613
139673
|
};
|
|
139614
139674
|
nodePortSegments.push(portSegment);
|
|
@@ -140414,37 +140474,37 @@ var SingleHighDensityRouteSolver = class extends BaseSolver {
|
|
|
140414
140474
|
return neighbors;
|
|
140415
140475
|
}
|
|
140416
140476
|
getNodePath(node) {
|
|
140417
|
-
const
|
|
140477
|
+
const path32 = [];
|
|
140418
140478
|
while (node) {
|
|
140419
|
-
|
|
140479
|
+
path32.push(node);
|
|
140420
140480
|
node = node.parent;
|
|
140421
140481
|
}
|
|
140422
|
-
return
|
|
140482
|
+
return path32;
|
|
140423
140483
|
}
|
|
140424
140484
|
getViasInNodePath(node) {
|
|
140425
|
-
const
|
|
140485
|
+
const path32 = this.getNodePath(node);
|
|
140426
140486
|
const vias = [];
|
|
140427
|
-
for (let i = 0;i <
|
|
140428
|
-
if (
|
|
140429
|
-
vias.push({ x:
|
|
140487
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
140488
|
+
if (path32[i].z !== path32[i + 1].z) {
|
|
140489
|
+
vias.push({ x: path32[i].x, y: path32[i].y });
|
|
140430
140490
|
}
|
|
140431
140491
|
}
|
|
140432
140492
|
return vias;
|
|
140433
140493
|
}
|
|
140434
140494
|
setSolvedPath(node) {
|
|
140435
|
-
const
|
|
140436
|
-
|
|
140495
|
+
const path32 = this.getNodePath(node);
|
|
140496
|
+
path32.reverse();
|
|
140437
140497
|
const vias = [];
|
|
140438
|
-
for (let i = 0;i <
|
|
140439
|
-
if (
|
|
140440
|
-
vias.push({ x:
|
|
140498
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
140499
|
+
if (path32[i].z !== path32[i + 1].z) {
|
|
140500
|
+
vias.push({ x: path32[i].x, y: path32[i].y });
|
|
140441
140501
|
}
|
|
140442
140502
|
}
|
|
140443
140503
|
this.solvedPath = {
|
|
140444
140504
|
connectionName: this.connectionName,
|
|
140445
140505
|
traceThickness: this.traceThickness,
|
|
140446
140506
|
viaDiameter: this.viaDiameter,
|
|
140447
|
-
route:
|
|
140507
|
+
route: path32.map((node2) => ({ x: node2.x, y: node2.y, z: node2.z })).concat([this.B]),
|
|
140448
140508
|
vias
|
|
140449
140509
|
};
|
|
140450
140510
|
}
|
|
@@ -141252,12 +141312,12 @@ function computeDumbbellPaths({
|
|
|
141252
141312
|
specialType: circleCenter === A3 ? "A" : "B"
|
|
141253
141313
|
};
|
|
141254
141314
|
};
|
|
141255
|
-
const subdivideOptimalPath = (
|
|
141256
|
-
if (
|
|
141257
|
-
return
|
|
141258
|
-
const result = [
|
|
141259
|
-
for (let i = 0;i <
|
|
141260
|
-
const segment2 = { start:
|
|
141315
|
+
const subdivideOptimalPath = (path32, numSubdivisions) => {
|
|
141316
|
+
if (path32.length < 2)
|
|
141317
|
+
return path32;
|
|
141318
|
+
const result = [path32[0]];
|
|
141319
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
141320
|
+
const segment2 = { start: path32[i], end: path32[i + 1] };
|
|
141261
141321
|
const segmentMidpoint = {
|
|
141262
141322
|
x: (segment2.start.x + segment2.end.x) / 2,
|
|
141263
141323
|
y: (segment2.start.y + segment2.end.y) / 2
|
|
@@ -141319,7 +141379,7 @@ function computeDumbbellPaths({
|
|
|
141319
141379
|
}
|
|
141320
141380
|
subdivisionPoints.forEach((p) => result.push(p));
|
|
141321
141381
|
}
|
|
141322
|
-
result.push(
|
|
141382
|
+
result.push(path32[i + 1]);
|
|
141323
141383
|
}
|
|
141324
141384
|
if (result.length > 1) {
|
|
141325
141385
|
const filteredResult = [result[0]];
|
|
@@ -141554,13 +141614,13 @@ function computeDumbbellPaths({
|
|
|
141554
141614
|
].map((l, index) => ({ ...l, index }));
|
|
141555
141615
|
};
|
|
141556
141616
|
const subdivideJLinePath = (jLine, oppositePoint, r3, m2, numSubdivisions) => {
|
|
141557
|
-
const
|
|
141558
|
-
if (
|
|
141559
|
-
return
|
|
141617
|
+
const path32 = jLine.points;
|
|
141618
|
+
if (path32.length < 2)
|
|
141619
|
+
return path32;
|
|
141560
141620
|
const minDistThreshold = r3 + m2;
|
|
141561
|
-
const result = [
|
|
141562
|
-
for (let i = 0;i <
|
|
141563
|
-
const segment2 = { start:
|
|
141621
|
+
const result = [path32[0]];
|
|
141622
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
141623
|
+
const segment2 = { start: path32[i], end: path32[i + 1] };
|
|
141564
141624
|
const distToOpposite = pointToSegmentDistance22(oppositePoint, segment2.start, segment2.end);
|
|
141565
141625
|
if (distToOpposite < minDistThreshold) {
|
|
141566
141626
|
const closestPt = closestPointOnSegment(segment2, oppositePoint);
|
|
@@ -141629,26 +141689,26 @@ function computeDumbbellPaths({
|
|
|
141629
141689
|
return { index: 0, path: [] };
|
|
141630
141690
|
}
|
|
141631
141691
|
const optimalPath2 = validPaths.sort((a, b3) => a.length - b3.length)[0];
|
|
141632
|
-
const
|
|
141633
|
-
const firstPoint =
|
|
141634
|
-
const dist3 = distance3(firstPoint,
|
|
141635
|
-
const dist4 = distance3(firstPoint,
|
|
141692
|
+
const path32 = [...optimalPath2.path];
|
|
141693
|
+
const firstPoint = path32[0];
|
|
141694
|
+
const dist3 = distance3(firstPoint, path32[2]);
|
|
141695
|
+
const dist4 = distance3(firstPoint, path32[3]);
|
|
141636
141696
|
const closerIdx = dist3 < dist4 ? 2 : 3;
|
|
141637
|
-
if (dist3 < distance3(firstPoint,
|
|
141638
|
-
|
|
141697
|
+
if (dist3 < distance3(firstPoint, path32[1]) || dist4 < distance3(firstPoint, path32[1])) {
|
|
141698
|
+
path32.splice(1, closerIdx - 1);
|
|
141639
141699
|
}
|
|
141640
|
-
const lastPoint =
|
|
141641
|
-
const distM3 = distance3(lastPoint,
|
|
141642
|
-
const distM4 = distance3(lastPoint,
|
|
141643
|
-
const closerLastIdx = distM3 < distM4 ?
|
|
141644
|
-
if (distM3 < distance3(lastPoint,
|
|
141645
|
-
|
|
141700
|
+
const lastPoint = path32[path32.length - 1];
|
|
141701
|
+
const distM3 = distance3(lastPoint, path32[path32.length - 3]);
|
|
141702
|
+
const distM4 = distance3(lastPoint, path32[path32.length - 4]);
|
|
141703
|
+
const closerLastIdx = distM3 < distM4 ? path32.length - 3 : path32.length - 4;
|
|
141704
|
+
if (distM3 < distance3(lastPoint, path32[path32.length - 2]) || distM4 < distance3(lastPoint, path32[path32.length - 2])) {
|
|
141705
|
+
path32.splice(closerLastIdx + 1, path32.length - closerLastIdx - 2);
|
|
141646
141706
|
}
|
|
141647
141707
|
return {
|
|
141648
141708
|
index: optimalPath2.index,
|
|
141649
|
-
path:
|
|
141650
|
-
startsAt:
|
|
141651
|
-
goesTo:
|
|
141709
|
+
path: path32,
|
|
141710
|
+
startsAt: path32[0] === C2 ? "C" : "D",
|
|
141711
|
+
goesTo: path32[path32.length - 1] === C2 ? "C" : "D"
|
|
141652
141712
|
};
|
|
141653
141713
|
};
|
|
141654
141714
|
const optimalPath = findOptimalPath();
|
|
@@ -143068,9 +143128,9 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
143068
143128
|
let closestIntersection = null;
|
|
143069
143129
|
let intersectedSegmentZ = null;
|
|
143070
143130
|
const checkIntersectionsWithPathMap = (pathMap) => {
|
|
143071
|
-
for (const
|
|
143072
|
-
for (let i = 0;i <
|
|
143073
|
-
const segment2 = [
|
|
143131
|
+
for (const path32 of pathMap.values()) {
|
|
143132
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
143133
|
+
const segment2 = [path32[i], path32[i + 1]];
|
|
143074
143134
|
if (segment2[0].x === segment2[1].x && segment2[0].y === segment2[1].y) {
|
|
143075
143135
|
continue;
|
|
143076
143136
|
}
|
|
@@ -143200,11 +143260,11 @@ var ViaPossibilitiesSolver2 = class extends BaseSolver {
|
|
|
143200
143260
|
});
|
|
143201
143261
|
}
|
|
143202
143262
|
const drawPath = (pathMap, labelPrefix) => {
|
|
143203
|
-
for (const [connectionName,
|
|
143263
|
+
for (const [connectionName, path32] of pathMap.entries()) {
|
|
143204
143264
|
const color = colorMap[connectionName] ?? "black";
|
|
143205
|
-
for (let i = 0;i <
|
|
143206
|
-
const p12 =
|
|
143207
|
-
const p2 =
|
|
143265
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
143266
|
+
const p12 = path32[i];
|
|
143267
|
+
const p2 = path32[i + 1];
|
|
143208
143268
|
if (p12.x === p2.x && p12.y === p2.y && p12.z !== p2.z) {
|
|
143209
143269
|
graphics.circles.push({
|
|
143210
143270
|
center: { x: p12.x, y: p12.y },
|
|
@@ -143802,10 +143862,10 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
143802
143862
|
const allSegments = [];
|
|
143803
143863
|
const viaPoints = /* @__PURE__ */ new Map;
|
|
143804
143864
|
for (const polyLine of polyLines) {
|
|
143805
|
-
const
|
|
143806
|
-
for (let i = 0;i <
|
|
143807
|
-
const p12 =
|
|
143808
|
-
const p2 =
|
|
143865
|
+
const path32 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
143866
|
+
for (let i = 0;i < path32.length - 1; i++) {
|
|
143867
|
+
const p12 = path32[i];
|
|
143868
|
+
const p2 = path32[i + 1];
|
|
143809
143869
|
const layer = p12.z2;
|
|
143810
143870
|
allSegments.push({
|
|
143811
143871
|
start: { x: p12.x, y: p12.y },
|
|
@@ -143823,7 +143883,7 @@ function detectMultiConnectionClosedFacesWithoutVias(polyLines, bounds) {
|
|
|
143823
143883
|
}
|
|
143824
143884
|
}
|
|
143825
143885
|
}
|
|
143826
|
-
const lastPoint =
|
|
143886
|
+
const lastPoint = path32[path32.length - 1];
|
|
143827
143887
|
if (lastPoint.z1 !== lastPoint.z2) {
|
|
143828
143888
|
const key = pointKey2(lastPoint);
|
|
143829
143889
|
if (!viaPoints.has(key)) {
|
|
@@ -144122,14 +144182,14 @@ var MultiHeadPolyLineIntraNodeSolver = class extends BaseSolver {
|
|
|
144122
144182
|
const polyLineVias = [];
|
|
144123
144183
|
for (let i = 0;i < polyLines.length; i++) {
|
|
144124
144184
|
const polyLine = polyLines[i];
|
|
144125
|
-
const
|
|
144185
|
+
const path32 = [polyLine.start, ...polyLine.mPoints, polyLine.end];
|
|
144126
144186
|
const segmentsByLayer = new Map(this.availableZ.map((z852) => [z852, []]));
|
|
144127
|
-
for (let i22 = 0;i22 <
|
|
144128
|
-
const segment2 = [
|
|
144187
|
+
for (let i22 = 0;i22 < path32.length - 1; i22++) {
|
|
144188
|
+
const segment2 = [path32[i22], path32[i22 + 1]];
|
|
144129
144189
|
segmentsByLayer.get(segment2[0].z2).push(segment2);
|
|
144130
144190
|
}
|
|
144131
144191
|
polyLineSegmentsByLayer.push(segmentsByLayer);
|
|
144132
|
-
polyLineVias.push(
|
|
144192
|
+
polyLineVias.push(path32.filter((p) => p.z1 !== p.z2));
|
|
144133
144193
|
}
|
|
144134
144194
|
for (let i = 0;i < polyLines.length; i++) {
|
|
144135
144195
|
const path1SegmentsByLayer = polyLineSegmentsByLayer[i];
|
|
@@ -145558,7 +145618,7 @@ var HighDensitySolver = class extends BaseSolver {
|
|
|
145558
145618
|
if (this.failedSolvers.length > 0) {
|
|
145559
145619
|
this.solved = false;
|
|
145560
145620
|
this.failed = true;
|
|
145561
|
-
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((
|
|
145621
|
+
this.error = `Failed to solve ${this.failedSolvers.length} nodes, ${this.failedSolvers.slice(0, 5).map((fs31) => fs31.nodeWithPortPoints.capacityMeshNodeId)}. err0: ${this.failedSolvers[0].error}.`;
|
|
145562
145622
|
return;
|
|
145563
145623
|
}
|
|
145564
145624
|
this.solved = true;
|
|
@@ -148339,13 +148399,13 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
148339
148399
|
return this.getDistanceBetweenNodes(node, endGoal);
|
|
148340
148400
|
}
|
|
148341
148401
|
getBacktrackedPath(candidate) {
|
|
148342
|
-
const
|
|
148402
|
+
const path32 = [];
|
|
148343
148403
|
let currentCandidate = candidate;
|
|
148344
148404
|
while (currentCandidate) {
|
|
148345
|
-
|
|
148405
|
+
path32.push(currentCandidate.node);
|
|
148346
148406
|
currentCandidate = currentCandidate.prevCandidate;
|
|
148347
148407
|
}
|
|
148348
|
-
return
|
|
148408
|
+
return path32;
|
|
148349
148409
|
}
|
|
148350
148410
|
getNeighboringNodes(node) {
|
|
148351
148411
|
return this.nodeEdgeMap.get(node.capacityMeshNodeId).flatMap((edge) => edge.nodeIds.filter((n3) => n3 !== node.capacityMeshNodeId)).map((n3) => this.nodeMap.get(n3));
|
|
@@ -148353,12 +148413,12 @@ var CapacityPathingSolver = class extends BaseSolver {
|
|
|
148353
148413
|
getCapacityPaths() {
|
|
148354
148414
|
const capacityPaths = [];
|
|
148355
148415
|
for (const connection of this.connectionsWithNodes) {
|
|
148356
|
-
const
|
|
148357
|
-
if (
|
|
148416
|
+
const path32 = connection.path;
|
|
148417
|
+
if (path32) {
|
|
148358
148418
|
capacityPaths.push({
|
|
148359
148419
|
capacityPathId: connection.connection.name,
|
|
148360
148420
|
connectionName: connection.connection.name,
|
|
148361
|
-
nodeIds:
|
|
148421
|
+
nodeIds: path32.map((node) => node.capacityMeshNodeId)
|
|
148362
148422
|
});
|
|
148363
148423
|
}
|
|
148364
148424
|
}
|
|
@@ -149043,10 +149103,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149043
149103
|
return this.getDistanceBetweenNodes(node, endGoal) + this.getNodeCapacityPenalty(node);
|
|
149044
149104
|
}
|
|
149045
149105
|
getBacktrackedPath(candidate) {
|
|
149046
|
-
const
|
|
149106
|
+
const path32 = [];
|
|
149047
149107
|
let currentCandidate = candidate;
|
|
149048
149108
|
while (currentCandidate) {
|
|
149049
|
-
|
|
149109
|
+
path32.push(currentCandidate.node);
|
|
149050
149110
|
if (this.nodeMap.has(currentCandidate.node.capacityMeshNodeId)) {
|
|
149051
149111
|
currentCandidate = currentCandidate.prevCandidate;
|
|
149052
149112
|
} else {
|
|
@@ -149054,7 +149114,7 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149054
149114
|
break;
|
|
149055
149115
|
}
|
|
149056
149116
|
}
|
|
149057
|
-
return
|
|
149117
|
+
return path32.reverse();
|
|
149058
149118
|
}
|
|
149059
149119
|
getNeighboringNodes(node) {
|
|
149060
149120
|
if (!this.nodeMap.has(node.capacityMeshNodeId))
|
|
@@ -149069,8 +149129,8 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149069
149129
|
doesNodeHaveCapacityForTrace(node, prevNode) {
|
|
149070
149130
|
return true;
|
|
149071
149131
|
}
|
|
149072
|
-
reduceCapacityAlongPath(
|
|
149073
|
-
for (const pathNode of
|
|
149132
|
+
reduceCapacityAlongPath(path32) {
|
|
149133
|
+
for (const pathNode of path32) {
|
|
149074
149134
|
if (this.usedNodeCapacityMap.has(pathNode.capacityMeshNodeId)) {
|
|
149075
149135
|
const nodeId = pathNode.capacityMeshNodeId;
|
|
149076
149136
|
const nodeInSection = this.nodeMap.get(nodeId);
|
|
@@ -149199,9 +149259,9 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149199
149259
|
this.queuedNodes = null;
|
|
149200
149260
|
}
|
|
149201
149261
|
_handleGoalReached(currentCandidate, currentTerminal, endNode) {
|
|
149202
|
-
const
|
|
149203
|
-
currentTerminal.path =
|
|
149204
|
-
this.reduceCapacityAlongPath(
|
|
149262
|
+
const path32 = this.getBacktrackedPath(currentCandidate);
|
|
149263
|
+
currentTerminal.path = path32;
|
|
149264
|
+
this.reduceCapacityAlongPath(path32);
|
|
149205
149265
|
this.currentConnectionIndex++;
|
|
149206
149266
|
this.candidates = null;
|
|
149207
149267
|
this.visitedNodes = null;
|
|
@@ -149250,10 +149310,10 @@ var CapacityPathingSingleSectionSolver = class extends BaseSolver {
|
|
|
149250
149310
|
const connectionColor = this.colorMap[connectionName] ?? "purple";
|
|
149251
149311
|
topCandidates.forEach((candidate, index) => {
|
|
149252
149312
|
const opacity = 0.8 * (1 - index / 5);
|
|
149253
|
-
const
|
|
149254
|
-
if (
|
|
149313
|
+
const path32 = this.getBacktrackedPath(candidate);
|
|
149314
|
+
if (path32.length > 0) {
|
|
149255
149315
|
baseGraphics.lines.push({
|
|
149256
|
-
points:
|
|
149316
|
+
points: path32.map(({ center: { x, y } }) => ({ x, y })),
|
|
149257
149317
|
strokeColor: safeTransparentize(connectionColor, 1 - opacity),
|
|
149258
149318
|
strokeWidth: 0.05
|
|
149259
149319
|
});
|
|
@@ -149942,12 +150002,12 @@ var CapacityPathingMultiSectionSolver = class extends BaseSolver {
|
|
|
149942
150002
|
getCapacityPaths() {
|
|
149943
150003
|
const capacityPaths = [];
|
|
149944
150004
|
for (const connection of this.connectionsWithNodes) {
|
|
149945
|
-
const
|
|
149946
|
-
if (
|
|
150005
|
+
const path32 = connection.path;
|
|
150006
|
+
if (path32) {
|
|
149947
150007
|
capacityPaths.push({
|
|
149948
150008
|
capacityPathId: connection.connection.name,
|
|
149949
150009
|
connectionName: connection.connection.name,
|
|
149950
|
-
nodeIds:
|
|
150010
|
+
nodeIds: path32.map((node) => node.capacityMeshNodeId)
|
|
149951
150011
|
});
|
|
149952
150012
|
}
|
|
149953
150013
|
}
|
|
@@ -150968,22 +151028,22 @@ var SingleSimplifiedPathSolver5 = class extends SingleSimplifiedPathSolver {
|
|
|
150968
151028
|
return null;
|
|
150969
151029
|
}
|
|
150970
151030
|
const possiblePaths = calculate45DegreePaths({ x: start.x, y: start.y }, { x: end.x, y: end.y });
|
|
150971
|
-
for (const
|
|
150972
|
-
const fullPath =
|
|
151031
|
+
for (const path32 of possiblePaths) {
|
|
151032
|
+
const fullPath = path32.map((p) => ({ x: p.x, y: p.y, z: start.z }));
|
|
150973
151033
|
if (this.isValidPath(fullPath)) {
|
|
150974
151034
|
return fullPath;
|
|
150975
151035
|
}
|
|
150976
151036
|
}
|
|
150977
151037
|
return null;
|
|
150978
151038
|
}
|
|
150979
|
-
addPathToResult(
|
|
150980
|
-
if (
|
|
151039
|
+
addPathToResult(path32) {
|
|
151040
|
+
if (path32.length === 0)
|
|
150981
151041
|
return;
|
|
150982
|
-
for (let i = 0;i <
|
|
150983
|
-
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1],
|
|
151042
|
+
for (let i = 0;i < path32.length; i++) {
|
|
151043
|
+
if (i === 0 && this.newRoute.length > 0 && this.arePointsEqual(this.newRoute[this.newRoute.length - 1], path32[i])) {
|
|
150984
151044
|
continue;
|
|
150985
151045
|
}
|
|
150986
|
-
this.newRoute.push(
|
|
151046
|
+
this.newRoute.push(path32[i]);
|
|
150987
151047
|
}
|
|
150988
151048
|
this.currentStepSize = this.maxStepSize;
|
|
150989
151049
|
}
|
|
@@ -178390,7 +178450,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
178390
178450
|
for (let i = 0;i < portsWithPosition.length - 1; i++) {
|
|
178391
178451
|
const start = portsWithPosition[i];
|
|
178392
178452
|
const end = portsWithPosition[i + 1];
|
|
178393
|
-
const
|
|
178453
|
+
const path32 = calculateElbow({
|
|
178394
178454
|
x: start.position.x,
|
|
178395
178455
|
y: start.position.y,
|
|
178396
178456
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -178399,8 +178459,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
178399
178459
|
y: end.position.y,
|
|
178400
178460
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
178401
178461
|
});
|
|
178402
|
-
for (let j4 = 0;j4 <
|
|
178403
|
-
elbowEdges.push({ from:
|
|
178462
|
+
for (let j4 = 0;j4 < path32.length - 1; j4++) {
|
|
178463
|
+
elbowEdges.push({ from: path32[j4], to: path32[j4 + 1] });
|
|
178404
178464
|
}
|
|
178405
178465
|
}
|
|
178406
178466
|
const doesSegmentIntersectRect = (edge, rect) => {
|
|
@@ -184588,8 +184648,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
184588
184648
|
*/
|
|
184589
184649
|
|
|
184590
184650
|
// lib/import/import-component-from-jlcpcb.ts
|
|
184591
|
-
import
|
|
184592
|
-
import
|
|
184651
|
+
import fs31 from "node:fs/promises";
|
|
184652
|
+
import path32 from "node:path";
|
|
184593
184653
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
184594
184654
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
184595
184655
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -184597,10 +184657,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
184597
184657
|
if (!fileName) {
|
|
184598
184658
|
throw new Error("Could not determine file name of converted component");
|
|
184599
184659
|
}
|
|
184600
|
-
const importsDir =
|
|
184601
|
-
await
|
|
184602
|
-
const filePath =
|
|
184603
|
-
await
|
|
184660
|
+
const importsDir = path32.join(projectDir, "imports");
|
|
184661
|
+
await fs31.mkdir(importsDir, { recursive: true });
|
|
184662
|
+
const filePath = path32.join(importsDir, `${fileName}.tsx`);
|
|
184663
|
+
await fs31.writeFile(filePath, tsx);
|
|
184604
184664
|
return { filePath };
|
|
184605
184665
|
};
|
|
184606
184666
|
|
|
@@ -184786,7 +184846,7 @@ var ansi_styles_default = ansiStyles;
|
|
|
184786
184846
|
|
|
184787
184847
|
// node_modules/chalk/source/vendor/supports-color/index.js
|
|
184788
184848
|
import process10 from "node:process";
|
|
184789
|
-
import
|
|
184849
|
+
import os6 from "node:os";
|
|
184790
184850
|
import tty from "node:tty";
|
|
184791
184851
|
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process10.argv) {
|
|
184792
184852
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
@@ -184851,7 +184911,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
184851
184911
|
return min;
|
|
184852
184912
|
}
|
|
184853
184913
|
if (process10.platform === "win32") {
|
|
184854
|
-
const osRelease =
|
|
184914
|
+
const osRelease = os6.release().split(".");
|
|
184855
184915
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
184856
184916
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
184857
184917
|
}
|
|
@@ -185965,12 +186025,12 @@ var registerRemove = (program3) => {
|
|
|
185965
186025
|
};
|
|
185966
186026
|
|
|
185967
186027
|
// cli/build/register.ts
|
|
185968
|
-
import
|
|
185969
|
-
import
|
|
186028
|
+
import path40 from "node:path";
|
|
186029
|
+
import fs39 from "node:fs";
|
|
185970
186030
|
|
|
185971
186031
|
// cli/build/build-file.ts
|
|
185972
|
-
import
|
|
185973
|
-
import
|
|
186032
|
+
import path33 from "node:path";
|
|
186033
|
+
import fs32 from "node:fs";
|
|
185974
186034
|
|
|
185975
186035
|
// lib/shared/circuit-json-diagnostics.ts
|
|
185976
186036
|
function analyzeCircuitJson(circuitJson) {
|
|
@@ -186032,9 +186092,9 @@ var buildFile = async (input, output, projectDir, options) => {
|
|
|
186032
186092
|
filePath: input,
|
|
186033
186093
|
platformConfig: completePlatformConfig
|
|
186034
186094
|
});
|
|
186035
|
-
|
|
186036
|
-
|
|
186037
|
-
console.log(`Circuit JSON written to ${
|
|
186095
|
+
fs32.mkdirSync(path33.dirname(output), { recursive: true });
|
|
186096
|
+
fs32.writeFileSync(output, JSON.stringify(result.circuitJson, null, 2));
|
|
186097
|
+
console.log(`Circuit JSON written to ${path33.relative(projectDir, output)}`);
|
|
186038
186098
|
const { errors, warnings } = analyzeCircuitJson(result.circuitJson);
|
|
186039
186099
|
if (!options?.ignoreWarnings) {
|
|
186040
186100
|
for (const warn of warnings) {
|
|
@@ -186072,7 +186132,7 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
186072
186132
|
if (!match)
|
|
186073
186133
|
return;
|
|
186074
186134
|
const [, exportName, fromSpecifier] = match;
|
|
186075
|
-
const entryFileName =
|
|
186135
|
+
const entryFileName = path33.basename(entryFilePath);
|
|
186076
186136
|
console.error([
|
|
186077
186137
|
"",
|
|
186078
186138
|
`It looks like "${entryFileName}" re-exports the type-only symbol "${exportName}" from "${fromSpecifier}" without the "type" modifier.`,
|
|
@@ -186085,20 +186145,20 @@ var logTypeReexportHint = (error, entryFilePath) => {
|
|
|
186085
186145
|
};
|
|
186086
186146
|
|
|
186087
186147
|
// cli/build/get-build-entrypoints.ts
|
|
186088
|
-
import
|
|
186089
|
-
import
|
|
186148
|
+
import fs33 from "node:fs";
|
|
186149
|
+
import path34 from "node:path";
|
|
186090
186150
|
var isSubPath2 = (maybeChild, maybeParent) => {
|
|
186091
|
-
const relative9 =
|
|
186092
|
-
return relative9 === "" || !relative9.startsWith("..") && !
|
|
186151
|
+
const relative9 = path34.relative(maybeParent, maybeChild);
|
|
186152
|
+
return relative9 === "" || !relative9.startsWith("..") && !path34.isAbsolute(relative9);
|
|
186093
186153
|
};
|
|
186094
186154
|
var findProjectRoot = (startDir) => {
|
|
186095
186155
|
let currentDir = startDir;
|
|
186096
|
-
while (currentDir !==
|
|
186097
|
-
const packageJsonPath =
|
|
186098
|
-
if (
|
|
186156
|
+
while (currentDir !== path34.dirname(currentDir)) {
|
|
186157
|
+
const packageJsonPath = path34.join(currentDir, "package.json");
|
|
186158
|
+
if (fs33.existsSync(packageJsonPath)) {
|
|
186099
186159
|
return currentDir;
|
|
186100
186160
|
}
|
|
186101
|
-
currentDir =
|
|
186161
|
+
currentDir = path34.dirname(currentDir);
|
|
186102
186162
|
}
|
|
186103
186163
|
return startDir;
|
|
186104
186164
|
};
|
|
@@ -186107,7 +186167,7 @@ async function getBuildEntrypoints({
|
|
|
186107
186167
|
rootDir = process.cwd(),
|
|
186108
186168
|
includeBoardFiles = true
|
|
186109
186169
|
}) {
|
|
186110
|
-
const resolvedRoot =
|
|
186170
|
+
const resolvedRoot = path34.resolve(rootDir);
|
|
186111
186171
|
const includeBoardFilePatterns = includeBoardFiles ? getBoardFilePatterns(resolvedRoot) : [];
|
|
186112
186172
|
const buildFromProjectDir = async () => {
|
|
186113
186173
|
if (includeBoardFiles) {
|
|
@@ -186141,8 +186201,8 @@ async function getBuildEntrypoints({
|
|
|
186141
186201
|
};
|
|
186142
186202
|
};
|
|
186143
186203
|
if (fileOrDir) {
|
|
186144
|
-
const resolved =
|
|
186145
|
-
if (
|
|
186204
|
+
const resolved = path34.resolve(resolvedRoot, fileOrDir);
|
|
186205
|
+
if (fs33.existsSync(resolved) && fs33.statSync(resolved).isDirectory()) {
|
|
186146
186206
|
if (includeBoardFiles) {
|
|
186147
186207
|
const circuitFiles = findBoardFiles({
|
|
186148
186208
|
projectDir: resolvedRoot,
|
|
@@ -186172,7 +186232,7 @@ async function getBuildEntrypoints({
|
|
|
186172
186232
|
circuitFiles: mainEntrypoint ? [mainEntrypoint] : []
|
|
186173
186233
|
};
|
|
186174
186234
|
}
|
|
186175
|
-
const fileDir =
|
|
186235
|
+
const fileDir = path34.dirname(resolved);
|
|
186176
186236
|
const projectDir = findProjectRoot(fileDir);
|
|
186177
186237
|
return { projectDir, circuitFiles: [resolved] };
|
|
186178
186238
|
}
|
|
@@ -186209,8 +186269,8 @@ ${scriptBlock} <script src="https://cdn.tailwindcss.com"></script>
|
|
|
186209
186269
|
};
|
|
186210
186270
|
|
|
186211
186271
|
// cli/build/build-preview-images.ts
|
|
186212
|
-
import
|
|
186213
|
-
import
|
|
186272
|
+
import fs34 from "node:fs";
|
|
186273
|
+
import path35 from "node:path";
|
|
186214
186274
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
186215
186275
|
import {
|
|
186216
186276
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg2,
|
|
@@ -186283,21 +186343,21 @@ var generatePreviewAssets = async ({
|
|
|
186283
186343
|
outputDir,
|
|
186284
186344
|
distDir
|
|
186285
186345
|
}) => {
|
|
186286
|
-
const prefixRelative =
|
|
186346
|
+
const prefixRelative = path35.relative(distDir, outputDir) || ".";
|
|
186287
186347
|
const prefix = prefixRelative === "." ? "" : `[${prefixRelative}] `;
|
|
186288
186348
|
let circuitJson;
|
|
186289
186349
|
try {
|
|
186290
|
-
const circuitJsonRaw =
|
|
186350
|
+
const circuitJsonRaw = fs34.readFileSync(build.outputPath, "utf-8");
|
|
186291
186351
|
circuitJson = JSON.parse(circuitJsonRaw);
|
|
186292
186352
|
} catch (error) {
|
|
186293
186353
|
console.error(`${prefix}Failed to read circuit JSON:`, error);
|
|
186294
186354
|
return;
|
|
186295
186355
|
}
|
|
186296
|
-
|
|
186356
|
+
fs34.mkdirSync(outputDir, { recursive: true });
|
|
186297
186357
|
try {
|
|
186298
186358
|
console.log(`${prefix}Generating PCB SVG...`);
|
|
186299
186359
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson);
|
|
186300
|
-
|
|
186360
|
+
fs34.writeFileSync(path35.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
186301
186361
|
console.log(`${prefix}Written pcb.svg`);
|
|
186302
186362
|
} catch (error) {
|
|
186303
186363
|
console.error(`${prefix}Failed to generate PCB SVG:`, error);
|
|
@@ -186305,7 +186365,7 @@ var generatePreviewAssets = async ({
|
|
|
186305
186365
|
try {
|
|
186306
186366
|
console.log(`${prefix}Generating schematic SVG...`);
|
|
186307
186367
|
const schematicSvg = convertCircuitJsonToSchematicSvg2(circuitJson);
|
|
186308
|
-
|
|
186368
|
+
fs34.writeFileSync(path35.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
186309
186369
|
console.log(`${prefix}Written schematic.svg`);
|
|
186310
186370
|
} catch (error) {
|
|
186311
186371
|
console.error(`${prefix}Failed to generate schematic SVG:`, error);
|
|
@@ -186322,7 +186382,7 @@ var generatePreviewAssets = async ({
|
|
|
186322
186382
|
camPos: [10, 10, 10],
|
|
186323
186383
|
lookAt: [0, 0, 0]
|
|
186324
186384
|
});
|
|
186325
|
-
|
|
186385
|
+
fs34.writeFileSync(path35.join(outputDir, "3d.png"), Buffer.from(normalizeToUint8Array(pngBuffer)));
|
|
186326
186386
|
console.log(`${prefix}Written 3d.png`);
|
|
186327
186387
|
} catch (error) {
|
|
186328
186388
|
console.error(`${prefix}Failed to generate 3D PNG:`, error);
|
|
@@ -186335,14 +186395,14 @@ var buildPreviewImages = async ({
|
|
|
186335
186395
|
allImages
|
|
186336
186396
|
}) => {
|
|
186337
186397
|
const successfulBuilds = builtFiles.filter((file) => file.ok);
|
|
186338
|
-
const normalizedMainEntrypoint = mainEntrypoint ?
|
|
186398
|
+
const normalizedMainEntrypoint = mainEntrypoint ? path35.resolve(mainEntrypoint) : undefined;
|
|
186339
186399
|
if (allImages) {
|
|
186340
186400
|
if (successfulBuilds.length === 0) {
|
|
186341
186401
|
console.warn("No successful build output available for preview image generation.");
|
|
186342
186402
|
return;
|
|
186343
186403
|
}
|
|
186344
186404
|
for (const build of successfulBuilds) {
|
|
186345
|
-
const outputDir =
|
|
186405
|
+
const outputDir = path35.dirname(build.outputPath);
|
|
186346
186406
|
await generatePreviewAssets({
|
|
186347
186407
|
build,
|
|
186348
186408
|
outputDir,
|
|
@@ -186353,7 +186413,7 @@ var buildPreviewImages = async ({
|
|
|
186353
186413
|
}
|
|
186354
186414
|
const previewBuild = (() => {
|
|
186355
186415
|
if (normalizedMainEntrypoint) {
|
|
186356
|
-
const match = successfulBuilds.find((built) =>
|
|
186416
|
+
const match = successfulBuilds.find((built) => path35.resolve(built.sourcePath) === normalizedMainEntrypoint);
|
|
186357
186417
|
if (match)
|
|
186358
186418
|
return match;
|
|
186359
186419
|
}
|
|
@@ -186371,8 +186431,8 @@ var buildPreviewImages = async ({
|
|
|
186371
186431
|
};
|
|
186372
186432
|
|
|
186373
186433
|
// cli/build/generate-kicad-project.ts
|
|
186374
|
-
import
|
|
186375
|
-
import
|
|
186434
|
+
import fs35 from "node:fs";
|
|
186435
|
+
import path36 from "node:path";
|
|
186376
186436
|
var createKicadProContent = ({
|
|
186377
186437
|
projectName,
|
|
186378
186438
|
schematicFileName,
|
|
@@ -186412,10 +186472,10 @@ var generateKicadProject = async ({
|
|
|
186412
186472
|
boardFileName
|
|
186413
186473
|
});
|
|
186414
186474
|
if (writeFiles) {
|
|
186415
|
-
|
|
186416
|
-
|
|
186417
|
-
|
|
186418
|
-
|
|
186475
|
+
fs35.mkdirSync(outputDir, { recursive: true });
|
|
186476
|
+
fs35.writeFileSync(path36.join(outputDir, schematicFileName), schContent);
|
|
186477
|
+
fs35.writeFileSync(path36.join(outputDir, boardFileName), pcbContent);
|
|
186478
|
+
fs35.writeFileSync(path36.join(outputDir, projectFileName), proContent);
|
|
186419
186479
|
}
|
|
186420
186480
|
return {
|
|
186421
186481
|
pcbContent,
|
|
@@ -186427,8 +186487,8 @@ var generateKicadProject = async ({
|
|
|
186427
186487
|
};
|
|
186428
186488
|
|
|
186429
186489
|
// cli/build/transpile/index.ts
|
|
186430
|
-
import
|
|
186431
|
-
import
|
|
186490
|
+
import path38 from "node:path";
|
|
186491
|
+
import fs37 from "node:fs";
|
|
186432
186492
|
import { rollup } from "rollup";
|
|
186433
186493
|
import typescript from "@rollup/plugin-typescript";
|
|
186434
186494
|
import resolve11 from "@rollup/plugin-node-resolve";
|
|
@@ -186437,11 +186497,11 @@ import json from "@rollup/plugin-json";
|
|
|
186437
186497
|
import dts from "rollup-plugin-dts";
|
|
186438
186498
|
|
|
186439
186499
|
// cli/build/transpile/static-asset-plugin.ts
|
|
186440
|
-
import
|
|
186441
|
-
import
|
|
186500
|
+
import fs36 from "node:fs";
|
|
186501
|
+
import path37 from "node:path";
|
|
186442
186502
|
import { createHash } from "node:crypto";
|
|
186443
186503
|
function normalizePathSeparators(filePath) {
|
|
186444
|
-
return filePath.split(
|
|
186504
|
+
return filePath.split(path37.sep).join("/");
|
|
186445
186505
|
}
|
|
186446
186506
|
var STATIC_ASSET_EXTENSIONS = new Set([
|
|
186447
186507
|
".glb",
|
|
@@ -186472,24 +186532,24 @@ var createStaticAssetPlugin = ({
|
|
|
186472
186532
|
return {
|
|
186473
186533
|
name: "tsci-static-assets",
|
|
186474
186534
|
resolveId(source, importer) {
|
|
186475
|
-
const ext =
|
|
186535
|
+
const ext = path37.extname(source).toLowerCase();
|
|
186476
186536
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
186477
186537
|
return null;
|
|
186478
|
-
if (
|
|
186479
|
-
return
|
|
186538
|
+
if (path37.isAbsolute(source)) {
|
|
186539
|
+
return fs36.existsSync(source) ? { id: normalizePathSeparators(source), external: true } : null;
|
|
186480
186540
|
}
|
|
186481
186541
|
if (importer) {
|
|
186482
|
-
const importerNative = importer.split("/").join(
|
|
186483
|
-
const resolvedFromImporter =
|
|
186484
|
-
if (
|
|
186542
|
+
const importerNative = importer.split("/").join(path37.sep);
|
|
186543
|
+
const resolvedFromImporter = path37.resolve(path37.dirname(importerNative), source);
|
|
186544
|
+
if (fs36.existsSync(resolvedFromImporter)) {
|
|
186485
186545
|
return {
|
|
186486
186546
|
id: normalizePathSeparators(resolvedFromImporter),
|
|
186487
186547
|
external: true
|
|
186488
186548
|
};
|
|
186489
186549
|
}
|
|
186490
186550
|
}
|
|
186491
|
-
const resolvedFromProject =
|
|
186492
|
-
if (
|
|
186551
|
+
const resolvedFromProject = path37.resolve(resolvedBaseUrl, source);
|
|
186552
|
+
if (fs36.existsSync(resolvedFromProject)) {
|
|
186493
186553
|
return {
|
|
186494
186554
|
id: normalizePathSeparators(resolvedFromProject),
|
|
186495
186555
|
external: true
|
|
@@ -186502,8 +186562,8 @@ var createStaticAssetPlugin = ({
|
|
|
186502
186562
|
const wildcard = isWildcard ? source.slice(patternPrefix.length) : "";
|
|
186503
186563
|
for (const target of targets) {
|
|
186504
186564
|
const targetPath = isWildcard ? target.replace("*", wildcard) : target;
|
|
186505
|
-
const resolvedTarget =
|
|
186506
|
-
if (
|
|
186565
|
+
const resolvedTarget = path37.resolve(resolvedBaseUrl, targetPath);
|
|
186566
|
+
if (fs36.existsSync(resolvedTarget)) {
|
|
186507
186567
|
return {
|
|
186508
186568
|
id: normalizePathSeparators(resolvedTarget),
|
|
186509
186569
|
external: true
|
|
@@ -186529,18 +186589,18 @@ var createStaticAssetPlugin = ({
|
|
|
186529
186589
|
if (chunk.type !== "chunk")
|
|
186530
186590
|
continue;
|
|
186531
186591
|
for (const importedId of chunk.imports) {
|
|
186532
|
-
const ext =
|
|
186592
|
+
const ext = path37.extname(importedId).toLowerCase();
|
|
186533
186593
|
if (!STATIC_ASSET_EXTENSIONS.has(ext))
|
|
186534
186594
|
continue;
|
|
186535
186595
|
if (!copiedAssets.has(importedId)) {
|
|
186536
|
-
const assetDir =
|
|
186537
|
-
|
|
186538
|
-
const nativePath = importedId.split("/").join(
|
|
186539
|
-
const fileBuffer =
|
|
186596
|
+
const assetDir = path37.join(outputDir, "assets");
|
|
186597
|
+
fs36.mkdirSync(assetDir, { recursive: true });
|
|
186598
|
+
const nativePath = importedId.split("/").join(path37.sep);
|
|
186599
|
+
const fileBuffer = fs36.readFileSync(nativePath);
|
|
186540
186600
|
const hash = createHash("sha1").update(fileBuffer).digest("hex").slice(0, 8);
|
|
186541
|
-
const fileName = `${
|
|
186542
|
-
const outputFilePath =
|
|
186543
|
-
|
|
186601
|
+
const fileName = `${path37.basename(importedId, ext)}-${hash}${ext}`;
|
|
186602
|
+
const outputFilePath = path37.join(assetDir, fileName);
|
|
186603
|
+
fs36.writeFileSync(outputFilePath, fileBuffer);
|
|
186544
186604
|
copiedAssets.set(importedId, `./assets/${fileName}`);
|
|
186545
186605
|
assetIdToOutputPath.set(importedId, `./assets/${fileName}`);
|
|
186546
186606
|
}
|
|
@@ -186562,17 +186622,17 @@ function escapeRegExp(string) {
|
|
|
186562
186622
|
|
|
186563
186623
|
// cli/build/transpile/index.ts
|
|
186564
186624
|
var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
186565
|
-
if (id2.startsWith(".") || id2.startsWith("/") ||
|
|
186625
|
+
if (id2.startsWith(".") || id2.startsWith("/") || path38.isAbsolute(id2)) {
|
|
186566
186626
|
return false;
|
|
186567
186627
|
}
|
|
186568
186628
|
let baseUrl = projectDir;
|
|
186569
186629
|
let pathMappings = {};
|
|
186570
|
-
if (tsconfigPath &&
|
|
186630
|
+
if (tsconfigPath && fs37.existsSync(tsconfigPath)) {
|
|
186571
186631
|
try {
|
|
186572
|
-
const tsconfigContent =
|
|
186632
|
+
const tsconfigContent = fs37.readFileSync(tsconfigPath, "utf-8");
|
|
186573
186633
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
186574
186634
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
186575
|
-
baseUrl =
|
|
186635
|
+
baseUrl = path38.resolve(path38.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
186576
186636
|
}
|
|
186577
186637
|
if (tsconfig.compilerOptions?.paths) {
|
|
186578
186638
|
pathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -186586,17 +186646,17 @@ var createExternalFunction = (projectDir, tsconfigPath) => (id2) => {
|
|
|
186586
186646
|
}
|
|
186587
186647
|
}
|
|
186588
186648
|
const potentialPaths = [
|
|
186589
|
-
|
|
186590
|
-
|
|
186591
|
-
|
|
186592
|
-
|
|
186593
|
-
|
|
186594
|
-
|
|
186595
|
-
|
|
186596
|
-
|
|
186597
|
-
|
|
186649
|
+
path38.join(baseUrl, id2),
|
|
186650
|
+
path38.join(baseUrl, `${id2}.ts`),
|
|
186651
|
+
path38.join(baseUrl, `${id2}.tsx`),
|
|
186652
|
+
path38.join(baseUrl, `${id2}.js`),
|
|
186653
|
+
path38.join(baseUrl, `${id2}.jsx`),
|
|
186654
|
+
path38.join(baseUrl, id2, "index.ts"),
|
|
186655
|
+
path38.join(baseUrl, id2, "index.tsx"),
|
|
186656
|
+
path38.join(baseUrl, id2, "index.js"),
|
|
186657
|
+
path38.join(baseUrl, id2, "index.jsx")
|
|
186598
186658
|
];
|
|
186599
|
-
if (potentialPaths.some((p) =>
|
|
186659
|
+
if (potentialPaths.some((p) => fs37.existsSync(p))) {
|
|
186600
186660
|
return false;
|
|
186601
186661
|
}
|
|
186602
186662
|
return true;
|
|
@@ -186607,17 +186667,17 @@ var transpileFile = async ({
|
|
|
186607
186667
|
projectDir
|
|
186608
186668
|
}) => {
|
|
186609
186669
|
try {
|
|
186610
|
-
|
|
186611
|
-
const tsconfigPath =
|
|
186612
|
-
const hasTsConfig =
|
|
186670
|
+
fs37.mkdirSync(outputDir, { recursive: true });
|
|
186671
|
+
const tsconfigPath = path38.join(projectDir, "tsconfig.json");
|
|
186672
|
+
const hasTsConfig = fs37.existsSync(tsconfigPath);
|
|
186613
186673
|
let tsconfigBaseUrl = projectDir;
|
|
186614
186674
|
let tsconfigPathMappings;
|
|
186615
186675
|
if (hasTsConfig) {
|
|
186616
186676
|
try {
|
|
186617
|
-
const tsconfigContent =
|
|
186677
|
+
const tsconfigContent = fs37.readFileSync(tsconfigPath, "utf-8");
|
|
186618
186678
|
const tsconfig = JSON.parse(tsconfigContent);
|
|
186619
186679
|
if (tsconfig.compilerOptions?.baseUrl) {
|
|
186620
|
-
tsconfigBaseUrl =
|
|
186680
|
+
tsconfigBaseUrl = path38.resolve(path38.dirname(tsconfigPath), tsconfig.compilerOptions.baseUrl);
|
|
186621
186681
|
}
|
|
186622
186682
|
if (tsconfig.compilerOptions?.paths) {
|
|
186623
186683
|
tsconfigPathMappings = tsconfig.compilerOptions.paths;
|
|
@@ -186672,27 +186732,27 @@ var transpileFile = async ({
|
|
|
186672
186732
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
186673
186733
|
plugins: getPlugins()
|
|
186674
186734
|
});
|
|
186675
|
-
const esmOutputPath =
|
|
186735
|
+
const esmOutputPath = path38.join(outputDir, "index.js");
|
|
186676
186736
|
await esmBundle.write({
|
|
186677
186737
|
file: esmOutputPath,
|
|
186678
186738
|
format: "es",
|
|
186679
186739
|
sourcemap: false
|
|
186680
186740
|
});
|
|
186681
|
-
console.log(`ESM bundle written to ${
|
|
186741
|
+
console.log(`ESM bundle written to ${path38.relative(projectDir, esmOutputPath)}`);
|
|
186682
186742
|
console.log("Building CommonJS bundle...");
|
|
186683
186743
|
const cjsBundle = await rollup({
|
|
186684
186744
|
input,
|
|
186685
186745
|
external: createExternalFunction(projectDir, hasTsConfig ? tsconfigPath : undefined),
|
|
186686
186746
|
plugins: getPlugins()
|
|
186687
186747
|
});
|
|
186688
|
-
const cjsOutputPath =
|
|
186748
|
+
const cjsOutputPath = path38.join(outputDir, "index.cjs");
|
|
186689
186749
|
console.log("Writing CJS bundle to:", cjsOutputPath);
|
|
186690
186750
|
await cjsBundle.write({
|
|
186691
186751
|
file: cjsOutputPath,
|
|
186692
186752
|
format: "cjs",
|
|
186693
186753
|
sourcemap: false
|
|
186694
186754
|
});
|
|
186695
|
-
console.log(`CommonJS bundle written to ${
|
|
186755
|
+
console.log(`CommonJS bundle written to ${path38.relative(projectDir, cjsOutputPath)}`);
|
|
186696
186756
|
console.log("Generating type declarations...");
|
|
186697
186757
|
const dtsBundle = await rollup({
|
|
186698
186758
|
input,
|
|
@@ -186717,9 +186777,9 @@ var transpileFile = async ({
|
|
|
186717
186777
|
dtsContent = dtsContent.replace(/import \* as [\w_]+ from ['"]react\/jsx-runtime['"];?\s*\n?/g, "");
|
|
186718
186778
|
dtsContent = dtsContent.replace(/[\w_]+\.JSX\.Element/g, "any");
|
|
186719
186779
|
dtsContent = dtsContent.replace(/export\s*{\s*};\s*$/gm, "").trim();
|
|
186720
|
-
const dtsOutputPath =
|
|
186721
|
-
|
|
186722
|
-
console.log(`Type declarations written to ${
|
|
186780
|
+
const dtsOutputPath = path38.join(outputDir, "index.d.ts");
|
|
186781
|
+
fs37.writeFileSync(dtsOutputPath, dtsContent);
|
|
186782
|
+
console.log(`Type declarations written to ${path38.relative(projectDir, dtsOutputPath)}`);
|
|
186723
186783
|
console.log(kleur_default.green("Transpilation complete!"));
|
|
186724
186784
|
return true;
|
|
186725
186785
|
} catch (err) {
|
|
@@ -186732,17 +186792,17 @@ var transpileFile = async ({
|
|
|
186732
186792
|
};
|
|
186733
186793
|
|
|
186734
186794
|
// cli/utils/validate-main-in-dist.ts
|
|
186735
|
-
import
|
|
186736
|
-
import
|
|
186795
|
+
import fs38 from "node:fs";
|
|
186796
|
+
import path39 from "node:path";
|
|
186737
186797
|
var validateMainInDist = (projectDir, distDir) => {
|
|
186738
|
-
const packageJsonPath =
|
|
186739
|
-
if (!
|
|
186798
|
+
const packageJsonPath = path39.join(projectDir, "package.json");
|
|
186799
|
+
if (!fs38.existsSync(packageJsonPath))
|
|
186740
186800
|
return;
|
|
186741
|
-
const packageJson = JSON.parse(
|
|
186801
|
+
const packageJson = JSON.parse(fs38.readFileSync(packageJsonPath, "utf-8"));
|
|
186742
186802
|
if (typeof packageJson.main !== "string")
|
|
186743
186803
|
return;
|
|
186744
|
-
const resolvedMainPath =
|
|
186745
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
186804
|
+
const resolvedMainPath = path39.resolve(projectDir, packageJson.main);
|
|
186805
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path39.sep}`);
|
|
186746
186806
|
if (!isMainInDist) {
|
|
186747
186807
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
186748
186808
|
}
|
|
@@ -186767,8 +186827,8 @@ var registerBuild = (program3) => {
|
|
|
186767
186827
|
}
|
|
186768
186828
|
return config;
|
|
186769
186829
|
})();
|
|
186770
|
-
const distDir =
|
|
186771
|
-
|
|
186830
|
+
const distDir = path40.join(projectDir, "dist");
|
|
186831
|
+
fs39.mkdirSync(distDir, { recursive: true });
|
|
186772
186832
|
console.log(`Building ${circuitFiles.length} file(s)...`);
|
|
186773
186833
|
let hasErrors = false;
|
|
186774
186834
|
const staticFileReferences = [];
|
|
@@ -186776,10 +186836,10 @@ var registerBuild = (program3) => {
|
|
|
186776
186836
|
const kicadProjects = [];
|
|
186777
186837
|
const shouldGenerateKicad = options?.kicad || options?.kicadFootprintLibrary;
|
|
186778
186838
|
for (const filePath of circuitFiles) {
|
|
186779
|
-
const relative9 =
|
|
186839
|
+
const relative9 = path40.relative(projectDir, filePath);
|
|
186780
186840
|
console.log(`Building ${relative9}...`);
|
|
186781
186841
|
const outputDirName = relative9.replace(/(\.board|\.circuit)?\.tsx$/, "");
|
|
186782
|
-
const outputPath =
|
|
186842
|
+
const outputPath = path40.join(distDir, outputDirName, "circuit.json");
|
|
186783
186843
|
const buildOutcome = await buildFile(filePath, outputPath, projectDir, {
|
|
186784
186844
|
ignoreErrors: options?.ignoreErrors,
|
|
186785
186845
|
ignoreWarnings: options?.ignoreWarnings,
|
|
@@ -186793,17 +186853,17 @@ var registerBuild = (program3) => {
|
|
|
186793
186853
|
if (!buildOutcome.ok) {
|
|
186794
186854
|
hasErrors = true;
|
|
186795
186855
|
} else if (options?.site) {
|
|
186796
|
-
const normalizedSourcePath = relative9.split(
|
|
186797
|
-
const relativeOutputPath =
|
|
186798
|
-
const normalizedOutputPath = relativeOutputPath.split(
|
|
186856
|
+
const normalizedSourcePath = relative9.split(path40.sep).join("/");
|
|
186857
|
+
const relativeOutputPath = path40.join(outputDirName, "circuit.json");
|
|
186858
|
+
const normalizedOutputPath = relativeOutputPath.split(path40.sep).join("/");
|
|
186799
186859
|
staticFileReferences.push({
|
|
186800
186860
|
filePath: normalizedSourcePath,
|
|
186801
186861
|
fileStaticAssetUrl: `./${normalizedOutputPath}`
|
|
186802
186862
|
});
|
|
186803
186863
|
}
|
|
186804
186864
|
if (buildOutcome.ok && shouldGenerateKicad && buildOutcome.circuitJson) {
|
|
186805
|
-
const projectOutputDir =
|
|
186806
|
-
const projectName =
|
|
186865
|
+
const projectOutputDir = path40.join(distDir, outputDirName, "kicad");
|
|
186866
|
+
const projectName = path40.basename(outputDirName);
|
|
186807
186867
|
const project = await generateKicadProject({
|
|
186808
186868
|
circuitJson: buildOutcome.circuitJson,
|
|
186809
186869
|
outputDir: projectOutputDir,
|
|
@@ -186856,8 +186916,8 @@ var registerBuild = (program3) => {
|
|
|
186856
186916
|
files: staticFileReferences,
|
|
186857
186917
|
standaloneScriptSrc: "./standalone.min.js"
|
|
186858
186918
|
});
|
|
186859
|
-
|
|
186860
|
-
|
|
186919
|
+
fs39.writeFileSync(path40.join(distDir, "index.html"), indexHtml);
|
|
186920
|
+
fs39.writeFileSync(path40.join(distDir, "standalone.min.js"), standalone_min_default);
|
|
186861
186921
|
}
|
|
186862
186922
|
if (options?.kicadFootprintLibrary) {
|
|
186863
186923
|
if (kicadProjects.length === 0) {
|
|
@@ -186880,8 +186940,8 @@ var registerBuild = (program3) => {
|
|
|
186880
186940
|
};
|
|
186881
186941
|
|
|
186882
186942
|
// lib/shared/snapshot-project.ts
|
|
186883
|
-
import
|
|
186884
|
-
import
|
|
186943
|
+
import fs41 from "node:fs";
|
|
186944
|
+
import path41 from "node:path";
|
|
186885
186945
|
import looksSame2 from "looks-same";
|
|
186886
186946
|
import {
|
|
186887
186947
|
convertCircuitJsonToPcbSvg as convertCircuitJsonToPcbSvg3,
|
|
@@ -186892,7 +186952,7 @@ import { renderGLTFToPNGBufferFromGLBBuffer as renderGLTFToPNGBufferFromGLBBuffe
|
|
|
186892
186952
|
|
|
186893
186953
|
// lib/shared/compare-images.ts
|
|
186894
186954
|
import looksSame from "looks-same";
|
|
186895
|
-
import
|
|
186955
|
+
import fs40 from "node:fs/promises";
|
|
186896
186956
|
var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
186897
186957
|
const { equal: equal2 } = await looksSame(buffer1, buffer2, {
|
|
186898
186958
|
strict: false,
|
|
@@ -186908,7 +186968,7 @@ var compareAndCreateDiff = async (buffer1, buffer2, diffPath) => {
|
|
|
186908
186968
|
tolerance: 2
|
|
186909
186969
|
});
|
|
186910
186970
|
} else {
|
|
186911
|
-
await
|
|
186971
|
+
await fs40.writeFile(diffPath, buffer2);
|
|
186912
186972
|
}
|
|
186913
186973
|
}
|
|
186914
186974
|
return { equal: equal2 };
|
|
@@ -186933,7 +186993,7 @@ var snapshotProject = async ({
|
|
|
186933
186993
|
...DEFAULT_IGNORED_PATTERNS,
|
|
186934
186994
|
...ignored.map(normalizeIgnorePattern)
|
|
186935
186995
|
];
|
|
186936
|
-
const resolvedPaths = filePaths.map((f) =>
|
|
186996
|
+
const resolvedPaths = filePaths.map((f) => path41.resolve(projectDir, f));
|
|
186937
186997
|
const boardFiles = findBoardFiles({
|
|
186938
186998
|
projectDir,
|
|
186939
186999
|
ignore,
|
|
@@ -186947,7 +187007,7 @@ var snapshotProject = async ({
|
|
|
186947
187007
|
const mismatches = [];
|
|
186948
187008
|
let didUpdate = false;
|
|
186949
187009
|
for (const file of boardFiles) {
|
|
186950
|
-
const relativeFilePath =
|
|
187010
|
+
const relativeFilePath = path41.relative(projectDir, file);
|
|
186951
187011
|
let circuitJson;
|
|
186952
187012
|
let pcbSvg;
|
|
186953
187013
|
let schSvg;
|
|
@@ -187002,17 +187062,17 @@ var snapshotProject = async ({
|
|
|
187002
187062
|
} catch (error) {
|
|
187003
187063
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
187004
187064
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
187005
|
-
const fileDir =
|
|
187006
|
-
const relativeDir =
|
|
187007
|
-
const snapDir2 = snapshotsDirName ?
|
|
187008
|
-
const base2 =
|
|
187009
|
-
const snap3dPath =
|
|
187010
|
-
const existing3dSnapshot =
|
|
187065
|
+
const fileDir = path41.dirname(file);
|
|
187066
|
+
const relativeDir = path41.relative(projectDir, fileDir);
|
|
187067
|
+
const snapDir2 = snapshotsDirName ? path41.join(projectDir, snapshotsDirName, relativeDir) : path41.join(fileDir, "__snapshots__");
|
|
187068
|
+
const base2 = path41.basename(file).replace(/\.tsx$/, "");
|
|
187069
|
+
const snap3dPath = path41.join(snapDir2, `${base2}-3d.snap.png`);
|
|
187070
|
+
const existing3dSnapshot = fs41.existsSync(snap3dPath);
|
|
187011
187071
|
if (existing3dSnapshot) {
|
|
187012
187072
|
onError(kleur_default.red(`
|
|
187013
187073
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
187014
187074
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
187015
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
187075
|
+
`) + kleur_default.red(` Existing snapshot: ${path41.relative(projectDir, snap3dPath)}
|
|
187016
187076
|
`));
|
|
187017
187077
|
return onExit2(1);
|
|
187018
187078
|
} else {
|
|
@@ -187028,9 +187088,9 @@ var snapshotProject = async ({
|
|
|
187028
187088
|
}
|
|
187029
187089
|
}
|
|
187030
187090
|
}
|
|
187031
|
-
const snapDir = snapshotsDirName ?
|
|
187032
|
-
|
|
187033
|
-
const base =
|
|
187091
|
+
const snapDir = snapshotsDirName ? path41.join(projectDir, snapshotsDirName, path41.relative(projectDir, path41.dirname(file))) : path41.join(path41.dirname(file), "__snapshots__");
|
|
187092
|
+
fs41.mkdirSync(snapDir, { recursive: true });
|
|
187093
|
+
const base = path41.basename(file).replace(/\.tsx$/, "");
|
|
187034
187094
|
const snapshots = [];
|
|
187035
187095
|
if (pcbOnly || !schematicOnly) {
|
|
187036
187096
|
snapshots.push({ type: "pcb", content: pcbSvg, isBinary: false });
|
|
@@ -187048,31 +187108,31 @@ var snapshotProject = async ({
|
|
|
187048
187108
|
for (const snapshot of snapshots) {
|
|
187049
187109
|
const { type } = snapshot;
|
|
187050
187110
|
const is3d = type === "3d";
|
|
187051
|
-
const snapPath =
|
|
187052
|
-
const existing =
|
|
187111
|
+
const snapPath = path41.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
187112
|
+
const existing = fs41.existsSync(snapPath);
|
|
187053
187113
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
187054
187114
|
const newContentForFile = snapshot.content;
|
|
187055
187115
|
if (!existing) {
|
|
187056
|
-
|
|
187057
|
-
console.log("✅", kleur_default.gray(
|
|
187116
|
+
fs41.writeFileSync(snapPath, newContentForFile);
|
|
187117
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
187058
187118
|
didUpdate = true;
|
|
187059
187119
|
continue;
|
|
187060
187120
|
}
|
|
187061
|
-
const oldContentBuffer =
|
|
187121
|
+
const oldContentBuffer = fs41.readFileSync(snapPath);
|
|
187062
187122
|
const diffPath = snapPath.replace(is3d ? ".snap.png" : ".snap.svg", is3d ? ".diff.png" : ".diff.svg");
|
|
187063
187123
|
const { equal: equal2 } = await compareAndCreateDiff(oldContentBuffer, newContentBuffer, diffPath);
|
|
187064
187124
|
if (update) {
|
|
187065
187125
|
if (!forceUpdate && equal2) {
|
|
187066
|
-
console.log("✅", kleur_default.gray(
|
|
187126
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
187067
187127
|
} else {
|
|
187068
|
-
|
|
187069
|
-
console.log("✅", kleur_default.gray(
|
|
187128
|
+
fs41.writeFileSync(snapPath, newContentForFile);
|
|
187129
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
187070
187130
|
didUpdate = true;
|
|
187071
187131
|
}
|
|
187072
187132
|
} else if (!equal2) {
|
|
187073
187133
|
mismatches.push(`${snapPath} (diff: ${diffPath})`);
|
|
187074
187134
|
} else {
|
|
187075
|
-
console.log("✅", kleur_default.gray(
|
|
187135
|
+
console.log("✅", kleur_default.gray(path41.relative(projectDir, snapPath)));
|
|
187076
187136
|
}
|
|
187077
187137
|
}
|
|
187078
187138
|
}
|
|
@@ -187111,22 +187171,22 @@ var registerSnapshot = (program3) => {
|
|
|
187111
187171
|
};
|
|
187112
187172
|
|
|
187113
187173
|
// lib/shared/setup-github-actions.ts
|
|
187114
|
-
import
|
|
187115
|
-
import
|
|
187174
|
+
import fs42 from "node:fs";
|
|
187175
|
+
import path42 from "node:path";
|
|
187116
187176
|
var setupGithubActions = (projectDir = process.cwd()) => {
|
|
187117
187177
|
const findGitRoot = (startDir) => {
|
|
187118
|
-
let dir =
|
|
187119
|
-
while (dir !==
|
|
187120
|
-
if (
|
|
187178
|
+
let dir = path42.resolve(startDir);
|
|
187179
|
+
while (dir !== path42.parse(dir).root) {
|
|
187180
|
+
if (fs42.existsSync(path42.join(dir, ".git"))) {
|
|
187121
187181
|
return dir;
|
|
187122
187182
|
}
|
|
187123
|
-
dir =
|
|
187183
|
+
dir = path42.dirname(dir);
|
|
187124
187184
|
}
|
|
187125
187185
|
return null;
|
|
187126
187186
|
};
|
|
187127
187187
|
const gitRoot = findGitRoot(projectDir) ?? projectDir;
|
|
187128
|
-
const workflowsDir =
|
|
187129
|
-
|
|
187188
|
+
const workflowsDir = path42.join(gitRoot, ".github", "workflows");
|
|
187189
|
+
fs42.mkdirSync(workflowsDir, { recursive: true });
|
|
187130
187190
|
const buildWorkflow = `name: tscircuit Build
|
|
187131
187191
|
|
|
187132
187192
|
on:
|
|
@@ -187165,8 +187225,8 @@ jobs:
|
|
|
187165
187225
|
- run: bun install
|
|
187166
187226
|
- run: bunx tsci snapshot
|
|
187167
187227
|
`;
|
|
187168
|
-
writeFileIfNotExists(
|
|
187169
|
-
writeFileIfNotExists(
|
|
187228
|
+
writeFileIfNotExists(path42.join(workflowsDir, "tscircuit-build.yml"), buildWorkflow);
|
|
187229
|
+
writeFileIfNotExists(path42.join(workflowsDir, "tscircuit-snapshot.yml"), snapshotWorkflow);
|
|
187170
187230
|
};
|
|
187171
187231
|
|
|
187172
187232
|
// cli/setup/register.ts
|
|
@@ -187204,8 +187264,8 @@ function registerAuthSetupNpmrc(program3) {
|
|
|
187204
187264
|
}
|
|
187205
187265
|
|
|
187206
187266
|
// cli/convert/register.ts
|
|
187207
|
-
import
|
|
187208
|
-
import
|
|
187267
|
+
import fs43 from "node:fs/promises";
|
|
187268
|
+
import path43 from "node:path";
|
|
187209
187269
|
import { parseKicadModToCircuitJson } from "kicad-component-converter";
|
|
187210
187270
|
|
|
187211
187271
|
// node_modules/@tscircuit/mm/dist/index.js
|
|
@@ -187325,15 +187385,15 @@ var convertCircuitJsonToTscircuit = (circuitJson, opts) => {
|
|
|
187325
187385
|
var registerConvert = (program3) => {
|
|
187326
187386
|
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) => {
|
|
187327
187387
|
try {
|
|
187328
|
-
const inputPath =
|
|
187329
|
-
const modContent = await
|
|
187388
|
+
const inputPath = path43.resolve(file);
|
|
187389
|
+
const modContent = await fs43.readFile(inputPath, "utf-8");
|
|
187330
187390
|
const circuitJson = await parseKicadModToCircuitJson(modContent);
|
|
187331
|
-
const componentName = options.name ??
|
|
187391
|
+
const componentName = options.name ?? path43.basename(inputPath, ".kicad_mod");
|
|
187332
187392
|
const tsx = convertCircuitJsonToTscircuit(circuitJson, {
|
|
187333
187393
|
componentName
|
|
187334
187394
|
});
|
|
187335
|
-
const outputPath = options.output ?
|
|
187336
|
-
await
|
|
187395
|
+
const outputPath = options.output ? path43.resolve(options.output) : path43.join(path43.dirname(inputPath), `${componentName}.tsx`);
|
|
187396
|
+
await fs43.writeFile(outputPath, tsx);
|
|
187337
187397
|
console.log(kleur_default.green(`Converted ${outputPath}`));
|
|
187338
187398
|
} catch (error) {
|
|
187339
187399
|
console.error(kleur_default.red("Failed to convert footprint:"), error instanceof Error ? error.message : error);
|
|
@@ -187429,12 +187489,12 @@ var registerSimulate = (program3) => {
|
|
|
187429
187489
|
};
|
|
187430
187490
|
|
|
187431
187491
|
// lib/shared/install-project-dependencies.ts
|
|
187432
|
-
import
|
|
187433
|
-
import
|
|
187492
|
+
import fs45 from "node:fs";
|
|
187493
|
+
import path45 from "node:path";
|
|
187434
187494
|
|
|
187435
187495
|
// lib/shared/collect-tsci-dependencies.ts
|
|
187436
|
-
import
|
|
187437
|
-
import
|
|
187496
|
+
import fs44 from "node:fs";
|
|
187497
|
+
import path44 from "node:path";
|
|
187438
187498
|
var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
|
|
187439
187499
|
var DEFAULT_IGNORES = [
|
|
187440
187500
|
"**/node_modules/**",
|
|
@@ -187449,7 +187509,7 @@ function collectTsciDependencies({
|
|
|
187449
187509
|
patterns = DEFAULT_PATTERNS,
|
|
187450
187510
|
ignore = DEFAULT_IGNORES
|
|
187451
187511
|
} = {}) {
|
|
187452
|
-
const searchRoot =
|
|
187512
|
+
const searchRoot = path44.resolve(cwd);
|
|
187453
187513
|
const files = globbySync(patterns, {
|
|
187454
187514
|
cwd: searchRoot,
|
|
187455
187515
|
absolute: true,
|
|
@@ -187459,7 +187519,7 @@ function collectTsciDependencies({
|
|
|
187459
187519
|
const dependencies2 = new Set;
|
|
187460
187520
|
for (const filePath of files) {
|
|
187461
187521
|
try {
|
|
187462
|
-
const fileContents =
|
|
187522
|
+
const fileContents = fs44.readFileSync(filePath, "utf-8");
|
|
187463
187523
|
let match;
|
|
187464
187524
|
while (true) {
|
|
187465
187525
|
match = IMPORT_PATTERN.exec(fileContents);
|
|
@@ -187476,26 +187536,26 @@ function collectTsciDependencies({
|
|
|
187476
187536
|
async function installProjectDependencies({
|
|
187477
187537
|
cwd = process.cwd()
|
|
187478
187538
|
} = {}) {
|
|
187479
|
-
const projectRoot =
|
|
187480
|
-
const packageJsonPath =
|
|
187481
|
-
const npmrcPath =
|
|
187539
|
+
const projectRoot = path45.resolve(cwd);
|
|
187540
|
+
const packageJsonPath = path45.join(projectRoot, "package.json");
|
|
187541
|
+
const npmrcPath = path45.join(projectRoot, ".npmrc");
|
|
187482
187542
|
const packageManager = getPackageManager();
|
|
187483
|
-
if (!
|
|
187543
|
+
if (!fs45.existsSync(projectRoot)) {
|
|
187484
187544
|
throw new Error(`Directory not found: ${projectRoot}`);
|
|
187485
187545
|
}
|
|
187486
187546
|
let packageJsonCreated = false;
|
|
187487
|
-
if (!
|
|
187547
|
+
if (!fs45.existsSync(packageJsonPath)) {
|
|
187488
187548
|
console.log("No package.json found. Generating a new one.");
|
|
187489
187549
|
generatePackageJson(projectRoot);
|
|
187490
187550
|
packageJsonCreated = true;
|
|
187491
187551
|
} else {
|
|
187492
187552
|
console.log("Found existing package.json.");
|
|
187493
187553
|
}
|
|
187494
|
-
if (!
|
|
187554
|
+
if (!fs45.existsSync(npmrcPath)) {
|
|
187495
187555
|
console.log("Creating .npmrc with tscircuit registry configuration.");
|
|
187496
|
-
|
|
187556
|
+
fs45.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
|
|
187497
187557
|
}
|
|
187498
|
-
const packageJson = JSON.parse(
|
|
187558
|
+
const packageJson = JSON.parse(fs45.readFileSync(packageJsonPath, "utf-8"));
|
|
187499
187559
|
if (packageJsonCreated) {
|
|
187500
187560
|
const tsciDependencies = collectTsciDependencies({ cwd: projectRoot });
|
|
187501
187561
|
if (tsciDependencies.length > 0) {
|
|
@@ -187510,7 +187570,7 @@ async function installProjectDependencies({
|
|
|
187510
187570
|
console.log("No @tsci dependencies detected in circuit files.");
|
|
187511
187571
|
}
|
|
187512
187572
|
}
|
|
187513
|
-
|
|
187573
|
+
fs45.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
187514
187574
|
`);
|
|
187515
187575
|
console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
|
|
187516
187576
|
try {
|
|
@@ -187519,6 +187579,7 @@ async function installProjectDependencies({
|
|
|
187519
187579
|
} catch (error) {
|
|
187520
187580
|
console.warn("Failed to automatically install dependencies.");
|
|
187521
187581
|
console.warn(`Please run \`${packageManager.getInstallAllCommand()}\` manually.`);
|
|
187582
|
+
handleRegistryAuthError({ error, projectDir: projectRoot });
|
|
187522
187583
|
throw error;
|
|
187523
187584
|
}
|
|
187524
187585
|
}
|
|
@@ -187544,7 +187605,7 @@ var registerInstall = (program3) => {
|
|
|
187544
187605
|
};
|
|
187545
187606
|
|
|
187546
187607
|
// cli/transpile/register.ts
|
|
187547
|
-
import
|
|
187608
|
+
import path46 from "node:path";
|
|
187548
187609
|
var registerTranspile = (program3) => {
|
|
187549
187610
|
program3.command("transpile").description("Transpile TypeScript/TSX to JavaScript (ESM, CommonJS, and type declarations)").argument("[file]", "Path to the entry file").action(async (file) => {
|
|
187550
187611
|
try {
|
|
@@ -187552,7 +187613,7 @@ var registerTranspile = (program3) => {
|
|
|
187552
187613
|
fileOrDir: file,
|
|
187553
187614
|
includeBoardFiles: false
|
|
187554
187615
|
});
|
|
187555
|
-
const distDir =
|
|
187616
|
+
const distDir = path46.join(projectDir, "dist");
|
|
187556
187617
|
validateMainInDist(projectDir, distDir);
|
|
187557
187618
|
console.log("Transpiling entry file...");
|
|
187558
187619
|
const entryFile = mainEntrypoint || circuitFiles[0];
|