nanos-lint 2.8.0 → 2.8.2
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/README.md +49 -44
- package/action.yml +25 -25
- package/bin/nanos-lint.js +0 -2
- package/dist/{cli-DGez8MSI.js → cli-BTHx4yp_.js} +3951 -222
- package/dist/cli-BTHx4yp_.js.map +1 -0
- package/dist/{cli-r8LDolDk.d.ts → cli-dxsaVVVq.d.ts} +5 -1
- package/dist/{cli-r8LDolDk.d.ts.map → cli-dxsaVVVq.d.ts.map} +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/index.d.ts +135 -36
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/package.json +14 -3
- package/templates/.luarc.json +2 -9
- package/dist/cli-DGez8MSI.js.map +0 -1
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { fileURLToPath } from "node:url";
|
|
2
|
+
import * as xi from "node:fs";
|
|
2
3
|
import fs from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
|
+
import path, { posix, win32 } from "node:path";
|
|
4
5
|
import os from "node:os";
|
|
5
6
|
import process$1 from "node:process";
|
|
6
7
|
import childProcess, { execFile, execFileSync } from "node:child_process";
|
|
7
8
|
import { promisify, stripVTControlCharacters } from "node:util";
|
|
9
|
+
import crypto from "node:crypto";
|
|
10
|
+
import Pe, { Readable } from "node:stream";
|
|
11
|
+
import { pipeline } from "node:stream/promises";
|
|
12
|
+
import { lstatSync, readdir, readdirSync, readlinkSync, realpathSync } from "fs";
|
|
13
|
+
import { lstat, readdir as readdir$1, readlink, realpath } from "node:fs/promises";
|
|
8
14
|
import { EventEmitter } from "node:events";
|
|
15
|
+
import { StringDecoder } from "node:string_decoder";
|
|
9
16
|
//#region src/logger.ts
|
|
10
17
|
const LOG_LEVELS = [
|
|
11
18
|
"silent",
|
|
@@ -22,9 +29,11 @@ const LOG_LEVEL_PRIORITY = {
|
|
|
22
29
|
debug: 4
|
|
23
30
|
};
|
|
24
31
|
const DEFAULT_LOG_LEVEL = "warn";
|
|
32
|
+
/** Validates whether a string corresponds to a recognized log level. */
|
|
25
33
|
function isValidLogLevel(level) {
|
|
26
34
|
return level in LOG_LEVEL_PRIORITY;
|
|
27
35
|
}
|
|
36
|
+
/** Parses a string into a valid LogLevel, defaulting to 'warn'. */
|
|
28
37
|
function parseLogLevel(raw) {
|
|
29
38
|
if (!raw) return DEFAULT_LOG_LEVEL;
|
|
30
39
|
const lower = raw.trim().toLowerCase();
|
|
@@ -39,12 +48,15 @@ var Logger = class {
|
|
|
39
48
|
if (envLevel && isValidLogLevel(envLevel.trim().toLowerCase())) this.level = envLevel.trim().toLowerCase();
|
|
40
49
|
}
|
|
41
50
|
}
|
|
51
|
+
/** Sets the active minimum logging level. */
|
|
42
52
|
setLevel(level) {
|
|
43
53
|
if (isValidLogLevel(level)) this.level = level;
|
|
44
54
|
}
|
|
55
|
+
/** Returns the current active log level. */
|
|
45
56
|
getLevel() {
|
|
46
57
|
return this.level;
|
|
47
58
|
}
|
|
59
|
+
/** Checks if a message at the specified level should be emitted. */
|
|
48
60
|
isEnabledFor(level) {
|
|
49
61
|
return LOG_LEVEL_PRIORITY[this.level] >= LOG_LEVEL_PRIORITY[level];
|
|
50
62
|
}
|
|
@@ -52,15 +64,19 @@ var Logger = class {
|
|
|
52
64
|
isOutputEnabled() {
|
|
53
65
|
return this.level !== "silent";
|
|
54
66
|
}
|
|
67
|
+
/** Logs an error-level message to stderr. */
|
|
55
68
|
error(...args) {
|
|
56
69
|
if (this.isEnabledFor("error")) console.error(...args);
|
|
57
70
|
}
|
|
71
|
+
/** Logs a warning-level message to stderr. */
|
|
58
72
|
warn(...args) {
|
|
59
73
|
if (this.isEnabledFor("warn")) console.warn(...args);
|
|
60
74
|
}
|
|
75
|
+
/** Logs an informational message to stdout. */
|
|
61
76
|
info(...args) {
|
|
62
77
|
if (this.isEnabledFor("info")) console.log(...args);
|
|
63
78
|
}
|
|
79
|
+
/** Logs a debug-level diagnostic message to stdout. */
|
|
64
80
|
debug(...args) {
|
|
65
81
|
if (this.isEnabledFor("debug")) console.debug(...args);
|
|
66
82
|
}
|
|
@@ -1015,6 +1031,7 @@ function getPackageRoot() {
|
|
|
1015
1031
|
}
|
|
1016
1032
|
return path.resolve(__dirname, "..");
|
|
1017
1033
|
}
|
|
1034
|
+
/** Resolves the default annotations path from environment variable, bundled file, or user cache. */
|
|
1018
1035
|
function getDefaultAnnotationsPath() {
|
|
1019
1036
|
const envPath = process.env.NANOS_ANNOTATIONS_PATH || process.env.NANOS_ANNOTATIONS;
|
|
1020
1037
|
if (envPath && fs.existsSync(envPath)) return path.resolve(envPath);
|
|
@@ -1029,6 +1046,7 @@ function getDefaultAnnotationsPath() {
|
|
|
1029
1046
|
function getDefinitionsDir() {
|
|
1030
1047
|
return path.dirname(getDefaultAnnotationsPath());
|
|
1031
1048
|
}
|
|
1049
|
+
/** Resolves the absolute path to the default .luarc.json template shipped with the package. */
|
|
1032
1050
|
function getDefaultTemplatePath() {
|
|
1033
1051
|
const root = getPackageRoot();
|
|
1034
1052
|
return path.join(root, "templates", ".luarc.json");
|
|
@@ -1040,6 +1058,7 @@ function stripJsonComments(text) {
|
|
|
1040
1058
|
const cleanText = text.replace(/^\uFEFF/, "");
|
|
1041
1059
|
return stripComments(cleanText);
|
|
1042
1060
|
}
|
|
1061
|
+
/** Parses JSONC text with support for comments and trailing commas. */
|
|
1043
1062
|
function parseJsonc(text) {
|
|
1044
1063
|
const cleanText = text.replace(/^\uFEFF/, "");
|
|
1045
1064
|
const errors = [];
|
|
@@ -1050,6 +1069,7 @@ function parseJsonc(text) {
|
|
|
1050
1069
|
}
|
|
1051
1070
|
return result;
|
|
1052
1071
|
}
|
|
1072
|
+
/** Reads and parses a .luarc.json configuration file from disk. */
|
|
1053
1073
|
function loadConfigFile(filePath) {
|
|
1054
1074
|
if (!fs.existsSync(filePath)) throw new ConfigError(`Configuration file not found: ${filePath}`, "ERR_CONFIG_NOT_FOUND", "Ensure the configuration file path is correct or run 'nanos-lint init' to generate a default config.");
|
|
1055
1075
|
const content = fs.readFileSync(filePath, "utf-8");
|
|
@@ -1345,25 +1365,12 @@ function initWorkspace(workspacePath, options) {
|
|
|
1345
1365
|
//#region src/luals/version.ts
|
|
1346
1366
|
const FALLBACK_LUALS_VERSION = "3.19.1";
|
|
1347
1367
|
const DEFAULT_LUALS_VERSION = "latest";
|
|
1348
|
-
/**
|
|
1349
|
-
* Characters accepted in a LuaLS version/tag. Only ASCII letters, digits, dots,
|
|
1350
|
-
* dashes and underscores are allowed, so a version can never contain a path
|
|
1351
|
-
* separator, a drive letter or a traversal segment.
|
|
1352
|
-
*/
|
|
1368
|
+
/** Characters accepted in a safe LuaLS version tag. */
|
|
1353
1369
|
const SAFE_VERSION_CHARS = new Map([..."0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-"].map((ch) => [ch, ch]));
|
|
1354
1370
|
const MAX_VERSION_LENGTH = 64;
|
|
1355
1371
|
/**
|
|
1356
|
-
* Validates a LuaLS version
|
|
1357
|
-
*
|
|
1358
|
-
* Version strings originate from untrusted sources: the GitHub releases API
|
|
1359
|
-
* response and user supplied `--luals-version` arguments. They are interpolated
|
|
1360
|
-
* into cache directory paths, download URLs, and the path of the binary that is
|
|
1361
|
-
* eventually executed, so they must be constrained to a single safe path
|
|
1362
|
-
* segment. Rebuilding the value character by character guarantees the returned
|
|
1363
|
-
* string only ever contains allow-listed characters (CodeQL: js/command-line-injection).
|
|
1364
|
-
*
|
|
1365
|
-
* @returns the normalized version (a single leading `v` is dropped), or `null`
|
|
1366
|
-
* when the input cannot be used as a version tag.
|
|
1372
|
+
* Validates and normalizes a LuaLS version string to prevent path traversal or injection.
|
|
1373
|
+
* Drops a single leading 'v' and returns null on invalid characters.
|
|
1367
1374
|
*/
|
|
1368
1375
|
function sanitizeLuaLSVersion(raw) {
|
|
1369
1376
|
const trimmed = raw.trim();
|
|
@@ -1420,6 +1427,7 @@ async function resolveLuaLSVersion(version) {
|
|
|
1420
1427
|
}
|
|
1421
1428
|
//#endregion
|
|
1422
1429
|
//#region src/luals/platform.ts
|
|
1430
|
+
/** Resolves platform-specific binary naming and relative paths for the host operating system. */
|
|
1423
1431
|
function getPlatformInfo(version = FALLBACK_LUALS_VERSION) {
|
|
1424
1432
|
const platform = process.platform;
|
|
1425
1433
|
const arch = process.arch;
|
|
@@ -1457,14 +1465,172 @@ function getPlatformInfo(version = FALLBACK_LUALS_VERSION) {
|
|
|
1457
1465
|
}
|
|
1458
1466
|
//#endregion
|
|
1459
1467
|
//#region src/luals/validation.ts
|
|
1468
|
+
const execFileAsync$2 = promisify(execFile);
|
|
1460
1469
|
/**
|
|
1461
|
-
*
|
|
1470
|
+
* Escapes single quotes for safe PowerShell single-quoted string interpolation.
|
|
1462
1471
|
*/
|
|
1463
|
-
function
|
|
1464
|
-
|
|
1472
|
+
function escapePowerShellSingleQuote(str) {
|
|
1473
|
+
return str.replace(/'/g, "''");
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Maximum total decompressed size of a LuaLS release archive (500 MB).
|
|
1477
|
+
* Protects against zip bombs and maliciously inflated archives (#31).
|
|
1478
|
+
*/
|
|
1479
|
+
const MAX_DECOMPRESSED_SIZE_BYTES = 524288e3;
|
|
1480
|
+
/**
|
|
1481
|
+
* Maximum number of members allowed in a LuaLS release archive (10,000).
|
|
1482
|
+
* Protects against inode exhaustion and archive recursion attacks (#31).
|
|
1483
|
+
*/
|
|
1484
|
+
const MAX_ARCHIVE_MEMBER_COUNT = 1e4;
|
|
1485
|
+
/** Parses the file size column from a 'tar -tvf' listing output line. */
|
|
1486
|
+
function parseTarTvSize(line) {
|
|
1487
|
+
const parts = line.trim().split(/\s+/);
|
|
1488
|
+
if (parts.length < 5) return 0;
|
|
1489
|
+
const p1 = parts[1];
|
|
1490
|
+
const p2 = parts[2];
|
|
1491
|
+
const p4 = parts[4];
|
|
1492
|
+
if (p1 && p2 && p1.includes("/") && /^\d+$/.test(p2)) return parseInt(p2, 10) || 0;
|
|
1493
|
+
if (p4 && /^\d+$/.test(p4)) return parseInt(p4, 10) || 0;
|
|
1494
|
+
for (let i = 2; i < Math.min(parts.length - 1, 6); i++) {
|
|
1495
|
+
const p = parts[i];
|
|
1496
|
+
if (p && /^\d+$/.test(p)) return parseInt(p, 10) || 0;
|
|
1497
|
+
}
|
|
1498
|
+
return 0;
|
|
1499
|
+
}
|
|
1500
|
+
/** Asserts that an archive entry name does not escape the destination directory. */
|
|
1501
|
+
function checkEscapedMember(member) {
|
|
1502
|
+
if (member.startsWith("/") || member.startsWith("\\") || /^[a-zA-Z]:[\\/]/.test(member) || member.split(/[/\\]/).includes("..")) throw new LuaLSError(`Archive member path escapes extraction directory: ${member}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1503
|
+
}
|
|
1504
|
+
/** Validates that archive entry count and decompressed size do not exceed safety limits. */
|
|
1505
|
+
function checkArchiveLimits(count, size) {
|
|
1506
|
+
if (count > 1e4) throw new LuaLSError(`Archive member count (${count}) exceeds maximum limit (${MAX_ARCHIVE_MEMBER_COUNT})`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1507
|
+
if (size > 524288e3) throw new LuaLSError(`Archive declared decompressed size (${size} bytes) exceeds maximum limit (${MAX_DECOMPRESSED_SIZE_BYTES} bytes)`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
|
|
1508
|
+
}
|
|
1509
|
+
/** Locates the platform tar executable path, checking System32 on Windows. */
|
|
1510
|
+
function getTarBinary() {
|
|
1511
|
+
if (process.platform === "win32") {
|
|
1512
|
+
const sysTar = path.join(process.env.SystemRoot || "C:\\Windows", "System32", "tar.exe");
|
|
1513
|
+
if (fs.existsSync(sysTar)) return sysTar;
|
|
1514
|
+
}
|
|
1515
|
+
return "tar";
|
|
1516
|
+
}
|
|
1517
|
+
/** Pre-inspects a ZIP archive's central directory to enforce extraction safety constraints (#31). */
|
|
1518
|
+
function inspectZipMembers(archivePath) {
|
|
1519
|
+
const buf = fs.readFileSync(archivePath);
|
|
1520
|
+
if (buf.length < 22) throw new LuaLSError("Failed to inspect release archive before extraction: archive is too small to be a valid zip", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1521
|
+
let eocdOffset = -1;
|
|
1522
|
+
const minOffset = Math.max(0, buf.length - 22 - 65535);
|
|
1523
|
+
for (let i = buf.length - 22; i >= minOffset; i--) if (buf.readUInt32LE(i) === 101010256) {
|
|
1524
|
+
const commentLen = buf.readUInt16LE(i + 20);
|
|
1525
|
+
if (i + 22 + commentLen === buf.length) {
|
|
1526
|
+
eocdOffset = i;
|
|
1527
|
+
break;
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
if (eocdOffset === -1) {
|
|
1531
|
+
for (let i = buf.length - 22; i >= minOffset; i--) if (buf.readUInt32LE(i) === 101010256) {
|
|
1532
|
+
eocdOffset = i;
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
}
|
|
1536
|
+
if (eocdOffset === -1) throw new LuaLSError("Failed to inspect release archive before extraction: corrupt or invalid zip archive (missing EOCD)", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1537
|
+
const entryCount = buf.readUInt16LE(eocdOffset + 10);
|
|
1538
|
+
let offset = buf.readUInt32LE(eocdOffset + 16);
|
|
1539
|
+
let memberCount = 0;
|
|
1540
|
+
let totalDeclaredSize = 0;
|
|
1541
|
+
for (let i = 0; i < entryCount && offset + 46 <= buf.length; i++) {
|
|
1542
|
+
if (buf.readUInt32LE(offset) !== 33639248) throw new LuaLSError("Failed to inspect release archive before extraction: invalid central directory header", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1543
|
+
const uncompressedSize = buf.readUInt32LE(offset + 24);
|
|
1544
|
+
const fileNameLen = buf.readUInt16LE(offset + 28);
|
|
1545
|
+
const extraLen = buf.readUInt16LE(offset + 30);
|
|
1546
|
+
const commentLen = buf.readUInt16LE(offset + 32);
|
|
1547
|
+
if ((buf.readUInt32LE(offset + 38) >>> 16 & 61440) === 40960) throw new LuaLSError("Archive member is a symbolic or hard link. Refusing to extract archive-planted links.", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1548
|
+
const fileNameStart = offset + 46;
|
|
1549
|
+
const fileNameEnd = fileNameStart + fileNameLen;
|
|
1550
|
+
if (fileNameEnd > buf.length) throw new LuaLSError("Failed to inspect release archive before extraction: corrupt file name length in zip", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1551
|
+
const fileName = buf.toString("utf-8", fileNameStart, fileNameEnd);
|
|
1552
|
+
memberCount++;
|
|
1553
|
+
totalDeclaredSize += uncompressedSize;
|
|
1554
|
+
checkEscapedMember(fileName);
|
|
1555
|
+
offset += 46 + fileNameLen + extraLen + commentLen;
|
|
1556
|
+
}
|
|
1557
|
+
checkArchiveLimits(memberCount, totalDeclaredSize);
|
|
1558
|
+
return {
|
|
1559
|
+
memberCount,
|
|
1560
|
+
totalDeclaredSize
|
|
1561
|
+
};
|
|
1562
|
+
}
|
|
1563
|
+
/** Detects whether an archive file starts with ZIP magic bytes. */
|
|
1564
|
+
function isZipArchive(archivePath) {
|
|
1565
|
+
try {
|
|
1566
|
+
const fd = fs.openSync(archivePath, "r");
|
|
1567
|
+
const buf = Buffer.alloc(4);
|
|
1568
|
+
const bytesRead = fs.readSync(fd, buf, 0, 4, 0);
|
|
1569
|
+
fs.closeSync(fd);
|
|
1570
|
+
if (bytesRead < 4) return false;
|
|
1571
|
+
return buf[0] === 80 && buf[1] === 75 && (buf[2] === 3 && buf[3] === 4 || buf[2] === 5 && buf[3] === 6 || buf[2] === 7 && buf[3] === 8);
|
|
1572
|
+
} catch {
|
|
1573
|
+
return false;
|
|
1574
|
+
}
|
|
1575
|
+
}
|
|
1576
|
+
/** Detects whether an archive file starts with GZIP magic bytes. */
|
|
1577
|
+
function isGzipArchive(archivePath) {
|
|
1578
|
+
try {
|
|
1579
|
+
const fd = fs.openSync(archivePath, "r");
|
|
1580
|
+
const buf = Buffer.alloc(2);
|
|
1581
|
+
const bytesRead = fs.readSync(fd, buf, 0, 2, 0);
|
|
1582
|
+
fs.closeSync(fd);
|
|
1583
|
+
return bytesRead >= 2 && buf[0] === 31 && buf[1] === 139;
|
|
1584
|
+
} catch {
|
|
1585
|
+
return false;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
/** Pre-inspects archive members using tar listing or zip directory parsing to enforce extraction safety constraints (#31). */
|
|
1589
|
+
async function validateArchiveMembers(archivePath) {
|
|
1590
|
+
if (isZipArchive(archivePath) || archivePath.toLowerCase().endsWith(".zip") && !isGzipArchive(archivePath)) return inspectZipMembers(archivePath);
|
|
1591
|
+
let memberCount = 0;
|
|
1592
|
+
let totalDeclaredSize = 0;
|
|
1593
|
+
const tarBin = getTarBinary();
|
|
1594
|
+
const archiveDir = path.dirname(archivePath);
|
|
1595
|
+
const archiveFile = path.basename(archivePath);
|
|
1596
|
+
try {
|
|
1597
|
+
const [namesOutput, verboseOutput] = await Promise.all([execFileAsync$2(tarBin, ["-tf", archiveFile], { cwd: archiveDir }), execFileAsync$2(tarBin, ["-tvf", archiveFile], { cwd: archiveDir })]);
|
|
1598
|
+
for (const rawName of namesOutput.stdout.split(/\r?\n/)) {
|
|
1599
|
+
const member = rawName.trim();
|
|
1600
|
+
if (!member) continue;
|
|
1601
|
+
memberCount++;
|
|
1602
|
+
checkEscapedMember(member);
|
|
1603
|
+
}
|
|
1604
|
+
for (const rawLine of verboseOutput.stdout.split(/\r?\n/)) {
|
|
1605
|
+
const line = rawLine.trim();
|
|
1606
|
+
if (!line) continue;
|
|
1607
|
+
if (/^[lh]/.test(line) || line.includes(" -> ") || line.includes(" link to ")) throw new LuaLSError("Archive member is a symbolic or hard link. Refusing to extract archive-planted links.", "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1608
|
+
totalDeclaredSize += parseTarTvSize(line);
|
|
1609
|
+
}
|
|
1610
|
+
checkArchiveLimits(memberCount, totalDeclaredSize);
|
|
1611
|
+
} catch (err) {
|
|
1612
|
+
if (err instanceof LuaLSError) throw err;
|
|
1613
|
+
throw new LuaLSError(`Failed to inspect release archive before extraction: ${err instanceof Error ? err.message : String(err)}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.", { cause: err });
|
|
1614
|
+
}
|
|
1615
|
+
return {
|
|
1616
|
+
memberCount,
|
|
1617
|
+
totalDeclaredSize
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Minimum plausible size of a downloaded LuaLS executable. Release assets are
|
|
1622
|
+
* several megabytes, so anything smaller is a truncated download or a stray
|
|
1623
|
+
* file. This floor only applies to binaries nanos-lint fetched itself: a
|
|
1624
|
+
* user-supplied `LUALS_BIN` may legitimately be a small wrapper script.
|
|
1625
|
+
*/
|
|
1626
|
+
const MIN_DOWNLOADED_BINARY_SIZE_BYTES = 1e5;
|
|
1627
|
+
/**
|
|
1628
|
+
* Runs `binaryPath --version` and checks that it reports a LuaLS version.
|
|
1629
|
+
* Shared by every binary validation path; the size heuristic stays separate
|
|
1630
|
+
* because only downloaded archives have a known-plausible size.
|
|
1631
|
+
*/
|
|
1632
|
+
function reportsLuaLSVersion(binaryPath) {
|
|
1465
1633
|
try {
|
|
1466
|
-
const stats = fs.statSync(binaryPath);
|
|
1467
|
-
if (!stats.isFile() || stats.size < 1e5) return false;
|
|
1468
1634
|
const output = execFileSync(binaryPath, ["--version"], {
|
|
1469
1635
|
timeout: 5e3,
|
|
1470
1636
|
stdio: "pipe",
|
|
@@ -1476,8 +1642,63 @@ function isBinaryValid(binaryPath) {
|
|
|
1476
1642
|
return false;
|
|
1477
1643
|
}
|
|
1478
1644
|
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Verifies that a downloaded or cached LuaLS binary exists, has non-trivial
|
|
1647
|
+
* size, and is executable.
|
|
1648
|
+
*/
|
|
1649
|
+
function isBinaryValid(binaryPath) {
|
|
1650
|
+
if (!fs.existsSync(binaryPath)) return false;
|
|
1651
|
+
try {
|
|
1652
|
+
const stats = fs.statSync(binaryPath);
|
|
1653
|
+
if (!stats.isFile() || stats.size < 1e5) return false;
|
|
1654
|
+
return reportsLuaLSVersion(binaryPath);
|
|
1655
|
+
} catch (err) {
|
|
1656
|
+
logger.debug(`[luals] Binary validation check failed for ${binaryPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1657
|
+
return false;
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Verifies that an explicitly configured binary is a regular file that runs and
|
|
1662
|
+
* reports a LuaLS version, without the downloaded-archive size heuristic so
|
|
1663
|
+
* wrapper scripts (`LUALS_BIN=/usr/local/bin/lua-language-server`) keep working.
|
|
1664
|
+
*/
|
|
1665
|
+
function isBinaryRunnable(binaryPath) {
|
|
1666
|
+
try {
|
|
1667
|
+
if (!fs.statSync(binaryPath).isFile()) return false;
|
|
1668
|
+
} catch (err) {
|
|
1669
|
+
logger.debug(`[luals] Binary validation check failed for ${binaryPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
return reportsLuaLSVersion(binaryPath);
|
|
1673
|
+
}
|
|
1674
|
+
/**
|
|
1675
|
+
* Validates an explicitly configured LuaLS binary (`LUALS_BIN` environment
|
|
1676
|
+
* variable or `--luals-bin` CLI option) and returns its path.
|
|
1677
|
+
*
|
|
1678
|
+
* Both are documented escape hatches, so a typo, a stale path, a directory or an
|
|
1679
|
+
* unrelated executable must fail with an actionable error instead of a
|
|
1680
|
+
* confusing low-level failure deep inside the check run (#26). Executables are
|
|
1681
|
+
* accepted as-is when `--version` reports a version, including the thin wrapper
|
|
1682
|
+
* scripts that Homebrew/mason-style installations put on `PATH`: the size floor
|
|
1683
|
+
* used for downloaded archives would reject those.
|
|
1684
|
+
*
|
|
1685
|
+
* @param binaryPath Path exactly as the user supplied it.
|
|
1686
|
+
* @param source Name of the setting being validated (`LUALS_BIN` / `--luals-bin`).
|
|
1687
|
+
*/
|
|
1688
|
+
function assertValidLuaLSBinary(binaryPath, source) {
|
|
1689
|
+
let stats;
|
|
1690
|
+
try {
|
|
1691
|
+
stats = fs.statSync(binaryPath);
|
|
1692
|
+
} catch (err) {
|
|
1693
|
+
throw new LuaLSError(`${source} points to '${binaryPath}', which does not exist or cannot be read: ${err instanceof Error ? err.message : String(err)}`, "ERR_LUALS_BIN_INVALID", `Set ${source} to the full path of a lua-language-server executable, or leave it unset so nanos-lint resolves LuaLS automatically.`, { cause: err });
|
|
1694
|
+
}
|
|
1695
|
+
if (!stats.isFile()) throw new LuaLSError(`${source} points to '${binaryPath}', which is not a regular file (a directory or special file was found).`, "ERR_LUALS_BIN_INVALID", `Point ${source} at the lua-language-server executable itself, or leave it unset so nanos-lint resolves LuaLS automatically.`);
|
|
1696
|
+
if (!isBinaryRunnable(binaryPath)) throw new LuaLSError(`${source} points to '${binaryPath}', which is not a runnable LuaLS binary (running it with '--version' failed or printed no version).`, "ERR_LUALS_BIN_INVALID", `Verify ${source} points at a working lua-language-server executable or wrapper script, or leave it unset so nanos-lint resolves LuaLS automatically.`);
|
|
1697
|
+
return binaryPath;
|
|
1698
|
+
}
|
|
1479
1699
|
//#endregion
|
|
1480
1700
|
//#region src/luals/cache.ts
|
|
1701
|
+
/** Returns the base directory in the system cache where LuaLS versions and metadata are stored. */
|
|
1481
1702
|
function getBaseLuaLSCacheDir() {
|
|
1482
1703
|
return path.join(systemPaths.cache, "luals");
|
|
1483
1704
|
}
|
|
@@ -1507,16 +1728,23 @@ function getIsoWeek(d = /* @__PURE__ */ new Date()) {
|
|
|
1507
1728
|
const weekNo = Math.ceil(((date.getTime() - yearStart.getTime()) / 864e5 + 1) / 7);
|
|
1508
1729
|
return `${date.getUTCFullYear()}-W${String(weekNo).padStart(2, "0")}`;
|
|
1509
1730
|
}
|
|
1731
|
+
/** Returns the path to the LuaLS metadata.json file within the specified cache directory. */
|
|
1510
1732
|
function getLuaLSMetadataPath(baseCacheDir = getBaseLuaLSCacheDir()) {
|
|
1511
1733
|
return path.join(baseCacheDir, LUALS_METADATA_FILENAME);
|
|
1512
1734
|
}
|
|
1735
|
+
/** Reads and parses the LuaLS metadata.json file, purging corrupted or invalid files automatically. */
|
|
1513
1736
|
function readLuaLSMetadata(baseCacheDir = getBaseLuaLSCacheDir()) {
|
|
1514
1737
|
const metaPath = getLuaLSMetadataPath(baseCacheDir);
|
|
1515
1738
|
if (!fs.existsSync(metaPath)) return null;
|
|
1516
1739
|
try {
|
|
1517
1740
|
const content = fs.readFileSync(metaPath, "utf-8");
|
|
1518
1741
|
const parsed = JSON.parse(content);
|
|
1519
|
-
|
|
1742
|
+
const rawVersion = parsed?.latestVersion;
|
|
1743
|
+
const safeVersion = typeof rawVersion === "string" ? sanitizeLuaLSVersion(rawVersion) : null;
|
|
1744
|
+
if (typeof parsed?.lastCheckedWeek === "string" && safeVersion !== null) return {
|
|
1745
|
+
...parsed,
|
|
1746
|
+
latestVersion: safeVersion
|
|
1747
|
+
};
|
|
1520
1748
|
try {
|
|
1521
1749
|
fs.unlinkSync(metaPath);
|
|
1522
1750
|
logger.warn(`[luals] Stale or invalid LuaLS metadata at ${metaPath} purged.`);
|
|
@@ -1534,6 +1762,7 @@ function readLuaLSMetadata(baseCacheDir = getBaseLuaLSCacheDir()) {
|
|
|
1534
1762
|
}
|
|
1535
1763
|
return null;
|
|
1536
1764
|
}
|
|
1765
|
+
/** Writes metadata.json containing the latest checked version and timestamp. */
|
|
1537
1766
|
function writeLuaLSMetadata(metadata, baseCacheDir = getBaseLuaLSCacheDir()) {
|
|
1538
1767
|
try {
|
|
1539
1768
|
fs.mkdirSync(baseCacheDir, { recursive: true });
|
|
@@ -1656,13 +1885,57 @@ function findExistingLuaLSDir(version, baseCacheDir = getBaseLuaLSCacheDir()) {
|
|
|
1656
1885
|
}
|
|
1657
1886
|
//#endregion
|
|
1658
1887
|
//#region src/luals/download.ts
|
|
1888
|
+
const DOWNLOAD_TIMEOUT_MS = 12e4;
|
|
1889
|
+
const MAX_ARCHIVE_SIZE_BYTES = 157286400;
|
|
1890
|
+
const ALLOWED_DOWNLOAD_DOMAINS = ["github.com", "githubusercontent.com"];
|
|
1891
|
+
/**
|
|
1892
|
+
* Validates that a download URL uses HTTPS and targets an allowlisted host.
|
|
1893
|
+
*/
|
|
1894
|
+
function isAllowedDownloadUrl(urlString) {
|
|
1895
|
+
try {
|
|
1896
|
+
const parsed = new URL(urlString);
|
|
1897
|
+
if (parsed.protocol !== "https:") return false;
|
|
1898
|
+
const hostname = parsed.hostname.toLowerCase();
|
|
1899
|
+
return ALLOWED_DOWNLOAD_DOMAINS.some((domain) => hostname === domain || hostname.endsWith(`.${domain}`));
|
|
1900
|
+
} catch {
|
|
1901
|
+
return false;
|
|
1902
|
+
}
|
|
1903
|
+
}
|
|
1904
|
+
/** Chunk size used when hashing an archive, so a 150 MB asset is never buffered whole. */
|
|
1905
|
+
const HASH_CHUNK_SIZE_BYTES = 1048576;
|
|
1906
|
+
/**
|
|
1907
|
+
* Calculates the SHA-256 hash of a file on disk in bounded memory.
|
|
1908
|
+
*/
|
|
1909
|
+
function computeFileSha256(filePath) {
|
|
1910
|
+
const hash = crypto.createHash("sha256");
|
|
1911
|
+
const fd = fs.openSync(filePath, "r");
|
|
1912
|
+
try {
|
|
1913
|
+
const buffer = Buffer.alloc(HASH_CHUNK_SIZE_BYTES);
|
|
1914
|
+
let position = 0;
|
|
1915
|
+
let bytesRead = fs.readSync(fd, buffer, 0, buffer.length, position);
|
|
1916
|
+
while (bytesRead > 0) {
|
|
1917
|
+
hash.update(buffer.subarray(0, bytesRead));
|
|
1918
|
+
position += bytesRead;
|
|
1919
|
+
bytesRead = fs.readSync(fd, buffer, 0, buffer.length, position);
|
|
1920
|
+
}
|
|
1921
|
+
} finally {
|
|
1922
|
+
fs.closeSync(fd);
|
|
1923
|
+
}
|
|
1924
|
+
return hash.digest("hex");
|
|
1925
|
+
}
|
|
1659
1926
|
const execFileAsync$1 = promisify(execFile);
|
|
1660
1927
|
/**
|
|
1661
|
-
*
|
|
1928
|
+
* Enforces a maximum byte count on an asynchronous download stream.
|
|
1662
1929
|
*/
|
|
1663
|
-
function
|
|
1664
|
-
|
|
1930
|
+
async function* limitDownloadStream(source) {
|
|
1931
|
+
let total = 0;
|
|
1932
|
+
for await (const chunk of source) {
|
|
1933
|
+
total += chunk.length;
|
|
1934
|
+
if (total > 157286400) throw new LuaLSError(`Download exceeded maximum allowed size of ${MAX_ARCHIVE_SIZE_BYTES} bytes`, "ERR_LUALS_DOWNLOAD", "Verify the LuaLS release asset size or specify a local binary with LUALS_BIN.");
|
|
1935
|
+
yield chunk;
|
|
1936
|
+
}
|
|
1665
1937
|
}
|
|
1938
|
+
/** Downloads, verifies, and extracts the LuaLS release archive for the current platform. */
|
|
1666
1939
|
async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDir, options) {
|
|
1667
1940
|
const resolvedVersion = await resolveLuaLSVersion(version);
|
|
1668
1941
|
const info = getPlatformInfo(resolvedVersion);
|
|
@@ -1697,12 +1970,17 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
|
|
|
1697
1970
|
if (!options?.quiet) logger.info(`[luals] Reusing existing LuaLS ${resolvedVersion} installation from ${existingSourceDir}...`);
|
|
1698
1971
|
fs.cpSync(existingSourceDir, tempDir, { recursive: true });
|
|
1699
1972
|
} else {
|
|
1973
|
+
if (!isAllowedDownloadUrl(url)) throw new LuaLSError(`Refusing to download LuaLS from untrusted URL: ${url}`, "ERR_LUALS_DOWNLOAD", "Download URLs must use HTTPS and target an allowlisted GitHub host.");
|
|
1700
1974
|
if (!options?.quiet) logger.info(`[luals] Downloading LuaLS ${resolvedVersion} from ${url}...`);
|
|
1701
1975
|
let response = null;
|
|
1702
1976
|
let lastErr = null;
|
|
1703
1977
|
for (let attempt = 1; attempt <= 3; attempt++) {
|
|
1704
1978
|
try {
|
|
1705
|
-
const res = await fetch(url);
|
|
1979
|
+
const res = await fetch(url, { signal: AbortSignal.timeout(DOWNLOAD_TIMEOUT_MS) });
|
|
1980
|
+
if (res.url && !isAllowedDownloadUrl(res.url)) {
|
|
1981
|
+
await res.body?.cancel();
|
|
1982
|
+
throw new LuaLSError(`Redirect to untrusted URL blocked: ${res.url}`, "ERR_LUALS_DOWNLOAD", "Download redirects must stay on allowlisted HTTPS GitHub hosts.");
|
|
1983
|
+
}
|
|
1706
1984
|
if (res.ok && res.body) {
|
|
1707
1985
|
response = res;
|
|
1708
1986
|
break;
|
|
@@ -1718,16 +1996,44 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
|
|
|
1718
1996
|
if (lastErr instanceof LuaLSError) throw lastErr;
|
|
1719
1997
|
throw new LuaLSError(`Failed to download LuaLS from ${url}${lastErr ? `: ${lastErr instanceof Error ? lastErr.message : String(lastErr)}` : ""}`, "ERR_LUALS_DOWNLOAD", "Check your network connection or specify a custom binary with LUALS_BIN.", { cause: lastErr });
|
|
1720
1998
|
}
|
|
1721
|
-
const
|
|
1722
|
-
|
|
1999
|
+
const contentLengthHeader = response.headers?.get?.("content-length");
|
|
2000
|
+
if (contentLengthHeader) {
|
|
2001
|
+
const contentLength = parseInt(contentLengthHeader, 10);
|
|
2002
|
+
if (!isNaN(contentLength) && contentLength > 157286400) {
|
|
2003
|
+
await response.body.cancel();
|
|
2004
|
+
throw new LuaLSError(`Archive size (${contentLength} bytes) exceeds maximum limit (${MAX_ARCHIVE_SIZE_BYTES} bytes)`, "ERR_LUALS_DOWNLOAD", "Verify the LuaLS release asset size or specify a local binary with LUALS_BIN.");
|
|
2005
|
+
}
|
|
2006
|
+
}
|
|
2007
|
+
const fileStream = fs.createWriteStream(archivePath);
|
|
2008
|
+
try {
|
|
2009
|
+
const streamSource = typeof Readable.fromWeb === "function" && !("pipe" in response.body) ? Readable.fromWeb(response.body) : response.body;
|
|
2010
|
+
await pipeline(streamSource, limitDownloadStream, fileStream);
|
|
2011
|
+
} catch (streamErr) {
|
|
2012
|
+
try {
|
|
2013
|
+
if (fs.existsSync(archivePath)) fs.unlinkSync(archivePath);
|
|
2014
|
+
} catch (unlinkErr) {}
|
|
2015
|
+
if (streamErr instanceof LuaLSError) throw streamErr;
|
|
2016
|
+
throw new LuaLSError(`Failed to download LuaLS from ${url}: ${streamErr instanceof Error ? streamErr.message : String(streamErr)}`, "ERR_LUALS_DOWNLOAD", "Check your network connection or specify a custom binary with LUALS_BIN.", { cause: streamErr });
|
|
2017
|
+
}
|
|
2018
|
+
const archiveSha256 = computeFileSha256(archivePath);
|
|
2019
|
+
logger.info(`[luals] Downloaded ${info.assetName} (SHA-256 ${archiveSha256})`);
|
|
1723
2020
|
if (!options?.quiet) logger.info(`[luals] Extracting to ${destDir}...`);
|
|
2021
|
+
await validateArchiveMembers(archivePath);
|
|
1724
2022
|
try {
|
|
1725
|
-
|
|
2023
|
+
const tarArgs = process.platform === "win32" ? [
|
|
1726
2024
|
"-xf",
|
|
1727
|
-
archivePath,
|
|
2025
|
+
path.basename(archivePath),
|
|
1728
2026
|
"-C",
|
|
1729
2027
|
tempDir
|
|
1730
|
-
]
|
|
2028
|
+
] : [
|
|
2029
|
+
"-xf",
|
|
2030
|
+
path.basename(archivePath),
|
|
2031
|
+
"--no-same-owner",
|
|
2032
|
+
"--no-same-permissions",
|
|
2033
|
+
"-C",
|
|
2034
|
+
tempDir
|
|
2035
|
+
];
|
|
2036
|
+
await execFileAsync$1(getTarBinary(), tarArgs, { cwd: path.dirname(archivePath) });
|
|
1731
2037
|
} catch (tarErr) {
|
|
1732
2038
|
if (process.platform === "win32" && info.assetName.endsWith(".zip")) await execFileAsync$1("powershell.exe", [
|
|
1733
2039
|
"-NoProfile",
|
|
@@ -1736,6 +2042,8 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
|
|
|
1736
2042
|
]);
|
|
1737
2043
|
else throw tarErr;
|
|
1738
2044
|
}
|
|
2045
|
+
const extractedSize = getDirectorySize(tempDir);
|
|
2046
|
+
if (extractedSize > 524288e3) throw new LuaLSError(`Extracted archive size (${extractedSize} bytes) exceeds maximum limit (${MAX_DECOMPRESSED_SIZE_BYTES} bytes)`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
|
|
1739
2047
|
try {
|
|
1740
2048
|
fs.unlinkSync(archivePath);
|
|
1741
2049
|
} catch (err) {
|
|
@@ -1743,12 +2051,19 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
|
|
|
1743
2051
|
}
|
|
1744
2052
|
}
|
|
1745
2053
|
const tempBinaryPath = path.join(tempDir, info.binaryRelativePath);
|
|
2054
|
+
if (!fs.existsSync(tempBinaryPath)) throw new LuaLSError(`Failed to extract valid LuaLS binary to expected path: ${tempBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
|
|
2055
|
+
const lstat = fs.lstatSync(tempBinaryPath);
|
|
2056
|
+
if (lstat.isSymbolicLink()) throw new LuaLSError(`Extracted binary at '${tempBinaryPath}' is a symbolic link. Refusing to chmod or execute archive-planted symlinks.`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
2057
|
+
if (!lstat.isFile()) throw new LuaLSError(`Extracted binary at '${tempBinaryPath}' is not a regular file.`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
2058
|
+
const realBinaryPath = fs.realpathSync(tempBinaryPath);
|
|
2059
|
+
const resolvedTemp = fs.realpathSync(tempDir);
|
|
2060
|
+
if (!realBinaryPath.startsWith(resolvedTemp + path.sep) && realBinaryPath !== resolvedTemp) throw new LuaLSError(`Extracted binary path escapes extraction directory: ${realBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and verify the LuaLS release integrity.");
|
|
1746
2061
|
if (process.platform !== "win32") try {
|
|
1747
2062
|
fs.chmodSync(tempBinaryPath, 493);
|
|
1748
2063
|
} catch (err) {
|
|
1749
2064
|
logger.warn(`[luals] Failed to chmod binary at ${tempBinaryPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1750
2065
|
}
|
|
1751
|
-
if (
|
|
2066
|
+
if (lstat.size < 1e5) throw new LuaLSError(`Failed to extract valid LuaLS binary to expected path: ${tempBinaryPath}`, "ERR_LUALS_EXTRACT", "Run 'nanos-lint clean-cache' and ensure there is sufficient disk space.");
|
|
1752
2067
|
if (!isBinaryValid(tempBinaryPath)) throw new LuaLSError(`Extracted LuaLS binary at ${tempBinaryPath} is invalid or non-functional.`, "ERR_LUALS_INVALID_BINARY", "Run 'nanos-lint clean-cache' to remove corrupted downloads or set LUALS_BIN to a custom binary.");
|
|
1753
2068
|
fs.writeFileSync(path.join(tempDir, ".complete"), resolvedVersion, "utf-8");
|
|
1754
2069
|
for (let attempt = 0; attempt < 5; attempt++) try {
|
|
@@ -1764,139 +2079,3454 @@ async function downloadAndExtractLuaLS(version = DEFAULT_LUALS_VERSION, targetDi
|
|
|
1764
2079
|
} catch (err) {
|
|
1765
2080
|
logger.debug(`[luals] Failed to remove temp directory after concurrent promotion: ${err instanceof Error ? err.message : String(err)}`);
|
|
1766
2081
|
}
|
|
1767
|
-
if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
|
|
1768
|
-
return binaryPath;
|
|
2082
|
+
if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
|
|
2083
|
+
return binaryPath;
|
|
2084
|
+
}
|
|
2085
|
+
if (attempt < 4) await new Promise((resolve) => setTimeout(resolve, 100 * (attempt + 1)));
|
|
2086
|
+
else {
|
|
2087
|
+
if (fs.existsSync(destDir) && (!fs.existsSync(binaryPath) || !fs.existsSync(completeMarker))) try {
|
|
2088
|
+
fs.rmSync(destDir, {
|
|
2089
|
+
recursive: true,
|
|
2090
|
+
force: true
|
|
2091
|
+
});
|
|
2092
|
+
} catch (err) {
|
|
2093
|
+
logger.warn(`[luals] Failed to clean up broken destination directory ${destDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2094
|
+
}
|
|
2095
|
+
throw renameErr;
|
|
2096
|
+
}
|
|
2097
|
+
}
|
|
2098
|
+
if (!options?.quiet) logger.info(`[luals] Ready: ${binaryPath}`);
|
|
2099
|
+
return binaryPath;
|
|
2100
|
+
} finally {
|
|
2101
|
+
if (fs.existsSync(tempDir)) try {
|
|
2102
|
+
fs.rmSync(tempDir, {
|
|
2103
|
+
recursive: true,
|
|
2104
|
+
force: true
|
|
2105
|
+
});
|
|
2106
|
+
} catch (err) {
|
|
2107
|
+
logger.debug(`[luals] Failed to clean up temporary directory ${tempDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
//#endregion
|
|
2112
|
+
//#region node_modules/glob/dist/esm/index.min.js
|
|
2113
|
+
var Gt = (n, t, e) => {
|
|
2114
|
+
let s = n instanceof RegExp ? ce(n, e) : n, i = t instanceof RegExp ? ce(t, e) : t, r = s !== null && i != null && ss(s, i, e);
|
|
2115
|
+
return r && {
|
|
2116
|
+
start: r[0],
|
|
2117
|
+
end: r[1],
|
|
2118
|
+
pre: e.slice(0, r[0]),
|
|
2119
|
+
body: e.slice(r[0] + s.length, r[1]),
|
|
2120
|
+
post: e.slice(r[1] + i.length)
|
|
2121
|
+
};
|
|
2122
|
+
};
|
|
2123
|
+
var ce = (n, t) => {
|
|
2124
|
+
let e = t.match(n);
|
|
2125
|
+
return e ? e[0] : null;
|
|
2126
|
+
};
|
|
2127
|
+
var ss = (n, t, e) => {
|
|
2128
|
+
let s, i, r, o, h, a = e.indexOf(n), l = e.indexOf(t, a + 1), u = a;
|
|
2129
|
+
if (a >= 0 && l > 0) {
|
|
2130
|
+
if (n === t) return [a, l];
|
|
2131
|
+
for (s = [], r = e.length; u >= 0 && !h;) {
|
|
2132
|
+
if (u === a) s.push(u), a = e.indexOf(n, u + 1);
|
|
2133
|
+
else if (s.length === 1) {
|
|
2134
|
+
let c = s.pop();
|
|
2135
|
+
c !== void 0 && (h = [c, l]);
|
|
2136
|
+
} else i = s.pop(), i !== void 0 && i < r && (r = i, o = l), l = e.indexOf(t, u + 1);
|
|
2137
|
+
u = a < l && a >= 0 ? a : l;
|
|
2138
|
+
}
|
|
2139
|
+
s.length && o !== void 0 && (h = [r, o]);
|
|
2140
|
+
}
|
|
2141
|
+
return h;
|
|
2142
|
+
};
|
|
2143
|
+
var fe = "\0SLASH" + Math.random() + "\0";
|
|
2144
|
+
var ue = "\0OPEN" + Math.random() + "\0";
|
|
2145
|
+
var qt = "\0CLOSE" + Math.random() + "\0";
|
|
2146
|
+
var de = "\0COMMA" + Math.random() + "\0";
|
|
2147
|
+
var pe = "\0PERIOD" + Math.random() + "\0";
|
|
2148
|
+
var is = new RegExp(fe, "g");
|
|
2149
|
+
var rs = new RegExp(ue, "g");
|
|
2150
|
+
var ns = new RegExp(qt, "g");
|
|
2151
|
+
var os$1 = new RegExp(de, "g");
|
|
2152
|
+
var hs = new RegExp(pe, "g");
|
|
2153
|
+
var as = /\\\\/g;
|
|
2154
|
+
var ls = /\\{/g;
|
|
2155
|
+
var cs = /\\}/g;
|
|
2156
|
+
var fs$1 = /\\,/g;
|
|
2157
|
+
var us = /\\./g;
|
|
2158
|
+
var ds = 1e5;
|
|
2159
|
+
function Ht(n) {
|
|
2160
|
+
return isNaN(n) ? n.charCodeAt(0) : parseInt(n, 10);
|
|
2161
|
+
}
|
|
2162
|
+
function ps(n) {
|
|
2163
|
+
return n.replace(as, fe).replace(ls, ue).replace(cs, qt).replace(fs$1, de).replace(us, pe);
|
|
2164
|
+
}
|
|
2165
|
+
function ms(n) {
|
|
2166
|
+
return n.replace(is, "\\").replace(rs, "{").replace(ns, "}").replace(os$1, ",").replace(hs, ".");
|
|
2167
|
+
}
|
|
2168
|
+
function me(n) {
|
|
2169
|
+
if (!n) return [""];
|
|
2170
|
+
let t = [], e = Gt("{", "}", n);
|
|
2171
|
+
if (!e) return n.split(",");
|
|
2172
|
+
let { pre: s, body: i, post: r } = e, o = s.split(",");
|
|
2173
|
+
o[o.length - 1] += "{" + i + "}";
|
|
2174
|
+
let h = me(r);
|
|
2175
|
+
return r.length && (o[o.length - 1] += h.shift(), o.push.apply(o, h)), t.push.apply(t, o), t;
|
|
2176
|
+
}
|
|
2177
|
+
function ge(n, t = {}) {
|
|
2178
|
+
if (!n) return [];
|
|
2179
|
+
let { max: e = ds } = t;
|
|
2180
|
+
return n.slice(0, 2) === "{}" && (n = "\\{\\}" + n.slice(2)), ht(ps(n), e, !0).map(ms);
|
|
2181
|
+
}
|
|
2182
|
+
function gs(n) {
|
|
2183
|
+
return "{" + n + "}";
|
|
2184
|
+
}
|
|
2185
|
+
function ws(n) {
|
|
2186
|
+
return /^-?0\d/.test(n);
|
|
2187
|
+
}
|
|
2188
|
+
function ys(n, t) {
|
|
2189
|
+
return n <= t;
|
|
2190
|
+
}
|
|
2191
|
+
function bs(n, t) {
|
|
2192
|
+
return n >= t;
|
|
2193
|
+
}
|
|
2194
|
+
function ht(n, t, e) {
|
|
2195
|
+
let s = [], i = Gt("{", "}", n);
|
|
2196
|
+
if (!i) return [n];
|
|
2197
|
+
let r = i.pre, o = i.post.length ? ht(i.post, t, !1) : [""];
|
|
2198
|
+
if (/\$$/.test(i.pre)) for (let h = 0; h < o.length && h < t; h++) {
|
|
2199
|
+
let a = r + "{" + i.body + "}" + o[h];
|
|
2200
|
+
s.push(a);
|
|
2201
|
+
}
|
|
2202
|
+
else {
|
|
2203
|
+
let h = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(i.body), a = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(i.body), l = h || a, u = i.body.indexOf(",") >= 0;
|
|
2204
|
+
if (!l && !u) return i.post.match(/,(?!,).*\}/) ? (n = i.pre + "{" + i.body + qt + i.post, ht(n, t, !0)) : [n];
|
|
2205
|
+
let c;
|
|
2206
|
+
if (l) c = i.body.split(/\.\./);
|
|
2207
|
+
else if (c = me(i.body), c.length === 1 && c[0] !== void 0 && (c = ht(c[0], t, !1).map(gs), c.length === 1)) return o.map((f) => i.pre + c[0] + f);
|
|
2208
|
+
let d;
|
|
2209
|
+
if (l && c[0] !== void 0 && c[1] !== void 0) {
|
|
2210
|
+
let f = Ht(c[0]), m = Ht(c[1]), p = Math.max(c[0].length, c[1].length), w = c.length === 3 && c[2] !== void 0 ? Math.abs(Ht(c[2])) : 1, g = ys;
|
|
2211
|
+
m < f && (w *= -1, g = bs);
|
|
2212
|
+
let E = c.some(ws);
|
|
2213
|
+
d = [];
|
|
2214
|
+
for (let y = f; g(y, m); y += w) {
|
|
2215
|
+
let b;
|
|
2216
|
+
if (a) b = String.fromCharCode(y), b === "\\" && (b = "");
|
|
2217
|
+
else if (b = String(y), E) {
|
|
2218
|
+
let z = p - b.length;
|
|
2219
|
+
if (z > 0) {
|
|
2220
|
+
let $ = new Array(z + 1).join("0");
|
|
2221
|
+
y < 0 ? b = "-" + $ + b.slice(1) : b = $ + b;
|
|
2222
|
+
}
|
|
2223
|
+
}
|
|
2224
|
+
d.push(b);
|
|
2225
|
+
}
|
|
2226
|
+
} else {
|
|
2227
|
+
d = [];
|
|
2228
|
+
for (let f = 0; f < c.length; f++) d.push.apply(d, ht(c[f], t, !1));
|
|
2229
|
+
}
|
|
2230
|
+
for (let f = 0; f < d.length; f++) for (let m = 0; m < o.length && s.length < t; m++) {
|
|
2231
|
+
let p = r + d[f] + o[m];
|
|
2232
|
+
(!e || l || p) && s.push(p);
|
|
2233
|
+
}
|
|
2234
|
+
}
|
|
2235
|
+
return s;
|
|
2236
|
+
}
|
|
2237
|
+
var at = (n) => {
|
|
2238
|
+
if (typeof n != "string") throw new TypeError("invalid pattern");
|
|
2239
|
+
if (n.length > 65536) throw new TypeError("pattern is too long");
|
|
2240
|
+
};
|
|
2241
|
+
var Ss = {
|
|
2242
|
+
"[:alnum:]": ["\\p{L}\\p{Nl}\\p{Nd}", !0],
|
|
2243
|
+
"[:alpha:]": ["\\p{L}\\p{Nl}", !0],
|
|
2244
|
+
"[:ascii:]": ["\\x00-\\x7f", !1],
|
|
2245
|
+
"[:blank:]": ["\\p{Zs}\\t", !0],
|
|
2246
|
+
"[:cntrl:]": ["\\p{Cc}", !0],
|
|
2247
|
+
"[:digit:]": ["\\p{Nd}", !0],
|
|
2248
|
+
"[:graph:]": [
|
|
2249
|
+
"\\p{Z}\\p{C}",
|
|
2250
|
+
!0,
|
|
2251
|
+
!0
|
|
2252
|
+
],
|
|
2253
|
+
"[:lower:]": ["\\p{Ll}", !0],
|
|
2254
|
+
"[:print:]": ["\\p{C}", !0],
|
|
2255
|
+
"[:punct:]": ["\\p{P}", !0],
|
|
2256
|
+
"[:space:]": ["\\p{Z}\\t\\r\\n\\v\\f", !0],
|
|
2257
|
+
"[:upper:]": ["\\p{Lu}", !0],
|
|
2258
|
+
"[:word:]": ["\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}", !0],
|
|
2259
|
+
"[:xdigit:]": ["A-Fa-f0-9", !1]
|
|
2260
|
+
};
|
|
2261
|
+
var lt = (n) => n.replace(/[[\]\\-]/g, "\\$&");
|
|
2262
|
+
var Es = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2263
|
+
var we = (n) => n.join("");
|
|
2264
|
+
var ye = (n, t) => {
|
|
2265
|
+
let e = t;
|
|
2266
|
+
if (n.charAt(e) !== "[") throw new Error("not in a brace expression");
|
|
2267
|
+
let s = [], i = [], r = e + 1, o = !1, h = !1, a = !1, l = !1, u = e, c = "";
|
|
2268
|
+
t: for (; r < n.length;) {
|
|
2269
|
+
let p = n.charAt(r);
|
|
2270
|
+
if ((p === "!" || p === "^") && r === e + 1) {
|
|
2271
|
+
l = !0, r++;
|
|
2272
|
+
continue;
|
|
2273
|
+
}
|
|
2274
|
+
if (p === "]" && o && !a) {
|
|
2275
|
+
u = r + 1;
|
|
2276
|
+
break;
|
|
2277
|
+
}
|
|
2278
|
+
if (o = !0, p === "\\" && !a) {
|
|
2279
|
+
a = !0, r++;
|
|
2280
|
+
continue;
|
|
2281
|
+
}
|
|
2282
|
+
if (p === "[" && !a) {
|
|
2283
|
+
for (let [w, [g, S, E]] of Object.entries(Ss)) if (n.startsWith(w, r)) {
|
|
2284
|
+
if (c) return [
|
|
2285
|
+
"$.",
|
|
2286
|
+
!1,
|
|
2287
|
+
n.length - e,
|
|
2288
|
+
!0
|
|
2289
|
+
];
|
|
2290
|
+
r += w.length, E ? i.push(g) : s.push(g), h = h || S;
|
|
2291
|
+
continue t;
|
|
2292
|
+
}
|
|
2293
|
+
}
|
|
2294
|
+
if (a = !1, c) {
|
|
2295
|
+
p > c ? s.push(lt(c) + "-" + lt(p)) : p === c && s.push(lt(p)), c = "", r++;
|
|
2296
|
+
continue;
|
|
2297
|
+
}
|
|
2298
|
+
if (n.startsWith("-]", r + 1)) {
|
|
2299
|
+
s.push(lt(p + "-")), r += 2;
|
|
2300
|
+
continue;
|
|
2301
|
+
}
|
|
2302
|
+
if (n.startsWith("-", r + 1)) {
|
|
2303
|
+
c = p, r += 2;
|
|
2304
|
+
continue;
|
|
2305
|
+
}
|
|
2306
|
+
s.push(lt(p)), r++;
|
|
2307
|
+
}
|
|
2308
|
+
if (u < r) return [
|
|
2309
|
+
"",
|
|
2310
|
+
!1,
|
|
2311
|
+
0,
|
|
2312
|
+
!1
|
|
2313
|
+
];
|
|
2314
|
+
if (!s.length && !i.length) return [
|
|
2315
|
+
"$.",
|
|
2316
|
+
!1,
|
|
2317
|
+
n.length - e,
|
|
2318
|
+
!0
|
|
2319
|
+
];
|
|
2320
|
+
if (i.length === 0 && s.length === 1 && /^\\?.$/.test(s[0]) && !l) return [
|
|
2321
|
+
Es(s[0].length === 2 ? s[0].slice(-1) : s[0]),
|
|
2322
|
+
!1,
|
|
2323
|
+
u - e,
|
|
2324
|
+
!1
|
|
2325
|
+
];
|
|
2326
|
+
let d = "[" + (l ? "^" : "") + we(s) + "]", f = "[" + (l ? "" : "^") + we(i) + "]";
|
|
2327
|
+
return [
|
|
2328
|
+
s.length && i.length ? "(" + d + "|" + f + ")" : s.length ? d : f,
|
|
2329
|
+
h,
|
|
2330
|
+
u - e,
|
|
2331
|
+
!0
|
|
2332
|
+
];
|
|
2333
|
+
};
|
|
2334
|
+
var W = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !0 } = {}) => e ? t ? n.replace(/\[([^\/\\])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\])\]/g, "$1$2").replace(/\\([^\/])/g, "$1") : t ? n.replace(/\[([^\/\\{}])\]/g, "$1") : n.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, "$1$2").replace(/\\([^\/{}])/g, "$1");
|
|
2335
|
+
var xs = /* @__PURE__ */ new Set([
|
|
2336
|
+
"!",
|
|
2337
|
+
"?",
|
|
2338
|
+
"+",
|
|
2339
|
+
"*",
|
|
2340
|
+
"@"
|
|
2341
|
+
]);
|
|
2342
|
+
var be = (n) => xs.has(n);
|
|
2343
|
+
var vs = "(?!(?:^|/)\\.\\.?(?:$|/))";
|
|
2344
|
+
var Ct = "(?!\\.)";
|
|
2345
|
+
var Cs = /* @__PURE__ */ new Set(["[", "."]);
|
|
2346
|
+
var Ts = /* @__PURE__ */ new Set(["..", "."]);
|
|
2347
|
+
var As = /* @__PURE__ */ new Set("().*{}+?[]^$\\!");
|
|
2348
|
+
var ks = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2349
|
+
var Kt = "[^/]";
|
|
2350
|
+
var Se = Kt + "*?";
|
|
2351
|
+
var Ee = Kt + "+?";
|
|
2352
|
+
var Q = class n {
|
|
2353
|
+
type;
|
|
2354
|
+
#t;
|
|
2355
|
+
#s;
|
|
2356
|
+
#n = !1;
|
|
2357
|
+
#r = [];
|
|
2358
|
+
#o;
|
|
2359
|
+
#S;
|
|
2360
|
+
#w;
|
|
2361
|
+
#c = !1;
|
|
2362
|
+
#h;
|
|
2363
|
+
#u;
|
|
2364
|
+
#f = !1;
|
|
2365
|
+
constructor(t, e, s = {}) {
|
|
2366
|
+
this.type = t, t && (this.#s = !0), this.#o = e, this.#t = this.#o ? this.#o.#t : this, this.#h = this.#t === this ? s : this.#t.#h, this.#w = this.#t === this ? [] : this.#t.#w, t === "!" && !this.#t.#c && this.#w.push(this), this.#S = this.#o ? this.#o.#r.length : 0;
|
|
2367
|
+
}
|
|
2368
|
+
get hasMagic() {
|
|
2369
|
+
if (this.#s !== void 0) return this.#s;
|
|
2370
|
+
for (let t of this.#r) if (typeof t != "string" && (t.type || t.hasMagic)) return this.#s = !0;
|
|
2371
|
+
return this.#s;
|
|
2372
|
+
}
|
|
2373
|
+
toString() {
|
|
2374
|
+
return this.#u !== void 0 ? this.#u : this.type ? this.#u = this.type + "(" + this.#r.map((t) => String(t)).join("|") + ")" : this.#u = this.#r.map((t) => String(t)).join("");
|
|
2375
|
+
}
|
|
2376
|
+
#a() {
|
|
2377
|
+
if (this !== this.#t) throw new Error("should only call on root");
|
|
2378
|
+
if (this.#c) return this;
|
|
2379
|
+
this.toString(), this.#c = !0;
|
|
2380
|
+
let t;
|
|
2381
|
+
for (; t = this.#w.pop();) {
|
|
2382
|
+
if (t.type !== "!") continue;
|
|
2383
|
+
let e = t, s = e.#o;
|
|
2384
|
+
for (; s;) {
|
|
2385
|
+
for (let i = e.#S + 1; !s.type && i < s.#r.length; i++) for (let r of t.#r) {
|
|
2386
|
+
if (typeof r == "string") throw new Error("string part in extglob AST??");
|
|
2387
|
+
r.copyIn(s.#r[i]);
|
|
2388
|
+
}
|
|
2389
|
+
e = s, s = e.#o;
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
return this;
|
|
2393
|
+
}
|
|
2394
|
+
push(...t) {
|
|
2395
|
+
for (let e of t) if (e !== "") {
|
|
2396
|
+
if (typeof e != "string" && !(e instanceof n && e.#o === this)) throw new Error("invalid part: " + e);
|
|
2397
|
+
this.#r.push(e);
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2400
|
+
toJSON() {
|
|
2401
|
+
let t = this.type === null ? this.#r.slice().map((e) => typeof e == "string" ? e : e.toJSON()) : [this.type, ...this.#r.map((e) => e.toJSON())];
|
|
2402
|
+
return this.isStart() && !this.type && t.unshift([]), this.isEnd() && (this === this.#t || this.#t.#c && this.#o?.type === "!") && t.push({}), t;
|
|
2403
|
+
}
|
|
2404
|
+
isStart() {
|
|
2405
|
+
if (this.#t === this) return !0;
|
|
2406
|
+
if (!this.#o?.isStart()) return !1;
|
|
2407
|
+
if (this.#S === 0) return !0;
|
|
2408
|
+
let t = this.#o;
|
|
2409
|
+
for (let e = 0; e < this.#S; e++) {
|
|
2410
|
+
let s = t.#r[e];
|
|
2411
|
+
if (!(s instanceof n && s.type === "!")) return !1;
|
|
2412
|
+
}
|
|
2413
|
+
return !0;
|
|
2414
|
+
}
|
|
2415
|
+
isEnd() {
|
|
2416
|
+
if (this.#t === this || this.#o?.type === "!") return !0;
|
|
2417
|
+
if (!this.#o?.isEnd()) return !1;
|
|
2418
|
+
if (!this.type) return this.#o?.isEnd();
|
|
2419
|
+
let t = this.#o ? this.#o.#r.length : 0;
|
|
2420
|
+
return this.#S === t - 1;
|
|
2421
|
+
}
|
|
2422
|
+
copyIn(t) {
|
|
2423
|
+
typeof t == "string" ? this.push(t) : this.push(t.clone(this));
|
|
2424
|
+
}
|
|
2425
|
+
clone(t) {
|
|
2426
|
+
let e = new n(this.type, t);
|
|
2427
|
+
for (let s of this.#r) e.copyIn(s);
|
|
2428
|
+
return e;
|
|
2429
|
+
}
|
|
2430
|
+
static #i(t, e, s, i) {
|
|
2431
|
+
let r = !1, o = !1, h = -1, a = !1;
|
|
2432
|
+
if (e.type === null) {
|
|
2433
|
+
let f = s, m = "";
|
|
2434
|
+
for (; f < t.length;) {
|
|
2435
|
+
let p = t.charAt(f++);
|
|
2436
|
+
if (r || p === "\\") {
|
|
2437
|
+
r = !r, m += p;
|
|
2438
|
+
continue;
|
|
2439
|
+
}
|
|
2440
|
+
if (o) {
|
|
2441
|
+
f === h + 1 ? (p === "^" || p === "!") && (a = !0) : p === "]" && !(f === h + 2 && a) && (o = !1), m += p;
|
|
2442
|
+
continue;
|
|
2443
|
+
} else if (p === "[") {
|
|
2444
|
+
o = !0, h = f, a = !1, m += p;
|
|
2445
|
+
continue;
|
|
2446
|
+
}
|
|
2447
|
+
if (!i.noext && be(p) && t.charAt(f) === "(") {
|
|
2448
|
+
e.push(m), m = "";
|
|
2449
|
+
let w = new n(p, e);
|
|
2450
|
+
f = n.#i(t, w, f, i), e.push(w);
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
m += p;
|
|
2454
|
+
}
|
|
2455
|
+
return e.push(m), f;
|
|
2456
|
+
}
|
|
2457
|
+
let l = s + 1, u = new n(null, e), c = [], d = "";
|
|
2458
|
+
for (; l < t.length;) {
|
|
2459
|
+
let f = t.charAt(l++);
|
|
2460
|
+
if (r || f === "\\") {
|
|
2461
|
+
r = !r, d += f;
|
|
2462
|
+
continue;
|
|
2463
|
+
}
|
|
2464
|
+
if (o) {
|
|
2465
|
+
l === h + 1 ? (f === "^" || f === "!") && (a = !0) : f === "]" && !(l === h + 2 && a) && (o = !1), d += f;
|
|
2466
|
+
continue;
|
|
2467
|
+
} else if (f === "[") {
|
|
2468
|
+
o = !0, h = l, a = !1, d += f;
|
|
2469
|
+
continue;
|
|
2470
|
+
}
|
|
2471
|
+
if (be(f) && t.charAt(l) === "(") {
|
|
2472
|
+
u.push(d), d = "";
|
|
2473
|
+
let m = new n(f, u);
|
|
2474
|
+
u.push(m), l = n.#i(t, m, l, i);
|
|
2475
|
+
continue;
|
|
2476
|
+
}
|
|
2477
|
+
if (f === "|") {
|
|
2478
|
+
u.push(d), d = "", c.push(u), u = new n(null, e);
|
|
2479
|
+
continue;
|
|
2480
|
+
}
|
|
2481
|
+
if (f === ")") return d === "" && e.#r.length === 0 && (e.#f = !0), u.push(d), d = "", e.push(...c, u), l;
|
|
2482
|
+
d += f;
|
|
2483
|
+
}
|
|
2484
|
+
return e.type = null, e.#s = void 0, e.#r = [t.substring(s - 1)], l;
|
|
2485
|
+
}
|
|
2486
|
+
static fromGlob(t, e = {}) {
|
|
2487
|
+
let s = new n(null, void 0, e);
|
|
2488
|
+
return n.#i(t, s, 0, e), s;
|
|
2489
|
+
}
|
|
2490
|
+
toMMPattern() {
|
|
2491
|
+
if (this !== this.#t) return this.#t.toMMPattern();
|
|
2492
|
+
let t = this.toString(), [e, s, i, r] = this.toRegExpSource();
|
|
2493
|
+
if (!(i || this.#s || this.#h.nocase && !this.#h.nocaseMagicOnly && t.toUpperCase() !== t.toLowerCase())) return s;
|
|
2494
|
+
let h = (this.#h.nocase ? "i" : "") + (r ? "u" : "");
|
|
2495
|
+
return Object.assign(new RegExp(`^${e}$`, h), {
|
|
2496
|
+
_src: e,
|
|
2497
|
+
_glob: t
|
|
2498
|
+
});
|
|
2499
|
+
}
|
|
2500
|
+
get options() {
|
|
2501
|
+
return this.#h;
|
|
2502
|
+
}
|
|
2503
|
+
toRegExpSource(t) {
|
|
2504
|
+
let e = t ?? !!this.#h.dot;
|
|
2505
|
+
if (this.#t === this && this.#a(), !this.type) {
|
|
2506
|
+
let a = this.isStart() && this.isEnd() && !this.#r.some((f) => typeof f != "string"), l = this.#r.map((f) => {
|
|
2507
|
+
let [m, p, w, g] = typeof f == "string" ? n.#E(f, this.#s, a) : f.toRegExpSource(t);
|
|
2508
|
+
return this.#s = this.#s || w, this.#n = this.#n || g, m;
|
|
2509
|
+
}).join(""), u = "";
|
|
2510
|
+
if (this.isStart() && typeof this.#r[0] == "string" && !(this.#r.length === 1 && Ts.has(this.#r[0]))) {
|
|
2511
|
+
let m = Cs, p = e && m.has(l.charAt(0)) || l.startsWith("\\.") && m.has(l.charAt(2)) || l.startsWith("\\.\\.") && m.has(l.charAt(4)), w = !e && !t && m.has(l.charAt(0));
|
|
2512
|
+
u = p ? vs : w ? Ct : "";
|
|
2513
|
+
}
|
|
2514
|
+
let c = "";
|
|
2515
|
+
return this.isEnd() && this.#t.#c && this.#o?.type === "!" && (c = "(?:$|\\/)"), [
|
|
2516
|
+
u + l + c,
|
|
2517
|
+
W(l),
|
|
2518
|
+
this.#s = !!this.#s,
|
|
2519
|
+
this.#n
|
|
2520
|
+
];
|
|
2521
|
+
}
|
|
2522
|
+
let s = this.type === "*" || this.type === "+", i = this.type === "!" ? "(?:(?!(?:" : "(?:", r = this.#d(e);
|
|
2523
|
+
if (this.isStart() && this.isEnd() && !r && this.type !== "!") {
|
|
2524
|
+
let a = this.toString();
|
|
2525
|
+
return this.#r = [a], this.type = null, this.#s = void 0, [
|
|
2526
|
+
a,
|
|
2527
|
+
W(this.toString()),
|
|
2528
|
+
!1,
|
|
2529
|
+
!1
|
|
2530
|
+
];
|
|
2531
|
+
}
|
|
2532
|
+
let o = !s || t || e || !Ct ? "" : this.#d(!0);
|
|
2533
|
+
o === r && (o = ""), o && (r = `(?:${r})(?:${o})*?`);
|
|
2534
|
+
let h = "";
|
|
2535
|
+
if (this.type === "!" && this.#f) h = (this.isStart() && !e ? Ct : "") + Ee;
|
|
2536
|
+
else {
|
|
2537
|
+
let a = this.type === "!" ? "))" + (this.isStart() && !e && !t ? Ct : "") + Se + ")" : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && o ? ")" : this.type === "*" && o ? ")?" : `)${this.type}`;
|
|
2538
|
+
h = i + r + a;
|
|
2539
|
+
}
|
|
2540
|
+
return [
|
|
2541
|
+
h,
|
|
2542
|
+
W(r),
|
|
2543
|
+
this.#s = !!this.#s,
|
|
2544
|
+
this.#n
|
|
2545
|
+
];
|
|
2546
|
+
}
|
|
2547
|
+
#d(t) {
|
|
2548
|
+
return this.#r.map((e) => {
|
|
2549
|
+
if (typeof e == "string") throw new Error("string type in extglob ast??");
|
|
2550
|
+
let [s, i, r, o] = e.toRegExpSource(t);
|
|
2551
|
+
return this.#n = this.#n || o, s;
|
|
2552
|
+
}).filter((e) => !(this.isStart() && this.isEnd()) || !!e).join("|");
|
|
2553
|
+
}
|
|
2554
|
+
static #E(t, e, s = !1) {
|
|
2555
|
+
let i = !1, r = "", o = !1, h = !1;
|
|
2556
|
+
for (let a = 0; a < t.length; a++) {
|
|
2557
|
+
let l = t.charAt(a);
|
|
2558
|
+
if (i) {
|
|
2559
|
+
i = !1, r += (As.has(l) ? "\\" : "") + l;
|
|
2560
|
+
continue;
|
|
2561
|
+
}
|
|
2562
|
+
if (l === "*") {
|
|
2563
|
+
if (h) continue;
|
|
2564
|
+
h = !0, r += s && /^[*]+$/.test(t) ? Ee : Se, e = !0;
|
|
2565
|
+
continue;
|
|
2566
|
+
} else h = !1;
|
|
2567
|
+
if (l === "\\") {
|
|
2568
|
+
a === t.length - 1 ? r += "\\\\" : i = !0;
|
|
2569
|
+
continue;
|
|
2570
|
+
}
|
|
2571
|
+
if (l === "[") {
|
|
2572
|
+
let [u, c, d, f] = ye(t, a);
|
|
2573
|
+
if (d) {
|
|
2574
|
+
r += u, o = o || c, a += d - 1, e = e || f;
|
|
2575
|
+
continue;
|
|
2576
|
+
}
|
|
2577
|
+
}
|
|
2578
|
+
if (l === "?") {
|
|
2579
|
+
r += Kt, e = !0;
|
|
2580
|
+
continue;
|
|
2581
|
+
}
|
|
2582
|
+
r += ks(l);
|
|
2583
|
+
}
|
|
2584
|
+
return [
|
|
2585
|
+
r,
|
|
2586
|
+
W(t),
|
|
2587
|
+
!!e,
|
|
2588
|
+
o
|
|
2589
|
+
];
|
|
2590
|
+
}
|
|
2591
|
+
};
|
|
2592
|
+
var tt = (n, { windowsPathsNoEscape: t = !1, magicalBraces: e = !1 } = {}) => e ? t ? n.replace(/[?*()[\]{}]/g, "[$&]") : n.replace(/[?*()[\]\\{}]/g, "\\$&") : t ? n.replace(/[?*()[\]]/g, "[$&]") : n.replace(/[?*()[\]\\]/g, "\\$&");
|
|
2593
|
+
var O = (n, t, e = {}) => (at(t), !e.nocomment && t.charAt(0) === "#" ? !1 : new D(t, e).match(n));
|
|
2594
|
+
var Rs = /^\*+([^+@!?\*\[\(]*)$/;
|
|
2595
|
+
var Os = (n) => (t) => !t.startsWith(".") && t.endsWith(n);
|
|
2596
|
+
var Fs = (n) => (t) => t.endsWith(n);
|
|
2597
|
+
var Ds = (n) => (n = n.toLowerCase(), (t) => !t.startsWith(".") && t.toLowerCase().endsWith(n));
|
|
2598
|
+
var Ms = (n) => (n = n.toLowerCase(), (t) => t.toLowerCase().endsWith(n));
|
|
2599
|
+
var Ns = /^\*+\.\*+$/;
|
|
2600
|
+
var _s = (n) => !n.startsWith(".") && n.includes(".");
|
|
2601
|
+
var Ls = (n) => n !== "." && n !== ".." && n.includes(".");
|
|
2602
|
+
var Ws = /^\.\*+$/;
|
|
2603
|
+
var Ps = (n) => n !== "." && n !== ".." && n.startsWith(".");
|
|
2604
|
+
var js = /^\*+$/;
|
|
2605
|
+
var Is = (n) => n.length !== 0 && !n.startsWith(".");
|
|
2606
|
+
var zs = (n) => n.length !== 0 && n !== "." && n !== "..";
|
|
2607
|
+
var Bs = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
2608
|
+
var Us = ([n, t = ""]) => {
|
|
2609
|
+
let e = Ce([n]);
|
|
2610
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
2611
|
+
};
|
|
2612
|
+
var $s = ([n, t = ""]) => {
|
|
2613
|
+
let e = Te([n]);
|
|
2614
|
+
return t ? (t = t.toLowerCase(), (s) => e(s) && s.toLowerCase().endsWith(t)) : e;
|
|
2615
|
+
};
|
|
2616
|
+
var Gs = ([n, t = ""]) => {
|
|
2617
|
+
let e = Te([n]);
|
|
2618
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
2619
|
+
};
|
|
2620
|
+
var Hs = ([n, t = ""]) => {
|
|
2621
|
+
let e = Ce([n]);
|
|
2622
|
+
return t ? (s) => e(s) && s.endsWith(t) : e;
|
|
2623
|
+
};
|
|
2624
|
+
var Ce = ([n]) => {
|
|
2625
|
+
let t = n.length;
|
|
2626
|
+
return (e) => e.length === t && !e.startsWith(".");
|
|
2627
|
+
};
|
|
2628
|
+
var Te = ([n]) => {
|
|
2629
|
+
let t = n.length;
|
|
2630
|
+
return (e) => e.length === t && e !== "." && e !== "..";
|
|
2631
|
+
};
|
|
2632
|
+
var Ae = typeof process == "object" && process ? typeof process.env == "object" && process.env && process.env.__MINIMATCH_TESTING_PLATFORM__ || process.platform : "posix";
|
|
2633
|
+
var xe = {
|
|
2634
|
+
win32: { sep: "\\" },
|
|
2635
|
+
posix: { sep: "/" }
|
|
2636
|
+
};
|
|
2637
|
+
O.sep = Ae === "win32" ? xe.win32.sep : xe.posix.sep;
|
|
2638
|
+
var A = Symbol("globstar **");
|
|
2639
|
+
O.GLOBSTAR = A;
|
|
2640
|
+
var Vs = "[^/]*?";
|
|
2641
|
+
var Ys = "(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?";
|
|
2642
|
+
var Xs = "(?:(?!(?:\\/|^)\\.).)*?";
|
|
2643
|
+
var Js = (n, t = {}) => (e) => O(e, n, t);
|
|
2644
|
+
O.filter = Js;
|
|
2645
|
+
var N = (n, t = {}) => Object.assign({}, n, t);
|
|
2646
|
+
var Zs = (n) => {
|
|
2647
|
+
if (!n || typeof n != "object" || !Object.keys(n).length) return O;
|
|
2648
|
+
let t = O;
|
|
2649
|
+
return Object.assign((s, i, r = {}) => t(s, i, N(n, r)), {
|
|
2650
|
+
Minimatch: class extends t.Minimatch {
|
|
2651
|
+
constructor(i, r = {}) {
|
|
2652
|
+
super(i, N(n, r));
|
|
2653
|
+
}
|
|
2654
|
+
static defaults(i) {
|
|
2655
|
+
return t.defaults(N(n, i)).Minimatch;
|
|
2656
|
+
}
|
|
2657
|
+
},
|
|
2658
|
+
AST: class extends t.AST {
|
|
2659
|
+
constructor(i, r, o = {}) {
|
|
2660
|
+
super(i, r, N(n, o));
|
|
2661
|
+
}
|
|
2662
|
+
static fromGlob(i, r = {}) {
|
|
2663
|
+
return t.AST.fromGlob(i, N(n, r));
|
|
2664
|
+
}
|
|
2665
|
+
},
|
|
2666
|
+
unescape: (s, i = {}) => t.unescape(s, N(n, i)),
|
|
2667
|
+
escape: (s, i = {}) => t.escape(s, N(n, i)),
|
|
2668
|
+
filter: (s, i = {}) => t.filter(s, N(n, i)),
|
|
2669
|
+
defaults: (s) => t.defaults(N(n, s)),
|
|
2670
|
+
makeRe: (s, i = {}) => t.makeRe(s, N(n, i)),
|
|
2671
|
+
braceExpand: (s, i = {}) => t.braceExpand(s, N(n, i)),
|
|
2672
|
+
match: (s, i, r = {}) => t.match(s, i, N(n, r)),
|
|
2673
|
+
sep: t.sep,
|
|
2674
|
+
GLOBSTAR: A
|
|
2675
|
+
});
|
|
2676
|
+
};
|
|
2677
|
+
O.defaults = Zs;
|
|
2678
|
+
var ke = (n, t = {}) => (at(n), t.nobrace || !/\{(?:(?!\{).)*\}/.test(n) ? [n] : ge(n, { max: t.braceExpandMax }));
|
|
2679
|
+
O.braceExpand = ke;
|
|
2680
|
+
var Qs = (n, t = {}) => new D(n, t).makeRe();
|
|
2681
|
+
O.makeRe = Qs;
|
|
2682
|
+
var ti = (n, t, e = {}) => {
|
|
2683
|
+
let s = new D(t, e);
|
|
2684
|
+
return n = n.filter((i) => s.match(i)), s.options.nonull && !n.length && n.push(t), n;
|
|
2685
|
+
};
|
|
2686
|
+
O.match = ti;
|
|
2687
|
+
var ve = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
2688
|
+
var ei = (n) => n.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
|
2689
|
+
var D = class {
|
|
2690
|
+
options;
|
|
2691
|
+
set;
|
|
2692
|
+
pattern;
|
|
2693
|
+
windowsPathsNoEscape;
|
|
2694
|
+
nonegate;
|
|
2695
|
+
negate;
|
|
2696
|
+
comment;
|
|
2697
|
+
empty;
|
|
2698
|
+
preserveMultipleSlashes;
|
|
2699
|
+
partial;
|
|
2700
|
+
globSet;
|
|
2701
|
+
globParts;
|
|
2702
|
+
nocase;
|
|
2703
|
+
isWindows;
|
|
2704
|
+
platform;
|
|
2705
|
+
windowsNoMagicRoot;
|
|
2706
|
+
regexp;
|
|
2707
|
+
constructor(t, e = {}) {
|
|
2708
|
+
at(t), e = e || {}, this.options = e, this.pattern = t, this.platform = e.platform || Ae, this.isWindows = this.platform === "win32";
|
|
2709
|
+
let s = "allowWindowsEscape";
|
|
2710
|
+
this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e[s] === !1, this.windowsPathsNoEscape && (this.pattern = this.pattern.replace(/\\/g, "/")), this.preserveMultipleSlashes = !!e.preserveMultipleSlashes, this.regexp = null, this.negate = !1, this.nonegate = !!e.nonegate, this.comment = !1, this.empty = !1, this.partial = !!e.partial, this.nocase = !!this.options.nocase, this.windowsNoMagicRoot = e.windowsNoMagicRoot !== void 0 ? e.windowsNoMagicRoot : !!(this.isWindows && this.nocase), this.globSet = [], this.globParts = [], this.set = [], this.make();
|
|
2711
|
+
}
|
|
2712
|
+
hasMagic() {
|
|
2713
|
+
if (this.options.magicalBraces && this.set.length > 1) return !0;
|
|
2714
|
+
for (let t of this.set) for (let e of t) if (typeof e != "string") return !0;
|
|
2715
|
+
return !1;
|
|
2716
|
+
}
|
|
2717
|
+
debug(...t) {}
|
|
2718
|
+
make() {
|
|
2719
|
+
let t = this.pattern, e = this.options;
|
|
2720
|
+
if (!e.nocomment && t.charAt(0) === "#") {
|
|
2721
|
+
this.comment = !0;
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
if (!t) {
|
|
2725
|
+
this.empty = !0;
|
|
2726
|
+
return;
|
|
2727
|
+
}
|
|
2728
|
+
this.parseNegate(), this.globSet = [...new Set(this.braceExpand())], e.debug && (this.debug = (...r) => console.error(...r)), this.debug(this.pattern, this.globSet);
|
|
2729
|
+
let s = this.globSet.map((r) => this.slashSplit(r));
|
|
2730
|
+
this.globParts = this.preprocess(s), this.debug(this.pattern, this.globParts);
|
|
2731
|
+
let i = this.globParts.map((r, o, h) => {
|
|
2732
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
2733
|
+
let a = r[0] === "" && r[1] === "" && (r[2] === "?" || !ve.test(r[2])) && !ve.test(r[3]), l = /^[a-z]:/i.test(r[0]);
|
|
2734
|
+
if (a) return [...r.slice(0, 4), ...r.slice(4).map((u) => this.parse(u))];
|
|
2735
|
+
if (l) return [r[0], ...r.slice(1).map((u) => this.parse(u))];
|
|
2736
|
+
}
|
|
2737
|
+
return r.map((a) => this.parse(a));
|
|
2738
|
+
});
|
|
2739
|
+
if (this.debug(this.pattern, i), this.set = i.filter((r) => r.indexOf(!1) === -1), this.isWindows) for (let r = 0; r < this.set.length; r++) {
|
|
2740
|
+
let o = this.set[r];
|
|
2741
|
+
o[0] === "" && o[1] === "" && this.globParts[r][2] === "?" && typeof o[3] == "string" && /^[a-z]:$/i.test(o[3]) && (o[2] = "?");
|
|
2742
|
+
}
|
|
2743
|
+
this.debug(this.pattern, this.set);
|
|
2744
|
+
}
|
|
2745
|
+
preprocess(t) {
|
|
2746
|
+
if (this.options.noglobstar) for (let s = 0; s < t.length; s++) for (let i = 0; i < t[s].length; i++) t[s][i] === "**" && (t[s][i] = "*");
|
|
2747
|
+
let { optimizationLevel: e = 1 } = this.options;
|
|
2748
|
+
return e >= 2 ? (t = this.firstPhasePreProcess(t), t = this.secondPhasePreProcess(t)) : e >= 1 ? t = this.levelOneOptimize(t) : t = this.adjascentGlobstarOptimize(t), t;
|
|
2749
|
+
}
|
|
2750
|
+
adjascentGlobstarOptimize(t) {
|
|
2751
|
+
return t.map((e) => {
|
|
2752
|
+
let s = -1;
|
|
2753
|
+
for (; (s = e.indexOf("**", s + 1)) !== -1;) {
|
|
2754
|
+
let i = s;
|
|
2755
|
+
for (; e[i + 1] === "**";) i++;
|
|
2756
|
+
i !== s && e.splice(s, i - s);
|
|
2757
|
+
}
|
|
2758
|
+
return e;
|
|
2759
|
+
});
|
|
2760
|
+
}
|
|
2761
|
+
levelOneOptimize(t) {
|
|
2762
|
+
return t.map((e) => (e = e.reduce((s, i) => {
|
|
2763
|
+
let r = s[s.length - 1];
|
|
2764
|
+
return i === "**" && r === "**" ? s : i === ".." && r && r !== ".." && r !== "." && r !== "**" ? (s.pop(), s) : (s.push(i), s);
|
|
2765
|
+
}, []), e.length === 0 ? [""] : e));
|
|
2766
|
+
}
|
|
2767
|
+
levelTwoFileOptimize(t) {
|
|
2768
|
+
Array.isArray(t) || (t = this.slashSplit(t));
|
|
2769
|
+
let e = !1;
|
|
2770
|
+
do {
|
|
2771
|
+
if (e = !1, !this.preserveMultipleSlashes) {
|
|
2772
|
+
for (let i = 1; i < t.length - 1; i++) {
|
|
2773
|
+
let r = t[i];
|
|
2774
|
+
i === 1 && r === "" && t[0] === "" || (r === "." || r === "") && (e = !0, t.splice(i, 1), i--);
|
|
2775
|
+
}
|
|
2776
|
+
t[0] === "." && t.length === 2 && (t[1] === "." || t[1] === "") && (e = !0, t.pop());
|
|
2777
|
+
}
|
|
2778
|
+
let s = 0;
|
|
2779
|
+
for (; (s = t.indexOf("..", s + 1)) !== -1;) {
|
|
2780
|
+
let i = t[s - 1];
|
|
2781
|
+
i && i !== "." && i !== ".." && i !== "**" && (e = !0, t.splice(s - 1, 2), s -= 2);
|
|
2782
|
+
}
|
|
2783
|
+
} while (e);
|
|
2784
|
+
return t.length === 0 ? [""] : t;
|
|
2785
|
+
}
|
|
2786
|
+
firstPhasePreProcess(t) {
|
|
2787
|
+
let e = !1;
|
|
2788
|
+
do {
|
|
2789
|
+
e = !1;
|
|
2790
|
+
for (let s of t) {
|
|
2791
|
+
let i = -1;
|
|
2792
|
+
for (; (i = s.indexOf("**", i + 1)) !== -1;) {
|
|
2793
|
+
let o = i;
|
|
2794
|
+
for (; s[o + 1] === "**";) o++;
|
|
2795
|
+
o > i && s.splice(i + 1, o - i);
|
|
2796
|
+
let h = s[i + 1], a = s[i + 2], l = s[i + 3];
|
|
2797
|
+
if (h !== ".." || !a || a === "." || a === ".." || !l || l === "." || l === "..") continue;
|
|
2798
|
+
e = !0, s.splice(i, 1);
|
|
2799
|
+
let u = s.slice(0);
|
|
2800
|
+
u[i] = "**", t.push(u), i--;
|
|
2801
|
+
}
|
|
2802
|
+
if (!this.preserveMultipleSlashes) {
|
|
2803
|
+
for (let o = 1; o < s.length - 1; o++) {
|
|
2804
|
+
let h = s[o];
|
|
2805
|
+
o === 1 && h === "" && s[0] === "" || (h === "." || h === "") && (e = !0, s.splice(o, 1), o--);
|
|
2806
|
+
}
|
|
2807
|
+
s[0] === "." && s.length === 2 && (s[1] === "." || s[1] === "") && (e = !0, s.pop());
|
|
2808
|
+
}
|
|
2809
|
+
let r = 0;
|
|
2810
|
+
for (; (r = s.indexOf("..", r + 1)) !== -1;) {
|
|
2811
|
+
let o = s[r - 1];
|
|
2812
|
+
if (o && o !== "." && o !== ".." && o !== "**") {
|
|
2813
|
+
e = !0;
|
|
2814
|
+
let a = r === 1 && s[r + 1] === "**" ? ["."] : [];
|
|
2815
|
+
s.splice(r - 1, 2, ...a), s.length === 0 && s.push(""), r -= 2;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
} while (e);
|
|
2820
|
+
return t;
|
|
2821
|
+
}
|
|
2822
|
+
secondPhasePreProcess(t) {
|
|
2823
|
+
for (let e = 0; e < t.length - 1; e++) for (let s = e + 1; s < t.length; s++) {
|
|
2824
|
+
let i = this.partsMatch(t[e], t[s], !this.preserveMultipleSlashes);
|
|
2825
|
+
if (i) {
|
|
2826
|
+
t[e] = [], t[s] = i;
|
|
2827
|
+
break;
|
|
2828
|
+
}
|
|
2829
|
+
}
|
|
2830
|
+
return t.filter((e) => e.length);
|
|
2831
|
+
}
|
|
2832
|
+
partsMatch(t, e, s = !1) {
|
|
2833
|
+
let i = 0, r = 0, o = [], h = "";
|
|
2834
|
+
for (; i < t.length && r < e.length;) if (t[i] === e[r]) o.push(h === "b" ? e[r] : t[i]), i++, r++;
|
|
2835
|
+
else if (s && t[i] === "**" && e[r] === t[i + 1]) o.push(t[i]), i++;
|
|
2836
|
+
else if (s && e[r] === "**" && t[i] === e[r + 1]) o.push(e[r]), r++;
|
|
2837
|
+
else if (t[i] === "*" && e[r] && (this.options.dot || !e[r].startsWith(".")) && e[r] !== "**") {
|
|
2838
|
+
if (h === "b") return !1;
|
|
2839
|
+
h = "a", o.push(t[i]), i++, r++;
|
|
2840
|
+
} else if (e[r] === "*" && t[i] && (this.options.dot || !t[i].startsWith(".")) && t[i] !== "**") {
|
|
2841
|
+
if (h === "a") return !1;
|
|
2842
|
+
h = "b", o.push(e[r]), i++, r++;
|
|
2843
|
+
} else return !1;
|
|
2844
|
+
return t.length === e.length && o;
|
|
2845
|
+
}
|
|
2846
|
+
parseNegate() {
|
|
2847
|
+
if (this.nonegate) return;
|
|
2848
|
+
let t = this.pattern, e = !1, s = 0;
|
|
2849
|
+
for (let i = 0; i < t.length && t.charAt(i) === "!"; i++) e = !e, s++;
|
|
2850
|
+
s && (this.pattern = t.slice(s)), this.negate = e;
|
|
2851
|
+
}
|
|
2852
|
+
matchOne(t, e, s = !1) {
|
|
2853
|
+
let i = this.options;
|
|
2854
|
+
if (this.isWindows) {
|
|
2855
|
+
let p = typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]), w = !p && t[0] === "" && t[1] === "" && t[2] === "?" && /^[a-z]:$/i.test(t[3]), g = typeof e[0] == "string" && /^[a-z]:$/i.test(e[0]), S = !g && e[0] === "" && e[1] === "" && e[2] === "?" && typeof e[3] == "string" && /^[a-z]:$/i.test(e[3]), E = w ? 3 : p ? 0 : void 0, y = S ? 3 : g ? 0 : void 0;
|
|
2856
|
+
if (typeof E == "number" && typeof y == "number") {
|
|
2857
|
+
let [b, z] = [t[E], e[y]];
|
|
2858
|
+
b.toLowerCase() === z.toLowerCase() && (e[y] = b, y > E ? e = e.slice(y) : E > y && (t = t.slice(E)));
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
let { optimizationLevel: r = 1 } = this.options;
|
|
2862
|
+
r >= 2 && (t = this.levelTwoFileOptimize(t)), this.debug("matchOne", this, {
|
|
2863
|
+
file: t,
|
|
2864
|
+
pattern: e
|
|
2865
|
+
}), this.debug("matchOne", t.length, e.length);
|
|
2866
|
+
for (var o = 0, h = 0, a = t.length, l = e.length; o < a && h < l; o++, h++) {
|
|
2867
|
+
this.debug("matchOne loop");
|
|
2868
|
+
var u = e[h], c = t[o];
|
|
2869
|
+
if (this.debug(e, u, c), u === !1) return !1;
|
|
2870
|
+
if (u === A) {
|
|
2871
|
+
this.debug("GLOBSTAR", [
|
|
2872
|
+
e,
|
|
2873
|
+
u,
|
|
2874
|
+
c
|
|
2875
|
+
]);
|
|
2876
|
+
var d = o, f = h + 1;
|
|
2877
|
+
if (f === l) {
|
|
2878
|
+
for (this.debug("** at the end"); o < a; o++) if (t[o] === "." || t[o] === ".." || !i.dot && t[o].charAt(0) === ".") return !1;
|
|
2879
|
+
return !0;
|
|
2880
|
+
}
|
|
2881
|
+
for (; d < a;) {
|
|
2882
|
+
var m = t[d];
|
|
2883
|
+
if (this.debug(`
|
|
2884
|
+
globstar while`, t, d, e, f, m), this.matchOne(t.slice(d), e.slice(f), s)) return this.debug("globstar found match!", d, a, m), !0;
|
|
2885
|
+
if (m === "." || m === ".." || !i.dot && m.charAt(0) === ".") {
|
|
2886
|
+
this.debug("dot detected!", t, d, e, f);
|
|
2887
|
+
break;
|
|
2888
|
+
}
|
|
2889
|
+
this.debug("globstar swallow a segment, and continue"), d++;
|
|
2890
|
+
}
|
|
2891
|
+
return !!(s && (this.debug(`
|
|
2892
|
+
>>> no match, partial?`, t, d, e, f), d === a));
|
|
2893
|
+
}
|
|
2894
|
+
let p;
|
|
2895
|
+
if (typeof u == "string" ? (p = c === u, this.debug("string match", u, c, p)) : (p = u.test(c), this.debug("pattern match", u, c, p)), !p) return !1;
|
|
2896
|
+
}
|
|
2897
|
+
if (o === a && h === l) return !0;
|
|
2898
|
+
if (o === a) return s;
|
|
2899
|
+
if (h === l) return o === a - 1 && t[o] === "";
|
|
2900
|
+
throw new Error("wtf?");
|
|
2901
|
+
}
|
|
2902
|
+
braceExpand() {
|
|
2903
|
+
return ke(this.pattern, this.options);
|
|
2904
|
+
}
|
|
2905
|
+
parse(t) {
|
|
2906
|
+
at(t);
|
|
2907
|
+
let e = this.options;
|
|
2908
|
+
if (t === "**") return A;
|
|
2909
|
+
if (t === "") return "";
|
|
2910
|
+
let s, i = null;
|
|
2911
|
+
(s = t.match(js)) ? i = e.dot ? zs : Is : (s = t.match(Rs)) ? i = (e.nocase ? e.dot ? Ms : Ds : e.dot ? Fs : Os)(s[1]) : (s = t.match(Bs)) ? i = (e.nocase ? e.dot ? $s : Us : e.dot ? Gs : Hs)(s) : (s = t.match(Ns)) ? i = e.dot ? Ls : _s : (s = t.match(Ws)) && (i = Ps);
|
|
2912
|
+
let r = Q.fromGlob(t, this.options).toMMPattern();
|
|
2913
|
+
return i && typeof r == "object" && Reflect.defineProperty(r, "test", { value: i }), r;
|
|
2914
|
+
}
|
|
2915
|
+
makeRe() {
|
|
2916
|
+
if (this.regexp || this.regexp === !1) return this.regexp;
|
|
2917
|
+
let t = this.set;
|
|
2918
|
+
if (!t.length) return this.regexp = !1, this.regexp;
|
|
2919
|
+
let e = this.options, s = e.noglobstar ? Vs : e.dot ? Ys : Xs, i = new Set(e.nocase ? ["i"] : []), r = t.map((a) => {
|
|
2920
|
+
let l = a.map((c) => {
|
|
2921
|
+
if (c instanceof RegExp) for (let d of c.flags.split("")) i.add(d);
|
|
2922
|
+
return typeof c == "string" ? ei(c) : c === A ? A : c._src;
|
|
2923
|
+
});
|
|
2924
|
+
l.forEach((c, d) => {
|
|
2925
|
+
let f = l[d + 1], m = l[d - 1];
|
|
2926
|
+
c !== A || m === A || (m === void 0 ? f !== void 0 && f !== A ? l[d + 1] = "(?:\\/|" + s + "\\/)?" + f : l[d] = s : f === void 0 ? l[d - 1] = m + "(?:\\/|\\/" + s + ")?" : f !== A && (l[d - 1] = m + "(?:\\/|\\/" + s + "\\/)" + f, l[d + 1] = A));
|
|
2927
|
+
});
|
|
2928
|
+
let u = l.filter((c) => c !== A);
|
|
2929
|
+
if (this.partial && u.length >= 1) {
|
|
2930
|
+
let c = [];
|
|
2931
|
+
for (let d = 1; d <= u.length; d++) c.push(u.slice(0, d).join("/"));
|
|
2932
|
+
return "(?:" + c.join("|") + ")";
|
|
2933
|
+
}
|
|
2934
|
+
return u.join("/");
|
|
2935
|
+
}).join("|"), [o, h] = t.length > 1 ? ["(?:", ")"] : ["", ""];
|
|
2936
|
+
r = "^" + o + r + h + "$", this.partial && (r = "^(?:\\/|" + o + r.slice(1, -1) + h + ")$"), this.negate && (r = "^(?!" + r + ").+$");
|
|
2937
|
+
try {
|
|
2938
|
+
this.regexp = new RegExp(r, [...i].join(""));
|
|
2939
|
+
} catch {
|
|
2940
|
+
this.regexp = !1;
|
|
2941
|
+
}
|
|
2942
|
+
return this.regexp;
|
|
2943
|
+
}
|
|
2944
|
+
slashSplit(t) {
|
|
2945
|
+
return this.preserveMultipleSlashes ? t.split("/") : this.isWindows && /^\/\/[^\/]+/.test(t) ? ["", ...t.split(/\/+/)] : t.split(/\/+/);
|
|
2946
|
+
}
|
|
2947
|
+
match(t, e = this.partial) {
|
|
2948
|
+
if (this.debug("match", t, this.pattern), this.comment) return !1;
|
|
2949
|
+
if (this.empty) return t === "";
|
|
2950
|
+
if (t === "/" && e) return !0;
|
|
2951
|
+
let s = this.options;
|
|
2952
|
+
this.isWindows && (t = t.split("\\").join("/"));
|
|
2953
|
+
let i = this.slashSplit(t);
|
|
2954
|
+
this.debug(this.pattern, "split", i);
|
|
2955
|
+
let r = this.set;
|
|
2956
|
+
this.debug(this.pattern, "set", r);
|
|
2957
|
+
let o = i[i.length - 1];
|
|
2958
|
+
if (!o) for (let h = i.length - 2; !o && h >= 0; h--) o = i[h];
|
|
2959
|
+
for (let h = 0; h < r.length; h++) {
|
|
2960
|
+
let a = r[h], l = i;
|
|
2961
|
+
if (s.matchBase && a.length === 1 && (l = [o]), this.matchOne(l, a, e)) return s.flipNegate ? !0 : !this.negate;
|
|
2962
|
+
}
|
|
2963
|
+
return s.flipNegate ? !1 : this.negate;
|
|
2964
|
+
}
|
|
2965
|
+
static defaults(t) {
|
|
2966
|
+
return O.defaults(t).Minimatch;
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
O.AST = Q;
|
|
2970
|
+
O.Minimatch = D;
|
|
2971
|
+
O.escape = tt;
|
|
2972
|
+
O.unescape = W;
|
|
2973
|
+
var si = typeof performance == "object" && performance && typeof performance.now == "function" ? performance : Date;
|
|
2974
|
+
var Oe = /* @__PURE__ */ new Set();
|
|
2975
|
+
var Vt = typeof process == "object" && process ? process : {};
|
|
2976
|
+
var Fe = (n, t, e, s) => {
|
|
2977
|
+
typeof Vt.emitWarning == "function" ? Vt.emitWarning(n, t, e, s) : console.error(`[${e}] ${t}: ${n}`);
|
|
2978
|
+
};
|
|
2979
|
+
var At = globalThis.AbortController;
|
|
2980
|
+
var Re = globalThis.AbortSignal;
|
|
2981
|
+
if (typeof At > "u") {
|
|
2982
|
+
Re = class {
|
|
2983
|
+
onabort;
|
|
2984
|
+
_onabort = [];
|
|
2985
|
+
reason;
|
|
2986
|
+
aborted = !1;
|
|
2987
|
+
addEventListener(e, s) {
|
|
2988
|
+
this._onabort.push(s);
|
|
2989
|
+
}
|
|
2990
|
+
}, At = class {
|
|
2991
|
+
constructor() {
|
|
2992
|
+
t();
|
|
2993
|
+
}
|
|
2994
|
+
signal = new Re();
|
|
2995
|
+
abort(e) {
|
|
2996
|
+
if (!this.signal.aborted) {
|
|
2997
|
+
this.signal.reason = e, this.signal.aborted = !0;
|
|
2998
|
+
for (let s of this.signal._onabort) s(e);
|
|
2999
|
+
this.signal.onabort?.(e);
|
|
3000
|
+
}
|
|
3001
|
+
}
|
|
3002
|
+
};
|
|
3003
|
+
let n = Vt.env?.LRU_CACHE_IGNORE_AC_WARNING !== "1", t = () => {
|
|
3004
|
+
n && (n = !1, Fe("AbortController is not defined. If using lru-cache in node 14, load an AbortController polyfill from the `node-abort-controller` package. A minimal polyfill is provided for use by LRUCache.fetch(), but it should not be relied upon in other contexts (eg, passing it to other APIs that use AbortController/AbortSignal might have undesirable effects). You may disable this with LRU_CACHE_IGNORE_AC_WARNING=1 in the env.", "NO_ABORT_CONTROLLER", "ENOTSUP", t));
|
|
3005
|
+
};
|
|
3006
|
+
}
|
|
3007
|
+
var ii = (n) => !Oe.has(n);
|
|
3008
|
+
var q = (n) => n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
3009
|
+
var De = (n) => q(n) ? n <= Math.pow(2, 8) ? Uint8Array : n <= Math.pow(2, 16) ? Uint16Array : n <= Math.pow(2, 32) ? Uint32Array : n <= Number.MAX_SAFE_INTEGER ? Tt : null : null;
|
|
3010
|
+
var Tt = class extends Array {
|
|
3011
|
+
constructor(n) {
|
|
3012
|
+
super(n), this.fill(0);
|
|
3013
|
+
}
|
|
3014
|
+
};
|
|
3015
|
+
var ri = class ct {
|
|
3016
|
+
heap;
|
|
3017
|
+
length;
|
|
3018
|
+
static #t = !1;
|
|
3019
|
+
static create(t) {
|
|
3020
|
+
let e = De(t);
|
|
3021
|
+
if (!e) return [];
|
|
3022
|
+
ct.#t = !0;
|
|
3023
|
+
let s = new ct(t, e);
|
|
3024
|
+
return ct.#t = !1, s;
|
|
3025
|
+
}
|
|
3026
|
+
constructor(t, e) {
|
|
3027
|
+
if (!ct.#t) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
3028
|
+
this.heap = new e(t), this.length = 0;
|
|
3029
|
+
}
|
|
3030
|
+
push(t) {
|
|
3031
|
+
this.heap[this.length++] = t;
|
|
3032
|
+
}
|
|
3033
|
+
pop() {
|
|
3034
|
+
return this.heap[--this.length];
|
|
3035
|
+
}
|
|
3036
|
+
};
|
|
3037
|
+
var ft = class Me {
|
|
3038
|
+
#t;
|
|
3039
|
+
#s;
|
|
3040
|
+
#n;
|
|
3041
|
+
#r;
|
|
3042
|
+
#o;
|
|
3043
|
+
#S;
|
|
3044
|
+
#w;
|
|
3045
|
+
#c;
|
|
3046
|
+
get perf() {
|
|
3047
|
+
return this.#c;
|
|
3048
|
+
}
|
|
3049
|
+
ttl;
|
|
3050
|
+
ttlResolution;
|
|
3051
|
+
ttlAutopurge;
|
|
3052
|
+
updateAgeOnGet;
|
|
3053
|
+
updateAgeOnHas;
|
|
3054
|
+
allowStale;
|
|
3055
|
+
noDisposeOnSet;
|
|
3056
|
+
noUpdateTTL;
|
|
3057
|
+
maxEntrySize;
|
|
3058
|
+
sizeCalculation;
|
|
3059
|
+
noDeleteOnFetchRejection;
|
|
3060
|
+
noDeleteOnStaleGet;
|
|
3061
|
+
allowStaleOnFetchAbort;
|
|
3062
|
+
allowStaleOnFetchRejection;
|
|
3063
|
+
ignoreFetchAbort;
|
|
3064
|
+
#h;
|
|
3065
|
+
#u;
|
|
3066
|
+
#f;
|
|
3067
|
+
#a;
|
|
3068
|
+
#i;
|
|
3069
|
+
#d;
|
|
3070
|
+
#E;
|
|
3071
|
+
#b;
|
|
3072
|
+
#p;
|
|
3073
|
+
#R;
|
|
3074
|
+
#m;
|
|
3075
|
+
#C;
|
|
3076
|
+
#T;
|
|
3077
|
+
#g;
|
|
3078
|
+
#y;
|
|
3079
|
+
#x;
|
|
3080
|
+
#A;
|
|
3081
|
+
#e;
|
|
3082
|
+
#_;
|
|
3083
|
+
static unsafeExposeInternals(t) {
|
|
3084
|
+
return {
|
|
3085
|
+
starts: t.#T,
|
|
3086
|
+
ttls: t.#g,
|
|
3087
|
+
autopurgeTimers: t.#y,
|
|
3088
|
+
sizes: t.#C,
|
|
3089
|
+
keyMap: t.#f,
|
|
3090
|
+
keyList: t.#a,
|
|
3091
|
+
valList: t.#i,
|
|
3092
|
+
next: t.#d,
|
|
3093
|
+
prev: t.#E,
|
|
3094
|
+
get head() {
|
|
3095
|
+
return t.#b;
|
|
3096
|
+
},
|
|
3097
|
+
get tail() {
|
|
3098
|
+
return t.#p;
|
|
3099
|
+
},
|
|
3100
|
+
free: t.#R,
|
|
3101
|
+
isBackgroundFetch: (e) => t.#l(e),
|
|
3102
|
+
backgroundFetch: (e, s, i, r) => t.#U(e, s, i, r),
|
|
3103
|
+
moveToTail: (e) => t.#W(e),
|
|
3104
|
+
indexes: (e) => t.#F(e),
|
|
3105
|
+
rindexes: (e) => t.#D(e),
|
|
3106
|
+
isStale: (e) => t.#v(e)
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
get max() {
|
|
3110
|
+
return this.#t;
|
|
3111
|
+
}
|
|
3112
|
+
get maxSize() {
|
|
3113
|
+
return this.#s;
|
|
3114
|
+
}
|
|
3115
|
+
get calculatedSize() {
|
|
3116
|
+
return this.#u;
|
|
3117
|
+
}
|
|
3118
|
+
get size() {
|
|
3119
|
+
return this.#h;
|
|
3120
|
+
}
|
|
3121
|
+
get fetchMethod() {
|
|
3122
|
+
return this.#S;
|
|
3123
|
+
}
|
|
3124
|
+
get memoMethod() {
|
|
3125
|
+
return this.#w;
|
|
3126
|
+
}
|
|
3127
|
+
get dispose() {
|
|
3128
|
+
return this.#n;
|
|
3129
|
+
}
|
|
3130
|
+
get onInsert() {
|
|
3131
|
+
return this.#r;
|
|
3132
|
+
}
|
|
3133
|
+
get disposeAfter() {
|
|
3134
|
+
return this.#o;
|
|
3135
|
+
}
|
|
3136
|
+
constructor(t) {
|
|
3137
|
+
let { max: e = 0, ttl: s, ttlResolution: i = 1, ttlAutopurge: r, updateAgeOnGet: o, updateAgeOnHas: h, allowStale: a, dispose: l, onInsert: u, disposeAfter: c, noDisposeOnSet: d, noUpdateTTL: f, maxSize: m = 0, maxEntrySize: p = 0, sizeCalculation: w, fetchMethod: g, memoMethod: S, noDeleteOnFetchRejection: E, noDeleteOnStaleGet: y, allowStaleOnFetchRejection: b, allowStaleOnFetchAbort: z, ignoreFetchAbort: $, perf: J } = t;
|
|
3138
|
+
if (J !== void 0 && typeof J?.now != "function") throw new TypeError("perf option must have a now() method if specified");
|
|
3139
|
+
if (this.#c = J ?? si, e !== 0 && !q(e)) throw new TypeError("max option must be a nonnegative integer");
|
|
3140
|
+
let Z = e ? De(e) : Array;
|
|
3141
|
+
if (!Z) throw new Error("invalid max value: " + e);
|
|
3142
|
+
if (this.#t = e, this.#s = m, this.maxEntrySize = p || this.#s, this.sizeCalculation = w, this.sizeCalculation) {
|
|
3143
|
+
if (!this.#s && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
3144
|
+
if (typeof this.sizeCalculation != "function") throw new TypeError("sizeCalculation set to non-function");
|
|
3145
|
+
}
|
|
3146
|
+
if (S !== void 0 && typeof S != "function") throw new TypeError("memoMethod must be a function if defined");
|
|
3147
|
+
if (this.#w = S, g !== void 0 && typeof g != "function") throw new TypeError("fetchMethod must be a function if specified");
|
|
3148
|
+
if (this.#S = g, this.#A = !!g, this.#f = /* @__PURE__ */ new Map(), this.#a = new Array(e).fill(void 0), this.#i = new Array(e).fill(void 0), this.#d = new Z(e), this.#E = new Z(e), this.#b = 0, this.#p = 0, this.#R = ri.create(e), this.#h = 0, this.#u = 0, typeof l == "function" && (this.#n = l), typeof u == "function" && (this.#r = u), typeof c == "function" ? (this.#o = c, this.#m = []) : (this.#o = void 0, this.#m = void 0), this.#x = !!this.#n, this.#_ = !!this.#r, this.#e = !!this.#o, this.noDisposeOnSet = !!d, this.noUpdateTTL = !!f, this.noDeleteOnFetchRejection = !!E, this.allowStaleOnFetchRejection = !!b, this.allowStaleOnFetchAbort = !!z, this.ignoreFetchAbort = !!$, this.maxEntrySize !== 0) {
|
|
3149
|
+
if (this.#s !== 0 && !q(this.#s)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
3150
|
+
if (!q(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
3151
|
+
this.#G();
|
|
3152
|
+
}
|
|
3153
|
+
if (this.allowStale = !!a, this.noDeleteOnStaleGet = !!y, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!h, this.ttlResolution = q(i) || i === 0 ? i : 1, this.ttlAutopurge = !!r, this.ttl = s || 0, this.ttl) {
|
|
3154
|
+
if (!q(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
3155
|
+
this.#M();
|
|
3156
|
+
}
|
|
3157
|
+
if (this.#t === 0 && this.ttl === 0 && this.#s === 0) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
3158
|
+
if (!this.ttlAutopurge && !this.#t && !this.#s) {
|
|
3159
|
+
let $t = "LRU_CACHE_UNBOUNDED";
|
|
3160
|
+
ii($t) && (Oe.add($t), Fe("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", $t, Me));
|
|
3161
|
+
}
|
|
3162
|
+
}
|
|
3163
|
+
getRemainingTTL(t) {
|
|
3164
|
+
return this.#f.has(t) ? 1 / 0 : 0;
|
|
3165
|
+
}
|
|
3166
|
+
#M() {
|
|
3167
|
+
let t = new Tt(this.#t), e = new Tt(this.#t);
|
|
3168
|
+
this.#g = t, this.#T = e;
|
|
3169
|
+
let s = this.ttlAutopurge ? new Array(this.#t) : void 0;
|
|
3170
|
+
this.#y = s, this.#j = (o, h, a = this.#c.now()) => {
|
|
3171
|
+
if (e[o] = h !== 0 ? a : 0, t[o] = h, s?.[o] && (clearTimeout(s[o]), s[o] = void 0), h !== 0 && s) {
|
|
3172
|
+
let l = setTimeout(() => {
|
|
3173
|
+
this.#v(o) && this.#O(this.#a[o], "expire");
|
|
3174
|
+
}, h + 1);
|
|
3175
|
+
l.unref && l.unref(), s[o] = l;
|
|
3176
|
+
}
|
|
3177
|
+
}, this.#k = (o) => {
|
|
3178
|
+
e[o] = t[o] !== 0 ? this.#c.now() : 0;
|
|
3179
|
+
}, this.#N = (o, h) => {
|
|
3180
|
+
if (t[h]) {
|
|
3181
|
+
let a = t[h], l = e[h];
|
|
3182
|
+
if (!a || !l) return;
|
|
3183
|
+
o.ttl = a, o.start = l, o.now = i || r();
|
|
3184
|
+
o.remainingTTL = a - (o.now - l);
|
|
3185
|
+
}
|
|
3186
|
+
};
|
|
3187
|
+
let i = 0, r = () => {
|
|
3188
|
+
let o = this.#c.now();
|
|
3189
|
+
if (this.ttlResolution > 0) {
|
|
3190
|
+
i = o;
|
|
3191
|
+
let h = setTimeout(() => i = 0, this.ttlResolution);
|
|
3192
|
+
h.unref && h.unref();
|
|
3193
|
+
}
|
|
3194
|
+
return o;
|
|
3195
|
+
};
|
|
3196
|
+
this.getRemainingTTL = (o) => {
|
|
3197
|
+
let h = this.#f.get(o);
|
|
3198
|
+
if (h === void 0) return 0;
|
|
3199
|
+
let a = t[h], l = e[h];
|
|
3200
|
+
if (!a || !l) return 1 / 0;
|
|
3201
|
+
return a - ((i || r()) - l);
|
|
3202
|
+
}, this.#v = (o) => {
|
|
3203
|
+
let h = e[o], a = t[o];
|
|
3204
|
+
return !!a && !!h && (i || r()) - h > a;
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
#k = () => {};
|
|
3208
|
+
#N = () => {};
|
|
3209
|
+
#j = () => {};
|
|
3210
|
+
#v = () => !1;
|
|
3211
|
+
#G() {
|
|
3212
|
+
let t = new Tt(this.#t);
|
|
3213
|
+
this.#u = 0, this.#C = t, this.#P = (e) => {
|
|
3214
|
+
this.#u -= t[e], t[e] = 0;
|
|
3215
|
+
}, this.#I = (e, s, i, r) => {
|
|
3216
|
+
if (this.#l(s)) return 0;
|
|
3217
|
+
if (!q(i)) if (r) {
|
|
3218
|
+
if (typeof r != "function") throw new TypeError("sizeCalculation must be a function");
|
|
3219
|
+
if (i = r(s, e), !q(i)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
3220
|
+
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
3221
|
+
return i;
|
|
3222
|
+
}, this.#L = (e, s, i) => {
|
|
3223
|
+
if (t[e] = s, this.#s) {
|
|
3224
|
+
let r = this.#s - t[e];
|
|
3225
|
+
for (; this.#u > r;) this.#B(!0);
|
|
3226
|
+
}
|
|
3227
|
+
this.#u += t[e], i && (i.entrySize = s, i.totalCalculatedSize = this.#u);
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
#P = (t) => {};
|
|
3231
|
+
#L = (t, e, s) => {};
|
|
3232
|
+
#I = (t, e, s, i) => {
|
|
3233
|
+
if (s || i) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
3234
|
+
return 0;
|
|
3235
|
+
};
|
|
3236
|
+
*#F({ allowStale: t = this.allowStale } = {}) {
|
|
3237
|
+
if (this.#h) for (let e = this.#p; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#b));) e = this.#E[e];
|
|
3238
|
+
}
|
|
3239
|
+
*#D({ allowStale: t = this.allowStale } = {}) {
|
|
3240
|
+
if (this.#h) for (let e = this.#b; !(!this.#z(e) || ((t || !this.#v(e)) && (yield e), e === this.#p));) e = this.#d[e];
|
|
3241
|
+
}
|
|
3242
|
+
#z(t) {
|
|
3243
|
+
return t !== void 0 && this.#f.get(this.#a[t]) === t;
|
|
3244
|
+
}
|
|
3245
|
+
*entries() {
|
|
3246
|
+
for (let t of this.#F()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
3247
|
+
}
|
|
3248
|
+
*rentries() {
|
|
3249
|
+
for (let t of this.#D()) this.#i[t] !== void 0 && this.#a[t] !== void 0 && !this.#l(this.#i[t]) && (yield [this.#a[t], this.#i[t]]);
|
|
3250
|
+
}
|
|
3251
|
+
*keys() {
|
|
3252
|
+
for (let t of this.#F()) {
|
|
3253
|
+
let e = this.#a[t];
|
|
3254
|
+
e !== void 0 && !this.#l(this.#i[t]) && (yield e);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
*rkeys() {
|
|
3258
|
+
for (let t of this.#D()) {
|
|
3259
|
+
let e = this.#a[t];
|
|
3260
|
+
e !== void 0 && !this.#l(this.#i[t]) && (yield e);
|
|
3261
|
+
}
|
|
3262
|
+
}
|
|
3263
|
+
*values() {
|
|
3264
|
+
for (let t of this.#F()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
3265
|
+
}
|
|
3266
|
+
*rvalues() {
|
|
3267
|
+
for (let t of this.#D()) this.#i[t] !== void 0 && !this.#l(this.#i[t]) && (yield this.#i[t]);
|
|
3268
|
+
}
|
|
3269
|
+
[Symbol.iterator]() {
|
|
3270
|
+
return this.entries();
|
|
3271
|
+
}
|
|
3272
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
3273
|
+
find(t, e = {}) {
|
|
3274
|
+
for (let s of this.#F()) {
|
|
3275
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
3276
|
+
if (r !== void 0 && t(r, this.#a[s], this)) return this.get(this.#a[s], e);
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
forEach(t, e = this) {
|
|
3280
|
+
for (let s of this.#F()) {
|
|
3281
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
3282
|
+
r !== void 0 && t.call(e, r, this.#a[s], this);
|
|
3283
|
+
}
|
|
3284
|
+
}
|
|
3285
|
+
rforEach(t, e = this) {
|
|
3286
|
+
for (let s of this.#D()) {
|
|
3287
|
+
let i = this.#i[s], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
3288
|
+
r !== void 0 && t.call(e, r, this.#a[s], this);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
purgeStale() {
|
|
3292
|
+
let t = !1;
|
|
3293
|
+
for (let e of this.#D({ allowStale: !0 })) this.#v(e) && (this.#O(this.#a[e], "expire"), t = !0);
|
|
3294
|
+
return t;
|
|
3295
|
+
}
|
|
3296
|
+
info(t) {
|
|
3297
|
+
let e = this.#f.get(t);
|
|
3298
|
+
if (e === void 0) return;
|
|
3299
|
+
let s = this.#i[e], i = this.#l(s) ? s.__staleWhileFetching : s;
|
|
3300
|
+
if (i === void 0) return;
|
|
3301
|
+
let r = { value: i };
|
|
3302
|
+
if (this.#g && this.#T) {
|
|
3303
|
+
let o = this.#g[e], h = this.#T[e];
|
|
3304
|
+
if (o && h) r.ttl = o - (this.#c.now() - h), r.start = Date.now();
|
|
3305
|
+
}
|
|
3306
|
+
return this.#C && (r.size = this.#C[e]), r;
|
|
3307
|
+
}
|
|
3308
|
+
dump() {
|
|
3309
|
+
let t = [];
|
|
3310
|
+
for (let e of this.#F({ allowStale: !0 })) {
|
|
3311
|
+
let s = this.#a[e], i = this.#i[e], r = this.#l(i) ? i.__staleWhileFetching : i;
|
|
3312
|
+
if (r === void 0 || s === void 0) continue;
|
|
3313
|
+
let o = { value: r };
|
|
3314
|
+
if (this.#g && this.#T) {
|
|
3315
|
+
o.ttl = this.#g[e];
|
|
3316
|
+
let h = this.#c.now() - this.#T[e];
|
|
3317
|
+
o.start = Math.floor(Date.now() - h);
|
|
3318
|
+
}
|
|
3319
|
+
this.#C && (o.size = this.#C[e]), t.unshift([s, o]);
|
|
3320
|
+
}
|
|
3321
|
+
return t;
|
|
3322
|
+
}
|
|
3323
|
+
load(t) {
|
|
3324
|
+
this.clear();
|
|
3325
|
+
for (let [e, s] of t) {
|
|
3326
|
+
if (s.start) {
|
|
3327
|
+
let i = Date.now() - s.start;
|
|
3328
|
+
s.start = this.#c.now() - i;
|
|
3329
|
+
}
|
|
3330
|
+
this.set(e, s.value, s);
|
|
3331
|
+
}
|
|
3332
|
+
}
|
|
3333
|
+
set(t, e, s = {}) {
|
|
3334
|
+
if (e === void 0) return this.delete(t), this;
|
|
3335
|
+
let { ttl: i = this.ttl, start: r, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: h = this.sizeCalculation, status: a } = s, { noUpdateTTL: l = this.noUpdateTTL } = s, u = this.#I(t, e, s.size || 0, h);
|
|
3336
|
+
if (this.maxEntrySize && u > this.maxEntrySize) return a && (a.set = "miss", a.maxEntrySizeExceeded = !0), this.#O(t, "set"), this;
|
|
3337
|
+
let c = this.#h === 0 ? void 0 : this.#f.get(t);
|
|
3338
|
+
if (c === void 0) c = this.#h === 0 ? this.#p : this.#R.length !== 0 ? this.#R.pop() : this.#h === this.#t ? this.#B(!1) : this.#h, this.#a[c] = t, this.#i[c] = e, this.#f.set(t, c), this.#d[this.#p] = c, this.#E[c] = this.#p, this.#p = c, this.#h++, this.#L(c, u, a), a && (a.set = "add"), l = !1, this.#_ && this.#r?.(e, t, "add");
|
|
3339
|
+
else {
|
|
3340
|
+
this.#W(c);
|
|
3341
|
+
let d = this.#i[c];
|
|
3342
|
+
if (e !== d) {
|
|
3343
|
+
if (this.#A && this.#l(d)) {
|
|
3344
|
+
d.__abortController.abort(/* @__PURE__ */ new Error("replaced"));
|
|
3345
|
+
let { __staleWhileFetching: f } = d;
|
|
3346
|
+
f !== void 0 && !o && (this.#x && this.#n?.(f, t, "set"), this.#e && this.#m?.push([
|
|
3347
|
+
f,
|
|
3348
|
+
t,
|
|
3349
|
+
"set"
|
|
3350
|
+
]));
|
|
3351
|
+
} else o || (this.#x && this.#n?.(d, t, "set"), this.#e && this.#m?.push([
|
|
3352
|
+
d,
|
|
3353
|
+
t,
|
|
3354
|
+
"set"
|
|
3355
|
+
]));
|
|
3356
|
+
if (this.#P(c), this.#L(c, u, a), this.#i[c] = e, a) {
|
|
3357
|
+
a.set = "replace";
|
|
3358
|
+
let f = d && this.#l(d) ? d.__staleWhileFetching : d;
|
|
3359
|
+
f !== void 0 && (a.oldValue = f);
|
|
3360
|
+
}
|
|
3361
|
+
} else a && (a.set = "update");
|
|
3362
|
+
this.#_ && this.onInsert?.(e, t, e === d ? "update" : "replace");
|
|
3363
|
+
}
|
|
3364
|
+
if (i !== 0 && !this.#g && this.#M(), this.#g && (l || this.#j(c, i, r), a && this.#N(a, c)), !o && this.#e && this.#m) {
|
|
3365
|
+
let d = this.#m, f;
|
|
3366
|
+
for (; f = d?.shift();) this.#o?.(...f);
|
|
3367
|
+
}
|
|
3368
|
+
return this;
|
|
3369
|
+
}
|
|
3370
|
+
pop() {
|
|
3371
|
+
try {
|
|
3372
|
+
for (; this.#h;) {
|
|
3373
|
+
let t = this.#i[this.#b];
|
|
3374
|
+
if (this.#B(!0), this.#l(t)) {
|
|
3375
|
+
if (t.__staleWhileFetching) return t.__staleWhileFetching;
|
|
3376
|
+
} else if (t !== void 0) return t;
|
|
3377
|
+
}
|
|
3378
|
+
} finally {
|
|
3379
|
+
if (this.#e && this.#m) {
|
|
3380
|
+
let t = this.#m, e;
|
|
3381
|
+
for (; e = t?.shift();) this.#o?.(...e);
|
|
3382
|
+
}
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
#B(t) {
|
|
3386
|
+
let e = this.#b, s = this.#a[e], i = this.#i[e];
|
|
3387
|
+
return this.#A && this.#l(i) ? i.__abortController.abort(/* @__PURE__ */ new Error("evicted")) : (this.#x || this.#e) && (this.#x && this.#n?.(i, s, "evict"), this.#e && this.#m?.push([
|
|
3388
|
+
i,
|
|
3389
|
+
s,
|
|
3390
|
+
"evict"
|
|
3391
|
+
])), this.#P(e), this.#y?.[e] && (clearTimeout(this.#y[e]), this.#y[e] = void 0), t && (this.#a[e] = void 0, this.#i[e] = void 0, this.#R.push(e)), this.#h === 1 ? (this.#b = this.#p = 0, this.#R.length = 0) : this.#b = this.#d[e], this.#f.delete(s), this.#h--, e;
|
|
3392
|
+
}
|
|
3393
|
+
has(t, e = {}) {
|
|
3394
|
+
let { updateAgeOnHas: s = this.updateAgeOnHas, status: i } = e, r = this.#f.get(t);
|
|
3395
|
+
if (r !== void 0) {
|
|
3396
|
+
let o = this.#i[r];
|
|
3397
|
+
if (this.#l(o) && o.__staleWhileFetching === void 0) return !1;
|
|
3398
|
+
if (this.#v(r)) i && (i.has = "stale", this.#N(i, r));
|
|
3399
|
+
else return s && this.#k(r), i && (i.has = "hit", this.#N(i, r)), !0;
|
|
3400
|
+
} else i && (i.has = "miss");
|
|
3401
|
+
return !1;
|
|
3402
|
+
}
|
|
3403
|
+
peek(t, e = {}) {
|
|
3404
|
+
let { allowStale: s = this.allowStale } = e, i = this.#f.get(t);
|
|
3405
|
+
if (i === void 0 || !s && this.#v(i)) return;
|
|
3406
|
+
let r = this.#i[i];
|
|
3407
|
+
return this.#l(r) ? r.__staleWhileFetching : r;
|
|
3408
|
+
}
|
|
3409
|
+
#U(t, e, s, i) {
|
|
3410
|
+
let r = e === void 0 ? void 0 : this.#i[e];
|
|
3411
|
+
if (this.#l(r)) return r;
|
|
3412
|
+
let o = new At(), { signal: h } = s;
|
|
3413
|
+
h?.addEventListener("abort", () => o.abort(h.reason), { signal: o.signal });
|
|
3414
|
+
let a = {
|
|
3415
|
+
signal: o.signal,
|
|
3416
|
+
options: s,
|
|
3417
|
+
context: i
|
|
3418
|
+
}, l = (p, w = !1) => {
|
|
3419
|
+
let { aborted: g } = o.signal, S = s.ignoreFetchAbort && p !== void 0, E = s.ignoreFetchAbort || !!(s.allowStaleOnFetchAbort && p !== void 0);
|
|
3420
|
+
if (s.status && (g && !w ? (s.status.fetchAborted = !0, s.status.fetchError = o.signal.reason, S && (s.status.fetchAbortIgnored = !0)) : s.status.fetchResolved = !0), g && !S && !w) return c(o.signal.reason, E);
|
|
3421
|
+
let y = f, b = this.#i[e];
|
|
3422
|
+
return (b === f || S && w && b === void 0) && (p === void 0 ? y.__staleWhileFetching !== void 0 ? this.#i[e] = y.__staleWhileFetching : this.#O(t, "fetch") : (s.status && (s.status.fetchUpdated = !0), this.set(t, p, a.options))), p;
|
|
3423
|
+
}, u = (p) => (s.status && (s.status.fetchRejected = !0, s.status.fetchError = p), c(p, !1)), c = (p, w) => {
|
|
3424
|
+
let { aborted: g } = o.signal, S = g && s.allowStaleOnFetchAbort, E = S || s.allowStaleOnFetchRejection, y = E || s.noDeleteOnFetchRejection, b = f;
|
|
3425
|
+
if (this.#i[e] === f && (!y || !w && b.__staleWhileFetching === void 0 ? this.#O(t, "fetch") : S || (this.#i[e] = b.__staleWhileFetching)), E) return s.status && b.__staleWhileFetching !== void 0 && (s.status.returnedStale = !0), b.__staleWhileFetching;
|
|
3426
|
+
if (b.__returned === b) throw p;
|
|
3427
|
+
}, d = (p, w) => {
|
|
3428
|
+
let g = this.#S?.(t, r, a);
|
|
3429
|
+
g && g instanceof Promise && g.then((S) => p(S === void 0 ? void 0 : S), w), o.signal.addEventListener("abort", () => {
|
|
3430
|
+
(!s.ignoreFetchAbort || s.allowStaleOnFetchAbort) && (p(void 0), s.allowStaleOnFetchAbort && (p = (S) => l(S, !0)));
|
|
3431
|
+
});
|
|
3432
|
+
};
|
|
3433
|
+
s.status && (s.status.fetchDispatched = !0);
|
|
3434
|
+
let f = new Promise(d).then(l, u), m = Object.assign(f, {
|
|
3435
|
+
__abortController: o,
|
|
3436
|
+
__staleWhileFetching: r,
|
|
3437
|
+
__returned: void 0
|
|
3438
|
+
});
|
|
3439
|
+
return e === void 0 ? (this.set(t, m, {
|
|
3440
|
+
...a.options,
|
|
3441
|
+
status: void 0
|
|
3442
|
+
}), e = this.#f.get(t)) : this.#i[e] = m, m;
|
|
3443
|
+
}
|
|
3444
|
+
#l(t) {
|
|
3445
|
+
if (!this.#A) return !1;
|
|
3446
|
+
let e = t;
|
|
3447
|
+
return !!e && e instanceof Promise && e.hasOwnProperty("__staleWhileFetching") && e.__abortController instanceof At;
|
|
3448
|
+
}
|
|
3449
|
+
async fetch(t, e = {}) {
|
|
3450
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: h = this.noDisposeOnSet, size: a = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: u = this.noUpdateTTL, noDeleteOnFetchRejection: c = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: d = this.allowStaleOnFetchRejection, ignoreFetchAbort: f = this.ignoreFetchAbort, allowStaleOnFetchAbort: m = this.allowStaleOnFetchAbort, context: p, forceRefresh: w = !1, status: g, signal: S } = e;
|
|
3451
|
+
if (!this.#A) return g && (g.fetch = "get"), this.get(t, {
|
|
3452
|
+
allowStale: s,
|
|
3453
|
+
updateAgeOnGet: i,
|
|
3454
|
+
noDeleteOnStaleGet: r,
|
|
3455
|
+
status: g
|
|
3456
|
+
});
|
|
3457
|
+
let E = {
|
|
3458
|
+
allowStale: s,
|
|
3459
|
+
updateAgeOnGet: i,
|
|
3460
|
+
noDeleteOnStaleGet: r,
|
|
3461
|
+
ttl: o,
|
|
3462
|
+
noDisposeOnSet: h,
|
|
3463
|
+
size: a,
|
|
3464
|
+
sizeCalculation: l,
|
|
3465
|
+
noUpdateTTL: u,
|
|
3466
|
+
noDeleteOnFetchRejection: c,
|
|
3467
|
+
allowStaleOnFetchRejection: d,
|
|
3468
|
+
allowStaleOnFetchAbort: m,
|
|
3469
|
+
ignoreFetchAbort: f,
|
|
3470
|
+
status: g,
|
|
3471
|
+
signal: S
|
|
3472
|
+
}, y = this.#f.get(t);
|
|
3473
|
+
if (y === void 0) {
|
|
3474
|
+
g && (g.fetch = "miss");
|
|
3475
|
+
let b = this.#U(t, y, E, p);
|
|
3476
|
+
return b.__returned = b;
|
|
3477
|
+
} else {
|
|
3478
|
+
let b = this.#i[y];
|
|
3479
|
+
if (this.#l(b)) {
|
|
3480
|
+
let Z = s && b.__staleWhileFetching !== void 0;
|
|
3481
|
+
return g && (g.fetch = "inflight", Z && (g.returnedStale = !0)), Z ? b.__staleWhileFetching : b.__returned = b;
|
|
3482
|
+
}
|
|
3483
|
+
let z = this.#v(y);
|
|
3484
|
+
if (!w && !z) return g && (g.fetch = "hit"), this.#W(y), i && this.#k(y), g && this.#N(g, y), b;
|
|
3485
|
+
let $ = this.#U(t, y, E, p), J = $.__staleWhileFetching !== void 0 && s;
|
|
3486
|
+
return g && (g.fetch = z ? "stale" : "refresh", J && z && (g.returnedStale = !0)), J ? $.__staleWhileFetching : $.__returned = $;
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
async forceFetch(t, e = {}) {
|
|
3490
|
+
let s = await this.fetch(t, e);
|
|
3491
|
+
if (s === void 0) throw new Error("fetch() returned undefined");
|
|
3492
|
+
return s;
|
|
3493
|
+
}
|
|
3494
|
+
memo(t, e = {}) {
|
|
3495
|
+
let s = this.#w;
|
|
3496
|
+
if (!s) throw new Error("no memoMethod provided to constructor");
|
|
3497
|
+
let { context: i, forceRefresh: r, ...o } = e, h = this.get(t, o);
|
|
3498
|
+
if (!r && h !== void 0) return h;
|
|
3499
|
+
let a = s(t, h, {
|
|
3500
|
+
options: o,
|
|
3501
|
+
context: i
|
|
3502
|
+
});
|
|
3503
|
+
return this.set(t, a, o), a;
|
|
3504
|
+
}
|
|
3505
|
+
get(t, e = {}) {
|
|
3506
|
+
let { allowStale: s = this.allowStale, updateAgeOnGet: i = this.updateAgeOnGet, noDeleteOnStaleGet: r = this.noDeleteOnStaleGet, status: o } = e, h = this.#f.get(t);
|
|
3507
|
+
if (h !== void 0) {
|
|
3508
|
+
let a = this.#i[h], l = this.#l(a);
|
|
3509
|
+
return o && this.#N(o, h), this.#v(h) ? (o && (o.get = "stale"), l ? (o && s && a.__staleWhileFetching !== void 0 && (o.returnedStale = !0), s ? a.__staleWhileFetching : void 0) : (r || this.#O(t, "expire"), o && s && (o.returnedStale = !0), s ? a : void 0)) : (o && (o.get = "hit"), l ? a.__staleWhileFetching : (this.#W(h), i && this.#k(h), a));
|
|
3510
|
+
} else o && (o.get = "miss");
|
|
3511
|
+
}
|
|
3512
|
+
#$(t, e) {
|
|
3513
|
+
this.#E[e] = t, this.#d[t] = e;
|
|
3514
|
+
}
|
|
3515
|
+
#W(t) {
|
|
3516
|
+
t !== this.#p && (t === this.#b ? this.#b = this.#d[t] : this.#$(this.#E[t], this.#d[t]), this.#$(this.#p, t), this.#p = t);
|
|
3517
|
+
}
|
|
3518
|
+
delete(t) {
|
|
3519
|
+
return this.#O(t, "delete");
|
|
3520
|
+
}
|
|
3521
|
+
#O(t, e) {
|
|
3522
|
+
let s = !1;
|
|
3523
|
+
if (this.#h !== 0) {
|
|
3524
|
+
let i = this.#f.get(t);
|
|
3525
|
+
if (i !== void 0) if (this.#y?.[i] && (clearTimeout(this.#y?.[i]), this.#y[i] = void 0), s = !0, this.#h === 1) this.#H(e);
|
|
3526
|
+
else {
|
|
3527
|
+
this.#P(i);
|
|
3528
|
+
let r = this.#i[i];
|
|
3529
|
+
if (this.#l(r) ? r.__abortController.abort(/* @__PURE__ */ new Error("deleted")) : (this.#x || this.#e) && (this.#x && this.#n?.(r, t, e), this.#e && this.#m?.push([
|
|
3530
|
+
r,
|
|
3531
|
+
t,
|
|
3532
|
+
e
|
|
3533
|
+
])), this.#f.delete(t), this.#a[i] = void 0, this.#i[i] = void 0, i === this.#p) this.#p = this.#E[i];
|
|
3534
|
+
else if (i === this.#b) this.#b = this.#d[i];
|
|
3535
|
+
else {
|
|
3536
|
+
let o = this.#E[i];
|
|
3537
|
+
this.#d[o] = this.#d[i];
|
|
3538
|
+
let h = this.#d[i];
|
|
3539
|
+
this.#E[h] = this.#E[i];
|
|
3540
|
+
}
|
|
3541
|
+
this.#h--, this.#R.push(i);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
if (this.#e && this.#m?.length) {
|
|
3545
|
+
let i = this.#m, r;
|
|
3546
|
+
for (; r = i?.shift();) this.#o?.(...r);
|
|
3547
|
+
}
|
|
3548
|
+
return s;
|
|
3549
|
+
}
|
|
3550
|
+
clear() {
|
|
3551
|
+
return this.#H("delete");
|
|
3552
|
+
}
|
|
3553
|
+
#H(t) {
|
|
3554
|
+
for (let e of this.#D({ allowStale: !0 })) {
|
|
3555
|
+
let s = this.#i[e];
|
|
3556
|
+
if (this.#l(s)) s.__abortController.abort(/* @__PURE__ */ new Error("deleted"));
|
|
3557
|
+
else {
|
|
3558
|
+
let i = this.#a[e];
|
|
3559
|
+
this.#x && this.#n?.(s, i, t), this.#e && this.#m?.push([
|
|
3560
|
+
s,
|
|
3561
|
+
i,
|
|
3562
|
+
t
|
|
3563
|
+
]);
|
|
3564
|
+
}
|
|
3565
|
+
}
|
|
3566
|
+
if (this.#f.clear(), this.#i.fill(void 0), this.#a.fill(void 0), this.#g && this.#T) {
|
|
3567
|
+
this.#g.fill(0), this.#T.fill(0);
|
|
3568
|
+
for (let e of this.#y ?? []) e !== void 0 && clearTimeout(e);
|
|
3569
|
+
this.#y?.fill(void 0);
|
|
3570
|
+
}
|
|
3571
|
+
if (this.#C && this.#C.fill(0), this.#b = 0, this.#p = 0, this.#R.length = 0, this.#u = 0, this.#h = 0, this.#e && this.#m) {
|
|
3572
|
+
let e = this.#m, s;
|
|
3573
|
+
for (; s = e?.shift();) this.#o?.(...s);
|
|
3574
|
+
}
|
|
3575
|
+
}
|
|
3576
|
+
};
|
|
3577
|
+
var Ne = typeof process == "object" && process ? process : {
|
|
3578
|
+
stdout: null,
|
|
3579
|
+
stderr: null
|
|
3580
|
+
};
|
|
3581
|
+
var oi = (n) => !!n && typeof n == "object" && (n instanceof V || n instanceof Pe || hi(n) || ai(n));
|
|
3582
|
+
var hi = (n) => !!n && typeof n == "object" && n instanceof EventEmitter && typeof n.pipe == "function" && n.pipe !== Pe.Writable.prototype.pipe;
|
|
3583
|
+
var ai = (n) => !!n && typeof n == "object" && n instanceof EventEmitter && typeof n.write == "function" && typeof n.end == "function";
|
|
3584
|
+
var G = Symbol("EOF");
|
|
3585
|
+
var H = Symbol("maybeEmitEnd");
|
|
3586
|
+
var K = Symbol("emittedEnd");
|
|
3587
|
+
var kt = Symbol("emittingEnd");
|
|
3588
|
+
var ut = Symbol("emittedError");
|
|
3589
|
+
var Rt = Symbol("closed");
|
|
3590
|
+
var _e = Symbol("read");
|
|
3591
|
+
var Ot = Symbol("flush");
|
|
3592
|
+
var Le = Symbol("flushChunk");
|
|
3593
|
+
var P = Symbol("encoding");
|
|
3594
|
+
var et = Symbol("decoder");
|
|
3595
|
+
var v = Symbol("flowing");
|
|
3596
|
+
var dt = Symbol("paused");
|
|
3597
|
+
var st = Symbol("resume");
|
|
3598
|
+
var C = Symbol("buffer");
|
|
3599
|
+
var F = Symbol("pipes");
|
|
3600
|
+
var T = Symbol("bufferLength");
|
|
3601
|
+
var Yt = Symbol("bufferPush");
|
|
3602
|
+
var Ft = Symbol("bufferShift");
|
|
3603
|
+
var k = Symbol("objectMode");
|
|
3604
|
+
var x = Symbol("destroyed");
|
|
3605
|
+
var Xt = Symbol("error");
|
|
3606
|
+
var Jt = Symbol("emitData");
|
|
3607
|
+
var We = Symbol("emitEnd");
|
|
3608
|
+
var Zt = Symbol("emitEnd2");
|
|
3609
|
+
var B = Symbol("async");
|
|
3610
|
+
var Qt = Symbol("abort");
|
|
3611
|
+
var Dt = Symbol("aborted");
|
|
3612
|
+
var pt = Symbol("signal");
|
|
3613
|
+
var Y = Symbol("dataListeners");
|
|
3614
|
+
var M = Symbol("discarded");
|
|
3615
|
+
var mt = (n) => Promise.resolve().then(n);
|
|
3616
|
+
var li = (n) => n();
|
|
3617
|
+
var ci = (n) => n === "end" || n === "finish" || n === "prefinish";
|
|
3618
|
+
var fi = (n) => n instanceof ArrayBuffer || !!n && typeof n == "object" && n.constructor && n.constructor.name === "ArrayBuffer" && n.byteLength >= 0;
|
|
3619
|
+
var ui = (n) => !Buffer.isBuffer(n) && ArrayBuffer.isView(n);
|
|
3620
|
+
var Mt = class {
|
|
3621
|
+
src;
|
|
3622
|
+
dest;
|
|
3623
|
+
opts;
|
|
3624
|
+
ondrain;
|
|
3625
|
+
constructor(t, e, s) {
|
|
3626
|
+
this.src = t, this.dest = e, this.opts = s, this.ondrain = () => t[st](), this.dest.on("drain", this.ondrain);
|
|
3627
|
+
}
|
|
3628
|
+
unpipe() {
|
|
3629
|
+
this.dest.removeListener("drain", this.ondrain);
|
|
3630
|
+
}
|
|
3631
|
+
proxyErrors(t) {}
|
|
3632
|
+
end() {
|
|
3633
|
+
this.unpipe(), this.opts.end && this.dest.end();
|
|
3634
|
+
}
|
|
3635
|
+
};
|
|
3636
|
+
var te = class extends Mt {
|
|
3637
|
+
unpipe() {
|
|
3638
|
+
this.src.removeListener("error", this.proxyErrors), super.unpipe();
|
|
3639
|
+
}
|
|
3640
|
+
constructor(t, e, s) {
|
|
3641
|
+
super(t, e, s), this.proxyErrors = (i) => this.dest.emit("error", i), t.on("error", this.proxyErrors);
|
|
3642
|
+
}
|
|
3643
|
+
};
|
|
3644
|
+
var di = (n) => !!n.objectMode;
|
|
3645
|
+
var pi = (n) => !n.objectMode && !!n.encoding && n.encoding !== "buffer";
|
|
3646
|
+
var V = class extends EventEmitter {
|
|
3647
|
+
[v] = !1;
|
|
3648
|
+
[dt] = !1;
|
|
3649
|
+
[F] = [];
|
|
3650
|
+
[C] = [];
|
|
3651
|
+
[k];
|
|
3652
|
+
[P];
|
|
3653
|
+
[B];
|
|
3654
|
+
[et];
|
|
3655
|
+
[G] = !1;
|
|
3656
|
+
[K] = !1;
|
|
3657
|
+
[kt] = !1;
|
|
3658
|
+
[Rt] = !1;
|
|
3659
|
+
[ut] = null;
|
|
3660
|
+
[T] = 0;
|
|
3661
|
+
[x] = !1;
|
|
3662
|
+
[pt];
|
|
3663
|
+
[Dt] = !1;
|
|
3664
|
+
[Y] = 0;
|
|
3665
|
+
[M] = !1;
|
|
3666
|
+
writable = !0;
|
|
3667
|
+
readable = !0;
|
|
3668
|
+
constructor(...t) {
|
|
3669
|
+
let e = t[0] || {};
|
|
3670
|
+
if (super(), e.objectMode && typeof e.encoding == "string") throw new TypeError("Encoding and objectMode may not be used together");
|
|
3671
|
+
di(e) ? (this[k] = !0, this[P] = null) : pi(e) ? (this[P] = e.encoding, this[k] = !1) : (this[k] = !1, this[P] = null), this[B] = !!e.async, this[et] = this[P] ? new StringDecoder(this[P]) : null, e && e.debugExposeBuffer === !0 && Object.defineProperty(this, "buffer", { get: () => this[C] }), e && e.debugExposePipes === !0 && Object.defineProperty(this, "pipes", { get: () => this[F] });
|
|
3672
|
+
let { signal: s } = e;
|
|
3673
|
+
s && (this[pt] = s, s.aborted ? this[Qt]() : s.addEventListener("abort", () => this[Qt]()));
|
|
3674
|
+
}
|
|
3675
|
+
get bufferLength() {
|
|
3676
|
+
return this[T];
|
|
3677
|
+
}
|
|
3678
|
+
get encoding() {
|
|
3679
|
+
return this[P];
|
|
3680
|
+
}
|
|
3681
|
+
set encoding(t) {
|
|
3682
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
3683
|
+
}
|
|
3684
|
+
setEncoding(t) {
|
|
3685
|
+
throw new Error("Encoding must be set at instantiation time");
|
|
3686
|
+
}
|
|
3687
|
+
get objectMode() {
|
|
3688
|
+
return this[k];
|
|
3689
|
+
}
|
|
3690
|
+
set objectMode(t) {
|
|
3691
|
+
throw new Error("objectMode must be set at instantiation time");
|
|
3692
|
+
}
|
|
3693
|
+
get async() {
|
|
3694
|
+
return this[B];
|
|
3695
|
+
}
|
|
3696
|
+
set async(t) {
|
|
3697
|
+
this[B] = this[B] || !!t;
|
|
3698
|
+
}
|
|
3699
|
+
[Qt]() {
|
|
3700
|
+
this[Dt] = !0, this.emit("abort", this[pt]?.reason), this.destroy(this[pt]?.reason);
|
|
3701
|
+
}
|
|
3702
|
+
get aborted() {
|
|
3703
|
+
return this[Dt];
|
|
3704
|
+
}
|
|
3705
|
+
set aborted(t) {}
|
|
3706
|
+
write(t, e, s) {
|
|
3707
|
+
if (this[Dt]) return !1;
|
|
3708
|
+
if (this[G]) throw new Error("write after end");
|
|
3709
|
+
if (this[x]) return this.emit("error", Object.assign(/* @__PURE__ */ new Error("Cannot call write after a stream was destroyed"), { code: "ERR_STREAM_DESTROYED" })), !0;
|
|
3710
|
+
typeof e == "function" && (s = e, e = "utf8"), e || (e = "utf8");
|
|
3711
|
+
let i = this[B] ? mt : li;
|
|
3712
|
+
if (!this[k] && !Buffer.isBuffer(t)) {
|
|
3713
|
+
if (ui(t)) t = Buffer.from(t.buffer, t.byteOffset, t.byteLength);
|
|
3714
|
+
else if (fi(t)) t = Buffer.from(t);
|
|
3715
|
+
else if (typeof t != "string") throw new Error("Non-contiguous data written to non-objectMode stream");
|
|
3716
|
+
}
|
|
3717
|
+
return this[k] ? (this[v] && this[T] !== 0 && this[Ot](!0), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : t.length ? (typeof t == "string" && (e !== this[P] || this[et]?.lastNeed) && (t = Buffer.from(t, e)), Buffer.isBuffer(t) && this[P] && (t = this[et].write(t)), this[v] && this[T] !== 0 && this[Ot](!0), this[v] ? this.emit("data", t) : this[Yt](t), this[T] !== 0 && this.emit("readable"), s && i(s), this[v]) : (this[T] !== 0 && this.emit("readable"), s && i(s), this[v]);
|
|
3718
|
+
}
|
|
3719
|
+
read(t) {
|
|
3720
|
+
if (this[x]) return null;
|
|
3721
|
+
if (this[M] = !1, this[T] === 0 || t === 0 || t && t > this[T]) return this[H](), null;
|
|
3722
|
+
this[k] && (t = null), this[C].length > 1 && !this[k] && (this[C] = [this[P] ? this[C].join("") : Buffer.concat(this[C], this[T])]);
|
|
3723
|
+
let e = this[_e](t || null, this[C][0]);
|
|
3724
|
+
return this[H](), e;
|
|
3725
|
+
}
|
|
3726
|
+
[_e](t, e) {
|
|
3727
|
+
if (this[k]) this[Ft]();
|
|
3728
|
+
else {
|
|
3729
|
+
let s = e;
|
|
3730
|
+
t === s.length || t === null ? this[Ft]() : typeof s == "string" ? (this[C][0] = s.slice(t), e = s.slice(0, t), this[T] -= t) : (this[C][0] = s.subarray(t), e = s.subarray(0, t), this[T] -= t);
|
|
3731
|
+
}
|
|
3732
|
+
return this.emit("data", e), !this[C].length && !this[G] && this.emit("drain"), e;
|
|
3733
|
+
}
|
|
3734
|
+
end(t, e, s) {
|
|
3735
|
+
return typeof t == "function" && (s = t, t = void 0), typeof e == "function" && (s = e, e = "utf8"), t !== void 0 && this.write(t, e), s && this.once("end", s), this[G] = !0, this.writable = !1, (this[v] || !this[dt]) && this[H](), this;
|
|
3736
|
+
}
|
|
3737
|
+
[st]() {
|
|
3738
|
+
this[x] || (!this[Y] && !this[F].length && (this[M] = !0), this[dt] = !1, this[v] = !0, this.emit("resume"), this[C].length ? this[Ot]() : this[G] ? this[H]() : this.emit("drain"));
|
|
3739
|
+
}
|
|
3740
|
+
resume() {
|
|
3741
|
+
return this[st]();
|
|
3742
|
+
}
|
|
3743
|
+
pause() {
|
|
3744
|
+
this[v] = !1, this[dt] = !0, this[M] = !1;
|
|
3745
|
+
}
|
|
3746
|
+
get destroyed() {
|
|
3747
|
+
return this[x];
|
|
3748
|
+
}
|
|
3749
|
+
get flowing() {
|
|
3750
|
+
return this[v];
|
|
3751
|
+
}
|
|
3752
|
+
get paused() {
|
|
3753
|
+
return this[dt];
|
|
3754
|
+
}
|
|
3755
|
+
[Yt](t) {
|
|
3756
|
+
this[k] ? this[T] += 1 : this[T] += t.length, this[C].push(t);
|
|
3757
|
+
}
|
|
3758
|
+
[Ft]() {
|
|
3759
|
+
return this[k] ? this[T] -= 1 : this[T] -= this[C][0].length, this[C].shift();
|
|
3760
|
+
}
|
|
3761
|
+
[Ot](t = !1) {
|
|
3762
|
+
do ;
|
|
3763
|
+
while (this[Le](this[Ft]()) && this[C].length);
|
|
3764
|
+
!t && !this[C].length && !this[G] && this.emit("drain");
|
|
3765
|
+
}
|
|
3766
|
+
[Le](t) {
|
|
3767
|
+
return this.emit("data", t), this[v];
|
|
3768
|
+
}
|
|
3769
|
+
pipe(t, e) {
|
|
3770
|
+
if (this[x]) return t;
|
|
3771
|
+
this[M] = !1;
|
|
3772
|
+
let s = this[K];
|
|
3773
|
+
return e = e || {}, t === Ne.stdout || t === Ne.stderr ? e.end = !1 : e.end = e.end !== !1, e.proxyErrors = !!e.proxyErrors, s ? e.end && t.end() : (this[F].push(e.proxyErrors ? new te(this, t, e) : new Mt(this, t, e)), this[B] ? mt(() => this[st]()) : this[st]()), t;
|
|
3774
|
+
}
|
|
3775
|
+
unpipe(t) {
|
|
3776
|
+
let e = this[F].find((s) => s.dest === t);
|
|
3777
|
+
e && (this[F].length === 1 ? (this[v] && this[Y] === 0 && (this[v] = !1), this[F] = []) : this[F].splice(this[F].indexOf(e), 1), e.unpipe());
|
|
3778
|
+
}
|
|
3779
|
+
addListener(t, e) {
|
|
3780
|
+
return this.on(t, e);
|
|
3781
|
+
}
|
|
3782
|
+
on(t, e) {
|
|
3783
|
+
let s = super.on(t, e);
|
|
3784
|
+
if (t === "data") this[M] = !1, this[Y]++, !this[F].length && !this[v] && this[st]();
|
|
3785
|
+
else if (t === "readable" && this[T] !== 0) super.emit("readable");
|
|
3786
|
+
else if (ci(t) && this[K]) super.emit(t), this.removeAllListeners(t);
|
|
3787
|
+
else if (t === "error" && this[ut]) {
|
|
3788
|
+
let i = e;
|
|
3789
|
+
this[B] ? mt(() => i.call(this, this[ut])) : i.call(this, this[ut]);
|
|
3790
|
+
}
|
|
3791
|
+
return s;
|
|
3792
|
+
}
|
|
3793
|
+
removeListener(t, e) {
|
|
3794
|
+
return this.off(t, e);
|
|
3795
|
+
}
|
|
3796
|
+
off(t, e) {
|
|
3797
|
+
let s = super.off(t, e);
|
|
3798
|
+
return t === "data" && (this[Y] = this.listeners("data").length, this[Y] === 0 && !this[M] && !this[F].length && (this[v] = !1)), s;
|
|
3799
|
+
}
|
|
3800
|
+
removeAllListeners(t) {
|
|
3801
|
+
let e = super.removeAllListeners(t);
|
|
3802
|
+
return (t === "data" || t === void 0) && (this[Y] = 0, !this[M] && !this[F].length && (this[v] = !1)), e;
|
|
3803
|
+
}
|
|
3804
|
+
get emittedEnd() {
|
|
3805
|
+
return this[K];
|
|
3806
|
+
}
|
|
3807
|
+
[H]() {
|
|
3808
|
+
!this[kt] && !this[K] && !this[x] && this[C].length === 0 && this[G] && (this[kt] = !0, this.emit("end"), this.emit("prefinish"), this.emit("finish"), this[Rt] && this.emit("close"), this[kt] = !1);
|
|
3809
|
+
}
|
|
3810
|
+
emit(t, ...e) {
|
|
3811
|
+
let s = e[0];
|
|
3812
|
+
if (t !== "error" && t !== "close" && t !== x && this[x]) return !1;
|
|
3813
|
+
if (t === "data") return !this[k] && !s ? !1 : this[B] ? (mt(() => this[Jt](s)), !0) : this[Jt](s);
|
|
3814
|
+
if (t === "end") return this[We]();
|
|
3815
|
+
if (t === "close") {
|
|
3816
|
+
if (this[Rt] = !0, !this[K] && !this[x]) return !1;
|
|
3817
|
+
let r = super.emit("close");
|
|
3818
|
+
return this.removeAllListeners("close"), r;
|
|
3819
|
+
} else if (t === "error") {
|
|
3820
|
+
this[ut] = s, super.emit(Xt, s);
|
|
3821
|
+
let r = !this[pt] || this.listeners("error").length ? super.emit("error", s) : !1;
|
|
3822
|
+
return this[H](), r;
|
|
3823
|
+
} else if (t === "resume") {
|
|
3824
|
+
let r = super.emit("resume");
|
|
3825
|
+
return this[H](), r;
|
|
3826
|
+
} else if (t === "finish" || t === "prefinish") {
|
|
3827
|
+
let r = super.emit(t);
|
|
3828
|
+
return this.removeAllListeners(t), r;
|
|
3829
|
+
}
|
|
3830
|
+
let i = super.emit(t, ...e);
|
|
3831
|
+
return this[H](), i;
|
|
3832
|
+
}
|
|
3833
|
+
[Jt](t) {
|
|
3834
|
+
for (let s of this[F]) s.dest.write(t) === !1 && this.pause();
|
|
3835
|
+
let e = this[M] ? !1 : super.emit("data", t);
|
|
3836
|
+
return this[H](), e;
|
|
3837
|
+
}
|
|
3838
|
+
[We]() {
|
|
3839
|
+
return this[K] ? !1 : (this[K] = !0, this.readable = !1, this[B] ? (mt(() => this[Zt]()), !0) : this[Zt]());
|
|
3840
|
+
}
|
|
3841
|
+
[Zt]() {
|
|
3842
|
+
if (this[et]) {
|
|
3843
|
+
let e = this[et].end();
|
|
3844
|
+
if (e) {
|
|
3845
|
+
for (let s of this[F]) s.dest.write(e);
|
|
3846
|
+
this[M] || super.emit("data", e);
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
for (let e of this[F]) e.end();
|
|
3850
|
+
let t = super.emit("end");
|
|
3851
|
+
return this.removeAllListeners("end"), t;
|
|
3852
|
+
}
|
|
3853
|
+
async collect() {
|
|
3854
|
+
let t = Object.assign([], { dataLength: 0 });
|
|
3855
|
+
this[k] || (t.dataLength = 0);
|
|
3856
|
+
let e = this.promise();
|
|
3857
|
+
return this.on("data", (s) => {
|
|
3858
|
+
t.push(s), this[k] || (t.dataLength += s.length);
|
|
3859
|
+
}), await e, t;
|
|
3860
|
+
}
|
|
3861
|
+
async concat() {
|
|
3862
|
+
if (this[k]) throw new Error("cannot concat in objectMode");
|
|
3863
|
+
let t = await this.collect();
|
|
3864
|
+
return this[P] ? t.join("") : Buffer.concat(t, t.dataLength);
|
|
3865
|
+
}
|
|
3866
|
+
async promise() {
|
|
3867
|
+
return new Promise((t, e) => {
|
|
3868
|
+
this.on(x, () => e(/* @__PURE__ */ new Error("stream destroyed"))), this.on("error", (s) => e(s)), this.on("end", () => t());
|
|
3869
|
+
});
|
|
3870
|
+
}
|
|
3871
|
+
[Symbol.asyncIterator]() {
|
|
3872
|
+
this[M] = !1;
|
|
3873
|
+
let t = !1, e = async () => (this.pause(), t = !0, {
|
|
3874
|
+
value: void 0,
|
|
3875
|
+
done: !0
|
|
3876
|
+
});
|
|
3877
|
+
return {
|
|
3878
|
+
next: () => {
|
|
3879
|
+
if (t) return e();
|
|
3880
|
+
let i = this.read();
|
|
3881
|
+
if (i !== null) return Promise.resolve({
|
|
3882
|
+
done: !1,
|
|
3883
|
+
value: i
|
|
3884
|
+
});
|
|
3885
|
+
if (this[G]) return e();
|
|
3886
|
+
let r, o, h = (c) => {
|
|
3887
|
+
this.off("data", a), this.off("end", l), this.off(x, u), e(), o(c);
|
|
3888
|
+
}, a = (c) => {
|
|
3889
|
+
this.off("error", h), this.off("end", l), this.off(x, u), this.pause(), r({
|
|
3890
|
+
value: c,
|
|
3891
|
+
done: !!this[G]
|
|
3892
|
+
});
|
|
3893
|
+
}, l = () => {
|
|
3894
|
+
this.off("error", h), this.off("data", a), this.off(x, u), e(), r({
|
|
3895
|
+
done: !0,
|
|
3896
|
+
value: void 0
|
|
3897
|
+
});
|
|
3898
|
+
}, u = () => h(/* @__PURE__ */ new Error("stream destroyed"));
|
|
3899
|
+
return new Promise((c, d) => {
|
|
3900
|
+
o = d, r = c, this.once(x, u), this.once("error", h), this.once("end", l), this.once("data", a);
|
|
3901
|
+
});
|
|
3902
|
+
},
|
|
3903
|
+
throw: e,
|
|
3904
|
+
return: e,
|
|
3905
|
+
[Symbol.asyncIterator]() {
|
|
3906
|
+
return this;
|
|
3907
|
+
},
|
|
3908
|
+
[Symbol.asyncDispose]: async () => {}
|
|
3909
|
+
};
|
|
3910
|
+
}
|
|
3911
|
+
[Symbol.iterator]() {
|
|
3912
|
+
this[M] = !1;
|
|
3913
|
+
let t = !1, e = () => (this.pause(), this.off(Xt, e), this.off(x, e), this.off("end", e), t = !0, {
|
|
3914
|
+
done: !0,
|
|
3915
|
+
value: void 0
|
|
3916
|
+
}), s = () => {
|
|
3917
|
+
if (t) return e();
|
|
3918
|
+
let i = this.read();
|
|
3919
|
+
return i === null ? e() : {
|
|
3920
|
+
done: !1,
|
|
3921
|
+
value: i
|
|
3922
|
+
};
|
|
3923
|
+
};
|
|
3924
|
+
return this.once("end", e), this.once(Xt, e), this.once(x, e), {
|
|
3925
|
+
next: s,
|
|
3926
|
+
throw: e,
|
|
3927
|
+
return: e,
|
|
3928
|
+
[Symbol.iterator]() {
|
|
3929
|
+
return this;
|
|
3930
|
+
},
|
|
3931
|
+
[Symbol.dispose]: () => {}
|
|
3932
|
+
};
|
|
3933
|
+
}
|
|
3934
|
+
destroy(t) {
|
|
3935
|
+
if (this[x]) return t ? this.emit("error", t) : this.emit(x), this;
|
|
3936
|
+
this[x] = !0, this[M] = !0, this[C].length = 0, this[T] = 0;
|
|
3937
|
+
let e = this;
|
|
3938
|
+
return typeof e.close == "function" && !this[Rt] && e.close(), t ? this.emit("error", t) : this.emit(x), this;
|
|
3939
|
+
}
|
|
3940
|
+
static get isStream() {
|
|
3941
|
+
return oi;
|
|
3942
|
+
}
|
|
3943
|
+
};
|
|
3944
|
+
var vi = realpathSync.native;
|
|
3945
|
+
var wt = {
|
|
3946
|
+
lstatSync,
|
|
3947
|
+
readdir,
|
|
3948
|
+
readdirSync,
|
|
3949
|
+
readlinkSync,
|
|
3950
|
+
realpathSync: vi,
|
|
3951
|
+
promises: {
|
|
3952
|
+
lstat,
|
|
3953
|
+
readdir: readdir$1,
|
|
3954
|
+
readlink,
|
|
3955
|
+
realpath
|
|
3956
|
+
}
|
|
3957
|
+
};
|
|
3958
|
+
var Ue = (n) => !n || n === wt || n === xi ? wt : {
|
|
3959
|
+
...wt,
|
|
3960
|
+
...n,
|
|
3961
|
+
promises: {
|
|
3962
|
+
...wt.promises,
|
|
3963
|
+
...n.promises || {}
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
var $e = /^\\\\\?\\([a-z]:)\\?$/i;
|
|
3967
|
+
var Ri = (n) => n.replace(/\//g, "\\").replace($e, "$1\\");
|
|
3968
|
+
var Oi = /[\\\/]/;
|
|
3969
|
+
var L = 0;
|
|
3970
|
+
var Ge = 1;
|
|
3971
|
+
var He = 2;
|
|
3972
|
+
var U = 4;
|
|
3973
|
+
var qe = 6;
|
|
3974
|
+
var Ke = 8;
|
|
3975
|
+
var X = 10;
|
|
3976
|
+
var Ve = 12;
|
|
3977
|
+
var _ = 15;
|
|
3978
|
+
var gt = ~_;
|
|
3979
|
+
var se = 16;
|
|
3980
|
+
var je = 32;
|
|
3981
|
+
var yt = 64;
|
|
3982
|
+
var j = 128;
|
|
3983
|
+
var Nt = 256;
|
|
3984
|
+
var Lt = 512;
|
|
3985
|
+
var Ie = yt | j | Lt;
|
|
3986
|
+
var Fi = 1023;
|
|
3987
|
+
var ie = (n) => n.isFile() ? Ke : n.isDirectory() ? U : n.isSymbolicLink() ? X : n.isCharacterDevice() ? He : n.isBlockDevice() ? qe : n.isSocket() ? Ve : n.isFIFO() ? Ge : L;
|
|
3988
|
+
var ze = new ft({ max: 4096 });
|
|
3989
|
+
var bt = (n) => {
|
|
3990
|
+
let t = ze.get(n);
|
|
3991
|
+
if (t) return t;
|
|
3992
|
+
let e = n.normalize("NFKD");
|
|
3993
|
+
return ze.set(n, e), e;
|
|
3994
|
+
};
|
|
3995
|
+
var Be = new ft({ max: 4096 });
|
|
3996
|
+
var _t = (n) => {
|
|
3997
|
+
let t = Be.get(n);
|
|
3998
|
+
if (t) return t;
|
|
3999
|
+
let e = bt(n.toLowerCase());
|
|
4000
|
+
return Be.set(n, e), e;
|
|
4001
|
+
};
|
|
4002
|
+
var Wt = class extends ft {
|
|
4003
|
+
constructor() {
|
|
4004
|
+
super({ max: 256 });
|
|
4005
|
+
}
|
|
4006
|
+
};
|
|
4007
|
+
var ne = class extends ft {
|
|
4008
|
+
constructor(t = 16384) {
|
|
4009
|
+
super({
|
|
4010
|
+
maxSize: t,
|
|
4011
|
+
sizeCalculation: (e) => e.length + 1
|
|
4012
|
+
});
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
var Ye = Symbol("PathScurry setAsCwd");
|
|
4016
|
+
var R = class {
|
|
4017
|
+
name;
|
|
4018
|
+
root;
|
|
4019
|
+
roots;
|
|
4020
|
+
parent;
|
|
4021
|
+
nocase;
|
|
4022
|
+
isCWD = !1;
|
|
4023
|
+
#t;
|
|
4024
|
+
#s;
|
|
4025
|
+
get dev() {
|
|
4026
|
+
return this.#s;
|
|
4027
|
+
}
|
|
4028
|
+
#n;
|
|
4029
|
+
get mode() {
|
|
4030
|
+
return this.#n;
|
|
4031
|
+
}
|
|
4032
|
+
#r;
|
|
4033
|
+
get nlink() {
|
|
4034
|
+
return this.#r;
|
|
4035
|
+
}
|
|
4036
|
+
#o;
|
|
4037
|
+
get uid() {
|
|
4038
|
+
return this.#o;
|
|
4039
|
+
}
|
|
4040
|
+
#S;
|
|
4041
|
+
get gid() {
|
|
4042
|
+
return this.#S;
|
|
4043
|
+
}
|
|
4044
|
+
#w;
|
|
4045
|
+
get rdev() {
|
|
4046
|
+
return this.#w;
|
|
4047
|
+
}
|
|
4048
|
+
#c;
|
|
4049
|
+
get blksize() {
|
|
4050
|
+
return this.#c;
|
|
4051
|
+
}
|
|
4052
|
+
#h;
|
|
4053
|
+
get ino() {
|
|
4054
|
+
return this.#h;
|
|
4055
|
+
}
|
|
4056
|
+
#u;
|
|
4057
|
+
get size() {
|
|
4058
|
+
return this.#u;
|
|
4059
|
+
}
|
|
4060
|
+
#f;
|
|
4061
|
+
get blocks() {
|
|
4062
|
+
return this.#f;
|
|
4063
|
+
}
|
|
4064
|
+
#a;
|
|
4065
|
+
get atimeMs() {
|
|
4066
|
+
return this.#a;
|
|
4067
|
+
}
|
|
4068
|
+
#i;
|
|
4069
|
+
get mtimeMs() {
|
|
4070
|
+
return this.#i;
|
|
4071
|
+
}
|
|
4072
|
+
#d;
|
|
4073
|
+
get ctimeMs() {
|
|
4074
|
+
return this.#d;
|
|
4075
|
+
}
|
|
4076
|
+
#E;
|
|
4077
|
+
get birthtimeMs() {
|
|
4078
|
+
return this.#E;
|
|
4079
|
+
}
|
|
4080
|
+
#b;
|
|
4081
|
+
get atime() {
|
|
4082
|
+
return this.#b;
|
|
4083
|
+
}
|
|
4084
|
+
#p;
|
|
4085
|
+
get mtime() {
|
|
4086
|
+
return this.#p;
|
|
4087
|
+
}
|
|
4088
|
+
#R;
|
|
4089
|
+
get ctime() {
|
|
4090
|
+
return this.#R;
|
|
4091
|
+
}
|
|
4092
|
+
#m;
|
|
4093
|
+
get birthtime() {
|
|
4094
|
+
return this.#m;
|
|
4095
|
+
}
|
|
4096
|
+
#C;
|
|
4097
|
+
#T;
|
|
4098
|
+
#g;
|
|
4099
|
+
#y;
|
|
4100
|
+
#x;
|
|
4101
|
+
#A;
|
|
4102
|
+
#e;
|
|
4103
|
+
#_;
|
|
4104
|
+
#M;
|
|
4105
|
+
#k;
|
|
4106
|
+
get parentPath() {
|
|
4107
|
+
return (this.parent || this).fullpath();
|
|
4108
|
+
}
|
|
4109
|
+
get path() {
|
|
4110
|
+
return this.parentPath;
|
|
4111
|
+
}
|
|
4112
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
4113
|
+
this.name = t, this.#C = r ? _t(t) : bt(t), this.#e = e & Fi, this.nocase = r, this.roots = i, this.root = s || this, this.#_ = o, this.#g = h.fullpath, this.#x = h.relative, this.#A = h.relativePosix, this.parent = h.parent, this.parent ? this.#t = this.parent.#t : this.#t = Ue(h.fs);
|
|
4114
|
+
}
|
|
4115
|
+
depth() {
|
|
4116
|
+
return this.#T !== void 0 ? this.#T : this.parent ? this.#T = this.parent.depth() + 1 : this.#T = 0;
|
|
4117
|
+
}
|
|
4118
|
+
childrenCache() {
|
|
4119
|
+
return this.#_;
|
|
4120
|
+
}
|
|
4121
|
+
resolve(t) {
|
|
4122
|
+
if (!t) return this;
|
|
4123
|
+
let e = this.getRootString(t), i = t.substring(e.length).split(this.splitSep);
|
|
4124
|
+
return e ? this.getRoot(e).#N(i) : this.#N(i);
|
|
4125
|
+
}
|
|
4126
|
+
#N(t) {
|
|
4127
|
+
let e = this;
|
|
4128
|
+
for (let s of t) e = e.child(s);
|
|
4129
|
+
return e;
|
|
4130
|
+
}
|
|
4131
|
+
children() {
|
|
4132
|
+
let t = this.#_.get(this);
|
|
4133
|
+
if (t) return t;
|
|
4134
|
+
let e = Object.assign([], { provisional: 0 });
|
|
4135
|
+
return this.#_.set(this, e), this.#e &= ~se, e;
|
|
4136
|
+
}
|
|
4137
|
+
child(t, e) {
|
|
4138
|
+
if (t === "" || t === ".") return this;
|
|
4139
|
+
if (t === "..") return this.parent || this;
|
|
4140
|
+
let s = this.children(), i = this.nocase ? _t(t) : bt(t);
|
|
4141
|
+
for (let a of s) if (a.#C === i) return a;
|
|
4142
|
+
let r = this.parent ? this.sep : "", o = this.#g ? this.#g + r + t : void 0, h = this.newChild(t, L, {
|
|
4143
|
+
...e,
|
|
4144
|
+
parent: this,
|
|
4145
|
+
fullpath: o
|
|
4146
|
+
});
|
|
4147
|
+
return this.canReaddir() || (h.#e |= j), s.push(h), h;
|
|
4148
|
+
}
|
|
4149
|
+
relative() {
|
|
4150
|
+
if (this.isCWD) return "";
|
|
4151
|
+
if (this.#x !== void 0) return this.#x;
|
|
4152
|
+
let t = this.name, e = this.parent;
|
|
4153
|
+
if (!e) return this.#x = this.name;
|
|
4154
|
+
let s = e.relative();
|
|
4155
|
+
return s + (!s || !e.parent ? "" : this.sep) + t;
|
|
4156
|
+
}
|
|
4157
|
+
relativePosix() {
|
|
4158
|
+
if (this.sep === "/") return this.relative();
|
|
4159
|
+
if (this.isCWD) return "";
|
|
4160
|
+
if (this.#A !== void 0) return this.#A;
|
|
4161
|
+
let t = this.name, e = this.parent;
|
|
4162
|
+
if (!e) return this.#A = this.fullpathPosix();
|
|
4163
|
+
let s = e.relativePosix();
|
|
4164
|
+
return s + (!s || !e.parent ? "" : "/") + t;
|
|
4165
|
+
}
|
|
4166
|
+
fullpath() {
|
|
4167
|
+
if (this.#g !== void 0) return this.#g;
|
|
4168
|
+
let t = this.name, e = this.parent;
|
|
4169
|
+
if (!e) return this.#g = this.name;
|
|
4170
|
+
let i = e.fullpath() + (e.parent ? this.sep : "") + t;
|
|
4171
|
+
return this.#g = i;
|
|
4172
|
+
}
|
|
4173
|
+
fullpathPosix() {
|
|
4174
|
+
if (this.#y !== void 0) return this.#y;
|
|
4175
|
+
if (this.sep === "/") return this.#y = this.fullpath();
|
|
4176
|
+
if (!this.parent) {
|
|
4177
|
+
let i = this.fullpath().replace(/\\/g, "/");
|
|
4178
|
+
return /^[a-z]:\//i.test(i) ? this.#y = `//?/${i}` : this.#y = i;
|
|
4179
|
+
}
|
|
4180
|
+
let t = this.parent, e = t.fullpathPosix(), s = e + (!e || !t.parent ? "" : "/") + this.name;
|
|
4181
|
+
return this.#y = s;
|
|
4182
|
+
}
|
|
4183
|
+
isUnknown() {
|
|
4184
|
+
return (this.#e & _) === L;
|
|
4185
|
+
}
|
|
4186
|
+
isType(t) {
|
|
4187
|
+
return this[`is${t}`]();
|
|
4188
|
+
}
|
|
4189
|
+
getType() {
|
|
4190
|
+
return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : this.isSocket() ? "Socket" : "Unknown";
|
|
4191
|
+
}
|
|
4192
|
+
isFile() {
|
|
4193
|
+
return (this.#e & _) === Ke;
|
|
4194
|
+
}
|
|
4195
|
+
isDirectory() {
|
|
4196
|
+
return (this.#e & _) === U;
|
|
4197
|
+
}
|
|
4198
|
+
isCharacterDevice() {
|
|
4199
|
+
return (this.#e & _) === He;
|
|
4200
|
+
}
|
|
4201
|
+
isBlockDevice() {
|
|
4202
|
+
return (this.#e & _) === qe;
|
|
4203
|
+
}
|
|
4204
|
+
isFIFO() {
|
|
4205
|
+
return (this.#e & _) === Ge;
|
|
4206
|
+
}
|
|
4207
|
+
isSocket() {
|
|
4208
|
+
return (this.#e & _) === Ve;
|
|
4209
|
+
}
|
|
4210
|
+
isSymbolicLink() {
|
|
4211
|
+
return (this.#e & X) === X;
|
|
4212
|
+
}
|
|
4213
|
+
lstatCached() {
|
|
4214
|
+
return this.#e & je ? this : void 0;
|
|
4215
|
+
}
|
|
4216
|
+
readlinkCached() {
|
|
4217
|
+
return this.#M;
|
|
4218
|
+
}
|
|
4219
|
+
realpathCached() {
|
|
4220
|
+
return this.#k;
|
|
4221
|
+
}
|
|
4222
|
+
readdirCached() {
|
|
4223
|
+
let t = this.children();
|
|
4224
|
+
return t.slice(0, t.provisional);
|
|
4225
|
+
}
|
|
4226
|
+
canReadlink() {
|
|
4227
|
+
if (this.#M) return !0;
|
|
4228
|
+
if (!this.parent) return !1;
|
|
4229
|
+
let t = this.#e & _;
|
|
4230
|
+
return !(t !== L && t !== X || this.#e & Nt || this.#e & j);
|
|
4231
|
+
}
|
|
4232
|
+
calledReaddir() {
|
|
4233
|
+
return !!(this.#e & se);
|
|
4234
|
+
}
|
|
4235
|
+
isENOENT() {
|
|
4236
|
+
return !!(this.#e & j);
|
|
4237
|
+
}
|
|
4238
|
+
isNamed(t) {
|
|
4239
|
+
return this.nocase ? this.#C === _t(t) : this.#C === bt(t);
|
|
4240
|
+
}
|
|
4241
|
+
async readlink() {
|
|
4242
|
+
let t = this.#M;
|
|
4243
|
+
if (t) return t;
|
|
4244
|
+
if (this.canReadlink() && this.parent) try {
|
|
4245
|
+
let e = await this.#t.promises.readlink(this.fullpath()), s = (await this.parent.realpath())?.resolve(e);
|
|
4246
|
+
if (s) return this.#M = s;
|
|
4247
|
+
} catch (e) {
|
|
4248
|
+
this.#D(e.code);
|
|
4249
|
+
return;
|
|
4250
|
+
}
|
|
4251
|
+
}
|
|
4252
|
+
readlinkSync() {
|
|
4253
|
+
let t = this.#M;
|
|
4254
|
+
if (t) return t;
|
|
4255
|
+
if (this.canReadlink() && this.parent) try {
|
|
4256
|
+
let e = this.#t.readlinkSync(this.fullpath()), s = this.parent.realpathSync()?.resolve(e);
|
|
4257
|
+
if (s) return this.#M = s;
|
|
4258
|
+
} catch (e) {
|
|
4259
|
+
this.#D(e.code);
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
}
|
|
4263
|
+
#j(t) {
|
|
4264
|
+
this.#e |= se;
|
|
4265
|
+
for (let e = t.provisional; e < t.length; e++) {
|
|
4266
|
+
let s = t[e];
|
|
4267
|
+
s && s.#v();
|
|
4268
|
+
}
|
|
4269
|
+
}
|
|
4270
|
+
#v() {
|
|
4271
|
+
this.#e & j || (this.#e = (this.#e | j) & gt, this.#G());
|
|
4272
|
+
}
|
|
4273
|
+
#G() {
|
|
4274
|
+
let t = this.children();
|
|
4275
|
+
t.provisional = 0;
|
|
4276
|
+
for (let e of t) e.#v();
|
|
4277
|
+
}
|
|
4278
|
+
#P() {
|
|
4279
|
+
this.#e |= Lt, this.#L();
|
|
4280
|
+
}
|
|
4281
|
+
#L() {
|
|
4282
|
+
if (this.#e & yt) return;
|
|
4283
|
+
let t = this.#e;
|
|
4284
|
+
(t & _) === U && (t &= gt), this.#e = t | yt, this.#G();
|
|
4285
|
+
}
|
|
4286
|
+
#I(t = "") {
|
|
4287
|
+
t === "ENOTDIR" || t === "EPERM" ? this.#L() : t === "ENOENT" ? this.#v() : this.children().provisional = 0;
|
|
4288
|
+
}
|
|
4289
|
+
#F(t = "") {
|
|
4290
|
+
t === "ENOTDIR" ? this.parent.#L() : t === "ENOENT" && this.#v();
|
|
4291
|
+
}
|
|
4292
|
+
#D(t = "") {
|
|
4293
|
+
let e = this.#e;
|
|
4294
|
+
e |= Nt, t === "ENOENT" && (e |= j), (t === "EINVAL" || t === "UNKNOWN") && (e &= gt), this.#e = e, t === "ENOTDIR" && this.parent && this.parent.#L();
|
|
4295
|
+
}
|
|
4296
|
+
#z(t, e) {
|
|
4297
|
+
return this.#U(t, e) || this.#B(t, e);
|
|
4298
|
+
}
|
|
4299
|
+
#B(t, e) {
|
|
4300
|
+
let s = ie(t), i = this.newChild(t.name, s, { parent: this }), r = i.#e & _;
|
|
4301
|
+
return r !== U && r !== X && r !== L && (i.#e |= yt), e.unshift(i), e.provisional++, i;
|
|
4302
|
+
}
|
|
4303
|
+
#U(t, e) {
|
|
4304
|
+
for (let s = e.provisional; s < e.length; s++) {
|
|
4305
|
+
let i = e[s];
|
|
4306
|
+
if ((this.nocase ? _t(t.name) : bt(t.name)) === i.#C) return this.#l(t, i, s, e);
|
|
4307
|
+
}
|
|
4308
|
+
}
|
|
4309
|
+
#l(t, e, s, i) {
|
|
4310
|
+
let r = e.name;
|
|
4311
|
+
return e.#e = e.#e & gt | ie(t), r !== t.name && (e.name = t.name), s !== i.provisional && (s === i.length - 1 ? i.pop() : i.splice(s, 1), i.unshift(e)), i.provisional++, e;
|
|
4312
|
+
}
|
|
4313
|
+
async lstat() {
|
|
4314
|
+
if ((this.#e & j) === 0) try {
|
|
4315
|
+
return this.#$(await this.#t.promises.lstat(this.fullpath())), this;
|
|
4316
|
+
} catch (t) {
|
|
4317
|
+
this.#F(t.code);
|
|
4318
|
+
}
|
|
4319
|
+
}
|
|
4320
|
+
lstatSync() {
|
|
4321
|
+
if ((this.#e & j) === 0) try {
|
|
4322
|
+
return this.#$(this.#t.lstatSync(this.fullpath())), this;
|
|
4323
|
+
} catch (t) {
|
|
4324
|
+
this.#F(t.code);
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
#$(t) {
|
|
4328
|
+
let { atime: e, atimeMs: s, birthtime: i, birthtimeMs: r, blksize: o, blocks: h, ctime: a, ctimeMs: l, dev: u, gid: c, ino: d, mode: f, mtime: m, mtimeMs: p, nlink: w, rdev: g, size: S, uid: E } = t;
|
|
4329
|
+
this.#b = e, this.#a = s, this.#m = i, this.#E = r, this.#c = o, this.#f = h, this.#R = a, this.#d = l, this.#s = u, this.#S = c, this.#h = d, this.#n = f, this.#p = m, this.#i = p, this.#r = w, this.#w = g, this.#u = S, this.#o = E;
|
|
4330
|
+
let y = ie(t);
|
|
4331
|
+
this.#e = this.#e & gt | y | je, y !== L && y !== U && y !== X && (this.#e |= yt);
|
|
4332
|
+
}
|
|
4333
|
+
#W = [];
|
|
4334
|
+
#O = !1;
|
|
4335
|
+
#H(t) {
|
|
4336
|
+
this.#O = !1;
|
|
4337
|
+
let e = this.#W.slice();
|
|
4338
|
+
this.#W.length = 0, e.forEach((s) => s(null, t));
|
|
4339
|
+
}
|
|
4340
|
+
readdirCB(t, e = !1) {
|
|
4341
|
+
if (!this.canReaddir()) {
|
|
4342
|
+
e ? t(null, []) : queueMicrotask(() => t(null, []));
|
|
4343
|
+
return;
|
|
4344
|
+
}
|
|
4345
|
+
let s = this.children();
|
|
4346
|
+
if (this.calledReaddir()) {
|
|
4347
|
+
let r = s.slice(0, s.provisional);
|
|
4348
|
+
e ? t(null, r) : queueMicrotask(() => t(null, r));
|
|
4349
|
+
return;
|
|
4350
|
+
}
|
|
4351
|
+
if (this.#W.push(t), this.#O) return;
|
|
4352
|
+
this.#O = !0;
|
|
4353
|
+
let i = this.fullpath();
|
|
4354
|
+
this.#t.readdir(i, { withFileTypes: !0 }, (r, o) => {
|
|
4355
|
+
if (r) this.#I(r.code), s.provisional = 0;
|
|
4356
|
+
else {
|
|
4357
|
+
for (let h of o) this.#z(h, s);
|
|
4358
|
+
this.#j(s);
|
|
4359
|
+
}
|
|
4360
|
+
this.#H(s.slice(0, s.provisional));
|
|
4361
|
+
});
|
|
4362
|
+
}
|
|
4363
|
+
#q;
|
|
4364
|
+
async readdir() {
|
|
4365
|
+
if (!this.canReaddir()) return [];
|
|
4366
|
+
let t = this.children();
|
|
4367
|
+
if (this.calledReaddir()) return t.slice(0, t.provisional);
|
|
4368
|
+
let e = this.fullpath();
|
|
4369
|
+
if (this.#q) await this.#q;
|
|
4370
|
+
else {
|
|
4371
|
+
let s = () => {};
|
|
4372
|
+
this.#q = new Promise((i) => s = i);
|
|
4373
|
+
try {
|
|
4374
|
+
for (let i of await this.#t.promises.readdir(e, { withFileTypes: !0 })) this.#z(i, t);
|
|
4375
|
+
this.#j(t);
|
|
4376
|
+
} catch (i) {
|
|
4377
|
+
this.#I(i.code), t.provisional = 0;
|
|
4378
|
+
}
|
|
4379
|
+
this.#q = void 0, s();
|
|
4380
|
+
}
|
|
4381
|
+
return t.slice(0, t.provisional);
|
|
4382
|
+
}
|
|
4383
|
+
readdirSync() {
|
|
4384
|
+
if (!this.canReaddir()) return [];
|
|
4385
|
+
let t = this.children();
|
|
4386
|
+
if (this.calledReaddir()) return t.slice(0, t.provisional);
|
|
4387
|
+
let e = this.fullpath();
|
|
4388
|
+
try {
|
|
4389
|
+
for (let s of this.#t.readdirSync(e, { withFileTypes: !0 })) this.#z(s, t);
|
|
4390
|
+
this.#j(t);
|
|
4391
|
+
} catch (s) {
|
|
4392
|
+
this.#I(s.code), t.provisional = 0;
|
|
4393
|
+
}
|
|
4394
|
+
return t.slice(0, t.provisional);
|
|
4395
|
+
}
|
|
4396
|
+
canReaddir() {
|
|
4397
|
+
if (this.#e & Ie) return !1;
|
|
4398
|
+
let t = _ & this.#e;
|
|
4399
|
+
return t === L || t === U || t === X;
|
|
4400
|
+
}
|
|
4401
|
+
shouldWalk(t, e) {
|
|
4402
|
+
return (this.#e & U) === U && !(this.#e & Ie) && !t.has(this) && (!e || e(this));
|
|
4403
|
+
}
|
|
4404
|
+
async realpath() {
|
|
4405
|
+
if (this.#k) return this.#k;
|
|
4406
|
+
if (!((Lt | Nt | j) & this.#e)) try {
|
|
4407
|
+
let t = await this.#t.promises.realpath(this.fullpath());
|
|
4408
|
+
return this.#k = this.resolve(t);
|
|
4409
|
+
} catch {
|
|
4410
|
+
this.#P();
|
|
4411
|
+
}
|
|
4412
|
+
}
|
|
4413
|
+
realpathSync() {
|
|
4414
|
+
if (this.#k) return this.#k;
|
|
4415
|
+
if (!((Lt | Nt | j) & this.#e)) try {
|
|
4416
|
+
let t = this.#t.realpathSync(this.fullpath());
|
|
4417
|
+
return this.#k = this.resolve(t);
|
|
4418
|
+
} catch {
|
|
4419
|
+
this.#P();
|
|
4420
|
+
}
|
|
4421
|
+
}
|
|
4422
|
+
[Ye](t) {
|
|
4423
|
+
if (t === this) return;
|
|
4424
|
+
t.isCWD = !1, this.isCWD = !0;
|
|
4425
|
+
let e = /* @__PURE__ */ new Set([]), s = [], i = this;
|
|
4426
|
+
for (; i && i.parent;) e.add(i), i.#x = s.join(this.sep), i.#A = s.join("/"), i = i.parent, s.push("..");
|
|
4427
|
+
for (i = t; i && i.parent && !e.has(i);) i.#x = void 0, i.#A = void 0, i = i.parent;
|
|
4428
|
+
}
|
|
4429
|
+
};
|
|
4430
|
+
var Pt = class n extends R {
|
|
4431
|
+
sep = "\\";
|
|
4432
|
+
splitSep = Oi;
|
|
4433
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
4434
|
+
super(t, e, s, i, r, o, h);
|
|
4435
|
+
}
|
|
4436
|
+
newChild(t, e = L, s = {}) {
|
|
4437
|
+
return new n(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
4438
|
+
}
|
|
4439
|
+
getRootString(t) {
|
|
4440
|
+
return win32.parse(t).root;
|
|
4441
|
+
}
|
|
4442
|
+
getRoot(t) {
|
|
4443
|
+
if (t = Ri(t.toUpperCase()), t === this.root.name) return this.root;
|
|
4444
|
+
for (let [e, s] of Object.entries(this.roots)) if (this.sameRoot(t, e)) return this.roots[t] = s;
|
|
4445
|
+
return this.roots[t] = new it(t, this).root;
|
|
4446
|
+
}
|
|
4447
|
+
sameRoot(t, e = this.root.name) {
|
|
4448
|
+
return t = t.toUpperCase().replace(/\//g, "\\").replace($e, "$1\\"), t === e;
|
|
4449
|
+
}
|
|
4450
|
+
};
|
|
4451
|
+
var jt = class n extends R {
|
|
4452
|
+
splitSep = "/";
|
|
4453
|
+
sep = "/";
|
|
4454
|
+
constructor(t, e = L, s, i, r, o, h) {
|
|
4455
|
+
super(t, e, s, i, r, o, h);
|
|
4456
|
+
}
|
|
4457
|
+
getRootString(t) {
|
|
4458
|
+
return t.startsWith("/") ? "/" : "";
|
|
4459
|
+
}
|
|
4460
|
+
getRoot(t) {
|
|
4461
|
+
return this.root;
|
|
4462
|
+
}
|
|
4463
|
+
newChild(t, e = L, s = {}) {
|
|
4464
|
+
return new n(t, e, this.root, this.roots, this.nocase, this.childrenCache(), s);
|
|
4465
|
+
}
|
|
4466
|
+
};
|
|
4467
|
+
var It = class {
|
|
4468
|
+
root;
|
|
4469
|
+
rootPath;
|
|
4470
|
+
roots;
|
|
4471
|
+
cwd;
|
|
4472
|
+
#t;
|
|
4473
|
+
#s;
|
|
4474
|
+
#n;
|
|
4475
|
+
nocase;
|
|
4476
|
+
#r;
|
|
4477
|
+
constructor(t = process.cwd(), e, s, { nocase: i, childrenCacheSize: r = 16384, fs: o = wt } = {}) {
|
|
4478
|
+
this.#r = Ue(o), (t instanceof URL || t.startsWith("file://")) && (t = fileURLToPath(t));
|
|
4479
|
+
let h = e.resolve(t);
|
|
4480
|
+
this.roots = Object.create(null), this.rootPath = this.parseRootPath(h), this.#t = new Wt(), this.#s = new Wt(), this.#n = new ne(r);
|
|
4481
|
+
let a = h.substring(this.rootPath.length).split(s);
|
|
4482
|
+
if (a.length === 1 && !a[0] && a.pop(), i === void 0) throw new TypeError("must provide nocase setting to PathScurryBase ctor");
|
|
4483
|
+
this.nocase = i, this.root = this.newRoot(this.#r), this.roots[this.rootPath] = this.root;
|
|
4484
|
+
let l = this.root, u = a.length - 1, c = e.sep, d = this.rootPath, f = !1;
|
|
4485
|
+
for (let m of a) {
|
|
4486
|
+
let p = u--;
|
|
4487
|
+
l = l.child(m, {
|
|
4488
|
+
relative: new Array(p).fill("..").join(c),
|
|
4489
|
+
relativePosix: new Array(p).fill("..").join("/"),
|
|
4490
|
+
fullpath: d += (f ? "" : c) + m
|
|
4491
|
+
}), f = !0;
|
|
4492
|
+
}
|
|
4493
|
+
this.cwd = l;
|
|
4494
|
+
}
|
|
4495
|
+
depth(t = this.cwd) {
|
|
4496
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.depth();
|
|
4497
|
+
}
|
|
4498
|
+
childrenCache() {
|
|
4499
|
+
return this.#n;
|
|
4500
|
+
}
|
|
4501
|
+
resolve(...t) {
|
|
4502
|
+
let e = "";
|
|
4503
|
+
for (let r = t.length - 1; r >= 0; r--) {
|
|
4504
|
+
let o = t[r];
|
|
4505
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
|
|
4506
|
+
}
|
|
4507
|
+
let s = this.#t.get(e);
|
|
4508
|
+
if (s !== void 0) return s;
|
|
4509
|
+
let i = this.cwd.resolve(e).fullpath();
|
|
4510
|
+
return this.#t.set(e, i), i;
|
|
4511
|
+
}
|
|
4512
|
+
resolvePosix(...t) {
|
|
4513
|
+
let e = "";
|
|
4514
|
+
for (let r = t.length - 1; r >= 0; r--) {
|
|
4515
|
+
let o = t[r];
|
|
4516
|
+
if (!(!o || o === ".") && (e = e ? `${o}/${e}` : o, this.isAbsolute(o))) break;
|
|
4517
|
+
}
|
|
4518
|
+
let s = this.#s.get(e);
|
|
4519
|
+
if (s !== void 0) return s;
|
|
4520
|
+
let i = this.cwd.resolve(e).fullpathPosix();
|
|
4521
|
+
return this.#s.set(e, i), i;
|
|
4522
|
+
}
|
|
4523
|
+
relative(t = this.cwd) {
|
|
4524
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relative();
|
|
4525
|
+
}
|
|
4526
|
+
relativePosix(t = this.cwd) {
|
|
4527
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.relativePosix();
|
|
4528
|
+
}
|
|
4529
|
+
basename(t = this.cwd) {
|
|
4530
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.name;
|
|
4531
|
+
}
|
|
4532
|
+
dirname(t = this.cwd) {
|
|
4533
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), (t.parent || t).fullpath();
|
|
4534
|
+
}
|
|
4535
|
+
async readdir(t = this.cwd, e = { withFileTypes: !0 }) {
|
|
4536
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4537
|
+
let { withFileTypes: s } = e;
|
|
4538
|
+
if (t.canReaddir()) {
|
|
4539
|
+
let i = await t.readdir();
|
|
4540
|
+
return s ? i : i.map((r) => r.name);
|
|
4541
|
+
} else return [];
|
|
4542
|
+
}
|
|
4543
|
+
readdirSync(t = this.cwd, e = { withFileTypes: !0 }) {
|
|
4544
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4545
|
+
let { withFileTypes: s = !0 } = e;
|
|
4546
|
+
return t.canReaddir() ? s ? t.readdirSync() : t.readdirSync().map((i) => i.name) : [];
|
|
4547
|
+
}
|
|
4548
|
+
async lstat(t = this.cwd) {
|
|
4549
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstat();
|
|
4550
|
+
}
|
|
4551
|
+
lstatSync(t = this.cwd) {
|
|
4552
|
+
return typeof t == "string" && (t = this.cwd.resolve(t)), t.lstatSync();
|
|
4553
|
+
}
|
|
4554
|
+
async readlink(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
|
|
4555
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
4556
|
+
let s = await t.readlink();
|
|
4557
|
+
return e ? s : s?.fullpath();
|
|
4558
|
+
}
|
|
4559
|
+
readlinkSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
|
|
4560
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
4561
|
+
let s = t.readlinkSync();
|
|
4562
|
+
return e ? s : s?.fullpath();
|
|
4563
|
+
}
|
|
4564
|
+
async realpath(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
|
|
4565
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
4566
|
+
let s = await t.realpath();
|
|
4567
|
+
return e ? s : s?.fullpath();
|
|
4568
|
+
}
|
|
4569
|
+
realpathSync(t = this.cwd, { withFileTypes: e } = { withFileTypes: !1 }) {
|
|
4570
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t.withFileTypes, t = this.cwd);
|
|
4571
|
+
let s = t.realpathSync();
|
|
4572
|
+
return e ? s : s?.fullpath();
|
|
4573
|
+
}
|
|
4574
|
+
async walk(t = this.cwd, e = {}) {
|
|
4575
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4576
|
+
let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = [];
|
|
4577
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
4578
|
+
let a = /* @__PURE__ */ new Set(), l = (c, d) => {
|
|
4579
|
+
a.add(c), c.readdirCB((f, m) => {
|
|
4580
|
+
if (f) return d(f);
|
|
4581
|
+
let p = m.length;
|
|
4582
|
+
if (!p) return d();
|
|
4583
|
+
let w = () => {
|
|
4584
|
+
--p === 0 && d();
|
|
4585
|
+
};
|
|
4586
|
+
for (let g of m) (!r || r(g)) && h.push(s ? g : g.fullpath()), i && g.isSymbolicLink() ? g.realpath().then((S) => S?.isUnknown() ? S.lstat() : S).then((S) => S?.shouldWalk(a, o) ? l(S, w) : w()) : g.shouldWalk(a, o) ? l(g, w) : w();
|
|
4587
|
+
}, !0);
|
|
4588
|
+
}, u = t;
|
|
4589
|
+
return new Promise((c, d) => {
|
|
4590
|
+
l(u, (f) => {
|
|
4591
|
+
if (f) return d(f);
|
|
4592
|
+
c(h);
|
|
4593
|
+
});
|
|
4594
|
+
});
|
|
4595
|
+
}
|
|
4596
|
+
walkSync(t = this.cwd, e = {}) {
|
|
4597
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4598
|
+
let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = [];
|
|
4599
|
+
(!r || r(t)) && h.push(s ? t : t.fullpath());
|
|
4600
|
+
let a = /* @__PURE__ */ new Set([t]);
|
|
4601
|
+
for (let l of a) {
|
|
4602
|
+
let u = l.readdirSync();
|
|
4603
|
+
for (let c of u) {
|
|
4604
|
+
(!r || r(c)) && h.push(s ? c : c.fullpath());
|
|
4605
|
+
let d = c;
|
|
4606
|
+
if (c.isSymbolicLink()) {
|
|
4607
|
+
if (!(i && (d = c.realpathSync()))) continue;
|
|
4608
|
+
d.isUnknown() && d.lstatSync();
|
|
4609
|
+
}
|
|
4610
|
+
d.shouldWalk(a, o) && a.add(d);
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
return h;
|
|
4614
|
+
}
|
|
4615
|
+
[Symbol.asyncIterator]() {
|
|
4616
|
+
return this.iterate();
|
|
4617
|
+
}
|
|
4618
|
+
iterate(t = this.cwd, e = {}) {
|
|
4619
|
+
return typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd), this.stream(t, e)[Symbol.asyncIterator]();
|
|
4620
|
+
}
|
|
4621
|
+
[Symbol.iterator]() {
|
|
4622
|
+
return this.iterateSync();
|
|
4623
|
+
}
|
|
4624
|
+
*iterateSync(t = this.cwd, e = {}) {
|
|
4625
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4626
|
+
let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e;
|
|
4627
|
+
(!r || r(t)) && (yield s ? t : t.fullpath());
|
|
4628
|
+
let h = /* @__PURE__ */ new Set([t]);
|
|
4629
|
+
for (let a of h) {
|
|
4630
|
+
let l = a.readdirSync();
|
|
4631
|
+
for (let u of l) {
|
|
4632
|
+
(!r || r(u)) && (yield s ? u : u.fullpath());
|
|
4633
|
+
let c = u;
|
|
4634
|
+
if (u.isSymbolicLink()) {
|
|
4635
|
+
if (!(i && (c = u.realpathSync()))) continue;
|
|
4636
|
+
c.isUnknown() && c.lstatSync();
|
|
4637
|
+
}
|
|
4638
|
+
c.shouldWalk(h, o) && h.add(c);
|
|
4639
|
+
}
|
|
4640
|
+
}
|
|
4641
|
+
}
|
|
4642
|
+
stream(t = this.cwd, e = {}) {
|
|
4643
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4644
|
+
let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = new V({ objectMode: !0 });
|
|
4645
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
4646
|
+
let a = /* @__PURE__ */ new Set(), l = [t], u = 0, c = () => {
|
|
4647
|
+
let d = !1;
|
|
4648
|
+
for (; !d;) {
|
|
4649
|
+
let f = l.shift();
|
|
4650
|
+
if (!f) {
|
|
4651
|
+
u === 0 && h.end();
|
|
4652
|
+
return;
|
|
4653
|
+
}
|
|
4654
|
+
u++, a.add(f);
|
|
4655
|
+
let m = (w, g, S = !1) => {
|
|
4656
|
+
if (w) return h.emit("error", w);
|
|
4657
|
+
if (i && !S) {
|
|
4658
|
+
let E = [];
|
|
4659
|
+
for (let y of g) y.isSymbolicLink() && E.push(y.realpath().then((b) => b?.isUnknown() ? b.lstat() : b));
|
|
4660
|
+
if (E.length) {
|
|
4661
|
+
Promise.all(E).then(() => m(null, g, !0));
|
|
4662
|
+
return;
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
for (let E of g) E && (!r || r(E)) && (h.write(s ? E : E.fullpath()) || (d = !0));
|
|
4666
|
+
u--;
|
|
4667
|
+
for (let E of g) {
|
|
4668
|
+
let y = E.realpathCached() || E;
|
|
4669
|
+
y.shouldWalk(a, o) && l.push(y);
|
|
4670
|
+
}
|
|
4671
|
+
d && !h.flowing ? h.once("drain", c) : p || c();
|
|
4672
|
+
}, p = !0;
|
|
4673
|
+
f.readdirCB(m, !0), p = !1;
|
|
4674
|
+
}
|
|
4675
|
+
};
|
|
4676
|
+
return c(), h;
|
|
4677
|
+
}
|
|
4678
|
+
streamSync(t = this.cwd, e = {}) {
|
|
4679
|
+
typeof t == "string" ? t = this.cwd.resolve(t) : t instanceof R || (e = t, t = this.cwd);
|
|
4680
|
+
let { withFileTypes: s = !0, follow: i = !1, filter: r, walkFilter: o } = e, h = new V({ objectMode: !0 }), a = /* @__PURE__ */ new Set();
|
|
4681
|
+
(!r || r(t)) && h.write(s ? t : t.fullpath());
|
|
4682
|
+
let l = [t], u = 0, c = () => {
|
|
4683
|
+
let d = !1;
|
|
4684
|
+
for (; !d;) {
|
|
4685
|
+
let f = l.shift();
|
|
4686
|
+
if (!f) {
|
|
4687
|
+
u === 0 && h.end();
|
|
4688
|
+
return;
|
|
4689
|
+
}
|
|
4690
|
+
u++, a.add(f);
|
|
4691
|
+
let m = f.readdirSync();
|
|
4692
|
+
for (let p of m) (!r || r(p)) && (h.write(s ? p : p.fullpath()) || (d = !0));
|
|
4693
|
+
u--;
|
|
4694
|
+
for (let p of m) {
|
|
4695
|
+
let w = p;
|
|
4696
|
+
if (p.isSymbolicLink()) {
|
|
4697
|
+
if (!(i && (w = p.realpathSync()))) continue;
|
|
4698
|
+
w.isUnknown() && w.lstatSync();
|
|
4699
|
+
}
|
|
4700
|
+
w.shouldWalk(a, o) && l.push(w);
|
|
4701
|
+
}
|
|
4702
|
+
}
|
|
4703
|
+
d && !h.flowing && h.once("drain", c);
|
|
4704
|
+
};
|
|
4705
|
+
return c(), h;
|
|
4706
|
+
}
|
|
4707
|
+
chdir(t = this.cwd) {
|
|
4708
|
+
let e = this.cwd;
|
|
4709
|
+
this.cwd = typeof t == "string" ? this.cwd.resolve(t) : t, this.cwd[Ye](e);
|
|
4710
|
+
}
|
|
4711
|
+
};
|
|
4712
|
+
var it = class extends It {
|
|
4713
|
+
sep = "\\";
|
|
4714
|
+
constructor(t = process.cwd(), e = {}) {
|
|
4715
|
+
let { nocase: s = !0 } = e;
|
|
4716
|
+
super(t, win32, "\\", {
|
|
4717
|
+
...e,
|
|
4718
|
+
nocase: s
|
|
4719
|
+
}), this.nocase = s;
|
|
4720
|
+
for (let i = this.cwd; i; i = i.parent) i.nocase = this.nocase;
|
|
4721
|
+
}
|
|
4722
|
+
parseRootPath(t) {
|
|
4723
|
+
return win32.parse(t).root.toUpperCase();
|
|
4724
|
+
}
|
|
4725
|
+
newRoot(t) {
|
|
4726
|
+
return new Pt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
4727
|
+
}
|
|
4728
|
+
isAbsolute(t) {
|
|
4729
|
+
return t.startsWith("/") || t.startsWith("\\") || /^[a-z]:(\/|\\)/i.test(t);
|
|
4730
|
+
}
|
|
4731
|
+
};
|
|
4732
|
+
var rt = class extends It {
|
|
4733
|
+
sep = "/";
|
|
4734
|
+
constructor(t = process.cwd(), e = {}) {
|
|
4735
|
+
let { nocase: s = !1 } = e;
|
|
4736
|
+
super(t, posix, "/", {
|
|
4737
|
+
...e,
|
|
4738
|
+
nocase: s
|
|
4739
|
+
}), this.nocase = s;
|
|
4740
|
+
}
|
|
4741
|
+
parseRootPath(t) {
|
|
4742
|
+
return "/";
|
|
4743
|
+
}
|
|
4744
|
+
newRoot(t) {
|
|
4745
|
+
return new jt(this.rootPath, U, void 0, this.roots, this.nocase, this.childrenCache(), { fs: t });
|
|
4746
|
+
}
|
|
4747
|
+
isAbsolute(t) {
|
|
4748
|
+
return t.startsWith("/");
|
|
4749
|
+
}
|
|
4750
|
+
};
|
|
4751
|
+
var St = class extends rt {
|
|
4752
|
+
constructor(t = process.cwd(), e = {}) {
|
|
4753
|
+
let { nocase: s = !0 } = e;
|
|
4754
|
+
super(t, {
|
|
4755
|
+
...e,
|
|
4756
|
+
nocase: s
|
|
4757
|
+
});
|
|
4758
|
+
}
|
|
4759
|
+
};
|
|
4760
|
+
process.platform;
|
|
4761
|
+
var Xe = process.platform === "win32" ? it : process.platform === "darwin" ? St : rt;
|
|
4762
|
+
var Di = (n) => n.length >= 1;
|
|
4763
|
+
var Mi = (n) => n.length >= 1;
|
|
4764
|
+
var Ni = Symbol.for("nodejs.util.inspect.custom");
|
|
4765
|
+
var nt = class n {
|
|
4766
|
+
#t;
|
|
4767
|
+
#s;
|
|
4768
|
+
#n;
|
|
4769
|
+
length;
|
|
4770
|
+
#r;
|
|
4771
|
+
#o;
|
|
4772
|
+
#S;
|
|
4773
|
+
#w;
|
|
4774
|
+
#c;
|
|
4775
|
+
#h;
|
|
4776
|
+
#u = !0;
|
|
4777
|
+
constructor(t, e, s, i) {
|
|
4778
|
+
if (!Di(t)) throw new TypeError("empty pattern list");
|
|
4779
|
+
if (!Mi(e)) throw new TypeError("empty glob list");
|
|
4780
|
+
if (e.length !== t.length) throw new TypeError("mismatched pattern list and glob list lengths");
|
|
4781
|
+
if (this.length = t.length, s < 0 || s >= this.length) throw new TypeError("index out of range");
|
|
4782
|
+
if (this.#t = t, this.#s = e, this.#n = s, this.#r = i, this.#n === 0) {
|
|
4783
|
+
if (this.isUNC()) {
|
|
4784
|
+
let [r, o, h, a, ...l] = this.#t, [u, c, d, f, ...m] = this.#s;
|
|
4785
|
+
l[0] === "" && (l.shift(), m.shift());
|
|
4786
|
+
let p = [
|
|
4787
|
+
r,
|
|
4788
|
+
o,
|
|
4789
|
+
h,
|
|
4790
|
+
a,
|
|
4791
|
+
""
|
|
4792
|
+
].join("/"), w = [
|
|
4793
|
+
u,
|
|
4794
|
+
c,
|
|
4795
|
+
d,
|
|
4796
|
+
f,
|
|
4797
|
+
""
|
|
4798
|
+
].join("/");
|
|
4799
|
+
this.#t = [p, ...l], this.#s = [w, ...m], this.length = this.#t.length;
|
|
4800
|
+
} else if (this.isDrive() || this.isAbsolute()) {
|
|
4801
|
+
let [r, ...o] = this.#t, [h, ...a] = this.#s;
|
|
4802
|
+
o[0] === "" && (o.shift(), a.shift());
|
|
4803
|
+
let l = r + "/", u = h + "/";
|
|
4804
|
+
this.#t = [l, ...o], this.#s = [u, ...a], this.length = this.#t.length;
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
}
|
|
4808
|
+
[Ni]() {
|
|
4809
|
+
return "Pattern <" + this.#s.slice(this.#n).join("/") + ">";
|
|
4810
|
+
}
|
|
4811
|
+
pattern() {
|
|
4812
|
+
return this.#t[this.#n];
|
|
4813
|
+
}
|
|
4814
|
+
isString() {
|
|
4815
|
+
return typeof this.#t[this.#n] == "string";
|
|
4816
|
+
}
|
|
4817
|
+
isGlobstar() {
|
|
4818
|
+
return this.#t[this.#n] === A;
|
|
4819
|
+
}
|
|
4820
|
+
isRegExp() {
|
|
4821
|
+
return this.#t[this.#n] instanceof RegExp;
|
|
4822
|
+
}
|
|
4823
|
+
globString() {
|
|
4824
|
+
return this.#S = this.#S || (this.#n === 0 ? this.isAbsolute() ? this.#s[0] + this.#s.slice(1).join("/") : this.#s.join("/") : this.#s.slice(this.#n).join("/"));
|
|
4825
|
+
}
|
|
4826
|
+
hasMore() {
|
|
4827
|
+
return this.length > this.#n + 1;
|
|
4828
|
+
}
|
|
4829
|
+
rest() {
|
|
4830
|
+
return this.#o !== void 0 ? this.#o : this.hasMore() ? (this.#o = new n(this.#t, this.#s, this.#n + 1, this.#r), this.#o.#h = this.#h, this.#o.#c = this.#c, this.#o.#w = this.#w, this.#o) : this.#o = null;
|
|
4831
|
+
}
|
|
4832
|
+
isUNC() {
|
|
4833
|
+
let t = this.#t;
|
|
4834
|
+
return this.#c !== void 0 ? this.#c : this.#c = this.#r === "win32" && this.#n === 0 && t[0] === "" && t[1] === "" && typeof t[2] == "string" && !!t[2] && typeof t[3] == "string" && !!t[3];
|
|
4835
|
+
}
|
|
4836
|
+
isDrive() {
|
|
4837
|
+
let t = this.#t;
|
|
4838
|
+
return this.#w !== void 0 ? this.#w : this.#w = this.#r === "win32" && this.#n === 0 && this.length > 1 && typeof t[0] == "string" && /^[a-z]:$/i.test(t[0]);
|
|
4839
|
+
}
|
|
4840
|
+
isAbsolute() {
|
|
4841
|
+
let t = this.#t;
|
|
4842
|
+
return this.#h !== void 0 ? this.#h : this.#h = t[0] === "" && t.length > 1 || this.isDrive() || this.isUNC();
|
|
4843
|
+
}
|
|
4844
|
+
root() {
|
|
4845
|
+
let t = this.#t[0];
|
|
4846
|
+
return typeof t == "string" && this.isAbsolute() && this.#n === 0 ? t : "";
|
|
4847
|
+
}
|
|
4848
|
+
checkFollowGlobstar() {
|
|
4849
|
+
return !(this.#n === 0 || !this.isGlobstar() || !this.#u);
|
|
4850
|
+
}
|
|
4851
|
+
markFollowGlobstar() {
|
|
4852
|
+
return this.#n === 0 || !this.isGlobstar() || !this.#u ? !1 : (this.#u = !1, !0);
|
|
4853
|
+
}
|
|
4854
|
+
};
|
|
4855
|
+
var _i = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
4856
|
+
var ot = class {
|
|
4857
|
+
relative;
|
|
4858
|
+
relativeChildren;
|
|
4859
|
+
absolute;
|
|
4860
|
+
absoluteChildren;
|
|
4861
|
+
platform;
|
|
4862
|
+
mmopts;
|
|
4863
|
+
constructor(t, { nobrace: e, nocase: s, noext: i, noglobstar: r, platform: o = _i }) {
|
|
4864
|
+
this.relative = [], this.absolute = [], this.relativeChildren = [], this.absoluteChildren = [], this.platform = o, this.mmopts = {
|
|
4865
|
+
dot: !0,
|
|
4866
|
+
nobrace: e,
|
|
4867
|
+
nocase: s,
|
|
4868
|
+
noext: i,
|
|
4869
|
+
noglobstar: r,
|
|
4870
|
+
optimizationLevel: 2,
|
|
4871
|
+
platform: o,
|
|
4872
|
+
nocomment: !0,
|
|
4873
|
+
nonegate: !0
|
|
4874
|
+
};
|
|
4875
|
+
for (let h of t) this.add(h);
|
|
4876
|
+
}
|
|
4877
|
+
add(t) {
|
|
4878
|
+
let e = new D(t, this.mmopts);
|
|
4879
|
+
for (let s = 0; s < e.set.length; s++) {
|
|
4880
|
+
let i = e.set[s], r = e.globParts[s];
|
|
4881
|
+
if (!i || !r) throw new Error("invalid pattern object");
|
|
4882
|
+
for (; i[0] === "." && r[0] === ".";) i.shift(), r.shift();
|
|
4883
|
+
let o = new nt(i, r, 0, this.platform), h = new D(o.globString(), this.mmopts), a = r[r.length - 1] === "**", l = o.isAbsolute();
|
|
4884
|
+
l ? this.absolute.push(h) : this.relative.push(h), a && (l ? this.absoluteChildren.push(h) : this.relativeChildren.push(h));
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
ignored(t) {
|
|
4888
|
+
let e = t.fullpath(), s = `${e}/`, i = t.relative() || ".", r = `${i}/`;
|
|
4889
|
+
for (let o of this.relative) if (o.match(i) || o.match(r)) return !0;
|
|
4890
|
+
for (let o of this.absolute) if (o.match(e) || o.match(s)) return !0;
|
|
4891
|
+
return !1;
|
|
4892
|
+
}
|
|
4893
|
+
childrenIgnored(t) {
|
|
4894
|
+
let e = t.fullpath() + "/", s = (t.relative() || ".") + "/";
|
|
4895
|
+
for (let i of this.relativeChildren) if (i.match(s)) return !0;
|
|
4896
|
+
for (let i of this.absoluteChildren) if (i.match(e)) return !0;
|
|
4897
|
+
return !1;
|
|
4898
|
+
}
|
|
4899
|
+
};
|
|
4900
|
+
var oe = class n {
|
|
4901
|
+
store;
|
|
4902
|
+
constructor(t = /* @__PURE__ */ new Map()) {
|
|
4903
|
+
this.store = t;
|
|
4904
|
+
}
|
|
4905
|
+
copy() {
|
|
4906
|
+
return new n(new Map(this.store));
|
|
4907
|
+
}
|
|
4908
|
+
hasWalked(t, e) {
|
|
4909
|
+
return this.store.get(t.fullpath())?.has(e.globString());
|
|
4910
|
+
}
|
|
4911
|
+
storeWalked(t, e) {
|
|
4912
|
+
let s = t.fullpath(), i = this.store.get(s);
|
|
4913
|
+
i ? i.add(e.globString()) : this.store.set(s, /* @__PURE__ */ new Set([e.globString()]));
|
|
4914
|
+
}
|
|
4915
|
+
};
|
|
4916
|
+
var he = class {
|
|
4917
|
+
store = /* @__PURE__ */ new Map();
|
|
4918
|
+
add(t, e, s) {
|
|
4919
|
+
let i = (e ? 2 : 0) | (s ? 1 : 0), r = this.store.get(t);
|
|
4920
|
+
this.store.set(t, r === void 0 ? i : i & r);
|
|
4921
|
+
}
|
|
4922
|
+
entries() {
|
|
4923
|
+
return [...this.store.entries()].map(([t, e]) => [
|
|
4924
|
+
t,
|
|
4925
|
+
!!(e & 2),
|
|
4926
|
+
!!(e & 1)
|
|
4927
|
+
]);
|
|
4928
|
+
}
|
|
4929
|
+
};
|
|
4930
|
+
var ae = class {
|
|
4931
|
+
store = /* @__PURE__ */ new Map();
|
|
4932
|
+
add(t, e) {
|
|
4933
|
+
if (!t.canReaddir()) return;
|
|
4934
|
+
let s = this.store.get(t);
|
|
4935
|
+
s ? s.find((i) => i.globString() === e.globString()) || s.push(e) : this.store.set(t, [e]);
|
|
4936
|
+
}
|
|
4937
|
+
get(t) {
|
|
4938
|
+
let e = this.store.get(t);
|
|
4939
|
+
if (!e) throw new Error("attempting to walk unknown path");
|
|
4940
|
+
return e;
|
|
4941
|
+
}
|
|
4942
|
+
entries() {
|
|
4943
|
+
return this.keys().map((t) => [t, this.store.get(t)]);
|
|
4944
|
+
}
|
|
4945
|
+
keys() {
|
|
4946
|
+
return [...this.store.keys()].filter((t) => t.canReaddir());
|
|
4947
|
+
}
|
|
4948
|
+
};
|
|
4949
|
+
var Et = class n {
|
|
4950
|
+
hasWalkedCache;
|
|
4951
|
+
matches = new he();
|
|
4952
|
+
subwalks = new ae();
|
|
4953
|
+
patterns;
|
|
4954
|
+
follow;
|
|
4955
|
+
dot;
|
|
4956
|
+
opts;
|
|
4957
|
+
constructor(t, e) {
|
|
4958
|
+
this.opts = t, this.follow = !!t.follow, this.dot = !!t.dot, this.hasWalkedCache = e ? e.copy() : new oe();
|
|
4959
|
+
}
|
|
4960
|
+
processPatterns(t, e) {
|
|
4961
|
+
this.patterns = e;
|
|
4962
|
+
let s = e.map((i) => [t, i]);
|
|
4963
|
+
for (let [i, r] of s) {
|
|
4964
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
4965
|
+
let o = r.root(), h = r.isAbsolute() && this.opts.absolute !== !1;
|
|
4966
|
+
if (o) {
|
|
4967
|
+
i = i.resolve(o === "/" && this.opts.root !== void 0 ? this.opts.root : o);
|
|
4968
|
+
let c = r.rest();
|
|
4969
|
+
if (c) r = c;
|
|
4970
|
+
else {
|
|
4971
|
+
this.matches.add(i, !0, !1);
|
|
4972
|
+
continue;
|
|
4973
|
+
}
|
|
1769
4974
|
}
|
|
1770
|
-
if (
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
});
|
|
1777
|
-
} catch (err) {
|
|
1778
|
-
logger.warn(`[luals] Failed to clean up broken destination directory ${destDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1779
|
-
}
|
|
1780
|
-
throw renameErr;
|
|
4975
|
+
if (i.isENOENT()) continue;
|
|
4976
|
+
let a, l, u = !1;
|
|
4977
|
+
for (; typeof (a = r.pattern()) == "string" && (l = r.rest());) i = i.resolve(a), r = l, u = !0;
|
|
4978
|
+
if (a = r.pattern(), l = r.rest(), u) {
|
|
4979
|
+
if (this.hasWalkedCache.hasWalked(i, r)) continue;
|
|
4980
|
+
this.hasWalkedCache.storeWalked(i, r);
|
|
1781
4981
|
}
|
|
4982
|
+
if (typeof a == "string") {
|
|
4983
|
+
let c = a === ".." || a === "" || a === ".";
|
|
4984
|
+
this.matches.add(i.resolve(a), h, c);
|
|
4985
|
+
continue;
|
|
4986
|
+
} else if (a === A) {
|
|
4987
|
+
(!i.isSymbolicLink() || this.follow || r.checkFollowGlobstar()) && this.subwalks.add(i, r);
|
|
4988
|
+
let c = l?.pattern(), d = l?.rest();
|
|
4989
|
+
if (!l || (c === "" || c === ".") && !d) this.matches.add(i, h, c === "" || c === ".");
|
|
4990
|
+
else if (c === "..") {
|
|
4991
|
+
let f = i.parent || i;
|
|
4992
|
+
d ? this.hasWalkedCache.hasWalked(f, d) || this.subwalks.add(f, d) : this.matches.add(f, h, !0);
|
|
4993
|
+
}
|
|
4994
|
+
} else a instanceof RegExp && this.subwalks.add(i, r);
|
|
1782
4995
|
}
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
4996
|
+
return this;
|
|
4997
|
+
}
|
|
4998
|
+
subwalkTargets() {
|
|
4999
|
+
return this.subwalks.keys();
|
|
5000
|
+
}
|
|
5001
|
+
child() {
|
|
5002
|
+
return new n(this.opts, this.hasWalkedCache);
|
|
5003
|
+
}
|
|
5004
|
+
filterEntries(t, e) {
|
|
5005
|
+
let s = this.subwalks.get(t), i = this.child();
|
|
5006
|
+
for (let r of e) for (let o of s) {
|
|
5007
|
+
let h = o.isAbsolute(), a = o.pattern(), l = o.rest();
|
|
5008
|
+
a === A ? i.testGlobstar(r, o, l, h) : a instanceof RegExp ? i.testRegExp(r, a, l, h) : i.testString(r, a, l, h);
|
|
5009
|
+
}
|
|
5010
|
+
return i;
|
|
5011
|
+
}
|
|
5012
|
+
testGlobstar(t, e, s, i) {
|
|
5013
|
+
if ((this.dot || !t.name.startsWith(".")) && (e.hasMore() || this.matches.add(t, i, !1), t.canReaddir() && (this.follow || !t.isSymbolicLink() ? this.subwalks.add(t, e) : t.isSymbolicLink() && (s && e.checkFollowGlobstar() ? this.subwalks.add(t, s) : e.markFollowGlobstar() && this.subwalks.add(t, e)))), s) {
|
|
5014
|
+
let r = s.pattern();
|
|
5015
|
+
if (typeof r == "string" && r !== ".." && r !== "" && r !== ".") this.testString(t, r, s.rest(), i);
|
|
5016
|
+
else if (r === "..") {
|
|
5017
|
+
let o = t.parent || t;
|
|
5018
|
+
this.subwalks.add(o, s);
|
|
5019
|
+
} else r instanceof RegExp && this.testRegExp(t, r, s.rest(), i);
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
testRegExp(t, e, s, i) {
|
|
5023
|
+
e.test(t.name) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
|
|
5024
|
+
}
|
|
5025
|
+
testString(t, e, s, i) {
|
|
5026
|
+
t.isNamed(e) && (s ? this.subwalks.add(t, s) : this.matches.add(t, i, !1));
|
|
5027
|
+
}
|
|
5028
|
+
};
|
|
5029
|
+
var Li = (n, t) => typeof n == "string" ? new ot([n], t) : Array.isArray(n) ? new ot(n, t) : n;
|
|
5030
|
+
var zt = class {
|
|
5031
|
+
path;
|
|
5032
|
+
patterns;
|
|
5033
|
+
opts;
|
|
5034
|
+
seen = /* @__PURE__ */ new Set();
|
|
5035
|
+
paused = !1;
|
|
5036
|
+
aborted = !1;
|
|
5037
|
+
#t = [];
|
|
5038
|
+
#s;
|
|
5039
|
+
#n;
|
|
5040
|
+
signal;
|
|
5041
|
+
maxDepth;
|
|
5042
|
+
includeChildMatches;
|
|
5043
|
+
constructor(t, e, s) {
|
|
5044
|
+
if (this.patterns = t, this.path = e, this.opts = s, this.#n = !s.posix && s.platform === "win32" ? "\\" : "/", this.includeChildMatches = s.includeChildMatches !== !1, (s.ignore || !this.includeChildMatches) && (this.#s = Li(s.ignore ?? [], s), !this.includeChildMatches && typeof this.#s.add != "function")) throw new Error("cannot ignore child matches, ignore lacks add() method.");
|
|
5045
|
+
this.maxDepth = s.maxDepth || 1 / 0, s.signal && (this.signal = s.signal, this.signal.addEventListener("abort", () => {
|
|
5046
|
+
this.#t.length = 0;
|
|
5047
|
+
}));
|
|
5048
|
+
}
|
|
5049
|
+
#r(t) {
|
|
5050
|
+
return this.seen.has(t) || !!this.#s?.ignored?.(t);
|
|
5051
|
+
}
|
|
5052
|
+
#o(t) {
|
|
5053
|
+
return !!this.#s?.childrenIgnored?.(t);
|
|
5054
|
+
}
|
|
5055
|
+
pause() {
|
|
5056
|
+
this.paused = !0;
|
|
5057
|
+
}
|
|
5058
|
+
resume() {
|
|
5059
|
+
if (this.signal?.aborted) return;
|
|
5060
|
+
this.paused = !1;
|
|
5061
|
+
let t;
|
|
5062
|
+
for (; !this.paused && (t = this.#t.shift());) t();
|
|
5063
|
+
}
|
|
5064
|
+
onResume(t) {
|
|
5065
|
+
this.signal?.aborted || (this.paused ? this.#t.push(t) : t());
|
|
5066
|
+
}
|
|
5067
|
+
async matchCheck(t, e) {
|
|
5068
|
+
if (e && this.opts.nodir) return;
|
|
5069
|
+
let s;
|
|
5070
|
+
if (this.opts.realpath) {
|
|
5071
|
+
if (s = t.realpathCached() || await t.realpath(), !s) return;
|
|
5072
|
+
t = s;
|
|
5073
|
+
}
|
|
5074
|
+
let r = t.isUnknown() || this.opts.stat ? await t.lstat() : t;
|
|
5075
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
5076
|
+
let o = await r.realpath();
|
|
5077
|
+
o && (o.isUnknown() || this.opts.stat) && await o.lstat();
|
|
5078
|
+
}
|
|
5079
|
+
return this.matchCheckTest(r, e);
|
|
5080
|
+
}
|
|
5081
|
+
matchCheckTest(t, e) {
|
|
5082
|
+
return t && (this.maxDepth === 1 / 0 || t.depth() <= this.maxDepth) && (!e || t.canReaddir()) && (!this.opts.nodir || !t.isDirectory()) && (!this.opts.nodir || !this.opts.follow || !t.isSymbolicLink() || !t.realpathCached()?.isDirectory()) && !this.#r(t) ? t : void 0;
|
|
5083
|
+
}
|
|
5084
|
+
matchCheckSync(t, e) {
|
|
5085
|
+
if (e && this.opts.nodir) return;
|
|
5086
|
+
let s;
|
|
5087
|
+
if (this.opts.realpath) {
|
|
5088
|
+
if (s = t.realpathCached() || t.realpathSync(), !s) return;
|
|
5089
|
+
t = s;
|
|
5090
|
+
}
|
|
5091
|
+
let r = t.isUnknown() || this.opts.stat ? t.lstatSync() : t;
|
|
5092
|
+
if (this.opts.follow && this.opts.nodir && r?.isSymbolicLink()) {
|
|
5093
|
+
let o = r.realpathSync();
|
|
5094
|
+
o && (o?.isUnknown() || this.opts.stat) && o.lstatSync();
|
|
5095
|
+
}
|
|
5096
|
+
return this.matchCheckTest(r, e);
|
|
5097
|
+
}
|
|
5098
|
+
matchFinish(t, e) {
|
|
5099
|
+
if (this.#r(t)) return;
|
|
5100
|
+
if (!this.includeChildMatches && this.#s?.add) {
|
|
5101
|
+
let r = `${t.relativePosix()}/**`;
|
|
5102
|
+
this.#s.add(r);
|
|
5103
|
+
}
|
|
5104
|
+
let s = this.opts.absolute === void 0 ? e : this.opts.absolute;
|
|
5105
|
+
this.seen.add(t);
|
|
5106
|
+
let i = this.opts.mark && t.isDirectory() ? this.#n : "";
|
|
5107
|
+
if (this.opts.withFileTypes) this.matchEmit(t);
|
|
5108
|
+
else if (s) {
|
|
5109
|
+
let r = this.opts.posix ? t.fullpathPosix() : t.fullpath();
|
|
5110
|
+
this.matchEmit(r + i);
|
|
5111
|
+
} else {
|
|
5112
|
+
let r = this.opts.posix ? t.relativePosix() : t.relative(), o = this.opts.dotRelative && !r.startsWith(".." + this.#n) ? "." + this.#n : "";
|
|
5113
|
+
this.matchEmit(r ? o + r + i : "." + i);
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
async match(t, e, s) {
|
|
5117
|
+
let i = await this.matchCheck(t, s);
|
|
5118
|
+
i && this.matchFinish(i, e);
|
|
5119
|
+
}
|
|
5120
|
+
matchSync(t, e, s) {
|
|
5121
|
+
let i = this.matchCheckSync(t, s);
|
|
5122
|
+
i && this.matchFinish(i, e);
|
|
5123
|
+
}
|
|
5124
|
+
walkCB(t, e, s) {
|
|
5125
|
+
this.signal?.aborted && s(), this.walkCB2(t, e, new Et(this.opts), s);
|
|
5126
|
+
}
|
|
5127
|
+
walkCB2(t, e, s, i) {
|
|
5128
|
+
if (this.#o(t)) return i();
|
|
5129
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
5130
|
+
this.onResume(() => this.walkCB2(t, e, s, i));
|
|
5131
|
+
return;
|
|
5132
|
+
}
|
|
5133
|
+
s.processPatterns(t, e);
|
|
5134
|
+
let r = 1, o = () => {
|
|
5135
|
+
--r === 0 && i();
|
|
5136
|
+
};
|
|
5137
|
+
for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
5138
|
+
for (let h of s.subwalkTargets()) {
|
|
5139
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
|
|
5140
|
+
r++;
|
|
5141
|
+
let a = h.readdirCached();
|
|
5142
|
+
h.calledReaddir() ? this.walkCB3(h, a, s, o) : h.readdirCB((l, u) => this.walkCB3(h, u, s, o), !0);
|
|
5143
|
+
}
|
|
5144
|
+
o();
|
|
5145
|
+
}
|
|
5146
|
+
walkCB3(t, e, s, i) {
|
|
5147
|
+
s = s.filterEntries(t, e);
|
|
5148
|
+
let r = 1, o = () => {
|
|
5149
|
+
--r === 0 && i();
|
|
5150
|
+
};
|
|
5151
|
+
for (let [h, a, l] of s.matches.entries()) this.#r(h) || (r++, this.match(h, a, l).then(() => o()));
|
|
5152
|
+
for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2(h, a, s.child(), o);
|
|
5153
|
+
o();
|
|
5154
|
+
}
|
|
5155
|
+
walkCBSync(t, e, s) {
|
|
5156
|
+
this.signal?.aborted && s(), this.walkCB2Sync(t, e, new Et(this.opts), s);
|
|
5157
|
+
}
|
|
5158
|
+
walkCB2Sync(t, e, s, i) {
|
|
5159
|
+
if (this.#o(t)) return i();
|
|
5160
|
+
if (this.signal?.aborted && i(), this.paused) {
|
|
5161
|
+
this.onResume(() => this.walkCB2Sync(t, e, s, i));
|
|
5162
|
+
return;
|
|
5163
|
+
}
|
|
5164
|
+
s.processPatterns(t, e);
|
|
5165
|
+
let r = 1, o = () => {
|
|
5166
|
+
--r === 0 && i();
|
|
5167
|
+
};
|
|
5168
|
+
for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
|
|
5169
|
+
for (let h of s.subwalkTargets()) {
|
|
5170
|
+
if (this.maxDepth !== 1 / 0 && h.depth() >= this.maxDepth) continue;
|
|
5171
|
+
r++;
|
|
5172
|
+
let a = h.readdirSync();
|
|
5173
|
+
this.walkCB3Sync(h, a, s, o);
|
|
5174
|
+
}
|
|
5175
|
+
o();
|
|
5176
|
+
}
|
|
5177
|
+
walkCB3Sync(t, e, s, i) {
|
|
5178
|
+
s = s.filterEntries(t, e);
|
|
5179
|
+
let r = 1, o = () => {
|
|
5180
|
+
--r === 0 && i();
|
|
5181
|
+
};
|
|
5182
|
+
for (let [h, a, l] of s.matches.entries()) this.#r(h) || this.matchSync(h, a, l);
|
|
5183
|
+
for (let [h, a] of s.subwalks.entries()) r++, this.walkCB2Sync(h, a, s.child(), o);
|
|
5184
|
+
o();
|
|
5185
|
+
}
|
|
5186
|
+
};
|
|
5187
|
+
var xt = class extends zt {
|
|
5188
|
+
matches = /* @__PURE__ */ new Set();
|
|
5189
|
+
constructor(t, e, s) {
|
|
5190
|
+
super(t, e, s);
|
|
5191
|
+
}
|
|
5192
|
+
matchEmit(t) {
|
|
5193
|
+
this.matches.add(t);
|
|
5194
|
+
}
|
|
5195
|
+
async walk() {
|
|
5196
|
+
if (this.signal?.aborted) throw this.signal.reason;
|
|
5197
|
+
return this.path.isUnknown() && await this.path.lstat(), await new Promise((t, e) => {
|
|
5198
|
+
this.walkCB(this.path, this.patterns, () => {
|
|
5199
|
+
this.signal?.aborted ? e(this.signal.reason) : t(this.matches);
|
|
5200
|
+
});
|
|
5201
|
+
}), this.matches;
|
|
5202
|
+
}
|
|
5203
|
+
walkSync() {
|
|
5204
|
+
if (this.signal?.aborted) throw this.signal.reason;
|
|
5205
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => {
|
|
5206
|
+
if (this.signal?.aborted) throw this.signal.reason;
|
|
5207
|
+
}), this.matches;
|
|
5208
|
+
}
|
|
5209
|
+
};
|
|
5210
|
+
var vt = class extends zt {
|
|
5211
|
+
results;
|
|
5212
|
+
constructor(t, e, s) {
|
|
5213
|
+
super(t, e, s), this.results = new V({
|
|
5214
|
+
signal: this.signal,
|
|
5215
|
+
objectMode: !0
|
|
5216
|
+
}), this.results.on("drain", () => this.resume()), this.results.on("resume", () => this.resume());
|
|
5217
|
+
}
|
|
5218
|
+
matchEmit(t) {
|
|
5219
|
+
this.results.write(t), this.results.flowing || this.pause();
|
|
5220
|
+
}
|
|
5221
|
+
stream() {
|
|
5222
|
+
let t = this.path;
|
|
5223
|
+
return t.isUnknown() ? t.lstat().then(() => {
|
|
5224
|
+
this.walkCB(t, this.patterns, () => this.results.end());
|
|
5225
|
+
}) : this.walkCB(t, this.patterns, () => this.results.end()), this.results;
|
|
5226
|
+
}
|
|
5227
|
+
streamSync() {
|
|
5228
|
+
return this.path.isUnknown() && this.path.lstatSync(), this.walkCBSync(this.path, this.patterns, () => this.results.end()), this.results;
|
|
5229
|
+
}
|
|
5230
|
+
};
|
|
5231
|
+
var Pi = typeof process == "object" && process && typeof process.platform == "string" ? process.platform : "linux";
|
|
5232
|
+
var I = class {
|
|
5233
|
+
absolute;
|
|
5234
|
+
cwd;
|
|
5235
|
+
root;
|
|
5236
|
+
dot;
|
|
5237
|
+
dotRelative;
|
|
5238
|
+
follow;
|
|
5239
|
+
ignore;
|
|
5240
|
+
magicalBraces;
|
|
5241
|
+
mark;
|
|
5242
|
+
matchBase;
|
|
5243
|
+
maxDepth;
|
|
5244
|
+
nobrace;
|
|
5245
|
+
nocase;
|
|
5246
|
+
nodir;
|
|
5247
|
+
noext;
|
|
5248
|
+
noglobstar;
|
|
5249
|
+
pattern;
|
|
5250
|
+
platform;
|
|
5251
|
+
realpath;
|
|
5252
|
+
scurry;
|
|
5253
|
+
stat;
|
|
5254
|
+
signal;
|
|
5255
|
+
windowsPathsNoEscape;
|
|
5256
|
+
withFileTypes;
|
|
5257
|
+
includeChildMatches;
|
|
5258
|
+
opts;
|
|
5259
|
+
patterns;
|
|
5260
|
+
constructor(t, e) {
|
|
5261
|
+
if (!e) throw new TypeError("glob options required");
|
|
5262
|
+
if (this.withFileTypes = !!e.withFileTypes, this.signal = e.signal, this.follow = !!e.follow, this.dot = !!e.dot, this.dotRelative = !!e.dotRelative, this.nodir = !!e.nodir, this.mark = !!e.mark, e.cwd ? (e.cwd instanceof URL || e.cwd.startsWith("file://")) && (e.cwd = fileURLToPath(e.cwd)) : this.cwd = "", this.cwd = e.cwd || "", this.root = e.root, this.magicalBraces = !!e.magicalBraces, this.nobrace = !!e.nobrace, this.noext = !!e.noext, this.realpath = !!e.realpath, this.absolute = e.absolute, this.includeChildMatches = e.includeChildMatches !== !1, this.noglobstar = !!e.noglobstar, this.matchBase = !!e.matchBase, this.maxDepth = typeof e.maxDepth == "number" ? e.maxDepth : 1 / 0, this.stat = !!e.stat, this.ignore = e.ignore, this.withFileTypes && this.absolute !== void 0) throw new Error("cannot set absolute and withFileTypes:true");
|
|
5263
|
+
if (typeof t == "string" && (t = [t]), this.windowsPathsNoEscape = !!e.windowsPathsNoEscape || e.allowWindowsEscape === !1, this.windowsPathsNoEscape && (t = t.map((a) => a.replace(/\\/g, "/"))), this.matchBase) {
|
|
5264
|
+
if (e.noglobstar) throw new TypeError("base matching requires globstar");
|
|
5265
|
+
t = t.map((a) => a.includes("/") ? a : `./**/${a}`);
|
|
5266
|
+
}
|
|
5267
|
+
if (this.pattern = t, this.platform = e.platform || Pi, this.opts = {
|
|
5268
|
+
...e,
|
|
5269
|
+
platform: this.platform
|
|
5270
|
+
}, e.scurry) {
|
|
5271
|
+
if (this.scurry = e.scurry, e.nocase !== void 0 && e.nocase !== e.scurry.nocase) throw new Error("nocase option contradicts provided scurry option");
|
|
5272
|
+
} else {
|
|
5273
|
+
let a = e.platform === "win32" ? it : e.platform === "darwin" ? St : e.platform ? rt : Xe;
|
|
5274
|
+
this.scurry = new a(this.cwd, {
|
|
5275
|
+
nocase: e.nocase,
|
|
5276
|
+
fs: e.fs
|
|
1790
5277
|
});
|
|
1791
|
-
} catch (err) {
|
|
1792
|
-
logger.debug(`[luals] Failed to clean up temporary directory ${tempDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1793
5278
|
}
|
|
5279
|
+
this.nocase = this.scurry.nocase;
|
|
5280
|
+
let s = this.platform === "darwin" || this.platform === "win32", i = {
|
|
5281
|
+
braceExpandMax: 1e4,
|
|
5282
|
+
...e,
|
|
5283
|
+
dot: this.dot,
|
|
5284
|
+
matchBase: this.matchBase,
|
|
5285
|
+
nobrace: this.nobrace,
|
|
5286
|
+
nocase: this.nocase,
|
|
5287
|
+
nocaseMagicOnly: s,
|
|
5288
|
+
nocomment: !0,
|
|
5289
|
+
noext: this.noext,
|
|
5290
|
+
nonegate: !0,
|
|
5291
|
+
optimizationLevel: 2,
|
|
5292
|
+
platform: this.platform,
|
|
5293
|
+
windowsPathsNoEscape: this.windowsPathsNoEscape,
|
|
5294
|
+
debug: !!this.opts.debug
|
|
5295
|
+
}, [o, h] = this.pattern.map((a) => new D(a, i)).reduce((a, l) => (a[0].push(...l.set), a[1].push(...l.globParts), a), [[], []]);
|
|
5296
|
+
this.patterns = o.map((a, l) => {
|
|
5297
|
+
let u = h[l];
|
|
5298
|
+
if (!u) throw new Error("invalid pattern object");
|
|
5299
|
+
return new nt(a, u, 0, this.platform);
|
|
5300
|
+
});
|
|
5301
|
+
}
|
|
5302
|
+
async walk() {
|
|
5303
|
+
return [...await new xt(this.patterns, this.scurry.cwd, {
|
|
5304
|
+
...this.opts,
|
|
5305
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
5306
|
+
platform: this.platform,
|
|
5307
|
+
nocase: this.nocase,
|
|
5308
|
+
includeChildMatches: this.includeChildMatches
|
|
5309
|
+
}).walk()];
|
|
5310
|
+
}
|
|
5311
|
+
walkSync() {
|
|
5312
|
+
return [...new xt(this.patterns, this.scurry.cwd, {
|
|
5313
|
+
...this.opts,
|
|
5314
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
5315
|
+
platform: this.platform,
|
|
5316
|
+
nocase: this.nocase,
|
|
5317
|
+
includeChildMatches: this.includeChildMatches
|
|
5318
|
+
}).walkSync()];
|
|
5319
|
+
}
|
|
5320
|
+
stream() {
|
|
5321
|
+
return new vt(this.patterns, this.scurry.cwd, {
|
|
5322
|
+
...this.opts,
|
|
5323
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
5324
|
+
platform: this.platform,
|
|
5325
|
+
nocase: this.nocase,
|
|
5326
|
+
includeChildMatches: this.includeChildMatches
|
|
5327
|
+
}).stream();
|
|
5328
|
+
}
|
|
5329
|
+
streamSync() {
|
|
5330
|
+
return new vt(this.patterns, this.scurry.cwd, {
|
|
5331
|
+
...this.opts,
|
|
5332
|
+
maxDepth: this.maxDepth !== 1 / 0 ? this.maxDepth + this.scurry.cwd.depth() : 1 / 0,
|
|
5333
|
+
platform: this.platform,
|
|
5334
|
+
nocase: this.nocase,
|
|
5335
|
+
includeChildMatches: this.includeChildMatches
|
|
5336
|
+
}).streamSync();
|
|
5337
|
+
}
|
|
5338
|
+
iterateSync() {
|
|
5339
|
+
return this.streamSync()[Symbol.iterator]();
|
|
5340
|
+
}
|
|
5341
|
+
[Symbol.iterator]() {
|
|
5342
|
+
return this.iterateSync();
|
|
5343
|
+
}
|
|
5344
|
+
iterate() {
|
|
5345
|
+
return this.stream()[Symbol.asyncIterator]();
|
|
5346
|
+
}
|
|
5347
|
+
[Symbol.asyncIterator]() {
|
|
5348
|
+
return this.iterate();
|
|
1794
5349
|
}
|
|
5350
|
+
};
|
|
5351
|
+
var le = (n, t = {}) => {
|
|
5352
|
+
Array.isArray(n) || (n = [n]);
|
|
5353
|
+
for (let e of n) if (new D(e, t).hasMagic()) return !0;
|
|
5354
|
+
return !1;
|
|
5355
|
+
};
|
|
5356
|
+
function Bt(n, t = {}) {
|
|
5357
|
+
return new I(n, t).streamSync();
|
|
1795
5358
|
}
|
|
5359
|
+
function Qe(n, t = {}) {
|
|
5360
|
+
return new I(n, t).stream();
|
|
5361
|
+
}
|
|
5362
|
+
function ts(n, t = {}) {
|
|
5363
|
+
return new I(n, t).walkSync();
|
|
5364
|
+
}
|
|
5365
|
+
async function Je(n, t = {}) {
|
|
5366
|
+
return new I(n, t).walk();
|
|
5367
|
+
}
|
|
5368
|
+
function Ut(n, t = {}) {
|
|
5369
|
+
return new I(n, t).iterateSync();
|
|
5370
|
+
}
|
|
5371
|
+
function es(n, t = {}) {
|
|
5372
|
+
return new I(n, t).iterate();
|
|
5373
|
+
}
|
|
5374
|
+
var ji = Bt;
|
|
5375
|
+
var Ii = Object.assign(Qe, { sync: Bt });
|
|
5376
|
+
var zi = Ut;
|
|
5377
|
+
var Bi = Object.assign(es, { sync: Ut });
|
|
5378
|
+
var Ui = Object.assign(ts, {
|
|
5379
|
+
stream: Bt,
|
|
5380
|
+
iterate: Ut
|
|
5381
|
+
});
|
|
5382
|
+
var Ze = Object.assign(Je, {
|
|
5383
|
+
glob: Je,
|
|
5384
|
+
globSync: ts,
|
|
5385
|
+
sync: Ui,
|
|
5386
|
+
globStream: Qe,
|
|
5387
|
+
stream: Ii,
|
|
5388
|
+
globStreamSync: Bt,
|
|
5389
|
+
streamSync: ji,
|
|
5390
|
+
globIterate: es,
|
|
5391
|
+
iterate: Bi,
|
|
5392
|
+
globIterateSync: Ut,
|
|
5393
|
+
iterateSync: zi,
|
|
5394
|
+
Glob: I,
|
|
5395
|
+
hasMagic: le,
|
|
5396
|
+
escape: tt,
|
|
5397
|
+
unescape: W
|
|
5398
|
+
});
|
|
5399
|
+
Ze.glob = Ze;
|
|
1796
5400
|
//#endregion
|
|
1797
5401
|
//#region src/luals/files.ts
|
|
5402
|
+
/** Directories skipped unless the workspace config overrides `workspace.ignoreDir`. */
|
|
5403
|
+
const DEFAULT_IGNORE_DIRS = [
|
|
5404
|
+
".git",
|
|
5405
|
+
".vscode",
|
|
5406
|
+
".nanos-lint",
|
|
5407
|
+
"node_modules"
|
|
5408
|
+
];
|
|
5409
|
+
/** Candidate Lua files: LuaLS checks every `*.lua` file in the tree. */
|
|
5410
|
+
const LUA_FILE_PATTERN = "**/*.lua";
|
|
5411
|
+
/** `glob` rejects patterns longer than this, so they are dropped before matching. */
|
|
5412
|
+
const MAX_PATTERN_LENGTH = 65536;
|
|
1798
5413
|
/**
|
|
1799
|
-
*
|
|
5414
|
+
* Complexity budget per pattern to bound backtracking and combinatorial brace expansion.
|
|
5415
|
+
* Patterns exceeding limits are skipped with a warning to protect against ReDoS (#27).
|
|
1800
5416
|
*/
|
|
5417
|
+
const MAX_WILDCARDS_PER_SEGMENT = 2;
|
|
5418
|
+
const MAX_TOTAL_WILDCARDS = 12;
|
|
5419
|
+
const MAX_BRACE_ALTERNATIVES = 256;
|
|
5420
|
+
/** Counts wildcard tokens (`*`, `?`, character classes and brace groups). */
|
|
5421
|
+
function countWildcards(value) {
|
|
5422
|
+
let count = 0;
|
|
5423
|
+
for (const char of value) if (char === "*" || char === "?" || char === "[" || char === "{") count += 1;
|
|
5424
|
+
return count;
|
|
5425
|
+
}
|
|
5426
|
+
/**
|
|
5427
|
+
* Upper bound of the alternatives brace expansion would produce; `1` when the
|
|
5428
|
+
* pattern has no brace groups. Nested groups count towards their parent, which
|
|
5429
|
+
* over-estimates on purpose so the bound stays safe.
|
|
5430
|
+
*/
|
|
5431
|
+
function estimateBraceAlternatives(pattern) {
|
|
5432
|
+
const pending = [];
|
|
5433
|
+
let estimate = 1;
|
|
5434
|
+
for (const char of pattern) if (char === "{") pending.push(0);
|
|
5435
|
+
else if (char === "}" && pending.length > 0) {
|
|
5436
|
+
const alternatives = (pending.pop() ?? 0) + 1;
|
|
5437
|
+
estimate *= alternatives;
|
|
5438
|
+
if (pending.length > 0) pending[pending.length - 1] = (pending[pending.length - 1] ?? 0) + alternatives - 1;
|
|
5439
|
+
} else if (char === "," && pending.length > 0) pending[pending.length - 1] = (pending[pending.length - 1] ?? 0) + 1;
|
|
5440
|
+
return estimate;
|
|
5441
|
+
}
|
|
5442
|
+
/** Returns `false` when matching the pattern could become pathologically slow. */
|
|
5443
|
+
function isPatternWithinBudget(pattern) {
|
|
5444
|
+
if (estimateBraceAlternatives(pattern) > MAX_BRACE_ALTERNATIVES) return false;
|
|
5445
|
+
if (countWildcards(pattern) > MAX_TOTAL_WILDCARDS) return false;
|
|
5446
|
+
return pattern.split("/").every((segment) => countWildcards(segment) <= MAX_WILDCARDS_PER_SEGMENT);
|
|
5447
|
+
}
|
|
5448
|
+
/** Normalizes a user pattern to slash-separated form, dropping trailing slashes and invalid inputs. */
|
|
5449
|
+
function normalizePattern(pattern) {
|
|
5450
|
+
if (typeof pattern !== "string") return null;
|
|
5451
|
+
const normalized = pattern.trim().replace(/\\/g, "/").replace(/\/+$/, "");
|
|
5452
|
+
if (!normalized || normalized === "." || normalized.length > MAX_PATTERN_LENGTH || normalized.includes("\0") || isAbsolutePattern(normalized)) return null;
|
|
5453
|
+
return normalized;
|
|
5454
|
+
}
|
|
5455
|
+
/** Drive-letter prefixes, recognized on every platform (not just Windows). */
|
|
5456
|
+
const WINDOWS_ABSOLUTE_PATTERN = /^[A-Za-z]:\//;
|
|
5457
|
+
/** Rejects absolute patterns to maintain cross-platform consistency with LuaLS relative paths. */
|
|
5458
|
+
function isAbsolutePattern(normalized) {
|
|
5459
|
+
return path.posix.isAbsolute(normalized) || WINDOWS_ABSOLUTE_PATTERN.test(normalized);
|
|
5460
|
+
}
|
|
5461
|
+
/** Expands a LuaLS pattern to include basename and sub-directory variants for glob matching. */
|
|
5462
|
+
function expandIgnorePattern(pattern) {
|
|
5463
|
+
return pattern.includes("/") ? [pattern, `${pattern}/**`] : [`**/${pattern}`, `**/${pattern}/**`];
|
|
5464
|
+
}
|
|
5465
|
+
/** Normalizes and expands a list of LuaLS patterns into `glob` ignore patterns. */
|
|
5466
|
+
function toIgnorePatterns(patterns) {
|
|
5467
|
+
const ignore = [];
|
|
5468
|
+
for (const raw of patterns) {
|
|
5469
|
+
const normalized = normalizePattern(raw);
|
|
5470
|
+
if (!normalized) {
|
|
5471
|
+
logger.debug(`[luals] Skipping unusable glob pattern "${String(raw)}" while counting checked files.`);
|
|
5472
|
+
continue;
|
|
5473
|
+
}
|
|
5474
|
+
if (!isPatternWithinBudget(normalized)) {
|
|
5475
|
+
logger.warn(`[luals] Skipping glob pattern "${raw}": it is too complex to match safely and would slow down file counting.`);
|
|
5476
|
+
continue;
|
|
5477
|
+
}
|
|
5478
|
+
ignore.push(...expandIgnorePattern(normalized));
|
|
5479
|
+
}
|
|
5480
|
+
return ignore;
|
|
5481
|
+
}
|
|
5482
|
+
/** Counts candidate Lua files within targetPath, taking workspace ignoreDir and files.exclude into account (#27). */
|
|
1801
5483
|
function countCheckedFiles(targetPath, configPath) {
|
|
1802
|
-
|
|
5484
|
+
let absPath = path.resolve(targetPath);
|
|
1803
5485
|
if (!fs.existsSync(absPath)) return 0;
|
|
5486
|
+
try {
|
|
5487
|
+
absPath = fs.realpathSync.native(absPath);
|
|
5488
|
+
} catch {
|
|
5489
|
+
try {
|
|
5490
|
+
absPath = fs.realpathSync(absPath);
|
|
5491
|
+
} catch (err) {}
|
|
5492
|
+
}
|
|
1804
5493
|
if (fs.statSync(absPath).isFile()) return absPath.toLowerCase().endsWith(".lua") ? 1 : 0;
|
|
1805
|
-
let ignoreDirs =
|
|
1806
|
-
".git",
|
|
1807
|
-
".vscode",
|
|
1808
|
-
".nanos-lint",
|
|
1809
|
-
"node_modules"
|
|
1810
|
-
];
|
|
5494
|
+
let ignoreDirs = DEFAULT_IGNORE_DIRS;
|
|
1811
5495
|
let excludePatterns = [];
|
|
1812
5496
|
if (configPath && fs.existsSync(configPath)) try {
|
|
1813
5497
|
const cfg = JSON.parse(fs.readFileSync(configPath, "utf-8"));
|
|
1814
|
-
if (cfg.workspace?.ignoreDir) ignoreDirs = cfg.workspace.ignoreDir;
|
|
1815
|
-
if (cfg.files?.exclude) excludePatterns = cfg.files.exclude;
|
|
5498
|
+
if (Array.isArray(cfg.workspace?.ignoreDir)) ignoreDirs = cfg.workspace.ignoreDir;
|
|
5499
|
+
if (Array.isArray(cfg.files?.exclude)) excludePatterns = cfg.files.exclude;
|
|
1816
5500
|
} catch (err) {
|
|
1817
5501
|
logger.warn(`[luals] Failed to parse config file for file counting at ${configPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1818
5502
|
}
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
if (!normPat.includes("/")) {
|
|
1833
|
-
const baseRegexStr = "^" + normPat.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*").replace(/\?/g, ".") + "$";
|
|
1834
|
-
try {
|
|
1835
|
-
if (new RegExp(baseRegexStr, "i").test(baseName)) return true;
|
|
1836
|
-
} catch (err) {
|
|
1837
|
-
logger.debug(`[luals] Invalid regex for pattern "${normPat}": ${err instanceof Error ? err.message : String(err)}`);
|
|
1838
|
-
}
|
|
1839
|
-
}
|
|
1840
|
-
let regexStr = normPat;
|
|
1841
|
-
const hasLeadingDoubleStar = regexStr.startsWith("**/");
|
|
1842
|
-
if (hasLeadingDoubleStar) regexStr = regexStr.slice(3);
|
|
1843
|
-
const hasTrailingDoubleStar = regexStr.endsWith("/**");
|
|
1844
|
-
if (hasTrailingDoubleStar) regexStr = regexStr.slice(0, -3);
|
|
1845
|
-
let escaped = regexStr.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\/\*\*\//g, "/(?:.*/)?").replace(/\*\*/g, ".*").replace(/(?<!\.)\*/g, "[^/]*").replace(/\?/g, "[^/]");
|
|
1846
|
-
if (hasLeadingDoubleStar) escaped = `(?:^|.*/)${escaped}`;
|
|
1847
|
-
if (hasTrailingDoubleStar) escaped = `${escaped}(?:/.*)?`;
|
|
1848
|
-
try {
|
|
1849
|
-
if (new RegExp(`^${escaped}$`, "i").test(norm)) return true;
|
|
1850
|
-
} catch (err) {
|
|
1851
|
-
logger.debug(`[luals] Invalid glob regex for pattern "${normPat}": ${err instanceof Error ? err.message : String(err)}`);
|
|
1852
|
-
}
|
|
1853
|
-
}
|
|
1854
|
-
}
|
|
1855
|
-
return false;
|
|
1856
|
-
}
|
|
1857
|
-
let count = 0;
|
|
1858
|
-
function walk(currentDir, relDir = "") {
|
|
1859
|
-
let entries;
|
|
1860
|
-
try {
|
|
1861
|
-
entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
1862
|
-
} catch (err) {
|
|
1863
|
-
logger.debug(`[luals] Failed to read directory ${currentDir}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1864
|
-
return;
|
|
1865
|
-
}
|
|
1866
|
-
for (const entry of entries) {
|
|
1867
|
-
const name = entry.name;
|
|
1868
|
-
const relPath = relDir ? `${relDir}/${name}` : name;
|
|
1869
|
-
const fullPath = path.join(currentDir, name);
|
|
1870
|
-
if (entry.isDirectory() || entry.isSymbolicLink() && (() => {
|
|
1871
|
-
try {
|
|
1872
|
-
return fs.statSync(fullPath).isDirectory();
|
|
1873
|
-
} catch (err) {
|
|
1874
|
-
logger.debug(`[luals] Failed to stat symlink target ${fullPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
1875
|
-
return false;
|
|
1876
|
-
}
|
|
1877
|
-
})()) {
|
|
1878
|
-
const lowerName = name.toLowerCase();
|
|
1879
|
-
if (normIgnoreDirs.has(lowerName) || normIgnoreDirs.has(relPath.toLowerCase())) continue;
|
|
1880
|
-
if (isExcluded(relPath) || isExcluded(`${relPath}/**`)) continue;
|
|
1881
|
-
walk(fullPath, relPath);
|
|
1882
|
-
} else if (entry.isFile() && name.toLowerCase().endsWith(".lua")) {
|
|
1883
|
-
if (!isExcluded(relPath)) count++;
|
|
1884
|
-
}
|
|
1885
|
-
}
|
|
5503
|
+
const ignore = [...toIgnorePatterns(ignoreDirs), ...toIgnorePatterns(excludePatterns)];
|
|
5504
|
+
try {
|
|
5505
|
+
return ts(LUA_FILE_PATTERN, {
|
|
5506
|
+
cwd: absPath,
|
|
5507
|
+
ignore,
|
|
5508
|
+
dot: true,
|
|
5509
|
+
nocase: true,
|
|
5510
|
+
follow: false,
|
|
5511
|
+
withFileTypes: true
|
|
5512
|
+
}).filter((entry) => entry.isFile()).length;
|
|
5513
|
+
} catch (err) {
|
|
5514
|
+
logger.warn(`[luals] Failed to walk ${absPath} while counting checked files: ${err instanceof Error ? err.message : String(err)}`);
|
|
5515
|
+
return 0;
|
|
1886
5516
|
}
|
|
1887
|
-
walk(absPath);
|
|
1888
|
-
return count;
|
|
1889
5517
|
}
|
|
1890
5518
|
//#endregion
|
|
1891
5519
|
//#region src/luals/runner.ts
|
|
1892
5520
|
const execFileAsync = promisify(execFile);
|
|
5521
|
+
/** Determines if an error represents an offline network condition. */
|
|
1893
5522
|
function isOfflineError(err) {
|
|
1894
5523
|
if (!err) return false;
|
|
1895
5524
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1896
5525
|
return /offline|enotfound|eai_again|econnrefused|etimedout|fetch failed/i.test(msg);
|
|
1897
5526
|
}
|
|
5527
|
+
/** Resolves the executable path of a LuaLS binary from env, bundle, cache, or network download. */
|
|
1898
5528
|
async function resolveLuaLSBinary(version = DEFAULT_LUALS_VERSION, options) {
|
|
1899
|
-
if (process.env.LUALS_BIN
|
|
5529
|
+
if (process.env.LUALS_BIN) return assertValidLuaLSBinary(process.env.LUALS_BIN, "LUALS_BIN");
|
|
1900
5530
|
if (options?.reuseExisting !== false && (!version || version === "latest")) {
|
|
1901
5531
|
const defaultInfo = getPlatformInfo(FALLBACK_LUALS_VERSION);
|
|
1902
5532
|
const defaultBundledPath = path.join(getPackageRoot(), defaultInfo.binaryRelativePath);
|
|
@@ -1985,10 +5615,15 @@ async function resolveLuaLSBinary(version = DEFAULT_LUALS_VERSION, options) {
|
|
|
1985
5615
|
}
|
|
1986
5616
|
const currentWeek = getIsoWeek();
|
|
1987
5617
|
const metadata = readLuaLSMetadata(baseCacheDir);
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
const
|
|
1991
|
-
|
|
5618
|
+
const safeLatest = metadata?.latestVersion ? sanitizeLuaLSVersion(metadata.latestVersion) : null;
|
|
5619
|
+
if (options?.reuseExisting !== false && metadata && metadata.lastCheckedWeek === currentWeek && safeLatest) {
|
|
5620
|
+
const info = getPlatformInfo(safeLatest);
|
|
5621
|
+
const targetDir = path.resolve(getCacheDir(safeLatest, baseCacheDir));
|
|
5622
|
+
const resolvedBase = path.resolve(baseCacheDir);
|
|
5623
|
+
if (targetDir.startsWith(resolvedBase + path.sep) || targetDir === resolvedBase) {
|
|
5624
|
+
const cachedPath = path.join(targetDir, info.binaryRelativePath);
|
|
5625
|
+
if (isBinaryValid(cachedPath)) return cachedPath;
|
|
5626
|
+
}
|
|
1992
5627
|
}
|
|
1993
5628
|
const cachedVersions = options?.reuseExisting !== false ? listCachedLuaLSVersions(baseCacheDir) : [];
|
|
1994
5629
|
const firstCachedVersion = cachedVersions[0];
|
|
@@ -2047,6 +5682,7 @@ async function resolveLuaLSBinary(version = DEFAULT_LUALS_VERSION, options) {
|
|
|
2047
5682
|
cleanupOldCachedLuaLSVersions(targetVersion, baseCacheDir);
|
|
2048
5683
|
return downloadedBinary;
|
|
2049
5684
|
}
|
|
5685
|
+
/** Executes the LuaLS diagnostics check on the target path using merged configurations. */
|
|
2050
5686
|
async function runLuaLSCheck(targetPath, configPath, options) {
|
|
2051
5687
|
let absoluteTarget = path.resolve(targetPath);
|
|
2052
5688
|
try {
|
|
@@ -2055,7 +5691,7 @@ async function runLuaLSCheck(targetPath, configPath, options) {
|
|
|
2055
5691
|
logger.debug(`[luals] Failed to resolve native realpath for target: ${err instanceof Error ? err.message : String(err)}`);
|
|
2056
5692
|
}
|
|
2057
5693
|
if (!fs.existsSync(absoluteTarget)) throw new LuaLSError(`Target path does not exist: ${targetPath}`, "ERR_TARGET_NOT_FOUND", "Verify that the target path exists and is accessible.");
|
|
2058
|
-
const binary = options.lualsBin
|
|
5694
|
+
const binary = options.lualsBin ? assertValidLuaLSBinary(options.lualsBin, "--luals-bin") : await resolveLuaLSBinary(options.lualsVersion, { quiet: options.quiet });
|
|
2059
5695
|
let checkDir = absoluteTarget;
|
|
2060
5696
|
let targetFileOnly = null;
|
|
2061
5697
|
if (fs.statSync(absoluteTarget).isFile()) {
|
|
@@ -2155,6 +5791,7 @@ function shouldEnableColor() {
|
|
|
2155
5791
|
if (process.env.FORCE_COLOR !== void 0 && process.env.FORCE_COLOR !== "0") return true;
|
|
2156
5792
|
return process.stdout ? Boolean(process.stdout.isTTY) : true;
|
|
2157
5793
|
}
|
|
5794
|
+
/** Returns ANSI color escape code helpers or empty strings when colors are disabled. */
|
|
2158
5795
|
function getColors(useColor = shouldEnableColor()) {
|
|
2159
5796
|
if (!useColor) return {
|
|
2160
5797
|
reset: "",
|
|
@@ -2181,6 +5818,7 @@ function getColors(useColor = shouldEnableColor()) {
|
|
|
2181
5818
|
gray: "\x1B[90m"
|
|
2182
5819
|
};
|
|
2183
5820
|
}
|
|
5821
|
+
/** Formats a numeric diagnostic severity level into a colored badge. */
|
|
2184
5822
|
function formatSeverityBadge(severity, useColor = shouldEnableColor()) {
|
|
2185
5823
|
const c = getColors(useColor);
|
|
2186
5824
|
const name = SEVERITY_NAMES[severity] || "Warning";
|
|
@@ -2191,9 +5829,11 @@ function formatSeverityBadge(severity, useColor = shouldEnableColor()) {
|
|
|
2191
5829
|
default: return `${c.gray}[${name}]${c.reset}`;
|
|
2192
5830
|
}
|
|
2193
5831
|
}
|
|
5832
|
+
/** Formats a noun with its count and pluralizes if necessary. */
|
|
2194
5833
|
function pluralize(count, singular, plural = `${singular}s`) {
|
|
2195
5834
|
return `${count} ${count === 1 ? singular : plural}`;
|
|
2196
5835
|
}
|
|
5836
|
+
/** Formats the summary text detailing diagnostic counts and affected files. */
|
|
2197
5837
|
function formatProblemSummary(totalProblems, errors, warnings, files) {
|
|
2198
5838
|
const parts = [];
|
|
2199
5839
|
if (errors > 0) parts.push(pluralize(errors, "error"));
|
|
@@ -2203,6 +5843,7 @@ function formatProblemSummary(totalProblems, errors, warnings, files) {
|
|
|
2203
5843
|
const breakdown = parts.length > 0 ? ` (${parts.join(", ")})` : "";
|
|
2204
5844
|
return `Diagnosis complete: ${pluralize(totalProblems, "problem")}${breakdown} found across ${pluralize(files, "file")}.`;
|
|
2205
5845
|
}
|
|
5846
|
+
/** Formats check results into pretty human-readable terminal output. */
|
|
2206
5847
|
function formatPretty(result, cwd = process.cwd(), useColor = shouldEnableColor()) {
|
|
2207
5848
|
const c = getColors(useColor);
|
|
2208
5849
|
const symCross = "✖ ";
|
|
@@ -2252,6 +5893,7 @@ function formatPretty(result, cwd = process.cwd(), useColor = shouldEnableColor(
|
|
|
2252
5893
|
lines.push(`${c.red}${c.bold}${symCross}${summary}${c.reset}`);
|
|
2253
5894
|
return lines.join("\n");
|
|
2254
5895
|
}
|
|
5896
|
+
/** Formats check diagnostics into GitHub Actions workflow annotation commands. */
|
|
2255
5897
|
function formatGitHubAnnotations(result, cwd = process.cwd()) {
|
|
2256
5898
|
const commands = [];
|
|
2257
5899
|
for (const [rawUri, diags] of Object.entries(result.diagnostics)) {
|
|
@@ -2271,6 +5913,7 @@ function formatGitHubAnnotations(result, cwd = process.cwd()) {
|
|
|
2271
5913
|
}
|
|
2272
5914
|
return commands.join("\n");
|
|
2273
5915
|
}
|
|
5916
|
+
/** Formats check results according to the chosen format (pretty, json, github). */
|
|
2274
5917
|
function formatReport(result, format = "pretty", cwd = process.cwd(), useColor = shouldEnableColor()) {
|
|
2275
5918
|
switch (format) {
|
|
2276
5919
|
case "json": return JSON.stringify(result, null, 2);
|
|
@@ -5238,13 +8881,13 @@ function useColor() {
|
|
|
5238
8881
|
}
|
|
5239
8882
|
new Command();
|
|
5240
8883
|
//#endregion
|
|
5241
|
-
//#region src/annotations.ts
|
|
5242
|
-
const DOCGEN_REPO = "nanos-world/vscode-extension";
|
|
5243
|
-
const DOCGEN_BRANCH = "docgen-output";
|
|
5244
|
-
const RAW_ANNOTATIONS_URL = "https://raw.githubusercontent.com/nanos-world/vscode-extension/refs/heads/docgen-output/annotations.lua";
|
|
5245
|
-
const GITHUB_COMMITS_API = "https://api.github.com/repos/nanos-world/vscode-extension/commits/docgen-output";
|
|
8884
|
+
//#region src/annotations-metadata.ts
|
|
5246
8885
|
const ANNOTATIONS_FILENAME = "annotations.lua";
|
|
5247
8886
|
const METADATA_FILENAME = "metadata.json";
|
|
8887
|
+
const MIN_ANNOTATIONS_SIZE_BYTES = 1e3;
|
|
8888
|
+
const MAX_ANNOTATIONS_SIZE_BYTES = 10485760;
|
|
8889
|
+
const MAX_COMMIT_JSON_SIZE_BYTES = 1048576;
|
|
8890
|
+
/** Returns current date string formatted as YYYY-MM-DD alongside a date components object. */
|
|
5248
8891
|
function getTodayDateString(d = /* @__PURE__ */ new Date()) {
|
|
5249
8892
|
const year = d.getFullYear();
|
|
5250
8893
|
const month = d.getMonth() + 1;
|
|
@@ -5258,59 +8901,127 @@ function getTodayDateString(d = /* @__PURE__ */ new Date()) {
|
|
|
5258
8901
|
}
|
|
5259
8902
|
};
|
|
5260
8903
|
}
|
|
8904
|
+
/** Returns the system cache directory used for nanos world annotations. */
|
|
5261
8905
|
function getAnnotationsCacheDir() {
|
|
5262
8906
|
return path.join(systemPaths.cache, "annotations");
|
|
5263
8907
|
}
|
|
8908
|
+
/** Returns the full path to the cached annotations.lua file. */
|
|
5264
8909
|
function getCachedAnnotationsFilePath() {
|
|
5265
8910
|
return path.join(getAnnotationsCacheDir(), ANNOTATIONS_FILENAME);
|
|
5266
8911
|
}
|
|
8912
|
+
/** Returns the full path to the annotations metadata.json file. */
|
|
5267
8913
|
function getAnnotationsMetadataFilePath() {
|
|
5268
8914
|
return path.join(getAnnotationsCacheDir(), METADATA_FILENAME);
|
|
5269
8915
|
}
|
|
8916
|
+
/** Reads and parses annotations metadata.json, purging corrupt files automatically. */
|
|
5270
8917
|
function readAnnotationsMetadata(cacheDir = getAnnotationsCacheDir()) {
|
|
5271
8918
|
const metaPath = path.join(cacheDir, "metadata.json");
|
|
5272
8919
|
if (!fs.existsSync(metaPath)) return null;
|
|
5273
|
-
|
|
5274
|
-
const content = fs.readFileSync(metaPath, "utf-8");
|
|
5275
|
-
const parsed = JSON.parse(content);
|
|
5276
|
-
if (typeof parsed?.commitId === "string" && typeof parsed?.lastChecked === "string") return parsed;
|
|
8920
|
+
const purge = (reason) => {
|
|
5277
8921
|
try {
|
|
5278
8922
|
fs.unlinkSync(metaPath);
|
|
5279
|
-
logger.warn(`[annotations]
|
|
5280
|
-
} catch (
|
|
5281
|
-
logger.debug(`[annotations] Failed to unlink
|
|
8923
|
+
logger.warn(`[annotations] ${reason} annotations metadata at ${metaPath} purged.`);
|
|
8924
|
+
} catch (err) {
|
|
8925
|
+
logger.debug(`[annotations] Failed to unlink metadata: ${err instanceof Error ? err.message : String(err)}`);
|
|
5282
8926
|
}
|
|
8927
|
+
};
|
|
8928
|
+
try {
|
|
8929
|
+
const parsed = JSON.parse(fs.readFileSync(metaPath, "utf-8"));
|
|
8930
|
+
if (typeof parsed?.commitId === "string" && typeof parsed?.lastChecked === "string") return parsed;
|
|
8931
|
+
purge("Stale or invalid");
|
|
5283
8932
|
} catch (err) {
|
|
5284
8933
|
logger.debug(`Failed to parse annotations metadata: ${err instanceof Error ? err.message : String(err)}`);
|
|
5285
|
-
|
|
5286
|
-
fs.unlinkSync(metaPath);
|
|
5287
|
-
logger.warn(`[annotations] Corrupted annotations metadata at ${metaPath} purged.`);
|
|
5288
|
-
} catch (unlinkErr) {
|
|
5289
|
-
logger.debug(`[annotations] Failed to unlink corrupted metadata: ${unlinkErr instanceof Error ? unlinkErr.message : String(unlinkErr)}`);
|
|
5290
|
-
}
|
|
8934
|
+
purge("Corrupted");
|
|
5291
8935
|
}
|
|
5292
8936
|
return null;
|
|
5293
8937
|
}
|
|
5294
|
-
/**
|
|
5295
|
-
* Verifies that an annotations file exists, is a regular file, is of non-trivial size (>= 1000 bytes),
|
|
5296
|
-
* and begins with valid Lua comments or nanos world definitions.
|
|
5297
|
-
*/
|
|
8938
|
+
/** Verifies that an annotations file exists, is non-trivial in size, and contains valid header. */
|
|
5298
8939
|
function isAnnotationsValid(filePath) {
|
|
5299
8940
|
if (!fs.existsSync(filePath)) return false;
|
|
5300
8941
|
try {
|
|
5301
8942
|
const stat = fs.statSync(filePath);
|
|
5302
8943
|
if (!stat.isFile() || stat.size < 1e3) return false;
|
|
5303
8944
|
const fd = fs.openSync(filePath, "r");
|
|
5304
|
-
|
|
5305
|
-
|
|
5306
|
-
|
|
5307
|
-
|
|
5308
|
-
|
|
8945
|
+
try {
|
|
8946
|
+
const buffer = Buffer.alloc(512);
|
|
8947
|
+
const bytesRead = fs.readSync(fd, buffer, 0, buffer.length, 0);
|
|
8948
|
+
const header = buffer.toString("utf-8", 0, bytesRead).trimStart();
|
|
8949
|
+
return header.startsWith("---@meta") || header.includes("nanos world") || header.includes("nanos-world");
|
|
8950
|
+
} finally {
|
|
8951
|
+
fs.closeSync(fd);
|
|
8952
|
+
}
|
|
5309
8953
|
} catch (err) {
|
|
5310
8954
|
logger.debug(`[annotations] Annotation validation failed for ${filePath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
5311
8955
|
return false;
|
|
5312
8956
|
}
|
|
5313
8957
|
}
|
|
8958
|
+
/** Updates metadata lastChecked date atomically without modifying annotations.lua. */
|
|
8959
|
+
function updateLastCheckedDate(commitId, cacheDir = getAnnotationsCacheDir()) {
|
|
8960
|
+
const { dateStr, dateObj } = getTodayDateString();
|
|
8961
|
+
const metadata = {
|
|
8962
|
+
commitId,
|
|
8963
|
+
lastChecked: dateStr,
|
|
8964
|
+
date: dateObj
|
|
8965
|
+
};
|
|
8966
|
+
fs.mkdirSync(cacheDir, { recursive: true });
|
|
8967
|
+
const metaPath = path.join(cacheDir, METADATA_FILENAME);
|
|
8968
|
+
const tempMetaPath = path.join(os.tmpdir(), `.metadata-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.tmp`);
|
|
8969
|
+
try {
|
|
8970
|
+
fs.writeFileSync(tempMetaPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
8971
|
+
fs.copyFileSync(tempMetaPath, metaPath);
|
|
8972
|
+
} finally {
|
|
8973
|
+
try {
|
|
8974
|
+
if (fs.existsSync(tempMetaPath)) fs.unlinkSync(tempMetaPath);
|
|
8975
|
+
} catch (err) {
|
|
8976
|
+
logger.warn(`Failed to clean up temporary metadata file ${tempMetaPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
8977
|
+
}
|
|
8978
|
+
}
|
|
8979
|
+
return metadata;
|
|
8980
|
+
}
|
|
8981
|
+
//#endregion
|
|
8982
|
+
//#region src/annotations-download.ts
|
|
8983
|
+
const DOCGEN_REPO = "nanos-world/vscode-extension";
|
|
8984
|
+
const DOCGEN_BRANCH = "docgen-output";
|
|
8985
|
+
const RAW_ANNOTATIONS_URL = "https://raw.githubusercontent.com/nanos-world/vscode-extension/refs/heads/docgen-output/annotations.lua";
|
|
8986
|
+
const GITHUB_COMMITS_API = "https://api.github.com/repos/nanos-world/vscode-extension/commits/docgen-output";
|
|
8987
|
+
/** Reads an HTTP response body with an upper byte limit to guard against memory exhaustion. */
|
|
8988
|
+
async function readBoundedResponseBody(res, maxBytes, onExceeded) {
|
|
8989
|
+
const lengthHeader = res.headers?.get?.("content-length");
|
|
8990
|
+
if (lengthHeader) {
|
|
8991
|
+
const declared = parseInt(lengthHeader, 10);
|
|
8992
|
+
if (!isNaN(declared) && declared > maxBytes) {
|
|
8993
|
+
if (typeof res.body?.cancel === "function") await res.body.cancel().catch(() => {});
|
|
8994
|
+
onExceeded(declared, "header");
|
|
8995
|
+
return null;
|
|
8996
|
+
}
|
|
8997
|
+
}
|
|
8998
|
+
if (res.body && typeof res.body[Symbol.asyncIterator] === "function") {
|
|
8999
|
+
let total = 0;
|
|
9000
|
+
const chunks = [];
|
|
9001
|
+
for await (const chunk of res.body) {
|
|
9002
|
+
const buf = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
9003
|
+
total += buf.length;
|
|
9004
|
+
if (total > maxBytes) {
|
|
9005
|
+
if (typeof res.body.cancel === "function") await res.body.cancel().catch(() => {});
|
|
9006
|
+
onExceeded(total, "stream");
|
|
9007
|
+
return null;
|
|
9008
|
+
}
|
|
9009
|
+
chunks.push(buf);
|
|
9010
|
+
}
|
|
9011
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
9012
|
+
}
|
|
9013
|
+
if (typeof res.text === "function") {
|
|
9014
|
+
const text = await res.text();
|
|
9015
|
+
const len = Buffer.byteLength(text, "utf-8");
|
|
9016
|
+
if (len > maxBytes) {
|
|
9017
|
+
onExceeded(len, "stream");
|
|
9018
|
+
return null;
|
|
9019
|
+
}
|
|
9020
|
+
return text;
|
|
9021
|
+
}
|
|
9022
|
+
return "";
|
|
9023
|
+
}
|
|
9024
|
+
/** Fetches the latest commit SHA for the annotations branch from the GitHub API. */
|
|
5314
9025
|
async function fetchLatestCommitId() {
|
|
5315
9026
|
try {
|
|
5316
9027
|
const headers = { "User-Agent": "nanos-lint" };
|
|
@@ -5320,7 +9031,17 @@ async function fetchLatestCommitId() {
|
|
|
5320
9031
|
signal: AbortSignal.timeout(5e3)
|
|
5321
9032
|
});
|
|
5322
9033
|
if (res.ok) {
|
|
5323
|
-
const
|
|
9034
|
+
const rawJson = await readBoundedResponseBody(res, MAX_COMMIT_JSON_SIZE_BYTES, (bytes) => {
|
|
9035
|
+
logger.warn(`GitHub commits response exceeded size limit of ${MAX_COMMIT_JSON_SIZE_BYTES} bytes (${bytes} bytes)`);
|
|
9036
|
+
});
|
|
9037
|
+
if (rawJson === null) return null;
|
|
9038
|
+
if (!rawJson && !res.bodyUsed && typeof res.json === "function") {
|
|
9039
|
+
const data = await res.json();
|
|
9040
|
+
if (typeof data.sha === "string" && /^[0-9a-fA-F]{7,40}$/.test(data.sha)) return data.sha;
|
|
9041
|
+
return null;
|
|
9042
|
+
}
|
|
9043
|
+
if (!rawJson) return null;
|
|
9044
|
+
const data = JSON.parse(rawJson);
|
|
5324
9045
|
if (typeof data.sha === "string" && /^[0-9a-fA-F]{7,40}$/.test(data.sha)) return data.sha;
|
|
5325
9046
|
}
|
|
5326
9047
|
} catch (err) {
|
|
@@ -5328,16 +9049,26 @@ async function fetchLatestCommitId() {
|
|
|
5328
9049
|
}
|
|
5329
9050
|
return null;
|
|
5330
9051
|
}
|
|
5331
|
-
|
|
5332
|
-
|
|
9052
|
+
/** Returns raw annotations URL, pinned to commit SHA if provided and valid. */
|
|
9053
|
+
function getRawAnnotationsUrl(commitSha) {
|
|
9054
|
+
if (commitSha && /^[0-9a-fA-F]{7,40}$/.test(commitSha)) return `https://raw.githubusercontent.com/${DOCGEN_REPO}/${commitSha}/annotations.lua`;
|
|
9055
|
+
return RAW_ANNOTATIONS_URL;
|
|
9056
|
+
}
|
|
9057
|
+
/** Downloads raw annotations.lua content from GitHub raw content endpoints. */
|
|
9058
|
+
async function fetchRawAnnotationsContent(commitSha) {
|
|
9059
|
+
const url = getRawAnnotationsUrl(commitSha);
|
|
9060
|
+
const res = await fetch(url, {
|
|
5333
9061
|
headers: { "User-Agent": "nanos-lint" },
|
|
5334
9062
|
signal: AbortSignal.timeout(15e3)
|
|
5335
9063
|
});
|
|
5336
9064
|
if (!res.ok) throw new AnnotationsError(`Failed to download annotations.lua: ${res.status} ${res.statusText}`, "ERR_ANNOTATIONS_DOWNLOAD", "Verify your internet connection and that GitHub raw endpoints are accessible.");
|
|
5337
|
-
const text = await res
|
|
9065
|
+
const text = await readBoundedResponseBody(res, MAX_ANNOTATIONS_SIZE_BYTES, (bytes, reason) => {
|
|
9066
|
+
throw new AnnotationsError(reason === "header" ? `Annotations file size (${bytes} bytes) exceeds maximum limit (${MAX_ANNOTATIONS_SIZE_BYTES} bytes)` : `Annotations file download exceeded maximum allowed size of ${MAX_ANNOTATIONS_SIZE_BYTES} bytes`, "ERR_ANNOTATIONS_TOO_LARGE", "Specify a local annotations file via --annotations <path>.");
|
|
9067
|
+
});
|
|
5338
9068
|
if (!text || text.length < 1e3) throw new AnnotationsError("Downloaded annotations.lua appears truncated or invalid", "ERR_ANNOTATIONS_INVALID", "Retry downloading or pass a local annotations file via --annotations <path>.");
|
|
5339
9069
|
return text;
|
|
5340
9070
|
}
|
|
9071
|
+
/** Copies a file with exponential backoff retries to handle transient file lock contention. */
|
|
5341
9072
|
async function copyFileWithRetry(src, dest, maxRetries = 10) {
|
|
5342
9073
|
for (let attempt = 0; attempt < maxRetries; attempt++) try {
|
|
5343
9074
|
fs.copyFileSync(src, dest);
|
|
@@ -5351,35 +9082,7 @@ async function copyFileWithRetry(src, dest, maxRetries = 10) {
|
|
|
5351
9082
|
throw err;
|
|
5352
9083
|
}
|
|
5353
9084
|
}
|
|
5354
|
-
/**
|
|
5355
|
-
* Updates the metadata lastChecked date atomically without modifying annotations.lua.
|
|
5356
|
-
*/
|
|
5357
|
-
function updateLastCheckedDate(commitId, cacheDir = getAnnotationsCacheDir()) {
|
|
5358
|
-
const { dateStr, dateObj } = getTodayDateString();
|
|
5359
|
-
const metadata = {
|
|
5360
|
-
commitId,
|
|
5361
|
-
lastChecked: dateStr,
|
|
5362
|
-
date: dateObj
|
|
5363
|
-
};
|
|
5364
|
-
fs.mkdirSync(cacheDir, { recursive: true });
|
|
5365
|
-
const metaPath = path.join(cacheDir, METADATA_FILENAME);
|
|
5366
|
-
const tempMetaPath = path.join(os.tmpdir(), `.metadata-${Date.now()}-${Math.random().toString(36).slice(2, 8)}.tmp`);
|
|
5367
|
-
try {
|
|
5368
|
-
fs.writeFileSync(tempMetaPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
5369
|
-
fs.copyFileSync(tempMetaPath, metaPath);
|
|
5370
|
-
} finally {
|
|
5371
|
-
try {
|
|
5372
|
-
if (fs.existsSync(tempMetaPath)) fs.unlinkSync(tempMetaPath);
|
|
5373
|
-
} catch (err) {
|
|
5374
|
-
logger.warn(`Failed to clean up temporary metadata file ${tempMetaPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
5375
|
-
}
|
|
5376
|
-
}
|
|
5377
|
-
return metadata;
|
|
5378
|
-
}
|
|
5379
|
-
/**
|
|
5380
|
-
* Downloads annotations.lua, writes it and the new metadata in a chained atomic transaction.
|
|
5381
|
-
* If any step fails, the previous cache state is reverted.
|
|
5382
|
-
*/
|
|
9085
|
+
/** Downloads annotations.lua and writes metadata in a chained atomic transaction with rollback. */
|
|
5383
9086
|
async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCacheDir(), options) {
|
|
5384
9087
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
5385
9088
|
const finalAnnotationsPath = path.join(cacheDir, ANNOTATIONS_FILENAME);
|
|
@@ -5390,10 +9093,10 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
|
|
|
5390
9093
|
try {
|
|
5391
9094
|
fs.mkdirSync(tempDir, { recursive: true });
|
|
5392
9095
|
if (!options?.quiet) {
|
|
5393
|
-
|
|
5394
|
-
|
|
9096
|
+
const label = commitId && commitId !== "unknown" ? ` (${commitId.slice(0, 7)})` : "";
|
|
9097
|
+
logger.info(`[annotations] Downloading nanos world API annotations${label}...`);
|
|
5395
9098
|
}
|
|
5396
|
-
const content = await fetchRawAnnotationsContent();
|
|
9099
|
+
const content = await fetchRawAnnotationsContent(commitId);
|
|
5397
9100
|
const tempAnnotationsPath = path.join(tempDir, ANNOTATIONS_FILENAME);
|
|
5398
9101
|
fs.writeFileSync(tempAnnotationsPath, content, "utf-8");
|
|
5399
9102
|
const { dateStr, dateObj } = getTodayDateString();
|
|
@@ -5405,7 +9108,7 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
|
|
|
5405
9108
|
const tempMetaPath = path.join(tempDir, METADATA_FILENAME);
|
|
5406
9109
|
fs.writeFileSync(tempMetaPath, JSON.stringify(metadata, null, 2), "utf-8");
|
|
5407
9110
|
const existingMeta = readAnnotationsMetadata(cacheDir);
|
|
5408
|
-
if (existingMeta && existingMeta.commitId === commitId && fs.existsSync(finalAnnotationsPath) &&
|
|
9111
|
+
if (existingMeta && existingMeta.commitId === commitId && fs.existsSync(finalAnnotationsPath) && isAnnotationsValid(finalAnnotationsPath)) return finalAnnotationsPath;
|
|
5409
9112
|
const oldAnnotationsExists = fs.existsSync(finalAnnotationsPath);
|
|
5410
9113
|
const oldMetaExists = fs.existsSync(finalMetaPath);
|
|
5411
9114
|
if (oldAnnotationsExists || oldMetaExists) {
|
|
@@ -5417,16 +9120,16 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
|
|
|
5417
9120
|
await copyFileWithRetry(tempAnnotationsPath, finalAnnotationsPath);
|
|
5418
9121
|
await copyFileWithRetry(tempMetaPath, finalMetaPath);
|
|
5419
9122
|
if (!options?.quiet) {
|
|
5420
|
-
|
|
5421
|
-
|
|
9123
|
+
const label = commitId && commitId !== "unknown" ? ` to commit ${commitId.slice(0, 7)}` : "";
|
|
9124
|
+
logger.info(`[annotations] Updated annotations.lua${label}.`);
|
|
5422
9125
|
}
|
|
5423
9126
|
return finalAnnotationsPath;
|
|
5424
9127
|
} catch (err) {
|
|
5425
9128
|
if (hasBackup && fs.existsSync(backupDir)) try {
|
|
5426
|
-
const
|
|
5427
|
-
const
|
|
5428
|
-
if (fs.existsSync(
|
|
5429
|
-
if (fs.existsSync(
|
|
9129
|
+
const bAnn = path.join(backupDir, ANNOTATIONS_FILENAME);
|
|
9130
|
+
const bMeta = path.join(backupDir, METADATA_FILENAME);
|
|
9131
|
+
if (fs.existsSync(bAnn)) await copyFileWithRetry(bAnn, finalAnnotationsPath);
|
|
9132
|
+
if (fs.existsSync(bMeta)) await copyFileWithRetry(bMeta, finalMetaPath);
|
|
5430
9133
|
} catch (rollbackErr) {
|
|
5431
9134
|
logger.error(`Failed to restore annotations from backup during rollback: ${rollbackErr instanceof Error ? rollbackErr.message : String(rollbackErr)}`);
|
|
5432
9135
|
}
|
|
@@ -5446,6 +9149,33 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
|
|
|
5446
9149
|
}
|
|
5447
9150
|
}
|
|
5448
9151
|
}
|
|
9152
|
+
//#endregion
|
|
9153
|
+
//#region src/annotations.ts
|
|
9154
|
+
/** Validates that a user-supplied or environment-specified annotations path exists and is a valid file. */
|
|
9155
|
+
function validateCustomAnnotationsPath(filePath, source) {
|
|
9156
|
+
const resolved = path.resolve(filePath);
|
|
9157
|
+
const isCustom = source === "custom";
|
|
9158
|
+
const targetDesc = isCustom ? "path specified in --annotations" : "path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS";
|
|
9159
|
+
if (!fs.existsSync(resolved)) throw new AnnotationsError(isCustom ? `Custom annotations file not found: ${resolved}` : `Annotations file specified in environment not found: ${resolved}`, isCustom ? "ERR_ANNOTATIONS_NOT_FOUND" : "ERR_ANNOTATIONS_ENV_NOT_FOUND", `Verify that the ${targetDesc} exists and is accessible.`);
|
|
9160
|
+
const stat = fs.statSync(resolved);
|
|
9161
|
+
if (!stat.isFile()) throw new AnnotationsError(isCustom ? `Custom annotations path is not a file: ${resolved}` : `Annotations path specified in environment is not a file: ${resolved}`, "ERR_ANNOTATIONS_NOT_A_FILE", `Verify that the ${targetDesc} points to a regular file, not a directory.`);
|
|
9162
|
+
if (stat.size === 0) throw new AnnotationsError(isCustom ? `Custom annotations file is empty: ${resolved}` : `Annotations file specified in environment is empty: ${resolved}`, "ERR_ANNOTATIONS_INVALID", `Verify that the ${targetDesc} is a valid non-empty Lua annotations file.`);
|
|
9163
|
+
try {
|
|
9164
|
+
const fd = fs.openSync(resolved, "r");
|
|
9165
|
+
let isBinary = false;
|
|
9166
|
+
try {
|
|
9167
|
+
const buffer = Buffer.alloc(Math.min(stat.size, 512));
|
|
9168
|
+
const bytesRead = fs.readSync(fd, buffer, 0, buffer.length, 0);
|
|
9169
|
+
isBinary = buffer.subarray(0, bytesRead).includes(0);
|
|
9170
|
+
} finally {
|
|
9171
|
+
fs.closeSync(fd);
|
|
9172
|
+
}
|
|
9173
|
+
if (isBinary) throw new AnnotationsError(isCustom ? `Custom annotations file appears to be a binary file: ${resolved}` : `Annotations file specified in environment appears to be a binary file: ${resolved}`, "ERR_ANNOTATIONS_INVALID", "Verify that the annotations file is a valid Lua text annotations file.");
|
|
9174
|
+
} catch (err) {
|
|
9175
|
+
if (err instanceof AnnotationsError) throw err;
|
|
9176
|
+
}
|
|
9177
|
+
return resolved;
|
|
9178
|
+
}
|
|
5449
9179
|
/**
|
|
5450
9180
|
* Resolves the nanos world annotations.lua definitions file path.
|
|
5451
9181
|
* Resolution precedence:
|
|
@@ -5455,17 +9185,9 @@ async function downloadAndCacheAnnotations(commitId, cacheDir = getAnnotationsCa
|
|
|
5455
9185
|
* 4. User cache (checked once per day from upstream GitHub)
|
|
5456
9186
|
*/
|
|
5457
9187
|
async function resolveAnnotations(options = {}) {
|
|
5458
|
-
if (options.customPath)
|
|
5459
|
-
const resolved = path.resolve(options.customPath);
|
|
5460
|
-
if (!fs.existsSync(resolved)) throw new AnnotationsError(`Custom annotations file not found: ${resolved}`, "ERR_ANNOTATIONS_NOT_FOUND", "Verify that the path specified in --annotations exists and is accessible.");
|
|
5461
|
-
return resolved;
|
|
5462
|
-
}
|
|
9188
|
+
if (options.customPath) return validateCustomAnnotationsPath(options.customPath, "custom");
|
|
5463
9189
|
const envPath = process.env.NANOS_ANNOTATIONS_PATH || process.env.NANOS_ANNOTATIONS;
|
|
5464
|
-
if (envPath)
|
|
5465
|
-
const resolved = path.resolve(envPath);
|
|
5466
|
-
if (!fs.existsSync(resolved)) throw new AnnotationsError(`Annotations file specified in environment not found: ${resolved}`, "ERR_ANNOTATIONS_ENV_NOT_FOUND", "Verify that the path specified in NANOS_ANNOTATIONS_PATH or NANOS_ANNOTATIONS exists.");
|
|
5467
|
-
return resolved;
|
|
5468
|
-
}
|
|
9190
|
+
if (envPath) return validateCustomAnnotationsPath(envPath, "env");
|
|
5469
9191
|
const bundled = path.join(getPackageRoot(), "annotations.lua");
|
|
5470
9192
|
if (fs.existsSync(bundled) && isAnnotationsValid(bundled)) return bundled;
|
|
5471
9193
|
const cacheDir = options.cacheDir ?? getAnnotationsCacheDir();
|
|
@@ -5517,6 +9239,7 @@ async function resolveAnnotations(options = {}) {
|
|
|
5517
9239
|
}
|
|
5518
9240
|
//#endregion
|
|
5519
9241
|
//#region src/cache-status.ts
|
|
9242
|
+
/** Collects detailed status and disk usage information for LuaLS and annotations caches. */
|
|
5520
9243
|
function getCacheStatus(baseCacheDir = systemPaths.cache) {
|
|
5521
9244
|
const totalSize = getDirectorySize(baseCacheDir);
|
|
5522
9245
|
const totalSizeFormatted = formatBytes(totalSize);
|
|
@@ -5574,6 +9297,7 @@ function getCacheStatus(baseCacheDir = systemPaths.cache) {
|
|
|
5574
9297
|
}
|
|
5575
9298
|
};
|
|
5576
9299
|
}
|
|
9300
|
+
/** Formats a cache status report into human-readable terminal output. */
|
|
5577
9301
|
function formatCacheStatusPretty(report) {
|
|
5578
9302
|
const lines = [];
|
|
5579
9303
|
lines.push("nanos-lint Cache Status");
|
|
@@ -5608,6 +9332,7 @@ function formatCacheStatusPretty(report) {
|
|
|
5608
9332
|
}
|
|
5609
9333
|
//#endregion
|
|
5610
9334
|
//#region src/cli.ts
|
|
9335
|
+
/** Retrieves the formatted package name and version string from package.json. */
|
|
5611
9336
|
function getVersionString() {
|
|
5612
9337
|
const root = getPackageRoot();
|
|
5613
9338
|
try {
|
|
@@ -5621,10 +9346,12 @@ function getVersionString() {
|
|
|
5621
9346
|
function writeOutput(message) {
|
|
5622
9347
|
if (logger.isOutputEnabled()) console.log(message);
|
|
5623
9348
|
}
|
|
9349
|
+
/** Accumulates repeatable --ignore pattern arguments, splitting by comma and newline. */
|
|
5624
9350
|
function collectIgnorePatterns(val, prev) {
|
|
5625
9351
|
const parts = val.split(/[\r\n,]+/).map((s) => s.trim()).filter(Boolean);
|
|
5626
9352
|
return (prev ?? []).concat(parts);
|
|
5627
9353
|
}
|
|
9354
|
+
/** Constructs and configures the top-level Commander program and its CLI subcommands. */
|
|
5628
9355
|
function createProgram(options) {
|
|
5629
9356
|
const setExitCode = options?.setExitCode ?? (() => {});
|
|
5630
9357
|
const program = new Command("nanos-lint");
|
|
@@ -5773,6 +9500,7 @@ Examples:
|
|
|
5773
9500
|
`);
|
|
5774
9501
|
return program;
|
|
5775
9502
|
}
|
|
9503
|
+
/** Parses command-line arguments and executes the requested CLI action. */
|
|
5776
9504
|
async function runCLI(args = process.argv.slice(2)) {
|
|
5777
9505
|
for (let i = 0; i < args.length; i++) {
|
|
5778
9506
|
const arg = args[i];
|
|
@@ -5809,6 +9537,7 @@ async function runCLI(args = process.argv.slice(2)) {
|
|
|
5809
9537
|
return 1;
|
|
5810
9538
|
}
|
|
5811
9539
|
}
|
|
9540
|
+
/** Determines whether the current module is being directly executed as an application entrypoint. */
|
|
5812
9541
|
function isDirectExecution(importMetaUrl = import.meta.url, argv1 = process.argv[1]) {
|
|
5813
9542
|
if (!argv1) return false;
|
|
5814
9543
|
const toPath = (urlStr) => {
|
|
@@ -5845,6 +9574,6 @@ if (isDirectExecution()) runCLI().then((code) => {
|
|
|
5845
9574
|
process.exit(1);
|
|
5846
9575
|
});
|
|
5847
9576
|
//#endregion
|
|
5848
|
-
export {
|
|
9577
|
+
export { getLuaLSMetadataPath as $, formatProblemSummary as A, loadConfigFile as At, DOWNLOAD_TIMEOUT_MS as B, NanosLintError as Bt, getCachedAnnotationsFilePath as C, sanitizeLuaLSVersion as Ct, updateLastCheckedDate as D, getDefinitionsDir as Dt, readAnnotationsMetadata as E, getDefaultTemplatePath as Et, shouldEnableColor as F, stripTrailingSlashes as Ft, limitDownloadStream as G, fileUriToPath as Gt, computeFileSha256 as H, formatBytes as Ht, resolveLuaLSBinary as I, AnnotationsError as It, findExistingLuaLSDir as J, LOG_LEVEL_PRIORITY as Jt, LUALS_METADATA_FILENAME as K, DEFAULT_LOG_LEVEL as Kt, runLuaLSCheck as L, CacheError as Lt, formatSeverityBadge as M, parseJsonc as Mt, getColors as N, resolveWorkspaceConfig as Nt, formatGitHubAnnotations as O, getPackageRoot as Ot, pluralize as P, stripJsonComments as Pt, getLegacyCacheDir as Q, parseLogLevel as Qt, countCheckedFiles as R, ConfigError as Rt, getAnnotationsMetadataFilePath as S, resolveLuaLSVersion as St, isAnnotationsValid as T, getDefaultAnnotationsPath as Tt, downloadAndExtractLuaLS as U, getDirectorySize as Ut, MAX_ARCHIVE_SIZE_BYTES as V, cleanCache as Vt, isAllowedDownloadUrl as W, systemPaths as Wt, getCacheDir as X, isValidLogLevel as Xt, getBaseLuaLSCacheDir as Y, Logger as Yt, getIsoWeek as Z, logger as Zt, MAX_ANNOTATIONS_SIZE_BYTES as _, getPlatformInfo as _t, formatCacheStatusPretty as a, MAX_DECOMPRESSED_SIZE_BYTES as at, MIN_ANNOTATIONS_SIZE_BYTES as b, fetchLatestLuaLSVersionFromGitHub as bt, DOCGEN_BRANCH as c, escapePowerShellSingleQuote as ct, RAW_ANNOTATIONS_URL as d, isBinaryRunnable as dt, listCachedLuaLSVersionDirs as et, downloadAndCacheAnnotations as f, isBinaryValid as ft, ANNOTATIONS_FILENAME as g, validateArchiveMembers as gt, getRawAnnotationsUrl as h, parseTarTvSize as ht, runCLI as i, MAX_ARCHIVE_MEMBER_COUNT as it, formatReport as j, mergeConfigs as jt, formatPretty as k, initWorkspace as kt, DOCGEN_REPO as l, getTarBinary as lt, fetchRawAnnotationsContent as m, isZipArchive as mt, createProgram as n, readLuaLSMetadata as nt, getCacheStatus as o, MIN_DOWNLOADED_BINARY_SIZE_BYTES as ot, fetchLatestCommitId as p, isGzipArchive as pt, cleanupOldCachedLuaLSVersions as q, LOG_LEVELS as qt, isDirectExecution as r, writeLuaLSMetadata as rt, resolveAnnotations as s, assertValidLuaLSBinary as st, collectIgnorePatterns as t, listCachedLuaLSVersions as tt, GITHUB_COMMITS_API as u, inspectZipMembers as ut, MAX_COMMIT_JSON_SIZE_BYTES as v, DEFAULT_LUALS_VERSION as vt, getTodayDateString as w, VALID_LUALS_DIAGNOSTIC_CODES as wt, getAnnotationsCacheDir as x, resolveLatestLuaLSVersion as xt, METADATA_FILENAME as y, FALLBACK_LUALS_VERSION as yt, ALLOWED_DOWNLOAD_DOMAINS as z, LuaLSError as zt };
|
|
5849
9578
|
|
|
5850
|
-
//# sourceMappingURL=cli-
|
|
9579
|
+
//# sourceMappingURL=cli-BTHx4yp_.js.map
|