@tscircuit/cli 0.1.2401 → 0.1.2402
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/build/build.worker.js +1248 -242
- package/dist/cli/main.js +2 -2
- package/dist/cli/snapshot/snapshot.worker.js +1171 -165
- package/dist/lib/index.js +1318 -197
- package/package.json +8 -6
|
@@ -20336,7 +20336,7 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20336
20336
|
"node_modules/fs.realpath/old.js"(exports2) {
|
|
20337
20337
|
var pathModule = __require("path");
|
|
20338
20338
|
var isWindows = process.platform === "win32";
|
|
20339
|
-
var
|
|
20339
|
+
var fs3 = __require("fs");
|
|
20340
20340
|
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
|
20341
20341
|
function rethrow() {
|
|
20342
20342
|
var callback;
|
|
@@ -20401,7 +20401,7 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20401
20401
|
base = m[0];
|
|
20402
20402
|
previous = "";
|
|
20403
20403
|
if (isWindows && !knownHard[base]) {
|
|
20404
|
-
|
|
20404
|
+
fs3.lstatSync(base);
|
|
20405
20405
|
knownHard[base] = true;
|
|
20406
20406
|
}
|
|
20407
20407
|
}
|
|
@@ -20419,7 +20419,7 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20419
20419
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
20420
20420
|
resolvedLink = cache[base];
|
|
20421
20421
|
} else {
|
|
20422
|
-
var stat =
|
|
20422
|
+
var stat = fs3.lstatSync(base);
|
|
20423
20423
|
if (!stat.isSymbolicLink()) {
|
|
20424
20424
|
knownHard[base] = true;
|
|
20425
20425
|
if (cache)
|
|
@@ -20434,8 +20434,8 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20434
20434
|
}
|
|
20435
20435
|
}
|
|
20436
20436
|
if (linkTarget === null) {
|
|
20437
|
-
|
|
20438
|
-
linkTarget =
|
|
20437
|
+
fs3.statSync(base);
|
|
20438
|
+
linkTarget = fs3.readlinkSync(base);
|
|
20439
20439
|
}
|
|
20440
20440
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
20441
20441
|
if (cache)
|
|
@@ -20472,7 +20472,7 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20472
20472
|
base = m[0];
|
|
20473
20473
|
previous = "";
|
|
20474
20474
|
if (isWindows && !knownHard[base]) {
|
|
20475
|
-
|
|
20475
|
+
fs3.lstat(base, function(err) {
|
|
20476
20476
|
if (err)
|
|
20477
20477
|
return cb(err);
|
|
20478
20478
|
knownHard[base] = true;
|
|
@@ -20500,7 +20500,7 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20500
20500
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
20501
20501
|
return gotResolvedLink(cache[base]);
|
|
20502
20502
|
}
|
|
20503
|
-
return
|
|
20503
|
+
return fs3.lstat(base, gotStat);
|
|
20504
20504
|
}
|
|
20505
20505
|
function gotStat(err, stat) {
|
|
20506
20506
|
if (err)
|
|
@@ -20517,10 +20517,10 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20517
20517
|
return gotTarget(null, seenLinks[id], base);
|
|
20518
20518
|
}
|
|
20519
20519
|
}
|
|
20520
|
-
|
|
20520
|
+
fs3.stat(base, function(err2) {
|
|
20521
20521
|
if (err2)
|
|
20522
20522
|
return cb(err2);
|
|
20523
|
-
|
|
20523
|
+
fs3.readlink(base, function(err3, target) {
|
|
20524
20524
|
if (!isWindows)
|
|
20525
20525
|
seenLinks[id] = target;
|
|
20526
20526
|
gotTarget(err3, target);
|
|
@@ -20550,9 +20550,9 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20550
20550
|
realpath.realpathSync = realpathSync;
|
|
20551
20551
|
realpath.monkeypatch = monkeypatch;
|
|
20552
20552
|
realpath.unmonkeypatch = unmonkeypatch;
|
|
20553
|
-
var
|
|
20554
|
-
var origRealpath =
|
|
20555
|
-
var origRealpathSync =
|
|
20553
|
+
var fs3 = __require("fs");
|
|
20554
|
+
var origRealpath = fs3.realpath;
|
|
20555
|
+
var origRealpathSync = fs3.realpathSync;
|
|
20556
20556
|
var version = process.version;
|
|
20557
20557
|
var ok = /^v[0-5]\./.test(version);
|
|
20558
20558
|
var old = require_old();
|
|
@@ -20590,12 +20590,12 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20590
20590
|
}
|
|
20591
20591
|
}
|
|
20592
20592
|
function monkeypatch() {
|
|
20593
|
-
|
|
20594
|
-
|
|
20593
|
+
fs3.realpath = realpath;
|
|
20594
|
+
fs3.realpathSync = realpathSync;
|
|
20595
20595
|
}
|
|
20596
20596
|
function unmonkeypatch() {
|
|
20597
|
-
|
|
20598
|
-
|
|
20597
|
+
fs3.realpath = origRealpath;
|
|
20598
|
+
fs3.realpathSync = origRealpathSync;
|
|
20599
20599
|
}
|
|
20600
20600
|
}
|
|
20601
20601
|
});
|
|
@@ -20821,8 +20821,8 @@ var require_dist2 = __commonJS(function(exports, module) {
|
|
|
20821
20821
|
return new Minimatch(pattern, options).match(p);
|
|
20822
20822
|
};
|
|
20823
20823
|
module2.exports = minimatch;
|
|
20824
|
-
var
|
|
20825
|
-
minimatch.sep =
|
|
20824
|
+
var path3 = require_path();
|
|
20825
|
+
minimatch.sep = path3.sep;
|
|
20826
20826
|
var GLOBSTAR = Symbol("globstar **");
|
|
20827
20827
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
20828
20828
|
var expand = require_brace_expansion();
|
|
@@ -21313,8 +21313,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21313
21313
|
if (f === "/" && partial)
|
|
21314
21314
|
return true;
|
|
21315
21315
|
const options = this.options;
|
|
21316
|
-
if (
|
|
21317
|
-
f = f.split(
|
|
21316
|
+
if (path3.sep !== "/") {
|
|
21317
|
+
f = f.split(path3.sep).join("/");
|
|
21318
21318
|
}
|
|
21319
21319
|
f = f.split(slashSplit);
|
|
21320
21320
|
this.debug(this.pattern, "split", f);
|
|
@@ -21404,8 +21404,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21404
21404
|
function ownProp(obj, field) {
|
|
21405
21405
|
return Object.prototype.hasOwnProperty.call(obj, field);
|
|
21406
21406
|
}
|
|
21407
|
-
var
|
|
21408
|
-
var
|
|
21407
|
+
var fs3 = __require("fs");
|
|
21408
|
+
var path3 = __require("path");
|
|
21409
21409
|
var minimatch = require_minimatch();
|
|
21410
21410
|
var isAbsolute = __require("path").isAbsolute;
|
|
21411
21411
|
var Minimatch = minimatch.Minimatch;
|
|
@@ -21459,7 +21459,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21459
21459
|
self.stat = !!options.stat;
|
|
21460
21460
|
self.noprocess = !!options.noprocess;
|
|
21461
21461
|
self.absolute = !!options.absolute;
|
|
21462
|
-
self.fs = options.fs ||
|
|
21462
|
+
self.fs = options.fs || fs3;
|
|
21463
21463
|
self.maxLength = options.maxLength || Infinity;
|
|
21464
21464
|
self.cache = options.cache || /* @__PURE__ */ Object.create(null);
|
|
21465
21465
|
self.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
|
|
@@ -21468,13 +21468,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21468
21468
|
self.changedCwd = false;
|
|
21469
21469
|
var cwd = process.cwd();
|
|
21470
21470
|
if (!ownProp(options, "cwd"))
|
|
21471
|
-
self.cwd =
|
|
21471
|
+
self.cwd = path3.resolve(cwd);
|
|
21472
21472
|
else {
|
|
21473
|
-
self.cwd =
|
|
21473
|
+
self.cwd = path3.resolve(options.cwd);
|
|
21474
21474
|
self.changedCwd = self.cwd !== cwd;
|
|
21475
21475
|
}
|
|
21476
|
-
self.root = options.root ||
|
|
21477
|
-
self.root =
|
|
21476
|
+
self.root = options.root || path3.resolve(self.cwd, "/");
|
|
21477
|
+
self.root = path3.resolve(self.root);
|
|
21478
21478
|
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
|
|
21479
21479
|
self.nomount = !!options.nomount;
|
|
21480
21480
|
if (process.platform === "win32") {
|
|
@@ -21557,30 +21557,30 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21557
21557
|
function makeAbs(self, f) {
|
|
21558
21558
|
var abs = f;
|
|
21559
21559
|
if (f.charAt(0) === "/") {
|
|
21560
|
-
abs =
|
|
21560
|
+
abs = path3.join(self.root, f);
|
|
21561
21561
|
} else if (isAbsolute(f) || f === "") {
|
|
21562
21562
|
abs = f;
|
|
21563
21563
|
} else if (self.changedCwd) {
|
|
21564
|
-
abs =
|
|
21564
|
+
abs = path3.resolve(self.cwd, f);
|
|
21565
21565
|
} else {
|
|
21566
|
-
abs =
|
|
21566
|
+
abs = path3.resolve(f);
|
|
21567
21567
|
}
|
|
21568
21568
|
if (process.platform === "win32")
|
|
21569
21569
|
abs = abs.replace(/\\/g, "/");
|
|
21570
21570
|
return abs;
|
|
21571
21571
|
}
|
|
21572
|
-
function isIgnored(self,
|
|
21572
|
+
function isIgnored(self, path4) {
|
|
21573
21573
|
if (!self.ignore.length)
|
|
21574
21574
|
return false;
|
|
21575
21575
|
return self.ignore.some(function(item) {
|
|
21576
|
-
return item.matcher.match(
|
|
21576
|
+
return item.matcher.match(path4) || !!(item.gmatcher && item.gmatcher.match(path4));
|
|
21577
21577
|
});
|
|
21578
21578
|
}
|
|
21579
|
-
function childrenIgnored(self,
|
|
21579
|
+
function childrenIgnored(self, path4) {
|
|
21580
21580
|
if (!self.ignore.length)
|
|
21581
21581
|
return false;
|
|
21582
21582
|
return self.ignore.some(function(item) {
|
|
21583
|
-
return !!(item.gmatcher && item.gmatcher.match(
|
|
21583
|
+
return !!(item.gmatcher && item.gmatcher.match(path4));
|
|
21584
21584
|
});
|
|
21585
21585
|
}
|
|
21586
21586
|
}
|
|
@@ -21594,7 +21594,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
21594
21594
|
var Minimatch = minimatch.Minimatch;
|
|
21595
21595
|
var Glob = require_glob().Glob;
|
|
21596
21596
|
var util = __require("util");
|
|
21597
|
-
var
|
|
21597
|
+
var path3 = __require("path");
|
|
21598
21598
|
var assert = __require("assert");
|
|
21599
21599
|
var isAbsolute = __require("path").isAbsolute;
|
|
21600
21600
|
var common = require_common();
|
|
@@ -21724,7 +21724,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
21724
21724
|
e = prefix + e;
|
|
21725
21725
|
}
|
|
21726
21726
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
21727
|
-
e =
|
|
21727
|
+
e = path3.join(this.root, e);
|
|
21728
21728
|
}
|
|
21729
21729
|
this._emitMatch(index, e);
|
|
21730
21730
|
}
|
|
@@ -21873,9 +21873,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
21873
21873
|
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
|
21874
21874
|
var trail = /[\/\\]$/.test(prefix);
|
|
21875
21875
|
if (prefix.charAt(0) === "/") {
|
|
21876
|
-
prefix =
|
|
21876
|
+
prefix = path3.join(this.root, prefix);
|
|
21877
21877
|
} else {
|
|
21878
|
-
prefix =
|
|
21878
|
+
prefix = path3.resolve(this.root, prefix);
|
|
21879
21879
|
if (trail)
|
|
21880
21880
|
prefix += "/";
|
|
21881
21881
|
}
|
|
@@ -22062,7 +22062,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22062
22062
|
var Minimatch = minimatch.Minimatch;
|
|
22063
22063
|
var inherits = require_inherits();
|
|
22064
22064
|
var EE = __require("events").EventEmitter;
|
|
22065
|
-
var
|
|
22065
|
+
var path3 = __require("path");
|
|
22066
22066
|
var assert = __require("assert");
|
|
22067
22067
|
var isAbsolute = __require("path").isAbsolute;
|
|
22068
22068
|
var globSync = require_sync();
|
|
@@ -22345,7 +22345,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22345
22345
|
e = prefix + e;
|
|
22346
22346
|
}
|
|
22347
22347
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
22348
|
-
e =
|
|
22348
|
+
e = path3.join(this.root, e);
|
|
22349
22349
|
}
|
|
22350
22350
|
this._emitMatch(index, e);
|
|
22351
22351
|
}
|
|
@@ -22532,9 +22532,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22532
22532
|
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
|
22533
22533
|
var trail = /[\/\\]$/.test(prefix);
|
|
22534
22534
|
if (prefix.charAt(0) === "/") {
|
|
22535
|
-
prefix =
|
|
22535
|
+
prefix = path3.join(this.root, prefix);
|
|
22536
22536
|
} else {
|
|
22537
|
-
prefix =
|
|
22537
|
+
prefix = path3.resolve(this.root, prefix);
|
|
22538
22538
|
if (trail)
|
|
22539
22539
|
prefix += "/";
|
|
22540
22540
|
}
|
|
@@ -22627,12 +22627,27 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22627
22627
|
__export(src_exports, {
|
|
22628
22628
|
getMatchingFilePaths: () => getMatchingFilePaths,
|
|
22629
22629
|
getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
|
|
22630
|
-
getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath
|
|
22630
|
+
getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath,
|
|
22631
|
+
writeVfsToDirectory: () => writeVfsToDirectory
|
|
22631
22632
|
});
|
|
22632
22633
|
module.exports = __toCommonJS(src_exports);
|
|
22633
22634
|
var import_glob_promise = __toESM(require_lib());
|
|
22634
|
-
var
|
|
22635
|
+
var import_path2 = __toESM(__require("path"));
|
|
22635
22636
|
var import_promises = __toESM(__require("fs/promises"));
|
|
22637
|
+
var import_fs = __toESM(__require("fs"));
|
|
22638
|
+
var import_path = __toESM(__require("path"));
|
|
22639
|
+
var writeVfsToDirectory = async (opts) => {
|
|
22640
|
+
const { vfs, vfsDir, outDir } = opts;
|
|
22641
|
+
for (const [filePath, content] of Object.entries(vfs)) {
|
|
22642
|
+
if (vfsDir && !filePath.startsWith(vfsDir)) {
|
|
22643
|
+
continue;
|
|
22644
|
+
}
|
|
22645
|
+
const relativePath = vfsDir ? import_path.default.relative(vfsDir, filePath) : filePath;
|
|
22646
|
+
const outputPath = import_path.default.join(outDir, relativePath);
|
|
22647
|
+
await import_fs.default.promises.mkdir(import_path.default.dirname(outputPath), { recursive: true });
|
|
22648
|
+
await import_fs.default.promises.writeFile(outputPath, content);
|
|
22649
|
+
}
|
|
22650
|
+
};
|
|
22636
22651
|
var charsSafeToLeaveEncoded = "{}.,<>?/:'[]!@#$^&*() -_=+".split("");
|
|
22637
22652
|
var replaceSafeEncodedChars = (s) => {
|
|
22638
22653
|
for (const char of charsSafeToLeaveEncoded) {
|
|
@@ -22645,12 +22660,6 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22645
22660
|
function idsafe(s) {
|
|
22646
22661
|
return "_" + s.replace(/[^a-zA-Z0-9]/g, "_");
|
|
22647
22662
|
}
|
|
22648
|
-
var toPosixPath = (pathStr) => {
|
|
22649
|
-
if (!pathStr)
|
|
22650
|
-
return pathStr;
|
|
22651
|
-
pathStr = pathStr.replace(/^[A-Za-z]:/, "");
|
|
22652
|
-
return pathStr.split(import_path.default.sep).join("/");
|
|
22653
|
-
};
|
|
22654
22663
|
var getMatchingFilePaths = async ({
|
|
22655
22664
|
dirPath,
|
|
22656
22665
|
extensions,
|
|
@@ -22663,24 +22672,17 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22663
22672
|
}
|
|
22664
22673
|
if (!fileMatchFn)
|
|
22665
22674
|
fileMatchFn = () => true;
|
|
22666
|
-
|
|
22667
|
-
cwd: dirPath,
|
|
22668
|
-
nodir: true,
|
|
22669
|
-
dot: true,
|
|
22670
|
-
absolute: false,
|
|
22671
|
-
windowsPathsNoEscape: true
|
|
22672
|
-
});
|
|
22673
|
-
return files.map((f) => toPosixPath(f)).filter((filename) => fileMatchFn(filename, import_path.default.join(dirPath, filename)));
|
|
22675
|
+
return (await (0, import_glob_promise.default)("**/*", { cwd: dirPath, nodir: true })).filter((filename) => fileMatchFn(filename, import_path2.default.resolve(dirPath, filename)));
|
|
22674
22676
|
};
|
|
22675
22677
|
var getVirtualFileSystemFromDirPath = async (opts) => {
|
|
22676
|
-
const { dirPath, contentFormat
|
|
22678
|
+
const { dirPath, contentFormat } = opts;
|
|
22677
22679
|
const filePaths = await getMatchingFilePaths(opts);
|
|
22678
22680
|
const vfs = {};
|
|
22679
22681
|
for (const filePath of filePaths) {
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22682
|
+
vfs[filePath] = await import_promises.default.readFile(import_path2.default.resolve(dirPath, filePath));
|
|
22683
|
+
if (contentFormat === "string") {
|
|
22684
|
+
vfs[filePath] = vfs[filePath].toString();
|
|
22685
|
+
}
|
|
22684
22686
|
}
|
|
22685
22687
|
return vfs;
|
|
22686
22688
|
};
|
|
@@ -22691,7 +22693,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22691
22693
|
case "buffer":
|
|
22692
22694
|
case "string": {
|
|
22693
22695
|
return `export default {
|
|
22694
|
-
` + Object.entries(vfs).map(([
|
|
22696
|
+
` + Object.entries(vfs).map(([path3, content]) => cf === "buffer" ? ` "${path3}": Buffer.from("${content.toString("base64")}")` : ` "${path3}": decodeURIComponent("${replaceSafeEncodedChars(encodeURIComponent(content.toString()))}")`).join(`,
|
|
22695
22697
|
`) + `
|
|
22696
22698
|
}`;
|
|
22697
22699
|
}
|
|
@@ -22700,12 +22702,12 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
22700
22702
|
case "import-star": {
|
|
22701
22703
|
if (!opts.targetPath)
|
|
22702
22704
|
throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
|
|
22703
|
-
const basePath =
|
|
22705
|
+
const basePath = import_path2.default.relative(import_path2.default.dirname(opts.targetPath), opts.dirPath);
|
|
22704
22706
|
let fps = Object.keys(vfs);
|
|
22705
22707
|
if (opts.noImportExt) {
|
|
22706
22708
|
fps = fps.map((fp) => fp.replace(/\.[^.]+$/, ""));
|
|
22707
22709
|
}
|
|
22708
|
-
return `${fps.map((fp) => cf === "require" ? `const ${idsafe(fp)} = require("./${
|
|
22710
|
+
return `${fps.map((fp) => cf === "require" ? `const ${idsafe(fp)} = require("./${import_path2.default.join(basePath, fp)}")` : cf === "import-default" ? `import ${idsafe(fp)} from "./${import_path2.default.join(basePath, fp)}"` : `import * as ${idsafe(fp)} from "./${import_path2.default.join(basePath, fp)}"`).join(`
|
|
22709
22711
|
`)}
|
|
22710
22712
|
|
|
22711
22713
|
export default {
|
|
@@ -22718,25 +22720,10 @@ export default {
|
|
|
22718
22720
|
}
|
|
22719
22721
|
case "export-pathlist": {
|
|
22720
22722
|
return `export default [
|
|
22721
|
-
` + Object.keys(vfs).map((
|
|
22723
|
+
` + Object.keys(vfs).map((path3) => ` "${path3}"`).join(`,
|
|
22722
22724
|
`) + `
|
|
22723
22725
|
]`;
|
|
22724
22726
|
}
|
|
22725
|
-
case "import-bunfile": {
|
|
22726
|
-
if (!opts.targetPath)
|
|
22727
|
-
throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
|
|
22728
|
-
const basePath = import_path.default.relative(import_path.default.dirname(opts.targetPath), opts.dirPath);
|
|
22729
|
-
let fps = Object.keys(vfs);
|
|
22730
|
-
return `${fps.map((fp) => `import ${idsafe(fp)} from "./${import_path.default.join(basePath, fp)}" with { type: "file" };`).join(`
|
|
22731
|
-
`)}
|
|
22732
|
-
|
|
22733
|
-
import { file } from "bun";
|
|
22734
|
-
|
|
22735
|
-
export default {
|
|
22736
|
-
` + fps.map((fp) => ` "${fp}": file(${idsafe(fp)})`).join(`,
|
|
22737
|
-
`) + `
|
|
22738
|
-
}`;
|
|
22739
|
-
}
|
|
22740
22727
|
}
|
|
22741
22728
|
throw new Error(`Unknown content format: ${cf}`);
|
|
22742
22729
|
};
|
|
@@ -22815,7 +22802,7 @@ function convertCircuitJsonToPcbSvg(elements, options = {}) {
|
|
|
22815
22802
|
|
|
22816
22803
|
// lib/shared/process-snapshot-file.ts
|
|
22817
22804
|
import fs10 from "node:fs";
|
|
22818
|
-
import
|
|
22805
|
+
import path11 from "node:path";
|
|
22819
22806
|
|
|
22820
22807
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
22821
22808
|
function normalizeDir(dir) {
|
|
@@ -23236,8 +23223,8 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
23236
23223
|
|
|
23237
23224
|
// lib/shared/generate-circuit-json.tsx
|
|
23238
23225
|
import fs7 from "node:fs";
|
|
23239
|
-
import
|
|
23240
|
-
import { pathToFileURL } from "node:url";
|
|
23226
|
+
import path9 from "node:path";
|
|
23227
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
23241
23228
|
import Debug from "debug";
|
|
23242
23229
|
|
|
23243
23230
|
// lib/utils/abbreviate-stringify-object.ts
|
|
@@ -23933,36 +23920,1045 @@ function attachAutoroutingArtifacts(root, filePath, projectDir = process.cwd())
|
|
|
23933
23920
|
|
|
23934
23921
|
// lib/shared/importFromUserLand.ts
|
|
23935
23922
|
import { createRequire as createRequire3 } from "node:module";
|
|
23923
|
+
import path6 from "node:path";
|
|
23924
|
+
import { pathToFileURL as pathToFileURL2 } from "node:url";
|
|
23925
|
+
|
|
23926
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
23927
|
+
import assert2 from "node:assert";
|
|
23928
|
+
import { statSync, realpathSync } from "node:fs";
|
|
23929
|
+
import process2 from "node:process";
|
|
23930
|
+
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
23931
|
+
import path5 from "node:path";
|
|
23932
|
+
import { builtinModules } from "node:module";
|
|
23933
|
+
|
|
23934
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
23935
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
23936
|
+
|
|
23937
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
23936
23938
|
import fs4 from "node:fs";
|
|
23937
23939
|
import path4 from "node:path";
|
|
23938
|
-
|
|
23939
|
-
|
|
23940
|
-
|
|
23941
|
-
|
|
23940
|
+
import { fileURLToPath } from "node:url";
|
|
23941
|
+
|
|
23942
|
+
// node_modules/import-meta-resolve/lib/errors.js
|
|
23943
|
+
import v8 from "node:v8";
|
|
23944
|
+
import assert from "node:assert";
|
|
23945
|
+
import { format, inspect } from "node:util";
|
|
23946
|
+
var own = {}.hasOwnProperty;
|
|
23947
|
+
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
23948
|
+
var kTypes = new Set([
|
|
23949
|
+
"string",
|
|
23950
|
+
"function",
|
|
23951
|
+
"number",
|
|
23952
|
+
"object",
|
|
23953
|
+
"Function",
|
|
23954
|
+
"Object",
|
|
23955
|
+
"boolean",
|
|
23956
|
+
"bigint",
|
|
23957
|
+
"symbol"
|
|
23958
|
+
]);
|
|
23959
|
+
var codes = {};
|
|
23960
|
+
function formatList(array, type = "and") {
|
|
23961
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
23962
|
+
}
|
|
23963
|
+
var messages = new Map;
|
|
23964
|
+
var nodeInternalPrefix = "__node_internal_";
|
|
23965
|
+
var userStackTraceLimit;
|
|
23966
|
+
codes.ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
23967
|
+
assert.ok(typeof name === "string", "'name' must be a string");
|
|
23968
|
+
if (!Array.isArray(expected)) {
|
|
23969
|
+
expected = [expected];
|
|
23970
|
+
}
|
|
23971
|
+
let message = "The ";
|
|
23972
|
+
if (name.endsWith(" argument")) {
|
|
23973
|
+
message += `${name} `;
|
|
23974
|
+
} else {
|
|
23975
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
23976
|
+
message += `"${name}" ${type} `;
|
|
23977
|
+
}
|
|
23978
|
+
message += "must be ";
|
|
23979
|
+
const types = [];
|
|
23980
|
+
const instances = [];
|
|
23981
|
+
const other = [];
|
|
23982
|
+
for (const value of expected) {
|
|
23983
|
+
assert.ok(typeof value === "string", "All expected entries have to be of type string");
|
|
23984
|
+
if (kTypes.has(value)) {
|
|
23985
|
+
types.push(value.toLowerCase());
|
|
23986
|
+
} else if (classRegExp.exec(value) === null) {
|
|
23987
|
+
assert.ok(value !== "object", 'The value "object" should be written as "Object"');
|
|
23988
|
+
other.push(value);
|
|
23989
|
+
} else {
|
|
23990
|
+
instances.push(value);
|
|
23991
|
+
}
|
|
23992
|
+
}
|
|
23993
|
+
if (instances.length > 0) {
|
|
23994
|
+
const pos = types.indexOf("object");
|
|
23995
|
+
if (pos !== -1) {
|
|
23996
|
+
types.slice(pos, 1);
|
|
23997
|
+
instances.push("Object");
|
|
23998
|
+
}
|
|
23999
|
+
}
|
|
24000
|
+
if (types.length > 0) {
|
|
24001
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
|
|
24002
|
+
if (instances.length > 0 || other.length > 0)
|
|
24003
|
+
message += " or ";
|
|
24004
|
+
}
|
|
24005
|
+
if (instances.length > 0) {
|
|
24006
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
24007
|
+
if (other.length > 0)
|
|
24008
|
+
message += " or ";
|
|
24009
|
+
}
|
|
24010
|
+
if (other.length > 0) {
|
|
24011
|
+
if (other.length > 1) {
|
|
24012
|
+
message += `one of ${formatList(other, "or")}`;
|
|
24013
|
+
} else {
|
|
24014
|
+
if (other[0].toLowerCase() !== other[0])
|
|
24015
|
+
message += "an ";
|
|
24016
|
+
message += `${other[0]}`;
|
|
24017
|
+
}
|
|
24018
|
+
}
|
|
24019
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
24020
|
+
return message;
|
|
24021
|
+
}, TypeError);
|
|
24022
|
+
codes.ERR_INVALID_MODULE_SPECIFIER = createError("ERR_INVALID_MODULE_SPECIFIER", (request, reason, base = undefined) => {
|
|
24023
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
24024
|
+
}, TypeError);
|
|
24025
|
+
codes.ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path, base, message) => {
|
|
24026
|
+
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
24027
|
+
}, Error);
|
|
24028
|
+
codes.ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base = undefined) => {
|
|
24029
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
24030
|
+
if (key === ".") {
|
|
24031
|
+
assert.ok(isImport === false);
|
|
24032
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined ` + `in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
24033
|
+
}
|
|
24034
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(target)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
24035
|
+
}, Error);
|
|
24036
|
+
codes.ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path, base, exactUrl = false) => {
|
|
24037
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
|
|
24038
|
+
}, Error);
|
|
24039
|
+
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
|
|
24040
|
+
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
|
|
24041
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
24042
|
+
}, TypeError);
|
|
24043
|
+
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError("ERR_PACKAGE_PATH_NOT_EXPORTED", (packagePath, subpath, base = undefined) => {
|
|
24044
|
+
if (subpath === ".")
|
|
24045
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
24046
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
24047
|
+
}, Error);
|
|
24048
|
+
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported " + "resolving ES modules imported from %s", Error);
|
|
24049
|
+
codes.ERR_UNSUPPORTED_RESOLVE_REQUEST = createError("ERR_UNSUPPORTED_RESOLVE_REQUEST", 'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.', TypeError);
|
|
24050
|
+
codes.ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path) => {
|
|
24051
|
+
return `Unknown file extension "${extension}" for ${path}`;
|
|
24052
|
+
}, TypeError);
|
|
24053
|
+
codes.ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
24054
|
+
let inspected = inspect(value);
|
|
24055
|
+
if (inspected.length > 128) {
|
|
24056
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
24057
|
+
}
|
|
24058
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
24059
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
24060
|
+
}, TypeError);
|
|
24061
|
+
function createError(sym, value, constructor) {
|
|
24062
|
+
messages.set(sym, value);
|
|
24063
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
24064
|
+
}
|
|
24065
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
24066
|
+
return NodeError;
|
|
24067
|
+
function NodeError(...parameters) {
|
|
24068
|
+
const limit = Error.stackTraceLimit;
|
|
24069
|
+
if (isErrorStackTraceLimitWritable())
|
|
24070
|
+
Error.stackTraceLimit = 0;
|
|
24071
|
+
const error = new Base;
|
|
24072
|
+
if (isErrorStackTraceLimitWritable())
|
|
24073
|
+
Error.stackTraceLimit = limit;
|
|
24074
|
+
const message = getMessage(key, parameters, error);
|
|
24075
|
+
Object.defineProperties(error, {
|
|
24076
|
+
message: {
|
|
24077
|
+
value: message,
|
|
24078
|
+
enumerable: false,
|
|
24079
|
+
writable: true,
|
|
24080
|
+
configurable: true
|
|
24081
|
+
},
|
|
24082
|
+
toString: {
|
|
24083
|
+
value() {
|
|
24084
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
24085
|
+
},
|
|
24086
|
+
enumerable: false,
|
|
24087
|
+
writable: true,
|
|
24088
|
+
configurable: true
|
|
24089
|
+
}
|
|
24090
|
+
});
|
|
24091
|
+
captureLargerStackTrace(error);
|
|
24092
|
+
error.code = key;
|
|
24093
|
+
return error;
|
|
24094
|
+
}
|
|
24095
|
+
}
|
|
24096
|
+
function isErrorStackTraceLimitWritable() {
|
|
24097
|
+
try {
|
|
24098
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
24099
|
+
return false;
|
|
24100
|
+
}
|
|
24101
|
+
} catch {}
|
|
24102
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
24103
|
+
if (desc === undefined) {
|
|
24104
|
+
return Object.isExtensible(Error);
|
|
24105
|
+
}
|
|
24106
|
+
return own.call(desc, "writable") && desc.writable !== undefined ? desc.writable : desc.set !== undefined;
|
|
24107
|
+
}
|
|
24108
|
+
function hideStackFrames(wrappedFunction) {
|
|
24109
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
24110
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
24111
|
+
return wrappedFunction;
|
|
24112
|
+
}
|
|
24113
|
+
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
24114
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
24115
|
+
if (stackTraceLimitIsWritable) {
|
|
24116
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
24117
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
24118
|
+
}
|
|
24119
|
+
Error.captureStackTrace(error);
|
|
24120
|
+
if (stackTraceLimitIsWritable)
|
|
24121
|
+
Error.stackTraceLimit = userStackTraceLimit;
|
|
24122
|
+
return error;
|
|
24123
|
+
});
|
|
24124
|
+
function getMessage(key, parameters, self) {
|
|
24125
|
+
const message = messages.get(key);
|
|
24126
|
+
assert.ok(message !== undefined, "expected `message` to be found");
|
|
24127
|
+
if (typeof message === "function") {
|
|
24128
|
+
assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${message.length}).`);
|
|
24129
|
+
return Reflect.apply(message, self, parameters);
|
|
24130
|
+
}
|
|
24131
|
+
const regex = /%[dfijoOs]/g;
|
|
24132
|
+
let expectedLength = 0;
|
|
24133
|
+
while (regex.exec(message) !== null)
|
|
24134
|
+
expectedLength++;
|
|
24135
|
+
assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${expectedLength}).`);
|
|
24136
|
+
if (parameters.length === 0)
|
|
24137
|
+
return message;
|
|
24138
|
+
parameters.unshift(message);
|
|
24139
|
+
return Reflect.apply(format, null, parameters);
|
|
24140
|
+
}
|
|
24141
|
+
function determineSpecificType(value) {
|
|
24142
|
+
if (value === null || value === undefined) {
|
|
24143
|
+
return String(value);
|
|
24144
|
+
}
|
|
24145
|
+
if (typeof value === "function" && value.name) {
|
|
24146
|
+
return `function ${value.name}`;
|
|
24147
|
+
}
|
|
24148
|
+
if (typeof value === "object") {
|
|
24149
|
+
if (value.constructor && value.constructor.name) {
|
|
24150
|
+
return `an instance of ${value.constructor.name}`;
|
|
24151
|
+
}
|
|
24152
|
+
return `${inspect(value, { depth: -1 })}`;
|
|
24153
|
+
}
|
|
24154
|
+
let inspected = inspect(value, { colors: false });
|
|
24155
|
+
if (inspected.length > 28) {
|
|
24156
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
24157
|
+
}
|
|
24158
|
+
return `type ${typeof value} (${inspected})`;
|
|
24159
|
+
}
|
|
24160
|
+
|
|
24161
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
24162
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
24163
|
+
var { ERR_INVALID_PACKAGE_CONFIG } = codes;
|
|
24164
|
+
var cache = new Map;
|
|
24165
|
+
function read(jsonPath, { base, specifier }) {
|
|
24166
|
+
const existing = cache.get(jsonPath);
|
|
24167
|
+
if (existing) {
|
|
24168
|
+
return existing;
|
|
24169
|
+
}
|
|
24170
|
+
let string;
|
|
24171
|
+
try {
|
|
24172
|
+
string = fs4.readFileSync(path4.toNamespacedPath(jsonPath), "utf8");
|
|
24173
|
+
} catch (error) {
|
|
24174
|
+
const exception = error;
|
|
24175
|
+
if (exception.code !== "ENOENT") {
|
|
24176
|
+
throw exception;
|
|
24177
|
+
}
|
|
24178
|
+
}
|
|
24179
|
+
const result = {
|
|
24180
|
+
exists: false,
|
|
24181
|
+
pjsonPath: jsonPath,
|
|
24182
|
+
main: undefined,
|
|
24183
|
+
name: undefined,
|
|
24184
|
+
type: "none",
|
|
24185
|
+
exports: undefined,
|
|
24186
|
+
imports: undefined
|
|
24187
|
+
};
|
|
24188
|
+
if (string !== undefined) {
|
|
24189
|
+
let parsed;
|
|
23942
24190
|
try {
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
24191
|
+
parsed = JSON.parse(string);
|
|
24192
|
+
} catch (error_) {
|
|
24193
|
+
const cause = error_;
|
|
24194
|
+
const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), cause.message);
|
|
24195
|
+
error.cause = cause;
|
|
24196
|
+
throw error;
|
|
24197
|
+
}
|
|
24198
|
+
result.exists = true;
|
|
24199
|
+
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
|
|
24200
|
+
result.name = parsed.name;
|
|
24201
|
+
}
|
|
24202
|
+
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
|
|
24203
|
+
result.main = parsed.main;
|
|
24204
|
+
}
|
|
24205
|
+
if (hasOwnProperty.call(parsed, "exports")) {
|
|
24206
|
+
result.exports = parsed.exports;
|
|
24207
|
+
}
|
|
24208
|
+
if (hasOwnProperty.call(parsed, "imports")) {
|
|
24209
|
+
result.imports = parsed.imports;
|
|
24210
|
+
}
|
|
24211
|
+
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
|
|
24212
|
+
result.type = parsed.type;
|
|
24213
|
+
}
|
|
24214
|
+
}
|
|
24215
|
+
cache.set(jsonPath, result);
|
|
24216
|
+
return result;
|
|
24217
|
+
}
|
|
24218
|
+
function getPackageScopeConfig(resolved) {
|
|
24219
|
+
let packageJSONUrl = new URL("package.json", resolved);
|
|
24220
|
+
while (true) {
|
|
24221
|
+
const packageJSONPath = packageJSONUrl.pathname;
|
|
24222
|
+
if (packageJSONPath.endsWith("node_modules/package.json")) {
|
|
24223
|
+
break;
|
|
24224
|
+
}
|
|
24225
|
+
const packageConfig = read(fileURLToPath(packageJSONUrl), {
|
|
24226
|
+
specifier: resolved
|
|
24227
|
+
});
|
|
24228
|
+
if (packageConfig.exists) {
|
|
24229
|
+
return packageConfig;
|
|
24230
|
+
}
|
|
24231
|
+
const lastPackageJSONUrl = packageJSONUrl;
|
|
24232
|
+
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
24233
|
+
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
|
|
24234
|
+
break;
|
|
24235
|
+
}
|
|
24236
|
+
}
|
|
24237
|
+
const packageJSONPath = fileURLToPath(packageJSONUrl);
|
|
24238
|
+
return {
|
|
24239
|
+
pjsonPath: packageJSONPath,
|
|
24240
|
+
exists: false,
|
|
24241
|
+
type: "none"
|
|
24242
|
+
};
|
|
24243
|
+
}
|
|
24244
|
+
function getPackageType(url) {
|
|
24245
|
+
return getPackageScopeConfig(url).type;
|
|
24246
|
+
}
|
|
24247
|
+
|
|
24248
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
24249
|
+
var { ERR_UNKNOWN_FILE_EXTENSION } = codes;
|
|
24250
|
+
var hasOwnProperty2 = {}.hasOwnProperty;
|
|
24251
|
+
var extensionFormatMap = {
|
|
24252
|
+
__proto__: null,
|
|
24253
|
+
".cjs": "commonjs",
|
|
24254
|
+
".js": "module",
|
|
24255
|
+
".json": "json",
|
|
24256
|
+
".mjs": "module"
|
|
24257
|
+
};
|
|
24258
|
+
function mimeToFormat(mime) {
|
|
24259
|
+
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
|
|
24260
|
+
return "module";
|
|
24261
|
+
if (mime === "application/json")
|
|
24262
|
+
return "json";
|
|
24263
|
+
return null;
|
|
24264
|
+
}
|
|
24265
|
+
var protocolHandlers = {
|
|
24266
|
+
__proto__: null,
|
|
24267
|
+
"data:": getDataProtocolModuleFormat,
|
|
24268
|
+
"file:": getFileProtocolModuleFormat,
|
|
24269
|
+
"http:": getHttpProtocolModuleFormat,
|
|
24270
|
+
"https:": getHttpProtocolModuleFormat,
|
|
24271
|
+
"node:"() {
|
|
24272
|
+
return "builtin";
|
|
24273
|
+
}
|
|
24274
|
+
};
|
|
24275
|
+
function getDataProtocolModuleFormat(parsed) {
|
|
24276
|
+
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null, null];
|
|
24277
|
+
return mimeToFormat(mime);
|
|
24278
|
+
}
|
|
24279
|
+
function extname(url) {
|
|
24280
|
+
const pathname = url.pathname;
|
|
24281
|
+
let index = pathname.length;
|
|
24282
|
+
while (index--) {
|
|
24283
|
+
const code = pathname.codePointAt(index);
|
|
24284
|
+
if (code === 47) {
|
|
24285
|
+
return "";
|
|
24286
|
+
}
|
|
24287
|
+
if (code === 46) {
|
|
24288
|
+
return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
|
|
24289
|
+
}
|
|
24290
|
+
}
|
|
24291
|
+
return "";
|
|
24292
|
+
}
|
|
24293
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
24294
|
+
const value = extname(url);
|
|
24295
|
+
if (value === ".js") {
|
|
24296
|
+
const packageType = getPackageType(url);
|
|
24297
|
+
if (packageType !== "none") {
|
|
24298
|
+
return packageType;
|
|
24299
|
+
}
|
|
24300
|
+
return "commonjs";
|
|
24301
|
+
}
|
|
24302
|
+
if (value === "") {
|
|
24303
|
+
const packageType = getPackageType(url);
|
|
24304
|
+
if (packageType === "none" || packageType === "commonjs") {
|
|
24305
|
+
return "commonjs";
|
|
24306
|
+
}
|
|
24307
|
+
return "module";
|
|
24308
|
+
}
|
|
24309
|
+
const format = extensionFormatMap[value];
|
|
24310
|
+
if (format)
|
|
24311
|
+
return format;
|
|
24312
|
+
if (ignoreErrors) {
|
|
24313
|
+
return;
|
|
24314
|
+
}
|
|
24315
|
+
const filepath = fileURLToPath2(url);
|
|
24316
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
24317
|
+
}
|
|
24318
|
+
function getHttpProtocolModuleFormat() {}
|
|
24319
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
24320
|
+
const protocol = url.protocol;
|
|
24321
|
+
if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
|
|
24322
|
+
return null;
|
|
24323
|
+
}
|
|
24324
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
24325
|
+
}
|
|
24326
|
+
|
|
24327
|
+
// node_modules/import-meta-resolve/lib/utils.js
|
|
24328
|
+
var { ERR_INVALID_ARG_VALUE } = codes;
|
|
24329
|
+
var DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
|
|
24330
|
+
var DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
24331
|
+
function getDefaultConditions() {
|
|
24332
|
+
return DEFAULT_CONDITIONS;
|
|
24333
|
+
}
|
|
24334
|
+
function getDefaultConditionsSet() {
|
|
24335
|
+
return DEFAULT_CONDITIONS_SET;
|
|
24336
|
+
}
|
|
24337
|
+
function getConditionsSet(conditions) {
|
|
24338
|
+
if (conditions !== undefined && conditions !== getDefaultConditions()) {
|
|
24339
|
+
if (!Array.isArray(conditions)) {
|
|
24340
|
+
throw new ERR_INVALID_ARG_VALUE("conditions", conditions, "expected an array");
|
|
24341
|
+
}
|
|
24342
|
+
return new Set(conditions);
|
|
24343
|
+
}
|
|
24344
|
+
return getDefaultConditionsSet();
|
|
24345
|
+
}
|
|
24346
|
+
|
|
24347
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
24348
|
+
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
24349
|
+
var {
|
|
24350
|
+
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
24351
|
+
ERR_INVALID_MODULE_SPECIFIER,
|
|
24352
|
+
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
|
|
24353
|
+
ERR_INVALID_PACKAGE_TARGET,
|
|
24354
|
+
ERR_MODULE_NOT_FOUND,
|
|
24355
|
+
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
24356
|
+
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
24357
|
+
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
24358
|
+
ERR_UNSUPPORTED_RESOLVE_REQUEST
|
|
24359
|
+
} = codes;
|
|
24360
|
+
var own2 = {}.hasOwnProperty;
|
|
24361
|
+
var invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
|
|
24362
|
+
var deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
|
|
24363
|
+
var invalidPackageNameRegEx = /^\.|%|\\/;
|
|
24364
|
+
var patternRegEx = /\*/g;
|
|
24365
|
+
var encodedSeparatorRegEx = /%2f|%5c/i;
|
|
24366
|
+
var emittedPackageWarnings = new Set;
|
|
24367
|
+
var doubleSlashRegEx = /[/\\]{2}/;
|
|
24368
|
+
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
24369
|
+
if (process2.noDeprecation) {
|
|
24370
|
+
return;
|
|
24371
|
+
}
|
|
24372
|
+
const pjsonPath = fileURLToPath3(packageJsonUrl);
|
|
24373
|
+
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
24374
|
+
process2.emitWarning(`Use of deprecated ${double ? "double slash" : "leading or trailing slash matching"} resolving "${target}" for module ` + `request "${request}" ${request === match ? "" : `matched to "${match}" `}in the "${internal ? "imports" : "exports"}" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath3(base)}` : ""}.`, "DeprecationWarning", "DEP0166");
|
|
24375
|
+
}
|
|
24376
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
24377
|
+
if (process2.noDeprecation) {
|
|
24378
|
+
return;
|
|
24379
|
+
}
|
|
24380
|
+
const format = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
|
|
24381
|
+
if (format !== "module")
|
|
24382
|
+
return;
|
|
24383
|
+
const urlPath = fileURLToPath3(url.href);
|
|
24384
|
+
const packagePath = fileURLToPath3(new URL(".", packageJsonUrl));
|
|
24385
|
+
const basePath = fileURLToPath3(base);
|
|
24386
|
+
if (!main) {
|
|
24387
|
+
process2.emitWarning(`No "main" or "exports" field defined in the package.json for ${packagePath} resolving the main entry point "${urlPath.slice(packagePath.length)}", imported from ${basePath}.
|
|
24388
|
+
Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
24389
|
+
} else if (path5.resolve(packagePath, main) !== urlPath) {
|
|
24390
|
+
process2.emitWarning(`Package ${packagePath} has a "main" field set to "${main}", ` + `excluding the full filename and extension to the resolved file at "${urlPath.slice(packagePath.length)}", imported from ${basePath}.
|
|
24391
|
+
Automatic extension resolution of the "main" field is ` + "deprecated for ES modules.", "DeprecationWarning", "DEP0151");
|
|
24392
|
+
}
|
|
24393
|
+
}
|
|
24394
|
+
function tryStatSync(path) {
|
|
24395
|
+
try {
|
|
24396
|
+
return statSync(path);
|
|
24397
|
+
} catch {}
|
|
24398
|
+
}
|
|
24399
|
+
function fileExists(url) {
|
|
24400
|
+
const stats = statSync(url, { throwIfNoEntry: false });
|
|
24401
|
+
const isFile = stats ? stats.isFile() : undefined;
|
|
24402
|
+
return isFile === null || isFile === undefined ? false : isFile;
|
|
24403
|
+
}
|
|
24404
|
+
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
24405
|
+
let guess;
|
|
24406
|
+
if (packageConfig.main !== undefined) {
|
|
24407
|
+
guess = new URL(packageConfig.main, packageJsonUrl);
|
|
24408
|
+
if (fileExists(guess))
|
|
24409
|
+
return guess;
|
|
24410
|
+
const tries = [
|
|
24411
|
+
`./${packageConfig.main}.js`,
|
|
24412
|
+
`./${packageConfig.main}.json`,
|
|
24413
|
+
`./${packageConfig.main}.node`,
|
|
24414
|
+
`./${packageConfig.main}/index.js`,
|
|
24415
|
+
`./${packageConfig.main}/index.json`,
|
|
24416
|
+
`./${packageConfig.main}/index.node`
|
|
24417
|
+
];
|
|
24418
|
+
let i = -1;
|
|
24419
|
+
while (++i < tries.length) {
|
|
24420
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
24421
|
+
if (fileExists(guess))
|
|
24422
|
+
break;
|
|
24423
|
+
guess = undefined;
|
|
24424
|
+
}
|
|
24425
|
+
if (guess) {
|
|
24426
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
24427
|
+
return guess;
|
|
24428
|
+
}
|
|
24429
|
+
}
|
|
24430
|
+
const tries = ["./index.js", "./index.json", "./index.node"];
|
|
24431
|
+
let i = -1;
|
|
24432
|
+
while (++i < tries.length) {
|
|
24433
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
24434
|
+
if (fileExists(guess))
|
|
24435
|
+
break;
|
|
24436
|
+
guess = undefined;
|
|
24437
|
+
}
|
|
24438
|
+
if (guess) {
|
|
24439
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
24440
|
+
return guess;
|
|
24441
|
+
}
|
|
24442
|
+
throw new ERR_MODULE_NOT_FOUND(fileURLToPath3(new URL(".", packageJsonUrl)), fileURLToPath3(base));
|
|
24443
|
+
}
|
|
24444
|
+
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
24445
|
+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
|
|
24446
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath3(base));
|
|
24447
|
+
}
|
|
24448
|
+
let filePath;
|
|
24449
|
+
try {
|
|
24450
|
+
filePath = fileURLToPath3(resolved);
|
|
24451
|
+
} catch (error) {
|
|
24452
|
+
const cause = error;
|
|
24453
|
+
Object.defineProperty(cause, "input", { value: String(resolved) });
|
|
24454
|
+
Object.defineProperty(cause, "module", { value: String(base) });
|
|
24455
|
+
throw cause;
|
|
24456
|
+
}
|
|
24457
|
+
const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
|
|
24458
|
+
if (stats && stats.isDirectory()) {
|
|
24459
|
+
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath3(base));
|
|
24460
|
+
error.url = String(resolved);
|
|
24461
|
+
throw error;
|
|
24462
|
+
}
|
|
24463
|
+
if (!stats || !stats.isFile()) {
|
|
24464
|
+
const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath3(base), true);
|
|
24465
|
+
error.url = String(resolved);
|
|
24466
|
+
throw error;
|
|
24467
|
+
}
|
|
24468
|
+
if (!preserveSymlinks) {
|
|
24469
|
+
const real = realpathSync(filePath);
|
|
24470
|
+
const { search, hash } = resolved;
|
|
24471
|
+
resolved = pathToFileURL(real + (filePath.endsWith(path5.sep) ? "/" : ""));
|
|
24472
|
+
resolved.search = search;
|
|
24473
|
+
resolved.hash = hash;
|
|
24474
|
+
}
|
|
24475
|
+
return resolved;
|
|
24476
|
+
}
|
|
24477
|
+
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
24478
|
+
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath3(new URL(".", packageJsonUrl)), fileURLToPath3(base));
|
|
24479
|
+
}
|
|
24480
|
+
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
24481
|
+
return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath3(new URL(".", packageJsonUrl)), subpath, base && fileURLToPath3(base));
|
|
24482
|
+
}
|
|
24483
|
+
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
24484
|
+
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath3(packageJsonUrl)}`;
|
|
24485
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && fileURLToPath3(base));
|
|
24486
|
+
}
|
|
24487
|
+
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
24488
|
+
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
24489
|
+
return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath3(new URL(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath3(base));
|
|
24490
|
+
}
|
|
24491
|
+
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
24492
|
+
if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
|
|
24493
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
24494
|
+
if (!target.startsWith("./")) {
|
|
24495
|
+
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
24496
|
+
let isURL = false;
|
|
24497
|
+
try {
|
|
24498
|
+
new URL(target);
|
|
24499
|
+
isURL = true;
|
|
24500
|
+
} catch {}
|
|
24501
|
+
if (!isURL) {
|
|
24502
|
+
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath;
|
|
24503
|
+
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
24504
|
+
}
|
|
24505
|
+
}
|
|
24506
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
24507
|
+
}
|
|
24508
|
+
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
|
|
24509
|
+
if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
24510
|
+
if (!isPathMap) {
|
|
24511
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
24512
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
|
|
24513
|
+
emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, true);
|
|
24514
|
+
}
|
|
24515
|
+
} else {
|
|
24516
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
24517
|
+
}
|
|
24518
|
+
}
|
|
24519
|
+
const resolved = new URL(target, packageJsonUrl);
|
|
24520
|
+
const resolvedPath = resolved.pathname;
|
|
24521
|
+
const packagePath = new URL(".", packageJsonUrl).pathname;
|
|
24522
|
+
if (!resolvedPath.startsWith(packagePath))
|
|
24523
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
24524
|
+
if (subpath === "")
|
|
24525
|
+
return resolved;
|
|
24526
|
+
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
24527
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
24528
|
+
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
24529
|
+
if (!isPathMap) {
|
|
24530
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
|
|
24531
|
+
emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, false);
|
|
24532
|
+
}
|
|
24533
|
+
} else {
|
|
24534
|
+
throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
24535
|
+
}
|
|
24536
|
+
}
|
|
24537
|
+
if (pattern) {
|
|
24538
|
+
return new URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
|
|
24539
|
+
}
|
|
24540
|
+
return new URL(subpath, resolved);
|
|
24541
|
+
}
|
|
24542
|
+
function isArrayIndex(key) {
|
|
24543
|
+
const keyNumber = Number(key);
|
|
24544
|
+
if (`${keyNumber}` !== key)
|
|
24545
|
+
return false;
|
|
24546
|
+
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
24547
|
+
}
|
|
24548
|
+
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
24549
|
+
if (typeof target === "string") {
|
|
24550
|
+
return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
|
|
24551
|
+
}
|
|
24552
|
+
if (Array.isArray(target)) {
|
|
24553
|
+
const targetList = target;
|
|
24554
|
+
if (targetList.length === 0)
|
|
24555
|
+
return null;
|
|
24556
|
+
let lastException;
|
|
24557
|
+
let i = -1;
|
|
24558
|
+
while (++i < targetList.length) {
|
|
24559
|
+
const targetItem = targetList[i];
|
|
24560
|
+
let resolveResult;
|
|
24561
|
+
try {
|
|
24562
|
+
resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
24563
|
+
} catch (error) {
|
|
24564
|
+
const exception = error;
|
|
24565
|
+
lastException = exception;
|
|
24566
|
+
if (exception.code === "ERR_INVALID_PACKAGE_TARGET")
|
|
24567
|
+
continue;
|
|
24568
|
+
throw error;
|
|
24569
|
+
}
|
|
24570
|
+
if (resolveResult === undefined)
|
|
24571
|
+
continue;
|
|
24572
|
+
if (resolveResult === null) {
|
|
24573
|
+
lastException = null;
|
|
24574
|
+
continue;
|
|
24575
|
+
}
|
|
24576
|
+
return resolveResult;
|
|
24577
|
+
}
|
|
24578
|
+
if (lastException === undefined || lastException === null) {
|
|
24579
|
+
return null;
|
|
24580
|
+
}
|
|
24581
|
+
throw lastException;
|
|
24582
|
+
}
|
|
24583
|
+
if (typeof target === "object" && target !== null) {
|
|
24584
|
+
const keys = Object.getOwnPropertyNames(target);
|
|
24585
|
+
let i = -1;
|
|
24586
|
+
while (++i < keys.length) {
|
|
24587
|
+
const key = keys[i];
|
|
24588
|
+
if (isArrayIndex(key)) {
|
|
24589
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath3(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
|
|
24590
|
+
}
|
|
24591
|
+
}
|
|
24592
|
+
i = -1;
|
|
24593
|
+
while (++i < keys.length) {
|
|
24594
|
+
const key = keys[i];
|
|
24595
|
+
if (key === "default" || conditions && conditions.has(key)) {
|
|
24596
|
+
const conditionalTarget = target[key];
|
|
24597
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
24598
|
+
if (resolveResult === undefined)
|
|
24599
|
+
continue;
|
|
24600
|
+
return resolveResult;
|
|
24601
|
+
}
|
|
24602
|
+
}
|
|
24603
|
+
return null;
|
|
24604
|
+
}
|
|
24605
|
+
if (target === null) {
|
|
24606
|
+
return null;
|
|
24607
|
+
}
|
|
24608
|
+
throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
|
|
24609
|
+
}
|
|
24610
|
+
function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
|
|
24611
|
+
if (typeof exports === "string" || Array.isArray(exports))
|
|
24612
|
+
return true;
|
|
24613
|
+
if (typeof exports !== "object" || exports === null)
|
|
24614
|
+
return false;
|
|
24615
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
24616
|
+
let isConditionalSugar = false;
|
|
24617
|
+
let i = 0;
|
|
24618
|
+
let keyIndex = -1;
|
|
24619
|
+
while (++keyIndex < keys.length) {
|
|
24620
|
+
const key = keys[keyIndex];
|
|
24621
|
+
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
24622
|
+
if (i++ === 0) {
|
|
24623
|
+
isConditionalSugar = currentIsConditionalSugar;
|
|
24624
|
+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
|
|
24625
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath3(packageJsonUrl), base, `"exports" cannot contain some keys starting with '.' and some not.` + " The exports object must either be an object of package subpath keys" + " or an object of main entry condition name keys only.");
|
|
24626
|
+
}
|
|
24627
|
+
}
|
|
24628
|
+
return isConditionalSugar;
|
|
24629
|
+
}
|
|
24630
|
+
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
24631
|
+
if (process2.noDeprecation) {
|
|
24632
|
+
return;
|
|
24633
|
+
}
|
|
24634
|
+
const pjsonPath = fileURLToPath3(pjsonUrl);
|
|
24635
|
+
if (emittedPackageWarnings.has(pjsonPath + "|" + match))
|
|
24636
|
+
return;
|
|
24637
|
+
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
24638
|
+
process2.emitWarning(`Use of deprecated trailing slash pattern mapping "${match}" in the ` + `"exports" field module resolution of the package at ${pjsonPath}${base ? ` imported from ${fileURLToPath3(base)}` : ""}. Mapping specifiers ending in "/" is no longer supported.`, "DeprecationWarning", "DEP0155");
|
|
24639
|
+
}
|
|
24640
|
+
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
24641
|
+
let exports = packageConfig.exports;
|
|
24642
|
+
if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
|
|
24643
|
+
exports = { ".": exports };
|
|
24644
|
+
}
|
|
24645
|
+
if (own2.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
24646
|
+
const target = exports[packageSubpath];
|
|
24647
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
|
|
24648
|
+
if (resolveResult === null || resolveResult === undefined) {
|
|
24649
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
24650
|
+
}
|
|
24651
|
+
return resolveResult;
|
|
24652
|
+
}
|
|
24653
|
+
let bestMatch = "";
|
|
24654
|
+
let bestMatchSubpath = "";
|
|
24655
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
24656
|
+
let i = -1;
|
|
24657
|
+
while (++i < keys.length) {
|
|
24658
|
+
const key = keys[i];
|
|
24659
|
+
const patternIndex = key.indexOf("*");
|
|
24660
|
+
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
24661
|
+
if (packageSubpath.endsWith("/")) {
|
|
24662
|
+
emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
|
|
24663
|
+
}
|
|
24664
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
24665
|
+
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
24666
|
+
bestMatch = key;
|
|
24667
|
+
bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
|
|
24668
|
+
}
|
|
24669
|
+
}
|
|
24670
|
+
}
|
|
24671
|
+
if (bestMatch) {
|
|
24672
|
+
const target = exports[bestMatch];
|
|
24673
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
|
|
24674
|
+
if (resolveResult === null || resolveResult === undefined) {
|
|
24675
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
24676
|
+
}
|
|
24677
|
+
return resolveResult;
|
|
24678
|
+
}
|
|
24679
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
24680
|
+
}
|
|
24681
|
+
function patternKeyCompare(a, b) {
|
|
24682
|
+
const aPatternIndex = a.indexOf("*");
|
|
24683
|
+
const bPatternIndex = b.indexOf("*");
|
|
24684
|
+
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
24685
|
+
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
24686
|
+
if (baseLengthA > baseLengthB)
|
|
24687
|
+
return -1;
|
|
24688
|
+
if (baseLengthB > baseLengthA)
|
|
24689
|
+
return 1;
|
|
24690
|
+
if (aPatternIndex === -1)
|
|
24691
|
+
return 1;
|
|
24692
|
+
if (bPatternIndex === -1)
|
|
24693
|
+
return -1;
|
|
24694
|
+
if (a.length > b.length)
|
|
24695
|
+
return -1;
|
|
24696
|
+
if (b.length > a.length)
|
|
24697
|
+
return 1;
|
|
24698
|
+
return 0;
|
|
24699
|
+
}
|
|
24700
|
+
function packageImportsResolve(name, base, conditions) {
|
|
24701
|
+
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
|
|
24702
|
+
const reason = "is not a valid internal imports specifier name";
|
|
24703
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath3(base));
|
|
24704
|
+
}
|
|
24705
|
+
let packageJsonUrl;
|
|
24706
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
24707
|
+
if (packageConfig.exists) {
|
|
24708
|
+
packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
24709
|
+
const imports = packageConfig.imports;
|
|
24710
|
+
if (imports) {
|
|
24711
|
+
if (own2.call(imports, name) && !name.includes("*")) {
|
|
24712
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
|
|
24713
|
+
if (resolveResult !== null && resolveResult !== undefined) {
|
|
24714
|
+
return resolveResult;
|
|
24715
|
+
}
|
|
24716
|
+
} else {
|
|
24717
|
+
let bestMatch = "";
|
|
24718
|
+
let bestMatchSubpath = "";
|
|
24719
|
+
const keys = Object.getOwnPropertyNames(imports);
|
|
24720
|
+
let i = -1;
|
|
24721
|
+
while (++i < keys.length) {
|
|
24722
|
+
const key = keys[i];
|
|
24723
|
+
const patternIndex = key.indexOf("*");
|
|
24724
|
+
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
24725
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
24726
|
+
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
24727
|
+
bestMatch = key;
|
|
24728
|
+
bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
|
|
24729
|
+
}
|
|
24730
|
+
}
|
|
24731
|
+
}
|
|
24732
|
+
if (bestMatch) {
|
|
24733
|
+
const target = imports[bestMatch];
|
|
24734
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
|
|
24735
|
+
if (resolveResult !== null && resolveResult !== undefined) {
|
|
24736
|
+
return resolveResult;
|
|
24737
|
+
}
|
|
24738
|
+
}
|
|
24739
|
+
}
|
|
24740
|
+
}
|
|
24741
|
+
}
|
|
24742
|
+
throw importNotDefined(name, packageJsonUrl, base);
|
|
24743
|
+
}
|
|
24744
|
+
function parsePackageName(specifier, base) {
|
|
24745
|
+
let separatorIndex = specifier.indexOf("/");
|
|
24746
|
+
let validPackageName = true;
|
|
24747
|
+
let isScoped = false;
|
|
24748
|
+
if (specifier[0] === "@") {
|
|
24749
|
+
isScoped = true;
|
|
24750
|
+
if (separatorIndex === -1 || specifier.length === 0) {
|
|
24751
|
+
validPackageName = false;
|
|
24752
|
+
} else {
|
|
24753
|
+
separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
24754
|
+
}
|
|
24755
|
+
}
|
|
24756
|
+
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
24757
|
+
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
24758
|
+
validPackageName = false;
|
|
24759
|
+
}
|
|
24760
|
+
if (!validPackageName) {
|
|
24761
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath3(base));
|
|
24762
|
+
}
|
|
24763
|
+
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
24764
|
+
return { packageName, packageSubpath, isScoped };
|
|
24765
|
+
}
|
|
24766
|
+
function packageResolve(specifier, base, conditions) {
|
|
24767
|
+
if (builtinModules.includes(specifier)) {
|
|
24768
|
+
return new URL("node:" + specifier);
|
|
24769
|
+
}
|
|
24770
|
+
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
|
|
24771
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
24772
|
+
if (packageConfig.exists) {
|
|
24773
|
+
const packageJsonUrl = pathToFileURL(packageConfig.pjsonPath);
|
|
24774
|
+
if (packageConfig.name === packageName && packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
|
24775
|
+
return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
24776
|
+
}
|
|
24777
|
+
}
|
|
24778
|
+
let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
|
|
24779
|
+
let packageJsonPath = fileURLToPath3(packageJsonUrl);
|
|
24780
|
+
let lastPath;
|
|
24781
|
+
do {
|
|
24782
|
+
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
24783
|
+
if (!stat || !stat.isDirectory()) {
|
|
24784
|
+
lastPath = packageJsonPath;
|
|
24785
|
+
packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
|
|
24786
|
+
packageJsonPath = fileURLToPath3(packageJsonUrl);
|
|
24787
|
+
continue;
|
|
24788
|
+
}
|
|
24789
|
+
const packageConfig = read(packageJsonPath, { base, specifier });
|
|
24790
|
+
if (packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
|
24791
|
+
return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
24792
|
+
}
|
|
24793
|
+
if (packageSubpath === ".") {
|
|
24794
|
+
return legacyMainResolve(packageJsonUrl, packageConfig, base);
|
|
24795
|
+
}
|
|
24796
|
+
return new URL(packageSubpath, packageJsonUrl);
|
|
24797
|
+
} while (packageJsonPath.length !== lastPath.length);
|
|
24798
|
+
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath3(base), false);
|
|
24799
|
+
}
|
|
24800
|
+
function isRelativeSpecifier(specifier) {
|
|
24801
|
+
if (specifier[0] === ".") {
|
|
24802
|
+
if (specifier.length === 1 || specifier[1] === "/")
|
|
24803
|
+
return true;
|
|
24804
|
+
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
|
|
24805
|
+
return true;
|
|
24806
|
+
}
|
|
24807
|
+
}
|
|
24808
|
+
return false;
|
|
24809
|
+
}
|
|
24810
|
+
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
24811
|
+
if (specifier === "")
|
|
24812
|
+
return false;
|
|
24813
|
+
if (specifier[0] === "/")
|
|
24814
|
+
return true;
|
|
24815
|
+
return isRelativeSpecifier(specifier);
|
|
24816
|
+
}
|
|
24817
|
+
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
24818
|
+
if (conditions === undefined) {
|
|
24819
|
+
conditions = getConditionsSet();
|
|
24820
|
+
}
|
|
24821
|
+
const protocol = base.protocol;
|
|
24822
|
+
const isData = protocol === "data:";
|
|
24823
|
+
const isRemote = isData || protocol === "http:" || protocol === "https:";
|
|
24824
|
+
let resolved;
|
|
24825
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
24826
|
+
try {
|
|
24827
|
+
resolved = new URL(specifier, base);
|
|
24828
|
+
} catch (error_) {
|
|
24829
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
24830
|
+
error.cause = error_;
|
|
24831
|
+
throw error;
|
|
24832
|
+
}
|
|
24833
|
+
} else if (protocol === "file:" && specifier[0] === "#") {
|
|
24834
|
+
resolved = packageImportsResolve(specifier, base, conditions);
|
|
24835
|
+
} else {
|
|
24836
|
+
try {
|
|
24837
|
+
resolved = new URL(specifier);
|
|
24838
|
+
} catch (error_) {
|
|
24839
|
+
if (isRemote && !builtinModules.includes(specifier)) {
|
|
24840
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
24841
|
+
error.cause = error_;
|
|
23947
24842
|
throw error;
|
|
23948
24843
|
}
|
|
24844
|
+
resolved = packageResolve(specifier, base, conditions);
|
|
24845
|
+
}
|
|
24846
|
+
}
|
|
24847
|
+
assert2.ok(resolved !== undefined, "expected to be defined");
|
|
24848
|
+
if (resolved.protocol !== "file:") {
|
|
24849
|
+
return resolved;
|
|
24850
|
+
}
|
|
24851
|
+
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
24852
|
+
}
|
|
24853
|
+
function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
|
|
24854
|
+
if (parsedParentURL) {
|
|
24855
|
+
const parentProtocol = parsedParentURL.protocol;
|
|
24856
|
+
if (parentProtocol === "http:" || parentProtocol === "https:") {
|
|
24857
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
24858
|
+
const parsedProtocol = parsed?.protocol;
|
|
24859
|
+
if (parsedProtocol && parsedProtocol !== "https:" && parsedProtocol !== "http:") {
|
|
24860
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
|
|
24861
|
+
}
|
|
24862
|
+
return { url: parsed?.href || "" };
|
|
24863
|
+
}
|
|
24864
|
+
if (builtinModules.includes(specifier)) {
|
|
24865
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
|
|
24866
|
+
}
|
|
24867
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "only relative and absolute specifiers are supported.");
|
|
24868
|
+
}
|
|
24869
|
+
}
|
|
24870
|
+
}
|
|
24871
|
+
function isURL(self) {
|
|
24872
|
+
return Boolean(self && typeof self === "object" && "href" in self && typeof self.href === "string" && "protocol" in self && typeof self.protocol === "string" && self.href && self.protocol);
|
|
24873
|
+
}
|
|
24874
|
+
function throwIfInvalidParentURL(parentURL) {
|
|
24875
|
+
if (parentURL === undefined) {
|
|
24876
|
+
return;
|
|
24877
|
+
}
|
|
24878
|
+
if (typeof parentURL !== "string" && !isURL(parentURL)) {
|
|
24879
|
+
throw new codes.ERR_INVALID_ARG_TYPE("parentURL", ["string", "URL"], parentURL);
|
|
24880
|
+
}
|
|
24881
|
+
}
|
|
24882
|
+
function defaultResolve(specifier, context = {}) {
|
|
24883
|
+
const { parentURL } = context;
|
|
24884
|
+
assert2.ok(parentURL !== undefined, "expected `parentURL` to be defined");
|
|
24885
|
+
throwIfInvalidParentURL(parentURL);
|
|
24886
|
+
let parsedParentURL;
|
|
24887
|
+
if (parentURL) {
|
|
24888
|
+
try {
|
|
24889
|
+
parsedParentURL = new URL(parentURL);
|
|
24890
|
+
} catch {}
|
|
24891
|
+
}
|
|
24892
|
+
let parsed;
|
|
24893
|
+
let protocol;
|
|
24894
|
+
try {
|
|
24895
|
+
parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new URL(specifier, parsedParentURL) : new URL(specifier);
|
|
24896
|
+
protocol = parsed.protocol;
|
|
24897
|
+
if (protocol === "data:") {
|
|
24898
|
+
return { url: parsed.href, format: null };
|
|
23949
24899
|
}
|
|
24900
|
+
} catch {}
|
|
24901
|
+
const maybeReturn = checkIfDisallowedImport(specifier, parsed, parsedParentURL);
|
|
24902
|
+
if (maybeReturn)
|
|
24903
|
+
return maybeReturn;
|
|
24904
|
+
if (protocol === undefined && parsed) {
|
|
24905
|
+
protocol = parsed.protocol;
|
|
24906
|
+
}
|
|
24907
|
+
if (protocol === "node:") {
|
|
24908
|
+
return { url: specifier };
|
|
24909
|
+
}
|
|
24910
|
+
if (parsed && parsed.protocol === "node:")
|
|
24911
|
+
return { url: specifier };
|
|
24912
|
+
const conditions = getConditionsSet(context.conditions);
|
|
24913
|
+
const url = moduleResolve(specifier, new URL(parentURL), conditions, false);
|
|
24914
|
+
return {
|
|
24915
|
+
url: url.href,
|
|
24916
|
+
format: defaultGetFormatWithoutErrors(url, { parentURL })
|
|
24917
|
+
};
|
|
24918
|
+
}
|
|
24919
|
+
|
|
24920
|
+
// node_modules/import-meta-resolve/index.js
|
|
24921
|
+
function resolve(specifier, parent) {
|
|
24922
|
+
if (!parent) {
|
|
24923
|
+
throw new Error("Please pass `parent`: `import-meta-resolve` cannot ponyfill that");
|
|
23950
24924
|
}
|
|
23951
|
-
const cliRequire = createRequire3(import.meta.url);
|
|
23952
24925
|
try {
|
|
23953
|
-
|
|
23954
|
-
return await import(resolvedCliPath);
|
|
24926
|
+
return defaultResolve(specifier, { parentURL: parent }).url;
|
|
23955
24927
|
} catch (error) {
|
|
23956
|
-
|
|
23957
|
-
|
|
24928
|
+
const exception = error;
|
|
24929
|
+
if ((exception.code === "ERR_UNSUPPORTED_DIR_IMPORT" || exception.code === "ERR_MODULE_NOT_FOUND") && typeof exception.url === "string") {
|
|
24930
|
+
return exception.url;
|
|
23958
24931
|
}
|
|
24932
|
+
throw error;
|
|
24933
|
+
}
|
|
24934
|
+
}
|
|
24935
|
+
|
|
24936
|
+
// lib/shared/importFromUserLand.ts
|
|
24937
|
+
async function importFromUserLand(moduleName, projectDir = process.cwd()) {
|
|
24938
|
+
for (const parent of [
|
|
24939
|
+
pathToFileURL2(path6.join(projectDir, "noop.js")).href,
|
|
24940
|
+
import.meta.url
|
|
24941
|
+
]) {
|
|
24942
|
+
let resolved;
|
|
24943
|
+
try {
|
|
24944
|
+
resolved = resolve(moduleName, parent);
|
|
24945
|
+
} catch (error) {
|
|
24946
|
+
if (error?.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
|
24947
|
+
resolved = pathToFileURL2(createRequire3(parent).resolve(moduleName)).href;
|
|
24948
|
+
} else if (error?.code === "ERR_MODULE_NOT_FOUND") {
|
|
24949
|
+
continue;
|
|
24950
|
+
} else {
|
|
24951
|
+
throw error;
|
|
24952
|
+
}
|
|
24953
|
+
}
|
|
24954
|
+
return import(resolved);
|
|
23959
24955
|
}
|
|
23960
24956
|
return import(moduleName);
|
|
23961
24957
|
}
|
|
23962
24958
|
|
|
23963
24959
|
// lib/shared/register-static-asset-loaders.ts
|
|
23964
24960
|
import fs5 from "node:fs";
|
|
23965
|
-
import
|
|
24961
|
+
import path7 from "node:path";
|
|
23966
24962
|
var STATIC_ASSET_EXTENSIONS = [
|
|
23967
24963
|
".glb",
|
|
23968
24964
|
".gltf",
|
|
@@ -23989,7 +24985,7 @@ var TEXT_STATIC_ASSET_EXTENSIONS = new Set([
|
|
|
23989
24985
|
".kicad_sym"
|
|
23990
24986
|
]);
|
|
23991
24987
|
var readFileContentForStaticLoader = (filePath) => {
|
|
23992
|
-
const ext =
|
|
24988
|
+
const ext = path7.extname(filePath).toLowerCase();
|
|
23993
24989
|
if (TEXT_STATIC_ASSET_EXTENSIONS.has(ext)) {
|
|
23994
24990
|
return fs5.readFileSync(filePath, "utf-8");
|
|
23995
24991
|
}
|
|
@@ -23997,7 +24993,7 @@ var readFileContentForStaticLoader = (filePath) => {
|
|
|
23997
24993
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
23998
24994
|
};
|
|
23999
24995
|
var getStaticFileLoader = (filePath) => {
|
|
24000
|
-
const extWithDot =
|
|
24996
|
+
const extWithDot = path7.extname(filePath).toLowerCase();
|
|
24001
24997
|
const ext = extWithDot.replace(/^\./, "");
|
|
24002
24998
|
return activePlatformConfig?.staticFileLoaderMap?.[ext] ?? activePlatformConfig?.staticFileLoaderMap?.[extWithDot];
|
|
24003
24999
|
};
|
|
@@ -24011,7 +25007,7 @@ var normalizeStaticFileLoaderResult = (result) => {
|
|
|
24011
25007
|
};
|
|
24012
25008
|
};
|
|
24013
25009
|
var getBaseUrlFromTsConfig = (projectDir) => {
|
|
24014
|
-
const tsconfigPath =
|
|
25010
|
+
const tsconfigPath = path7.join(projectDir, "tsconfig.json");
|
|
24015
25011
|
try {
|
|
24016
25012
|
if (!fs5.existsSync(tsconfigPath)) {
|
|
24017
25013
|
return null;
|
|
@@ -24043,8 +25039,8 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
24043
25039
|
loader: "object"
|
|
24044
25040
|
};
|
|
24045
25041
|
}
|
|
24046
|
-
const baseDir = baseUrl ?
|
|
24047
|
-
const relativePath =
|
|
25042
|
+
const baseDir = baseUrl ? path7.resolve(projectDir, baseUrl) : projectDir;
|
|
25043
|
+
const relativePath = path7.relative(baseDir, args.path).split(path7.sep).join("/");
|
|
24048
25044
|
const pathStr = `./${relativePath}`;
|
|
24049
25045
|
return {
|
|
24050
25046
|
exports: {
|
|
@@ -24061,7 +25057,7 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
24061
25057
|
|
|
24062
25058
|
// lib/shared/solver-diagnostics.ts
|
|
24063
25059
|
import fs6 from "node:fs";
|
|
24064
|
-
import
|
|
25060
|
+
import path8 from "node:path";
|
|
24065
25061
|
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
24066
25062
|
var cloneAsJson = (value, ancestors = new WeakMap, path = "#") => {
|
|
24067
25063
|
if (value === undefined)
|
|
@@ -24162,7 +25158,7 @@ class SolverDiagnostics {
|
|
|
24162
25158
|
finalize() {
|
|
24163
25159
|
if (!this.options.enabled)
|
|
24164
25160
|
return;
|
|
24165
|
-
fs6.mkdirSync(
|
|
25161
|
+
fs6.mkdirSync(path8.dirname(this.options.outputPath), { recursive: true });
|
|
24166
25162
|
fs6.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
24167
25163
|
format: "tscircuit_solver_debug_v1",
|
|
24168
25164
|
entrypoint: this.options.entrypoint,
|
|
@@ -24206,7 +25202,7 @@ async function generateCircuitJson({
|
|
|
24206
25202
|
}) {
|
|
24207
25203
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
24208
25204
|
const currentSourceFilesystemMd5Hash = sourceFilesystemMd5Hash ?? getSourceFilesystemMd5Hash(filePath);
|
|
24209
|
-
const projectRootDir =
|
|
25205
|
+
const projectRootDir = path9.resolve(projectDirOption ?? process.cwd());
|
|
24210
25206
|
const React = await importFromUserLand("react", projectRootDir);
|
|
24211
25207
|
globalThis.React = React;
|
|
24212
25208
|
registerStaticAssetLoaders(platformConfig, projectRootDir);
|
|
@@ -24219,12 +25215,12 @@ async function generateCircuitJson({
|
|
|
24219
25215
|
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
24220
25216
|
solverDiagnostics?.attachToRootCircuit(runner);
|
|
24221
25217
|
attachAutoroutingArtifacts(runner, filePath, projectRootDir);
|
|
24222
|
-
const absoluteFilePath =
|
|
24223
|
-
const sourceDir =
|
|
25218
|
+
const absoluteFilePath = path9.isAbsolute(filePath) ? filePath : path9.resolve(projectRootDir, filePath);
|
|
25219
|
+
const sourceDir = path9.dirname(absoluteFilePath);
|
|
24224
25220
|
const resolvedOutputDir = outputDir ?? sourceDir;
|
|
24225
|
-
const relativeComponentPath =
|
|
24226
|
-
const baseFileName = outputFileName ||
|
|
24227
|
-
const outputPath =
|
|
25221
|
+
const relativeComponentPath = path9.relative(sourceDir, absoluteFilePath);
|
|
25222
|
+
const baseFileName = outputFileName || path9.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
25223
|
+
const outputPath = path9.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
24228
25224
|
debug(`Project directory: ${sourceDir}`);
|
|
24229
25225
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
24230
25226
|
debug(`Output path: ${outputPath}`);
|
|
@@ -24244,7 +25240,7 @@ async function generateCircuitJson({
|
|
|
24244
25240
|
return false;
|
|
24245
25241
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
24246
25242
|
return false;
|
|
24247
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
25243
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path9.extname(normalizedFilePath)))
|
|
24248
25244
|
return false;
|
|
24249
25245
|
return true;
|
|
24250
25246
|
},
|
|
@@ -24252,32 +25248,41 @@ async function generateCircuitJson({
|
|
|
24252
25248
|
})
|
|
24253
25249
|
};
|
|
24254
25250
|
debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
|
|
24255
|
-
const MainComponent = await import(
|
|
24256
|
-
|
|
24257
|
-
if (
|
|
24258
|
-
|
|
24259
|
-
}
|
|
24260
|
-
|
|
24261
|
-
|
|
24262
|
-
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
|
|
24266
|
-
|
|
24267
|
-
|
|
24268
|
-
|
|
24269
|
-
|
|
25251
|
+
const MainComponent = await import(pathToFileURL3(absoluteFilePath).href);
|
|
25252
|
+
let records;
|
|
25253
|
+
if (Array.isArray(MainComponent.circuitJson)) {
|
|
25254
|
+
records = MainComponent.circuitJson;
|
|
25255
|
+
} else {
|
|
25256
|
+
const namedComponent = Object.keys(MainComponent).find((key) => key[0] === key[0].toUpperCase());
|
|
25257
|
+
const Component = MainComponent.default || (namedComponent ? MainComponent[namedComponent] : undefined);
|
|
25258
|
+
if (!Component) {
|
|
25259
|
+
throw new Error(`No component found in "${absoluteFilePath}". Make sure you export a component.`);
|
|
25260
|
+
}
|
|
25261
|
+
runner.add(/* @__PURE__ */ jsxDEV(Component, {
|
|
25262
|
+
...injectedProps ?? {}
|
|
25263
|
+
}, undefined, false, undefined, this));
|
|
25264
|
+
runner.render();
|
|
25265
|
+
const loggedAsyncEffectNames = new Set;
|
|
25266
|
+
while (!runner.isDoneRendering()) {
|
|
25267
|
+
for (const asyncEffect of runner.getRunningAsyncEffects()) {
|
|
25268
|
+
const asyncEffectName = asyncEffect.effectName;
|
|
25269
|
+
if (!asyncEffectName || loggedAsyncEffectNames.has(asyncEffectName)) {
|
|
25270
|
+
continue;
|
|
25271
|
+
}
|
|
25272
|
+
loggedAsyncEffectNames.add(asyncEffectName);
|
|
25273
|
+
onAsyncEffectStatus?.(asyncEffectName);
|
|
24270
25274
|
}
|
|
24271
|
-
|
|
24272
|
-
|
|
25275
|
+
autorouterDiagnostics.checkTimeout();
|
|
25276
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
25277
|
+
runner.render();
|
|
24273
25278
|
}
|
|
24274
|
-
|
|
24275
|
-
|
|
24276
|
-
runner.
|
|
25279
|
+
runner.emit("renderComplete");
|
|
25280
|
+
solverDiagnostics?.finalize();
|
|
25281
|
+
const hasImportedBoard = runner.children.some((component) => [component, ...component.getDescendants()].some((instance) => instance[Symbol.for("pcb-spice-pipeline.imported-board.v2")]));
|
|
25282
|
+
records = hasImportedBoard ? (await importFromUserLand("@tscircuit/pcb-spice-pipeline/tsx", projectRootDir)).serializeSimulation(runner) : await runner.getCircuitJson();
|
|
24277
25283
|
}
|
|
24278
|
-
|
|
24279
|
-
|
|
24280
|
-
const circuitJson = addSourceFilesystemHash(await runner.getCircuitJson(), currentSourceFilesystemMd5Hash);
|
|
25284
|
+
const modeling = MainComponent.modeling;
|
|
25285
|
+
const circuitJson = addSourceFilesystemHash(records, currentSourceFilesystemMd5Hash);
|
|
24281
25286
|
await autorouterDiagnostics.finalize(circuitJson);
|
|
24282
25287
|
if (saveToFile) {
|
|
24283
25288
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
@@ -24286,7 +25291,8 @@ async function generateCircuitJson({
|
|
|
24286
25291
|
return {
|
|
24287
25292
|
circuitJson,
|
|
24288
25293
|
outputPath,
|
|
24289
|
-
rootCircuit: runner
|
|
25294
|
+
rootCircuit: runner,
|
|
25295
|
+
modeling
|
|
24290
25296
|
};
|
|
24291
25297
|
}
|
|
24292
25298
|
|
|
@@ -24317,7 +25323,7 @@ var getOrGenerateCircuitJson = async (options) => {
|
|
|
24317
25323
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
24318
25324
|
import { createHash as createHash3 } from "node:crypto";
|
|
24319
25325
|
import fs8 from "node:fs";
|
|
24320
|
-
import
|
|
25326
|
+
import path10 from "node:path";
|
|
24321
25327
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
24322
25328
|
|
|
24323
25329
|
// lib/shared/platform-config-utils.ts
|
|
@@ -24378,13 +25384,13 @@ var getPlatformFetch = (upstreamFetch = globalThis.fetch) => {
|
|
|
24378
25384
|
};
|
|
24379
25385
|
|
|
24380
25386
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
24381
|
-
function createLocalCacheEngine(cacheDir =
|
|
25387
|
+
function createLocalCacheEngine(cacheDir = path10.join(process.cwd(), ".tscircuit", "cache")) {
|
|
24382
25388
|
return {
|
|
24383
25389
|
getItem: (key) => {
|
|
24384
25390
|
try {
|
|
24385
25391
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
24386
25392
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
24387
|
-
const filePath =
|
|
25393
|
+
const filePath = path10.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
24388
25394
|
return fs8.readFileSync(filePath, "utf-8");
|
|
24389
25395
|
} catch {
|
|
24390
25396
|
return null;
|
|
@@ -24395,7 +25401,7 @@ function createLocalCacheEngine(cacheDir = path8.join(process.cwd(), ".tscircuit
|
|
|
24395
25401
|
fs8.mkdirSync(cacheDir, { recursive: true });
|
|
24396
25402
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
24397
25403
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
24398
|
-
const filePath =
|
|
25404
|
+
const filePath = path10.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
24399
25405
|
fs8.writeFileSync(filePath, value);
|
|
24400
25406
|
} catch {}
|
|
24401
25407
|
}
|
|
@@ -24404,7 +25410,7 @@ function createLocalCacheEngine(cacheDir = path8.join(process.cwd(), ".tscircuit
|
|
|
24404
25410
|
function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
24405
25411
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
24406
25412
|
const basePlatformConfig = getPlatformConfig();
|
|
24407
|
-
const cacheDir =
|
|
25413
|
+
const cacheDir = path10.join(projectDir, ".tscircuit", "cache");
|
|
24408
25414
|
const defaultConfig = {
|
|
24409
25415
|
...basePlatformConfig,
|
|
24410
25416
|
checkAvailability: true,
|
|
@@ -24415,14 +25421,14 @@ function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
|
24415
25421
|
loadFromUrl: async (url) => {
|
|
24416
25422
|
let fetchUrl = url;
|
|
24417
25423
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
24418
|
-
const absolutePath =
|
|
25424
|
+
const absolutePath = path10.resolve(projectDir, url);
|
|
24419
25425
|
fetchUrl = `file://${absolutePath}`;
|
|
24420
25426
|
} else if (url.startsWith("/")) {
|
|
24421
25427
|
if (fs8.existsSync(url)) {
|
|
24422
25428
|
fetchUrl = `file://${url}`;
|
|
24423
25429
|
} else {
|
|
24424
25430
|
const relativePath = `.${url}`;
|
|
24425
|
-
const absolutePath =
|
|
25431
|
+
const absolutePath = path10.resolve(projectDir, relativePath);
|
|
24426
25432
|
if (fs8.existsSync(absolutePath)) {
|
|
24427
25433
|
fetchUrl = `file://${absolutePath}`;
|
|
24428
25434
|
} else {
|
|
@@ -24559,7 +25565,7 @@ var processSnapshotFile = async ({
|
|
|
24559
25565
|
cameraPreset,
|
|
24560
25566
|
pcbLayer
|
|
24561
25567
|
}) => {
|
|
24562
|
-
const relativeFilePath =
|
|
25568
|
+
const relativeFilePath = path11.relative(projectDir, file);
|
|
24563
25569
|
const successPaths = [];
|
|
24564
25570
|
const warningMessages = [];
|
|
24565
25571
|
const mismatches = [];
|
|
@@ -24655,11 +25661,11 @@ var processSnapshotFile = async ({
|
|
|
24655
25661
|
} catch (error) {
|
|
24656
25662
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
24657
25663
|
if (errorMessage.includes("No pcb_board found in circuit JSON")) {
|
|
24658
|
-
const fileDir =
|
|
24659
|
-
const relativeDir =
|
|
24660
|
-
const snapDir = snapshotsDirName ?
|
|
24661
|
-
const base =
|
|
24662
|
-
const snap3dPath =
|
|
25664
|
+
const fileDir = path11.dirname(file);
|
|
25665
|
+
const relativeDir = path11.relative(projectDir, fileDir);
|
|
25666
|
+
const snapDir = snapshotsDirName ? path11.join(projectDir, snapshotsDirName, relativeDir) : path11.join(fileDir, "__snapshots__");
|
|
25667
|
+
const base = path11.basename(file).replace(/\.[^.]+$/, "");
|
|
25668
|
+
const snap3dPath = path11.join(snapDir, `${base}-3d.snap.png`);
|
|
24663
25669
|
const existing3dSnapshot = fs10.existsSync(snap3dPath);
|
|
24664
25670
|
if (existing3dSnapshot) {
|
|
24665
25671
|
return {
|
|
@@ -24671,7 +25677,7 @@ var processSnapshotFile = async ({
|
|
|
24671
25677
|
errorMessage: kleur_default.red(`
|
|
24672
25678
|
❌ Failed to generate 3D snapshot for ${relativeFilePath}:
|
|
24673
25679
|
`) + kleur_default.red(` No pcb_board found in circuit JSON
|
|
24674
|
-
`) + kleur_default.red(` Existing snapshot: ${
|
|
25680
|
+
`) + kleur_default.red(` Existing snapshot: ${path11.relative(projectDir, snap3dPath)}
|
|
24675
25681
|
`)
|
|
24676
25682
|
};
|
|
24677
25683
|
}
|
|
@@ -24692,9 +25698,9 @@ var processSnapshotFile = async ({
|
|
|
24692
25698
|
}
|
|
24693
25699
|
}
|
|
24694
25700
|
}
|
|
24695
|
-
const snapDir = snapshotsDirName ?
|
|
25701
|
+
const snapDir = snapshotsDirName ? path11.join(projectDir, snapshotsDirName, path11.relative(projectDir, path11.dirname(file))) : path11.join(path11.dirname(file), "__snapshots__");
|
|
24696
25702
|
fs10.mkdirSync(snapDir, { recursive: true });
|
|
24697
|
-
const base =
|
|
25703
|
+
const base = path11.basename(file).replace(/\.[^.]+$/, "");
|
|
24698
25704
|
const snapshots = [];
|
|
24699
25705
|
if (!simulationOnly && (pcbOnly || !schematicOnly)) {
|
|
24700
25706
|
let pcbSnapshotType = "pcb";
|
|
@@ -24735,13 +25741,13 @@ var processSnapshotFile = async ({
|
|
|
24735
25741
|
for (const snapshot of snapshots) {
|
|
24736
25742
|
const { type } = snapshot;
|
|
24737
25743
|
const is3d = type === "3d";
|
|
24738
|
-
const snapPath =
|
|
25744
|
+
const snapPath = path11.join(snapDir, `${base}-${type}.snap.${is3d ? "png" : "svg"}`);
|
|
24739
25745
|
const existing = fs10.existsSync(snapPath);
|
|
24740
25746
|
const newContentBuffer = snapshot.isBinary ? snapshot.content : Buffer.from(snapshot.content, "utf8");
|
|
24741
25747
|
const newContentForFile = snapshot.content;
|
|
24742
25748
|
if (!existing) {
|
|
24743
25749
|
fs10.writeFileSync(snapPath, newContentForFile);
|
|
24744
|
-
successPaths.push(
|
|
25750
|
+
successPaths.push(path11.relative(projectDir, snapPath));
|
|
24745
25751
|
didUpdate = true;
|
|
24746
25752
|
continue;
|
|
24747
25753
|
}
|
|
@@ -24759,16 +25765,16 @@ var processSnapshotFile = async ({
|
|
|
24759
25765
|
}
|
|
24760
25766
|
if (update) {
|
|
24761
25767
|
if (!forceUpdate && equal) {
|
|
24762
|
-
successPaths.push(
|
|
25768
|
+
successPaths.push(path11.relative(projectDir, snapPath));
|
|
24763
25769
|
} else {
|
|
24764
25770
|
fs10.writeFileSync(snapPath, newContentForFile);
|
|
24765
|
-
successPaths.push(
|
|
25771
|
+
successPaths.push(path11.relative(projectDir, snapPath));
|
|
24766
25772
|
didUpdate = true;
|
|
24767
25773
|
}
|
|
24768
25774
|
} else if (!equal) {
|
|
24769
25775
|
mismatches.push(diffPath ? `${snapPath} (diff: ${diffPath})` : snapPath);
|
|
24770
25776
|
} else {
|
|
24771
|
-
successPaths.push(
|
|
25777
|
+
successPaths.push(path11.relative(projectDir, snapPath));
|
|
24772
25778
|
}
|
|
24773
25779
|
}
|
|
24774
25780
|
return {
|
|
@@ -24782,8 +25788,8 @@ var processSnapshotFile = async ({
|
|
|
24782
25788
|
|
|
24783
25789
|
// lib/project-config/index.ts
|
|
24784
25790
|
import * as fs11 from "node:fs";
|
|
24785
|
-
import * as
|
|
24786
|
-
import { pathToFileURL as
|
|
25791
|
+
import * as path12 from "node:path";
|
|
25792
|
+
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
24787
25793
|
|
|
24788
25794
|
// lib/project-config/project-config-schema.ts
|
|
24789
25795
|
import { z } from "zod";
|
|
@@ -24883,7 +25889,7 @@ var stripWrappingQuotes = (value) => {
|
|
|
24883
25889
|
var loadProjectEnv = (projectDir) => {
|
|
24884
25890
|
const initialEnvKeys = new Set(Object.keys(process.env));
|
|
24885
25891
|
for (const envFileName of ENV_FILENAMES) {
|
|
24886
|
-
const envPath =
|
|
25892
|
+
const envPath = path12.join(projectDir, envFileName);
|
|
24887
25893
|
if (!fs11.existsSync(envPath))
|
|
24888
25894
|
continue;
|
|
24889
25895
|
const envContent = fs11.readFileSync(envPath, "utf8");
|
|
@@ -24904,7 +25910,7 @@ var loadProjectEnv = (projectDir) => {
|
|
|
24904
25910
|
}
|
|
24905
25911
|
};
|
|
24906
25912
|
var loadProjectConfigSync = (projectDir = process.cwd(), options = {}) => {
|
|
24907
|
-
const configPath =
|
|
25913
|
+
const configPath = path12.join(projectDir, CONFIG_FILENAME);
|
|
24908
25914
|
if (!fs11.existsSync(configPath)) {
|
|
24909
25915
|
return null;
|
|
24910
25916
|
}
|
|
@@ -24922,11 +25928,11 @@ var loadProjectConfigSync = (projectDir = process.cwd(), options = {}) => {
|
|
|
24922
25928
|
var loadProjectConfigModule = async (projectDir, options = {}) => {
|
|
24923
25929
|
loadProjectEnv(projectDir);
|
|
24924
25930
|
for (const configFileName of CONFIG_MODULE_FILENAMES) {
|
|
24925
|
-
const configPath =
|
|
25931
|
+
const configPath = path12.join(projectDir, configFileName);
|
|
24926
25932
|
if (!fs11.existsSync(configPath))
|
|
24927
25933
|
continue;
|
|
24928
25934
|
try {
|
|
24929
|
-
const moduleUrl =
|
|
25935
|
+
const moduleUrl = pathToFileURL4(configPath);
|
|
24930
25936
|
const stat = fs11.statSync(configPath);
|
|
24931
25937
|
moduleUrl.searchParams.set("tsci", String(stat.mtimeMs));
|
|
24932
25938
|
const importedModule = await import(moduleUrl.href);
|
|
@@ -24983,7 +25989,7 @@ var getSnapshotsDir = (projectDir = process.cwd()) => {
|
|
|
24983
25989
|
return config?.snapshotsDir;
|
|
24984
25990
|
};
|
|
24985
25991
|
var saveProjectConfig = (config, projectDir = process.cwd()) => {
|
|
24986
|
-
const configPath =
|
|
25992
|
+
const configPath = path12.join(projectDir, CONFIG_FILENAME);
|
|
24987
25993
|
try {
|
|
24988
25994
|
const configWithSchema = {
|
|
24989
25995
|
$schema: CONFIG_SCHEMA_URL,
|