@danielx/civet 0.7.9 → 0.7.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/browser.js +686 -526
- package/dist/civet +54 -25
- package/dist/esm.mjs +1 -33
- package/dist/main.js +689 -527
- package/dist/main.mjs +687 -526
- package/dist/types.d.ts +11 -4
- package/package.json +5 -5
- package/register.js +40 -12
package/dist/browser.js
CHANGED
|
@@ -38,9 +38,9 @@ var Civet = (() => {
|
|
|
38
38
|
));
|
|
39
39
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
40
40
|
|
|
41
|
-
//
|
|
41
|
+
// node_modules/@danielx/hera/dist/machine.js
|
|
42
42
|
var require_machine = __commonJS({
|
|
43
|
-
"
|
|
43
|
+
"node_modules/@danielx/hera/dist/machine.js"(exports, module) {
|
|
44
44
|
"use strict";
|
|
45
45
|
var __defProp2 = Object.defineProperty;
|
|
46
46
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -79,6 +79,7 @@ var Civet = (() => {
|
|
|
79
79
|
$TS: () => $TS2,
|
|
80
80
|
$TV: () => $TV2,
|
|
81
81
|
$Y: () => $Y2,
|
|
82
|
+
ParseError: () => ParseError2,
|
|
82
83
|
Validator: () => Validator2
|
|
83
84
|
});
|
|
84
85
|
module.exports = __toCommonJS2(machine_exports);
|
|
@@ -445,11 +446,10 @@ ${input.slice(result.pos)}
|
|
|
445
446
|
hint = JSON.stringify(hint);
|
|
446
447
|
else
|
|
447
448
|
hint = "EOF";
|
|
448
|
-
const error = new
|
|
449
|
-
Expected:
|
|
449
|
+
const error = new ParseError2("Failed to parse", `Expected:
|
|
450
450
|
${expectations.join("\n ")}
|
|
451
451
|
Found: ${hint}
|
|
452
|
-
`,
|
|
452
|
+
`, filename2, line, column, maxFailPos);
|
|
453
453
|
throw error;
|
|
454
454
|
}
|
|
455
455
|
if (result) {
|
|
@@ -472,15 +472,21 @@ ${input.slice(result.pos)}
|
|
|
472
472
|
reset
|
|
473
473
|
};
|
|
474
474
|
}
|
|
475
|
-
var
|
|
476
|
-
constructor(
|
|
475
|
+
var ParseError2 = class extends Error {
|
|
476
|
+
constructor(header, body, filename2, line, column, offset) {
|
|
477
|
+
let message = `${filename2}:${line}:${column} ${header}`;
|
|
478
|
+
if (body)
|
|
479
|
+
message += `
|
|
480
|
+
${body}`;
|
|
477
481
|
super(message);
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
482
|
+
this.header = header;
|
|
483
|
+
this.body = body;
|
|
480
484
|
this.filename = filename2;
|
|
481
485
|
this.line = line;
|
|
482
486
|
this.column = column;
|
|
483
487
|
this.offset = offset;
|
|
488
|
+
this.name = "ParseError";
|
|
489
|
+
this.message = message;
|
|
484
490
|
}
|
|
485
491
|
};
|
|
486
492
|
}
|
|
@@ -489,7 +495,9 @@ ${input.slice(result.pos)}
|
|
|
489
495
|
// source/main.civet
|
|
490
496
|
var main_exports = {};
|
|
491
497
|
__export(main_exports, {
|
|
498
|
+
ParseError: () => import_lib3.ParseError,
|
|
492
499
|
ParseErrors: () => ParseErrors,
|
|
500
|
+
SourceMap: () => SourceMap2,
|
|
493
501
|
compile: () => compile,
|
|
494
502
|
default: () => main_default,
|
|
495
503
|
generate: () => generate_default,
|
|
@@ -498,7 +506,7 @@ ${input.slice(result.pos)}
|
|
|
498
506
|
parse: () => parse,
|
|
499
507
|
parseProgram: () => parseProgram,
|
|
500
508
|
prune: () => prune,
|
|
501
|
-
|
|
509
|
+
sourcemap: () => sourcemap_exports
|
|
502
510
|
});
|
|
503
511
|
|
|
504
512
|
// source/parser.hera
|
|
@@ -553,6 +561,7 @@ ${input.slice(result.pos)}
|
|
|
553
561
|
processAssignmentDeclaration: () => processAssignmentDeclaration,
|
|
554
562
|
processBinaryOpExpression: () => processBinaryOpExpression,
|
|
555
563
|
processCallMemberExpression: () => processCallMemberExpression,
|
|
564
|
+
processCoffeeDo: () => processCoffeeDo,
|
|
556
565
|
processCoffeeInterpolation: () => processCoffeeInterpolation,
|
|
557
566
|
processForInOf: () => processForInOf,
|
|
558
567
|
processProgram: () => processProgram,
|
|
@@ -958,27 +967,49 @@ ${input.slice(result.pos)}
|
|
|
958
967
|
case "DebuggerStatement":
|
|
959
968
|
case "EmptyStatement":
|
|
960
969
|
case "ReturnStatement":
|
|
961
|
-
case "ThrowStatement":
|
|
970
|
+
case "ThrowStatement": {
|
|
962
971
|
return;
|
|
963
|
-
|
|
972
|
+
}
|
|
973
|
+
case "Declaration": {
|
|
974
|
+
let ref5;
|
|
975
|
+
if (exp.bindings?.length) {
|
|
976
|
+
ref5 = patternAsValue((ref4 = exp.bindings)[ref4.length - 1].pattern);
|
|
977
|
+
} else {
|
|
978
|
+
ref5 = "void 0";
|
|
979
|
+
}
|
|
980
|
+
;
|
|
981
|
+
const value = ref5;
|
|
964
982
|
exp.children.push([
|
|
965
983
|
"",
|
|
966
|
-
[";", collect(
|
|
984
|
+
[";", collect(value)]
|
|
967
985
|
]);
|
|
968
986
|
return;
|
|
987
|
+
}
|
|
988
|
+
case "FunctionExpression": {
|
|
989
|
+
if (exp.id) {
|
|
990
|
+
exp.children.push([
|
|
991
|
+
"",
|
|
992
|
+
[";", collect(exp.id)]
|
|
993
|
+
]);
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
break;
|
|
997
|
+
}
|
|
969
998
|
case "ForStatement":
|
|
970
999
|
case "IterationStatement":
|
|
971
1000
|
case "DoStatement":
|
|
972
|
-
case "ComptimeStatement":
|
|
1001
|
+
case "ComptimeStatement": {
|
|
973
1002
|
wrapIterationReturningResults(exp, outer, collect);
|
|
974
1003
|
return;
|
|
975
|
-
|
|
1004
|
+
}
|
|
1005
|
+
case "BlockStatement": {
|
|
976
1006
|
if (node.expressions.some(isExit)) {
|
|
977
1007
|
return;
|
|
978
1008
|
}
|
|
979
1009
|
assignResults(exp.expressions[exp.expressions.length - 1], collect);
|
|
980
1010
|
return;
|
|
981
|
-
|
|
1011
|
+
}
|
|
1012
|
+
case "IfStatement": {
|
|
982
1013
|
assignResults(exp.then, collect);
|
|
983
1014
|
if (exp.then.bare && !exp.then.semicolon) {
|
|
984
1015
|
exp.then.children.push(exp.then.semicolon = ";");
|
|
@@ -986,18 +1017,22 @@ ${input.slice(result.pos)}
|
|
|
986
1017
|
if (exp.else) {
|
|
987
1018
|
assignResults(exp.else.block, collect);
|
|
988
1019
|
} else {
|
|
989
|
-
exp.children.push([" else {", collect("
|
|
1020
|
+
exp.children.push([" else {", collect("void 0"), "}"]);
|
|
990
1021
|
}
|
|
991
1022
|
return;
|
|
992
|
-
|
|
1023
|
+
}
|
|
1024
|
+
case "PatternMatchingStatement": {
|
|
993
1025
|
assignResults(exp.children[0], collect);
|
|
994
1026
|
return;
|
|
995
|
-
|
|
1027
|
+
}
|
|
1028
|
+
case "SwitchStatement": {
|
|
996
1029
|
assignResults(exp.children[2], collect);
|
|
997
1030
|
return;
|
|
998
|
-
|
|
1031
|
+
}
|
|
1032
|
+
case "TryStatement": {
|
|
999
1033
|
exp.blocks.forEach((block) => assignResults(block, collect));
|
|
1000
1034
|
return;
|
|
1035
|
+
}
|
|
1001
1036
|
}
|
|
1002
1037
|
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
1003
1038
|
return;
|
|
@@ -1008,7 +1043,7 @@ ${input.slice(result.pos)}
|
|
|
1008
1043
|
if (!node)
|
|
1009
1044
|
return;
|
|
1010
1045
|
switch (node.type) {
|
|
1011
|
-
case "BlockStatement":
|
|
1046
|
+
case "BlockStatement": {
|
|
1012
1047
|
if (node.expressions.length) {
|
|
1013
1048
|
if (node.expressions.some(([, exp2]) => isExit(exp2))) {
|
|
1014
1049
|
return;
|
|
@@ -1021,7 +1056,8 @@ ${input.slice(result.pos)}
|
|
|
1021
1056
|
}
|
|
1022
1057
|
}
|
|
1023
1058
|
return;
|
|
1024
|
-
|
|
1059
|
+
}
|
|
1060
|
+
case "WhenClause": {
|
|
1025
1061
|
if (node.break) {
|
|
1026
1062
|
node.children.splice(node.children.indexOf(node.break), 1);
|
|
1027
1063
|
}
|
|
@@ -1031,9 +1067,11 @@ ${input.slice(result.pos)}
|
|
|
1031
1067
|
node.block.expressions.push(wrapWithReturn());
|
|
1032
1068
|
}
|
|
1033
1069
|
return;
|
|
1034
|
-
|
|
1070
|
+
}
|
|
1071
|
+
case "DefaultClause": {
|
|
1035
1072
|
insertReturn(node.block);
|
|
1036
1073
|
return;
|
|
1074
|
+
}
|
|
1037
1075
|
}
|
|
1038
1076
|
if (!Array.isArray(node))
|
|
1039
1077
|
return;
|
|
@@ -1053,23 +1091,36 @@ ${input.slice(result.pos)}
|
|
|
1053
1091
|
exp = exp.statement;
|
|
1054
1092
|
({ type } = exp);
|
|
1055
1093
|
}
|
|
1056
|
-
let
|
|
1094
|
+
let ref6;
|
|
1057
1095
|
switch (type) {
|
|
1058
1096
|
case "BreakStatement":
|
|
1059
1097
|
case "ContinueStatement":
|
|
1060
1098
|
case "DebuggerStatement":
|
|
1061
1099
|
case "EmptyStatement":
|
|
1062
1100
|
case "ReturnStatement":
|
|
1063
|
-
case "ThrowStatement":
|
|
1101
|
+
case "ThrowStatement": {
|
|
1064
1102
|
return;
|
|
1065
|
-
|
|
1103
|
+
}
|
|
1104
|
+
case "Declaration": {
|
|
1105
|
+
let ref7;
|
|
1106
|
+
if (exp.bindings?.length) {
|
|
1107
|
+
ref7 = [" ", patternAsValue((ref6 = exp.bindings)[ref6.length - 1].pattern)];
|
|
1108
|
+
} else {
|
|
1109
|
+
ref7 = [];
|
|
1110
|
+
}
|
|
1111
|
+
;
|
|
1112
|
+
const value = ref7;
|
|
1066
1113
|
exp.children.push(["", {
|
|
1067
1114
|
type: "ReturnStatement",
|
|
1068
|
-
children: [
|
|
1115
|
+
children: [
|
|
1116
|
+
";return",
|
|
1117
|
+
...value
|
|
1118
|
+
],
|
|
1069
1119
|
parent: exp
|
|
1070
1120
|
}]);
|
|
1071
1121
|
return;
|
|
1072
|
-
|
|
1122
|
+
}
|
|
1123
|
+
case "FunctionExpression": {
|
|
1073
1124
|
if (exp.id) {
|
|
1074
1125
|
exp.children.push([
|
|
1075
1126
|
"",
|
|
@@ -1082,16 +1133,19 @@ ${input.slice(result.pos)}
|
|
|
1082
1133
|
return;
|
|
1083
1134
|
}
|
|
1084
1135
|
break;
|
|
1136
|
+
}
|
|
1085
1137
|
case "ForStatement":
|
|
1086
1138
|
case "IterationStatement":
|
|
1087
1139
|
case "DoStatement":
|
|
1088
|
-
case "ComptimeStatement":
|
|
1140
|
+
case "ComptimeStatement": {
|
|
1089
1141
|
wrapIterationReturningResults(exp, outer);
|
|
1090
1142
|
return;
|
|
1091
|
-
|
|
1143
|
+
}
|
|
1144
|
+
case "BlockStatement": {
|
|
1092
1145
|
insertReturn(exp.expressions[exp.expressions.length - 1]);
|
|
1093
1146
|
return;
|
|
1094
|
-
|
|
1147
|
+
}
|
|
1148
|
+
case "IfStatement": {
|
|
1095
1149
|
insertReturn(exp.then);
|
|
1096
1150
|
if (exp.else)
|
|
1097
1151
|
insertReturn(exp.else.block);
|
|
@@ -1103,18 +1157,23 @@ ${input.slice(result.pos)}
|
|
|
1103
1157
|
parent: exp
|
|
1104
1158
|
}]);
|
|
1105
1159
|
return;
|
|
1106
|
-
|
|
1160
|
+
}
|
|
1161
|
+
case "PatternMatchingStatement": {
|
|
1107
1162
|
insertReturn(exp.children[0]);
|
|
1108
1163
|
return;
|
|
1109
|
-
|
|
1164
|
+
}
|
|
1165
|
+
case "SwitchStatement": {
|
|
1110
1166
|
insertSwitchReturns(exp);
|
|
1111
1167
|
return;
|
|
1112
|
-
|
|
1168
|
+
}
|
|
1169
|
+
case "TryStatement": {
|
|
1113
1170
|
exp.blocks.forEach((block) => insertReturn(block));
|
|
1114
1171
|
return;
|
|
1172
|
+
}
|
|
1115
1173
|
}
|
|
1116
|
-
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
1174
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
1117
1175
|
return;
|
|
1176
|
+
}
|
|
1118
1177
|
const returnStatement = wrapWithReturn(node[1]);
|
|
1119
1178
|
node.splice(1, 1, returnStatement);
|
|
1120
1179
|
}
|
|
@@ -1203,10 +1262,33 @@ ${input.slice(result.pos)}
|
|
|
1203
1262
|
}
|
|
1204
1263
|
expressions.unshift(...prefix);
|
|
1205
1264
|
}
|
|
1265
|
+
function processSignature(f) {
|
|
1266
|
+
const { block, signature } = f;
|
|
1267
|
+
if (hasAwait(block) && !f.async?.length) {
|
|
1268
|
+
f.async.push("async ");
|
|
1269
|
+
signature.modifier.async = true;
|
|
1270
|
+
}
|
|
1271
|
+
if (hasYield(block) && !f.generator?.length) {
|
|
1272
|
+
if (f.type === "ArrowFunction") {
|
|
1273
|
+
gatherRecursiveWithinFunction(block, ($) => $.type === "YieldExpression").forEach((y) => {
|
|
1274
|
+
const i = y.children.findIndex(($1) => $1.type === "Yield");
|
|
1275
|
+
return y.children.splice(i + 1, 0, {
|
|
1276
|
+
type: "Error",
|
|
1277
|
+
message: "Can't use yield inside of => arrow function"
|
|
1278
|
+
});
|
|
1279
|
+
});
|
|
1280
|
+
} else {
|
|
1281
|
+
f.generator.push("*");
|
|
1282
|
+
signature.modifier.generator = true;
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1206
1286
|
function processFunctions(statements, config2) {
|
|
1207
1287
|
gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
|
|
1208
|
-
if (f.type === "FunctionExpression")
|
|
1288
|
+
if (f.type === "FunctionExpression") {
|
|
1209
1289
|
implicitFunctionBlock(f);
|
|
1290
|
+
}
|
|
1291
|
+
processSignature(f);
|
|
1210
1292
|
processParams(f);
|
|
1211
1293
|
return processReturn(f, config2.implicitReturns);
|
|
1212
1294
|
});
|
|
@@ -1254,6 +1336,102 @@ ${input.slice(result.pos)}
|
|
|
1254
1336
|
}
|
|
1255
1337
|
return false;
|
|
1256
1338
|
}
|
|
1339
|
+
function processCoffeeDo(ws, expression) {
|
|
1340
|
+
ws = insertTrimmingSpace(ws, "");
|
|
1341
|
+
const args = [];
|
|
1342
|
+
if (typeof expression === "object" && expression != null && "type" in expression && expression.type === "ArrowFunction" || typeof expression === "object" && expression != null && "type" in expression && expression.type === "FunctionExpression") {
|
|
1343
|
+
const { parameters } = expression;
|
|
1344
|
+
const newParameters = {
|
|
1345
|
+
...parameters,
|
|
1346
|
+
children: (() => {
|
|
1347
|
+
const results = [];
|
|
1348
|
+
for (let ref8 = parameters.children, i1 = 0, len3 = ref8.length; i1 < len3; i1++) {
|
|
1349
|
+
let parameter = ref8[i1];
|
|
1350
|
+
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
1351
|
+
let ref9;
|
|
1352
|
+
if (ref9 = parameter.initializer) {
|
|
1353
|
+
const initializer = ref9;
|
|
1354
|
+
args.push(initializer.expression, parameter.delim);
|
|
1355
|
+
parameter = {
|
|
1356
|
+
...parameter,
|
|
1357
|
+
initializer: void 0,
|
|
1358
|
+
children: parameter.children.filter((a2) => a2 !== initializer)
|
|
1359
|
+
};
|
|
1360
|
+
} else {
|
|
1361
|
+
args.push(parameter.children.filter(
|
|
1362
|
+
(a3) => a3 !== parameter.typeSuffix
|
|
1363
|
+
));
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
results.push(parameter);
|
|
1367
|
+
}
|
|
1368
|
+
return results;
|
|
1369
|
+
})()
|
|
1370
|
+
};
|
|
1371
|
+
expression = {
|
|
1372
|
+
...expression,
|
|
1373
|
+
parameters: newParameters,
|
|
1374
|
+
children: expression.children.map(($2) => $2 === parameters ? newParameters : $2)
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
return {
|
|
1378
|
+
type: "CallExpression",
|
|
1379
|
+
children: [
|
|
1380
|
+
makeLeftHandSideExpression(expression),
|
|
1381
|
+
{
|
|
1382
|
+
type: "Call",
|
|
1383
|
+
args,
|
|
1384
|
+
children: ["(", args, ")"]
|
|
1385
|
+
}
|
|
1386
|
+
]
|
|
1387
|
+
};
|
|
1388
|
+
}
|
|
1389
|
+
function makeAmpersandFunction(rhs) {
|
|
1390
|
+
let { ref, typeSuffix, body } = rhs;
|
|
1391
|
+
if (!(ref != null)) {
|
|
1392
|
+
ref = makeRef("$");
|
|
1393
|
+
inplacePrepend(ref, body);
|
|
1394
|
+
}
|
|
1395
|
+
if (body?.type === "ObjectExpression") {
|
|
1396
|
+
body = makeLeftHandSideExpression(body);
|
|
1397
|
+
}
|
|
1398
|
+
const parameters = makeNode({
|
|
1399
|
+
type: "Parameters",
|
|
1400
|
+
children: typeSuffix ? ["(", ref, typeSuffix, ")"] : [ref],
|
|
1401
|
+
names: []
|
|
1402
|
+
});
|
|
1403
|
+
const expressions = [[" ", body]];
|
|
1404
|
+
const block = makeNode({
|
|
1405
|
+
type: "BlockStatement",
|
|
1406
|
+
bare: true,
|
|
1407
|
+
expressions,
|
|
1408
|
+
children: [expressions],
|
|
1409
|
+
implicitlyReturned: true
|
|
1410
|
+
});
|
|
1411
|
+
const async = [];
|
|
1412
|
+
const children = [async, parameters, " =>", block];
|
|
1413
|
+
const fn = makeNode({
|
|
1414
|
+
type: "ArrowFunction",
|
|
1415
|
+
async,
|
|
1416
|
+
signature: {
|
|
1417
|
+
modifier: {
|
|
1418
|
+
async: !!async
|
|
1419
|
+
}
|
|
1420
|
+
},
|
|
1421
|
+
children,
|
|
1422
|
+
ref,
|
|
1423
|
+
block,
|
|
1424
|
+
parameters,
|
|
1425
|
+
ampersandBlock: true,
|
|
1426
|
+
body
|
|
1427
|
+
});
|
|
1428
|
+
if (isStatement(body)) {
|
|
1429
|
+
braceBlock(block);
|
|
1430
|
+
fn.ampersandBlock = false;
|
|
1431
|
+
delete fn.body;
|
|
1432
|
+
}
|
|
1433
|
+
return fn;
|
|
1434
|
+
}
|
|
1257
1435
|
|
|
1258
1436
|
// source/parser/block.civet
|
|
1259
1437
|
function blockWithPrefix(prefixStatements, block) {
|
|
@@ -1414,6 +1592,9 @@ ${input.slice(result.pos)}
|
|
|
1414
1592
|
}
|
|
1415
1593
|
return false;
|
|
1416
1594
|
}
|
|
1595
|
+
if (isToken(exp)) {
|
|
1596
|
+
exp = exp.token;
|
|
1597
|
+
}
|
|
1417
1598
|
if (typeof exp === "string") {
|
|
1418
1599
|
return /^\s*[\(\[\`\+\-\/]/.test(exp);
|
|
1419
1600
|
}
|
|
@@ -1474,8 +1655,8 @@ ${input.slice(result.pos)}
|
|
|
1474
1655
|
node.parent = parent;
|
|
1475
1656
|
}
|
|
1476
1657
|
if (node.children) {
|
|
1477
|
-
for (let
|
|
1478
|
-
const child =
|
|
1658
|
+
for (let ref = node.children, i1 = 0, len1 = ref.length; i1 < len1; i1++) {
|
|
1659
|
+
const child = ref[i1];
|
|
1479
1660
|
addParentPointers(child, node);
|
|
1480
1661
|
}
|
|
1481
1662
|
}
|
|
@@ -1757,13 +1938,13 @@ ${input.slice(result.pos)}
|
|
|
1757
1938
|
return;
|
|
1758
1939
|
}
|
|
1759
1940
|
function hasAwait(exp) {
|
|
1760
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1941
|
+
return gatherRecursiveWithinFunction(exp, ($1) => $1.type === "Await").length > 0;
|
|
1761
1942
|
}
|
|
1762
1943
|
function hasYield(exp) {
|
|
1763
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1944
|
+
return gatherRecursiveWithinFunction(exp, ($2) => $2.type === "Yield").length > 0;
|
|
1764
1945
|
}
|
|
1765
1946
|
function hasImportDeclaration(exp) {
|
|
1766
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1947
|
+
return gatherRecursiveWithinFunction(exp, ($3) => $3.type === "ImportDeclaration").length > 0;
|
|
1767
1948
|
}
|
|
1768
1949
|
function deepCopy(node) {
|
|
1769
1950
|
if (node == null)
|
|
@@ -1801,72 +1982,29 @@ ${input.slice(result.pos)}
|
|
|
1801
1982
|
}
|
|
1802
1983
|
}
|
|
1803
1984
|
}
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
const block = makeNode({
|
|
1820
|
-
type: "BlockStatement",
|
|
1821
|
-
bare: true,
|
|
1822
|
-
expressions,
|
|
1823
|
-
children: [expressions],
|
|
1824
|
-
implicitlyReturned: true
|
|
1825
|
-
});
|
|
1826
|
-
const children = [parameters, " =>", block];
|
|
1827
|
-
const async = hasAwait(body);
|
|
1828
|
-
if (async) {
|
|
1829
|
-
children.unshift("async ");
|
|
1830
|
-
}
|
|
1831
|
-
const fn = makeNode({
|
|
1832
|
-
type: "ArrowFunction",
|
|
1833
|
-
signature: {
|
|
1834
|
-
modifier: {
|
|
1835
|
-
async
|
|
1836
|
-
}
|
|
1837
|
-
},
|
|
1838
|
-
children,
|
|
1839
|
-
ref,
|
|
1840
|
-
block,
|
|
1841
|
-
parameters,
|
|
1842
|
-
ampersandBlock: true,
|
|
1843
|
-
body
|
|
1844
|
-
});
|
|
1845
|
-
if (isStatement(body)) {
|
|
1846
|
-
braceBlock(block);
|
|
1847
|
-
fn.ampersandBlock = false;
|
|
1848
|
-
delete fn.body;
|
|
1849
|
-
}
|
|
1850
|
-
return fn;
|
|
1851
|
-
}
|
|
1985
|
+
var skipParens = /* @__PURE__ */ new Set([
|
|
1986
|
+
"AmpersandRef",
|
|
1987
|
+
"CallExpression",
|
|
1988
|
+
"Identifier",
|
|
1989
|
+
"JSXElement",
|
|
1990
|
+
"JSXFragment",
|
|
1991
|
+
"Literal",
|
|
1992
|
+
"MemberExpression",
|
|
1993
|
+
"NewExpression",
|
|
1994
|
+
"ParenthesizedExpression",
|
|
1995
|
+
"Ref",
|
|
1996
|
+
"Placeholder",
|
|
1997
|
+
"StatementExpression"
|
|
1998
|
+
// wrapIIFE
|
|
1999
|
+
]);
|
|
1852
2000
|
function makeLeftHandSideExpression(expression) {
|
|
1853
|
-
if (expression
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
case "CallExpression":
|
|
1859
|
-
case "Identifier":
|
|
1860
|
-
case "JSXElement":
|
|
1861
|
-
case "JSXFragment":
|
|
1862
|
-
case "Literal":
|
|
1863
|
-
case "MemberExpression":
|
|
1864
|
-
case "NewExpression":
|
|
1865
|
-
case "ParenthesizedExpression":
|
|
1866
|
-
case "Ref":
|
|
1867
|
-
case "Placeholder":
|
|
1868
|
-
case "StatementExpression":
|
|
2001
|
+
if (isASTNodeObject(expression)) {
|
|
2002
|
+
if (expression.parenthesized) {
|
|
2003
|
+
return expression;
|
|
2004
|
+
}
|
|
2005
|
+
if (skipParens.has(expression.type)) {
|
|
1869
2006
|
return expression;
|
|
2007
|
+
}
|
|
1870
2008
|
}
|
|
1871
2009
|
return makeNode({
|
|
1872
2010
|
type: "ParenthesizedExpression",
|
|
@@ -1894,8 +2032,8 @@ ${input.slice(result.pos)}
|
|
|
1894
2032
|
node.parent = parent;
|
|
1895
2033
|
}
|
|
1896
2034
|
if (depth && isParent(node)) {
|
|
1897
|
-
for (let
|
|
1898
|
-
const child =
|
|
2035
|
+
for (let ref1 = node.children, i3 = 0, len3 = ref1.length; i3 < len3; i3++) {
|
|
2036
|
+
const child = ref1[i3];
|
|
1899
2037
|
updateParentPointers(child, node, depth - 1);
|
|
1900
2038
|
}
|
|
1901
2039
|
}
|
|
@@ -1966,11 +2104,11 @@ ${input.slice(result.pos)}
|
|
|
1966
2104
|
}
|
|
1967
2105
|
function wrapIIFE(expressions, asyncFlag) {
|
|
1968
2106
|
let prefix;
|
|
1969
|
-
|
|
2107
|
+
const async = [];
|
|
1970
2108
|
if (asyncFlag) {
|
|
1971
|
-
async
|
|
2109
|
+
async.push("async ");
|
|
1972
2110
|
} else if (hasAwait(expressions)) {
|
|
1973
|
-
async
|
|
2111
|
+
async.push("async ");
|
|
1974
2112
|
prefix = {
|
|
1975
2113
|
type: "Await",
|
|
1976
2114
|
children: ["await "]
|
|
@@ -1981,8 +2119,7 @@ ${input.slice(result.pos)}
|
|
|
1981
2119
|
expressions,
|
|
1982
2120
|
children: ["{", expressions, "}"],
|
|
1983
2121
|
bare: false,
|
|
1984
|
-
root: false
|
|
1985
|
-
parent: void 0
|
|
2122
|
+
root: false
|
|
1986
2123
|
});
|
|
1987
2124
|
const parameters = {
|
|
1988
2125
|
type: "Parameters",
|
|
@@ -1991,7 +2128,7 @@ ${input.slice(result.pos)}
|
|
|
1991
2128
|
};
|
|
1992
2129
|
const signature = {
|
|
1993
2130
|
modifier: {
|
|
1994
|
-
async: !!async
|
|
2131
|
+
async: !!async.length
|
|
1995
2132
|
},
|
|
1996
2133
|
returnType: void 0
|
|
1997
2134
|
};
|
|
@@ -2334,8 +2471,6 @@ ${input.slice(result.pos)}
|
|
|
2334
2471
|
}
|
|
2335
2472
|
return expandedOps;
|
|
2336
2473
|
}
|
|
2337
|
-
;
|
|
2338
|
-
return recurse;
|
|
2339
2474
|
}
|
|
2340
2475
|
function dotNumericLiteral(literal) {
|
|
2341
2476
|
if (literal?.type === "Literal" && /^[+-]?(?:0|[1-9](?:_[0-9]|[0-9])*)$/.test(literal.raw)) {
|
|
@@ -2852,7 +2987,13 @@ ${input.slice(result.pos)}
|
|
|
2852
2987
|
thisAssignments = thisAssignments.map(($6) => ["", $6, ";"]);
|
|
2853
2988
|
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
|
|
2854
2989
|
return [
|
|
2855
|
-
["",
|
|
2990
|
+
["", {
|
|
2991
|
+
type: "Declaration",
|
|
2992
|
+
children: [decl, patternBindings, suffix, " = ", ref, ...splices],
|
|
2993
|
+
names: [],
|
|
2994
|
+
bindings: []
|
|
2995
|
+
// avoid implicit return of any bindings
|
|
2996
|
+
}, ";"],
|
|
2856
2997
|
...thisAssignments,
|
|
2857
2998
|
...duplicateDeclarations.map(($7) => ["", $7, ";"])
|
|
2858
2999
|
];
|
|
@@ -3000,9 +3141,18 @@ ${input.slice(result.pos)}
|
|
|
3000
3141
|
aliasBinding(p, ref);
|
|
3001
3142
|
return ref;
|
|
3002
3143
|
});
|
|
3003
|
-
return declarations.push(
|
|
3004
|
-
|
|
3005
|
-
|
|
3144
|
+
return declarations.push({
|
|
3145
|
+
type: "Declaration",
|
|
3146
|
+
children: [
|
|
3147
|
+
"const ",
|
|
3148
|
+
key,
|
|
3149
|
+
" = [",
|
|
3150
|
+
...refs.map((r, i) => i === 0 ? r : [", ", r]),
|
|
3151
|
+
"]"
|
|
3152
|
+
],
|
|
3153
|
+
names: [],
|
|
3154
|
+
bindings: []
|
|
3155
|
+
});
|
|
3006
3156
|
});
|
|
3007
3157
|
return declarations;
|
|
3008
3158
|
}
|
|
@@ -3239,7 +3389,6 @@ ${input.slice(result.pos)}
|
|
|
3239
3389
|
if (s.negated) {
|
|
3240
3390
|
let m;
|
|
3241
3391
|
if (!(m = condition.expression, typeof m === "object" && m != null && "type" in m && m.type === "UnaryExpression" && "children" in m && Array.isArray(m.children) && len2(m.children, 2) && m.children[0] === "!" && typeof m.children[1] === "object" && m.children[1] != null && "type" in m.children[1] && m.children[1].type === "ParenthesizedExpression")) {
|
|
3242
|
-
console.log(condition.expression);
|
|
3243
3392
|
throw new Error("Unsupported negated condition");
|
|
3244
3393
|
}
|
|
3245
3394
|
const { children } = condition.expression.children[1];
|
|
@@ -3494,8 +3643,7 @@ ${input.slice(result.pos)}
|
|
|
3494
3643
|
token: " != null"
|
|
3495
3644
|
};
|
|
3496
3645
|
if (pre.length) {
|
|
3497
|
-
|
|
3498
|
-
const lastPre = (ref = pre)[ref.length - 1];
|
|
3646
|
+
const lastPre = pre[pre.length - 1];
|
|
3499
3647
|
if (lastPre.token === "!") {
|
|
3500
3648
|
post.token = " == null";
|
|
3501
3649
|
pre = pre.slice(0, -1);
|
|
@@ -3539,9 +3687,9 @@ ${input.slice(result.pos)}
|
|
|
3539
3687
|
}
|
|
3540
3688
|
}
|
|
3541
3689
|
}
|
|
3542
|
-
let
|
|
3543
|
-
while (
|
|
3544
|
-
const l =
|
|
3690
|
+
let ref;
|
|
3691
|
+
while (ref = pre.length) {
|
|
3692
|
+
const l = ref;
|
|
3545
3693
|
const last = pre[l - 1];
|
|
3546
3694
|
if (last.type === "Await") {
|
|
3547
3695
|
if (last.op) {
|
|
@@ -4147,49 +4295,69 @@ ${input.slice(result.pos)}
|
|
|
4147
4295
|
return `${node}`;
|
|
4148
4296
|
}
|
|
4149
4297
|
}
|
|
4150
|
-
function gen(
|
|
4151
|
-
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
options?.updateSourceMap?.(node);
|
|
4156
|
-
return node;
|
|
4157
|
-
}
|
|
4158
|
-
if (Array.isArray(node)) {
|
|
4159
|
-
return node.map(function(child) {
|
|
4160
|
-
return gen(child, options);
|
|
4161
|
-
}).join("");
|
|
4162
|
-
}
|
|
4163
|
-
if (typeof node === "object") {
|
|
4164
|
-
if (options.js && node.ts) {
|
|
4165
|
-
return "";
|
|
4166
|
-
}
|
|
4167
|
-
if (!options.js && node.js) {
|
|
4298
|
+
function gen(root, options) {
|
|
4299
|
+
const updateSourceMap = options?.sourceMap?.updateSourceMap;
|
|
4300
|
+
return recurse(root);
|
|
4301
|
+
function recurse(node) {
|
|
4302
|
+
if (!(node != null)) {
|
|
4168
4303
|
return "";
|
|
4169
4304
|
}
|
|
4170
|
-
if (node
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
return "";
|
|
4305
|
+
if (typeof node === "string") {
|
|
4306
|
+
updateSourceMap?.(node);
|
|
4307
|
+
return node;
|
|
4174
4308
|
}
|
|
4175
|
-
if (node
|
|
4176
|
-
|
|
4177
|
-
options?.updateSourceMap?.(token, $loc.pos);
|
|
4178
|
-
return token;
|
|
4309
|
+
if (Array.isArray(node)) {
|
|
4310
|
+
return node.map(recurse).join("");
|
|
4179
4311
|
}
|
|
4180
|
-
if (
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4312
|
+
if (typeof node === "object") {
|
|
4313
|
+
if (options.js && node.ts) {
|
|
4314
|
+
return "";
|
|
4315
|
+
}
|
|
4316
|
+
if (!options.js && node.js) {
|
|
4317
|
+
return "";
|
|
4318
|
+
}
|
|
4319
|
+
if (node.type === "Error") {
|
|
4320
|
+
const filename2 = options?.filename ?? "unknown";
|
|
4321
|
+
let line = "?";
|
|
4322
|
+
let column = "?";
|
|
4323
|
+
let offset;
|
|
4324
|
+
if (options && typeof options === "object" && "sourceMap" in options) {
|
|
4325
|
+
const { sourceMap } = options;
|
|
4326
|
+
line = sourceMap.data.srcLine + 1;
|
|
4327
|
+
column = sourceMap.data.srcColumn + 1;
|
|
4328
|
+
offset = sourceMap.data.srcOffset;
|
|
4184
4329
|
}
|
|
4330
|
+
options.errors ??= [];
|
|
4331
|
+
options.errors.push(new import_lib3.ParseError(
|
|
4332
|
+
node.message,
|
|
4333
|
+
void 0,
|
|
4334
|
+
// body
|
|
4335
|
+
filename2,
|
|
4336
|
+
line,
|
|
4337
|
+
column,
|
|
4338
|
+
offset
|
|
4339
|
+
));
|
|
4340
|
+
return "";
|
|
4341
|
+
}
|
|
4342
|
+
if (node.$loc != null) {
|
|
4343
|
+
const { token, $loc } = node;
|
|
4344
|
+
updateSourceMap?.(token, $loc.pos);
|
|
4345
|
+
return token;
|
|
4185
4346
|
}
|
|
4186
|
-
|
|
4187
|
-
|
|
4347
|
+
if (!node.children) {
|
|
4348
|
+
switch (node.type) {
|
|
4349
|
+
case "Ref": {
|
|
4350
|
+
throw new Error(`Unpopulated ref ${stringify(node)}`);
|
|
4351
|
+
}
|
|
4352
|
+
}
|
|
4353
|
+
debugger;
|
|
4354
|
+
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4355
|
+
}
|
|
4356
|
+
return recurse(node.children);
|
|
4188
4357
|
}
|
|
4189
|
-
|
|
4358
|
+
debugger;
|
|
4359
|
+
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4190
4360
|
}
|
|
4191
|
-
debugger;
|
|
4192
|
-
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4193
4361
|
}
|
|
4194
4362
|
var generate_default = gen;
|
|
4195
4363
|
function prune(node) {
|
|
@@ -4765,8 +4933,11 @@ ${js}`
|
|
|
4765
4933
|
}
|
|
4766
4934
|
if (results.length > 1) {
|
|
4767
4935
|
return makeLeftHandSideExpression(results);
|
|
4936
|
+
} else if (results.length) {
|
|
4937
|
+
return results;
|
|
4938
|
+
} else {
|
|
4939
|
+
return ["void 0"];
|
|
4768
4940
|
}
|
|
4769
|
-
return results;
|
|
4770
4941
|
} else {
|
|
4771
4942
|
return blockOrExpression;
|
|
4772
4943
|
}
|
|
@@ -4793,10 +4964,10 @@ ${js}`
|
|
|
4793
4964
|
children.push(":void 0");
|
|
4794
4965
|
}
|
|
4795
4966
|
children.push(closeParen);
|
|
4796
|
-
return {
|
|
4967
|
+
return makeNode({
|
|
4797
4968
|
type: "IfExpression",
|
|
4798
4969
|
children
|
|
4799
|
-
};
|
|
4970
|
+
});
|
|
4800
4971
|
}
|
|
4801
4972
|
function expressionizeTypeIf([ws, ifOp, condition, t, e]) {
|
|
4802
4973
|
const children = [
|
|
@@ -5293,7 +5464,8 @@ ${js}`
|
|
|
5293
5464
|
while (expr.type === "ParenthesizedExpression") {
|
|
5294
5465
|
expr = expr.expression;
|
|
5295
5466
|
}
|
|
5296
|
-
|
|
5467
|
+
let m;
|
|
5468
|
+
if (m = expr.type, m === "AssignmentExpression" || m === "UpdateExpression") {
|
|
5297
5469
|
if (expr.type === "UpdateExpression" && expr.children[0] === expr.assigned) {
|
|
5298
5470
|
pre.push("(");
|
|
5299
5471
|
post.push([", ", lhs, ")"]);
|
|
@@ -5307,26 +5479,31 @@ ${js}`
|
|
|
5307
5479
|
return;
|
|
5308
5480
|
}
|
|
5309
5481
|
const pre = [], post = [];
|
|
5482
|
+
let ref4;
|
|
5310
5483
|
switch (exp.type) {
|
|
5311
|
-
case "AssignmentExpression":
|
|
5484
|
+
case "AssignmentExpression": {
|
|
5312
5485
|
if (!exp.lhs)
|
|
5313
5486
|
return;
|
|
5314
5487
|
exp.lhs.forEach((lhsPart, i) => {
|
|
5315
|
-
let
|
|
5316
|
-
if (
|
|
5317
|
-
|
|
5488
|
+
let ref5;
|
|
5489
|
+
if (ref5 = extractAssignment(lhsPart[1])) {
|
|
5490
|
+
const newLhs = ref5;
|
|
5491
|
+
return lhsPart[1] = newLhs;
|
|
5318
5492
|
}
|
|
5319
5493
|
;
|
|
5320
5494
|
return;
|
|
5321
5495
|
});
|
|
5322
5496
|
break;
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
if (
|
|
5497
|
+
}
|
|
5498
|
+
case "UpdateExpression": {
|
|
5499
|
+
if (ref4 = extractAssignment(exp.assigned)) {
|
|
5500
|
+
const newLhs = ref4;
|
|
5326
5501
|
const i = exp.children.indexOf(exp.assigned);
|
|
5327
5502
|
exp.assigned = exp.children[i] = newLhs;
|
|
5328
5503
|
}
|
|
5504
|
+
;
|
|
5329
5505
|
break;
|
|
5506
|
+
}
|
|
5330
5507
|
}
|
|
5331
5508
|
if (pre.length)
|
|
5332
5509
|
exp.children.unshift(...pre);
|
|
@@ -5336,13 +5513,7 @@ ${js}`
|
|
|
5336
5513
|
const { assigned } = exp;
|
|
5337
5514
|
const ref = makeRef();
|
|
5338
5515
|
const newMemberExp = unchainOptionalMemberExpression(assigned, ref, (children) => {
|
|
5339
|
-
return exp.children.map((
|
|
5340
|
-
if (c === assigned) {
|
|
5341
|
-
return children;
|
|
5342
|
-
} else {
|
|
5343
|
-
return c;
|
|
5344
|
-
}
|
|
5345
|
-
});
|
|
5516
|
+
return exp.children.map(($) => $ === assigned ? children : $);
|
|
5346
5517
|
});
|
|
5347
5518
|
if (newMemberExp !== assigned) {
|
|
5348
5519
|
if (newMemberExp.usesRef) {
|
|
@@ -5364,38 +5535,34 @@ ${js}`
|
|
|
5364
5535
|
statements,
|
|
5365
5536
|
(n) => n.type === "AssignmentExpression" && n.names === null,
|
|
5366
5537
|
(exp) => {
|
|
5367
|
-
let { lhs: $1, expression: $2 } = exp, tail = [],
|
|
5538
|
+
let { lhs: $1, expression: $2 } = exp, tail = [], len3 = $1.length;
|
|
5368
5539
|
let block;
|
|
5369
|
-
let
|
|
5370
|
-
if (exp.parent?.type === "BlockStatement" && !(
|
|
5540
|
+
let ref6;
|
|
5541
|
+
if (exp.parent?.type === "BlockStatement" && !(ref6 = $1[$1.length - 1])?.[ref6.length - 1]?.special) {
|
|
5371
5542
|
block = makeBlockFragment();
|
|
5372
|
-
let
|
|
5373
|
-
if (
|
|
5543
|
+
let ref7;
|
|
5544
|
+
if (ref7 = prependStatementExpressionBlock(
|
|
5374
5545
|
{ type: "Initializer", expression: $2, children: [void 0, void 0, $2] },
|
|
5375
5546
|
block
|
|
5376
5547
|
)) {
|
|
5377
|
-
const ref =
|
|
5378
|
-
exp.children = exp.children.map(
|
|
5379
|
-
if (c === $2)
|
|
5380
|
-
return ref;
|
|
5381
|
-
else
|
|
5382
|
-
return c;
|
|
5383
|
-
});
|
|
5548
|
+
const ref = ref7;
|
|
5549
|
+
exp.children = exp.children.map(($3) => $3 === $2 ? ref : $3);
|
|
5384
5550
|
$2 = ref;
|
|
5385
5551
|
} else {
|
|
5386
5552
|
block = void 0;
|
|
5387
5553
|
}
|
|
5388
5554
|
}
|
|
5389
|
-
|
|
5555
|
+
let ref8;
|
|
5556
|
+
if ($1.some(($4) => (ref8 = $4)[ref8.length - 1].special)) {
|
|
5390
5557
|
if ($1.length !== 1)
|
|
5391
5558
|
throw new Error("Only one assignment with id= is allowed");
|
|
5392
5559
|
const [, lhs, , op] = $1[0];
|
|
5393
5560
|
const { call, omitLhs } = op;
|
|
5394
|
-
const
|
|
5395
|
-
if (
|
|
5561
|
+
const index = exp.children.indexOf($2);
|
|
5562
|
+
if (index < 0)
|
|
5396
5563
|
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
5397
5564
|
exp.children.splice(
|
|
5398
|
-
|
|
5565
|
+
index,
|
|
5399
5566
|
1,
|
|
5400
5567
|
exp.expression = $2 = [call, "(", lhs, ", ", $2, ")"]
|
|
5401
5568
|
);
|
|
@@ -5404,12 +5571,15 @@ ${js}`
|
|
|
5404
5571
|
}
|
|
5405
5572
|
}
|
|
5406
5573
|
let wrapped = false;
|
|
5574
|
+
let i = 0;
|
|
5407
5575
|
while (i < len3) {
|
|
5408
5576
|
const lastAssignment = $1[i++];
|
|
5409
5577
|
const [, lhs, , op] = lastAssignment;
|
|
5410
|
-
if (op.token
|
|
5578
|
+
if (!(op.token === "=")) {
|
|
5411
5579
|
continue;
|
|
5412
|
-
|
|
5580
|
+
}
|
|
5581
|
+
let m1;
|
|
5582
|
+
if (m1 = lhs.type, m1 === "ObjectExpression" || m1 === "ObjectBindingPattern") {
|
|
5413
5583
|
if (!wrapped) {
|
|
5414
5584
|
wrapped = true;
|
|
5415
5585
|
lhs.children.splice(0, 0, "(");
|
|
@@ -5422,6 +5592,7 @@ ${js}`
|
|
|
5422
5592
|
const lastAssignment = $1[i];
|
|
5423
5593
|
if (lastAssignment[3].token === "=") {
|
|
5424
5594
|
const lhs = lastAssignment[1];
|
|
5595
|
+
let m2;
|
|
5425
5596
|
if (lhs.type === "MemberExpression") {
|
|
5426
5597
|
const members = lhs.children;
|
|
5427
5598
|
const lastMember = members[members.length - 1];
|
|
@@ -5445,9 +5616,9 @@ ${js}`
|
|
|
5445
5616
|
}
|
|
5446
5617
|
exp.children = [$1];
|
|
5447
5618
|
exp.names = [];
|
|
5448
|
-
|
|
5619
|
+
break;
|
|
5449
5620
|
}
|
|
5450
|
-
} else if (lhs.type === "ObjectBindingPattern" ||
|
|
5621
|
+
} else if (m2 = lhs.type, m2 === "ObjectBindingPattern" || m2 === "ArrayBindingPattern") {
|
|
5451
5622
|
processBindingPatternLHS(lhs, tail);
|
|
5452
5623
|
}
|
|
5453
5624
|
}
|
|
@@ -5480,10 +5651,12 @@ ${js}`
|
|
|
5480
5651
|
i--;
|
|
5481
5652
|
}
|
|
5482
5653
|
exp.names = $1.flatMap(([, l]) => l.names || []);
|
|
5483
|
-
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5654
|
+
if (tail.length) {
|
|
5655
|
+
const index = exp.children.indexOf($2);
|
|
5656
|
+
if (index < 0)
|
|
5657
|
+
throw new Error("Assertion error: exp not in AssignmentExpression");
|
|
5658
|
+
exp.children.splice(index + 1, 0, ...tail);
|
|
5659
|
+
}
|
|
5487
5660
|
if (block) {
|
|
5488
5661
|
block.parent = exp.parent;
|
|
5489
5662
|
block.expressions.push(["", exp]);
|
|
@@ -5542,9 +5715,9 @@ ${js}`
|
|
|
5542
5715
|
}
|
|
5543
5716
|
j++;
|
|
5544
5717
|
}
|
|
5545
|
-
let
|
|
5546
|
-
if (
|
|
5547
|
-
const l =
|
|
5718
|
+
let ref9;
|
|
5719
|
+
if (ref9 = conditions.length) {
|
|
5720
|
+
const l = ref9;
|
|
5548
5721
|
const cs = flatJoin(conditions, " && ");
|
|
5549
5722
|
return {
|
|
5550
5723
|
...exp,
|
|
@@ -5581,8 +5754,8 @@ ${js}`
|
|
|
5581
5754
|
return gatherRecursiveAll(node, (n) => n.type === "UnaryType").forEach((unary) => {
|
|
5582
5755
|
let last;
|
|
5583
5756
|
let count = 0;
|
|
5584
|
-
let
|
|
5585
|
-
while (unary.suffix.length && (
|
|
5757
|
+
let ref10;
|
|
5758
|
+
while (unary.suffix.length && (ref10 = unary.suffix)[ref10.length - 1]?.token === "?") {
|
|
5586
5759
|
last = unary.suffix.pop();
|
|
5587
5760
|
count++;
|
|
5588
5761
|
}
|
|
@@ -5613,14 +5786,14 @@ ${js}`
|
|
|
5613
5786
|
});
|
|
5614
5787
|
}
|
|
5615
5788
|
function processStatementExpressions(statements) {
|
|
5616
|
-
gatherRecursiveAll(statements, ($) =>
|
|
5789
|
+
gatherRecursiveAll(statements, ($5) => $5.type === "StatementExpression").forEach((_exp) => {
|
|
5617
5790
|
const exp = _exp;
|
|
5618
5791
|
const { statement } = exp;
|
|
5619
|
-
let
|
|
5792
|
+
let ref11;
|
|
5620
5793
|
switch (statement.type) {
|
|
5621
5794
|
case "IfStatement": {
|
|
5622
|
-
if (
|
|
5623
|
-
const expression =
|
|
5795
|
+
if (ref11 = expressionizeIfStatement(statement)) {
|
|
5796
|
+
const expression = ref11;
|
|
5624
5797
|
return replaceNode(statement, expression, exp);
|
|
5625
5798
|
} else {
|
|
5626
5799
|
return replaceNode(statement, wrapIIFE([["", statement]]), exp);
|
|
@@ -5662,7 +5835,7 @@ ${js}`
|
|
|
5662
5835
|
}
|
|
5663
5836
|
} else if (index > start + 1) {
|
|
5664
5837
|
ref = makeRef();
|
|
5665
|
-
subexp = children.splice(start, index);
|
|
5838
|
+
subexp = children.splice(start, index - start);
|
|
5666
5839
|
} else {
|
|
5667
5840
|
throw new Error("Invalid parse tree for negative index access");
|
|
5668
5841
|
}
|
|
@@ -5671,7 +5844,7 @@ ${js}`
|
|
|
5671
5844
|
exp.hoistDec = hoistDec;
|
|
5672
5845
|
children.splice(start, 0, makeLeftHandSideExpression(refAssignment));
|
|
5673
5846
|
}
|
|
5674
|
-
|
|
5847
|
+
exp.len.children = [
|
|
5675
5848
|
ref,
|
|
5676
5849
|
".length"
|
|
5677
5850
|
];
|
|
@@ -5743,11 +5916,11 @@ ${js}`
|
|
|
5743
5916
|
function processPlaceholders(statements) {
|
|
5744
5917
|
const placeholderMap = /* @__PURE__ */ new Map();
|
|
5745
5918
|
const liftedIfs = /* @__PURE__ */ new Set();
|
|
5746
|
-
gatherRecursiveAll(statements, ($
|
|
5919
|
+
gatherRecursiveAll(statements, ($6) => $6.type === "Placeholder").forEach((_exp) => {
|
|
5747
5920
|
const exp = _exp;
|
|
5748
5921
|
let ancestor;
|
|
5749
5922
|
if (exp.subtype === ".") {
|
|
5750
|
-
({ ancestor } = findAncestor(exp, ($
|
|
5923
|
+
({ ancestor } = findAncestor(exp, ($7) => $7.type === "Call"));
|
|
5751
5924
|
ancestor = ancestor?.parent;
|
|
5752
5925
|
while (ancestor?.parent?.type === "UnaryExpression" || ancestor?.parent?.type === "NewExpression") {
|
|
5753
5926
|
ancestor = ancestor.parent;
|
|
@@ -5766,10 +5939,10 @@ ${js}`
|
|
|
5766
5939
|
if (type === "IfStatement") {
|
|
5767
5940
|
liftedIfs.add(ancestor2);
|
|
5768
5941
|
}
|
|
5769
|
-
let
|
|
5770
|
-
let
|
|
5942
|
+
let m3;
|
|
5943
|
+
let m4;
|
|
5771
5944
|
return type === "Call" || // Block, except for if/else blocks when condition already lifted
|
|
5772
|
-
type === "BlockStatement" && !((
|
|
5945
|
+
type === "BlockStatement" && !((m3 = ancestor2.parent, typeof m3 === "object" && m3 != null && "type" in m3 && m3.type === "IfStatement") && liftedIfs.has(ancestor2.parent)) && !((m4 = ancestor2.parent, typeof m4 === "object" && m4 != null && "type" in m4 && m4.type === "ElseClause" && "parent" in m4 && typeof m4.parent === "object" && m4.parent != null && "type" in m4.parent && m4.parent.type === "IfStatement") && liftedIfs.has(ancestor2.parent.parent)) || type === "PipelineExpression" || // Declaration
|
|
5773
5946
|
type === "Initializer" || // Right-hand side of assignment
|
|
5774
5947
|
type === "AssignmentExpression" && findChildIndex(ancestor2, child2) === ancestor2.children.indexOf(ancestor2.expression) || type === "ReturnStatement" || type === "YieldExpression";
|
|
5775
5948
|
}));
|
|
@@ -5848,8 +6021,8 @@ ${js}`
|
|
|
5848
6021
|
for (let i4 = 0, len3 = placeholders.length; i4 < len3; i4++) {
|
|
5849
6022
|
const placeholder = placeholders[i4];
|
|
5850
6023
|
typeSuffix ??= placeholder.typeSuffix;
|
|
5851
|
-
let
|
|
5852
|
-
replaceNode((
|
|
6024
|
+
let ref12;
|
|
6025
|
+
replaceNode((ref12 = placeholder.children)[ref12.length - 1], ref);
|
|
5853
6026
|
}
|
|
5854
6027
|
const { parent } = ancestor;
|
|
5855
6028
|
const body = maybeUnwrap(ancestor);
|
|
@@ -5880,9 +6053,9 @@ ${js}`
|
|
|
5880
6053
|
fnExp = makeLeftHandSideExpression(fnExp);
|
|
5881
6054
|
}
|
|
5882
6055
|
replaceNode(ancestor, fnExp, parent);
|
|
5883
|
-
let
|
|
5884
|
-
if (
|
|
5885
|
-
const ws =
|
|
6056
|
+
let ref13;
|
|
6057
|
+
if (ref13 = getTrimmingSpace(body)) {
|
|
6058
|
+
const ws = ref13;
|
|
5886
6059
|
inplaceInsertTrimmingSpace(body, "");
|
|
5887
6060
|
inplacePrepend(ws, fnExp);
|
|
5888
6061
|
}
|
|
@@ -5907,43 +6080,39 @@ ${js}`
|
|
|
5907
6080
|
children: props,
|
|
5908
6081
|
names
|
|
5909
6082
|
};
|
|
5910
|
-
}
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
|
|
5916
|
-
|
|
5917
|
-
|
|
5918
|
-
|
|
5919
|
-
|
|
5920
|
-
};
|
|
5921
|
-
after = [
|
|
5922
|
-
...after.slice(0, -1),
|
|
5923
|
-
{
|
|
5924
|
-
...lastAfterProp,
|
|
5925
|
-
delim: restDelim,
|
|
5926
|
-
children: [...lastAfterChildren.slice(0, -1), restDelim]
|
|
5927
|
-
}
|
|
5928
|
-
];
|
|
5929
|
-
}
|
|
5930
|
-
let ref11;
|
|
5931
|
-
if (Array.isArray(rest.delim) && (ref11 = rest.delim)[ref11.length - 1]?.token === ",") {
|
|
5932
|
-
rest.delim = rest.delim.slice(0, -1);
|
|
5933
|
-
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
5934
|
-
}
|
|
5935
|
-
const children = [...props, ...after, rest];
|
|
5936
|
-
return {
|
|
5937
|
-
children,
|
|
5938
|
-
names
|
|
6083
|
+
}
|
|
6084
|
+
let after = props.slice(restIndex + 1);
|
|
6085
|
+
let rest = props[restIndex];
|
|
6086
|
+
props = props.slice(0, restIndex);
|
|
6087
|
+
if (after.length) {
|
|
6088
|
+
const { delim: restDelim } = rest, lastAfterProp = after[after.length - 1], { delim: lastDelim, children: lastAfterChildren } = lastAfterProp;
|
|
6089
|
+
rest = {
|
|
6090
|
+
...rest,
|
|
6091
|
+
delim: lastDelim,
|
|
6092
|
+
children: [...rest.children.slice(0, -1), lastDelim]
|
|
5939
6093
|
};
|
|
6094
|
+
after = [
|
|
6095
|
+
...after.slice(0, -1),
|
|
6096
|
+
{
|
|
6097
|
+
...lastAfterProp,
|
|
6098
|
+
delim: restDelim,
|
|
6099
|
+
children: [...lastAfterChildren.slice(0, -1), restDelim]
|
|
6100
|
+
}
|
|
6101
|
+
];
|
|
5940
6102
|
}
|
|
5941
|
-
|
|
5942
|
-
|
|
6103
|
+
let ref14;
|
|
6104
|
+
if (Array.isArray(rest.delim) && (ref14 = rest.delim)[ref14.length - 1]?.token === ",") {
|
|
6105
|
+
rest.delim = rest.delim.slice(0, -1);
|
|
6106
|
+
rest.children = [...rest.children.slice(0, -1), rest.delim];
|
|
6107
|
+
}
|
|
6108
|
+
const children = [...props, ...after, rest];
|
|
6109
|
+
if (restCount > 1) {
|
|
6110
|
+
children.push({
|
|
5943
6111
|
type: "Error",
|
|
5944
6112
|
message: "Multiple rest properties in object pattern"
|
|
5945
|
-
}
|
|
5946
|
-
}
|
|
6113
|
+
});
|
|
6114
|
+
}
|
|
6115
|
+
return { children, names };
|
|
5947
6116
|
}
|
|
5948
6117
|
function replaceNodes(root, predicate, replacer) {
|
|
5949
6118
|
if (!(root != null)) {
|
|
@@ -6126,6 +6295,7 @@ ${js}`
|
|
|
6126
6295
|
YieldExpression,
|
|
6127
6296
|
ArrowFunction,
|
|
6128
6297
|
FatArrow,
|
|
6298
|
+
FatArrowToken,
|
|
6129
6299
|
TrailingDeclaration,
|
|
6130
6300
|
TrailingPipe,
|
|
6131
6301
|
FatArrowBody,
|
|
@@ -6246,9 +6416,11 @@ ${js}`
|
|
|
6246
6416
|
NoCommaBracedOrEmptyBlock,
|
|
6247
6417
|
NoPostfixBracedOrEmptyBlock,
|
|
6248
6418
|
EmptyBlock,
|
|
6419
|
+
BlockOrEmptyStatement,
|
|
6249
6420
|
BlockOrEmpty,
|
|
6250
|
-
EmptyBareBlock,
|
|
6251
6421
|
EmptyStatementBareBlock,
|
|
6422
|
+
EmptyBareBlock,
|
|
6423
|
+
NoBlock,
|
|
6252
6424
|
BracedBlock,
|
|
6253
6425
|
NoPostfixBracedBlock,
|
|
6254
6426
|
NoCommaBracedBlock,
|
|
@@ -7267,13 +7439,14 @@ ${js}`
|
|
|
7267
7439
|
}
|
|
7268
7440
|
var StatementExpression$0 = DebuggerStatement;
|
|
7269
7441
|
var StatementExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(IfStatement), function($skip, $loc, $0, $1) {
|
|
7270
|
-
if (!$1.else &&
|
|
7442
|
+
if (!$1.else && $1.then.implicit)
|
|
7271
7443
|
return $skip;
|
|
7272
7444
|
return $1;
|
|
7273
7445
|
});
|
|
7274
7446
|
var StatementExpression$2 = (0, import_lib3.$TS)((0, import_lib3.$S)(IterationExpression), function($skip, $loc, $0, $1) {
|
|
7275
|
-
if (
|
|
7447
|
+
if ($1.block.implicit && $1.subtype !== "DoStatement" && $1.subtype !== "ComptimeStatement") {
|
|
7276
7448
|
return $skip;
|
|
7449
|
+
}
|
|
7277
7450
|
return $1;
|
|
7278
7451
|
});
|
|
7279
7452
|
var StatementExpression$3 = SwitchStatement;
|
|
@@ -7364,7 +7537,7 @@ ${js}`
|
|
|
7364
7537
|
return $0;
|
|
7365
7538
|
return $skip;
|
|
7366
7539
|
});
|
|
7367
|
-
var ForbiddenImplicitCalls$7 = (0, import_lib3.$S)(PostfixStatement,
|
|
7540
|
+
var ForbiddenImplicitCalls$7 = (0, import_lib3.$S)(PostfixStatement, NoBlock);
|
|
7368
7541
|
var ForbiddenImplicitCalls$8 = (0, import_lib3.$EXPECT)($L5, 'ForbiddenImplicitCalls "... "');
|
|
7369
7542
|
var ForbiddenImplicitCalls$$ = [ForbiddenImplicitCalls$0, ForbiddenImplicitCalls$1, ForbiddenImplicitCalls$2, ForbiddenImplicitCalls$3, ForbiddenImplicitCalls$4, ForbiddenImplicitCalls$5, ForbiddenImplicitCalls$6, ForbiddenImplicitCalls$7, ForbiddenImplicitCalls$8];
|
|
7370
7543
|
function ForbiddenImplicitCalls(ctx, state2) {
|
|
@@ -7589,11 +7762,10 @@ ${js}`
|
|
|
7589
7762
|
var post = $3;
|
|
7590
7763
|
return processUnaryExpression(pre, exp, post);
|
|
7591
7764
|
});
|
|
7592
|
-
var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, __, (0, import_lib3.$C)((0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol))),
|
|
7765
|
+
var UnaryExpression$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(CoffeeDoEnabled, Do, __, (0, import_lib3.$C)(ArrowFunction, (0, import_lib3.$S)(LeftHandSideExpression, (0, import_lib3.$N)((0, import_lib3.$S)(__, AssignmentOpSymbol))), ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
|
|
7593
7766
|
var ws = $3;
|
|
7594
7767
|
var exp = $4;
|
|
7595
|
-
|
|
7596
|
-
return ["(", ...ws, exp, ")()"];
|
|
7768
|
+
return processCoffeeDo(ws, exp);
|
|
7597
7769
|
});
|
|
7598
7770
|
var UnaryExpression$$ = [UnaryExpression$0, UnaryExpression$1];
|
|
7599
7771
|
function UnaryExpression(ctx, state2) {
|
|
@@ -7815,17 +7987,10 @@ ${js}`
|
|
|
7815
7987
|
var async = $1;
|
|
7816
7988
|
var parameters = $2;
|
|
7817
7989
|
var suffix = $3;
|
|
7990
|
+
var arrow = $4;
|
|
7818
7991
|
var expOrBlock = $5;
|
|
7819
|
-
if (
|
|
7820
|
-
async =
|
|
7821
|
-
}
|
|
7822
|
-
let error;
|
|
7823
|
-
if (hasYield(expOrBlock)) {
|
|
7824
|
-
error = {
|
|
7825
|
-
type: "Error",
|
|
7826
|
-
message: "Can't use yield inside of => arrow function"
|
|
7827
|
-
};
|
|
7828
|
-
}
|
|
7992
|
+
if (!async)
|
|
7993
|
+
async = [];
|
|
7829
7994
|
return {
|
|
7830
7995
|
type: "ArrowFunction",
|
|
7831
7996
|
signature: {
|
|
@@ -7836,25 +8001,31 @@ ${js}`
|
|
|
7836
8001
|
},
|
|
7837
8002
|
parameters,
|
|
7838
8003
|
returnType: suffix,
|
|
7839
|
-
ts: false,
|
|
7840
8004
|
async,
|
|
7841
8005
|
block: expOrBlock,
|
|
7842
|
-
children: [async,
|
|
8006
|
+
children: [async, parameters, suffix, arrow, expOrBlock]
|
|
7843
8007
|
};
|
|
7844
8008
|
});
|
|
7845
8009
|
var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
|
|
7846
8010
|
function ArrowFunction(ctx, state2) {
|
|
7847
8011
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "ArrowFunction", ArrowFunction$$);
|
|
7848
8012
|
}
|
|
7849
|
-
var FatArrow$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_),
|
|
8013
|
+
var FatArrow$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), FatArrowToken), function($skip, $loc, $0, $1, $2) {
|
|
7850
8014
|
var ws = $1;
|
|
8015
|
+
var arrow = $2;
|
|
7851
8016
|
if (!ws)
|
|
7852
|
-
|
|
7853
|
-
return [
|
|
8017
|
+
ws = " ";
|
|
8018
|
+
return [ws, arrow];
|
|
7854
8019
|
});
|
|
7855
8020
|
function FatArrow(ctx, state2) {
|
|
7856
8021
|
return (0, import_lib3.$EVENT)(ctx, state2, "FatArrow", FatArrow$0);
|
|
7857
8022
|
}
|
|
8023
|
+
var FatArrowToken$0 = (0, import_lib3.$TV)((0, import_lib3.$C)((0, import_lib3.$EXPECT)($L13, 'FatArrowToken "=>"'), (0, import_lib3.$EXPECT)($L14, 'FatArrowToken "\u21D2"')), function($skip, $loc, $0, $1) {
|
|
8024
|
+
return { $loc, token: "=>" };
|
|
8025
|
+
});
|
|
8026
|
+
function FatArrowToken(ctx, state2) {
|
|
8027
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "FatArrowToken", FatArrowToken$0);
|
|
8028
|
+
}
|
|
7858
8029
|
var TrailingDeclaration$0 = (0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$C)(ConstAssignment, LetAssignment));
|
|
7859
8030
|
function TrailingDeclaration(ctx, state2) {
|
|
7860
8031
|
return (0, import_lib3.$EVENT)(ctx, state2, "TrailingDeclaration", TrailingDeclaration$0);
|
|
@@ -8366,7 +8537,13 @@ ${js}`
|
|
|
8366
8537
|
children: [at, {
|
|
8367
8538
|
type: "PropertyAccess",
|
|
8368
8539
|
name: id,
|
|
8369
|
-
children: [".",
|
|
8540
|
+
children: [".", {
|
|
8541
|
+
$loc: {
|
|
8542
|
+
pos: $loc.pos + 1,
|
|
8543
|
+
length: $loc.length - 1
|
|
8544
|
+
},
|
|
8545
|
+
token: id
|
|
8546
|
+
}]
|
|
8370
8547
|
}],
|
|
8371
8548
|
thisShorthand: true
|
|
8372
8549
|
};
|
|
@@ -9038,11 +9215,17 @@ ${js}`
|
|
|
9038
9215
|
var ParameterElement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)(_), (0, import_lib3.$E)(AccessModifier), (0, import_lib3.$E)(_), (0, import_lib3.$C)(NWBindingIdentifier, BindingPattern), (0, import_lib3.$E)(TypeSuffix), (0, import_lib3.$E)(Initializer), ParameterElementDelimiter), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7) {
|
|
9039
9216
|
var accessModifier = $2;
|
|
9040
9217
|
var binding = $4;
|
|
9218
|
+
var typeSuffix = $5;
|
|
9219
|
+
var initializer = $6;
|
|
9220
|
+
var delim = $7;
|
|
9041
9221
|
return {
|
|
9042
9222
|
type: "Parameter",
|
|
9043
9223
|
children: $0,
|
|
9044
9224
|
names: binding.names,
|
|
9045
|
-
|
|
9225
|
+
typeSuffix,
|
|
9226
|
+
accessModifier,
|
|
9227
|
+
initializer,
|
|
9228
|
+
delim
|
|
9046
9229
|
};
|
|
9047
9230
|
});
|
|
9048
9231
|
function ParameterElement(ctx, state2) {
|
|
@@ -9457,7 +9640,6 @@ ${js}`
|
|
|
9457
9640
|
name: id?.name,
|
|
9458
9641
|
parameters,
|
|
9459
9642
|
returnType: suffix,
|
|
9460
|
-
ts: false,
|
|
9461
9643
|
async,
|
|
9462
9644
|
generator,
|
|
9463
9645
|
modifier: {
|
|
@@ -9483,14 +9665,6 @@ ${js}`
|
|
|
9483
9665
|
ts: true
|
|
9484
9666
|
};
|
|
9485
9667
|
}
|
|
9486
|
-
if (hasAwait(block) && !signature.async.length) {
|
|
9487
|
-
signature.async.push("async ");
|
|
9488
|
-
signature.modifier.async = true;
|
|
9489
|
-
}
|
|
9490
|
-
if (hasYield(block) && !signature.generator.length) {
|
|
9491
|
-
signature.generator.push("*");
|
|
9492
|
-
signature.modifier.generator = true;
|
|
9493
|
-
}
|
|
9494
9668
|
return {
|
|
9495
9669
|
...signature,
|
|
9496
9670
|
type: "FunctionExpression",
|
|
@@ -9662,15 +9836,21 @@ ${js}`
|
|
|
9662
9836
|
function OperatorDeclaration(ctx, state2) {
|
|
9663
9837
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "OperatorDeclaration", OperatorDeclaration$$);
|
|
9664
9838
|
}
|
|
9665
|
-
var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Operator, (0, import_lib3.$E)((0, import_lib3.$S)(_, Function2)), _, Identifier, (0, import_lib3.$E)(OperatorBehavior), (0, import_lib3.$E)(_), NonEmptyParameters, (0, import_lib3.$E)(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
|
|
9666
|
-
var
|
|
9667
|
-
var
|
|
9668
|
-
var
|
|
9669
|
-
var
|
|
9670
|
-
var
|
|
9671
|
-
var
|
|
9672
|
-
var
|
|
9673
|
-
var
|
|
9839
|
+
var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$E)((0, import_lib3.$S)(Async, _)), Operator, (0, import_lib3.$E)((0, import_lib3.$S)(_, Function2)), (0, import_lib3.$E)((0, import_lib3.$S)((0, import_lib3.$E)(_), Star)), _, Identifier, (0, import_lib3.$E)(OperatorBehavior), (0, import_lib3.$E)(_), NonEmptyParameters, (0, import_lib3.$E)(ReturnTypeSuffix)), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10) {
|
|
9840
|
+
var async = $1;
|
|
9841
|
+
var op = $2;
|
|
9842
|
+
var func = $3;
|
|
9843
|
+
var generator = $4;
|
|
9844
|
+
var w1 = $5;
|
|
9845
|
+
var id = $6;
|
|
9846
|
+
var behavior = $7;
|
|
9847
|
+
var w2 = $8;
|
|
9848
|
+
var parameters = $9;
|
|
9849
|
+
var suffix = $10;
|
|
9850
|
+
if (!async)
|
|
9851
|
+
async = [];
|
|
9852
|
+
if (!generator)
|
|
9853
|
+
generator = [];
|
|
9674
9854
|
if (!func) {
|
|
9675
9855
|
func = { $loc: op.$loc, token: "function" };
|
|
9676
9856
|
} else {
|
|
@@ -9679,12 +9859,17 @@ ${js}`
|
|
|
9679
9859
|
return {
|
|
9680
9860
|
type: "FunctionSignature",
|
|
9681
9861
|
id,
|
|
9682
|
-
|
|
9862
|
+
name: id.name,
|
|
9683
9863
|
parameters,
|
|
9684
9864
|
returnType: suffix,
|
|
9685
|
-
|
|
9865
|
+
async,
|
|
9866
|
+
generator,
|
|
9867
|
+
modifier: {
|
|
9868
|
+
async: !!async.length,
|
|
9869
|
+
generator: !!generator.length
|
|
9870
|
+
},
|
|
9686
9871
|
block: null,
|
|
9687
|
-
children: [func, w1, id, w2, parameters, suffix],
|
|
9872
|
+
children: [async, func, generator, w1, id, w2, parameters, suffix],
|
|
9688
9873
|
behavior
|
|
9689
9874
|
};
|
|
9690
9875
|
});
|
|
@@ -9734,27 +9919,24 @@ ${js}`
|
|
|
9734
9919
|
var suffix = $3;
|
|
9735
9920
|
var arrow = $5;
|
|
9736
9921
|
var block = $6;
|
|
9737
|
-
if (
|
|
9738
|
-
async =
|
|
9739
|
-
|
|
9740
|
-
let generator;
|
|
9741
|
-
if (hasYield(block)) {
|
|
9742
|
-
generator = "*";
|
|
9743
|
-
}
|
|
9922
|
+
if (!async)
|
|
9923
|
+
async = [];
|
|
9924
|
+
const generator = [];
|
|
9744
9925
|
return {
|
|
9745
9926
|
type: "FunctionExpression",
|
|
9746
9927
|
id: void 0,
|
|
9747
9928
|
parameters,
|
|
9748
9929
|
returnType: suffix,
|
|
9749
|
-
ts: false,
|
|
9750
9930
|
async,
|
|
9751
9931
|
generator,
|
|
9752
9932
|
block,
|
|
9753
9933
|
signature: {
|
|
9754
9934
|
name: void 0,
|
|
9935
|
+
async,
|
|
9936
|
+
generator,
|
|
9755
9937
|
modifier: {
|
|
9756
|
-
async: !!async,
|
|
9757
|
-
generator: !!generator
|
|
9938
|
+
async: !!async.length,
|
|
9939
|
+
generator: !!generator.length
|
|
9758
9940
|
},
|
|
9759
9941
|
returnType: suffix
|
|
9760
9942
|
},
|
|
@@ -9904,43 +10086,62 @@ ${js}`
|
|
|
9904
10086
|
expressions,
|
|
9905
10087
|
children: [$1, expressions, $2],
|
|
9906
10088
|
bare: false,
|
|
9907
|
-
empty: true
|
|
10089
|
+
empty: true,
|
|
10090
|
+
implicit: true
|
|
9908
10091
|
};
|
|
9909
10092
|
});
|
|
9910
10093
|
function EmptyBlock(ctx, state2) {
|
|
9911
10094
|
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyBlock", EmptyBlock$0);
|
|
9912
10095
|
}
|
|
10096
|
+
var BlockOrEmptyStatement$0 = Block;
|
|
10097
|
+
var BlockOrEmptyStatement$1 = (0, import_lib3.$T)((0, import_lib3.$S)(NoBlock, EmptyStatementBareBlock), function(value) {
|
|
10098
|
+
return value[1];
|
|
10099
|
+
});
|
|
10100
|
+
var BlockOrEmptyStatement$$ = [BlockOrEmptyStatement$0, BlockOrEmptyStatement$1];
|
|
10101
|
+
function BlockOrEmptyStatement(ctx, state2) {
|
|
10102
|
+
return (0, import_lib3.$EVENT_C)(ctx, state2, "BlockOrEmptyStatement", BlockOrEmptyStatement$$);
|
|
10103
|
+
}
|
|
9913
10104
|
var BlockOrEmpty$0 = Block;
|
|
9914
|
-
var BlockOrEmpty$1 =
|
|
10105
|
+
var BlockOrEmpty$1 = (0, import_lib3.$T)((0, import_lib3.$S)(NoBlock, EmptyBlock), function(value) {
|
|
10106
|
+
return value[1];
|
|
10107
|
+
});
|
|
9915
10108
|
var BlockOrEmpty$$ = [BlockOrEmpty$0, BlockOrEmpty$1];
|
|
9916
10109
|
function BlockOrEmpty(ctx, state2) {
|
|
9917
10110
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "BlockOrEmpty", BlockOrEmpty$$);
|
|
9918
10111
|
}
|
|
9919
|
-
var
|
|
9920
|
-
|
|
10112
|
+
var EmptyStatementBareBlock$0 = (0, import_lib3.$TV)(InsertEmptyStatement, function($skip, $loc, $0, $1) {
|
|
10113
|
+
var s = $0;
|
|
10114
|
+
const expressions = [["", s]];
|
|
9921
10115
|
return {
|
|
9922
10116
|
type: "BlockStatement",
|
|
9923
10117
|
expressions,
|
|
9924
10118
|
children: [expressions],
|
|
9925
|
-
bare: true
|
|
10119
|
+
bare: true,
|
|
10120
|
+
empty: true,
|
|
10121
|
+
implicit: true,
|
|
10122
|
+
semicolon: s.children[0]
|
|
9926
10123
|
};
|
|
9927
10124
|
});
|
|
9928
|
-
function
|
|
9929
|
-
return (0, import_lib3.$EVENT)(ctx, state2, "
|
|
10125
|
+
function EmptyStatementBareBlock(ctx, state2) {
|
|
10126
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyStatementBareBlock", EmptyStatementBareBlock$0);
|
|
9930
10127
|
}
|
|
9931
|
-
var
|
|
9932
|
-
|
|
9933
|
-
const expressions = [["", s]];
|
|
10128
|
+
var EmptyBareBlock$0 = (0, import_lib3.$TV)((0, import_lib3.$EXPECT)($L0, 'EmptyBareBlock ""'), function($skip, $loc, $0, $1) {
|
|
10129
|
+
const expressions = [];
|
|
9934
10130
|
return {
|
|
9935
10131
|
type: "BlockStatement",
|
|
9936
10132
|
expressions,
|
|
9937
10133
|
children: [expressions],
|
|
9938
10134
|
bare: true,
|
|
9939
|
-
|
|
10135
|
+
empty: true,
|
|
10136
|
+
implicit: true
|
|
9940
10137
|
};
|
|
9941
10138
|
});
|
|
9942
|
-
function
|
|
9943
|
-
return (0, import_lib3.$EVENT)(ctx, state2, "
|
|
10139
|
+
function EmptyBareBlock(ctx, state2) {
|
|
10140
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "EmptyBareBlock", EmptyBareBlock$0);
|
|
10141
|
+
}
|
|
10142
|
+
var NoBlock$0 = (0, import_lib3.$S)((0, import_lib3.$Y)(EOS), (0, import_lib3.$N)(IndentedFurther));
|
|
10143
|
+
function NoBlock(ctx, state2) {
|
|
10144
|
+
return (0, import_lib3.$EVENT)(ctx, state2, "NoBlock", NoBlock$0);
|
|
9944
10145
|
}
|
|
9945
10146
|
var BracedBlock$0 = NonSingleBracedBlock;
|
|
9946
10147
|
var BracedBlock$1 = (0, import_lib3.$TS)((0, import_lib3.$S)(InsertOpenBrace, (0, import_lib3.$N)(EOS), PostfixedSingleLineStatements, InsertSpace, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5) {
|
|
@@ -11792,7 +11993,7 @@ ${js}`
|
|
|
11792
11993
|
function IterationExpression(ctx, state2) {
|
|
11793
11994
|
return (0, import_lib3.$EVENT)(ctx, state2, "IterationExpression", IterationExpression$0);
|
|
11794
11995
|
}
|
|
11795
|
-
var LoopStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(LoopClause,
|
|
11996
|
+
var LoopStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(LoopClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11796
11997
|
var clause = $1;
|
|
11797
11998
|
var block = $2;
|
|
11798
11999
|
return {
|
|
@@ -11870,7 +12071,7 @@ ${js}`
|
|
|
11870
12071
|
function ComptimeStatement(ctx, state2) {
|
|
11871
12072
|
return (0, import_lib3.$EVENT)(ctx, state2, "ComptimeStatement", ComptimeStatement$0);
|
|
11872
12073
|
}
|
|
11873
|
-
var WhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WhileClause,
|
|
12074
|
+
var WhileStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(WhileClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11874
12075
|
var clause = $1;
|
|
11875
12076
|
var block = $2;
|
|
11876
12077
|
return {
|
|
@@ -11901,7 +12102,7 @@ ${js}`
|
|
|
11901
12102
|
function WhileClause(ctx, state2) {
|
|
11902
12103
|
return (0, import_lib3.$EVENT)(ctx, state2, "WhileClause", WhileClause$0);
|
|
11903
12104
|
}
|
|
11904
|
-
var ForStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForClause,
|
|
12105
|
+
var ForStatement$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(ForClause, BlockOrEmptyStatement), function($skip, $loc, $0, $1, $2) {
|
|
11905
12106
|
var clause = $1;
|
|
11906
12107
|
var block = $2;
|
|
11907
12108
|
block = blockWithPrefix(clause.blockPrefix, block);
|
|
@@ -16479,34 +16680,22 @@ ${js}`
|
|
|
16479
16680
|
}
|
|
16480
16681
|
}
|
|
16481
16682
|
|
|
16482
|
-
// source/
|
|
16483
|
-
var
|
|
16484
|
-
__export(
|
|
16683
|
+
// source/sourcemap.civet
|
|
16684
|
+
var sourcemap_exports = {};
|
|
16685
|
+
__export(sourcemap_exports, {
|
|
16485
16686
|
SourceMap: () => SourceMap,
|
|
16486
16687
|
base64Encode: () => base64Encode,
|
|
16487
16688
|
locationTable: () => locationTable,
|
|
16488
16689
|
lookupLineColumn: () => lookupLineColumn
|
|
16489
16690
|
});
|
|
16490
|
-
var smRegexp;
|
|
16491
|
-
var prettySourceExcerpt;
|
|
16492
|
-
var VLQ_SHIFT;
|
|
16493
|
-
var VLQ_CONTINUATION_BIT;
|
|
16494
|
-
var VLQ_VALUE_MASK;
|
|
16495
|
-
var encodeVlq;
|
|
16496
|
-
var BASE64_CHARS;
|
|
16497
|
-
var encodeBase64;
|
|
16498
|
-
var vlqTable;
|
|
16499
|
-
var vlqChars;
|
|
16500
|
-
var decodeError;
|
|
16501
|
-
var decodeVLQ;
|
|
16502
|
-
var remapPosition;
|
|
16503
16691
|
var locationTable = function(input) {
|
|
16504
|
-
|
|
16505
|
-
|
|
16506
|
-
|
|
16507
|
-
|
|
16508
|
-
|
|
16509
|
-
while (
|
|
16692
|
+
const linesRe = /([^\r\n]*)(\r\n|\r|\n|$)/y;
|
|
16693
|
+
const lines = [];
|
|
16694
|
+
let line = 0;
|
|
16695
|
+
let pos = 0;
|
|
16696
|
+
let ref;
|
|
16697
|
+
while (ref = linesRe.exec(input)) {
|
|
16698
|
+
const result = ref;
|
|
16510
16699
|
pos += result[0].length;
|
|
16511
16700
|
lines[line++] = pos;
|
|
16512
16701
|
if (pos === input.length) {
|
|
@@ -16516,39 +16705,39 @@ ${js}`
|
|
|
16516
16705
|
return lines;
|
|
16517
16706
|
};
|
|
16518
16707
|
var lookupLineColumn = function(table, pos) {
|
|
16519
|
-
|
|
16520
|
-
|
|
16521
|
-
prevEnd = 0;
|
|
16708
|
+
let l = 0;
|
|
16709
|
+
let prevEnd = 0;
|
|
16522
16710
|
while (table[l] <= pos) {
|
|
16523
16711
|
prevEnd = table[l++];
|
|
16524
16712
|
}
|
|
16525
16713
|
return [l, pos - prevEnd];
|
|
16526
16714
|
};
|
|
16527
16715
|
var SourceMap = function(sourceString) {
|
|
16528
|
-
|
|
16529
|
-
|
|
16530
|
-
sm = {
|
|
16716
|
+
const srcTable = locationTable(sourceString);
|
|
16717
|
+
const sm = {
|
|
16531
16718
|
lines: [[]],
|
|
16532
|
-
|
|
16719
|
+
line: 0,
|
|
16533
16720
|
colOffset: 0,
|
|
16721
|
+
// relative to previous entry
|
|
16722
|
+
srcLine: 0,
|
|
16723
|
+
srcColumn: 0,
|
|
16724
|
+
srcOffset: 0,
|
|
16534
16725
|
srcTable
|
|
16535
16726
|
};
|
|
16536
|
-
EOL2 = /\r?\n|\r/;
|
|
16727
|
+
const EOL2 = /\r?\n|\r/;
|
|
16537
16728
|
return {
|
|
16538
16729
|
data: sm,
|
|
16539
16730
|
source: function() {
|
|
16540
16731
|
return sourceString;
|
|
16541
16732
|
},
|
|
16542
16733
|
renderMappings: function() {
|
|
16543
|
-
|
|
16544
|
-
|
|
16545
|
-
|
|
16546
|
-
|
|
16547
|
-
return line.map(function(entry) {
|
|
16548
|
-
var colDelta, sourceFileIndex, srcLine, srcCol, lineDelta;
|
|
16734
|
+
let lastSourceLine = 0;
|
|
16735
|
+
let lastSourceColumn = 0;
|
|
16736
|
+
return sm.lines.map((line) => {
|
|
16737
|
+
return line.map((entry) => {
|
|
16549
16738
|
if (entry.length === 4) {
|
|
16550
|
-
[colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16551
|
-
lineDelta = srcLine - lastSourceLine;
|
|
16739
|
+
let [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16740
|
+
const lineDelta = srcLine - lastSourceLine;
|
|
16552
16741
|
colDelta = srcCol - lastSourceColumn;
|
|
16553
16742
|
lastSourceLine = srcLine;
|
|
16554
16743
|
lastSourceColumn = srcCol;
|
|
@@ -16572,102 +16761,69 @@ ${js}`
|
|
|
16572
16761
|
}
|
|
16573
16762
|
};
|
|
16574
16763
|
},
|
|
16575
|
-
updateSourceMap: function(outputStr, inputPos) {
|
|
16576
|
-
|
|
16577
|
-
|
|
16764
|
+
updateSourceMap: function(outputStr, inputPos, colOffset = 0) {
|
|
16765
|
+
const outLines = outputStr.split(EOL2);
|
|
16766
|
+
let srcLine, srcCol;
|
|
16578
16767
|
if (inputPos != null) {
|
|
16579
16768
|
[srcLine, srcCol] = lookupLineColumn(srcTable, inputPos);
|
|
16769
|
+
srcCol += colOffset;
|
|
16770
|
+
sm.srcLine = srcLine;
|
|
16771
|
+
sm.srcColumn = srcCol;
|
|
16772
|
+
sm.srcOffset = inputPos + outputStr.length;
|
|
16580
16773
|
}
|
|
16581
|
-
|
|
16582
|
-
|
|
16774
|
+
for (let i1 = 0, len3 = outLines.length; i1 < len3; i1++) {
|
|
16775
|
+
const i = i1;
|
|
16776
|
+
const line = outLines[i1];
|
|
16583
16777
|
if (i > 0) {
|
|
16584
|
-
sm.
|
|
16778
|
+
sm.line++;
|
|
16779
|
+
sm.srcLine++;
|
|
16585
16780
|
sm.colOffset = 0;
|
|
16586
|
-
sm.lines[sm.
|
|
16587
|
-
srcCol =
|
|
16781
|
+
sm.lines[sm.line] = [];
|
|
16782
|
+
sm.srcColumn = srcCol = colOffset;
|
|
16588
16783
|
}
|
|
16589
|
-
l = sm.colOffset;
|
|
16784
|
+
const l = sm.colOffset;
|
|
16590
16785
|
sm.colOffset = line.length;
|
|
16786
|
+
sm.srcColumn += line.length;
|
|
16591
16787
|
if (inputPos != null) {
|
|
16592
|
-
|
|
16593
|
-
} else if (l
|
|
16594
|
-
|
|
16788
|
+
sm.lines[sm.line].push([l, 0, srcLine + i, srcCol]);
|
|
16789
|
+
} else if (l != 0) {
|
|
16790
|
+
sm.lines[sm.line].push([l]);
|
|
16595
16791
|
}
|
|
16596
|
-
|
|
16597
|
-
return;
|
|
16598
|
-
});
|
|
16792
|
+
}
|
|
16599
16793
|
return;
|
|
16600
16794
|
}
|
|
16601
16795
|
};
|
|
16602
16796
|
};
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
|
|
16607
|
-
|
|
16608
|
-
|
|
16609
|
-
if (line.length === 0) {
|
|
16610
|
-
return [];
|
|
16611
|
-
}
|
|
16612
|
-
return line.split(",").map(function(entry) {
|
|
16613
|
-
var result;
|
|
16614
|
-
result = decodeVLQ(entry);
|
|
16615
|
-
switch (result.length) {
|
|
16616
|
-
case 1: {
|
|
16617
|
-
return [result[0]];
|
|
16618
|
-
}
|
|
16619
|
-
case 4: {
|
|
16620
|
-
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
|
|
16621
|
-
}
|
|
16622
|
-
case 5: {
|
|
16623
|
-
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
|
|
16624
|
-
}
|
|
16625
|
-
default: {
|
|
16626
|
-
throw new Error("Unknown source map entry", result);
|
|
16627
|
-
}
|
|
16628
|
-
}
|
|
16629
|
-
});
|
|
16797
|
+
var smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
|
|
16798
|
+
var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
|
|
16799
|
+
let sourceMapText;
|
|
16800
|
+
const codeWithoutSourceMap = codeWithSourceMap.replace(smRegexp, (match, sm) => {
|
|
16801
|
+
sourceMapText = sm;
|
|
16802
|
+
return "";
|
|
16630
16803
|
});
|
|
16631
|
-
json.lines = lines;
|
|
16632
|
-
return json;
|
|
16633
|
-
};
|
|
16634
|
-
smRegexp = /\n\/\/# sourceMappingURL=data:application\/json;charset=utf-8;base64,([+a-zA-Z0-9\/]*=?=?)$/;
|
|
16635
|
-
SourceMap.remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
|
|
16636
|
-
var sourceMapText, codeWithoutSourceMap, remappedSourceMapJSON, newSourceMap, remappedCodeWithSourceMap, parsed, composedLines;
|
|
16637
|
-
sourceMapText = null;
|
|
16638
|
-
codeWithoutSourceMap = codeWithSourceMap.replace(
|
|
16639
|
-
smRegexp,
|
|
16640
|
-
(match, sm) => {
|
|
16641
|
-
sourceMapText = sm;
|
|
16642
|
-
return "";
|
|
16643
|
-
}
|
|
16644
|
-
);
|
|
16645
16804
|
if (sourceMapText) {
|
|
16646
|
-
parsed =
|
|
16647
|
-
composedLines =
|
|
16805
|
+
const parsed = parseWithLines(sourceMapText);
|
|
16806
|
+
const composedLines = composeLines(upstreamMap.data.lines, parsed.lines);
|
|
16648
16807
|
upstreamMap.data.lines = composedLines;
|
|
16649
16808
|
}
|
|
16650
|
-
remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
16651
|
-
newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
16652
|
-
remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
16809
|
+
const remappedSourceMapJSON = upstreamMap.json(sourcePath, targetPath);
|
|
16810
|
+
const newSourceMap = `${"sourceMapping"}URL=data:application/json;charset=utf-8;base64,${base64Encode(JSON.stringify(remappedSourceMapJSON))}`;
|
|
16811
|
+
const remappedCodeWithSourceMap = `${codeWithoutSourceMap}
|
|
16653
16812
|
//# ${newSourceMap}`;
|
|
16654
16813
|
return remappedCodeWithSourceMap;
|
|
16655
16814
|
};
|
|
16656
|
-
|
|
16657
|
-
return lines.map(
|
|
16658
|
-
return line.map(
|
|
16659
|
-
var colDelta, sourceFileIndex, srcLine, srcCol, srcPos, upstreamLine, upstreamCol;
|
|
16815
|
+
var composeLines = function(upstreamMapping, lines) {
|
|
16816
|
+
return lines.map((line) => {
|
|
16817
|
+
return line.map((entry) => {
|
|
16660
16818
|
if (entry.length === 1) {
|
|
16661
16819
|
return entry;
|
|
16662
16820
|
}
|
|
16663
|
-
;
|
|
16664
|
-
|
|
16665
|
-
srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
16821
|
+
const [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16822
|
+
const srcPos = remapPosition([srcLine, srcCol], upstreamMapping);
|
|
16666
16823
|
if (!srcPos) {
|
|
16667
16824
|
return [entry[0]];
|
|
16668
16825
|
}
|
|
16669
|
-
;
|
|
16670
|
-
[upstreamLine, upstreamCol] = srcPos;
|
|
16826
|
+
const [upstreamLine, upstreamCol] = srcPos;
|
|
16671
16827
|
if (entry.length === 4) {
|
|
16672
16828
|
return [colDelta, sourceFileIndex, upstreamLine, upstreamCol];
|
|
16673
16829
|
}
|
|
@@ -16675,44 +16831,50 @@ ${js}`
|
|
|
16675
16831
|
});
|
|
16676
16832
|
});
|
|
16677
16833
|
};
|
|
16678
|
-
|
|
16679
|
-
|
|
16680
|
-
|
|
16681
|
-
|
|
16682
|
-
|
|
16683
|
-
|
|
16684
|
-
|
|
16685
|
-
continue;
|
|
16686
|
-
}
|
|
16687
|
-
line = lines[i];
|
|
16688
|
-
lineNumStr = (i + 1).toString();
|
|
16689
|
-
while (lineNumStr.length < 4) {
|
|
16690
|
-
lineNumStr = " " + lineNumStr;
|
|
16691
|
-
}
|
|
16692
|
-
if (i === lineNum) {
|
|
16693
|
-
console.log(`${lineNumStr}: ${line}`);
|
|
16694
|
-
console.log(" ".repeat(lineNumStr.length + 2 + colNum) + "^".repeat(length));
|
|
16695
|
-
} else {
|
|
16696
|
-
console.log(`${lineNumStr}: ${line}`);
|
|
16834
|
+
var parseWithLines = function(base64encodedJSONstr) {
|
|
16835
|
+
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
16836
|
+
let sourceLine = 0;
|
|
16837
|
+
let sourceColumn = 0;
|
|
16838
|
+
const lines = json.mappings.split(";").map((line) => {
|
|
16839
|
+
if (line.length === 0) {
|
|
16840
|
+
return [];
|
|
16697
16841
|
}
|
|
16698
|
-
|
|
16699
|
-
|
|
16842
|
+
return line.split(",").map((entry) => {
|
|
16843
|
+
const result = decodeVLQ(entry);
|
|
16844
|
+
switch (result.length) {
|
|
16845
|
+
case 1: {
|
|
16846
|
+
return [result[0]];
|
|
16847
|
+
}
|
|
16848
|
+
case 4: {
|
|
16849
|
+
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3]];
|
|
16850
|
+
}
|
|
16851
|
+
case 5: {
|
|
16852
|
+
return [result[0], result[1], sourceLine += result[2], sourceColumn += result[3], result[4]];
|
|
16853
|
+
}
|
|
16854
|
+
default: {
|
|
16855
|
+
throw new Error("Unknown source map entry", result);
|
|
16856
|
+
}
|
|
16857
|
+
}
|
|
16858
|
+
});
|
|
16859
|
+
});
|
|
16860
|
+
json.lines = lines;
|
|
16861
|
+
return json;
|
|
16700
16862
|
};
|
|
16701
|
-
|
|
16702
|
-
|
|
16703
|
-
|
|
16704
|
-
|
|
16705
|
-
|
|
16706
|
-
answer = "";
|
|
16707
|
-
let
|
|
16863
|
+
Object.assign(SourceMap, { remap, parseWithLines, composeLines });
|
|
16864
|
+
var VLQ_SHIFT = 5;
|
|
16865
|
+
var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
16866
|
+
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
16867
|
+
var encodeVlq = function(value) {
|
|
16868
|
+
let answer = "";
|
|
16869
|
+
let ref1;
|
|
16708
16870
|
if (value < 0)
|
|
16709
|
-
|
|
16871
|
+
ref1 = 1;
|
|
16710
16872
|
else
|
|
16711
|
-
|
|
16712
|
-
signBit =
|
|
16713
|
-
valueToEncode = (Math.abs(value) << 1) + signBit;
|
|
16873
|
+
ref1 = 0;
|
|
16874
|
+
const signBit = ref1;
|
|
16875
|
+
let valueToEncode = (Math.abs(value) << 1) + signBit;
|
|
16714
16876
|
while (valueToEncode || !answer) {
|
|
16715
|
-
nextChunk = valueToEncode & VLQ_VALUE_MASK;
|
|
16877
|
+
let nextChunk = valueToEncode & VLQ_VALUE_MASK;
|
|
16716
16878
|
valueToEncode = valueToEncode >> VLQ_SHIFT;
|
|
16717
16879
|
if (valueToEncode) {
|
|
16718
16880
|
nextChunk |= VLQ_CONTINUATION_BIT;
|
|
@@ -16721,57 +16883,53 @@ ${js}`
|
|
|
16721
16883
|
}
|
|
16722
16884
|
return answer;
|
|
16723
16885
|
};
|
|
16724
|
-
BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16725
|
-
encodeBase64 = function(value) {
|
|
16886
|
+
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16887
|
+
var encodeBase64 = function(value) {
|
|
16726
16888
|
return BASE64_CHARS[value] || (() => {
|
|
16727
|
-
throw new Error(
|
|
16889
|
+
throw new Error("Cannot Base64 encode value: ${value}");
|
|
16728
16890
|
})();
|
|
16729
16891
|
};
|
|
16730
16892
|
var base64Encode = function(src) {
|
|
16731
16893
|
return Buffer.from(src).toString("base64");
|
|
16732
16894
|
};
|
|
16733
|
-
vlqTable = new Uint8Array(128);
|
|
16734
|
-
vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
l = vlqTable.length;
|
|
16895
|
+
var vlqTable = new Uint8Array(128);
|
|
16896
|
+
var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16897
|
+
{
|
|
16898
|
+
let i = 0;
|
|
16899
|
+
let l = vlqTable.length;
|
|
16739
16900
|
while (i < l) {
|
|
16740
16901
|
vlqTable[i] = 255;
|
|
16741
16902
|
i++;
|
|
16742
16903
|
}
|
|
16743
16904
|
i = 0;
|
|
16744
16905
|
l = vlqChars.length;
|
|
16745
|
-
const results = [];
|
|
16746
16906
|
while (i < l) {
|
|
16747
16907
|
vlqTable[vlqChars.charCodeAt(i)] = i;
|
|
16748
|
-
|
|
16908
|
+
i++;
|
|
16749
16909
|
}
|
|
16750
|
-
|
|
16751
|
-
|
|
16752
|
-
})();
|
|
16753
|
-
decodeError = function(message) {
|
|
16910
|
+
}
|
|
16911
|
+
var decodeError = function(message) {
|
|
16754
16912
|
throw new Error(message);
|
|
16755
16913
|
};
|
|
16756
|
-
decodeVLQ = function(mapping) {
|
|
16757
|
-
|
|
16758
|
-
|
|
16759
|
-
|
|
16760
|
-
result = [];
|
|
16914
|
+
var decodeVLQ = function(mapping) {
|
|
16915
|
+
let i = 0;
|
|
16916
|
+
let l = mapping.length;
|
|
16917
|
+
let result = [];
|
|
16761
16918
|
while (i < l) {
|
|
16762
|
-
shift = 0;
|
|
16763
|
-
vlq = 0;
|
|
16919
|
+
let shift = 0;
|
|
16920
|
+
let vlq = 0;
|
|
16921
|
+
let v = 0;
|
|
16764
16922
|
while (true) {
|
|
16765
16923
|
if (i >= l) {
|
|
16766
16924
|
decodeError("Unexpected early end of mapping data");
|
|
16767
16925
|
}
|
|
16768
|
-
c = mapping.charCodeAt(i);
|
|
16769
|
-
if ((c & 127)
|
|
16770
|
-
decodeError(
|
|
16926
|
+
const c = mapping.charCodeAt(i);
|
|
16927
|
+
if ((c & 127) != c) {
|
|
16928
|
+
decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
|
|
16771
16929
|
}
|
|
16772
|
-
index = vlqTable[c & 127];
|
|
16930
|
+
const index = vlqTable[c & 127];
|
|
16773
16931
|
if (index === 255) {
|
|
16774
|
-
decodeError(
|
|
16932
|
+
decodeError("Invalid mapping character: ${JSON.stringify(String.fromCharCode(c))}");
|
|
16775
16933
|
}
|
|
16776
16934
|
i++;
|
|
16777
16935
|
vlq |= (index & 31) << shift;
|
|
@@ -16789,20 +16947,19 @@ ${js}`
|
|
|
16789
16947
|
}
|
|
16790
16948
|
return result;
|
|
16791
16949
|
};
|
|
16792
|
-
remapPosition = function(position, sourcemapLines) {
|
|
16793
|
-
|
|
16794
|
-
|
|
16795
|
-
textLine = sourcemapLines[line];
|
|
16950
|
+
var remapPosition = function(position, sourcemapLines) {
|
|
16951
|
+
const [line, character] = position;
|
|
16952
|
+
const textLine = sourcemapLines[line];
|
|
16796
16953
|
if (!textLine?.length) {
|
|
16797
16954
|
return void 0;
|
|
16798
16955
|
}
|
|
16799
|
-
i = 0;
|
|
16800
|
-
p = 0;
|
|
16801
|
-
l = textLine.length;
|
|
16802
|
-
lastMapping = void 0;
|
|
16803
|
-
lastMappingPosition = 0;
|
|
16956
|
+
let i = 0;
|
|
16957
|
+
let p = 0;
|
|
16958
|
+
const l = textLine.length;
|
|
16959
|
+
let lastMapping = void 0;
|
|
16960
|
+
let lastMappingPosition = 0;
|
|
16804
16961
|
while (i < l) {
|
|
16805
|
-
mapping = textLine[i];
|
|
16962
|
+
const mapping = textLine[i];
|
|
16806
16963
|
p += mapping[0];
|
|
16807
16964
|
if (mapping.length === 4) {
|
|
16808
16965
|
lastMapping = mapping;
|
|
@@ -16813,7 +16970,7 @@ ${js}`
|
|
|
16813
16970
|
}
|
|
16814
16971
|
i++;
|
|
16815
16972
|
}
|
|
16816
|
-
if (character - lastMappingPosition
|
|
16973
|
+
if (character - lastMappingPosition != 0) {
|
|
16817
16974
|
return void 0;
|
|
16818
16975
|
}
|
|
16819
16976
|
if (lastMapping) {
|
|
@@ -16864,20 +17021,15 @@ ${js}`
|
|
|
16864
17021
|
};
|
|
16865
17022
|
|
|
16866
17023
|
// source/main.civet
|
|
16867
|
-
var { SourceMap: SourceMap2 } =
|
|
17024
|
+
var { SourceMap: SourceMap2 } = sourcemap_exports;
|
|
16868
17025
|
var ParseErrors = class extends Error {
|
|
16869
17026
|
name = "ParseErrors";
|
|
16870
|
-
|
|
16871
|
-
|
|
16872
|
-
|
|
16873
|
-
|
|
16874
|
-
constructor(message, filename1, line1, column1, offset1) {
|
|
16875
|
-
super(message);
|
|
16876
|
-
this.filename = filename1;
|
|
16877
|
-
this.line = line1;
|
|
16878
|
-
this.column = column1;
|
|
16879
|
-
this.offset = offset1;
|
|
17027
|
+
errors;
|
|
17028
|
+
constructor(errors) {
|
|
17029
|
+
const message = errors.map(($) => $.message).join("\n");
|
|
17030
|
+
super(errors.map(($1) => $1.message).join("\n"));
|
|
16880
17031
|
this.message = message;
|
|
17032
|
+
this.errors = errors;
|
|
16881
17033
|
}
|
|
16882
17034
|
};
|
|
16883
17035
|
var uncacheable = /* @__PURE__ */ new Set([
|
|
@@ -16979,6 +17131,7 @@ ${counts}`;
|
|
|
16979
17131
|
});
|
|
16980
17132
|
}
|
|
16981
17133
|
}
|
|
17134
|
+
const throwOnErrors = options.errors == null;
|
|
16982
17135
|
function rest(ast2) {
|
|
16983
17136
|
options = options;
|
|
16984
17137
|
if (!(options.ast === "raw")) {
|
|
@@ -16988,28 +17141,36 @@ ${counts}`;
|
|
|
16988
17141
|
return ast2;
|
|
16989
17142
|
}
|
|
16990
17143
|
function checkErrors() {
|
|
17144
|
+
if (!throwOnErrors) {
|
|
17145
|
+
return;
|
|
17146
|
+
}
|
|
17147
|
+
options = options;
|
|
16991
17148
|
if (options.errors?.length) {
|
|
16992
|
-
throw new ParseErrors(options.errors
|
|
17149
|
+
throw new ParseErrors(options.errors);
|
|
16993
17150
|
}
|
|
16994
17151
|
;
|
|
16995
17152
|
return;
|
|
16996
17153
|
}
|
|
16997
17154
|
if (options.sourceMap || options.inlineMap) {
|
|
16998
|
-
|
|
16999
|
-
options.updateSourceMap = sm.updateSourceMap;
|
|
17155
|
+
options.sourceMap = SourceMap2(src);
|
|
17000
17156
|
const code = generate_default(ast2, options);
|
|
17001
17157
|
checkErrors();
|
|
17002
17158
|
if (options.inlineMap) {
|
|
17003
|
-
return SourceMap2.remap(code,
|
|
17159
|
+
return SourceMap2.remap(code, options.sourceMap, filename2, filename2 + ".tsx");
|
|
17004
17160
|
} else {
|
|
17005
17161
|
return {
|
|
17006
17162
|
code,
|
|
17007
|
-
sourceMap:
|
|
17163
|
+
sourceMap: options.sourceMap
|
|
17008
17164
|
};
|
|
17009
17165
|
}
|
|
17010
17166
|
}
|
|
17011
17167
|
const result = generate_default(ast2, options);
|
|
17012
|
-
|
|
17168
|
+
if (options.errors?.length) {
|
|
17169
|
+
delete options.errors;
|
|
17170
|
+
options.sourceMap = SourceMap2(src);
|
|
17171
|
+
generate_default(ast2, options);
|
|
17172
|
+
checkErrors();
|
|
17173
|
+
}
|
|
17013
17174
|
return result;
|
|
17014
17175
|
}
|
|
17015
17176
|
if (ast.then != null) {
|
|
@@ -17081,9 +17242,8 @@ ${counts}`;
|
|
|
17081
17242
|
return events;
|
|
17082
17243
|
};
|
|
17083
17244
|
var isCompileError = function(err) {
|
|
17084
|
-
return err instanceof
|
|
17085
|
-
[err.message, err.name, err.filename, err.line, err.column, err.offset].every(($1) => $1 !== void 0);
|
|
17245
|
+
return err instanceof import_lib3.ParseError || err instanceof ParseErrors;
|
|
17086
17246
|
};
|
|
17087
|
-
var main_default = { parse, parseProgram, generate: generate_default,
|
|
17247
|
+
var main_default = { parse, parseProgram, ParseError: import_lib3.ParseError, ParseErrors, generate: generate_default, sourcemap: sourcemap_exports, SourceMap: SourceMap2, compile, isCompileError };
|
|
17088
17248
|
return __toCommonJS(main_exports);
|
|
17089
17249
|
})();
|