@danielx/civet 0.7.10 → 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 +255 -180
- package/dist/civet +19 -14
- package/dist/esm.mjs +0 -31
- package/dist/main.js +255 -180
- package/dist/main.mjs +255 -180
- package/package.json +2 -2
- package/register.js +40 -12
package/dist/main.mjs
CHANGED
|
@@ -940,27 +940,49 @@ function assignResults(node, collect) {
|
|
|
940
940
|
case "DebuggerStatement":
|
|
941
941
|
case "EmptyStatement":
|
|
942
942
|
case "ReturnStatement":
|
|
943
|
-
case "ThrowStatement":
|
|
943
|
+
case "ThrowStatement": {
|
|
944
944
|
return;
|
|
945
|
-
|
|
945
|
+
}
|
|
946
|
+
case "Declaration": {
|
|
947
|
+
let ref5;
|
|
948
|
+
if (exp.bindings?.length) {
|
|
949
|
+
ref5 = patternAsValue((ref4 = exp.bindings)[ref4.length - 1].pattern);
|
|
950
|
+
} else {
|
|
951
|
+
ref5 = "void 0";
|
|
952
|
+
}
|
|
953
|
+
;
|
|
954
|
+
const value = ref5;
|
|
946
955
|
exp.children.push([
|
|
947
956
|
"",
|
|
948
|
-
[";", collect(
|
|
957
|
+
[";", collect(value)]
|
|
949
958
|
]);
|
|
950
959
|
return;
|
|
960
|
+
}
|
|
961
|
+
case "FunctionExpression": {
|
|
962
|
+
if (exp.id) {
|
|
963
|
+
exp.children.push([
|
|
964
|
+
"",
|
|
965
|
+
[";", collect(exp.id)]
|
|
966
|
+
]);
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
951
971
|
case "ForStatement":
|
|
952
972
|
case "IterationStatement":
|
|
953
973
|
case "DoStatement":
|
|
954
|
-
case "ComptimeStatement":
|
|
974
|
+
case "ComptimeStatement": {
|
|
955
975
|
wrapIterationReturningResults(exp, outer, collect);
|
|
956
976
|
return;
|
|
957
|
-
|
|
977
|
+
}
|
|
978
|
+
case "BlockStatement": {
|
|
958
979
|
if (node.expressions.some(isExit)) {
|
|
959
980
|
return;
|
|
960
981
|
}
|
|
961
982
|
assignResults(exp.expressions[exp.expressions.length - 1], collect);
|
|
962
983
|
return;
|
|
963
|
-
|
|
984
|
+
}
|
|
985
|
+
case "IfStatement": {
|
|
964
986
|
assignResults(exp.then, collect);
|
|
965
987
|
if (exp.then.bare && !exp.then.semicolon) {
|
|
966
988
|
exp.then.children.push(exp.then.semicolon = ";");
|
|
@@ -968,18 +990,22 @@ function assignResults(node, collect) {
|
|
|
968
990
|
if (exp.else) {
|
|
969
991
|
assignResults(exp.else.block, collect);
|
|
970
992
|
} else {
|
|
971
|
-
exp.children.push([" else {", collect("
|
|
993
|
+
exp.children.push([" else {", collect("void 0"), "}"]);
|
|
972
994
|
}
|
|
973
995
|
return;
|
|
974
|
-
|
|
996
|
+
}
|
|
997
|
+
case "PatternMatchingStatement": {
|
|
975
998
|
assignResults(exp.children[0], collect);
|
|
976
999
|
return;
|
|
977
|
-
|
|
1000
|
+
}
|
|
1001
|
+
case "SwitchStatement": {
|
|
978
1002
|
assignResults(exp.children[2], collect);
|
|
979
1003
|
return;
|
|
980
|
-
|
|
1004
|
+
}
|
|
1005
|
+
case "TryStatement": {
|
|
981
1006
|
exp.blocks.forEach((block) => assignResults(block, collect));
|
|
982
1007
|
return;
|
|
1008
|
+
}
|
|
983
1009
|
}
|
|
984
1010
|
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
985
1011
|
return;
|
|
@@ -990,7 +1016,7 @@ function insertReturn(node, outerNode = node) {
|
|
|
990
1016
|
if (!node)
|
|
991
1017
|
return;
|
|
992
1018
|
switch (node.type) {
|
|
993
|
-
case "BlockStatement":
|
|
1019
|
+
case "BlockStatement": {
|
|
994
1020
|
if (node.expressions.length) {
|
|
995
1021
|
if (node.expressions.some(([, exp2]) => isExit(exp2))) {
|
|
996
1022
|
return;
|
|
@@ -1003,7 +1029,8 @@ function insertReturn(node, outerNode = node) {
|
|
|
1003
1029
|
}
|
|
1004
1030
|
}
|
|
1005
1031
|
return;
|
|
1006
|
-
|
|
1032
|
+
}
|
|
1033
|
+
case "WhenClause": {
|
|
1007
1034
|
if (node.break) {
|
|
1008
1035
|
node.children.splice(node.children.indexOf(node.break), 1);
|
|
1009
1036
|
}
|
|
@@ -1013,9 +1040,11 @@ function insertReturn(node, outerNode = node) {
|
|
|
1013
1040
|
node.block.expressions.push(wrapWithReturn());
|
|
1014
1041
|
}
|
|
1015
1042
|
return;
|
|
1016
|
-
|
|
1043
|
+
}
|
|
1044
|
+
case "DefaultClause": {
|
|
1017
1045
|
insertReturn(node.block);
|
|
1018
1046
|
return;
|
|
1047
|
+
}
|
|
1019
1048
|
}
|
|
1020
1049
|
if (!Array.isArray(node))
|
|
1021
1050
|
return;
|
|
@@ -1035,23 +1064,36 @@ function insertReturn(node, outerNode = node) {
|
|
|
1035
1064
|
exp = exp.statement;
|
|
1036
1065
|
({ type } = exp);
|
|
1037
1066
|
}
|
|
1038
|
-
let
|
|
1067
|
+
let ref6;
|
|
1039
1068
|
switch (type) {
|
|
1040
1069
|
case "BreakStatement":
|
|
1041
1070
|
case "ContinueStatement":
|
|
1042
1071
|
case "DebuggerStatement":
|
|
1043
1072
|
case "EmptyStatement":
|
|
1044
1073
|
case "ReturnStatement":
|
|
1045
|
-
case "ThrowStatement":
|
|
1074
|
+
case "ThrowStatement": {
|
|
1046
1075
|
return;
|
|
1047
|
-
|
|
1076
|
+
}
|
|
1077
|
+
case "Declaration": {
|
|
1078
|
+
let ref7;
|
|
1079
|
+
if (exp.bindings?.length) {
|
|
1080
|
+
ref7 = [" ", patternAsValue((ref6 = exp.bindings)[ref6.length - 1].pattern)];
|
|
1081
|
+
} else {
|
|
1082
|
+
ref7 = [];
|
|
1083
|
+
}
|
|
1084
|
+
;
|
|
1085
|
+
const value = ref7;
|
|
1048
1086
|
exp.children.push(["", {
|
|
1049
1087
|
type: "ReturnStatement",
|
|
1050
|
-
children: [
|
|
1088
|
+
children: [
|
|
1089
|
+
";return",
|
|
1090
|
+
...value
|
|
1091
|
+
],
|
|
1051
1092
|
parent: exp
|
|
1052
1093
|
}]);
|
|
1053
1094
|
return;
|
|
1054
|
-
|
|
1095
|
+
}
|
|
1096
|
+
case "FunctionExpression": {
|
|
1055
1097
|
if (exp.id) {
|
|
1056
1098
|
exp.children.push([
|
|
1057
1099
|
"",
|
|
@@ -1064,16 +1106,19 @@ function insertReturn(node, outerNode = node) {
|
|
|
1064
1106
|
return;
|
|
1065
1107
|
}
|
|
1066
1108
|
break;
|
|
1109
|
+
}
|
|
1067
1110
|
case "ForStatement":
|
|
1068
1111
|
case "IterationStatement":
|
|
1069
1112
|
case "DoStatement":
|
|
1070
|
-
case "ComptimeStatement":
|
|
1113
|
+
case "ComptimeStatement": {
|
|
1071
1114
|
wrapIterationReturningResults(exp, outer);
|
|
1072
1115
|
return;
|
|
1073
|
-
|
|
1116
|
+
}
|
|
1117
|
+
case "BlockStatement": {
|
|
1074
1118
|
insertReturn(exp.expressions[exp.expressions.length - 1]);
|
|
1075
1119
|
return;
|
|
1076
|
-
|
|
1120
|
+
}
|
|
1121
|
+
case "IfStatement": {
|
|
1077
1122
|
insertReturn(exp.then);
|
|
1078
1123
|
if (exp.else)
|
|
1079
1124
|
insertReturn(exp.else.block);
|
|
@@ -1085,18 +1130,23 @@ function insertReturn(node, outerNode = node) {
|
|
|
1085
1130
|
parent: exp
|
|
1086
1131
|
}]);
|
|
1087
1132
|
return;
|
|
1088
|
-
|
|
1133
|
+
}
|
|
1134
|
+
case "PatternMatchingStatement": {
|
|
1089
1135
|
insertReturn(exp.children[0]);
|
|
1090
1136
|
return;
|
|
1091
|
-
|
|
1137
|
+
}
|
|
1138
|
+
case "SwitchStatement": {
|
|
1092
1139
|
insertSwitchReturns(exp);
|
|
1093
1140
|
return;
|
|
1094
|
-
|
|
1141
|
+
}
|
|
1142
|
+
case "TryStatement": {
|
|
1095
1143
|
exp.blocks.forEach((block) => insertReturn(block));
|
|
1096
1144
|
return;
|
|
1145
|
+
}
|
|
1097
1146
|
}
|
|
1098
|
-
if (node[node.length - 1]?.type === "SemicolonDelimiter")
|
|
1147
|
+
if (node[node.length - 1]?.type === "SemicolonDelimiter") {
|
|
1099
1148
|
return;
|
|
1149
|
+
}
|
|
1100
1150
|
const returnStatement = wrapWithReturn(node[1]);
|
|
1101
1151
|
node.splice(1, 1, returnStatement);
|
|
1102
1152
|
}
|
|
@@ -1185,10 +1235,33 @@ function processParams(f) {
|
|
|
1185
1235
|
}
|
|
1186
1236
|
expressions.unshift(...prefix);
|
|
1187
1237
|
}
|
|
1238
|
+
function processSignature(f) {
|
|
1239
|
+
const { block, signature } = f;
|
|
1240
|
+
if (hasAwait(block) && !f.async?.length) {
|
|
1241
|
+
f.async.push("async ");
|
|
1242
|
+
signature.modifier.async = true;
|
|
1243
|
+
}
|
|
1244
|
+
if (hasYield(block) && !f.generator?.length) {
|
|
1245
|
+
if (f.type === "ArrowFunction") {
|
|
1246
|
+
gatherRecursiveWithinFunction(block, ($) => $.type === "YieldExpression").forEach((y) => {
|
|
1247
|
+
const i = y.children.findIndex(($1) => $1.type === "Yield");
|
|
1248
|
+
return y.children.splice(i + 1, 0, {
|
|
1249
|
+
type: "Error",
|
|
1250
|
+
message: "Can't use yield inside of => arrow function"
|
|
1251
|
+
});
|
|
1252
|
+
});
|
|
1253
|
+
} else {
|
|
1254
|
+
f.generator.push("*");
|
|
1255
|
+
signature.modifier.generator = true;
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1188
1259
|
function processFunctions(statements, config2) {
|
|
1189
1260
|
gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
|
|
1190
|
-
if (f.type === "FunctionExpression")
|
|
1261
|
+
if (f.type === "FunctionExpression") {
|
|
1191
1262
|
implicitFunctionBlock(f);
|
|
1263
|
+
}
|
|
1264
|
+
processSignature(f);
|
|
1192
1265
|
processParams(f);
|
|
1193
1266
|
return processReturn(f, config2.implicitReturns);
|
|
1194
1267
|
});
|
|
@@ -1245,12 +1318,12 @@ function processCoffeeDo(ws, expression) {
|
|
|
1245
1318
|
...parameters,
|
|
1246
1319
|
children: (() => {
|
|
1247
1320
|
const results = [];
|
|
1248
|
-
for (let
|
|
1249
|
-
let parameter =
|
|
1321
|
+
for (let ref8 = parameters.children, i1 = 0, len3 = ref8.length; i1 < len3; i1++) {
|
|
1322
|
+
let parameter = ref8[i1];
|
|
1250
1323
|
if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
|
|
1251
|
-
let
|
|
1252
|
-
if (
|
|
1253
|
-
const initializer =
|
|
1324
|
+
let ref9;
|
|
1325
|
+
if (ref9 = parameter.initializer) {
|
|
1326
|
+
const initializer = ref9;
|
|
1254
1327
|
args.push(initializer.expression, parameter.delim);
|
|
1255
1328
|
parameter = {
|
|
1256
1329
|
...parameter,
|
|
@@ -1271,7 +1344,7 @@ function processCoffeeDo(ws, expression) {
|
|
|
1271
1344
|
expression = {
|
|
1272
1345
|
...expression,
|
|
1273
1346
|
parameters: newParameters,
|
|
1274
|
-
children: expression.children.map(($) => $ === parameters ? newParameters : $)
|
|
1347
|
+
children: expression.children.map(($2) => $2 === parameters ? newParameters : $2)
|
|
1275
1348
|
};
|
|
1276
1349
|
}
|
|
1277
1350
|
return {
|
|
@@ -1286,6 +1359,52 @@ function processCoffeeDo(ws, expression) {
|
|
|
1286
1359
|
]
|
|
1287
1360
|
};
|
|
1288
1361
|
}
|
|
1362
|
+
function makeAmpersandFunction(rhs) {
|
|
1363
|
+
let { ref, typeSuffix, body } = rhs;
|
|
1364
|
+
if (!(ref != null)) {
|
|
1365
|
+
ref = makeRef("$");
|
|
1366
|
+
inplacePrepend(ref, body);
|
|
1367
|
+
}
|
|
1368
|
+
if (body?.type === "ObjectExpression") {
|
|
1369
|
+
body = makeLeftHandSideExpression(body);
|
|
1370
|
+
}
|
|
1371
|
+
const parameters = makeNode({
|
|
1372
|
+
type: "Parameters",
|
|
1373
|
+
children: typeSuffix ? ["(", ref, typeSuffix, ")"] : [ref],
|
|
1374
|
+
names: []
|
|
1375
|
+
});
|
|
1376
|
+
const expressions = [[" ", body]];
|
|
1377
|
+
const block = makeNode({
|
|
1378
|
+
type: "BlockStatement",
|
|
1379
|
+
bare: true,
|
|
1380
|
+
expressions,
|
|
1381
|
+
children: [expressions],
|
|
1382
|
+
implicitlyReturned: true
|
|
1383
|
+
});
|
|
1384
|
+
const async = [];
|
|
1385
|
+
const children = [async, parameters, " =>", block];
|
|
1386
|
+
const fn = makeNode({
|
|
1387
|
+
type: "ArrowFunction",
|
|
1388
|
+
async,
|
|
1389
|
+
signature: {
|
|
1390
|
+
modifier: {
|
|
1391
|
+
async: !!async
|
|
1392
|
+
}
|
|
1393
|
+
},
|
|
1394
|
+
children,
|
|
1395
|
+
ref,
|
|
1396
|
+
block,
|
|
1397
|
+
parameters,
|
|
1398
|
+
ampersandBlock: true,
|
|
1399
|
+
body
|
|
1400
|
+
});
|
|
1401
|
+
if (isStatement(body)) {
|
|
1402
|
+
braceBlock(block);
|
|
1403
|
+
fn.ampersandBlock = false;
|
|
1404
|
+
delete fn.body;
|
|
1405
|
+
}
|
|
1406
|
+
return fn;
|
|
1407
|
+
}
|
|
1289
1408
|
|
|
1290
1409
|
// source/parser/block.civet
|
|
1291
1410
|
function blockWithPrefix(prefixStatements, block) {
|
|
@@ -1509,8 +1628,8 @@ function addParentPointers(node, parent) {
|
|
|
1509
1628
|
node.parent = parent;
|
|
1510
1629
|
}
|
|
1511
1630
|
if (node.children) {
|
|
1512
|
-
for (let
|
|
1513
|
-
const child =
|
|
1631
|
+
for (let ref = node.children, i1 = 0, len1 = ref.length; i1 < len1; i1++) {
|
|
1632
|
+
const child = ref[i1];
|
|
1514
1633
|
addParentPointers(child, node);
|
|
1515
1634
|
}
|
|
1516
1635
|
}
|
|
@@ -1792,13 +1911,13 @@ function startsWith(target, value) {
|
|
|
1792
1911
|
return;
|
|
1793
1912
|
}
|
|
1794
1913
|
function hasAwait(exp) {
|
|
1795
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1914
|
+
return gatherRecursiveWithinFunction(exp, ($1) => $1.type === "Await").length > 0;
|
|
1796
1915
|
}
|
|
1797
1916
|
function hasYield(exp) {
|
|
1798
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1917
|
+
return gatherRecursiveWithinFunction(exp, ($2) => $2.type === "Yield").length > 0;
|
|
1799
1918
|
}
|
|
1800
1919
|
function hasImportDeclaration(exp) {
|
|
1801
|
-
return gatherRecursiveWithinFunction(exp, (
|
|
1920
|
+
return gatherRecursiveWithinFunction(exp, ($3) => $3.type === "ImportDeclaration").length > 0;
|
|
1802
1921
|
}
|
|
1803
1922
|
function deepCopy(node) {
|
|
1804
1923
|
if (node == null)
|
|
@@ -1836,54 +1955,6 @@ function removeHoistDecs(node) {
|
|
|
1836
1955
|
}
|
|
1837
1956
|
}
|
|
1838
1957
|
}
|
|
1839
|
-
function makeAmpersandFunction(rhs) {
|
|
1840
|
-
let { ref, typeSuffix, body } = rhs;
|
|
1841
|
-
if (!(ref != null)) {
|
|
1842
|
-
ref = makeRef("$");
|
|
1843
|
-
inplacePrepend(ref, body);
|
|
1844
|
-
}
|
|
1845
|
-
if (body?.type === "ObjectExpression") {
|
|
1846
|
-
body = makeLeftHandSideExpression(body);
|
|
1847
|
-
}
|
|
1848
|
-
const parameters = makeNode({
|
|
1849
|
-
type: "Parameters",
|
|
1850
|
-
children: typeSuffix ? ["(", ref, typeSuffix, ")"] : [ref],
|
|
1851
|
-
names: []
|
|
1852
|
-
});
|
|
1853
|
-
const expressions = [[" ", body]];
|
|
1854
|
-
const block = makeNode({
|
|
1855
|
-
type: "BlockStatement",
|
|
1856
|
-
bare: true,
|
|
1857
|
-
expressions,
|
|
1858
|
-
children: [expressions],
|
|
1859
|
-
implicitlyReturned: true
|
|
1860
|
-
});
|
|
1861
|
-
const children = [parameters, " =>", block];
|
|
1862
|
-
const async = hasAwait(body);
|
|
1863
|
-
if (async) {
|
|
1864
|
-
children.unshift("async ");
|
|
1865
|
-
}
|
|
1866
|
-
const fn = makeNode({
|
|
1867
|
-
type: "ArrowFunction",
|
|
1868
|
-
signature: {
|
|
1869
|
-
modifier: {
|
|
1870
|
-
async
|
|
1871
|
-
}
|
|
1872
|
-
},
|
|
1873
|
-
children,
|
|
1874
|
-
ref,
|
|
1875
|
-
block,
|
|
1876
|
-
parameters,
|
|
1877
|
-
ampersandBlock: true,
|
|
1878
|
-
body
|
|
1879
|
-
});
|
|
1880
|
-
if (isStatement(body)) {
|
|
1881
|
-
braceBlock(block);
|
|
1882
|
-
fn.ampersandBlock = false;
|
|
1883
|
-
delete fn.body;
|
|
1884
|
-
}
|
|
1885
|
-
return fn;
|
|
1886
|
-
}
|
|
1887
1958
|
var skipParens = /* @__PURE__ */ new Set([
|
|
1888
1959
|
"AmpersandRef",
|
|
1889
1960
|
"CallExpression",
|
|
@@ -1934,8 +2005,8 @@ function updateParentPointers(node, parent, depth = 1) {
|
|
|
1934
2005
|
node.parent = parent;
|
|
1935
2006
|
}
|
|
1936
2007
|
if (depth && isParent(node)) {
|
|
1937
|
-
for (let
|
|
1938
|
-
const child =
|
|
2008
|
+
for (let ref1 = node.children, i3 = 0, len3 = ref1.length; i3 < len3; i3++) {
|
|
2009
|
+
const child = ref1[i3];
|
|
1939
2010
|
updateParentPointers(child, node, depth - 1);
|
|
1940
2011
|
}
|
|
1941
2012
|
}
|
|
@@ -2006,11 +2077,11 @@ function parenthesizeType(type) {
|
|
|
2006
2077
|
}
|
|
2007
2078
|
function wrapIIFE(expressions, asyncFlag) {
|
|
2008
2079
|
let prefix;
|
|
2009
|
-
|
|
2080
|
+
const async = [];
|
|
2010
2081
|
if (asyncFlag) {
|
|
2011
|
-
async
|
|
2082
|
+
async.push("async ");
|
|
2012
2083
|
} else if (hasAwait(expressions)) {
|
|
2013
|
-
async
|
|
2084
|
+
async.push("async ");
|
|
2014
2085
|
prefix = {
|
|
2015
2086
|
type: "Await",
|
|
2016
2087
|
children: ["await "]
|
|
@@ -2021,8 +2092,7 @@ function wrapIIFE(expressions, asyncFlag) {
|
|
|
2021
2092
|
expressions,
|
|
2022
2093
|
children: ["{", expressions, "}"],
|
|
2023
2094
|
bare: false,
|
|
2024
|
-
root: false
|
|
2025
|
-
parent: void 0
|
|
2095
|
+
root: false
|
|
2026
2096
|
});
|
|
2027
2097
|
const parameters = {
|
|
2028
2098
|
type: "Parameters",
|
|
@@ -2031,7 +2101,7 @@ function wrapIIFE(expressions, asyncFlag) {
|
|
|
2031
2101
|
};
|
|
2032
2102
|
const signature = {
|
|
2033
2103
|
modifier: {
|
|
2034
|
-
async: !!async
|
|
2104
|
+
async: !!async.length
|
|
2035
2105
|
},
|
|
2036
2106
|
returnType: void 0
|
|
2037
2107
|
};
|
|
@@ -2374,8 +2444,6 @@ function processBinaryOpExpression($0) {
|
|
|
2374
2444
|
}
|
|
2375
2445
|
return expandedOps;
|
|
2376
2446
|
}
|
|
2377
|
-
;
|
|
2378
|
-
return recurse;
|
|
2379
2447
|
}
|
|
2380
2448
|
function dotNumericLiteral(literal) {
|
|
2381
2449
|
if (literal?.type === "Literal" && /^[+-]?(?:0|[1-9](?:_[0-9]|[0-9])*)$/.test(literal.raw)) {
|
|
@@ -2892,7 +2960,13 @@ function getPatternBlockPrefix(pattern, ref, decl = "const ", suffix) {
|
|
|
2892
2960
|
thisAssignments = thisAssignments.map(($6) => ["", $6, ";"]);
|
|
2893
2961
|
const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
|
|
2894
2962
|
return [
|
|
2895
|
-
["",
|
|
2963
|
+
["", {
|
|
2964
|
+
type: "Declaration",
|
|
2965
|
+
children: [decl, patternBindings, suffix, " = ", ref, ...splices],
|
|
2966
|
+
names: [],
|
|
2967
|
+
bindings: []
|
|
2968
|
+
// avoid implicit return of any bindings
|
|
2969
|
+
}, ";"],
|
|
2896
2970
|
...thisAssignments,
|
|
2897
2971
|
...duplicateDeclarations.map(($7) => ["", $7, ";"])
|
|
2898
2972
|
];
|
|
@@ -3040,9 +3114,18 @@ function aggregateDuplicateBindings(bindings) {
|
|
|
3040
3114
|
aliasBinding(p, ref);
|
|
3041
3115
|
return ref;
|
|
3042
3116
|
});
|
|
3043
|
-
return declarations.push(
|
|
3044
|
-
|
|
3045
|
-
|
|
3117
|
+
return declarations.push({
|
|
3118
|
+
type: "Declaration",
|
|
3119
|
+
children: [
|
|
3120
|
+
"const ",
|
|
3121
|
+
key,
|
|
3122
|
+
" = [",
|
|
3123
|
+
...refs.map((r, i) => i === 0 ? r : [", ", r]),
|
|
3124
|
+
"]"
|
|
3125
|
+
],
|
|
3126
|
+
names: [],
|
|
3127
|
+
bindings: []
|
|
3128
|
+
});
|
|
3046
3129
|
});
|
|
3047
3130
|
return declarations;
|
|
3048
3131
|
}
|
|
@@ -3533,8 +3616,7 @@ function processUnaryExpression(pre, exp, post) {
|
|
|
3533
3616
|
token: " != null"
|
|
3534
3617
|
};
|
|
3535
3618
|
if (pre.length) {
|
|
3536
|
-
|
|
3537
|
-
const lastPre = (ref = pre)[ref.length - 1];
|
|
3619
|
+
const lastPre = pre[pre.length - 1];
|
|
3538
3620
|
if (lastPre.token === "!") {
|
|
3539
3621
|
post.token = " == null";
|
|
3540
3622
|
pre = pre.slice(0, -1);
|
|
@@ -3578,9 +3660,9 @@ function processUnaryExpression(pre, exp, post) {
|
|
|
3578
3660
|
}
|
|
3579
3661
|
}
|
|
3580
3662
|
}
|
|
3581
|
-
let
|
|
3582
|
-
while (
|
|
3583
|
-
const l =
|
|
3663
|
+
let ref;
|
|
3664
|
+
while (ref = pre.length) {
|
|
3665
|
+
const l = ref;
|
|
3584
3666
|
const last = pre[l - 1];
|
|
3585
3667
|
if (last.type === "Await") {
|
|
3586
3668
|
if (last.op) {
|
|
@@ -4234,8 +4316,6 @@ function gen(root, options) {
|
|
|
4234
4316
|
debugger;
|
|
4235
4317
|
throw new Error(`Unknown node ${stringify(node)}`);
|
|
4236
4318
|
}
|
|
4237
|
-
;
|
|
4238
|
-
return recurse;
|
|
4239
4319
|
}
|
|
4240
4320
|
var generate_default = gen;
|
|
4241
4321
|
function prune(node) {
|
|
@@ -4811,8 +4891,11 @@ function expressionizeBlock(blockOrExpression) {
|
|
|
4811
4891
|
}
|
|
4812
4892
|
if (results.length > 1) {
|
|
4813
4893
|
return makeLeftHandSideExpression(results);
|
|
4894
|
+
} else if (results.length) {
|
|
4895
|
+
return results;
|
|
4896
|
+
} else {
|
|
4897
|
+
return ["void 0"];
|
|
4814
4898
|
}
|
|
4815
|
-
return results;
|
|
4816
4899
|
} else {
|
|
4817
4900
|
return blockOrExpression;
|
|
4818
4901
|
}
|
|
@@ -4839,10 +4922,10 @@ function expressionizeIfStatement(statement) {
|
|
|
4839
4922
|
children.push(":void 0");
|
|
4840
4923
|
}
|
|
4841
4924
|
children.push(closeParen);
|
|
4842
|
-
return {
|
|
4925
|
+
return makeNode({
|
|
4843
4926
|
type: "IfExpression",
|
|
4844
4927
|
children
|
|
4845
|
-
};
|
|
4928
|
+
});
|
|
4846
4929
|
}
|
|
4847
4930
|
function expressionizeTypeIf([ws, ifOp, condition, t, e]) {
|
|
4848
4931
|
const children = [
|
|
@@ -7864,16 +7947,8 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
|
|
|
7864
7947
|
var suffix = $3;
|
|
7865
7948
|
var arrow = $4;
|
|
7866
7949
|
var expOrBlock = $5;
|
|
7867
|
-
if (
|
|
7868
|
-
async =
|
|
7869
|
-
}
|
|
7870
|
-
let error;
|
|
7871
|
-
if (hasYield(expOrBlock)) {
|
|
7872
|
-
error = {
|
|
7873
|
-
type: "Error",
|
|
7874
|
-
message: "Can't use yield inside of => arrow function"
|
|
7875
|
-
};
|
|
7876
|
-
}
|
|
7950
|
+
if (!async)
|
|
7951
|
+
async = [];
|
|
7877
7952
|
return {
|
|
7878
7953
|
type: "ArrowFunction",
|
|
7879
7954
|
signature: {
|
|
@@ -7884,10 +7959,9 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
|
|
|
7884
7959
|
},
|
|
7885
7960
|
parameters,
|
|
7886
7961
|
returnType: suffix,
|
|
7887
|
-
ts: false,
|
|
7888
7962
|
async,
|
|
7889
7963
|
block: expOrBlock,
|
|
7890
|
-
children: [async, parameters, suffix, arrow,
|
|
7964
|
+
children: [async, parameters, suffix, arrow, expOrBlock]
|
|
7891
7965
|
};
|
|
7892
7966
|
});
|
|
7893
7967
|
var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
|
|
@@ -9524,7 +9598,6 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
|
|
|
9524
9598
|
name: id?.name,
|
|
9525
9599
|
parameters,
|
|
9526
9600
|
returnType: suffix,
|
|
9527
|
-
ts: false,
|
|
9528
9601
|
async,
|
|
9529
9602
|
generator,
|
|
9530
9603
|
modifier: {
|
|
@@ -9550,14 +9623,6 @@ var FunctionExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(FunctionSign
|
|
|
9550
9623
|
ts: true
|
|
9551
9624
|
};
|
|
9552
9625
|
}
|
|
9553
|
-
if (hasAwait(block) && !signature.async.length) {
|
|
9554
|
-
signature.async.push("async ");
|
|
9555
|
-
signature.modifier.async = true;
|
|
9556
|
-
}
|
|
9557
|
-
if (hasYield(block) && !signature.generator.length) {
|
|
9558
|
-
signature.generator.push("*");
|
|
9559
|
-
signature.modifier.generator = true;
|
|
9560
|
-
}
|
|
9561
9626
|
return {
|
|
9562
9627
|
...signature,
|
|
9563
9628
|
type: "FunctionExpression",
|
|
@@ -9729,15 +9794,21 @@ var OperatorDeclaration$$ = [OperatorDeclaration$0, OperatorDeclaration$1, Opera
|
|
|
9729
9794
|
function OperatorDeclaration(ctx, state2) {
|
|
9730
9795
|
return (0, import_lib3.$EVENT_C)(ctx, state2, "OperatorDeclaration", OperatorDeclaration$$);
|
|
9731
9796
|
}
|
|
9732
|
-
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) {
|
|
9733
|
-
var
|
|
9734
|
-
var
|
|
9735
|
-
var
|
|
9736
|
-
var
|
|
9737
|
-
var
|
|
9738
|
-
var
|
|
9739
|
-
var
|
|
9740
|
-
var
|
|
9797
|
+
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) {
|
|
9798
|
+
var async = $1;
|
|
9799
|
+
var op = $2;
|
|
9800
|
+
var func = $3;
|
|
9801
|
+
var generator = $4;
|
|
9802
|
+
var w1 = $5;
|
|
9803
|
+
var id = $6;
|
|
9804
|
+
var behavior = $7;
|
|
9805
|
+
var w2 = $8;
|
|
9806
|
+
var parameters = $9;
|
|
9807
|
+
var suffix = $10;
|
|
9808
|
+
if (!async)
|
|
9809
|
+
async = [];
|
|
9810
|
+
if (!generator)
|
|
9811
|
+
generator = [];
|
|
9741
9812
|
if (!func) {
|
|
9742
9813
|
func = { $loc: op.$loc, token: "function" };
|
|
9743
9814
|
} else {
|
|
@@ -9746,12 +9817,17 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Operator, (0,
|
|
|
9746
9817
|
return {
|
|
9747
9818
|
type: "FunctionSignature",
|
|
9748
9819
|
id,
|
|
9749
|
-
|
|
9820
|
+
name: id.name,
|
|
9750
9821
|
parameters,
|
|
9751
9822
|
returnType: suffix,
|
|
9752
|
-
|
|
9823
|
+
async,
|
|
9824
|
+
generator,
|
|
9825
|
+
modifier: {
|
|
9826
|
+
async: !!async.length,
|
|
9827
|
+
generator: !!generator.length
|
|
9828
|
+
},
|
|
9753
9829
|
block: null,
|
|
9754
|
-
children: [func, w1, id, w2, parameters, suffix],
|
|
9830
|
+
children: [async, func, generator, w1, id, w2, parameters, suffix],
|
|
9755
9831
|
behavior
|
|
9756
9832
|
};
|
|
9757
9833
|
});
|
|
@@ -9801,27 +9877,24 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
|
|
|
9801
9877
|
var suffix = $3;
|
|
9802
9878
|
var arrow = $5;
|
|
9803
9879
|
var block = $6;
|
|
9804
|
-
if (
|
|
9805
|
-
async =
|
|
9806
|
-
|
|
9807
|
-
let generator;
|
|
9808
|
-
if (hasYield(block)) {
|
|
9809
|
-
generator = "*";
|
|
9810
|
-
}
|
|
9880
|
+
if (!async)
|
|
9881
|
+
async = [];
|
|
9882
|
+
const generator = [];
|
|
9811
9883
|
return {
|
|
9812
9884
|
type: "FunctionExpression",
|
|
9813
9885
|
id: void 0,
|
|
9814
9886
|
parameters,
|
|
9815
9887
|
returnType: suffix,
|
|
9816
|
-
ts: false,
|
|
9817
9888
|
async,
|
|
9818
9889
|
generator,
|
|
9819
9890
|
block,
|
|
9820
9891
|
signature: {
|
|
9821
9892
|
name: void 0,
|
|
9893
|
+
async,
|
|
9894
|
+
generator,
|
|
9822
9895
|
modifier: {
|
|
9823
|
-
async: !!async,
|
|
9824
|
-
generator: !!generator
|
|
9896
|
+
async: !!async.length,
|
|
9897
|
+
generator: !!generator.length
|
|
9825
9898
|
},
|
|
9826
9899
|
returnType: suffix
|
|
9827
9900
|
},
|
|
@@ -16578,8 +16651,9 @@ var locationTable = function(input) {
|
|
|
16578
16651
|
const lines = [];
|
|
16579
16652
|
let line = 0;
|
|
16580
16653
|
let pos = 0;
|
|
16581
|
-
let
|
|
16582
|
-
while (
|
|
16654
|
+
let ref;
|
|
16655
|
+
while (ref = linesRe.exec(input)) {
|
|
16656
|
+
const result = ref;
|
|
16583
16657
|
pos += result[0].length;
|
|
16584
16658
|
lines[line++] = pos;
|
|
16585
16659
|
if (pos === input.length) {
|
|
@@ -16601,7 +16675,8 @@ var SourceMap = function(sourceString) {
|
|
|
16601
16675
|
const sm = {
|
|
16602
16676
|
lines: [[]],
|
|
16603
16677
|
line: 0,
|
|
16604
|
-
|
|
16678
|
+
colOffset: 0,
|
|
16679
|
+
// relative to previous entry
|
|
16605
16680
|
srcLine: 0,
|
|
16606
16681
|
srcColumn: 0,
|
|
16607
16682
|
srcOffset: 0,
|
|
@@ -16610,11 +16685,14 @@ var SourceMap = function(sourceString) {
|
|
|
16610
16685
|
const EOL2 = /\r?\n|\r/;
|
|
16611
16686
|
return {
|
|
16612
16687
|
data: sm,
|
|
16688
|
+
source: function() {
|
|
16689
|
+
return sourceString;
|
|
16690
|
+
},
|
|
16613
16691
|
renderMappings: function() {
|
|
16614
16692
|
let lastSourceLine = 0;
|
|
16615
16693
|
let lastSourceColumn = 0;
|
|
16616
|
-
return sm.lines.map(
|
|
16617
|
-
return line.map(
|
|
16694
|
+
return sm.lines.map((line) => {
|
|
16695
|
+
return line.map((entry) => {
|
|
16618
16696
|
if (entry.length === 4) {
|
|
16619
16697
|
let [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
|
|
16620
16698
|
const lineDelta = srcLine - lastSourceLine;
|
|
@@ -16651,25 +16729,25 @@ var SourceMap = function(sourceString) {
|
|
|
16651
16729
|
sm.srcColumn = srcCol;
|
|
16652
16730
|
sm.srcOffset = inputPos + outputStr.length;
|
|
16653
16731
|
}
|
|
16654
|
-
|
|
16732
|
+
for (let i1 = 0, len3 = outLines.length; i1 < len3; i1++) {
|
|
16733
|
+
const i = i1;
|
|
16734
|
+
const line = outLines[i1];
|
|
16655
16735
|
if (i > 0) {
|
|
16656
16736
|
sm.line++;
|
|
16657
16737
|
sm.srcLine++;
|
|
16658
|
-
sm.
|
|
16738
|
+
sm.colOffset = 0;
|
|
16659
16739
|
sm.lines[sm.line] = [];
|
|
16660
16740
|
sm.srcColumn = srcCol = colOffset;
|
|
16661
16741
|
}
|
|
16662
|
-
const l = sm.
|
|
16663
|
-
sm.
|
|
16742
|
+
const l = sm.colOffset;
|
|
16743
|
+
sm.colOffset = line.length;
|
|
16664
16744
|
sm.srcColumn += line.length;
|
|
16665
16745
|
if (inputPos != null) {
|
|
16666
|
-
|
|
16746
|
+
sm.lines[sm.line].push([l, 0, srcLine + i, srcCol]);
|
|
16667
16747
|
} else if (l != 0) {
|
|
16668
|
-
|
|
16748
|
+
sm.lines[sm.line].push([l]);
|
|
16669
16749
|
}
|
|
16670
|
-
|
|
16671
|
-
return;
|
|
16672
|
-
});
|
|
16750
|
+
}
|
|
16673
16751
|
return;
|
|
16674
16752
|
}
|
|
16675
16753
|
};
|
|
@@ -16693,8 +16771,8 @@ var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
|
|
|
16693
16771
|
return remappedCodeWithSourceMap;
|
|
16694
16772
|
};
|
|
16695
16773
|
var composeLines = function(upstreamMapping, lines) {
|
|
16696
|
-
return lines.map(
|
|
16697
|
-
return line.map(
|
|
16774
|
+
return lines.map((line) => {
|
|
16775
|
+
return line.map((entry) => {
|
|
16698
16776
|
if (entry.length === 1) {
|
|
16699
16777
|
return entry;
|
|
16700
16778
|
}
|
|
@@ -16715,11 +16793,11 @@ var parseWithLines = function(base64encodedJSONstr) {
|
|
|
16715
16793
|
const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
|
|
16716
16794
|
let sourceLine = 0;
|
|
16717
16795
|
let sourceColumn = 0;
|
|
16718
|
-
const lines = json.mappings.split(";").map(
|
|
16796
|
+
const lines = json.mappings.split(";").map((line) => {
|
|
16719
16797
|
if (line.length === 0) {
|
|
16720
16798
|
return [];
|
|
16721
16799
|
}
|
|
16722
|
-
return line.split(",").map(
|
|
16800
|
+
return line.split(",").map((entry) => {
|
|
16723
16801
|
const result = decodeVLQ(entry);
|
|
16724
16802
|
switch (result.length) {
|
|
16725
16803
|
case 1: {
|
|
@@ -16746,12 +16824,12 @@ var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
|
|
|
16746
16824
|
var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
|
|
16747
16825
|
var encodeVlq = function(value) {
|
|
16748
16826
|
let answer = "";
|
|
16749
|
-
let
|
|
16827
|
+
let ref1;
|
|
16750
16828
|
if (value < 0)
|
|
16751
|
-
|
|
16829
|
+
ref1 = 1;
|
|
16752
16830
|
else
|
|
16753
|
-
|
|
16754
|
-
const signBit =
|
|
16831
|
+
ref1 = 0;
|
|
16832
|
+
const signBit = ref1;
|
|
16755
16833
|
let valueToEncode = (Math.abs(value) << 1) + signBit;
|
|
16756
16834
|
while (valueToEncode || !answer) {
|
|
16757
16835
|
let nextChunk = valueToEncode & VLQ_VALUE_MASK;
|
|
@@ -16774,7 +16852,7 @@ var base64Encode = function(src) {
|
|
|
16774
16852
|
};
|
|
16775
16853
|
var vlqTable = new Uint8Array(128);
|
|
16776
16854
|
var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
16777
|
-
|
|
16855
|
+
{
|
|
16778
16856
|
let i = 0;
|
|
16779
16857
|
let l = vlqTable.length;
|
|
16780
16858
|
while (i < l) {
|
|
@@ -16783,14 +16861,11 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
|
|
|
16783
16861
|
}
|
|
16784
16862
|
i = 0;
|
|
16785
16863
|
l = vlqChars.length;
|
|
16786
|
-
const results = [];
|
|
16787
16864
|
while (i < l) {
|
|
16788
16865
|
vlqTable[vlqChars.charCodeAt(i)] = i;
|
|
16789
|
-
|
|
16866
|
+
i++;
|
|
16790
16867
|
}
|
|
16791
|
-
|
|
16792
|
-
return results;
|
|
16793
|
-
})();
|
|
16868
|
+
}
|
|
16794
16869
|
var decodeError = function(message) {
|
|
16795
16870
|
throw new Error(message);
|
|
16796
16871
|
};
|