@tscircuit/cli 0.1.987 → 0.1.988
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/main.js +890 -832
- package/dist/lib/index.js +367 -237
- package/package.json +2 -2
package/dist/cli/main.js
CHANGED
|
@@ -55042,8 +55042,8 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
55042
55042
|
var result = transform[inputType][outputType](input);
|
|
55043
55043
|
return result;
|
|
55044
55044
|
};
|
|
55045
|
-
exports2.resolve = function(
|
|
55046
|
-
var parts =
|
|
55045
|
+
exports2.resolve = function(path17) {
|
|
55046
|
+
var parts = path17.split("/");
|
|
55047
55047
|
var result = [];
|
|
55048
55048
|
for (var index = 0;index < parts.length; index++) {
|
|
55049
55049
|
var part = parts[index];
|
|
@@ -60493,18 +60493,18 @@ var require_object = __commonJS((exports2, module2) => {
|
|
|
60493
60493
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
60494
60494
|
this.files[name] = object;
|
|
60495
60495
|
};
|
|
60496
|
-
var parentFolder = function(
|
|
60497
|
-
if (
|
|
60498
|
-
|
|
60496
|
+
var parentFolder = function(path17) {
|
|
60497
|
+
if (path17.slice(-1) === "/") {
|
|
60498
|
+
path17 = path17.substring(0, path17.length - 1);
|
|
60499
60499
|
}
|
|
60500
|
-
var lastSlash =
|
|
60501
|
-
return lastSlash > 0 ?
|
|
60500
|
+
var lastSlash = path17.lastIndexOf("/");
|
|
60501
|
+
return lastSlash > 0 ? path17.substring(0, lastSlash) : "";
|
|
60502
60502
|
};
|
|
60503
|
-
var forceTrailingSlash = function(
|
|
60504
|
-
if (
|
|
60505
|
-
|
|
60503
|
+
var forceTrailingSlash = function(path17) {
|
|
60504
|
+
if (path17.slice(-1) !== "/") {
|
|
60505
|
+
path17 += "/";
|
|
60506
60506
|
}
|
|
60507
|
-
return
|
|
60507
|
+
return path17;
|
|
60508
60508
|
};
|
|
60509
60509
|
var folderAdd = function(name, createFolders) {
|
|
60510
60510
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -61335,7 +61335,7 @@ var require_path = __commonJS((exports2) => {
|
|
|
61335
61335
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
61336
61336
|
exports2.convertPosixPathToPattern = exports2.convertWindowsPathToPattern = exports2.convertPathToPattern = exports2.escapePosixPath = exports2.escapeWindowsPath = exports2.escape = exports2.removeLeadingDotSegment = exports2.makeAbsolute = exports2.unixify = undefined;
|
|
61337
61337
|
var os4 = __require("os");
|
|
61338
|
-
var
|
|
61338
|
+
var path20 = __require("path");
|
|
61339
61339
|
var IS_WINDOWS_PLATFORM = os4.platform() === "win32";
|
|
61340
61340
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
61341
61341
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -61347,7 +61347,7 @@ var require_path = __commonJS((exports2) => {
|
|
|
61347
61347
|
}
|
|
61348
61348
|
exports2.unixify = unixify;
|
|
61349
61349
|
function makeAbsolute(cwd, filepath) {
|
|
61350
|
-
return
|
|
61350
|
+
return path20.resolve(cwd, filepath);
|
|
61351
61351
|
}
|
|
61352
61352
|
exports2.makeAbsolute = makeAbsolute;
|
|
61353
61353
|
function removeLeadingDotSegment(entry) {
|
|
@@ -62605,7 +62605,7 @@ var require_braces = __commonJS((exports2, module2) => {
|
|
|
62605
62605
|
|
|
62606
62606
|
// node_modules/micromatch/node_modules/picomatch/lib/constants.js
|
|
62607
62607
|
var require_constants4 = __commonJS((exports2, module2) => {
|
|
62608
|
-
var
|
|
62608
|
+
var path20 = __require("path");
|
|
62609
62609
|
var WIN_SLASH = "\\\\/";
|
|
62610
62610
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
62611
62611
|
var DOT_LITERAL = "\\.";
|
|
@@ -62727,7 +62727,7 @@ var require_constants4 = __commonJS((exports2, module2) => {
|
|
|
62727
62727
|
CHAR_UNDERSCORE: 95,
|
|
62728
62728
|
CHAR_VERTICAL_LINE: 124,
|
|
62729
62729
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
62730
|
-
SEP:
|
|
62730
|
+
SEP: path20.sep,
|
|
62731
62731
|
extglobChars(chars) {
|
|
62732
62732
|
return {
|
|
62733
62733
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -62745,7 +62745,7 @@ var require_constants4 = __commonJS((exports2, module2) => {
|
|
|
62745
62745
|
|
|
62746
62746
|
// node_modules/micromatch/node_modules/picomatch/lib/utils.js
|
|
62747
62747
|
var require_utils4 = __commonJS((exports2) => {
|
|
62748
|
-
var
|
|
62748
|
+
var path20 = __require("path");
|
|
62749
62749
|
var win32 = process.platform === "win32";
|
|
62750
62750
|
var {
|
|
62751
62751
|
REGEX_BACKSLASH,
|
|
@@ -62774,7 +62774,7 @@ var require_utils4 = __commonJS((exports2) => {
|
|
|
62774
62774
|
if (options && typeof options.windows === "boolean") {
|
|
62775
62775
|
return options.windows;
|
|
62776
62776
|
}
|
|
62777
|
-
return win32 === true ||
|
|
62777
|
+
return win32 === true || path20.sep === "\\";
|
|
62778
62778
|
};
|
|
62779
62779
|
exports2.escapeLast = (input, char, lastIdx) => {
|
|
62780
62780
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -63898,7 +63898,7 @@ var require_parse3 = __commonJS((exports2, module2) => {
|
|
|
63898
63898
|
|
|
63899
63899
|
// node_modules/micromatch/node_modules/picomatch/lib/picomatch.js
|
|
63900
63900
|
var require_picomatch = __commonJS((exports2, module2) => {
|
|
63901
|
-
var
|
|
63901
|
+
var path20 = __require("path");
|
|
63902
63902
|
var scan = require_scan();
|
|
63903
63903
|
var parse = require_parse3();
|
|
63904
63904
|
var utils = require_utils4();
|
|
@@ -63984,7 +63984,7 @@ var require_picomatch = __commonJS((exports2, module2) => {
|
|
|
63984
63984
|
};
|
|
63985
63985
|
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
63986
63986
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
63987
|
-
return regex.test(
|
|
63987
|
+
return regex.test(path20.basename(input));
|
|
63988
63988
|
};
|
|
63989
63989
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
63990
63990
|
picomatch.parse = (pattern, options) => {
|
|
@@ -64205,7 +64205,7 @@ var require_micromatch = __commonJS((exports2, module2) => {
|
|
|
64205
64205
|
var require_pattern2 = __commonJS((exports2) => {
|
|
64206
64206
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64207
64207
|
exports2.isAbsolute = exports2.partitionAbsoluteAndRelative = exports2.removeDuplicateSlashes = exports2.matchAny = exports2.convertPatternsToRe = exports2.makeRe = exports2.getPatternParts = exports2.expandBraceExpansion = exports2.expandPatternsWithBraceExpansion = exports2.isAffectDepthOfReadingPattern = exports2.endsWithSlashGlobStar = exports2.hasGlobStar = exports2.getBaseDirectory = exports2.isPatternRelatedToParentDirectory = exports2.getPatternsOutsideCurrentDirectory = exports2.getPatternsInsideCurrentDirectory = exports2.getPositivePatterns = exports2.getNegativePatterns = exports2.isPositivePattern = exports2.isNegativePattern = exports2.convertToNegativePattern = exports2.convertToPositivePattern = exports2.isDynamicPattern = exports2.isStaticPattern = undefined;
|
|
64208
|
-
var
|
|
64208
|
+
var path20 = __require("path");
|
|
64209
64209
|
var globParent = require_glob_parent();
|
|
64210
64210
|
var micromatch = require_micromatch();
|
|
64211
64211
|
var GLOBSTAR = "**";
|
|
@@ -64300,7 +64300,7 @@ var require_pattern2 = __commonJS((exports2) => {
|
|
|
64300
64300
|
}
|
|
64301
64301
|
exports2.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
64302
64302
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
64303
|
-
const basename3 =
|
|
64303
|
+
const basename3 = path20.basename(pattern);
|
|
64304
64304
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename3);
|
|
64305
64305
|
}
|
|
64306
64306
|
exports2.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -64358,7 +64358,7 @@ var require_pattern2 = __commonJS((exports2) => {
|
|
|
64358
64358
|
}
|
|
64359
64359
|
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
64360
64360
|
function isAbsolute(pattern) {
|
|
64361
|
-
return
|
|
64361
|
+
return path20.isAbsolute(pattern);
|
|
64362
64362
|
}
|
|
64363
64363
|
exports2.isAbsolute = isAbsolute;
|
|
64364
64364
|
});
|
|
@@ -64521,10 +64521,10 @@ var require_utils5 = __commonJS((exports2) => {
|
|
|
64521
64521
|
exports2.array = array;
|
|
64522
64522
|
var errno = require_errno();
|
|
64523
64523
|
exports2.errno = errno;
|
|
64524
|
-
var
|
|
64525
|
-
exports2.fs =
|
|
64526
|
-
var
|
|
64527
|
-
exports2.path =
|
|
64524
|
+
var fs17 = require_fs();
|
|
64525
|
+
exports2.fs = fs17;
|
|
64526
|
+
var path20 = require_path();
|
|
64527
|
+
exports2.path = path20;
|
|
64528
64528
|
var pattern = require_pattern2();
|
|
64529
64529
|
exports2.pattern = pattern;
|
|
64530
64530
|
var stream = require_stream();
|
|
@@ -64620,8 +64620,8 @@ var require_tasks = __commonJS((exports2) => {
|
|
|
64620
64620
|
var require_async = __commonJS((exports2) => {
|
|
64621
64621
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64622
64622
|
exports2.read = undefined;
|
|
64623
|
-
function read(
|
|
64624
|
-
settings.fs.lstat(
|
|
64623
|
+
function read(path20, settings, callback) {
|
|
64624
|
+
settings.fs.lstat(path20, (lstatError, lstat) => {
|
|
64625
64625
|
if (lstatError !== null) {
|
|
64626
64626
|
callFailureCallback(callback, lstatError);
|
|
64627
64627
|
return;
|
|
@@ -64630,7 +64630,7 @@ var require_async = __commonJS((exports2) => {
|
|
|
64630
64630
|
callSuccessCallback(callback, lstat);
|
|
64631
64631
|
return;
|
|
64632
64632
|
}
|
|
64633
|
-
settings.fs.stat(
|
|
64633
|
+
settings.fs.stat(path20, (statError, stat) => {
|
|
64634
64634
|
if (statError !== null) {
|
|
64635
64635
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
64636
64636
|
callFailureCallback(callback, statError);
|
|
@@ -64659,13 +64659,13 @@ var require_async = __commonJS((exports2) => {
|
|
|
64659
64659
|
var require_sync = __commonJS((exports2) => {
|
|
64660
64660
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64661
64661
|
exports2.read = undefined;
|
|
64662
|
-
function read(
|
|
64663
|
-
const lstat = settings.fs.lstatSync(
|
|
64662
|
+
function read(path20, settings) {
|
|
64663
|
+
const lstat = settings.fs.lstatSync(path20);
|
|
64664
64664
|
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
|
64665
64665
|
return lstat;
|
|
64666
64666
|
}
|
|
64667
64667
|
try {
|
|
64668
|
-
const stat = settings.fs.statSync(
|
|
64668
|
+
const stat = settings.fs.statSync(path20);
|
|
64669
64669
|
if (settings.markSymbolicLink) {
|
|
64670
64670
|
stat.isSymbolicLink = () => true;
|
|
64671
64671
|
}
|
|
@@ -64684,12 +64684,12 @@ var require_sync = __commonJS((exports2) => {
|
|
|
64684
64684
|
var require_fs2 = __commonJS((exports2) => {
|
|
64685
64685
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64686
64686
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = undefined;
|
|
64687
|
-
var
|
|
64687
|
+
var fs17 = __require("fs");
|
|
64688
64688
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
64689
|
-
lstat:
|
|
64690
|
-
stat:
|
|
64691
|
-
lstatSync:
|
|
64692
|
-
statSync:
|
|
64689
|
+
lstat: fs17.lstat,
|
|
64690
|
+
stat: fs17.stat,
|
|
64691
|
+
lstatSync: fs17.lstatSync,
|
|
64692
|
+
statSync: fs17.statSync
|
|
64693
64693
|
};
|
|
64694
64694
|
function createFileSystemAdapter(fsMethods) {
|
|
64695
64695
|
if (fsMethods === undefined) {
|
|
@@ -64703,13 +64703,13 @@ var require_fs2 = __commonJS((exports2) => {
|
|
|
64703
64703
|
// node_modules/@nodelib/fs.stat/out/settings.js
|
|
64704
64704
|
var require_settings = __commonJS((exports2) => {
|
|
64705
64705
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64706
|
-
var
|
|
64706
|
+
var fs17 = require_fs2();
|
|
64707
64707
|
|
|
64708
64708
|
class Settings {
|
|
64709
64709
|
constructor(_options = {}) {
|
|
64710
64710
|
this._options = _options;
|
|
64711
64711
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
64712
|
-
this.fs =
|
|
64712
|
+
this.fs = fs17.createFileSystemAdapter(this._options.fs);
|
|
64713
64713
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
64714
64714
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
64715
64715
|
}
|
|
@@ -64728,17 +64728,17 @@ var require_out = __commonJS((exports2) => {
|
|
|
64728
64728
|
var sync = require_sync();
|
|
64729
64729
|
var settings_1 = require_settings();
|
|
64730
64730
|
exports2.Settings = settings_1.default;
|
|
64731
|
-
function stat(
|
|
64731
|
+
function stat(path20, optionsOrSettingsOrCallback, callback) {
|
|
64732
64732
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
64733
|
-
async.read(
|
|
64733
|
+
async.read(path20, getSettings(), optionsOrSettingsOrCallback);
|
|
64734
64734
|
return;
|
|
64735
64735
|
}
|
|
64736
|
-
async.read(
|
|
64736
|
+
async.read(path20, getSettings(optionsOrSettingsOrCallback), callback);
|
|
64737
64737
|
}
|
|
64738
64738
|
exports2.stat = stat;
|
|
64739
|
-
function statSync(
|
|
64739
|
+
function statSync(path20, optionsOrSettings) {
|
|
64740
64740
|
const settings = getSettings(optionsOrSettings);
|
|
64741
|
-
return sync.read(
|
|
64741
|
+
return sync.read(path20, settings);
|
|
64742
64742
|
}
|
|
64743
64743
|
exports2.statSync = statSync;
|
|
64744
64744
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -64854,8 +64854,8 @@ var require_fs3 = __commonJS((exports2) => {
|
|
|
64854
64854
|
var require_utils6 = __commonJS((exports2) => {
|
|
64855
64855
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
64856
64856
|
exports2.fs = undefined;
|
|
64857
|
-
var
|
|
64858
|
-
exports2.fs =
|
|
64857
|
+
var fs17 = require_fs3();
|
|
64858
|
+
exports2.fs = fs17;
|
|
64859
64859
|
});
|
|
64860
64860
|
|
|
64861
64861
|
// node_modules/@nodelib/fs.scandir/out/providers/common.js
|
|
@@ -64941,16 +64941,16 @@ var require_async2 = __commonJS((exports2) => {
|
|
|
64941
64941
|
return;
|
|
64942
64942
|
}
|
|
64943
64943
|
const tasks = names.map((name) => {
|
|
64944
|
-
const
|
|
64944
|
+
const path20 = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
|
64945
64945
|
return (done) => {
|
|
64946
|
-
fsStat.stat(
|
|
64946
|
+
fsStat.stat(path20, settings.fsStatSettings, (error, stats) => {
|
|
64947
64947
|
if (error !== null) {
|
|
64948
64948
|
done(error);
|
|
64949
64949
|
return;
|
|
64950
64950
|
}
|
|
64951
64951
|
const entry = {
|
|
64952
64952
|
name,
|
|
64953
|
-
path:
|
|
64953
|
+
path: path20,
|
|
64954
64954
|
dirent: utils.fs.createDirentFromStats(name, stats)
|
|
64955
64955
|
};
|
|
64956
64956
|
if (settings.stats) {
|
|
@@ -65038,14 +65038,14 @@ var require_sync2 = __commonJS((exports2) => {
|
|
|
65038
65038
|
var require_fs4 = __commonJS((exports2) => {
|
|
65039
65039
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65040
65040
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = undefined;
|
|
65041
|
-
var
|
|
65041
|
+
var fs17 = __require("fs");
|
|
65042
65042
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
65043
|
-
lstat:
|
|
65044
|
-
stat:
|
|
65045
|
-
lstatSync:
|
|
65046
|
-
statSync:
|
|
65047
|
-
readdir:
|
|
65048
|
-
readdirSync:
|
|
65043
|
+
lstat: fs17.lstat,
|
|
65044
|
+
stat: fs17.stat,
|
|
65045
|
+
lstatSync: fs17.lstatSync,
|
|
65046
|
+
statSync: fs17.statSync,
|
|
65047
|
+
readdir: fs17.readdir,
|
|
65048
|
+
readdirSync: fs17.readdirSync
|
|
65049
65049
|
};
|
|
65050
65050
|
function createFileSystemAdapter(fsMethods) {
|
|
65051
65051
|
if (fsMethods === undefined) {
|
|
@@ -65059,16 +65059,16 @@ var require_fs4 = __commonJS((exports2) => {
|
|
|
65059
65059
|
// node_modules/@nodelib/fs.scandir/out/settings.js
|
|
65060
65060
|
var require_settings2 = __commonJS((exports2) => {
|
|
65061
65061
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65062
|
-
var
|
|
65062
|
+
var path20 = __require("path");
|
|
65063
65063
|
var fsStat = require_out();
|
|
65064
|
-
var
|
|
65064
|
+
var fs17 = require_fs4();
|
|
65065
65065
|
|
|
65066
65066
|
class Settings {
|
|
65067
65067
|
constructor(_options = {}) {
|
|
65068
65068
|
this._options = _options;
|
|
65069
65069
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
65070
|
-
this.fs =
|
|
65071
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
65070
|
+
this.fs = fs17.createFileSystemAdapter(this._options.fs);
|
|
65071
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path20.sep);
|
|
65072
65072
|
this.stats = this._getValue(this._options.stats, false);
|
|
65073
65073
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
65074
65074
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -65092,17 +65092,17 @@ var require_out2 = __commonJS((exports2) => {
|
|
|
65092
65092
|
var sync = require_sync2();
|
|
65093
65093
|
var settings_1 = require_settings2();
|
|
65094
65094
|
exports2.Settings = settings_1.default;
|
|
65095
|
-
function scandir(
|
|
65095
|
+
function scandir(path20, optionsOrSettingsOrCallback, callback) {
|
|
65096
65096
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
65097
|
-
async.read(
|
|
65097
|
+
async.read(path20, getSettings(), optionsOrSettingsOrCallback);
|
|
65098
65098
|
return;
|
|
65099
65099
|
}
|
|
65100
|
-
async.read(
|
|
65100
|
+
async.read(path20, getSettings(optionsOrSettingsOrCallback), callback);
|
|
65101
65101
|
}
|
|
65102
65102
|
exports2.scandir = scandir;
|
|
65103
|
-
function scandirSync(
|
|
65103
|
+
function scandirSync(path20, optionsOrSettings) {
|
|
65104
65104
|
const settings = getSettings(optionsOrSettings);
|
|
65105
|
-
return sync.read(
|
|
65105
|
+
return sync.read(path20, settings);
|
|
65106
65106
|
}
|
|
65107
65107
|
exports2.scandirSync = scandirSync;
|
|
65108
65108
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -65726,7 +65726,7 @@ var require_sync4 = __commonJS((exports2) => {
|
|
|
65726
65726
|
// node_modules/@nodelib/fs.walk/out/settings.js
|
|
65727
65727
|
var require_settings3 = __commonJS((exports2) => {
|
|
65728
65728
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65729
|
-
var
|
|
65729
|
+
var path20 = __require("path");
|
|
65730
65730
|
var fsScandir = require_out2();
|
|
65731
65731
|
|
|
65732
65732
|
class Settings {
|
|
@@ -65737,7 +65737,7 @@ var require_settings3 = __commonJS((exports2) => {
|
|
|
65737
65737
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
65738
65738
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
65739
65739
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
65740
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
65740
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path20.sep);
|
|
65741
65741
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
65742
65742
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
65743
65743
|
fs: this._options.fs,
|
|
@@ -65793,7 +65793,7 @@ var require_out3 = __commonJS((exports2) => {
|
|
|
65793
65793
|
// node_modules/fast-glob/out/readers/reader.js
|
|
65794
65794
|
var require_reader2 = __commonJS((exports2) => {
|
|
65795
65795
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
65796
|
-
var
|
|
65796
|
+
var path20 = __require("path");
|
|
65797
65797
|
var fsStat = require_out();
|
|
65798
65798
|
var utils = require_utils5();
|
|
65799
65799
|
|
|
@@ -65807,7 +65807,7 @@ var require_reader2 = __commonJS((exports2) => {
|
|
|
65807
65807
|
});
|
|
65808
65808
|
}
|
|
65809
65809
|
_getFullEntryPath(filepath) {
|
|
65810
|
-
return
|
|
65810
|
+
return path20.resolve(this._settings.cwd, filepath);
|
|
65811
65811
|
}
|
|
65812
65812
|
_makeEntry(stats, pattern) {
|
|
65813
65813
|
const entry = {
|
|
@@ -66204,7 +66204,7 @@ var require_entry2 = __commonJS((exports2) => {
|
|
|
66204
66204
|
// node_modules/fast-glob/out/providers/provider.js
|
|
66205
66205
|
var require_provider = __commonJS((exports2) => {
|
|
66206
66206
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66207
|
-
var
|
|
66207
|
+
var path20 = __require("path");
|
|
66208
66208
|
var deep_1 = require_deep();
|
|
66209
66209
|
var entry_1 = require_entry();
|
|
66210
66210
|
var error_1 = require_error2();
|
|
@@ -66219,7 +66219,7 @@ var require_provider = __commonJS((exports2) => {
|
|
|
66219
66219
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
66220
66220
|
}
|
|
66221
66221
|
_getRootDirectory(task) {
|
|
66222
|
-
return
|
|
66222
|
+
return path20.resolve(this._settings.cwd, task.base);
|
|
66223
66223
|
}
|
|
66224
66224
|
_getReaderOptions(task) {
|
|
66225
66225
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -66388,16 +66388,16 @@ var require_sync6 = __commonJS((exports2) => {
|
|
|
66388
66388
|
var require_settings4 = __commonJS((exports2) => {
|
|
66389
66389
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
66390
66390
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
|
|
66391
|
-
var
|
|
66391
|
+
var fs17 = __require("fs");
|
|
66392
66392
|
var os4 = __require("os");
|
|
66393
66393
|
var CPU_COUNT = Math.max(os4.cpus().length, 1);
|
|
66394
66394
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
66395
|
-
lstat:
|
|
66396
|
-
lstatSync:
|
|
66397
|
-
stat:
|
|
66398
|
-
statSync:
|
|
66399
|
-
readdir:
|
|
66400
|
-
readdirSync:
|
|
66395
|
+
lstat: fs17.lstat,
|
|
66396
|
+
lstatSync: fs17.lstatSync,
|
|
66397
|
+
stat: fs17.stat,
|
|
66398
|
+
statSync: fs17.statSync,
|
|
66399
|
+
readdir: fs17.readdir,
|
|
66400
|
+
readdirSync: fs17.readdirSync
|
|
66401
66401
|
};
|
|
66402
66402
|
|
|
66403
66403
|
class Settings {
|
|
@@ -66733,7 +66733,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
66733
66733
|
makeArray(isString2(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
66734
66734
|
return this._added;
|
|
66735
66735
|
}
|
|
66736
|
-
test(
|
|
66736
|
+
test(path20, checkUnignored, mode) {
|
|
66737
66737
|
let ignored = false;
|
|
66738
66738
|
let unignored = false;
|
|
66739
66739
|
let matchedRule;
|
|
@@ -66742,7 +66742,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
66742
66742
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
66743
66743
|
return;
|
|
66744
66744
|
}
|
|
66745
|
-
const matched = rule[mode].test(
|
|
66745
|
+
const matched = rule[mode].test(path20);
|
|
66746
66746
|
if (!matched) {
|
|
66747
66747
|
return;
|
|
66748
66748
|
}
|
|
@@ -66763,20 +66763,20 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
66763
66763
|
var throwError = (message, Ctor) => {
|
|
66764
66764
|
throw new Ctor(message);
|
|
66765
66765
|
};
|
|
66766
|
-
var checkPath = (
|
|
66767
|
-
if (!isString2(
|
|
66766
|
+
var checkPath = (path20, originalPath, doThrow) => {
|
|
66767
|
+
if (!isString2(path20)) {
|
|
66768
66768
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
66769
66769
|
}
|
|
66770
|
-
if (!
|
|
66770
|
+
if (!path20) {
|
|
66771
66771
|
return doThrow(`path must not be empty`, TypeError);
|
|
66772
66772
|
}
|
|
66773
|
-
if (checkPath.isNotRelative(
|
|
66773
|
+
if (checkPath.isNotRelative(path20)) {
|
|
66774
66774
|
const r = "`path.relative()`d";
|
|
66775
66775
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
66776
66776
|
}
|
|
66777
66777
|
return true;
|
|
66778
66778
|
};
|
|
66779
|
-
var isNotRelative = (
|
|
66779
|
+
var isNotRelative = (path20) => REGEX_TEST_INVALID_PATH.test(path20);
|
|
66780
66780
|
checkPath.isNotRelative = isNotRelative;
|
|
66781
66781
|
checkPath.convert = (p) => p;
|
|
66782
66782
|
|
|
@@ -66805,15 +66805,15 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
66805
66805
|
return this.add(pattern);
|
|
66806
66806
|
}
|
|
66807
66807
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
66808
|
-
const
|
|
66809
|
-
checkPath(
|
|
66810
|
-
return this._t(
|
|
66808
|
+
const path20 = originalPath && checkPath.convert(originalPath);
|
|
66809
|
+
checkPath(path20, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
66810
|
+
return this._t(path20, cache, checkUnignored, slices);
|
|
66811
66811
|
}
|
|
66812
|
-
checkIgnore(
|
|
66813
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
66814
|
-
return this.test(
|
|
66812
|
+
checkIgnore(path20) {
|
|
66813
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path20)) {
|
|
66814
|
+
return this.test(path20);
|
|
66815
66815
|
}
|
|
66816
|
-
const slices =
|
|
66816
|
+
const slices = path20.split(SLASH).filter(Boolean);
|
|
66817
66817
|
slices.pop();
|
|
66818
66818
|
if (slices.length) {
|
|
66819
66819
|
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
@@ -66821,42 +66821,42 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
66821
66821
|
return parent;
|
|
66822
66822
|
}
|
|
66823
66823
|
}
|
|
66824
|
-
return this._rules.test(
|
|
66824
|
+
return this._rules.test(path20, false, MODE_CHECK_IGNORE);
|
|
66825
66825
|
}
|
|
66826
|
-
_t(
|
|
66827
|
-
if (
|
|
66828
|
-
return cache[
|
|
66826
|
+
_t(path20, cache, checkUnignored, slices) {
|
|
66827
|
+
if (path20 in cache) {
|
|
66828
|
+
return cache[path20];
|
|
66829
66829
|
}
|
|
66830
66830
|
if (!slices) {
|
|
66831
|
-
slices =
|
|
66831
|
+
slices = path20.split(SLASH).filter(Boolean);
|
|
66832
66832
|
}
|
|
66833
66833
|
slices.pop();
|
|
66834
66834
|
if (!slices.length) {
|
|
66835
|
-
return cache[
|
|
66835
|
+
return cache[path20] = this._rules.test(path20, checkUnignored, MODE_IGNORE);
|
|
66836
66836
|
}
|
|
66837
66837
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
66838
|
-
return cache[
|
|
66838
|
+
return cache[path20] = parent.ignored ? parent : this._rules.test(path20, checkUnignored, MODE_IGNORE);
|
|
66839
66839
|
}
|
|
66840
|
-
ignores(
|
|
66841
|
-
return this._test(
|
|
66840
|
+
ignores(path20) {
|
|
66841
|
+
return this._test(path20, this._ignoreCache, false).ignored;
|
|
66842
66842
|
}
|
|
66843
66843
|
createFilter() {
|
|
66844
|
-
return (
|
|
66844
|
+
return (path20) => !this.ignores(path20);
|
|
66845
66845
|
}
|
|
66846
66846
|
filter(paths) {
|
|
66847
66847
|
return makeArray(paths).filter(this.createFilter());
|
|
66848
66848
|
}
|
|
66849
|
-
test(
|
|
66850
|
-
return this._test(
|
|
66849
|
+
test(path20) {
|
|
66850
|
+
return this._test(path20, this._testCache, true);
|
|
66851
66851
|
}
|
|
66852
66852
|
}
|
|
66853
66853
|
var factory = (options) => new Ignore(options);
|
|
66854
|
-
var isPathValid = (
|
|
66854
|
+
var isPathValid = (path20) => checkPath(path20 && checkPath.convert(path20), path20, RETURN_FALSE);
|
|
66855
66855
|
var setupWindows = () => {
|
|
66856
66856
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
66857
66857
|
checkPath.convert = makePosix;
|
|
66858
66858
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
66859
|
-
checkPath.isNotRelative = (
|
|
66859
|
+
checkPath.isNotRelative = (path20) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path20) || isNotRelative(path20);
|
|
66860
66860
|
};
|
|
66861
66861
|
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
66862
66862
|
setupWindows();
|
|
@@ -67243,7 +67243,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67243
67243
|
});
|
|
67244
67244
|
};
|
|
67245
67245
|
traverse(program3, []);
|
|
67246
|
-
return allCommandPaths.filter((
|
|
67246
|
+
return allCommandPaths.filter((path37) => path37 !== "");
|
|
67247
67247
|
};
|
|
67248
67248
|
var normalizeCommandName = (s) => s.replace(/_/g, "-").toLowerCase();
|
|
67249
67249
|
var getCommandFromPath = (program3, commandPathAndPositionalArgs) => {
|
|
@@ -67251,7 +67251,7 @@ var require_dist7 = __commonJS((exports2, module2) => {
|
|
|
67251
67251
|
return commandPath.reduce((curr, nextCommandName) => !curr ? null : curr.commands.find((c) => normalizeCommandName(c.name()) === normalizeCommandName(nextCommandName)), program3);
|
|
67252
67252
|
};
|
|
67253
67253
|
var getCommandPathOnly = (program3, commandPathAndPositionalArgs) => {
|
|
67254
|
-
const allLeafCommandPaths = getAllLeafCommandPaths(program3).map((
|
|
67254
|
+
const allLeafCommandPaths = getAllLeafCommandPaths(program3).map((path37) => normalizeCommandName(path37));
|
|
67255
67255
|
const commandPath = [];
|
|
67256
67256
|
for (const elm of commandPathAndPositionalArgs) {
|
|
67257
67257
|
if (elm.startsWith("-"))
|
|
@@ -68771,18 +68771,18 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
68771
68771
|
abs = abs.replace(/\\/g, "/");
|
|
68772
68772
|
return abs;
|
|
68773
68773
|
}
|
|
68774
|
-
function isIgnored(self2,
|
|
68774
|
+
function isIgnored(self2, path37) {
|
|
68775
68775
|
if (!self2.ignore.length)
|
|
68776
68776
|
return false;
|
|
68777
68777
|
return self2.ignore.some(function(item) {
|
|
68778
|
-
return item.matcher.match(
|
|
68778
|
+
return item.matcher.match(path37) || !!(item.gmatcher && item.gmatcher.match(path37));
|
|
68779
68779
|
});
|
|
68780
68780
|
}
|
|
68781
|
-
function childrenIgnored(self2,
|
|
68781
|
+
function childrenIgnored(self2, path37) {
|
|
68782
68782
|
if (!self2.ignore.length)
|
|
68783
68783
|
return false;
|
|
68784
68784
|
return self2.ignore.some(function(item) {
|
|
68785
|
-
return !!(item.gmatcher && item.gmatcher.match(
|
|
68785
|
+
return !!(item.gmatcher && item.gmatcher.match(path37));
|
|
68786
68786
|
});
|
|
68787
68787
|
}
|
|
68788
68788
|
}
|
|
@@ -74413,7 +74413,7 @@ var getGlobalDepsInstallCommand = (packageManager, deps) => {
|
|
|
74413
74413
|
import { execSync as execSync2 } from "node:child_process";
|
|
74414
74414
|
var import_semver2 = __toESM2(require_semver2(), 1);
|
|
74415
74415
|
// package.json
|
|
74416
|
-
var version = "0.1.
|
|
74416
|
+
var version = "0.1.987";
|
|
74417
74417
|
var package_default = {
|
|
74418
74418
|
name: "@tscircuit/cli",
|
|
74419
74419
|
main: "dist/cli/main.js",
|
|
@@ -74442,7 +74442,7 @@ var package_default = {
|
|
|
74442
74442
|
"@types/semver": "^7.5.8",
|
|
74443
74443
|
"bun-match-svg": "^0.0.12",
|
|
74444
74444
|
chokidar: "4.0.1",
|
|
74445
|
-
"circuit-json-to-kicad": "^0.0.
|
|
74445
|
+
"circuit-json-to-kicad": "^0.0.81",
|
|
74446
74446
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
74447
74447
|
"circuit-json-to-spice": "^0.0.10",
|
|
74448
74448
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -74720,13 +74720,13 @@ export default () => (
|
|
|
74720
74720
|
};
|
|
74721
74721
|
|
|
74722
74722
|
// cli/dev/register.ts
|
|
74723
|
-
import * as
|
|
74723
|
+
import * as fs30 from "node:fs";
|
|
74724
74724
|
import * as net from "node:net";
|
|
74725
|
-
import * as
|
|
74725
|
+
import * as path32 from "node:path";
|
|
74726
74726
|
|
|
74727
74727
|
// lib/server/createHttpServer.ts
|
|
74728
74728
|
import * as http from "node:http";
|
|
74729
|
-
import * as
|
|
74729
|
+
import * as fs21 from "node:fs";
|
|
74730
74730
|
|
|
74731
74731
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
74732
74732
|
var import_node_utils = __toESM2(require_dist3(), 1);
|
|
@@ -76291,16 +76291,16 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
76291
76291
|
};
|
|
76292
76292
|
|
|
76293
76293
|
// lib/server/kicad-pcm-proxy.ts
|
|
76294
|
-
import * as
|
|
76295
|
-
import * as
|
|
76294
|
+
import * as fs20 from "node:fs";
|
|
76295
|
+
import * as path21 from "node:path";
|
|
76296
76296
|
|
|
76297
76297
|
// cli/build/build-kicad-pcm.ts
|
|
76298
|
-
import
|
|
76299
|
-
import
|
|
76298
|
+
import path19 from "node:path";
|
|
76299
|
+
import fs16 from "node:fs";
|
|
76300
76300
|
|
|
76301
76301
|
// lib/shared/convert-to-kicad-library.tsx
|
|
76302
|
-
import
|
|
76303
|
-
import
|
|
76302
|
+
import fs13 from "node:fs";
|
|
76303
|
+
import path16 from "node:path";
|
|
76304
76304
|
import { pathToFileURL } from "node:url";
|
|
76305
76305
|
|
|
76306
76306
|
// node_modules/circuit-json-to-kicad/dist/index.js
|
|
@@ -79584,6 +79584,7 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
79584
79584
|
return this.ctx.libraryOutput;
|
|
79585
79585
|
}
|
|
79586
79586
|
};
|
|
79587
|
+
var MODEL_CDN_BASE_URL = "https://modelcdn.tscircuit.com/jscad_models";
|
|
79587
79588
|
var KICAD_FP_VERSION = 20240108;
|
|
79588
79589
|
var KICAD_FP_GENERATOR = "pcbnew";
|
|
79589
79590
|
var KICAD_FP_GENERATOR_VERSION = "8.0";
|
|
@@ -79592,24 +79593,27 @@ function getBasename(filePath) {
|
|
|
79592
79593
|
return parts[parts.length - 1] || filePath;
|
|
79593
79594
|
}
|
|
79594
79595
|
var ExtractFootprintsStage = class extends ConverterStage {
|
|
79595
|
-
|
|
79596
|
-
const
|
|
79596
|
+
classifyFootprints() {
|
|
79597
|
+
const customFootprintNames = /* @__PURE__ */ new Set;
|
|
79598
|
+
const footprinterStrings = /* @__PURE__ */ new Map;
|
|
79597
79599
|
const cadComponents = this.ctx.db.cad_component?.list() ?? [];
|
|
79598
79600
|
const sourceComponents = this.ctx.db.source_component;
|
|
79599
79601
|
for (const cadComponent of cadComponents) {
|
|
79600
|
-
|
|
79601
|
-
|
|
79602
|
-
|
|
79603
|
-
|
|
79604
|
-
|
|
79605
|
-
|
|
79606
|
-
|
|
79607
|
-
|
|
79608
|
-
|
|
79602
|
+
const sourceComp = cadComponent.source_component_id ? sourceComponents?.get(cadComponent.source_component_id) : null;
|
|
79603
|
+
if (!sourceComp)
|
|
79604
|
+
continue;
|
|
79605
|
+
const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
79606
|
+
if (cadComponent.footprinter_string) {
|
|
79607
|
+
footprinterStrings.set(footprintName, cadComponent.footprinter_string);
|
|
79608
|
+
} else {
|
|
79609
|
+
customFootprintNames.add(footprintName);
|
|
79610
|
+
const pcbComp = this.ctx.circuitJson.find((el) => el.type === "pcb_component" && el.source_component_id === cadComponent.source_component_id);
|
|
79611
|
+
if (pcbComp && pcbComp.type === "pcb_component" && pcbComp.metadata?.kicad_footprint?.footprintName) {
|
|
79612
|
+
customFootprintNames.add(pcbComp.metadata.kicad_footprint.footprintName);
|
|
79609
79613
|
}
|
|
79610
79614
|
}
|
|
79611
79615
|
}
|
|
79612
|
-
return
|
|
79616
|
+
return { customFootprintNames, footprinterStrings };
|
|
79613
79617
|
}
|
|
79614
79618
|
_step() {
|
|
79615
79619
|
const kicadPcbString = this.ctx.kicadPcbString;
|
|
@@ -79617,7 +79621,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
79617
79621
|
if (!kicadPcbString) {
|
|
79618
79622
|
throw new Error("PCB content not available. Run GenerateKicadSchAndPcbStage first.");
|
|
79619
79623
|
}
|
|
79620
|
-
const customFootprintNames = this.
|
|
79624
|
+
const { customFootprintNames, footprinterStrings } = this.classifyFootprints();
|
|
79621
79625
|
const uniqueFootprints = /* @__PURE__ */ new Map;
|
|
79622
79626
|
try {
|
|
79623
79627
|
const parsed = parseKicadSexpr2(kicadPcbString);
|
|
@@ -79632,7 +79636,8 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
79632
79636
|
const footprintEntry = this.sanitizeFootprint({
|
|
79633
79637
|
footprint,
|
|
79634
79638
|
fpLibraryName,
|
|
79635
|
-
customFootprintNames
|
|
79639
|
+
customFootprintNames,
|
|
79640
|
+
footprinterStrings
|
|
79636
79641
|
});
|
|
79637
79642
|
if (!uniqueFootprints.has(footprintEntry.footprintName)) {
|
|
79638
79643
|
uniqueFootprints.set(footprintEntry.footprintName, footprintEntry);
|
|
@@ -79647,7 +79652,8 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
79647
79652
|
sanitizeFootprint({
|
|
79648
79653
|
footprint,
|
|
79649
79654
|
fpLibraryName,
|
|
79650
|
-
customFootprintNames
|
|
79655
|
+
customFootprintNames,
|
|
79656
|
+
footprinterStrings
|
|
79651
79657
|
}) {
|
|
79652
79658
|
const libraryLink = footprint.libraryLink ?? "footprint";
|
|
79653
79659
|
const parts = libraryLink.split(":");
|
|
@@ -79777,6 +79783,16 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
79777
79783
|
modelFiles.push(model.path);
|
|
79778
79784
|
}
|
|
79779
79785
|
}
|
|
79786
|
+
if (updatedModels.length === 0) {
|
|
79787
|
+
const footprinterString = footprinterStrings.get(footprintName);
|
|
79788
|
+
if (footprinterString) {
|
|
79789
|
+
const cdnUrl = `${MODEL_CDN_BASE_URL}/${footprinterString}.step`;
|
|
79790
|
+
const cdnModelFilename = getBasename(cdnUrl);
|
|
79791
|
+
const newPath = `../../3dmodels/tscircuit_builtin.3dshapes/${cdnModelFilename}`;
|
|
79792
|
+
updatedModels.push(new FootprintModel3(newPath));
|
|
79793
|
+
modelFiles.push(cdnUrl);
|
|
79794
|
+
}
|
|
79795
|
+
}
|
|
79780
79796
|
footprint.models = updatedModels;
|
|
79781
79797
|
return {
|
|
79782
79798
|
footprintName,
|
|
@@ -80346,6 +80362,16 @@ function classifyKicadSymbols(ctx) {
|
|
|
80346
80362
|
});
|
|
80347
80363
|
}
|
|
80348
80364
|
}
|
|
80365
|
+
function getSymbolFootprintRef(kicadSymbol) {
|
|
80366
|
+
const properties = kicadSymbol.symbol.properties ?? [];
|
|
80367
|
+
for (const prop of properties) {
|
|
80368
|
+
if (prop.key === "Footprint" && prop.value) {
|
|
80369
|
+
const parts = prop.value.split(":");
|
|
80370
|
+
return (parts.length > 1 ? parts[1] : parts[0]) ?? null;
|
|
80371
|
+
}
|
|
80372
|
+
}
|
|
80373
|
+
return null;
|
|
80374
|
+
}
|
|
80349
80375
|
function classifySymbolsForComponent({
|
|
80350
80376
|
ctx,
|
|
80351
80377
|
extractedKicadComponent
|
|
@@ -80353,6 +80379,7 @@ function classifySymbolsForComponent({
|
|
|
80353
80379
|
const { tscircuitComponentName, kicadSymbols } = extractedKicadComponent;
|
|
80354
80380
|
const hasCustomFootprint = componentHasCustomFootprint(extractedKicadComponent);
|
|
80355
80381
|
let hasAddedUserSymbol = false;
|
|
80382
|
+
const customFootprintNames = new Set(extractedKicadComponent.kicadFootprints.filter((fp) => !fp.isBuiltin).map((fp) => fp.footprintName));
|
|
80356
80383
|
const builtComponent = ctx.builtTscircuitComponents.find((c) => c.tscircuitComponentName === tscircuitComponentName);
|
|
80357
80384
|
const schematicSymbol = builtComponent?.circuitJson.find((el) => el.type === "schematic_symbol");
|
|
80358
80385
|
const metadata = schematicSymbol?.metadata?.kicad_symbol;
|
|
@@ -80374,19 +80401,28 @@ function classifySymbolsForComponent({
|
|
|
80374
80401
|
const updatedSymbol = metadata ? applyKicadSymbolMetadata(kicadSymbol, metadata) : kicadSymbol;
|
|
80375
80402
|
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
80376
80403
|
} else if (hasCustomFootprint && !hasAddedUserSymbol) {
|
|
80377
|
-
|
|
80378
|
-
const
|
|
80379
|
-
|
|
80380
|
-
|
|
80381
|
-
|
|
80382
|
-
|
|
80383
|
-
|
|
80384
|
-
|
|
80385
|
-
|
|
80386
|
-
|
|
80387
|
-
|
|
80388
|
-
|
|
80389
|
-
|
|
80404
|
+
const footprintRef = getSymbolFootprintRef(kicadSymbol);
|
|
80405
|
+
const symbolMatchesCustomFootprint = footprintRef != null && customFootprintNames.has(footprintRef);
|
|
80406
|
+
if (symbolMatchesCustomFootprint) {
|
|
80407
|
+
hasAddedUserSymbol = true;
|
|
80408
|
+
const renamedSymbol = renameKicadSymbol({
|
|
80409
|
+
kicadSymbol,
|
|
80410
|
+
newKicadSymbolName: tscircuitComponentName
|
|
80411
|
+
});
|
|
80412
|
+
updateKicadSymbolFootprint({
|
|
80413
|
+
kicadSymbol: renamedSymbol,
|
|
80414
|
+
kicadLibraryName: ctx.kicadLibraryName,
|
|
80415
|
+
kicadFootprintName: tscircuitComponentName,
|
|
80416
|
+
isPcm: ctx.isPcm
|
|
80417
|
+
});
|
|
80418
|
+
const updatedSymbol = metadata ? applyKicadSymbolMetadata(renamedSymbol, metadata) : renamedSymbol;
|
|
80419
|
+
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
80420
|
+
} else {
|
|
80421
|
+
const updatedSymbol = updateBuiltinKicadSymbolFootprint(kicadSymbol, {
|
|
80422
|
+
isPcm: ctx.isPcm
|
|
80423
|
+
});
|
|
80424
|
+
addBuiltinSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
80425
|
+
}
|
|
80390
80426
|
} else {
|
|
80391
80427
|
const updatedSymbol = updateBuiltinKicadSymbolFootprint(kicadSymbol, {
|
|
80392
80428
|
isPcm: ctx.isPcm
|
|
@@ -80415,11 +80451,13 @@ function addBuiltinSymbol({
|
|
|
80415
80451
|
}
|
|
80416
80452
|
}
|
|
80417
80453
|
function generateSymLibTable(params2) {
|
|
80418
|
-
const { kicadLibraryName, includeBuiltin } = params2;
|
|
80454
|
+
const { kicadLibraryName, includeUser, includeBuiltin } = params2;
|
|
80419
80455
|
let content = `(sym_lib_table
|
|
80420
80456
|
`;
|
|
80421
|
-
|
|
80457
|
+
if (includeUser) {
|
|
80458
|
+
content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/symbols/${kicadLibraryName}.kicad_sym")(options "")(descr ""))
|
|
80422
80459
|
`;
|
|
80460
|
+
}
|
|
80423
80461
|
if (includeBuiltin) {
|
|
80424
80462
|
content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/symbols/tscircuit_builtin.kicad_sym")(options "")(descr ""))
|
|
80425
80463
|
`;
|
|
@@ -80429,11 +80467,13 @@ function generateSymLibTable(params2) {
|
|
|
80429
80467
|
return content;
|
|
80430
80468
|
}
|
|
80431
80469
|
function generateFpLibTable(params2) {
|
|
80432
|
-
const { kicadLibraryName, includeBuiltin } = params2;
|
|
80470
|
+
const { kicadLibraryName, includeUser, includeBuiltin } = params2;
|
|
80433
80471
|
let content = `(fp_lib_table
|
|
80434
80472
|
`;
|
|
80435
|
-
|
|
80473
|
+
if (includeUser) {
|
|
80474
|
+
content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/footprints/${kicadLibraryName}.pretty")(options "")(descr ""))
|
|
80436
80475
|
`;
|
|
80476
|
+
}
|
|
80437
80477
|
if (includeBuiltin) {
|
|
80438
80478
|
content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/footprints/tscircuit_builtin.pretty")(options "")(descr ""))
|
|
80439
80479
|
`;
|
|
@@ -80486,14 +80526,18 @@ function buildBuiltinFootprintLibrary(ctx) {
|
|
|
80486
80526
|
}
|
|
80487
80527
|
}
|
|
80488
80528
|
function buildLibraryTables(ctx) {
|
|
80529
|
+
const hasUserFootprints = ctx.userKicadFootprints.length > 0;
|
|
80530
|
+
const hasUserSymbols = ctx.userKicadSymbols.length > 0;
|
|
80489
80531
|
const hasBuiltinFootprints = ctx.includeBuiltins && ctx.builtinKicadFootprints.length > 0;
|
|
80490
80532
|
const hasBuiltinSymbols = ctx.includeBuiltins && ctx.builtinKicadSymbols.length > 0;
|
|
80491
80533
|
ctx.kicadProjectFsMap["fp-lib-table"] = generateFpLibTable({
|
|
80492
80534
|
kicadLibraryName: ctx.kicadLibraryName,
|
|
80535
|
+
includeUser: hasUserFootprints,
|
|
80493
80536
|
includeBuiltin: hasBuiltinFootprints
|
|
80494
80537
|
});
|
|
80495
80538
|
ctx.kicadProjectFsMap["sym-lib-table"] = generateSymLibTable({
|
|
80496
80539
|
kicadLibraryName: ctx.kicadLibraryName,
|
|
80540
|
+
includeUser: hasUserSymbols,
|
|
80497
80541
|
includeBuiltin: hasBuiltinSymbols
|
|
80498
80542
|
});
|
|
80499
80543
|
}
|
|
@@ -80640,6 +80684,78 @@ async function importFromUserLand(moduleName) {
|
|
|
80640
80684
|
return import(moduleName);
|
|
80641
80685
|
}
|
|
80642
80686
|
|
|
80687
|
+
// lib/shared/get-complete-platform-config.ts
|
|
80688
|
+
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
80689
|
+
import { createHash } from "node:crypto";
|
|
80690
|
+
import path15 from "node:path";
|
|
80691
|
+
import fs12 from "node:fs";
|
|
80692
|
+
function createLocalCacheEngine(cacheDir = path15.join(process.cwd(), ".tscircuit", "cache")) {
|
|
80693
|
+
return {
|
|
80694
|
+
getItem: (key) => {
|
|
80695
|
+
try {
|
|
80696
|
+
const hash = createHash("md5").update(key).digest("hex");
|
|
80697
|
+
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
80698
|
+
const filePath = path15.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
80699
|
+
return fs12.readFileSync(filePath, "utf-8");
|
|
80700
|
+
} catch {
|
|
80701
|
+
return null;
|
|
80702
|
+
}
|
|
80703
|
+
},
|
|
80704
|
+
setItem: (key, value) => {
|
|
80705
|
+
try {
|
|
80706
|
+
fs12.mkdirSync(cacheDir, { recursive: true });
|
|
80707
|
+
const hash = createHash("md5").update(key).digest("hex");
|
|
80708
|
+
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
80709
|
+
const filePath = path15.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
80710
|
+
fs12.writeFileSync(filePath, value);
|
|
80711
|
+
} catch {}
|
|
80712
|
+
}
|
|
80713
|
+
};
|
|
80714
|
+
}
|
|
80715
|
+
function getCompletePlatformConfig(userConfig) {
|
|
80716
|
+
const basePlatformConfig = getPlatformConfig();
|
|
80717
|
+
const defaultConfig = {
|
|
80718
|
+
...basePlatformConfig,
|
|
80719
|
+
localCacheEngine: createLocalCacheEngine(),
|
|
80720
|
+
footprintFileParserMap: {
|
|
80721
|
+
...basePlatformConfig.footprintFileParserMap,
|
|
80722
|
+
kicad_mod: {
|
|
80723
|
+
loadFromUrl: async (url) => {
|
|
80724
|
+
let fetchUrl = url;
|
|
80725
|
+
if (url.startsWith("./") || url.startsWith("../")) {
|
|
80726
|
+
const absolutePath = path15.resolve(process.cwd(), url);
|
|
80727
|
+
fetchUrl = `file://${absolutePath}`;
|
|
80728
|
+
} else if (url.startsWith("/")) {
|
|
80729
|
+
if (fs12.existsSync(url)) {
|
|
80730
|
+
fetchUrl = `file://${url}`;
|
|
80731
|
+
} else {
|
|
80732
|
+
const relativePath = `.${url}`;
|
|
80733
|
+
const absolutePath = path15.resolve(process.cwd(), relativePath);
|
|
80734
|
+
if (fs12.existsSync(absolutePath)) {
|
|
80735
|
+
fetchUrl = `file://${absolutePath}`;
|
|
80736
|
+
} else {
|
|
80737
|
+
fetchUrl = `file://${url}`;
|
|
80738
|
+
}
|
|
80739
|
+
}
|
|
80740
|
+
}
|
|
80741
|
+
return basePlatformConfig.footprintFileParserMap.kicad_mod.loadFromUrl(fetchUrl);
|
|
80742
|
+
}
|
|
80743
|
+
}
|
|
80744
|
+
}
|
|
80745
|
+
};
|
|
80746
|
+
if (!userConfig) {
|
|
80747
|
+
return defaultConfig;
|
|
80748
|
+
}
|
|
80749
|
+
return {
|
|
80750
|
+
...defaultConfig,
|
|
80751
|
+
...userConfig,
|
|
80752
|
+
footprintFileParserMap: {
|
|
80753
|
+
...defaultConfig.footprintFileParserMap,
|
|
80754
|
+
...userConfig.footprintFileParserMap
|
|
80755
|
+
}
|
|
80756
|
+
};
|
|
80757
|
+
}
|
|
80758
|
+
|
|
80643
80759
|
// lib/shared/convert-to-kicad-library.tsx
|
|
80644
80760
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
80645
80761
|
async function convertToKicadLibrary({
|
|
@@ -80650,7 +80766,9 @@ async function convertToKicadLibrary({
|
|
|
80650
80766
|
kicadPcmPackageId,
|
|
80651
80767
|
circuitJsonToKicadModule
|
|
80652
80768
|
}) {
|
|
80653
|
-
const
|
|
80769
|
+
const platformConfig = getCompletePlatformConfig();
|
|
80770
|
+
const platformFetch = platformConfig.platformFetch ?? globalThis.fetch;
|
|
80771
|
+
const absoluteFilePath = path16.isAbsolute(filePath) ? filePath : path16.resolve(process.cwd(), filePath);
|
|
80654
80772
|
const React = await importFromUserLand("react");
|
|
80655
80773
|
globalThis.React = React;
|
|
80656
80774
|
const userLandTscircuit = await importFromUserLand("tscircuit");
|
|
@@ -80666,9 +80784,7 @@ async function convertToKicadLibrary({
|
|
|
80666
80784
|
return null;
|
|
80667
80785
|
}
|
|
80668
80786
|
const runner = new userLandTscircuit.RootCircuit;
|
|
80669
|
-
runner.add(/* @__PURE__ */ jsxDEV(Component, {
|
|
80670
|
-
name: "REF**"
|
|
80671
|
-
}, undefined, false, undefined, this));
|
|
80787
|
+
runner.add(/* @__PURE__ */ jsxDEV(Component, {}, undefined, false, undefined, this));
|
|
80672
80788
|
await runner.renderUntilSettled();
|
|
80673
80789
|
return await runner.getCircuitJson();
|
|
80674
80790
|
} catch (error) {
|
|
@@ -80686,24 +80802,38 @@ async function convertToKicadLibrary({
|
|
|
80686
80802
|
});
|
|
80687
80803
|
await converter.run();
|
|
80688
80804
|
const kicadLibOutput = converter.getOutput();
|
|
80689
|
-
|
|
80805
|
+
fs13.mkdirSync(outputDir, { recursive: true });
|
|
80690
80806
|
for (const [relativePath, content] of Object.entries(kicadLibOutput.kicadProjectFsMap)) {
|
|
80691
|
-
const fullPath =
|
|
80692
|
-
const dir =
|
|
80693
|
-
|
|
80807
|
+
const fullPath = path16.join(outputDir, relativePath);
|
|
80808
|
+
const dir = path16.dirname(fullPath);
|
|
80809
|
+
fs13.mkdirSync(dir, { recursive: true });
|
|
80694
80810
|
if (typeof content === "string") {
|
|
80695
|
-
|
|
80811
|
+
fs13.writeFileSync(fullPath, content);
|
|
80696
80812
|
} else {
|
|
80697
|
-
|
|
80813
|
+
fs13.writeFileSync(fullPath, content);
|
|
80698
80814
|
}
|
|
80699
80815
|
}
|
|
80700
80816
|
if (kicadLibOutput.model3dSourcePaths.length > 0) {
|
|
80701
|
-
const shapesDir = path15.join(outputDir, `3dmodels/${libraryName}.3dshapes`);
|
|
80702
|
-
fs12.mkdirSync(shapesDir, { recursive: true });
|
|
80703
80817
|
for (const modelPath of kicadLibOutput.model3dSourcePaths) {
|
|
80704
|
-
|
|
80705
|
-
|
|
80706
|
-
|
|
80818
|
+
const filename = path16.basename(modelPath);
|
|
80819
|
+
const isRemote = modelPath.startsWith("http://") || modelPath.startsWith("https://");
|
|
80820
|
+
const shapesDir = isRemote ? "tscircuit_builtin.3dshapes" : `${libraryName}.3dshapes`;
|
|
80821
|
+
const destDir = path16.join(outputDir, `3dmodels/${shapesDir}`);
|
|
80822
|
+
fs13.mkdirSync(destDir, { recursive: true });
|
|
80823
|
+
const destPath = path16.join(destDir, filename);
|
|
80824
|
+
if (isRemote) {
|
|
80825
|
+
try {
|
|
80826
|
+
const response = await platformFetch(modelPath);
|
|
80827
|
+
if (!response.ok) {
|
|
80828
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
80829
|
+
}
|
|
80830
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
80831
|
+
fs13.writeFileSync(destPath, buffer);
|
|
80832
|
+
} catch (error) {
|
|
80833
|
+
console.warn(`Failed to fetch 3D model from ${modelPath}: ${error instanceof Error ? error.message : error}`);
|
|
80834
|
+
}
|
|
80835
|
+
} else if (fs13.existsSync(modelPath)) {
|
|
80836
|
+
fs13.copyFileSync(modelPath, destPath);
|
|
80707
80837
|
}
|
|
80708
80838
|
}
|
|
80709
80839
|
}
|
|
@@ -80715,8 +80845,8 @@ async function convertToKicadLibrary({
|
|
|
80715
80845
|
|
|
80716
80846
|
// lib/shared/generate-pcm-assets.ts
|
|
80717
80847
|
var import_jszip = __toESM2(require_lib4(), 1);
|
|
80718
|
-
import
|
|
80719
|
-
import
|
|
80848
|
+
import fs14 from "node:fs";
|
|
80849
|
+
import path17 from "node:path";
|
|
80720
80850
|
import crypto3 from "node:crypto";
|
|
80721
80851
|
async function generatePcmAssets(options) {
|
|
80722
80852
|
const {
|
|
@@ -80732,7 +80862,7 @@ async function generatePcmAssets(options) {
|
|
|
80732
80862
|
displayName = `${author}/${packageName}`
|
|
80733
80863
|
} = options;
|
|
80734
80864
|
const identifier = `com.tscircuit.${author}.${packageName}`.toLowerCase().replace(/[^a-z0-9.-]/g, "-").slice(0, 50);
|
|
80735
|
-
|
|
80865
|
+
fs14.mkdirSync(outputDir, { recursive: true });
|
|
80736
80866
|
console.log("Creating metadata.json...");
|
|
80737
80867
|
const metadata = {
|
|
80738
80868
|
$schema: "https://go.kicad.org/pcm/schemas/v1",
|
|
@@ -80758,13 +80888,13 @@ async function generatePcmAssets(options) {
|
|
|
80758
80888
|
]
|
|
80759
80889
|
};
|
|
80760
80890
|
const zipFileName = `${identifier}-${version2}.zip`;
|
|
80761
|
-
const zipFilePath =
|
|
80891
|
+
const zipFilePath = path17.join(outputDir, zipFileName);
|
|
80762
80892
|
await createPcmZip({
|
|
80763
80893
|
kicadLibraryPath,
|
|
80764
80894
|
metadata,
|
|
80765
80895
|
outputPath: zipFilePath
|
|
80766
80896
|
});
|
|
80767
|
-
const zipBuffer =
|
|
80897
|
+
const zipBuffer = fs14.readFileSync(zipFilePath);
|
|
80768
80898
|
const sha256 = crypto3.createHash("sha256").update(zipBuffer).digest("hex");
|
|
80769
80899
|
const zipSize = zipBuffer.length;
|
|
80770
80900
|
const downloadUrl = baseUrl ? `${baseUrl}/pcm/${zipFileName}` : `./${zipFileName}`;
|
|
@@ -80798,9 +80928,9 @@ async function generatePcmAssets(options) {
|
|
|
80798
80928
|
}
|
|
80799
80929
|
]
|
|
80800
80930
|
};
|
|
80801
|
-
const packagesJsonPath =
|
|
80802
|
-
|
|
80803
|
-
const packagesJsonBuffer =
|
|
80931
|
+
const packagesJsonPath = path17.join(outputDir, "packages.json");
|
|
80932
|
+
fs14.writeFileSync(packagesJsonPath, JSON.stringify(packagesJson, null, 2));
|
|
80933
|
+
const packagesJsonBuffer = fs14.readFileSync(packagesJsonPath);
|
|
80804
80934
|
const packagesJsonSha256 = crypto3.createHash("sha256").update(packagesJsonBuffer).digest("hex");
|
|
80805
80935
|
const packagesJsonUrl = baseUrl ? `${baseUrl}/pcm/packages.json` : "./packages.json";
|
|
80806
80936
|
const repositoryJson = {
|
|
@@ -80818,8 +80948,8 @@ async function generatePcmAssets(options) {
|
|
|
80818
80948
|
update_timestamp: Math.floor(Date.now() / 1000)
|
|
80819
80949
|
}
|
|
80820
80950
|
};
|
|
80821
|
-
const repositoryJsonPath =
|
|
80822
|
-
|
|
80951
|
+
const repositoryJsonPath = path17.join(outputDir, "repository.json");
|
|
80952
|
+
fs14.writeFileSync(repositoryJsonPath, JSON.stringify(repositoryJson, null, 2));
|
|
80823
80953
|
return {
|
|
80824
80954
|
outputDir,
|
|
80825
80955
|
repositoryJsonPath,
|
|
@@ -80831,14 +80961,14 @@ async function generatePcmAssets(options) {
|
|
|
80831
80961
|
}
|
|
80832
80962
|
function addDirectoryToZip(opts) {
|
|
80833
80963
|
const { zip, dirPath, zipPath } = opts;
|
|
80834
|
-
const entries =
|
|
80964
|
+
const entries = fs14.readdirSync(dirPath, { withFileTypes: true });
|
|
80835
80965
|
for (const entry of entries) {
|
|
80836
|
-
const fullPath =
|
|
80966
|
+
const fullPath = path17.join(dirPath, entry.name);
|
|
80837
80967
|
const entryZipPath = zipPath ? `${zipPath}/${entry.name}` : entry.name;
|
|
80838
80968
|
if (entry.isDirectory()) {
|
|
80839
80969
|
addDirectoryToZip({ zip, dirPath: fullPath, zipPath: entryZipPath });
|
|
80840
80970
|
} else {
|
|
80841
|
-
const content =
|
|
80971
|
+
const content = fs14.readFileSync(fullPath);
|
|
80842
80972
|
zip.file(entryZipPath, content);
|
|
80843
80973
|
}
|
|
80844
80974
|
}
|
|
@@ -80847,18 +80977,18 @@ async function createPcmZip(options) {
|
|
|
80847
80977
|
const { kicadLibraryPath, metadata, outputPath } = options;
|
|
80848
80978
|
const zip = new import_jszip.default;
|
|
80849
80979
|
zip.file("metadata.json", JSON.stringify(metadata, null, 2));
|
|
80850
|
-
const footprintsDir =
|
|
80851
|
-
if (
|
|
80980
|
+
const footprintsDir = path17.join(kicadLibraryPath, "footprints");
|
|
80981
|
+
if (fs14.existsSync(footprintsDir)) {
|
|
80852
80982
|
console.log("Adding footprints directory...");
|
|
80853
80983
|
addDirectoryToZip({ zip, dirPath: footprintsDir, zipPath: "footprints" });
|
|
80854
80984
|
}
|
|
80855
|
-
const symbolsDir =
|
|
80856
|
-
if (
|
|
80985
|
+
const symbolsDir = path17.join(kicadLibraryPath, "symbols");
|
|
80986
|
+
if (fs14.existsSync(symbolsDir)) {
|
|
80857
80987
|
console.log("Adding symbols directory...");
|
|
80858
80988
|
addDirectoryToZip({ zip, dirPath: symbolsDir, zipPath: "symbols" });
|
|
80859
80989
|
}
|
|
80860
|
-
const modelsDir =
|
|
80861
|
-
if (
|
|
80990
|
+
const modelsDir = path17.join(kicadLibraryPath, "3dmodels");
|
|
80991
|
+
if (fs14.existsSync(modelsDir)) {
|
|
80862
80992
|
console.log("Adding 3dmodels directory...");
|
|
80863
80993
|
addDirectoryToZip({ zip, dirPath: modelsDir, zipPath: "3dmodels" });
|
|
80864
80994
|
}
|
|
@@ -80868,7 +80998,7 @@ async function createPcmZip(options) {
|
|
|
80868
80998
|
compression: "DEFLATE",
|
|
80869
80999
|
compressionOptions: { level: 9 }
|
|
80870
81000
|
});
|
|
80871
|
-
|
|
81001
|
+
fs14.writeFileSync(outputPath, zipBuffer);
|
|
80872
81002
|
}
|
|
80873
81003
|
|
|
80874
81004
|
// lib/utils/get-package-author.ts
|
|
@@ -80883,8 +81013,8 @@ var getPackageAuthor = (packageName) => {
|
|
|
80883
81013
|
};
|
|
80884
81014
|
|
|
80885
81015
|
// lib/utils/resolve-kicad-library-name.ts
|
|
80886
|
-
import
|
|
80887
|
-
import
|
|
81016
|
+
import path18 from "node:path";
|
|
81017
|
+
import fs15 from "node:fs";
|
|
80888
81018
|
|
|
80889
81019
|
// lib/utils/get-unscoped-package-name.ts
|
|
80890
81020
|
var getUnscopedPackageName = (packageName) => {
|
|
@@ -80899,9 +81029,9 @@ function resolveKicadLibraryName({
|
|
|
80899
81029
|
if (projectConfig?.kicadLibraryName) {
|
|
80900
81030
|
return projectConfig.kicadLibraryName;
|
|
80901
81031
|
}
|
|
80902
|
-
const packageJsonPath =
|
|
80903
|
-
if (
|
|
80904
|
-
const packageJson = JSON.parse(
|
|
81032
|
+
const packageJsonPath = path18.join(projectDir, "package.json");
|
|
81033
|
+
if (fs15.existsSync(packageJsonPath)) {
|
|
81034
|
+
const packageJson = JSON.parse(fs15.readFileSync(packageJsonPath, "utf-8"));
|
|
80905
81035
|
const unscopedName = getUnscopedPackageName(packageJson.name || "");
|
|
80906
81036
|
if (unscopedName) {
|
|
80907
81037
|
return unscopedName.replace("@tsci/", "").replace(/\./g, "-");
|
|
@@ -80919,18 +81049,18 @@ async function buildKicadPcm({
|
|
|
80919
81049
|
circuitJsonToKicadModule,
|
|
80920
81050
|
kicadLibraryName: kicadLibraryNameOption
|
|
80921
81051
|
}) {
|
|
80922
|
-
const packageJsonPath =
|
|
80923
|
-
if (!
|
|
81052
|
+
const packageJsonPath = path19.join(projectDir, "package.json");
|
|
81053
|
+
if (!fs16.existsSync(packageJsonPath)) {
|
|
80924
81054
|
throw new Error("No package.json found for KiCad PCM generation");
|
|
80925
81055
|
}
|
|
80926
|
-
const packageJson = JSON.parse(
|
|
81056
|
+
const packageJson = JSON.parse(fs16.readFileSync(packageJsonPath, "utf-8"));
|
|
80927
81057
|
const projectConfig = loadProjectConfig(projectDir);
|
|
80928
|
-
const packageName = packageJson.name?.split("/").pop()?.split(".").pop() ||
|
|
81058
|
+
const packageName = packageJson.name?.split("/").pop()?.split(".").pop() || path19.basename(projectDir);
|
|
80929
81059
|
const version2 = packageJson.version || "1.0.0";
|
|
80930
81060
|
const author = getPackageAuthor(packageJson.name || "") || "tscircuit";
|
|
80931
81061
|
const description = packageJson.description || "";
|
|
80932
81062
|
const libraryName = kicadLibraryNameOption ?? resolveKicadLibraryName({ projectDir });
|
|
80933
|
-
const kicadLibOutputDir =
|
|
81063
|
+
const kicadLibOutputDir = path19.join(distDir, "kicad-library-pcm");
|
|
80934
81064
|
const kicadPcmPackageId = `com_tscircuit_${author}_${packageName}`.replace(/\./g, "_");
|
|
80935
81065
|
console.log("Converting to KiCad library for PCM...");
|
|
80936
81066
|
await convertToKicadLibrary({
|
|
@@ -80941,7 +81071,7 @@ async function buildKicadPcm({
|
|
|
80941
81071
|
kicadPcmPackageId,
|
|
80942
81072
|
circuitJsonToKicadModule
|
|
80943
81073
|
});
|
|
80944
|
-
const pcmOutputDir =
|
|
81074
|
+
const pcmOutputDir = path19.join(distDir, "pcm");
|
|
80945
81075
|
const envDeploymentUrl = process.env.TSCIRCUIT_DEPLOYMENT_URL?.replace(/\/+$/, "");
|
|
80946
81076
|
const baseUrl = baseUrlOption ?? envDeploymentUrl ?? `https://${author}--${packageName}.tscircuit.app`;
|
|
80947
81077
|
console.log("Generating PCM assets...");
|
|
@@ -80955,13 +81085,13 @@ async function buildKicadPcm({
|
|
|
80955
81085
|
baseUrl,
|
|
80956
81086
|
displayName: kicadLibraryNameOption || projectConfig?.kicadLibraryName || undefined
|
|
80957
81087
|
});
|
|
80958
|
-
console.log(` KiCad PCM assets generated at ${kleur_default.dim(
|
|
81088
|
+
console.log(` KiCad PCM assets generated at ${kleur_default.dim(path19.relative(process.cwd(), pcmOutputDir))}`);
|
|
80959
81089
|
console.log(` Repository URL: ${kleur_default.cyan(`${baseUrl}/pcm/repository.json`)}`);
|
|
80960
81090
|
}
|
|
80961
81091
|
|
|
80962
81092
|
// node_modules/globby/index.js
|
|
80963
81093
|
import process9 from "node:process";
|
|
80964
|
-
import
|
|
81094
|
+
import fs19 from "node:fs";
|
|
80965
81095
|
import nodePath from "node:path";
|
|
80966
81096
|
|
|
80967
81097
|
// node_modules/@sindresorhus/merge-streams/index.js
|
|
@@ -81145,7 +81275,7 @@ var PASSTHROUGH_LISTENERS_PER_STREAM = 1;
|
|
|
81145
81275
|
var import_fast_glob2 = __toESM2(require_out4(), 1);
|
|
81146
81276
|
|
|
81147
81277
|
// node_modules/path-type/index.js
|
|
81148
|
-
import
|
|
81278
|
+
import fs17 from "node:fs";
|
|
81149
81279
|
import fsPromises from "node:fs/promises";
|
|
81150
81280
|
async function isType2(fsStatType, statsMethodName, filePath) {
|
|
81151
81281
|
if (typeof filePath !== "string") {
|
|
@@ -81166,7 +81296,7 @@ function isTypeSync(fsStatType, statsMethodName, filePath) {
|
|
|
81166
81296
|
throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
81167
81297
|
}
|
|
81168
81298
|
try {
|
|
81169
|
-
return
|
|
81299
|
+
return fs17[fsStatType](filePath)[statsMethodName]();
|
|
81170
81300
|
} catch (error) {
|
|
81171
81301
|
if (error.code === "ENOENT") {
|
|
81172
81302
|
return false;
|
|
@@ -81195,17 +81325,17 @@ var TEN_MEGABYTES_IN_BYTES = 10 * 1024 * 1024;
|
|
|
81195
81325
|
var import_fast_glob = __toESM2(require_out4(), 1);
|
|
81196
81326
|
var import_ignore = __toESM2(require_ignore(), 1);
|
|
81197
81327
|
import process8 from "node:process";
|
|
81198
|
-
import
|
|
81328
|
+
import fs18 from "node:fs";
|
|
81199
81329
|
import fsPromises2 from "node:fs/promises";
|
|
81200
|
-
import
|
|
81330
|
+
import path20 from "node:path";
|
|
81201
81331
|
|
|
81202
81332
|
// node_modules/slash/index.js
|
|
81203
|
-
function slash(
|
|
81204
|
-
const isExtendedLengthPath =
|
|
81333
|
+
function slash(path20) {
|
|
81334
|
+
const isExtendedLengthPath = path20.startsWith("\\\\?\\");
|
|
81205
81335
|
if (isExtendedLengthPath) {
|
|
81206
|
-
return
|
|
81336
|
+
return path20;
|
|
81207
81337
|
}
|
|
81208
|
-
return
|
|
81338
|
+
return path20.replace(/\\/g, "/");
|
|
81209
81339
|
}
|
|
81210
81340
|
|
|
81211
81341
|
// node_modules/globby/utilities.js
|
|
@@ -81223,16 +81353,16 @@ var ignoreFilesGlobOptions = {
|
|
|
81223
81353
|
dot: true
|
|
81224
81354
|
};
|
|
81225
81355
|
var GITIGNORE_FILES_PATTERN = "**/.gitignore";
|
|
81226
|
-
var applyBaseToPattern = (pattern, base) => isNegativePattern(pattern) ? "!" +
|
|
81356
|
+
var applyBaseToPattern = (pattern, base) => isNegativePattern(pattern) ? "!" + path20.posix.join(base, pattern.slice(1)) : path20.posix.join(base, pattern);
|
|
81227
81357
|
var parseIgnoreFile = (file, cwd) => {
|
|
81228
|
-
const base = slash(
|
|
81358
|
+
const base = slash(path20.relative(cwd, path20.dirname(file.filePath)));
|
|
81229
81359
|
return file.content.split(/\r?\n/).filter((line) => line && !line.startsWith("#")).map((pattern) => applyBaseToPattern(pattern, base));
|
|
81230
81360
|
};
|
|
81231
81361
|
var toRelativePath = (fileOrDirectory, cwd) => {
|
|
81232
81362
|
cwd = slash(cwd);
|
|
81233
|
-
if (
|
|
81363
|
+
if (path20.isAbsolute(fileOrDirectory)) {
|
|
81234
81364
|
if (slash(fileOrDirectory).startsWith(cwd)) {
|
|
81235
|
-
return
|
|
81365
|
+
return path20.relative(cwd, fileOrDirectory);
|
|
81236
81366
|
}
|
|
81237
81367
|
throw new Error(`Path ${fileOrDirectory} is not in cwd ${cwd}`);
|
|
81238
81368
|
}
|
|
@@ -81279,7 +81409,7 @@ var isIgnoredByIgnoreFilesSync = (patterns, options) => {
|
|
|
81279
81409
|
});
|
|
81280
81410
|
const files = paths.map((filePath) => ({
|
|
81281
81411
|
filePath,
|
|
81282
|
-
content:
|
|
81412
|
+
content: fs18.readFileSync(filePath, "utf8")
|
|
81283
81413
|
}));
|
|
81284
81414
|
return getIsIgnoredPredicate(files, cwd);
|
|
81285
81415
|
};
|
|
@@ -81291,8 +81421,8 @@ var assertPatternsInput = (patterns) => {
|
|
|
81291
81421
|
}
|
|
81292
81422
|
};
|
|
81293
81423
|
var normalizePathForDirectoryGlob = (filePath, cwd) => {
|
|
81294
|
-
const
|
|
81295
|
-
return nodePath.isAbsolute(
|
|
81424
|
+
const path21 = isNegativePattern(filePath) ? filePath.slice(1) : filePath;
|
|
81425
|
+
return nodePath.isAbsolute(path21) ? path21 : nodePath.join(cwd, path21);
|
|
81296
81426
|
};
|
|
81297
81427
|
var getDirectoryGlob = ({ directoryPath, files, extensions }) => {
|
|
81298
81428
|
const extensionGlob = extensions?.length > 0 ? `.${extensions.length > 1 ? `{${extensions.join(",")}}` : extensions[0]}` : "";
|
|
@@ -81322,7 +81452,7 @@ var checkCwdOption = (cwd) => {
|
|
|
81322
81452
|
}
|
|
81323
81453
|
let stat;
|
|
81324
81454
|
try {
|
|
81325
|
-
stat =
|
|
81455
|
+
stat = fs19.statSync(cwd);
|
|
81326
81456
|
} catch {
|
|
81327
81457
|
return;
|
|
81328
81458
|
}
|
|
@@ -81469,7 +81599,7 @@ var getSourceFilesChecksum = (projectDir) => {
|
|
|
81469
81599
|
let checksum = "";
|
|
81470
81600
|
for (const file of sourceFiles) {
|
|
81471
81601
|
try {
|
|
81472
|
-
const stat =
|
|
81602
|
+
const stat = fs20.statSync(path21.join(projectDir, file));
|
|
81473
81603
|
checksum += `${file}:${stat.mtimeMs};`;
|
|
81474
81604
|
} catch {}
|
|
81475
81605
|
}
|
|
@@ -81489,9 +81619,9 @@ var createKicadPcmProxy = ({
|
|
|
81489
81619
|
};
|
|
81490
81620
|
const handleRequest = async (url, res) => {
|
|
81491
81621
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
81492
|
-
const distDir =
|
|
81493
|
-
const pcmDir =
|
|
81494
|
-
const filePath =
|
|
81622
|
+
const distDir = path21.join(projectDir, "dist");
|
|
81623
|
+
const pcmDir = path21.join(distDir, "pcm");
|
|
81624
|
+
const filePath = path21.join(pcmDir, requestedFile);
|
|
81495
81625
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
81496
81626
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
81497
81627
|
if (needsRebuild) {
|
|
@@ -81536,12 +81666,12 @@ Rebuilding KiCad PCM assets...`));
|
|
|
81536
81666
|
}
|
|
81537
81667
|
}
|
|
81538
81668
|
}
|
|
81539
|
-
if (!
|
|
81669
|
+
if (!fs20.existsSync(filePath)) {
|
|
81540
81670
|
res.writeHead(404);
|
|
81541
81671
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
81542
81672
|
return;
|
|
81543
81673
|
}
|
|
81544
|
-
const ext =
|
|
81674
|
+
const ext = path21.extname(filePath).toLowerCase();
|
|
81545
81675
|
let contentType = "application/octet-stream";
|
|
81546
81676
|
if (ext === ".json") {
|
|
81547
81677
|
contentType = "application/json";
|
|
@@ -81549,7 +81679,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
81549
81679
|
contentType = "application/zip";
|
|
81550
81680
|
}
|
|
81551
81681
|
try {
|
|
81552
|
-
const content =
|
|
81682
|
+
const content = fs20.readFileSync(filePath);
|
|
81553
81683
|
res.writeHead(200, { "Content-Type": contentType });
|
|
81554
81684
|
res.end(content);
|
|
81555
81685
|
} catch (error) {
|
|
@@ -81582,7 +81712,7 @@ var createHttpServer = async ({
|
|
|
81582
81712
|
return;
|
|
81583
81713
|
}
|
|
81584
81714
|
try {
|
|
81585
|
-
const content =
|
|
81715
|
+
const content = fs21.readFileSync(standaloneFilePath, "utf8");
|
|
81586
81716
|
res.writeHead(200, {
|
|
81587
81717
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
81588
81718
|
});
|
|
@@ -81673,8 +81803,8 @@ class EventsWatcher extends EventEmitter {
|
|
|
81673
81803
|
}
|
|
81674
81804
|
|
|
81675
81805
|
// cli/dev/DevServer.ts
|
|
81676
|
-
import
|
|
81677
|
-
import
|
|
81806
|
+
import path29 from "node:path";
|
|
81807
|
+
import fs27 from "node:fs";
|
|
81678
81808
|
|
|
81679
81809
|
// node_modules/chokidar/esm/index.js
|
|
81680
81810
|
import { stat as statcb } from "fs";
|
|
@@ -81753,7 +81883,7 @@ class ReaddirpStream extends Readable {
|
|
|
81753
81883
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
81754
81884
|
const statMethod = opts.lstat ? lstat : stat;
|
|
81755
81885
|
if (wantBigintFsStats) {
|
|
81756
|
-
this._stat = (
|
|
81886
|
+
this._stat = (path22) => statMethod(path22, { bigint: true });
|
|
81757
81887
|
} else {
|
|
81758
81888
|
this._stat = statMethod;
|
|
81759
81889
|
}
|
|
@@ -81778,8 +81908,8 @@ class ReaddirpStream extends Readable {
|
|
|
81778
81908
|
const par = this.parent;
|
|
81779
81909
|
const fil = par && par.files;
|
|
81780
81910
|
if (fil && fil.length > 0) {
|
|
81781
|
-
const { path:
|
|
81782
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
81911
|
+
const { path: path22, depth } = par;
|
|
81912
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path22));
|
|
81783
81913
|
const awaited = await Promise.all(slice);
|
|
81784
81914
|
for (const entry of awaited) {
|
|
81785
81915
|
if (!entry)
|
|
@@ -81819,20 +81949,20 @@ class ReaddirpStream extends Readable {
|
|
|
81819
81949
|
this.reading = false;
|
|
81820
81950
|
}
|
|
81821
81951
|
}
|
|
81822
|
-
async _exploreDir(
|
|
81952
|
+
async _exploreDir(path22, depth) {
|
|
81823
81953
|
let files;
|
|
81824
81954
|
try {
|
|
81825
|
-
files = await readdir(
|
|
81955
|
+
files = await readdir(path22, this._rdOptions);
|
|
81826
81956
|
} catch (error) {
|
|
81827
81957
|
this._onError(error);
|
|
81828
81958
|
}
|
|
81829
|
-
return { files, depth, path:
|
|
81959
|
+
return { files, depth, path: path22 };
|
|
81830
81960
|
}
|
|
81831
|
-
async _formatEntry(dirent,
|
|
81961
|
+
async _formatEntry(dirent, path22) {
|
|
81832
81962
|
let entry;
|
|
81833
81963
|
const basename3 = this._isDirent ? dirent.name : dirent;
|
|
81834
81964
|
try {
|
|
81835
|
-
const fullPath = presolve(pjoin(
|
|
81965
|
+
const fullPath = presolve(pjoin(path22, basename3));
|
|
81836
81966
|
entry = { path: prelative(this._root, fullPath), fullPath, basename: basename3 };
|
|
81837
81967
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
81838
81968
|
} catch (err) {
|
|
@@ -82230,16 +82360,16 @@ var delFromSet = (main, prop, item) => {
|
|
|
82230
82360
|
};
|
|
82231
82361
|
var isEmptySet = (val) => val instanceof Set ? val.size === 0 : !val;
|
|
82232
82362
|
var FsWatchInstances = new Map;
|
|
82233
|
-
function createFsWatchInstance(
|
|
82363
|
+
function createFsWatchInstance(path22, options, listener, errHandler, emitRaw) {
|
|
82234
82364
|
const handleEvent = (rawEvent, evPath) => {
|
|
82235
|
-
listener(
|
|
82236
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
82237
|
-
if (evPath &&
|
|
82238
|
-
fsWatchBroadcast(sysPath.resolve(
|
|
82365
|
+
listener(path22);
|
|
82366
|
+
emitRaw(rawEvent, evPath, { watchedPath: path22 });
|
|
82367
|
+
if (evPath && path22 !== evPath) {
|
|
82368
|
+
fsWatchBroadcast(sysPath.resolve(path22, evPath), KEY_LISTENERS, sysPath.join(path22, evPath));
|
|
82239
82369
|
}
|
|
82240
82370
|
};
|
|
82241
82371
|
try {
|
|
82242
|
-
return fs_watch(
|
|
82372
|
+
return fs_watch(path22, {
|
|
82243
82373
|
persistent: options.persistent
|
|
82244
82374
|
}, handleEvent);
|
|
82245
82375
|
} catch (error) {
|
|
@@ -82255,12 +82385,12 @@ var fsWatchBroadcast = (fullPath, listenerType, val1, val2, val3) => {
|
|
|
82255
82385
|
listener(val1, val2, val3);
|
|
82256
82386
|
});
|
|
82257
82387
|
};
|
|
82258
|
-
var setFsWatchListener = (
|
|
82388
|
+
var setFsWatchListener = (path22, fullPath, options, handlers) => {
|
|
82259
82389
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
82260
82390
|
let cont = FsWatchInstances.get(fullPath);
|
|
82261
82391
|
let watcher;
|
|
82262
82392
|
if (!options.persistent) {
|
|
82263
|
-
watcher = createFsWatchInstance(
|
|
82393
|
+
watcher = createFsWatchInstance(path22, options, listener, errHandler, rawEmitter);
|
|
82264
82394
|
if (!watcher)
|
|
82265
82395
|
return;
|
|
82266
82396
|
return watcher.close.bind(watcher);
|
|
@@ -82270,7 +82400,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
|
|
|
82270
82400
|
addAndConvert(cont, KEY_ERR, errHandler);
|
|
82271
82401
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
82272
82402
|
} else {
|
|
82273
|
-
watcher = createFsWatchInstance(
|
|
82403
|
+
watcher = createFsWatchInstance(path22, options, fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS), errHandler, fsWatchBroadcast.bind(null, fullPath, KEY_RAW));
|
|
82274
82404
|
if (!watcher)
|
|
82275
82405
|
return;
|
|
82276
82406
|
watcher.on(EV.ERROR, async (error) => {
|
|
@@ -82279,7 +82409,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
|
|
|
82279
82409
|
cont.watcherUnusable = true;
|
|
82280
82410
|
if (isWindows && error.code === "EPERM") {
|
|
82281
82411
|
try {
|
|
82282
|
-
const fd = await open(
|
|
82412
|
+
const fd = await open(path22, "r");
|
|
82283
82413
|
await fd.close();
|
|
82284
82414
|
broadcastErr(error);
|
|
82285
82415
|
} catch (err) {}
|
|
@@ -82309,7 +82439,7 @@ var setFsWatchListener = (path21, fullPath, options, handlers) => {
|
|
|
82309
82439
|
};
|
|
82310
82440
|
};
|
|
82311
82441
|
var FsWatchFileInstances = new Map;
|
|
82312
|
-
var setFsWatchFileListener = (
|
|
82442
|
+
var setFsWatchFileListener = (path22, fullPath, options, handlers) => {
|
|
82313
82443
|
const { listener, rawEmitter } = handlers;
|
|
82314
82444
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
82315
82445
|
const copts = cont && cont.options;
|
|
@@ -82331,7 +82461,7 @@ var setFsWatchFileListener = (path21, fullPath, options, handlers) => {
|
|
|
82331
82461
|
});
|
|
82332
82462
|
const currmtime = curr.mtimeMs;
|
|
82333
82463
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
82334
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
82464
|
+
foreach(cont.listeners, (listener2) => listener2(path22, curr));
|
|
82335
82465
|
}
|
|
82336
82466
|
})
|
|
82337
82467
|
};
|
|
@@ -82354,13 +82484,13 @@ class NodeFsHandler {
|
|
|
82354
82484
|
this.fsw = fsW;
|
|
82355
82485
|
this._boundHandleError = (error) => fsW._handleError(error);
|
|
82356
82486
|
}
|
|
82357
|
-
_watchWithNodeFs(
|
|
82487
|
+
_watchWithNodeFs(path22, listener) {
|
|
82358
82488
|
const opts = this.fsw.options;
|
|
82359
|
-
const directory = sysPath.dirname(
|
|
82360
|
-
const basename4 = sysPath.basename(
|
|
82489
|
+
const directory = sysPath.dirname(path22);
|
|
82490
|
+
const basename4 = sysPath.basename(path22);
|
|
82361
82491
|
const parent = this.fsw._getWatchedDir(directory);
|
|
82362
82492
|
parent.add(basename4);
|
|
82363
|
-
const absolutePath = sysPath.resolve(
|
|
82493
|
+
const absolutePath = sysPath.resolve(path22);
|
|
82364
82494
|
const options = {
|
|
82365
82495
|
persistent: opts.persistent
|
|
82366
82496
|
};
|
|
@@ -82370,12 +82500,12 @@ class NodeFsHandler {
|
|
|
82370
82500
|
if (opts.usePolling) {
|
|
82371
82501
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
82372
82502
|
options.interval = enableBin && isBinaryPath(basename4) ? opts.binaryInterval : opts.interval;
|
|
82373
|
-
closer = setFsWatchFileListener(
|
|
82503
|
+
closer = setFsWatchFileListener(path22, absolutePath, options, {
|
|
82374
82504
|
listener,
|
|
82375
82505
|
rawEmitter: this.fsw._emitRaw
|
|
82376
82506
|
});
|
|
82377
82507
|
} else {
|
|
82378
|
-
closer = setFsWatchListener(
|
|
82508
|
+
closer = setFsWatchListener(path22, absolutePath, options, {
|
|
82379
82509
|
listener,
|
|
82380
82510
|
errHandler: this._boundHandleError,
|
|
82381
82511
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -82393,7 +82523,7 @@ class NodeFsHandler {
|
|
|
82393
82523
|
let prevStats = stats;
|
|
82394
82524
|
if (parent.has(basename4))
|
|
82395
82525
|
return;
|
|
82396
|
-
const listener = async (
|
|
82526
|
+
const listener = async (path22, newStats) => {
|
|
82397
82527
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file, 5))
|
|
82398
82528
|
return;
|
|
82399
82529
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -82407,11 +82537,11 @@ class NodeFsHandler {
|
|
|
82407
82537
|
this.fsw._emit(EV.CHANGE, file, newStats2);
|
|
82408
82538
|
}
|
|
82409
82539
|
if ((isMacos || isLinux) && prevStats.ino !== newStats2.ino) {
|
|
82410
|
-
this.fsw._closeFile(
|
|
82540
|
+
this.fsw._closeFile(path22);
|
|
82411
82541
|
prevStats = newStats2;
|
|
82412
82542
|
const closer2 = this._watchWithNodeFs(file, listener);
|
|
82413
82543
|
if (closer2)
|
|
82414
|
-
this.fsw._addPathCloser(
|
|
82544
|
+
this.fsw._addPathCloser(path22, closer2);
|
|
82415
82545
|
} else {
|
|
82416
82546
|
prevStats = newStats2;
|
|
82417
82547
|
}
|
|
@@ -82435,7 +82565,7 @@ class NodeFsHandler {
|
|
|
82435
82565
|
}
|
|
82436
82566
|
return closer;
|
|
82437
82567
|
}
|
|
82438
|
-
async _handleSymlink(entry, directory,
|
|
82568
|
+
async _handleSymlink(entry, directory, path22, item) {
|
|
82439
82569
|
if (this.fsw.closed) {
|
|
82440
82570
|
return;
|
|
82441
82571
|
}
|
|
@@ -82445,7 +82575,7 @@ class NodeFsHandler {
|
|
|
82445
82575
|
this.fsw._incrReadyCount();
|
|
82446
82576
|
let linkPath;
|
|
82447
82577
|
try {
|
|
82448
|
-
linkPath = await fsrealpath(
|
|
82578
|
+
linkPath = await fsrealpath(path22);
|
|
82449
82579
|
} catch (e) {
|
|
82450
82580
|
this.fsw._emitReady();
|
|
82451
82581
|
return true;
|
|
@@ -82455,12 +82585,12 @@ class NodeFsHandler {
|
|
|
82455
82585
|
if (dir.has(item)) {
|
|
82456
82586
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
82457
82587
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
82458
|
-
this.fsw._emit(EV.CHANGE,
|
|
82588
|
+
this.fsw._emit(EV.CHANGE, path22, entry.stats);
|
|
82459
82589
|
}
|
|
82460
82590
|
} else {
|
|
82461
82591
|
dir.add(item);
|
|
82462
82592
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
82463
|
-
this.fsw._emit(EV.ADD,
|
|
82593
|
+
this.fsw._emit(EV.ADD, path22, entry.stats);
|
|
82464
82594
|
}
|
|
82465
82595
|
this.fsw._emitReady();
|
|
82466
82596
|
return true;
|
|
@@ -82489,9 +82619,9 @@ class NodeFsHandler {
|
|
|
82489
82619
|
return;
|
|
82490
82620
|
}
|
|
82491
82621
|
const item = entry.path;
|
|
82492
|
-
let
|
|
82622
|
+
let path22 = sysPath.join(directory, item);
|
|
82493
82623
|
current.add(item);
|
|
82494
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
82624
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path22, item)) {
|
|
82495
82625
|
return;
|
|
82496
82626
|
}
|
|
82497
82627
|
if (this.fsw.closed) {
|
|
@@ -82500,8 +82630,8 @@ class NodeFsHandler {
|
|
|
82500
82630
|
}
|
|
82501
82631
|
if (item === target || !target && !previous.has(item)) {
|
|
82502
82632
|
this.fsw._incrReadyCount();
|
|
82503
|
-
|
|
82504
|
-
this._addToNodeFs(
|
|
82633
|
+
path22 = sysPath.join(dir, sysPath.relative(dir, path22));
|
|
82634
|
+
this._addToNodeFs(path22, initialAdd, wh, depth + 1);
|
|
82505
82635
|
}
|
|
82506
82636
|
}).on(EV.ERROR, this._boundHandleError);
|
|
82507
82637
|
return new Promise((resolve4, reject) => {
|
|
@@ -82550,13 +82680,13 @@ class NodeFsHandler {
|
|
|
82550
82680
|
}
|
|
82551
82681
|
return closer;
|
|
82552
82682
|
}
|
|
82553
|
-
async _addToNodeFs(
|
|
82683
|
+
async _addToNodeFs(path22, initialAdd, priorWh, depth, target) {
|
|
82554
82684
|
const ready = this.fsw._emitReady;
|
|
82555
|
-
if (this.fsw._isIgnored(
|
|
82685
|
+
if (this.fsw._isIgnored(path22) || this.fsw.closed) {
|
|
82556
82686
|
ready();
|
|
82557
82687
|
return false;
|
|
82558
82688
|
}
|
|
82559
|
-
const wh = this.fsw._getWatchHelpers(
|
|
82689
|
+
const wh = this.fsw._getWatchHelpers(path22);
|
|
82560
82690
|
if (priorWh) {
|
|
82561
82691
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
82562
82692
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -82572,8 +82702,8 @@ class NodeFsHandler {
|
|
|
82572
82702
|
const follow = this.fsw.options.followSymlinks;
|
|
82573
82703
|
let closer;
|
|
82574
82704
|
if (stats.isDirectory()) {
|
|
82575
|
-
const absPath = sysPath.resolve(
|
|
82576
|
-
const targetPath = follow ? await fsrealpath(
|
|
82705
|
+
const absPath = sysPath.resolve(path22);
|
|
82706
|
+
const targetPath = follow ? await fsrealpath(path22) : path22;
|
|
82577
82707
|
if (this.fsw.closed)
|
|
82578
82708
|
return;
|
|
82579
82709
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -82583,29 +82713,29 @@ class NodeFsHandler {
|
|
|
82583
82713
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
82584
82714
|
}
|
|
82585
82715
|
} else if (stats.isSymbolicLink()) {
|
|
82586
|
-
const targetPath = follow ? await fsrealpath(
|
|
82716
|
+
const targetPath = follow ? await fsrealpath(path22) : path22;
|
|
82587
82717
|
if (this.fsw.closed)
|
|
82588
82718
|
return;
|
|
82589
82719
|
const parent = sysPath.dirname(wh.watchPath);
|
|
82590
82720
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
82591
82721
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
82592
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
82722
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path22, wh, targetPath);
|
|
82593
82723
|
if (this.fsw.closed)
|
|
82594
82724
|
return;
|
|
82595
82725
|
if (targetPath !== undefined) {
|
|
82596
|
-
this.fsw._symlinkPaths.set(sysPath.resolve(
|
|
82726
|
+
this.fsw._symlinkPaths.set(sysPath.resolve(path22), targetPath);
|
|
82597
82727
|
}
|
|
82598
82728
|
} else {
|
|
82599
82729
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
82600
82730
|
}
|
|
82601
82731
|
ready();
|
|
82602
82732
|
if (closer)
|
|
82603
|
-
this.fsw._addPathCloser(
|
|
82733
|
+
this.fsw._addPathCloser(path22, closer);
|
|
82604
82734
|
return false;
|
|
82605
82735
|
} catch (error) {
|
|
82606
82736
|
if (this.fsw._handleError(error)) {
|
|
82607
82737
|
ready();
|
|
82608
|
-
return
|
|
82738
|
+
return path22;
|
|
82609
82739
|
}
|
|
82610
82740
|
}
|
|
82611
82741
|
}
|
|
@@ -82648,26 +82778,26 @@ function createPattern(matcher) {
|
|
|
82648
82778
|
}
|
|
82649
82779
|
return () => false;
|
|
82650
82780
|
}
|
|
82651
|
-
function normalizePath2(
|
|
82652
|
-
if (typeof
|
|
82781
|
+
function normalizePath2(path22) {
|
|
82782
|
+
if (typeof path22 !== "string")
|
|
82653
82783
|
throw new Error("string expected");
|
|
82654
|
-
|
|
82655
|
-
|
|
82784
|
+
path22 = sysPath2.normalize(path22);
|
|
82785
|
+
path22 = path22.replace(/\\/g, "/");
|
|
82656
82786
|
let prepend = false;
|
|
82657
|
-
if (
|
|
82787
|
+
if (path22.startsWith("//"))
|
|
82658
82788
|
prepend = true;
|
|
82659
82789
|
const DOUBLE_SLASH_RE2 = /\/\//;
|
|
82660
|
-
while (
|
|
82661
|
-
|
|
82790
|
+
while (path22.match(DOUBLE_SLASH_RE2))
|
|
82791
|
+
path22 = path22.replace(DOUBLE_SLASH_RE2, "/");
|
|
82662
82792
|
if (prepend)
|
|
82663
|
-
|
|
82664
|
-
return
|
|
82793
|
+
path22 = "/" + path22;
|
|
82794
|
+
return path22;
|
|
82665
82795
|
}
|
|
82666
82796
|
function matchPatterns(patterns, testString, stats) {
|
|
82667
|
-
const
|
|
82797
|
+
const path22 = normalizePath2(testString);
|
|
82668
82798
|
for (let index = 0;index < patterns.length; index++) {
|
|
82669
82799
|
const pattern = patterns[index];
|
|
82670
|
-
if (pattern(
|
|
82800
|
+
if (pattern(path22, stats)) {
|
|
82671
82801
|
return true;
|
|
82672
82802
|
}
|
|
82673
82803
|
}
|
|
@@ -82707,19 +82837,19 @@ var toUnix = (string) => {
|
|
|
82707
82837
|
}
|
|
82708
82838
|
return str;
|
|
82709
82839
|
};
|
|
82710
|
-
var normalizePathToUnix = (
|
|
82711
|
-
var normalizeIgnored = (cwd = "") => (
|
|
82712
|
-
if (typeof
|
|
82713
|
-
return normalizePathToUnix(sysPath2.isAbsolute(
|
|
82840
|
+
var normalizePathToUnix = (path22) => toUnix(sysPath2.normalize(toUnix(path22)));
|
|
82841
|
+
var normalizeIgnored = (cwd = "") => (path22) => {
|
|
82842
|
+
if (typeof path22 === "string") {
|
|
82843
|
+
return normalizePathToUnix(sysPath2.isAbsolute(path22) ? path22 : sysPath2.join(cwd, path22));
|
|
82714
82844
|
} else {
|
|
82715
|
-
return
|
|
82845
|
+
return path22;
|
|
82716
82846
|
}
|
|
82717
82847
|
};
|
|
82718
|
-
var getAbsolutePath = (
|
|
82719
|
-
if (sysPath2.isAbsolute(
|
|
82720
|
-
return
|
|
82848
|
+
var getAbsolutePath = (path22, cwd) => {
|
|
82849
|
+
if (sysPath2.isAbsolute(path22)) {
|
|
82850
|
+
return path22;
|
|
82721
82851
|
}
|
|
82722
|
-
return sysPath2.join(cwd,
|
|
82852
|
+
return sysPath2.join(cwd, path22);
|
|
82723
82853
|
};
|
|
82724
82854
|
var EMPTY_SET = Object.freeze(new Set);
|
|
82725
82855
|
|
|
@@ -82776,10 +82906,10 @@ var STAT_METHOD_F = "stat";
|
|
|
82776
82906
|
var STAT_METHOD_L = "lstat";
|
|
82777
82907
|
|
|
82778
82908
|
class WatchHelper {
|
|
82779
|
-
constructor(
|
|
82909
|
+
constructor(path22, follow, fsw) {
|
|
82780
82910
|
this.fsw = fsw;
|
|
82781
|
-
const watchPath =
|
|
82782
|
-
this.path =
|
|
82911
|
+
const watchPath = path22;
|
|
82912
|
+
this.path = path22 = path22.replace(REPLACER_RE, "");
|
|
82783
82913
|
this.watchPath = watchPath;
|
|
82784
82914
|
this.fullWatchPath = sysPath2.resolve(watchPath);
|
|
82785
82915
|
this.dirParts = [];
|
|
@@ -82892,20 +83022,20 @@ class FSWatcher extends EventEmitter2 {
|
|
|
82892
83022
|
this._closePromise = undefined;
|
|
82893
83023
|
let paths = unifyPaths(paths_);
|
|
82894
83024
|
if (cwd) {
|
|
82895
|
-
paths = paths.map((
|
|
82896
|
-
const absPath = getAbsolutePath(
|
|
83025
|
+
paths = paths.map((path22) => {
|
|
83026
|
+
const absPath = getAbsolutePath(path22, cwd);
|
|
82897
83027
|
return absPath;
|
|
82898
83028
|
});
|
|
82899
83029
|
}
|
|
82900
|
-
paths.forEach((
|
|
82901
|
-
this._removeIgnoredPath(
|
|
83030
|
+
paths.forEach((path22) => {
|
|
83031
|
+
this._removeIgnoredPath(path22);
|
|
82902
83032
|
});
|
|
82903
83033
|
this._userIgnored = undefined;
|
|
82904
83034
|
if (!this._readyCount)
|
|
82905
83035
|
this._readyCount = 0;
|
|
82906
83036
|
this._readyCount += paths.length;
|
|
82907
|
-
Promise.all(paths.map(async (
|
|
82908
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
83037
|
+
Promise.all(paths.map(async (path22) => {
|
|
83038
|
+
const res = await this._nodeFsHandler._addToNodeFs(path22, !_internal, undefined, 0, _origAdd);
|
|
82909
83039
|
if (res)
|
|
82910
83040
|
this._emitReady();
|
|
82911
83041
|
return res;
|
|
@@ -82924,17 +83054,17 @@ class FSWatcher extends EventEmitter2 {
|
|
|
82924
83054
|
return this;
|
|
82925
83055
|
const paths = unifyPaths(paths_);
|
|
82926
83056
|
const { cwd } = this.options;
|
|
82927
|
-
paths.forEach((
|
|
82928
|
-
if (!sysPath2.isAbsolute(
|
|
83057
|
+
paths.forEach((path22) => {
|
|
83058
|
+
if (!sysPath2.isAbsolute(path22) && !this._closers.has(path22)) {
|
|
82929
83059
|
if (cwd)
|
|
82930
|
-
|
|
82931
|
-
|
|
83060
|
+
path22 = sysPath2.join(cwd, path22);
|
|
83061
|
+
path22 = sysPath2.resolve(path22);
|
|
82932
83062
|
}
|
|
82933
|
-
this._closePath(
|
|
82934
|
-
this._addIgnoredPath(
|
|
82935
|
-
if (this._watched.has(
|
|
83063
|
+
this._closePath(path22);
|
|
83064
|
+
this._addIgnoredPath(path22);
|
|
83065
|
+
if (this._watched.has(path22)) {
|
|
82936
83066
|
this._addIgnoredPath({
|
|
82937
|
-
path:
|
|
83067
|
+
path: path22,
|
|
82938
83068
|
recursive: true
|
|
82939
83069
|
});
|
|
82940
83070
|
}
|
|
@@ -82983,38 +83113,38 @@ class FSWatcher extends EventEmitter2 {
|
|
|
82983
83113
|
if (event !== EVENTS.ERROR)
|
|
82984
83114
|
this.emit(EVENTS.ALL, ...args);
|
|
82985
83115
|
}
|
|
82986
|
-
async _emit(event,
|
|
83116
|
+
async _emit(event, path22, stats) {
|
|
82987
83117
|
if (this.closed)
|
|
82988
83118
|
return;
|
|
82989
83119
|
const opts = this.options;
|
|
82990
83120
|
if (isWindows)
|
|
82991
|
-
|
|
83121
|
+
path22 = sysPath2.normalize(path22);
|
|
82992
83122
|
if (opts.cwd)
|
|
82993
|
-
|
|
82994
|
-
const args = [event,
|
|
83123
|
+
path22 = sysPath2.relative(opts.cwd, path22);
|
|
83124
|
+
const args = [event, path22];
|
|
82995
83125
|
if (stats != null)
|
|
82996
83126
|
args.push(stats);
|
|
82997
83127
|
const awf = opts.awaitWriteFinish;
|
|
82998
83128
|
let pw;
|
|
82999
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
83129
|
+
if (awf && (pw = this._pendingWrites.get(path22))) {
|
|
83000
83130
|
pw.lastChange = new Date;
|
|
83001
83131
|
return this;
|
|
83002
83132
|
}
|
|
83003
83133
|
if (opts.atomic) {
|
|
83004
83134
|
if (event === EVENTS.UNLINK) {
|
|
83005
|
-
this._pendingUnlinks.set(
|
|
83135
|
+
this._pendingUnlinks.set(path22, args);
|
|
83006
83136
|
setTimeout(() => {
|
|
83007
|
-
this._pendingUnlinks.forEach((entry,
|
|
83137
|
+
this._pendingUnlinks.forEach((entry, path23) => {
|
|
83008
83138
|
this.emit(...entry);
|
|
83009
83139
|
this.emit(EVENTS.ALL, ...entry);
|
|
83010
|
-
this._pendingUnlinks.delete(
|
|
83140
|
+
this._pendingUnlinks.delete(path23);
|
|
83011
83141
|
});
|
|
83012
83142
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
83013
83143
|
return this;
|
|
83014
83144
|
}
|
|
83015
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
83145
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path22)) {
|
|
83016
83146
|
event = args[0] = EVENTS.CHANGE;
|
|
83017
|
-
this._pendingUnlinks.delete(
|
|
83147
|
+
this._pendingUnlinks.delete(path22);
|
|
83018
83148
|
}
|
|
83019
83149
|
}
|
|
83020
83150
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -83032,16 +83162,16 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83032
83162
|
this.emitWithAll(event, args);
|
|
83033
83163
|
}
|
|
83034
83164
|
};
|
|
83035
|
-
this._awaitWriteFinish(
|
|
83165
|
+
this._awaitWriteFinish(path22, awf.stabilityThreshold, event, awfEmit);
|
|
83036
83166
|
return this;
|
|
83037
83167
|
}
|
|
83038
83168
|
if (event === EVENTS.CHANGE) {
|
|
83039
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
83169
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path22, 50);
|
|
83040
83170
|
if (isThrottled)
|
|
83041
83171
|
return this;
|
|
83042
83172
|
}
|
|
83043
83173
|
if (opts.alwaysStat && stats === undefined && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
83044
|
-
const fullPath = opts.cwd ? sysPath2.join(opts.cwd,
|
|
83174
|
+
const fullPath = opts.cwd ? sysPath2.join(opts.cwd, path22) : path22;
|
|
83045
83175
|
let stats2;
|
|
83046
83176
|
try {
|
|
83047
83177
|
stats2 = await stat3(fullPath);
|
|
@@ -83060,23 +83190,23 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83060
83190
|
}
|
|
83061
83191
|
return error || this.closed;
|
|
83062
83192
|
}
|
|
83063
|
-
_throttle(actionType,
|
|
83193
|
+
_throttle(actionType, path22, timeout2) {
|
|
83064
83194
|
if (!this._throttled.has(actionType)) {
|
|
83065
83195
|
this._throttled.set(actionType, new Map);
|
|
83066
83196
|
}
|
|
83067
83197
|
const action = this._throttled.get(actionType);
|
|
83068
83198
|
if (!action)
|
|
83069
83199
|
throw new Error("invalid throttle");
|
|
83070
|
-
const actionPath = action.get(
|
|
83200
|
+
const actionPath = action.get(path22);
|
|
83071
83201
|
if (actionPath) {
|
|
83072
83202
|
actionPath.count++;
|
|
83073
83203
|
return false;
|
|
83074
83204
|
}
|
|
83075
83205
|
let timeoutObject;
|
|
83076
83206
|
const clear = () => {
|
|
83077
|
-
const item = action.get(
|
|
83207
|
+
const item = action.get(path22);
|
|
83078
83208
|
const count = item ? item.count : 0;
|
|
83079
|
-
action.delete(
|
|
83209
|
+
action.delete(path22);
|
|
83080
83210
|
clearTimeout(timeoutObject);
|
|
83081
83211
|
if (item)
|
|
83082
83212
|
clearTimeout(item.timeoutObject);
|
|
@@ -83084,50 +83214,50 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83084
83214
|
};
|
|
83085
83215
|
timeoutObject = setTimeout(clear, timeout2);
|
|
83086
83216
|
const thr = { timeoutObject, clear, count: 0 };
|
|
83087
|
-
action.set(
|
|
83217
|
+
action.set(path22, thr);
|
|
83088
83218
|
return thr;
|
|
83089
83219
|
}
|
|
83090
83220
|
_incrReadyCount() {
|
|
83091
83221
|
return this._readyCount++;
|
|
83092
83222
|
}
|
|
83093
|
-
_awaitWriteFinish(
|
|
83223
|
+
_awaitWriteFinish(path22, threshold, event, awfEmit) {
|
|
83094
83224
|
const awf = this.options.awaitWriteFinish;
|
|
83095
83225
|
if (typeof awf !== "object")
|
|
83096
83226
|
return;
|
|
83097
83227
|
const pollInterval = awf.pollInterval;
|
|
83098
83228
|
let timeoutHandler;
|
|
83099
|
-
let fullPath =
|
|
83100
|
-
if (this.options.cwd && !sysPath2.isAbsolute(
|
|
83101
|
-
fullPath = sysPath2.join(this.options.cwd,
|
|
83229
|
+
let fullPath = path22;
|
|
83230
|
+
if (this.options.cwd && !sysPath2.isAbsolute(path22)) {
|
|
83231
|
+
fullPath = sysPath2.join(this.options.cwd, path22);
|
|
83102
83232
|
}
|
|
83103
83233
|
const now = new Date;
|
|
83104
83234
|
const writes = this._pendingWrites;
|
|
83105
83235
|
function awaitWriteFinishFn(prevStat) {
|
|
83106
83236
|
statcb(fullPath, (err, curStat) => {
|
|
83107
|
-
if (err || !writes.has(
|
|
83237
|
+
if (err || !writes.has(path22)) {
|
|
83108
83238
|
if (err && err.code !== "ENOENT")
|
|
83109
83239
|
awfEmit(err);
|
|
83110
83240
|
return;
|
|
83111
83241
|
}
|
|
83112
83242
|
const now2 = Number(new Date);
|
|
83113
83243
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
83114
|
-
writes.get(
|
|
83244
|
+
writes.get(path22).lastChange = now2;
|
|
83115
83245
|
}
|
|
83116
|
-
const pw = writes.get(
|
|
83246
|
+
const pw = writes.get(path22);
|
|
83117
83247
|
const df = now2 - pw.lastChange;
|
|
83118
83248
|
if (df >= threshold) {
|
|
83119
|
-
writes.delete(
|
|
83249
|
+
writes.delete(path22);
|
|
83120
83250
|
awfEmit(undefined, curStat);
|
|
83121
83251
|
} else {
|
|
83122
83252
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
83123
83253
|
}
|
|
83124
83254
|
});
|
|
83125
83255
|
}
|
|
83126
|
-
if (!writes.has(
|
|
83127
|
-
writes.set(
|
|
83256
|
+
if (!writes.has(path22)) {
|
|
83257
|
+
writes.set(path22, {
|
|
83128
83258
|
lastChange: now,
|
|
83129
83259
|
cancelWait: () => {
|
|
83130
|
-
writes.delete(
|
|
83260
|
+
writes.delete(path22);
|
|
83131
83261
|
clearTimeout(timeoutHandler);
|
|
83132
83262
|
return event;
|
|
83133
83263
|
}
|
|
@@ -83135,8 +83265,8 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83135
83265
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval);
|
|
83136
83266
|
}
|
|
83137
83267
|
}
|
|
83138
|
-
_isIgnored(
|
|
83139
|
-
if (this.options.atomic && DOT_RE.test(
|
|
83268
|
+
_isIgnored(path22, stats) {
|
|
83269
|
+
if (this.options.atomic && DOT_RE.test(path22))
|
|
83140
83270
|
return true;
|
|
83141
83271
|
if (!this._userIgnored) {
|
|
83142
83272
|
const { cwd } = this.options;
|
|
@@ -83146,13 +83276,13 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83146
83276
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
83147
83277
|
this._userIgnored = anymatch(list, undefined);
|
|
83148
83278
|
}
|
|
83149
|
-
return this._userIgnored(
|
|
83279
|
+
return this._userIgnored(path22, stats);
|
|
83150
83280
|
}
|
|
83151
|
-
_isntIgnored(
|
|
83152
|
-
return !this._isIgnored(
|
|
83281
|
+
_isntIgnored(path22, stat4) {
|
|
83282
|
+
return !this._isIgnored(path22, stat4);
|
|
83153
83283
|
}
|
|
83154
|
-
_getWatchHelpers(
|
|
83155
|
-
return new WatchHelper(
|
|
83284
|
+
_getWatchHelpers(path22) {
|
|
83285
|
+
return new WatchHelper(path22, this.options.followSymlinks, this);
|
|
83156
83286
|
}
|
|
83157
83287
|
_getWatchedDir(directory) {
|
|
83158
83288
|
const dir = sysPath2.resolve(directory);
|
|
@@ -83166,57 +83296,57 @@ class FSWatcher extends EventEmitter2 {
|
|
|
83166
83296
|
return Boolean(Number(stats.mode) & 256);
|
|
83167
83297
|
}
|
|
83168
83298
|
_remove(directory, item, isDirectory2) {
|
|
83169
|
-
const
|
|
83170
|
-
const fullPath = sysPath2.resolve(
|
|
83171
|
-
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(
|
|
83172
|
-
if (!this._throttle("remove",
|
|
83299
|
+
const path22 = sysPath2.join(directory, item);
|
|
83300
|
+
const fullPath = sysPath2.resolve(path22);
|
|
83301
|
+
isDirectory2 = isDirectory2 != null ? isDirectory2 : this._watched.has(path22) || this._watched.has(fullPath);
|
|
83302
|
+
if (!this._throttle("remove", path22, 100))
|
|
83173
83303
|
return;
|
|
83174
83304
|
if (!isDirectory2 && this._watched.size === 1) {
|
|
83175
83305
|
this.add(directory, item, true);
|
|
83176
83306
|
}
|
|
83177
|
-
const wp = this._getWatchedDir(
|
|
83307
|
+
const wp = this._getWatchedDir(path22);
|
|
83178
83308
|
const nestedDirectoryChildren = wp.getChildren();
|
|
83179
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
83309
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path22, nested));
|
|
83180
83310
|
const parent = this._getWatchedDir(directory);
|
|
83181
83311
|
const wasTracked = parent.has(item);
|
|
83182
83312
|
parent.remove(item);
|
|
83183
83313
|
if (this._symlinkPaths.has(fullPath)) {
|
|
83184
83314
|
this._symlinkPaths.delete(fullPath);
|
|
83185
83315
|
}
|
|
83186
|
-
let relPath =
|
|
83316
|
+
let relPath = path22;
|
|
83187
83317
|
if (this.options.cwd)
|
|
83188
|
-
relPath = sysPath2.relative(this.options.cwd,
|
|
83318
|
+
relPath = sysPath2.relative(this.options.cwd, path22);
|
|
83189
83319
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
83190
83320
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
83191
83321
|
if (event === EVENTS.ADD)
|
|
83192
83322
|
return;
|
|
83193
83323
|
}
|
|
83194
|
-
this._watched.delete(
|
|
83324
|
+
this._watched.delete(path22);
|
|
83195
83325
|
this._watched.delete(fullPath);
|
|
83196
83326
|
const eventName = isDirectory2 ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
83197
|
-
if (wasTracked && !this._isIgnored(
|
|
83198
|
-
this._emit(eventName,
|
|
83199
|
-
this._closePath(
|
|
83327
|
+
if (wasTracked && !this._isIgnored(path22))
|
|
83328
|
+
this._emit(eventName, path22);
|
|
83329
|
+
this._closePath(path22);
|
|
83200
83330
|
}
|
|
83201
|
-
_closePath(
|
|
83202
|
-
this._closeFile(
|
|
83203
|
-
const dir = sysPath2.dirname(
|
|
83204
|
-
this._getWatchedDir(dir).remove(sysPath2.basename(
|
|
83331
|
+
_closePath(path22) {
|
|
83332
|
+
this._closeFile(path22);
|
|
83333
|
+
const dir = sysPath2.dirname(path22);
|
|
83334
|
+
this._getWatchedDir(dir).remove(sysPath2.basename(path22));
|
|
83205
83335
|
}
|
|
83206
|
-
_closeFile(
|
|
83207
|
-
const closers = this._closers.get(
|
|
83336
|
+
_closeFile(path22) {
|
|
83337
|
+
const closers = this._closers.get(path22);
|
|
83208
83338
|
if (!closers)
|
|
83209
83339
|
return;
|
|
83210
83340
|
closers.forEach((closer) => closer());
|
|
83211
|
-
this._closers.delete(
|
|
83341
|
+
this._closers.delete(path22);
|
|
83212
83342
|
}
|
|
83213
|
-
_addPathCloser(
|
|
83343
|
+
_addPathCloser(path22, closer) {
|
|
83214
83344
|
if (!closer)
|
|
83215
83345
|
return;
|
|
83216
|
-
let list = this._closers.get(
|
|
83346
|
+
let list = this._closers.get(path22);
|
|
83217
83347
|
if (!list) {
|
|
83218
83348
|
list = [];
|
|
83219
|
-
this._closers.set(
|
|
83349
|
+
this._closers.set(path22, list);
|
|
83220
83350
|
}
|
|
83221
83351
|
list.push(closer);
|
|
83222
83352
|
}
|
|
@@ -83246,13 +83376,13 @@ function watch(paths, options = {}) {
|
|
|
83246
83376
|
|
|
83247
83377
|
// lib/shared/push-snippet.ts
|
|
83248
83378
|
var import_semver3 = __toESM2(require_semver2(), 1);
|
|
83249
|
-
import * as
|
|
83250
|
-
import * as
|
|
83379
|
+
import * as fs23 from "node:fs";
|
|
83380
|
+
import * as path25 from "node:path";
|
|
83251
83381
|
import Debug from "debug";
|
|
83252
83382
|
|
|
83253
83383
|
// lib/shared/get-entrypoint.ts
|
|
83254
|
-
import * as
|
|
83255
|
-
import * as
|
|
83384
|
+
import * as fs22 from "node:fs";
|
|
83385
|
+
import * as path22 from "node:path";
|
|
83256
83386
|
var ALLOWED_ENTRYPOINT_NAMES = Object.freeze([
|
|
83257
83387
|
"index.tsx",
|
|
83258
83388
|
"index.ts",
|
|
@@ -83263,8 +83393,8 @@ var ALLOWED_ENTRYPOINT_NAMES = Object.freeze([
|
|
|
83263
83393
|
var MAX_SEARCH_DEPTH = 3;
|
|
83264
83394
|
var MAX_RESULTS = 100;
|
|
83265
83395
|
var isValidDirectory = (dirPath, projectDir) => {
|
|
83266
|
-
const resolvedDir =
|
|
83267
|
-
const resolvedProject =
|
|
83396
|
+
const resolvedDir = path22.resolve(dirPath);
|
|
83397
|
+
const resolvedProject = path22.resolve(projectDir);
|
|
83268
83398
|
return resolvedDir.startsWith(resolvedProject) && !resolvedDir.includes("..");
|
|
83269
83399
|
};
|
|
83270
83400
|
var findEntrypointsRecursively = (dir, projectDir, maxDepth = MAX_SEARCH_DEPTH, fileNames = ALLOWED_ENTRYPOINT_NAMES) => {
|
|
@@ -83273,12 +83403,12 @@ var findEntrypointsRecursively = (dir, projectDir, maxDepth = MAX_SEARCH_DEPTH,
|
|
|
83273
83403
|
}
|
|
83274
83404
|
const results = [];
|
|
83275
83405
|
try {
|
|
83276
|
-
const entries =
|
|
83406
|
+
const entries = fs22.readdirSync(dir, { withFileTypes: true });
|
|
83277
83407
|
for (const entry of entries) {
|
|
83278
83408
|
if (results.length >= MAX_RESULTS)
|
|
83279
83409
|
break;
|
|
83280
83410
|
if (entry.isFile() && fileNames.includes(entry.name)) {
|
|
83281
|
-
const filePath =
|
|
83411
|
+
const filePath = path22.resolve(dir, entry.name);
|
|
83282
83412
|
if (isValidDirectory(filePath, projectDir)) {
|
|
83283
83413
|
results.push(filePath);
|
|
83284
83414
|
}
|
|
@@ -83288,7 +83418,7 @@ var findEntrypointsRecursively = (dir, projectDir, maxDepth = MAX_SEARCH_DEPTH,
|
|
|
83288
83418
|
if (results.length >= MAX_RESULTS)
|
|
83289
83419
|
break;
|
|
83290
83420
|
if (entry.isDirectory() && !entry.name.startsWith(".") && entry.name !== "node_modules") {
|
|
83291
|
-
const subdirPath =
|
|
83421
|
+
const subdirPath = path22.resolve(dir, entry.name);
|
|
83292
83422
|
if (isValidDirectory(subdirPath, projectDir)) {
|
|
83293
83423
|
results.push(...findEntrypointsRecursively(subdirPath, projectDir, maxDepth - 1, fileNames));
|
|
83294
83424
|
}
|
|
@@ -83300,21 +83430,21 @@ var findEntrypointsRecursively = (dir, projectDir, maxDepth = MAX_SEARCH_DEPTH,
|
|
|
83300
83430
|
return results;
|
|
83301
83431
|
};
|
|
83302
83432
|
var validateProjectDir = (projectDir) => {
|
|
83303
|
-
const resolvedDir =
|
|
83304
|
-
if (!
|
|
83433
|
+
const resolvedDir = path22.resolve(projectDir);
|
|
83434
|
+
if (!fs22.existsSync(resolvedDir)) {
|
|
83305
83435
|
throw new Error(`Project directory does not exist: ${projectDir}`);
|
|
83306
83436
|
}
|
|
83307
83437
|
return resolvedDir;
|
|
83308
83438
|
};
|
|
83309
83439
|
var validateFilePath = (filePath, projectDir) => {
|
|
83310
|
-
const absolutePath =
|
|
83311
|
-
if (!absolutePath.startsWith(
|
|
83440
|
+
const absolutePath = path22.resolve(projectDir, filePath);
|
|
83441
|
+
if (!absolutePath.startsWith(path22.resolve(projectDir))) {
|
|
83312
83442
|
return null;
|
|
83313
83443
|
}
|
|
83314
83444
|
if (absolutePath.includes("..")) {
|
|
83315
83445
|
return null;
|
|
83316
83446
|
}
|
|
83317
|
-
return
|
|
83447
|
+
return fs22.existsSync(absolutePath) ? absolutePath : null;
|
|
83318
83448
|
};
|
|
83319
83449
|
var getEntrypoint = async ({
|
|
83320
83450
|
filePath,
|
|
@@ -83327,7 +83457,7 @@ var getEntrypoint = async ({
|
|
|
83327
83457
|
if (filePath) {
|
|
83328
83458
|
const validatedPath = validateFilePath(filePath, validatedProjectDir);
|
|
83329
83459
|
if (validatedPath) {
|
|
83330
|
-
const relativePath =
|
|
83460
|
+
const relativePath = path22.relative(validatedProjectDir, validatedPath);
|
|
83331
83461
|
onSuccess(`Using provided file: '${relativePath}'`);
|
|
83332
83462
|
return validatedPath;
|
|
83333
83463
|
}
|
|
@@ -83338,7 +83468,7 @@ var getEntrypoint = async ({
|
|
|
83338
83468
|
if (projectConfig?.mainEntrypoint && typeof projectConfig.mainEntrypoint === "string") {
|
|
83339
83469
|
const validatedConfigPath = validateFilePath(projectConfig.mainEntrypoint, validatedProjectDir);
|
|
83340
83470
|
if (validatedConfigPath) {
|
|
83341
|
-
const relativePath =
|
|
83471
|
+
const relativePath = path22.relative(validatedProjectDir, validatedConfigPath);
|
|
83342
83472
|
onSuccess(`Using entrypoint from tscircuit.config.json: '${relativePath}'`);
|
|
83343
83473
|
return validatedConfigPath;
|
|
83344
83474
|
}
|
|
@@ -83359,12 +83489,12 @@ var getEntrypoint = async ({
|
|
|
83359
83489
|
"src/index.circuit.tsx",
|
|
83360
83490
|
"src/main.tsx",
|
|
83361
83491
|
"src/main.circuit.tsx"
|
|
83362
|
-
].map((location) =>
|
|
83492
|
+
].map((location) => path22.resolve(validatedProjectDir, location));
|
|
83363
83493
|
const recursiveEntrypoints = findEntrypointsRecursively(validatedProjectDir, validatedProjectDir);
|
|
83364
83494
|
const possibleEntrypoints = [...commonLocations, ...recursiveEntrypoints];
|
|
83365
83495
|
for (const entrypoint of possibleEntrypoints) {
|
|
83366
|
-
if (
|
|
83367
|
-
const relativePath =
|
|
83496
|
+
if (fs22.existsSync(entrypoint) && isValidDirectory(entrypoint, validatedProjectDir)) {
|
|
83497
|
+
const relativePath = path22.relative(validatedProjectDir, entrypoint);
|
|
83368
83498
|
onSuccess(`Detected entrypoint: '${relativePath}'`);
|
|
83369
83499
|
return entrypoint;
|
|
83370
83500
|
}
|
|
@@ -83392,7 +83522,7 @@ var validatePackageName = (name) => {
|
|
|
83392
83522
|
};
|
|
83393
83523
|
|
|
83394
83524
|
// cli/dev/get-package-file-paths.ts
|
|
83395
|
-
import * as
|
|
83525
|
+
import * as path23 from "node:path";
|
|
83396
83526
|
|
|
83397
83527
|
// lib/shared/should-ignore-path.ts
|
|
83398
83528
|
var import_micromatch = __toESM2(require_micromatch(), 1);
|
|
@@ -83426,7 +83556,7 @@ var getPackageFilePaths = (projectDir, ignored = []) => {
|
|
|
83426
83556
|
ignore: ignorePatterns
|
|
83427
83557
|
});
|
|
83428
83558
|
fileNames.sort();
|
|
83429
|
-
return fileNames.map((fileName) =>
|
|
83559
|
+
return fileNames.map((fileName) => path23.join(projectDir, fileName));
|
|
83430
83560
|
};
|
|
83431
83561
|
|
|
83432
83562
|
// lib/utils/check-org-access.ts
|
|
@@ -83442,7 +83572,7 @@ var checkOrgAccess = async (ky2, orgTscircuitHandle) => {
|
|
|
83442
83572
|
};
|
|
83443
83573
|
|
|
83444
83574
|
// lib/shared/is-binary-file.ts
|
|
83445
|
-
import * as
|
|
83575
|
+
import * as path24 from "node:path";
|
|
83446
83576
|
var BINARY_FILE_EXTENSIONS = new Set([
|
|
83447
83577
|
".glb",
|
|
83448
83578
|
".gltf",
|
|
@@ -83458,7 +83588,7 @@ var BINARY_FILE_EXTENSIONS = new Set([
|
|
|
83458
83588
|
".tar"
|
|
83459
83589
|
]);
|
|
83460
83590
|
var isBinaryFile = (filePath) => {
|
|
83461
|
-
const ext =
|
|
83591
|
+
const ext = path24.extname(filePath).toLowerCase();
|
|
83462
83592
|
return BINARY_FILE_EXTENSIONS.has(ext);
|
|
83463
83593
|
};
|
|
83464
83594
|
|
|
@@ -83484,8 +83614,8 @@ var debug = Debug("tsci:push-snippet");
|
|
|
83484
83614
|
var getArchivePayload = async (filePaths, projectDir, packageNameWithVersion) => {
|
|
83485
83615
|
const zip = new import_jszip2.default;
|
|
83486
83616
|
for (const fullFilePath of filePaths) {
|
|
83487
|
-
const relativeFilePath =
|
|
83488
|
-
zip.file(relativeFilePath,
|
|
83617
|
+
const relativeFilePath = path25.relative(projectDir, fullFilePath);
|
|
83618
|
+
zip.file(relativeFilePath, fs23.readFileSync(fullFilePath));
|
|
83489
83619
|
}
|
|
83490
83620
|
const archive = await zip.generateAsync({
|
|
83491
83621
|
type: "uint8array",
|
|
@@ -83522,24 +83652,24 @@ var pushSnippet = async ({
|
|
|
83522
83652
|
return onExit(1);
|
|
83523
83653
|
}
|
|
83524
83654
|
const packageJsonPath = [
|
|
83525
|
-
|
|
83526
|
-
|
|
83527
|
-
].find((
|
|
83528
|
-
const projectDir = packageJsonPath ?
|
|
83655
|
+
path25.resolve(path25.join(path25.dirname(snippetFilePath), "package.json")),
|
|
83656
|
+
path25.resolve(path25.join(process.cwd(), "package.json"))
|
|
83657
|
+
].find((path26) => fs23.existsSync(path26));
|
|
83658
|
+
const projectDir = packageJsonPath ? path25.dirname(packageJsonPath) : path25.dirname(snippetFilePath);
|
|
83529
83659
|
if (!packageJsonPath) {
|
|
83530
83660
|
onError("No package.json found, try running 'tsci init' to bootstrap the project");
|
|
83531
83661
|
return onExit(1);
|
|
83532
83662
|
}
|
|
83533
83663
|
let packageJson = {};
|
|
83534
|
-
if (
|
|
83664
|
+
if (fs23.existsSync(packageJsonPath)) {
|
|
83535
83665
|
try {
|
|
83536
|
-
packageJson = JSON.parse(
|
|
83666
|
+
packageJson = JSON.parse(fs23.readFileSync(packageJsonPath).toString());
|
|
83537
83667
|
} catch {
|
|
83538
83668
|
onError("Invalid package.json");
|
|
83539
83669
|
return onExit(1);
|
|
83540
83670
|
}
|
|
83541
83671
|
}
|
|
83542
|
-
if (!
|
|
83672
|
+
if (!fs23.existsSync(snippetFilePath)) {
|
|
83543
83673
|
onError(`File not found: ${snippetFilePath}`);
|
|
83544
83674
|
return onExit(1);
|
|
83545
83675
|
}
|
|
@@ -83580,7 +83710,7 @@ var pushSnippet = async ({
|
|
|
83580
83710
|
}
|
|
83581
83711
|
unscopedPackageName = inputName;
|
|
83582
83712
|
packageJson.name = `@tsci/${currentUsername}.${unscopedPackageName}`;
|
|
83583
|
-
|
|
83713
|
+
fs23.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
83584
83714
|
}
|
|
83585
83715
|
let accountName = currentUsername;
|
|
83586
83716
|
if (packageJsonAuthor && currentUsername !== packageJsonAuthor) {
|
|
@@ -83611,7 +83741,7 @@ var pushSnippet = async ({
|
|
|
83611
83741
|
const updatePackageJsonVersion = (newVersion) => {
|
|
83612
83742
|
try {
|
|
83613
83743
|
packageJson.version = newVersion ?? `${packageVersion}`;
|
|
83614
|
-
|
|
83744
|
+
fs23.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2));
|
|
83615
83745
|
} catch (error) {
|
|
83616
83746
|
onError(`Failed to update package.json version: ${error}`);
|
|
83617
83747
|
}
|
|
@@ -83719,7 +83849,7 @@ var pushSnippet = async ({
|
|
|
83719
83849
|
json: archivePayload
|
|
83720
83850
|
});
|
|
83721
83851
|
for (const fullFilePath of filePaths) {
|
|
83722
|
-
const relativeFilePath =
|
|
83852
|
+
const relativeFilePath = path25.relative(projectDir, fullFilePath);
|
|
83723
83853
|
uploadResults.succeeded.push(relativeFilePath);
|
|
83724
83854
|
}
|
|
83725
83855
|
log(kleur_default.gray(`\uD83D\uDCE6 Uploaded archive with ${filePaths.length} files`));
|
|
@@ -83729,8 +83859,8 @@ var pushSnippet = async ({
|
|
|
83729
83859
|
}
|
|
83730
83860
|
if (uploadResults.succeeded.length === 0) {
|
|
83731
83861
|
for (const fullFilePath of filePaths) {
|
|
83732
|
-
const relativeFilePath =
|
|
83733
|
-
const fileBuffer =
|
|
83862
|
+
const relativeFilePath = path25.relative(projectDir, fullFilePath);
|
|
83863
|
+
const fileBuffer = fs23.readFileSync(fullFilePath);
|
|
83734
83864
|
const isBinary = isBinaryFile(relativeFilePath) || hasBinaryContent(fileBuffer);
|
|
83735
83865
|
const payload = {
|
|
83736
83866
|
file_path: relativeFilePath,
|
|
@@ -83797,8 +83927,8 @@ Publish completed with ${uploadResults.succeeded.length} files uploaded and ${up
|
|
|
83797
83927
|
};
|
|
83798
83928
|
|
|
83799
83929
|
// lib/shared/add-package.ts
|
|
83800
|
-
import * as
|
|
83801
|
-
import * as
|
|
83930
|
+
import * as fs25 from "node:fs";
|
|
83931
|
+
import * as path27 from "node:path";
|
|
83802
83932
|
|
|
83803
83933
|
// lib/shared/resolve-tarball-url-from-registry.ts
|
|
83804
83934
|
async function resolveTarballUrlFromRegistry(packageName) {
|
|
@@ -83827,8 +83957,8 @@ async function resolveTarballUrlFromRegistry(packageName) {
|
|
|
83827
83957
|
}
|
|
83828
83958
|
|
|
83829
83959
|
// lib/shared/detect-and-setup-kicad-library.ts
|
|
83830
|
-
import * as
|
|
83831
|
-
import * as
|
|
83960
|
+
import * as fs24 from "node:fs";
|
|
83961
|
+
import * as path26 from "node:path";
|
|
83832
83962
|
var import_strip_json_comments = __toESM2(require_strip_json_comments(), 1);
|
|
83833
83963
|
function extractPackageName(packageSpec) {
|
|
83834
83964
|
if (packageSpec.startsWith("http")) {
|
|
@@ -83857,8 +83987,8 @@ function extractPackageName(packageSpec) {
|
|
|
83857
83987
|
async function detectAndSetupKicadLibrary(packageSpec, projectDir = process.cwd()) {
|
|
83858
83988
|
try {
|
|
83859
83989
|
const packageName = extractPackageName(packageSpec);
|
|
83860
|
-
const nodeModulesPath =
|
|
83861
|
-
if (!
|
|
83990
|
+
const nodeModulesPath = path26.join(projectDir, "node_modules", packageName);
|
|
83991
|
+
if (!fs24.existsSync(nodeModulesPath)) {
|
|
83862
83992
|
return false;
|
|
83863
83993
|
}
|
|
83864
83994
|
const kicadModFiles = globbySync(["**/*.kicad_mod"], {
|
|
@@ -83880,10 +84010,10 @@ async function detectAndSetupKicadLibrary(packageSpec, projectDir = process.cwd(
|
|
|
83880
84010
|
}
|
|
83881
84011
|
}
|
|
83882
84012
|
async function generateKicadTypes(projectDir, packageName, kicadModFiles) {
|
|
83883
|
-
const typesDir =
|
|
83884
|
-
|
|
84013
|
+
const typesDir = path26.join(projectDir, "types");
|
|
84014
|
+
fs24.mkdirSync(typesDir, { recursive: true });
|
|
83885
84015
|
const typeFileName = `${packageName.replace(/[@/]/g, "-")}.d.ts`;
|
|
83886
|
-
const typesFilePath =
|
|
84016
|
+
const typesFilePath = path26.join(typesDir, typeFileName);
|
|
83887
84017
|
const declarations = kicadModFiles.map((filePath) => {
|
|
83888
84018
|
const modulePath = `${packageName}/${filePath}`;
|
|
83889
84019
|
return `declare module "${modulePath}" {
|
|
@@ -83893,27 +84023,27 @@ async function generateKicadTypes(projectDir, packageName, kicadModFiles) {
|
|
|
83893
84023
|
}).join(`
|
|
83894
84024
|
|
|
83895
84025
|
`);
|
|
83896
|
-
|
|
84026
|
+
fs24.writeFileSync(typesFilePath, declarations);
|
|
83897
84027
|
console.log(kleur_default.green(`✓ Generated types at ${kleur_default.cyan(`types/${typeFileName}`)}`));
|
|
83898
84028
|
}
|
|
83899
84029
|
async function setupTsConfig(projectDir) {
|
|
83900
|
-
const tsconfigPath =
|
|
83901
|
-
if (!
|
|
84030
|
+
const tsconfigPath = path26.join(projectDir, "tsconfig.json");
|
|
84031
|
+
if (!fs24.existsSync(tsconfigPath)) {
|
|
83902
84032
|
console.log(kleur_default.dim("Creating tsconfig.json..."));
|
|
83903
84033
|
generateTsConfig(projectDir);
|
|
83904
84034
|
}
|
|
83905
|
-
const content =
|
|
84035
|
+
const content = fs24.readFileSync(tsconfigPath, "utf-8");
|
|
83906
84036
|
const tsconfig = JSON.parse(import_strip_json_comments.default(content));
|
|
83907
84037
|
if (!tsconfig.compilerOptions) {
|
|
83908
84038
|
tsconfig.compilerOptions = {};
|
|
83909
84039
|
}
|
|
83910
84040
|
if (!tsconfig.compilerOptions.typeRoots) {
|
|
83911
84041
|
tsconfig.compilerOptions.typeRoots = ["./types", "./node_modules/@types"];
|
|
83912
|
-
|
|
84042
|
+
fs24.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
|
|
83913
84043
|
console.log(kleur_default.green("✓ Updated tsconfig.json with types directory"));
|
|
83914
84044
|
} else if (!tsconfig.compilerOptions.typeRoots.includes("./types")) {
|
|
83915
84045
|
tsconfig.compilerOptions.typeRoots.unshift("./types");
|
|
83916
|
-
|
|
84046
|
+
fs24.writeFileSync(tsconfigPath, JSON.stringify(tsconfig, null, 2));
|
|
83917
84047
|
console.log(kleur_default.green("✓ Updated tsconfig.json with types directory"));
|
|
83918
84048
|
}
|
|
83919
84049
|
}
|
|
@@ -83945,8 +84075,8 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
83945
84075
|
let installTarget = normalizedName || packageSpec;
|
|
83946
84076
|
console.log(kleur_default.cyan(`Adding ${kleur_default.bold(displayName)}...`));
|
|
83947
84077
|
if (normalizedName?.startsWith("@tsci/")) {
|
|
83948
|
-
const npmrcPath =
|
|
83949
|
-
const npmrcContent =
|
|
84078
|
+
const npmrcPath = path27.join(projectDir, ".npmrc");
|
|
84079
|
+
const npmrcContent = fs25.existsSync(npmrcPath) ? fs25.readFileSync(npmrcPath, "utf-8") : "";
|
|
83950
84080
|
let hasTsciRegistry = /@tsci[/:]/.test(npmrcContent);
|
|
83951
84081
|
if (!hasTsciRegistry) {
|
|
83952
84082
|
const { addRegistry } = await prompts({
|
|
@@ -83960,7 +84090,7 @@ async function addPackage(packageSpec, projectDir = process.cwd()) {
|
|
|
83960
84090
|
const newContent = `${trimmedContent.length > 0 ? `${trimmedContent}
|
|
83961
84091
|
` : ""}@tsci:registry=https://npm.tscircuit.com
|
|
83962
84092
|
`;
|
|
83963
|
-
|
|
84093
|
+
fs25.writeFileSync(npmrcPath, newContent);
|
|
83964
84094
|
console.log(kleur_default.green("✓ Updated .npmrc with tscircuit registry"));
|
|
83965
84095
|
hasTsciRegistry = true;
|
|
83966
84096
|
} else {
|
|
@@ -83989,16 +84119,16 @@ import Debug2 from "debug";
|
|
|
83989
84119
|
|
|
83990
84120
|
// lib/dependency-analysis/getNodeModuleDependencies.ts
|
|
83991
84121
|
import * as ts from "typescript";
|
|
83992
|
-
import * as
|
|
83993
|
-
import * as
|
|
84122
|
+
import * as path28 from "path";
|
|
84123
|
+
import * as fs26 from "fs";
|
|
83994
84124
|
function getAllDependencyPackages(projectDir) {
|
|
83995
|
-
const packageJsonPath =
|
|
84125
|
+
const packageJsonPath = path28.join(projectDir, "package.json");
|
|
83996
84126
|
const allPackages = new Set;
|
|
83997
|
-
if (!
|
|
84127
|
+
if (!fs26.existsSync(packageJsonPath)) {
|
|
83998
84128
|
return allPackages;
|
|
83999
84129
|
}
|
|
84000
84130
|
try {
|
|
84001
|
-
const packageJson = JSON.parse(
|
|
84131
|
+
const packageJson = JSON.parse(fs26.readFileSync(packageJsonPath, "utf-8"));
|
|
84002
84132
|
const deps = packageJson.dependencies || {};
|
|
84003
84133
|
const devDeps = packageJson.devDependencies || {};
|
|
84004
84134
|
for (const packageName of Object.keys(deps)) {
|
|
@@ -84013,11 +84143,11 @@ function getAllDependencyPackages(projectDir) {
|
|
|
84013
84143
|
return allPackages;
|
|
84014
84144
|
}
|
|
84015
84145
|
function getNodeModuleImports(filePath) {
|
|
84016
|
-
const absolutePath =
|
|
84017
|
-
if (!
|
|
84146
|
+
const absolutePath = path28.resolve(filePath);
|
|
84147
|
+
if (!fs26.existsSync(absolutePath)) {
|
|
84018
84148
|
return [];
|
|
84019
84149
|
}
|
|
84020
|
-
const content =
|
|
84150
|
+
const content = fs26.readFileSync(absolutePath, "utf-8");
|
|
84021
84151
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
84022
84152
|
const imports = new Set;
|
|
84023
84153
|
function visit(node) {
|
|
@@ -84067,17 +84197,17 @@ function resolveNodeModuleImport({
|
|
|
84067
84197
|
}) {
|
|
84068
84198
|
const packageName = getPackageNameFromImport(importPath);
|
|
84069
84199
|
const searchPaths = [
|
|
84070
|
-
|
|
84200
|
+
path28.join(projectDir, "node_modules", packageName)
|
|
84071
84201
|
];
|
|
84072
84202
|
if (searchFromDir) {
|
|
84073
|
-
let currentDir =
|
|
84074
|
-
const projectDirNormalized =
|
|
84203
|
+
let currentDir = path28.dirname(searchFromDir);
|
|
84204
|
+
const projectDirNormalized = path28.normalize(projectDir);
|
|
84075
84205
|
while (currentDir.startsWith(projectDirNormalized)) {
|
|
84076
|
-
const candidatePath =
|
|
84206
|
+
const candidatePath = path28.join(currentDir, "node_modules", packageName);
|
|
84077
84207
|
if (!searchPaths.includes(candidatePath)) {
|
|
84078
84208
|
searchPaths.push(candidatePath);
|
|
84079
84209
|
}
|
|
84080
|
-
const parentDir =
|
|
84210
|
+
const parentDir = path28.dirname(currentDir);
|
|
84081
84211
|
if (parentDir === currentDir)
|
|
84082
84212
|
break;
|
|
84083
84213
|
currentDir = parentDir;
|
|
@@ -84085,7 +84215,7 @@ function resolveNodeModuleImport({
|
|
|
84085
84215
|
}
|
|
84086
84216
|
let packageDir;
|
|
84087
84217
|
for (const candidatePath of searchPaths) {
|
|
84088
|
-
if (
|
|
84218
|
+
if (fs26.existsSync(candidatePath)) {
|
|
84089
84219
|
packageDir = candidatePath;
|
|
84090
84220
|
break;
|
|
84091
84221
|
}
|
|
@@ -84093,25 +84223,25 @@ function resolveNodeModuleImport({
|
|
|
84093
84223
|
if (!packageDir) {
|
|
84094
84224
|
return [];
|
|
84095
84225
|
}
|
|
84096
|
-
const packageJsonPath =
|
|
84097
|
-
const hasPackageJson =
|
|
84098
|
-
const packageJson = hasPackageJson ? JSON.parse(
|
|
84226
|
+
const packageJsonPath = path28.join(packageDir, "package.json");
|
|
84227
|
+
const hasPackageJson = fs26.existsSync(packageJsonPath);
|
|
84228
|
+
const packageJson = hasPackageJson ? JSON.parse(fs26.readFileSync(packageJsonPath, "utf-8")) : null;
|
|
84099
84229
|
const resolvedFiles = [];
|
|
84100
84230
|
if (importPath !== packageName) {
|
|
84101
84231
|
const subpath = importPath.slice(packageName.length + 1);
|
|
84102
84232
|
const possiblePaths = [
|
|
84103
|
-
|
|
84104
|
-
|
|
84105
|
-
|
|
84106
|
-
|
|
84107
|
-
|
|
84108
|
-
|
|
84109
|
-
|
|
84110
|
-
|
|
84111
|
-
|
|
84233
|
+
path28.join(packageDir, subpath),
|
|
84234
|
+
path28.join(packageDir, `${subpath}.js`),
|
|
84235
|
+
path28.join(packageDir, `${subpath}.mjs`),
|
|
84236
|
+
path28.join(packageDir, `${subpath}.ts`),
|
|
84237
|
+
path28.join(packageDir, `${subpath}.tsx`),
|
|
84238
|
+
path28.join(packageDir, subpath, "index.js"),
|
|
84239
|
+
path28.join(packageDir, subpath, "index.mjs"),
|
|
84240
|
+
path28.join(packageDir, subpath, "index.ts"),
|
|
84241
|
+
path28.join(packageDir, subpath, "index.tsx")
|
|
84112
84242
|
];
|
|
84113
84243
|
for (const p of possiblePaths) {
|
|
84114
|
-
if (
|
|
84244
|
+
if (fs26.existsSync(p) && fs26.statSync(p).isFile()) {
|
|
84115
84245
|
resolvedFiles.push(p);
|
|
84116
84246
|
break;
|
|
84117
84247
|
}
|
|
@@ -84143,25 +84273,25 @@ function resolveNodeModuleImport({
|
|
|
84143
84273
|
resolveExportValue(packageJson.exports?.["."]?.require)
|
|
84144
84274
|
].filter((entry) => typeof entry === "string");
|
|
84145
84275
|
for (const entry of entryPoints) {
|
|
84146
|
-
const entryPath =
|
|
84147
|
-
if (
|
|
84276
|
+
const entryPath = path28.join(packageDir, entry);
|
|
84277
|
+
if (fs26.existsSync(entryPath) && fs26.statSync(entryPath).isFile()) {
|
|
84148
84278
|
resolvedFiles.push(entryPath);
|
|
84149
84279
|
}
|
|
84150
84280
|
}
|
|
84151
84281
|
if (resolvedFiles.length === 0) {
|
|
84152
84282
|
const fallbackPaths = [
|
|
84153
|
-
|
|
84154
|
-
|
|
84155
|
-
|
|
84156
|
-
|
|
84157
|
-
|
|
84158
|
-
|
|
84159
|
-
|
|
84160
|
-
|
|
84161
|
-
|
|
84283
|
+
path28.join(packageDir, "index.js"),
|
|
84284
|
+
path28.join(packageDir, "index.mjs"),
|
|
84285
|
+
path28.join(packageDir, "index.ts"),
|
|
84286
|
+
path28.join(packageDir, "index.tsx"),
|
|
84287
|
+
path28.join(packageDir, "dist", "index.js"),
|
|
84288
|
+
path28.join(packageDir, "dist", "index.mjs"),
|
|
84289
|
+
path28.join(packageDir, "lib", "index.js"),
|
|
84290
|
+
path28.join(packageDir, "src", "index.ts"),
|
|
84291
|
+
path28.join(packageDir, "src", "index.tsx")
|
|
84162
84292
|
];
|
|
84163
84293
|
for (const p of fallbackPaths) {
|
|
84164
|
-
if (
|
|
84294
|
+
if (fs26.existsSync(p) && fs26.statSync(p).isFile()) {
|
|
84165
84295
|
resolvedFiles.push(p);
|
|
84166
84296
|
break;
|
|
84167
84297
|
}
|
|
@@ -84199,12 +84329,12 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
84199
84329
|
}
|
|
84200
84330
|
}
|
|
84201
84331
|
function getLocalDependencies(filePath) {
|
|
84202
|
-
const absolutePath =
|
|
84203
|
-
const baseDir =
|
|
84204
|
-
if (!
|
|
84332
|
+
const absolutePath = path28.resolve(filePath);
|
|
84333
|
+
const baseDir = path28.dirname(absolutePath);
|
|
84334
|
+
if (!fs26.existsSync(absolutePath)) {
|
|
84205
84335
|
return [];
|
|
84206
84336
|
}
|
|
84207
|
-
const content =
|
|
84337
|
+
const content = fs26.readFileSync(absolutePath, "utf-8");
|
|
84208
84338
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
84209
84339
|
const dependencies2 = [];
|
|
84210
84340
|
function visit(node) {
|
|
@@ -84226,20 +84356,20 @@ function collectAllNodeModuleDependencies(entryFilePath, projectDir, maxDepth =
|
|
|
84226
84356
|
}
|
|
84227
84357
|
function resolveLocalImport(importPath, baseDir) {
|
|
84228
84358
|
const extensions = [".tsx", ".ts", ".jsx", ".js", ".mjs"];
|
|
84229
|
-
const resolvedPath =
|
|
84230
|
-
if (
|
|
84359
|
+
const resolvedPath = path28.resolve(baseDir, importPath);
|
|
84360
|
+
if (fs26.existsSync(resolvedPath) && fs26.statSync(resolvedPath).isFile()) {
|
|
84231
84361
|
return resolvedPath;
|
|
84232
84362
|
}
|
|
84233
84363
|
for (const ext of extensions) {
|
|
84234
84364
|
const pathWithExt = resolvedPath + ext;
|
|
84235
|
-
if (
|
|
84365
|
+
if (fs26.existsSync(pathWithExt)) {
|
|
84236
84366
|
return pathWithExt;
|
|
84237
84367
|
}
|
|
84238
84368
|
}
|
|
84239
|
-
if (
|
|
84369
|
+
if (fs26.existsSync(resolvedPath) && fs26.statSync(resolvedPath).isDirectory()) {
|
|
84240
84370
|
for (const ext of extensions) {
|
|
84241
|
-
const indexPath =
|
|
84242
|
-
if (
|
|
84371
|
+
const indexPath = path28.join(resolvedPath, `index${ext}`);
|
|
84372
|
+
if (fs26.existsSync(indexPath)) {
|
|
84243
84373
|
return indexPath;
|
|
84244
84374
|
}
|
|
84245
84375
|
}
|
|
@@ -84264,12 +84394,12 @@ var EXCLUDED_PACKAGE_DIRECTORIES = new Set([
|
|
|
84264
84394
|
function collectLocalPackageFiles(packageDir) {
|
|
84265
84395
|
const buildDirs = ["dist", "build"];
|
|
84266
84396
|
for (const dirName of buildDirs) {
|
|
84267
|
-
const dirPath =
|
|
84268
|
-
if (
|
|
84397
|
+
const dirPath = path28.join(packageDir, dirName);
|
|
84398
|
+
if (fs26.existsSync(dirPath)) {
|
|
84269
84399
|
const files = walkDirectory(dirPath, new Set);
|
|
84270
84400
|
if (files.length > 0) {
|
|
84271
|
-
const packageJsonPath =
|
|
84272
|
-
if (
|
|
84401
|
+
const packageJsonPath = path28.join(packageDir, "package.json");
|
|
84402
|
+
if (fs26.existsSync(packageJsonPath)) {
|
|
84273
84403
|
files.push(packageJsonPath);
|
|
84274
84404
|
}
|
|
84275
84405
|
return files;
|
|
@@ -84280,11 +84410,11 @@ function collectLocalPackageFiles(packageDir) {
|
|
|
84280
84410
|
}
|
|
84281
84411
|
function walkDirectory(dir, excludedDirs) {
|
|
84282
84412
|
const files = [];
|
|
84283
|
-
if (!
|
|
84413
|
+
if (!fs26.existsSync(dir))
|
|
84284
84414
|
return files;
|
|
84285
|
-
const entries =
|
|
84415
|
+
const entries = fs26.readdirSync(dir, { withFileTypes: true });
|
|
84286
84416
|
for (const entry of entries) {
|
|
84287
|
-
const fullPath =
|
|
84417
|
+
const fullPath = path28.join(dir, entry.name);
|
|
84288
84418
|
if (entry.isDirectory()) {
|
|
84289
84419
|
if (excludedDirs.has(entry.name)) {
|
|
84290
84420
|
continue;
|
|
@@ -84345,13 +84475,13 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
84345
84475
|
processedPackages.add(packageName);
|
|
84346
84476
|
if (resolvedFiles.length > 0) {
|
|
84347
84477
|
const firstResolvedFile = resolvedFiles[0];
|
|
84348
|
-
let packageDir =
|
|
84478
|
+
let packageDir = path28.dirname(firstResolvedFile);
|
|
84349
84479
|
let hasPackageJson = false;
|
|
84350
84480
|
while (packageDir.includes("node_modules")) {
|
|
84351
|
-
const packageJsonPath =
|
|
84352
|
-
if (
|
|
84481
|
+
const packageJsonPath = path28.join(packageDir, "package.json");
|
|
84482
|
+
if (fs26.existsSync(packageJsonPath)) {
|
|
84353
84483
|
try {
|
|
84354
|
-
const pkgJson = JSON.parse(
|
|
84484
|
+
const pkgJson = JSON.parse(fs26.readFileSync(packageJsonPath, "utf-8"));
|
|
84355
84485
|
if (pkgJson.name === packageName) {
|
|
84356
84486
|
hasPackageJson = true;
|
|
84357
84487
|
break;
|
|
@@ -84359,15 +84489,15 @@ function getAllNodeModuleFilePaths(entryFilePath, projectDir) {
|
|
|
84359
84489
|
} catch {}
|
|
84360
84490
|
}
|
|
84361
84491
|
const expectedPackagePath = packageName.startsWith("@") ? `node_modules/${packageName}` : `node_modules/${packageName}`;
|
|
84362
|
-
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g,
|
|
84492
|
+
if (packageDir.endsWith(expectedPackagePath) || packageDir.endsWith(expectedPackagePath.replace(/\//g, path28.sep))) {
|
|
84363
84493
|
break;
|
|
84364
84494
|
}
|
|
84365
|
-
const parentDir =
|
|
84495
|
+
const parentDir = path28.dirname(packageDir);
|
|
84366
84496
|
if (parentDir === packageDir)
|
|
84367
84497
|
break;
|
|
84368
84498
|
packageDir = parentDir;
|
|
84369
84499
|
}
|
|
84370
|
-
if (
|
|
84500
|
+
if (fs26.existsSync(packageDir)) {
|
|
84371
84501
|
if (hasPackageJson) {
|
|
84372
84502
|
const packageFiles = collectLocalPackageFiles(packageDir);
|
|
84373
84503
|
packageFiles.forEach((file) => allFiles.add(file));
|
|
@@ -84412,7 +84542,7 @@ class DevServer {
|
|
|
84412
84542
|
}) {
|
|
84413
84543
|
this.port = port;
|
|
84414
84544
|
this.componentFilePath = componentFilePath;
|
|
84415
|
-
this.projectDir = projectDir ??
|
|
84545
|
+
this.projectDir = projectDir ?? path29.dirname(componentFilePath);
|
|
84416
84546
|
this.kicadPcm = kicadPcm ?? false;
|
|
84417
84547
|
const projectConfig = loadProjectConfig(this.projectDir);
|
|
84418
84548
|
this.ignoredFiles = projectConfig?.ignoredFiles ?? [];
|
|
@@ -84423,7 +84553,7 @@ class DevServer {
|
|
|
84423
84553
|
async start() {
|
|
84424
84554
|
const { server } = await createHttpServer({
|
|
84425
84555
|
port: this.port,
|
|
84426
|
-
defaultMainComponentPath:
|
|
84556
|
+
defaultMainComponentPath: path29.relative(this.projectDir, this.componentFilePath),
|
|
84427
84557
|
kicadPcm: this.kicadPcm,
|
|
84428
84558
|
projectDir: this.projectDir,
|
|
84429
84559
|
entryFile: this.componentFilePath
|
|
@@ -84439,7 +84569,7 @@ class DevServer {
|
|
|
84439
84569
|
this.filesystemWatcher = watch(this.projectDir, {
|
|
84440
84570
|
persistent: true,
|
|
84441
84571
|
ignoreInitial: true,
|
|
84442
|
-
ignored: (p) => shouldIgnorePath(
|
|
84572
|
+
ignored: (p) => shouldIgnorePath(path29.relative(this.projectDir, p), this.ignoredFiles)
|
|
84443
84573
|
});
|
|
84444
84574
|
this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
84445
84575
|
this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
|
|
@@ -84454,27 +84584,27 @@ class DevServer {
|
|
|
84454
84584
|
const { file } = await this.fsKy.get("api/files/get", {
|
|
84455
84585
|
searchParams: { file_path: ev.file_path }
|
|
84456
84586
|
}).json();
|
|
84457
|
-
const fullPath =
|
|
84458
|
-
const dirPath =
|
|
84459
|
-
if (!
|
|
84460
|
-
|
|
84587
|
+
const fullPath = path29.join(this.projectDir, ev.file_path);
|
|
84588
|
+
const dirPath = path29.dirname(fullPath);
|
|
84589
|
+
if (!fs27.existsSync(dirPath)) {
|
|
84590
|
+
fs27.mkdirSync(dirPath, { recursive: true });
|
|
84461
84591
|
}
|
|
84462
84592
|
if (file.binary_content_b64) {
|
|
84463
84593
|
const decodedContent = Buffer.from(file.binary_content_b64, "base64");
|
|
84464
|
-
|
|
84594
|
+
fs27.writeFileSync(fullPath, decodedContent);
|
|
84465
84595
|
} else {
|
|
84466
|
-
|
|
84596
|
+
fs27.writeFileSync(fullPath, file.text_content ?? "", "utf-8");
|
|
84467
84597
|
}
|
|
84468
84598
|
}
|
|
84469
84599
|
async handleFileDeletedEventFromServer(ev) {
|
|
84470
|
-
const fullPath =
|
|
84471
|
-
if (
|
|
84600
|
+
const fullPath = path29.join(this.projectDir, ev.file_path);
|
|
84601
|
+
if (fs27.existsSync(fullPath)) {
|
|
84472
84602
|
debug2(`Deleting file ${ev.file_path} from filesystem`);
|
|
84473
|
-
|
|
84603
|
+
fs27.unlinkSync(fullPath);
|
|
84474
84604
|
}
|
|
84475
84605
|
}
|
|
84476
84606
|
async handleFileChangedOnFilesystem(absoluteFilePath) {
|
|
84477
|
-
const relativeFilePath =
|
|
84607
|
+
const relativeFilePath = path29.relative(this.projectDir, absoluteFilePath);
|
|
84478
84608
|
if (relativeFilePath.includes("manual-edits.json"))
|
|
84479
84609
|
return;
|
|
84480
84610
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
@@ -84489,14 +84619,14 @@ class DevServer {
|
|
|
84489
84619
|
await this.checkAndUploadNewNodeModules(absoluteFilePath);
|
|
84490
84620
|
}
|
|
84491
84621
|
async checkAndUploadNewNodeModules(filePath) {
|
|
84492
|
-
const ext =
|
|
84622
|
+
const ext = path29.extname(filePath).toLowerCase();
|
|
84493
84623
|
const isSourceFile = [".ts", ".tsx", ".js", ".jsx", ".mjs"].includes(ext);
|
|
84494
84624
|
if (!isSourceFile)
|
|
84495
84625
|
return;
|
|
84496
84626
|
try {
|
|
84497
84627
|
const nodeModuleFiles = getAllNodeModuleFilePaths(filePath, this.projectDir);
|
|
84498
84628
|
const newFiles = nodeModuleFiles.filter((file) => {
|
|
84499
|
-
const relativePath =
|
|
84629
|
+
const relativePath = path29.relative(this.projectDir, file);
|
|
84500
84630
|
return !this.uploadedNodeModules.has(relativePath);
|
|
84501
84631
|
});
|
|
84502
84632
|
if (newFiles.length === 0)
|
|
@@ -84509,7 +84639,7 @@ class DevServer {
|
|
|
84509
84639
|
}
|
|
84510
84640
|
}
|
|
84511
84641
|
async handleFileRemovedFromFilesystem(absoluteFilePath) {
|
|
84512
|
-
const relativeFilePath =
|
|
84642
|
+
const relativeFilePath = path29.relative(this.projectDir, absoluteFilePath);
|
|
84513
84643
|
if (shouldIgnorePath(relativeFilePath, this.ignoredFiles))
|
|
84514
84644
|
return;
|
|
84515
84645
|
if (!relativeFilePath || relativeFilePath.trim() === "") {
|
|
@@ -84547,8 +84677,8 @@ class DevServer {
|
|
|
84547
84677
|
debug2(`Successfully deleted file ${relativeFilePath} from server`);
|
|
84548
84678
|
}
|
|
84549
84679
|
async handleFileRename(oldPath, newPath) {
|
|
84550
|
-
const oldRelativePath =
|
|
84551
|
-
const newRelativePath =
|
|
84680
|
+
const oldRelativePath = path29.relative(this.projectDir, oldPath);
|
|
84681
|
+
const newRelativePath = path29.relative(this.projectDir, newPath);
|
|
84552
84682
|
if (shouldIgnorePath(oldRelativePath, this.ignoredFiles) || shouldIgnorePath(newRelativePath, this.ignoredFiles))
|
|
84553
84683
|
return;
|
|
84554
84684
|
await this.handleFileRemovedFromFilesystem(oldPath);
|
|
@@ -84566,7 +84696,7 @@ class DevServer {
|
|
|
84566
84696
|
});
|
|
84567
84697
|
const filePaths = getPackageFilePaths(this.projectDir, this.ignoredFiles);
|
|
84568
84698
|
for (const filePath of filePaths) {
|
|
84569
|
-
const relativeFilePath =
|
|
84699
|
+
const relativeFilePath = path29.relative(this.projectDir, filePath);
|
|
84570
84700
|
const filePayload = this.createFileUploadPayload(filePath, relativeFilePath);
|
|
84571
84701
|
await this.postFileUpsert({
|
|
84572
84702
|
filePath: relativeFilePath,
|
|
@@ -84598,7 +84728,7 @@ class DevServer {
|
|
|
84598
84728
|
}
|
|
84599
84729
|
async uploadNodeModuleFiles(files) {
|
|
84600
84730
|
for (const nodeModuleFile of files) {
|
|
84601
|
-
const relativeFilePath =
|
|
84731
|
+
const relativeFilePath = path29.relative(this.projectDir, nodeModuleFile);
|
|
84602
84732
|
this.uploadedNodeModules.add(relativeFilePath);
|
|
84603
84733
|
const filePayload = this.createFileUploadPayload(nodeModuleFile, relativeFilePath);
|
|
84604
84734
|
await this.postFileUpsert({
|
|
@@ -84656,12 +84786,12 @@ class DevServer {
|
|
|
84656
84786
|
await this.filesystemWatcher?.close();
|
|
84657
84787
|
}
|
|
84658
84788
|
createFileUploadPayload(absoluteFilePath, relativeFilePath) {
|
|
84659
|
-
const ext =
|
|
84789
|
+
const ext = path29.extname(relativeFilePath).toLowerCase();
|
|
84660
84790
|
if (BINARY_FILE_EXTENSIONS2.has(ext)) {
|
|
84661
|
-
const fileBuffer =
|
|
84791
|
+
const fileBuffer = fs27.readFileSync(absoluteFilePath);
|
|
84662
84792
|
return { binary_content_b64: fileBuffer.toString("base64") };
|
|
84663
84793
|
}
|
|
84664
|
-
return { text_content:
|
|
84794
|
+
return { text_content: fs27.readFileSync(absoluteFilePath, "utf-8") };
|
|
84665
84795
|
}
|
|
84666
84796
|
async handleInstallPackage(full_package_name) {
|
|
84667
84797
|
const postEvent = async (event, message) => {
|
|
@@ -84691,15 +84821,15 @@ class DevServer {
|
|
|
84691
84821
|
}
|
|
84692
84822
|
|
|
84693
84823
|
// cli/dev/resolve-dev-target.ts
|
|
84694
|
-
import * as
|
|
84695
|
-
import * as
|
|
84824
|
+
import * as fs29 from "node:fs";
|
|
84825
|
+
import * as path31 from "node:path";
|
|
84696
84826
|
|
|
84697
84827
|
// lib/shared/find-board-files.ts
|
|
84698
|
-
import
|
|
84699
|
-
import
|
|
84828
|
+
import fs28 from "node:fs";
|
|
84829
|
+
import path30 from "node:path";
|
|
84700
84830
|
var isSubPath = (maybeChild, maybeParent) => {
|
|
84701
|
-
const relative6 =
|
|
84702
|
-
return relative6 === "" || !relative6.startsWith("..") && !
|
|
84831
|
+
const relative6 = path30.relative(maybeParent, maybeChild);
|
|
84832
|
+
return relative6 === "" || !relative6.startsWith("..") && !path30.isAbsolute(relative6);
|
|
84703
84833
|
};
|
|
84704
84834
|
var isGlobPattern = (str) => {
|
|
84705
84835
|
return /[*?[\]{}]/.test(str);
|
|
@@ -84709,13 +84839,13 @@ var findBoardFiles = ({
|
|
|
84709
84839
|
ignore = DEFAULT_IGNORED_PATTERNS,
|
|
84710
84840
|
filePaths = []
|
|
84711
84841
|
} = {}) => {
|
|
84712
|
-
const resolvedProjectDir =
|
|
84842
|
+
const resolvedProjectDir = path30.resolve(projectDir);
|
|
84713
84843
|
const boardFilePatterns = getBoardFilePatterns(resolvedProjectDir);
|
|
84714
84844
|
const relativeBoardFiles = globbySync(boardFilePatterns, {
|
|
84715
84845
|
cwd: resolvedProjectDir,
|
|
84716
84846
|
ignore
|
|
84717
84847
|
});
|
|
84718
|
-
const absoluteBoardFiles = relativeBoardFiles.map((f) =>
|
|
84848
|
+
const absoluteBoardFiles = relativeBoardFiles.map((f) => path30.join(resolvedProjectDir, f));
|
|
84719
84849
|
const boardFileSet = new Set;
|
|
84720
84850
|
if (filePaths.length > 0) {
|
|
84721
84851
|
for (const inputPath of filePaths) {
|
|
@@ -84729,13 +84859,13 @@ var findBoardFiles = ({
|
|
|
84729
84859
|
boardFileSet.add(match);
|
|
84730
84860
|
}
|
|
84731
84861
|
} else {
|
|
84732
|
-
const targetPath =
|
|
84733
|
-
if (!
|
|
84862
|
+
const targetPath = path30.resolve(resolvedProjectDir, inputPath);
|
|
84863
|
+
if (!fs28.existsSync(targetPath)) {
|
|
84734
84864
|
continue;
|
|
84735
84865
|
}
|
|
84736
|
-
const stat4 =
|
|
84866
|
+
const stat4 = fs28.statSync(targetPath);
|
|
84737
84867
|
if (stat4.isDirectory()) {
|
|
84738
|
-
const resolvedDir =
|
|
84868
|
+
const resolvedDir = path30.resolve(targetPath);
|
|
84739
84869
|
if (isSubPath(resolvedDir, resolvedProjectDir)) {
|
|
84740
84870
|
for (const boardFile of absoluteBoardFiles) {
|
|
84741
84871
|
if (isSubPath(boardFile, resolvedDir)) {
|
|
@@ -84746,7 +84876,7 @@ var findBoardFiles = ({
|
|
|
84746
84876
|
const externalMatches = globbySync(boardFilePatterns, {
|
|
84747
84877
|
cwd: resolvedDir,
|
|
84748
84878
|
ignore
|
|
84749
|
-
}).map((f) =>
|
|
84879
|
+
}).map((f) => path30.join(resolvedDir, f));
|
|
84750
84880
|
for (const match of externalMatches) {
|
|
84751
84881
|
boardFileSet.add(match);
|
|
84752
84882
|
}
|
|
@@ -84766,7 +84896,7 @@ var findBoardFiles = ({
|
|
|
84766
84896
|
|
|
84767
84897
|
// cli/dev/resolve-dev-target.ts
|
|
84768
84898
|
var findSelectableFiles = (projectDir) => {
|
|
84769
|
-
const boardFiles = findBoardFiles({ projectDir }).filter((file) =>
|
|
84899
|
+
const boardFiles = findBoardFiles({ projectDir }).filter((file) => fs29.existsSync(file)).sort();
|
|
84770
84900
|
if (boardFiles.length > 0) {
|
|
84771
84901
|
return boardFiles;
|
|
84772
84902
|
}
|
|
@@ -84774,7 +84904,7 @@ var findSelectableFiles = (projectDir) => {
|
|
|
84774
84904
|
cwd: projectDir,
|
|
84775
84905
|
ignore: DEFAULT_IGNORED_PATTERNS
|
|
84776
84906
|
});
|
|
84777
|
-
return files.map((file) =>
|
|
84907
|
+
return files.map((file) => path31.resolve(projectDir, file)).filter((file) => fs29.existsSync(file)).sort();
|
|
84778
84908
|
};
|
|
84779
84909
|
var isValidDevFile = (filePath) => {
|
|
84780
84910
|
return filePath.endsWith(".tsx") || filePath.endsWith(".ts") || filePath.endsWith(".circuit.json");
|
|
@@ -84782,18 +84912,18 @@ var isValidDevFile = (filePath) => {
|
|
|
84782
84912
|
var resolveDevTarget = async (file) => {
|
|
84783
84913
|
let projectDir = process.cwd();
|
|
84784
84914
|
if (file) {
|
|
84785
|
-
const resolvedPath =
|
|
84786
|
-
if (
|
|
84915
|
+
const resolvedPath = path31.resolve(file);
|
|
84916
|
+
if (fs29.existsSync(resolvedPath) && fs29.statSync(resolvedPath).isDirectory()) {
|
|
84787
84917
|
projectDir = resolvedPath;
|
|
84788
84918
|
const availableFiles2 = findSelectableFiles(projectDir);
|
|
84789
84919
|
if (availableFiles2.length === 0) {
|
|
84790
84920
|
console.log(`No .tsx, .ts, or .circuit.json files found in ${projectDir}. Run 'tsci init' to bootstrap a basic project.`);
|
|
84791
84921
|
return null;
|
|
84792
84922
|
}
|
|
84793
|
-
console.log("Selected file:",
|
|
84923
|
+
console.log("Selected file:", path31.relative(projectDir, availableFiles2[0]));
|
|
84794
84924
|
return { absolutePath: availableFiles2[0], projectDir };
|
|
84795
84925
|
}
|
|
84796
|
-
if (!
|
|
84926
|
+
if (!fs29.existsSync(resolvedPath)) {
|
|
84797
84927
|
console.error(`Error: File not found: ${file}`);
|
|
84798
84928
|
return null;
|
|
84799
84929
|
}
|
|
@@ -84804,7 +84934,7 @@ var resolveDevTarget = async (file) => {
|
|
|
84804
84934
|
return { absolutePath: resolvedPath, projectDir };
|
|
84805
84935
|
}
|
|
84806
84936
|
const entrypointPath = await getEntrypoint({ onError: () => {} });
|
|
84807
|
-
if (entrypointPath &&
|
|
84937
|
+
if (entrypointPath && fs29.existsSync(entrypointPath)) {
|
|
84808
84938
|
console.log("Found entrypoint at:", entrypointPath);
|
|
84809
84939
|
return { absolutePath: entrypointPath, projectDir };
|
|
84810
84940
|
}
|
|
@@ -84813,7 +84943,7 @@ var resolveDevTarget = async (file) => {
|
|
|
84813
84943
|
console.log("No .tsx, .ts, or .circuit.json files found in the project. Run 'tsci init' to bootstrap a basic project.");
|
|
84814
84944
|
return null;
|
|
84815
84945
|
}
|
|
84816
|
-
console.log("Selected file:",
|
|
84946
|
+
console.log("Selected file:", path31.relative(projectDir, availableFiles[0]));
|
|
84817
84947
|
return { absolutePath: availableFiles[0], projectDir };
|
|
84818
84948
|
};
|
|
84819
84949
|
|
|
@@ -84835,12 +84965,12 @@ var isPortAvailable = (port) => {
|
|
|
84835
84965
|
});
|
|
84836
84966
|
};
|
|
84837
84967
|
var warnIfTsconfigMissingTscircuitType = (projectDir) => {
|
|
84838
|
-
const tsconfigPath =
|
|
84839
|
-
if (!
|
|
84968
|
+
const tsconfigPath = path32.join(projectDir, "tsconfig.json");
|
|
84969
|
+
if (!fs30.existsSync(tsconfigPath)) {
|
|
84840
84970
|
return;
|
|
84841
84971
|
}
|
|
84842
84972
|
try {
|
|
84843
|
-
const tsconfig = JSON.parse(
|
|
84973
|
+
const tsconfig = JSON.parse(fs30.readFileSync(tsconfigPath, "utf-8"));
|
|
84844
84974
|
const types = tsconfig?.compilerOptions?.types;
|
|
84845
84975
|
if (!Array.isArray(types) || !types.includes("tscircuit")) {
|
|
84846
84976
|
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.'));
|
|
@@ -84872,7 +85002,7 @@ var registerDev = (program3) => {
|
|
|
84872
85002
|
|
|
84873
85003
|
${kleur_default.green(`@tscircuit/cli@${getVersion()}`)} ${kleur_default.gray("ready in")} ${kleur_default.white(`${Math.round(timeToStart)}ms`)}`);
|
|
84874
85004
|
console.log(`
|
|
84875
|
-
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(
|
|
85005
|
+
${kleur_default.bold("➜ Local:")} ${kleur_default.underline(kleur_default.cyan(`http://localhost:${port}`))}${server.componentFilePath ? kleur_default.underline(kleur_default.cyan(`/#file=${encodeURIComponent(path32.relative(process.cwd(), server.componentFilePath).replaceAll("\\", "/"))}`)) : ""}
|
|
84876
85006
|
|
|
84877
85007
|
`);
|
|
84878
85008
|
console.log(kleur_default.gray(`Watching ${kleur_default.underline(server.projectDir.split("/").slice(-2).join("/"))} for changes...`));
|
|
@@ -84932,21 +85062,21 @@ var delay2 = createDelay();
|
|
|
84932
85062
|
var delay_default = delay2;
|
|
84933
85063
|
|
|
84934
85064
|
// cli/auth/setup-npmrc/setup-npmrc.ts
|
|
84935
|
-
import * as
|
|
84936
|
-
import * as
|
|
85065
|
+
import * as fs31 from "node:fs";
|
|
85066
|
+
import * as path33 from "node:path";
|
|
84937
85067
|
import * as os4 from "node:os";
|
|
84938
85068
|
var REGISTRY_URL = "npm.tscircuit.com";
|
|
84939
85069
|
function findGlobalNpmrc() {
|
|
84940
85070
|
const possiblePaths = [
|
|
84941
|
-
|
|
84942
|
-
process.env.USERPROFILE ?
|
|
85071
|
+
path33.join(os4.homedir(), ".npmrc"),
|
|
85072
|
+
process.env.USERPROFILE ? path33.join(process.env.USERPROFILE, ".npmrc") : null
|
|
84943
85073
|
].filter(Boolean);
|
|
84944
85074
|
for (const npmrcPath of possiblePaths) {
|
|
84945
|
-
if (
|
|
85075
|
+
if (fs31.existsSync(npmrcPath)) {
|
|
84946
85076
|
return npmrcPath;
|
|
84947
85077
|
}
|
|
84948
85078
|
}
|
|
84949
|
-
return
|
|
85079
|
+
return path33.join(os4.homedir(), ".npmrc");
|
|
84950
85080
|
}
|
|
84951
85081
|
function printManualInstructions(sessionToken) {
|
|
84952
85082
|
console.log(kleur_default.yellow(`
|
|
@@ -84954,7 +85084,7 @@ Manual setup instructions:`));
|
|
|
84954
85084
|
console.log(kleur_default.gray("─".repeat(50)));
|
|
84955
85085
|
console.log(`
|
|
84956
85086
|
1. Open or create your global .npmrc file:`);
|
|
84957
|
-
console.log(kleur_default.cyan(` ${
|
|
85087
|
+
console.log(kleur_default.cyan(` ${path33.join(os4.homedir(), ".npmrc")}`));
|
|
84958
85088
|
console.log(`
|
|
84959
85089
|
2. Add the following line:`);
|
|
84960
85090
|
console.log(kleur_default.cyan(` //${REGISTRY_URL}/:_authToken=${sessionToken}`));
|
|
@@ -84973,8 +85103,8 @@ function setupNpmrc(sessionToken) {
|
|
|
84973
85103
|
}
|
|
84974
85104
|
try {
|
|
84975
85105
|
let existingContent = "";
|
|
84976
|
-
if (
|
|
84977
|
-
existingContent =
|
|
85106
|
+
if (fs31.existsSync(npmrcPath)) {
|
|
85107
|
+
existingContent = fs31.readFileSync(npmrcPath, "utf-8");
|
|
84978
85108
|
}
|
|
84979
85109
|
let registryAdded = false;
|
|
84980
85110
|
const registryRegex = new RegExp(`^${registryLine.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`, "m");
|
|
@@ -84998,7 +85128,7 @@ ${registryLine}
|
|
|
84998
85128
|
const authLineRegex = new RegExp(`^//${REGISTRY_URL.replace(/\./g, "\\.")}/:_authToken=.+$`, "m");
|
|
84999
85129
|
if (authLineRegex.test(existingContent)) {
|
|
85000
85130
|
const updatedContent = existingContent.replace(authLineRegex, authLine);
|
|
85001
|
-
|
|
85131
|
+
fs31.writeFileSync(npmrcPath, updatedContent, "utf-8");
|
|
85002
85132
|
console.log(kleur_default.green(`Updated authentication token in ${npmrcPath}`) + (registryAdded ? `
|
|
85003
85133
|
${kleur_default.green(`Added registry setting to ${npmrcPath}`)}` : ""));
|
|
85004
85134
|
return true;
|
|
@@ -85009,7 +85139,7 @@ ${kleur_default.green(`Added registry setting to ${npmrcPath}`)}` : ""));
|
|
|
85009
85139
|
${authLine}
|
|
85010
85140
|
` : `${authLine}
|
|
85011
85141
|
`;
|
|
85012
|
-
|
|
85142
|
+
fs31.writeFileSync(npmrcPath, newContent, "utf-8");
|
|
85013
85143
|
if (registryAdded) {
|
|
85014
85144
|
console.log(kleur_default.green(`Added authentication token and registry setting to ${npmrcPath}`));
|
|
85015
85145
|
} else {
|
|
@@ -85107,26 +85237,26 @@ var registerConfigPrint = (program3) => {
|
|
|
85107
85237
|
};
|
|
85108
85238
|
|
|
85109
85239
|
// cli/clone/register.ts
|
|
85110
|
-
import * as
|
|
85111
|
-
import * as
|
|
85240
|
+
import * as fs34 from "node:fs";
|
|
85241
|
+
import * as path36 from "node:path";
|
|
85112
85242
|
|
|
85113
85243
|
// cli/clone/clone-bug-report.ts
|
|
85114
85244
|
var import_jszip3 = __toESM2(require_lib4(), 1);
|
|
85115
85245
|
var import_prompts8 = __toESM2(require_prompts3(), 1);
|
|
85116
|
-
import * as
|
|
85117
|
-
import * as
|
|
85246
|
+
import * as fs33 from "node:fs";
|
|
85247
|
+
import * as path35 from "node:path";
|
|
85118
85248
|
|
|
85119
85249
|
// cli/clone/handle-existing-directory.ts
|
|
85120
85250
|
var import_prompts7 = __toESM2(require_prompts3(), 1);
|
|
85121
|
-
import * as
|
|
85122
|
-
import * as
|
|
85251
|
+
import * as fs32 from "node:fs";
|
|
85252
|
+
import * as path34 from "node:path";
|
|
85123
85253
|
var handleExistingDirectory = async (dirPath) => {
|
|
85124
|
-
if (!
|
|
85254
|
+
if (!fs32.existsSync(dirPath))
|
|
85125
85255
|
return;
|
|
85126
85256
|
const response = await import_prompts7.default({
|
|
85127
85257
|
type: "select",
|
|
85128
85258
|
name: "action",
|
|
85129
|
-
message: `Directory "${
|
|
85259
|
+
message: `Directory "${path34.basename(dirPath)}" already exists. What would you like to do?`,
|
|
85130
85260
|
choices: [
|
|
85131
85261
|
{ title: "Merge files into existing directory", value: "merge" },
|
|
85132
85262
|
{
|
|
@@ -85141,7 +85271,7 @@ var handleExistingDirectory = async (dirPath) => {
|
|
|
85141
85271
|
process.exit(0);
|
|
85142
85272
|
}
|
|
85143
85273
|
if (response.action === "delete") {
|
|
85144
|
-
|
|
85274
|
+
fs32.rmSync(dirPath, { recursive: true, force: true });
|
|
85145
85275
|
console.log(`Deleted existing directory: ${dirPath}`);
|
|
85146
85276
|
} else if (response.action === "merge") {
|
|
85147
85277
|
console.log(`Merging files into existing directory: ${dirPath}`);
|
|
@@ -85167,12 +85297,12 @@ var getCommonDirectoryPrefix = (paths) => {
|
|
|
85167
85297
|
return commonSegments.join("/");
|
|
85168
85298
|
};
|
|
85169
85299
|
var sanitizeRelativePath = (relativePath) => {
|
|
85170
|
-
const normalizedPath =
|
|
85300
|
+
const normalizedPath = path35.normalize(relativePath);
|
|
85171
85301
|
if (!normalizedPath)
|
|
85172
85302
|
return null;
|
|
85173
|
-
if (
|
|
85303
|
+
if (path35.isAbsolute(normalizedPath))
|
|
85174
85304
|
return null;
|
|
85175
|
-
const segments = normalizedPath.split(
|
|
85305
|
+
const segments = normalizedPath.split(path35.sep);
|
|
85176
85306
|
if (segments.some((segment) => segment === ".." || segment === "")) {
|
|
85177
85307
|
return null;
|
|
85178
85308
|
}
|
|
@@ -85187,7 +85317,7 @@ var cloneBugReport = async ({
|
|
|
85187
85317
|
console.error("Bug report ID must not be empty.");
|
|
85188
85318
|
process.exit(1);
|
|
85189
85319
|
}
|
|
85190
|
-
let dirPath =
|
|
85320
|
+
let dirPath = path35.resolve(`bug-report-${trimmedBugReportId}`);
|
|
85191
85321
|
await handleExistingDirectory(dirPath);
|
|
85192
85322
|
const ky2 = getRegistryApiKy();
|
|
85193
85323
|
let zipBuffer;
|
|
@@ -85205,7 +85335,7 @@ var cloneBugReport = async ({
|
|
|
85205
85335
|
}
|
|
85206
85336
|
process.exit(1);
|
|
85207
85337
|
}
|
|
85208
|
-
|
|
85338
|
+
fs33.mkdirSync(dirPath, { recursive: true });
|
|
85209
85339
|
const zip = await import_jszip3.default.loadAsync(zipBuffer);
|
|
85210
85340
|
const fileEntries = Object.entries(zip.files).filter(([, entry]) => !entry.dir);
|
|
85211
85341
|
const commonPrefix = getCommonDirectoryPrefix(fileEntries.map(([fileName]) => fileName));
|
|
@@ -85217,29 +85347,29 @@ var cloneBugReport = async ({
|
|
|
85217
85347
|
console.warn(`Skipping potentially unsafe path: ${fileName}`);
|
|
85218
85348
|
continue;
|
|
85219
85349
|
}
|
|
85220
|
-
const fullPath =
|
|
85221
|
-
|
|
85350
|
+
const fullPath = path35.join(dirPath, sanitizedRelativePath);
|
|
85351
|
+
fs33.mkdirSync(path35.dirname(fullPath), { recursive: true });
|
|
85222
85352
|
const fileContent = await entry.async("nodebuffer");
|
|
85223
|
-
|
|
85353
|
+
fs33.writeFileSync(fullPath, fileContent);
|
|
85224
85354
|
}
|
|
85225
|
-
const packageJsonPath =
|
|
85226
|
-
if (
|
|
85355
|
+
const packageJsonPath = path35.join(dirPath, "package.json");
|
|
85356
|
+
if (fs33.existsSync(packageJsonPath)) {
|
|
85227
85357
|
try {
|
|
85228
|
-
const packageJson = JSON.parse(
|
|
85358
|
+
const packageJson = JSON.parse(fs33.readFileSync(packageJsonPath, "utf-8"));
|
|
85229
85359
|
const packageName = packageJson?.name;
|
|
85230
85360
|
if (typeof packageName === "string" && packageName.trim()) {
|
|
85231
85361
|
const sanitizedName = packageName.replace(/[^a-zA-Z0-9]/g, "_");
|
|
85232
|
-
const suggestedDirPath =
|
|
85362
|
+
const suggestedDirPath = path35.resolve(`${sanitizedName}_${trimmedBugReportId.slice(7)}`);
|
|
85233
85363
|
if (suggestedDirPath !== dirPath) {
|
|
85234
85364
|
const response = await import_prompts8.default({
|
|
85235
85365
|
type: "confirm",
|
|
85236
85366
|
name: "rename",
|
|
85237
85367
|
initial: true,
|
|
85238
|
-
message: `Rename the directory to "${
|
|
85368
|
+
message: `Rename the directory to "${path35.basename(suggestedDirPath)}"?`
|
|
85239
85369
|
});
|
|
85240
85370
|
if (response.rename) {
|
|
85241
85371
|
await handleExistingDirectory(suggestedDirPath);
|
|
85242
|
-
|
|
85372
|
+
fs33.renameSync(dirPath, suggestedDirPath);
|
|
85243
85373
|
dirPath = suggestedDirPath;
|
|
85244
85374
|
}
|
|
85245
85375
|
}
|
|
@@ -85248,9 +85378,9 @@ var cloneBugReport = async ({
|
|
|
85248
85378
|
console.warn("Unable to read package name for renaming:", error);
|
|
85249
85379
|
}
|
|
85250
85380
|
}
|
|
85251
|
-
|
|
85381
|
+
fs33.writeFileSync(path35.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
85252
85382
|
generateTsConfig(dirPath);
|
|
85253
|
-
const relativeDirPath =
|
|
85383
|
+
const relativeDirPath = path35.relative(originalCwd, dirPath);
|
|
85254
85384
|
console.log(kleur_default.green(`
|
|
85255
85385
|
Successfully cloned bug report to:`));
|
|
85256
85386
|
console.log(` ${dirPath}/
|
|
@@ -85289,7 +85419,7 @@ var registerClone = (program3) => {
|
|
|
85289
85419
|
const [, author, packageName] = match;
|
|
85290
85420
|
console.log(`Cloning ${author}/${packageName}...`);
|
|
85291
85421
|
const userSettingToIncludeAuthor = options.includeAuthor || cliConfig.get("alwaysCloneWithAuthorName");
|
|
85292
|
-
const dirPath = userSettingToIncludeAuthor ?
|
|
85422
|
+
const dirPath = userSettingToIncludeAuthor ? path36.resolve(`${author}.${packageName}`) : path36.resolve(packageName);
|
|
85293
85423
|
await handleExistingDirectory(dirPath);
|
|
85294
85424
|
const ky2 = getRegistryApiKy();
|
|
85295
85425
|
let packageFileList = {
|
|
@@ -85310,13 +85440,13 @@ var registerClone = (program3) => {
|
|
|
85310
85440
|
console.error("Failed to fetch package files:", error instanceof Error ? error.message : error);
|
|
85311
85441
|
process.exit(1);
|
|
85312
85442
|
}
|
|
85313
|
-
|
|
85443
|
+
fs34.mkdirSync(dirPath, { recursive: true });
|
|
85314
85444
|
for (const fileInfo of packageFileList.package_files) {
|
|
85315
85445
|
const filePath = fileInfo.file_path.replace(/^\/+/, "");
|
|
85316
85446
|
if (!filePath)
|
|
85317
85447
|
continue;
|
|
85318
|
-
const fullPath =
|
|
85319
|
-
|
|
85448
|
+
const fullPath = path36.join(dirPath, filePath);
|
|
85449
|
+
fs34.mkdirSync(path36.dirname(fullPath), { recursive: true });
|
|
85320
85450
|
try {
|
|
85321
85451
|
const fileContent = await ky2.get("package_files/get", {
|
|
85322
85452
|
searchParams: {
|
|
@@ -85327,14 +85457,14 @@ var registerClone = (program3) => {
|
|
|
85327
85457
|
}).json();
|
|
85328
85458
|
const { is_text: isText, content_text: contentText } = fileContent.package_file;
|
|
85329
85459
|
if (isText && typeof contentText === "string") {
|
|
85330
|
-
|
|
85460
|
+
fs34.writeFileSync(fullPath, contentText);
|
|
85331
85461
|
} else if (!isText) {
|
|
85332
85462
|
const fileBuffer = await ky2.get("package_files/download", {
|
|
85333
85463
|
searchParams: {
|
|
85334
85464
|
package_file_id: fileContent.package_file.package_file_id
|
|
85335
85465
|
}
|
|
85336
85466
|
}).arrayBuffer();
|
|
85337
|
-
|
|
85467
|
+
fs34.writeFileSync(fullPath, Buffer.from(fileBuffer));
|
|
85338
85468
|
} else {
|
|
85339
85469
|
console.warn(`Skipping ${filePath} due to empty content.`);
|
|
85340
85470
|
}
|
|
@@ -85342,10 +85472,10 @@ var registerClone = (program3) => {
|
|
|
85342
85472
|
console.warn(`Skipping ${filePath} due to error:`, error instanceof Error ? error.message : error);
|
|
85343
85473
|
}
|
|
85344
85474
|
}
|
|
85345
|
-
|
|
85475
|
+
fs34.writeFileSync(path36.join(dirPath, ".npmrc"), "@tsci:registry=https://npm.tscircuit.com");
|
|
85346
85476
|
generateTsConfig(dirPath);
|
|
85347
85477
|
await setupTsciProject(dirPath);
|
|
85348
|
-
const relativeDirPath =
|
|
85478
|
+
const relativeDirPath = path36.relative(originalCwd, dirPath);
|
|
85349
85479
|
console.log(kleur_default.green(`
|
|
85350
85480
|
Successfully cloned to:`));
|
|
85351
85481
|
console.log(` ${dirPath}/
|
|
@@ -85361,8 +85491,8 @@ Successfully cloned to:`));
|
|
|
85361
85491
|
var import_perfect_cli = __toESM2(require_dist7(), 1);
|
|
85362
85492
|
|
|
85363
85493
|
// lib/shared/export-snippet.ts
|
|
85364
|
-
import
|
|
85365
|
-
import
|
|
85494
|
+
import fs36 from "node:fs";
|
|
85495
|
+
import path38 from "node:path";
|
|
85366
85496
|
import { promisify as promisify3 } from "node:util";
|
|
85367
85497
|
import { convertCircuitJsonToGltf } from "circuit-json-to-gltf";
|
|
85368
85498
|
|
|
@@ -86435,9 +86565,9 @@ var stringifyDsnJson = (dsnJson) => {
|
|
|
86435
86565
|
const stringifyCoordinates = (coordinates) => {
|
|
86436
86566
|
return coordinates.join(" ");
|
|
86437
86567
|
};
|
|
86438
|
-
const stringifyPath = (
|
|
86568
|
+
const stringifyPath = (path37, level) => {
|
|
86439
86569
|
const padding = indent.repeat(level);
|
|
86440
|
-
return `${padding}(path ${
|
|
86570
|
+
return `${padding}(path ${path37.layer} ${path37.width} ${stringifyCoordinates(path37.coordinates)})`;
|
|
86441
86571
|
};
|
|
86442
86572
|
result += `(pcb ${dsnJson.filename ? dsnJson.filename : "./converted_dsn.dsn"}
|
|
86443
86573
|
`;
|
|
@@ -86622,8 +86752,8 @@ var import_jszip4 = __toESM2(require_lib4(), 1);
|
|
|
86622
86752
|
|
|
86623
86753
|
// lib/shared/generate-circuit-json.tsx
|
|
86624
86754
|
var import_make_vfs2 = __toESM2(require_dist8(), 1);
|
|
86625
|
-
import
|
|
86626
|
-
import
|
|
86755
|
+
import path37 from "node:path";
|
|
86756
|
+
import fs35 from "node:fs";
|
|
86627
86757
|
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
86628
86758
|
import Debug11 from "debug";
|
|
86629
86759
|
|
|
@@ -86669,12 +86799,12 @@ async function generateCircuitJson({
|
|
|
86669
86799
|
const runner = new userLandTscircuit.RootCircuit({
|
|
86670
86800
|
platform: platformConfig
|
|
86671
86801
|
});
|
|
86672
|
-
const absoluteFilePath =
|
|
86673
|
-
const projectDir =
|
|
86802
|
+
const absoluteFilePath = path37.isAbsolute(filePath) ? filePath : path37.resolve(process.cwd(), filePath);
|
|
86803
|
+
const projectDir = path37.dirname(absoluteFilePath);
|
|
86674
86804
|
const resolvedOutputDir = outputDir ?? projectDir;
|
|
86675
|
-
const relativeComponentPath =
|
|
86676
|
-
const baseFileName = outputFileName ||
|
|
86677
|
-
const outputPath =
|
|
86805
|
+
const relativeComponentPath = path37.relative(projectDir, absoluteFilePath);
|
|
86806
|
+
const baseFileName = outputFileName || path37.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
86807
|
+
const outputPath = path37.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
86678
86808
|
debug11(`Project directory: ${projectDir}`);
|
|
86679
86809
|
debug11(`Relative component path: ${relativeComponentPath}`);
|
|
86680
86810
|
debug11(`Output path: ${outputPath}`);
|
|
@@ -86694,7 +86824,7 @@ async function generateCircuitJson({
|
|
|
86694
86824
|
return false;
|
|
86695
86825
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
86696
86826
|
return false;
|
|
86697
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
86827
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path37.extname(normalizedFilePath)))
|
|
86698
86828
|
return false;
|
|
86699
86829
|
return true;
|
|
86700
86830
|
},
|
|
@@ -86712,7 +86842,7 @@ async function generateCircuitJson({
|
|
|
86712
86842
|
const circuitJson = await runner.getCircuitJson();
|
|
86713
86843
|
if (saveToFile) {
|
|
86714
86844
|
debug11(`Saving circuit JSON to ${outputPath}`);
|
|
86715
|
-
|
|
86845
|
+
fs35.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
86716
86846
|
}
|
|
86717
86847
|
return {
|
|
86718
86848
|
circuitJson,
|
|
@@ -86733,7 +86863,7 @@ var getCircuitJsonToGltfOptions = ({
|
|
|
86733
86863
|
};
|
|
86734
86864
|
|
|
86735
86865
|
// lib/shared/export-snippet.ts
|
|
86736
|
-
var writeFileAsync = promisify3(
|
|
86866
|
+
var writeFileAsync = promisify3(fs36.writeFile);
|
|
86737
86867
|
var ALLOWED_EXPORT_FORMATS = [
|
|
86738
86868
|
"json",
|
|
86739
86869
|
"circuit-json",
|
|
@@ -86778,10 +86908,10 @@ var exportSnippet = async ({
|
|
|
86778
86908
|
onError(`Invalid format: ${format}`);
|
|
86779
86909
|
return onExit(1);
|
|
86780
86910
|
}
|
|
86781
|
-
const projectDir =
|
|
86782
|
-
const outputBaseName =
|
|
86911
|
+
const projectDir = path38.dirname(filePath);
|
|
86912
|
+
const outputBaseName = path38.basename(filePath).replace(/\.[^.]+$/, "");
|
|
86783
86913
|
const outputFileName = `${outputBaseName}${OUTPUT_EXTENSIONS[format]}`;
|
|
86784
|
-
const outputDestination =
|
|
86914
|
+
const outputDestination = path38.join(projectDir, outputPath ?? outputFileName);
|
|
86785
86915
|
if (format === "kicad-library") {
|
|
86786
86916
|
try {
|
|
86787
86917
|
const result = await convertToKicadLibrary({
|
|
@@ -86978,12 +87108,12 @@ var getSpiceWithPaddedSim = (circuitJson, options) => {
|
|
|
86978
87108
|
};
|
|
86979
87109
|
|
|
86980
87110
|
// lib/eecircuit-engine/run-simulation.ts
|
|
86981
|
-
import { promises as
|
|
86982
|
-
import
|
|
87111
|
+
import { promises as fs37, existsSync as existsSync14 } from "node:fs";
|
|
87112
|
+
import path39 from "node:path";
|
|
86983
87113
|
import os5 from "node:os";
|
|
86984
87114
|
var sim = null;
|
|
86985
87115
|
var fetchSimulation = async () => {
|
|
86986
|
-
const tempFilePath =
|
|
87116
|
+
const tempFilePath = path39.join(os5.tmpdir(), "eecircuit-engine-1.5.2.mjs");
|
|
86987
87117
|
if (!existsSync14(tempFilePath)) {
|
|
86988
87118
|
const url = "https://cdn.jsdelivr.net/npm/eecircuit-engine@1.5.2/+esm";
|
|
86989
87119
|
const response = await fetch(url);
|
|
@@ -86991,7 +87121,7 @@ var fetchSimulation = async () => {
|
|
|
86991
87121
|
throw new Error(`Failed to fetch eecircuit-engine from ${url}: ${response.statusText}`);
|
|
86992
87122
|
}
|
|
86993
87123
|
const scriptContent = await response.text();
|
|
86994
|
-
await
|
|
87124
|
+
await fs37.writeFile(tempFilePath, scriptContent);
|
|
86995
87125
|
}
|
|
86996
87126
|
const module2 = await import(tempFilePath);
|
|
86997
87127
|
return module2.Simulation;
|
|
@@ -87080,8 +87210,8 @@ var resultToCsv = (result) => {
|
|
|
87080
87210
|
};
|
|
87081
87211
|
|
|
87082
87212
|
// cli/export/register.ts
|
|
87083
|
-
import
|
|
87084
|
-
import { promises as
|
|
87213
|
+
import path40 from "node:path";
|
|
87214
|
+
import { promises as fs38 } from "node:fs";
|
|
87085
87215
|
var registerExport = (program3) => {
|
|
87086
87216
|
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) => {
|
|
87087
87217
|
const formatOption = options.format ?? "json";
|
|
@@ -87093,12 +87223,12 @@ var registerExport = (program3) => {
|
|
|
87093
87223
|
});
|
|
87094
87224
|
if (circuitJson) {
|
|
87095
87225
|
const spiceString = getSpiceWithPaddedSim(circuitJson);
|
|
87096
|
-
const outputSpicePath = options.output ??
|
|
87097
|
-
await
|
|
87226
|
+
const outputSpicePath = options.output ?? path40.join(path40.dirname(file), `${path40.basename(file, path40.extname(file))}.spice.cir`);
|
|
87227
|
+
await fs38.writeFile(outputSpicePath, spiceString);
|
|
87098
87228
|
const { result } = await runSimulation(spiceString);
|
|
87099
87229
|
const csvContent = resultToCsv(result);
|
|
87100
87230
|
const outputCsvPath = outputSpicePath.replace(/\.spice\.cir$/, ".csv");
|
|
87101
|
-
await
|
|
87231
|
+
await fs38.writeFile(outputCsvPath, csvContent);
|
|
87102
87232
|
console.log(`Exported to ${outputSpicePath} and ${outputCsvPath} (simulation results)!`);
|
|
87103
87233
|
}
|
|
87104
87234
|
process.exit(0);
|
|
@@ -87328,14 +87458,14 @@ class KeyStore {
|
|
|
87328
87458
|
}
|
|
87329
87459
|
}
|
|
87330
87460
|
function createKey(key) {
|
|
87331
|
-
let
|
|
87461
|
+
let path41 = null;
|
|
87332
87462
|
let id = null;
|
|
87333
87463
|
let src = null;
|
|
87334
87464
|
let weight = 1;
|
|
87335
87465
|
let getFn = null;
|
|
87336
87466
|
if (isString2(key) || isArray(key)) {
|
|
87337
87467
|
src = key;
|
|
87338
|
-
|
|
87468
|
+
path41 = createKeyPath(key);
|
|
87339
87469
|
id = createKeyId(key);
|
|
87340
87470
|
} else {
|
|
87341
87471
|
if (!hasOwn.call(key, "name")) {
|
|
@@ -87349,11 +87479,11 @@ function createKey(key) {
|
|
|
87349
87479
|
throw new Error(INVALID_KEY_WEIGHT_VALUE(name));
|
|
87350
87480
|
}
|
|
87351
87481
|
}
|
|
87352
|
-
|
|
87482
|
+
path41 = createKeyPath(name);
|
|
87353
87483
|
id = createKeyId(name);
|
|
87354
87484
|
getFn = key.getFn;
|
|
87355
87485
|
}
|
|
87356
|
-
return { path:
|
|
87486
|
+
return { path: path41, id, weight, src, getFn };
|
|
87357
87487
|
}
|
|
87358
87488
|
function createKeyPath(key) {
|
|
87359
87489
|
return isArray(key) ? key : key.split(".");
|
|
@@ -87361,34 +87491,34 @@ function createKeyPath(key) {
|
|
|
87361
87491
|
function createKeyId(key) {
|
|
87362
87492
|
return isArray(key) ? key.join(".") : key;
|
|
87363
87493
|
}
|
|
87364
|
-
function get(obj,
|
|
87494
|
+
function get(obj, path41) {
|
|
87365
87495
|
let list = [];
|
|
87366
87496
|
let arr = false;
|
|
87367
|
-
const deepGet = (obj2,
|
|
87497
|
+
const deepGet = (obj2, path42, index) => {
|
|
87368
87498
|
if (!isDefined(obj2)) {
|
|
87369
87499
|
return;
|
|
87370
87500
|
}
|
|
87371
|
-
if (!
|
|
87501
|
+
if (!path42[index]) {
|
|
87372
87502
|
list.push(obj2);
|
|
87373
87503
|
} else {
|
|
87374
|
-
let key =
|
|
87504
|
+
let key = path42[index];
|
|
87375
87505
|
const value = obj2[key];
|
|
87376
87506
|
if (!isDefined(value)) {
|
|
87377
87507
|
return;
|
|
87378
87508
|
}
|
|
87379
|
-
if (index ===
|
|
87509
|
+
if (index === path42.length - 1 && (isString2(value) || isNumber(value) || isBoolean(value))) {
|
|
87380
87510
|
list.push(toString(value));
|
|
87381
87511
|
} else if (isArray(value)) {
|
|
87382
87512
|
arr = true;
|
|
87383
87513
|
for (let i = 0, len = value.length;i < len; i += 1) {
|
|
87384
|
-
deepGet(value[i],
|
|
87514
|
+
deepGet(value[i], path42, index + 1);
|
|
87385
87515
|
}
|
|
87386
|
-
} else if (
|
|
87387
|
-
deepGet(value,
|
|
87516
|
+
} else if (path42.length) {
|
|
87517
|
+
deepGet(value, path42, index + 1);
|
|
87388
87518
|
}
|
|
87389
87519
|
}
|
|
87390
87520
|
};
|
|
87391
|
-
deepGet(obj, isString2(
|
|
87521
|
+
deepGet(obj, isString2(path41) ? path41.split(".") : path41, 0);
|
|
87392
87522
|
return arr ? list : list[0];
|
|
87393
87523
|
}
|
|
87394
87524
|
var MatchOptions = {
|
|
@@ -88592,8 +88722,8 @@ var registerSearch = (program3) => {
|
|
|
88592
88722
|
}
|
|
88593
88723
|
if (kicadResults.length) {
|
|
88594
88724
|
console.log(kleur_default.bold().underline(`Found ${kicadResults.length} footprint(s) from KiCad:`));
|
|
88595
|
-
kicadResults.forEach((
|
|
88596
|
-
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${
|
|
88725
|
+
kicadResults.forEach((path41, idx) => {
|
|
88726
|
+
console.log(`${(idx + 1).toString().padStart(2, " ")}. kicad:${path41.replace(".kicad_mod", "").replace(".pretty", "")}`);
|
|
88597
88727
|
});
|
|
88598
88728
|
}
|
|
88599
88729
|
if (results.packages.length) {
|
|
@@ -90066,8 +90196,8 @@ function getErrorMap() {
|
|
|
90066
90196
|
return overrideErrorMap;
|
|
90067
90197
|
}
|
|
90068
90198
|
var makeIssue = (params2) => {
|
|
90069
|
-
const { data, path:
|
|
90070
|
-
const fullPath = [...
|
|
90199
|
+
const { data, path: path41, errorMaps, issueData } = params2;
|
|
90200
|
+
const fullPath = [...path41, ...issueData.path || []];
|
|
90071
90201
|
const fullIssue = {
|
|
90072
90202
|
...issueData,
|
|
90073
90203
|
path: fullPath
|
|
@@ -90175,11 +90305,11 @@ var errorUtil;
|
|
|
90175
90305
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
90176
90306
|
})(errorUtil || (errorUtil = {}));
|
|
90177
90307
|
var ParseInputLazyPath = class {
|
|
90178
|
-
constructor(parent, value,
|
|
90308
|
+
constructor(parent, value, path41, key) {
|
|
90179
90309
|
this._cachedPath = [];
|
|
90180
90310
|
this.parent = parent;
|
|
90181
90311
|
this.data = value;
|
|
90182
|
-
this._path =
|
|
90312
|
+
this._path = path41;
|
|
90183
90313
|
this._key = key;
|
|
90184
90314
|
}
|
|
90185
90315
|
get path() {
|
|
@@ -98366,7 +98496,7 @@ var ss = ys;
|
|
|
98366
98496
|
var ms2 = { paths: { diag1: { type: "path", points: [{ x: -0.1, y: -0.1 }, { x: 0.1, y: 0.1 }], color: "primary", fill: false }, diag2: { type: "path", points: [{ x: -0.1, y: 0.1 }, { x: 0.1, y: -0.1 }], color: "primary", fill: false }, stem: { type: "path", points: [{ x: -0.2, y: 0 }, { x: 0, y: 0 }], color: "primary", fill: false } }, texts: {}, refblocks: { left1: { x: -0.2, y: 0 } }, bounds: { minX: -0.19, maxX: 0.2, minY: -0.12, maxY: 0.12, width: 0.39, height: 0.24, centerX: 0, centerY: 0 }, circles: {} };
|
|
98367
98497
|
var { paths: Yd, bounds: ns, refblocks: Xd } = ms2;
|
|
98368
98498
|
var U = e({ primitives: [...Object.values(Yd)], ports: [{ ...Xd.left1, labels: ["1"] }], center: { x: ns.centerX, y: ns.centerY } }).rotateRightFacingSymbol("right").labelPort("left1", ["1"]).build();
|
|
98369
|
-
var
|
|
98499
|
+
var fs39 = r(U, "down");
|
|
98370
98500
|
var hs = r(U, "left");
|
|
98371
98501
|
var cs = r(U, "up");
|
|
98372
98502
|
var g = { paths: { path11: { type: "path", points: [{ x: -0.4, y: 0 }, { x: 0.06, y: -0.01 }], color: "primary", fill: false }, "path40-0": { type: "path", points: [{ x: 0.07, y: 0.27 }, { x: 0.07, y: -0.28 }], color: "primary", fill: false }, "path40-0-5": { type: "path", points: [{ x: 0.28, y: 0.24 }, { x: 0.08, y: 0.11 }], color: "primary", fill: false }, "path40-0-5-0": { type: "path", points: [{ x: 0.29, y: -0.24 }, { x: 0.09, y: -0.11 }], color: "primary", fill: false }, "path12-1-5": { type: "path", points: [{ x: 0.29, y: 0.25 }, { x: 0.29, y: 0.55 }], color: "primary", fill: false }, "path12-1-5-3": { type: "path", points: [{ x: 0.29, y: -0.55 }, { x: 0.29, y: -0.25 }], color: "primary", fill: false }, path15: { type: "path", points: [{ x: 0.19, y: -0.1 }, { x: 0.12, y: -0.2 }, { x: 0.22, y: -0.2 }, { x: 0.19, y: -0.1 }], color: "primary", fill: true } }, texts: { top1: { type: "text", text: "{REF}", x: -0.08, y: 0.36 }, bottom1: { type: "text", text: "{VAL}", x: -0.07, y: -0.41 } }, refblocks: { top1: { x: 0.29, y: 0.55 }, bottom1: { x: 0.29, y: -0.55 }, left1: { x: -0.4, y: 0 } }, bounds: { minX: -0.43, maxX: 0.43, minY: -0.58, maxY: 0.58, width: 0.85, height: 1.16, centerX: 0, centerY: 0 }, circles: { "path1-0": { type: "circle", x: 0.14, y: 0, radius: 0.29, color: "primary", fill: false } } };
|
|
@@ -98969,7 +99099,7 @@ var jb = Il.primitives.find((t) => t.type === "text" && t.text === "{VAL}");
|
|
|
98969
99099
|
Vb.anchor = "middle_left";
|
|
98970
99100
|
jb.anchor = "middle_right";
|
|
98971
99101
|
var tf = Il;
|
|
98972
|
-
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down:
|
|
99102
|
+
var ef = { ac_voltmeter_down: Wl, ac_voltmeter_horz: Zl, ac_voltmeter_left: Kl, ac_voltmeter_right: ep, ac_voltmeter_up: op, ac_voltmeter_vert: lp, avalanche_diode_down: ap, avalanche_diode_horz: yp, avalanche_diode_left: sp, avalanche_diode_right: mp, avalanche_diode_up: fp, avalanche_diode_vert: cp, backward_diode_down: bp, backward_diode_left: Ut, backward_diode_right: up, backward_diode_up: vp, battery_horz: Zt, battery_vert: Sp, boxresistor_down: Tp, boxresistor_left: Xp, boxresistor_right: jp, boxresistor_small_down: zp, boxresistor_small_left: Jp, boxresistor_small_right: Mp, boxresistor_small_up: Np, boxresistor_up: qp, bridged_ground_down: Up, bridged_ground_left: Zp, bridged_ground_right: re, bridged_ground_up: ta, capacitor_down: ra, capacitor_left: oa, capacitor_polarized_down: la, capacitor_polarized_left: pa, capacitor_polarized_right: ya, capacitor_polarized_up: sa, capacitor_right: ma, capacitor_up: fa, constant_current_diode_down: ca, constant_current_diode_horz: da, constant_current_diode_left: _a, constant_current_diode_right: ga, constant_current_diode_up: va, constant_current_diode_vert: Aa, crystal_4pin_down: Pa, crystal_4pin_left: Sa, crystal_4pin_right: Fa, crystal_4pin_up: Ra, crystal_down: Ea, crystal_left: Ya, crystal_right: Xa, crystal_up: Va, darlington_pair_transistor_down: ja, darlington_pair_transistor_horz: ka, darlington_pair_transistor_left: za, darlington_pair_transistor_right: Oa, darlington_pair_transistor_up: Ja, darlington_pair_transistor_vert: $a, dc_ammeter_horz: Pt, dc_ammeter_vert: Ia, dc_voltmeter_down: qa, dc_voltmeter_horz: Ga, dc_voltmeter_left: Wa, dc_voltmeter_right: Za, dc_voltmeter_up: Ka, dc_voltmeter_vert: ey, diac_down: ry, diac_horz: oy, diac_left: iy, diac_right: ly, diac_up: py, diac_vert: ay, digital_ground_down: xy, digital_ground_left: my, digital_ground_right: fy, digital_ground_up: cy, diode_down: by, diode_left: _y, diode_right: C, diode_up: gy, dpdt_normally_closed_switch_down: vy, dpdt_normally_closed_switch_left: wy, dpdt_normally_closed_switch_right: N, dpdt_normally_closed_switch_up: Ay, dpdt_switch_down: Sy, dpdt_switch_left: Fy, dpdt_switch_right: I, dpdt_switch_up: Ry, dpst_normally_closed_switch_down: Ey, dpst_normally_closed_switch_left: Yy, dpst_normally_closed_switch_right: B, dpst_normally_closed_switch_up: Xy5, dpst_switch_down: Vy, dpst_switch_left: jy, dpst_switch_right: q, dpst_switch_up: ky2, ferrite_bead_down: Oy, ferrite_bead_left: Jy, ferrite_bead_right: Te, ferrite_bead_up: Re, filled_diode_down: My, filled_diode_horz: Ny, filled_diode_left: By, filled_diode_right: Dy, filled_diode_up: Uy, filled_diode_vert: Hy, frequency_meter_horz: St, frequency_meter_vert: tx, fuse_horz: Oe, fuse_vert: ox, ground_down: ix, ground_horz: lx, ground_left: px, ground_right: ax, ground_up: yx, ground_vert: xx, gunn_diode_horz: sx, gunn_diode_vert: mx, icled_down: fx, icled_left: hx, icled_right: D, icled_up: cx, igbt_transistor_horz: Je, igbt_transistor_vert: _x, illuminated_push_button_normally_open_horz: $e, illuminated_push_button_normally_open_vert: wx, inductor_down: Fx, inductor_left: Rx, inductor_right: ut, inductor_up: Ce, laser_diode_down: Tx, laser_diode_left: Ex, laser_diode_right: G, laser_diode_up: Yx, led_down: jx, led_left: kx, led_right: vt, led_up: Ie, light_dependent_resistor_horz: qe, light_dependent_resistor_vert: Cx, mosfet_depletion_normally_on_horz: Ge, mosfet_depletion_normally_on_vert: qx, mushroom_head_normally_open_momentary_horz: We, mushroom_head_normally_open_momentary_vert: Wx, n_channel_d_mosfet_transistor_horz: Qe, n_channel_d_mosfet_transistor_vert: ts2, n_channel_e_mosfet_transistor_horz: t0, n_channel_e_mosfet_transistor_vert: ls, njfet_transistor_horz: r0, njfet_transistor_vert: ss, not_connected_down: fs39, not_connected_left: hs, not_connected_right: U, not_connected_up: cs, npn_bipolar_transistor_down: ds, npn_bipolar_transistor_horz: bs, npn_bipolar_transistor_left: _s, npn_bipolar_transistor_right: gs, npn_bipolar_transistor_up: us, npn_bipolar_transistor_vert: vs, opamp_no_power_down: As, opamp_no_power_left: Ps, opamp_no_power_right: W, opamp_no_power_up: Ss, opamp_with_power_down: Rs, opamp_with_power_left: Ts, opamp_with_power_right: H, opamp_with_power_up: Es, p_channel_d_mosfet_transistor_horz: x0, p_channel_d_mosfet_transistor_vert: js, p_channel_e_mosfet_transistor_horz: m0, p_channel_e_mosfet_transistor_vert: $s, photodiode_horz: n0, photodiode_vert: Is, pjfet_transistor_horz: h0, pjfet_transistor_vert: Us, pnp_bipolar_transistor_down: Ws, pnp_bipolar_transistor_horz: Hs, pnp_bipolar_transistor_left: Zs, pnp_bipolar_transistor_right: Qs, pnp_bipolar_transistor_up: Ks, pnp_bipolar_transistor_vert: tm, potentiometer_horz: v0, potentiometer_vert: im, potentiometer2_down: ym, potentiometer2_left: xm, potentiometer2_right: Z, potentiometer2_up: sm, potentiometer3_down: mm, potentiometer3_left: nm, potentiometer3_right: fm, potentiometer3_up: hm, power_factor_meter_horz: R0, power_factor_meter_vert: _m, push_button_normally_closed_momentary_horz: E0, push_button_normally_closed_momentary_vert: wm, push_button_normally_open_momentary_horz: X0, push_button_normally_open_momentary_vert: Fm, rail_down: Tm, rail_left: Ym, rail_right: Lm, rail_up: jm, rectifier_diode_horz: j0, rectifier_diode_vert: Om, resistor_down: $m, resistor_left: Cm, resistor_right: Im, resistor_up: qm, resonator_down: Gm, resonator_horz: N0, resonator_left: Um, resonator_right: et, resonator_up: Wm, resonator_vert: Hm, schottky_diode_down: Qm, schottky_diode_left: Km, schottky_diode_right: rt, schottky_diode_up: tn, silicon_controlled_rectifier_horz: I0, silicon_controlled_rectifier_vert: on2, solderjumper2_bridged12_down: ln, solderjumper2_bridged12_left: pn, solderjumper2_bridged12_right: an, solderjumper2_bridged12_up: yn, solderjumper2_down: xn, solderjumper2_left: sn, solderjumper2_right: mn, solderjumper2_up: nn, solderjumper3_bridged12_down: fn, solderjumper3_bridged12_left: hn, solderjumper3_bridged12_right: cn, solderjumper3_bridged12_up: dn, solderjumper3_bridged123_down: bn, solderjumper3_bridged123_left: _n, solderjumper3_bridged123_right: gn, solderjumper3_bridged123_up: un, solderjumper3_bridged23_down: vn, solderjumper3_bridged23_left: wn, solderjumper3_bridged23_right: An, solderjumper3_bridged23_up: Pn, solderjumper3_down: Sn, solderjumper3_left: Fn, solderjumper3_right: Rn, solderjumper3_up: Tn, spdt_normally_closed_switch_down: Yn, spdt_normally_closed_switch_left: Xn, spdt_normally_closed_switch_right: xt, spdt_normally_closed_switch_up: Ln, spdt_switch_down: jn, spdt_switch_left: kn, spdt_switch_right: st, spdt_switch_up: zn, spst_normally_closed_switch_down: On, spst_normally_closed_switch_left: Jn, spst_normally_closed_switch_right: mt, spst_normally_closed_switch_up: $n, spst_switch_down: Mn, spst_switch_left: Cn, spst_switch_right: nt, spst_switch_up: Nn, square_wave_down: In, square_wave_left: Bn, square_wave_right: qn, square_wave_up: Dn, step_recovery_diode_horz: B0, step_recovery_diode_vert: Gn, tachometer_horz: Yt, tachometer_vert: Zn, testpoint_down: t1, testpoint_left: e1, testpoint_right: ht, testpoint_up: i1, tilted_ground_down: p1, tilted_ground_left: a1, tilted_ground_right: wt, tilted_ground_up: D0, triac_horz: G0, triac_vert: s1, tunnel_diode_horz: W0, tunnel_diode_vert: h1, unijunction_transistor_horz: Z0, unijunction_transistor_vert: u1, usbc: w1, var_meter_horz: K0, var_meter_vert: S1, varactor_diode_horz: er, varactor_diode_vert: E1, varistor_horz: or, varistor_vert: V1, varmeter_horz: Xt, varmeter_vert: O1, vcc_down: J1, vcc_left: $1, vcc_right: M1, vcc_up: C1, volt_meter_horz: lr, volt_meter_vert: N1, watt_hour_meter_horz: Lt, watt_hour_meter_vert: D1, wattmeter_horz: Vt, wattmeter_vert: H1, zener_diode_horz: xr, zener_diode_vert: tf };
|
|
98973
99103
|
var gM = Object.fromEntries(Object.keys(ef).map((t) => [t, t]));
|
|
98974
99104
|
function doesLineIntersectLine([a12, a22], [b12, b22], {
|
|
98975
99105
|
lineThickness = 0
|
|
@@ -101277,11 +101407,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
101277
101407
|
fiber = fiber.next, id--;
|
|
101278
101408
|
return fiber;
|
|
101279
101409
|
}
|
|
101280
|
-
function copyWithSetImpl(obj,
|
|
101281
|
-
if (index >=
|
|
101410
|
+
function copyWithSetImpl(obj, path41, index, value) {
|
|
101411
|
+
if (index >= path41.length)
|
|
101282
101412
|
return value;
|
|
101283
|
-
var key =
|
|
101284
|
-
updated[key] = copyWithSetImpl(obj[key],
|
|
101413
|
+
var key = path41[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
101414
|
+
updated[key] = copyWithSetImpl(obj[key], path41, index + 1, value);
|
|
101285
101415
|
return updated;
|
|
101286
101416
|
}
|
|
101287
101417
|
function copyWithRename(obj, oldPath, newPath) {
|
|
@@ -101301,11 +101431,11 @@ var require_react_reconciler_development = __commonJS2({
|
|
|
101301
101431
|
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);
|
|
101302
101432
|
return updated;
|
|
101303
101433
|
}
|
|
101304
|
-
function copyWithDeleteImpl(obj,
|
|
101305
|
-
var key =
|
|
101306
|
-
if (index + 1 ===
|
|
101434
|
+
function copyWithDeleteImpl(obj, path41, index) {
|
|
101435
|
+
var key = path41[index], updated = isArrayImpl(obj) ? obj.slice() : assign2({}, obj);
|
|
101436
|
+
if (index + 1 === path41.length)
|
|
101307
101437
|
return isArrayImpl(updated) ? updated.splice(key, 1) : delete updated[key], updated;
|
|
101308
|
-
updated[key] = copyWithDeleteImpl(obj[key],
|
|
101438
|
+
updated[key] = copyWithDeleteImpl(obj[key], path41, index + 1);
|
|
101309
101439
|
return updated;
|
|
101310
101440
|
}
|
|
101311
101441
|
function shouldSuspendImpl() {
|
|
@@ -110331,29 +110461,29 @@ Check the top-level render call using <` + componentName2 + ">.");
|
|
|
110331
110461
|
var didWarnAboutNestedUpdates = false;
|
|
110332
110462
|
var didWarnAboutFindNodeInStrictMode = {};
|
|
110333
110463
|
var overrideHookState = null, overrideHookStateDeletePath = null, overrideHookStateRenamePath = null, overrideProps = null, overridePropsDeletePath = null, overridePropsRenamePath = null, scheduleUpdate = null, setErrorHandler = null, setSuspenseHandler = null;
|
|
110334
|
-
overrideHookState = function(fiber, id,
|
|
110464
|
+
overrideHookState = function(fiber, id, path41, value) {
|
|
110335
110465
|
id = findHook(fiber, id);
|
|
110336
|
-
id !== null && (
|
|
110466
|
+
id !== null && (path41 = copyWithSetImpl(id.memoizedState, path41, 0, value), id.memoizedState = path41, id.baseState = path41, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path41 = enqueueConcurrentRenderForLane(fiber, 2), path41 !== null && scheduleUpdateOnFiber(path41, fiber, 2));
|
|
110337
110467
|
};
|
|
110338
|
-
overrideHookStateDeletePath = function(fiber, id,
|
|
110468
|
+
overrideHookStateDeletePath = function(fiber, id, path41) {
|
|
110339
110469
|
id = findHook(fiber, id);
|
|
110340
|
-
id !== null && (
|
|
110470
|
+
id !== null && (path41 = copyWithDeleteImpl(id.memoizedState, path41, 0), id.memoizedState = path41, id.baseState = path41, fiber.memoizedProps = assign2({}, fiber.memoizedProps), path41 = enqueueConcurrentRenderForLane(fiber, 2), path41 !== null && scheduleUpdateOnFiber(path41, fiber, 2));
|
|
110341
110471
|
};
|
|
110342
110472
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
110343
110473
|
id = findHook(fiber, id);
|
|
110344
110474
|
id !== null && (oldPath = copyWithRename(id.memoizedState, oldPath, newPath), id.memoizedState = oldPath, id.baseState = oldPath, fiber.memoizedProps = assign2({}, fiber.memoizedProps), oldPath = enqueueConcurrentRenderForLane(fiber, 2), oldPath !== null && scheduleUpdateOnFiber(oldPath, fiber, 2));
|
|
110345
110475
|
};
|
|
110346
|
-
overrideProps = function(fiber,
|
|
110347
|
-
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps,
|
|
110476
|
+
overrideProps = function(fiber, path41, value) {
|
|
110477
|
+
fiber.pendingProps = copyWithSetImpl(fiber.memoizedProps, path41, 0, value);
|
|
110348
110478
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
110349
|
-
|
|
110350
|
-
|
|
110479
|
+
path41 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
110480
|
+
path41 !== null && scheduleUpdateOnFiber(path41, fiber, 2);
|
|
110351
110481
|
};
|
|
110352
|
-
overridePropsDeletePath = function(fiber,
|
|
110353
|
-
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps,
|
|
110482
|
+
overridePropsDeletePath = function(fiber, path41) {
|
|
110483
|
+
fiber.pendingProps = copyWithDeleteImpl(fiber.memoizedProps, path41, 0);
|
|
110354
110484
|
fiber.alternate && (fiber.alternate.pendingProps = fiber.pendingProps);
|
|
110355
|
-
|
|
110356
|
-
|
|
110485
|
+
path41 = enqueueConcurrentRenderForLane(fiber, 2);
|
|
110486
|
+
path41 !== null && scheduleUpdateOnFiber(path41, fiber, 2);
|
|
110357
110487
|
};
|
|
110358
110488
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
110359
110489
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
@@ -116656,7 +116786,7 @@ var parsePin = (pinString) => {
|
|
|
116656
116786
|
const colorMatch = pinString.match(/#[0-9A-F]{6}/);
|
|
116657
116787
|
const labelColor = colorMatch ? colorMatch[0] : "";
|
|
116658
116788
|
const pathMatch = pinString.match(/\^\^([^~]+)/);
|
|
116659
|
-
const
|
|
116789
|
+
const path41 = pathMatch ? pathMatch[1] : "";
|
|
116660
116790
|
const arrowMatch = pinString.match(/\^\^0~(.+)$/);
|
|
116661
116791
|
const arrow = arrowMatch ? arrowMatch[1] : "";
|
|
116662
116792
|
const r2 = Number.parseFloat(rotation4);
|
|
@@ -116670,7 +116800,7 @@ var parsePin = (pinString) => {
|
|
|
116670
116800
|
rotation: Number.isNaN(r2) ? 0 : r2,
|
|
116671
116801
|
label,
|
|
116672
116802
|
labelColor,
|
|
116673
|
-
path:
|
|
116803
|
+
path: path41,
|
|
116674
116804
|
arrow
|
|
116675
116805
|
};
|
|
116676
116806
|
};
|
|
@@ -117110,15 +117240,15 @@ function generateArcFromSweep(startX, startY, endX, endY, radius, largeArcFlag,
|
|
|
117110
117240
|
}
|
|
117111
117241
|
}
|
|
117112
117242
|
const numPoints = Math.max(2, Math.ceil(Math.abs(endAngle - startAngle) * radius));
|
|
117113
|
-
const
|
|
117243
|
+
const path41 = [];
|
|
117114
117244
|
for (let i22 = 0;i22 <= numPoints; i22++) {
|
|
117115
117245
|
const t3 = i22 / numPoints;
|
|
117116
117246
|
const angle2 = startAngle + t3 * (endAngle - startAngle);
|
|
117117
117247
|
const x22 = centerX + radius * Math.cos(angle2);
|
|
117118
117248
|
const y22 = centerY + radius * Math.sin(angle2);
|
|
117119
|
-
|
|
117249
|
+
path41.push({ x: x22, y: y22 });
|
|
117120
117250
|
}
|
|
117121
|
-
return
|
|
117251
|
+
return path41;
|
|
117122
117252
|
}
|
|
117123
117253
|
var __defProp4 = Object.defineProperty;
|
|
117124
117254
|
var __export22 = (target, all) => {
|
|
@@ -126197,17 +126327,17 @@ var ObstacleList = class {
|
|
|
126197
126327
|
return obstacles;
|
|
126198
126328
|
}
|
|
126199
126329
|
};
|
|
126200
|
-
function removePathLoops(
|
|
126201
|
-
if (
|
|
126202
|
-
return
|
|
126203
|
-
const result = [{ ...
|
|
126204
|
-
let currentLayer =
|
|
126205
|
-
for (let i22 = 1;i22 <
|
|
126206
|
-
const currentSegment = { start:
|
|
126207
|
-
const isVia =
|
|
126208
|
-
if (
|
|
126209
|
-
result.push({ ...
|
|
126210
|
-
currentLayer =
|
|
126330
|
+
function removePathLoops(path41) {
|
|
126331
|
+
if (path41.length < 4)
|
|
126332
|
+
return path41;
|
|
126333
|
+
const result = [{ ...path41[0] }];
|
|
126334
|
+
let currentLayer = path41[0].layer;
|
|
126335
|
+
for (let i22 = 1;i22 < path41.length; i22++) {
|
|
126336
|
+
const currentSegment = { start: path41[i22 - 1], end: path41[i22] };
|
|
126337
|
+
const isVia = path41[i22].route_type === "via" || path41[i22 - 1].route_type === "via";
|
|
126338
|
+
if (path41[i22].layer !== currentLayer || isVia) {
|
|
126339
|
+
result.push({ ...path41[i22] });
|
|
126340
|
+
currentLayer = path41[i22].layer;
|
|
126211
126341
|
continue;
|
|
126212
126342
|
}
|
|
126213
126343
|
let intersectionFound = false;
|
|
@@ -126236,8 +126366,8 @@ function removePathLoops(path40) {
|
|
|
126236
126366
|
result.push(intersectionPoint);
|
|
126237
126367
|
}
|
|
126238
126368
|
const lastPoint = result[result.length - 1];
|
|
126239
|
-
if (lastPoint.x !==
|
|
126240
|
-
result.push(
|
|
126369
|
+
if (lastPoint.x !== path41[i22].x || lastPoint.y !== path41[i22].y) {
|
|
126370
|
+
result.push(path41[i22]);
|
|
126241
126371
|
}
|
|
126242
126372
|
}
|
|
126243
126373
|
return result;
|
|
@@ -126726,10 +126856,10 @@ var GeneralizedAstarAutorouter = class {
|
|
|
126726
126856
|
});
|
|
126727
126857
|
}
|
|
126728
126858
|
if (current2.parent) {
|
|
126729
|
-
const
|
|
126859
|
+
const path41 = [];
|
|
126730
126860
|
let p22 = current2;
|
|
126731
126861
|
while (p22) {
|
|
126732
|
-
|
|
126862
|
+
path41.unshift(p22);
|
|
126733
126863
|
p22 = p22.parent;
|
|
126734
126864
|
}
|
|
126735
126865
|
debugSolution.push({
|
|
@@ -126737,7 +126867,7 @@ var GeneralizedAstarAutorouter = class {
|
|
|
126737
126867
|
pcb_component_id: "",
|
|
126738
126868
|
pcb_fabrication_note_path_id: `note_path_${current2.x}_${current2.y}`,
|
|
126739
126869
|
layer: "top",
|
|
126740
|
-
route:
|
|
126870
|
+
route: path41,
|
|
126741
126871
|
stroke_width: 0.01
|
|
126742
126872
|
});
|
|
126743
126873
|
}
|
|
@@ -135088,7 +135218,7 @@ var ps2 = class extends e3 {
|
|
|
135088
135218
|
return t3;
|
|
135089
135219
|
}
|
|
135090
135220
|
};
|
|
135091
|
-
var
|
|
135221
|
+
var fs40 = (t3) => {
|
|
135092
135222
|
const e22 = [], s22 = [], n22 = [], i22 = ht2(t3);
|
|
135093
135223
|
if (t3.connections)
|
|
135094
135224
|
for (const e32 of t3.connections)
|
|
@@ -137711,7 +137841,7 @@ var Tn2 = class extends e3 {
|
|
|
137711
137841
|
const t3 = M22.map((t42) => ({ x: t42.x, y: t42.y }));
|
|
137712
137842
|
t3.push({ ...t3[0] }), v22.push({ points: t3, strokeColor: "rgba(0, 136, 255, 0.95)" });
|
|
137713
137843
|
}
|
|
137714
|
-
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22,
|
|
137844
|
+
const S22 = { points: [...this.srj.connections.flatMap((t3) => t3.pointsToConnect.map((e32) => ({ ...e32, label: `${t3.name} ${e32.pcb_port_id ?? ""}` })))], rects: [...(this.srj.obstacles ?? []).map((t3) => ({ ...t3, fill: t3.layers?.includes("top") ? "rgba(255,0,0,0.25)" : t3.layers?.includes("bottom") ? "rgba(0,0,255,0.25)" : "rgba(255,0,0,0.25)", label: t3.layers?.join(", ") }))], lines: v22 }, b22 = [S22, e22, s22, n22, i22, o22, a22, r22, h22, c22, d2, l22, u22, p22 ? t(S22, p22) : null, f2, m22, y22, g22, x22, this.solved ? t(S22, fs40(this.getOutputSimpleRouteJson())) : null].filter(Boolean);
|
|
137715
137845
|
return t(...b22);
|
|
137716
137846
|
}
|
|
137717
137847
|
preview() {
|
|
@@ -151182,10 +151312,10 @@ var findFirstCollision = (pts, rects, opts = {}) => {
|
|
|
151182
151312
|
}
|
|
151183
151313
|
return null;
|
|
151184
151314
|
};
|
|
151185
|
-
var isPathCollidingWithObstacles = (
|
|
151186
|
-
for (let i22 = 0;i22 <
|
|
151315
|
+
var isPathCollidingWithObstacles = (path41, obstacles) => {
|
|
151316
|
+
for (let i22 = 0;i22 < path41.length - 1; i22++) {
|
|
151187
151317
|
for (const obstacle of obstacles) {
|
|
151188
|
-
if (segmentIntersectsRect(
|
|
151318
|
+
if (segmentIntersectsRect(path41[i22], path41[i22 + 1], obstacle)) {
|
|
151189
151319
|
return true;
|
|
151190
151320
|
}
|
|
151191
151321
|
}
|
|
@@ -151379,36 +151509,36 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
151379
151509
|
this.error = "No collision-free path found";
|
|
151380
151510
|
return;
|
|
151381
151511
|
}
|
|
151382
|
-
const { path:
|
|
151512
|
+
const { path: path41, collisionChipIds } = state;
|
|
151383
151513
|
const [PA, PB] = this.pins;
|
|
151384
|
-
const collision = findFirstCollision(
|
|
151514
|
+
const collision = findFirstCollision(path41, this.obstacles);
|
|
151385
151515
|
if (!collision) {
|
|
151386
|
-
const first =
|
|
151387
|
-
const last =
|
|
151516
|
+
const first = path41[0];
|
|
151517
|
+
const last = path41[path41.length - 1];
|
|
151388
151518
|
const EPS42 = 0.000000001;
|
|
151389
151519
|
const samePoint = (p22, q22) => Math.abs(p22.x - q22.x) < EPS42 && Math.abs(p22.y - q22.y) < EPS42;
|
|
151390
151520
|
if (samePoint(first, { x: PA.x, y: PA.y }) && samePoint(last, { x: PB.x, y: PB.y })) {
|
|
151391
|
-
this.solvedTracePath =
|
|
151521
|
+
this.solvedTracePath = path41;
|
|
151392
151522
|
this.solved = true;
|
|
151393
151523
|
}
|
|
151394
151524
|
return;
|
|
151395
151525
|
}
|
|
151396
151526
|
let { segIndex, rect } = collision;
|
|
151397
151527
|
const isFirstSegment = segIndex === 0;
|
|
151398
|
-
const isLastSegment = segIndex ===
|
|
151528
|
+
const isLastSegment = segIndex === path41.length - 2;
|
|
151399
151529
|
if (isFirstSegment) {
|
|
151400
|
-
if (
|
|
151530
|
+
if (path41.length < 3) {
|
|
151401
151531
|
return;
|
|
151402
151532
|
}
|
|
151403
151533
|
segIndex = 1;
|
|
151404
151534
|
} else if (isLastSegment) {
|
|
151405
|
-
if (
|
|
151535
|
+
if (path41.length < 3) {
|
|
151406
151536
|
return;
|
|
151407
151537
|
}
|
|
151408
|
-
segIndex =
|
|
151538
|
+
segIndex = path41.length - 3;
|
|
151409
151539
|
}
|
|
151410
|
-
const a22 =
|
|
151411
|
-
const b22 =
|
|
151540
|
+
const a22 = path41[segIndex];
|
|
151541
|
+
const b22 = path41[segIndex + 1];
|
|
151412
151542
|
const axis = this.axisOfSegment(a22, b22);
|
|
151413
151543
|
if (!axis) {
|
|
151414
151544
|
return;
|
|
@@ -151426,7 +151556,7 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
151426
151556
|
}
|
|
151427
151557
|
const newStates = [];
|
|
151428
151558
|
for (const coord of candidates) {
|
|
151429
|
-
const newPath = shiftSegmentOrth(
|
|
151559
|
+
const newPath = shiftSegmentOrth(path41, segIndex, axis, coord);
|
|
151430
151560
|
if (!newPath)
|
|
151431
151561
|
continue;
|
|
151432
151562
|
const key = pathKey(newPath);
|
|
@@ -151462,8 +151592,8 @@ var SchematicTraceSingleLineSolver2 = class extends BaseSolver3 {
|
|
|
151462
151592
|
strokeColor: "blue",
|
|
151463
151593
|
strokeDash: "5 5"
|
|
151464
151594
|
});
|
|
151465
|
-
for (const { path:
|
|
151466
|
-
g22.lines.push({ points:
|
|
151595
|
+
for (const { path: path41, collisionChipIds: collisionRectIds } of this.queue) {
|
|
151596
|
+
g22.lines.push({ points: path41, strokeColor: "teal", strokeDash: "2 2" });
|
|
151467
151597
|
}
|
|
151468
151598
|
if (this.solvedTracePath) {
|
|
151469
151599
|
g22.lines.push({ points: this.solvedTracePath, strokeColor: "green" });
|
|
@@ -151700,9 +151830,9 @@ var TraceOverlapIssueSolver = class extends BaseSolver3 {
|
|
|
151700
151830
|
solvedTracePathIndex,
|
|
151701
151831
|
traceSegmentIndex
|
|
151702
151832
|
} of group.pathsWithOverlap) {
|
|
151703
|
-
const
|
|
151704
|
-
const segStart =
|
|
151705
|
-
const segEnd =
|
|
151833
|
+
const path41 = this.traceNetIslands[group.connNetId][solvedTracePathIndex];
|
|
151834
|
+
const segStart = path41.tracePath[traceSegmentIndex];
|
|
151835
|
+
const segEnd = path41.tracePath[traceSegmentIndex + 1];
|
|
151706
151836
|
graphics.lines.push({
|
|
151707
151837
|
points: [segStart, segEnd],
|
|
151708
151838
|
strokeColor: "red"
|
|
@@ -151746,11 +151876,11 @@ var TraceOverlapShiftSolver = class extends BaseSolver3 {
|
|
|
151746
151876
|
computeTraceNetIslands() {
|
|
151747
151877
|
const islands = {};
|
|
151748
151878
|
for (const original of this.inputTracePaths) {
|
|
151749
|
-
const
|
|
151750
|
-
const key =
|
|
151879
|
+
const path41 = this.correctedTraceMap[original.mspPairId] ?? original;
|
|
151880
|
+
const key = path41.globalConnNetId;
|
|
151751
151881
|
if (!islands[key])
|
|
151752
151882
|
islands[key] = [];
|
|
151753
|
-
islands[key].push(
|
|
151883
|
+
islands[key].push(path41);
|
|
151754
151884
|
}
|
|
151755
151885
|
return islands;
|
|
151756
151886
|
}
|
|
@@ -151998,9 +152128,9 @@ function rectIntersectsAnyTrace(bounds, inputTraceMap, hostPathId, hostSegIndex)
|
|
|
151998
152128
|
}
|
|
151999
152129
|
return { hasIntersection: false };
|
|
152000
152130
|
}
|
|
152001
|
-
function lengthOfTrace(
|
|
152131
|
+
function lengthOfTrace(path41) {
|
|
152002
152132
|
let sum = 0;
|
|
152003
|
-
const pts =
|
|
152133
|
+
const pts = path41.tracePath;
|
|
152004
152134
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
152005
152135
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
152006
152136
|
}
|
|
@@ -152529,9 +152659,9 @@ var NetLabelPlacementSolver = class extends BaseSolver3 {
|
|
|
152529
152659
|
}
|
|
152530
152660
|
const compTraces = (byGlobal[globalConnNetId] ?? []).filter((t3) => component.has(t3.pins[0].pinId) && component.has(t3.pins[1].pinId));
|
|
152531
152661
|
if (compTraces.length > 0) {
|
|
152532
|
-
const lengthOf = (
|
|
152662
|
+
const lengthOf = (path41) => {
|
|
152533
152663
|
let sum = 0;
|
|
152534
|
-
const pts =
|
|
152664
|
+
const pts = path41.tracePath;
|
|
152535
152665
|
for (let i22 = 0;i22 < pts.length - 1; i22++) {
|
|
152536
152666
|
sum += Math.abs(pts[i22 + 1].x - pts[i22].x) + Math.abs(pts[i22 + 1].y - pts[i22].y);
|
|
152537
152667
|
}
|
|
@@ -152676,12 +152806,12 @@ var detectTraceLabelOverlap = (traces, netLabels) => {
|
|
|
152676
152806
|
}
|
|
152677
152807
|
return overlaps;
|
|
152678
152808
|
};
|
|
152679
|
-
var findTraceViolationZone = (
|
|
152809
|
+
var findTraceViolationZone = (path41, labelBounds) => {
|
|
152680
152810
|
const isPointInside = (p22) => p22.x > labelBounds.minX && p22.x < labelBounds.maxX && p22.y > labelBounds.minY && p22.y < labelBounds.maxY;
|
|
152681
152811
|
let firstInsideIndex = -1;
|
|
152682
152812
|
let lastInsideIndex = -1;
|
|
152683
|
-
for (let i22 = 0;i22 <
|
|
152684
|
-
if (isPointInside(
|
|
152813
|
+
for (let i22 = 0;i22 < path41.length; i22++) {
|
|
152814
|
+
if (isPointInside(path41[i22])) {
|
|
152685
152815
|
if (firstInsideIndex === -1) {
|
|
152686
152816
|
firstInsideIndex = i22;
|
|
152687
152817
|
}
|
|
@@ -152690,20 +152820,20 @@ var findTraceViolationZone = (path40, labelBounds) => {
|
|
|
152690
152820
|
}
|
|
152691
152821
|
return { firstInsideIndex, lastInsideIndex };
|
|
152692
152822
|
};
|
|
152693
|
-
var simplifyPath = (
|
|
152694
|
-
if (
|
|
152695
|
-
return
|
|
152696
|
-
const newPath = [
|
|
152697
|
-
for (let i22 = 1;i22 <
|
|
152823
|
+
var simplifyPath = (path41) => {
|
|
152824
|
+
if (path41.length < 3)
|
|
152825
|
+
return path41;
|
|
152826
|
+
const newPath = [path41[0]];
|
|
152827
|
+
for (let i22 = 1;i22 < path41.length - 1; i22++) {
|
|
152698
152828
|
const p12 = newPath[newPath.length - 1];
|
|
152699
|
-
const p22 =
|
|
152700
|
-
const p32 =
|
|
152829
|
+
const p22 = path41[i22];
|
|
152830
|
+
const p32 = path41[i22 + 1];
|
|
152701
152831
|
if (isVertical(p12, p22) && isVertical(p22, p32) || isHorizontal(p12, p22) && isHorizontal(p22, p32)) {
|
|
152702
152832
|
continue;
|
|
152703
152833
|
}
|
|
152704
152834
|
newPath.push(p22);
|
|
152705
152835
|
}
|
|
152706
|
-
newPath.push(
|
|
152836
|
+
newPath.push(path41[path41.length - 1]);
|
|
152707
152837
|
if (newPath.length < 3)
|
|
152708
152838
|
return newPath;
|
|
152709
152839
|
const finalPath = [newPath[0]];
|
|
@@ -152963,12 +153093,12 @@ var hasCollisionsWithLabels = (pathSegments, labels) => {
|
|
|
152963
153093
|
return false;
|
|
152964
153094
|
};
|
|
152965
153095
|
var minimizeTurns = ({
|
|
152966
|
-
path:
|
|
153096
|
+
path: path41,
|
|
152967
153097
|
obstacles,
|
|
152968
153098
|
labelBounds
|
|
152969
153099
|
}) => {
|
|
152970
|
-
if (
|
|
152971
|
-
return
|
|
153100
|
+
if (path41.length <= 2) {
|
|
153101
|
+
return path41;
|
|
152972
153102
|
}
|
|
152973
153103
|
const recognizeStairStepPattern = (pathToCheck, startIdx) => {
|
|
152974
153104
|
if (startIdx >= pathToCheck.length - 3)
|
|
@@ -153000,7 +153130,7 @@ var minimizeTurns = ({
|
|
|
153000
153130
|
}
|
|
153001
153131
|
return isStairStep && endIdx - startIdx >= 3 ? endIdx : -1;
|
|
153002
153132
|
};
|
|
153003
|
-
let optimizedPath = [...
|
|
153133
|
+
let optimizedPath = [...path41];
|
|
153004
153134
|
let currentTurns = countTurns(optimizedPath);
|
|
153005
153135
|
let improved = true;
|
|
153006
153136
|
while (improved) {
|
|
@@ -160605,9 +160735,9 @@ var getFileExtension = (filename) => {
|
|
|
160605
160735
|
const extension = lastSegment.split(".").pop();
|
|
160606
160736
|
return extension?.toLowerCase() ?? null;
|
|
160607
160737
|
};
|
|
160608
|
-
var joinUrlPath = (base,
|
|
160738
|
+
var joinUrlPath = (base, path41) => {
|
|
160609
160739
|
const trimmedBase = base.replace(/\/+$/, "");
|
|
160610
|
-
const trimmedPath =
|
|
160740
|
+
const trimmedPath = path41.replace(/^\/+/, "");
|
|
160611
160741
|
return `${trimmedBase}/${trimmedPath}`;
|
|
160612
160742
|
};
|
|
160613
160743
|
var constructAssetUrl = (targetUrl, baseUrl) => {
|
|
@@ -161921,7 +162051,7 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
161921
162051
|
for (let i22 = 0;i22 < portsWithPosition.length - 1; i22++) {
|
|
161922
162052
|
const start = portsWithPosition[i22];
|
|
161923
162053
|
const end = portsWithPosition[i22 + 1];
|
|
161924
|
-
const
|
|
162054
|
+
const path41 = calculateElbow({
|
|
161925
162055
|
x: start.position.x,
|
|
161926
162056
|
y: start.position.y,
|
|
161927
162057
|
facingDirection: convertFacingDirectionToElbowDirection(start.facingDirection)
|
|
@@ -161930,8 +162060,8 @@ var Trace_doInitialSchematicTraceRender = (trace) => {
|
|
|
161930
162060
|
y: end.position.y,
|
|
161931
162061
|
facingDirection: convertFacingDirectionToElbowDirection(end.facingDirection)
|
|
161932
162062
|
});
|
|
161933
|
-
for (let j22 = 0;j22 <
|
|
161934
|
-
elbowEdges.push({ from:
|
|
162063
|
+
for (let j22 = 0;j22 < path41.length - 1; j22++) {
|
|
162064
|
+
elbowEdges.push({ from: path41[j22], to: path41[j22 + 1] });
|
|
161935
162065
|
}
|
|
161936
162066
|
}
|
|
161937
162067
|
const doesSegmentIntersectRect2 = (edge, rect) => {
|
|
@@ -163124,20 +163254,20 @@ var parseLibraryFootprintRef = (s22) => {
|
|
|
163124
163254
|
};
|
|
163125
163255
|
var isStaticAssetPath = (s22) => s22.startsWith("/");
|
|
163126
163256
|
var resolveStaticFileImportDebug = (0, import_debug92.default)("tscircuit:core:resolveStaticFileImport");
|
|
163127
|
-
async function resolveStaticFileImport(
|
|
163128
|
-
if (!
|
|
163129
|
-
return
|
|
163257
|
+
async function resolveStaticFileImport(path41, platform) {
|
|
163258
|
+
if (!path41)
|
|
163259
|
+
return path41;
|
|
163130
163260
|
const resolver = platform?.resolveProjectStaticFileImportUrl;
|
|
163131
|
-
if (resolver &&
|
|
163261
|
+
if (resolver && path41.startsWith("/")) {
|
|
163132
163262
|
try {
|
|
163133
|
-
const resolved = await resolver(
|
|
163263
|
+
const resolved = await resolver(path41);
|
|
163134
163264
|
if (resolved)
|
|
163135
163265
|
return resolved;
|
|
163136
163266
|
} catch (error) {
|
|
163137
163267
|
resolveStaticFileImportDebug("failed to resolve static file via platform resolver", error);
|
|
163138
163268
|
}
|
|
163139
163269
|
}
|
|
163140
|
-
return constructAssetUrl(
|
|
163270
|
+
return constructAssetUrl(path41, platform?.projectBaseUrl);
|
|
163141
163271
|
}
|
|
163142
163272
|
function NormalComponent_doInitialPcbFootprintStringRender(component, queueAsyncEffect) {
|
|
163143
163273
|
let { footprint } = component.props;
|
|
@@ -168225,7 +168355,7 @@ var Group6 = class extends NormalComponent3 {
|
|
|
168225
168355
|
});
|
|
168226
168356
|
}
|
|
168227
168357
|
if (debug112.enabled) {
|
|
168228
|
-
const graphicsObject =
|
|
168358
|
+
const graphicsObject = fs40(simpleRouteJson);
|
|
168229
168359
|
graphicsObject.title = `autorouting-${this.props.name}`;
|
|
168230
168360
|
global.debugGraphics?.push(graphicsObject);
|
|
168231
168361
|
}
|
|
@@ -170784,7 +170914,7 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
170784
170914
|
}
|
|
170785
170915
|
const portPos = port._getGlobalSchematicPositionAfterLayout();
|
|
170786
170916
|
const portFacing = convertFacingDirectionToElbowDirection(port.facingDirection ?? "right") ?? "x+";
|
|
170787
|
-
const
|
|
170917
|
+
const path41 = calculateElbow({
|
|
170788
170918
|
x: portPos.x,
|
|
170789
170919
|
y: portPos.y,
|
|
170790
170920
|
facingDirection: portFacing
|
|
@@ -170793,13 +170923,13 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
170793
170923
|
y: anchorPos.y,
|
|
170794
170924
|
facingDirection: anchorFacing
|
|
170795
170925
|
});
|
|
170796
|
-
if (!Array.isArray(
|
|
170926
|
+
if (!Array.isArray(path41) || path41.length < 2)
|
|
170797
170927
|
continue;
|
|
170798
170928
|
const edges = [];
|
|
170799
|
-
for (let i22 = 0;i22 <
|
|
170929
|
+
for (let i22 = 0;i22 < path41.length - 1; i22++) {
|
|
170800
170930
|
edges.push({
|
|
170801
|
-
from: { x:
|
|
170802
|
-
to: { x:
|
|
170931
|
+
from: { x: path41[i22].x, y: path41[i22].y },
|
|
170932
|
+
to: { x: path41[i22 + 1].x, y: path41[i22 + 1].y }
|
|
170803
170933
|
});
|
|
170804
170934
|
}
|
|
170805
170935
|
let source_trace_id;
|
|
@@ -173111,8 +173241,8 @@ react/cjs/react-jsx-runtime.development.js:
|
|
|
173111
173241
|
*/
|
|
173112
173242
|
|
|
173113
173243
|
// lib/import/import-component-from-jlcpcb.ts
|
|
173114
|
-
import
|
|
173115
|
-
import
|
|
173244
|
+
import fs41 from "node:fs/promises";
|
|
173245
|
+
import path41 from "node:path";
|
|
173116
173246
|
var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cwd()) => {
|
|
173117
173247
|
const component = await fetchEasyEDAComponent(jlcpcbPartNumber);
|
|
173118
173248
|
const tsx = await convertRawEasyToTsx(component);
|
|
@@ -173120,10 +173250,10 @@ var importComponentFromJlcpcb = async (jlcpcbPartNumber, projectDir = process.cw
|
|
|
173120
173250
|
if (!fileName) {
|
|
173121
173251
|
throw new Error("Could not determine file name of converted component");
|
|
173122
173252
|
}
|
|
173123
|
-
const importsDir =
|
|
173124
|
-
await
|
|
173125
|
-
const filePath =
|
|
173126
|
-
await
|
|
173253
|
+
const importsDir = path41.join(projectDir, "imports");
|
|
173254
|
+
await fs41.mkdir(importsDir, { recursive: true });
|
|
173255
|
+
const filePath = path41.join(importsDir, `${fileName}.tsx`);
|
|
173256
|
+
await fs41.writeFile(filePath, tsx);
|
|
173127
173257
|
return { filePath };
|
|
173128
173258
|
};
|
|
173129
173259
|
|
|
@@ -174553,17 +174683,17 @@ async function getLatestTscircuitCdnUrl() {
|
|
|
174553
174683
|
}
|
|
174554
174684
|
|
|
174555
174685
|
// cli/utils/validate-main-in-dist.ts
|
|
174556
|
-
import
|
|
174557
|
-
import
|
|
174686
|
+
import fs42 from "node:fs";
|
|
174687
|
+
import path42 from "node:path";
|
|
174558
174688
|
var validateMainInDist = (projectDir, distDir) => {
|
|
174559
|
-
const packageJsonPath =
|
|
174560
|
-
if (!
|
|
174689
|
+
const packageJsonPath = path42.join(projectDir, "package.json");
|
|
174690
|
+
if (!fs42.existsSync(packageJsonPath))
|
|
174561
174691
|
return;
|
|
174562
|
-
const packageJson = JSON.parse(
|
|
174692
|
+
const packageJson = JSON.parse(fs42.readFileSync(packageJsonPath, "utf-8"));
|
|
174563
174693
|
if (typeof packageJson.main !== "string")
|
|
174564
174694
|
return;
|
|
174565
|
-
const resolvedMainPath =
|
|
174566
|
-
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${
|
|
174695
|
+
const resolvedMainPath = path42.resolve(projectDir, packageJson.main);
|
|
174696
|
+
const isMainInDist = resolvedMainPath === distDir || resolvedMainPath.startsWith(`${distDir}${path42.sep}`);
|
|
174567
174697
|
if (!isMainInDist) {
|
|
174568
174698
|
console.warn('When using transpilation, your package\'s "main" field should point inside the `dist/*` directory, usually to "dist/index.js"');
|
|
174569
174699
|
}
|
|
@@ -174573,12 +174703,12 @@ var validateMainInDist = (projectDir, distDir) => {
|
|
|
174573
174703
|
import { execSync as execSync3 } from "node:child_process";
|
|
174574
174704
|
|
|
174575
174705
|
// lib/shared/install-project-dependencies.ts
|
|
174576
|
-
import
|
|
174577
|
-
import
|
|
174706
|
+
import fs44 from "node:fs";
|
|
174707
|
+
import path44 from "node:path";
|
|
174578
174708
|
|
|
174579
174709
|
// lib/shared/collect-tsci-dependencies.ts
|
|
174580
|
-
import
|
|
174581
|
-
import
|
|
174710
|
+
import fs43 from "node:fs";
|
|
174711
|
+
import path43 from "node:path";
|
|
174582
174712
|
var DEFAULT_PATTERNS = ["**/*.{ts,tsx,js,jsx}"];
|
|
174583
174713
|
var DEFAULT_IGNORES = [
|
|
174584
174714
|
"**/node_modules/**",
|
|
@@ -174593,7 +174723,7 @@ function collectTsciDependencies({
|
|
|
174593
174723
|
patterns = DEFAULT_PATTERNS,
|
|
174594
174724
|
ignore = DEFAULT_IGNORES
|
|
174595
174725
|
} = {}) {
|
|
174596
|
-
const searchRoot =
|
|
174726
|
+
const searchRoot = path43.resolve(cwd);
|
|
174597
174727
|
const files = globbySync(patterns, {
|
|
174598
174728
|
cwd: searchRoot,
|
|
174599
174729
|
absolute: true,
|
|
@@ -174603,7 +174733,7 @@ function collectTsciDependencies({
|
|
|
174603
174733
|
const dependencies2 = new Set;
|
|
174604
174734
|
for (const filePath of files) {
|
|
174605
174735
|
try {
|
|
174606
|
-
const fileContents =
|
|
174736
|
+
const fileContents = fs43.readFileSync(filePath, "utf-8");
|
|
174607
174737
|
let match;
|
|
174608
174738
|
while (true) {
|
|
174609
174739
|
match = IMPORT_PATTERN.exec(fileContents);
|
|
@@ -174627,31 +174757,31 @@ async function installProjectDependencies({
|
|
|
174627
174757
|
cwd = process.cwd(),
|
|
174628
174758
|
skipTscircuitPackage = false
|
|
174629
174759
|
} = {}) {
|
|
174630
|
-
const projectRoot =
|
|
174631
|
-
const packageJsonPath =
|
|
174632
|
-
const npmrcPath =
|
|
174760
|
+
const projectRoot = path44.resolve(cwd);
|
|
174761
|
+
const packageJsonPath = path44.join(projectRoot, "package.json");
|
|
174762
|
+
const npmrcPath = path44.join(projectRoot, ".npmrc");
|
|
174633
174763
|
const packageManager = getPackageManager();
|
|
174634
|
-
if (!
|
|
174764
|
+
if (!fs44.existsSync(projectRoot)) {
|
|
174635
174765
|
throw new Error(`Directory not found: ${projectRoot}`);
|
|
174636
174766
|
}
|
|
174637
174767
|
let packageJsonCreated = false;
|
|
174638
|
-
if (!
|
|
174768
|
+
if (!fs44.existsSync(packageJsonPath)) {
|
|
174639
174769
|
console.log("No package.json found. Generating a new one.");
|
|
174640
174770
|
generatePackageJson(projectRoot);
|
|
174641
174771
|
packageJsonCreated = true;
|
|
174642
174772
|
} else {
|
|
174643
174773
|
console.log("Found existing package.json.");
|
|
174644
174774
|
}
|
|
174645
|
-
const tsconfigPath =
|
|
174646
|
-
if (!
|
|
174775
|
+
const tsconfigPath = path44.join(projectRoot, "tsconfig.json");
|
|
174776
|
+
if (!fs44.existsSync(tsconfigPath)) {
|
|
174647
174777
|
console.log("No tsconfig.json found. Generating a new one.");
|
|
174648
174778
|
generateTsConfig(projectRoot);
|
|
174649
174779
|
}
|
|
174650
|
-
if (!
|
|
174780
|
+
if (!fs44.existsSync(npmrcPath)) {
|
|
174651
174781
|
console.log("Creating .npmrc with tscircuit registry configuration.");
|
|
174652
|
-
|
|
174782
|
+
fs44.writeFileSync(npmrcPath, "@tsci:registry=https://npm.tscircuit.com");
|
|
174653
174783
|
}
|
|
174654
|
-
const packageJson = JSON.parse(
|
|
174784
|
+
const packageJson = JSON.parse(fs44.readFileSync(packageJsonPath, "utf-8"));
|
|
174655
174785
|
if (skipTscircuitPackage) {
|
|
174656
174786
|
packageJson.dependencies = removeTscircuitPackage(packageJson.dependencies);
|
|
174657
174787
|
console.log("Skipping tscircuit package installation from dependencies (using cloud container version).");
|
|
@@ -174670,7 +174800,7 @@ async function installProjectDependencies({
|
|
|
174670
174800
|
console.log("No @tsci dependencies detected in circuit files.");
|
|
174671
174801
|
}
|
|
174672
174802
|
}
|
|
174673
|
-
|
|
174803
|
+
fs44.writeFileSync(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
174674
174804
|
`);
|
|
174675
174805
|
console.log(`Installing dependencies using ${kleur_default.bold(packageManager.name)}...`);
|
|
174676
174806
|
try {
|
|
@@ -174758,78 +174888,6 @@ function analyzeCircuitJson(circuitJson) {
|
|
|
174758
174888
|
return { errors, warnings };
|
|
174759
174889
|
}
|
|
174760
174890
|
|
|
174761
|
-
// lib/shared/get-complete-platform-config.ts
|
|
174762
|
-
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
174763
|
-
import { createHash } from "node:crypto";
|
|
174764
|
-
import path44 from "node:path";
|
|
174765
|
-
import fs44 from "node:fs";
|
|
174766
|
-
function createLocalCacheEngine(cacheDir = path44.join(process.cwd(), ".tscircuit", "cache")) {
|
|
174767
|
-
return {
|
|
174768
|
-
getItem: (key) => {
|
|
174769
|
-
try {
|
|
174770
|
-
const hash = createHash("md5").update(key).digest("hex");
|
|
174771
|
-
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
174772
|
-
const filePath = path44.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
174773
|
-
return fs44.readFileSync(filePath, "utf-8");
|
|
174774
|
-
} catch {
|
|
174775
|
-
return null;
|
|
174776
|
-
}
|
|
174777
|
-
},
|
|
174778
|
-
setItem: (key, value) => {
|
|
174779
|
-
try {
|
|
174780
|
-
fs44.mkdirSync(cacheDir, { recursive: true });
|
|
174781
|
-
const hash = createHash("md5").update(key).digest("hex");
|
|
174782
|
-
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
174783
|
-
const filePath = path44.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
174784
|
-
fs44.writeFileSync(filePath, value);
|
|
174785
|
-
} catch {}
|
|
174786
|
-
}
|
|
174787
|
-
};
|
|
174788
|
-
}
|
|
174789
|
-
function getCompletePlatformConfig(userConfig) {
|
|
174790
|
-
const basePlatformConfig = getPlatformConfig();
|
|
174791
|
-
const defaultConfig = {
|
|
174792
|
-
...basePlatformConfig,
|
|
174793
|
-
localCacheEngine: createLocalCacheEngine(),
|
|
174794
|
-
footprintFileParserMap: {
|
|
174795
|
-
...basePlatformConfig.footprintFileParserMap,
|
|
174796
|
-
kicad_mod: {
|
|
174797
|
-
loadFromUrl: async (url) => {
|
|
174798
|
-
let fetchUrl = url;
|
|
174799
|
-
if (url.startsWith("./") || url.startsWith("../")) {
|
|
174800
|
-
const absolutePath = path44.resolve(process.cwd(), url);
|
|
174801
|
-
fetchUrl = `file://${absolutePath}`;
|
|
174802
|
-
} else if (url.startsWith("/")) {
|
|
174803
|
-
if (fs44.existsSync(url)) {
|
|
174804
|
-
fetchUrl = `file://${url}`;
|
|
174805
|
-
} else {
|
|
174806
|
-
const relativePath = `.${url}`;
|
|
174807
|
-
const absolutePath = path44.resolve(process.cwd(), relativePath);
|
|
174808
|
-
if (fs44.existsSync(absolutePath)) {
|
|
174809
|
-
fetchUrl = `file://${absolutePath}`;
|
|
174810
|
-
} else {
|
|
174811
|
-
fetchUrl = `file://${url}`;
|
|
174812
|
-
}
|
|
174813
|
-
}
|
|
174814
|
-
}
|
|
174815
|
-
return basePlatformConfig.footprintFileParserMap.kicad_mod.loadFromUrl(fetchUrl);
|
|
174816
|
-
}
|
|
174817
|
-
}
|
|
174818
|
-
}
|
|
174819
|
-
};
|
|
174820
|
-
if (!userConfig) {
|
|
174821
|
-
return defaultConfig;
|
|
174822
|
-
}
|
|
174823
|
-
return {
|
|
174824
|
-
...defaultConfig,
|
|
174825
|
-
...userConfig,
|
|
174826
|
-
footprintFileParserMap: {
|
|
174827
|
-
...defaultConfig.footprintFileParserMap,
|
|
174828
|
-
...userConfig.footprintFileParserMap
|
|
174829
|
-
}
|
|
174830
|
-
};
|
|
174831
|
-
}
|
|
174832
|
-
|
|
174833
174891
|
// cli/build/build-file.ts
|
|
174834
174892
|
var buildFile = async (input, output, projectDir, options) => {
|
|
174835
174893
|
try {
|