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");
|
|
@@ -288,6 +288,18 @@ function safeJoin(base, ...parts) {
|
|
|
288
288
|
}
|
|
289
289
|
return path2.join(base, ...parts);
|
|
290
290
|
}
|
|
291
|
+
function displaySafeText(text) {
|
|
292
|
+
return text.replace(new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u2028\\u2029]|\\p{Cf}", "gu"), (ch) => {
|
|
293
|
+
if (ch === "\n") return "\\n";
|
|
294
|
+
if (ch === "\r") return "\\r";
|
|
295
|
+
if (ch === " ") return "\\t";
|
|
296
|
+
const code = ch.codePointAt(0) ?? 0;
|
|
297
|
+
return code <= 255 ? "\\x" + code.toString(16).padStart(2, "0") : "\\u" + code.toString(16).padStart(4, "0");
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
function displaySafePath(p) {
|
|
301
|
+
return displaySafeText(p);
|
|
302
|
+
}
|
|
291
303
|
|
|
292
304
|
// src/util.ts
|
|
293
305
|
import { spawn, spawnSync } from "node:child_process";
|
|
@@ -725,6 +737,11 @@ function countNoun(count, singular, plural = `${singular}s`) {
|
|
|
725
737
|
function excludeTestsHiddenNote(count) {
|
|
726
738
|
return `${count} in test ${count === 1 ? "file" : "files"} hidden by --exclude-tests`;
|
|
727
739
|
}
|
|
740
|
+
function countContentLines(content) {
|
|
741
|
+
if (content === "") return 0;
|
|
742
|
+
const n = content.split("\n").length;
|
|
743
|
+
return content.endsWith("\n") ? n - 1 : n;
|
|
744
|
+
}
|
|
728
745
|
function escapeRegExp(s) {
|
|
729
746
|
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
730
747
|
}
|
|
@@ -901,6 +918,72 @@ function packageNameDistance(a, b, cap = 3) {
|
|
|
901
918
|
function suggestPackageNames(query, names) {
|
|
902
919
|
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);
|
|
903
920
|
}
|
|
921
|
+
function detectSourceEncoding(buf) {
|
|
922
|
+
if (buf.length >= 4) {
|
|
923
|
+
if (buf[0] === 255 && buf[1] === 254 && buf[2] === 0 && buf[3] === 0) return "utf32le";
|
|
924
|
+
if (buf[0] === 0 && buf[1] === 0 && buf[2] === 254 && buf[3] === 255) return "utf32be";
|
|
925
|
+
}
|
|
926
|
+
if (buf.length >= 2) {
|
|
927
|
+
if (buf[0] === 255 && buf[1] === 254) return "utf16le";
|
|
928
|
+
if (buf[0] === 254 && buf[1] === 255) return "utf16be";
|
|
929
|
+
}
|
|
930
|
+
if (buf.length >= 3 && buf[0] === 239 && buf[1] === 187 && buf[2] === 191) return "utf8-bom";
|
|
931
|
+
return "utf8";
|
|
932
|
+
}
|
|
933
|
+
function decodeSource(buf) {
|
|
934
|
+
switch (detectSourceEncoding(buf)) {
|
|
935
|
+
case "utf32le":
|
|
936
|
+
return decodeUtf32(buf.subarray(4), true);
|
|
937
|
+
case "utf32be":
|
|
938
|
+
return decodeUtf32(buf.subarray(4), false);
|
|
939
|
+
case "utf16le":
|
|
940
|
+
return buf.subarray(2).toString("utf16le");
|
|
941
|
+
case "utf16be":
|
|
942
|
+
return swap16(buf.subarray(2)).toString("utf16le");
|
|
943
|
+
case "utf8-bom":
|
|
944
|
+
return buf.subarray(3).toString("utf8");
|
|
945
|
+
default:
|
|
946
|
+
return buf.toString("utf8");
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
function encodeSource(text, encoding) {
|
|
950
|
+
switch (encoding) {
|
|
951
|
+
case "utf32le":
|
|
952
|
+
return Buffer.concat([Buffer.from([255, 254, 0, 0]), encodeUtf32(text, true)]);
|
|
953
|
+
case "utf32be":
|
|
954
|
+
return Buffer.concat([Buffer.from([0, 0, 254, 255]), encodeUtf32(text, false)]);
|
|
955
|
+
case "utf16le":
|
|
956
|
+
return Buffer.concat([Buffer.from([255, 254]), Buffer.from(text, "utf16le")]);
|
|
957
|
+
case "utf16be":
|
|
958
|
+
return Buffer.concat([Buffer.from([254, 255]), swap16(Buffer.from(text, "utf16le"))]);
|
|
959
|
+
case "utf8-bom":
|
|
960
|
+
return Buffer.concat([Buffer.from([239, 187, 191]), Buffer.from(text, "utf8")]);
|
|
961
|
+
default:
|
|
962
|
+
return Buffer.from(text, "utf8");
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
function swap16(buf) {
|
|
966
|
+
const out = Buffer.from(buf);
|
|
967
|
+
return out.subarray(0, out.length - out.length % 2).swap16();
|
|
968
|
+
}
|
|
969
|
+
function decodeUtf32(buf, littleEndian) {
|
|
970
|
+
const points = [];
|
|
971
|
+
for (let i = 0; i + 4 <= buf.length; i += 4) {
|
|
972
|
+
const cp = littleEndian ? buf.readUInt32LE(i) : buf.readUInt32BE(i);
|
|
973
|
+
points.push(cp > 1114111 || cp >= 55296 && cp <= 57343 ? 65533 : cp);
|
|
974
|
+
}
|
|
975
|
+
return String.fromCodePoint(...points);
|
|
976
|
+
}
|
|
977
|
+
function encodeUtf32(text, littleEndian) {
|
|
978
|
+
const points = [...text];
|
|
979
|
+
const out = Buffer.alloc(points.length * 4);
|
|
980
|
+
points.forEach((ch, i) => {
|
|
981
|
+
const cp = ch.codePointAt(0) ?? 65533;
|
|
982
|
+
if (littleEndian) out.writeUInt32LE(cp, i * 4);
|
|
983
|
+
else out.writeUInt32BE(cp, i * 4);
|
|
984
|
+
});
|
|
985
|
+
return out;
|
|
986
|
+
}
|
|
904
987
|
|
|
905
988
|
// src/fingerprint.ts
|
|
906
989
|
import { createHash } from "node:crypto";
|
|
@@ -922,6 +1005,13 @@ function fingerprintFile(filePath) {
|
|
|
922
1005
|
}
|
|
923
1006
|
return fingerprintContent(data);
|
|
924
1007
|
}
|
|
1008
|
+
function fileIsAbsent(filePath) {
|
|
1009
|
+
try {
|
|
1010
|
+
return fs3.statSync(filePath, { throwIfNoEntry: false }) === void 0;
|
|
1011
|
+
} catch {
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
925
1015
|
|
|
926
1016
|
// src/project.ts
|
|
927
1017
|
import * as fs4 from "node:fs";
|
|
@@ -1272,57 +1362,111 @@ ${codeblock}`, options);
|
|
|
1272
1362
|
}
|
|
1273
1363
|
};
|
|
1274
1364
|
|
|
1365
|
+
// node_modules/smol-toml/dist/util.js
|
|
1366
|
+
function indexOfNewline(str, start = 0) {
|
|
1367
|
+
let idx = str.indexOf("\n", start);
|
|
1368
|
+
if (str.charCodeAt(idx - 1) === 13)
|
|
1369
|
+
idx--;
|
|
1370
|
+
return idx;
|
|
1371
|
+
}
|
|
1372
|
+
function skipComment(ctx) {
|
|
1373
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1374
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1375
|
+
if (c === 10)
|
|
1376
|
+
break;
|
|
1377
|
+
if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
1378
|
+
ctx.p++;
|
|
1379
|
+
break;
|
|
1380
|
+
}
|
|
1381
|
+
if (c < 32 && c !== 9 || c === 127) {
|
|
1382
|
+
throw new TomlError("control characters are not allowed in comments", {
|
|
1383
|
+
toml: ctx.s,
|
|
1384
|
+
ptr: ctx.p
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
1390
|
+
let c;
|
|
1391
|
+
while (1) {
|
|
1392
|
+
while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10))
|
|
1393
|
+
ctx.p++;
|
|
1394
|
+
if (banComments || c !== 35)
|
|
1395
|
+
break;
|
|
1396
|
+
skipComment(ctx);
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
function skipUntil(ctx, sep, end) {
|
|
1400
|
+
let ptr = ctx.p;
|
|
1401
|
+
if (!end) {
|
|
1402
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
1403
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
1404
|
+
return;
|
|
1405
|
+
}
|
|
1406
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1407
|
+
let c = ctx.s.charCodeAt(ctx.p);
|
|
1408
|
+
if (c === 35) {
|
|
1409
|
+
skipComment(ctx);
|
|
1410
|
+
} else if (c === end || c === sep) {
|
|
1411
|
+
return;
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
throw new TomlError("cannot find end of structure", {
|
|
1415
|
+
toml: ctx.s,
|
|
1416
|
+
ptr
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1275
1420
|
// node_modules/smol-toml/dist/primitive.js
|
|
1276
1421
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
1277
1422
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
1278
1423
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
1279
|
-
function parseString(
|
|
1280
|
-
let
|
|
1424
|
+
function parseString(ctx) {
|
|
1425
|
+
let start = ctx.p;
|
|
1426
|
+
let c = ctx.s.charCodeAt(ctx.p++);
|
|
1281
1427
|
let first = c;
|
|
1282
|
-
let isLiteral = c ===
|
|
1283
|
-
let isMultiline = c ===
|
|
1428
|
+
let isLiteral = c === 39;
|
|
1429
|
+
let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
|
|
1284
1430
|
if (isMultiline) {
|
|
1285
|
-
if (
|
|
1286
|
-
|
|
1287
|
-
else if (
|
|
1288
|
-
|
|
1431
|
+
if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10)
|
|
1432
|
+
ctx.p++;
|
|
1433
|
+
else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)
|
|
1434
|
+
ctx.p += 2;
|
|
1289
1435
|
}
|
|
1290
1436
|
let parsed = "";
|
|
1291
|
-
let sliceStart =
|
|
1437
|
+
let sliceStart = ctx.p;
|
|
1292
1438
|
let state = 0;
|
|
1293
|
-
for (
|
|
1294
|
-
c =
|
|
1295
|
-
if (isMultiline && (c ===
|
|
1439
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1440
|
+
c = ctx.s.charCodeAt(ctx.p);
|
|
1441
|
+
if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) {
|
|
1296
1442
|
state = state && 3;
|
|
1297
|
-
} else if (c <
|
|
1443
|
+
} else if (c < 32 && c !== 9 || c === 127) {
|
|
1298
1444
|
throw new TomlError("control characters are not allowed in strings", {
|
|
1299
|
-
toml:
|
|
1300
|
-
ptr:
|
|
1445
|
+
toml: ctx.s,
|
|
1446
|
+
ptr: ctx.p
|
|
1301
1447
|
});
|
|
1302
|
-
} else if ((!state || state === 3) && c === first && (!isMultiline ||
|
|
1448
|
+
} else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
1303
1449
|
if (isMultiline) {
|
|
1304
|
-
if (
|
|
1305
|
-
|
|
1306
|
-
if (
|
|
1307
|
-
|
|
1450
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1451
|
+
ctx.p++;
|
|
1452
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first)
|
|
1453
|
+
ctx.p++;
|
|
1308
1454
|
}
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
i + (isMultiline ? 3 : 1)
|
|
1314
|
-
];
|
|
1455
|
+
if (!state)
|
|
1456
|
+
parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
1457
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
1458
|
+
return parsed;
|
|
1315
1459
|
} else if (!state) {
|
|
1316
|
-
if (!isLiteral && c ===
|
|
1317
|
-
parsed +=
|
|
1460
|
+
if (!isLiteral && c === 92) {
|
|
1461
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
1318
1462
|
state = 1;
|
|
1319
1463
|
}
|
|
1320
1464
|
} else if (state === 1) {
|
|
1321
|
-
if (c ===
|
|
1465
|
+
if (c === 120 || c === 117 || c === 85) {
|
|
1322
1466
|
let value = 0;
|
|
1323
|
-
let len = c ===
|
|
1324
|
-
for (let j = 0; j < len; j++,
|
|
1325
|
-
let hex =
|
|
1467
|
+
let len = c === 120 ? 2 : c === 117 ? 4 : 8;
|
|
1468
|
+
for (let j = 0; j < len; j++, ctx.p++) {
|
|
1469
|
+
let hex = ctx.s.charCodeAt(ctx.p + 1);
|
|
1326
1470
|
let digit = (
|
|
1327
1471
|
/* 0-9 */
|
|
1328
1472
|
hex >= 48 && hex <= 57 ? hex - 48 : (
|
|
@@ -1334,57 +1478,68 @@ function parseString(str, ptr) {
|
|
|
1334
1478
|
)
|
|
1335
1479
|
);
|
|
1336
1480
|
if (digit < 0)
|
|
1337
|
-
throw new TomlError("invalid non-hex character in unicode escape", { toml:
|
|
1481
|
+
throw new TomlError("invalid non-hex character in unicode escape", { toml: ctx.s, ptr: ctx.p + 1 });
|
|
1338
1482
|
value = value << 4 | digit;
|
|
1339
1483
|
}
|
|
1340
1484
|
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) {
|
|
1341
|
-
throw new TomlError("invalid unicode escape", { toml:
|
|
1485
|
+
throw new TomlError("invalid unicode escape", { toml: ctx.s, ptr: ctx.p });
|
|
1342
1486
|
}
|
|
1343
1487
|
parsed += String.fromCodePoint(value);
|
|
1344
|
-
sliceStart =
|
|
1488
|
+
sliceStart = ctx.p + 1;
|
|
1345
1489
|
state = 0;
|
|
1346
|
-
} else if (c ===
|
|
1490
|
+
} else if (c === 32 || c === 9) {
|
|
1347
1491
|
state = 2;
|
|
1348
1492
|
} else {
|
|
1349
|
-
if (c ===
|
|
1493
|
+
if (c === 98)
|
|
1350
1494
|
parsed += "\b";
|
|
1351
|
-
else if (c ===
|
|
1495
|
+
else if (c === 116)
|
|
1352
1496
|
parsed += " ";
|
|
1353
|
-
else if (c ===
|
|
1497
|
+
else if (c === 110)
|
|
1354
1498
|
parsed += "\n";
|
|
1355
|
-
else if (c ===
|
|
1499
|
+
else if (c === 102)
|
|
1356
1500
|
parsed += "\f";
|
|
1357
|
-
else if (c ===
|
|
1501
|
+
else if (c === 114)
|
|
1358
1502
|
parsed += "\r";
|
|
1359
|
-
else if (c ===
|
|
1503
|
+
else if (c === 101)
|
|
1360
1504
|
parsed += "\x1B";
|
|
1361
|
-
else if (c ===
|
|
1505
|
+
else if (c === 34)
|
|
1362
1506
|
parsed += '"';
|
|
1363
|
-
else if (c ===
|
|
1507
|
+
else if (c === 92)
|
|
1364
1508
|
parsed += "\\";
|
|
1365
1509
|
else
|
|
1366
|
-
throw new TomlError("unrecognized escape sequence", { toml:
|
|
1367
|
-
sliceStart =
|
|
1510
|
+
throw new TomlError("unrecognized escape sequence", { toml: ctx.s, ptr: ctx.p });
|
|
1511
|
+
sliceStart = ctx.p + 1;
|
|
1368
1512
|
state = 0;
|
|
1369
1513
|
}
|
|
1370
|
-
} else if (c !==
|
|
1514
|
+
} else if (c !== 32 && c !== 9) {
|
|
1371
1515
|
if (state === 2) {
|
|
1372
1516
|
throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
1373
|
-
toml:
|
|
1517
|
+
toml: ctx.s,
|
|
1374
1518
|
ptr: sliceStart
|
|
1375
1519
|
});
|
|
1376
1520
|
}
|
|
1377
|
-
state = !isLiteral && c ===
|
|
1378
|
-
sliceStart =
|
|
1521
|
+
state = !isLiteral && c === 92 ? 1 : 0;
|
|
1522
|
+
sliceStart = ctx.p;
|
|
1379
1523
|
}
|
|
1380
1524
|
}
|
|
1381
|
-
throw new TomlError("unfinished string", { toml:
|
|
1525
|
+
throw new TomlError("unfinished string", { toml: ctx.s, ptr: start });
|
|
1382
1526
|
}
|
|
1383
|
-
function
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
if (
|
|
1387
|
-
|
|
1527
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
1528
|
+
let value = ctx.s.slice(start, end);
|
|
1529
|
+
let commentIdx = value.indexOf("#");
|
|
1530
|
+
if (commentIdx > 0) {
|
|
1531
|
+
skipComment({ s: value, p: commentIdx, d: 0 });
|
|
1532
|
+
value = value.slice(0, commentIdx);
|
|
1533
|
+
}
|
|
1534
|
+
return value.trimEnd();
|
|
1535
|
+
}
|
|
1536
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
1537
|
+
let ptr = ctx.p;
|
|
1538
|
+
let err = { toml: ctx.s, ptr };
|
|
1539
|
+
skipUntil(ctx, 44, end);
|
|
1540
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
1541
|
+
if (!value)
|
|
1542
|
+
throw new TomlError("incomplete declaration: value expected", err);
|
|
1388
1543
|
if (value === "-inf")
|
|
1389
1544
|
return -Infinity;
|
|
1390
1545
|
if (value === "inf" || value === "+inf")
|
|
@@ -1396,25 +1551,16 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1396
1551
|
let isInt = INT_REGEX.test(value);
|
|
1397
1552
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
1398
1553
|
if (LEADING_ZERO.test(value)) {
|
|
1399
|
-
throw new TomlError("leading zeroes are not allowed",
|
|
1400
|
-
toml,
|
|
1401
|
-
ptr
|
|
1402
|
-
});
|
|
1554
|
+
throw new TomlError("leading zeroes are not allowed", err);
|
|
1403
1555
|
}
|
|
1404
1556
|
value = value.replace(/_/g, "");
|
|
1405
1557
|
let numeric = +value;
|
|
1406
1558
|
if (isNaN(numeric)) {
|
|
1407
|
-
throw new TomlError("invalid number",
|
|
1408
|
-
toml,
|
|
1409
|
-
ptr
|
|
1410
|
-
});
|
|
1559
|
+
throw new TomlError("invalid number", err);
|
|
1411
1560
|
}
|
|
1412
1561
|
if (isInt) {
|
|
1413
1562
|
if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) {
|
|
1414
|
-
throw new TomlError("integer value cannot be represented losslessly",
|
|
1415
|
-
toml,
|
|
1416
|
-
ptr
|
|
1417
|
-
});
|
|
1563
|
+
throw new TomlError("integer value cannot be represented losslessly", err);
|
|
1418
1564
|
}
|
|
1419
1565
|
if (isInt || integersAsBigInt === true)
|
|
1420
1566
|
numeric = BigInt(value);
|
|
@@ -1422,277 +1568,184 @@ function parseValue(value, toml, ptr, integersAsBigInt) {
|
|
|
1422
1568
|
return numeric;
|
|
1423
1569
|
}
|
|
1424
1570
|
const date = new TomlDate(value);
|
|
1425
|
-
if (!date.isValid())
|
|
1426
|
-
throw new TomlError("invalid value",
|
|
1427
|
-
toml,
|
|
1428
|
-
ptr
|
|
1429
|
-
});
|
|
1430
|
-
}
|
|
1571
|
+
if (!date.isValid())
|
|
1572
|
+
throw new TomlError("invalid value", err);
|
|
1431
1573
|
return date;
|
|
1432
1574
|
}
|
|
1433
1575
|
|
|
1434
|
-
// node_modules/smol-toml/dist/
|
|
1435
|
-
function
|
|
1436
|
-
let
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1443
|
-
let c = str[i];
|
|
1444
|
-
if (c === "\n")
|
|
1445
|
-
return i;
|
|
1446
|
-
if (c === "\r" && str[i + 1] === "\n")
|
|
1447
|
-
return i + 1;
|
|
1448
|
-
if (c < " " && c !== " " || c === "\x7F") {
|
|
1449
|
-
throw new TomlError("control characters are not allowed in comments", {
|
|
1450
|
-
toml: str,
|
|
1576
|
+
// node_modules/smol-toml/dist/extract.js
|
|
1577
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
1578
|
+
let ptr = ctx.p;
|
|
1579
|
+
let c = ctx.s.charCodeAt(ptr);
|
|
1580
|
+
if (c === 91 || c === 123) {
|
|
1581
|
+
if (!ctx.d--) {
|
|
1582
|
+
throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
1583
|
+
toml: ctx.s,
|
|
1451
1584
|
ptr
|
|
1452
1585
|
});
|
|
1453
1586
|
}
|
|
1587
|
+
let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
1588
|
+
ctx.d++;
|
|
1589
|
+
return value;
|
|
1454
1590
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
1458
|
-
let c;
|
|
1459
|
-
while (1) {
|
|
1460
|
-
while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n"))
|
|
1461
|
-
ptr++;
|
|
1462
|
-
if (banComments || c !== "#")
|
|
1463
|
-
break;
|
|
1464
|
-
ptr = skipComment(str, ptr);
|
|
1465
|
-
}
|
|
1466
|
-
return ptr;
|
|
1467
|
-
}
|
|
1468
|
-
function skipUntil(str, ptr, sep, end, banNewLines = false) {
|
|
1469
|
-
if (!end) {
|
|
1470
|
-
ptr = indexOfNewline(str, ptr);
|
|
1471
|
-
return ptr < 0 ? str.length : ptr;
|
|
1472
|
-
}
|
|
1473
|
-
for (let i = ptr; i < str.length; i++) {
|
|
1474
|
-
let c = str[i];
|
|
1475
|
-
if (c === "#") {
|
|
1476
|
-
i = indexOfNewline(str, i);
|
|
1477
|
-
} else if (c === sep) {
|
|
1478
|
-
return i + 1;
|
|
1479
|
-
} else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) {
|
|
1480
|
-
return i;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
throw new TomlError("cannot find end of structure", {
|
|
1484
|
-
toml: str,
|
|
1485
|
-
ptr
|
|
1486
|
-
});
|
|
1487
|
-
}
|
|
1488
|
-
|
|
1489
|
-
// node_modules/smol-toml/dist/extract.js
|
|
1490
|
-
function sliceAndTrimEndOf(str, startPtr, endPtr) {
|
|
1491
|
-
let value = str.slice(startPtr, endPtr);
|
|
1492
|
-
let commentIdx = value.indexOf("#");
|
|
1493
|
-
if (commentIdx > -1) {
|
|
1494
|
-
skipComment(str, commentIdx);
|
|
1495
|
-
value = value.slice(0, commentIdx);
|
|
1591
|
+
if (c === 34 || c === 39) {
|
|
1592
|
+
return parseString(ctx);
|
|
1496
1593
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
toml: str,
|
|
1503
|
-
ptr
|
|
1504
|
-
});
|
|
1505
|
-
}
|
|
1506
|
-
let c = str[ptr];
|
|
1507
|
-
if (c === "[" || c === "{") {
|
|
1508
|
-
let [value, endPtr2] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
|
|
1509
|
-
if (end) {
|
|
1510
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1511
|
-
if (str[endPtr2] === ",")
|
|
1512
|
-
endPtr2++;
|
|
1513
|
-
else if (str[endPtr2] !== end) {
|
|
1514
|
-
throw new TomlError("expected comma or end of structure", {
|
|
1515
|
-
toml: str,
|
|
1516
|
-
ptr: endPtr2
|
|
1517
|
-
});
|
|
1518
|
-
}
|
|
1519
|
-
}
|
|
1520
|
-
return [value, endPtr2];
|
|
1521
|
-
}
|
|
1522
|
-
if (c === '"' || c === "'") {
|
|
1523
|
-
let [parsed, endPtr2] = parseString(str, ptr);
|
|
1524
|
-
if (end) {
|
|
1525
|
-
endPtr2 = skipVoid(str, endPtr2);
|
|
1526
|
-
if (str[endPtr2] && str[endPtr2] !== "," && str[endPtr2] !== end && str[endPtr2] !== "\n" && str[endPtr2] !== "\r") {
|
|
1527
|
-
throw new TomlError("unexpected character encountered", {
|
|
1528
|
-
toml: str,
|
|
1529
|
-
ptr: endPtr2
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
if (str[endPtr2] === ",")
|
|
1533
|
-
endPtr2++;
|
|
1534
|
-
}
|
|
1535
|
-
return [parsed, endPtr2];
|
|
1536
|
-
}
|
|
1537
|
-
let endPtr = skipUntil(str, ptr, ",", end);
|
|
1538
|
-
let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
|
|
1539
|
-
if (!slice[0]) {
|
|
1540
|
-
throw new TomlError("incomplete key-value declaration: no value specified", {
|
|
1541
|
-
toml: str,
|
|
1542
|
-
ptr
|
|
1543
|
-
});
|
|
1594
|
+
if (c === 116) {
|
|
1595
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101)
|
|
1596
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1597
|
+
ctx.p++;
|
|
1598
|
+
return true;
|
|
1544
1599
|
}
|
|
1545
|
-
if (
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1600
|
+
if (c === 102) {
|
|
1601
|
+
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)
|
|
1602
|
+
throw new TomlError("invalid value", { toml: ctx.s, ptr });
|
|
1603
|
+
ctx.p++;
|
|
1604
|
+
return false;
|
|
1549
1605
|
}
|
|
1550
|
-
return
|
|
1551
|
-
parseValue(slice[0], str, ptr, integersAsBigInt),
|
|
1552
|
-
endPtr
|
|
1553
|
-
];
|
|
1606
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
1554
1607
|
}
|
|
1555
1608
|
|
|
1556
1609
|
// node_modules/smol-toml/dist/struct.js
|
|
1557
1610
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1558
|
-
function parseKey(
|
|
1559
|
-
let
|
|
1611
|
+
function parseKey(ctx, end = "=") {
|
|
1612
|
+
let start = ctx.p;
|
|
1613
|
+
let dot = start - 1;
|
|
1560
1614
|
let parsed = [];
|
|
1561
|
-
let endPtr =
|
|
1615
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
1562
1616
|
if (endPtr < 0) {
|
|
1563
1617
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1564
|
-
toml:
|
|
1565
|
-
ptr
|
|
1618
|
+
toml: ctx.s,
|
|
1619
|
+
ptr: start
|
|
1566
1620
|
});
|
|
1567
1621
|
}
|
|
1568
1622
|
do {
|
|
1569
|
-
let c =
|
|
1570
|
-
if (c !==
|
|
1571
|
-
if (c ===
|
|
1572
|
-
if (c ===
|
|
1623
|
+
let c = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
1624
|
+
if (c !== 32 && c !== 9) {
|
|
1625
|
+
if (c === 34 || c === 39) {
|
|
1626
|
+
if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) {
|
|
1573
1627
|
throw new TomlError("multiline strings are not allowed in keys", {
|
|
1574
|
-
toml:
|
|
1575
|
-
ptr
|
|
1628
|
+
toml: ctx.s,
|
|
1629
|
+
ptr: ctx.p
|
|
1576
1630
|
});
|
|
1577
1631
|
}
|
|
1578
|
-
let
|
|
1579
|
-
dot =
|
|
1580
|
-
let strEnd =
|
|
1632
|
+
let part = parseString(ctx);
|
|
1633
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1634
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1581
1635
|
let newLine = indexOfNewline(strEnd);
|
|
1582
1636
|
if (newLine > -1) {
|
|
1583
1637
|
throw new TomlError("newlines are not allowed in keys", {
|
|
1584
|
-
toml:
|
|
1585
|
-
ptr:
|
|
1638
|
+
toml: ctx.s,
|
|
1639
|
+
ptr: newLine
|
|
1586
1640
|
});
|
|
1587
1641
|
}
|
|
1588
1642
|
if (strEnd.trimStart()) {
|
|
1589
1643
|
throw new TomlError("found extra tokens after the string part", {
|
|
1590
|
-
toml:
|
|
1591
|
-
ptr:
|
|
1644
|
+
toml: ctx.s,
|
|
1645
|
+
ptr: ctx.p
|
|
1592
1646
|
});
|
|
1593
1647
|
}
|
|
1594
|
-
if (endPtr <
|
|
1595
|
-
endPtr =
|
|
1648
|
+
if (endPtr < ctx.p) {
|
|
1649
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
1596
1650
|
if (endPtr < 0) {
|
|
1597
1651
|
throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
1598
|
-
toml:
|
|
1599
|
-
ptr
|
|
1652
|
+
toml: ctx.s,
|
|
1653
|
+
ptr: start
|
|
1600
1654
|
});
|
|
1601
1655
|
}
|
|
1602
1656
|
}
|
|
1603
1657
|
parsed.push(part);
|
|
1604
1658
|
} else {
|
|
1605
|
-
dot =
|
|
1606
|
-
let part =
|
|
1659
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1660
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1607
1661
|
if (!KEY_PART_RE.test(part)) {
|
|
1608
1662
|
throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1609
|
-
toml:
|
|
1610
|
-
ptr
|
|
1663
|
+
toml: ctx.s,
|
|
1664
|
+
ptr: ctx.p
|
|
1611
1665
|
});
|
|
1612
1666
|
}
|
|
1613
1667
|
parsed.push(part.trimEnd());
|
|
1614
1668
|
}
|
|
1615
1669
|
}
|
|
1616
1670
|
} while (dot + 1 && dot < endPtr);
|
|
1617
|
-
|
|
1671
|
+
ctx.p = endPtr + 1;
|
|
1672
|
+
skipVoid(ctx, true, true);
|
|
1673
|
+
return parsed;
|
|
1618
1674
|
}
|
|
1619
|
-
function parseInlineTable(
|
|
1675
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
1620
1676
|
let res = {};
|
|
1621
1677
|
let seen = /* @__PURE__ */ new Set();
|
|
1622
1678
|
let c;
|
|
1623
|
-
|
|
1624
|
-
while (
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
k = key[i];
|
|
1641
|
-
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1642
|
-
throw new TomlError("trying to redefine an already defined value", {
|
|
1643
|
-
toml: str,
|
|
1644
|
-
ptr
|
|
1645
|
-
});
|
|
1646
|
-
}
|
|
1647
|
-
if (!hasOwn && k === "__proto__") {
|
|
1648
|
-
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
if (hasOwn) {
|
|
1679
|
+
ctx.p++;
|
|
1680
|
+
while (ctx.p < ctx.s.length) {
|
|
1681
|
+
skipVoid(ctx);
|
|
1682
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
1683
|
+
ctx.p++;
|
|
1684
|
+
return res;
|
|
1685
|
+
}
|
|
1686
|
+
let k;
|
|
1687
|
+
let t = res;
|
|
1688
|
+
let hasOwn = false;
|
|
1689
|
+
let p = ctx.p;
|
|
1690
|
+
let key = parseKey(ctx);
|
|
1691
|
+
for (let i = 0; i < key.length; i++) {
|
|
1692
|
+
if (i)
|
|
1693
|
+
t = hasOwn ? t[k] : t[k] = {};
|
|
1694
|
+
k = key[i];
|
|
1695
|
+
if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) {
|
|
1652
1696
|
throw new TomlError("trying to redefine an already defined value", {
|
|
1653
|
-
toml:
|
|
1654
|
-
ptr
|
|
1697
|
+
toml: ctx.s,
|
|
1698
|
+
ptr: p
|
|
1655
1699
|
});
|
|
1656
1700
|
}
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1701
|
+
if (!hasOwn && k === "__proto__") {
|
|
1702
|
+
Object.defineProperty(t, k, { enumerable: true, configurable: true, writable: true });
|
|
1703
|
+
}
|
|
1704
|
+
}
|
|
1705
|
+
if (hasOwn) {
|
|
1706
|
+
throw new TomlError("trying to redefine an already defined value", {
|
|
1707
|
+
toml: ctx.s,
|
|
1708
|
+
ptr: ctx.p
|
|
1709
|
+
});
|
|
1710
|
+
}
|
|
1711
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
1712
|
+
seen.add(t[k] = value);
|
|
1713
|
+
skipVoid(ctx);
|
|
1714
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) {
|
|
1715
|
+
return res;
|
|
1716
|
+
}
|
|
1717
|
+
if (c !== 44) {
|
|
1718
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1661
1719
|
}
|
|
1662
1720
|
}
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
});
|
|
1668
|
-
}
|
|
1669
|
-
return [res, ptr];
|
|
1721
|
+
throw new TomlError("unfinished table encountered", {
|
|
1722
|
+
toml: ctx.s,
|
|
1723
|
+
ptr: ctx.p
|
|
1724
|
+
});
|
|
1670
1725
|
}
|
|
1671
|
-
function parseArray(
|
|
1726
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
1672
1727
|
let res = [];
|
|
1673
1728
|
let c;
|
|
1674
|
-
|
|
1675
|
-
while (
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
if (!c) {
|
|
1690
|
-
throw new TomlError("unfinished array encountered", {
|
|
1691
|
-
toml: str,
|
|
1692
|
-
ptr
|
|
1693
|
-
});
|
|
1729
|
+
ctx.p++;
|
|
1730
|
+
while (ctx.p < ctx.s.length) {
|
|
1731
|
+
skipVoid(ctx);
|
|
1732
|
+
if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
1733
|
+
ctx.p++;
|
|
1734
|
+
return res;
|
|
1735
|
+
}
|
|
1736
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
1737
|
+
skipVoid(ctx);
|
|
1738
|
+
if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) {
|
|
1739
|
+
return res;
|
|
1740
|
+
}
|
|
1741
|
+
if (c !== 44) {
|
|
1742
|
+
throw new TomlError("expected comma or end of structure", { toml: ctx.s, ptr: ctx.p - 1 });
|
|
1743
|
+
}
|
|
1694
1744
|
}
|
|
1695
|
-
|
|
1745
|
+
throw new TomlError("unfinished array encountered", {
|
|
1746
|
+
toml: ctx.s,
|
|
1747
|
+
ptr: ctx.p
|
|
1748
|
+
});
|
|
1696
1749
|
}
|
|
1697
1750
|
|
|
1698
1751
|
// node_modules/smol-toml/dist/parse.js
|
|
@@ -1756,25 +1809,29 @@ function peekTable(key, table, meta, type) {
|
|
|
1756
1809
|
return [k, t, state.c];
|
|
1757
1810
|
}
|
|
1758
1811
|
function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
1812
|
+
let ctx = { s: toml, p: 0, d: maxDepth };
|
|
1759
1813
|
let res = {};
|
|
1760
1814
|
let meta = {};
|
|
1815
|
+
let tmp;
|
|
1761
1816
|
let tbl = res;
|
|
1762
1817
|
let m = meta;
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
let
|
|
1818
|
+
skipVoid(ctx);
|
|
1819
|
+
while (ctx.p < toml.length) {
|
|
1820
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
1821
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
1822
|
+
tmp = ctx.p += +isTableArray;
|
|
1823
|
+
let k = parseKey(ctx, "]");
|
|
1767
1824
|
if (isTableArray) {
|
|
1768
|
-
if (toml
|
|
1825
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) {
|
|
1769
1826
|
throw new TomlError("expected end of table declaration", {
|
|
1770
1827
|
toml,
|
|
1771
|
-
ptr:
|
|
1828
|
+
ptr: ctx.p - 1
|
|
1772
1829
|
});
|
|
1773
1830
|
}
|
|
1774
|
-
|
|
1831
|
+
ctx.p++;
|
|
1775
1832
|
}
|
|
1776
1833
|
let p = peekTable(
|
|
1777
|
-
k
|
|
1834
|
+
k,
|
|
1778
1835
|
res,
|
|
1779
1836
|
meta,
|
|
1780
1837
|
isTableArray ? 2 : 1
|
|
@@ -1783,16 +1840,16 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1783
1840
|
if (!p) {
|
|
1784
1841
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1785
1842
|
toml,
|
|
1786
|
-
ptr
|
|
1843
|
+
ptr: tmp
|
|
1787
1844
|
});
|
|
1788
1845
|
}
|
|
1789
1846
|
m = p[2];
|
|
1790
1847
|
tbl = p[1];
|
|
1791
|
-
ptr = k[1];
|
|
1792
1848
|
} else {
|
|
1793
|
-
|
|
1849
|
+
tmp = ctx.p;
|
|
1850
|
+
let k = parseKey(ctx);
|
|
1794
1851
|
let p = peekTable(
|
|
1795
|
-
k
|
|
1852
|
+
k,
|
|
1796
1853
|
tbl,
|
|
1797
1854
|
m,
|
|
1798
1855
|
0
|
|
@@ -1801,21 +1858,19 @@ function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
|
1801
1858
|
if (!p) {
|
|
1802
1859
|
throw new TomlError("trying to redefine an already defined table or value", {
|
|
1803
1860
|
toml,
|
|
1804
|
-
ptr
|
|
1861
|
+
ptr: tmp
|
|
1805
1862
|
});
|
|
1806
1863
|
}
|
|
1807
|
-
|
|
1808
|
-
p[1][p[0]] = v[0];
|
|
1809
|
-
ptr = v[1];
|
|
1864
|
+
p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
1810
1865
|
}
|
|
1811
|
-
|
|
1812
|
-
if (toml
|
|
1866
|
+
skipVoid(ctx, true);
|
|
1867
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) {
|
|
1813
1868
|
throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
1814
1869
|
toml,
|
|
1815
|
-
ptr
|
|
1870
|
+
ptr: ctx.p
|
|
1816
1871
|
});
|
|
1817
1872
|
}
|
|
1818
|
-
|
|
1873
|
+
skipVoid(ctx);
|
|
1819
1874
|
}
|
|
1820
1875
|
return res;
|
|
1821
1876
|
}
|
|
@@ -1827,8 +1882,12 @@ function extendedTypeOf(obj) {
|
|
|
1827
1882
|
if (type === "object") {
|
|
1828
1883
|
if (Array.isArray(obj))
|
|
1829
1884
|
return "array";
|
|
1830
|
-
if (obj instanceof Date)
|
|
1885
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date)
|
|
1831
1886
|
return "date";
|
|
1887
|
+
if (globalThis.Temporal && // check for the 'since' property as an early bailout that avoids running all 5 instanceof checks
|
|
1888
|
+
typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) {
|
|
1889
|
+
return "temporal";
|
|
1890
|
+
}
|
|
1832
1891
|
}
|
|
1833
1892
|
return type;
|
|
1834
1893
|
}
|
|
@@ -1842,38 +1901,42 @@ function isArrayOfTables(obj) {
|
|
|
1842
1901
|
function formatString(s) {
|
|
1843
1902
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
1844
1903
|
}
|
|
1904
|
+
function stringifyTemporal(temporal) {
|
|
1905
|
+
return temporal.toString({
|
|
1906
|
+
calendarName: "never",
|
|
1907
|
+
timeZoneName: "never"
|
|
1908
|
+
});
|
|
1909
|
+
}
|
|
1845
1910
|
function stringifyValue(val, type, depth, numberAsFloat) {
|
|
1846
1911
|
if (depth === 0) {
|
|
1847
1912
|
throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
1848
1913
|
}
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
if (type === "array") {
|
|
1876
|
-
return stringifyArray(val, depth, numberAsFloat);
|
|
1914
|
+
switch (type) {
|
|
1915
|
+
// @ts-expect-error -- intentional fallthrough case
|
|
1916
|
+
case "number":
|
|
1917
|
+
if (isNaN(val))
|
|
1918
|
+
return "nan";
|
|
1919
|
+
if (val === Infinity)
|
|
1920
|
+
return "inf";
|
|
1921
|
+
if (val === -Infinity)
|
|
1922
|
+
return "-inf";
|
|
1923
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val)))
|
|
1924
|
+
return val.toFixed(1);
|
|
1925
|
+
case "bigint":
|
|
1926
|
+
case "boolean":
|
|
1927
|
+
return val.toString();
|
|
1928
|
+
case "string":
|
|
1929
|
+
return formatString(val);
|
|
1930
|
+
case "date":
|
|
1931
|
+
if (isNaN(val.getTime()))
|
|
1932
|
+
throw new TypeError("cannot serialize invalid date");
|
|
1933
|
+
return val.toISOString();
|
|
1934
|
+
case "object":
|
|
1935
|
+
return stringifyInlineTable(val, depth, numberAsFloat);
|
|
1936
|
+
case "array":
|
|
1937
|
+
return stringifyArray(val, depth, numberAsFloat);
|
|
1938
|
+
case "temporal":
|
|
1939
|
+
return stringifyTemporal(val);
|
|
1877
1940
|
}
|
|
1878
1941
|
}
|
|
1879
1942
|
function stringifyInlineTable(obj, depth, numberAsFloat) {
|
|
@@ -4095,7 +4158,7 @@ function propagateEndLinesToSymbols(symbols, sections) {
|
|
|
4095
4158
|
return sym;
|
|
4096
4159
|
});
|
|
4097
4160
|
}
|
|
4098
|
-
function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex) {
|
|
4161
|
+
function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex, lineCommentPrefix) {
|
|
4099
4162
|
let depth = 0;
|
|
4100
4163
|
let quote = null;
|
|
4101
4164
|
for (let i = openBraceIndex; i < content.length; i++) {
|
|
@@ -4108,6 +4171,10 @@ function findMatchingBraceEndLine(content, openBraceIndex, totalLines, lineIndex
|
|
|
4108
4171
|
if (ch === quote) quote = null;
|
|
4109
4172
|
continue;
|
|
4110
4173
|
}
|
|
4174
|
+
if (lineCommentPrefix !== void 0 && content.startsWith(lineCommentPrefix, i)) {
|
|
4175
|
+
while (i < content.length && content[i] !== "\n") i++;
|
|
4176
|
+
continue;
|
|
4177
|
+
}
|
|
4111
4178
|
if (ch === '"' || ch === "'") {
|
|
4112
4179
|
quote = ch;
|
|
4113
4180
|
continue;
|
|
@@ -4134,7 +4201,7 @@ function extractIni(content, filePath) {
|
|
|
4134
4201
|
const sections = [];
|
|
4135
4202
|
const seen = /* @__PURE__ */ new Set();
|
|
4136
4203
|
const lines = content.split(/\r?\n/);
|
|
4137
|
-
const totalLines =
|
|
4204
|
+
const totalLines = countContentLines(content);
|
|
4138
4205
|
for (let i = 0; i < lines.length; i++) {
|
|
4139
4206
|
if (symbols.length >= MAX_SECTIONS) break;
|
|
4140
4207
|
const line = lines[i] ?? "";
|
|
@@ -5436,6 +5503,8 @@ var KIND_TO_SOURCE = {
|
|
|
5436
5503
|
json_outline: SOURCE_READ,
|
|
5437
5504
|
yaml_query: SOURCE_READ,
|
|
5438
5505
|
yaml_outline: SOURCE_READ,
|
|
5506
|
+
xml_query: SOURCE_READ,
|
|
5507
|
+
xml_outline: SOURCE_READ,
|
|
5439
5508
|
openapi_op: SOURCE_READ,
|
|
5440
5509
|
openapi_outline: SOURCE_READ,
|
|
5441
5510
|
zip_list: SOURCE_READ,
|
|
@@ -5521,6 +5590,8 @@ var COMMAND_KINDS = {
|
|
|
5521
5590
|
"json-outline": /* @__PURE__ */ new Set(["json_outline"]),
|
|
5522
5591
|
"yaml-query": /* @__PURE__ */ new Set(["yaml_query"]),
|
|
5523
5592
|
"yaml-outline": /* @__PURE__ */ new Set(["yaml_outline"]),
|
|
5593
|
+
"xml-query": /* @__PURE__ */ new Set(["xml_query"]),
|
|
5594
|
+
"xml-outline": /* @__PURE__ */ new Set(["xml_outline"]),
|
|
5524
5595
|
"openapi-op": /* @__PURE__ */ new Set(["openapi_op"]),
|
|
5525
5596
|
"openapi-outline": /* @__PURE__ */ new Set(["openapi_outline"]),
|
|
5526
5597
|
"zip-list": /* @__PURE__ */ new Set(["zip_list"]),
|
|
@@ -5855,13 +5926,42 @@ var SECRET_PATTERNS = [
|
|
|
5855
5926
|
// contain '_' and could otherwise partially match the classic pattern.
|
|
5856
5927
|
["github_token", /github_pat_[A-Za-z0-9_]{22,}/g],
|
|
5857
5928
|
["github_token", /gh[oprsu]_[A-Za-z0-9]{36,}/g],
|
|
5929
|
+
// xapp- is Slack's app-level token (Socket Mode), a bearer credential in its own right that
|
|
5930
|
+
// the xox[baprs]- prefix does not cover. It gets its own entry rather than joining the
|
|
5931
|
+
// alternation above because it needs the full segmented shape (xapp-<ver>-<app id>-<digits>-
|
|
5932
|
+
// <hex>) to be safe: a bare /xapp-[A-Za-z0-9-]+/ redacted ordinary identifiers like
|
|
5933
|
+
// "xapp-config" and the css class "xapp-container", mangling normal source. The xox* prefixes
|
|
5934
|
+
// are distinctive enough on their own; "xapp-" is not.
|
|
5858
5935
|
["slack_token", /xox[baprs]-[A-Za-z0-9-]+/g],
|
|
5936
|
+
["slack_token", /xapp-\d-[A-Za-z0-9]{6,}-\d{8,}-[A-Za-z0-9]{16,}/g],
|
|
5859
5937
|
// Matches the full block (BEGIN marker through its matching END marker), not just the
|
|
5860
5938
|
// header -- the actual secret material is the base64 body between them, so redacting only
|
|
5861
5939
|
// the header line would leave the key bytes themselves fully readable in the cached blob.
|
|
5862
|
-
// The
|
|
5863
|
-
//
|
|
5864
|
-
|
|
5940
|
+
// The body is lazy and additionally refuses to cross a following BEGIN marker. Both halves
|
|
5941
|
+
// matter. The laziness bounds a successful match at the very next END marker; the negative
|
|
5942
|
+
// lookahead bounds a *failing* one, because a BEGIN with no END of its own would otherwise
|
|
5943
|
+
// scan to end-of-input, and a blob full of such markers made the pass quadratic -- 6 ms, 20 ms
|
|
5944
|
+
// and 78 ms for 2000, 4000 and 8000 of them, four times the work for twice the input, the same
|
|
5945
|
+
// shape as the lookbehind incident described above. Private key blocks do not nest, so
|
|
5946
|
+
// refusing to cross a BEGIN costs nothing in correctness.
|
|
5947
|
+
// The algorithm and ` BLOCK` groups are backreferenced in the END marker rather than repeated,
|
|
5948
|
+
// so a BEGIN only ever pairs with its own END spelling. Written as two independent optional
|
|
5949
|
+
// groups, `BEGIN PGP PRIVATE KEY` would happily close on a distant `END RSA PRIVATE KEY BLOCK`
|
|
5950
|
+
// and redact everything in between. A non-participating group backreferences as the empty
|
|
5951
|
+
// string in JS, which is exactly what the unprefixed `BEGIN PRIVATE KEY` form needs.
|
|
5952
|
+
// The algorithm list covers every armored private-key header openssl, ssh-keygen and gpg
|
|
5953
|
+
// actually emit, not just the ones a first draft happened to think of. ENCRYPTED is the
|
|
5954
|
+
// PKCS#8 passphrase-protected form (`openssl genpkey -aes256`, `ssh-keygen -m PKCS8`) and is
|
|
5955
|
+
// the most common shape of all; DSA is legacy but still written verbatim; PGP carries the
|
|
5956
|
+
// ` BLOCK` suffix, which is why that suffix is optional here. All three used to fall through
|
|
5957
|
+
// to disk in full. An encrypted key is still key material: the passphrase can be attacked
|
|
5958
|
+
// offline once the bytes are cached, so it is redacted like any other.
|
|
5959
|
+
// PuTTY `.ppk` files are deliberately not matched. They have no END marker -- the private
|
|
5960
|
+
// section is a `Private-Lines: N` count followed by exactly N base64 lines -- so bounding a
|
|
5961
|
+
// match would take a stateful parse rather than a regex, on a path that runs over every
|
|
5962
|
+
// command output. A regex guess at where the body ends is exactly the over-eager match this
|
|
5963
|
+
// module's header warns against.
|
|
5964
|
+
["private_key_block", /-----BEGIN (RSA |DSA |EC |OPENSSH |ENCRYPTED |PGP )?PRIVATE KEY( BLOCK)?-----(?:(?!-----BEGIN )[\s\S])*?-----END \1PRIVATE KEY\2-----/g],
|
|
5865
5965
|
// Redacts only the token itself, not the "Authorization: Bearer " prefix -- the lookbehind
|
|
5866
5966
|
// anchors on the header name and scheme so the surrounding request-log line stays readable,
|
|
5867
5967
|
// matching how AWS_ACCESS_KEY_ID=... above keeps its own prefix intact.
|
|
@@ -6018,6 +6118,8 @@ export {
|
|
|
6018
6118
|
normalizeDarwinSystemAlias,
|
|
6019
6119
|
resolveIndexPath,
|
|
6020
6120
|
toDisplayPath,
|
|
6121
|
+
displaySafeText,
|
|
6122
|
+
displaySafePath,
|
|
6021
6123
|
sleepSync,
|
|
6022
6124
|
isWindows,
|
|
6023
6125
|
isCaseInsensitiveFs,
|
|
@@ -6049,6 +6151,7 @@ export {
|
|
|
6049
6151
|
grepFilteredToEmptyNotice,
|
|
6050
6152
|
countNoun,
|
|
6051
6153
|
excludeTestsHiddenNote,
|
|
6154
|
+
countContentLines,
|
|
6052
6155
|
escapeRegExp,
|
|
6053
6156
|
windowsCmdQuoteArg,
|
|
6054
6157
|
redactUrlQuery,
|
|
@@ -6067,9 +6170,13 @@ export {
|
|
|
6067
6170
|
isWithinQuietHours,
|
|
6068
6171
|
hookCommandFor,
|
|
6069
6172
|
suggestPackageNames,
|
|
6173
|
+
detectSourceEncoding,
|
|
6174
|
+
decodeSource,
|
|
6175
|
+
encodeSource,
|
|
6070
6176
|
fingerprintContent,
|
|
6071
6177
|
shortFingerprint,
|
|
6072
6178
|
fingerprintFile,
|
|
6179
|
+
fileIsAbsent,
|
|
6073
6180
|
canonicalize,
|
|
6074
6181
|
makeProjectAt,
|
|
6075
6182
|
findProject,
|
|
@@ -6142,8 +6249,8 @@ export {
|
|
|
6142
6249
|
|
|
6143
6250
|
smol-toml/dist/date.js:
|
|
6144
6251
|
smol-toml/dist/error.js:
|
|
6145
|
-
smol-toml/dist/primitive.js:
|
|
6146
6252
|
smol-toml/dist/util.js:
|
|
6253
|
+
smol-toml/dist/primitive.js:
|
|
6147
6254
|
smol-toml/dist/extract.js:
|
|
6148
6255
|
smol-toml/dist/struct.js:
|
|
6149
6256
|
smol-toml/dist/parse.js:
|