@danielx/civet 0.6.31 → 0.6.33

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/browser.js CHANGED
@@ -23,6 +23,10 @@ var Civet = (() => {
23
23
  return to;
24
24
  };
25
25
  var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
+ // If the importer is in node compatibility mode or this is not an ESM
27
+ // file that has been converted to a CommonJS file using a Babel-
28
+ // compatible transform (i.e. "__esModule" has not been set), then set
29
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
30
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
31
  mod
28
32
  ));
@@ -523,9 +527,10 @@ ${input.slice(result.pos)}
523
527
  }
524
528
  function addPostfixStatement(statement, ws, post) {
525
529
  let children, expressions;
526
- if (post.blockPrefix?.length) {
527
- let indent = post.blockPrefix[0][0];
528
- expressions = [...post.blockPrefix, [indent, statement]];
530
+ const prefix = post.blockPrefix || post.condition?.expression.blockPrefix;
531
+ if (prefix?.length) {
532
+ const indent = prefix[0][0];
533
+ expressions = [...prefix, [indent, statement]];
529
534
  children = [" {\n", ...expressions, "\n", indent?.slice?.(0, -2), "}"];
530
535
  } else {
531
536
  expressions = [["", statement]];
@@ -604,6 +609,7 @@ ${input.slice(result.pos)}
604
609
  children: [...elements.slice(0, restIndex), {
605
610
  ...rest,
606
611
  children: rest.children.slice(0, -1)
612
+ // remove trailing comma
607
613
  }],
608
614
  blockPrefix,
609
615
  length
@@ -648,7 +654,9 @@ ${input.slice(result.pos)}
648
654
  if (prefixStatements && prefixStatements.length) {
649
655
  const indent = getIndent(block.expressions[0]);
650
656
  if (indent) {
651
- prefixStatements = prefixStatements.map((statement) => [indent, ...statement.slice(1)]);
657
+ prefixStatements = prefixStatements.map((statement) => {
658
+ return [indent, ...statement.slice(1)];
659
+ });
652
660
  }
653
661
  const expressions = [...prefixStatements, ...block.expressions];
654
662
  block = {
@@ -833,7 +841,8 @@ ${input.slice(result.pos)}
833
841
  ...wrapIIFE([
834
842
  ["", ["const ", resultsRef, "=[]"], ";"],
835
843
  ...children,
836
- ["", ["; return ", resultsRef]]
844
+ ["", "; "],
845
+ ["", wrapWithReturn(resultsRef)]
837
846
  ], async)
838
847
  );
839
848
  }
@@ -948,6 +957,7 @@ ${input.slice(result.pos)}
948
957
  part.children[3]?.token === ":" ? part.children[3] : ":",
949
958
  value,
950
959
  part.delim
960
+ // comma delimiter
951
961
  ]
952
962
  });
953
963
  }
@@ -956,8 +966,10 @@ ${input.slice(result.pos)}
956
966
  type: "ObjectExpression",
957
967
  children: [
958
968
  glob.object.children[0],
969
+ // {
959
970
  ...parts,
960
971
  glob.object.children.at(-1)
972
+ // whitespace and }
961
973
  ],
962
974
  properties: parts,
963
975
  hoistDec
@@ -972,12 +984,14 @@ ${input.slice(result.pos)}
972
984
  if (i === children.length - 1)
973
985
  return object;
974
986
  return processCallMemberExpression({
987
+ // in case there are more
975
988
  ...node,
976
989
  children: [object, ...children.slice(i + 1)]
977
990
  });
978
991
  } else if (glob?.type === "PropertyBind") {
979
992
  const prefix = children.slice(0, i);
980
993
  return processCallMemberExpression({
994
+ // in case there are more
981
995
  ...node,
982
996
  children: [
983
997
  prefix,
@@ -1113,35 +1127,41 @@ ${input.slice(result.pos)}
1113
1127
  ;
1114
1128
  return;
1115
1129
  }
1130
+ var relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
1131
+ function isRelationalOp(op) {
1132
+ return relationalOps.includes(op.token) || op.relational;
1133
+ }
1116
1134
  function expandChainedComparisons([first, binops]) {
1117
- const relationalOps = ["==", "===", "!=", "!==", "<", "<=", ">", ">=", "in"];
1118
1135
  const lowerPrecedenceOps = ["??", "&&", "||", "&", "|", "^"];
1119
- let results = [];
1136
+ const results = [];
1120
1137
  let i = 0;
1121
1138
  const l = binops.length;
1122
1139
  let start = 0;
1123
1140
  let chains = [];
1141
+ let op;
1124
1142
  while (i < l) {
1125
- const [, op] = binops[i];
1126
- if (relationalOps.includes(op.token) || op.relational) {
1143
+ [, op] = binops[i];
1144
+ if (isRelationalOp(op)) {
1127
1145
  chains.push(i);
1128
1146
  } else if (lowerPrecedenceOps.includes(op.token)) {
1129
- processChains();
1147
+ processChains(op);
1130
1148
  first = [];
1131
1149
  }
1132
1150
  i++;
1133
1151
  }
1134
- processChains();
1152
+ processChains(op);
1135
1153
  return results;
1136
- function processChains() {
1137
- first = expandExistence(first);
1154
+ function processChains(op2) {
1155
+ if (isRelationalOp(op2)) {
1156
+ first = expandExistence(first);
1157
+ }
1138
1158
  if (chains.length > 1) {
1139
1159
  chains.forEach((index, k) => {
1140
1160
  if (k > 0) {
1141
1161
  results.push(" ", "&&", " ");
1142
1162
  }
1143
1163
  const binop = binops[index];
1144
- let [pre, op, post, exp] = binop;
1164
+ let [pre, op3, post, exp] = binop;
1145
1165
  exp = binop[3] = expandExistence(exp);
1146
1166
  let endIndex;
1147
1167
  if (k < chains.length - 1) {
@@ -1297,7 +1317,6 @@ ${input.slice(result.pos)}
1297
1317
  default:
1298
1318
  return gatherNodes(node.children, predicate);
1299
1319
  }
1300
- return [];
1301
1320
  }
1302
1321
  function gatherRecursive(node, predicate, skipPredicate) {
1303
1322
  if (node == null)
@@ -1479,6 +1498,7 @@ ${input.slice(result.pos)}
1479
1498
  else
1480
1499
  exp.children.push(["", {
1481
1500
  type: "ReturnStatement",
1501
+ // NOTE: add a prefixed semi-colon because the if block may not be braced
1482
1502
  children: [";return"]
1483
1503
  }]);
1484
1504
  return;
@@ -1498,17 +1518,9 @@ ${input.slice(result.pos)}
1498
1518
  node.splice(1, 1, returnStatement);
1499
1519
  }
1500
1520
  function insertSwitchReturns(exp) {
1501
- switch (exp.type) {
1502
- case "SwitchStatement":
1503
- exp.caseBlock.clauses.forEach((clause) => {
1504
- insertReturn:
1505
- insertReturn(clause);
1506
- });
1507
- return;
1508
- case "SwitchExpression":
1509
- exp.caseBlock.clauses.forEach(insertReturn);
1510
- return;
1511
- }
1521
+ exp.caseBlock.clauses.forEach((clause) => {
1522
+ return insertReturn(clause);
1523
+ });
1512
1524
  }
1513
1525
  function isEmptyBareBlock(node) {
1514
1526
  if (node?.type !== "BlockStatement")
@@ -1647,6 +1659,7 @@ ${input.slice(result.pos)}
1647
1659
  declaration,
1648
1660
  blockPrefix,
1649
1661
  children: [awaits, eachOwnError, open, declaration, ws, inOf, expRef ?? exp, step, close]
1662
+ // omit declaration2, replace eachOwn with eachOwnError, replace exp with expRef
1650
1663
  };
1651
1664
  }
1652
1665
  let ws2, decl2;
@@ -1714,6 +1727,7 @@ ${input.slice(result.pos)}
1714
1727
  return {
1715
1728
  declaration,
1716
1729
  children: [awaits, eachOwnError, open, declaration, ws, inOf, exp, step, close],
1730
+ // omit declaration2, replace each with eachOwnError
1717
1731
  blockPrefix,
1718
1732
  hoistDec
1719
1733
  };
@@ -2090,14 +2104,6 @@ ${input.slice(result.pos)}
2090
2104
  return processReturn(f, config.implicitReturns);
2091
2105
  });
2092
2106
  }
2093
- function processSwitchExpressions(statements) {
2094
- gatherRecursiveAll(statements, (n) => n.type === "SwitchExpression").forEach(insertSwitchReturns);
2095
- }
2096
- function processTryExpressions(statements) {
2097
- gatherRecursiveAll(statements, (n) => n.type === "TryExpression").forEach(({ blocks }) => {
2098
- blocks.forEach(insertReturn);
2099
- });
2100
- }
2101
2107
  function processBindingPatternLHS(lhs, tail) {
2102
2108
  adjustAtBindings(lhs, true);
2103
2109
  const [splices, thisAssignments] = gatherBindingCode(lhs);
@@ -2477,7 +2483,7 @@ ${input.slice(result.pos)}
2477
2483
  return declarations;
2478
2484
  }
2479
2485
  function processPatternMatching(statements, ReservedWord) {
2480
- gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement" || n.type === "SwitchExpression").forEach((s) => {
2486
+ gatherRecursiveAll(statements, (n) => n.type === "SwitchStatement").forEach((s) => {
2481
2487
  const { caseBlock } = s;
2482
2488
  const { clauses } = caseBlock;
2483
2489
  let errors = false;
@@ -2583,10 +2589,6 @@ ${input.slice(result.pos)}
2583
2589
  refAssignment = [];
2584
2590
  return prev = next;
2585
2591
  });
2586
- if (s.type === "SwitchExpression") {
2587
- insertReturn(root[0]);
2588
- root.splice(0, 1, wrapIIFE(root[0]));
2589
- }
2590
2592
  s.type = "PatternMatchingStatement";
2591
2593
  s.children = [root];
2592
2594
  return addParentPointers(s, s.parent);
@@ -2726,14 +2728,12 @@ ${input.slice(result.pos)}
2726
2728
  assert.equal(m.forbidIndentedApplication.length, 1, "forbidIndentedApplication");
2727
2729
  assert.equal(m.forbidNewlineBinaryOp.length, 1, "forbidNewlineBinaryOp");
2728
2730
  assert.equal(m.forbidTrailingMemberProperty.length, 1, "forbidTrailingMemberProperty");
2729
- assert.equal(m.JSXTagStack.length, 0, "JSXTagStack should be empty");
2731
+ assert.equal(m.JSXTagStack.length, 1, "JSXTagStack");
2730
2732
  addParentPointers(root);
2731
2733
  const { expressions: statements } = root;
2732
2734
  processPipelineExpressions(statements);
2733
2735
  processAssignments(statements);
2734
2736
  processPatternMatching(statements, ReservedWord);
2735
- processSwitchExpressions(statements);
2736
- processTryExpressions(statements);
2737
2737
  gatherRecursiveAll(statements, (n) => n.type === "IterationExpression").forEach((e) => expressionizeIteration(e));
2738
2738
  hoistRefDecs(statements);
2739
2739
  processFunctions(statements, config);
@@ -2970,20 +2970,31 @@ ${input.slice(result.pos)}
2970
2970
  if (post?.token === "?") {
2971
2971
  post = {
2972
2972
  $loc: post.$loc,
2973
- token: "!="
2973
+ token: " != null"
2974
2974
  };
2975
2975
  if (pre.length) {
2976
- exp = {
2977
- type: "UnaryExpression",
2978
- children: [...pre, exp, void 0]
2979
- };
2976
+ const lastPre = pre[pre.length - 1];
2977
+ if (lastPre.token === "!") {
2978
+ post.token = " == null";
2979
+ pre = pre.slice(0, -1);
2980
+ } else if (lastPre.length === 2 && lastPre[0].token === "!") {
2981
+ post.token = " == null";
2982
+ pre = pre.slice(0, -1);
2983
+ }
2980
2984
  }
2981
2985
  const existence = {
2982
2986
  type: "Existence",
2983
2987
  expression: exp,
2984
- children: [exp, " ", post, " ", "null"]
2988
+ children: [exp, post]
2985
2989
  };
2986
- return makeLeftHandSideExpression(existence);
2990
+ exp = makeLeftHandSideExpression(existence);
2991
+ if (pre.length) {
2992
+ return {
2993
+ type: "UnaryExpression",
2994
+ children: [...pre, exp]
2995
+ };
2996
+ }
2997
+ return exp;
2987
2998
  }
2988
2999
  if (exp.type === "Literal") {
2989
3000
  if (pre.length === 1 && pre[0].token === "-") {
@@ -3180,31 +3191,53 @@ ${input.slice(result.pos)}
3180
3191
  ;
3181
3192
  return;
3182
3193
  }
3183
- function wrapIIFE(exp, async) {
3184
- let prefix, suffix;
3194
+ function wrapIIFE(expressions, async) {
3195
+ let prefix;
3185
3196
  if (async) {
3186
- prefix = "(async ()=>";
3187
- suffix = ")()";
3188
- } else if (hasAwait(exp)) {
3189
- prefix = "(await (async ()=>";
3190
- suffix = ")())";
3191
- } else {
3192
- prefix = "(()=>";
3193
- suffix = ")()";
3197
+ async = "async ";
3198
+ } else if (hasAwait(expressions)) {
3199
+ async = "async ";
3200
+ prefix = {
3201
+ type: "Await",
3202
+ children: ["await "]
3203
+ };
3194
3204
  }
3195
- const expressions = Array.isArray(exp) ? [...exp] : [exp];
3196
3205
  const block = {
3197
3206
  type: "BlockStatement",
3198
3207
  expressions,
3199
3208
  children: ["{", expressions, "}"],
3200
3209
  bare: false
3201
3210
  };
3202
- updateParentPointers(block);
3203
- return [
3204
- prefix,
3211
+ const parameters = {
3212
+ type: "Parameters",
3213
+ children: ["()"],
3214
+ names: []
3215
+ };
3216
+ const signature = {
3217
+ modifier: {
3218
+ async: !!async
3219
+ },
3220
+ returnType: void 0
3221
+ };
3222
+ const fn = {
3223
+ type: "ArrowFunction",
3224
+ signature,
3225
+ parameters,
3226
+ returnType: void 0,
3227
+ ts: false,
3228
+ async,
3205
3229
  block,
3206
- suffix
3207
- ];
3230
+ children: [async, parameters, "=>", block]
3231
+ };
3232
+ updateParentPointers(block, fn);
3233
+ const exp = {
3234
+ type: "CallExpression",
3235
+ children: [makeLeftHandSideExpression(fn), "()"]
3236
+ };
3237
+ if (prefix) {
3238
+ return [makeLeftHandSideExpression([prefix, exp])];
3239
+ }
3240
+ return [exp];
3208
3241
  }
3209
3242
  module.exports = {
3210
3243
  addParentPointers,
@@ -3616,6 +3649,8 @@ ${input.slice(result.pos)}
3616
3649
  RestoreAll,
3617
3650
  ExpressionStatement,
3618
3651
  KeywordStatement,
3652
+ DebuggerStatement,
3653
+ ThrowStatement,
3619
3654
  Break,
3620
3655
  Continue,
3621
3656
  Debugger,
@@ -4709,6 +4744,8 @@ ${input.slice(result.pos)}
4709
4744
  return {
4710
4745
  type: "AssignmentExpression",
4711
4746
  children: $0,
4747
+ // NOTE: This null marks the assignment for later processing to distinguish it
4748
+ // from fake assignments that only add a name to a scope
4712
4749
  names: null,
4713
4750
  lhs: $1,
4714
4751
  assigned: $1[0][1],
@@ -5348,6 +5385,7 @@ ${input.slice(result.pos)}
5348
5385
  var num = $3;
5349
5386
  return [
5350
5387
  { type: "PropertyAccess", children: [dot, "at"] },
5388
+ // not including `name` so that `{x.-1}` doesn't use it
5351
5389
  { type: "Call", children: ["(", neg, num, ")"] }
5352
5390
  ];
5353
5391
  });
@@ -5480,6 +5518,7 @@ ${input.slice(result.pos)}
5480
5518
  type: "PropertyBind",
5481
5519
  name: id.name,
5482
5520
  children: [modifier, dot, id]
5521
+ // omit `@` from children
5483
5522
  };
5484
5523
  });
5485
5524
  function PropertyBind(ctx, state) {
@@ -5575,6 +5614,7 @@ ${input.slice(result.pos)}
5575
5614
  open,
5576
5615
  tt,
5577
5616
  ...pes,
5617
+ // Remove delimiter
5578
5618
  { ...rest, children: rest.children.slice(0, -1) },
5579
5619
  close
5580
5620
  ],
@@ -5730,6 +5770,7 @@ ${input.slice(result.pos)}
5730
5770
  var c = $3;
5731
5771
  return {
5732
5772
  ...c,
5773
+ // names, blockPrefix, length
5733
5774
  type: "ArrayBindingPattern",
5734
5775
  elements: c.children,
5735
5776
  children: [$1, $2, c.children, $4, $5]
@@ -5754,6 +5795,7 @@ ${input.slice(result.pos)}
5754
5795
  return elements.map(([element, delim]) => {
5755
5796
  return {
5756
5797
  ...element,
5798
+ // BindingElement.children is a tuple of the form [ws, element]
5757
5799
  children: [...element.children, delim]
5758
5800
  };
5759
5801
  });
@@ -5770,6 +5812,7 @@ ${input.slice(result.pos)}
5770
5812
  return {
5771
5813
  ...element,
5772
5814
  children: [indent, ...element.children.slice(1)]
5815
+ // replace ws wth indent
5773
5816
  };
5774
5817
  });
5775
5818
  });
@@ -5999,6 +6042,7 @@ ${input.slice(result.pos)}
5999
6042
  },
6000
6043
  block: null,
6001
6044
  children: !parameters.implicit ? [async, func, generator, wid, w, parameters, suffix] : [async, func, generator, wid, parameters, w, suffix]
6045
+ // move whitespace w to after implicit () in parameters
6002
6046
  };
6003
6047
  });
6004
6048
  function FunctionSignature(ctx, state) {
@@ -6389,6 +6433,7 @@ ${input.slice(result.pos)}
6389
6433
  return {
6390
6434
  type: "BlockStatement",
6391
6435
  expressions: s.expressions,
6436
+ // Remove !EOS assertion
6392
6437
  children: [o, s.children, ws, c]
6393
6438
  };
6394
6439
  });
@@ -6407,6 +6452,7 @@ ${input.slice(result.pos)}
6407
6452
  return {
6408
6453
  type: "BlockStatement",
6409
6454
  expressions: s.expressions,
6455
+ // Remove !EOS assertion
6410
6456
  children: [o, s.children, ws, c]
6411
6457
  };
6412
6458
  });
@@ -6434,6 +6480,7 @@ ${input.slice(result.pos)}
6434
6480
  return {
6435
6481
  type: "BlockStatement",
6436
6482
  expressions: [s],
6483
+ // Remove &EOS assertion
6437
6484
  children: [$1, s, $3]
6438
6485
  };
6439
6486
  });
@@ -6457,6 +6504,7 @@ ${input.slice(result.pos)}
6457
6504
  type: "BlockStatement",
6458
6505
  expressions,
6459
6506
  children: [expressions],
6507
+ // avoid aliasing
6460
6508
  bare: true
6461
6509
  };
6462
6510
  });
@@ -6882,6 +6930,8 @@ ${input.slice(result.pos)}
6882
6930
  last = {
6883
6931
  ...last,
6884
6932
  delim,
6933
+ // __ will consume all whitespace that _? in PropertyDefinition could,
6934
+ // so replace _? (via slice) with __
6885
6935
  children: [ws, ...last.children.slice(1), delim]
6886
6936
  };
6887
6937
  return [...prop.slice(0, prop.length - 1), last];
@@ -7323,6 +7373,7 @@ ${input.slice(result.pos)}
7323
7373
  name,
7324
7374
  optional,
7325
7375
  modifier,
7376
+ // get/set/async/generator
7326
7377
  returnType,
7327
7378
  parameters
7328
7379
  };
@@ -7602,6 +7653,7 @@ ${input.slice(result.pos)}
7602
7653
  token: $1,
7603
7654
  relational: true,
7604
7655
  special: true
7656
+ // for typeof shorthand
7605
7657
  };
7606
7658
  });
7607
7659
  var BinaryOpSymbol$40 = $TS($S(Not, __, $EXPECT($L93, 'BinaryOpSymbol "instanceof"'), NonIdContinue), function($skip, $loc, $0, $1, $2, $3, $4) {
@@ -7894,6 +7946,7 @@ ${input.slice(result.pos)}
7894
7946
  condition = insertTrimmingSpace(condition, "");
7895
7947
  return {
7896
7948
  type: "IfStatement",
7949
+ // TODO: Don't add unnecessary parens
7897
7950
  children: [kind, ["(!", condition, ")"]],
7898
7951
  condition
7899
7952
  };
@@ -8430,12 +8483,12 @@ ${input.slice(result.pos)}
8430
8483
  return $EVENT(ctx, state, "EmptyCondition", EmptyCondition$0);
8431
8484
  }
8432
8485
  var SwitchExpression$0 = $TV(SwitchStatement, function($skip, $loc, $0, $1) {
8433
- var e = $0;
8486
+ var s = $0;
8434
8487
  return {
8435
8488
  type: "SwitchExpression",
8436
- children: wrapIIFE(e.children),
8437
- expression: e.expression,
8438
- caseBlock: e.caseBlock
8489
+ // wrap with IIFE
8490
+ children: wrapIIFE([["", s]]),
8491
+ statement: s
8439
8492
  };
8440
8493
  });
8441
8494
  function SwitchExpression(ctx, state) {
@@ -8475,6 +8528,7 @@ ${input.slice(result.pos)}
8475
8528
  var clause = $2;
8476
8529
  return {
8477
8530
  ...clause,
8531
+ // Bring the indent into the clause
8478
8532
  children: [indent, ...clause.children]
8479
8533
  };
8480
8534
  });
@@ -8626,7 +8680,7 @@ ${input.slice(result.pos)}
8626
8680
  return {
8627
8681
  type: "TryExpression",
8628
8682
  blocks: t.blocks,
8629
- children: wrapIIFE(t)
8683
+ children: wrapIIFE([["", t]])
8630
8684
  };
8631
8685
  });
8632
8686
  function TryExpression(ctx, state) {
@@ -8902,28 +8956,38 @@ ${input.slice(result.pos)}
8902
8956
  return {
8903
8957
  type: "BreakStatement",
8904
8958
  children: $2 ? [$1, $2[0], $2[2]] : [$1]
8959
+ // omit colon
8905
8960
  };
8906
8961
  });
8907
8962
  var KeywordStatement$1 = $TS($S(Continue, $E($S(_, $E(Colon), Identifier))), function($skip, $loc, $0, $1, $2) {
8908
8963
  return {
8909
8964
  type: "ContinueStatement",
8910
8965
  children: $2 ? [$1, $2[0], $2[2]] : [$1]
8966
+ // omit colon
8911
8967
  };
8912
8968
  });
8913
- var KeywordStatement$2 = $T($S(Debugger), function(value) {
8914
- return { "type": "DebuggerStatement", "children": value };
8915
- });
8969
+ var KeywordStatement$2 = DebuggerStatement;
8916
8970
  var KeywordStatement$3 = $T($S(Return, $N($C($EXPECT($L12, 'KeywordStatement ":"'), $EXPECT($L6, 'KeywordStatement "."'), AfterReturnShorthand)), $E(MaybeNestedExpression)), function(value) {
8917
8971
  var expression = value[2];
8918
8972
  return { "type": "ReturnStatement", "expression": expression, "children": value };
8919
8973
  });
8920
- var KeywordStatement$4 = $T($S(Throw, ExtendedExpression), function(value) {
8921
- return { "type": "ThrowStatement", "children": value };
8922
- });
8974
+ var KeywordStatement$4 = ThrowStatement;
8923
8975
  var KeywordStatement$$ = [KeywordStatement$0, KeywordStatement$1, KeywordStatement$2, KeywordStatement$3, KeywordStatement$4];
8924
8976
  function KeywordStatement(ctx, state) {
8925
8977
  return $EVENT_C(ctx, state, "KeywordStatement", KeywordStatement$$);
8926
8978
  }
8979
+ var DebuggerStatement$0 = $T($S(Debugger), function(value) {
8980
+ return { "type": "DebuggerStatement", "children": value };
8981
+ });
8982
+ function DebuggerStatement(ctx, state) {
8983
+ return $EVENT(ctx, state, "DebuggerStatement", DebuggerStatement$0);
8984
+ }
8985
+ var ThrowStatement$0 = $T($S(Throw, ExtendedExpression), function(value) {
8986
+ return { "type": "ThrowStatement", "children": value };
8987
+ });
8988
+ function ThrowStatement(ctx, state) {
8989
+ return $EVENT(ctx, state, "ThrowStatement", ThrowStatement$0);
8990
+ }
8927
8991
  var Break$0 = $TS($S($EXPECT($L102, 'Break "break"'), NonIdContinue), function($skip, $loc, $0, $1, $2) {
8928
8992
  return { $loc, token: $1 };
8929
8993
  });
@@ -8942,19 +9006,21 @@ ${input.slice(result.pos)}
8942
9006
  function Debugger(ctx, state) {
8943
9007
  return $EVENT(ctx, state, "Debugger", Debugger$0);
8944
9008
  }
8945
- var DebuggerExpression$0 = $TS($S(Debugger), function($skip, $loc, $0, $1) {
9009
+ var DebuggerExpression$0 = $TV(DebuggerStatement, function($skip, $loc, $0, $1) {
9010
+ var s = $0;
8946
9011
  return {
8947
9012
  type: "DebuggerExpression",
8948
- children: wrapIIFE($1)
9013
+ children: wrapIIFE([["", s]])
8949
9014
  };
8950
9015
  });
8951
9016
  function DebuggerExpression(ctx, state) {
8952
9017
  return $EVENT(ctx, state, "DebuggerExpression", DebuggerExpression$0);
8953
9018
  }
8954
- var ThrowExpression$0 = $TS($S(Throw, ExtendedExpression), function($skip, $loc, $0, $1, $2) {
9019
+ var ThrowExpression$0 = $TV(ThrowStatement, function($skip, $loc, $0, $1) {
9020
+ var s = $0;
8955
9021
  return {
8956
9022
  type: "ThrowExpression",
8957
- children: wrapIIFE($0)
9023
+ children: wrapIIFE([["", s]])
8958
9024
  };
8959
9025
  });
8960
9026
  function ThrowExpression(ctx, state) {
@@ -9503,6 +9569,7 @@ ${input.slice(result.pos)}
9503
9569
  if (hasSubstitutions) {
9504
9570
  const result = [
9505
9571
  { ...open, token: "RegExp(`" },
9572
+ // Escape backticks, backslashes, and '$' in the body text
9506
9573
  body.map(
9507
9574
  (e) => e.type === "Substitution" ? e : {
9508
9575
  ...e,
@@ -10382,7 +10449,9 @@ ${input.slice(result.pos)}
10382
10449
  parts = [
10383
10450
  ...$0,
10384
10451
  "\n",
10452
+ // InsertNewline
10385
10453
  module.currentIndent.token,
10454
+ // InsertIndent
10386
10455
  ["</", open[1], ">"]
10387
10456
  ];
10388
10457
  } else {
@@ -10450,7 +10519,9 @@ ${input.slice(result.pos)}
10450
10519
  const parts = close ? $0 : [
10451
10520
  ...$0,
10452
10521
  "\n",
10522
+ // InsertNewline
10453
10523
  module.currentIndent.token,
10524
+ // InsertIndent
10454
10525
  "</>"
10455
10526
  ];
10456
10527
  return { type: "JSXFragment", children: parts, jsxChildren: children.jsxChildren };
@@ -11964,7 +12035,7 @@ ${input.slice(result.pos)}
11964
12035
  module.forbidBracedApplication = [false];
11965
12036
  module.forbidTrailingMemberProperty = [false];
11966
12037
  module.forbidNewlineBinaryOp = [false];
11967
- module.JSXTagStack = [];
12038
+ module.JSXTagStack = [void 0];
11968
12039
  module.operators = /* @__PURE__ */ new Set();
11969
12040
  if (!module._init) {
11970
12041
  module._init = true;
@@ -12037,9 +12108,11 @@ ${input.slice(result.pos)}
12037
12108
  react: false,
12038
12109
  solid: false,
12039
12110
  client: false,
12111
+ // default behavior: client only
12040
12112
  rewriteTsImports: true,
12041
12113
  server: false,
12042
12114
  tab: void 0,
12115
+ // default behavior = same as space
12043
12116
  verbose: false
12044
12117
  };
12045
12118
  const asAny = {
@@ -12177,7 +12250,12 @@ ${input.slice(result.pos)}
12177
12250
  type: "ParserMeta",
12178
12251
  children: [],
12179
12252
  getStateKey() {
12180
- 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;
12253
+ 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,
12254
+ // since it is affected by the directive prologue and may be hit
12255
+ // by the EOL rule early in the parse. Later if we wanted to
12256
+ // allow block scoping of the compat directives we would need to
12257
+ // add them all here.
12258
+ module.config.coffeeComment << 2;
12181
12259
  return [stateInt, module.currentJSXTag];
12182
12260
  }
12183
12261
  };
@@ -12202,7 +12280,8 @@ ${input.slice(result.pos)}
12202
12280
  if (module.config.tab) {
12203
12281
  const tabs = $0.match(/\t/g);
12204
12282
  const numTabs = tabs ? tabs.length : 0;
12205
- level = numTabs * module.config.tab + ($0.length - numTabs);
12283
+ level = numTabs * module.config.tab + /*spaces*/
12284
+ ($0.length - numTabs);
12206
12285
  } else {
12207
12286
  level = $0.length;
12208
12287
  }
@@ -12625,6 +12704,8 @@ ${input.slice(result.pos)}
12625
12704
  exports.RestoreAll = RestoreAll;
12626
12705
  exports.ExpressionStatement = ExpressionStatement;
12627
12706
  exports.KeywordStatement = KeywordStatement;
12707
+ exports.DebuggerStatement = DebuggerStatement;
12708
+ exports.ThrowStatement = ThrowStatement;
12628
12709
  exports.Break = Break;
12629
12710
  exports.Continue = Continue;
12630
12711
  exports.Debugger = Debugger;
@@ -13454,6 +13535,10 @@ ${input.slice(result.pos)}
13454
13535
  get(key) {
13455
13536
  return this.cache.get(key[0])?.get(key[1])?.get(key[2])?.get(key[3]);
13456
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
+ */
13457
13542
  has(key) {
13458
13543
  return !!this.cache.get(key[0])?.get(key[1])?.get(key[2])?.has(key[3]);
13459
13544
  }
@@ -13488,16 +13573,23 @@ ${input.slice(result.pos)}
13488
13573
  var { parse } = import_parser.default;
13489
13574
  var { SourceMap: SourceMap2 } = util_exports;
13490
13575
  var uncacheable = /* @__PURE__ */ new Set([
13576
+ // Meta
13491
13577
  "DebugHere",
13492
13578
  "Init",
13493
13579
  "Program",
13494
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.
13495
13585
  "PushIndent",
13496
13586
  "PopIndent",
13497
13587
  "TrackIndented",
13588
+ // JSX
13498
13589
  "PushJSXOpeningElement",
13499
13590
  "PushJSXOpeningFragment",
13500
13591
  "PopJSXStack",
13592
+ // State
13501
13593
  "AllowAll",
13502
13594
  "AllowClassImplicitCall",
13503
13595
  "AllowBracedApplication",
@@ -13600,7 +13692,8 @@ ${input.slice(result.pos)}
13600
13692
  return events;
13601
13693
  }
13602
13694
  var isCompileError = function(err) {
13603
- 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);
13604
13697
  };
13605
13698
  var main_default = { parse, generate: generate_default, util: util_exports, compile, isCompileError };
13606
13699
  return __toCommonJS(main_exports);