token-goat 2.6.33 → 2.6.34
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 +4 -0
- package/dist/{token-goat-chunk-WFRR2DBG.mjs → token-goat-chunk-7FWBSPCT.mjs} +446 -339
- package/dist/{token-goat-chunk-HPWPUBAK.mjs → token-goat-chunk-CKRATWCJ.mjs} +5 -5
- package/dist/{token-goat-chunk-TDYTBCT4.mjs → token-goat-chunk-CN7GUPX6.mjs} +328 -86
- package/dist/{token-goat-chunk-L6FVTDPD.mjs → token-goat-chunk-FRMEOIRU.mjs} +361 -23
- package/dist/{token-goat-chunk-RPOXYJWK.mjs → token-goat-chunk-GXBPEQR2.mjs} +70 -25
- package/dist/{token-goat-chunk-77CX3MCN.mjs → token-goat-chunk-I6EQH27G.mjs} +2 -2
- package/dist/{token-goat-chunk-FN6WLFIX.mjs → token-goat-chunk-IYYQOPY4.mjs} +801 -51
- package/dist/{token-goat-chunk-72R7M5H7.mjs → token-goat-chunk-L7QLEVO7.mjs} +3 -3
- package/dist/{token-goat-chunk-OHQ7RBLL.mjs → token-goat-chunk-OA3GFKP2.mjs} +2 -2
- package/dist/{token-goat-hook-chunk-HXHFLKEL.mjs → token-goat-chunk-WA2ER6TZ.mjs} +7 -2
- package/dist/{token-goat-chunk-RQQ4SY2P.mjs → token-goat-hook-chunk-2ISZ4AZR.mjs} +7 -2
- package/dist/{token-goat-hook-chunk-ZT47M3IA.mjs → token-goat-hook-chunk-6C5RN3CM.mjs} +2 -2
- package/dist/{token-goat-hook-chunk-UWV4MTYI.mjs → token-goat-hook-chunk-6QTWMSRO.mjs} +328 -86
- package/dist/{token-goat-hook-chunk-XBOWDNJB.mjs → token-goat-hook-chunk-ATEGFQAU.mjs} +5 -5
- package/dist/{token-goat-hook-chunk-QD2DX2U7.mjs → token-goat-hook-chunk-BU5OFDGQ.mjs} +361 -23
- package/dist/{token-goat-hook-chunk-E6AIPKNF.mjs → token-goat-hook-chunk-CNLMPHXT.mjs} +442 -335
- package/dist/{token-goat-hook-chunk-WBBHV6TZ.mjs → token-goat-hook-chunk-I5VM5PO5.mjs} +70 -25
- package/dist/{token-goat-hook-chunk-VDXQXYJK.mjs → token-goat-hook-chunk-KGLMNOGD.mjs} +801 -51
- package/dist/{token-goat-hook-chunk-EKGDLI4D.mjs → token-goat-hook-chunk-OQML5EMA.mjs} +3 -3
- package/dist/{token-goat-hook-chunk-26DLRODR.mjs → token-goat-hook-chunk-QTZ6YUMQ.mjs} +2 -2
- package/dist/token-goat-hook.mjs +5 -5
- package/dist/token-goat.core.mjs +5 -5
- package/package.json +8 -8
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
9
|
function resolveVersion() {
|
|
10
10
|
if (true) {
|
|
11
|
-
return "2.6.
|
|
11
|
+
return "2.6.34";
|
|
12
12
|
}
|
|
13
13
|
const require2 = createRequire(import.meta.url);
|
|
14
14
|
const pkg = require2("../package.json");
|
|
@@ -213,6 +213,13 @@ function fingerprintFile(filePath) {
|
|
|
213
213
|
}
|
|
214
214
|
return fingerprintContent(data);
|
|
215
215
|
}
|
|
216
|
+
function fileIsAbsent(filePath) {
|
|
217
|
+
try {
|
|
218
|
+
return fs2.statSync(filePath, { throwIfNoEntry: false }) === void 0;
|
|
219
|
+
} catch {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
216
223
|
|
|
217
224
|
// src/paths.ts
|
|
218
225
|
import * as fs3 from "node:fs";
|
|
@@ -309,10 +316,22 @@ function safeJoin(base, ...parts) {
|
|
|
309
316
|
}
|
|
310
317
|
return path2.join(base, ...parts);
|
|
311
318
|
}
|
|
319
|
+
function displaySafeText(text) {
|
|
320
|
+
return text.replace(new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cf}", "gu"), (ch) => {
|
|
321
|
+
if (ch === "\n") return "\\n";
|
|
322
|
+
if (ch === "\r") return "\\r";
|
|
323
|
+
if (ch === " ") return "\\t";
|
|
324
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
325
|
+
return code <= 255 ? "\\x" + code.toString(16).padStart(2, "0") : "\\u" + code.toString(16).padStart(4, "0");
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
function displaySafePath(p) {
|
|
329
|
+
return displaySafeText(p);
|
|
330
|
+
}
|
|
312
331
|
|
|
313
332
|
// src/util.ts
|
|
314
333
|
import { spawn, spawnSync } from "node:child_process";
|
|
315
|
-
import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as
|
|
334
|
+
import { chmodSync as chmodSync2, closeSync, copyFileSync, existsSync, mkdirSync as mkdirSync2, openSync, readdirSync, readFileSync as readFileSync2, renameSync, statSync as statSync3, unlinkSync, writeFileSync, writeSync } from "node:fs";
|
|
316
335
|
import * as path3 from "node:path";
|
|
317
336
|
function sleepSync(ms) {
|
|
318
337
|
if (ms <= 0) return;
|
|
@@ -332,7 +351,7 @@ function foldPath(p) {
|
|
|
332
351
|
}
|
|
333
352
|
function statSize(absPath) {
|
|
334
353
|
try {
|
|
335
|
-
const st =
|
|
354
|
+
const st = statSync3(absPath);
|
|
336
355
|
return st.isFile() ? st.size : null;
|
|
337
356
|
} catch {
|
|
338
357
|
return null;
|
|
@@ -426,7 +445,7 @@ function atomicWriteCore(dest, content) {
|
|
|
426
445
|
closeSync(fd);
|
|
427
446
|
}
|
|
428
447
|
try {
|
|
429
|
-
const destMode =
|
|
448
|
+
const destMode = statSync3(dest).mode;
|
|
430
449
|
chmodSync2(tmp, destMode);
|
|
431
450
|
} catch (e) {
|
|
432
451
|
if (e.code !== "ENOENT") throw e;
|
|
@@ -550,7 +569,7 @@ function withFileLock(lockPath, fn, opts = {}) {
|
|
|
550
569
|
}
|
|
551
570
|
let stale;
|
|
552
571
|
try {
|
|
553
|
-
const st =
|
|
572
|
+
const st = statSync3(lockPath);
|
|
554
573
|
stale = Date.now() - st.mtimeMs > staleMs;
|
|
555
574
|
} catch {
|
|
556
575
|
stale = true;
|
|
@@ -746,6 +765,11 @@ function countNoun(count, singular, plural = `${singular}s`) {
|
|
|
746
765
|
function excludeTestsHiddenNote(count) {
|
|
747
766
|
return `${count} in test ${count === 1 ? "file" : "files"} hidden by --exclude-tests`;
|
|
748
767
|
}
|
|
768
|
+
function countContentLines(content) {
|
|
769
|
+
if (content === "") return 0;
|
|
770
|
+
const n = content.split("\n").length;
|
|
771
|
+
return content.endsWith("\n") ? n - 1 : n;
|
|
772
|
+
}
|
|
749
773
|
function escapeRegExp(s) {
|
|
750
774
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
751
775
|
}
|
|
@@ -935,6 +959,72 @@ function packageNameDistance(a, b, cap = 3) {
|
|
|
935
959
|
function suggestPackageNames(query, names) {
|
|
936
960
|
return [...new Set(names)].map((n) => ({ n, d: packageNameDistance(query.toLowerCase(), n.toLowerCase()) })).filter((x) => x.d <= 3).sort((a, b) => a.d - b.d).slice(0, 5).map((x) => x.n);
|
|
937
961
|
}
|
|
962
|
+
function detectSourceEncoding(buf) {
|
|
963
|
+
if (buf.length >= 4) {
|
|
964
|
+
if (buf[0] === 255 && buf[1] === 254 && buf[2] === 0 && buf[3] === 0) return "utf32le";
|
|
965
|
+
if (buf[0] === 0 && buf[1] === 0 && buf[2] === 254 && buf[3] === 255) return "utf32be";
|
|
966
|
+
}
|
|
967
|
+
if (buf.length >= 2) {
|
|
968
|
+
if (buf[0] === 255 && buf[1] === 254) return "utf16le";
|
|
969
|
+
if (buf[0] === 254 && buf[1] === 255) return "utf16be";
|
|
970
|
+
}
|
|
971
|
+
if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) return "utf8-bom";
|
|
972
|
+
return "utf8";
|
|
973
|
+
}
|
|
974
|
+
function decodeSource(buf) {
|
|
975
|
+
switch (detectSourceEncoding(buf)) {
|
|
976
|
+
case "utf32le":
|
|
977
|
+
return decodeUtf32(buf.subarray(4), true);
|
|
978
|
+
case "utf32be":
|
|
979
|
+
return decodeUtf32(buf.subarray(4), false);
|
|
980
|
+
case "utf16le":
|
|
981
|
+
return buf.subarray(2).toString("utf16le");
|
|
982
|
+
case "utf16be":
|
|
983
|
+
return swap16(buf.subarray(2)).toString("utf16le");
|
|
984
|
+
case "utf8-bom":
|
|
985
|
+
return buf.subarray(3).toString("utf8");
|
|
986
|
+
default:
|
|
987
|
+
return buf.toString("utf8");
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
function encodeSource(text, encoding) {
|
|
991
|
+
switch (encoding) {
|
|
992
|
+
case "utf32le":
|
|
993
|
+
return Buffer.concat([Buffer.from([255, 254, 0, 0]), encodeUtf32(text, true)]);
|
|
994
|
+
case "utf32be":
|
|
995
|
+
return Buffer.concat([Buffer.from([0, 0, 254, 255]), encodeUtf32(text, false)]);
|
|
996
|
+
case "utf16le":
|
|
997
|
+
return Buffer.concat([Buffer.from([255, 254]), Buffer.from(text, "utf16le")]);
|
|
998
|
+
case "utf16be":
|
|
999
|
+
return Buffer.concat([Buffer.from([254, 255]), swap16(Buffer.from(text, "utf16le"))]);
|
|
1000
|
+
case "utf8-bom":
|
|
1001
|
+
return Buffer.concat([Buffer.from([239, 187, 191]), Buffer.from(text, "utf8")]);
|
|
1002
|
+
default:
|
|
1003
|
+
return Buffer.from(text, "utf8");
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
function swap16(buf) {
|
|
1007
|
+
const out = Buffer.from(buf);
|
|
1008
|
+
return out.subarray(0, out.length - out.length % 2).swap16();
|
|
1009
|
+
}
|
|
1010
|
+
function decodeUtf32(buf, littleEndian) {
|
|
1011
|
+
const points = [];
|
|
1012
|
+
for (let i = 0; i + 4 <= buf.length; i += 4) {
|
|
1013
|
+
const cp = littleEndian ? buf.readUInt32LE(i) : buf.readUInt32BE(i);
|
|
1014
|
+
points.push(cp > 1114111 || cp >= 55296 && cp <= 57343 ? 65533 : cp);
|
|
1015
|
+
}
|
|
1016
|
+
return String.fromCodePoint(...points);
|
|
1017
|
+
}
|
|
1018
|
+
function encodeUtf32(text, littleEndian) {
|
|
1019
|
+
const points = [...text];
|
|
1020
|
+
const out = Buffer.alloc(points.length * 4);
|
|
1021
|
+
points.forEach((ch, i) => {
|
|
1022
|
+
const cp = ch.codePointAt(0) ?? 65533;
|
|
1023
|
+
if (littleEndian) out.writeUInt32LE(cp, i * 4);
|
|
1024
|
+
else out.writeUInt32BE(cp, i * 4);
|
|
1025
|
+
});
|
|
1026
|
+
return out;
|
|
1027
|
+
}
|
|
938
1028
|
|
|
939
1029
|
// src/project.ts
|
|
940
1030
|
import * as fs4 from "node:fs";
|
|
@@ -1285,57 +1375,111 @@ ${codeblock}`, options);
|
|
|
1285
1375
|
}
|
|
1286
1376
|
};
|
|
1287
1377
|
|
|
1378
|
+
// node_modules/smol-toml/dist/util.js
|
|
1379
|
+
function indexOfNewline(str, start = 0) {
|
|
1380
|
+
let idx = str.indexOf("\n", start);
|
|
1381
|
+
if (str.charCodeAt(idx - 1) === 13)
|
|
1382
|
+
idx--;
|
|
1383
|
+
return idx;
|
|
1384
|
+
}
|
|
1385
|
+
function skipComment(ctx) {
|
|
1386
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1387
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1388
|
+
if (c === 10)
|
|
1389
|
+
break;
|
|
1390
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
1391
|
+
ctx.p++;
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
1395
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
1396
|
+
toml: ctx.s,
|
|
1397
|
+
ptr: ctx.p
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
1403
|
+
let c;
|
|
1404
|
+
while (1) {
|
|
1405
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
1406
|
+
ctx.p++;
|
|
1407
|
+
if (banComments || c !== 35)
|
|
1408
|
+
break;
|
|
1409
|
+
skipComment(ctx);
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
function skipUntil(ctx, sep, end) {
|
|
1413
|
+
let ptr = ctx.p;
|
|
1414
|
+
if (!end) {
|
|
1415
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
1416
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
1417
|
+
return;
|
|
1418
|
+
}
|
|
1419
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1420
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1421
|
+
if (c === 35) {
|
|
1422
|
+
skipComment(ctx);
|
|
1423
|
+
} else if (c === end || c === sep) {
|
|
1424
|
+
return;
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
throw new TomlError("cannot find end of structure", {
|
|
1428
|
+
toml: ctx.s,
|
|
1429
|
+
ptr
|
|
1430
|
+
});
|
|
1431
|
+
}
|
|
1432
|
+
|
|
1288
1433
|
// node_modules/smol-toml/dist/primitive.js
|
|
1289
1434
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
1290
1435
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
1291
1436
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
1292
|
-
function parseString(
|
|
1293
|
-
let
|
|
1437
|
+
function parseString(ctx) {
|
|
1438
|
+
let start = ctx.p;
|
|
1439
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
1294
1440
|
let first = c;
|
|
1295
|
-
let isLiteral = c ===
|
|
1296
|
-
let isMultiline = c ===
|
|
1441
|
+
let isLiteral = c === 39;
|
|
1442
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
1297
1443
|
if (isMultiline) {
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1300
|
-
else if (
|
|
1301
|
-
|
|
1444
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
1445
|
+
ctx.p++;
|
|
1446
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
1447
|
+
ctx.p += 2;
|
|
1302
1448
|
}
|
|
1303
1449
|
let parsed = "";
|
|
1304
|
-
let sliceStart =
|
|
1450
|
+
let sliceStart = ctx.p;
|
|
1305
1451
|
let state = 0;
|
|
1306
|
-
for (
|
|
1307
|
-
c =
|
|
1308
|
-
if (isMultiline && (c ===
|
|
1452
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1453
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
1454
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
1309
1455
|
state = state && 3;
|
|
1310
|
-
} else if (c <
|
|
1456
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
1311
1457
|
throw new TomlError("control characters are not allowed in strings", {
|
|
1312
|
-
toml:
|
|
1313
|
-
ptr:
|
|
1458
|
+
toml: ctx.s,
|
|
1459
|
+
ptr: ctx.p
|
|
1314
1460
|
});
|
|
1315
|
-
} else if ((!state || state === 3) && c === first && (!isMultiline ||
|
|
1461
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
1316
1462
|
if (isMultiline) {
|
|
1317
|
-
if (
|
|
1318
|
-
|
|
1319
|
-
if (
|
|
1320
|
-
|
|
1463
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1464
|
+
ctx.p++;
|
|
1465
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1466
|
+
ctx.p++;
|
|
1321
1467
|
}
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
i + (isMultiline ? 3 : 1)
|
|
1327
|
-
];
|
|
1468
|
+
if (!state)
|
|
1469
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
1470
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
1471
|
+
return parsed;
|
|
1328
1472
|
} else if (!state) {
|
|
1329
|
-
if (!isLiteral && c ===
|
|
1330
|
-
parsed +=
|
|
1473
|
+
if (!isLiteral && c === 92) {
|
|
1474
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
1331
1475
|
state = 1;
|
|
1332
1476
|
}
|
|
1333
1477
|
} else if (state === 1) {
|
|
1334
|
-
if (c ===
|
|
1478
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
1335
1479
|
let value = 0;
|
|
1336
|
-
let len = c ===
|
|
1337
|
-
for (let j = 0; j < len; j++,
|
|
1338
|
-
let hex =
|
|
1480
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
1481
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
1482
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
1339
1483
|
let digit = (
|
|
1340
1484
|
/* 0-9 */
|
|
1341
1485
|
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
@@ -1347,57 +1491,68 @@ function parseString(str, ptr) {
|
|
|
1347
1491
|
)
|
|
1348
1492
|
);
|
|
1349
1493
|
if (digit < 0)
|
|
1350
|
-
throw new TomlError("invalid non-hex character in unicode escape", { toml:
|
|
1494
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
1351
1495
|
value = value << 4 | digit;
|
|
1352
1496
|
}
|
|
1353
1497
|
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
1354
|
-
throw new TomlError("invalid unicode escape", { toml:
|
|
1498
|
+
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
1355
1499
|
}
|
|
1356
1500
|
parsed += String.fromCodePoint(value);
|
|
1357
|
-
sliceStart =
|
|
1501
|
+
sliceStart = ctx.p + 1;
|
|
1358
1502
|
state = 0;
|
|
1359
|
-
} else if (c ===
|
|
1503
|
+
} else if (c === 32 || c === 9) {
|
|
1360
1504
|
state = 2;
|
|
1361
1505
|
} else {
|
|
1362
|
-
if (c ===
|
|
1506
|
+
if (c === 98)
|
|
1363
1507
|
parsed += "\b";
|
|
1364
|
-
else if (c ===
|
|
1508
|
+
else if (c === 116)
|
|
1365
1509
|
parsed += " ";
|
|
1366
|
-
else if (c ===
|
|
1510
|
+
else if (c === 110)
|
|
1367
1511
|
parsed += "\n";
|
|
1368
|
-
else if (c ===
|
|
1512
|
+
else if (c === 102)
|
|
1369
1513
|
parsed += "\f";
|
|
1370
|
-
else if (c ===
|
|
1514
|
+
else if (c === 114)
|
|
1371
1515
|
parsed += "\r";
|
|
1372
|
-
else if (c ===
|
|
1516
|
+
else if (c === 101)
|
|
1373
1517
|
parsed += "\x1B";
|
|
1374
|
-
else if (c ===
|
|
1518
|
+
else if (c === 34)
|
|
1375
1519
|
parsed += '"';
|
|
1376
|
-
else if (c ===
|
|
1520
|
+
else if (c === 92)
|
|
1377
1521
|
parsed += "\\";
|
|
1378
1522
|
else
|
|
1379
|
-
throw new TomlError("unrecognized escape sequence", { toml:
|
|
1380
|
-
sliceStart =
|
|
1523
|
+
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
1524
|
+
sliceStart = ctx.p + 1;
|
|
1381
1525
|
state = 0;
|
|
1382
1526
|
}
|
|
1383
|
-
} else if (c !==
|
|
1527
|
+
} else if (c !== 32 && c !== 9) {
|
|
1384
1528
|
if (state === 2) {
|
|
1385
1529
|
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
1386
|
-
toml:
|
|
1530
|
+
toml: ctx.s,
|
|
1387
1531
|
ptr: sliceStart
|
|
1388
1532
|
});
|
|
1389
1533
|
}
|
|
1390
|
-
state = !isLiteral && c ===
|
|
1391
|
-
sliceStart =
|
|
1534
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
1535
|
+
sliceStart = ctx.p;
|
|
1392
1536
|
}
|
|
1393
1537
|
}
|
|
1394
|
-
throw new TomlError("unfinished string", { toml:
|
|
1538
|
+
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
1395
1539
|
}
|
|
1396
|
-
function
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1540
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
1541
|
+
let value = ctx.s.slice(start, end);
|
|
1542
|
+
let commentIdx = value.indexOf("#");
|
|
1543
|
+
if (commentIdx > 0) {
|
|
1544
|
+
skipComment({ s: value, p: commentIdx, d: 0 });
|
|
1545
|
+
value = value.slice(0, commentIdx);
|
|
1546
|
+
}
|
|
1547
|
+
return value.trimEnd();
|
|
1548
|
+
}
|
|
1549
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
1550
|
+
let ptr = ctx.p;
|
|
1551
|
+
let err = { toml: ctx.s, ptr };
|
|
1552
|
+
skipUntil(ctx, 44, end);
|
|
1553
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
1554
|
+
if (!value)
|
|
1555
|
+
throw new TomlError("incomplete declaration: value expected", err);
|
|
1401
1556
|
if (value === "-inf")
|
|
1402
1557
|
return -Infinity;
|
|
1403
1558
|
if (value === "inf" || value === "+inf")
|
|
@@ -1409,25 +1564,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1409
1564
|
let isInt = INT_REGEX.test(value);
|
|
1410
1565
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
1411
1566
|
if (LEADING_ZERO.test(value)) {
|
|
1412
|
-
throw new TomlError("leading zeroes are not allowed",
|
|
1413
|
-
toml,
|
|
1414
|
-
ptr
|
|
1415
|
-
});
|
|
1567
|
+
throw new TomlError("leading zeroes are not allowed", err);
|
|
1416
1568
|
}
|
|
1417
1569
|
value = value.replace(/_/g, "");
|
|
1418
1570
|
let numeric = +value;
|
|
1419
1571
|
if (isNaN(numeric)) {
|
|
1420
|
-
throw new TomlError("invalid number",
|
|
1421
|
-
toml,
|
|
1422
|
-
ptr
|
|
1423
|
-
});
|
|
1572
|
+
throw new TomlError("invalid number", err);
|
|
1424
1573
|
}
|
|
1425
1574
|
if (isInt) {
|
|
1426
1575
|
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
1427
|
-
throw new TomlError("integer value cannot be represented losslessly",
|
|
1428
|
-
toml,
|
|
1429
|
-
ptr
|
|
1430
|
-
});
|
|
1576
|
+
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
1431
1577
|
}
|
|
1432
1578
|
if (isInt || integersAsBigInt === true)
|
|
1433
1579
|
numeric = BigInt(value);
|
|
@@ -1435,277 +1581,184 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1435
1581
|
return numeric;
|
|
1436
1582
|
}
|
|
1437
1583
|
const date = new TomlDate(value);
|
|
1438
|
-
if (!date.isValid())
|
|
1439
|
-
throw new TomlError("invalid value",
|
|
1440
|
-
toml,
|
|
1441
|
-
ptr
|
|
1442
|
-
});
|
|
1443
|
-
}
|
|
1584
|
+
if (!date.isValid())
|
|
1585
|
+
throw new TomlError("invalid value", err);
|
|
1444
1586
|
return date;
|
|
1445
1587
|
}
|
|
1446
1588
|
|
|
1447
|
-
// node_modules/smol-toml/dist/
|
|
1448
|
-
function
|
|
1449
|
-
let
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1456
|
-
let c = str[i];
|
|
1457
|
-
if (c === "\n")
|
|
1458
|
-
return i;
|
|
1459
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
1460
|
-
return i + 1;
|
|
1461
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
1462
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
1463
|
-
toml: str,
|
|
1589
|
+
// node_modules/smol-toml/dist/extract.js
|
|
1590
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
1591
|
+
let ptr = ctx.p;
|
|
1592
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
1593
|
+
if (c === 91 || c === 123) {
|
|
1594
|
+
if (!ctx.d--) {
|
|
1595
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
1596
|
+
toml: ctx.s,
|
|
1464
1597
|
ptr
|
|
1465
1598
|
});
|
|
1466
1599
|
}
|
|
1600
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
1601
|
+
ctx.d++;
|
|
1602
|
+
return value;
|
|
1467
1603
|
}
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
1471
|
-
let c;
|
|
1472
|
-
while (1) {
|
|
1473
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
1474
|
-
ptr++;
|
|
1475
|
-
if (banComments || c !== "#")
|
|
1476
|
-
break;
|
|
1477
|
-
ptr = skipComment(str, ptr);
|
|
1478
|
-
}
|
|
1479
|
-
return ptr;
|
|
1480
|
-
}
|
|
1481
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
1482
|
-
if (!end) {
|
|
1483
|
-
ptr = indexOfNewline(str, ptr);
|
|
1484
|
-
return ptr < 0 ? str.length : ptr;
|
|
1485
|
-
}
|
|
1486
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1487
|
-
let c = str[i];
|
|
1488
|
-
if (c === "#") {
|
|
1489
|
-
i = indexOfNewline(str, i);
|
|
1490
|
-
} else if (c === sep) {
|
|
1491
|
-
return i + 1;
|
|
1492
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
1493
|
-
return i;
|
|
1494
|
-
}
|
|
1495
|
-
}
|
|
1496
|
-
throw new TomlError("cannot find end of structure", {
|
|
1497
|
-
toml: str,
|
|
1498
|
-
ptr
|
|
1499
|
-
});
|
|
1500
|
-
}
|
|
1501
|
-
|
|
1502
|
-
// node_modules/smol-toml/dist/extract.js
|
|
1503
|
-
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
1504
|
-
let value = str.slice(startPtr, endPtr);
|
|
1505
|
-
let commentIdx = value.indexOf("#");
|
|
1506
|
-
if (commentIdx > -1) {
|
|
1507
|
-
skipComment(str, commentIdx);
|
|
1508
|
-
value = value.slice(0, commentIdx);
|
|
1604
|
+
if (c === 34 || c === 39) {
|
|
1605
|
+
return parseString(ctx);
|
|
1509
1606
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
toml: str,
|
|
1516
|
-
ptr
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
let c = str[ptr];
|
|
1520
|
-
if (c === "[" || c === "{") {
|
|
1521
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
1522
|
-
if (end) {
|
|
1523
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1524
|
-
if (str[endPtr2] === ",")
|
|
1525
|
-
endPtr2++;
|
|
1526
|
-
else if (str[endPtr2] !== end) {
|
|
1527
|
-
throw new TomlError("expected comma or end of structure", {
|
|
1528
|
-
toml: str,
|
|
1529
|
-
ptr: endPtr2
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
return [value, endPtr2];
|
|
1534
|
-
}
|
|
1535
|
-
if (c === '"' || c === "'") {
|
|
1536
|
-
let [parsed, endPtr2] = parseString(str, ptr);
|
|
1537
|
-
if (end) {
|
|
1538
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1539
|
-
if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
|
|
1540
|
-
throw new TomlError("unexpected character encountered", {
|
|
1541
|
-
toml: str,
|
|
1542
|
-
ptr: endPtr2
|
|
1543
|
-
});
|
|
1544
|
-
}
|
|
1545
|
-
if (str[endPtr2] === ",")
|
|
1546
|
-
endPtr2++;
|
|
1547
|
-
}
|
|
1548
|
-
return [parsed, endPtr2];
|
|
1549
|
-
}
|
|
1550
|
-
let endPtr = skipUntil(str, ptr, ",", end);
|
|
1551
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
|
|
1552
|
-
if (!slice[0]) {
|
|
1553
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
1554
|
-
toml: str,
|
|
1555
|
-
ptr
|
|
1556
|
-
});
|
|
1607
|
+
if (c === 116) {
|
|
1608
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1609
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1610
|
+
ctx.p++;
|
|
1611
|
+
return true;
|
|
1557
1612
|
}
|
|
1558
|
-
if (
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1613
|
+
if (c === 102) {
|
|
1614
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1615
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1616
|
+
ctx.p++;
|
|
1617
|
+
return false;
|
|
1562
1618
|
}
|
|
1563
|
-
return
|
|
1564
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
1565
|
-
endPtr
|
|
1566
|
-
];
|
|
1619
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
1567
1620
|
}
|
|
1568
1621
|
|
|
1569
1622
|
// node_modules/smol-toml/dist/struct.js
|
|
1570
1623
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1571
|
-
function parseKey(
|
|
1572
|
-
let
|
|
1624
|
+
function parseKey(ctx, end = "=") {
|
|
1625
|
+
let start = ctx.p;
|
|
1626
|
+
let dot = start - 1;
|
|
1573
1627
|
let parsed = [];
|
|
1574
|
-
let endPtr =
|
|
1628
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
1575
1629
|
if (endPtr < 0) {
|
|
1576
1630
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1577
|
-
toml:
|
|
1578
|
-
ptr
|
|
1631
|
+
toml: ctx.s,
|
|
1632
|
+
ptr: start
|
|
1579
1633
|
});
|
|
1580
1634
|
}
|
|
1581
1635
|
do {
|
|
1582
|
-
let c =
|
|
1583
|
-
if (c !==
|
|
1584
|
-
if (c ===
|
|
1585
|
-
if (c ===
|
|
1636
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
1637
|
+
if (c !== 32 && c !== 9) {
|
|
1638
|
+
if (c === 34 || c === 39) {
|
|
1639
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
1586
1640
|
throw new TomlError("multiline strings are not allowed in keys", {
|
|
1587
|
-
toml:
|
|
1588
|
-
ptr
|
|
1641
|
+
toml: ctx.s,
|
|
1642
|
+
ptr: ctx.p
|
|
1589
1643
|
});
|
|
1590
1644
|
}
|
|
1591
|
-
let
|
|
1592
|
-
dot =
|
|
1593
|
-
let strEnd =
|
|
1645
|
+
let part = parseString(ctx);
|
|
1646
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1647
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1594
1648
|
let newLine = indexOfNewline(strEnd);
|
|
1595
1649
|
if (newLine > -1) {
|
|
1596
1650
|
throw new TomlError("newlines are not allowed in keys", {
|
|
1597
|
-
toml:
|
|
1598
|
-
ptr:
|
|
1651
|
+
toml: ctx.s,
|
|
1652
|
+
ptr: newLine
|
|
1599
1653
|
});
|
|
1600
1654
|
}
|
|
1601
1655
|
if (strEnd.trimStart()) {
|
|
1602
1656
|
throw new TomlError("found extra tokens after the string part", {
|
|
1603
|
-
toml:
|
|
1604
|
-
ptr:
|
|
1657
|
+
toml: ctx.s,
|
|
1658
|
+
ptr: ctx.p
|
|
1605
1659
|
});
|
|
1606
1660
|
}
|
|
1607
|
-
if (endPtr <
|
|
1608
|
-
endPtr =
|
|
1661
|
+
if (endPtr < ctx.p) {
|
|
1662
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
1609
1663
|
if (endPtr < 0) {
|
|
1610
1664
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1611
|
-
toml:
|
|
1612
|
-
ptr
|
|
1665
|
+
toml: ctx.s,
|
|
1666
|
+
ptr: start
|
|
1613
1667
|
});
|
|
1614
1668
|
}
|
|
1615
1669
|
}
|
|
1616
1670
|
parsed.push(part);
|
|
1617
1671
|
} else {
|
|
1618
|
-
dot =
|
|
1619
|
-
let part =
|
|
1672
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1673
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1620
1674
|
if (!KEY_PART_RE.test(part)) {
|
|
1621
1675
|
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1622
|
-
toml:
|
|
1623
|
-
ptr
|
|
1676
|
+
toml: ctx.s,
|
|
1677
|
+
ptr: ctx.p
|
|
1624
1678
|
});
|
|
1625
1679
|
}
|
|
1626
1680
|
parsed.push(part.trimEnd());
|
|
1627
1681
|
}
|
|
1628
1682
|
}
|
|
1629
1683
|
} while (dot + 1 && dot < endPtr);
|
|
1630
|
-
|
|
1684
|
+
ctx.p = endPtr + 1;
|
|
1685
|
+
skipVoid(ctx, true, true);
|
|
1686
|
+
return parsed;
|
|
1631
1687
|
}
|
|
1632
|
-
function parseInlineTable(
|
|
1688
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
1633
1689
|
let res = {};
|
|
1634
1690
|
let seen = /* @__PURE__ */ new Set();
|
|
1635
1691
|
let c;
|
|
1636
|
-
|
|
1637
|
-
while (
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
k = key[i];
|
|
1654
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1655
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
1656
|
-
toml: str,
|
|
1657
|
-
ptr
|
|
1658
|
-
});
|
|
1659
|
-
}
|
|
1660
|
-
if (!hasOwn && k === "__proto__") {
|
|
1661
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
if (hasOwn) {
|
|
1692
|
+
ctx.p++;
|
|
1693
|
+
while (ctx.p < ctx.s.length) {
|
|
1694
|
+
skipVoid(ctx);
|
|
1695
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
1696
|
+
ctx.p++;
|
|
1697
|
+
return res;
|
|
1698
|
+
}
|
|
1699
|
+
let k;
|
|
1700
|
+
let t = res;
|
|
1701
|
+
let hasOwn = false;
|
|
1702
|
+
let p = ctx.p;
|
|
1703
|
+
let key = parseKey(ctx);
|
|
1704
|
+
for (let i = 0; i < key.length; i++) {
|
|
1705
|
+
if (i)
|
|
1706
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1707
|
+
k = key[i];
|
|
1708
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1665
1709
|
throw new TomlError("trying to redefine an already defined value", {
|
|
1666
|
-
toml:
|
|
1667
|
-
ptr
|
|
1710
|
+
toml: ctx.s,
|
|
1711
|
+
ptr: p
|
|
1668
1712
|
});
|
|
1669
1713
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1714
|
+
if (!hasOwn && k === "__proto__") {
|
|
1715
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
if (hasOwn) {
|
|
1719
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
1720
|
+
toml: ctx.s,
|
|
1721
|
+
ptr: ctx.p
|
|
1722
|
+
});
|
|
1723
|
+
}
|
|
1724
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
1725
|
+
seen.add(t[k] = value);
|
|
1726
|
+
skipVoid(ctx);
|
|
1727
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
1728
|
+
return res;
|
|
1729
|
+
}
|
|
1730
|
+
if (c !== 44) {
|
|
1731
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1674
1732
|
}
|
|
1675
1733
|
}
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
});
|
|
1681
|
-
}
|
|
1682
|
-
return [res, ptr];
|
|
1734
|
+
throw new TomlError("unfinished table encountered", {
|
|
1735
|
+
toml: ctx.s,
|
|
1736
|
+
ptr: ctx.p
|
|
1737
|
+
});
|
|
1683
1738
|
}
|
|
1684
|
-
function parseArray(
|
|
1739
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
1685
1740
|
let res = [];
|
|
1686
1741
|
let c;
|
|
1687
|
-
|
|
1688
|
-
while (
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
if (!c) {
|
|
1703
|
-
throw new TomlError("unfinished array encountered", {
|
|
1704
|
-
toml: str,
|
|
1705
|
-
ptr
|
|
1706
|
-
});
|
|
1742
|
+
ctx.p++;
|
|
1743
|
+
while (ctx.p < ctx.s.length) {
|
|
1744
|
+
skipVoid(ctx);
|
|
1745
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
1746
|
+
ctx.p++;
|
|
1747
|
+
return res;
|
|
1748
|
+
}
|
|
1749
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
1750
|
+
skipVoid(ctx);
|
|
1751
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
1752
|
+
return res;
|
|
1753
|
+
}
|
|
1754
|
+
if (c !== 44) {
|
|
1755
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1756
|
+
}
|
|
1707
1757
|
}
|
|
1708
|
-
|
|
1758
|
+
throw new TomlError("unfinished array encountered", {
|
|
1759
|
+
toml: ctx.s,
|
|
1760
|
+
ptr: ctx.p
|
|
1761
|
+
});
|
|
1709
1762
|
}
|
|
1710
1763
|
|
|
1711
1764
|
// node_modules/smol-toml/dist/parse.js
|
|
@@ -1769,25 +1822,29 @@ function peekTable(key, table, meta, type) {
|
|
|
1769
1822
|
return [k, t, state.c];
|
|
1770
1823
|
}
|
|
1771
1824
|
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
1825
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
1772
1826
|
let res = {};
|
|
1773
1827
|
let meta = {};
|
|
1828
|
+
let tmp;
|
|
1774
1829
|
let tbl = res;
|
|
1775
1830
|
let m = meta;
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
let
|
|
1831
|
+
skipVoid(ctx);
|
|
1832
|
+
while (ctx.p < toml.length) {
|
|
1833
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
1834
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
1835
|
+
tmp = ctx.p += +isTableArray;
|
|
1836
|
+
let k = parseKey(ctx, "]");
|
|
1780
1837
|
if (isTableArray) {
|
|
1781
|
-
if (toml
|
|
1838
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
1782
1839
|
throw new TomlError("expected end of table declaration", {
|
|
1783
1840
|
toml,
|
|
1784
|
-
ptr:
|
|
1841
|
+
ptr: ctx.p - 1
|
|
1785
1842
|
});
|
|
1786
1843
|
}
|
|
1787
|
-
|
|
1844
|
+
ctx.p++;
|
|
1788
1845
|
}
|
|
1789
1846
|
let p = peekTable(
|
|
1790
|
-
k
|
|
1847
|
+
k,
|
|
1791
1848
|
res,
|
|
1792
1849
|
meta,
|
|
1793
1850
|
isTableArray ? 2 : 1
|
|
@@ -1796,16 +1853,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1796
1853
|
if (!p) {
|
|
1797
1854
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1798
1855
|
toml,
|
|
1799
|
-
ptr
|
|
1856
|
+
ptr: tmp
|
|
1800
1857
|
});
|
|
1801
1858
|
}
|
|
1802
1859
|
m = p[2];
|
|
1803
1860
|
tbl = p[1];
|
|
1804
|
-
ptr = k[1];
|
|
1805
1861
|
} else {
|
|
1806
|
-
|
|
1862
|
+
tmp = ctx.p;
|
|
1863
|
+
let k = parseKey(ctx);
|
|
1807
1864
|
let p = peekTable(
|
|
1808
|
-
k
|
|
1865
|
+
k,
|
|
1809
1866
|
tbl,
|
|
1810
1867
|
m,
|
|
1811
1868
|
0
|
|
@@ -1814,21 +1871,19 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1814
1871
|
if (!p) {
|
|
1815
1872
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1816
1873
|
toml,
|
|
1817
|
-
ptr
|
|
1874
|
+
ptr: tmp
|
|
1818
1875
|
});
|
|
1819
1876
|
}
|
|
1820
|
-
|
|
1821
|
-
p[1][p[0]] = v[0];
|
|
1822
|
-
ptr = v[1];
|
|
1877
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
1823
1878
|
}
|
|
1824
|
-
|
|
1825
|
-
if (toml
|
|
1879
|
+
skipVoid(ctx, true);
|
|
1880
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
1826
1881
|
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
1827
1882
|
toml,
|
|
1828
|
-
ptr
|
|
1883
|
+
ptr: ctx.p
|
|
1829
1884
|
});
|
|
1830
1885
|
}
|
|
1831
|
-
|
|
1886
|
+
skipVoid(ctx);
|
|
1832
1887
|
}
|
|
1833
1888
|
return res;
|
|
1834
1889
|
}
|
|
@@ -1840,8 +1895,12 @@ function extendedTypeOf(obj) {
|
|
|
1840
1895
|
if (type === "object") {
|
|
1841
1896
|
if (Array.isArray(obj))
|
|
1842
1897
|
return "array";
|
|
1843
|
-
if (obj instanceof Date)
|
|
1898
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
|
|
1844
1899
|
return "date";
|
|
1900
|
+
if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
1901
|
+
typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
|
|
1902
|
+
return "temporal";
|
|
1903
|
+
}
|
|
1845
1904
|
}
|
|
1846
1905
|
return type;
|
|
1847
1906
|
}
|
|
@@ -1855,38 +1914,42 @@ function isArrayOfTables(obj) {
|
|
|
1855
1914
|
function formatString(s) {
|
|
1856
1915
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
1857
1916
|
}
|
|
1917
|
+
function stringifyTemporal(temporal) {
|
|
1918
|
+
return temporal.toString({
|
|
1919
|
+
calendarName: "never",
|
|
1920
|
+
timeZoneName: "never"
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1858
1923
|
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
1859
1924
|
if (depth === 0) {
|
|
1860
1925
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
1861
1926
|
}
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
if (type === "array") {
|
|
1889
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
1927
|
+
switch (type) {
|
|
1928
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
1929
|
+
case "number":
|
|
1930
|
+
if (isNaN(val))
|
|
1931
|
+
return "nan";
|
|
1932
|
+
if (val === Infinity)
|
|
1933
|
+
return "inf";
|
|
1934
|
+
if (val === -Infinity)
|
|
1935
|
+
return "-inf";
|
|
1936
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
1937
|
+
return val.toFixed(1);
|
|
1938
|
+
case "bigint":
|
|
1939
|
+
case "boolean":
|
|
1940
|
+
return val.toString();
|
|
1941
|
+
case "string":
|
|
1942
|
+
return formatString(val);
|
|
1943
|
+
case "date":
|
|
1944
|
+
if (isNaN(val.getTime()))
|
|
1945
|
+
throw new TypeError("cannot serialize invalid date");
|
|
1946
|
+
return val.toISOString();
|
|
1947
|
+
case "object":
|
|
1948
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
1949
|
+
case "array":
|
|
1950
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
1951
|
+
case "temporal":
|
|
1952
|
+
return stringifyTemporal(val);
|
|
1890
1953
|
}
|
|
1891
1954
|
}
|
|
1892
1955
|
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
@@ -4108,7 +4171,7 @@ function propagateEndLinesToSymbols(symbols, sections) {
|
|
|
4108
4171
|
return sym;
|
|
4109
4172
|
});
|
|
4110
4173
|
}
|
|
4111
|
-
function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex) {
|
|
4174
|
+
function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex, lineCommentPrefix) {
|
|
4112
4175
|
let depth = 0;
|
|
4113
4176
|
let quote = null;
|
|
4114
4177
|
for (let i = openBraceIndex; i < content.length; i++) {
|
|
@@ -4121,6 +4184,10 @@ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex
|
|
|
4121
4184
|
if (ch === quote) quote = null;
|
|
4122
4185
|
continue;
|
|
4123
4186
|
}
|
|
4187
|
+
if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
|
|
4188
|
+
while (i < content.length && content[i] !== "\n") i++;
|
|
4189
|
+
continue;
|
|
4190
|
+
}
|
|
4124
4191
|
if (ch === '"' || ch === "'") {
|
|
4125
4192
|
quote = ch;
|
|
4126
4193
|
continue;
|
|
@@ -4147,7 +4214,7 @@ function extractIni(content, filePath) {
|
|
|
4147
4214
|
const sections = [];
|
|
4148
4215
|
const seen = /* @__PURE__ */ new Set();
|
|
4149
4216
|
const lines = content.split(/\r?\n/);
|
|
4150
|
-
const totalLines =
|
|
4217
|
+
const totalLines = countContentLines(content);
|
|
4151
4218
|
for (let i = 0; i < lines.length; i++) {
|
|
4152
4219
|
if (symbols.length >= MAX_SECTIONS) break;
|
|
4153
4220
|
const line = lines[i] ?? "";
|
|
@@ -5449,6 +5516,8 @@ var KIND_TO_SOURCE = {
|
|
|
5449
5516
|
json_outline: SOURCE_READ,
|
|
5450
5517
|
yaml_query: SOURCE_READ,
|
|
5451
5518
|
yaml_outline: SOURCE_READ,
|
|
5519
|
+
xml_query: SOURCE_READ,
|
|
5520
|
+
xml_outline: SOURCE_READ,
|
|
5452
5521
|
openapi_op: SOURCE_READ,
|
|
5453
5522
|
openapi_outline: SOURCE_READ,
|
|
5454
5523
|
zip_list: SOURCE_READ,
|
|
@@ -5534,6 +5603,8 @@ var COMMAND_KINDS = {
|
|
|
5534
5603
|
"json-outline": /* @__PURE__ */ new Set(["json_outline"]),
|
|
5535
5604
|
"yaml-query": /* @__PURE__ */ new Set(["yaml_query"]),
|
|
5536
5605
|
"yaml-outline": /* @__PURE__ */ new Set(["yaml_outline"]),
|
|
5606
|
+
"xml-query": /* @__PURE__ */ new Set(["xml_query"]),
|
|
5607
|
+
"xml-outline": /* @__PURE__ */ new Set(["xml_outline"]),
|
|
5537
5608
|
"openapi-op": /* @__PURE__ */ new Set(["openapi_op"]),
|
|
5538
5609
|
"openapi-outline": /* @__PURE__ */ new Set(["openapi_outline"]),
|
|
5539
5610
|
"zip-list": /* @__PURE__ */ new Set(["zip_list"]),
|
|
@@ -5868,13 +5939,42 @@ var SECRET_PATTERNS = [
|
|
|
5868
5939
|
// contain '_' and could otherwise partially match the classic pattern.
|
|
5869
5940
|
["github_token", /github_pat_[A-Za-z0-9_]{22,}/g],
|
|
5870
5941
|
["github_token", /gh[oprsu]_[A-Za-z0-9]{36,}/g],
|
|
5942
|
+
// xapp- is Slack's app-level token (Socket Mode), a bearer credential in its own right that
|
|
5943
|
+
// the xox[baprs]- prefix does not cover. It gets its own entry rather than joining the
|
|
5944
|
+
// alternation above because it needs the full segmented shape (xapp-<ver>-<app id>-<digits>-
|
|
5945
|
+
// <hex>) to be safe: a bare /xapp-[A-Za-z0-9-]+/ redacted ordinary identifiers like
|
|
5946
|
+
// "xapp-config" and the css class "xapp-container", mangling normal source. The xox* prefixes
|
|
5947
|
+
// are distinctive enough on their own; "xapp-" is not.
|
|
5871
5948
|
["slack_token", /xox[baprs]-[A-Za-z0-9-]+/g],
|
|
5949
|
+
["slack_token", /xapp-\d-[A-Za-z0-9]{6,}-\d{8,}-[A-Za-z0-9]{16,}/g],
|
|
5872
5950
|
// Matches the full block (BEGIN marker through its matching END marker), not just the
|
|
5873
5951
|
// header -- the actual secret material is the base64 body between them, so redacting only
|
|
5874
5952
|
// the header line would leave the key bytes themselves fully readable in the cached blob.
|
|
5875
|
-
// The
|
|
5876
|
-
//
|
|
5877
|
-
|
|
5953
|
+
// The body is lazy and additionally refuses to cross a following BEGIN marker. Both halves
|
|
5954
|
+
// matter. The laziness bounds a successful match at the very next END marker; the negative
|
|
5955
|
+
// lookahead bounds a *failing* one, because a BEGIN with no END of its own would otherwise
|
|
5956
|
+
// scan to end-of-input, and a blob full of such markers made the pass quadratic -- 6 ms, 20 ms
|
|
5957
|
+
// and 78 ms for 2000, 4000 and 8000 of them, four times the work for twice the input, the same
|
|
5958
|
+
// shape as the lookbehind incident described above. Private key blocks do not nest, so
|
|
5959
|
+
// refusing to cross a BEGIN costs nothing in correctness.
|
|
5960
|
+
// The algorithm and ` BLOCK` groups are backreferenced in the END marker rather than repeated,
|
|
5961
|
+
// so a BEGIN only ever pairs with its own END spelling. Written as two independent optional
|
|
5962
|
+
// groups, `BEGIN PGP PRIVATE KEY` would happily close on a distant `END RSA PRIVATE KEY BLOCK`
|
|
5963
|
+
// and redact everything in between. A non-participating group backreferences as the empty
|
|
5964
|
+
// string in JS, which is exactly what the unprefixed `BEGIN PRIVATE KEY` form needs.
|
|
5965
|
+
// The algorithm list covers every armored private-key header openssl, ssh-keygen and gpg
|
|
5966
|
+
// actually emit, not just the ones a first draft happened to think of. ENCRYPTED is the
|
|
5967
|
+
// PKCS#8 passphrase-protected form (`openssl genpkey -aes256`, `ssh-keygen -m PKCS8`) and is
|
|
5968
|
+
// the most common shape of all; DSA is legacy but still written verbatim; PGP carries the
|
|
5969
|
+
// ` BLOCK` suffix, which is why that suffix is optional here. All three used to fall through
|
|
5970
|
+
// to disk in full. An encrypted key is still key material: the passphrase can be attacked
|
|
5971
|
+
// offline once the bytes are cached, so it is redacted like any other.
|
|
5972
|
+
// PuTTY `.ppk` files are deliberately not matched. They have no END marker -- the private
|
|
5973
|
+
// section is a `Private-Lines: N` count followed by exactly N base64 lines -- so bounding a
|
|
5974
|
+
// match would take a stateful parse rather than a regex, on a path that runs over every
|
|
5975
|
+
// command output. A regex guess at where the body ends is exactly the over-eager match this
|
|
5976
|
+
// module's header warns against.
|
|
5977
|
+
["private_key_block", /-----BEGIN (RSA |DSA |EC |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY( BLOCK)?-----(?:(?!-----BEGIN )[\s\S])*?-----END \1PRIVATE KEY\2-----/g],
|
|
5878
5978
|
// Redacts only the token itself, not the "Authorization: Bearer " prefix -- the lookbehind
|
|
5879
5979
|
// anchors on the header name and scheme so the surrounding request-log line stays readable,
|
|
5880
5980
|
// matching how AWS_ACCESS_KEY_ID=... above keeps its own prefix intact.
|
|
@@ -6030,10 +6130,13 @@ export {
|
|
|
6030
6130
|
fingerprintContent,
|
|
6031
6131
|
shortFingerprint,
|
|
6032
6132
|
fingerprintFile,
|
|
6133
|
+
fileIsAbsent,
|
|
6033
6134
|
normalizePath,
|
|
6034
6135
|
normalizeDarwinSystemAlias,
|
|
6035
6136
|
resolveIndexPath,
|
|
6036
6137
|
toDisplayPath,
|
|
6138
|
+
displaySafeText,
|
|
6139
|
+
displaySafePath,
|
|
6037
6140
|
sleepSync,
|
|
6038
6141
|
isWindows,
|
|
6039
6142
|
isCaseInsensitiveFs,
|
|
@@ -6065,6 +6168,7 @@ export {
|
|
|
6065
6168
|
grepFilteredToEmptyNotice,
|
|
6066
6169
|
countNoun,
|
|
6067
6170
|
excludeTestsHiddenNote,
|
|
6171
|
+
countContentLines,
|
|
6068
6172
|
escapeRegExp,
|
|
6069
6173
|
windowsCmdQuoteArg,
|
|
6070
6174
|
redactUrlQuery,
|
|
@@ -6084,6 +6188,9 @@ export {
|
|
|
6084
6188
|
isWithinQuietHours,
|
|
6085
6189
|
hookCommandFor,
|
|
6086
6190
|
suggestPackageNames,
|
|
6191
|
+
detectSourceEncoding,
|
|
6192
|
+
decodeSource,
|
|
6193
|
+
encodeSource,
|
|
6087
6194
|
canonicalize,
|
|
6088
6195
|
makeProjectAt,
|
|
6089
6196
|
findProject,
|
|
@@ -6156,8 +6263,8 @@ export {
|
|
|
6156
6263
|
|
|
6157
6264
|
smol-toml/dist/date.js:
|
|
6158
6265
|
smol-toml/dist/error.js:
|
|
6159
|
-
smol-toml/dist/primitive.js:
|
|
6160
6266
|
smol-toml/dist/util.js:
|
|
6267
|
+
smol-toml/dist/primitive.js:
|
|
6161
6268
|
smol-toml/dist/extract.js:
|
|
6162
6269
|
smol-toml/dist/struct.js:
|
|
6163
6270
|
smol-toml/dist/parse.js:
|