@tscircuit/cli 0.1.987 → 0.1.989
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 +895 -837
- package/dist/lib/index.js +367 -237
- package/package.json +2 -2
package/dist/lib/index.js
CHANGED
|
@@ -48031,8 +48031,8 @@ var require_utils2 = __commonJS((exports2) => {
|
|
|
48031
48031
|
var result = transform[inputType][outputType](input);
|
|
48032
48032
|
return result;
|
|
48033
48033
|
};
|
|
48034
|
-
exports2.resolve = function(
|
|
48035
|
-
var parts =
|
|
48034
|
+
exports2.resolve = function(path10) {
|
|
48035
|
+
var parts = path10.split("/");
|
|
48036
48036
|
var result = [];
|
|
48037
48037
|
for (var index = 0;index < parts.length; index++) {
|
|
48038
48038
|
var part = parts[index];
|
|
@@ -53482,18 +53482,18 @@ var require_object = __commonJS((exports2, module2) => {
|
|
|
53482
53482
|
var object = new ZipObject(name, zipObjectContent, o);
|
|
53483
53483
|
this.files[name] = object;
|
|
53484
53484
|
};
|
|
53485
|
-
var parentFolder = function(
|
|
53486
|
-
if (
|
|
53487
|
-
|
|
53485
|
+
var parentFolder = function(path10) {
|
|
53486
|
+
if (path10.slice(-1) === "/") {
|
|
53487
|
+
path10 = path10.substring(0, path10.length - 1);
|
|
53488
53488
|
}
|
|
53489
|
-
var lastSlash =
|
|
53490
|
-
return lastSlash > 0 ?
|
|
53489
|
+
var lastSlash = path10.lastIndexOf("/");
|
|
53490
|
+
return lastSlash > 0 ? path10.substring(0, lastSlash) : "";
|
|
53491
53491
|
};
|
|
53492
|
-
var forceTrailingSlash = function(
|
|
53493
|
-
if (
|
|
53494
|
-
|
|
53492
|
+
var forceTrailingSlash = function(path10) {
|
|
53493
|
+
if (path10.slice(-1) !== "/") {
|
|
53494
|
+
path10 += "/";
|
|
53495
53495
|
}
|
|
53496
|
-
return
|
|
53496
|
+
return path10;
|
|
53497
53497
|
};
|
|
53498
53498
|
var folderAdd = function(name, createFolders) {
|
|
53499
53499
|
createFolders = typeof createFolders !== "undefined" ? createFolders : defaults.createFolders;
|
|
@@ -54324,7 +54324,7 @@ var require_path = __commonJS((exports2) => {
|
|
|
54324
54324
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
54325
54325
|
exports2.convertPosixPathToPattern = exports2.convertWindowsPathToPattern = exports2.convertPathToPattern = exports2.escapePosixPath = exports2.escapeWindowsPath = exports2.escape = exports2.removeLeadingDotSegment = exports2.makeAbsolute = exports2.unixify = undefined;
|
|
54326
54326
|
var os4 = __require("os");
|
|
54327
|
-
var
|
|
54327
|
+
var path14 = __require("path");
|
|
54328
54328
|
var IS_WINDOWS_PLATFORM = os4.platform() === "win32";
|
|
54329
54329
|
var LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2;
|
|
54330
54330
|
var POSIX_UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\()|\\(?![!()*+?@[\]{|}]))/g;
|
|
@@ -54336,7 +54336,7 @@ var require_path = __commonJS((exports2) => {
|
|
|
54336
54336
|
}
|
|
54337
54337
|
exports2.unixify = unixify;
|
|
54338
54338
|
function makeAbsolute(cwd, filepath) {
|
|
54339
|
-
return
|
|
54339
|
+
return path14.resolve(cwd, filepath);
|
|
54340
54340
|
}
|
|
54341
54341
|
exports2.makeAbsolute = makeAbsolute;
|
|
54342
54342
|
function removeLeadingDotSegment(entry) {
|
|
@@ -55594,7 +55594,7 @@ var require_braces = __commonJS((exports2, module2) => {
|
|
|
55594
55594
|
|
|
55595
55595
|
// node_modules/micromatch/node_modules/picomatch/lib/constants.js
|
|
55596
55596
|
var require_constants4 = __commonJS((exports2, module2) => {
|
|
55597
|
-
var
|
|
55597
|
+
var path14 = __require("path");
|
|
55598
55598
|
var WIN_SLASH = "\\\\/";
|
|
55599
55599
|
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
55600
55600
|
var DOT_LITERAL = "\\.";
|
|
@@ -55716,7 +55716,7 @@ var require_constants4 = __commonJS((exports2, module2) => {
|
|
|
55716
55716
|
CHAR_UNDERSCORE: 95,
|
|
55717
55717
|
CHAR_VERTICAL_LINE: 124,
|
|
55718
55718
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
55719
|
-
SEP:
|
|
55719
|
+
SEP: path14.sep,
|
|
55720
55720
|
extglobChars(chars) {
|
|
55721
55721
|
return {
|
|
55722
55722
|
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
@@ -55734,7 +55734,7 @@ var require_constants4 = __commonJS((exports2, module2) => {
|
|
|
55734
55734
|
|
|
55735
55735
|
// node_modules/micromatch/node_modules/picomatch/lib/utils.js
|
|
55736
55736
|
var require_utils4 = __commonJS((exports2) => {
|
|
55737
|
-
var
|
|
55737
|
+
var path14 = __require("path");
|
|
55738
55738
|
var win32 = process.platform === "win32";
|
|
55739
55739
|
var {
|
|
55740
55740
|
REGEX_BACKSLASH,
|
|
@@ -55763,7 +55763,7 @@ var require_utils4 = __commonJS((exports2) => {
|
|
|
55763
55763
|
if (options && typeof options.windows === "boolean") {
|
|
55764
55764
|
return options.windows;
|
|
55765
55765
|
}
|
|
55766
|
-
return win32 === true ||
|
|
55766
|
+
return win32 === true || path14.sep === "\\";
|
|
55767
55767
|
};
|
|
55768
55768
|
exports2.escapeLast = (input, char, lastIdx) => {
|
|
55769
55769
|
const idx = input.lastIndexOf(char, lastIdx);
|
|
@@ -56887,7 +56887,7 @@ var require_parse3 = __commonJS((exports2, module2) => {
|
|
|
56887
56887
|
|
|
56888
56888
|
// node_modules/micromatch/node_modules/picomatch/lib/picomatch.js
|
|
56889
56889
|
var require_picomatch = __commonJS((exports2, module2) => {
|
|
56890
|
-
var
|
|
56890
|
+
var path14 = __require("path");
|
|
56891
56891
|
var scan = require_scan();
|
|
56892
56892
|
var parse = require_parse3();
|
|
56893
56893
|
var utils = require_utils4();
|
|
@@ -56973,7 +56973,7 @@ var require_picomatch = __commonJS((exports2, module2) => {
|
|
|
56973
56973
|
};
|
|
56974
56974
|
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
56975
56975
|
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
56976
|
-
return regex.test(
|
|
56976
|
+
return regex.test(path14.basename(input));
|
|
56977
56977
|
};
|
|
56978
56978
|
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
56979
56979
|
picomatch.parse = (pattern, options) => {
|
|
@@ -57194,7 +57194,7 @@ var require_micromatch = __commonJS((exports2, module2) => {
|
|
|
57194
57194
|
var require_pattern2 = __commonJS((exports2) => {
|
|
57195
57195
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57196
57196
|
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;
|
|
57197
|
-
var
|
|
57197
|
+
var path14 = __require("path");
|
|
57198
57198
|
var globParent = require_glob_parent();
|
|
57199
57199
|
var micromatch = require_micromatch();
|
|
57200
57200
|
var GLOBSTAR = "**";
|
|
@@ -57289,7 +57289,7 @@ var require_pattern2 = __commonJS((exports2) => {
|
|
|
57289
57289
|
}
|
|
57290
57290
|
exports2.endsWithSlashGlobStar = endsWithSlashGlobStar;
|
|
57291
57291
|
function isAffectDepthOfReadingPattern(pattern) {
|
|
57292
|
-
const basename =
|
|
57292
|
+
const basename = path14.basename(pattern);
|
|
57293
57293
|
return endsWithSlashGlobStar(pattern) || isStaticPattern(basename);
|
|
57294
57294
|
}
|
|
57295
57295
|
exports2.isAffectDepthOfReadingPattern = isAffectDepthOfReadingPattern;
|
|
@@ -57347,7 +57347,7 @@ var require_pattern2 = __commonJS((exports2) => {
|
|
|
57347
57347
|
}
|
|
57348
57348
|
exports2.partitionAbsoluteAndRelative = partitionAbsoluteAndRelative;
|
|
57349
57349
|
function isAbsolute(pattern) {
|
|
57350
|
-
return
|
|
57350
|
+
return path14.isAbsolute(pattern);
|
|
57351
57351
|
}
|
|
57352
57352
|
exports2.isAbsolute = isAbsolute;
|
|
57353
57353
|
});
|
|
@@ -57510,10 +57510,10 @@ var require_utils5 = __commonJS((exports2) => {
|
|
|
57510
57510
|
exports2.array = array;
|
|
57511
57511
|
var errno = require_errno();
|
|
57512
57512
|
exports2.errno = errno;
|
|
57513
|
-
var
|
|
57514
|
-
exports2.fs =
|
|
57515
|
-
var
|
|
57516
|
-
exports2.path =
|
|
57513
|
+
var fs12 = require_fs();
|
|
57514
|
+
exports2.fs = fs12;
|
|
57515
|
+
var path14 = require_path();
|
|
57516
|
+
exports2.path = path14;
|
|
57517
57517
|
var pattern = require_pattern2();
|
|
57518
57518
|
exports2.pattern = pattern;
|
|
57519
57519
|
var stream = require_stream();
|
|
@@ -57609,8 +57609,8 @@ var require_tasks = __commonJS((exports2) => {
|
|
|
57609
57609
|
var require_async = __commonJS((exports2) => {
|
|
57610
57610
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57611
57611
|
exports2.read = undefined;
|
|
57612
|
-
function read(
|
|
57613
|
-
settings.fs.lstat(
|
|
57612
|
+
function read(path14, settings, callback) {
|
|
57613
|
+
settings.fs.lstat(path14, (lstatError, lstat) => {
|
|
57614
57614
|
if (lstatError !== null) {
|
|
57615
57615
|
callFailureCallback(callback, lstatError);
|
|
57616
57616
|
return;
|
|
@@ -57619,7 +57619,7 @@ var require_async = __commonJS((exports2) => {
|
|
|
57619
57619
|
callSuccessCallback(callback, lstat);
|
|
57620
57620
|
return;
|
|
57621
57621
|
}
|
|
57622
|
-
settings.fs.stat(
|
|
57622
|
+
settings.fs.stat(path14, (statError, stat) => {
|
|
57623
57623
|
if (statError !== null) {
|
|
57624
57624
|
if (settings.throwErrorOnBrokenSymbolicLink) {
|
|
57625
57625
|
callFailureCallback(callback, statError);
|
|
@@ -57648,13 +57648,13 @@ var require_async = __commonJS((exports2) => {
|
|
|
57648
57648
|
var require_sync = __commonJS((exports2) => {
|
|
57649
57649
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57650
57650
|
exports2.read = undefined;
|
|
57651
|
-
function read(
|
|
57652
|
-
const lstat = settings.fs.lstatSync(
|
|
57651
|
+
function read(path14, settings) {
|
|
57652
|
+
const lstat = settings.fs.lstatSync(path14);
|
|
57653
57653
|
if (!lstat.isSymbolicLink() || !settings.followSymbolicLink) {
|
|
57654
57654
|
return lstat;
|
|
57655
57655
|
}
|
|
57656
57656
|
try {
|
|
57657
|
-
const stat = settings.fs.statSync(
|
|
57657
|
+
const stat = settings.fs.statSync(path14);
|
|
57658
57658
|
if (settings.markSymbolicLink) {
|
|
57659
57659
|
stat.isSymbolicLink = () => true;
|
|
57660
57660
|
}
|
|
@@ -57673,12 +57673,12 @@ var require_sync = __commonJS((exports2) => {
|
|
|
57673
57673
|
var require_fs2 = __commonJS((exports2) => {
|
|
57674
57674
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57675
57675
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = undefined;
|
|
57676
|
-
var
|
|
57676
|
+
var fs12 = __require("fs");
|
|
57677
57677
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
57678
|
-
lstat:
|
|
57679
|
-
stat:
|
|
57680
|
-
lstatSync:
|
|
57681
|
-
statSync:
|
|
57678
|
+
lstat: fs12.lstat,
|
|
57679
|
+
stat: fs12.stat,
|
|
57680
|
+
lstatSync: fs12.lstatSync,
|
|
57681
|
+
statSync: fs12.statSync
|
|
57682
57682
|
};
|
|
57683
57683
|
function createFileSystemAdapter(fsMethods) {
|
|
57684
57684
|
if (fsMethods === undefined) {
|
|
@@ -57692,13 +57692,13 @@ var require_fs2 = __commonJS((exports2) => {
|
|
|
57692
57692
|
// node_modules/@nodelib/fs.stat/out/settings.js
|
|
57693
57693
|
var require_settings = __commonJS((exports2) => {
|
|
57694
57694
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57695
|
-
var
|
|
57695
|
+
var fs12 = require_fs2();
|
|
57696
57696
|
|
|
57697
57697
|
class Settings {
|
|
57698
57698
|
constructor(_options = {}) {
|
|
57699
57699
|
this._options = _options;
|
|
57700
57700
|
this.followSymbolicLink = this._getValue(this._options.followSymbolicLink, true);
|
|
57701
|
-
this.fs =
|
|
57701
|
+
this.fs = fs12.createFileSystemAdapter(this._options.fs);
|
|
57702
57702
|
this.markSymbolicLink = this._getValue(this._options.markSymbolicLink, false);
|
|
57703
57703
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
57704
57704
|
}
|
|
@@ -57717,17 +57717,17 @@ var require_out = __commonJS((exports2) => {
|
|
|
57717
57717
|
var sync = require_sync();
|
|
57718
57718
|
var settings_1 = require_settings();
|
|
57719
57719
|
exports2.Settings = settings_1.default;
|
|
57720
|
-
function stat(
|
|
57720
|
+
function stat(path14, optionsOrSettingsOrCallback, callback) {
|
|
57721
57721
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
57722
|
-
async.read(
|
|
57722
|
+
async.read(path14, getSettings(), optionsOrSettingsOrCallback);
|
|
57723
57723
|
return;
|
|
57724
57724
|
}
|
|
57725
|
-
async.read(
|
|
57725
|
+
async.read(path14, getSettings(optionsOrSettingsOrCallback), callback);
|
|
57726
57726
|
}
|
|
57727
57727
|
exports2.stat = stat;
|
|
57728
|
-
function statSync(
|
|
57728
|
+
function statSync(path14, optionsOrSettings) {
|
|
57729
57729
|
const settings = getSettings(optionsOrSettings);
|
|
57730
|
-
return sync.read(
|
|
57730
|
+
return sync.read(path14, settings);
|
|
57731
57731
|
}
|
|
57732
57732
|
exports2.statSync = statSync;
|
|
57733
57733
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -57843,8 +57843,8 @@ var require_fs3 = __commonJS((exports2) => {
|
|
|
57843
57843
|
var require_utils6 = __commonJS((exports2) => {
|
|
57844
57844
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
57845
57845
|
exports2.fs = undefined;
|
|
57846
|
-
var
|
|
57847
|
-
exports2.fs =
|
|
57846
|
+
var fs12 = require_fs3();
|
|
57847
|
+
exports2.fs = fs12;
|
|
57848
57848
|
});
|
|
57849
57849
|
|
|
57850
57850
|
// node_modules/@nodelib/fs.scandir/out/providers/common.js
|
|
@@ -57930,16 +57930,16 @@ var require_async2 = __commonJS((exports2) => {
|
|
|
57930
57930
|
return;
|
|
57931
57931
|
}
|
|
57932
57932
|
const tasks = names.map((name) => {
|
|
57933
|
-
const
|
|
57933
|
+
const path14 = common.joinPathSegments(directory, name, settings.pathSegmentSeparator);
|
|
57934
57934
|
return (done) => {
|
|
57935
|
-
fsStat.stat(
|
|
57935
|
+
fsStat.stat(path14, settings.fsStatSettings, (error, stats) => {
|
|
57936
57936
|
if (error !== null) {
|
|
57937
57937
|
done(error);
|
|
57938
57938
|
return;
|
|
57939
57939
|
}
|
|
57940
57940
|
const entry = {
|
|
57941
57941
|
name,
|
|
57942
|
-
path:
|
|
57942
|
+
path: path14,
|
|
57943
57943
|
dirent: utils.fs.createDirentFromStats(name, stats)
|
|
57944
57944
|
};
|
|
57945
57945
|
if (settings.stats) {
|
|
@@ -58027,14 +58027,14 @@ var require_sync2 = __commonJS((exports2) => {
|
|
|
58027
58027
|
var require_fs4 = __commonJS((exports2) => {
|
|
58028
58028
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
58029
58029
|
exports2.createFileSystemAdapter = exports2.FILE_SYSTEM_ADAPTER = undefined;
|
|
58030
|
-
var
|
|
58030
|
+
var fs12 = __require("fs");
|
|
58031
58031
|
exports2.FILE_SYSTEM_ADAPTER = {
|
|
58032
|
-
lstat:
|
|
58033
|
-
stat:
|
|
58034
|
-
lstatSync:
|
|
58035
|
-
statSync:
|
|
58036
|
-
readdir:
|
|
58037
|
-
readdirSync:
|
|
58032
|
+
lstat: fs12.lstat,
|
|
58033
|
+
stat: fs12.stat,
|
|
58034
|
+
lstatSync: fs12.lstatSync,
|
|
58035
|
+
statSync: fs12.statSync,
|
|
58036
|
+
readdir: fs12.readdir,
|
|
58037
|
+
readdirSync: fs12.readdirSync
|
|
58038
58038
|
};
|
|
58039
58039
|
function createFileSystemAdapter(fsMethods) {
|
|
58040
58040
|
if (fsMethods === undefined) {
|
|
@@ -58048,16 +58048,16 @@ var require_fs4 = __commonJS((exports2) => {
|
|
|
58048
58048
|
// node_modules/@nodelib/fs.scandir/out/settings.js
|
|
58049
58049
|
var require_settings2 = __commonJS((exports2) => {
|
|
58050
58050
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
58051
|
-
var
|
|
58051
|
+
var path14 = __require("path");
|
|
58052
58052
|
var fsStat = require_out();
|
|
58053
|
-
var
|
|
58053
|
+
var fs12 = require_fs4();
|
|
58054
58054
|
|
|
58055
58055
|
class Settings {
|
|
58056
58056
|
constructor(_options = {}) {
|
|
58057
58057
|
this._options = _options;
|
|
58058
58058
|
this.followSymbolicLinks = this._getValue(this._options.followSymbolicLinks, false);
|
|
58059
|
-
this.fs =
|
|
58060
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
58059
|
+
this.fs = fs12.createFileSystemAdapter(this._options.fs);
|
|
58060
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path14.sep);
|
|
58061
58061
|
this.stats = this._getValue(this._options.stats, false);
|
|
58062
58062
|
this.throwErrorOnBrokenSymbolicLink = this._getValue(this._options.throwErrorOnBrokenSymbolicLink, true);
|
|
58063
58063
|
this.fsStatSettings = new fsStat.Settings({
|
|
@@ -58081,17 +58081,17 @@ var require_out2 = __commonJS((exports2) => {
|
|
|
58081
58081
|
var sync = require_sync2();
|
|
58082
58082
|
var settings_1 = require_settings2();
|
|
58083
58083
|
exports2.Settings = settings_1.default;
|
|
58084
|
-
function scandir(
|
|
58084
|
+
function scandir(path14, optionsOrSettingsOrCallback, callback) {
|
|
58085
58085
|
if (typeof optionsOrSettingsOrCallback === "function") {
|
|
58086
|
-
async.read(
|
|
58086
|
+
async.read(path14, getSettings(), optionsOrSettingsOrCallback);
|
|
58087
58087
|
return;
|
|
58088
58088
|
}
|
|
58089
|
-
async.read(
|
|
58089
|
+
async.read(path14, getSettings(optionsOrSettingsOrCallback), callback);
|
|
58090
58090
|
}
|
|
58091
58091
|
exports2.scandir = scandir;
|
|
58092
|
-
function scandirSync(
|
|
58092
|
+
function scandirSync(path14, optionsOrSettings) {
|
|
58093
58093
|
const settings = getSettings(optionsOrSettings);
|
|
58094
|
-
return sync.read(
|
|
58094
|
+
return sync.read(path14, settings);
|
|
58095
58095
|
}
|
|
58096
58096
|
exports2.scandirSync = scandirSync;
|
|
58097
58097
|
function getSettings(settingsOrOptions = {}) {
|
|
@@ -58715,7 +58715,7 @@ var require_sync4 = __commonJS((exports2) => {
|
|
|
58715
58715
|
// node_modules/@nodelib/fs.walk/out/settings.js
|
|
58716
58716
|
var require_settings3 = __commonJS((exports2) => {
|
|
58717
58717
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
58718
|
-
var
|
|
58718
|
+
var path14 = __require("path");
|
|
58719
58719
|
var fsScandir = require_out2();
|
|
58720
58720
|
|
|
58721
58721
|
class Settings {
|
|
@@ -58726,7 +58726,7 @@ var require_settings3 = __commonJS((exports2) => {
|
|
|
58726
58726
|
this.deepFilter = this._getValue(this._options.deepFilter, null);
|
|
58727
58727
|
this.entryFilter = this._getValue(this._options.entryFilter, null);
|
|
58728
58728
|
this.errorFilter = this._getValue(this._options.errorFilter, null);
|
|
58729
|
-
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator,
|
|
58729
|
+
this.pathSegmentSeparator = this._getValue(this._options.pathSegmentSeparator, path14.sep);
|
|
58730
58730
|
this.fsScandirSettings = new fsScandir.Settings({
|
|
58731
58731
|
followSymbolicLinks: this._options.followSymbolicLinks,
|
|
58732
58732
|
fs: this._options.fs,
|
|
@@ -58782,7 +58782,7 @@ var require_out3 = __commonJS((exports2) => {
|
|
|
58782
58782
|
// node_modules/fast-glob/out/readers/reader.js
|
|
58783
58783
|
var require_reader2 = __commonJS((exports2) => {
|
|
58784
58784
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
58785
|
-
var
|
|
58785
|
+
var path14 = __require("path");
|
|
58786
58786
|
var fsStat = require_out();
|
|
58787
58787
|
var utils = require_utils5();
|
|
58788
58788
|
|
|
@@ -58796,7 +58796,7 @@ var require_reader2 = __commonJS((exports2) => {
|
|
|
58796
58796
|
});
|
|
58797
58797
|
}
|
|
58798
58798
|
_getFullEntryPath(filepath) {
|
|
58799
|
-
return
|
|
58799
|
+
return path14.resolve(this._settings.cwd, filepath);
|
|
58800
58800
|
}
|
|
58801
58801
|
_makeEntry(stats, pattern) {
|
|
58802
58802
|
const entry = {
|
|
@@ -59193,7 +59193,7 @@ var require_entry2 = __commonJS((exports2) => {
|
|
|
59193
59193
|
// node_modules/fast-glob/out/providers/provider.js
|
|
59194
59194
|
var require_provider = __commonJS((exports2) => {
|
|
59195
59195
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
59196
|
-
var
|
|
59196
|
+
var path14 = __require("path");
|
|
59197
59197
|
var deep_1 = require_deep();
|
|
59198
59198
|
var entry_1 = require_entry();
|
|
59199
59199
|
var error_1 = require_error();
|
|
@@ -59208,7 +59208,7 @@ var require_provider = __commonJS((exports2) => {
|
|
|
59208
59208
|
this.entryTransformer = new entry_2.default(this._settings);
|
|
59209
59209
|
}
|
|
59210
59210
|
_getRootDirectory(task) {
|
|
59211
|
-
return
|
|
59211
|
+
return path14.resolve(this._settings.cwd, task.base);
|
|
59212
59212
|
}
|
|
59213
59213
|
_getReaderOptions(task) {
|
|
59214
59214
|
const basePath = task.base === "." ? "" : task.base;
|
|
@@ -59377,16 +59377,16 @@ var require_sync6 = __commonJS((exports2) => {
|
|
|
59377
59377
|
var require_settings4 = __commonJS((exports2) => {
|
|
59378
59378
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
59379
59379
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = undefined;
|
|
59380
|
-
var
|
|
59380
|
+
var fs12 = __require("fs");
|
|
59381
59381
|
var os4 = __require("os");
|
|
59382
59382
|
var CPU_COUNT = Math.max(os4.cpus().length, 1);
|
|
59383
59383
|
exports2.DEFAULT_FILE_SYSTEM_ADAPTER = {
|
|
59384
|
-
lstat:
|
|
59385
|
-
lstatSync:
|
|
59386
|
-
stat:
|
|
59387
|
-
statSync:
|
|
59388
|
-
readdir:
|
|
59389
|
-
readdirSync:
|
|
59384
|
+
lstat: fs12.lstat,
|
|
59385
|
+
lstatSync: fs12.lstatSync,
|
|
59386
|
+
stat: fs12.stat,
|
|
59387
|
+
statSync: fs12.statSync,
|
|
59388
|
+
readdir: fs12.readdir,
|
|
59389
|
+
readdirSync: fs12.readdirSync
|
|
59390
59390
|
};
|
|
59391
59391
|
|
|
59392
59392
|
class Settings {
|
|
@@ -59722,7 +59722,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59722
59722
|
makeArray(isString2(pattern) ? splitPattern(pattern) : pattern).forEach(this._add, this);
|
|
59723
59723
|
return this._added;
|
|
59724
59724
|
}
|
|
59725
|
-
test(
|
|
59725
|
+
test(path14, checkUnignored, mode) {
|
|
59726
59726
|
let ignored = false;
|
|
59727
59727
|
let unignored = false;
|
|
59728
59728
|
let matchedRule;
|
|
@@ -59731,7 +59731,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59731
59731
|
if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
|
|
59732
59732
|
return;
|
|
59733
59733
|
}
|
|
59734
|
-
const matched = rule[mode].test(
|
|
59734
|
+
const matched = rule[mode].test(path14);
|
|
59735
59735
|
if (!matched) {
|
|
59736
59736
|
return;
|
|
59737
59737
|
}
|
|
@@ -59752,20 +59752,20 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59752
59752
|
var throwError = (message, Ctor) => {
|
|
59753
59753
|
throw new Ctor(message);
|
|
59754
59754
|
};
|
|
59755
|
-
var checkPath = (
|
|
59756
|
-
if (!isString2(
|
|
59755
|
+
var checkPath = (path14, originalPath, doThrow) => {
|
|
59756
|
+
if (!isString2(path14)) {
|
|
59757
59757
|
return doThrow(`path must be a string, but got \`${originalPath}\``, TypeError);
|
|
59758
59758
|
}
|
|
59759
|
-
if (!
|
|
59759
|
+
if (!path14) {
|
|
59760
59760
|
return doThrow(`path must not be empty`, TypeError);
|
|
59761
59761
|
}
|
|
59762
|
-
if (checkPath.isNotRelative(
|
|
59762
|
+
if (checkPath.isNotRelative(path14)) {
|
|
59763
59763
|
const r = "`path.relative()`d";
|
|
59764
59764
|
return doThrow(`path should be a ${r} string, but got "${originalPath}"`, RangeError);
|
|
59765
59765
|
}
|
|
59766
59766
|
return true;
|
|
59767
59767
|
};
|
|
59768
|
-
var isNotRelative = (
|
|
59768
|
+
var isNotRelative = (path14) => REGEX_TEST_INVALID_PATH.test(path14);
|
|
59769
59769
|
checkPath.isNotRelative = isNotRelative;
|
|
59770
59770
|
checkPath.convert = (p) => p;
|
|
59771
59771
|
|
|
@@ -59794,15 +59794,15 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59794
59794
|
return this.add(pattern);
|
|
59795
59795
|
}
|
|
59796
59796
|
_test(originalPath, cache, checkUnignored, slices) {
|
|
59797
|
-
const
|
|
59798
|
-
checkPath(
|
|
59799
|
-
return this._t(
|
|
59797
|
+
const path14 = originalPath && checkPath.convert(originalPath);
|
|
59798
|
+
checkPath(path14, originalPath, this._strictPathCheck ? throwError : RETURN_FALSE);
|
|
59799
|
+
return this._t(path14, cache, checkUnignored, slices);
|
|
59800
59800
|
}
|
|
59801
|
-
checkIgnore(
|
|
59802
|
-
if (!REGEX_TEST_TRAILING_SLASH.test(
|
|
59803
|
-
return this.test(
|
|
59801
|
+
checkIgnore(path14) {
|
|
59802
|
+
if (!REGEX_TEST_TRAILING_SLASH.test(path14)) {
|
|
59803
|
+
return this.test(path14);
|
|
59804
59804
|
}
|
|
59805
|
-
const slices =
|
|
59805
|
+
const slices = path14.split(SLASH).filter(Boolean);
|
|
59806
59806
|
slices.pop();
|
|
59807
59807
|
if (slices.length) {
|
|
59808
59808
|
const parent = this._t(slices.join(SLASH) + SLASH, this._testCache, true, slices);
|
|
@@ -59810,42 +59810,42 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59810
59810
|
return parent;
|
|
59811
59811
|
}
|
|
59812
59812
|
}
|
|
59813
|
-
return this._rules.test(
|
|
59813
|
+
return this._rules.test(path14, false, MODE_CHECK_IGNORE);
|
|
59814
59814
|
}
|
|
59815
|
-
_t(
|
|
59816
|
-
if (
|
|
59817
|
-
return cache[
|
|
59815
|
+
_t(path14, cache, checkUnignored, slices) {
|
|
59816
|
+
if (path14 in cache) {
|
|
59817
|
+
return cache[path14];
|
|
59818
59818
|
}
|
|
59819
59819
|
if (!slices) {
|
|
59820
|
-
slices =
|
|
59820
|
+
slices = path14.split(SLASH).filter(Boolean);
|
|
59821
59821
|
}
|
|
59822
59822
|
slices.pop();
|
|
59823
59823
|
if (!slices.length) {
|
|
59824
|
-
return cache[
|
|
59824
|
+
return cache[path14] = this._rules.test(path14, checkUnignored, MODE_IGNORE);
|
|
59825
59825
|
}
|
|
59826
59826
|
const parent = this._t(slices.join(SLASH) + SLASH, cache, checkUnignored, slices);
|
|
59827
|
-
return cache[
|
|
59827
|
+
return cache[path14] = parent.ignored ? parent : this._rules.test(path14, checkUnignored, MODE_IGNORE);
|
|
59828
59828
|
}
|
|
59829
|
-
ignores(
|
|
59830
|
-
return this._test(
|
|
59829
|
+
ignores(path14) {
|
|
59830
|
+
return this._test(path14, this._ignoreCache, false).ignored;
|
|
59831
59831
|
}
|
|
59832
59832
|
createFilter() {
|
|
59833
|
-
return (
|
|
59833
|
+
return (path14) => !this.ignores(path14);
|
|
59834
59834
|
}
|
|
59835
59835
|
filter(paths) {
|
|
59836
59836
|
return makeArray(paths).filter(this.createFilter());
|
|
59837
59837
|
}
|
|
59838
|
-
test(
|
|
59839
|
-
return this._test(
|
|
59838
|
+
test(path14) {
|
|
59839
|
+
return this._test(path14, this._testCache, true);
|
|
59840
59840
|
}
|
|
59841
59841
|
}
|
|
59842
59842
|
var factory = (options) => new Ignore(options);
|
|
59843
|
-
var isPathValid = (
|
|
59843
|
+
var isPathValid = (path14) => checkPath(path14 && checkPath.convert(path14), path14, RETURN_FALSE);
|
|
59844
59844
|
var setupWindows = () => {
|
|
59845
59845
|
const makePosix = (str) => /^\\\\\?\\/.test(str) || /["<>|\u0000-\u001F]+/u.test(str) ? str : str.replace(/\\/g, "/");
|
|
59846
59846
|
checkPath.convert = makePosix;
|
|
59847
59847
|
const REGEX_TEST_WINDOWS_PATH_ABSOLUTE = /^[a-z]:\//i;
|
|
59848
|
-
checkPath.isNotRelative = (
|
|
59848
|
+
checkPath.isNotRelative = (path14) => REGEX_TEST_WINDOWS_PATH_ABSOLUTE.test(path14) || isNotRelative(path14);
|
|
59849
59849
|
};
|
|
59850
59850
|
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
59851
59851
|
setupWindows();
|
|
@@ -59858,7 +59858,7 @@ var require_ignore = __commonJS((exports2, module2) => {
|
|
|
59858
59858
|
|
|
59859
59859
|
// lib/server/createHttpServer.ts
|
|
59860
59860
|
import * as http from "node:http";
|
|
59861
|
-
import * as
|
|
59861
|
+
import * as fs16 from "node:fs";
|
|
59862
59862
|
|
|
59863
59863
|
// node_modules/winterspec/dist/edge/transform-to-node.js
|
|
59864
59864
|
var import_node_utils = __toESM2(require_dist(), 1);
|
|
@@ -60432,7 +60432,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
|
|
|
60432
60432
|
}));
|
|
60433
60433
|
};
|
|
60434
60434
|
// package.json
|
|
60435
|
-
var version = "0.1.
|
|
60435
|
+
var version = "0.1.988";
|
|
60436
60436
|
var package_default = {
|
|
60437
60437
|
name: "@tscircuit/cli",
|
|
60438
60438
|
main: "dist/cli/main.js",
|
|
@@ -60461,7 +60461,7 @@ var package_default = {
|
|
|
60461
60461
|
"@types/semver": "^7.5.8",
|
|
60462
60462
|
"bun-match-svg": "^0.0.12",
|
|
60463
60463
|
chokidar: "4.0.1",
|
|
60464
|
-
"circuit-json-to-kicad": "^0.0.
|
|
60464
|
+
"circuit-json-to-kicad": "^0.0.81",
|
|
60465
60465
|
"circuit-json-to-readable-netlist": "^0.0.13",
|
|
60466
60466
|
"circuit-json-to-spice": "^0.0.10",
|
|
60467
60467
|
"circuit-json-to-tscircuit": "^0.0.9",
|
|
@@ -62994,16 +62994,16 @@ var getIndex = async (mainComponentPath, fileServerApiBaseUrl) => {
|
|
|
62994
62994
|
};
|
|
62995
62995
|
|
|
62996
62996
|
// lib/server/kicad-pcm-proxy.ts
|
|
62997
|
-
import * as
|
|
62998
|
-
import * as
|
|
62997
|
+
import * as fs15 from "node:fs";
|
|
62998
|
+
import * as path15 from "node:path";
|
|
62999
62999
|
|
|
63000
63000
|
// cli/build/build-kicad-pcm.ts
|
|
63001
|
-
import
|
|
63002
|
-
import
|
|
63001
|
+
import path13 from "node:path";
|
|
63002
|
+
import fs11 from "node:fs";
|
|
63003
63003
|
|
|
63004
63004
|
// lib/shared/convert-to-kicad-library.tsx
|
|
63005
|
-
import
|
|
63006
|
-
import
|
|
63005
|
+
import fs7 from "node:fs";
|
|
63006
|
+
import path9 from "node:path";
|
|
63007
63007
|
import { pathToFileURL } from "node:url";
|
|
63008
63008
|
|
|
63009
63009
|
// node_modules/circuit-json-to-kicad/dist/index.js
|
|
@@ -66287,6 +66287,7 @@ var ExtractSymbolsStage = class extends ConverterStage {
|
|
|
66287
66287
|
return this.ctx.libraryOutput;
|
|
66288
66288
|
}
|
|
66289
66289
|
};
|
|
66290
|
+
var MODEL_CDN_BASE_URL = "https://modelcdn.tscircuit.com/jscad_models";
|
|
66290
66291
|
var KICAD_FP_VERSION = 20240108;
|
|
66291
66292
|
var KICAD_FP_GENERATOR = "pcbnew";
|
|
66292
66293
|
var KICAD_FP_GENERATOR_VERSION = "8.0";
|
|
@@ -66295,24 +66296,27 @@ function getBasename(filePath) {
|
|
|
66295
66296
|
return parts[parts.length - 1] || filePath;
|
|
66296
66297
|
}
|
|
66297
66298
|
var ExtractFootprintsStage = class extends ConverterStage {
|
|
66298
|
-
|
|
66299
|
-
const
|
|
66299
|
+
classifyFootprints() {
|
|
66300
|
+
const customFootprintNames = /* @__PURE__ */ new Set;
|
|
66301
|
+
const footprinterStrings = /* @__PURE__ */ new Map;
|
|
66300
66302
|
const cadComponents = this.ctx.db.cad_component?.list() ?? [];
|
|
66301
66303
|
const sourceComponents = this.ctx.db.source_component;
|
|
66302
66304
|
for (const cadComponent of cadComponents) {
|
|
66303
|
-
|
|
66304
|
-
|
|
66305
|
-
|
|
66306
|
-
|
|
66307
|
-
|
|
66308
|
-
|
|
66309
|
-
|
|
66310
|
-
|
|
66311
|
-
|
|
66305
|
+
const sourceComp = cadComponent.source_component_id ? sourceComponents?.get(cadComponent.source_component_id) : null;
|
|
66306
|
+
if (!sourceComp)
|
|
66307
|
+
continue;
|
|
66308
|
+
const footprintName = getKicadCompatibleComponentName(sourceComp, cadComponent);
|
|
66309
|
+
if (cadComponent.footprinter_string) {
|
|
66310
|
+
footprinterStrings.set(footprintName, cadComponent.footprinter_string);
|
|
66311
|
+
} else {
|
|
66312
|
+
customFootprintNames.add(footprintName);
|
|
66313
|
+
const pcbComp = this.ctx.circuitJson.find((el) => el.type === "pcb_component" && el.source_component_id === cadComponent.source_component_id);
|
|
66314
|
+
if (pcbComp && pcbComp.type === "pcb_component" && pcbComp.metadata?.kicad_footprint?.footprintName) {
|
|
66315
|
+
customFootprintNames.add(pcbComp.metadata.kicad_footprint.footprintName);
|
|
66312
66316
|
}
|
|
66313
66317
|
}
|
|
66314
66318
|
}
|
|
66315
|
-
return
|
|
66319
|
+
return { customFootprintNames, footprinterStrings };
|
|
66316
66320
|
}
|
|
66317
66321
|
_step() {
|
|
66318
66322
|
const kicadPcbString = this.ctx.kicadPcbString;
|
|
@@ -66320,7 +66324,7 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
66320
66324
|
if (!kicadPcbString) {
|
|
66321
66325
|
throw new Error("PCB content not available. Run GenerateKicadSchAndPcbStage first.");
|
|
66322
66326
|
}
|
|
66323
|
-
const customFootprintNames = this.
|
|
66327
|
+
const { customFootprintNames, footprinterStrings } = this.classifyFootprints();
|
|
66324
66328
|
const uniqueFootprints = /* @__PURE__ */ new Map;
|
|
66325
66329
|
try {
|
|
66326
66330
|
const parsed = parseKicadSexpr2(kicadPcbString);
|
|
@@ -66335,7 +66339,8 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
66335
66339
|
const footprintEntry = this.sanitizeFootprint({
|
|
66336
66340
|
footprint,
|
|
66337
66341
|
fpLibraryName,
|
|
66338
|
-
customFootprintNames
|
|
66342
|
+
customFootprintNames,
|
|
66343
|
+
footprinterStrings
|
|
66339
66344
|
});
|
|
66340
66345
|
if (!uniqueFootprints.has(footprintEntry.footprintName)) {
|
|
66341
66346
|
uniqueFootprints.set(footprintEntry.footprintName, footprintEntry);
|
|
@@ -66350,7 +66355,8 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
66350
66355
|
sanitizeFootprint({
|
|
66351
66356
|
footprint,
|
|
66352
66357
|
fpLibraryName,
|
|
66353
|
-
customFootprintNames
|
|
66358
|
+
customFootprintNames,
|
|
66359
|
+
footprinterStrings
|
|
66354
66360
|
}) {
|
|
66355
66361
|
const libraryLink = footprint.libraryLink ?? "footprint";
|
|
66356
66362
|
const parts = libraryLink.split(":");
|
|
@@ -66480,6 +66486,16 @@ var ExtractFootprintsStage = class extends ConverterStage {
|
|
|
66480
66486
|
modelFiles.push(model.path);
|
|
66481
66487
|
}
|
|
66482
66488
|
}
|
|
66489
|
+
if (updatedModels.length === 0) {
|
|
66490
|
+
const footprinterString = footprinterStrings.get(footprintName);
|
|
66491
|
+
if (footprinterString) {
|
|
66492
|
+
const cdnUrl = `${MODEL_CDN_BASE_URL}/${footprinterString}.step`;
|
|
66493
|
+
const cdnModelFilename = getBasename(cdnUrl);
|
|
66494
|
+
const newPath = `../../3dmodels/tscircuit_builtin.3dshapes/${cdnModelFilename}`;
|
|
66495
|
+
updatedModels.push(new FootprintModel3(newPath));
|
|
66496
|
+
modelFiles.push(cdnUrl);
|
|
66497
|
+
}
|
|
66498
|
+
}
|
|
66483
66499
|
footprint.models = updatedModels;
|
|
66484
66500
|
return {
|
|
66485
66501
|
footprintName,
|
|
@@ -67049,6 +67065,16 @@ function classifyKicadSymbols(ctx) {
|
|
|
67049
67065
|
});
|
|
67050
67066
|
}
|
|
67051
67067
|
}
|
|
67068
|
+
function getSymbolFootprintRef(kicadSymbol) {
|
|
67069
|
+
const properties = kicadSymbol.symbol.properties ?? [];
|
|
67070
|
+
for (const prop of properties) {
|
|
67071
|
+
if (prop.key === "Footprint" && prop.value) {
|
|
67072
|
+
const parts = prop.value.split(":");
|
|
67073
|
+
return (parts.length > 1 ? parts[1] : parts[0]) ?? null;
|
|
67074
|
+
}
|
|
67075
|
+
}
|
|
67076
|
+
return null;
|
|
67077
|
+
}
|
|
67052
67078
|
function classifySymbolsForComponent({
|
|
67053
67079
|
ctx,
|
|
67054
67080
|
extractedKicadComponent
|
|
@@ -67056,6 +67082,7 @@ function classifySymbolsForComponent({
|
|
|
67056
67082
|
const { tscircuitComponentName, kicadSymbols } = extractedKicadComponent;
|
|
67057
67083
|
const hasCustomFootprint = componentHasCustomFootprint(extractedKicadComponent);
|
|
67058
67084
|
let hasAddedUserSymbol = false;
|
|
67085
|
+
const customFootprintNames = new Set(extractedKicadComponent.kicadFootprints.filter((fp) => !fp.isBuiltin).map((fp) => fp.footprintName));
|
|
67059
67086
|
const builtComponent = ctx.builtTscircuitComponents.find((c) => c.tscircuitComponentName === tscircuitComponentName);
|
|
67060
67087
|
const schematicSymbol = builtComponent?.circuitJson.find((el) => el.type === "schematic_symbol");
|
|
67061
67088
|
const metadata = schematicSymbol?.metadata?.kicad_symbol;
|
|
@@ -67077,19 +67104,28 @@ function classifySymbolsForComponent({
|
|
|
67077
67104
|
const updatedSymbol = metadata ? applyKicadSymbolMetadata(kicadSymbol, metadata) : kicadSymbol;
|
|
67078
67105
|
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
67079
67106
|
} else if (hasCustomFootprint && !hasAddedUserSymbol) {
|
|
67080
|
-
|
|
67081
|
-
const
|
|
67082
|
-
|
|
67083
|
-
|
|
67084
|
-
|
|
67085
|
-
|
|
67086
|
-
|
|
67087
|
-
|
|
67088
|
-
|
|
67089
|
-
|
|
67090
|
-
|
|
67091
|
-
|
|
67092
|
-
|
|
67107
|
+
const footprintRef = getSymbolFootprintRef(kicadSymbol);
|
|
67108
|
+
const symbolMatchesCustomFootprint = footprintRef != null && customFootprintNames.has(footprintRef);
|
|
67109
|
+
if (symbolMatchesCustomFootprint) {
|
|
67110
|
+
hasAddedUserSymbol = true;
|
|
67111
|
+
const renamedSymbol = renameKicadSymbol({
|
|
67112
|
+
kicadSymbol,
|
|
67113
|
+
newKicadSymbolName: tscircuitComponentName
|
|
67114
|
+
});
|
|
67115
|
+
updateKicadSymbolFootprint({
|
|
67116
|
+
kicadSymbol: renamedSymbol,
|
|
67117
|
+
kicadLibraryName: ctx.kicadLibraryName,
|
|
67118
|
+
kicadFootprintName: tscircuitComponentName,
|
|
67119
|
+
isPcm: ctx.isPcm
|
|
67120
|
+
});
|
|
67121
|
+
const updatedSymbol = metadata ? applyKicadSymbolMetadata(renamedSymbol, metadata) : renamedSymbol;
|
|
67122
|
+
addUserSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
67123
|
+
} else {
|
|
67124
|
+
const updatedSymbol = updateBuiltinKicadSymbolFootprint(kicadSymbol, {
|
|
67125
|
+
isPcm: ctx.isPcm
|
|
67126
|
+
});
|
|
67127
|
+
addBuiltinSymbol({ ctx, kicadSymbol: updatedSymbol });
|
|
67128
|
+
}
|
|
67093
67129
|
} else {
|
|
67094
67130
|
const updatedSymbol = updateBuiltinKicadSymbolFootprint(kicadSymbol, {
|
|
67095
67131
|
isPcm: ctx.isPcm
|
|
@@ -67118,11 +67154,13 @@ function addBuiltinSymbol({
|
|
|
67118
67154
|
}
|
|
67119
67155
|
}
|
|
67120
67156
|
function generateSymLibTable(params2) {
|
|
67121
|
-
const { kicadLibraryName, includeBuiltin } = params2;
|
|
67157
|
+
const { kicadLibraryName, includeUser, includeBuiltin } = params2;
|
|
67122
67158
|
let content = `(sym_lib_table
|
|
67123
67159
|
`;
|
|
67124
|
-
|
|
67160
|
+
if (includeUser) {
|
|
67161
|
+
content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/symbols/${kicadLibraryName}.kicad_sym")(options "")(descr ""))
|
|
67125
67162
|
`;
|
|
67163
|
+
}
|
|
67126
67164
|
if (includeBuiltin) {
|
|
67127
67165
|
content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/symbols/tscircuit_builtin.kicad_sym")(options "")(descr ""))
|
|
67128
67166
|
`;
|
|
@@ -67132,11 +67170,13 @@ function generateSymLibTable(params2) {
|
|
|
67132
67170
|
return content;
|
|
67133
67171
|
}
|
|
67134
67172
|
function generateFpLibTable(params2) {
|
|
67135
|
-
const { kicadLibraryName, includeBuiltin } = params2;
|
|
67173
|
+
const { kicadLibraryName, includeUser, includeBuiltin } = params2;
|
|
67136
67174
|
let content = `(fp_lib_table
|
|
67137
67175
|
`;
|
|
67138
|
-
|
|
67176
|
+
if (includeUser) {
|
|
67177
|
+
content += ` (lib (name "${kicadLibraryName}")(type "KiCad")(uri "\${KIPRJMOD}/footprints/${kicadLibraryName}.pretty")(options "")(descr ""))
|
|
67139
67178
|
`;
|
|
67179
|
+
}
|
|
67140
67180
|
if (includeBuiltin) {
|
|
67141
67181
|
content += ` (lib (name "tscircuit_builtin")(type "KiCad")(uri "\${KIPRJMOD}/footprints/tscircuit_builtin.pretty")(options "")(descr ""))
|
|
67142
67182
|
`;
|
|
@@ -67189,14 +67229,18 @@ function buildBuiltinFootprintLibrary(ctx) {
|
|
|
67189
67229
|
}
|
|
67190
67230
|
}
|
|
67191
67231
|
function buildLibraryTables(ctx) {
|
|
67232
|
+
const hasUserFootprints = ctx.userKicadFootprints.length > 0;
|
|
67233
|
+
const hasUserSymbols = ctx.userKicadSymbols.length > 0;
|
|
67192
67234
|
const hasBuiltinFootprints = ctx.includeBuiltins && ctx.builtinKicadFootprints.length > 0;
|
|
67193
67235
|
const hasBuiltinSymbols = ctx.includeBuiltins && ctx.builtinKicadSymbols.length > 0;
|
|
67194
67236
|
ctx.kicadProjectFsMap["fp-lib-table"] = generateFpLibTable({
|
|
67195
67237
|
kicadLibraryName: ctx.kicadLibraryName,
|
|
67238
|
+
includeUser: hasUserFootprints,
|
|
67196
67239
|
includeBuiltin: hasBuiltinFootprints
|
|
67197
67240
|
});
|
|
67198
67241
|
ctx.kicadProjectFsMap["sym-lib-table"] = generateSymLibTable({
|
|
67199
67242
|
kicadLibraryName: ctx.kicadLibraryName,
|
|
67243
|
+
includeUser: hasUserSymbols,
|
|
67200
67244
|
includeBuiltin: hasBuiltinSymbols
|
|
67201
67245
|
});
|
|
67202
67246
|
}
|
|
@@ -67343,6 +67387,78 @@ async function importFromUserLand(moduleName) {
|
|
|
67343
67387
|
return import(moduleName);
|
|
67344
67388
|
}
|
|
67345
67389
|
|
|
67390
|
+
// lib/shared/get-complete-platform-config.ts
|
|
67391
|
+
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
67392
|
+
import { createHash } from "node:crypto";
|
|
67393
|
+
import path8 from "node:path";
|
|
67394
|
+
import fs6 from "node:fs";
|
|
67395
|
+
function createLocalCacheEngine(cacheDir = path8.join(process.cwd(), ".tscircuit", "cache")) {
|
|
67396
|
+
return {
|
|
67397
|
+
getItem: (key) => {
|
|
67398
|
+
try {
|
|
67399
|
+
const hash = createHash("md5").update(key).digest("hex");
|
|
67400
|
+
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
67401
|
+
const filePath = path8.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
67402
|
+
return fs6.readFileSync(filePath, "utf-8");
|
|
67403
|
+
} catch {
|
|
67404
|
+
return null;
|
|
67405
|
+
}
|
|
67406
|
+
},
|
|
67407
|
+
setItem: (key, value) => {
|
|
67408
|
+
try {
|
|
67409
|
+
fs6.mkdirSync(cacheDir, { recursive: true });
|
|
67410
|
+
const hash = createHash("md5").update(key).digest("hex");
|
|
67411
|
+
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
67412
|
+
const filePath = path8.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
67413
|
+
fs6.writeFileSync(filePath, value);
|
|
67414
|
+
} catch {}
|
|
67415
|
+
}
|
|
67416
|
+
};
|
|
67417
|
+
}
|
|
67418
|
+
function getCompletePlatformConfig(userConfig) {
|
|
67419
|
+
const basePlatformConfig = getPlatformConfig();
|
|
67420
|
+
const defaultConfig = {
|
|
67421
|
+
...basePlatformConfig,
|
|
67422
|
+
localCacheEngine: createLocalCacheEngine(),
|
|
67423
|
+
footprintFileParserMap: {
|
|
67424
|
+
...basePlatformConfig.footprintFileParserMap,
|
|
67425
|
+
kicad_mod: {
|
|
67426
|
+
loadFromUrl: async (url) => {
|
|
67427
|
+
let fetchUrl = url;
|
|
67428
|
+
if (url.startsWith("./") || url.startsWith("../")) {
|
|
67429
|
+
const absolutePath = path8.resolve(process.cwd(), url);
|
|
67430
|
+
fetchUrl = `file://${absolutePath}`;
|
|
67431
|
+
} else if (url.startsWith("/")) {
|
|
67432
|
+
if (fs6.existsSync(url)) {
|
|
67433
|
+
fetchUrl = `file://${url}`;
|
|
67434
|
+
} else {
|
|
67435
|
+
const relativePath = `.${url}`;
|
|
67436
|
+
const absolutePath = path8.resolve(process.cwd(), relativePath);
|
|
67437
|
+
if (fs6.existsSync(absolutePath)) {
|
|
67438
|
+
fetchUrl = `file://${absolutePath}`;
|
|
67439
|
+
} else {
|
|
67440
|
+
fetchUrl = `file://${url}`;
|
|
67441
|
+
}
|
|
67442
|
+
}
|
|
67443
|
+
}
|
|
67444
|
+
return basePlatformConfig.footprintFileParserMap.kicad_mod.loadFromUrl(fetchUrl);
|
|
67445
|
+
}
|
|
67446
|
+
}
|
|
67447
|
+
}
|
|
67448
|
+
};
|
|
67449
|
+
if (!userConfig) {
|
|
67450
|
+
return defaultConfig;
|
|
67451
|
+
}
|
|
67452
|
+
return {
|
|
67453
|
+
...defaultConfig,
|
|
67454
|
+
...userConfig,
|
|
67455
|
+
footprintFileParserMap: {
|
|
67456
|
+
...defaultConfig.footprintFileParserMap,
|
|
67457
|
+
...userConfig.footprintFileParserMap
|
|
67458
|
+
}
|
|
67459
|
+
};
|
|
67460
|
+
}
|
|
67461
|
+
|
|
67346
67462
|
// lib/shared/convert-to-kicad-library.tsx
|
|
67347
67463
|
import { jsxDEV } from "react/jsx-dev-runtime";
|
|
67348
67464
|
async function convertToKicadLibrary({
|
|
@@ -67353,7 +67469,9 @@ async function convertToKicadLibrary({
|
|
|
67353
67469
|
kicadPcmPackageId,
|
|
67354
67470
|
circuitJsonToKicadModule
|
|
67355
67471
|
}) {
|
|
67356
|
-
const
|
|
67472
|
+
const platformConfig = getCompletePlatformConfig();
|
|
67473
|
+
const platformFetch = platformConfig.platformFetch ?? globalThis.fetch;
|
|
67474
|
+
const absoluteFilePath = path9.isAbsolute(filePath) ? filePath : path9.resolve(process.cwd(), filePath);
|
|
67357
67475
|
const React = await importFromUserLand("react");
|
|
67358
67476
|
globalThis.React = React;
|
|
67359
67477
|
const userLandTscircuit = await importFromUserLand("tscircuit");
|
|
@@ -67369,9 +67487,7 @@ async function convertToKicadLibrary({
|
|
|
67369
67487
|
return null;
|
|
67370
67488
|
}
|
|
67371
67489
|
const runner = new userLandTscircuit.RootCircuit;
|
|
67372
|
-
runner.add(/* @__PURE__ */ jsxDEV(Component, {
|
|
67373
|
-
name: "REF**"
|
|
67374
|
-
}, undefined, false, undefined, this));
|
|
67490
|
+
runner.add(/* @__PURE__ */ jsxDEV(Component, {}, undefined, false, undefined, this));
|
|
67375
67491
|
await runner.renderUntilSettled();
|
|
67376
67492
|
return await runner.getCircuitJson();
|
|
67377
67493
|
} catch (error) {
|
|
@@ -67389,24 +67505,38 @@ async function convertToKicadLibrary({
|
|
|
67389
67505
|
});
|
|
67390
67506
|
await converter.run();
|
|
67391
67507
|
const kicadLibOutput = converter.getOutput();
|
|
67392
|
-
|
|
67508
|
+
fs7.mkdirSync(outputDir, { recursive: true });
|
|
67393
67509
|
for (const [relativePath, content] of Object.entries(kicadLibOutput.kicadProjectFsMap)) {
|
|
67394
|
-
const fullPath =
|
|
67395
|
-
const dir =
|
|
67396
|
-
|
|
67510
|
+
const fullPath = path9.join(outputDir, relativePath);
|
|
67511
|
+
const dir = path9.dirname(fullPath);
|
|
67512
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
67397
67513
|
if (typeof content === "string") {
|
|
67398
|
-
|
|
67514
|
+
fs7.writeFileSync(fullPath, content);
|
|
67399
67515
|
} else {
|
|
67400
|
-
|
|
67516
|
+
fs7.writeFileSync(fullPath, content);
|
|
67401
67517
|
}
|
|
67402
67518
|
}
|
|
67403
67519
|
if (kicadLibOutput.model3dSourcePaths.length > 0) {
|
|
67404
|
-
const shapesDir = path8.join(outputDir, `3dmodels/${libraryName}.3dshapes`);
|
|
67405
|
-
fs6.mkdirSync(shapesDir, { recursive: true });
|
|
67406
67520
|
for (const modelPath of kicadLibOutput.model3dSourcePaths) {
|
|
67407
|
-
|
|
67408
|
-
|
|
67409
|
-
|
|
67521
|
+
const filename = path9.basename(modelPath);
|
|
67522
|
+
const isRemote = modelPath.startsWith("http://") || modelPath.startsWith("https://");
|
|
67523
|
+
const shapesDir = isRemote ? "tscircuit_builtin.3dshapes" : `${libraryName}.3dshapes`;
|
|
67524
|
+
const destDir = path9.join(outputDir, `3dmodels/${shapesDir}`);
|
|
67525
|
+
fs7.mkdirSync(destDir, { recursive: true });
|
|
67526
|
+
const destPath = path9.join(destDir, filename);
|
|
67527
|
+
if (isRemote) {
|
|
67528
|
+
try {
|
|
67529
|
+
const response = await platformFetch(modelPath);
|
|
67530
|
+
if (!response.ok) {
|
|
67531
|
+
throw new Error(`${response.status} ${response.statusText}`);
|
|
67532
|
+
}
|
|
67533
|
+
const buffer = Buffer.from(await response.arrayBuffer());
|
|
67534
|
+
fs7.writeFileSync(destPath, buffer);
|
|
67535
|
+
} catch (error) {
|
|
67536
|
+
console.warn(`Failed to fetch 3D model from ${modelPath}: ${error instanceof Error ? error.message : error}`);
|
|
67537
|
+
}
|
|
67538
|
+
} else if (fs7.existsSync(modelPath)) {
|
|
67539
|
+
fs7.copyFileSync(modelPath, destPath);
|
|
67410
67540
|
}
|
|
67411
67541
|
}
|
|
67412
67542
|
}
|
|
@@ -67418,8 +67548,8 @@ async function convertToKicadLibrary({
|
|
|
67418
67548
|
|
|
67419
67549
|
// lib/shared/generate-pcm-assets.ts
|
|
67420
67550
|
var import_jszip = __toESM2(require_lib3(), 1);
|
|
67421
|
-
import
|
|
67422
|
-
import
|
|
67551
|
+
import fs8 from "node:fs";
|
|
67552
|
+
import path10 from "node:path";
|
|
67423
67553
|
import crypto3 from "node:crypto";
|
|
67424
67554
|
async function generatePcmAssets(options) {
|
|
67425
67555
|
const {
|
|
@@ -67435,7 +67565,7 @@ async function generatePcmAssets(options) {
|
|
|
67435
67565
|
displayName = `${author}/${packageName}`
|
|
67436
67566
|
} = options;
|
|
67437
67567
|
const identifier = `com.tscircuit.${author}.${packageName}`.toLowerCase().replace(/[^a-z0-9.-]/g, "-").slice(0, 50);
|
|
67438
|
-
|
|
67568
|
+
fs8.mkdirSync(outputDir, { recursive: true });
|
|
67439
67569
|
console.log("Creating metadata.json...");
|
|
67440
67570
|
const metadata = {
|
|
67441
67571
|
$schema: "https://go.kicad.org/pcm/schemas/v1",
|
|
@@ -67461,13 +67591,13 @@ async function generatePcmAssets(options) {
|
|
|
67461
67591
|
]
|
|
67462
67592
|
};
|
|
67463
67593
|
const zipFileName = `${identifier}-${version2}.zip`;
|
|
67464
|
-
const zipFilePath =
|
|
67594
|
+
const zipFilePath = path10.join(outputDir, zipFileName);
|
|
67465
67595
|
await createPcmZip({
|
|
67466
67596
|
kicadLibraryPath,
|
|
67467
67597
|
metadata,
|
|
67468
67598
|
outputPath: zipFilePath
|
|
67469
67599
|
});
|
|
67470
|
-
const zipBuffer =
|
|
67600
|
+
const zipBuffer = fs8.readFileSync(zipFilePath);
|
|
67471
67601
|
const sha256 = crypto3.createHash("sha256").update(zipBuffer).digest("hex");
|
|
67472
67602
|
const zipSize = zipBuffer.length;
|
|
67473
67603
|
const downloadUrl = baseUrl ? `${baseUrl}/pcm/${zipFileName}` : `./${zipFileName}`;
|
|
@@ -67501,9 +67631,9 @@ async function generatePcmAssets(options) {
|
|
|
67501
67631
|
}
|
|
67502
67632
|
]
|
|
67503
67633
|
};
|
|
67504
|
-
const packagesJsonPath =
|
|
67505
|
-
|
|
67506
|
-
const packagesJsonBuffer =
|
|
67634
|
+
const packagesJsonPath = path10.join(outputDir, "packages.json");
|
|
67635
|
+
fs8.writeFileSync(packagesJsonPath, JSON.stringify(packagesJson, null, 2));
|
|
67636
|
+
const packagesJsonBuffer = fs8.readFileSync(packagesJsonPath);
|
|
67507
67637
|
const packagesJsonSha256 = crypto3.createHash("sha256").update(packagesJsonBuffer).digest("hex");
|
|
67508
67638
|
const packagesJsonUrl = baseUrl ? `${baseUrl}/pcm/packages.json` : "./packages.json";
|
|
67509
67639
|
const repositoryJson = {
|
|
@@ -67521,8 +67651,8 @@ async function generatePcmAssets(options) {
|
|
|
67521
67651
|
update_timestamp: Math.floor(Date.now() / 1000)
|
|
67522
67652
|
}
|
|
67523
67653
|
};
|
|
67524
|
-
const repositoryJsonPath =
|
|
67525
|
-
|
|
67654
|
+
const repositoryJsonPath = path10.join(outputDir, "repository.json");
|
|
67655
|
+
fs8.writeFileSync(repositoryJsonPath, JSON.stringify(repositoryJson, null, 2));
|
|
67526
67656
|
return {
|
|
67527
67657
|
outputDir,
|
|
67528
67658
|
repositoryJsonPath,
|
|
@@ -67534,14 +67664,14 @@ async function generatePcmAssets(options) {
|
|
|
67534
67664
|
}
|
|
67535
67665
|
function addDirectoryToZip(opts) {
|
|
67536
67666
|
const { zip, dirPath, zipPath } = opts;
|
|
67537
|
-
const entries =
|
|
67667
|
+
const entries = fs8.readdirSync(dirPath, { withFileTypes: true });
|
|
67538
67668
|
for (const entry of entries) {
|
|
67539
|
-
const fullPath =
|
|
67669
|
+
const fullPath = path10.join(dirPath, entry.name);
|
|
67540
67670
|
const entryZipPath = zipPath ? `${zipPath}/${entry.name}` : entry.name;
|
|
67541
67671
|
if (entry.isDirectory()) {
|
|
67542
67672
|
addDirectoryToZip({ zip, dirPath: fullPath, zipPath: entryZipPath });
|
|
67543
67673
|
} else {
|
|
67544
|
-
const content =
|
|
67674
|
+
const content = fs8.readFileSync(fullPath);
|
|
67545
67675
|
zip.file(entryZipPath, content);
|
|
67546
67676
|
}
|
|
67547
67677
|
}
|
|
@@ -67550,18 +67680,18 @@ async function createPcmZip(options) {
|
|
|
67550
67680
|
const { kicadLibraryPath, metadata, outputPath } = options;
|
|
67551
67681
|
const zip = new import_jszip.default;
|
|
67552
67682
|
zip.file("metadata.json", JSON.stringify(metadata, null, 2));
|
|
67553
|
-
const footprintsDir =
|
|
67554
|
-
if (
|
|
67683
|
+
const footprintsDir = path10.join(kicadLibraryPath, "footprints");
|
|
67684
|
+
if (fs8.existsSync(footprintsDir)) {
|
|
67555
67685
|
console.log("Adding footprints directory...");
|
|
67556
67686
|
addDirectoryToZip({ zip, dirPath: footprintsDir, zipPath: "footprints" });
|
|
67557
67687
|
}
|
|
67558
|
-
const symbolsDir =
|
|
67559
|
-
if (
|
|
67688
|
+
const symbolsDir = path10.join(kicadLibraryPath, "symbols");
|
|
67689
|
+
if (fs8.existsSync(symbolsDir)) {
|
|
67560
67690
|
console.log("Adding symbols directory...");
|
|
67561
67691
|
addDirectoryToZip({ zip, dirPath: symbolsDir, zipPath: "symbols" });
|
|
67562
67692
|
}
|
|
67563
|
-
const modelsDir =
|
|
67564
|
-
if (
|
|
67693
|
+
const modelsDir = path10.join(kicadLibraryPath, "3dmodels");
|
|
67694
|
+
if (fs8.existsSync(modelsDir)) {
|
|
67565
67695
|
console.log("Adding 3dmodels directory...");
|
|
67566
67696
|
addDirectoryToZip({ zip, dirPath: modelsDir, zipPath: "3dmodels" });
|
|
67567
67697
|
}
|
|
@@ -67571,7 +67701,7 @@ async function createPcmZip(options) {
|
|
|
67571
67701
|
compression: "DEFLATE",
|
|
67572
67702
|
compressionOptions: { level: 9 }
|
|
67573
67703
|
});
|
|
67574
|
-
|
|
67704
|
+
fs8.writeFileSync(outputPath, zipBuffer);
|
|
67575
67705
|
}
|
|
67576
67706
|
|
|
67577
67707
|
// lib/utils/get-package-author.ts
|
|
@@ -67586,8 +67716,8 @@ var getPackageAuthor = (packageName) => {
|
|
|
67586
67716
|
};
|
|
67587
67717
|
|
|
67588
67718
|
// lib/project-config/index.ts
|
|
67589
|
-
import * as
|
|
67590
|
-
import * as
|
|
67719
|
+
import * as fs9 from "node:fs";
|
|
67720
|
+
import * as path11 from "node:path";
|
|
67591
67721
|
|
|
67592
67722
|
// lib/project-config/project-config-schema.ts
|
|
67593
67723
|
import { z as z21 } from "zod";
|
|
@@ -67624,12 +67754,12 @@ var DEFAULT_BOARD_FILE_PATTERNS = [
|
|
|
67624
67754
|
"**/*.circuit.json"
|
|
67625
67755
|
];
|
|
67626
67756
|
var loadProjectConfig = (projectDir = process.cwd()) => {
|
|
67627
|
-
const configPath =
|
|
67628
|
-
if (!
|
|
67757
|
+
const configPath = path11.join(projectDir, CONFIG_FILENAME);
|
|
67758
|
+
if (!fs9.existsSync(configPath)) {
|
|
67629
67759
|
return null;
|
|
67630
67760
|
}
|
|
67631
67761
|
try {
|
|
67632
|
-
const configContent =
|
|
67762
|
+
const configContent = fs9.readFileSync(configPath, "utf8");
|
|
67633
67763
|
const parsedConfig = JSON.parse(configContent);
|
|
67634
67764
|
return projectConfigSchema.parse(parsedConfig);
|
|
67635
67765
|
} catch (error) {
|
|
@@ -67650,13 +67780,13 @@ var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
|
67650
67780
|
return config?.snapshotsDir;
|
|
67651
67781
|
};
|
|
67652
67782
|
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
67653
|
-
const configPath =
|
|
67783
|
+
const configPath = path11.join(projectDir, CONFIG_FILENAME);
|
|
67654
67784
|
try {
|
|
67655
67785
|
const configWithSchema = {
|
|
67656
67786
|
$schema: CONFIG_SCHEMA_URL,
|
|
67657
67787
|
...config ?? {}
|
|
67658
67788
|
};
|
|
67659
|
-
|
|
67789
|
+
fs9.writeFileSync(configPath, JSON.stringify(configWithSchema, null, 2));
|
|
67660
67790
|
return true;
|
|
67661
67791
|
} catch (error) {
|
|
67662
67792
|
console.error(`Error saving tscircuit config: ${error}`);
|
|
@@ -67665,8 +67795,8 @@ var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
|
67665
67795
|
};
|
|
67666
67796
|
|
|
67667
67797
|
// lib/utils/resolve-kicad-library-name.ts
|
|
67668
|
-
import
|
|
67669
|
-
import
|
|
67798
|
+
import path12 from "node:path";
|
|
67799
|
+
import fs10 from "node:fs";
|
|
67670
67800
|
|
|
67671
67801
|
// lib/utils/get-unscoped-package-name.ts
|
|
67672
67802
|
var getUnscopedPackageName = (packageName) => {
|
|
@@ -67681,9 +67811,9 @@ function resolveKicadLibraryName({
|
|
|
67681
67811
|
if (projectConfig?.kicadLibraryName) {
|
|
67682
67812
|
return projectConfig.kicadLibraryName;
|
|
67683
67813
|
}
|
|
67684
|
-
const packageJsonPath =
|
|
67685
|
-
if (
|
|
67686
|
-
const packageJson = JSON.parse(
|
|
67814
|
+
const packageJsonPath = path12.join(projectDir, "package.json");
|
|
67815
|
+
if (fs10.existsSync(packageJsonPath)) {
|
|
67816
|
+
const packageJson = JSON.parse(fs10.readFileSync(packageJsonPath, "utf-8"));
|
|
67687
67817
|
const unscopedName = getUnscopedPackageName(packageJson.name || "");
|
|
67688
67818
|
if (unscopedName) {
|
|
67689
67819
|
return unscopedName.replace("@tsci/", "").replace(/\./g, "-");
|
|
@@ -67701,18 +67831,18 @@ async function buildKicadPcm({
|
|
|
67701
67831
|
circuitJsonToKicadModule,
|
|
67702
67832
|
kicadLibraryName: kicadLibraryNameOption
|
|
67703
67833
|
}) {
|
|
67704
|
-
const packageJsonPath =
|
|
67705
|
-
if (!
|
|
67834
|
+
const packageJsonPath = path13.join(projectDir, "package.json");
|
|
67835
|
+
if (!fs11.existsSync(packageJsonPath)) {
|
|
67706
67836
|
throw new Error("No package.json found for KiCad PCM generation");
|
|
67707
67837
|
}
|
|
67708
|
-
const packageJson = JSON.parse(
|
|
67838
|
+
const packageJson = JSON.parse(fs11.readFileSync(packageJsonPath, "utf-8"));
|
|
67709
67839
|
const projectConfig = loadProjectConfig(projectDir);
|
|
67710
|
-
const packageName = packageJson.name?.split("/").pop()?.split(".").pop() ||
|
|
67840
|
+
const packageName = packageJson.name?.split("/").pop()?.split(".").pop() || path13.basename(projectDir);
|
|
67711
67841
|
const version2 = packageJson.version || "1.0.0";
|
|
67712
67842
|
const author = getPackageAuthor(packageJson.name || "") || "tscircuit";
|
|
67713
67843
|
const description = packageJson.description || "";
|
|
67714
67844
|
const libraryName = kicadLibraryNameOption ?? resolveKicadLibraryName({ projectDir });
|
|
67715
|
-
const kicadLibOutputDir =
|
|
67845
|
+
const kicadLibOutputDir = path13.join(distDir, "kicad-library-pcm");
|
|
67716
67846
|
const kicadPcmPackageId = `com_tscircuit_${author}_${packageName}`.replace(/\./g, "_");
|
|
67717
67847
|
console.log("Converting to KiCad library for PCM...");
|
|
67718
67848
|
await convertToKicadLibrary({
|
|
@@ -67723,7 +67853,7 @@ async function buildKicadPcm({
|
|
|
67723
67853
|
kicadPcmPackageId,
|
|
67724
67854
|
circuitJsonToKicadModule
|
|
67725
67855
|
});
|
|
67726
|
-
const pcmOutputDir =
|
|
67856
|
+
const pcmOutputDir = path13.join(distDir, "pcm");
|
|
67727
67857
|
const envDeploymentUrl = process.env.TSCIRCUIT_DEPLOYMENT_URL?.replace(/\/+$/, "");
|
|
67728
67858
|
const baseUrl = baseUrlOption ?? envDeploymentUrl ?? `https://${author}--${packageName}.tscircuit.app`;
|
|
67729
67859
|
console.log("Generating PCM assets...");
|
|
@@ -67737,13 +67867,13 @@ async function buildKicadPcm({
|
|
|
67737
67867
|
baseUrl,
|
|
67738
67868
|
displayName: kicadLibraryNameOption || projectConfig?.kicadLibraryName || undefined
|
|
67739
67869
|
});
|
|
67740
|
-
console.log(` KiCad PCM assets generated at ${kleur_default.dim(
|
|
67870
|
+
console.log(` KiCad PCM assets generated at ${kleur_default.dim(path13.relative(process.cwd(), pcmOutputDir))}`);
|
|
67741
67871
|
console.log(` Repository URL: ${kleur_default.cyan(`${baseUrl}/pcm/repository.json`)}`);
|
|
67742
67872
|
}
|
|
67743
67873
|
|
|
67744
67874
|
// node_modules/globby/index.js
|
|
67745
67875
|
import process9 from "node:process";
|
|
67746
|
-
import
|
|
67876
|
+
import fs14 from "node:fs";
|
|
67747
67877
|
import nodePath from "node:path";
|
|
67748
67878
|
|
|
67749
67879
|
// node_modules/@sindresorhus/merge-streams/index.js
|
|
@@ -67927,7 +68057,7 @@ var PASSTHROUGH_LISTENERS_PER_STREAM = 1;
|
|
|
67927
68057
|
var import_fast_glob2 = __toESM2(require_out4(), 1);
|
|
67928
68058
|
|
|
67929
68059
|
// node_modules/path-type/index.js
|
|
67930
|
-
import
|
|
68060
|
+
import fs12 from "node:fs";
|
|
67931
68061
|
import fsPromises from "node:fs/promises";
|
|
67932
68062
|
async function isType2(fsStatType, statsMethodName, filePath) {
|
|
67933
68063
|
if (typeof filePath !== "string") {
|
|
@@ -67948,7 +68078,7 @@ function isTypeSync(fsStatType, statsMethodName, filePath) {
|
|
|
67948
68078
|
throw new TypeError(`Expected a string, got ${typeof filePath}`);
|
|
67949
68079
|
}
|
|
67950
68080
|
try {
|
|
67951
|
-
return
|
|
68081
|
+
return fs12[fsStatType](filePath)[statsMethodName]();
|
|
67952
68082
|
} catch (error) {
|
|
67953
68083
|
if (error.code === "ENOENT") {
|
|
67954
68084
|
return false;
|
|
@@ -67977,17 +68107,17 @@ var TEN_MEGABYTES_IN_BYTES = 10 * 1024 * 1024;
|
|
|
67977
68107
|
var import_fast_glob = __toESM2(require_out4(), 1);
|
|
67978
68108
|
var import_ignore = __toESM2(require_ignore(), 1);
|
|
67979
68109
|
import process8 from "node:process";
|
|
67980
|
-
import
|
|
68110
|
+
import fs13 from "node:fs";
|
|
67981
68111
|
import fsPromises2 from "node:fs/promises";
|
|
67982
|
-
import
|
|
68112
|
+
import path14 from "node:path";
|
|
67983
68113
|
|
|
67984
68114
|
// node_modules/slash/index.js
|
|
67985
|
-
function slash(
|
|
67986
|
-
const isExtendedLengthPath =
|
|
68115
|
+
function slash(path14) {
|
|
68116
|
+
const isExtendedLengthPath = path14.startsWith("\\\\?\\");
|
|
67987
68117
|
if (isExtendedLengthPath) {
|
|
67988
|
-
return
|
|
68118
|
+
return path14;
|
|
67989
68119
|
}
|
|
67990
|
-
return
|
|
68120
|
+
return path14.replace(/\\/g, "/");
|
|
67991
68121
|
}
|
|
67992
68122
|
|
|
67993
68123
|
// node_modules/globby/utilities.js
|
|
@@ -68005,16 +68135,16 @@ var ignoreFilesGlobOptions = {
|
|
|
68005
68135
|
dot: true
|
|
68006
68136
|
};
|
|
68007
68137
|
var GITIGNORE_FILES_PATTERN = "**/.gitignore";
|
|
68008
|
-
var applyBaseToPattern = (pattern, base) => isNegativePattern(pattern) ? "!" +
|
|
68138
|
+
var applyBaseToPattern = (pattern, base) => isNegativePattern(pattern) ? "!" + path14.posix.join(base, pattern.slice(1)) : path14.posix.join(base, pattern);
|
|
68009
68139
|
var parseIgnoreFile = (file, cwd) => {
|
|
68010
|
-
const base = slash(
|
|
68140
|
+
const base = slash(path14.relative(cwd, path14.dirname(file.filePath)));
|
|
68011
68141
|
return file.content.split(/\r?\n/).filter((line) => line && !line.startsWith("#")).map((pattern) => applyBaseToPattern(pattern, base));
|
|
68012
68142
|
};
|
|
68013
68143
|
var toRelativePath = (fileOrDirectory, cwd) => {
|
|
68014
68144
|
cwd = slash(cwd);
|
|
68015
|
-
if (
|
|
68145
|
+
if (path14.isAbsolute(fileOrDirectory)) {
|
|
68016
68146
|
if (slash(fileOrDirectory).startsWith(cwd)) {
|
|
68017
|
-
return
|
|
68147
|
+
return path14.relative(cwd, fileOrDirectory);
|
|
68018
68148
|
}
|
|
68019
68149
|
throw new Error(`Path ${fileOrDirectory} is not in cwd ${cwd}`);
|
|
68020
68150
|
}
|
|
@@ -68061,7 +68191,7 @@ var isIgnoredByIgnoreFilesSync = (patterns, options) => {
|
|
|
68061
68191
|
});
|
|
68062
68192
|
const files = paths.map((filePath) => ({
|
|
68063
68193
|
filePath,
|
|
68064
|
-
content:
|
|
68194
|
+
content: fs13.readFileSync(filePath, "utf8")
|
|
68065
68195
|
}));
|
|
68066
68196
|
return getIsIgnoredPredicate(files, cwd);
|
|
68067
68197
|
};
|
|
@@ -68073,8 +68203,8 @@ var assertPatternsInput = (patterns) => {
|
|
|
68073
68203
|
}
|
|
68074
68204
|
};
|
|
68075
68205
|
var normalizePathForDirectoryGlob = (filePath, cwd) => {
|
|
68076
|
-
const
|
|
68077
|
-
return nodePath.isAbsolute(
|
|
68206
|
+
const path15 = isNegativePattern(filePath) ? filePath.slice(1) : filePath;
|
|
68207
|
+
return nodePath.isAbsolute(path15) ? path15 : nodePath.join(cwd, path15);
|
|
68078
68208
|
};
|
|
68079
68209
|
var getDirectoryGlob = ({ directoryPath, files, extensions }) => {
|
|
68080
68210
|
const extensionGlob = extensions?.length > 0 ? `.${extensions.length > 1 ? `{${extensions.join(",")}}` : extensions[0]}` : "";
|
|
@@ -68104,7 +68234,7 @@ var checkCwdOption = (cwd) => {
|
|
|
68104
68234
|
}
|
|
68105
68235
|
let stat;
|
|
68106
68236
|
try {
|
|
68107
|
-
stat =
|
|
68237
|
+
stat = fs14.statSync(cwd);
|
|
68108
68238
|
} catch {
|
|
68109
68239
|
return;
|
|
68110
68240
|
}
|
|
@@ -68251,7 +68381,7 @@ var getSourceFilesChecksum = (projectDir) => {
|
|
|
68251
68381
|
let checksum = "";
|
|
68252
68382
|
for (const file of sourceFiles) {
|
|
68253
68383
|
try {
|
|
68254
|
-
const stat =
|
|
68384
|
+
const stat = fs15.statSync(path15.join(projectDir, file));
|
|
68255
68385
|
checksum += `${file}:${stat.mtimeMs};`;
|
|
68256
68386
|
} catch {}
|
|
68257
68387
|
}
|
|
@@ -68271,9 +68401,9 @@ var createKicadPcmProxy = ({
|
|
|
68271
68401
|
};
|
|
68272
68402
|
const handleRequest = async (url, res) => {
|
|
68273
68403
|
const requestedFile = url.pathname.replace(/^\/pcm\/?/, "") || "repository.json";
|
|
68274
|
-
const distDir =
|
|
68275
|
-
const pcmDir =
|
|
68276
|
-
const filePath =
|
|
68404
|
+
const distDir = path15.join(projectDir, "dist");
|
|
68405
|
+
const pcmDir = path15.join(distDir, "pcm");
|
|
68406
|
+
const filePath = path15.join(pcmDir, requestedFile);
|
|
68277
68407
|
const currentChecksum = getSourceFilesChecksum(projectDir);
|
|
68278
68408
|
const needsRebuild = currentChecksum !== pcmState.lastFileChecksum;
|
|
68279
68409
|
if (needsRebuild) {
|
|
@@ -68318,12 +68448,12 @@ Rebuilding KiCad PCM assets...`));
|
|
|
68318
68448
|
}
|
|
68319
68449
|
}
|
|
68320
68450
|
}
|
|
68321
|
-
if (!
|
|
68451
|
+
if (!fs15.existsSync(filePath)) {
|
|
68322
68452
|
res.writeHead(404);
|
|
68323
68453
|
res.end(`PCM file not found: ${requestedFile}`);
|
|
68324
68454
|
return;
|
|
68325
68455
|
}
|
|
68326
|
-
const ext =
|
|
68456
|
+
const ext = path15.extname(filePath).toLowerCase();
|
|
68327
68457
|
let contentType = "application/octet-stream";
|
|
68328
68458
|
if (ext === ".json") {
|
|
68329
68459
|
contentType = "application/json";
|
|
@@ -68331,7 +68461,7 @@ Rebuilding KiCad PCM assets...`));
|
|
|
68331
68461
|
contentType = "application/zip";
|
|
68332
68462
|
}
|
|
68333
68463
|
try {
|
|
68334
|
-
const content =
|
|
68464
|
+
const content = fs15.readFileSync(filePath);
|
|
68335
68465
|
res.writeHead(200, { "Content-Type": contentType });
|
|
68336
68466
|
res.end(content);
|
|
68337
68467
|
} catch (error) {
|
|
@@ -68364,7 +68494,7 @@ var createHttpServer = async ({
|
|
|
68364
68494
|
return;
|
|
68365
68495
|
}
|
|
68366
68496
|
try {
|
|
68367
|
-
const content =
|
|
68497
|
+
const content = fs16.readFileSync(standaloneFilePath, "utf8");
|
|
68368
68498
|
res.writeHead(200, {
|
|
68369
68499
|
"Content-Type": "application/javascript; charset=utf-8"
|
|
68370
68500
|
});
|
|
@@ -68406,12 +68536,12 @@ var createHttpServer = async ({
|
|
|
68406
68536
|
};
|
|
68407
68537
|
// lib/dependency-analysis/getLocalFileDependencies.ts
|
|
68408
68538
|
import * as ts from "typescript";
|
|
68409
|
-
import * as
|
|
68410
|
-
import * as
|
|
68539
|
+
import * as path16 from "path";
|
|
68540
|
+
import * as fs17 from "fs";
|
|
68411
68541
|
function getLocalFileDependencies(pathToTsxFile) {
|
|
68412
|
-
const absolutePath =
|
|
68413
|
-
const baseDir =
|
|
68414
|
-
const content =
|
|
68542
|
+
const absolutePath = path16.resolve(pathToTsxFile);
|
|
68543
|
+
const baseDir = path16.dirname(absolutePath);
|
|
68544
|
+
const content = fs17.readFileSync(absolutePath, "utf-8");
|
|
68415
68545
|
const sourceFile = ts.createSourceFile(absolutePath, content, ts.ScriptTarget.Latest, true);
|
|
68416
68546
|
const dependencies2 = new Set;
|
|
68417
68547
|
function visit(node) {
|
|
@@ -68446,22 +68576,22 @@ function getLocalFileDependencies(pathToTsxFile) {
|
|
|
68446
68576
|
".sass",
|
|
68447
68577
|
".less"
|
|
68448
68578
|
];
|
|
68449
|
-
let resolvedPath =
|
|
68450
|
-
if (
|
|
68579
|
+
let resolvedPath = path16.resolve(baseDir, importPath);
|
|
68580
|
+
if (fs17.existsSync(resolvedPath)) {
|
|
68451
68581
|
dependencies2.add(resolvedPath);
|
|
68452
68582
|
return;
|
|
68453
68583
|
}
|
|
68454
68584
|
for (const ext of extensions) {
|
|
68455
68585
|
const pathWithExt = resolvedPath + ext;
|
|
68456
|
-
if (
|
|
68586
|
+
if (fs17.existsSync(pathWithExt)) {
|
|
68457
68587
|
dependencies2.add(pathWithExt);
|
|
68458
68588
|
return;
|
|
68459
68589
|
}
|
|
68460
68590
|
}
|
|
68461
|
-
if (
|
|
68591
|
+
if (fs17.existsSync(resolvedPath) && fs17.statSync(resolvedPath).isDirectory()) {
|
|
68462
68592
|
for (const ext of extensions) {
|
|
68463
|
-
const indexPath =
|
|
68464
|
-
if (
|
|
68593
|
+
const indexPath = path16.join(resolvedPath, `index${ext}`);
|
|
68594
|
+
if (fs17.existsSync(indexPath)) {
|
|
68465
68595
|
dependencies2.add(indexPath);
|
|
68466
68596
|
return;
|
|
68467
68597
|
}
|