@danielx/civet 0.6.31 → 0.6.32
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/browser.js +175 -82
- package/dist/config.js +4 -0
- package/dist/esbuild-plugin.js +4 -0
- package/dist/esbuild.d.mts +1 -1
- package/dist/esbuild.d.ts +1 -1
- package/dist/esm.mjs +3 -0
- package/dist/main.js +175 -82
- package/dist/main.mjs +175 -82
- package/dist/rollup.d.mts +1 -1
- package/dist/rollup.d.ts +1 -1
- package/dist/unplugin.d.mts +2 -2
- package/dist/unplugin.d.ts +2 -2
- package/dist/vite.d.mts +1 -1
- package/dist/vite.d.ts +1 -1
- package/dist/webpack.d.mts +1 -1
- package/dist/webpack.d.ts +1 -1
- package/package.json +4 -3
package/dist/main.js
CHANGED
|
@@ -22,6 +22,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
22
22
|
return to;
|
|
23
23
|
};
|
|
24
24
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
29
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
30
|
mod
|
|
27
31
|
));
|
|
@@ -522,9 +526,10 @@ var require_lib = __commonJS({
|
|
|
522
526
|
}
|
|
523
527
|
function addPostfixStatement(statement, ws, post) {
|
|
524
528
|
let children, expressions;
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
529
|
+
const prefix = post.blockPrefix || post.condition?.expression.blockPrefix;
|
|
530
|
+
if (prefix?.length) {
|
|
531
|
+
const indent = prefix[0][0];
|
|
532
|
+
expressions = [...prefix, [indent, statement]];
|
|
528
533
|
children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
|
|
529
534
|
} else {
|
|
530
535
|
expressions = [["", statement]];
|
|
@@ -603,6 +608,7 @@ var require_lib = __commonJS({
|
|
|
603
608
|
children: [...elements.slice(0, restIndex), {
|
|
604
609
|
...rest,
|
|
605
610
|
children: rest.children.slice(0, -1)
|
|
611
|
+
// remove trailing comma
|
|
606
612
|
}],
|
|
607
613
|
blockPrefix,
|
|
608
614
|
length
|
|
@@ -647,7 +653,9 @@ var require_lib = __commonJS({
|
|
|
647
653
|
if (prefixStatements && prefixStatements.length) {
|
|
648
654
|
const indent = getIndent(block.expressions[0]);
|
|
649
655
|
if (indent) {
|
|
650
|
-
prefixStatements = prefixStatements.map((statement) =>
|
|
656
|
+
prefixStatements = prefixStatements.map((statement) => {
|
|
657
|
+
return [indent, ...statement.slice(1)];
|
|
658
|
+
});
|
|
651
659
|
}
|
|
652
660
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
653
661
|
block = {
|
|
@@ -832,7 +840,8 @@ var require_lib = __commonJS({
|
|
|
832
840
|
...wrapIIFE([
|
|
833
841
|
["", ["const ", resultsRef, "=[]"], ";"],
|
|
834
842
|
...children,
|
|
835
|
-
["",
|
|
843
|
+
["", "; "],
|
|
844
|
+
["", wrapWithReturn(resultsRef)]
|
|
836
845
|
], async)
|
|
837
846
|
);
|
|
838
847
|
}
|
|
@@ -947,6 +956,7 @@ var require_lib = __commonJS({
|
|
|
947
956
|
part.children[3]?.token === ":" ? part.children[3] : ":",
|
|
948
957
|
value,
|
|
949
958
|
part.delim
|
|
959
|
+
// comma delimiter
|
|
950
960
|
]
|
|
951
961
|
});
|
|
952
962
|
}
|
|
@@ -955,8 +965,10 @@ var require_lib = __commonJS({
|
|
|
955
965
|
type: "ObjectExpression",
|
|
956
966
|
children: [
|
|
957
967
|
glob.object.children[0],
|
|
968
|
+
// {
|
|
958
969
|
...parts,
|
|
959
970
|
glob.object.children.at(-1)
|
|
971
|
+
// whitespace and }
|
|
960
972
|
],
|
|
961
973
|
properties: parts,
|
|
962
974
|
hoistDec
|
|
@@ -971,12 +983,14 @@ var require_lib = __commonJS({
|
|
|
971
983
|
if (i === children.length - 1)
|
|
972
984
|
return object;
|
|
973
985
|
return processCallMemberExpression({
|
|
986
|
+
// in case there are more
|
|
974
987
|
...node,
|
|
975
988
|
children: [object, ...children.slice(i + 1)]
|
|
976
989
|
});
|
|
977
990
|
} else if (glob?.type === "PropertyBind") {
|
|
978
991
|
const prefix = children.slice(0, i);
|
|
979
992
|
return processCallMemberExpression({
|
|
993
|
+
// in case there are more
|
|
980
994
|
...node,
|
|
981
995
|
children: [
|
|
982
996
|
prefix,
|
|
@@ -1112,35 +1126,41 @@ var require_lib = __commonJS({
|
|
|
1112
1126
|
;
|
|
1113
1127
|
return;
|
|
1114
1128
|
}
|
|
1129
|
+
var relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
|
|
1130
|
+
function isRelationalOp(op) {
|
|
1131
|
+
return relationalOps.includes(op.token) || op.relational;
|
|
1132
|
+
}
|
|
1115
1133
|
function expandChainedComparisons([first, binops]) {
|
|
1116
|
-
const relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
|
|
1117
1134
|
const lowerPrecedenceOps = ["??", "&&", "||", "&", "|", "^"];
|
|
1118
|
-
|
|
1135
|
+
const results = [];
|
|
1119
1136
|
let i = 0;
|
|
1120
1137
|
const l = binops.length;
|
|
1121
1138
|
let start = 0;
|
|
1122
1139
|
let chains = [];
|
|
1140
|
+
let op;
|
|
1123
1141
|
while (i < l) {
|
|
1124
|
-
|
|
1125
|
-
if (
|
|
1142
|
+
[, op] = binops[i];
|
|
1143
|
+
if (isRelationalOp(op)) {
|
|
1126
1144
|
chains.push(i);
|
|
1127
1145
|
} else if (lowerPrecedenceOps.includes(op.token)) {
|
|
1128
|
-
processChains();
|
|
1146
|
+
processChains(op);
|
|
1129
1147
|
first = [];
|
|
1130
1148
|
}
|
|
1131
1149
|
i++;
|
|
1132
1150
|
}
|
|
1133
|
-
processChains();
|
|
1151
|
+
processChains(op);
|
|
1134
1152
|
return results;
|
|
1135
|
-
function processChains() {
|
|
1136
|
-
|
|
1153
|
+
function processChains(op2) {
|
|
1154
|
+
if (isRelationalOp(op2)) {
|
|
1155
|
+
first = expandExistence(first);
|
|
1156
|
+
}
|
|
1137
1157
|
if (chains.length > 1) {
|
|
1138
1158
|
chains.forEach((index, k) => {
|
|
1139
1159
|
if (k > 0) {
|
|
1140
1160
|
results.push(" ", "&&", " ");
|
|
1141
1161
|
}
|
|
1142
1162
|
const binop = binops[index];
|
|
1143
|
-
let [pre,
|
|
1163
|
+
let [pre, op3, post, exp] = binop;
|
|
1144
1164
|
exp = binop[3] = expandExistence(exp);
|
|
1145
1165
|
let endIndex;
|
|
1146
1166
|
if (k < chains.length - 1) {
|
|
@@ -1296,7 +1316,6 @@ var require_lib = __commonJS({
|
|
|
1296
1316
|
default:
|
|
1297
1317
|
return gatherNodes(node.children, predicate);
|
|
1298
1318
|
}
|
|
1299
|
-
return [];
|
|
1300
1319
|
}
|
|
1301
1320
|
function gatherRecursive(node, predicate, skipPredicate) {
|
|
1302
1321
|
if (node == null)
|
|
@@ -1478,6 +1497,7 @@ var require_lib = __commonJS({
|
|
|
1478
1497
|
else
|
|
1479
1498
|
exp.children.push(["", {
|
|
1480
1499
|
type: "ReturnStatement",
|
|
1500
|
+
// NOTE: add a prefixed semi-colon because the if block may not be braced
|
|
1481
1501
|
children: [";return"]
|
|
1482
1502
|
}]);
|
|
1483
1503
|
return;
|
|
@@ -1497,17 +1517,9 @@ var require_lib = __commonJS({
|
|
|
1497
1517
|
node.splice(1, 1, returnStatement);
|
|
1498
1518
|
}
|
|
1499
1519
|
function insertSwitchReturns(exp) {
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
insertReturn:
|
|
1504
|
-
insertReturn(clause);
|
|
1505
|
-
});
|
|
1506
|
-
return;
|
|
1507
|
-
case "SwitchExpression":
|
|
1508
|
-
exp.caseBlock.clauses.forEach(insertReturn);
|
|
1509
|
-
return;
|
|
1510
|
-
}
|
|
1520
|
+
exp.caseBlock.clauses.forEach((clause) => {
|
|
1521
|
+
return insertReturn(clause);
|
|
1522
|
+
});
|
|
1511
1523
|
}
|
|
1512
1524
|
function isEmptyBareBlock(node) {
|
|
1513
1525
|
if (node?.type !== "BlockStatement")
|
|
@@ -1646,6 +1658,7 @@ var require_lib = __commonJS({
|
|
|
1646
1658
|
declaration,
|
|
1647
1659
|
blockPrefix,
|
|
1648
1660
|
children: [awaits, eachOwnError, open, declaration, ws, inOf, expRef ?? exp, step, close]
|
|
1661
|
+
// omit declaration2, replace eachOwn with eachOwnError, replace exp with expRef
|
|
1649
1662
|
};
|
|
1650
1663
|
}
|
|
1651
1664
|
let ws2, decl2;
|
|
@@ -1713,6 +1726,7 @@ var require_lib = __commonJS({
|
|
|
1713
1726
|
return {
|
|
1714
1727
|
declaration,
|
|
1715
1728
|
children: [awaits, eachOwnError, open, declaration, ws, inOf, exp, step, close],
|
|
1729
|
+
// omit declaration2, replace each with eachOwnError
|
|
1716
1730
|
blockPrefix,
|
|
1717
1731
|
hoistDec
|
|
1718
1732
|
};
|
|
@@ -2089,14 +2103,6 @@ var require_lib = __commonJS({
|
|
|
2089
2103
|
return processReturn(f, config.implicitReturns);
|
|
2090
2104
|
});
|
|
2091
2105
|
}
|
|
2092
|
-
function processSwitchExpressions(statements) {
|
|
2093
|
-
gatherRecursiveAll(statements, (n) => n.type === "SwitchExpression").forEach(insertSwitchReturns);
|
|
2094
|
-
}
|
|
2095
|
-
function processTryExpressions(statements) {
|
|
2096
|
-
gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
|
|
2097
|
-
blocks.forEach(insertReturn);
|
|
2098
|
-
});
|
|
2099
|
-
}
|
|
2100
2106
|
function processBindingPatternLHS(lhs, tail) {
|
|
2101
2107
|
adjustAtBindings(lhs, true);
|
|
2102
2108
|
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
@@ -2476,7 +2482,7 @@ var require_lib = __commonJS({
|
|
|
2476
2482
|
return declarations;
|
|
2477
2483
|
}
|
|
2478
2484
|
function processPatternMatching(statements, ReservedWord) {
|
|
2479
|
-
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement"
|
|
2485
|
+
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
|
|
2480
2486
|
const { caseBlock } = s;
|
|
2481
2487
|
const { clauses } = caseBlock;
|
|
2482
2488
|
let errors = false;
|
|
@@ -2582,10 +2588,6 @@ var require_lib = __commonJS({
|
|
|
2582
2588
|
refAssignment = [];
|
|
2583
2589
|
return prev = next;
|
|
2584
2590
|
});
|
|
2585
|
-
if (s.type === "SwitchExpression") {
|
|
2586
|
-
insertReturn(root[0]);
|
|
2587
|
-
root.splice(0, 1, wrapIIFE(root[0]));
|
|
2588
|
-
}
|
|
2589
2591
|
s.type = "PatternMatchingStatement";
|
|
2590
2592
|
s.children = [root];
|
|
2591
2593
|
return addParentPointers(s, s.parent);
|
|
@@ -2731,8 +2733,6 @@ var require_lib = __commonJS({
|
|
|
2731
2733
|
processPipelineExpressions(statements);
|
|
2732
2734
|
processAssignments(statements);
|
|
2733
2735
|
processPatternMatching(statements, ReservedWord);
|
|
2734
|
-
processSwitchExpressions(statements);
|
|
2735
|
-
processTryExpressions(statements);
|
|
2736
2736
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
2737
2737
|
hoistRefDecs(statements);
|
|
2738
2738
|
processFunctions(statements, config);
|
|
@@ -2969,20 +2969,31 @@ var require_lib = __commonJS({
|
|
|
2969
2969
|
if (post?.token === "?") {
|
|
2970
2970
|
post = {
|
|
2971
2971
|
$loc: post.$loc,
|
|
2972
|
-
token: "!="
|
|
2972
|
+
token: " != null"
|
|
2973
2973
|
};
|
|
2974
2974
|
if (pre.length) {
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2975
|
+
const lastPre = pre[pre.length - 1];
|
|
2976
|
+
if (lastPre.token === "!") {
|
|
2977
|
+
post.token = " == null";
|
|
2978
|
+
pre = pre.slice(0, -1);
|
|
2979
|
+
} else if (lastPre.length === 2 && lastPre[0].token === "!") {
|
|
2980
|
+
post.token = " == null";
|
|
2981
|
+
pre = pre.slice(0, -1);
|
|
2982
|
+
}
|
|
2979
2983
|
}
|
|
2980
2984
|
const existence = {
|
|
2981
2985
|
type: "Existence",
|
|
2982
2986
|
expression: exp,
|
|
2983
|
-
children: [exp,
|
|
2987
|
+
children: [exp, post]
|
|
2984
2988
|
};
|
|
2985
|
-
|
|
2989
|
+
exp = makeLeftHandSideExpression(existence);
|
|
2990
|
+
if (pre.length) {
|
|
2991
|
+
return {
|
|
2992
|
+
type: "UnaryExpression",
|
|
2993
|
+
children: [...pre, exp]
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2996
|
+
return exp;
|
|
2986
2997
|
}
|
|
2987
2998
|
if (exp.type === "Literal") {
|
|
2988
2999
|
if (pre.length === 1 && pre[0].token === "-") {
|
|
@@ -3179,31 +3190,53 @@ var require_lib = __commonJS({
|
|
|
3179
3190
|
;
|
|
3180
3191
|
return;
|
|
3181
3192
|
}
|
|
3182
|
-
function wrapIIFE(
|
|
3183
|
-
let prefix
|
|
3193
|
+
function wrapIIFE(expressions, async) {
|
|
3194
|
+
let prefix;
|
|
3184
3195
|
if (async) {
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
prefix =
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
suffix = ")()";
|
|
3196
|
+
async = "async ";
|
|
3197
|
+
} else if (hasAwait(expressions)) {
|
|
3198
|
+
async = "async ";
|
|
3199
|
+
prefix = {
|
|
3200
|
+
type: "Await",
|
|
3201
|
+
children: ["await "]
|
|
3202
|
+
};
|
|
3193
3203
|
}
|
|
3194
|
-
const expressions = Array.isArray(exp) ? [...exp] : [exp];
|
|
3195
3204
|
const block = {
|
|
3196
3205
|
type: "BlockStatement",
|
|
3197
3206
|
expressions,
|
|
3198
3207
|
children: ["{", expressions, "}"],
|
|
3199
3208
|
bare: false
|
|
3200
3209
|
};
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3210
|
+
const parameters = {
|
|
3211
|
+
type: "Parameters",
|
|
3212
|
+
children: ["()"],
|
|
3213
|
+
names: []
|
|
3214
|
+
};
|
|
3215
|
+
const signature = {
|
|
3216
|
+
modifier: {
|
|
3217
|
+
async: !!async
|
|
3218
|
+
},
|
|
3219
|
+
returnType: void 0
|
|
3220
|
+
};
|
|
3221
|
+
const fn = {
|
|
3222
|
+
type: "ArrowFunction",
|
|
3223
|
+
signature,
|
|
3224
|
+
parameters,
|
|
3225
|
+
returnType: void 0,
|
|
3226
|
+
ts: false,
|
|
3227
|
+
async,
|
|
3204
3228
|
block,
|
|
3205
|
-
|
|
3206
|
-
|
|
3229
|
+
children: [async, parameters, "=>", block]
|
|
3230
|
+
};
|
|
3231
|
+
updateParentPointers(block, fn);
|
|
3232
|
+
const exp = {
|
|
3233
|
+
type: "CallExpression",
|
|
3234
|
+
children: [makeLeftHandSideExpression(fn), "()"]
|
|
3235
|
+
};
|
|
3236
|
+
if (prefix) {
|
|
3237
|
+
return [makeLeftHandSideExpression([prefix, exp])];
|
|
3238
|
+
}
|
|
3239
|
+
return [exp];
|
|
3207
3240
|
}
|
|
3208
3241
|
module2.exports = {
|
|
3209
3242
|
addParentPointers,
|
|
@@ -3615,6 +3648,8 @@ var require_parser = __commonJS({
|
|
|
3615
3648
|
RestoreAll,
|
|
3616
3649
|
ExpressionStatement,
|
|
3617
3650
|
KeywordStatement,
|
|
3651
|
+
DebuggerStatement,
|
|
3652
|
+
ThrowStatement,
|
|
3618
3653
|
Break,
|
|
3619
3654
|
Continue,
|
|
3620
3655
|
Debugger,
|
|
@@ -4708,6 +4743,8 @@ var require_parser = __commonJS({
|
|
|
4708
4743
|
return {
|
|
4709
4744
|
type: "AssignmentExpression",
|
|
4710
4745
|
children: $0,
|
|
4746
|
+
// NOTE: This null marks the assignment for later processing to distinguish it
|
|
4747
|
+
// from fake assignments that only add a name to a scope
|
|
4711
4748
|
names: null,
|
|
4712
4749
|
lhs: $1,
|
|
4713
4750
|
assigned: $1[0][1],
|
|
@@ -5347,6 +5384,7 @@ var require_parser = __commonJS({
|
|
|
5347
5384
|
var num = $3;
|
|
5348
5385
|
return [
|
|
5349
5386
|
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
5387
|
+
// not including `name` so that `{x.-1}` doesn't use it
|
|
5350
5388
|
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
5351
5389
|
];
|
|
5352
5390
|
});
|
|
@@ -5479,6 +5517,7 @@ var require_parser = __commonJS({
|
|
|
5479
5517
|
type: "PropertyBind",
|
|
5480
5518
|
name: id.name,
|
|
5481
5519
|
children: [modifier, dot, id]
|
|
5520
|
+
// omit `@` from children
|
|
5482
5521
|
};
|
|
5483
5522
|
});
|
|
5484
5523
|
function PropertyBind(ctx, state) {
|
|
@@ -5574,6 +5613,7 @@ var require_parser = __commonJS({
|
|
|
5574
5613
|
open,
|
|
5575
5614
|
tt,
|
|
5576
5615
|
...pes,
|
|
5616
|
+
// Remove delimiter
|
|
5577
5617
|
{ ...rest, children: rest.children.slice(0, -1) },
|
|
5578
5618
|
close
|
|
5579
5619
|
],
|
|
@@ -5729,6 +5769,7 @@ var require_parser = __commonJS({
|
|
|
5729
5769
|
var c = $3;
|
|
5730
5770
|
return {
|
|
5731
5771
|
...c,
|
|
5772
|
+
// names, blockPrefix, length
|
|
5732
5773
|
type: "ArrayBindingPattern",
|
|
5733
5774
|
elements: c.children,
|
|
5734
5775
|
children: [$1, $2, c.children, $4, $5]
|
|
@@ -5753,6 +5794,7 @@ var require_parser = __commonJS({
|
|
|
5753
5794
|
return elements.map(([element, delim]) => {
|
|
5754
5795
|
return {
|
|
5755
5796
|
...element,
|
|
5797
|
+
// BindingElement.children is a tuple of the form [ws, element]
|
|
5756
5798
|
children: [...element.children, delim]
|
|
5757
5799
|
};
|
|
5758
5800
|
});
|
|
@@ -5769,6 +5811,7 @@ var require_parser = __commonJS({
|
|
|
5769
5811
|
return {
|
|
5770
5812
|
...element,
|
|
5771
5813
|
children: [indent, ...element.children.slice(1)]
|
|
5814
|
+
// replace ws wth indent
|
|
5772
5815
|
};
|
|
5773
5816
|
});
|
|
5774
5817
|
});
|
|
@@ -5998,6 +6041,7 @@ var require_parser = __commonJS({
|
|
|
5998
6041
|
},
|
|
5999
6042
|
block: null,
|
|
6000
6043
|
children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
|
|
6044
|
+
// move whitespace w to after implicit () in parameters
|
|
6001
6045
|
};
|
|
6002
6046
|
});
|
|
6003
6047
|
function FunctionSignature(ctx, state) {
|
|
@@ -6388,6 +6432,7 @@ var require_parser = __commonJS({
|
|
|
6388
6432
|
return {
|
|
6389
6433
|
type: "BlockStatement",
|
|
6390
6434
|
expressions: s.expressions,
|
|
6435
|
+
// Remove !EOS assertion
|
|
6391
6436
|
children: [o, s.children, ws, c]
|
|
6392
6437
|
};
|
|
6393
6438
|
});
|
|
@@ -6406,6 +6451,7 @@ var require_parser = __commonJS({
|
|
|
6406
6451
|
return {
|
|
6407
6452
|
type: "BlockStatement",
|
|
6408
6453
|
expressions: s.expressions,
|
|
6454
|
+
// Remove !EOS assertion
|
|
6409
6455
|
children: [o, s.children, ws, c]
|
|
6410
6456
|
};
|
|
6411
6457
|
});
|
|
@@ -6433,6 +6479,7 @@ var require_parser = __commonJS({
|
|
|
6433
6479
|
return {
|
|
6434
6480
|
type: "BlockStatement",
|
|
6435
6481
|
expressions: [s],
|
|
6482
|
+
// Remove &EOS assertion
|
|
6436
6483
|
children: [$1, s, $3]
|
|
6437
6484
|
};
|
|
6438
6485
|
});
|
|
@@ -6456,6 +6503,7 @@ var require_parser = __commonJS({
|
|
|
6456
6503
|
type: "BlockStatement",
|
|
6457
6504
|
expressions,
|
|
6458
6505
|
children: [expressions],
|
|
6506
|
+
// avoid aliasing
|
|
6459
6507
|
bare: true
|
|
6460
6508
|
};
|
|
6461
6509
|
});
|
|
@@ -6881,6 +6929,8 @@ var require_parser = __commonJS({
|
|
|
6881
6929
|
last = {
|
|
6882
6930
|
...last,
|
|
6883
6931
|
delim,
|
|
6932
|
+
// __ will consume all whitespace that _? in PropertyDefinition could,
|
|
6933
|
+
// so replace _? (via slice) with __
|
|
6884
6934
|
children: [ws, ...last.children.slice(1), delim]
|
|
6885
6935
|
};
|
|
6886
6936
|
return [...prop.slice(0, prop.length - 1), last];
|
|
@@ -7322,6 +7372,7 @@ var require_parser = __commonJS({
|
|
|
7322
7372
|
name,
|
|
7323
7373
|
optional,
|
|
7324
7374
|
modifier,
|
|
7375
|
+
// get/set/async/generator
|
|
7325
7376
|
returnType,
|
|
7326
7377
|
parameters
|
|
7327
7378
|
};
|
|
@@ -7601,6 +7652,7 @@ var require_parser = __commonJS({
|
|
|
7601
7652
|
token: $1,
|
|
7602
7653
|
relational: true,
|
|
7603
7654
|
special: true
|
|
7655
|
+
// for typeof shorthand
|
|
7604
7656
|
};
|
|
7605
7657
|
});
|
|
7606
7658
|
var BinaryOpSymbol$40 = $TS($S(Not, __, $EXPECT($L93, 'BinaryOpSymbol "instanceof"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
@@ -7893,6 +7945,7 @@ var require_parser = __commonJS({
|
|
|
7893
7945
|
condition = insertTrimmingSpace(condition, "");
|
|
7894
7946
|
return {
|
|
7895
7947
|
type: "IfStatement",
|
|
7948
|
+
// TODO: Don't add unnecessary parens
|
|
7896
7949
|
children: [kind, ["(!", condition, ")"]],
|
|
7897
7950
|
condition
|
|
7898
7951
|
};
|
|
@@ -8429,12 +8482,12 @@ var require_parser = __commonJS({
|
|
|
8429
8482
|
return $EVENT(ctx, state, "EmptyCondition", EmptyCondition$0);
|
|
8430
8483
|
}
|
|
8431
8484
|
var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
|
|
8432
|
-
var
|
|
8485
|
+
var s = $0;
|
|
8433
8486
|
return {
|
|
8434
8487
|
type: "SwitchExpression",
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
|
|
8488
|
+
// wrap with IIFE
|
|
8489
|
+
children: wrapIIFE([["", s]]),
|
|
8490
|
+
statement: s
|
|
8438
8491
|
};
|
|
8439
8492
|
});
|
|
8440
8493
|
function SwitchExpression(ctx, state) {
|
|
@@ -8474,6 +8527,7 @@ var require_parser = __commonJS({
|
|
|
8474
8527
|
var clause = $2;
|
|
8475
8528
|
return {
|
|
8476
8529
|
...clause,
|
|
8530
|
+
// Bring the indent into the clause
|
|
8477
8531
|
children: [indent, ...clause.children]
|
|
8478
8532
|
};
|
|
8479
8533
|
});
|
|
@@ -8625,7 +8679,7 @@ var require_parser = __commonJS({
|
|
|
8625
8679
|
return {
|
|
8626
8680
|
type: "TryExpression",
|
|
8627
8681
|
blocks: t.blocks,
|
|
8628
|
-
children: wrapIIFE(t)
|
|
8682
|
+
children: wrapIIFE([["", t]])
|
|
8629
8683
|
};
|
|
8630
8684
|
});
|
|
8631
8685
|
function TryExpression(ctx, state) {
|
|
@@ -8901,28 +8955,38 @@ var require_parser = __commonJS({
|
|
|
8901
8955
|
return {
|
|
8902
8956
|
type: "BreakStatement",
|
|
8903
8957
|
children: $2 ? [$1, $2[0], $2[2]] : [$1]
|
|
8958
|
+
// omit colon
|
|
8904
8959
|
};
|
|
8905
8960
|
});
|
|
8906
8961
|
var KeywordStatement$1 = $TS($S(Continue, $E($S(_, $E(Colon), Identifier))), function($skip, $loc, $0, $1, $2) {
|
|
8907
8962
|
return {
|
|
8908
8963
|
type: "ContinueStatement",
|
|
8909
8964
|
children: $2 ? [$1, $2[0], $2[2]] : [$1]
|
|
8965
|
+
// omit colon
|
|
8910
8966
|
};
|
|
8911
8967
|
});
|
|
8912
|
-
var KeywordStatement$2 =
|
|
8913
|
-
return { "type": "DebuggerStatement", "children": value };
|
|
8914
|
-
});
|
|
8968
|
+
var KeywordStatement$2 = DebuggerStatement;
|
|
8915
8969
|
var KeywordStatement$3 = $T($S(Return, $N($C($EXPECT($L12, 'KeywordStatement ":"'), $EXPECT($L6, 'KeywordStatement "."'), AfterReturnShorthand)), $E(MaybeNestedExpression)), function(value) {
|
|
8916
8970
|
var expression = value[2];
|
|
8917
8971
|
return { "type": "ReturnStatement", "expression": expression, "children": value };
|
|
8918
8972
|
});
|
|
8919
|
-
var KeywordStatement$4 =
|
|
8920
|
-
return { "type": "ThrowStatement", "children": value };
|
|
8921
|
-
});
|
|
8973
|
+
var KeywordStatement$4 = ThrowStatement;
|
|
8922
8974
|
var KeywordStatement$$ = [KeywordStatement$0, KeywordStatement$1, KeywordStatement$2, KeywordStatement$3, KeywordStatement$4];
|
|
8923
8975
|
function KeywordStatement(ctx, state) {
|
|
8924
8976
|
return $EVENT_C(ctx, state, "KeywordStatement", KeywordStatement$$);
|
|
8925
8977
|
}
|
|
8978
|
+
var DebuggerStatement$0 = $T($S(Debugger), function(value) {
|
|
8979
|
+
return { "type": "DebuggerStatement", "children": value };
|
|
8980
|
+
});
|
|
8981
|
+
function DebuggerStatement(ctx, state) {
|
|
8982
|
+
return $EVENT(ctx, state, "DebuggerStatement", DebuggerStatement$0);
|
|
8983
|
+
}
|
|
8984
|
+
var ThrowStatement$0 = $T($S(Throw, ExtendedExpression), function(value) {
|
|
8985
|
+
return { "type": "ThrowStatement", "children": value };
|
|
8986
|
+
});
|
|
8987
|
+
function ThrowStatement(ctx, state) {
|
|
8988
|
+
return $EVENT(ctx, state, "ThrowStatement", ThrowStatement$0);
|
|
8989
|
+
}
|
|
8926
8990
|
var Break$0 = $TS($S($EXPECT($L102, 'Break "break"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
8927
8991
|
return { $loc, token: $1 };
|
|
8928
8992
|
});
|
|
@@ -8941,19 +9005,21 @@ var require_parser = __commonJS({
|
|
|
8941
9005
|
function Debugger(ctx, state) {
|
|
8942
9006
|
return $EVENT(ctx, state, "Debugger", Debugger$0);
|
|
8943
9007
|
}
|
|
8944
|
-
var DebuggerExpression$0 = $
|
|
9008
|
+
var DebuggerExpression$0 = $TV(DebuggerStatement, function($skip, $loc, $0, $1) {
|
|
9009
|
+
var s = $0;
|
|
8945
9010
|
return {
|
|
8946
9011
|
type: "DebuggerExpression",
|
|
8947
|
-
children: wrapIIFE(
|
|
9012
|
+
children: wrapIIFE([["", s]])
|
|
8948
9013
|
};
|
|
8949
9014
|
});
|
|
8950
9015
|
function DebuggerExpression(ctx, state) {
|
|
8951
9016
|
return $EVENT(ctx, state, "DebuggerExpression", DebuggerExpression$0);
|
|
8952
9017
|
}
|
|
8953
|
-
var ThrowExpression$0 = $
|
|
9018
|
+
var ThrowExpression$0 = $TV(ThrowStatement, function($skip, $loc, $0, $1) {
|
|
9019
|
+
var s = $0;
|
|
8954
9020
|
return {
|
|
8955
9021
|
type: "ThrowExpression",
|
|
8956
|
-
children: wrapIIFE(
|
|
9022
|
+
children: wrapIIFE([["", s]])
|
|
8957
9023
|
};
|
|
8958
9024
|
});
|
|
8959
9025
|
function ThrowExpression(ctx, state) {
|
|
@@ -9502,6 +9568,7 @@ var require_parser = __commonJS({
|
|
|
9502
9568
|
if (hasSubstitutions) {
|
|
9503
9569
|
const result = [
|
|
9504
9570
|
{ ...open, token: "RegExp(`" },
|
|
9571
|
+
// Escape backticks, backslashes, and '$' in the body text
|
|
9505
9572
|
body.map(
|
|
9506
9573
|
(e) => e.type === "Substitution" ? e : {
|
|
9507
9574
|
...e,
|
|
@@ -10381,7 +10448,9 @@ var require_parser = __commonJS({
|
|
|
10381
10448
|
parts = [
|
|
10382
10449
|
...$0,
|
|
10383
10450
|
"\n",
|
|
10451
|
+
// InsertNewline
|
|
10384
10452
|
module2.currentIndent.token,
|
|
10453
|
+
// InsertIndent
|
|
10385
10454
|
["</", open[1], ">"]
|
|
10386
10455
|
];
|
|
10387
10456
|
} else {
|
|
@@ -10449,7 +10518,9 @@ var require_parser = __commonJS({
|
|
|
10449
10518
|
const parts = close ? $0 : [
|
|
10450
10519
|
...$0,
|
|
10451
10520
|
"\n",
|
|
10521
|
+
// InsertNewline
|
|
10452
10522
|
module2.currentIndent.token,
|
|
10523
|
+
// InsertIndent
|
|
10453
10524
|
"</>"
|
|
10454
10525
|
];
|
|
10455
10526
|
return { type: "JSXFragment", children: parts, jsxChildren: children.jsxChildren };
|
|
@@ -12036,9 +12107,11 @@ var require_parser = __commonJS({
|
|
|
12036
12107
|
react: false,
|
|
12037
12108
|
solid: false,
|
|
12038
12109
|
client: false,
|
|
12110
|
+
// default behavior: client only
|
|
12039
12111
|
rewriteTsImports: true,
|
|
12040
12112
|
server: false,
|
|
12041
12113
|
tab: void 0,
|
|
12114
|
+
// default behavior = same as space
|
|
12042
12115
|
verbose: false
|
|
12043
12116
|
};
|
|
12044
12117
|
const asAny = {
|
|
@@ -12176,7 +12249,12 @@ var require_parser = __commonJS({
|
|
|
12176
12249
|
type: "ParserMeta",
|
|
12177
12250
|
children: [],
|
|
12178
12251
|
getStateKey() {
|
|
12179
|
-
const stateInt = module2.currentIndent.level % 256 << 8 | module2.classImplicitCallForbidden << 7 | module2.indentedApplicationForbidden << 6 | module2.bracedApplicationForbidden << 5 | module2.trailingMemberPropertyForbidden << 4 | module2.newlineBinaryOpForbidden << 3 |
|
|
12252
|
+
const stateInt = module2.currentIndent.level % 256 << 8 | module2.classImplicitCallForbidden << 7 | module2.indentedApplicationForbidden << 6 | module2.bracedApplicationForbidden << 5 | module2.trailingMemberPropertyForbidden << 4 | module2.newlineBinaryOpForbidden << 3 | // This is slightly different than the rest of the state,
|
|
12253
|
+
// since it is affected by the directive prologue and may be hit
|
|
12254
|
+
// by the EOL rule early in the parse. Later if we wanted to
|
|
12255
|
+
// allow block scoping of the compat directives we would need to
|
|
12256
|
+
// add them all here.
|
|
12257
|
+
module2.config.coffeeComment << 2;
|
|
12180
12258
|
return [stateInt, module2.currentJSXTag];
|
|
12181
12259
|
}
|
|
12182
12260
|
};
|
|
@@ -12201,7 +12279,8 @@ var require_parser = __commonJS({
|
|
|
12201
12279
|
if (module2.config.tab) {
|
|
12202
12280
|
const tabs = $0.match(/\t/g);
|
|
12203
12281
|
const numTabs = tabs ? tabs.length : 0;
|
|
12204
|
-
level = numTabs * module2.config.tab +
|
|
12282
|
+
level = numTabs * module2.config.tab + /*spaces*/
|
|
12283
|
+
($0.length - numTabs);
|
|
12205
12284
|
} else {
|
|
12206
12285
|
level = $0.length;
|
|
12207
12286
|
}
|
|
@@ -12624,6 +12703,8 @@ var require_parser = __commonJS({
|
|
|
12624
12703
|
exports.RestoreAll = RestoreAll;
|
|
12625
12704
|
exports.ExpressionStatement = ExpressionStatement;
|
|
12626
12705
|
exports.KeywordStatement = KeywordStatement;
|
|
12706
|
+
exports.DebuggerStatement = DebuggerStatement;
|
|
12707
|
+
exports.ThrowStatement = ThrowStatement;
|
|
12627
12708
|
exports.Break = Break;
|
|
12628
12709
|
exports.Continue = Continue;
|
|
12629
12710
|
exports.Debugger = Debugger;
|
|
@@ -13454,6 +13535,10 @@ var StateCache = class {
|
|
|
13454
13535
|
get(key) {
|
|
13455
13536
|
return this.cache.get(key[0])?.get(key[1])?.get(key[2])?.get(key[3]);
|
|
13456
13537
|
}
|
|
13538
|
+
/**
|
|
13539
|
+
* Check if this multi-layer cache has the given key.
|
|
13540
|
+
* Since the intermediate layers are always other maps we only need to check the last layer.
|
|
13541
|
+
*/
|
|
13457
13542
|
has(key) {
|
|
13458
13543
|
return !!this.cache.get(key[0])?.get(key[1])?.get(key[2])?.has(key[3]);
|
|
13459
13544
|
}
|
|
@@ -13488,16 +13573,23 @@ var StateCache = class {
|
|
|
13488
13573
|
var { parse } = import_parser.default;
|
|
13489
13574
|
var { SourceMap: SourceMap2 } = util_exports;
|
|
13490
13575
|
var uncacheable = /* @__PURE__ */ new Set([
|
|
13576
|
+
// Meta
|
|
13491
13577
|
"DebugHere",
|
|
13492
13578
|
"Init",
|
|
13493
13579
|
"Program",
|
|
13494
13580
|
"Reset",
|
|
13581
|
+
// Indentation
|
|
13582
|
+
// We need to no-cache the state modifying rules up to the point where they
|
|
13583
|
+
// balance within a parent so PushIndent needs to be marked no-cache even
|
|
13584
|
+
// though it only calls TrackIndented which does the actual work.
|
|
13495
13585
|
"PushIndent",
|
|
13496
13586
|
"PopIndent",
|
|
13497
13587
|
"TrackIndented",
|
|
13588
|
+
// JSX
|
|
13498
13589
|
"PushJSXOpeningElement",
|
|
13499
13590
|
"PushJSXOpeningFragment",
|
|
13500
13591
|
"PopJSXStack",
|
|
13592
|
+
// State
|
|
13501
13593
|
"AllowAll",
|
|
13502
13594
|
"AllowClassImplicitCall",
|
|
13503
13595
|
"AllowBracedApplication",
|
|
@@ -13600,7 +13692,8 @@ function makeCache() {
|
|
|
13600
13692
|
return events;
|
|
13601
13693
|
}
|
|
13602
13694
|
var isCompileError = function(err) {
|
|
13603
|
-
return err instanceof Error &&
|
|
13695
|
+
return err instanceof Error && //@ts-ignore
|
|
13696
|
+
[err.message, err.name, err.filename, err.line, err.column, err.offset].every(($1) => $1 !== void 0);
|
|
13604
13697
|
};
|
|
13605
13698
|
var main_default = { parse, generate: generate_default, util: util_exports, compile, isCompileError };
|
|
13606
13699
|
// Annotate the CommonJS export names for ESM import in node:
|