@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.mjs
CHANGED
|
@@ -21,6 +21,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
21
21
|
return to;
|
|
22
22
|
};
|
|
23
23
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
24
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
25
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
26
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
27
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
28
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
29
|
mod
|
|
26
30
|
));
|
|
@@ -520,9 +524,10 @@ var require_lib = __commonJS({
|
|
|
520
524
|
}
|
|
521
525
|
function addPostfixStatement(statement, ws, post) {
|
|
522
526
|
let children, expressions;
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
527
|
+
const prefix = post.blockPrefix || post.condition?.expression.blockPrefix;
|
|
528
|
+
if (prefix?.length) {
|
|
529
|
+
const indent = prefix[0][0];
|
|
530
|
+
expressions = [...prefix, [indent, statement]];
|
|
526
531
|
children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
|
|
527
532
|
} else {
|
|
528
533
|
expressions = [["", statement]];
|
|
@@ -601,6 +606,7 @@ var require_lib = __commonJS({
|
|
|
601
606
|
children: [...elements.slice(0, restIndex), {
|
|
602
607
|
...rest,
|
|
603
608
|
children: rest.children.slice(0, -1)
|
|
609
|
+
// remove trailing comma
|
|
604
610
|
}],
|
|
605
611
|
blockPrefix,
|
|
606
612
|
length
|
|
@@ -645,7 +651,9 @@ var require_lib = __commonJS({
|
|
|
645
651
|
if (prefixStatements && prefixStatements.length) {
|
|
646
652
|
const indent = getIndent(block.expressions[0]);
|
|
647
653
|
if (indent) {
|
|
648
|
-
prefixStatements = prefixStatements.map((statement) =>
|
|
654
|
+
prefixStatements = prefixStatements.map((statement) => {
|
|
655
|
+
return [indent, ...statement.slice(1)];
|
|
656
|
+
});
|
|
649
657
|
}
|
|
650
658
|
const expressions = [...prefixStatements, ...block.expressions];
|
|
651
659
|
block = {
|
|
@@ -830,7 +838,8 @@ var require_lib = __commonJS({
|
|
|
830
838
|
...wrapIIFE([
|
|
831
839
|
["", ["const ", resultsRef, "=[]"], ";"],
|
|
832
840
|
...children,
|
|
833
|
-
["",
|
|
841
|
+
["", "; "],
|
|
842
|
+
["", wrapWithReturn(resultsRef)]
|
|
834
843
|
], async)
|
|
835
844
|
);
|
|
836
845
|
}
|
|
@@ -945,6 +954,7 @@ var require_lib = __commonJS({
|
|
|
945
954
|
part.children[3]?.token === ":" ? part.children[3] : ":",
|
|
946
955
|
value,
|
|
947
956
|
part.delim
|
|
957
|
+
// comma delimiter
|
|
948
958
|
]
|
|
949
959
|
});
|
|
950
960
|
}
|
|
@@ -953,8 +963,10 @@ var require_lib = __commonJS({
|
|
|
953
963
|
type: "ObjectExpression",
|
|
954
964
|
children: [
|
|
955
965
|
glob.object.children[0],
|
|
966
|
+
// {
|
|
956
967
|
...parts,
|
|
957
968
|
glob.object.children.at(-1)
|
|
969
|
+
// whitespace and }
|
|
958
970
|
],
|
|
959
971
|
properties: parts,
|
|
960
972
|
hoistDec
|
|
@@ -969,12 +981,14 @@ var require_lib = __commonJS({
|
|
|
969
981
|
if (i === children.length - 1)
|
|
970
982
|
return object;
|
|
971
983
|
return processCallMemberExpression({
|
|
984
|
+
// in case there are more
|
|
972
985
|
...node,
|
|
973
986
|
children: [object, ...children.slice(i + 1)]
|
|
974
987
|
});
|
|
975
988
|
} else if (glob?.type === "PropertyBind") {
|
|
976
989
|
const prefix = children.slice(0, i);
|
|
977
990
|
return processCallMemberExpression({
|
|
991
|
+
// in case there are more
|
|
978
992
|
...node,
|
|
979
993
|
children: [
|
|
980
994
|
prefix,
|
|
@@ -1110,35 +1124,41 @@ var require_lib = __commonJS({
|
|
|
1110
1124
|
;
|
|
1111
1125
|
return;
|
|
1112
1126
|
}
|
|
1127
|
+
var relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
|
|
1128
|
+
function isRelationalOp(op) {
|
|
1129
|
+
return relationalOps.includes(op.token) || op.relational;
|
|
1130
|
+
}
|
|
1113
1131
|
function expandChainedComparisons([first, binops]) {
|
|
1114
|
-
const relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
|
|
1115
1132
|
const lowerPrecedenceOps = ["??", "&&", "||", "&", "|", "^"];
|
|
1116
|
-
|
|
1133
|
+
const results = [];
|
|
1117
1134
|
let i = 0;
|
|
1118
1135
|
const l = binops.length;
|
|
1119
1136
|
let start = 0;
|
|
1120
1137
|
let chains = [];
|
|
1138
|
+
let op;
|
|
1121
1139
|
while (i < l) {
|
|
1122
|
-
|
|
1123
|
-
if (
|
|
1140
|
+
[, op] = binops[i];
|
|
1141
|
+
if (isRelationalOp(op)) {
|
|
1124
1142
|
chains.push(i);
|
|
1125
1143
|
} else if (lowerPrecedenceOps.includes(op.token)) {
|
|
1126
|
-
processChains();
|
|
1144
|
+
processChains(op);
|
|
1127
1145
|
first = [];
|
|
1128
1146
|
}
|
|
1129
1147
|
i++;
|
|
1130
1148
|
}
|
|
1131
|
-
processChains();
|
|
1149
|
+
processChains(op);
|
|
1132
1150
|
return results;
|
|
1133
|
-
function processChains() {
|
|
1134
|
-
|
|
1151
|
+
function processChains(op2) {
|
|
1152
|
+
if (isRelationalOp(op2)) {
|
|
1153
|
+
first = expandExistence(first);
|
|
1154
|
+
}
|
|
1135
1155
|
if (chains.length > 1) {
|
|
1136
1156
|
chains.forEach((index, k) => {
|
|
1137
1157
|
if (k > 0) {
|
|
1138
1158
|
results.push(" ", "&&", " ");
|
|
1139
1159
|
}
|
|
1140
1160
|
const binop = binops[index];
|
|
1141
|
-
let [pre,
|
|
1161
|
+
let [pre, op3, post, exp] = binop;
|
|
1142
1162
|
exp = binop[3] = expandExistence(exp);
|
|
1143
1163
|
let endIndex;
|
|
1144
1164
|
if (k < chains.length - 1) {
|
|
@@ -1294,7 +1314,6 @@ var require_lib = __commonJS({
|
|
|
1294
1314
|
default:
|
|
1295
1315
|
return gatherNodes(node.children, predicate);
|
|
1296
1316
|
}
|
|
1297
|
-
return [];
|
|
1298
1317
|
}
|
|
1299
1318
|
function gatherRecursive(node, predicate, skipPredicate) {
|
|
1300
1319
|
if (node == null)
|
|
@@ -1476,6 +1495,7 @@ var require_lib = __commonJS({
|
|
|
1476
1495
|
else
|
|
1477
1496
|
exp.children.push(["", {
|
|
1478
1497
|
type: "ReturnStatement",
|
|
1498
|
+
// NOTE: add a prefixed semi-colon because the if block may not be braced
|
|
1479
1499
|
children: [";return"]
|
|
1480
1500
|
}]);
|
|
1481
1501
|
return;
|
|
@@ -1495,17 +1515,9 @@ var require_lib = __commonJS({
|
|
|
1495
1515
|
node.splice(1, 1, returnStatement);
|
|
1496
1516
|
}
|
|
1497
1517
|
function insertSwitchReturns(exp) {
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
insertReturn:
|
|
1502
|
-
insertReturn(clause);
|
|
1503
|
-
});
|
|
1504
|
-
return;
|
|
1505
|
-
case "SwitchExpression":
|
|
1506
|
-
exp.caseBlock.clauses.forEach(insertReturn);
|
|
1507
|
-
return;
|
|
1508
|
-
}
|
|
1518
|
+
exp.caseBlock.clauses.forEach((clause) => {
|
|
1519
|
+
return insertReturn(clause);
|
|
1520
|
+
});
|
|
1509
1521
|
}
|
|
1510
1522
|
function isEmptyBareBlock(node) {
|
|
1511
1523
|
if (node?.type !== "BlockStatement")
|
|
@@ -1644,6 +1656,7 @@ var require_lib = __commonJS({
|
|
|
1644
1656
|
declaration,
|
|
1645
1657
|
blockPrefix,
|
|
1646
1658
|
children: [awaits, eachOwnError, open, declaration, ws, inOf, expRef ?? exp, step, close]
|
|
1659
|
+
// omit declaration2, replace eachOwn with eachOwnError, replace exp with expRef
|
|
1647
1660
|
};
|
|
1648
1661
|
}
|
|
1649
1662
|
let ws2, decl2;
|
|
@@ -1711,6 +1724,7 @@ var require_lib = __commonJS({
|
|
|
1711
1724
|
return {
|
|
1712
1725
|
declaration,
|
|
1713
1726
|
children: [awaits, eachOwnError, open, declaration, ws, inOf, exp, step, close],
|
|
1727
|
+
// omit declaration2, replace each with eachOwnError
|
|
1714
1728
|
blockPrefix,
|
|
1715
1729
|
hoistDec
|
|
1716
1730
|
};
|
|
@@ -2087,14 +2101,6 @@ var require_lib = __commonJS({
|
|
|
2087
2101
|
return processReturn(f, config.implicitReturns);
|
|
2088
2102
|
});
|
|
2089
2103
|
}
|
|
2090
|
-
function processSwitchExpressions(statements) {
|
|
2091
|
-
gatherRecursiveAll(statements, (n) => n.type === "SwitchExpression").forEach(insertSwitchReturns);
|
|
2092
|
-
}
|
|
2093
|
-
function processTryExpressions(statements) {
|
|
2094
|
-
gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
|
|
2095
|
-
blocks.forEach(insertReturn);
|
|
2096
|
-
});
|
|
2097
|
-
}
|
|
2098
2104
|
function processBindingPatternLHS(lhs, tail) {
|
|
2099
2105
|
adjustAtBindings(lhs, true);
|
|
2100
2106
|
const [splices, thisAssignments] = gatherBindingCode(lhs);
|
|
@@ -2474,7 +2480,7 @@ var require_lib = __commonJS({
|
|
|
2474
2480
|
return declarations;
|
|
2475
2481
|
}
|
|
2476
2482
|
function processPatternMatching(statements, ReservedWord) {
|
|
2477
|
-
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement"
|
|
2483
|
+
gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
|
|
2478
2484
|
const { caseBlock } = s;
|
|
2479
2485
|
const { clauses } = caseBlock;
|
|
2480
2486
|
let errors = false;
|
|
@@ -2580,10 +2586,6 @@ var require_lib = __commonJS({
|
|
|
2580
2586
|
refAssignment = [];
|
|
2581
2587
|
return prev = next;
|
|
2582
2588
|
});
|
|
2583
|
-
if (s.type === "SwitchExpression") {
|
|
2584
|
-
insertReturn(root[0]);
|
|
2585
|
-
root.splice(0, 1, wrapIIFE(root[0]));
|
|
2586
|
-
}
|
|
2587
2589
|
s.type = "PatternMatchingStatement";
|
|
2588
2590
|
s.children = [root];
|
|
2589
2591
|
return addParentPointers(s, s.parent);
|
|
@@ -2729,8 +2731,6 @@ var require_lib = __commonJS({
|
|
|
2729
2731
|
processPipelineExpressions(statements);
|
|
2730
2732
|
processAssignments(statements);
|
|
2731
2733
|
processPatternMatching(statements, ReservedWord);
|
|
2732
|
-
processSwitchExpressions(statements);
|
|
2733
|
-
processTryExpressions(statements);
|
|
2734
2734
|
gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
|
|
2735
2735
|
hoistRefDecs(statements);
|
|
2736
2736
|
processFunctions(statements, config);
|
|
@@ -2967,20 +2967,31 @@ var require_lib = __commonJS({
|
|
|
2967
2967
|
if (post?.token === "?") {
|
|
2968
2968
|
post = {
|
|
2969
2969
|
$loc: post.$loc,
|
|
2970
|
-
token: "!="
|
|
2970
|
+
token: " != null"
|
|
2971
2971
|
};
|
|
2972
2972
|
if (pre.length) {
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2973
|
+
const lastPre = pre[pre.length - 1];
|
|
2974
|
+
if (lastPre.token === "!") {
|
|
2975
|
+
post.token = " == null";
|
|
2976
|
+
pre = pre.slice(0, -1);
|
|
2977
|
+
} else if (lastPre.length === 2 && lastPre[0].token === "!") {
|
|
2978
|
+
post.token = " == null";
|
|
2979
|
+
pre = pre.slice(0, -1);
|
|
2980
|
+
}
|
|
2977
2981
|
}
|
|
2978
2982
|
const existence = {
|
|
2979
2983
|
type: "Existence",
|
|
2980
2984
|
expression: exp,
|
|
2981
|
-
children: [exp,
|
|
2985
|
+
children: [exp, post]
|
|
2982
2986
|
};
|
|
2983
|
-
|
|
2987
|
+
exp = makeLeftHandSideExpression(existence);
|
|
2988
|
+
if (pre.length) {
|
|
2989
|
+
return {
|
|
2990
|
+
type: "UnaryExpression",
|
|
2991
|
+
children: [...pre, exp]
|
|
2992
|
+
};
|
|
2993
|
+
}
|
|
2994
|
+
return exp;
|
|
2984
2995
|
}
|
|
2985
2996
|
if (exp.type === "Literal") {
|
|
2986
2997
|
if (pre.length === 1 && pre[0].token === "-") {
|
|
@@ -3177,31 +3188,53 @@ var require_lib = __commonJS({
|
|
|
3177
3188
|
;
|
|
3178
3189
|
return;
|
|
3179
3190
|
}
|
|
3180
|
-
function wrapIIFE(
|
|
3181
|
-
let prefix
|
|
3191
|
+
function wrapIIFE(expressions, async) {
|
|
3192
|
+
let prefix;
|
|
3182
3193
|
if (async) {
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
prefix =
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
suffix = ")()";
|
|
3194
|
+
async = "async ";
|
|
3195
|
+
} else if (hasAwait(expressions)) {
|
|
3196
|
+
async = "async ";
|
|
3197
|
+
prefix = {
|
|
3198
|
+
type: "Await",
|
|
3199
|
+
children: ["await "]
|
|
3200
|
+
};
|
|
3191
3201
|
}
|
|
3192
|
-
const expressions = Array.isArray(exp) ? [...exp] : [exp];
|
|
3193
3202
|
const block = {
|
|
3194
3203
|
type: "BlockStatement",
|
|
3195
3204
|
expressions,
|
|
3196
3205
|
children: ["{", expressions, "}"],
|
|
3197
3206
|
bare: false
|
|
3198
3207
|
};
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3208
|
+
const parameters = {
|
|
3209
|
+
type: "Parameters",
|
|
3210
|
+
children: ["()"],
|
|
3211
|
+
names: []
|
|
3212
|
+
};
|
|
3213
|
+
const signature = {
|
|
3214
|
+
modifier: {
|
|
3215
|
+
async: !!async
|
|
3216
|
+
},
|
|
3217
|
+
returnType: void 0
|
|
3218
|
+
};
|
|
3219
|
+
const fn = {
|
|
3220
|
+
type: "ArrowFunction",
|
|
3221
|
+
signature,
|
|
3222
|
+
parameters,
|
|
3223
|
+
returnType: void 0,
|
|
3224
|
+
ts: false,
|
|
3225
|
+
async,
|
|
3202
3226
|
block,
|
|
3203
|
-
|
|
3204
|
-
|
|
3227
|
+
children: [async, parameters, "=>", block]
|
|
3228
|
+
};
|
|
3229
|
+
updateParentPointers(block, fn);
|
|
3230
|
+
const exp = {
|
|
3231
|
+
type: "CallExpression",
|
|
3232
|
+
children: [makeLeftHandSideExpression(fn), "()"]
|
|
3233
|
+
};
|
|
3234
|
+
if (prefix) {
|
|
3235
|
+
return [makeLeftHandSideExpression([prefix, exp])];
|
|
3236
|
+
}
|
|
3237
|
+
return [exp];
|
|
3205
3238
|
}
|
|
3206
3239
|
module.exports = {
|
|
3207
3240
|
addParentPointers,
|
|
@@ -3613,6 +3646,8 @@ var require_parser = __commonJS({
|
|
|
3613
3646
|
RestoreAll,
|
|
3614
3647
|
ExpressionStatement,
|
|
3615
3648
|
KeywordStatement,
|
|
3649
|
+
DebuggerStatement,
|
|
3650
|
+
ThrowStatement,
|
|
3616
3651
|
Break,
|
|
3617
3652
|
Continue,
|
|
3618
3653
|
Debugger,
|
|
@@ -4706,6 +4741,8 @@ var require_parser = __commonJS({
|
|
|
4706
4741
|
return {
|
|
4707
4742
|
type: "AssignmentExpression",
|
|
4708
4743
|
children: $0,
|
|
4744
|
+
// NOTE: This null marks the assignment for later processing to distinguish it
|
|
4745
|
+
// from fake assignments that only add a name to a scope
|
|
4709
4746
|
names: null,
|
|
4710
4747
|
lhs: $1,
|
|
4711
4748
|
assigned: $1[0][1],
|
|
@@ -5345,6 +5382,7 @@ var require_parser = __commonJS({
|
|
|
5345
5382
|
var num = $3;
|
|
5346
5383
|
return [
|
|
5347
5384
|
{ type: "PropertyAccess", children: [dot, "at"] },
|
|
5385
|
+
// not including `name` so that `{x.-1}` doesn't use it
|
|
5348
5386
|
{ type: "Call", children: ["(", neg, num, ")"] }
|
|
5349
5387
|
];
|
|
5350
5388
|
});
|
|
@@ -5477,6 +5515,7 @@ var require_parser = __commonJS({
|
|
|
5477
5515
|
type: "PropertyBind",
|
|
5478
5516
|
name: id.name,
|
|
5479
5517
|
children: [modifier, dot, id]
|
|
5518
|
+
// omit `@` from children
|
|
5480
5519
|
};
|
|
5481
5520
|
});
|
|
5482
5521
|
function PropertyBind(ctx, state) {
|
|
@@ -5572,6 +5611,7 @@ var require_parser = __commonJS({
|
|
|
5572
5611
|
open,
|
|
5573
5612
|
tt,
|
|
5574
5613
|
...pes,
|
|
5614
|
+
// Remove delimiter
|
|
5575
5615
|
{ ...rest, children: rest.children.slice(0, -1) },
|
|
5576
5616
|
close
|
|
5577
5617
|
],
|
|
@@ -5727,6 +5767,7 @@ var require_parser = __commonJS({
|
|
|
5727
5767
|
var c = $3;
|
|
5728
5768
|
return {
|
|
5729
5769
|
...c,
|
|
5770
|
+
// names, blockPrefix, length
|
|
5730
5771
|
type: "ArrayBindingPattern",
|
|
5731
5772
|
elements: c.children,
|
|
5732
5773
|
children: [$1, $2, c.children, $4, $5]
|
|
@@ -5751,6 +5792,7 @@ var require_parser = __commonJS({
|
|
|
5751
5792
|
return elements.map(([element, delim]) => {
|
|
5752
5793
|
return {
|
|
5753
5794
|
...element,
|
|
5795
|
+
// BindingElement.children is a tuple of the form [ws, element]
|
|
5754
5796
|
children: [...element.children, delim]
|
|
5755
5797
|
};
|
|
5756
5798
|
});
|
|
@@ -5767,6 +5809,7 @@ var require_parser = __commonJS({
|
|
|
5767
5809
|
return {
|
|
5768
5810
|
...element,
|
|
5769
5811
|
children: [indent, ...element.children.slice(1)]
|
|
5812
|
+
// replace ws wth indent
|
|
5770
5813
|
};
|
|
5771
5814
|
});
|
|
5772
5815
|
});
|
|
@@ -5996,6 +6039,7 @@ var require_parser = __commonJS({
|
|
|
5996
6039
|
},
|
|
5997
6040
|
block: null,
|
|
5998
6041
|
children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
|
|
6042
|
+
// move whitespace w to after implicit () in parameters
|
|
5999
6043
|
};
|
|
6000
6044
|
});
|
|
6001
6045
|
function FunctionSignature(ctx, state) {
|
|
@@ -6386,6 +6430,7 @@ var require_parser = __commonJS({
|
|
|
6386
6430
|
return {
|
|
6387
6431
|
type: "BlockStatement",
|
|
6388
6432
|
expressions: s.expressions,
|
|
6433
|
+
// Remove !EOS assertion
|
|
6389
6434
|
children: [o, s.children, ws, c]
|
|
6390
6435
|
};
|
|
6391
6436
|
});
|
|
@@ -6404,6 +6449,7 @@ var require_parser = __commonJS({
|
|
|
6404
6449
|
return {
|
|
6405
6450
|
type: "BlockStatement",
|
|
6406
6451
|
expressions: s.expressions,
|
|
6452
|
+
// Remove !EOS assertion
|
|
6407
6453
|
children: [o, s.children, ws, c]
|
|
6408
6454
|
};
|
|
6409
6455
|
});
|
|
@@ -6431,6 +6477,7 @@ var require_parser = __commonJS({
|
|
|
6431
6477
|
return {
|
|
6432
6478
|
type: "BlockStatement",
|
|
6433
6479
|
expressions: [s],
|
|
6480
|
+
// Remove &EOS assertion
|
|
6434
6481
|
children: [$1, s, $3]
|
|
6435
6482
|
};
|
|
6436
6483
|
});
|
|
@@ -6454,6 +6501,7 @@ var require_parser = __commonJS({
|
|
|
6454
6501
|
type: "BlockStatement",
|
|
6455
6502
|
expressions,
|
|
6456
6503
|
children: [expressions],
|
|
6504
|
+
// avoid aliasing
|
|
6457
6505
|
bare: true
|
|
6458
6506
|
};
|
|
6459
6507
|
});
|
|
@@ -6879,6 +6927,8 @@ var require_parser = __commonJS({
|
|
|
6879
6927
|
last = {
|
|
6880
6928
|
...last,
|
|
6881
6929
|
delim,
|
|
6930
|
+
// __ will consume all whitespace that _? in PropertyDefinition could,
|
|
6931
|
+
// so replace _? (via slice) with __
|
|
6882
6932
|
children: [ws, ...last.children.slice(1), delim]
|
|
6883
6933
|
};
|
|
6884
6934
|
return [...prop.slice(0, prop.length - 1), last];
|
|
@@ -7320,6 +7370,7 @@ var require_parser = __commonJS({
|
|
|
7320
7370
|
name,
|
|
7321
7371
|
optional,
|
|
7322
7372
|
modifier,
|
|
7373
|
+
// get/set/async/generator
|
|
7323
7374
|
returnType,
|
|
7324
7375
|
parameters
|
|
7325
7376
|
};
|
|
@@ -7599,6 +7650,7 @@ var require_parser = __commonJS({
|
|
|
7599
7650
|
token: $1,
|
|
7600
7651
|
relational: true,
|
|
7601
7652
|
special: true
|
|
7653
|
+
// for typeof shorthand
|
|
7602
7654
|
};
|
|
7603
7655
|
});
|
|
7604
7656
|
var BinaryOpSymbol$40 = $TS($S(Not, __, $EXPECT($L93, 'BinaryOpSymbol "instanceof"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
@@ -7891,6 +7943,7 @@ var require_parser = __commonJS({
|
|
|
7891
7943
|
condition = insertTrimmingSpace(condition, "");
|
|
7892
7944
|
return {
|
|
7893
7945
|
type: "IfStatement",
|
|
7946
|
+
// TODO: Don't add unnecessary parens
|
|
7894
7947
|
children: [kind, ["(!", condition, ")"]],
|
|
7895
7948
|
condition
|
|
7896
7949
|
};
|
|
@@ -8427,12 +8480,12 @@ var require_parser = __commonJS({
|
|
|
8427
8480
|
return $EVENT(ctx, state, "EmptyCondition", EmptyCondition$0);
|
|
8428
8481
|
}
|
|
8429
8482
|
var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
|
|
8430
|
-
var
|
|
8483
|
+
var s = $0;
|
|
8431
8484
|
return {
|
|
8432
8485
|
type: "SwitchExpression",
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8486
|
+
// wrap with IIFE
|
|
8487
|
+
children: wrapIIFE([["", s]]),
|
|
8488
|
+
statement: s
|
|
8436
8489
|
};
|
|
8437
8490
|
});
|
|
8438
8491
|
function SwitchExpression(ctx, state) {
|
|
@@ -8472,6 +8525,7 @@ var require_parser = __commonJS({
|
|
|
8472
8525
|
var clause = $2;
|
|
8473
8526
|
return {
|
|
8474
8527
|
...clause,
|
|
8528
|
+
// Bring the indent into the clause
|
|
8475
8529
|
children: [indent, ...clause.children]
|
|
8476
8530
|
};
|
|
8477
8531
|
});
|
|
@@ -8623,7 +8677,7 @@ var require_parser = __commonJS({
|
|
|
8623
8677
|
return {
|
|
8624
8678
|
type: "TryExpression",
|
|
8625
8679
|
blocks: t.blocks,
|
|
8626
|
-
children: wrapIIFE(t)
|
|
8680
|
+
children: wrapIIFE([["", t]])
|
|
8627
8681
|
};
|
|
8628
8682
|
});
|
|
8629
8683
|
function TryExpression(ctx, state) {
|
|
@@ -8899,28 +8953,38 @@ var require_parser = __commonJS({
|
|
|
8899
8953
|
return {
|
|
8900
8954
|
type: "BreakStatement",
|
|
8901
8955
|
children: $2 ? [$1, $2[0], $2[2]] : [$1]
|
|
8956
|
+
// omit colon
|
|
8902
8957
|
};
|
|
8903
8958
|
});
|
|
8904
8959
|
var KeywordStatement$1 = $TS($S(Continue, $E($S(_, $E(Colon), Identifier))), function($skip, $loc, $0, $1, $2) {
|
|
8905
8960
|
return {
|
|
8906
8961
|
type: "ContinueStatement",
|
|
8907
8962
|
children: $2 ? [$1, $2[0], $2[2]] : [$1]
|
|
8963
|
+
// omit colon
|
|
8908
8964
|
};
|
|
8909
8965
|
});
|
|
8910
|
-
var KeywordStatement$2 =
|
|
8911
|
-
return { "type": "DebuggerStatement", "children": value };
|
|
8912
|
-
});
|
|
8966
|
+
var KeywordStatement$2 = DebuggerStatement;
|
|
8913
8967
|
var KeywordStatement$3 = $T($S(Return, $N($C($EXPECT($L12, 'KeywordStatement ":"'), $EXPECT($L6, 'KeywordStatement "."'), AfterReturnShorthand)), $E(MaybeNestedExpression)), function(value) {
|
|
8914
8968
|
var expression = value[2];
|
|
8915
8969
|
return { "type": "ReturnStatement", "expression": expression, "children": value };
|
|
8916
8970
|
});
|
|
8917
|
-
var KeywordStatement$4 =
|
|
8918
|
-
return { "type": "ThrowStatement", "children": value };
|
|
8919
|
-
});
|
|
8971
|
+
var KeywordStatement$4 = ThrowStatement;
|
|
8920
8972
|
var KeywordStatement$$ = [KeywordStatement$0, KeywordStatement$1, KeywordStatement$2, KeywordStatement$3, KeywordStatement$4];
|
|
8921
8973
|
function KeywordStatement(ctx, state) {
|
|
8922
8974
|
return $EVENT_C(ctx, state, "KeywordStatement", KeywordStatement$$);
|
|
8923
8975
|
}
|
|
8976
|
+
var DebuggerStatement$0 = $T($S(Debugger), function(value) {
|
|
8977
|
+
return { "type": "DebuggerStatement", "children": value };
|
|
8978
|
+
});
|
|
8979
|
+
function DebuggerStatement(ctx, state) {
|
|
8980
|
+
return $EVENT(ctx, state, "DebuggerStatement", DebuggerStatement$0);
|
|
8981
|
+
}
|
|
8982
|
+
var ThrowStatement$0 = $T($S(Throw, ExtendedExpression), function(value) {
|
|
8983
|
+
return { "type": "ThrowStatement", "children": value };
|
|
8984
|
+
});
|
|
8985
|
+
function ThrowStatement(ctx, state) {
|
|
8986
|
+
return $EVENT(ctx, state, "ThrowStatement", ThrowStatement$0);
|
|
8987
|
+
}
|
|
8924
8988
|
var Break$0 = $TS($S($EXPECT($L102, 'Break "break"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
|
|
8925
8989
|
return { $loc, token: $1 };
|
|
8926
8990
|
});
|
|
@@ -8939,19 +9003,21 @@ var require_parser = __commonJS({
|
|
|
8939
9003
|
function Debugger(ctx, state) {
|
|
8940
9004
|
return $EVENT(ctx, state, "Debugger", Debugger$0);
|
|
8941
9005
|
}
|
|
8942
|
-
var DebuggerExpression$0 = $
|
|
9006
|
+
var DebuggerExpression$0 = $TV(DebuggerStatement, function($skip, $loc, $0, $1) {
|
|
9007
|
+
var s = $0;
|
|
8943
9008
|
return {
|
|
8944
9009
|
type: "DebuggerExpression",
|
|
8945
|
-
children: wrapIIFE(
|
|
9010
|
+
children: wrapIIFE([["", s]])
|
|
8946
9011
|
};
|
|
8947
9012
|
});
|
|
8948
9013
|
function DebuggerExpression(ctx, state) {
|
|
8949
9014
|
return $EVENT(ctx, state, "DebuggerExpression", DebuggerExpression$0);
|
|
8950
9015
|
}
|
|
8951
|
-
var ThrowExpression$0 = $
|
|
9016
|
+
var ThrowExpression$0 = $TV(ThrowStatement, function($skip, $loc, $0, $1) {
|
|
9017
|
+
var s = $0;
|
|
8952
9018
|
return {
|
|
8953
9019
|
type: "ThrowExpression",
|
|
8954
|
-
children: wrapIIFE(
|
|
9020
|
+
children: wrapIIFE([["", s]])
|
|
8955
9021
|
};
|
|
8956
9022
|
});
|
|
8957
9023
|
function ThrowExpression(ctx, state) {
|
|
@@ -9500,6 +9566,7 @@ var require_parser = __commonJS({
|
|
|
9500
9566
|
if (hasSubstitutions) {
|
|
9501
9567
|
const result = [
|
|
9502
9568
|
{ ...open, token: "RegExp(`" },
|
|
9569
|
+
// Escape backticks, backslashes, and '$' in the body text
|
|
9503
9570
|
body.map(
|
|
9504
9571
|
(e) => e.type === "Substitution" ? e : {
|
|
9505
9572
|
...e,
|
|
@@ -10379,7 +10446,9 @@ var require_parser = __commonJS({
|
|
|
10379
10446
|
parts = [
|
|
10380
10447
|
...$0,
|
|
10381
10448
|
"\n",
|
|
10449
|
+
// InsertNewline
|
|
10382
10450
|
module.currentIndent.token,
|
|
10451
|
+
// InsertIndent
|
|
10383
10452
|
["</", open[1], ">"]
|
|
10384
10453
|
];
|
|
10385
10454
|
} else {
|
|
@@ -10447,7 +10516,9 @@ var require_parser = __commonJS({
|
|
|
10447
10516
|
const parts = close ? $0 : [
|
|
10448
10517
|
...$0,
|
|
10449
10518
|
"\n",
|
|
10519
|
+
// InsertNewline
|
|
10450
10520
|
module.currentIndent.token,
|
|
10521
|
+
// InsertIndent
|
|
10451
10522
|
"</>"
|
|
10452
10523
|
];
|
|
10453
10524
|
return { type: "JSXFragment", children: parts, jsxChildren: children.jsxChildren };
|
|
@@ -12034,9 +12105,11 @@ var require_parser = __commonJS({
|
|
|
12034
12105
|
react: false,
|
|
12035
12106
|
solid: false,
|
|
12036
12107
|
client: false,
|
|
12108
|
+
// default behavior: client only
|
|
12037
12109
|
rewriteTsImports: true,
|
|
12038
12110
|
server: false,
|
|
12039
12111
|
tab: void 0,
|
|
12112
|
+
// default behavior = same as space
|
|
12040
12113
|
verbose: false
|
|
12041
12114
|
};
|
|
12042
12115
|
const asAny = {
|
|
@@ -12174,7 +12247,12 @@ var require_parser = __commonJS({
|
|
|
12174
12247
|
type: "ParserMeta",
|
|
12175
12248
|
children: [],
|
|
12176
12249
|
getStateKey() {
|
|
12177
|
-
const stateInt = module.currentIndent.level % 256 << 8 | module.classImplicitCallForbidden << 7 | module.indentedApplicationForbidden << 6 | module.bracedApplicationForbidden << 5 | module.trailingMemberPropertyForbidden << 4 | module.newlineBinaryOpForbidden << 3 |
|
|
12250
|
+
const stateInt = module.currentIndent.level % 256 << 8 | module.classImplicitCallForbidden << 7 | module.indentedApplicationForbidden << 6 | module.bracedApplicationForbidden << 5 | module.trailingMemberPropertyForbidden << 4 | module.newlineBinaryOpForbidden << 3 | // This is slightly different than the rest of the state,
|
|
12251
|
+
// since it is affected by the directive prologue and may be hit
|
|
12252
|
+
// by the EOL rule early in the parse. Later if we wanted to
|
|
12253
|
+
// allow block scoping of the compat directives we would need to
|
|
12254
|
+
// add them all here.
|
|
12255
|
+
module.config.coffeeComment << 2;
|
|
12178
12256
|
return [stateInt, module.currentJSXTag];
|
|
12179
12257
|
}
|
|
12180
12258
|
};
|
|
@@ -12199,7 +12277,8 @@ var require_parser = __commonJS({
|
|
|
12199
12277
|
if (module.config.tab) {
|
|
12200
12278
|
const tabs = $0.match(/\t/g);
|
|
12201
12279
|
const numTabs = tabs ? tabs.length : 0;
|
|
12202
|
-
level = numTabs * module.config.tab +
|
|
12280
|
+
level = numTabs * module.config.tab + /*spaces*/
|
|
12281
|
+
($0.length - numTabs);
|
|
12203
12282
|
} else {
|
|
12204
12283
|
level = $0.length;
|
|
12205
12284
|
}
|
|
@@ -12622,6 +12701,8 @@ var require_parser = __commonJS({
|
|
|
12622
12701
|
exports.RestoreAll = RestoreAll;
|
|
12623
12702
|
exports.ExpressionStatement = ExpressionStatement;
|
|
12624
12703
|
exports.KeywordStatement = KeywordStatement;
|
|
12704
|
+
exports.DebuggerStatement = DebuggerStatement;
|
|
12705
|
+
exports.ThrowStatement = ThrowStatement;
|
|
12625
12706
|
exports.Break = Break;
|
|
12626
12707
|
exports.Continue = Continue;
|
|
12627
12708
|
exports.Debugger = Debugger;
|
|
@@ -13442,6 +13523,10 @@ var StateCache = class {
|
|
|
13442
13523
|
get(key) {
|
|
13443
13524
|
return this.cache.get(key[0])?.get(key[1])?.get(key[2])?.get(key[3]);
|
|
13444
13525
|
}
|
|
13526
|
+
/**
|
|
13527
|
+
* Check if this multi-layer cache has the given key.
|
|
13528
|
+
* Since the intermediate layers are always other maps we only need to check the last layer.
|
|
13529
|
+
*/
|
|
13445
13530
|
has(key) {
|
|
13446
13531
|
return !!this.cache.get(key[0])?.get(key[1])?.get(key[2])?.has(key[3]);
|
|
13447
13532
|
}
|
|
@@ -13476,16 +13561,23 @@ var StateCache = class {
|
|
|
13476
13561
|
var { parse } = import_parser.default;
|
|
13477
13562
|
var { SourceMap: SourceMap2 } = util_exports;
|
|
13478
13563
|
var uncacheable = /* @__PURE__ */ new Set([
|
|
13564
|
+
// Meta
|
|
13479
13565
|
"DebugHere",
|
|
13480
13566
|
"Init",
|
|
13481
13567
|
"Program",
|
|
13482
13568
|
"Reset",
|
|
13569
|
+
// Indentation
|
|
13570
|
+
// We need to no-cache the state modifying rules up to the point where they
|
|
13571
|
+
// balance within a parent so PushIndent needs to be marked no-cache even
|
|
13572
|
+
// though it only calls TrackIndented which does the actual work.
|
|
13483
13573
|
"PushIndent",
|
|
13484
13574
|
"PopIndent",
|
|
13485
13575
|
"TrackIndented",
|
|
13576
|
+
// JSX
|
|
13486
13577
|
"PushJSXOpeningElement",
|
|
13487
13578
|
"PushJSXOpeningFragment",
|
|
13488
13579
|
"PopJSXStack",
|
|
13580
|
+
// State
|
|
13489
13581
|
"AllowAll",
|
|
13490
13582
|
"AllowClassImplicitCall",
|
|
13491
13583
|
"AllowBracedApplication",
|
|
@@ -13588,7 +13680,8 @@ function makeCache() {
|
|
|
13588
13680
|
return events;
|
|
13589
13681
|
}
|
|
13590
13682
|
var isCompileError = function(err) {
|
|
13591
|
-
return err instanceof Error &&
|
|
13683
|
+
return err instanceof Error && //@ts-ignore
|
|
13684
|
+
[err.message, err.name, err.filename, err.line, err.column, err.offset].every(($1) => $1 !== void 0);
|
|
13592
13685
|
};
|
|
13593
13686
|
var main_default = { parse, generate: generate_default, util: util_exports, compile, isCompileError };
|
|
13594
13687
|
export {
|