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