@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/dist/main.js CHANGED
@@ -960,27 +960,49 @@ function assignResults(node, collect) {
960
960
  case "DebuggerStatement":
961
961
  case "EmptyStatement":
962
962
  case "ReturnStatement":
963
- case "ThrowStatement":
963
+ case "ThrowStatement": {
964
964
  return;
965
- case "Declaration":
965
+ }
966
+ case "Declaration": {
967
+ let ref5;
968
+ if (exp.bindings?.length) {
969
+ ref5 = patternAsValue((ref4 = exp.bindings)[ref4.length - 1].pattern);
970
+ } else {
971
+ ref5 = "void 0";
972
+ }
973
+ ;
974
+ const value = ref5;
966
975
  exp.children.push([
967
976
  "",
968
- [";", collect(patternAsValue((ref4 = exp.bindings)[ref4.length - 1].pattern))]
977
+ [";", collect(value)]
969
978
  ]);
970
979
  return;
980
+ }
981
+ case "FunctionExpression": {
982
+ if (exp.id) {
983
+ exp.children.push([
984
+ "",
985
+ [";", collect(exp.id)]
986
+ ]);
987
+ return;
988
+ }
989
+ break;
990
+ }
971
991
  case "ForStatement":
972
992
  case "IterationStatement":
973
993
  case "DoStatement":
974
- case "ComptimeStatement":
994
+ case "ComptimeStatement": {
975
995
  wrapIterationReturningResults(exp, outer, collect);
976
996
  return;
977
- case "BlockStatement":
997
+ }
998
+ case "BlockStatement": {
978
999
  if (node.expressions.some(isExit)) {
979
1000
  return;
980
1001
  }
981
1002
  assignResults(exp.expressions[exp.expressions.length - 1], collect);
982
1003
  return;
983
- case "IfStatement":
1004
+ }
1005
+ case "IfStatement": {
984
1006
  assignResults(exp.then, collect);
985
1007
  if (exp.then.bare && !exp.then.semicolon) {
986
1008
  exp.then.children.push(exp.then.semicolon = ";");
@@ -988,18 +1010,22 @@ function assignResults(node, collect) {
988
1010
  if (exp.else) {
989
1011
  assignResults(exp.else.block, collect);
990
1012
  } else {
991
- exp.children.push([" else {", collect("undefined"), "}"]);
1013
+ exp.children.push([" else {", collect("void 0"), "}"]);
992
1014
  }
993
1015
  return;
994
- case "PatternMatchingStatement":
1016
+ }
1017
+ case "PatternMatchingStatement": {
995
1018
  assignResults(exp.children[0], collect);
996
1019
  return;
997
- case "SwitchStatement":
1020
+ }
1021
+ case "SwitchStatement": {
998
1022
  assignResults(exp.children[2], collect);
999
1023
  return;
1000
- case "TryStatement":
1024
+ }
1025
+ case "TryStatement": {
1001
1026
  exp.blocks.forEach((block) => assignResults(block, collect));
1002
1027
  return;
1028
+ }
1003
1029
  }
1004
1030
  if (node[node.length - 1]?.type === "SemicolonDelimiter") {
1005
1031
  return;
@@ -1010,7 +1036,7 @@ function insertReturn(node, outerNode = node) {
1010
1036
  if (!node)
1011
1037
  return;
1012
1038
  switch (node.type) {
1013
- case "BlockStatement":
1039
+ case "BlockStatement": {
1014
1040
  if (node.expressions.length) {
1015
1041
  if (node.expressions.some(([, exp2]) => isExit(exp2))) {
1016
1042
  return;
@@ -1023,7 +1049,8 @@ function insertReturn(node, outerNode = node) {
1023
1049
  }
1024
1050
  }
1025
1051
  return;
1026
- case "WhenClause":
1052
+ }
1053
+ case "WhenClause": {
1027
1054
  if (node.break) {
1028
1055
  node.children.splice(node.children.indexOf(node.break), 1);
1029
1056
  }
@@ -1033,9 +1060,11 @@ function insertReturn(node, outerNode = node) {
1033
1060
  node.block.expressions.push(wrapWithReturn());
1034
1061
  }
1035
1062
  return;
1036
- case "DefaultClause":
1063
+ }
1064
+ case "DefaultClause": {
1037
1065
  insertReturn(node.block);
1038
1066
  return;
1067
+ }
1039
1068
  }
1040
1069
  if (!Array.isArray(node))
1041
1070
  return;
@@ -1055,23 +1084,36 @@ function insertReturn(node, outerNode = node) {
1055
1084
  exp = exp.statement;
1056
1085
  ({ type } = exp);
1057
1086
  }
1058
- let ref5;
1087
+ let ref6;
1059
1088
  switch (type) {
1060
1089
  case "BreakStatement":
1061
1090
  case "ContinueStatement":
1062
1091
  case "DebuggerStatement":
1063
1092
  case "EmptyStatement":
1064
1093
  case "ReturnStatement":
1065
- case "ThrowStatement":
1094
+ case "ThrowStatement": {
1066
1095
  return;
1067
- case "Declaration":
1096
+ }
1097
+ case "Declaration": {
1098
+ let ref7;
1099
+ if (exp.bindings?.length) {
1100
+ ref7 = [" ", patternAsValue((ref6 = exp.bindings)[ref6.length - 1].pattern)];
1101
+ } else {
1102
+ ref7 = [];
1103
+ }
1104
+ ;
1105
+ const value = ref7;
1068
1106
  exp.children.push(["", {
1069
1107
  type: "ReturnStatement",
1070
- children: [";return ", patternAsValue((ref5 = exp.bindings)[ref5.length - 1].pattern)],
1108
+ children: [
1109
+ ";return",
1110
+ ...value
1111
+ ],
1071
1112
  parent: exp
1072
1113
  }]);
1073
1114
  return;
1074
- case "FunctionExpression":
1115
+ }
1116
+ case "FunctionExpression": {
1075
1117
  if (exp.id) {
1076
1118
  exp.children.push([
1077
1119
  "",
@@ -1084,16 +1126,19 @@ function insertReturn(node, outerNode = node) {
1084
1126
  return;
1085
1127
  }
1086
1128
  break;
1129
+ }
1087
1130
  case "ForStatement":
1088
1131
  case "IterationStatement":
1089
1132
  case "DoStatement":
1090
- case "ComptimeStatement":
1133
+ case "ComptimeStatement": {
1091
1134
  wrapIterationReturningResults(exp, outer);
1092
1135
  return;
1093
- case "BlockStatement":
1136
+ }
1137
+ case "BlockStatement": {
1094
1138
  insertReturn(exp.expressions[exp.expressions.length - 1]);
1095
1139
  return;
1096
- case "IfStatement":
1140
+ }
1141
+ case "IfStatement": {
1097
1142
  insertReturn(exp.then);
1098
1143
  if (exp.else)
1099
1144
  insertReturn(exp.else.block);
@@ -1105,18 +1150,23 @@ function insertReturn(node, outerNode = node) {
1105
1150
  parent: exp
1106
1151
  }]);
1107
1152
  return;
1108
- case "PatternMatchingStatement":
1153
+ }
1154
+ case "PatternMatchingStatement": {
1109
1155
  insertReturn(exp.children[0]);
1110
1156
  return;
1111
- case "SwitchStatement":
1157
+ }
1158
+ case "SwitchStatement": {
1112
1159
  insertSwitchReturns(exp);
1113
1160
  return;
1114
- case "TryStatement":
1161
+ }
1162
+ case "TryStatement": {
1115
1163
  exp.blocks.forEach((block) => insertReturn(block));
1116
1164
  return;
1165
+ }
1117
1166
  }
1118
- if (node[node.length - 1]?.type === "SemicolonDelimiter")
1167
+ if (node[node.length - 1]?.type === "SemicolonDelimiter") {
1119
1168
  return;
1169
+ }
1120
1170
  const returnStatement = wrapWithReturn(node[1]);
1121
1171
  node.splice(1, 1, returnStatement);
1122
1172
  }
@@ -1205,10 +1255,33 @@ function processParams(f) {
1205
1255
  }
1206
1256
  expressions.unshift(...prefix);
1207
1257
  }
1258
+ function processSignature(f) {
1259
+ const { block, signature } = f;
1260
+ if (hasAwait(block) && !f.async?.length) {
1261
+ f.async.push("async ");
1262
+ signature.modifier.async = true;
1263
+ }
1264
+ if (hasYield(block) && !f.generator?.length) {
1265
+ if (f.type === "ArrowFunction") {
1266
+ gatherRecursiveWithinFunction(block, ($) => $.type === "YieldExpression").forEach((y) => {
1267
+ const i = y.children.findIndex(($1) => $1.type === "Yield");
1268
+ return y.children.splice(i + 1, 0, {
1269
+ type: "Error",
1270
+ message: "Can't use yield inside of => arrow function"
1271
+ });
1272
+ });
1273
+ } else {
1274
+ f.generator.push("*");
1275
+ signature.modifier.generator = true;
1276
+ }
1277
+ }
1278
+ }
1208
1279
  function processFunctions(statements, config2) {
1209
1280
  gatherRecursiveAll(statements, ({ type }) => type === "FunctionExpression" || type === "ArrowFunction").forEach((f) => {
1210
- if (f.type === "FunctionExpression")
1281
+ if (f.type === "FunctionExpression") {
1211
1282
  implicitFunctionBlock(f);
1283
+ }
1284
+ processSignature(f);
1212
1285
  processParams(f);
1213
1286
  return processReturn(f, config2.implicitReturns);
1214
1287
  });
@@ -1265,12 +1338,12 @@ function processCoffeeDo(ws, expression) {
1265
1338
  ...parameters,
1266
1339
  children: (() => {
1267
1340
  const results = [];
1268
- for (let ref6 = parameters.children, i1 = 0, len3 = ref6.length; i1 < len3; i1++) {
1269
- let parameter = ref6[i1];
1341
+ for (let ref8 = parameters.children, i1 = 0, len3 = ref8.length; i1 < len3; i1++) {
1342
+ let parameter = ref8[i1];
1270
1343
  if (typeof parameter === "object" && parameter != null && "type" in parameter && parameter.type === "Parameter") {
1271
- let ref7;
1272
- if (ref7 = parameter.initializer) {
1273
- const initializer = ref7;
1344
+ let ref9;
1345
+ if (ref9 = parameter.initializer) {
1346
+ const initializer = ref9;
1274
1347
  args.push(initializer.expression, parameter.delim);
1275
1348
  parameter = {
1276
1349
  ...parameter,
@@ -1291,7 +1364,7 @@ function processCoffeeDo(ws, expression) {
1291
1364
  expression = {
1292
1365
  ...expression,
1293
1366
  parameters: newParameters,
1294
- children: expression.children.map(($) => $ === parameters ? newParameters : $)
1367
+ children: expression.children.map(($2) => $2 === parameters ? newParameters : $2)
1295
1368
  };
1296
1369
  }
1297
1370
  return {
@@ -1306,6 +1379,52 @@ function processCoffeeDo(ws, expression) {
1306
1379
  ]
1307
1380
  };
1308
1381
  }
1382
+ function makeAmpersandFunction(rhs) {
1383
+ let { ref, typeSuffix, body } = rhs;
1384
+ if (!(ref != null)) {
1385
+ ref = makeRef("$");
1386
+ inplacePrepend(ref, body);
1387
+ }
1388
+ if (body?.type === "ObjectExpression") {
1389
+ body = makeLeftHandSideExpression(body);
1390
+ }
1391
+ const parameters = makeNode({
1392
+ type: "Parameters",
1393
+ children: typeSuffix ? ["(", ref, typeSuffix, ")"] : [ref],
1394
+ names: []
1395
+ });
1396
+ const expressions = [[" ", body]];
1397
+ const block = makeNode({
1398
+ type: "BlockStatement",
1399
+ bare: true,
1400
+ expressions,
1401
+ children: [expressions],
1402
+ implicitlyReturned: true
1403
+ });
1404
+ const async = [];
1405
+ const children = [async, parameters, " =>", block];
1406
+ const fn = makeNode({
1407
+ type: "ArrowFunction",
1408
+ async,
1409
+ signature: {
1410
+ modifier: {
1411
+ async: !!async
1412
+ }
1413
+ },
1414
+ children,
1415
+ ref,
1416
+ block,
1417
+ parameters,
1418
+ ampersandBlock: true,
1419
+ body
1420
+ });
1421
+ if (isStatement(body)) {
1422
+ braceBlock(block);
1423
+ fn.ampersandBlock = false;
1424
+ delete fn.body;
1425
+ }
1426
+ return fn;
1427
+ }
1309
1428
 
1310
1429
  // source/parser/block.civet
1311
1430
  function blockWithPrefix(prefixStatements, block) {
@@ -1529,8 +1648,8 @@ function addParentPointers(node, parent) {
1529
1648
  node.parent = parent;
1530
1649
  }
1531
1650
  if (node.children) {
1532
- for (let ref1 = node.children, i1 = 0, len1 = ref1.length; i1 < len1; i1++) {
1533
- const child = ref1[i1];
1651
+ for (let ref = node.children, i1 = 0, len1 = ref.length; i1 < len1; i1++) {
1652
+ const child = ref[i1];
1534
1653
  addParentPointers(child, node);
1535
1654
  }
1536
1655
  }
@@ -1812,13 +1931,13 @@ function startsWith(target, value) {
1812
1931
  return;
1813
1932
  }
1814
1933
  function hasAwait(exp) {
1815
- return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Await").length > 0;
1934
+ return gatherRecursiveWithinFunction(exp, ($1) => $1.type === "Await").length > 0;
1816
1935
  }
1817
1936
  function hasYield(exp) {
1818
- return gatherRecursiveWithinFunction(exp, ({ type }) => type === "Yield").length > 0;
1937
+ return gatherRecursiveWithinFunction(exp, ($2) => $2.type === "Yield").length > 0;
1819
1938
  }
1820
1939
  function hasImportDeclaration(exp) {
1821
- return gatherRecursiveWithinFunction(exp, ({ type }) => type === "ImportDeclaration").length > 0;
1940
+ return gatherRecursiveWithinFunction(exp, ($3) => $3.type === "ImportDeclaration").length > 0;
1822
1941
  }
1823
1942
  function deepCopy(node) {
1824
1943
  if (node == null)
@@ -1856,54 +1975,6 @@ function removeHoistDecs(node) {
1856
1975
  }
1857
1976
  }
1858
1977
  }
1859
- function makeAmpersandFunction(rhs) {
1860
- let { ref, typeSuffix, body } = rhs;
1861
- if (!(ref != null)) {
1862
- ref = makeRef("$");
1863
- inplacePrepend(ref, body);
1864
- }
1865
- if (body?.type === "ObjectExpression") {
1866
- body = makeLeftHandSideExpression(body);
1867
- }
1868
- const parameters = makeNode({
1869
- type: "Parameters",
1870
- children: typeSuffix ? ["(", ref, typeSuffix, ")"] : [ref],
1871
- names: []
1872
- });
1873
- const expressions = [[" ", body]];
1874
- const block = makeNode({
1875
- type: "BlockStatement",
1876
- bare: true,
1877
- expressions,
1878
- children: [expressions],
1879
- implicitlyReturned: true
1880
- });
1881
- const children = [parameters, " =>", block];
1882
- const async = hasAwait(body);
1883
- if (async) {
1884
- children.unshift("async ");
1885
- }
1886
- const fn = makeNode({
1887
- type: "ArrowFunction",
1888
- signature: {
1889
- modifier: {
1890
- async
1891
- }
1892
- },
1893
- children,
1894
- ref,
1895
- block,
1896
- parameters,
1897
- ampersandBlock: true,
1898
- body
1899
- });
1900
- if (isStatement(body)) {
1901
- braceBlock(block);
1902
- fn.ampersandBlock = false;
1903
- delete fn.body;
1904
- }
1905
- return fn;
1906
- }
1907
1978
  var skipParens = /* @__PURE__ */ new Set([
1908
1979
  "AmpersandRef",
1909
1980
  "CallExpression",
@@ -1954,8 +2025,8 @@ function updateParentPointers(node, parent, depth = 1) {
1954
2025
  node.parent = parent;
1955
2026
  }
1956
2027
  if (depth && isParent(node)) {
1957
- for (let ref2 = node.children, i3 = 0, len3 = ref2.length; i3 < len3; i3++) {
1958
- const child = ref2[i3];
2028
+ for (let ref1 = node.children, i3 = 0, len3 = ref1.length; i3 < len3; i3++) {
2029
+ const child = ref1[i3];
1959
2030
  updateParentPointers(child, node, depth - 1);
1960
2031
  }
1961
2032
  }
@@ -2026,11 +2097,11 @@ function parenthesizeType(type) {
2026
2097
  }
2027
2098
  function wrapIIFE(expressions, asyncFlag) {
2028
2099
  let prefix;
2029
- let async;
2100
+ const async = [];
2030
2101
  if (asyncFlag) {
2031
- async = "async ";
2102
+ async.push("async ");
2032
2103
  } else if (hasAwait(expressions)) {
2033
- async = "async ";
2104
+ async.push("async ");
2034
2105
  prefix = {
2035
2106
  type: "Await",
2036
2107
  children: ["await "]
@@ -2041,8 +2112,7 @@ function wrapIIFE(expressions, asyncFlag) {
2041
2112
  expressions,
2042
2113
  children: ["{", expressions, "}"],
2043
2114
  bare: false,
2044
- root: false,
2045
- parent: void 0
2115
+ root: false
2046
2116
  });
2047
2117
  const parameters = {
2048
2118
  type: "Parameters",
@@ -2051,7 +2121,7 @@ function wrapIIFE(expressions, asyncFlag) {
2051
2121
  };
2052
2122
  const signature = {
2053
2123
  modifier: {
2054
- async: !!async
2124
+ async: !!async.length
2055
2125
  },
2056
2126
  returnType: void 0
2057
2127
  };
@@ -2394,8 +2464,6 @@ function processBinaryOpExpression($0) {
2394
2464
  }
2395
2465
  return expandedOps;
2396
2466
  }
2397
- ;
2398
- return recurse;
2399
2467
  }
2400
2468
  function dotNumericLiteral(literal) {
2401
2469
  if (literal?.type === "Literal" && /^[+-]?(?:0|[1-9](?:_[0-9]|[0-9])*)$/.test(literal.raw)) {
@@ -2912,7 +2980,13 @@ function getPatternBlockPrefix(pattern, ref, decl = "const ", suffix) {
2912
2980
  thisAssignments = thisAssignments.map(($6) => ["", $6, ";"]);
2913
2981
  const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
2914
2982
  return [
2915
- ["", [decl, patternBindings, suffix, " = ", ref, ...splices], ";"],
2983
+ ["", {
2984
+ type: "Declaration",
2985
+ children: [decl, patternBindings, suffix, " = ", ref, ...splices],
2986
+ names: [],
2987
+ bindings: []
2988
+ // avoid implicit return of any bindings
2989
+ }, ";"],
2916
2990
  ...thisAssignments,
2917
2991
  ...duplicateDeclarations.map(($7) => ["", $7, ";"])
2918
2992
  ];
@@ -3060,9 +3134,18 @@ function aggregateDuplicateBindings(bindings) {
3060
3134
  aliasBinding(p, ref);
3061
3135
  return ref;
3062
3136
  });
3063
- return declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
3064
- return i === 0 ? r : [", ", r];
3065
- }), "]"]);
3137
+ return declarations.push({
3138
+ type: "Declaration",
3139
+ children: [
3140
+ "const ",
3141
+ key,
3142
+ " = [",
3143
+ ...refs.map((r, i) => i === 0 ? r : [", ", r]),
3144
+ "]"
3145
+ ],
3146
+ names: [],
3147
+ bindings: []
3148
+ });
3066
3149
  });
3067
3150
  return declarations;
3068
3151
  }
@@ -3553,8 +3636,7 @@ function processUnaryExpression(pre, exp, post) {
3553
3636
  token: " != null"
3554
3637
  };
3555
3638
  if (pre.length) {
3556
- let ref;
3557
- const lastPre = (ref = pre)[ref.length - 1];
3639
+ const lastPre = pre[pre.length - 1];
3558
3640
  if (lastPre.token === "!") {
3559
3641
  post.token = " == null";
3560
3642
  pre = pre.slice(0, -1);
@@ -3598,9 +3680,9 @@ function processUnaryExpression(pre, exp, post) {
3598
3680
  }
3599
3681
  }
3600
3682
  }
3601
- let ref1;
3602
- while (ref1 = pre.length) {
3603
- const l = ref1;
3683
+ let ref;
3684
+ while (ref = pre.length) {
3685
+ const l = ref;
3604
3686
  const last = pre[l - 1];
3605
3687
  if (last.type === "Await") {
3606
3688
  if (last.op) {
@@ -4254,8 +4336,6 @@ function gen(root, options) {
4254
4336
  debugger;
4255
4337
  throw new Error(`Unknown node ${stringify(node)}`);
4256
4338
  }
4257
- ;
4258
- return recurse;
4259
4339
  }
4260
4340
  var generate_default = gen;
4261
4341
  function prune(node) {
@@ -4831,8 +4911,11 @@ function expressionizeBlock(blockOrExpression) {
4831
4911
  }
4832
4912
  if (results.length > 1) {
4833
4913
  return makeLeftHandSideExpression(results);
4914
+ } else if (results.length) {
4915
+ return results;
4916
+ } else {
4917
+ return ["void 0"];
4834
4918
  }
4835
- return results;
4836
4919
  } else {
4837
4920
  return blockOrExpression;
4838
4921
  }
@@ -4859,10 +4942,10 @@ function expressionizeIfStatement(statement) {
4859
4942
  children.push(":void 0");
4860
4943
  }
4861
4944
  children.push(closeParen);
4862
- return {
4945
+ return makeNode({
4863
4946
  type: "IfExpression",
4864
4947
  children
4865
- };
4948
+ });
4866
4949
  }
4867
4950
  function expressionizeTypeIf([ws, ifOp, condition, t, e]) {
4868
4951
  const children = [
@@ -7884,16 +7967,8 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
7884
7967
  var suffix = $3;
7885
7968
  var arrow = $4;
7886
7969
  var expOrBlock = $5;
7887
- if (hasAwait(expOrBlock) && !async) {
7888
- async = "async ";
7889
- }
7890
- let error;
7891
- if (hasYield(expOrBlock)) {
7892
- error = {
7893
- type: "Error",
7894
- message: "Can't use yield inside of => arrow function"
7895
- };
7896
- }
7970
+ if (!async)
7971
+ async = [];
7897
7972
  return {
7898
7973
  type: "ArrowFunction",
7899
7974
  signature: {
@@ -7904,10 +7979,9 @@ var ArrowFunction$1 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_lib3.$
7904
7979
  },
7905
7980
  parameters,
7906
7981
  returnType: suffix,
7907
- ts: false,
7908
7982
  async,
7909
7983
  block: expOrBlock,
7910
- children: [async, parameters, suffix, arrow, error, expOrBlock]
7984
+ children: [async, parameters, suffix, arrow, expOrBlock]
7911
7985
  };
7912
7986
  });
7913
7987
  var ArrowFunction$$ = [ArrowFunction$0, ArrowFunction$1];
@@ -9544,7 +9618,6 @@ var FunctionSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
9544
9618
  name: id?.name,
9545
9619
  parameters,
9546
9620
  returnType: suffix,
9547
- ts: false,
9548
9621
  async,
9549
9622
  generator,
9550
9623
  modifier: {
@@ -9570,14 +9643,6 @@ var FunctionExpression$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(FunctionSign
9570
9643
  ts: true
9571
9644
  };
9572
9645
  }
9573
- if (hasAwait(block) && !signature.async.length) {
9574
- signature.async.push("async ");
9575
- signature.modifier.async = true;
9576
- }
9577
- if (hasYield(block) && !signature.generator.length) {
9578
- signature.generator.push("*");
9579
- signature.modifier.generator = true;
9580
- }
9581
9646
  return {
9582
9647
  ...signature,
9583
9648
  type: "FunctionExpression",
@@ -9749,15 +9814,21 @@ var OperatorDeclaration$$ = [OperatorDeclaration$0, OperatorDeclaration$1, Opera
9749
9814
  function OperatorDeclaration(ctx, state2) {
9750
9815
  return (0, import_lib3.$EVENT_C)(ctx, state2, "OperatorDeclaration", OperatorDeclaration$$);
9751
9816
  }
9752
- 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) {
9753
- var op = $1;
9754
- var func = $2;
9755
- var w1 = $3;
9756
- var id = $4;
9757
- var behavior = $5;
9758
- var w2 = $6;
9759
- var parameters = $7;
9760
- var suffix = $8;
9817
+ 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) {
9818
+ var async = $1;
9819
+ var op = $2;
9820
+ var func = $3;
9821
+ var generator = $4;
9822
+ var w1 = $5;
9823
+ var id = $6;
9824
+ var behavior = $7;
9825
+ var w2 = $8;
9826
+ var parameters = $9;
9827
+ var suffix = $10;
9828
+ if (!async)
9829
+ async = [];
9830
+ if (!generator)
9831
+ generator = [];
9761
9832
  if (!func) {
9762
9833
  func = { $loc: op.$loc, token: "function" };
9763
9834
  } else {
@@ -9766,12 +9837,17 @@ var OperatorSignature$0 = (0, import_lib3.$TS)((0, import_lib3.$S)(Operator, (0,
9766
9837
  return {
9767
9838
  type: "FunctionSignature",
9768
9839
  id,
9769
- modifier: {},
9840
+ name: id.name,
9770
9841
  parameters,
9771
9842
  returnType: suffix,
9772
- ts: false,
9843
+ async,
9844
+ generator,
9845
+ modifier: {
9846
+ async: !!async.length,
9847
+ generator: !!generator.length
9848
+ },
9773
9849
  block: null,
9774
- children: [func, w1, id, w2, parameters, suffix],
9850
+ children: [async, func, generator, w1, id, w2, parameters, suffix],
9775
9851
  behavior
9776
9852
  };
9777
9853
  });
@@ -9821,27 +9897,24 @@ var ThinArrowFunction$0 = (0, import_lib3.$TS)((0, import_lib3.$S)((0, import_li
9821
9897
  var suffix = $3;
9822
9898
  var arrow = $5;
9823
9899
  var block = $6;
9824
- if (hasAwait(block) && !async) {
9825
- async = "async ";
9826
- }
9827
- let generator;
9828
- if (hasYield(block)) {
9829
- generator = "*";
9830
- }
9900
+ if (!async)
9901
+ async = [];
9902
+ const generator = [];
9831
9903
  return {
9832
9904
  type: "FunctionExpression",
9833
9905
  id: void 0,
9834
9906
  parameters,
9835
9907
  returnType: suffix,
9836
- ts: false,
9837
9908
  async,
9838
9909
  generator,
9839
9910
  block,
9840
9911
  signature: {
9841
9912
  name: void 0,
9913
+ async,
9914
+ generator,
9842
9915
  modifier: {
9843
- async: !!async,
9844
- generator: !!generator
9916
+ async: !!async.length,
9917
+ generator: !!generator.length
9845
9918
  },
9846
9919
  returnType: suffix
9847
9920
  },
@@ -16598,8 +16671,9 @@ var locationTable = function(input) {
16598
16671
  const lines = [];
16599
16672
  let line = 0;
16600
16673
  let pos = 0;
16601
- let result;
16602
- while (result = linesRe.exec(input)) {
16674
+ let ref;
16675
+ while (ref = linesRe.exec(input)) {
16676
+ const result = ref;
16603
16677
  pos += result[0].length;
16604
16678
  lines[line++] = pos;
16605
16679
  if (pos === input.length) {
@@ -16621,7 +16695,8 @@ var SourceMap = function(sourceString) {
16621
16695
  const sm = {
16622
16696
  lines: [[]],
16623
16697
  line: 0,
16624
- column: 0,
16698
+ colOffset: 0,
16699
+ // relative to previous entry
16625
16700
  srcLine: 0,
16626
16701
  srcColumn: 0,
16627
16702
  srcOffset: 0,
@@ -16630,11 +16705,14 @@ var SourceMap = function(sourceString) {
16630
16705
  const EOL2 = /\r?\n|\r/;
16631
16706
  return {
16632
16707
  data: sm,
16708
+ source: function() {
16709
+ return sourceString;
16710
+ },
16633
16711
  renderMappings: function() {
16634
16712
  let lastSourceLine = 0;
16635
16713
  let lastSourceColumn = 0;
16636
- return sm.lines.map(function(line) {
16637
- return line.map(function(entry) {
16714
+ return sm.lines.map((line) => {
16715
+ return line.map((entry) => {
16638
16716
  if (entry.length === 4) {
16639
16717
  let [colDelta, sourceFileIndex, srcLine, srcCol] = entry;
16640
16718
  const lineDelta = srcLine - lastSourceLine;
@@ -16671,25 +16749,25 @@ var SourceMap = function(sourceString) {
16671
16749
  sm.srcColumn = srcCol;
16672
16750
  sm.srcOffset = inputPos + outputStr.length;
16673
16751
  }
16674
- outLines.forEach(function(line, i) {
16752
+ for (let i1 = 0, len3 = outLines.length; i1 < len3; i1++) {
16753
+ const i = i1;
16754
+ const line = outLines[i1];
16675
16755
  if (i > 0) {
16676
16756
  sm.line++;
16677
16757
  sm.srcLine++;
16678
- sm.column = 0;
16758
+ sm.colOffset = 0;
16679
16759
  sm.lines[sm.line] = [];
16680
16760
  sm.srcColumn = srcCol = colOffset;
16681
16761
  }
16682
- const l = sm.column;
16683
- sm.column += line.length;
16762
+ const l = sm.colOffset;
16763
+ sm.colOffset = line.length;
16684
16764
  sm.srcColumn += line.length;
16685
16765
  if (inputPos != null) {
16686
- return sm.lines[sm.line].push([l, 0, srcLine + i, srcCol]);
16766
+ sm.lines[sm.line].push([l, 0, srcLine + i, srcCol]);
16687
16767
  } else if (l != 0) {
16688
- return sm.lines[sm.line].push([l]);
16768
+ sm.lines[sm.line].push([l]);
16689
16769
  }
16690
- ;
16691
- return;
16692
- });
16770
+ }
16693
16771
  return;
16694
16772
  }
16695
16773
  };
@@ -16713,8 +16791,8 @@ var remap = function(codeWithSourceMap, upstreamMap, sourcePath, targetPath) {
16713
16791
  return remappedCodeWithSourceMap;
16714
16792
  };
16715
16793
  var composeLines = function(upstreamMapping, lines) {
16716
- return lines.map(function(line) {
16717
- return line.map(function(entry) {
16794
+ return lines.map((line) => {
16795
+ return line.map((entry) => {
16718
16796
  if (entry.length === 1) {
16719
16797
  return entry;
16720
16798
  }
@@ -16735,11 +16813,11 @@ var parseWithLines = function(base64encodedJSONstr) {
16735
16813
  const json = JSON.parse(Buffer.from(base64encodedJSONstr, "base64").toString("utf8"));
16736
16814
  let sourceLine = 0;
16737
16815
  let sourceColumn = 0;
16738
- const lines = json.mappings.split(";").map(function(line) {
16816
+ const lines = json.mappings.split(";").map((line) => {
16739
16817
  if (line.length === 0) {
16740
16818
  return [];
16741
16819
  }
16742
- return line.split(",").map(function(entry) {
16820
+ return line.split(",").map((entry) => {
16743
16821
  const result = decodeVLQ(entry);
16744
16822
  switch (result.length) {
16745
16823
  case 1: {
@@ -16766,12 +16844,12 @@ var VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
16766
16844
  var VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
16767
16845
  var encodeVlq = function(value) {
16768
16846
  let answer = "";
16769
- let ref;
16847
+ let ref1;
16770
16848
  if (value < 0)
16771
- ref = 1;
16849
+ ref1 = 1;
16772
16850
  else
16773
- ref = 0;
16774
- const signBit = ref;
16851
+ ref1 = 0;
16852
+ const signBit = ref1;
16775
16853
  let valueToEncode = (Math.abs(value) << 1) + signBit;
16776
16854
  while (valueToEncode || !answer) {
16777
16855
  let nextChunk = valueToEncode & VLQ_VALUE_MASK;
@@ -16794,7 +16872,7 @@ var base64Encode = function(src) {
16794
16872
  };
16795
16873
  var vlqTable = new Uint8Array(128);
16796
16874
  var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
16797
- (function() {
16875
+ {
16798
16876
  let i = 0;
16799
16877
  let l = vlqTable.length;
16800
16878
  while (i < l) {
@@ -16803,14 +16881,11 @@ var vlqChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/
16803
16881
  }
16804
16882
  i = 0;
16805
16883
  l = vlqChars.length;
16806
- const results = [];
16807
16884
  while (i < l) {
16808
16885
  vlqTable[vlqChars.charCodeAt(i)] = i;
16809
- results.push(i++);
16886
+ i++;
16810
16887
  }
16811
- ;
16812
- return results;
16813
- })();
16888
+ }
16814
16889
  var decodeError = function(message) {
16815
16890
  throw new Error(message);
16816
16891
  };