@danielx/civet 0.6.30 → 0.6.32

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