@cloudflare/vite-plugin 1.57.2 → 1.58.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
|
@@ -136,7 +136,7 @@ function createFatalError$1(message, isJson, options) {
|
|
|
136
136
|
__name$6(createFatalError$1, "createFatalError");
|
|
137
137
|
|
|
138
138
|
//#endregion
|
|
139
|
-
//#region ../workers-utils/dist/chunk-
|
|
139
|
+
//#region ../workers-utils/dist/chunk-IKXB77SR.mjs
|
|
140
140
|
function hasKnownExportType(entry) {
|
|
141
141
|
const type = entry?.type;
|
|
142
142
|
return type === "durable-object" || type === "worker";
|
|
@@ -1440,114 +1440,7 @@ function applyEdits(text, edits) {
|
|
|
1440
1440
|
return text;
|
|
1441
1441
|
}
|
|
1442
1442
|
__name$6(applyEdits, "applyEdits");
|
|
1443
|
-
|
|
1444
|
-
let lines = string$3.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1445
|
-
return [lines.length, lines.pop().length + 1];
|
|
1446
|
-
}
|
|
1447
|
-
__name$6(getLineColFromPtr$1, "getLineColFromPtr");
|
|
1448
|
-
function makeCodeBlock$1(string$3, line, column) {
|
|
1449
|
-
let lines = string$3.split(/\r\n|\n|\r/g);
|
|
1450
|
-
let codeblock = "";
|
|
1451
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
1452
|
-
for (let i$1 = line - 1; i$1 <= line + 1; i$1++) {
|
|
1453
|
-
let l = lines[i$1 - 1];
|
|
1454
|
-
if (!l) continue;
|
|
1455
|
-
codeblock += i$1.toString().padEnd(numberLen, " ");
|
|
1456
|
-
codeblock += ": ";
|
|
1457
|
-
codeblock += l;
|
|
1458
|
-
codeblock += "\n";
|
|
1459
|
-
if (i$1 === line) {
|
|
1460
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
1461
|
-
codeblock += "^\n";
|
|
1462
|
-
}
|
|
1463
|
-
}
|
|
1464
|
-
return codeblock;
|
|
1465
|
-
}
|
|
1466
|
-
__name$6(makeCodeBlock$1, "makeCodeBlock");
|
|
1467
|
-
var TomlError$1 = class extends Error {
|
|
1468
|
-
static {
|
|
1469
|
-
__name$6(this, "TomlError");
|
|
1470
|
-
}
|
|
1471
|
-
line;
|
|
1472
|
-
column;
|
|
1473
|
-
codeblock;
|
|
1474
|
-
constructor(message, options) {
|
|
1475
|
-
const [line, column] = getLineColFromPtr$1(options.toml, options.ptr);
|
|
1476
|
-
const codeblock = makeCodeBlock$1(options.toml, line, column);
|
|
1477
|
-
super(`Invalid TOML document: ${message}
|
|
1478
|
-
|
|
1479
|
-
${codeblock}`, options);
|
|
1480
|
-
this.line = line;
|
|
1481
|
-
this.column = column;
|
|
1482
|
-
this.codeblock = codeblock;
|
|
1483
|
-
}
|
|
1484
|
-
};
|
|
1485
|
-
function isEscaped$1(str, ptr) {
|
|
1486
|
-
let i$1 = 0;
|
|
1487
|
-
while (str[ptr - ++i$1] === "\\");
|
|
1488
|
-
return --i$1 && i$1 % 2;
|
|
1489
|
-
}
|
|
1490
|
-
__name$6(isEscaped$1, "isEscaped");
|
|
1491
|
-
function indexOfNewline$1(str, start = 0, end = str.length) {
|
|
1492
|
-
let idx = str.indexOf("\n", start);
|
|
1493
|
-
if (str[idx - 1] === "\r") idx--;
|
|
1494
|
-
return idx <= end ? idx : -1;
|
|
1495
|
-
}
|
|
1496
|
-
__name$6(indexOfNewline$1, "indexOfNewline");
|
|
1497
|
-
function skipComment$1(str, ptr) {
|
|
1498
|
-
for (let i$1 = ptr; i$1 < str.length; i$1++) {
|
|
1499
|
-
let c$1 = str[i$1];
|
|
1500
|
-
if (c$1 === "\n") return i$1;
|
|
1501
|
-
if (c$1 === "\r" && str[i$1 + 1] === "\n") return i$1 + 1;
|
|
1502
|
-
if (c$1 < " " && c$1 !== " " || c$1 === "") throw new TomlError$1("control characters are not allowed in comments", {
|
|
1503
|
-
toml: str,
|
|
1504
|
-
ptr
|
|
1505
|
-
});
|
|
1506
|
-
}
|
|
1507
|
-
return str.length;
|
|
1508
|
-
}
|
|
1509
|
-
__name$6(skipComment$1, "skipComment");
|
|
1510
|
-
function skipVoid$1(str, ptr, banNewLines, banComments) {
|
|
1511
|
-
let c$1;
|
|
1512
|
-
while ((c$1 = str[ptr]) === " " || c$1 === " " || !banNewLines && (c$1 === "\n" || c$1 === "\r" && str[ptr + 1] === "\n")) ptr++;
|
|
1513
|
-
return banComments || c$1 !== "#" ? ptr : skipVoid$1(str, skipComment$1(str, ptr), banNewLines);
|
|
1514
|
-
}
|
|
1515
|
-
__name$6(skipVoid$1, "skipVoid");
|
|
1516
|
-
function skipUntil$1(str, ptr, sep$1, end, banNewLines = false) {
|
|
1517
|
-
if (!end) {
|
|
1518
|
-
ptr = indexOfNewline$1(str, ptr);
|
|
1519
|
-
return ptr < 0 ? str.length : ptr;
|
|
1520
|
-
}
|
|
1521
|
-
for (let i$1 = ptr; i$1 < str.length; i$1++) {
|
|
1522
|
-
let c$1 = str[i$1];
|
|
1523
|
-
if (c$1 === "#") i$1 = indexOfNewline$1(str, i$1);
|
|
1524
|
-
else if (c$1 === sep$1) return i$1 + 1;
|
|
1525
|
-
else if (c$1 === end || banNewLines && (c$1 === "\n" || c$1 === "\r" && str[i$1 + 1] === "\n")) return i$1;
|
|
1526
|
-
}
|
|
1527
|
-
throw new TomlError$1("cannot find end of structure", {
|
|
1528
|
-
toml: str,
|
|
1529
|
-
ptr
|
|
1530
|
-
});
|
|
1531
|
-
}
|
|
1532
|
-
__name$6(skipUntil$1, "skipUntil");
|
|
1533
|
-
function getStringEnd$1(str, seek) {
|
|
1534
|
-
let first = str[seek];
|
|
1535
|
-
let target$1 = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
1536
|
-
seek += target$1.length - 1;
|
|
1537
|
-
do
|
|
1538
|
-
seek = str.indexOf(target$1, ++seek);
|
|
1539
|
-
while (seek > -1 && first !== "'" && isEscaped$1(str, seek));
|
|
1540
|
-
if (seek > -1) {
|
|
1541
|
-
seek += target$1.length;
|
|
1542
|
-
if (target$1.length > 1) {
|
|
1543
|
-
if (str[seek] === first) seek++;
|
|
1544
|
-
if (str[seek] === first) seek++;
|
|
1545
|
-
}
|
|
1546
|
-
}
|
|
1547
|
-
return seek;
|
|
1548
|
-
}
|
|
1549
|
-
__name$6(getStringEnd$1, "getStringEnd");
|
|
1550
|
-
var DATE_TIME_RE$1 = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
1443
|
+
var DATE_TIME_RE$1 = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
1551
1444
|
var TomlDate$1 = class _TomlDate extends Date {
|
|
1552
1445
|
static {
|
|
1553
1446
|
__name$6(this, "TomlDate");
|
|
@@ -1631,305 +1524,380 @@ var TomlDate$1 = class _TomlDate extends Date {
|
|
|
1631
1524
|
return date$3;
|
|
1632
1525
|
}
|
|
1633
1526
|
};
|
|
1527
|
+
function getLineColFromPtr$1(string$3, ptr) {
|
|
1528
|
+
let lines = string$3.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
1529
|
+
return [lines.length, lines.pop().length + 1];
|
|
1530
|
+
}
|
|
1531
|
+
__name$6(getLineColFromPtr$1, "getLineColFromPtr");
|
|
1532
|
+
function makeCodeBlock$1(string$3, line, column) {
|
|
1533
|
+
let lines = string$3.split(/\r\n|\n|\r/g);
|
|
1534
|
+
let codeblock = "";
|
|
1535
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
1536
|
+
for (let i$1 = line - 1; i$1 <= line + 1; i$1++) {
|
|
1537
|
+
let l = lines[i$1 - 1];
|
|
1538
|
+
if (!l) continue;
|
|
1539
|
+
codeblock += i$1.toString().padEnd(numberLen, " ");
|
|
1540
|
+
codeblock += ": ";
|
|
1541
|
+
codeblock += l;
|
|
1542
|
+
codeblock += "\n";
|
|
1543
|
+
if (i$1 === line) {
|
|
1544
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
1545
|
+
codeblock += "^\n";
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
return codeblock;
|
|
1549
|
+
}
|
|
1550
|
+
__name$6(makeCodeBlock$1, "makeCodeBlock");
|
|
1551
|
+
var TomlError$1 = class extends Error {
|
|
1552
|
+
static {
|
|
1553
|
+
__name$6(this, "TomlError");
|
|
1554
|
+
}
|
|
1555
|
+
line;
|
|
1556
|
+
column;
|
|
1557
|
+
codeblock;
|
|
1558
|
+
constructor(message, options) {
|
|
1559
|
+
const [line, column] = getLineColFromPtr$1(options.toml, options.ptr);
|
|
1560
|
+
const codeblock = makeCodeBlock$1(options.toml, line, column);
|
|
1561
|
+
super(`Invalid TOML document: ${message}
|
|
1562
|
+
|
|
1563
|
+
${codeblock}`, options);
|
|
1564
|
+
this.line = line;
|
|
1565
|
+
this.column = column;
|
|
1566
|
+
this.codeblock = codeblock;
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
function indexOfNewline$1(str, start = 0) {
|
|
1570
|
+
let idx = str.indexOf("\n", start);
|
|
1571
|
+
if (str.charCodeAt(idx - 1) === 13) idx--;
|
|
1572
|
+
return idx;
|
|
1573
|
+
}
|
|
1574
|
+
__name$6(indexOfNewline$1, "indexOfNewline");
|
|
1575
|
+
function skipComment$1(ctx) {
|
|
1576
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1577
|
+
let c$1 = ctx.s.charCodeAt(ctx.p);
|
|
1578
|
+
if (c$1 === 10) break;
|
|
1579
|
+
if (c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
1580
|
+
ctx.p++;
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
if (c$1 < 32 && c$1 !== 9 || c$1 === 127) throw new TomlError$1("control characters are not allowed in comments", {
|
|
1584
|
+
toml: ctx.s,
|
|
1585
|
+
ptr: ctx.p
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
}
|
|
1589
|
+
__name$6(skipComment$1, "skipComment");
|
|
1590
|
+
function skipVoid$1(ctx, banNewLines, banComments) {
|
|
1591
|
+
let c$1;
|
|
1592
|
+
while (1) {
|
|
1593
|
+
while ((c$1 = ctx.s.charCodeAt(ctx.p)) === 32 || c$1 === 9 || !banNewLines && (c$1 === 10 || c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) ctx.p++;
|
|
1594
|
+
if (banComments || c$1 !== 35) break;
|
|
1595
|
+
skipComment$1(ctx);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
__name$6(skipVoid$1, "skipVoid");
|
|
1599
|
+
function skipUntil$1(ctx, sep$1, end) {
|
|
1600
|
+
let ptr = ctx.p;
|
|
1601
|
+
if (!end) {
|
|
1602
|
+
ptr = indexOfNewline$1(ctx.s, ptr);
|
|
1603
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1607
|
+
let c$1 = ctx.s.charCodeAt(ctx.p);
|
|
1608
|
+
if (c$1 === 35) skipComment$1(ctx);
|
|
1609
|
+
else if (c$1 === end || c$1 === sep$1) return;
|
|
1610
|
+
}
|
|
1611
|
+
throw new TomlError$1("cannot find end of structure", {
|
|
1612
|
+
toml: ctx.s,
|
|
1613
|
+
ptr
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
__name$6(skipUntil$1, "skipUntil");
|
|
1634
1617
|
var INT_REGEX$1 = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
1635
1618
|
var FLOAT_REGEX$1 = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
1636
1619
|
var LEADING_ZERO$1 = /^[+-]?0[0-9_]/;
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
r: "\r",
|
|
1644
|
-
"\"": "\"",
|
|
1645
|
-
"\\": "\\"
|
|
1646
|
-
};
|
|
1647
|
-
function parseString$1(str, ptr = 0, endPtr = str.length) {
|
|
1648
|
-
let isLiteral = str[ptr] === "'";
|
|
1649
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
1620
|
+
function parseString$1(ctx) {
|
|
1621
|
+
let start = ctx.p;
|
|
1622
|
+
let c$1 = ctx.s.charCodeAt(ctx.p++);
|
|
1623
|
+
let first = c$1;
|
|
1624
|
+
let isLiteral = c$1 === 39;
|
|
1625
|
+
let isMultiline = c$1 === ctx.s.charCodeAt(ctx.p) && c$1 === ctx.s.charCodeAt(ctx.p + 1);
|
|
1650
1626
|
if (isMultiline) {
|
|
1651
|
-
|
|
1652
|
-
if (
|
|
1653
|
-
if (str[ptr] === "\n") ptr++;
|
|
1627
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p += 2)) === 10) ctx.p++;
|
|
1628
|
+
else if (c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) ctx.p += 2;
|
|
1654
1629
|
}
|
|
1655
|
-
let tmp = 0;
|
|
1656
|
-
let isEscape;
|
|
1657
1630
|
let parsed = "";
|
|
1658
|
-
let sliceStart =
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
}
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
if (
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
toml: str,
|
|
1690
|
-
ptr: tmp
|
|
1631
|
+
let sliceStart = ctx.p;
|
|
1632
|
+
let state = 0;
|
|
1633
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
1634
|
+
c$1 = ctx.s.charCodeAt(ctx.p);
|
|
1635
|
+
if (isMultiline && (c$1 === 10 || c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) state = state && 3;
|
|
1636
|
+
else if (c$1 < 32 && c$1 !== 9 || c$1 === 127) throw new TomlError$1("control characters are not allowed in strings", {
|
|
1637
|
+
toml: ctx.s,
|
|
1638
|
+
ptr: ctx.p
|
|
1639
|
+
});
|
|
1640
|
+
else if ((!state || state === 3) && c$1 === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
1641
|
+
if (isMultiline) {
|
|
1642
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
1643
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
1644
|
+
}
|
|
1645
|
+
if (!state) parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
1646
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
1647
|
+
return parsed;
|
|
1648
|
+
} else if (!state) {
|
|
1649
|
+
if (!isLiteral && c$1 === 92) {
|
|
1650
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
1651
|
+
state = 1;
|
|
1652
|
+
}
|
|
1653
|
+
} else if (state === 1) if (c$1 === 120 || c$1 === 117 || c$1 === 85) {
|
|
1654
|
+
let value = 0;
|
|
1655
|
+
let len = c$1 === 120 ? 2 : c$1 === 117 ? 4 : 8;
|
|
1656
|
+
for (let j$1 = 0; j$1 < len; j$1++, ctx.p++) {
|
|
1657
|
+
let hex$1 = ctx.s.charCodeAt(ctx.p + 1);
|
|
1658
|
+
let digit = hex$1 >= 48 && hex$1 <= 57 ? hex$1 - 48 : hex$1 >= 65 && hex$1 <= 70 ? hex$1 - 65 + 10 : hex$1 >= 97 && hex$1 <= 102 ? hex$1 - 97 + 10 : -1;
|
|
1659
|
+
if (digit < 0) throw new TomlError$1("invalid non-hex character in unicode escape", {
|
|
1660
|
+
toml: ctx.s,
|
|
1661
|
+
ptr: ctx.p + 1
|
|
1691
1662
|
});
|
|
1692
|
-
|
|
1693
|
-
}
|
|
1663
|
+
value = value << 4 | digit;
|
|
1664
|
+
}
|
|
1665
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new TomlError$1("invalid unicode escape", {
|
|
1666
|
+
toml: ctx.s,
|
|
1667
|
+
ptr: ctx.p
|
|
1668
|
+
});
|
|
1669
|
+
parsed += String.fromCodePoint(value);
|
|
1670
|
+
sliceStart = ctx.p + 1;
|
|
1671
|
+
state = 0;
|
|
1672
|
+
} else if (c$1 === 32 || c$1 === 9) state = 2;
|
|
1673
|
+
else {
|
|
1674
|
+
if (c$1 === 98) parsed += "\b";
|
|
1675
|
+
else if (c$1 === 116) parsed += " ";
|
|
1676
|
+
else if (c$1 === 110) parsed += "\n";
|
|
1677
|
+
else if (c$1 === 102) parsed += "\f";
|
|
1678
|
+
else if (c$1 === 114) parsed += "\r";
|
|
1679
|
+
else if (c$1 === 101) parsed += "\x1B";
|
|
1680
|
+
else if (c$1 === 34) parsed += "\"";
|
|
1681
|
+
else if (c$1 === 92) parsed += "\\";
|
|
1694
1682
|
else throw new TomlError$1("unrecognized escape sequence", {
|
|
1695
|
-
toml:
|
|
1696
|
-
ptr:
|
|
1683
|
+
toml: ctx.s,
|
|
1684
|
+
ptr: ctx.p
|
|
1685
|
+
});
|
|
1686
|
+
sliceStart = ctx.p + 1;
|
|
1687
|
+
state = 0;
|
|
1688
|
+
}
|
|
1689
|
+
else if (c$1 !== 32 && c$1 !== 9) {
|
|
1690
|
+
if (state === 2) throw new TomlError$1("invalid escape: only line-ending whitespace may be escaped", {
|
|
1691
|
+
toml: ctx.s,
|
|
1692
|
+
ptr: sliceStart
|
|
1697
1693
|
});
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
tmp = ptr - 1;
|
|
1701
|
-
isEscape = true;
|
|
1702
|
-
parsed += str.slice(sliceStart, tmp);
|
|
1694
|
+
state = !isLiteral && c$1 === 92 ? 1 : 0;
|
|
1695
|
+
sliceStart = ctx.p;
|
|
1703
1696
|
}
|
|
1704
1697
|
}
|
|
1705
|
-
|
|
1698
|
+
throw new TomlError$1("unfinished string", {
|
|
1699
|
+
toml: ctx.s,
|
|
1700
|
+
ptr: start
|
|
1701
|
+
});
|
|
1706
1702
|
}
|
|
1707
1703
|
__name$6(parseString$1, "parseString");
|
|
1708
|
-
function
|
|
1709
|
-
|
|
1710
|
-
|
|
1704
|
+
function sliceAndTrimEndOf$1(ctx, start, end) {
|
|
1705
|
+
let value = ctx.s.slice(start, end);
|
|
1706
|
+
let commentIdx = value.indexOf("#");
|
|
1707
|
+
if (commentIdx > 0) {
|
|
1708
|
+
skipComment$1({
|
|
1709
|
+
s: value,
|
|
1710
|
+
p: commentIdx
|
|
1711
|
+
});
|
|
1712
|
+
value = value.slice(0, commentIdx);
|
|
1713
|
+
}
|
|
1714
|
+
return value.trimEnd();
|
|
1715
|
+
}
|
|
1716
|
+
__name$6(sliceAndTrimEndOf$1, "sliceAndTrimEndOf");
|
|
1717
|
+
function parseValue$1(ctx, integersAsBigInt, end) {
|
|
1718
|
+
let ptr = ctx.p;
|
|
1719
|
+
let err = {
|
|
1720
|
+
toml: ctx.s,
|
|
1721
|
+
ptr
|
|
1722
|
+
};
|
|
1723
|
+
skipUntil$1(ctx, 44, end);
|
|
1724
|
+
let value = sliceAndTrimEndOf$1(ctx, ptr, ctx.p);
|
|
1725
|
+
if (!value) throw new TomlError$1("incomplete declaration: value expected", err);
|
|
1711
1726
|
if (value === "-inf") return -Infinity;
|
|
1712
1727
|
if (value === "inf" || value === "+inf") return Infinity;
|
|
1713
1728
|
if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
|
|
1714
1729
|
if (value === "-0") return integersAsBigInt ? 0n : 0;
|
|
1715
1730
|
let isInt = INT_REGEX$1.test(value);
|
|
1716
1731
|
if (isInt || FLOAT_REGEX$1.test(value)) {
|
|
1717
|
-
if (LEADING_ZERO$1.test(value)) throw new TomlError$1("leading zeroes are not allowed",
|
|
1718
|
-
toml,
|
|
1719
|
-
ptr
|
|
1720
|
-
});
|
|
1732
|
+
if (LEADING_ZERO$1.test(value)) throw new TomlError$1("leading zeroes are not allowed", err);
|
|
1721
1733
|
value = value.replace(/_/g, "");
|
|
1722
1734
|
let numeric$1 = +value;
|
|
1723
|
-
if (isNaN(numeric$1)) throw new TomlError$1("invalid number",
|
|
1724
|
-
toml,
|
|
1725
|
-
ptr
|
|
1726
|
-
});
|
|
1735
|
+
if (isNaN(numeric$1)) throw new TomlError$1("invalid number", err);
|
|
1727
1736
|
if (isInt) {
|
|
1728
|
-
if ((isInt = !Number.isSafeInteger(numeric$1)) && !integersAsBigInt) throw new TomlError$1("integer value cannot be represented losslessly",
|
|
1729
|
-
toml,
|
|
1730
|
-
ptr
|
|
1731
|
-
});
|
|
1737
|
+
if ((isInt = !Number.isSafeInteger(numeric$1)) && !integersAsBigInt) throw new TomlError$1("integer value cannot be represented losslessly", err);
|
|
1732
1738
|
if (isInt || integersAsBigInt === true) numeric$1 = BigInt(value);
|
|
1733
1739
|
}
|
|
1734
1740
|
return numeric$1;
|
|
1735
1741
|
}
|
|
1736
1742
|
const date$3 = new TomlDate$1(value);
|
|
1737
|
-
if (!date$3.isValid()) throw new TomlError$1("invalid value",
|
|
1738
|
-
toml,
|
|
1739
|
-
ptr
|
|
1740
|
-
});
|
|
1743
|
+
if (!date$3.isValid()) throw new TomlError$1("invalid value", err);
|
|
1741
1744
|
return date$3;
|
|
1742
1745
|
}
|
|
1743
1746
|
__name$6(parseValue$1, "parseValue");
|
|
1744
|
-
function
|
|
1745
|
-
let
|
|
1746
|
-
let
|
|
1747
|
-
if (
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
let trimmed = value.trimEnd();
|
|
1752
|
-
if (!allowNewLines) {
|
|
1753
|
-
let newlineIdx = value.indexOf("\n", trimmed.length);
|
|
1754
|
-
if (newlineIdx > -1) throw new TomlError$1("newlines are not allowed in inline tables", {
|
|
1755
|
-
toml: str,
|
|
1756
|
-
ptr: startPtr + newlineIdx
|
|
1747
|
+
function extractValue$1(ctx, end, integersAsBigInt) {
|
|
1748
|
+
let ptr = ctx.p;
|
|
1749
|
+
let c$1 = ctx.s.charCodeAt(ptr);
|
|
1750
|
+
if (c$1 === 91 || c$1 === 123) {
|
|
1751
|
+
if (!ctx.d--) throw new TomlError$1("document contains excessively nested structures. aborting.", {
|
|
1752
|
+
toml: ctx.s,
|
|
1753
|
+
ptr
|
|
1757
1754
|
});
|
|
1755
|
+
let value = c$1 === 91 ? parseArray$1(ctx, integersAsBigInt) : parseInlineTable$1(ctx, integersAsBigInt);
|
|
1756
|
+
ctx.d++;
|
|
1757
|
+
return value;
|
|
1758
1758
|
}
|
|
1759
|
-
return
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
let c$1 = str[ptr];
|
|
1768
|
-
if (c$1 === "[" || c$1 === "{") {
|
|
1769
|
-
let [value, endPtr2] = c$1 === "[" ? parseArray$1(str, ptr, depth$1, integersAsBigInt) : parseInlineTable$1(str, ptr, depth$1, integersAsBigInt);
|
|
1770
|
-
let newPtr = end ? skipUntil$1(str, endPtr2, ",", end) : endPtr2;
|
|
1771
|
-
if (endPtr2 - newPtr && end === "}") {
|
|
1772
|
-
let nextNewLine = indexOfNewline$1(str, endPtr2, newPtr);
|
|
1773
|
-
if (nextNewLine > -1) throw new TomlError$1("newlines are not allowed in inline tables", {
|
|
1774
|
-
toml: str,
|
|
1775
|
-
ptr: nextNewLine
|
|
1776
|
-
});
|
|
1777
|
-
}
|
|
1778
|
-
return [value, newPtr];
|
|
1779
|
-
}
|
|
1780
|
-
let endPtr;
|
|
1781
|
-
if (c$1 === "\"" || c$1 === "'") {
|
|
1782
|
-
endPtr = getStringEnd$1(str, ptr);
|
|
1783
|
-
let parsed = parseString$1(str, ptr, endPtr);
|
|
1784
|
-
if (end) {
|
|
1785
|
-
endPtr = skipVoid$1(str, endPtr, end !== "]");
|
|
1786
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") throw new TomlError$1("unexpected character encountered", {
|
|
1787
|
-
toml: str,
|
|
1788
|
-
ptr: endPtr
|
|
1789
|
-
});
|
|
1790
|
-
endPtr += +(str[endPtr] === ",");
|
|
1791
|
-
}
|
|
1792
|
-
return [parsed, endPtr];
|
|
1759
|
+
if (c$1 === 34 || c$1 === 39) return parseString$1(ctx);
|
|
1760
|
+
if (c$1 === 116) {
|
|
1761
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError$1("invalid value", {
|
|
1762
|
+
toml: ctx.s,
|
|
1763
|
+
ptr
|
|
1764
|
+
});
|
|
1765
|
+
ctx.p++;
|
|
1766
|
+
return true;
|
|
1793
1767
|
}
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
endPtr = skipVoid$1(str, ptr + slice[1]);
|
|
1802
|
-
endPtr += +(str[endPtr] === ",");
|
|
1768
|
+
if (c$1 === 102) {
|
|
1769
|
+
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) throw new TomlError$1("invalid value", {
|
|
1770
|
+
toml: ctx.s,
|
|
1771
|
+
ptr
|
|
1772
|
+
});
|
|
1773
|
+
ctx.p++;
|
|
1774
|
+
return false;
|
|
1803
1775
|
}
|
|
1804
|
-
return
|
|
1776
|
+
return parseValue$1(ctx, integersAsBigInt, end);
|
|
1805
1777
|
}
|
|
1806
1778
|
__name$6(extractValue$1, "extractValue");
|
|
1807
1779
|
var KEY_PART_RE$1 = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
1808
|
-
function parseKey$1(
|
|
1809
|
-
let
|
|
1780
|
+
function parseKey$1(ctx, end = "=") {
|
|
1781
|
+
let start = ctx.p;
|
|
1782
|
+
let dot = start - 1;
|
|
1810
1783
|
let parsed = [];
|
|
1811
|
-
let endPtr =
|
|
1784
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
1812
1785
|
if (endPtr < 0) throw new TomlError$1("incomplete key-value: cannot find end of key", {
|
|
1813
|
-
toml:
|
|
1814
|
-
ptr
|
|
1786
|
+
toml: ctx.s,
|
|
1787
|
+
ptr: start
|
|
1815
1788
|
});
|
|
1816
1789
|
do {
|
|
1817
|
-
let c$1 =
|
|
1818
|
-
if (c$1 !==
|
|
1819
|
-
if (c$1 ===
|
|
1820
|
-
toml:
|
|
1821
|
-
ptr
|
|
1790
|
+
let c$1 = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
1791
|
+
if (c$1 !== 32 && c$1 !== 9) if (c$1 === 34 || c$1 === 39) {
|
|
1792
|
+
if (c$1 === ctx.s.charCodeAt(ctx.p + 1) && c$1 === ctx.s.charCodeAt(ctx.p + 2)) throw new TomlError$1("multiline strings are not allowed in keys", {
|
|
1793
|
+
toml: ctx.s,
|
|
1794
|
+
ptr: ctx.p
|
|
1822
1795
|
});
|
|
1823
|
-
let
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
ptr
|
|
1827
|
-
});
|
|
1828
|
-
dot = str.indexOf(".", eos);
|
|
1829
|
-
let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1796
|
+
let part = parseString$1(ctx);
|
|
1797
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1798
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1830
1799
|
let newLine = indexOfNewline$1(strEnd);
|
|
1831
1800
|
if (newLine > -1) throw new TomlError$1("newlines are not allowed in keys", {
|
|
1832
|
-
toml:
|
|
1833
|
-
ptr:
|
|
1801
|
+
toml: ctx.s,
|
|
1802
|
+
ptr: newLine
|
|
1834
1803
|
});
|
|
1835
1804
|
if (strEnd.trimStart()) throw new TomlError$1("found extra tokens after the string part", {
|
|
1836
|
-
toml:
|
|
1837
|
-
ptr:
|
|
1805
|
+
toml: ctx.s,
|
|
1806
|
+
ptr: ctx.p
|
|
1838
1807
|
});
|
|
1839
|
-
if (endPtr <
|
|
1840
|
-
endPtr =
|
|
1808
|
+
if (endPtr < ctx.p) {
|
|
1809
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
1841
1810
|
if (endPtr < 0) throw new TomlError$1("incomplete key-value: cannot find end of key", {
|
|
1842
|
-
toml:
|
|
1843
|
-
ptr
|
|
1811
|
+
toml: ctx.s,
|
|
1812
|
+
ptr: start
|
|
1844
1813
|
});
|
|
1845
1814
|
}
|
|
1846
|
-
parsed.push(
|
|
1815
|
+
parsed.push(part);
|
|
1847
1816
|
} else {
|
|
1848
|
-
dot =
|
|
1849
|
-
let part =
|
|
1817
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
1818
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
1850
1819
|
if (!KEY_PART_RE$1.test(part)) throw new TomlError$1("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
1851
|
-
toml:
|
|
1852
|
-
ptr
|
|
1820
|
+
toml: ctx.s,
|
|
1821
|
+
ptr: ctx.p
|
|
1853
1822
|
});
|
|
1854
1823
|
parsed.push(part.trimEnd());
|
|
1855
1824
|
}
|
|
1856
1825
|
} while (dot + 1 && dot < endPtr);
|
|
1857
|
-
|
|
1826
|
+
ctx.p = endPtr + 1;
|
|
1827
|
+
skipVoid$1(ctx, true, true);
|
|
1828
|
+
return parsed;
|
|
1858
1829
|
}
|
|
1859
1830
|
__name$6(parseKey$1, "parseKey");
|
|
1860
|
-
function parseInlineTable$1(
|
|
1831
|
+
function parseInlineTable$1(ctx, integersAsBigInt) {
|
|
1861
1832
|
let res = {};
|
|
1862
1833
|
let seen = /* @__PURE__ */ new Set();
|
|
1863
1834
|
let c$1;
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
}
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
enumerable: true,
|
|
1888
|
-
configurable: true,
|
|
1889
|
-
writable: true
|
|
1890
|
-
});
|
|
1891
|
-
}
|
|
1892
|
-
if (hasOwn$1) throw new TomlError$1("trying to redefine an already defined value", {
|
|
1893
|
-
toml: str,
|
|
1894
|
-
ptr
|
|
1835
|
+
ctx.p++;
|
|
1836
|
+
while (ctx.p < ctx.s.length) {
|
|
1837
|
+
skipVoid$1(ctx);
|
|
1838
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
1839
|
+
ctx.p++;
|
|
1840
|
+
return res;
|
|
1841
|
+
}
|
|
1842
|
+
let k;
|
|
1843
|
+
let t$5 = res;
|
|
1844
|
+
let hasOwn$1 = false;
|
|
1845
|
+
let p$2 = ctx.p;
|
|
1846
|
+
let key = parseKey$1(ctx);
|
|
1847
|
+
for (let i$1 = 0; i$1 < key.length; i$1++) {
|
|
1848
|
+
if (i$1) t$5 = hasOwn$1 ? t$5[k] : t$5[k] = {};
|
|
1849
|
+
k = key[i$1];
|
|
1850
|
+
if ((hasOwn$1 = Object.hasOwn(t$5, k)) && (typeof t$5[k] !== "object" || seen.has(t$5[k]))) throw new TomlError$1("trying to redefine an already defined value", {
|
|
1851
|
+
toml: ctx.s,
|
|
1852
|
+
ptr: p$2
|
|
1853
|
+
});
|
|
1854
|
+
if (!hasOwn$1 && k === "__proto__") Object.defineProperty(t$5, k, {
|
|
1855
|
+
enumerable: true,
|
|
1856
|
+
configurable: true,
|
|
1857
|
+
writable: true
|
|
1895
1858
|
});
|
|
1896
|
-
let [value, valueEndPtr] = extractValue$1(str, keyEndPtr, "}", depth$1 - 1, integersAsBigInt);
|
|
1897
|
-
seen.add(value);
|
|
1898
|
-
t$5[k] = value;
|
|
1899
|
-
ptr = valueEndPtr;
|
|
1900
|
-
comma$1 = str[ptr - 1] === "," ? ptr - 1 : 0;
|
|
1901
1859
|
}
|
|
1860
|
+
if (hasOwn$1) throw new TomlError$1("trying to redefine an already defined value", {
|
|
1861
|
+
toml: ctx.s,
|
|
1862
|
+
ptr: ctx.p
|
|
1863
|
+
});
|
|
1864
|
+
let value = extractValue$1(ctx, 125, integersAsBigInt);
|
|
1865
|
+
seen.add(t$5[k] = value);
|
|
1866
|
+
skipVoid$1(ctx);
|
|
1867
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p++)) === 125) return res;
|
|
1868
|
+
if (c$1 !== 44) throw new TomlError$1("expected comma or end of structure", {
|
|
1869
|
+
toml: ctx.s,
|
|
1870
|
+
ptr: ctx.p - 1
|
|
1871
|
+
});
|
|
1902
1872
|
}
|
|
1903
|
-
|
|
1904
|
-
toml:
|
|
1905
|
-
ptr:
|
|
1873
|
+
throw new TomlError$1("unfinished table encountered", {
|
|
1874
|
+
toml: ctx.s,
|
|
1875
|
+
ptr: ctx.p
|
|
1906
1876
|
});
|
|
1907
|
-
if (!c$1) throw new TomlError$1("unfinished table encountered", {
|
|
1908
|
-
toml: str,
|
|
1909
|
-
ptr
|
|
1910
|
-
});
|
|
1911
|
-
return [res, ptr];
|
|
1912
1877
|
}
|
|
1913
1878
|
__name$6(parseInlineTable$1, "parseInlineTable");
|
|
1914
|
-
function parseArray$1(
|
|
1879
|
+
function parseArray$1(ctx, integersAsBigInt) {
|
|
1915
1880
|
let res = [];
|
|
1916
1881
|
let c$1;
|
|
1917
|
-
|
|
1918
|
-
while (
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1882
|
+
ctx.p++;
|
|
1883
|
+
while (ctx.p < ctx.s.length) {
|
|
1884
|
+
skipVoid$1(ctx);
|
|
1885
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
1886
|
+
ctx.p++;
|
|
1887
|
+
return res;
|
|
1888
|
+
}
|
|
1889
|
+
res.push(extractValue$1(ctx, 93, integersAsBigInt));
|
|
1890
|
+
skipVoid$1(ctx);
|
|
1891
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p++)) === 93) return res;
|
|
1892
|
+
if (c$1 !== 44) throw new TomlError$1("expected comma or end of structure", {
|
|
1893
|
+
toml: ctx.s,
|
|
1894
|
+
ptr: ctx.p - 1
|
|
1895
|
+
});
|
|
1896
|
+
}
|
|
1897
|
+
throw new TomlError$1("unfinished array encountered", {
|
|
1898
|
+
toml: ctx.s,
|
|
1899
|
+
ptr: ctx.p
|
|
1931
1900
|
});
|
|
1932
|
-
return [res, ptr];
|
|
1933
1901
|
}
|
|
1934
1902
|
__name$6(parseArray$1, "parseArray");
|
|
1935
1903
|
function peekTable$1(key, table, meta$3, type) {
|
|
@@ -1999,46 +1967,51 @@ function peekTable$1(key, table, meta$3, type) {
|
|
|
1999
1967
|
}
|
|
2000
1968
|
__name$6(peekTable$1, "peekTable");
|
|
2001
1969
|
function parse3(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
1970
|
+
let ctx = {
|
|
1971
|
+
s: toml,
|
|
1972
|
+
p: 0,
|
|
1973
|
+
d: maxDepth
|
|
1974
|
+
};
|
|
2002
1975
|
let res = {};
|
|
2003
1976
|
let meta$3 = {};
|
|
1977
|
+
let tmp;
|
|
2004
1978
|
let tbl = res;
|
|
2005
1979
|
let m = meta$3;
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
let
|
|
1980
|
+
skipVoid$1(ctx);
|
|
1981
|
+
while (ctx.p < toml.length) {
|
|
1982
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
1983
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
1984
|
+
tmp = ctx.p += +isTableArray;
|
|
1985
|
+
let k = parseKey$1(ctx, "]");
|
|
2010
1986
|
if (isTableArray) {
|
|
2011
|
-
if (toml
|
|
1987
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) throw new TomlError$1("expected end of table declaration", {
|
|
2012
1988
|
toml,
|
|
2013
|
-
ptr:
|
|
1989
|
+
ptr: ctx.p - 1
|
|
2014
1990
|
});
|
|
2015
|
-
|
|
1991
|
+
ctx.p++;
|
|
2016
1992
|
}
|
|
2017
|
-
let p$2 = peekTable$1(k
|
|
1993
|
+
let p$2 = peekTable$1(k, res, meta$3, isTableArray ? 2 : 1);
|
|
2018
1994
|
if (!p$2) throw new TomlError$1("trying to redefine an already defined table or value", {
|
|
2019
1995
|
toml,
|
|
2020
|
-
ptr
|
|
1996
|
+
ptr: tmp
|
|
2021
1997
|
});
|
|
2022
1998
|
m = p$2[2];
|
|
2023
1999
|
tbl = p$2[1];
|
|
2024
|
-
ptr = k[1];
|
|
2025
2000
|
} else {
|
|
2026
|
-
|
|
2027
|
-
let p$2 = peekTable$1(
|
|
2001
|
+
tmp = ctx.p;
|
|
2002
|
+
let p$2 = peekTable$1(parseKey$1(ctx), tbl, m, 0);
|
|
2028
2003
|
if (!p$2) throw new TomlError$1("trying to redefine an already defined table or value", {
|
|
2029
2004
|
toml,
|
|
2030
|
-
ptr
|
|
2005
|
+
ptr: tmp
|
|
2031
2006
|
});
|
|
2032
|
-
|
|
2033
|
-
p$2[1][p$2[0]] = v[0];
|
|
2034
|
-
ptr = v[1];
|
|
2007
|
+
p$2[1][p$2[0]] = extractValue$1(ctx, void 0, integersAsBigInt);
|
|
2035
2008
|
}
|
|
2036
|
-
|
|
2037
|
-
if (toml
|
|
2009
|
+
skipVoid$1(ctx, true);
|
|
2010
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) throw new TomlError$1("each key-value declaration must be followed by an end-of-line", {
|
|
2038
2011
|
toml,
|
|
2039
|
-
ptr
|
|
2012
|
+
ptr: ctx.p
|
|
2040
2013
|
});
|
|
2041
|
-
|
|
2014
|
+
skipVoid$1(ctx);
|
|
2042
2015
|
}
|
|
2043
2016
|
return res;
|
|
2044
2017
|
}
|
|
@@ -2048,7 +2021,8 @@ function extendedTypeOf$1(obj) {
|
|
|
2048
2021
|
let type = typeof obj;
|
|
2049
2022
|
if (type === "object") {
|
|
2050
2023
|
if (Array.isArray(obj)) return "array";
|
|
2051
|
-
if (obj instanceof Date) return "date";
|
|
2024
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date) return "date";
|
|
2025
|
+
if (globalThis.Temporal && typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) return "temporal";
|
|
2052
2026
|
}
|
|
2053
2027
|
return type;
|
|
2054
2028
|
}
|
|
@@ -2062,23 +2036,31 @@ function formatString$1(s) {
|
|
|
2062
2036
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
2063
2037
|
}
|
|
2064
2038
|
__name$6(formatString$1, "formatString");
|
|
2039
|
+
function stringifyTemporal$1(temporal) {
|
|
2040
|
+
return temporal.toString({
|
|
2041
|
+
calendarName: "never",
|
|
2042
|
+
timeZoneName: "never"
|
|
2043
|
+
});
|
|
2044
|
+
}
|
|
2045
|
+
__name$6(stringifyTemporal$1, "stringifyTemporal");
|
|
2065
2046
|
function stringifyValue$1(val, type, depth$1, numberAsFloat) {
|
|
2066
2047
|
if (depth$1 === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2048
|
+
switch (type) {
|
|
2049
|
+
case "number":
|
|
2050
|
+
if (isNaN(val)) return "nan";
|
|
2051
|
+
if (val === Infinity) return "inf";
|
|
2052
|
+
if (val === -Infinity) return "-inf";
|
|
2053
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val))) return val.toFixed(1);
|
|
2054
|
+
case "bigint":
|
|
2055
|
+
case "boolean": return val.toString();
|
|
2056
|
+
case "string": return formatString$1(val);
|
|
2057
|
+
case "date":
|
|
2058
|
+
if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
|
|
2059
|
+
return val.toISOString();
|
|
2060
|
+
case "object": return stringifyInlineTable$1(val, depth$1, numberAsFloat);
|
|
2061
|
+
case "array": return stringifyArray$1(val, depth$1, numberAsFloat);
|
|
2062
|
+
case "temporal": return stringifyTemporal$1(val);
|
|
2063
|
+
}
|
|
2082
2064
|
}
|
|
2083
2065
|
__name$6(stringifyValue$1, "stringifyValue");
|
|
2084
2066
|
function stringifyInlineTable$1(obj, depth$1, numberAsFloat) {
|
|
@@ -56736,7 +56718,7 @@ var import_dist = (/* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ts-d
|
|
|
56736
56718
|
exports$1.dedent = dedent$1$1;
|
|
56737
56719
|
}) }))();
|
|
56738
56720
|
/**
|
|
56739
|
-
* Generate the content for
|
|
56721
|
+
* Generate the content for a Worker types declaration file.
|
|
56740
56722
|
*
|
|
56741
56723
|
* @example
|
|
56742
56724
|
* ```typescript
|
|
@@ -56744,10 +56726,10 @@ var import_dist = (/* @__PURE__ */ __commonJS$1({ "../../node_modules/.pnpm/ts-d
|
|
|
56744
56726
|
* import { writeFileSync } from "node:fs";
|
|
56745
56727
|
*
|
|
56746
56728
|
* const content = generateTypes({
|
|
56747
|
-
* configPath: "
|
|
56729
|
+
* configPath: "../../cloudflare.config.ts",
|
|
56748
56730
|
* });
|
|
56749
56731
|
*
|
|
56750
|
-
* writeFileSync("
|
|
56732
|
+
* writeFileSync(".cloudflare/types/index.d.ts", content);
|
|
56751
56733
|
* ```
|
|
56752
56734
|
*/
|
|
56753
56735
|
function generateTypes({ configPath, packageName = "@cloudflare/config" }) {
|
|
@@ -65424,7 +65406,6 @@ async function resolvePluginConfig(pluginConfig, userConfig, viteEnv) {
|
|
|
65424
65406
|
const result = await loadNewConfig({
|
|
65425
65407
|
root,
|
|
65426
65408
|
mode: viteEnv.mode,
|
|
65427
|
-
command: viteEnv.command,
|
|
65428
65409
|
types: resolvedNewConfig.types
|
|
65429
65410
|
});
|
|
65430
65411
|
configPath = result.configPath;
|
|
@@ -65555,7 +65536,7 @@ function resolveWorker(workerConfig, devOnly, parsedNewWorkerConfig) {
|
|
|
65555
65536
|
};
|
|
65556
65537
|
}
|
|
65557
65538
|
const NEW_CONFIG_FILENAME = "cloudflare.config.ts";
|
|
65558
|
-
const
|
|
65539
|
+
const TYPES_OUTPUT_PATH = ".cloudflare/types/index.d.ts";
|
|
65559
65540
|
const EXPERIMENTAL_CONFIG_PKG = "@cloudflare/vite-plugin/experimental-config";
|
|
65560
65541
|
/**
|
|
65561
65542
|
* Load and convert a `cloudflare.config.ts` file via `@cloudflare/config`. Returns
|
|
@@ -65564,9 +65545,8 @@ const EXPERIMENTAL_CONFIG_PKG = "@cloudflare/vite-plugin/experimental-config";
|
|
|
65564
65545
|
* file, and the set of files imported while resolving the config (for
|
|
65565
65546
|
* watch-mode).
|
|
65566
65547
|
*
|
|
65567
|
-
* When `types.generate` is true, also writes
|
|
65568
|
-
*
|
|
65569
|
-
* Type generation only runs in dev.
|
|
65548
|
+
* When `types.generate` is true, also writes `.cloudflare/types/index.d.ts`
|
|
65549
|
+
* when the generated content differs from what's already on disk.
|
|
65570
65550
|
*/
|
|
65571
65551
|
async function loadNewConfig(options) {
|
|
65572
65552
|
const configPath = path.resolve(options.root, NEW_CONFIG_FILENAME);
|
|
@@ -65579,7 +65559,7 @@ async function loadNewConfig(options) {
|
|
|
65579
65559
|
const worker = result.data.worker;
|
|
65580
65560
|
if (worker === void 0) throw new Error(`\`${NEW_CONFIG_FILENAME}\` must define a Worker using the \`worker\` property.`);
|
|
65581
65561
|
const rawConfig = convertToWranglerConfig(result.data);
|
|
65582
|
-
if (options.
|
|
65562
|
+
if (options.types.generate) await writeCloudflareTypes({
|
|
65583
65563
|
root: options.root,
|
|
65584
65564
|
configPath,
|
|
65585
65565
|
includeRuntime: options.types.includeRuntime,
|
|
@@ -65594,7 +65574,7 @@ async function loadNewConfig(options) {
|
|
|
65594
65574
|
};
|
|
65595
65575
|
}
|
|
65596
65576
|
/**
|
|
65597
|
-
* Write
|
|
65577
|
+
* Write `.cloudflare/types/index.d.ts` using
|
|
65598
65578
|
* `@cloudflare/config`'s `generateTypes`, targeting the vite-plugin's
|
|
65599
65579
|
* `experimental-config` subpath (so users don't need a direct dependency on
|
|
65600
65580
|
* `@cloudflare/config`).
|
|
@@ -65608,15 +65588,17 @@ async function loadNewConfig(options) {
|
|
|
65608
65588
|
* check and the diff-before-write (only writes if content differs, to avoid
|
|
65609
65589
|
* touching mtimes unnecessarily).
|
|
65610
65590
|
*/
|
|
65611
|
-
async function
|
|
65612
|
-
const outputPath = path.resolve(options.root,
|
|
65613
|
-
const
|
|
65591
|
+
async function writeCloudflareTypes(options) {
|
|
65592
|
+
const outputPath = path.resolve(options.root, TYPES_OUTPUT_PATH);
|
|
65593
|
+
const outputDir = path.dirname(outputPath);
|
|
65594
|
+
const relativeConfigPath = vite.normalizePath(path.relative(outputDir, options.configPath));
|
|
65595
|
+
const configImportPath = relativeConfigPath.startsWith(".") ? relativeConfigPath : `./${relativeConfigPath}`;
|
|
65614
65596
|
let existingContent;
|
|
65615
65597
|
try {
|
|
65616
65598
|
existingContent = await fsp.readFile(outputPath, "utf8");
|
|
65617
65599
|
} catch {}
|
|
65618
65600
|
let content = generateTypes({
|
|
65619
|
-
configPath:
|
|
65601
|
+
configPath: configImportPath,
|
|
65620
65602
|
packageName: EXPERIMENTAL_CONFIG_PKG
|
|
65621
65603
|
});
|
|
65622
65604
|
if (options.includeRuntime) {
|
|
@@ -65627,7 +65609,10 @@ async function writeWorkerConfigurationDts(options) {
|
|
|
65627
65609
|
});
|
|
65628
65610
|
content += `\n${runtimeHeader}\n${RUNTIME_TYPES_MARKER}\n${runtimeTypes}`;
|
|
65629
65611
|
}
|
|
65630
|
-
if (existingContent !== content)
|
|
65612
|
+
if (existingContent !== content) {
|
|
65613
|
+
await fsp.mkdir(outputDir, { recursive: true });
|
|
65614
|
+
await fsp.writeFile(outputPath, content);
|
|
65615
|
+
}
|
|
65631
65616
|
}
|
|
65632
65617
|
|
|
65633
65618
|
//#endregion
|
|
@@ -80003,6 +79988,79 @@ const generateStaticRoutingRuleMatcher = (rules) => ({ request: request$2 }) =>
|
|
|
80003
79988
|
return false;
|
|
80004
79989
|
};
|
|
80005
79990
|
|
|
79991
|
+
//#endregion
|
|
79992
|
+
//#region src/container-cleanup.ts
|
|
79993
|
+
/** Owns Container cleanup for one server session, including failed attempts. */
|
|
79994
|
+
function createContainerCleanup() {
|
|
79995
|
+
const pendingImages = /* @__PURE__ */ new Map();
|
|
79996
|
+
let restarting = false;
|
|
79997
|
+
function cleanupContainerImages() {
|
|
79998
|
+
for (const [dockerPath, imageTags] of pendingImages) if (cleanupContainers(dockerPath, imageTags)) pendingImages.delete(dockerPath);
|
|
79999
|
+
if (pendingImages.size === 0) process.off("exit", cleanupContainerImages);
|
|
80000
|
+
}
|
|
80001
|
+
return {
|
|
80002
|
+
cleanup: cleanupContainerImages,
|
|
80003
|
+
get isRestarting() {
|
|
80004
|
+
return restarting;
|
|
80005
|
+
},
|
|
80006
|
+
async restart(action) {
|
|
80007
|
+
if (restarting) return action();
|
|
80008
|
+
cleanupContainerImages();
|
|
80009
|
+
restarting = true;
|
|
80010
|
+
try {
|
|
80011
|
+
await action();
|
|
80012
|
+
} finally {
|
|
80013
|
+
restarting = false;
|
|
80014
|
+
}
|
|
80015
|
+
},
|
|
80016
|
+
track(dockerPath, imageTags) {
|
|
80017
|
+
const tags = new Set([...pendingImages.get(dockerPath) ?? [], ...imageTags]);
|
|
80018
|
+
if (tags.size === 0) return;
|
|
80019
|
+
pendingImages.set(dockerPath, tags);
|
|
80020
|
+
process.off("exit", cleanupContainerImages);
|
|
80021
|
+
process.on("exit", cleanupContainerImages);
|
|
80022
|
+
}
|
|
80023
|
+
};
|
|
80024
|
+
}
|
|
80025
|
+
/**
|
|
80026
|
+
* Retains Container cleanup across config reloads using Vite's inline plugins.
|
|
80027
|
+
* The state belongs to this server, not the re-evaluated cloudflare() factory.
|
|
80028
|
+
*/
|
|
80029
|
+
function getDevContainerCleanup(server) {
|
|
80030
|
+
const pluginName = "vite-plugin-cloudflare:container-cleanup";
|
|
80031
|
+
const retainedPlugin = server.config.plugins.find((plugin$1) => plugin$1.name === pluginName);
|
|
80032
|
+
if (retainedPlugin?.api) return retainedPlugin.api;
|
|
80033
|
+
const cleanup = createContainerCleanup();
|
|
80034
|
+
const plugin = {
|
|
80035
|
+
name: pluginName,
|
|
80036
|
+
api: cleanup,
|
|
80037
|
+
configureServer(nextServer) {
|
|
80038
|
+
attachContainerCleanup(nextServer, cleanup);
|
|
80039
|
+
}
|
|
80040
|
+
};
|
|
80041
|
+
server.config = {
|
|
80042
|
+
...server.config,
|
|
80043
|
+
inlineConfig: {
|
|
80044
|
+
...server.config.inlineConfig,
|
|
80045
|
+
plugins: [...server.config.inlineConfig.plugins ?? [], plugin]
|
|
80046
|
+
}
|
|
80047
|
+
};
|
|
80048
|
+
attachContainerCleanup(server, cleanup);
|
|
80049
|
+
return cleanup;
|
|
80050
|
+
}
|
|
80051
|
+
function attachContainerCleanup(server, cleanup) {
|
|
80052
|
+
const restartServer = server.restart.bind(server);
|
|
80053
|
+
server.restart = (...args) => cleanup.restart(() => restartServer(...args));
|
|
80054
|
+
const closeServer = server.close.bind(server);
|
|
80055
|
+
server.close = async () => {
|
|
80056
|
+
try {
|
|
80057
|
+
await closeServer();
|
|
80058
|
+
} finally {
|
|
80059
|
+
if (!cleanup.isRestarting) cleanup.cleanup();
|
|
80060
|
+
}
|
|
80061
|
+
};
|
|
80062
|
+
}
|
|
80063
|
+
|
|
80006
80064
|
//#endregion
|
|
80007
80065
|
//#region src/containers.ts
|
|
80008
80066
|
/**
|
|
@@ -80032,20 +80090,15 @@ function normalizeContainerImageUris(containerOptions, accountId, complianceConf
|
|
|
80032
80090
|
} : option);
|
|
80033
80091
|
}
|
|
80034
80092
|
/**
|
|
80035
|
-
* Prepares each Worker's Container images with that Worker's
|
|
80036
|
-
* and compliance settings
|
|
80093
|
+
* Prepares the sidecar and each Worker's Container images with that Worker's
|
|
80094
|
+
* registry account and compliance settings, including Workers whose images
|
|
80095
|
+
* are selected at start time.
|
|
80037
80096
|
*
|
|
80038
80097
|
* @param args - Planned images, Docker executable, and Vite logger.
|
|
80039
80098
|
* @returns No value.
|
|
80040
80099
|
*/
|
|
80041
80100
|
async function prepareContainerImagesForVite(args) {
|
|
80042
|
-
const
|
|
80043
|
-
for (const { containerOptions, workerConfig } of args.containerTagToOptionsMap.values()) {
|
|
80044
|
-
const options = optionsByWorkerConfig.get(workerConfig) ?? [];
|
|
80045
|
-
options.push(containerOptions);
|
|
80046
|
-
optionsByWorkerConfig.set(workerConfig, options);
|
|
80047
|
-
}
|
|
80048
|
-
for (const [workerConfig, plannedOptions] of optionsByWorkerConfig) {
|
|
80101
|
+
for (const [workerConfig, plannedOptions] of args.containerOptionsByWorker) {
|
|
80049
80102
|
let containerOptions = plannedOptions;
|
|
80050
80103
|
if (containerOptions.some((options) => "image_uri" in options && isCloudflareRegistryImage(options.image_uri, workerConfig))) {
|
|
80051
80104
|
const apiToken = process.env.CLOUDFLARE_API_TOKEN;
|
|
@@ -80082,7 +80135,7 @@ var __name$1 = (target$1, value) => __defProp$1(target$1, "name", {
|
|
|
80082
80135
|
});
|
|
80083
80136
|
|
|
80084
80137
|
//#endregion
|
|
80085
|
-
//#region ../workers-auth/dist/chunk-
|
|
80138
|
+
//#region ../workers-auth/dist/chunk-4CJO23DA.mjs
|
|
80086
80139
|
var import_undici$2 = require_undici();
|
|
80087
80140
|
var hasWarnedAboutDeprecatedV1ApiToken = false;
|
|
80088
80141
|
function readStoredAuthState(options) {
|
|
@@ -81571,114 +81624,7 @@ function getProfileForDirectoryFromBindings(startDir, bindings) {
|
|
|
81571
81624
|
}
|
|
81572
81625
|
}
|
|
81573
81626
|
__name$1(getProfileForDirectoryFromBindings, "getProfileForDirectoryFromBindings");
|
|
81574
|
-
|
|
81575
|
-
let lines = string$3.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
81576
|
-
return [lines.length, lines.pop().length + 1];
|
|
81577
|
-
}
|
|
81578
|
-
__name$1(getLineColFromPtr, "getLineColFromPtr");
|
|
81579
|
-
function makeCodeBlock(string$3, line, column) {
|
|
81580
|
-
let lines = string$3.split(/\r\n|\n|\r/g);
|
|
81581
|
-
let codeblock = "";
|
|
81582
|
-
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
81583
|
-
for (let i$1 = line - 1; i$1 <= line + 1; i$1++) {
|
|
81584
|
-
let l = lines[i$1 - 1];
|
|
81585
|
-
if (!l) continue;
|
|
81586
|
-
codeblock += i$1.toString().padEnd(numberLen, " ");
|
|
81587
|
-
codeblock += ": ";
|
|
81588
|
-
codeblock += l;
|
|
81589
|
-
codeblock += "\n";
|
|
81590
|
-
if (i$1 === line) {
|
|
81591
|
-
codeblock += " ".repeat(numberLen + column + 2);
|
|
81592
|
-
codeblock += "^\n";
|
|
81593
|
-
}
|
|
81594
|
-
}
|
|
81595
|
-
return codeblock;
|
|
81596
|
-
}
|
|
81597
|
-
__name$1(makeCodeBlock, "makeCodeBlock");
|
|
81598
|
-
var TomlError = class extends Error {
|
|
81599
|
-
static {
|
|
81600
|
-
__name$1(this, "TomlError");
|
|
81601
|
-
}
|
|
81602
|
-
line;
|
|
81603
|
-
column;
|
|
81604
|
-
codeblock;
|
|
81605
|
-
constructor(message, options) {
|
|
81606
|
-
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
81607
|
-
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
81608
|
-
super(`Invalid TOML document: ${message}
|
|
81609
|
-
|
|
81610
|
-
${codeblock}`, options);
|
|
81611
|
-
this.line = line;
|
|
81612
|
-
this.column = column;
|
|
81613
|
-
this.codeblock = codeblock;
|
|
81614
|
-
}
|
|
81615
|
-
};
|
|
81616
|
-
function isEscaped(str, ptr) {
|
|
81617
|
-
let i$1 = 0;
|
|
81618
|
-
while (str[ptr - ++i$1] === "\\");
|
|
81619
|
-
return --i$1 && i$1 % 2;
|
|
81620
|
-
}
|
|
81621
|
-
__name$1(isEscaped, "isEscaped");
|
|
81622
|
-
function indexOfNewline(str, start = 0, end = str.length) {
|
|
81623
|
-
let idx = str.indexOf("\n", start);
|
|
81624
|
-
if (str[idx - 1] === "\r") idx--;
|
|
81625
|
-
return idx <= end ? idx : -1;
|
|
81626
|
-
}
|
|
81627
|
-
__name$1(indexOfNewline, "indexOfNewline");
|
|
81628
|
-
function skipComment(str, ptr) {
|
|
81629
|
-
for (let i$1 = ptr; i$1 < str.length; i$1++) {
|
|
81630
|
-
let c$1 = str[i$1];
|
|
81631
|
-
if (c$1 === "\n") return i$1;
|
|
81632
|
-
if (c$1 === "\r" && str[i$1 + 1] === "\n") return i$1 + 1;
|
|
81633
|
-
if (c$1 < " " && c$1 !== " " || c$1 === "") throw new TomlError("control characters are not allowed in comments", {
|
|
81634
|
-
toml: str,
|
|
81635
|
-
ptr
|
|
81636
|
-
});
|
|
81637
|
-
}
|
|
81638
|
-
return str.length;
|
|
81639
|
-
}
|
|
81640
|
-
__name$1(skipComment, "skipComment");
|
|
81641
|
-
function skipVoid(str, ptr, banNewLines, banComments) {
|
|
81642
|
-
let c$1;
|
|
81643
|
-
while ((c$1 = str[ptr]) === " " || c$1 === " " || !banNewLines && (c$1 === "\n" || c$1 === "\r" && str[ptr + 1] === "\n")) ptr++;
|
|
81644
|
-
return banComments || c$1 !== "#" ? ptr : skipVoid(str, skipComment(str, ptr), banNewLines);
|
|
81645
|
-
}
|
|
81646
|
-
__name$1(skipVoid, "skipVoid");
|
|
81647
|
-
function skipUntil(str, ptr, sep$1, end, banNewLines = false) {
|
|
81648
|
-
if (!end) {
|
|
81649
|
-
ptr = indexOfNewline(str, ptr);
|
|
81650
|
-
return ptr < 0 ? str.length : ptr;
|
|
81651
|
-
}
|
|
81652
|
-
for (let i$1 = ptr; i$1 < str.length; i$1++) {
|
|
81653
|
-
let c$1 = str[i$1];
|
|
81654
|
-
if (c$1 === "#") i$1 = indexOfNewline(str, i$1);
|
|
81655
|
-
else if (c$1 === sep$1) return i$1 + 1;
|
|
81656
|
-
else if (c$1 === end || banNewLines && (c$1 === "\n" || c$1 === "\r" && str[i$1 + 1] === "\n")) return i$1;
|
|
81657
|
-
}
|
|
81658
|
-
throw new TomlError("cannot find end of structure", {
|
|
81659
|
-
toml: str,
|
|
81660
|
-
ptr
|
|
81661
|
-
});
|
|
81662
|
-
}
|
|
81663
|
-
__name$1(skipUntil, "skipUntil");
|
|
81664
|
-
function getStringEnd(str, seek) {
|
|
81665
|
-
let first = str[seek];
|
|
81666
|
-
let target$1 = first === str[seek + 1] && str[seek + 1] === str[seek + 2] ? str.slice(seek, seek + 3) : first;
|
|
81667
|
-
seek += target$1.length - 1;
|
|
81668
|
-
do
|
|
81669
|
-
seek = str.indexOf(target$1, ++seek);
|
|
81670
|
-
while (seek > -1 && first !== "'" && isEscaped(str, seek));
|
|
81671
|
-
if (seek > -1) {
|
|
81672
|
-
seek += target$1.length;
|
|
81673
|
-
if (target$1.length > 1) {
|
|
81674
|
-
if (str[seek] === first) seek++;
|
|
81675
|
-
if (str[seek] === first) seek++;
|
|
81676
|
-
}
|
|
81677
|
-
}
|
|
81678
|
-
return seek;
|
|
81679
|
-
}
|
|
81680
|
-
__name$1(getStringEnd, "getStringEnd");
|
|
81681
|
-
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}:\d{2}(?:\.\d+)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
81627
|
+
var DATE_TIME_RE = /^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i;
|
|
81682
81628
|
var TomlDate = class _TomlDate extends Date {
|
|
81683
81629
|
static {
|
|
81684
81630
|
__name$1(this, "TomlDate");
|
|
@@ -81762,305 +81708,380 @@ var TomlDate = class _TomlDate extends Date {
|
|
|
81762
81708
|
return date$3;
|
|
81763
81709
|
}
|
|
81764
81710
|
};
|
|
81711
|
+
function getLineColFromPtr(string$3, ptr) {
|
|
81712
|
+
let lines = string$3.slice(0, ptr).split(/\r\n|\n|\r/g);
|
|
81713
|
+
return [lines.length, lines.pop().length + 1];
|
|
81714
|
+
}
|
|
81715
|
+
__name$1(getLineColFromPtr, "getLineColFromPtr");
|
|
81716
|
+
function makeCodeBlock(string$3, line, column) {
|
|
81717
|
+
let lines = string$3.split(/\r\n|\n|\r/g);
|
|
81718
|
+
let codeblock = "";
|
|
81719
|
+
let numberLen = (Math.log10(line + 1) | 0) + 1;
|
|
81720
|
+
for (let i$1 = line - 1; i$1 <= line + 1; i$1++) {
|
|
81721
|
+
let l = lines[i$1 - 1];
|
|
81722
|
+
if (!l) continue;
|
|
81723
|
+
codeblock += i$1.toString().padEnd(numberLen, " ");
|
|
81724
|
+
codeblock += ": ";
|
|
81725
|
+
codeblock += l;
|
|
81726
|
+
codeblock += "\n";
|
|
81727
|
+
if (i$1 === line) {
|
|
81728
|
+
codeblock += " ".repeat(numberLen + column + 2);
|
|
81729
|
+
codeblock += "^\n";
|
|
81730
|
+
}
|
|
81731
|
+
}
|
|
81732
|
+
return codeblock;
|
|
81733
|
+
}
|
|
81734
|
+
__name$1(makeCodeBlock, "makeCodeBlock");
|
|
81735
|
+
var TomlError = class extends Error {
|
|
81736
|
+
static {
|
|
81737
|
+
__name$1(this, "TomlError");
|
|
81738
|
+
}
|
|
81739
|
+
line;
|
|
81740
|
+
column;
|
|
81741
|
+
codeblock;
|
|
81742
|
+
constructor(message, options) {
|
|
81743
|
+
const [line, column] = getLineColFromPtr(options.toml, options.ptr);
|
|
81744
|
+
const codeblock = makeCodeBlock(options.toml, line, column);
|
|
81745
|
+
super(`Invalid TOML document: ${message}
|
|
81746
|
+
|
|
81747
|
+
${codeblock}`, options);
|
|
81748
|
+
this.line = line;
|
|
81749
|
+
this.column = column;
|
|
81750
|
+
this.codeblock = codeblock;
|
|
81751
|
+
}
|
|
81752
|
+
};
|
|
81753
|
+
function indexOfNewline(str, start = 0) {
|
|
81754
|
+
let idx = str.indexOf("\n", start);
|
|
81755
|
+
if (str.charCodeAt(idx - 1) === 13) idx--;
|
|
81756
|
+
return idx;
|
|
81757
|
+
}
|
|
81758
|
+
__name$1(indexOfNewline, "indexOfNewline");
|
|
81759
|
+
function skipComment(ctx) {
|
|
81760
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
81761
|
+
let c$1 = ctx.s.charCodeAt(ctx.p);
|
|
81762
|
+
if (c$1 === 10) break;
|
|
81763
|
+
if (c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
|
|
81764
|
+
ctx.p++;
|
|
81765
|
+
break;
|
|
81766
|
+
}
|
|
81767
|
+
if (c$1 < 32 && c$1 !== 9 || c$1 === 127) throw new TomlError("control characters are not allowed in comments", {
|
|
81768
|
+
toml: ctx.s,
|
|
81769
|
+
ptr: ctx.p
|
|
81770
|
+
});
|
|
81771
|
+
}
|
|
81772
|
+
}
|
|
81773
|
+
__name$1(skipComment, "skipComment");
|
|
81774
|
+
function skipVoid(ctx, banNewLines, banComments) {
|
|
81775
|
+
let c$1;
|
|
81776
|
+
while (1) {
|
|
81777
|
+
while ((c$1 = ctx.s.charCodeAt(ctx.p)) === 32 || c$1 === 9 || !banNewLines && (c$1 === 10 || c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) ctx.p++;
|
|
81778
|
+
if (banComments || c$1 !== 35) break;
|
|
81779
|
+
skipComment(ctx);
|
|
81780
|
+
}
|
|
81781
|
+
}
|
|
81782
|
+
__name$1(skipVoid, "skipVoid");
|
|
81783
|
+
function skipUntil(ctx, sep$1, end) {
|
|
81784
|
+
let ptr = ctx.p;
|
|
81785
|
+
if (!end) {
|
|
81786
|
+
ptr = indexOfNewline(ctx.s, ptr);
|
|
81787
|
+
ctx.p = ptr < 0 ? ctx.s.length : ptr;
|
|
81788
|
+
return;
|
|
81789
|
+
}
|
|
81790
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
81791
|
+
let c$1 = ctx.s.charCodeAt(ctx.p);
|
|
81792
|
+
if (c$1 === 35) skipComment(ctx);
|
|
81793
|
+
else if (c$1 === end || c$1 === sep$1) return;
|
|
81794
|
+
}
|
|
81795
|
+
throw new TomlError("cannot find end of structure", {
|
|
81796
|
+
toml: ctx.s,
|
|
81797
|
+
ptr
|
|
81798
|
+
});
|
|
81799
|
+
}
|
|
81800
|
+
__name$1(skipUntil, "skipUntil");
|
|
81765
81801
|
var INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
|
|
81766
81802
|
var FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
|
|
81767
81803
|
var LEADING_ZERO = /^[+-]?0[0-9_]/;
|
|
81768
|
-
|
|
81769
|
-
|
|
81770
|
-
|
|
81771
|
-
|
|
81772
|
-
|
|
81773
|
-
|
|
81774
|
-
r: "\r",
|
|
81775
|
-
"\"": "\"",
|
|
81776
|
-
"\\": "\\"
|
|
81777
|
-
};
|
|
81778
|
-
function parseString(str, ptr = 0, endPtr = str.length) {
|
|
81779
|
-
let isLiteral = str[ptr] === "'";
|
|
81780
|
-
let isMultiline = str[ptr++] === str[ptr] && str[ptr] === str[ptr + 1];
|
|
81804
|
+
function parseString(ctx) {
|
|
81805
|
+
let start = ctx.p;
|
|
81806
|
+
let c$1 = ctx.s.charCodeAt(ctx.p++);
|
|
81807
|
+
let first = c$1;
|
|
81808
|
+
let isLiteral = c$1 === 39;
|
|
81809
|
+
let isMultiline = c$1 === ctx.s.charCodeAt(ctx.p) && c$1 === ctx.s.charCodeAt(ctx.p + 1);
|
|
81781
81810
|
if (isMultiline) {
|
|
81782
|
-
|
|
81783
|
-
if (
|
|
81784
|
-
if (str[ptr] === "\n") ptr++;
|
|
81811
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p += 2)) === 10) ctx.p++;
|
|
81812
|
+
else if (c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) ctx.p += 2;
|
|
81785
81813
|
}
|
|
81786
|
-
let tmp = 0;
|
|
81787
|
-
let isEscape;
|
|
81788
81814
|
let parsed = "";
|
|
81789
|
-
let sliceStart =
|
|
81790
|
-
|
|
81791
|
-
|
|
81792
|
-
|
|
81793
|
-
|
|
81794
|
-
|
|
81795
|
-
|
|
81796
|
-
|
|
81797
|
-
}
|
|
81798
|
-
|
|
81799
|
-
|
|
81800
|
-
|
|
81801
|
-
|
|
81802
|
-
|
|
81803
|
-
if (
|
|
81804
|
-
|
|
81805
|
-
|
|
81806
|
-
|
|
81807
|
-
|
|
81808
|
-
|
|
81809
|
-
|
|
81810
|
-
|
|
81811
|
-
|
|
81812
|
-
|
|
81813
|
-
|
|
81814
|
-
|
|
81815
|
-
|
|
81816
|
-
|
|
81817
|
-
|
|
81818
|
-
|
|
81819
|
-
|
|
81820
|
-
toml: str,
|
|
81821
|
-
ptr: tmp
|
|
81815
|
+
let sliceStart = ctx.p;
|
|
81816
|
+
let state = 0;
|
|
81817
|
+
for (; ctx.p < ctx.s.length; ctx.p++) {
|
|
81818
|
+
c$1 = ctx.s.charCodeAt(ctx.p);
|
|
81819
|
+
if (isMultiline && (c$1 === 10 || c$1 === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) state = state && 3;
|
|
81820
|
+
else if (c$1 < 32 && c$1 !== 9 || c$1 === 127) throw new TomlError("control characters are not allowed in strings", {
|
|
81821
|
+
toml: ctx.s,
|
|
81822
|
+
ptr: ctx.p
|
|
81823
|
+
});
|
|
81824
|
+
else if ((!state || state === 3) && c$1 === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
|
|
81825
|
+
if (isMultiline) {
|
|
81826
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
81827
|
+
if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
|
|
81828
|
+
}
|
|
81829
|
+
if (!state) parsed += ctx.s.slice(sliceStart, ctx.p);
|
|
81830
|
+
ctx.p += isMultiline ? 3 : 1;
|
|
81831
|
+
return parsed;
|
|
81832
|
+
} else if (!state) {
|
|
81833
|
+
if (!isLiteral && c$1 === 92) {
|
|
81834
|
+
parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
|
|
81835
|
+
state = 1;
|
|
81836
|
+
}
|
|
81837
|
+
} else if (state === 1) if (c$1 === 120 || c$1 === 117 || c$1 === 85) {
|
|
81838
|
+
let value = 0;
|
|
81839
|
+
let len = c$1 === 120 ? 2 : c$1 === 117 ? 4 : 8;
|
|
81840
|
+
for (let j$1 = 0; j$1 < len; j$1++, ctx.p++) {
|
|
81841
|
+
let hex$1 = ctx.s.charCodeAt(ctx.p + 1);
|
|
81842
|
+
let digit = hex$1 >= 48 && hex$1 <= 57 ? hex$1 - 48 : hex$1 >= 65 && hex$1 <= 70 ? hex$1 - 65 + 10 : hex$1 >= 97 && hex$1 <= 102 ? hex$1 - 97 + 10 : -1;
|
|
81843
|
+
if (digit < 0) throw new TomlError("invalid non-hex character in unicode escape", {
|
|
81844
|
+
toml: ctx.s,
|
|
81845
|
+
ptr: ctx.p + 1
|
|
81822
81846
|
});
|
|
81823
|
-
|
|
81824
|
-
}
|
|
81847
|
+
value = value << 4 | digit;
|
|
81848
|
+
}
|
|
81849
|
+
if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new TomlError("invalid unicode escape", {
|
|
81850
|
+
toml: ctx.s,
|
|
81851
|
+
ptr: ctx.p
|
|
81852
|
+
});
|
|
81853
|
+
parsed += String.fromCodePoint(value);
|
|
81854
|
+
sliceStart = ctx.p + 1;
|
|
81855
|
+
state = 0;
|
|
81856
|
+
} else if (c$1 === 32 || c$1 === 9) state = 2;
|
|
81857
|
+
else {
|
|
81858
|
+
if (c$1 === 98) parsed += "\b";
|
|
81859
|
+
else if (c$1 === 116) parsed += " ";
|
|
81860
|
+
else if (c$1 === 110) parsed += "\n";
|
|
81861
|
+
else if (c$1 === 102) parsed += "\f";
|
|
81862
|
+
else if (c$1 === 114) parsed += "\r";
|
|
81863
|
+
else if (c$1 === 101) parsed += "\x1B";
|
|
81864
|
+
else if (c$1 === 34) parsed += "\"";
|
|
81865
|
+
else if (c$1 === 92) parsed += "\\";
|
|
81825
81866
|
else throw new TomlError("unrecognized escape sequence", {
|
|
81826
|
-
toml:
|
|
81827
|
-
ptr:
|
|
81867
|
+
toml: ctx.s,
|
|
81868
|
+
ptr: ctx.p
|
|
81869
|
+
});
|
|
81870
|
+
sliceStart = ctx.p + 1;
|
|
81871
|
+
state = 0;
|
|
81872
|
+
}
|
|
81873
|
+
else if (c$1 !== 32 && c$1 !== 9) {
|
|
81874
|
+
if (state === 2) throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
|
|
81875
|
+
toml: ctx.s,
|
|
81876
|
+
ptr: sliceStart
|
|
81828
81877
|
});
|
|
81829
|
-
|
|
81830
|
-
|
|
81831
|
-
tmp = ptr - 1;
|
|
81832
|
-
isEscape = true;
|
|
81833
|
-
parsed += str.slice(sliceStart, tmp);
|
|
81878
|
+
state = !isLiteral && c$1 === 92 ? 1 : 0;
|
|
81879
|
+
sliceStart = ctx.p;
|
|
81834
81880
|
}
|
|
81835
81881
|
}
|
|
81836
|
-
|
|
81882
|
+
throw new TomlError("unfinished string", {
|
|
81883
|
+
toml: ctx.s,
|
|
81884
|
+
ptr: start
|
|
81885
|
+
});
|
|
81837
81886
|
}
|
|
81838
81887
|
__name$1(parseString, "parseString");
|
|
81839
|
-
function
|
|
81840
|
-
|
|
81841
|
-
|
|
81888
|
+
function sliceAndTrimEndOf(ctx, start, end) {
|
|
81889
|
+
let value = ctx.s.slice(start, end);
|
|
81890
|
+
let commentIdx = value.indexOf("#");
|
|
81891
|
+
if (commentIdx > 0) {
|
|
81892
|
+
skipComment({
|
|
81893
|
+
s: value,
|
|
81894
|
+
p: commentIdx
|
|
81895
|
+
});
|
|
81896
|
+
value = value.slice(0, commentIdx);
|
|
81897
|
+
}
|
|
81898
|
+
return value.trimEnd();
|
|
81899
|
+
}
|
|
81900
|
+
__name$1(sliceAndTrimEndOf, "sliceAndTrimEndOf");
|
|
81901
|
+
function parseValue(ctx, integersAsBigInt, end) {
|
|
81902
|
+
let ptr = ctx.p;
|
|
81903
|
+
let err = {
|
|
81904
|
+
toml: ctx.s,
|
|
81905
|
+
ptr
|
|
81906
|
+
};
|
|
81907
|
+
skipUntil(ctx, 44, end);
|
|
81908
|
+
let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
|
|
81909
|
+
if (!value) throw new TomlError("incomplete declaration: value expected", err);
|
|
81842
81910
|
if (value === "-inf") return -Infinity;
|
|
81843
81911
|
if (value === "inf" || value === "+inf") return Infinity;
|
|
81844
81912
|
if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
|
|
81845
81913
|
if (value === "-0") return integersAsBigInt ? 0n : 0;
|
|
81846
81914
|
let isInt = INT_REGEX.test(value);
|
|
81847
81915
|
if (isInt || FLOAT_REGEX.test(value)) {
|
|
81848
|
-
if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed",
|
|
81849
|
-
toml,
|
|
81850
|
-
ptr
|
|
81851
|
-
});
|
|
81916
|
+
if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", err);
|
|
81852
81917
|
value = value.replace(/_/g, "");
|
|
81853
81918
|
let numeric$1 = +value;
|
|
81854
|
-
if (isNaN(numeric$1)) throw new TomlError("invalid number",
|
|
81855
|
-
toml,
|
|
81856
|
-
ptr
|
|
81857
|
-
});
|
|
81919
|
+
if (isNaN(numeric$1)) throw new TomlError("invalid number", err);
|
|
81858
81920
|
if (isInt) {
|
|
81859
|
-
if ((isInt = !Number.isSafeInteger(numeric$1)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly",
|
|
81860
|
-
toml,
|
|
81861
|
-
ptr
|
|
81862
|
-
});
|
|
81921
|
+
if ((isInt = !Number.isSafeInteger(numeric$1)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", err);
|
|
81863
81922
|
if (isInt || integersAsBigInt === true) numeric$1 = BigInt(value);
|
|
81864
81923
|
}
|
|
81865
81924
|
return numeric$1;
|
|
81866
81925
|
}
|
|
81867
81926
|
const date$3 = new TomlDate(value);
|
|
81868
|
-
if (!date$3.isValid()) throw new TomlError("invalid value",
|
|
81869
|
-
toml,
|
|
81870
|
-
ptr
|
|
81871
|
-
});
|
|
81927
|
+
if (!date$3.isValid()) throw new TomlError("invalid value", err);
|
|
81872
81928
|
return date$3;
|
|
81873
81929
|
}
|
|
81874
81930
|
__name$1(parseValue, "parseValue");
|
|
81875
|
-
function
|
|
81876
|
-
let
|
|
81877
|
-
let
|
|
81878
|
-
if (
|
|
81879
|
-
|
|
81880
|
-
|
|
81881
|
-
|
|
81882
|
-
let trimmed = value.trimEnd();
|
|
81883
|
-
if (!allowNewLines) {
|
|
81884
|
-
let newlineIdx = value.indexOf("\n", trimmed.length);
|
|
81885
|
-
if (newlineIdx > -1) throw new TomlError("newlines are not allowed in inline tables", {
|
|
81886
|
-
toml: str,
|
|
81887
|
-
ptr: startPtr + newlineIdx
|
|
81931
|
+
function extractValue(ctx, end, integersAsBigInt) {
|
|
81932
|
+
let ptr = ctx.p;
|
|
81933
|
+
let c$1 = ctx.s.charCodeAt(ptr);
|
|
81934
|
+
if (c$1 === 91 || c$1 === 123) {
|
|
81935
|
+
if (!ctx.d--) throw new TomlError("document contains excessively nested structures. aborting.", {
|
|
81936
|
+
toml: ctx.s,
|
|
81937
|
+
ptr
|
|
81888
81938
|
});
|
|
81939
|
+
let value = c$1 === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
|
|
81940
|
+
ctx.d++;
|
|
81941
|
+
return value;
|
|
81889
81942
|
}
|
|
81890
|
-
return
|
|
81891
|
-
|
|
81892
|
-
|
|
81893
|
-
|
|
81894
|
-
|
|
81895
|
-
|
|
81896
|
-
|
|
81897
|
-
|
|
81898
|
-
let c$1 = str[ptr];
|
|
81899
|
-
if (c$1 === "[" || c$1 === "{") {
|
|
81900
|
-
let [value, endPtr2] = c$1 === "[" ? parseArray(str, ptr, depth$1, integersAsBigInt) : parseInlineTable(str, ptr, depth$1, integersAsBigInt);
|
|
81901
|
-
let newPtr = end ? skipUntil(str, endPtr2, ",", end) : endPtr2;
|
|
81902
|
-
if (endPtr2 - newPtr && end === "}") {
|
|
81903
|
-
let nextNewLine = indexOfNewline(str, endPtr2, newPtr);
|
|
81904
|
-
if (nextNewLine > -1) throw new TomlError("newlines are not allowed in inline tables", {
|
|
81905
|
-
toml: str,
|
|
81906
|
-
ptr: nextNewLine
|
|
81907
|
-
});
|
|
81908
|
-
}
|
|
81909
|
-
return [value, newPtr];
|
|
81910
|
-
}
|
|
81911
|
-
let endPtr;
|
|
81912
|
-
if (c$1 === "\"" || c$1 === "'") {
|
|
81913
|
-
endPtr = getStringEnd(str, ptr);
|
|
81914
|
-
let parsed = parseString(str, ptr, endPtr);
|
|
81915
|
-
if (end) {
|
|
81916
|
-
endPtr = skipVoid(str, endPtr, end !== "]");
|
|
81917
|
-
if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") throw new TomlError("unexpected character encountered", {
|
|
81918
|
-
toml: str,
|
|
81919
|
-
ptr: endPtr
|
|
81920
|
-
});
|
|
81921
|
-
endPtr += +(str[endPtr] === ",");
|
|
81922
|
-
}
|
|
81923
|
-
return [parsed, endPtr];
|
|
81943
|
+
if (c$1 === 34 || c$1 === 39) return parseString(ctx);
|
|
81944
|
+
if (c$1 === 116) {
|
|
81945
|
+
if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError("invalid value", {
|
|
81946
|
+
toml: ctx.s,
|
|
81947
|
+
ptr
|
|
81948
|
+
});
|
|
81949
|
+
ctx.p++;
|
|
81950
|
+
return true;
|
|
81924
81951
|
}
|
|
81925
|
-
|
|
81926
|
-
|
|
81927
|
-
|
|
81928
|
-
|
|
81929
|
-
|
|
81930
|
-
|
|
81931
|
-
|
|
81932
|
-
endPtr = skipVoid(str, ptr + slice[1]);
|
|
81933
|
-
endPtr += +(str[endPtr] === ",");
|
|
81952
|
+
if (c$1 === 102) {
|
|
81953
|
+
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) throw new TomlError("invalid value", {
|
|
81954
|
+
toml: ctx.s,
|
|
81955
|
+
ptr
|
|
81956
|
+
});
|
|
81957
|
+
ctx.p++;
|
|
81958
|
+
return false;
|
|
81934
81959
|
}
|
|
81935
|
-
return
|
|
81960
|
+
return parseValue(ctx, integersAsBigInt, end);
|
|
81936
81961
|
}
|
|
81937
81962
|
__name$1(extractValue, "extractValue");
|
|
81938
81963
|
var KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
81939
|
-
function parseKey(
|
|
81940
|
-
let
|
|
81964
|
+
function parseKey(ctx, end = "=") {
|
|
81965
|
+
let start = ctx.p;
|
|
81966
|
+
let dot = start - 1;
|
|
81941
81967
|
let parsed = [];
|
|
81942
|
-
let endPtr =
|
|
81968
|
+
let endPtr = ctx.s.indexOf(end, start);
|
|
81943
81969
|
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
81944
|
-
toml:
|
|
81945
|
-
ptr
|
|
81970
|
+
toml: ctx.s,
|
|
81971
|
+
ptr: start
|
|
81946
81972
|
});
|
|
81947
81973
|
do {
|
|
81948
|
-
let c$1 =
|
|
81949
|
-
if (c$1 !==
|
|
81950
|
-
if (c$1 ===
|
|
81951
|
-
toml:
|
|
81952
|
-
ptr
|
|
81953
|
-
});
|
|
81954
|
-
let eos = getStringEnd(str, ptr);
|
|
81955
|
-
if (eos < 0) throw new TomlError("unfinished string encountered", {
|
|
81956
|
-
toml: str,
|
|
81957
|
-
ptr
|
|
81974
|
+
let c$1 = ctx.s.charCodeAt(ctx.p = ++dot);
|
|
81975
|
+
if (c$1 !== 32 && c$1 !== 9) if (c$1 === 34 || c$1 === 39) {
|
|
81976
|
+
if (c$1 === ctx.s.charCodeAt(ctx.p + 1) && c$1 === ctx.s.charCodeAt(ctx.p + 2)) throw new TomlError("multiline strings are not allowed in keys", {
|
|
81977
|
+
toml: ctx.s,
|
|
81978
|
+
ptr: ctx.p
|
|
81958
81979
|
});
|
|
81959
|
-
|
|
81960
|
-
|
|
81980
|
+
let part = parseString(ctx);
|
|
81981
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
81982
|
+
let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
81961
81983
|
let newLine = indexOfNewline(strEnd);
|
|
81962
81984
|
if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
|
|
81963
|
-
toml:
|
|
81964
|
-
ptr:
|
|
81985
|
+
toml: ctx.s,
|
|
81986
|
+
ptr: newLine
|
|
81965
81987
|
});
|
|
81966
81988
|
if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
|
|
81967
|
-
toml:
|
|
81968
|
-
ptr:
|
|
81989
|
+
toml: ctx.s,
|
|
81990
|
+
ptr: ctx.p
|
|
81969
81991
|
});
|
|
81970
|
-
if (endPtr <
|
|
81971
|
-
endPtr =
|
|
81992
|
+
if (endPtr < ctx.p) {
|
|
81993
|
+
endPtr = ctx.s.indexOf(end, ctx.p);
|
|
81972
81994
|
if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
|
|
81973
|
-
toml:
|
|
81974
|
-
ptr
|
|
81995
|
+
toml: ctx.s,
|
|
81996
|
+
ptr: start
|
|
81975
81997
|
});
|
|
81976
81998
|
}
|
|
81977
|
-
parsed.push(
|
|
81999
|
+
parsed.push(part);
|
|
81978
82000
|
} else {
|
|
81979
|
-
dot =
|
|
81980
|
-
let part =
|
|
82001
|
+
dot = ctx.s.indexOf(".", ctx.p);
|
|
82002
|
+
let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
|
|
81981
82003
|
if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
|
|
81982
|
-
toml:
|
|
81983
|
-
ptr
|
|
82004
|
+
toml: ctx.s,
|
|
82005
|
+
ptr: ctx.p
|
|
81984
82006
|
});
|
|
81985
82007
|
parsed.push(part.trimEnd());
|
|
81986
82008
|
}
|
|
81987
82009
|
} while (dot + 1 && dot < endPtr);
|
|
81988
|
-
|
|
82010
|
+
ctx.p = endPtr + 1;
|
|
82011
|
+
skipVoid(ctx, true, true);
|
|
82012
|
+
return parsed;
|
|
81989
82013
|
}
|
|
81990
82014
|
__name$1(parseKey, "parseKey");
|
|
81991
|
-
function parseInlineTable(
|
|
82015
|
+
function parseInlineTable(ctx, integersAsBigInt) {
|
|
81992
82016
|
let res = {};
|
|
81993
82017
|
let seen = /* @__PURE__ */ new Set();
|
|
81994
82018
|
let c$1;
|
|
81995
|
-
|
|
81996
|
-
|
|
81997
|
-
|
|
81998
|
-
|
|
81999
|
-
|
|
82000
|
-
|
|
82001
|
-
}
|
|
82002
|
-
|
|
82003
|
-
|
|
82004
|
-
|
|
82005
|
-
|
|
82006
|
-
|
|
82007
|
-
|
|
82008
|
-
|
|
82009
|
-
|
|
82010
|
-
|
|
82011
|
-
|
|
82012
|
-
|
|
82013
|
-
|
|
82014
|
-
|
|
82015
|
-
|
|
82016
|
-
|
|
82017
|
-
|
|
82018
|
-
enumerable: true,
|
|
82019
|
-
configurable: true,
|
|
82020
|
-
writable: true
|
|
82021
|
-
});
|
|
82022
|
-
}
|
|
82023
|
-
if (hasOwn$1) throw new TomlError("trying to redefine an already defined value", {
|
|
82024
|
-
toml: str,
|
|
82025
|
-
ptr
|
|
82019
|
+
ctx.p++;
|
|
82020
|
+
while (ctx.p < ctx.s.length) {
|
|
82021
|
+
skipVoid(ctx);
|
|
82022
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p)) === 125) {
|
|
82023
|
+
ctx.p++;
|
|
82024
|
+
return res;
|
|
82025
|
+
}
|
|
82026
|
+
let k;
|
|
82027
|
+
let t$5 = res;
|
|
82028
|
+
let hasOwn$1 = false;
|
|
82029
|
+
let p$2 = ctx.p;
|
|
82030
|
+
let key = parseKey(ctx);
|
|
82031
|
+
for (let i$1 = 0; i$1 < key.length; i$1++) {
|
|
82032
|
+
if (i$1) t$5 = hasOwn$1 ? t$5[k] : t$5[k] = {};
|
|
82033
|
+
k = key[i$1];
|
|
82034
|
+
if ((hasOwn$1 = Object.hasOwn(t$5, k)) && (typeof t$5[k] !== "object" || seen.has(t$5[k]))) throw new TomlError("trying to redefine an already defined value", {
|
|
82035
|
+
toml: ctx.s,
|
|
82036
|
+
ptr: p$2
|
|
82037
|
+
});
|
|
82038
|
+
if (!hasOwn$1 && k === "__proto__") Object.defineProperty(t$5, k, {
|
|
82039
|
+
enumerable: true,
|
|
82040
|
+
configurable: true,
|
|
82041
|
+
writable: true
|
|
82026
82042
|
});
|
|
82027
|
-
let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth$1 - 1, integersAsBigInt);
|
|
82028
|
-
seen.add(value);
|
|
82029
|
-
t$5[k] = value;
|
|
82030
|
-
ptr = valueEndPtr;
|
|
82031
|
-
comma$1 = str[ptr - 1] === "," ? ptr - 1 : 0;
|
|
82032
82043
|
}
|
|
82044
|
+
if (hasOwn$1) throw new TomlError("trying to redefine an already defined value", {
|
|
82045
|
+
toml: ctx.s,
|
|
82046
|
+
ptr: ctx.p
|
|
82047
|
+
});
|
|
82048
|
+
let value = extractValue(ctx, 125, integersAsBigInt);
|
|
82049
|
+
seen.add(t$5[k] = value);
|
|
82050
|
+
skipVoid(ctx);
|
|
82051
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p++)) === 125) return res;
|
|
82052
|
+
if (c$1 !== 44) throw new TomlError("expected comma or end of structure", {
|
|
82053
|
+
toml: ctx.s,
|
|
82054
|
+
ptr: ctx.p - 1
|
|
82055
|
+
});
|
|
82033
82056
|
}
|
|
82034
|
-
|
|
82035
|
-
toml:
|
|
82036
|
-
ptr:
|
|
82037
|
-
});
|
|
82038
|
-
if (!c$1) throw new TomlError("unfinished table encountered", {
|
|
82039
|
-
toml: str,
|
|
82040
|
-
ptr
|
|
82057
|
+
throw new TomlError("unfinished table encountered", {
|
|
82058
|
+
toml: ctx.s,
|
|
82059
|
+
ptr: ctx.p
|
|
82041
82060
|
});
|
|
82042
|
-
return [res, ptr];
|
|
82043
82061
|
}
|
|
82044
82062
|
__name$1(parseInlineTable, "parseInlineTable");
|
|
82045
|
-
function parseArray(
|
|
82063
|
+
function parseArray(ctx, integersAsBigInt) {
|
|
82046
82064
|
let res = [];
|
|
82047
82065
|
let c$1;
|
|
82048
|
-
|
|
82049
|
-
while (
|
|
82050
|
-
|
|
82051
|
-
|
|
82052
|
-
|
|
82053
|
-
|
|
82054
|
-
|
|
82055
|
-
|
|
82056
|
-
|
|
82057
|
-
|
|
82058
|
-
|
|
82059
|
-
|
|
82060
|
-
|
|
82061
|
-
|
|
82066
|
+
ctx.p++;
|
|
82067
|
+
while (ctx.p < ctx.s.length) {
|
|
82068
|
+
skipVoid(ctx);
|
|
82069
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p)) === 93) {
|
|
82070
|
+
ctx.p++;
|
|
82071
|
+
return res;
|
|
82072
|
+
}
|
|
82073
|
+
res.push(extractValue(ctx, 93, integersAsBigInt));
|
|
82074
|
+
skipVoid(ctx);
|
|
82075
|
+
if ((c$1 = ctx.s.charCodeAt(ctx.p++)) === 93) return res;
|
|
82076
|
+
if (c$1 !== 44) throw new TomlError("expected comma or end of structure", {
|
|
82077
|
+
toml: ctx.s,
|
|
82078
|
+
ptr: ctx.p - 1
|
|
82079
|
+
});
|
|
82080
|
+
}
|
|
82081
|
+
throw new TomlError("unfinished array encountered", {
|
|
82082
|
+
toml: ctx.s,
|
|
82083
|
+
ptr: ctx.p
|
|
82062
82084
|
});
|
|
82063
|
-
return [res, ptr];
|
|
82064
82085
|
}
|
|
82065
82086
|
__name$1(parseArray, "parseArray");
|
|
82066
82087
|
function peekTable(key, table, meta$3, type) {
|
|
@@ -82130,46 +82151,51 @@ function peekTable(key, table, meta$3, type) {
|
|
|
82130
82151
|
}
|
|
82131
82152
|
__name$1(peekTable, "peekTable");
|
|
82132
82153
|
function parse$2(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
|
|
82154
|
+
let ctx = {
|
|
82155
|
+
s: toml,
|
|
82156
|
+
p: 0,
|
|
82157
|
+
d: maxDepth
|
|
82158
|
+
};
|
|
82133
82159
|
let res = {};
|
|
82134
82160
|
let meta$3 = {};
|
|
82161
|
+
let tmp;
|
|
82135
82162
|
let tbl = res;
|
|
82136
82163
|
let m = meta$3;
|
|
82137
|
-
|
|
82138
|
-
|
|
82139
|
-
|
|
82140
|
-
let
|
|
82164
|
+
skipVoid(ctx);
|
|
82165
|
+
while (ctx.p < toml.length) {
|
|
82166
|
+
if (toml.charCodeAt(ctx.p) === 91) {
|
|
82167
|
+
let isTableArray = toml.charCodeAt(++ctx.p) === 91;
|
|
82168
|
+
tmp = ctx.p += +isTableArray;
|
|
82169
|
+
let k = parseKey(ctx, "]");
|
|
82141
82170
|
if (isTableArray) {
|
|
82142
|
-
if (toml
|
|
82171
|
+
if (toml.charCodeAt(ctx.p - 1) !== 93) throw new TomlError("expected end of table declaration", {
|
|
82143
82172
|
toml,
|
|
82144
|
-
ptr:
|
|
82173
|
+
ptr: ctx.p - 1
|
|
82145
82174
|
});
|
|
82146
|
-
|
|
82175
|
+
ctx.p++;
|
|
82147
82176
|
}
|
|
82148
|
-
let p$2 = peekTable(k
|
|
82177
|
+
let p$2 = peekTable(k, res, meta$3, isTableArray ? 2 : 1);
|
|
82149
82178
|
if (!p$2) throw new TomlError("trying to redefine an already defined table or value", {
|
|
82150
82179
|
toml,
|
|
82151
|
-
ptr
|
|
82180
|
+
ptr: tmp
|
|
82152
82181
|
});
|
|
82153
82182
|
m = p$2[2];
|
|
82154
82183
|
tbl = p$2[1];
|
|
82155
|
-
ptr = k[1];
|
|
82156
82184
|
} else {
|
|
82157
|
-
|
|
82158
|
-
let p$2 = peekTable(
|
|
82185
|
+
tmp = ctx.p;
|
|
82186
|
+
let p$2 = peekTable(parseKey(ctx), tbl, m, 0);
|
|
82159
82187
|
if (!p$2) throw new TomlError("trying to redefine an already defined table or value", {
|
|
82160
82188
|
toml,
|
|
82161
|
-
ptr
|
|
82189
|
+
ptr: tmp
|
|
82162
82190
|
});
|
|
82163
|
-
|
|
82164
|
-
p$2[1][p$2[0]] = v[0];
|
|
82165
|
-
ptr = v[1];
|
|
82191
|
+
p$2[1][p$2[0]] = extractValue(ctx, void 0, integersAsBigInt);
|
|
82166
82192
|
}
|
|
82167
|
-
|
|
82168
|
-
if (toml
|
|
82193
|
+
skipVoid(ctx, true);
|
|
82194
|
+
if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) throw new TomlError("each key-value declaration must be followed by an end-of-line", {
|
|
82169
82195
|
toml,
|
|
82170
|
-
ptr
|
|
82196
|
+
ptr: ctx.p
|
|
82171
82197
|
});
|
|
82172
|
-
|
|
82198
|
+
skipVoid(ctx);
|
|
82173
82199
|
}
|
|
82174
82200
|
return res;
|
|
82175
82201
|
}
|
|
@@ -82179,7 +82205,8 @@ function extendedTypeOf(obj) {
|
|
|
82179
82205
|
let type = typeof obj;
|
|
82180
82206
|
if (type === "object") {
|
|
82181
82207
|
if (Array.isArray(obj)) return "array";
|
|
82182
|
-
if (obj instanceof Date) return "date";
|
|
82208
|
+
if (typeof obj?.getUTCDate === "function" && obj instanceof Date) return "date";
|
|
82209
|
+
if (globalThis.Temporal && typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) return "temporal";
|
|
82183
82210
|
}
|
|
82184
82211
|
return type;
|
|
82185
82212
|
}
|
|
@@ -82193,23 +82220,31 @@ function formatString(s) {
|
|
|
82193
82220
|
return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
|
|
82194
82221
|
}
|
|
82195
82222
|
__name$1(formatString, "formatString");
|
|
82223
|
+
function stringifyTemporal(temporal) {
|
|
82224
|
+
return temporal.toString({
|
|
82225
|
+
calendarName: "never",
|
|
82226
|
+
timeZoneName: "never"
|
|
82227
|
+
});
|
|
82228
|
+
}
|
|
82229
|
+
__name$1(stringifyTemporal, "stringifyTemporal");
|
|
82196
82230
|
function stringifyValue(val, type, depth$1, numberAsFloat) {
|
|
82197
82231
|
if (depth$1 === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
|
|
82198
|
-
|
|
82199
|
-
|
|
82200
|
-
|
|
82201
|
-
|
|
82202
|
-
|
|
82203
|
-
|
|
82204
|
-
|
|
82205
|
-
|
|
82206
|
-
|
|
82207
|
-
|
|
82208
|
-
|
|
82209
|
-
|
|
82210
|
-
|
|
82211
|
-
|
|
82212
|
-
|
|
82232
|
+
switch (type) {
|
|
82233
|
+
case "number":
|
|
82234
|
+
if (isNaN(val)) return "nan";
|
|
82235
|
+
if (val === Infinity) return "inf";
|
|
82236
|
+
if (val === -Infinity) return "-inf";
|
|
82237
|
+
if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val))) return val.toFixed(1);
|
|
82238
|
+
case "bigint":
|
|
82239
|
+
case "boolean": return val.toString();
|
|
82240
|
+
case "string": return formatString(val);
|
|
82241
|
+
case "date":
|
|
82242
|
+
if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
|
|
82243
|
+
return val.toISOString();
|
|
82244
|
+
case "object": return stringifyInlineTable(val, depth$1, numberAsFloat);
|
|
82245
|
+
case "array": return stringifyArray(val, depth$1, numberAsFloat);
|
|
82246
|
+
case "temporal": return stringifyTemporal(val);
|
|
82247
|
+
}
|
|
82213
82248
|
}
|
|
82214
82249
|
__name$1(stringifyValue, "stringifyValue");
|
|
82215
82250
|
function stringifyInlineTable(obj, depth$1, numberAsFloat) {
|
|
@@ -83038,7 +83073,7 @@ function scrubEncryptedCredentials(options) {
|
|
|
83038
83073
|
__name$1(scrubEncryptedCredentials, "scrubEncryptedCredentials");
|
|
83039
83074
|
|
|
83040
83075
|
//#endregion
|
|
83041
|
-
//#region ../workers-auth/dist/chunk-
|
|
83076
|
+
//#region ../workers-auth/dist/chunk-A6F4WXCF.mjs
|
|
83042
83077
|
function createPreferences(getConfigPath) {
|
|
83043
83078
|
function getUserPreferencesPath() {
|
|
83044
83079
|
return path__default.resolve(getConfigPath(), "preferences.json");
|
|
@@ -84192,7 +84227,7 @@ function getCfConfigPath() {
|
|
|
84192
84227
|
});
|
|
84193
84228
|
}
|
|
84194
84229
|
__name$1(getCfConfigPath, "getCfConfigPath");
|
|
84195
|
-
var
|
|
84230
|
+
var CF_CLIENT_REGISTERED_SCOPES = [
|
|
84196
84231
|
"access:read",
|
|
84197
84232
|
"access:write",
|
|
84198
84233
|
"account:read",
|
|
@@ -84668,102 +84703,21 @@ var CF_REGISTERED_SCOPES = [
|
|
|
84668
84703
|
"zone.read",
|
|
84669
84704
|
"zone.write"
|
|
84670
84705
|
];
|
|
84671
|
-
var
|
|
84672
|
-
"
|
|
84673
|
-
"
|
|
84674
|
-
"
|
|
84675
|
-
"
|
|
84676
|
-
"
|
|
84677
|
-
"
|
|
84678
|
-
|
|
84679
|
-
|
|
84680
|
-
|
|
84681
|
-
"ai:read",
|
|
84682
|
-
"ai:write",
|
|
84683
|
-
"ai-search:read",
|
|
84684
|
-
"ai-search:run",
|
|
84685
|
-
"ai-search:write",
|
|
84686
|
-
"aiaudit:read",
|
|
84687
|
-
"aiaudit:write",
|
|
84688
|
-
"aig:read",
|
|
84689
|
-
"aig:write",
|
|
84690
|
-
"auditlogs:read",
|
|
84691
|
-
"browser:read",
|
|
84692
|
-
"browser:write",
|
|
84693
|
-
"cfone:read",
|
|
84694
|
-
"cfone:write",
|
|
84695
|
-
"cloudchamber:write",
|
|
84696
|
-
"connectivity:admin",
|
|
84697
|
-
"connectivity:bind",
|
|
84698
|
-
"connectivity:read",
|
|
84699
|
-
"constellation:write",
|
|
84700
|
-
"containers:write",
|
|
84701
|
-
"d1:write",
|
|
84702
|
-
"dex:read",
|
|
84703
|
-
"dex:write",
|
|
84704
|
-
"dns_analytics:read",
|
|
84705
|
-
"dns_records:edit",
|
|
84706
|
-
"dns_records:read",
|
|
84707
|
-
"dns_settings:read",
|
|
84708
|
-
"email_routing:write",
|
|
84709
|
-
"email_sending:write",
|
|
84710
|
-
"firstpartytags:write",
|
|
84711
|
-
"images:read",
|
|
84712
|
-
"images:write",
|
|
84713
|
-
"lb:edit",
|
|
84714
|
-
"lb:read",
|
|
84715
|
-
"logpush:read",
|
|
84716
|
-
"logpush:write",
|
|
84717
|
-
"mcp_portals:read",
|
|
84718
|
-
"mcp_portals:write",
|
|
84719
|
-
"notebook-examples:read",
|
|
84720
|
-
"notification:read",
|
|
84721
|
-
"notification:write",
|
|
84722
|
-
"pages:read",
|
|
84723
|
-
"pages:write",
|
|
84724
|
-
"pipelines:read",
|
|
84725
|
-
"pipelines:setup",
|
|
84726
|
-
"pipelines:write",
|
|
84727
|
-
"query_cache:write",
|
|
84728
|
-
"queues:write",
|
|
84729
|
-
"r2_catalog:write",
|
|
84730
|
-
"radar:read",
|
|
84731
|
-
"rag:read",
|
|
84732
|
-
"rag:write",
|
|
84733
|
-
"registrar:read",
|
|
84734
|
-
"registrar:write",
|
|
84735
|
-
"secrets_store:read",
|
|
84736
|
-
"secrets_store:write",
|
|
84737
|
-
"sso-connector:read",
|
|
84738
|
-
"sso-connector:write",
|
|
84739
|
-
"ssl_certs:write",
|
|
84740
|
-
"tag.write",
|
|
84741
|
-
"teams:pii",
|
|
84742
|
-
"teams:read",
|
|
84743
|
-
"teams:secure_location",
|
|
84744
|
-
"teams:write",
|
|
84745
|
-
"url_scanner:read",
|
|
84746
|
-
"url_scanner:write",
|
|
84747
|
-
"vectorize:write",
|
|
84748
|
-
"workers:read",
|
|
84749
|
-
"workers:write",
|
|
84750
|
-
"workers_builds:read",
|
|
84751
|
-
"workers_builds:write",
|
|
84752
|
-
"workers_deployments:read",
|
|
84753
|
-
"workers_kv:write",
|
|
84754
|
-
"workers_observability:read",
|
|
84755
|
-
"workers_observability:write",
|
|
84756
|
-
"workers_observability_telemetry:write",
|
|
84757
|
-
"workers_routes:write",
|
|
84758
|
-
"workers_scripts:write",
|
|
84759
|
-
"workers_tail:read",
|
|
84760
|
-
"zone:read"
|
|
84761
|
-
]];
|
|
84706
|
+
var CF_UNGRANTABLE_SCOPE_SET = new Set([
|
|
84707
|
+
"billing:read",
|
|
84708
|
+
"billing:write",
|
|
84709
|
+
"email_routing:read",
|
|
84710
|
+
"email_sending:read",
|
|
84711
|
+
"notebook-managed:read",
|
|
84712
|
+
"oauth_account_ssl_and_certificates_write"
|
|
84713
|
+
]);
|
|
84714
|
+
var CF_REQUESTABLE_SCOPES = CF_CLIENT_REGISTERED_SCOPES.filter((scope) => !CF_UNGRANTABLE_SCOPE_SET.has(scope));
|
|
84715
|
+
var DefaultScopeKeys$1 = [...CF_REQUESTABLE_SCOPES];
|
|
84762
84716
|
function setLoginScopeKeys$1(scopes) {
|
|
84763
84717
|
DefaultScopeKeys$1 = scopes;
|
|
84764
84718
|
}
|
|
84765
84719
|
__name$1(setLoginScopeKeys$1, "setLoginScopeKeys");
|
|
84766
|
-
var CF_SCOPE_SET = new Set(
|
|
84720
|
+
var CF_SCOPE_SET = new Set(CF_REQUESTABLE_SCOPES);
|
|
84767
84721
|
function validateScopeKeys$1(scopes) {
|
|
84768
84722
|
return scopes.every((scope) => CF_SCOPE_SET.has(scope));
|
|
84769
84723
|
}
|
|
@@ -85634,7 +85588,7 @@ __name(createWorkerUploadForm, "createWorkerUploadForm");
|
|
|
85634
85588
|
//#endregion
|
|
85635
85589
|
//#region ../remote-bindings/dist/index.mjs
|
|
85636
85590
|
var import_undici = require_undici();
|
|
85637
|
-
var version$2 = "0.0.
|
|
85591
|
+
var version$2 = "0.0.32";
|
|
85638
85592
|
var NoDefaultValueProvided = class extends UserError {
|
|
85639
85593
|
constructor() {
|
|
85640
85594
|
super("This command cannot be run in a non-interactive context", { telemetryMessage: "remote bindings prompt default missing" });
|
|
@@ -89396,7 +89350,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
89396
89350
|
}
|
|
89397
89351
|
}
|
|
89398
89352
|
];
|
|
89399
|
-
const
|
|
89353
|
+
const containerOptionsByWorker = /* @__PURE__ */ new Map();
|
|
89400
89354
|
let containerEngine;
|
|
89401
89355
|
const workersFromConfig = resolvedPluginConfig.type === "workers" ? await Promise.all([...resolvedPluginConfig.environmentNameToWorkerMap].map(async ([environmentName, worker]) => {
|
|
89402
89356
|
const bindings = wrangler.unstable_convertConfigBindingsToStartWorkerBindings(worker.config);
|
|
@@ -89413,13 +89367,13 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
89413
89367
|
if (worker.config.containers?.length && worker.config.dev.enable_containers) {
|
|
89414
89368
|
containerEngine = resolveDockerHost(getDockerPath());
|
|
89415
89369
|
containerBuildId = generateContainerBuildId();
|
|
89370
|
+
containerOptionsByWorker.set(worker.config, createContainerDevPlan({
|
|
89371
|
+
containers: worker.config.containers,
|
|
89372
|
+
exports: worker.config.exports,
|
|
89373
|
+
containerBuildId,
|
|
89374
|
+
configPath: worker.config.configPath
|
|
89375
|
+
})?.containerOptions ?? []);
|
|
89416
89376
|
}
|
|
89417
|
-
const containerPlan = worker.config.dev.enable_containers ? createContainerDevPlan({
|
|
89418
|
-
containers: worker.config.containers,
|
|
89419
|
-
exports: worker.config.exports,
|
|
89420
|
-
containerBuildId,
|
|
89421
|
-
configPath: worker.config.configPath
|
|
89422
|
-
}) : void 0;
|
|
89423
89377
|
const miniflareWorkerOptions = wrangler.unstable_getMiniflareWorkerOptions({
|
|
89424
89378
|
...worker.config,
|
|
89425
89379
|
assets: void 0
|
|
@@ -89427,10 +89381,6 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
89427
89381
|
remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString,
|
|
89428
89382
|
containerBuildId
|
|
89429
89383
|
});
|
|
89430
|
-
for (const option of containerPlan?.containerOptions ?? []) containerTagToOptionsMap.set(option.image_tag, {
|
|
89431
|
-
containerOptions: option,
|
|
89432
|
-
workerConfig: worker.config
|
|
89433
|
-
});
|
|
89434
89384
|
const { externalWorkers: externalWorkers$1 } = miniflareWorkerOptions;
|
|
89435
89385
|
const workerOptions = miniflareWorkerOptions.workerOptions;
|
|
89436
89386
|
if (workerOptions.browserRendering && getBrowserRenderingHeadfulFromEnv()) workerOptions.browserRendering.headful = true;
|
|
@@ -89551,7 +89501,7 @@ async function getDevMiniflareOptions(ctx, viteDevServer) {
|
|
|
89551
89501
|
}
|
|
89552
89502
|
}
|
|
89553
89503
|
}),
|
|
89554
|
-
|
|
89504
|
+
containerOptionsByWorker
|
|
89555
89505
|
};
|
|
89556
89506
|
}
|
|
89557
89507
|
function getPreviewModules(main, modulesRules) {
|
|
@@ -89617,7 +89567,7 @@ function getModulesFromManifest(bundle) {
|
|
|
89617
89567
|
async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
89618
89568
|
const inputInspectorPort = await getInputInspectorPort(ctx, vitePreviewServer);
|
|
89619
89569
|
const { resolvedPluginConfig, resolvedViteConfig } = ctx;
|
|
89620
|
-
const
|
|
89570
|
+
const containerOptionsByWorker = /* @__PURE__ */ new Map();
|
|
89621
89571
|
let containerEngine;
|
|
89622
89572
|
const workers = (await Promise.all(resolvedPluginConfig.workers.map(async (previewWorker) => {
|
|
89623
89573
|
const workerConfig = previewWorker.config;
|
|
@@ -89635,21 +89585,17 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
89635
89585
|
if (workerConfig.containers?.length && workerConfig.dev.enable_containers) {
|
|
89636
89586
|
containerEngine = resolveDockerHost(getDockerPath());
|
|
89637
89587
|
containerBuildId = generateContainerBuildId();
|
|
89588
|
+
containerOptionsByWorker.set(workerConfig, createContainerDevPlan({
|
|
89589
|
+
containers: workerConfig.containers,
|
|
89590
|
+
exports: workerConfig.exports,
|
|
89591
|
+
containerBuildId,
|
|
89592
|
+
configPath: workerConfig.configPath
|
|
89593
|
+
})?.containerOptions ?? []);
|
|
89638
89594
|
}
|
|
89639
|
-
const containerPlan = workerConfig.dev.enable_containers ? createContainerDevPlan({
|
|
89640
|
-
containers: workerConfig.containers,
|
|
89641
|
-
exports: workerConfig.exports,
|
|
89642
|
-
containerBuildId,
|
|
89643
|
-
configPath: workerConfig.configPath
|
|
89644
|
-
}) : void 0;
|
|
89645
89595
|
const miniflareWorkerOptions = wrangler.unstable_getMiniflareWorkerOptions(workerConfig, void 0, {
|
|
89646
89596
|
remoteProxyConnectionString: remoteProxySessionData?.session?.remoteProxyConnectionString,
|
|
89647
89597
|
containerBuildId
|
|
89648
89598
|
});
|
|
89649
|
-
for (const option of containerPlan?.containerOptions ?? []) containerTagToOptionsMap.set(option.image_tag, {
|
|
89650
|
-
containerOptions: option,
|
|
89651
|
-
workerConfig
|
|
89652
|
-
});
|
|
89653
89599
|
const { externalWorkers } = miniflareWorkerOptions;
|
|
89654
89600
|
const { modulesRules,...sourcelessWorkerOptions } = miniflareWorkerOptions.workerOptions;
|
|
89655
89601
|
const workerOptions = sourcelessWorkerOptions;
|
|
@@ -89686,7 +89632,7 @@ async function getPreviewMiniflareOptions(ctx, vitePreviewServer) {
|
|
|
89686
89632
|
containerEngine,
|
|
89687
89633
|
workers
|
|
89688
89634
|
}),
|
|
89689
|
-
|
|
89635
|
+
containerOptionsByWorker
|
|
89690
89636
|
};
|
|
89691
89637
|
}
|
|
89692
89638
|
/**
|
|
@@ -89828,136 +89774,121 @@ function hasSandboxOrigin(origin) {
|
|
|
89828
89774
|
//#endregion
|
|
89829
89775
|
//#region src/plugins/dev.ts
|
|
89830
89776
|
var import_picocolors$2 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
89831
|
-
let exitCallback$2 = () => {};
|
|
89832
|
-
process.on("exit", () => {
|
|
89833
|
-
exitCallback$2();
|
|
89834
|
-
});
|
|
89835
89777
|
/**
|
|
89836
89778
|
* Plugin to provide core development functionality
|
|
89837
89779
|
*/
|
|
89838
89780
|
const devPlugin = createPlugin("dev", (ctx) => {
|
|
89839
|
-
|
|
89840
|
-
|
|
89841
|
-
|
|
89842
|
-
|
|
89843
|
-
|
|
89844
|
-
|
|
89845
|
-
|
|
89846
|
-
|
|
89847
|
-
|
|
89848
|
-
|
|
89849
|
-
|
|
89850
|
-
|
|
89851
|
-
|
|
89852
|
-
|
|
89853
|
-
|
|
89854
|
-
if (!ctx.isRestartingDevServer) {
|
|
89855
|
-
if (containerImageTags.size) cleanupContainers(getDockerPath(), containerImageTags);
|
|
89856
|
-
try {
|
|
89857
|
-
await ctx.disposeMiniflare();
|
|
89858
|
-
} catch (error$2) {
|
|
89859
|
-
debuglog("Failed to dispose Miniflare instance:", error$2);
|
|
89860
|
-
}
|
|
89861
|
-
}
|
|
89862
|
-
}
|
|
89863
|
-
};
|
|
89864
|
-
if (viteDevServer.httpServer) viteDevServer.httpServer.on("listening", () => {
|
|
89865
|
-
const addr = viteDevServer.httpServer?.address();
|
|
89866
|
-
if (typeof addr === "object" && addr !== null) {
|
|
89867
|
-
const serverConfig = viteDevServer.config.server;
|
|
89868
|
-
ctx.miniflare.publicUrl = buildPublicUrl({
|
|
89869
|
-
hostname: typeof serverConfig.host === "string" ? serverConfig.host : void 0,
|
|
89870
|
-
port: addr.port,
|
|
89871
|
-
secure: !!serverConfig.https
|
|
89872
|
-
});
|
|
89781
|
+
return { async configureServer(viteDevServer) {
|
|
89782
|
+
assertIsNotPreview(ctx);
|
|
89783
|
+
const containerCleanup = getDevContainerCleanup(viteDevServer);
|
|
89784
|
+
const initialOptions = await getDevMiniflareOptions(ctx, viteDevServer);
|
|
89785
|
+
let containerOptionsByWorker = initialOptions.containerOptionsByWorker;
|
|
89786
|
+
await ctx.startOrUpdateMiniflare(initialOptions.miniflareOptions);
|
|
89787
|
+
const closeServer = viteDevServer.close.bind(viteDevServer);
|
|
89788
|
+
viteDevServer.close = async () => {
|
|
89789
|
+
try {
|
|
89790
|
+
await closeServer();
|
|
89791
|
+
} finally {
|
|
89792
|
+
if (!ctx.isRestartingDevServer) try {
|
|
89793
|
+
await ctx.disposeMiniflare();
|
|
89794
|
+
} catch (error$2) {
|
|
89795
|
+
debuglog("Failed to dispose Miniflare instance:", error$2);
|
|
89873
89796
|
}
|
|
89874
|
-
}
|
|
89875
|
-
|
|
89876
|
-
|
|
89797
|
+
}
|
|
89798
|
+
};
|
|
89799
|
+
if (viteDevServer.httpServer) viteDevServer.httpServer.on("listening", () => {
|
|
89800
|
+
const addr = viteDevServer.httpServer?.address();
|
|
89801
|
+
if (typeof addr === "object" && addr !== null) {
|
|
89802
|
+
const serverConfig = viteDevServer.config.server;
|
|
89803
|
+
ctx.miniflare.publicUrl = buildPublicUrl({
|
|
89804
|
+
hostname: typeof serverConfig.host === "string" ? serverConfig.host : void 0,
|
|
89805
|
+
port: addr.port,
|
|
89806
|
+
secure: !!serverConfig.https
|
|
89807
|
+
});
|
|
89808
|
+
}
|
|
89809
|
+
});
|
|
89810
|
+
if (ctx.resolvedPluginConfig.type === "workers") {
|
|
89811
|
+
debuglog("Initializing the Vite module runners");
|
|
89812
|
+
await initRunners(ctx.resolvedPluginConfig, viteDevServer, ctx.miniflare);
|
|
89813
|
+
const currentWorkerNameToExportTypesMap = await getCurrentWorkerNameToExportTypesMap(ctx.resolvedPluginConfig, viteDevServer, ctx.miniflare);
|
|
89814
|
+
if (compareWorkerNameToExportTypesMaps(ctx.workerNameToExportTypesMap, currentWorkerNameToExportTypesMap)) {
|
|
89815
|
+
ctx.setWorkerNameToExportTypesMap(currentWorkerNameToExportTypesMap);
|
|
89816
|
+
const updatedOptions = await getDevMiniflareOptions(ctx, viteDevServer);
|
|
89817
|
+
containerOptionsByWorker = updatedOptions.containerOptionsByWorker;
|
|
89818
|
+
await ctx.startOrUpdateMiniflare(updatedOptions.miniflareOptions);
|
|
89877
89819
|
await initRunners(ctx.resolvedPluginConfig, viteDevServer, ctx.miniflare);
|
|
89878
|
-
const currentWorkerNameToExportTypesMap = await getCurrentWorkerNameToExportTypesMap(ctx.resolvedPluginConfig, viteDevServer, ctx.miniflare);
|
|
89879
|
-
if (compareWorkerNameToExportTypesMaps(ctx.workerNameToExportTypesMap, currentWorkerNameToExportTypesMap)) {
|
|
89880
|
-
ctx.setWorkerNameToExportTypesMap(currentWorkerNameToExportTypesMap);
|
|
89881
|
-
const updatedOptions = await getDevMiniflareOptions(ctx, viteDevServer);
|
|
89882
|
-
containerTagToOptionsMap = updatedOptions.containerTagToOptionsMap;
|
|
89883
|
-
await ctx.startOrUpdateMiniflare(updatedOptions.miniflareOptions);
|
|
89884
|
-
await initRunners(ctx.resolvedPluginConfig, viteDevServer, ctx.miniflare);
|
|
89885
|
-
}
|
|
89886
|
-
for (const environmentName of ctx.resolvedPluginConfig.environmentNameToWorkerMap.keys()) {
|
|
89887
|
-
const environment = viteDevServer.environments[environmentName];
|
|
89888
|
-
assert2(environment, `Expected environment "${environmentName}" to be defined`);
|
|
89889
|
-
environment.hot.on("vite-plugin-cloudflare:worker-export-types", async (newExportTypes) => {
|
|
89890
|
-
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
89891
|
-
assert2(workerConfig, `Expected workerConfig for environment "${environmentName}" to be defined`);
|
|
89892
|
-
const oldExportTypes = ctx.workerNameToExportTypesMap.get(workerConfig.name);
|
|
89893
|
-
assert2(oldExportTypes, `Expected export types for Worker "${workerConfig.name}" to be defined`);
|
|
89894
|
-
if (compareExportTypes(oldExportTypes, newExportTypes)) {
|
|
89895
|
-
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("Worker exports have changed. Restarting dev server.")));
|
|
89896
|
-
await viteDevServer.restart();
|
|
89897
|
-
}
|
|
89898
|
-
});
|
|
89899
|
-
}
|
|
89900
|
-
const entryWorkerConfig = ctx.entryWorkerConfig;
|
|
89901
|
-
assert2(entryWorkerConfig, `No entry Worker config`);
|
|
89902
|
-
const entryWorkerName = entryWorkerConfig.name;
|
|
89903
|
-
if (viteDevServer.httpServer) handleWebSocket(viteDevServer.httpServer, ctx.miniflare, entryWorkerName);
|
|
89904
|
-
const staticRouting = entryWorkerConfig.assets?.run_worker_first === true ? { user_worker: ["/*"] } : ctx.resolvedPluginConfig.staticRouting;
|
|
89905
|
-
if (staticRouting) {
|
|
89906
|
-
const excludeRulesMatcher = generateStaticRoutingRuleMatcher(staticRouting.asset_worker ?? []);
|
|
89907
|
-
const includeRulesMatcher = generateStaticRoutingRuleMatcher(staticRouting.user_worker);
|
|
89908
|
-
const userWorkerHandler = createRequestHandler(async (request$2) => {
|
|
89909
|
-
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, entryWorkerName);
|
|
89910
|
-
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89911
|
-
});
|
|
89912
|
-
viteDevServer.middlewares.use(async function cloudflarePreMiddleware(req, res, next) {
|
|
89913
|
-
assert2(req.url, `req.url not defined`);
|
|
89914
|
-
const request$2 = new Request(new URL(req.url, UNKNOWN_HOST));
|
|
89915
|
-
if (req[kRequestType] === "asset") next();
|
|
89916
|
-
else if (excludeRulesMatcher({ request: request$2 })) {
|
|
89917
|
-
req[kRequestType] = "asset";
|
|
89918
|
-
next();
|
|
89919
|
-
} else if (includeRulesMatcher({ request: request$2 })) userWorkerHandler(req, res, next);
|
|
89920
|
-
else next();
|
|
89921
|
-
});
|
|
89922
|
-
}
|
|
89923
|
-
if (containerTagToOptionsMap.size) {
|
|
89924
|
-
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("∷ Building container images for local development...\n")));
|
|
89925
|
-
await prepareContainerImagesForVite({
|
|
89926
|
-
dockerPath: getDockerPath(),
|
|
89927
|
-
containerTagToOptionsMap,
|
|
89928
|
-
logger: viteDevServer.config.logger
|
|
89929
|
-
});
|
|
89930
|
-
containerImageTags = new Set(containerTagToOptionsMap.keys());
|
|
89931
|
-
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("\n⚡️ Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter).")));
|
|
89932
|
-
exitCallback$2 = () => {
|
|
89933
|
-
if (containerImageTags.size) cleanupContainers(getDockerPath(), containerImageTags);
|
|
89934
|
-
};
|
|
89935
|
-
}
|
|
89936
89820
|
}
|
|
89937
|
-
|
|
89938
|
-
|
|
89939
|
-
|
|
89940
|
-
|
|
89941
|
-
|
|
89942
|
-
|
|
89943
|
-
|
|
89944
|
-
|
|
89945
|
-
|
|
89946
|
-
|
|
89947
|
-
|
|
89948
|
-
}
|
|
89949
|
-
viteDevServer.middlewares.use(createRequestHandler(async (request$2, req) => {
|
|
89950
|
-
if (req[kRequestType] === "asset") {
|
|
89951
|
-
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, ASSET_WORKER_NAME);
|
|
89952
|
-
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89953
|
-
} else {
|
|
89954
|
-
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, ROUTER_WORKER_NAME);
|
|
89955
|
-
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89821
|
+
for (const environmentName of ctx.resolvedPluginConfig.environmentNameToWorkerMap.keys()) {
|
|
89822
|
+
const environment = viteDevServer.environments[environmentName];
|
|
89823
|
+
assert2(environment, `Expected environment "${environmentName}" to be defined`);
|
|
89824
|
+
environment.hot.on("vite-plugin-cloudflare:worker-export-types", async (newExportTypes) => {
|
|
89825
|
+
const workerConfig = ctx.getWorkerConfig(environmentName);
|
|
89826
|
+
assert2(workerConfig, `Expected workerConfig for environment "${environmentName}" to be defined`);
|
|
89827
|
+
const oldExportTypes = ctx.workerNameToExportTypesMap.get(workerConfig.name);
|
|
89828
|
+
assert2(oldExportTypes, `Expected export types for Worker "${workerConfig.name}" to be defined`);
|
|
89829
|
+
if (compareExportTypes(oldExportTypes, newExportTypes)) {
|
|
89830
|
+
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("Worker exports have changed. Restarting dev server.")));
|
|
89831
|
+
await viteDevServer.restart();
|
|
89956
89832
|
}
|
|
89957
|
-
})
|
|
89958
|
-
}
|
|
89833
|
+
});
|
|
89834
|
+
}
|
|
89835
|
+
const entryWorkerConfig = ctx.entryWorkerConfig;
|
|
89836
|
+
assert2(entryWorkerConfig, `No entry Worker config`);
|
|
89837
|
+
const entryWorkerName = entryWorkerConfig.name;
|
|
89838
|
+
if (viteDevServer.httpServer) handleWebSocket(viteDevServer.httpServer, ctx.miniflare, entryWorkerName);
|
|
89839
|
+
const staticRouting = entryWorkerConfig.assets?.run_worker_first === true ? { user_worker: ["/*"] } : ctx.resolvedPluginConfig.staticRouting;
|
|
89840
|
+
if (staticRouting) {
|
|
89841
|
+
const excludeRulesMatcher = generateStaticRoutingRuleMatcher(staticRouting.asset_worker ?? []);
|
|
89842
|
+
const includeRulesMatcher = generateStaticRoutingRuleMatcher(staticRouting.user_worker);
|
|
89843
|
+
const userWorkerHandler = createRequestHandler(async (request$2) => {
|
|
89844
|
+
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, entryWorkerName);
|
|
89845
|
+
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89846
|
+
});
|
|
89847
|
+
viteDevServer.middlewares.use(async function cloudflarePreMiddleware(req, res, next) {
|
|
89848
|
+
assert2(req.url, `req.url not defined`);
|
|
89849
|
+
const request$2 = new Request(new URL(req.url, UNKNOWN_HOST));
|
|
89850
|
+
if (req[kRequestType] === "asset") next();
|
|
89851
|
+
else if (excludeRulesMatcher({ request: request$2 })) {
|
|
89852
|
+
req[kRequestType] = "asset";
|
|
89853
|
+
next();
|
|
89854
|
+
} else if (includeRulesMatcher({ request: request$2 })) userWorkerHandler(req, res, next);
|
|
89855
|
+
else next();
|
|
89856
|
+
});
|
|
89857
|
+
}
|
|
89858
|
+
if (containerOptionsByWorker.size) {
|
|
89859
|
+
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("∷ Building container images for local development...\n")));
|
|
89860
|
+
await prepareContainerImagesForVite({
|
|
89861
|
+
dockerPath: getDockerPath(),
|
|
89862
|
+
containerOptionsByWorker,
|
|
89863
|
+
logger: viteDevServer.config.logger
|
|
89864
|
+
});
|
|
89865
|
+
containerCleanup.track(getDockerPath(), [...containerOptionsByWorker.values()].flatMap((options) => options.map(({ image_tag }) => image_tag)));
|
|
89866
|
+
viteDevServer.config.logger.info(import_picocolors$2.default.dim(import_picocolors$2.default.yellow("\n⚡️ Containers successfully built. To rebuild your containers during development, restart the Vite dev server (r + enter).")));
|
|
89867
|
+
}
|
|
89959
89868
|
}
|
|
89960
|
-
|
|
89869
|
+
return () => {
|
|
89870
|
+
if (!satisfiesMinimumViteVersion("7.0.0")) {
|
|
89871
|
+
const middlewareStack = viteDevServer.middlewares.stack;
|
|
89872
|
+
const preMiddlewareIndex = middlewareStack.findIndex((middleware) => "name" in middleware.handle && middleware.handle.name === "cloudflarePreMiddleware");
|
|
89873
|
+
if (preMiddlewareIndex !== -1) {
|
|
89874
|
+
const [preMiddleware] = middlewareStack.splice(preMiddlewareIndex, 1);
|
|
89875
|
+
assert2(preMiddleware, "Failed to remove cloudflarePreMiddleware from stack");
|
|
89876
|
+
const cachedTransformMiddlewareIndex = middlewareStack.findIndex((middleware) => "name" in middleware.handle && middleware.handle.name === "viteCachedTransformMiddleware");
|
|
89877
|
+
assert2(cachedTransformMiddlewareIndex !== -1, "Failed to find viteCachedTransformMiddleware");
|
|
89878
|
+
middlewareStack.splice(cachedTransformMiddlewareIndex, 0, preMiddleware);
|
|
89879
|
+
}
|
|
89880
|
+
}
|
|
89881
|
+
viteDevServer.middlewares.use(createRequestHandler(async (request$2, req) => {
|
|
89882
|
+
if (req[kRequestType] === "asset") {
|
|
89883
|
+
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, ASSET_WORKER_NAME);
|
|
89884
|
+
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89885
|
+
} else {
|
|
89886
|
+
request$2.headers.set(CoreHeaders.ROUTE_OVERRIDE, ROUTER_WORKER_NAME);
|
|
89887
|
+
return ctx.miniflare.dispatchFetch(request$2, { redirect: "manual" });
|
|
89888
|
+
}
|
|
89889
|
+
}));
|
|
89890
|
+
};
|
|
89891
|
+
} };
|
|
89961
89892
|
});
|
|
89962
89893
|
|
|
89963
89894
|
//#endregion
|
|
@@ -90025,16 +89956,16 @@ const nodeJsCompatPlugin = createPlugin("nodejs-compat", (ctx) => {
|
|
|
90025
89956
|
}
|
|
90026
89957
|
};
|
|
90027
89958
|
});
|
|
90028
|
-
let exitCallback
|
|
89959
|
+
let exitCallback = () => {};
|
|
90029
89960
|
process.on("exit", () => {
|
|
90030
|
-
exitCallback
|
|
89961
|
+
exitCallback();
|
|
90031
89962
|
});
|
|
90032
89963
|
/**
|
|
90033
89964
|
* Plugin to warn if Node.js APIs are used without enabling the `nodejs_compat` compatibility flag
|
|
90034
89965
|
*/
|
|
90035
89966
|
const nodeJsCompatWarningsPlugin = createPlugin("nodejs-compat-warnings", (ctx) => {
|
|
90036
89967
|
const nodeJsCompatWarningsMap = /* @__PURE__ */ new Map();
|
|
90037
|
-
exitCallback
|
|
89968
|
+
exitCallback = () => {
|
|
90038
89969
|
for (const nodeJsCompatWarnings of nodeJsCompatWarningsMap.values()) nodeJsCompatWarnings.renderWarnings();
|
|
90039
89970
|
};
|
|
90040
89971
|
return {
|
|
@@ -90233,21 +90164,23 @@ const triggerHandlersPlugin = createPlugin("trigger-handlers", (ctx) => {
|
|
|
90233
90164
|
//#endregion
|
|
90234
90165
|
//#region src/plugins/preview.ts
|
|
90235
90166
|
var import_picocolors$1 = /* @__PURE__ */ __toESM$2(require_picocolors(), 1);
|
|
90236
|
-
let exitCallback = () => {};
|
|
90237
|
-
process.on("exit", () => {
|
|
90238
|
-
exitCallback();
|
|
90239
|
-
});
|
|
90240
90167
|
/**
|
|
90241
90168
|
* Plugin to provide core preview functionality
|
|
90242
90169
|
*/
|
|
90243
90170
|
const previewPlugin = createPlugin("preview", (ctx) => {
|
|
90244
90171
|
return { async configurePreviewServer(vitePreviewServer) {
|
|
90245
90172
|
assertIsPreview(ctx);
|
|
90173
|
+
const dockerPath = getDockerPath();
|
|
90174
|
+
const containerCleanup = createContainerCleanup();
|
|
90246
90175
|
const closePreviewServer = vitePreviewServer.close.bind(vitePreviewServer);
|
|
90247
90176
|
vitePreviewServer.close = async () => {
|
|
90248
|
-
|
|
90177
|
+
try {
|
|
90178
|
+
await Promise.all([ctx.disposeMiniflare(), closePreviewServer()]);
|
|
90179
|
+
} finally {
|
|
90180
|
+
containerCleanup.cleanup();
|
|
90181
|
+
}
|
|
90249
90182
|
};
|
|
90250
|
-
const { miniflareOptions,
|
|
90183
|
+
const { miniflareOptions, containerOptionsByWorker } = await getPreviewMiniflareOptions(ctx, vitePreviewServer);
|
|
90251
90184
|
await ctx.startOrUpdateMiniflare(miniflareOptions);
|
|
90252
90185
|
if (vitePreviewServer.httpServer) vitePreviewServer.httpServer.on("listening", () => {
|
|
90253
90186
|
const addr = vitePreviewServer.httpServer?.address();
|
|
@@ -90260,19 +90193,15 @@ const previewPlugin = createPlugin("preview", (ctx) => {
|
|
|
90260
90193
|
});
|
|
90261
90194
|
}
|
|
90262
90195
|
});
|
|
90263
|
-
if (
|
|
90264
|
-
const dockerPath = getDockerPath();
|
|
90196
|
+
if (containerOptionsByWorker.size) {
|
|
90265
90197
|
vitePreviewServer.config.logger.info(import_picocolors$1.default.dim(import_picocolors$1.default.yellow("∷ Building container images for local preview...\n")));
|
|
90266
90198
|
await prepareContainerImagesForVite({
|
|
90267
90199
|
dockerPath,
|
|
90268
|
-
|
|
90200
|
+
containerOptionsByWorker,
|
|
90269
90201
|
logger: vitePreviewServer.config.logger
|
|
90270
90202
|
});
|
|
90271
|
-
|
|
90203
|
+
containerCleanup.track(dockerPath, [...containerOptionsByWorker.values()].flatMap((options) => options.map(({ image_tag }) => image_tag)));
|
|
90272
90204
|
vitePreviewServer.config.logger.info(import_picocolors$1.default.dim(import_picocolors$1.default.yellow("\n⚡️ Containers successfully built.\n")));
|
|
90273
|
-
exitCallback = () => {
|
|
90274
|
-
if (containerImageTags.size) cleanupContainers(dockerPath, containerImageTags);
|
|
90275
|
-
};
|
|
90276
90205
|
}
|
|
90277
90206
|
handleWebSocket(vitePreviewServer.httpServer, ctx.miniflare);
|
|
90278
90207
|
vitePreviewServer.middlewares.use(createRequestHandler((request$2) => {
|