@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
|
@@ -96,7 +96,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
96
96
|
"node_modules/fs.realpath/old.js"(exports2) {
|
|
97
97
|
var pathModule = __require("path");
|
|
98
98
|
var isWindows = process.platform === "win32";
|
|
99
|
-
var
|
|
99
|
+
var fs3 = __require("fs");
|
|
100
100
|
var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
|
|
101
101
|
function rethrow() {
|
|
102
102
|
var callback;
|
|
@@ -161,7 +161,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
161
161
|
base = m[0];
|
|
162
162
|
previous = "";
|
|
163
163
|
if (isWindows && !knownHard[base]) {
|
|
164
|
-
|
|
164
|
+
fs3.lstatSync(base);
|
|
165
165
|
knownHard[base] = true;
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -179,7 +179,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
179
179
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
180
180
|
resolvedLink = cache[base];
|
|
181
181
|
} else {
|
|
182
|
-
var stat =
|
|
182
|
+
var stat = fs3.lstatSync(base);
|
|
183
183
|
if (!stat.isSymbolicLink()) {
|
|
184
184
|
knownHard[base] = true;
|
|
185
185
|
if (cache)
|
|
@@ -194,8 +194,8 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
194
194
|
}
|
|
195
195
|
}
|
|
196
196
|
if (linkTarget === null) {
|
|
197
|
-
|
|
198
|
-
linkTarget =
|
|
197
|
+
fs3.statSync(base);
|
|
198
|
+
linkTarget = fs3.readlinkSync(base);
|
|
199
199
|
}
|
|
200
200
|
resolvedLink = pathModule.resolve(previous, linkTarget);
|
|
201
201
|
if (cache)
|
|
@@ -232,7 +232,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
232
232
|
base = m[0];
|
|
233
233
|
previous = "";
|
|
234
234
|
if (isWindows && !knownHard[base]) {
|
|
235
|
-
|
|
235
|
+
fs3.lstat(base, function(err) {
|
|
236
236
|
if (err)
|
|
237
237
|
return cb(err);
|
|
238
238
|
knownHard[base] = true;
|
|
@@ -260,7 +260,7 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
260
260
|
if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
|
|
261
261
|
return gotResolvedLink(cache[base]);
|
|
262
262
|
}
|
|
263
|
-
return
|
|
263
|
+
return fs3.lstat(base, gotStat);
|
|
264
264
|
}
|
|
265
265
|
function gotStat(err, stat) {
|
|
266
266
|
if (err)
|
|
@@ -277,10 +277,10 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
277
277
|
return gotTarget(null, seenLinks[id], base);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
|
-
|
|
280
|
+
fs3.stat(base, function(err2) {
|
|
281
281
|
if (err2)
|
|
282
282
|
return cb(err2);
|
|
283
|
-
|
|
283
|
+
fs3.readlink(base, function(err3, target) {
|
|
284
284
|
if (!isWindows)
|
|
285
285
|
seenLinks[id] = target;
|
|
286
286
|
gotTarget(err3, target);
|
|
@@ -310,9 +310,9 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
310
310
|
realpath.realpathSync = realpathSync;
|
|
311
311
|
realpath.monkeypatch = monkeypatch;
|
|
312
312
|
realpath.unmonkeypatch = unmonkeypatch;
|
|
313
|
-
var
|
|
314
|
-
var origRealpath =
|
|
315
|
-
var origRealpathSync =
|
|
313
|
+
var fs3 = __require("fs");
|
|
314
|
+
var origRealpath = fs3.realpath;
|
|
315
|
+
var origRealpathSync = fs3.realpathSync;
|
|
316
316
|
var version = process.version;
|
|
317
317
|
var ok = /^v[0-5]\./.test(version);
|
|
318
318
|
var old = require_old();
|
|
@@ -350,12 +350,12 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
352
|
function monkeypatch() {
|
|
353
|
-
|
|
354
|
-
|
|
353
|
+
fs3.realpath = realpath;
|
|
354
|
+
fs3.realpathSync = realpathSync;
|
|
355
355
|
}
|
|
356
356
|
function unmonkeypatch() {
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
fs3.realpath = origRealpath;
|
|
358
|
+
fs3.realpathSync = origRealpathSync;
|
|
359
359
|
}
|
|
360
360
|
}
|
|
361
361
|
});
|
|
@@ -581,8 +581,8 @@ var require_dist = __commonJS(function(exports, module) {
|
|
|
581
581
|
return new Minimatch(pattern, options).match(p);
|
|
582
582
|
};
|
|
583
583
|
module2.exports = minimatch;
|
|
584
|
-
var
|
|
585
|
-
minimatch.sep =
|
|
584
|
+
var path3 = require_path();
|
|
585
|
+
minimatch.sep = path3.sep;
|
|
586
586
|
var GLOBSTAR = Symbol("globstar **");
|
|
587
587
|
minimatch.GLOBSTAR = GLOBSTAR;
|
|
588
588
|
var expand = require_brace_expansion();
|
|
@@ -1073,8 +1073,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1073
1073
|
if (f === "/" && partial)
|
|
1074
1074
|
return true;
|
|
1075
1075
|
const options = this.options;
|
|
1076
|
-
if (
|
|
1077
|
-
f = f.split(
|
|
1076
|
+
if (path3.sep !== "/") {
|
|
1077
|
+
f = f.split(path3.sep).join("/");
|
|
1078
1078
|
}
|
|
1079
1079
|
f = f.split(slashSplit);
|
|
1080
1080
|
this.debug(this.pattern, "split", f);
|
|
@@ -1164,8 +1164,8 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1164
1164
|
function ownProp(obj, field) {
|
|
1165
1165
|
return Object.prototype.hasOwnProperty.call(obj, field);
|
|
1166
1166
|
}
|
|
1167
|
-
var
|
|
1168
|
-
var
|
|
1167
|
+
var fs3 = __require("fs");
|
|
1168
|
+
var path3 = __require("path");
|
|
1169
1169
|
var minimatch = require_minimatch();
|
|
1170
1170
|
var isAbsolute = __require("path").isAbsolute;
|
|
1171
1171
|
var Minimatch = minimatch.Minimatch;
|
|
@@ -1219,7 +1219,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1219
1219
|
self.stat = !!options.stat;
|
|
1220
1220
|
self.noprocess = !!options.noprocess;
|
|
1221
1221
|
self.absolute = !!options.absolute;
|
|
1222
|
-
self.fs = options.fs ||
|
|
1222
|
+
self.fs = options.fs || fs3;
|
|
1223
1223
|
self.maxLength = options.maxLength || Infinity;
|
|
1224
1224
|
self.cache = options.cache || /* @__PURE__ */ Object.create(null);
|
|
1225
1225
|
self.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
|
|
@@ -1228,13 +1228,13 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1228
1228
|
self.changedCwd = false;
|
|
1229
1229
|
var cwd = process.cwd();
|
|
1230
1230
|
if (!ownProp(options, "cwd"))
|
|
1231
|
-
self.cwd =
|
|
1231
|
+
self.cwd = path3.resolve(cwd);
|
|
1232
1232
|
else {
|
|
1233
|
-
self.cwd =
|
|
1233
|
+
self.cwd = path3.resolve(options.cwd);
|
|
1234
1234
|
self.changedCwd = self.cwd !== cwd;
|
|
1235
1235
|
}
|
|
1236
|
-
self.root = options.root ||
|
|
1237
|
-
self.root =
|
|
1236
|
+
self.root = options.root || path3.resolve(self.cwd, "/");
|
|
1237
|
+
self.root = path3.resolve(self.root);
|
|
1238
1238
|
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
|
|
1239
1239
|
self.nomount = !!options.nomount;
|
|
1240
1240
|
if (process.platform === "win32") {
|
|
@@ -1317,30 +1317,30 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1317
1317
|
function makeAbs(self, f) {
|
|
1318
1318
|
var abs = f;
|
|
1319
1319
|
if (f.charAt(0) === "/") {
|
|
1320
|
-
abs =
|
|
1320
|
+
abs = path3.join(self.root, f);
|
|
1321
1321
|
} else if (isAbsolute(f) || f === "") {
|
|
1322
1322
|
abs = f;
|
|
1323
1323
|
} else if (self.changedCwd) {
|
|
1324
|
-
abs =
|
|
1324
|
+
abs = path3.resolve(self.cwd, f);
|
|
1325
1325
|
} else {
|
|
1326
|
-
abs =
|
|
1326
|
+
abs = path3.resolve(f);
|
|
1327
1327
|
}
|
|
1328
1328
|
if (process.platform === "win32")
|
|
1329
1329
|
abs = abs.replace(/\\/g, "/");
|
|
1330
1330
|
return abs;
|
|
1331
1331
|
}
|
|
1332
|
-
function isIgnored(self,
|
|
1332
|
+
function isIgnored(self, path4) {
|
|
1333
1333
|
if (!self.ignore.length)
|
|
1334
1334
|
return false;
|
|
1335
1335
|
return self.ignore.some(function(item) {
|
|
1336
|
-
return item.matcher.match(
|
|
1336
|
+
return item.matcher.match(path4) || !!(item.gmatcher && item.gmatcher.match(path4));
|
|
1337
1337
|
});
|
|
1338
1338
|
}
|
|
1339
|
-
function childrenIgnored(self,
|
|
1339
|
+
function childrenIgnored(self, path4) {
|
|
1340
1340
|
if (!self.ignore.length)
|
|
1341
1341
|
return false;
|
|
1342
1342
|
return self.ignore.some(function(item) {
|
|
1343
|
-
return !!(item.gmatcher && item.gmatcher.match(
|
|
1343
|
+
return !!(item.gmatcher && item.gmatcher.match(path4));
|
|
1344
1344
|
});
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
@@ -1354,7 +1354,7 @@ globstar while`, file, fr, pattern, pr, swallowee);
|
|
|
1354
1354
|
var Minimatch = minimatch.Minimatch;
|
|
1355
1355
|
var Glob = require_glob().Glob;
|
|
1356
1356
|
var util = __require("util");
|
|
1357
|
-
var
|
|
1357
|
+
var path3 = __require("path");
|
|
1358
1358
|
var assert = __require("assert");
|
|
1359
1359
|
var isAbsolute = __require("path").isAbsolute;
|
|
1360
1360
|
var common = require_common();
|
|
@@ -1484,7 +1484,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
1484
1484
|
e = prefix + e;
|
|
1485
1485
|
}
|
|
1486
1486
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
1487
|
-
e =
|
|
1487
|
+
e = path3.join(this.root, e);
|
|
1488
1488
|
}
|
|
1489
1489
|
this._emitMatch(index, e);
|
|
1490
1490
|
}
|
|
@@ -1633,9 +1633,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
1633
1633
|
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
|
1634
1634
|
var trail = /[\/\\]$/.test(prefix);
|
|
1635
1635
|
if (prefix.charAt(0) === "/") {
|
|
1636
|
-
prefix =
|
|
1636
|
+
prefix = path3.join(this.root, prefix);
|
|
1637
1637
|
} else {
|
|
1638
|
-
prefix =
|
|
1638
|
+
prefix = path3.resolve(this.root, prefix);
|
|
1639
1639
|
if (trail)
|
|
1640
1640
|
prefix += "/";
|
|
1641
1641
|
}
|
|
@@ -1822,7 +1822,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
1822
1822
|
var Minimatch = minimatch.Minimatch;
|
|
1823
1823
|
var inherits = require_inherits();
|
|
1824
1824
|
var EE = __require("events").EventEmitter;
|
|
1825
|
-
var
|
|
1825
|
+
var path3 = __require("path");
|
|
1826
1826
|
var assert = __require("assert");
|
|
1827
1827
|
var isAbsolute = __require("path").isAbsolute;
|
|
1828
1828
|
var globSync = require_sync();
|
|
@@ -2105,7 +2105,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2105
2105
|
e = prefix + e;
|
|
2106
2106
|
}
|
|
2107
2107
|
if (e.charAt(0) === "/" && !this.nomount) {
|
|
2108
|
-
e =
|
|
2108
|
+
e = path3.join(this.root, e);
|
|
2109
2109
|
}
|
|
2110
2110
|
this._emitMatch(index, e);
|
|
2111
2111
|
}
|
|
@@ -2292,9 +2292,9 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2292
2292
|
if (prefix && isAbsolute(prefix) && !this.nomount) {
|
|
2293
2293
|
var trail = /[\/\\]$/.test(prefix);
|
|
2294
2294
|
if (prefix.charAt(0) === "/") {
|
|
2295
|
-
prefix =
|
|
2295
|
+
prefix = path3.join(this.root, prefix);
|
|
2296
2296
|
} else {
|
|
2297
|
-
prefix =
|
|
2297
|
+
prefix = path3.resolve(this.root, prefix);
|
|
2298
2298
|
if (trail)
|
|
2299
2299
|
prefix += "/";
|
|
2300
2300
|
}
|
|
@@ -2387,12 +2387,27 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2387
2387
|
__export(src_exports, {
|
|
2388
2388
|
getMatchingFilePaths: () => getMatchingFilePaths,
|
|
2389
2389
|
getVirtualFileSystemFromDirPath: () => getVirtualFileSystemFromDirPath,
|
|
2390
|
-
getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath
|
|
2390
|
+
getVirtualFilesystemModuleFromDirPath: () => getVirtualFilesystemModuleFromDirPath,
|
|
2391
|
+
writeVfsToDirectory: () => writeVfsToDirectory
|
|
2391
2392
|
});
|
|
2392
2393
|
module.exports = __toCommonJS(src_exports);
|
|
2393
2394
|
var import_glob_promise = __toESM(require_lib());
|
|
2394
|
-
var
|
|
2395
|
+
var import_path2 = __toESM(__require("path"));
|
|
2395
2396
|
var import_promises = __toESM(__require("fs/promises"));
|
|
2397
|
+
var import_fs = __toESM(__require("fs"));
|
|
2398
|
+
var import_path = __toESM(__require("path"));
|
|
2399
|
+
var writeVfsToDirectory = async (opts) => {
|
|
2400
|
+
const { vfs, vfsDir, outDir } = opts;
|
|
2401
|
+
for (const [filePath, content] of Object.entries(vfs)) {
|
|
2402
|
+
if (vfsDir && !filePath.startsWith(vfsDir)) {
|
|
2403
|
+
continue;
|
|
2404
|
+
}
|
|
2405
|
+
const relativePath = vfsDir ? import_path.default.relative(vfsDir, filePath) : filePath;
|
|
2406
|
+
const outputPath = import_path.default.join(outDir, relativePath);
|
|
2407
|
+
await import_fs.default.promises.mkdir(import_path.default.dirname(outputPath), { recursive: true });
|
|
2408
|
+
await import_fs.default.promises.writeFile(outputPath, content);
|
|
2409
|
+
}
|
|
2410
|
+
};
|
|
2396
2411
|
var charsSafeToLeaveEncoded = "{}.,<>?/:'[]!@#$^&*() -_=+".split("");
|
|
2397
2412
|
var replaceSafeEncodedChars = (s) => {
|
|
2398
2413
|
for (const char of charsSafeToLeaveEncoded) {
|
|
@@ -2405,12 +2420,6 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2405
2420
|
function idsafe(s) {
|
|
2406
2421
|
return "_" + s.replace(/[^a-zA-Z0-9]/g, "_");
|
|
2407
2422
|
}
|
|
2408
|
-
var toPosixPath = (pathStr) => {
|
|
2409
|
-
if (!pathStr)
|
|
2410
|
-
return pathStr;
|
|
2411
|
-
pathStr = pathStr.replace(/^[A-Za-z]:/, "");
|
|
2412
|
-
return pathStr.split(import_path.default.sep).join("/");
|
|
2413
|
-
};
|
|
2414
2423
|
var getMatchingFilePaths = async ({
|
|
2415
2424
|
dirPath,
|
|
2416
2425
|
extensions,
|
|
@@ -2423,24 +2432,17 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2423
2432
|
}
|
|
2424
2433
|
if (!fileMatchFn)
|
|
2425
2434
|
fileMatchFn = () => true;
|
|
2426
|
-
|
|
2427
|
-
cwd: dirPath,
|
|
2428
|
-
nodir: true,
|
|
2429
|
-
dot: true,
|
|
2430
|
-
absolute: false,
|
|
2431
|
-
windowsPathsNoEscape: true
|
|
2432
|
-
});
|
|
2433
|
-
return files.map((f) => toPosixPath(f)).filter((filename) => fileMatchFn(filename, import_path.default.join(dirPath, filename)));
|
|
2435
|
+
return (await (0, import_glob_promise.default)("**/*", { cwd: dirPath, nodir: true })).filter((filename) => fileMatchFn(filename, import_path2.default.resolve(dirPath, filename)));
|
|
2434
2436
|
};
|
|
2435
2437
|
var getVirtualFileSystemFromDirPath = async (opts) => {
|
|
2436
|
-
const { dirPath, contentFormat
|
|
2438
|
+
const { dirPath, contentFormat } = opts;
|
|
2437
2439
|
const filePaths = await getMatchingFilePaths(opts);
|
|
2438
2440
|
const vfs = {};
|
|
2439
2441
|
for (const filePath of filePaths) {
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2442
|
+
vfs[filePath] = await import_promises.default.readFile(import_path2.default.resolve(dirPath, filePath));
|
|
2443
|
+
if (contentFormat === "string") {
|
|
2444
|
+
vfs[filePath] = vfs[filePath].toString();
|
|
2445
|
+
}
|
|
2444
2446
|
}
|
|
2445
2447
|
return vfs;
|
|
2446
2448
|
};
|
|
@@ -2451,7 +2453,7 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2451
2453
|
case "buffer":
|
|
2452
2454
|
case "string": {
|
|
2453
2455
|
return `export default {
|
|
2454
|
-
` + Object.entries(vfs).map(([
|
|
2456
|
+
` + Object.entries(vfs).map(([path3, content]) => cf === "buffer" ? ` "${path3}": Buffer.from("${content.toString("base64")}")` : ` "${path3}": decodeURIComponent("${replaceSafeEncodedChars(encodeURIComponent(content.toString()))}")`).join(`,
|
|
2455
2457
|
`) + `
|
|
2456
2458
|
}`;
|
|
2457
2459
|
}
|
|
@@ -2460,12 +2462,12 @@ See: https://github.com/isaacs/node-glob/issues/167`);
|
|
|
2460
2462
|
case "import-star": {
|
|
2461
2463
|
if (!opts.targetPath)
|
|
2462
2464
|
throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
|
|
2463
|
-
const basePath =
|
|
2465
|
+
const basePath = import_path2.default.relative(import_path2.default.dirname(opts.targetPath), opts.dirPath);
|
|
2464
2466
|
let fps = Object.keys(vfs);
|
|
2465
2467
|
if (opts.noImportExt) {
|
|
2466
2468
|
fps = fps.map((fp) => fp.replace(/\.[^.]+$/, ""));
|
|
2467
2469
|
}
|
|
2468
|
-
return `${fps.map((fp) => cf === "require" ? `const ${idsafe(fp)} = require("./${
|
|
2470
|
+
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(`
|
|
2469
2471
|
`)}
|
|
2470
2472
|
|
|
2471
2473
|
export default {
|
|
@@ -2478,25 +2480,10 @@ export default {
|
|
|
2478
2480
|
}
|
|
2479
2481
|
case "export-pathlist": {
|
|
2480
2482
|
return `export default [
|
|
2481
|
-
` + Object.keys(vfs).map((
|
|
2483
|
+
` + Object.keys(vfs).map((path3) => ` "${path3}"`).join(`,
|
|
2482
2484
|
`) + `
|
|
2483
2485
|
]`;
|
|
2484
2486
|
}
|
|
2485
|
-
case "import-bunfile": {
|
|
2486
|
-
if (!opts.targetPath)
|
|
2487
|
-
throw new Error(`targetPath is required when using content-format of require,import-default,import-star`);
|
|
2488
|
-
const basePath = import_path.default.relative(import_path.default.dirname(opts.targetPath), opts.dirPath);
|
|
2489
|
-
let fps = Object.keys(vfs);
|
|
2490
|
-
return `${fps.map((fp) => `import ${idsafe(fp)} from "./${import_path.default.join(basePath, fp)}" with { type: "file" };`).join(`
|
|
2491
|
-
`)}
|
|
2492
|
-
|
|
2493
|
-
import { file } from "bun";
|
|
2494
|
-
|
|
2495
|
-
export default {
|
|
2496
|
-
` + fps.map((fp) => ` "${fp}": file(${idsafe(fp)})`).join(`,
|
|
2497
|
-
`) + `
|
|
2498
|
-
}`;
|
|
2499
|
-
}
|
|
2500
2487
|
}
|
|
2501
2488
|
throw new Error(`Unknown content format: ${cf}`);
|
|
2502
2489
|
};
|
|
@@ -31913,7 +31900,7 @@ import { parentPort } from "node:worker_threads";
|
|
|
31913
31900
|
|
|
31914
31901
|
// cli/build/worker-build-handlers.ts
|
|
31915
31902
|
import fs15 from "node:fs";
|
|
31916
|
-
import
|
|
31903
|
+
import path21 from "node:path";
|
|
31917
31904
|
|
|
31918
31905
|
// lib/project-config/index.ts
|
|
31919
31906
|
import * as fs from "node:fs";
|
|
@@ -32169,8 +32156,8 @@ function formatCircuitJsonDiagnostics({
|
|
|
32169
32156
|
|
|
32170
32157
|
// lib/shared/generate-circuit-json.tsx
|
|
32171
32158
|
import fs8 from "node:fs";
|
|
32172
|
-
import
|
|
32173
|
-
import { pathToFileURL as
|
|
32159
|
+
import path10 from "node:path";
|
|
32160
|
+
import { pathToFileURL as pathToFileURL4 } from "node:url";
|
|
32174
32161
|
import Debug from "debug";
|
|
32175
32162
|
|
|
32176
32163
|
// lib/utils/abbreviate-stringify-object.ts
|
|
@@ -32963,36 +32950,1045 @@ function attachAutoroutingArtifacts(root, filePath, projectDir = process.cwd())
|
|
|
32963
32950
|
|
|
32964
32951
|
// lib/shared/importFromUserLand.ts
|
|
32965
32952
|
import { createRequire as createRequire2 } from "node:module";
|
|
32953
|
+
import path6 from "node:path";
|
|
32954
|
+
import { pathToFileURL as pathToFileURL3 } from "node:url";
|
|
32955
|
+
|
|
32956
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
32957
|
+
import assert2 from "node:assert";
|
|
32958
|
+
import { statSync as statSync2, realpathSync } from "node:fs";
|
|
32959
|
+
import process2 from "node:process";
|
|
32960
|
+
import { fileURLToPath as fileURLToPath3, pathToFileURL as pathToFileURL2 } from "node:url";
|
|
32961
|
+
import path5 from "node:path";
|
|
32962
|
+
import { builtinModules } from "node:module";
|
|
32963
|
+
|
|
32964
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
32965
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
32966
|
+
|
|
32967
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
32966
32968
|
import fs4 from "node:fs";
|
|
32967
32969
|
import path4 from "node:path";
|
|
32968
|
-
|
|
32969
|
-
|
|
32970
|
-
|
|
32971
|
-
|
|
32970
|
+
import { fileURLToPath } from "node:url";
|
|
32971
|
+
|
|
32972
|
+
// node_modules/import-meta-resolve/lib/errors.js
|
|
32973
|
+
import v8 from "node:v8";
|
|
32974
|
+
import assert from "node:assert";
|
|
32975
|
+
import { format, inspect } from "node:util";
|
|
32976
|
+
var own = {}.hasOwnProperty;
|
|
32977
|
+
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
32978
|
+
var kTypes = new Set([
|
|
32979
|
+
"string",
|
|
32980
|
+
"function",
|
|
32981
|
+
"number",
|
|
32982
|
+
"object",
|
|
32983
|
+
"Function",
|
|
32984
|
+
"Object",
|
|
32985
|
+
"boolean",
|
|
32986
|
+
"bigint",
|
|
32987
|
+
"symbol"
|
|
32988
|
+
]);
|
|
32989
|
+
var codes = {};
|
|
32990
|
+
function formatList(array, type = "and") {
|
|
32991
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array[array.length - 1]}`;
|
|
32992
|
+
}
|
|
32993
|
+
var messages = new Map;
|
|
32994
|
+
var nodeInternalPrefix = "__node_internal_";
|
|
32995
|
+
var userStackTraceLimit;
|
|
32996
|
+
codes.ERR_INVALID_ARG_TYPE = createError("ERR_INVALID_ARG_TYPE", (name, expected, actual) => {
|
|
32997
|
+
assert.ok(typeof name === "string", "'name' must be a string");
|
|
32998
|
+
if (!Array.isArray(expected)) {
|
|
32999
|
+
expected = [expected];
|
|
33000
|
+
}
|
|
33001
|
+
let message = "The ";
|
|
33002
|
+
if (name.endsWith(" argument")) {
|
|
33003
|
+
message += `${name} `;
|
|
33004
|
+
} else {
|
|
33005
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
33006
|
+
message += `"${name}" ${type} `;
|
|
33007
|
+
}
|
|
33008
|
+
message += "must be ";
|
|
33009
|
+
const types = [];
|
|
33010
|
+
const instances = [];
|
|
33011
|
+
const other = [];
|
|
33012
|
+
for (const value of expected) {
|
|
33013
|
+
assert.ok(typeof value === "string", "All expected entries have to be of type string");
|
|
33014
|
+
if (kTypes.has(value)) {
|
|
33015
|
+
types.push(value.toLowerCase());
|
|
33016
|
+
} else if (classRegExp.exec(value) === null) {
|
|
33017
|
+
assert.ok(value !== "object", 'The value "object" should be written as "Object"');
|
|
33018
|
+
other.push(value);
|
|
33019
|
+
} else {
|
|
33020
|
+
instances.push(value);
|
|
33021
|
+
}
|
|
33022
|
+
}
|
|
33023
|
+
if (instances.length > 0) {
|
|
33024
|
+
const pos = types.indexOf("object");
|
|
33025
|
+
if (pos !== -1) {
|
|
33026
|
+
types.slice(pos, 1);
|
|
33027
|
+
instances.push("Object");
|
|
33028
|
+
}
|
|
33029
|
+
}
|
|
33030
|
+
if (types.length > 0) {
|
|
33031
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(types, "or")}`;
|
|
33032
|
+
if (instances.length > 0 || other.length > 0)
|
|
33033
|
+
message += " or ";
|
|
33034
|
+
}
|
|
33035
|
+
if (instances.length > 0) {
|
|
33036
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
33037
|
+
if (other.length > 0)
|
|
33038
|
+
message += " or ";
|
|
33039
|
+
}
|
|
33040
|
+
if (other.length > 0) {
|
|
33041
|
+
if (other.length > 1) {
|
|
33042
|
+
message += `one of ${formatList(other, "or")}`;
|
|
33043
|
+
} else {
|
|
33044
|
+
if (other[0].toLowerCase() !== other[0])
|
|
33045
|
+
message += "an ";
|
|
33046
|
+
message += `${other[0]}`;
|
|
33047
|
+
}
|
|
33048
|
+
}
|
|
33049
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
33050
|
+
return message;
|
|
33051
|
+
}, TypeError);
|
|
33052
|
+
codes.ERR_INVALID_MODULE_SPECIFIER = createError("ERR_INVALID_MODULE_SPECIFIER", (request, reason, base = undefined) => {
|
|
33053
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
33054
|
+
}, TypeError);
|
|
33055
|
+
codes.ERR_INVALID_PACKAGE_CONFIG = createError("ERR_INVALID_PACKAGE_CONFIG", (path, base, message) => {
|
|
33056
|
+
return `Invalid package config ${path}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
33057
|
+
}, Error);
|
|
33058
|
+
codes.ERR_INVALID_PACKAGE_TARGET = createError("ERR_INVALID_PACKAGE_TARGET", (packagePath, key, target, isImport = false, base = undefined) => {
|
|
33059
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
33060
|
+
if (key === ".") {
|
|
33061
|
+
assert.ok(isImport === false);
|
|
33062
|
+
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 "./"' : ""}`;
|
|
33063
|
+
}
|
|
33064
|
+
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 "./"' : ""}`;
|
|
33065
|
+
}, Error);
|
|
33066
|
+
codes.ERR_MODULE_NOT_FOUND = createError("ERR_MODULE_NOT_FOUND", (path, base, exactUrl = false) => {
|
|
33067
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path}' imported from ${base}`;
|
|
33068
|
+
}, Error);
|
|
33069
|
+
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError("ERR_NETWORK_IMPORT_DISALLOWED", "import of '%s' by %s is not supported: %s", Error);
|
|
33070
|
+
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError("ERR_PACKAGE_IMPORT_NOT_DEFINED", (specifier, packagePath, base) => {
|
|
33071
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath}package.json` : ""} imported from ${base}`;
|
|
33072
|
+
}, TypeError);
|
|
33073
|
+
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError("ERR_PACKAGE_PATH_NOT_EXPORTED", (packagePath, subpath, base = undefined) => {
|
|
33074
|
+
if (subpath === ".")
|
|
33075
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
33076
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
33077
|
+
}, Error);
|
|
33078
|
+
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError("ERR_UNSUPPORTED_DIR_IMPORT", "Directory import '%s' is not supported " + "resolving ES modules imported from %s", Error);
|
|
33079
|
+
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);
|
|
33080
|
+
codes.ERR_UNKNOWN_FILE_EXTENSION = createError("ERR_UNKNOWN_FILE_EXTENSION", (extension, path) => {
|
|
33081
|
+
return `Unknown file extension "${extension}" for ${path}`;
|
|
33082
|
+
}, TypeError);
|
|
33083
|
+
codes.ERR_INVALID_ARG_VALUE = createError("ERR_INVALID_ARG_VALUE", (name, value, reason = "is invalid") => {
|
|
33084
|
+
let inspected = inspect(value);
|
|
33085
|
+
if (inspected.length > 128) {
|
|
33086
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
33087
|
+
}
|
|
33088
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
33089
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
33090
|
+
}, TypeError);
|
|
33091
|
+
function createError(sym, value, constructor) {
|
|
33092
|
+
messages.set(sym, value);
|
|
33093
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
33094
|
+
}
|
|
33095
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
33096
|
+
return NodeError;
|
|
33097
|
+
function NodeError(...parameters) {
|
|
33098
|
+
const limit = Error.stackTraceLimit;
|
|
33099
|
+
if (isErrorStackTraceLimitWritable())
|
|
33100
|
+
Error.stackTraceLimit = 0;
|
|
33101
|
+
const error = new Base;
|
|
33102
|
+
if (isErrorStackTraceLimitWritable())
|
|
33103
|
+
Error.stackTraceLimit = limit;
|
|
33104
|
+
const message = getMessage(key, parameters, error);
|
|
33105
|
+
Object.defineProperties(error, {
|
|
33106
|
+
message: {
|
|
33107
|
+
value: message,
|
|
33108
|
+
enumerable: false,
|
|
33109
|
+
writable: true,
|
|
33110
|
+
configurable: true
|
|
33111
|
+
},
|
|
33112
|
+
toString: {
|
|
33113
|
+
value() {
|
|
33114
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
33115
|
+
},
|
|
33116
|
+
enumerable: false,
|
|
33117
|
+
writable: true,
|
|
33118
|
+
configurable: true
|
|
33119
|
+
}
|
|
33120
|
+
});
|
|
33121
|
+
captureLargerStackTrace(error);
|
|
33122
|
+
error.code = key;
|
|
33123
|
+
return error;
|
|
33124
|
+
}
|
|
33125
|
+
}
|
|
33126
|
+
function isErrorStackTraceLimitWritable() {
|
|
33127
|
+
try {
|
|
33128
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
33129
|
+
return false;
|
|
33130
|
+
}
|
|
33131
|
+
} catch {}
|
|
33132
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
33133
|
+
if (desc === undefined) {
|
|
33134
|
+
return Object.isExtensible(Error);
|
|
33135
|
+
}
|
|
33136
|
+
return own.call(desc, "writable") && desc.writable !== undefined ? desc.writable : desc.set !== undefined;
|
|
33137
|
+
}
|
|
33138
|
+
function hideStackFrames(wrappedFunction) {
|
|
33139
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
33140
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
33141
|
+
return wrappedFunction;
|
|
33142
|
+
}
|
|
33143
|
+
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
33144
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
33145
|
+
if (stackTraceLimitIsWritable) {
|
|
33146
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
33147
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
33148
|
+
}
|
|
33149
|
+
Error.captureStackTrace(error);
|
|
33150
|
+
if (stackTraceLimitIsWritable)
|
|
33151
|
+
Error.stackTraceLimit = userStackTraceLimit;
|
|
33152
|
+
return error;
|
|
33153
|
+
});
|
|
33154
|
+
function getMessage(key, parameters, self) {
|
|
33155
|
+
const message = messages.get(key);
|
|
33156
|
+
assert.ok(message !== undefined, "expected `message` to be found");
|
|
33157
|
+
if (typeof message === "function") {
|
|
33158
|
+
assert.ok(message.length <= parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${message.length}).`);
|
|
33159
|
+
return Reflect.apply(message, self, parameters);
|
|
33160
|
+
}
|
|
33161
|
+
const regex = /%[dfijoOs]/g;
|
|
33162
|
+
let expectedLength = 0;
|
|
33163
|
+
while (regex.exec(message) !== null)
|
|
33164
|
+
expectedLength++;
|
|
33165
|
+
assert.ok(expectedLength === parameters.length, `Code: ${key}; The provided arguments length (${parameters.length}) does not ` + `match the required ones (${expectedLength}).`);
|
|
33166
|
+
if (parameters.length === 0)
|
|
33167
|
+
return message;
|
|
33168
|
+
parameters.unshift(message);
|
|
33169
|
+
return Reflect.apply(format, null, parameters);
|
|
33170
|
+
}
|
|
33171
|
+
function determineSpecificType(value) {
|
|
33172
|
+
if (value === null || value === undefined) {
|
|
33173
|
+
return String(value);
|
|
33174
|
+
}
|
|
33175
|
+
if (typeof value === "function" && value.name) {
|
|
33176
|
+
return `function ${value.name}`;
|
|
33177
|
+
}
|
|
33178
|
+
if (typeof value === "object") {
|
|
33179
|
+
if (value.constructor && value.constructor.name) {
|
|
33180
|
+
return `an instance of ${value.constructor.name}`;
|
|
33181
|
+
}
|
|
33182
|
+
return `${inspect(value, { depth: -1 })}`;
|
|
33183
|
+
}
|
|
33184
|
+
let inspected = inspect(value, { colors: false });
|
|
33185
|
+
if (inspected.length > 28) {
|
|
33186
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
33187
|
+
}
|
|
33188
|
+
return `type ${typeof value} (${inspected})`;
|
|
33189
|
+
}
|
|
33190
|
+
|
|
33191
|
+
// node_modules/import-meta-resolve/lib/package-json-reader.js
|
|
33192
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
33193
|
+
var { ERR_INVALID_PACKAGE_CONFIG } = codes;
|
|
33194
|
+
var cache = new Map;
|
|
33195
|
+
function read(jsonPath, { base, specifier }) {
|
|
33196
|
+
const existing = cache.get(jsonPath);
|
|
33197
|
+
if (existing) {
|
|
33198
|
+
return existing;
|
|
33199
|
+
}
|
|
33200
|
+
let string;
|
|
33201
|
+
try {
|
|
33202
|
+
string = fs4.readFileSync(path4.toNamespacedPath(jsonPath), "utf8");
|
|
33203
|
+
} catch (error) {
|
|
33204
|
+
const exception = error;
|
|
33205
|
+
if (exception.code !== "ENOENT") {
|
|
33206
|
+
throw exception;
|
|
33207
|
+
}
|
|
33208
|
+
}
|
|
33209
|
+
const result = {
|
|
33210
|
+
exists: false,
|
|
33211
|
+
pjsonPath: jsonPath,
|
|
33212
|
+
main: undefined,
|
|
33213
|
+
name: undefined,
|
|
33214
|
+
type: "none",
|
|
33215
|
+
exports: undefined,
|
|
33216
|
+
imports: undefined
|
|
33217
|
+
};
|
|
33218
|
+
if (string !== undefined) {
|
|
33219
|
+
let parsed;
|
|
32972
33220
|
try {
|
|
32973
|
-
|
|
32974
|
-
|
|
32975
|
-
|
|
32976
|
-
|
|
33221
|
+
parsed = JSON.parse(string);
|
|
33222
|
+
} catch (error_) {
|
|
33223
|
+
const cause = error_;
|
|
33224
|
+
const error = new ERR_INVALID_PACKAGE_CONFIG(jsonPath, (base ? `"${specifier}" from ` : "") + fileURLToPath(base || specifier), cause.message);
|
|
33225
|
+
error.cause = cause;
|
|
33226
|
+
throw error;
|
|
33227
|
+
}
|
|
33228
|
+
result.exists = true;
|
|
33229
|
+
if (hasOwnProperty.call(parsed, "name") && typeof parsed.name === "string") {
|
|
33230
|
+
result.name = parsed.name;
|
|
33231
|
+
}
|
|
33232
|
+
if (hasOwnProperty.call(parsed, "main") && typeof parsed.main === "string") {
|
|
33233
|
+
result.main = parsed.main;
|
|
33234
|
+
}
|
|
33235
|
+
if (hasOwnProperty.call(parsed, "exports")) {
|
|
33236
|
+
result.exports = parsed.exports;
|
|
33237
|
+
}
|
|
33238
|
+
if (hasOwnProperty.call(parsed, "imports")) {
|
|
33239
|
+
result.imports = parsed.imports;
|
|
33240
|
+
}
|
|
33241
|
+
if (hasOwnProperty.call(parsed, "type") && (parsed.type === "commonjs" || parsed.type === "module")) {
|
|
33242
|
+
result.type = parsed.type;
|
|
33243
|
+
}
|
|
33244
|
+
}
|
|
33245
|
+
cache.set(jsonPath, result);
|
|
33246
|
+
return result;
|
|
33247
|
+
}
|
|
33248
|
+
function getPackageScopeConfig(resolved) {
|
|
33249
|
+
let packageJSONUrl = new URL("package.json", resolved);
|
|
33250
|
+
while (true) {
|
|
33251
|
+
const packageJSONPath = packageJSONUrl.pathname;
|
|
33252
|
+
if (packageJSONPath.endsWith("node_modules/package.json")) {
|
|
33253
|
+
break;
|
|
33254
|
+
}
|
|
33255
|
+
const packageConfig = read(fileURLToPath(packageJSONUrl), {
|
|
33256
|
+
specifier: resolved
|
|
33257
|
+
});
|
|
33258
|
+
if (packageConfig.exists) {
|
|
33259
|
+
return packageConfig;
|
|
33260
|
+
}
|
|
33261
|
+
const lastPackageJSONUrl = packageJSONUrl;
|
|
33262
|
+
packageJSONUrl = new URL("../package.json", packageJSONUrl);
|
|
33263
|
+
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
|
|
33264
|
+
break;
|
|
33265
|
+
}
|
|
33266
|
+
}
|
|
33267
|
+
const packageJSONPath = fileURLToPath(packageJSONUrl);
|
|
33268
|
+
return {
|
|
33269
|
+
pjsonPath: packageJSONPath,
|
|
33270
|
+
exists: false,
|
|
33271
|
+
type: "none"
|
|
33272
|
+
};
|
|
33273
|
+
}
|
|
33274
|
+
function getPackageType(url) {
|
|
33275
|
+
return getPackageScopeConfig(url).type;
|
|
33276
|
+
}
|
|
33277
|
+
|
|
33278
|
+
// node_modules/import-meta-resolve/lib/get-format.js
|
|
33279
|
+
var { ERR_UNKNOWN_FILE_EXTENSION } = codes;
|
|
33280
|
+
var hasOwnProperty2 = {}.hasOwnProperty;
|
|
33281
|
+
var extensionFormatMap = {
|
|
33282
|
+
__proto__: null,
|
|
33283
|
+
".cjs": "commonjs",
|
|
33284
|
+
".js": "module",
|
|
33285
|
+
".json": "json",
|
|
33286
|
+
".mjs": "module"
|
|
33287
|
+
};
|
|
33288
|
+
function mimeToFormat(mime) {
|
|
33289
|
+
if (mime && /\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime))
|
|
33290
|
+
return "module";
|
|
33291
|
+
if (mime === "application/json")
|
|
33292
|
+
return "json";
|
|
33293
|
+
return null;
|
|
33294
|
+
}
|
|
33295
|
+
var protocolHandlers = {
|
|
33296
|
+
__proto__: null,
|
|
33297
|
+
"data:": getDataProtocolModuleFormat,
|
|
33298
|
+
"file:": getFileProtocolModuleFormat,
|
|
33299
|
+
"http:": getHttpProtocolModuleFormat,
|
|
33300
|
+
"https:": getHttpProtocolModuleFormat,
|
|
33301
|
+
"node:"() {
|
|
33302
|
+
return "builtin";
|
|
33303
|
+
}
|
|
33304
|
+
};
|
|
33305
|
+
function getDataProtocolModuleFormat(parsed) {
|
|
33306
|
+
const { 1: mime } = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(parsed.pathname) || [null, null, null];
|
|
33307
|
+
return mimeToFormat(mime);
|
|
33308
|
+
}
|
|
33309
|
+
function extname(url) {
|
|
33310
|
+
const pathname = url.pathname;
|
|
33311
|
+
let index = pathname.length;
|
|
33312
|
+
while (index--) {
|
|
33313
|
+
const code = pathname.codePointAt(index);
|
|
33314
|
+
if (code === 47) {
|
|
33315
|
+
return "";
|
|
33316
|
+
}
|
|
33317
|
+
if (code === 46) {
|
|
33318
|
+
return pathname.codePointAt(index - 1) === 47 ? "" : pathname.slice(index);
|
|
33319
|
+
}
|
|
33320
|
+
}
|
|
33321
|
+
return "";
|
|
33322
|
+
}
|
|
33323
|
+
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
|
|
33324
|
+
const value = extname(url);
|
|
33325
|
+
if (value === ".js") {
|
|
33326
|
+
const packageType = getPackageType(url);
|
|
33327
|
+
if (packageType !== "none") {
|
|
33328
|
+
return packageType;
|
|
33329
|
+
}
|
|
33330
|
+
return "commonjs";
|
|
33331
|
+
}
|
|
33332
|
+
if (value === "") {
|
|
33333
|
+
const packageType = getPackageType(url);
|
|
33334
|
+
if (packageType === "none" || packageType === "commonjs") {
|
|
33335
|
+
return "commonjs";
|
|
33336
|
+
}
|
|
33337
|
+
return "module";
|
|
33338
|
+
}
|
|
33339
|
+
const format = extensionFormatMap[value];
|
|
33340
|
+
if (format)
|
|
33341
|
+
return format;
|
|
33342
|
+
if (ignoreErrors) {
|
|
33343
|
+
return;
|
|
33344
|
+
}
|
|
33345
|
+
const filepath = fileURLToPath2(url);
|
|
33346
|
+
throw new ERR_UNKNOWN_FILE_EXTENSION(value, filepath);
|
|
33347
|
+
}
|
|
33348
|
+
function getHttpProtocolModuleFormat() {}
|
|
33349
|
+
function defaultGetFormatWithoutErrors(url, context) {
|
|
33350
|
+
const protocol = url.protocol;
|
|
33351
|
+
if (!hasOwnProperty2.call(protocolHandlers, protocol)) {
|
|
33352
|
+
return null;
|
|
33353
|
+
}
|
|
33354
|
+
return protocolHandlers[protocol](url, context, true) || null;
|
|
33355
|
+
}
|
|
33356
|
+
|
|
33357
|
+
// node_modules/import-meta-resolve/lib/utils.js
|
|
33358
|
+
var { ERR_INVALID_ARG_VALUE } = codes;
|
|
33359
|
+
var DEFAULT_CONDITIONS = Object.freeze(["node", "import"]);
|
|
33360
|
+
var DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS);
|
|
33361
|
+
function getDefaultConditions() {
|
|
33362
|
+
return DEFAULT_CONDITIONS;
|
|
33363
|
+
}
|
|
33364
|
+
function getDefaultConditionsSet() {
|
|
33365
|
+
return DEFAULT_CONDITIONS_SET;
|
|
33366
|
+
}
|
|
33367
|
+
function getConditionsSet(conditions) {
|
|
33368
|
+
if (conditions !== undefined && conditions !== getDefaultConditions()) {
|
|
33369
|
+
if (!Array.isArray(conditions)) {
|
|
33370
|
+
throw new ERR_INVALID_ARG_VALUE("conditions", conditions, "expected an array");
|
|
33371
|
+
}
|
|
33372
|
+
return new Set(conditions);
|
|
33373
|
+
}
|
|
33374
|
+
return getDefaultConditionsSet();
|
|
33375
|
+
}
|
|
33376
|
+
|
|
33377
|
+
// node_modules/import-meta-resolve/lib/resolve.js
|
|
33378
|
+
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
33379
|
+
var {
|
|
33380
|
+
ERR_NETWORK_IMPORT_DISALLOWED,
|
|
33381
|
+
ERR_INVALID_MODULE_SPECIFIER,
|
|
33382
|
+
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG2,
|
|
33383
|
+
ERR_INVALID_PACKAGE_TARGET,
|
|
33384
|
+
ERR_MODULE_NOT_FOUND,
|
|
33385
|
+
ERR_PACKAGE_IMPORT_NOT_DEFINED,
|
|
33386
|
+
ERR_PACKAGE_PATH_NOT_EXPORTED,
|
|
33387
|
+
ERR_UNSUPPORTED_DIR_IMPORT,
|
|
33388
|
+
ERR_UNSUPPORTED_RESOLVE_REQUEST
|
|
33389
|
+
} = codes;
|
|
33390
|
+
var own2 = {}.hasOwnProperty;
|
|
33391
|
+
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;
|
|
33392
|
+
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;
|
|
33393
|
+
var invalidPackageNameRegEx = /^\.|%|\\/;
|
|
33394
|
+
var patternRegEx = /\*/g;
|
|
33395
|
+
var encodedSeparatorRegEx = /%2f|%5c/i;
|
|
33396
|
+
var emittedPackageWarnings = new Set;
|
|
33397
|
+
var doubleSlashRegEx = /[/\\]{2}/;
|
|
33398
|
+
function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
|
|
33399
|
+
if (process2.noDeprecation) {
|
|
33400
|
+
return;
|
|
33401
|
+
}
|
|
33402
|
+
const pjsonPath = fileURLToPath3(packageJsonUrl);
|
|
33403
|
+
const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;
|
|
33404
|
+
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");
|
|
33405
|
+
}
|
|
33406
|
+
function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
|
|
33407
|
+
if (process2.noDeprecation) {
|
|
33408
|
+
return;
|
|
33409
|
+
}
|
|
33410
|
+
const format = defaultGetFormatWithoutErrors(url, { parentURL: base.href });
|
|
33411
|
+
if (format !== "module")
|
|
33412
|
+
return;
|
|
33413
|
+
const urlPath = fileURLToPath3(url.href);
|
|
33414
|
+
const packagePath = fileURLToPath3(new URL(".", packageJsonUrl));
|
|
33415
|
+
const basePath = fileURLToPath3(base);
|
|
33416
|
+
if (!main) {
|
|
33417
|
+
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}.
|
|
33418
|
+
Default "index" lookups for the main are deprecated for ES modules.`, "DeprecationWarning", "DEP0151");
|
|
33419
|
+
} else if (path5.resolve(packagePath, main) !== urlPath) {
|
|
33420
|
+
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}.
|
|
33421
|
+
Automatic extension resolution of the "main" field is ` + "deprecated for ES modules.", "DeprecationWarning", "DEP0151");
|
|
33422
|
+
}
|
|
33423
|
+
}
|
|
33424
|
+
function tryStatSync(path) {
|
|
33425
|
+
try {
|
|
33426
|
+
return statSync2(path);
|
|
33427
|
+
} catch {}
|
|
33428
|
+
}
|
|
33429
|
+
function fileExists(url) {
|
|
33430
|
+
const stats = statSync2(url, { throwIfNoEntry: false });
|
|
33431
|
+
const isFile = stats ? stats.isFile() : undefined;
|
|
33432
|
+
return isFile === null || isFile === undefined ? false : isFile;
|
|
33433
|
+
}
|
|
33434
|
+
function legacyMainResolve(packageJsonUrl, packageConfig, base) {
|
|
33435
|
+
let guess;
|
|
33436
|
+
if (packageConfig.main !== undefined) {
|
|
33437
|
+
guess = new URL(packageConfig.main, packageJsonUrl);
|
|
33438
|
+
if (fileExists(guess))
|
|
33439
|
+
return guess;
|
|
33440
|
+
const tries = [
|
|
33441
|
+
`./${packageConfig.main}.js`,
|
|
33442
|
+
`./${packageConfig.main}.json`,
|
|
33443
|
+
`./${packageConfig.main}.node`,
|
|
33444
|
+
`./${packageConfig.main}/index.js`,
|
|
33445
|
+
`./${packageConfig.main}/index.json`,
|
|
33446
|
+
`./${packageConfig.main}/index.node`
|
|
33447
|
+
];
|
|
33448
|
+
let i = -1;
|
|
33449
|
+
while (++i < tries.length) {
|
|
33450
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
33451
|
+
if (fileExists(guess))
|
|
33452
|
+
break;
|
|
33453
|
+
guess = undefined;
|
|
33454
|
+
}
|
|
33455
|
+
if (guess) {
|
|
33456
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
33457
|
+
return guess;
|
|
33458
|
+
}
|
|
33459
|
+
}
|
|
33460
|
+
const tries = ["./index.js", "./index.json", "./index.node"];
|
|
33461
|
+
let i = -1;
|
|
33462
|
+
while (++i < tries.length) {
|
|
33463
|
+
guess = new URL(tries[i], packageJsonUrl);
|
|
33464
|
+
if (fileExists(guess))
|
|
33465
|
+
break;
|
|
33466
|
+
guess = undefined;
|
|
33467
|
+
}
|
|
33468
|
+
if (guess) {
|
|
33469
|
+
emitLegacyIndexDeprecation(guess, packageJsonUrl, base, packageConfig.main);
|
|
33470
|
+
return guess;
|
|
33471
|
+
}
|
|
33472
|
+
throw new ERR_MODULE_NOT_FOUND(fileURLToPath3(new URL(".", packageJsonUrl)), fileURLToPath3(base));
|
|
33473
|
+
}
|
|
33474
|
+
function finalizeResolution(resolved, base, preserveSymlinks) {
|
|
33475
|
+
if (encodedSeparatorRegEx.exec(resolved.pathname) !== null) {
|
|
33476
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath3(base));
|
|
33477
|
+
}
|
|
33478
|
+
let filePath;
|
|
33479
|
+
try {
|
|
33480
|
+
filePath = fileURLToPath3(resolved);
|
|
33481
|
+
} catch (error) {
|
|
33482
|
+
const cause = error;
|
|
33483
|
+
Object.defineProperty(cause, "input", { value: String(resolved) });
|
|
33484
|
+
Object.defineProperty(cause, "module", { value: String(base) });
|
|
33485
|
+
throw cause;
|
|
33486
|
+
}
|
|
33487
|
+
const stats = tryStatSync(filePath.endsWith("/") ? filePath.slice(-1) : filePath);
|
|
33488
|
+
if (stats && stats.isDirectory()) {
|
|
33489
|
+
const error = new ERR_UNSUPPORTED_DIR_IMPORT(filePath, fileURLToPath3(base));
|
|
33490
|
+
error.url = String(resolved);
|
|
33491
|
+
throw error;
|
|
33492
|
+
}
|
|
33493
|
+
if (!stats || !stats.isFile()) {
|
|
33494
|
+
const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath3(base), true);
|
|
33495
|
+
error.url = String(resolved);
|
|
33496
|
+
throw error;
|
|
33497
|
+
}
|
|
33498
|
+
if (!preserveSymlinks) {
|
|
33499
|
+
const real = realpathSync(filePath);
|
|
33500
|
+
const { search, hash } = resolved;
|
|
33501
|
+
resolved = pathToFileURL2(real + (filePath.endsWith(path5.sep) ? "/" : ""));
|
|
33502
|
+
resolved.search = search;
|
|
33503
|
+
resolved.hash = hash;
|
|
33504
|
+
}
|
|
33505
|
+
return resolved;
|
|
33506
|
+
}
|
|
33507
|
+
function importNotDefined(specifier, packageJsonUrl, base) {
|
|
33508
|
+
return new ERR_PACKAGE_IMPORT_NOT_DEFINED(specifier, packageJsonUrl && fileURLToPath3(new URL(".", packageJsonUrl)), fileURLToPath3(base));
|
|
33509
|
+
}
|
|
33510
|
+
function exportsNotFound(subpath, packageJsonUrl, base) {
|
|
33511
|
+
return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath3(new URL(".", packageJsonUrl)), subpath, base && fileURLToPath3(base));
|
|
33512
|
+
}
|
|
33513
|
+
function throwInvalidSubpath(request, match, packageJsonUrl, internal, base) {
|
|
33514
|
+
const reason = `request is not a valid match in pattern "${match}" for the "${internal ? "imports" : "exports"}" resolution of ${fileURLToPath3(packageJsonUrl)}`;
|
|
33515
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(request, reason, base && fileURLToPath3(base));
|
|
33516
|
+
}
|
|
33517
|
+
function invalidPackageTarget(subpath, target, packageJsonUrl, internal, base) {
|
|
33518
|
+
target = typeof target === "object" && target !== null ? JSON.stringify(target, null, "") : `${target}`;
|
|
33519
|
+
return new ERR_INVALID_PACKAGE_TARGET(fileURLToPath3(new URL(".", packageJsonUrl)), subpath, target, internal, base && fileURLToPath3(base));
|
|
33520
|
+
}
|
|
33521
|
+
function resolvePackageTargetString(target, subpath, match, packageJsonUrl, base, pattern, internal, isPathMap, conditions) {
|
|
33522
|
+
if (subpath !== "" && !pattern && target[target.length - 1] !== "/")
|
|
33523
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
33524
|
+
if (!target.startsWith("./")) {
|
|
33525
|
+
if (internal && !target.startsWith("../") && !target.startsWith("/")) {
|
|
33526
|
+
let isURL = false;
|
|
33527
|
+
try {
|
|
33528
|
+
new URL(target);
|
|
33529
|
+
isURL = true;
|
|
33530
|
+
} catch {}
|
|
33531
|
+
if (!isURL) {
|
|
33532
|
+
const exportTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target + subpath;
|
|
33533
|
+
return packageResolve(exportTarget, packageJsonUrl, conditions);
|
|
33534
|
+
}
|
|
33535
|
+
}
|
|
33536
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
33537
|
+
}
|
|
33538
|
+
if (invalidSegmentRegEx.exec(target.slice(2)) !== null) {
|
|
33539
|
+
if (deprecatedInvalidSegmentRegEx.exec(target.slice(2)) === null) {
|
|
33540
|
+
if (!isPathMap) {
|
|
33541
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
33542
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
|
|
33543
|
+
emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, true);
|
|
33544
|
+
}
|
|
33545
|
+
} else {
|
|
33546
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
33547
|
+
}
|
|
33548
|
+
}
|
|
33549
|
+
const resolved = new URL(target, packageJsonUrl);
|
|
33550
|
+
const resolvedPath = resolved.pathname;
|
|
33551
|
+
const packagePath = new URL(".", packageJsonUrl).pathname;
|
|
33552
|
+
if (!resolvedPath.startsWith(packagePath))
|
|
33553
|
+
throw invalidPackageTarget(match, target, packageJsonUrl, internal, base);
|
|
33554
|
+
if (subpath === "")
|
|
33555
|
+
return resolved;
|
|
33556
|
+
if (invalidSegmentRegEx.exec(subpath) !== null) {
|
|
33557
|
+
const request = pattern ? match.replace("*", () => subpath) : match + subpath;
|
|
33558
|
+
if (deprecatedInvalidSegmentRegEx.exec(subpath) === null) {
|
|
33559
|
+
if (!isPathMap) {
|
|
33560
|
+
const resolvedTarget = pattern ? RegExpPrototypeSymbolReplace.call(patternRegEx, target, () => subpath) : target;
|
|
33561
|
+
emitInvalidSegmentDeprecation(resolvedTarget, request, match, packageJsonUrl, internal, base, false);
|
|
33562
|
+
}
|
|
33563
|
+
} else {
|
|
33564
|
+
throwInvalidSubpath(request, match, packageJsonUrl, internal, base);
|
|
33565
|
+
}
|
|
33566
|
+
}
|
|
33567
|
+
if (pattern) {
|
|
33568
|
+
return new URL(RegExpPrototypeSymbolReplace.call(patternRegEx, resolved.href, () => subpath));
|
|
33569
|
+
}
|
|
33570
|
+
return new URL(subpath, resolved);
|
|
33571
|
+
}
|
|
33572
|
+
function isArrayIndex(key) {
|
|
33573
|
+
const keyNumber = Number(key);
|
|
33574
|
+
if (`${keyNumber}` !== key)
|
|
33575
|
+
return false;
|
|
33576
|
+
return keyNumber >= 0 && keyNumber < 4294967295;
|
|
33577
|
+
}
|
|
33578
|
+
function resolvePackageTarget(packageJsonUrl, target, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions) {
|
|
33579
|
+
if (typeof target === "string") {
|
|
33580
|
+
return resolvePackageTargetString(target, subpath, packageSubpath, packageJsonUrl, base, pattern, internal, isPathMap, conditions);
|
|
33581
|
+
}
|
|
33582
|
+
if (Array.isArray(target)) {
|
|
33583
|
+
const targetList = target;
|
|
33584
|
+
if (targetList.length === 0)
|
|
33585
|
+
return null;
|
|
33586
|
+
let lastException;
|
|
33587
|
+
let i = -1;
|
|
33588
|
+
while (++i < targetList.length) {
|
|
33589
|
+
const targetItem = targetList[i];
|
|
33590
|
+
let resolveResult;
|
|
33591
|
+
try {
|
|
33592
|
+
resolveResult = resolvePackageTarget(packageJsonUrl, targetItem, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
33593
|
+
} catch (error) {
|
|
33594
|
+
const exception = error;
|
|
33595
|
+
lastException = exception;
|
|
33596
|
+
if (exception.code === "ERR_INVALID_PACKAGE_TARGET")
|
|
33597
|
+
continue;
|
|
33598
|
+
throw error;
|
|
33599
|
+
}
|
|
33600
|
+
if (resolveResult === undefined)
|
|
33601
|
+
continue;
|
|
33602
|
+
if (resolveResult === null) {
|
|
33603
|
+
lastException = null;
|
|
33604
|
+
continue;
|
|
33605
|
+
}
|
|
33606
|
+
return resolveResult;
|
|
33607
|
+
}
|
|
33608
|
+
if (lastException === undefined || lastException === null) {
|
|
33609
|
+
return null;
|
|
33610
|
+
}
|
|
33611
|
+
throw lastException;
|
|
33612
|
+
}
|
|
33613
|
+
if (typeof target === "object" && target !== null) {
|
|
33614
|
+
const keys = Object.getOwnPropertyNames(target);
|
|
33615
|
+
let i = -1;
|
|
33616
|
+
while (++i < keys.length) {
|
|
33617
|
+
const key = keys[i];
|
|
33618
|
+
if (isArrayIndex(key)) {
|
|
33619
|
+
throw new ERR_INVALID_PACKAGE_CONFIG2(fileURLToPath3(packageJsonUrl), base, '"exports" cannot contain numeric property keys.');
|
|
33620
|
+
}
|
|
33621
|
+
}
|
|
33622
|
+
i = -1;
|
|
33623
|
+
while (++i < keys.length) {
|
|
33624
|
+
const key = keys[i];
|
|
33625
|
+
if (key === "default" || conditions && conditions.has(key)) {
|
|
33626
|
+
const conditionalTarget = target[key];
|
|
33627
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, conditionalTarget, subpath, packageSubpath, base, pattern, internal, isPathMap, conditions);
|
|
33628
|
+
if (resolveResult === undefined)
|
|
33629
|
+
continue;
|
|
33630
|
+
return resolveResult;
|
|
33631
|
+
}
|
|
33632
|
+
}
|
|
33633
|
+
return null;
|
|
33634
|
+
}
|
|
33635
|
+
if (target === null) {
|
|
33636
|
+
return null;
|
|
33637
|
+
}
|
|
33638
|
+
throw invalidPackageTarget(packageSubpath, target, packageJsonUrl, internal, base);
|
|
33639
|
+
}
|
|
33640
|
+
function isConditionalExportsMainSugar(exports, packageJsonUrl, base) {
|
|
33641
|
+
if (typeof exports === "string" || Array.isArray(exports))
|
|
33642
|
+
return true;
|
|
33643
|
+
if (typeof exports !== "object" || exports === null)
|
|
33644
|
+
return false;
|
|
33645
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
33646
|
+
let isConditionalSugar = false;
|
|
33647
|
+
let i = 0;
|
|
33648
|
+
let keyIndex = -1;
|
|
33649
|
+
while (++keyIndex < keys.length) {
|
|
33650
|
+
const key = keys[keyIndex];
|
|
33651
|
+
const currentIsConditionalSugar = key === "" || key[0] !== ".";
|
|
33652
|
+
if (i++ === 0) {
|
|
33653
|
+
isConditionalSugar = currentIsConditionalSugar;
|
|
33654
|
+
} else if (isConditionalSugar !== currentIsConditionalSugar) {
|
|
33655
|
+
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.");
|
|
33656
|
+
}
|
|
33657
|
+
}
|
|
33658
|
+
return isConditionalSugar;
|
|
33659
|
+
}
|
|
33660
|
+
function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
|
|
33661
|
+
if (process2.noDeprecation) {
|
|
33662
|
+
return;
|
|
33663
|
+
}
|
|
33664
|
+
const pjsonPath = fileURLToPath3(pjsonUrl);
|
|
33665
|
+
if (emittedPackageWarnings.has(pjsonPath + "|" + match))
|
|
33666
|
+
return;
|
|
33667
|
+
emittedPackageWarnings.add(pjsonPath + "|" + match);
|
|
33668
|
+
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");
|
|
33669
|
+
}
|
|
33670
|
+
function packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions) {
|
|
33671
|
+
let exports = packageConfig.exports;
|
|
33672
|
+
if (isConditionalExportsMainSugar(exports, packageJsonUrl, base)) {
|
|
33673
|
+
exports = { ".": exports };
|
|
33674
|
+
}
|
|
33675
|
+
if (own2.call(exports, packageSubpath) && !packageSubpath.includes("*") && !packageSubpath.endsWith("/")) {
|
|
33676
|
+
const target = exports[packageSubpath];
|
|
33677
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, "", packageSubpath, base, false, false, false, conditions);
|
|
33678
|
+
if (resolveResult === null || resolveResult === undefined) {
|
|
33679
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
33680
|
+
}
|
|
33681
|
+
return resolveResult;
|
|
33682
|
+
}
|
|
33683
|
+
let bestMatch = "";
|
|
33684
|
+
let bestMatchSubpath = "";
|
|
33685
|
+
const keys = Object.getOwnPropertyNames(exports);
|
|
33686
|
+
let i = -1;
|
|
33687
|
+
while (++i < keys.length) {
|
|
33688
|
+
const key = keys[i];
|
|
33689
|
+
const patternIndex = key.indexOf("*");
|
|
33690
|
+
if (patternIndex !== -1 && packageSubpath.startsWith(key.slice(0, patternIndex))) {
|
|
33691
|
+
if (packageSubpath.endsWith("/")) {
|
|
33692
|
+
emitTrailingSlashPatternDeprecation(packageSubpath, packageJsonUrl, base);
|
|
33693
|
+
}
|
|
33694
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
33695
|
+
if (packageSubpath.length >= key.length && packageSubpath.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
33696
|
+
bestMatch = key;
|
|
33697
|
+
bestMatchSubpath = packageSubpath.slice(patternIndex, packageSubpath.length - patternTrailer.length);
|
|
33698
|
+
}
|
|
33699
|
+
}
|
|
33700
|
+
}
|
|
33701
|
+
if (bestMatch) {
|
|
33702
|
+
const target = exports[bestMatch];
|
|
33703
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, false, packageSubpath.endsWith("/"), conditions);
|
|
33704
|
+
if (resolveResult === null || resolveResult === undefined) {
|
|
33705
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
33706
|
+
}
|
|
33707
|
+
return resolveResult;
|
|
33708
|
+
}
|
|
33709
|
+
throw exportsNotFound(packageSubpath, packageJsonUrl, base);
|
|
33710
|
+
}
|
|
33711
|
+
function patternKeyCompare(a, b) {
|
|
33712
|
+
const aPatternIndex = a.indexOf("*");
|
|
33713
|
+
const bPatternIndex = b.indexOf("*");
|
|
33714
|
+
const baseLengthA = aPatternIndex === -1 ? a.length : aPatternIndex + 1;
|
|
33715
|
+
const baseLengthB = bPatternIndex === -1 ? b.length : bPatternIndex + 1;
|
|
33716
|
+
if (baseLengthA > baseLengthB)
|
|
33717
|
+
return -1;
|
|
33718
|
+
if (baseLengthB > baseLengthA)
|
|
33719
|
+
return 1;
|
|
33720
|
+
if (aPatternIndex === -1)
|
|
33721
|
+
return 1;
|
|
33722
|
+
if (bPatternIndex === -1)
|
|
33723
|
+
return -1;
|
|
33724
|
+
if (a.length > b.length)
|
|
33725
|
+
return -1;
|
|
33726
|
+
if (b.length > a.length)
|
|
33727
|
+
return 1;
|
|
33728
|
+
return 0;
|
|
33729
|
+
}
|
|
33730
|
+
function packageImportsResolve(name, base, conditions) {
|
|
33731
|
+
if (name === "#" || name.startsWith("#/") || name.endsWith("/")) {
|
|
33732
|
+
const reason = "is not a valid internal imports specifier name";
|
|
33733
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(name, reason, fileURLToPath3(base));
|
|
33734
|
+
}
|
|
33735
|
+
let packageJsonUrl;
|
|
33736
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
33737
|
+
if (packageConfig.exists) {
|
|
33738
|
+
packageJsonUrl = pathToFileURL2(packageConfig.pjsonPath);
|
|
33739
|
+
const imports = packageConfig.imports;
|
|
33740
|
+
if (imports) {
|
|
33741
|
+
if (own2.call(imports, name) && !name.includes("*")) {
|
|
33742
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, imports[name], "", name, base, false, true, false, conditions);
|
|
33743
|
+
if (resolveResult !== null && resolveResult !== undefined) {
|
|
33744
|
+
return resolveResult;
|
|
33745
|
+
}
|
|
33746
|
+
} else {
|
|
33747
|
+
let bestMatch = "";
|
|
33748
|
+
let bestMatchSubpath = "";
|
|
33749
|
+
const keys = Object.getOwnPropertyNames(imports);
|
|
33750
|
+
let i = -1;
|
|
33751
|
+
while (++i < keys.length) {
|
|
33752
|
+
const key = keys[i];
|
|
33753
|
+
const patternIndex = key.indexOf("*");
|
|
33754
|
+
if (patternIndex !== -1 && name.startsWith(key.slice(0, -1))) {
|
|
33755
|
+
const patternTrailer = key.slice(patternIndex + 1);
|
|
33756
|
+
if (name.length >= key.length && name.endsWith(patternTrailer) && patternKeyCompare(bestMatch, key) === 1 && key.lastIndexOf("*") === patternIndex) {
|
|
33757
|
+
bestMatch = key;
|
|
33758
|
+
bestMatchSubpath = name.slice(patternIndex, name.length - patternTrailer.length);
|
|
33759
|
+
}
|
|
33760
|
+
}
|
|
33761
|
+
}
|
|
33762
|
+
if (bestMatch) {
|
|
33763
|
+
const target = imports[bestMatch];
|
|
33764
|
+
const resolveResult = resolvePackageTarget(packageJsonUrl, target, bestMatchSubpath, bestMatch, base, true, true, false, conditions);
|
|
33765
|
+
if (resolveResult !== null && resolveResult !== undefined) {
|
|
33766
|
+
return resolveResult;
|
|
33767
|
+
}
|
|
33768
|
+
}
|
|
33769
|
+
}
|
|
33770
|
+
}
|
|
33771
|
+
}
|
|
33772
|
+
throw importNotDefined(name, packageJsonUrl, base);
|
|
33773
|
+
}
|
|
33774
|
+
function parsePackageName(specifier, base) {
|
|
33775
|
+
let separatorIndex = specifier.indexOf("/");
|
|
33776
|
+
let validPackageName = true;
|
|
33777
|
+
let isScoped = false;
|
|
33778
|
+
if (specifier[0] === "@") {
|
|
33779
|
+
isScoped = true;
|
|
33780
|
+
if (separatorIndex === -1 || specifier.length === 0) {
|
|
33781
|
+
validPackageName = false;
|
|
33782
|
+
} else {
|
|
33783
|
+
separatorIndex = specifier.indexOf("/", separatorIndex + 1);
|
|
33784
|
+
}
|
|
33785
|
+
}
|
|
33786
|
+
const packageName = separatorIndex === -1 ? specifier : specifier.slice(0, separatorIndex);
|
|
33787
|
+
if (invalidPackageNameRegEx.exec(packageName) !== null) {
|
|
33788
|
+
validPackageName = false;
|
|
33789
|
+
}
|
|
33790
|
+
if (!validPackageName) {
|
|
33791
|
+
throw new ERR_INVALID_MODULE_SPECIFIER(specifier, "is not a valid package name", fileURLToPath3(base));
|
|
33792
|
+
}
|
|
33793
|
+
const packageSubpath = "." + (separatorIndex === -1 ? "" : specifier.slice(separatorIndex));
|
|
33794
|
+
return { packageName, packageSubpath, isScoped };
|
|
33795
|
+
}
|
|
33796
|
+
function packageResolve(specifier, base, conditions) {
|
|
33797
|
+
if (builtinModules.includes(specifier)) {
|
|
33798
|
+
return new URL("node:" + specifier);
|
|
33799
|
+
}
|
|
33800
|
+
const { packageName, packageSubpath, isScoped } = parsePackageName(specifier, base);
|
|
33801
|
+
const packageConfig = getPackageScopeConfig(base);
|
|
33802
|
+
if (packageConfig.exists) {
|
|
33803
|
+
const packageJsonUrl = pathToFileURL2(packageConfig.pjsonPath);
|
|
33804
|
+
if (packageConfig.name === packageName && packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
|
33805
|
+
return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
33806
|
+
}
|
|
33807
|
+
}
|
|
33808
|
+
let packageJsonUrl = new URL("./node_modules/" + packageName + "/package.json", base);
|
|
33809
|
+
let packageJsonPath = fileURLToPath3(packageJsonUrl);
|
|
33810
|
+
let lastPath;
|
|
33811
|
+
do {
|
|
33812
|
+
const stat = tryStatSync(packageJsonPath.slice(0, -13));
|
|
33813
|
+
if (!stat || !stat.isDirectory()) {
|
|
33814
|
+
lastPath = packageJsonPath;
|
|
33815
|
+
packageJsonUrl = new URL((isScoped ? "../../../../node_modules/" : "../../../node_modules/") + packageName + "/package.json", packageJsonUrl);
|
|
33816
|
+
packageJsonPath = fileURLToPath3(packageJsonUrl);
|
|
33817
|
+
continue;
|
|
33818
|
+
}
|
|
33819
|
+
const packageConfig = read(packageJsonPath, { base, specifier });
|
|
33820
|
+
if (packageConfig.exports !== undefined && packageConfig.exports !== null) {
|
|
33821
|
+
return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);
|
|
33822
|
+
}
|
|
33823
|
+
if (packageSubpath === ".") {
|
|
33824
|
+
return legacyMainResolve(packageJsonUrl, packageConfig, base);
|
|
33825
|
+
}
|
|
33826
|
+
return new URL(packageSubpath, packageJsonUrl);
|
|
33827
|
+
} while (packageJsonPath.length !== lastPath.length);
|
|
33828
|
+
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath3(base), false);
|
|
33829
|
+
}
|
|
33830
|
+
function isRelativeSpecifier(specifier) {
|
|
33831
|
+
if (specifier[0] === ".") {
|
|
33832
|
+
if (specifier.length === 1 || specifier[1] === "/")
|
|
33833
|
+
return true;
|
|
33834
|
+
if (specifier[1] === "." && (specifier.length === 2 || specifier[2] === "/")) {
|
|
33835
|
+
return true;
|
|
33836
|
+
}
|
|
33837
|
+
}
|
|
33838
|
+
return false;
|
|
33839
|
+
}
|
|
33840
|
+
function shouldBeTreatedAsRelativeOrAbsolutePath(specifier) {
|
|
33841
|
+
if (specifier === "")
|
|
33842
|
+
return false;
|
|
33843
|
+
if (specifier[0] === "/")
|
|
33844
|
+
return true;
|
|
33845
|
+
return isRelativeSpecifier(specifier);
|
|
33846
|
+
}
|
|
33847
|
+
function moduleResolve(specifier, base, conditions, preserveSymlinks) {
|
|
33848
|
+
if (conditions === undefined) {
|
|
33849
|
+
conditions = getConditionsSet();
|
|
33850
|
+
}
|
|
33851
|
+
const protocol = base.protocol;
|
|
33852
|
+
const isData = protocol === "data:";
|
|
33853
|
+
const isRemote = isData || protocol === "http:" || protocol === "https:";
|
|
33854
|
+
let resolved;
|
|
33855
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
33856
|
+
try {
|
|
33857
|
+
resolved = new URL(specifier, base);
|
|
33858
|
+
} catch (error_) {
|
|
33859
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
33860
|
+
error.cause = error_;
|
|
33861
|
+
throw error;
|
|
33862
|
+
}
|
|
33863
|
+
} else if (protocol === "file:" && specifier[0] === "#") {
|
|
33864
|
+
resolved = packageImportsResolve(specifier, base, conditions);
|
|
33865
|
+
} else {
|
|
33866
|
+
try {
|
|
33867
|
+
resolved = new URL(specifier);
|
|
33868
|
+
} catch (error_) {
|
|
33869
|
+
if (isRemote && !builtinModules.includes(specifier)) {
|
|
33870
|
+
const error = new ERR_UNSUPPORTED_RESOLVE_REQUEST(specifier, base);
|
|
33871
|
+
error.cause = error_;
|
|
32977
33872
|
throw error;
|
|
32978
33873
|
}
|
|
33874
|
+
resolved = packageResolve(specifier, base, conditions);
|
|
33875
|
+
}
|
|
33876
|
+
}
|
|
33877
|
+
assert2.ok(resolved !== undefined, "expected to be defined");
|
|
33878
|
+
if (resolved.protocol !== "file:") {
|
|
33879
|
+
return resolved;
|
|
33880
|
+
}
|
|
33881
|
+
return finalizeResolution(resolved, base, preserveSymlinks);
|
|
33882
|
+
}
|
|
33883
|
+
function checkIfDisallowedImport(specifier, parsed, parsedParentURL) {
|
|
33884
|
+
if (parsedParentURL) {
|
|
33885
|
+
const parentProtocol = parsedParentURL.protocol;
|
|
33886
|
+
if (parentProtocol === "http:" || parentProtocol === "https:") {
|
|
33887
|
+
if (shouldBeTreatedAsRelativeOrAbsolutePath(specifier)) {
|
|
33888
|
+
const parsedProtocol = parsed?.protocol;
|
|
33889
|
+
if (parsedProtocol && parsedProtocol !== "https:" && parsedProtocol !== "http:") {
|
|
33890
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
|
|
33891
|
+
}
|
|
33892
|
+
return { url: parsed?.href || "" };
|
|
33893
|
+
}
|
|
33894
|
+
if (builtinModules.includes(specifier)) {
|
|
33895
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "remote imports cannot import from a local location.");
|
|
33896
|
+
}
|
|
33897
|
+
throw new ERR_NETWORK_IMPORT_DISALLOWED(specifier, parsedParentURL, "only relative and absolute specifiers are supported.");
|
|
33898
|
+
}
|
|
33899
|
+
}
|
|
33900
|
+
}
|
|
33901
|
+
function isURL(self) {
|
|
33902
|
+
return Boolean(self && typeof self === "object" && "href" in self && typeof self.href === "string" && "protocol" in self && typeof self.protocol === "string" && self.href && self.protocol);
|
|
33903
|
+
}
|
|
33904
|
+
function throwIfInvalidParentURL(parentURL) {
|
|
33905
|
+
if (parentURL === undefined) {
|
|
33906
|
+
return;
|
|
33907
|
+
}
|
|
33908
|
+
if (typeof parentURL !== "string" && !isURL(parentURL)) {
|
|
33909
|
+
throw new codes.ERR_INVALID_ARG_TYPE("parentURL", ["string", "URL"], parentURL);
|
|
33910
|
+
}
|
|
33911
|
+
}
|
|
33912
|
+
function defaultResolve(specifier, context = {}) {
|
|
33913
|
+
const { parentURL } = context;
|
|
33914
|
+
assert2.ok(parentURL !== undefined, "expected `parentURL` to be defined");
|
|
33915
|
+
throwIfInvalidParentURL(parentURL);
|
|
33916
|
+
let parsedParentURL;
|
|
33917
|
+
if (parentURL) {
|
|
33918
|
+
try {
|
|
33919
|
+
parsedParentURL = new URL(parentURL);
|
|
33920
|
+
} catch {}
|
|
33921
|
+
}
|
|
33922
|
+
let parsed;
|
|
33923
|
+
let protocol;
|
|
33924
|
+
try {
|
|
33925
|
+
parsed = shouldBeTreatedAsRelativeOrAbsolutePath(specifier) ? new URL(specifier, parsedParentURL) : new URL(specifier);
|
|
33926
|
+
protocol = parsed.protocol;
|
|
33927
|
+
if (protocol === "data:") {
|
|
33928
|
+
return { url: parsed.href, format: null };
|
|
32979
33929
|
}
|
|
33930
|
+
} catch {}
|
|
33931
|
+
const maybeReturn = checkIfDisallowedImport(specifier, parsed, parsedParentURL);
|
|
33932
|
+
if (maybeReturn)
|
|
33933
|
+
return maybeReturn;
|
|
33934
|
+
if (protocol === undefined && parsed) {
|
|
33935
|
+
protocol = parsed.protocol;
|
|
33936
|
+
}
|
|
33937
|
+
if (protocol === "node:") {
|
|
33938
|
+
return { url: specifier };
|
|
33939
|
+
}
|
|
33940
|
+
if (parsed && parsed.protocol === "node:")
|
|
33941
|
+
return { url: specifier };
|
|
33942
|
+
const conditions = getConditionsSet(context.conditions);
|
|
33943
|
+
const url = moduleResolve(specifier, new URL(parentURL), conditions, false);
|
|
33944
|
+
return {
|
|
33945
|
+
url: url.href,
|
|
33946
|
+
format: defaultGetFormatWithoutErrors(url, { parentURL })
|
|
33947
|
+
};
|
|
33948
|
+
}
|
|
33949
|
+
|
|
33950
|
+
// node_modules/import-meta-resolve/index.js
|
|
33951
|
+
function resolve(specifier, parent) {
|
|
33952
|
+
if (!parent) {
|
|
33953
|
+
throw new Error("Please pass `parent`: `import-meta-resolve` cannot ponyfill that");
|
|
32980
33954
|
}
|
|
32981
|
-
const cliRequire = createRequire2(import.meta.url);
|
|
32982
33955
|
try {
|
|
32983
|
-
|
|
32984
|
-
return await import(resolvedCliPath);
|
|
33956
|
+
return defaultResolve(specifier, { parentURL: parent }).url;
|
|
32985
33957
|
} catch (error) {
|
|
32986
|
-
|
|
32987
|
-
|
|
33958
|
+
const exception = error;
|
|
33959
|
+
if ((exception.code === "ERR_UNSUPPORTED_DIR_IMPORT" || exception.code === "ERR_MODULE_NOT_FOUND") && typeof exception.url === "string") {
|
|
33960
|
+
return exception.url;
|
|
32988
33961
|
}
|
|
33962
|
+
throw error;
|
|
33963
|
+
}
|
|
33964
|
+
}
|
|
33965
|
+
|
|
33966
|
+
// lib/shared/importFromUserLand.ts
|
|
33967
|
+
async function importFromUserLand(moduleName, projectDir = process.cwd()) {
|
|
33968
|
+
for (const parent of [
|
|
33969
|
+
pathToFileURL3(path6.join(projectDir, "noop.js")).href,
|
|
33970
|
+
import.meta.url
|
|
33971
|
+
]) {
|
|
33972
|
+
let resolved;
|
|
33973
|
+
try {
|
|
33974
|
+
resolved = resolve(moduleName, parent);
|
|
33975
|
+
} catch (error) {
|
|
33976
|
+
if (error?.code === "ERR_PACKAGE_PATH_NOT_EXPORTED") {
|
|
33977
|
+
resolved = pathToFileURL3(createRequire2(parent).resolve(moduleName)).href;
|
|
33978
|
+
} else if (error?.code === "ERR_MODULE_NOT_FOUND") {
|
|
33979
|
+
continue;
|
|
33980
|
+
} else {
|
|
33981
|
+
throw error;
|
|
33982
|
+
}
|
|
33983
|
+
}
|
|
33984
|
+
return import(resolved);
|
|
32989
33985
|
}
|
|
32990
33986
|
return import(moduleName);
|
|
32991
33987
|
}
|
|
32992
33988
|
|
|
32993
33989
|
// lib/shared/register-static-asset-loaders.ts
|
|
32994
33990
|
import fs5 from "node:fs";
|
|
32995
|
-
import
|
|
33991
|
+
import path7 from "node:path";
|
|
32996
33992
|
var STATIC_ASSET_EXTENSIONS = [
|
|
32997
33993
|
".glb",
|
|
32998
33994
|
".gltf",
|
|
@@ -33019,7 +34015,7 @@ var TEXT_STATIC_ASSET_EXTENSIONS = new Set([
|
|
|
33019
34015
|
".kicad_sym"
|
|
33020
34016
|
]);
|
|
33021
34017
|
var readFileContentForStaticLoader = (filePath) => {
|
|
33022
|
-
const ext =
|
|
34018
|
+
const ext = path7.extname(filePath).toLowerCase();
|
|
33023
34019
|
if (TEXT_STATIC_ASSET_EXTENSIONS.has(ext)) {
|
|
33024
34020
|
return fs5.readFileSync(filePath, "utf-8");
|
|
33025
34021
|
}
|
|
@@ -33027,7 +34023,7 @@ var readFileContentForStaticLoader = (filePath) => {
|
|
|
33027
34023
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
33028
34024
|
};
|
|
33029
34025
|
var getStaticFileLoader = (filePath) => {
|
|
33030
|
-
const extWithDot =
|
|
34026
|
+
const extWithDot = path7.extname(filePath).toLowerCase();
|
|
33031
34027
|
const ext = extWithDot.replace(/^\./, "");
|
|
33032
34028
|
return activePlatformConfig?.staticFileLoaderMap?.[ext] ?? activePlatformConfig?.staticFileLoaderMap?.[extWithDot];
|
|
33033
34029
|
};
|
|
@@ -33041,7 +34037,7 @@ var normalizeStaticFileLoaderResult = (result) => {
|
|
|
33041
34037
|
};
|
|
33042
34038
|
};
|
|
33043
34039
|
var getBaseUrlFromTsConfig = (projectDir) => {
|
|
33044
|
-
const tsconfigPath =
|
|
34040
|
+
const tsconfigPath = path7.join(projectDir, "tsconfig.json");
|
|
33045
34041
|
try {
|
|
33046
34042
|
if (!fs5.existsSync(tsconfigPath)) {
|
|
33047
34043
|
return null;
|
|
@@ -33073,8 +34069,8 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
33073
34069
|
loader: "object"
|
|
33074
34070
|
};
|
|
33075
34071
|
}
|
|
33076
|
-
const baseDir = baseUrl ?
|
|
33077
|
-
const relativePath =
|
|
34072
|
+
const baseDir = baseUrl ? path7.resolve(projectDir, baseUrl) : projectDir;
|
|
34073
|
+
const relativePath = path7.relative(baseDir, args.path).split(path7.sep).join("/");
|
|
33078
34074
|
const pathStr = `./${relativePath}`;
|
|
33079
34075
|
return {
|
|
33080
34076
|
exports: {
|
|
@@ -33091,7 +34087,7 @@ var registerStaticAssetLoaders = (platformConfig, projectDir = process.cwd()) =>
|
|
|
33091
34087
|
|
|
33092
34088
|
// lib/shared/circuit-json-build-cache.ts
|
|
33093
34089
|
import fs6 from "node:fs";
|
|
33094
|
-
import
|
|
34090
|
+
import path8 from "node:path";
|
|
33095
34091
|
import { createHash as createHash2 } from "node:crypto";
|
|
33096
34092
|
var SOURCE_FILE_EXTENSIONS = new Set([
|
|
33097
34093
|
".tsx",
|
|
@@ -33115,43 +34111,43 @@ var IGNORED_DIRECTORY_NAMES = new Set([
|
|
|
33115
34111
|
".git"
|
|
33116
34112
|
]);
|
|
33117
34113
|
var isPathInside = (childPath, parentPath) => {
|
|
33118
|
-
const relative =
|
|
33119
|
-
return relative === "" || !relative.startsWith("..") && !
|
|
34114
|
+
const relative = path8.relative(parentPath, childPath);
|
|
34115
|
+
return relative === "" || !relative.startsWith("..") && !path8.isAbsolute(relative);
|
|
33120
34116
|
};
|
|
33121
34117
|
var findCircuitProjectDir = (filePath) => {
|
|
33122
|
-
const absoluteFilePath =
|
|
33123
|
-
let currentDir =
|
|
34118
|
+
const absoluteFilePath = path8.resolve(filePath);
|
|
34119
|
+
let currentDir = path8.dirname(absoluteFilePath);
|
|
33124
34120
|
while (true) {
|
|
33125
|
-
if (fs6.existsSync(
|
|
34121
|
+
if (fs6.existsSync(path8.join(currentDir, "package.json"))) {
|
|
33126
34122
|
return currentDir;
|
|
33127
34123
|
}
|
|
33128
|
-
const parentDir =
|
|
34124
|
+
const parentDir = path8.dirname(currentDir);
|
|
33129
34125
|
if (parentDir === currentDir)
|
|
33130
34126
|
break;
|
|
33131
34127
|
currentDir = parentDir;
|
|
33132
34128
|
}
|
|
33133
|
-
const cwd =
|
|
33134
|
-
return isPathInside(absoluteFilePath, cwd) ? cwd :
|
|
34129
|
+
const cwd = path8.resolve(process.cwd());
|
|
34130
|
+
return isPathInside(absoluteFilePath, cwd) ? cwd : path8.dirname(absoluteFilePath);
|
|
33135
34131
|
};
|
|
33136
34132
|
var getCircuitJsonOutputDirName = (relativePath) => {
|
|
33137
34133
|
const normalizedRelativePath = relativePath.toLowerCase().replaceAll("\\", "/");
|
|
33138
34134
|
if (normalizedRelativePath === "circuit.json" || normalizedRelativePath.endsWith("/circuit.json")) {
|
|
33139
|
-
return
|
|
34135
|
+
return path8.dirname(relativePath);
|
|
33140
34136
|
}
|
|
33141
34137
|
return relativePath.replace(/(\.board|\.circuit)?\.tsx$/, "").replace(/\.circuit\.json$/, "");
|
|
33142
34138
|
};
|
|
33143
34139
|
var getCircuitJsonBuildOutputPath = (filePath) => {
|
|
33144
|
-
const absoluteFilePath =
|
|
34140
|
+
const absoluteFilePath = path8.resolve(filePath);
|
|
33145
34141
|
const projectDir = findCircuitProjectDir(absoluteFilePath);
|
|
33146
|
-
const relativePath =
|
|
33147
|
-
return
|
|
34142
|
+
const relativePath = path8.relative(projectDir, absoluteFilePath);
|
|
34143
|
+
return path8.join(projectDir, "dist", getCircuitJsonOutputDirName(relativePath), "circuit.json");
|
|
33148
34144
|
};
|
|
33149
34145
|
var getSourceFilePaths = (projectDir) => {
|
|
33150
34146
|
const sourceFilePaths = [];
|
|
33151
34147
|
const visit = (directoryPath) => {
|
|
33152
34148
|
const entries = fs6.readdirSync(directoryPath, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
33153
34149
|
for (const entry of entries) {
|
|
33154
|
-
const entryPath =
|
|
34150
|
+
const entryPath = path8.join(directoryPath, entry.name);
|
|
33155
34151
|
if (entry.isDirectory()) {
|
|
33156
34152
|
if (IGNORED_DIRECTORY_NAMES.has(entry.name) || entry.name.startsWith(".")) {
|
|
33157
34153
|
continue;
|
|
@@ -33159,7 +34155,7 @@ var getSourceFilePaths = (projectDir) => {
|
|
|
33159
34155
|
visit(entryPath);
|
|
33160
34156
|
continue;
|
|
33161
34157
|
}
|
|
33162
|
-
if (!entry.isFile() || entry.name.endsWith(".circuit.json") || !SOURCE_FILE_EXTENSIONS.has(
|
|
34158
|
+
if (!entry.isFile() || entry.name.endsWith(".circuit.json") || !SOURCE_FILE_EXTENSIONS.has(path8.extname(entry.name).toLowerCase())) {
|
|
33163
34159
|
continue;
|
|
33164
34160
|
}
|
|
33165
34161
|
sourceFilePaths.push(entryPath);
|
|
@@ -33172,7 +34168,7 @@ var getSourceFilesystemMd5Hash = (filePath) => {
|
|
|
33172
34168
|
const projectDir = findCircuitProjectDir(filePath);
|
|
33173
34169
|
const hash = createHash2("md5");
|
|
33174
34170
|
for (const sourceFilePath of getSourceFilePaths(projectDir)) {
|
|
33175
|
-
const relativePath =
|
|
34171
|
+
const relativePath = path8.relative(projectDir, sourceFilePath).split(path8.sep).join("/");
|
|
33176
34172
|
const content = fs6.readFileSync(sourceFilePath);
|
|
33177
34173
|
hash.update(`${Buffer.byteLength(relativePath)}:`);
|
|
33178
34174
|
hash.update(relativePath);
|
|
@@ -33223,7 +34219,7 @@ var readCurrentCircuitJsonBuild = ({
|
|
|
33223
34219
|
|
|
33224
34220
|
// lib/shared/solver-diagnostics.ts
|
|
33225
34221
|
import fs7 from "node:fs";
|
|
33226
|
-
import
|
|
34222
|
+
import path9 from "node:path";
|
|
33227
34223
|
var escapeJsonPointerSegment = (segment) => segment.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
33228
34224
|
var cloneAsJson = (value, ancestors = new WeakMap, path = "#") => {
|
|
33229
34225
|
if (value === undefined)
|
|
@@ -33324,7 +34320,7 @@ class SolverDiagnostics {
|
|
|
33324
34320
|
finalize() {
|
|
33325
34321
|
if (!this.options.enabled)
|
|
33326
34322
|
return;
|
|
33327
|
-
fs7.mkdirSync(
|
|
34323
|
+
fs7.mkdirSync(path9.dirname(this.options.outputPath), { recursive: true });
|
|
33328
34324
|
fs7.writeFileSync(this.options.outputPath, `${JSON.stringify({
|
|
33329
34325
|
format: "tscircuit_solver_debug_v1",
|
|
33330
34326
|
entrypoint: this.options.entrypoint,
|
|
@@ -33368,7 +34364,7 @@ async function generateCircuitJson({
|
|
|
33368
34364
|
}) {
|
|
33369
34365
|
debug(`Generating circuit JSON for ${filePath}`);
|
|
33370
34366
|
const currentSourceFilesystemMd5Hash = sourceFilesystemMd5Hash ?? getSourceFilesystemMd5Hash(filePath);
|
|
33371
|
-
const projectRootDir =
|
|
34367
|
+
const projectRootDir = path10.resolve(projectDirOption ?? process.cwd());
|
|
33372
34368
|
const React = await importFromUserLand("react", projectRootDir);
|
|
33373
34369
|
globalThis.React = React;
|
|
33374
34370
|
registerStaticAssetLoaders(platformConfig, projectRootDir);
|
|
@@ -33381,12 +34377,12 @@ async function generateCircuitJson({
|
|
|
33381
34377
|
const solverDiagnostics = solverDiagnosticsOptions ? new SolverDiagnostics(solverDiagnosticsOptions) : null;
|
|
33382
34378
|
solverDiagnostics?.attachToRootCircuit(runner);
|
|
33383
34379
|
attachAutoroutingArtifacts(runner, filePath, projectRootDir);
|
|
33384
|
-
const absoluteFilePath =
|
|
33385
|
-
const sourceDir =
|
|
34380
|
+
const absoluteFilePath = path10.isAbsolute(filePath) ? filePath : path10.resolve(projectRootDir, filePath);
|
|
34381
|
+
const sourceDir = path10.dirname(absoluteFilePath);
|
|
33386
34382
|
const resolvedOutputDir = outputDir ?? sourceDir;
|
|
33387
|
-
const relativeComponentPath =
|
|
33388
|
-
const baseFileName = outputFileName ||
|
|
33389
|
-
const outputPath =
|
|
34383
|
+
const relativeComponentPath = path10.relative(sourceDir, absoluteFilePath);
|
|
34384
|
+
const baseFileName = outputFileName || path10.basename(absoluteFilePath).replace(/\.[^.]+$/, "");
|
|
34385
|
+
const outputPath = path10.join(resolvedOutputDir, `${baseFileName}.circuit.json`);
|
|
33390
34386
|
debug(`Project directory: ${sourceDir}`);
|
|
33391
34387
|
debug(`Relative component path: ${relativeComponentPath}`);
|
|
33392
34388
|
debug(`Output path: ${outputPath}`);
|
|
@@ -33406,7 +34402,7 @@ async function generateCircuitJson({
|
|
|
33406
34402
|
return false;
|
|
33407
34403
|
if (normalizedFilePath.match(/^\.[^/]/))
|
|
33408
34404
|
return false;
|
|
33409
|
-
if (!ALLOWED_FILE_EXTENSIONS.includes(
|
|
34405
|
+
if (!ALLOWED_FILE_EXTENSIONS.includes(path10.extname(normalizedFilePath)))
|
|
33410
34406
|
return false;
|
|
33411
34407
|
return true;
|
|
33412
34408
|
},
|
|
@@ -33414,32 +34410,41 @@ async function generateCircuitJson({
|
|
|
33414
34410
|
})
|
|
33415
34411
|
};
|
|
33416
34412
|
debug(`fsMap: ${abbreviateStringifyObject(fsMap)}`);
|
|
33417
|
-
const MainComponent = await import(
|
|
33418
|
-
|
|
33419
|
-
if (
|
|
33420
|
-
|
|
33421
|
-
}
|
|
33422
|
-
|
|
33423
|
-
|
|
33424
|
-
|
|
33425
|
-
|
|
33426
|
-
|
|
33427
|
-
|
|
33428
|
-
|
|
33429
|
-
|
|
33430
|
-
|
|
33431
|
-
|
|
34413
|
+
const MainComponent = await import(pathToFileURL4(absoluteFilePath).href);
|
|
34414
|
+
let records;
|
|
34415
|
+
if (Array.isArray(MainComponent.circuitJson)) {
|
|
34416
|
+
records = MainComponent.circuitJson;
|
|
34417
|
+
} else {
|
|
34418
|
+
const namedComponent = Object.keys(MainComponent).find((key) => key[0] === key[0].toUpperCase());
|
|
34419
|
+
const Component = MainComponent.default || (namedComponent ? MainComponent[namedComponent] : undefined);
|
|
34420
|
+
if (!Component) {
|
|
34421
|
+
throw new Error(`No component found in "${absoluteFilePath}". Make sure you export a component.`);
|
|
34422
|
+
}
|
|
34423
|
+
runner.add(/* @__PURE__ */ jsxDEV(Component, {
|
|
34424
|
+
...injectedProps ?? {}
|
|
34425
|
+
}, undefined, false, undefined, this));
|
|
34426
|
+
runner.render();
|
|
34427
|
+
const loggedAsyncEffectNames = new Set;
|
|
34428
|
+
while (!runner.isDoneRendering()) {
|
|
34429
|
+
for (const asyncEffect of runner.getRunningAsyncEffects()) {
|
|
34430
|
+
const asyncEffectName = asyncEffect.effectName;
|
|
34431
|
+
if (!asyncEffectName || loggedAsyncEffectNames.has(asyncEffectName)) {
|
|
34432
|
+
continue;
|
|
34433
|
+
}
|
|
34434
|
+
loggedAsyncEffectNames.add(asyncEffectName);
|
|
34435
|
+
onAsyncEffectStatus?.(asyncEffectName);
|
|
33432
34436
|
}
|
|
33433
|
-
|
|
33434
|
-
|
|
34437
|
+
autorouterDiagnostics.checkTimeout();
|
|
34438
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
34439
|
+
runner.render();
|
|
33435
34440
|
}
|
|
33436
|
-
|
|
33437
|
-
|
|
33438
|
-
runner.
|
|
34441
|
+
runner.emit("renderComplete");
|
|
34442
|
+
solverDiagnostics?.finalize();
|
|
34443
|
+
const hasImportedBoard = runner.children.some((component) => [component, ...component.getDescendants()].some((instance) => instance[Symbol.for("pcb-spice-pipeline.imported-board.v2")]));
|
|
34444
|
+
records = hasImportedBoard ? (await importFromUserLand("@tscircuit/pcb-spice-pipeline/tsx", projectRootDir)).serializeSimulation(runner) : await runner.getCircuitJson();
|
|
33439
34445
|
}
|
|
33440
|
-
|
|
33441
|
-
|
|
33442
|
-
const circuitJson = addSourceFilesystemHash(await runner.getCircuitJson(), currentSourceFilesystemMd5Hash);
|
|
34446
|
+
const modeling = MainComponent.modeling;
|
|
34447
|
+
const circuitJson = addSourceFilesystemHash(records, currentSourceFilesystemMd5Hash);
|
|
33443
34448
|
await autorouterDiagnostics.finalize(circuitJson);
|
|
33444
34449
|
if (saveToFile) {
|
|
33445
34450
|
debug(`Saving circuit JSON to ${outputPath}`);
|
|
@@ -33448,14 +34453,15 @@ async function generateCircuitJson({
|
|
|
33448
34453
|
return {
|
|
33449
34454
|
circuitJson,
|
|
33450
34455
|
outputPath,
|
|
33451
|
-
rootCircuit: runner
|
|
34456
|
+
rootCircuit: runner,
|
|
34457
|
+
modeling
|
|
33452
34458
|
};
|
|
33453
34459
|
}
|
|
33454
34460
|
|
|
33455
34461
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
33456
34462
|
import { createHash as createHash3 } from "node:crypto";
|
|
33457
34463
|
import fs9 from "node:fs";
|
|
33458
|
-
import
|
|
34464
|
+
import path11 from "node:path";
|
|
33459
34465
|
import { getPlatformConfig } from "@tscircuit/eval/platform-config";
|
|
33460
34466
|
|
|
33461
34467
|
// lib/shared/platform-config-utils.ts
|
|
@@ -33516,13 +34522,13 @@ var getPlatformFetch = (upstreamFetch = globalThis.fetch) => {
|
|
|
33516
34522
|
};
|
|
33517
34523
|
|
|
33518
34524
|
// lib/shared/get-platform-config-with-cli-defaults.ts
|
|
33519
|
-
function createLocalCacheEngine(cacheDir =
|
|
34525
|
+
function createLocalCacheEngine(cacheDir = path11.join(process.cwd(), ".tscircuit", "cache")) {
|
|
33520
34526
|
return {
|
|
33521
34527
|
getItem: (key) => {
|
|
33522
34528
|
try {
|
|
33523
34529
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
33524
34530
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
33525
|
-
const filePath =
|
|
34531
|
+
const filePath = path11.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
33526
34532
|
return fs9.readFileSync(filePath, "utf-8");
|
|
33527
34533
|
} catch {
|
|
33528
34534
|
return null;
|
|
@@ -33533,7 +34539,7 @@ function createLocalCacheEngine(cacheDir = path9.join(process.cwd(), ".tscircuit
|
|
|
33533
34539
|
fs9.mkdirSync(cacheDir, { recursive: true });
|
|
33534
34540
|
const hash = createHash3("md5").update(key).digest("hex");
|
|
33535
34541
|
const keyWithSafeCharacters = key.replace(/[^a-zA-Z0-9]/g, "_");
|
|
33536
|
-
const filePath =
|
|
34542
|
+
const filePath = path11.join(cacheDir, `${keyWithSafeCharacters.slice(keyWithSafeCharacters.length - 10, keyWithSafeCharacters.length)}-${hash}.json`);
|
|
33537
34543
|
fs9.writeFileSync(filePath, value);
|
|
33538
34544
|
} catch {}
|
|
33539
34545
|
}
|
|
@@ -33542,7 +34548,7 @@ function createLocalCacheEngine(cacheDir = path9.join(process.cwd(), ".tscircuit
|
|
|
33542
34548
|
function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
33543
34549
|
const projectDir = options?.projectDir ?? process.cwd();
|
|
33544
34550
|
const basePlatformConfig = getPlatformConfig();
|
|
33545
|
-
const cacheDir =
|
|
34551
|
+
const cacheDir = path11.join(projectDir, ".tscircuit", "cache");
|
|
33546
34552
|
const defaultConfig = {
|
|
33547
34553
|
...basePlatformConfig,
|
|
33548
34554
|
checkAvailability: true,
|
|
@@ -33553,14 +34559,14 @@ function getPlatformConfigWithCliDefaults(userConfig, options) {
|
|
|
33553
34559
|
loadFromUrl: async (url) => {
|
|
33554
34560
|
let fetchUrl = url;
|
|
33555
34561
|
if (url.startsWith("./") || url.startsWith("../")) {
|
|
33556
|
-
const absolutePath =
|
|
34562
|
+
const absolutePath = path11.resolve(projectDir, url);
|
|
33557
34563
|
fetchUrl = `file://${absolutePath}`;
|
|
33558
34564
|
} else if (url.startsWith("/")) {
|
|
33559
34565
|
if (fs9.existsSync(url)) {
|
|
33560
34566
|
fetchUrl = `file://${url}`;
|
|
33561
34567
|
} else {
|
|
33562
34568
|
const relativePath = `.${url}`;
|
|
33563
|
-
const absolutePath =
|
|
34569
|
+
const absolutePath = path11.resolve(projectDir, relativePath);
|
|
33564
34570
|
if (fs9.existsSync(absolutePath)) {
|
|
33565
34571
|
fetchUrl = `file://${absolutePath}`;
|
|
33566
34572
|
} else {
|
|
@@ -33819,7 +34825,7 @@ function convertCircuitJsonToPcbSvg2(elements, options = {}) {
|
|
|
33819
34825
|
|
|
33820
34826
|
// cli/build/worker-output-generators.ts
|
|
33821
34827
|
import fs14 from "node:fs";
|
|
33822
|
-
import
|
|
34828
|
+
import path20 from "node:path";
|
|
33823
34829
|
|
|
33824
34830
|
// node_modules/circuit-json-to-3d-png/dist/index.js
|
|
33825
34831
|
function normalizeDir(dir) {
|
|
@@ -50554,7 +51560,7 @@ import { convertCircuitJsonToSchematicSvg } from "circuit-to-svg";
|
|
|
50554
51560
|
// lib/shared/load-local-step-model-fs-map.ts
|
|
50555
51561
|
import { existsSync as existsSync2 } from "node:fs";
|
|
50556
51562
|
import { readFile } from "node:fs/promises";
|
|
50557
|
-
import
|
|
51563
|
+
import path12 from "node:path";
|
|
50558
51564
|
var isRemoteUrl = (value) => /^https?:\/\//i.test(value);
|
|
50559
51565
|
async function loadLocalStepModelFsMap(circuitJson) {
|
|
50560
51566
|
const fsMap = {};
|
|
@@ -50566,7 +51572,7 @@ async function loadLocalStepModelFsMap(circuitJson) {
|
|
|
50566
51572
|
continue;
|
|
50567
51573
|
if (isRemoteUrl(modelUrl) || fsMap[modelUrl])
|
|
50568
51574
|
continue;
|
|
50569
|
-
const localPath =
|
|
51575
|
+
const localPath = path12.resolve(process.cwd(), modelUrl);
|
|
50570
51576
|
if (!existsSync2(localPath))
|
|
50571
51577
|
continue;
|
|
50572
51578
|
fsMap[modelUrl] = await readFile(localPath, "utf-8");
|
|
@@ -50641,11 +51647,11 @@ var getSimulationSvgAssetsFromCircuitJson = (circuitJson) => {
|
|
|
50641
51647
|
|
|
50642
51648
|
// node_modules/conf/dist/source/index.js
|
|
50643
51649
|
import { isDeepStrictEqual } from "node:util";
|
|
50644
|
-
import
|
|
51650
|
+
import process8 from "node:process";
|
|
50645
51651
|
import fs11 from "node:fs";
|
|
50646
|
-
import
|
|
51652
|
+
import path16 from "node:path";
|
|
50647
51653
|
import crypto from "node:crypto";
|
|
50648
|
-
import
|
|
51654
|
+
import assert3 from "node:assert";
|
|
50649
51655
|
|
|
50650
51656
|
// node_modules/dot-prop/index.js
|
|
50651
51657
|
var isObject = (value) => {
|
|
@@ -50863,41 +51869,41 @@ function hasProperty(object, path) {
|
|
|
50863
51869
|
}
|
|
50864
51870
|
|
|
50865
51871
|
// node_modules/env-paths/index.js
|
|
50866
|
-
import
|
|
51872
|
+
import path13 from "node:path";
|
|
50867
51873
|
import os from "node:os";
|
|
50868
|
-
import
|
|
51874
|
+
import process3 from "node:process";
|
|
50869
51875
|
var homedir = os.homedir();
|
|
50870
51876
|
var tmpdir = os.tmpdir();
|
|
50871
|
-
var { env } =
|
|
51877
|
+
var { env } = process3;
|
|
50872
51878
|
var macos = (name) => {
|
|
50873
|
-
const library =
|
|
51879
|
+
const library = path13.join(homedir, "Library");
|
|
50874
51880
|
return {
|
|
50875
|
-
data:
|
|
50876
|
-
config:
|
|
50877
|
-
cache:
|
|
50878
|
-
log:
|
|
50879
|
-
temp:
|
|
51881
|
+
data: path13.join(library, "Application Support", name),
|
|
51882
|
+
config: path13.join(library, "Preferences", name),
|
|
51883
|
+
cache: path13.join(library, "Caches", name),
|
|
51884
|
+
log: path13.join(library, "Logs", name),
|
|
51885
|
+
temp: path13.join(tmpdir, name)
|
|
50880
51886
|
};
|
|
50881
51887
|
};
|
|
50882
51888
|
var windows = (name) => {
|
|
50883
|
-
const appData = env.APPDATA ||
|
|
50884
|
-
const localAppData = env.LOCALAPPDATA ||
|
|
51889
|
+
const appData = env.APPDATA || path13.join(homedir, "AppData", "Roaming");
|
|
51890
|
+
const localAppData = env.LOCALAPPDATA || path13.join(homedir, "AppData", "Local");
|
|
50885
51891
|
return {
|
|
50886
|
-
data:
|
|
50887
|
-
config:
|
|
50888
|
-
cache:
|
|
50889
|
-
log:
|
|
50890
|
-
temp:
|
|
51892
|
+
data: path13.join(localAppData, name, "Data"),
|
|
51893
|
+
config: path13.join(appData, name, "Config"),
|
|
51894
|
+
cache: path13.join(localAppData, name, "Cache"),
|
|
51895
|
+
log: path13.join(localAppData, name, "Log"),
|
|
51896
|
+
temp: path13.join(tmpdir, name)
|
|
50891
51897
|
};
|
|
50892
51898
|
};
|
|
50893
51899
|
var linux = (name) => {
|
|
50894
|
-
const username =
|
|
51900
|
+
const username = path13.basename(homedir);
|
|
50895
51901
|
return {
|
|
50896
|
-
data:
|
|
50897
|
-
config:
|
|
50898
|
-
cache:
|
|
50899
|
-
log:
|
|
50900
|
-
temp:
|
|
51902
|
+
data: path13.join(env.XDG_DATA_HOME || path13.join(homedir, ".local", "share"), name),
|
|
51903
|
+
config: path13.join(env.XDG_CONFIG_HOME || path13.join(homedir, ".config"), name),
|
|
51904
|
+
cache: path13.join(env.XDG_CACHE_HOME || path13.join(homedir, ".cache"), name),
|
|
51905
|
+
log: path13.join(env.XDG_STATE_HOME || path13.join(homedir, ".local", "state"), name),
|
|
51906
|
+
temp: path13.join(tmpdir, username, name)
|
|
50901
51907
|
};
|
|
50902
51908
|
};
|
|
50903
51909
|
function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
@@ -50907,17 +51913,17 @@ function envPaths(name, { suffix = "nodejs" } = {}) {
|
|
|
50907
51913
|
if (suffix) {
|
|
50908
51914
|
name += `-${suffix}`;
|
|
50909
51915
|
}
|
|
50910
|
-
if (
|
|
51916
|
+
if (process3.platform === "darwin") {
|
|
50911
51917
|
return macos(name);
|
|
50912
51918
|
}
|
|
50913
|
-
if (
|
|
51919
|
+
if (process3.platform === "win32") {
|
|
50914
51920
|
return windows(name);
|
|
50915
51921
|
}
|
|
50916
51922
|
return linux(name);
|
|
50917
51923
|
}
|
|
50918
51924
|
|
|
50919
51925
|
// node_modules/atomically/dist/index.js
|
|
50920
|
-
import
|
|
51926
|
+
import path15 from "node:path";
|
|
50921
51927
|
|
|
50922
51928
|
// node_modules/stubborn-fs/dist/index.js
|
|
50923
51929
|
import fs10 from "node:fs";
|
|
@@ -50998,7 +52004,7 @@ var retryifySync = (fn, options) => {
|
|
|
50998
52004
|
var retryify_sync_default = retryifySync;
|
|
50999
52005
|
|
|
51000
52006
|
// node_modules/stubborn-fs/dist/constants.js
|
|
51001
|
-
import
|
|
52007
|
+
import process4 from "node:process";
|
|
51002
52008
|
|
|
51003
52009
|
// node_modules/stubborn-fs/dist/handlers.js
|
|
51004
52010
|
var Handlers = {
|
|
@@ -51042,7 +52048,7 @@ var ATTEMPTIFY_NOOP_OPTIONS = {
|
|
|
51042
52048
|
return;
|
|
51043
52049
|
}
|
|
51044
52050
|
};
|
|
51045
|
-
var IS_USER_ROOT =
|
|
52051
|
+
var IS_USER_ROOT = process4.getuid ? !process4.getuid() : false;
|
|
51046
52052
|
var RETRYIFY_OPTIONS = {
|
|
51047
52053
|
isRetriable: handlers_default.isRetriableError
|
|
51048
52054
|
};
|
|
@@ -51090,16 +52096,16 @@ var FS = {
|
|
|
51090
52096
|
var dist_default = FS;
|
|
51091
52097
|
|
|
51092
52098
|
// node_modules/atomically/dist/constants.js
|
|
51093
|
-
import
|
|
52099
|
+
import process5 from "node:process";
|
|
51094
52100
|
var DEFAULT_ENCODING = "utf8";
|
|
51095
52101
|
var DEFAULT_FILE_MODE = 438;
|
|
51096
52102
|
var DEFAULT_FOLDER_MODE = 511;
|
|
51097
52103
|
var DEFAULT_WRITE_OPTIONS = {};
|
|
51098
|
-
var DEFAULT_USER_UID =
|
|
51099
|
-
var DEFAULT_USER_GID =
|
|
52104
|
+
var DEFAULT_USER_UID = process5.geteuid ? process5.geteuid() : -1;
|
|
52105
|
+
var DEFAULT_USER_GID = process5.getegid ? process5.getegid() : -1;
|
|
51100
52106
|
var DEFAULT_TIMEOUT_SYNC = 1000;
|
|
51101
|
-
var IS_POSIX = !!
|
|
51102
|
-
var IS_USER_ROOT2 =
|
|
52107
|
+
var IS_POSIX = !!process5.getuid;
|
|
52108
|
+
var IS_USER_ROOT2 = process5.getuid ? !process5.getuid() : false;
|
|
51103
52109
|
var LIMIT_BASENAME_LENGTH = 128;
|
|
51104
52110
|
|
|
51105
52111
|
// node_modules/atomically/dist/utils/lang.js
|
|
@@ -51114,15 +52120,15 @@ var isUndefined = (value) => {
|
|
|
51114
52120
|
};
|
|
51115
52121
|
|
|
51116
52122
|
// node_modules/atomically/dist/utils/temp.js
|
|
51117
|
-
import
|
|
52123
|
+
import path14 from "node:path";
|
|
51118
52124
|
|
|
51119
52125
|
// node_modules/when-exit/dist/node/interceptor.js
|
|
51120
|
-
import
|
|
52126
|
+
import process7 from "node:process";
|
|
51121
52127
|
|
|
51122
52128
|
// node_modules/when-exit/dist/node/constants.js
|
|
51123
|
-
import
|
|
51124
|
-
var IS_LINUX =
|
|
51125
|
-
var IS_WINDOWS =
|
|
52129
|
+
import process6 from "node:process";
|
|
52130
|
+
var IS_LINUX = process6.platform === "linux";
|
|
52131
|
+
var IS_WINDOWS = process6.platform === "win32";
|
|
51126
52132
|
|
|
51127
52133
|
// node_modules/when-exit/dist/node/signals.js
|
|
51128
52134
|
var Signals = ["SIGHUP", "SIGINT", "SIGTERM"];
|
|
@@ -51148,17 +52154,17 @@ class Interceptor {
|
|
|
51148
52154
|
}
|
|
51149
52155
|
if (signal) {
|
|
51150
52156
|
if (IS_WINDOWS && (signal !== "SIGINT" && signal !== "SIGTERM" && signal !== "SIGKILL")) {
|
|
51151
|
-
|
|
52157
|
+
process7.kill(process7.pid, "SIGTERM");
|
|
51152
52158
|
} else {
|
|
51153
|
-
|
|
52159
|
+
process7.kill(process7.pid, signal);
|
|
51154
52160
|
}
|
|
51155
52161
|
}
|
|
51156
52162
|
};
|
|
51157
52163
|
this.hook = () => {
|
|
51158
|
-
|
|
52164
|
+
process7.once("exit", () => this.exit());
|
|
51159
52165
|
for (const signal of signals_default) {
|
|
51160
52166
|
try {
|
|
51161
|
-
|
|
52167
|
+
process7.once(signal, () => this.exit(signal));
|
|
51162
52168
|
} catch {}
|
|
51163
52169
|
}
|
|
51164
52170
|
};
|
|
@@ -51214,7 +52220,7 @@ var Temp = {
|
|
|
51214
52220
|
}
|
|
51215
52221
|
},
|
|
51216
52222
|
truncate: (filePath) => {
|
|
51217
|
-
const basename =
|
|
52223
|
+
const basename = path14.basename(filePath);
|
|
51218
52224
|
if (basename.length <= LIMIT_BASENAME_LENGTH)
|
|
51219
52225
|
return filePath;
|
|
51220
52226
|
const truncable = /^(\.?)(.*?)((?:\.[^.]+)?(?:\.tmp-\d{10}[a-f0-9]{6})?)$/.exec(basename);
|
|
@@ -51256,7 +52262,7 @@ function writeFileSync2(filePath, data, options = DEFAULT_WRITE_OPTIONS) {
|
|
|
51256
52262
|
}
|
|
51257
52263
|
}
|
|
51258
52264
|
if (!filePathExists) {
|
|
51259
|
-
const parentPath =
|
|
52265
|
+
const parentPath = path15.dirname(filePath);
|
|
51260
52266
|
dist_default.attempt.mkdirSync(parentPath, {
|
|
51261
52267
|
mode: DEFAULT_FOLDER_MODE,
|
|
51262
52268
|
recursive: true
|
|
@@ -51572,7 +52578,7 @@ class Conf {
|
|
|
51572
52578
|
this.events = new EventTarget;
|
|
51573
52579
|
this.#encryptionKey = options.encryptionKey;
|
|
51574
52580
|
const fileExtension = options.fileExtension ? `.${options.fileExtension}` : "";
|
|
51575
|
-
this.path =
|
|
52581
|
+
this.path = path16.resolve(options.cwd, `${options.configName ?? "config"}${fileExtension}`);
|
|
51576
52582
|
const fileStore = this.store;
|
|
51577
52583
|
const store = Object.assign(createPlainObject(), options.defaults, fileStore);
|
|
51578
52584
|
if (options.migrations) {
|
|
@@ -51583,7 +52589,7 @@ class Conf {
|
|
|
51583
52589
|
}
|
|
51584
52590
|
this._validate(store);
|
|
51585
52591
|
try {
|
|
51586
|
-
|
|
52592
|
+
assert3.deepEqual(fileStore, store);
|
|
51587
52593
|
} catch {
|
|
51588
52594
|
this.store = store;
|
|
51589
52595
|
}
|
|
@@ -51746,7 +52752,7 @@ class Conf {
|
|
|
51746
52752
|
throw new Error("Config schema violation: " + errors.join("; "));
|
|
51747
52753
|
}
|
|
51748
52754
|
_ensureDirectory() {
|
|
51749
|
-
fs11.mkdirSync(
|
|
52755
|
+
fs11.mkdirSync(path16.dirname(this.path), { recursive: true });
|
|
51750
52756
|
}
|
|
51751
52757
|
_write(value) {
|
|
51752
52758
|
let data = this._serialize(value);
|
|
@@ -51756,7 +52762,7 @@ class Conf {
|
|
|
51756
52762
|
const cipher = crypto.createCipheriv(encryptionAlgorithm, password, initializationVector);
|
|
51757
52763
|
data = concatUint8Arrays([initializationVector, stringToUint8Array(":"), cipher.update(stringToUint8Array(data)), cipher.final()]);
|
|
51758
52764
|
}
|
|
51759
|
-
if (
|
|
52765
|
+
if (process8.env.SNAP) {
|
|
51760
52766
|
fs11.writeFileSync(this.path, data, { mode: this.#options.configFileMode });
|
|
51761
52767
|
} else {
|
|
51762
52768
|
try {
|
|
@@ -51775,7 +52781,7 @@ class Conf {
|
|
|
51775
52781
|
if (!fs11.existsSync(this.path)) {
|
|
51776
52782
|
this._write(createPlainObject());
|
|
51777
52783
|
}
|
|
51778
|
-
if (
|
|
52784
|
+
if (process8.platform === "win32") {
|
|
51779
52785
|
fs11.watch(this.path, { persistent: false }, debounce_fn_default(() => {
|
|
51780
52786
|
this.events.dispatchEvent(new Event("change"));
|
|
51781
52787
|
}, { wait: 100 }));
|
|
@@ -51918,12 +52924,12 @@ function jwtDecode(token, options) {
|
|
|
51918
52924
|
// lib/cli-config/index.ts
|
|
51919
52925
|
import fs13 from "node:fs";
|
|
51920
52926
|
import os3 from "node:os";
|
|
51921
|
-
import
|
|
52927
|
+
import path18 from "node:path";
|
|
51922
52928
|
|
|
51923
52929
|
// lib/shared/handle-registry-auth-error.ts
|
|
51924
52930
|
import fs12 from "node:fs";
|
|
51925
52931
|
import os2 from "node:os";
|
|
51926
|
-
import
|
|
52932
|
+
import path17 from "node:path";
|
|
51927
52933
|
var AUTH_TOKEN_REGEX = /^\/\/npm\.tscircuit\.com\/:_authToken=(.+)$/m;
|
|
51928
52934
|
function isUnauthorizedError(error) {
|
|
51929
52935
|
const output = [
|
|
@@ -51956,8 +52962,8 @@ function handleRegistryAuthError({
|
|
|
51956
52962
|
if (!isUnauthorizedError(error))
|
|
51957
52963
|
return;
|
|
51958
52964
|
const npmrcPaths = [
|
|
51959
|
-
|
|
51960
|
-
|
|
52965
|
+
path17.join(projectDir, ".npmrc"),
|
|
52966
|
+
path17.join(os2.homedir(), ".npmrc")
|
|
51961
52967
|
];
|
|
51962
52968
|
const hasToken = npmrcPaths.some(hasTsciAuthToken);
|
|
51963
52969
|
if (hasToken) {
|
|
@@ -51980,8 +52986,8 @@ var getSessionToken = () => {
|
|
|
51980
52986
|
};
|
|
51981
52987
|
var getSessionTokenFromNpmrc = () => {
|
|
51982
52988
|
const npmrcPaths = [
|
|
51983
|
-
|
|
51984
|
-
|
|
52989
|
+
path18.join(process.cwd(), ".npmrc"),
|
|
52990
|
+
path18.join(os3.homedir(), ".npmrc")
|
|
51985
52991
|
];
|
|
51986
52992
|
for (const npmrcPath of npmrcPaths) {
|
|
51987
52993
|
if (!fs13.existsSync(npmrcPath))
|
|
@@ -52024,8 +53030,8 @@ var getCircuitJsonToGltfOptions = ({
|
|
|
52024
53030
|
};
|
|
52025
53031
|
|
|
52026
53032
|
// cli/build/convert-model-urls-to-file-urls.ts
|
|
52027
|
-
import
|
|
52028
|
-
import { pathToFileURL as
|
|
53033
|
+
import path19 from "node:path";
|
|
53034
|
+
import { pathToFileURL as pathToFileURL5 } from "node:url";
|
|
52029
53035
|
var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
52030
53036
|
const modelUrlKeys = [
|
|
52031
53037
|
"model_glb_url",
|
|
@@ -52049,9 +53055,9 @@ var convertModelUrlsToFileUrls = (circuitJson) => {
|
|
|
52049
53055
|
if (value.match(/^[a-zA-Z]+:\/\//))
|
|
52050
53056
|
continue;
|
|
52051
53057
|
if (value.startsWith("/") || value.match(/^[a-zA-Z]:\\/)) {
|
|
52052
|
-
updated[key] =
|
|
53058
|
+
updated[key] = pathToFileURL5(value).href;
|
|
52053
53059
|
} else if (value.startsWith(".")) {
|
|
52054
|
-
updated[key] =
|
|
53060
|
+
updated[key] = pathToFileURL5(path19.resolve(process.cwd(), value)).href;
|
|
52055
53061
|
}
|
|
52056
53062
|
}
|
|
52057
53063
|
}
|
|
@@ -52092,12 +53098,12 @@ var writeSimulationSvgAssetsFromCircuitJson = (circuitJson, outputDir, imageForm
|
|
|
52092
53098
|
for (const simulationSvgAsset of simulationSvgAssets) {
|
|
52093
53099
|
if (imageFormats.simulationSvgs) {
|
|
52094
53100
|
const fileName = hasMultipleSimulations ? `simulation-${simulationSvgAsset.fileNameSuffix}.svg` : "simulation.svg";
|
|
52095
|
-
fs14.writeFileSync(
|
|
53101
|
+
fs14.writeFileSync(path20.join(outputDir, fileName), simulationSvgAsset.simulationSvg, "utf-8");
|
|
52096
53102
|
simulationFileNames.push(fileName);
|
|
52097
53103
|
}
|
|
52098
53104
|
if (imageFormats.simulationSchematicSvgs) {
|
|
52099
53105
|
const fileName = hasMultipleSimulations ? `simulation-schematic-${simulationSvgAsset.fileNameSuffix}.svg` : "simulation-schematic.svg";
|
|
52100
|
-
fs14.writeFileSync(
|
|
53106
|
+
fs14.writeFileSync(path20.join(outputDir, fileName), simulationSvgAsset.schematicSimulationSvg, "utf-8");
|
|
52101
53107
|
schematicSimulationFileNames.push(fileName);
|
|
52102
53108
|
}
|
|
52103
53109
|
}
|
|
@@ -52107,7 +53113,7 @@ var writeGlbFromCircuitJson = async (circuitJson, glbOutputPath) => {
|
|
|
52107
53113
|
const circuitJsonWithFileUrls = convertModelUrlsToFileUrls(circuitJson);
|
|
52108
53114
|
const glbBuffer = await convertCircuitJsonToGltf(circuitJsonWithFileUrls, getCircuitJsonToGltfOptions({ format: "glb" }));
|
|
52109
53115
|
const glbData = normalizeToUint8Array2(glbBuffer);
|
|
52110
|
-
fs14.mkdirSync(
|
|
53116
|
+
fs14.mkdirSync(path20.dirname(glbOutputPath), { recursive: true });
|
|
52111
53117
|
fs14.writeFileSync(glbOutputPath, Buffer.from(glbData));
|
|
52112
53118
|
};
|
|
52113
53119
|
var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
@@ -52117,7 +53123,7 @@ var writeStepFromCircuitJson = async (circuitJson, stepOutputPath) => {
|
|
|
52117
53123
|
includeExternalMeshes: true,
|
|
52118
53124
|
fsMap: await loadLocalStepModelFsMap(circuitJson)
|
|
52119
53125
|
});
|
|
52120
|
-
fs14.mkdirSync(
|
|
53126
|
+
fs14.mkdirSync(path20.dirname(stepOutputPath), { recursive: true });
|
|
52121
53127
|
fs14.writeFileSync(stepOutputPath, stepContent);
|
|
52122
53128
|
};
|
|
52123
53129
|
var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
@@ -52126,30 +53132,30 @@ var writeImageAssetsFromCircuitJson = async (circuitJson, options) => {
|
|
|
52126
53132
|
const hasSchematic = circuitJson.some((e) => e.type.startsWith("schematic_"));
|
|
52127
53133
|
if (!hasSchematic) {
|
|
52128
53134
|
if (imageFormats.schematicSvgs)
|
|
52129
|
-
fs14.rmSync(
|
|
53135
|
+
fs14.rmSync(path20.join(outputDir, "schematic.svg"), { force: true });
|
|
52130
53136
|
if (imageFormats.schematicPngs)
|
|
52131
|
-
fs14.rmSync(
|
|
53137
|
+
fs14.rmSync(path20.join(outputDir, "schematic.png"), { force: true });
|
|
52132
53138
|
}
|
|
52133
53139
|
if (imageFormats.pcbSvgs) {
|
|
52134
53140
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
52135
|
-
fs14.writeFileSync(
|
|
53141
|
+
fs14.writeFileSync(path20.join(outputDir, "pcb.svg"), pcbSvg, "utf-8");
|
|
52136
53142
|
}
|
|
52137
53143
|
if (imageFormats.pcbPngs) {
|
|
52138
53144
|
const pcbSvg = convertCircuitJsonToPcbSvg2(circuitJson, pcbSnapshotSettings);
|
|
52139
|
-
fs14.writeFileSync(
|
|
53145
|
+
fs14.writeFileSync(path20.join(outputDir, "pcb.png"), await convertSvgToPngBuffer(pcbSvg));
|
|
52140
53146
|
}
|
|
52141
53147
|
if (imageFormats.schematicSvgs && hasSchematic) {
|
|
52142
53148
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
52143
|
-
fs14.writeFileSync(
|
|
53149
|
+
fs14.writeFileSync(path20.join(outputDir, "schematic.svg"), schematicSvg, "utf-8");
|
|
52144
53150
|
}
|
|
52145
53151
|
if (imageFormats.schematicPngs && hasSchematic) {
|
|
52146
53152
|
const schematicSvg = convertCircuitJsonToSchematicSvg(circuitJson);
|
|
52147
|
-
fs14.writeFileSync(
|
|
53153
|
+
fs14.writeFileSync(path20.join(outputDir, "schematic.png"), await convertSvgToPngBuffer(schematicSvg));
|
|
52148
53154
|
}
|
|
52149
53155
|
writeSimulationSvgAssetsFromCircuitJson(circuitJson, outputDir, imageFormats);
|
|
52150
53156
|
if (imageFormats.threeDPngs) {
|
|
52151
53157
|
const pngBuffer = await render3dThumbnail(circuitJson);
|
|
52152
|
-
fs14.writeFileSync(
|
|
53158
|
+
fs14.writeFileSync(path20.join(outputDir, "3d.png"), Buffer.from(pngBuffer));
|
|
52153
53159
|
}
|
|
52154
53160
|
};
|
|
52155
53161
|
|
|
@@ -52163,7 +53169,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
52163
53169
|
const warnings = [];
|
|
52164
53170
|
const startedAt = options?.profile ? performance.now() : 0;
|
|
52165
53171
|
try {
|
|
52166
|
-
workerLog(`Generating circuit JSON for ${
|
|
53172
|
+
workerLog(`Generating circuit JSON for ${path21.relative(projectDir, filePath)}...`);
|
|
52167
53173
|
await registerStaticAssetLoaders(undefined, projectDir);
|
|
52168
53174
|
const projectConfig = await loadRuntimeProjectConfig(projectDir);
|
|
52169
53175
|
const platformConfig = mergePlatformConfigs(projectConfig?.platformConfig, options?.platformConfig);
|
|
@@ -52187,9 +53193,9 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
52187
53193
|
workerStatus(`waiting on ${asyncEffectName}…`);
|
|
52188
53194
|
}
|
|
52189
53195
|
})).circuitJson;
|
|
52190
|
-
fs15.mkdirSync(
|
|
53196
|
+
fs15.mkdirSync(path21.dirname(outputPath), { recursive: true });
|
|
52191
53197
|
fs15.writeFileSync(outputPath, JSON.stringify(circuitJson, null, 2));
|
|
52192
|
-
workerLog(`Circuit JSON written to ${
|
|
53198
|
+
workerLog(`Circuit JSON written to ${path21.relative(projectDir, outputPath)}`);
|
|
52193
53199
|
const diagnostics = analyzeCircuitJson(circuitJson);
|
|
52194
53200
|
const filteredDiagnostics = filterDiagnosticsByDrcCategory({
|
|
52195
53201
|
errors: diagnostics.errors,
|
|
@@ -52219,7 +53225,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
52219
53225
|
let previewError;
|
|
52220
53226
|
if (glbOutputPath) {
|
|
52221
53227
|
try {
|
|
52222
|
-
workerLog(`Converting ${
|
|
53228
|
+
workerLog(`Converting ${path21.relative(projectDir, outputPath)} to GLB in same worker...`);
|
|
52223
53229
|
await writeGlbFromCircuitJson(circuitJson, glbOutputPath);
|
|
52224
53230
|
glbOk = true;
|
|
52225
53231
|
} catch (err) {
|
|
@@ -52230,7 +53236,7 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
52230
53236
|
}
|
|
52231
53237
|
if (stepOutputPath) {
|
|
52232
53238
|
try {
|
|
52233
|
-
workerLog(`Converting ${
|
|
53239
|
+
workerLog(`Converting ${path21.relative(projectDir, outputPath)} to STEP in same worker...`);
|
|
52234
53240
|
await writeStepFromCircuitJson(circuitJson, stepOutputPath);
|
|
52235
53241
|
stepOk = true;
|
|
52236
53242
|
} catch (err) {
|
|
@@ -52241,8 +53247,8 @@ var handleBuildFile = async (filePath, outputPath, glbOutputPath, stepOutputPath
|
|
|
52241
53247
|
}
|
|
52242
53248
|
if (options?.generatePreviewAssets) {
|
|
52243
53249
|
try {
|
|
52244
|
-
const resolvedPreviewOutputDir = previewOutputDir ??
|
|
52245
|
-
workerLog(`Generating preview assets for ${
|
|
53250
|
+
const resolvedPreviewOutputDir = previewOutputDir ?? path21.dirname(outputPath);
|
|
53251
|
+
workerLog(`Generating preview assets for ${path21.relative(projectDir, resolvedPreviewOutputDir)} in same worker...`);
|
|
52246
53252
|
await writeImageAssetsFromCircuitJson(circuitJson, {
|
|
52247
53253
|
outputDir: resolvedPreviewOutputDir,
|
|
52248
53254
|
imageFormats: options?.imageFormats ?? DEFAULT_IMAGE_FORMAT_SELECTION,
|