@danielx/civet 0.5.88 → 0.5.90

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
@@ -44,7 +44,7 @@ var Civet = (() => {
44
44
  children: block.children === block.expressions ? expressions : block.children.map((c) => c === block.expressions ? expressions : c)
45
45
  };
46
46
  if (block.bare) {
47
- block.children = [[" {\n", indent], ...block.children, "}"];
47
+ block.children = [[" {"], ...block.children, "}"];
48
48
  block.bare = false;
49
49
  }
50
50
  }
@@ -152,8 +152,16 @@ var Civet = (() => {
152
152
  }
153
153
  function getIndent(statement) {
154
154
  let indent = statement?.[0];
155
- if (Array.isArray(indent))
156
- indent = indent[indent.length - 1];
155
+ if (Array.isArray(indent)) {
156
+ indent = indent.flat(Infinity);
157
+ return indent.filter((n) => n && !(n.type === "Comment")).map((n) => {
158
+ if (typeof n === "string")
159
+ return n;
160
+ if (n.token != null)
161
+ return n.token;
162
+ return "";
163
+ });
164
+ }
157
165
  return indent;
158
166
  }
159
167
  function hasAwait(exp) {
@@ -319,7 +327,7 @@ var Civet = (() => {
319
327
  varLet = [",", ...varName, " = ", counterRef];
320
328
  } else {
321
329
  blockPrefix = [
322
- ["", forDeclaration, " = ", counterRef, ";\n"]
330
+ ["", forDeclaration, " = ", counterRef, ";"]
323
331
  ];
324
332
  }
325
333
  } else if (forDeclaration) {
@@ -428,16 +436,18 @@ var Civet = (() => {
428
436
  }
429
437
  let [splices, thisAssignments] = gatherBindingCode(id);
430
438
  splices = splices.map((s) => [", ", s]);
431
- thisAssignments = thisAssignments.map((a) => [";", a]);
439
+ thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
432
440
  const binding = [c, id, suffix, ...ws];
433
- const initializer = [ca, e, ...splices, ...thisAssignments];
441
+ const initializer = [ca, e];
434
442
  const children = [binding, initializer];
435
443
  return {
436
444
  type: "Declaration",
437
445
  names: id.names,
438
446
  children,
439
447
  binding,
440
- initializer
448
+ initializer,
449
+ splices,
450
+ thisAssignments
441
451
  };
442
452
  }
443
453
  function processLetAssignmentDeclaration(l, id, suffix, ws, la, e) {
@@ -450,18 +460,87 @@ var Civet = (() => {
450
460
  };
451
461
  let [splices, thisAssignments] = gatherBindingCode(id);
452
462
  splices = splices.map((s) => [", ", s]);
453
- thisAssignments = thisAssignments.map((a) => [";", a]);
463
+ thisAssignments = thisAssignments.map((a) => ["", a, ";"]);
454
464
  const binding = [l, id, suffix, ...ws];
455
- const initializer = [la, e, ...splices, ...thisAssignments];
465
+ const initializer = [la, e];
456
466
  const children = [binding, initializer];
457
467
  return {
458
468
  type: "Declaration",
459
469
  names: id.names,
460
470
  children,
461
471
  binding,
462
- initializer
472
+ initializer,
473
+ splices,
474
+ thisAssignments
463
475
  };
464
476
  }
477
+ function processUnaryExpression(pre, exp, post) {
478
+ if (post?.token === "?") {
479
+ post = {
480
+ $loc: post.$loc,
481
+ token: " != null"
482
+ };
483
+ switch (exp.type) {
484
+ case "Identifier":
485
+ case "Literal":
486
+ return {
487
+ ...exp,
488
+ children: [...pre, ...exp.children, post]
489
+ };
490
+ default:
491
+ const expression = {
492
+ ...exp,
493
+ children: [...pre, "(", exp.children, ")", post]
494
+ };
495
+ return {
496
+ type: "ParenthesizedExpression",
497
+ children: ["(", expression, ")"],
498
+ expression
499
+ };
500
+ }
501
+ }
502
+ if (exp.type === "Literal") {
503
+ if (pre.length === 1 && pre[0].token === "-") {
504
+ const children = [pre[0], ...exp.children];
505
+ if (post)
506
+ exp.children.push(post);
507
+ return {
508
+ type: "Literal",
509
+ children,
510
+ raw: `-${exp.raw}`
511
+ };
512
+ }
513
+ }
514
+ const l = pre.length;
515
+ if (l) {
516
+ const last = pre[l - 1];
517
+ if (last.type === "Await" && last.op) {
518
+ if (exp.type !== "ParenthesizedExpression") {
519
+ exp = ["(", exp, ")"];
520
+ }
521
+ exp = {
522
+ type: "CallExpression",
523
+ children: [" Promise", last.op, exp]
524
+ };
525
+ }
526
+ }
527
+ if (exp.children) {
528
+ const children = [...pre, ...exp.children];
529
+ if (post)
530
+ children.push(post);
531
+ return Object.assign({}, exp, { children });
532
+ } else if (Array.isArray(exp)) {
533
+ const children = [...pre, ...exp];
534
+ if (post)
535
+ children.push(post);
536
+ return { children };
537
+ } else {
538
+ const children = [...pre, exp];
539
+ if (post)
540
+ children.push(post);
541
+ return { children };
542
+ }
543
+ }
465
544
  module.exports = {
466
545
  blockWithPrefix,
467
546
  clone,
@@ -485,6 +564,7 @@ var Civet = (() => {
485
564
  processCoffeeInterpolation,
486
565
  processConstAssignmentDeclaration,
487
566
  processLetAssignmentDeclaration,
567
+ processUnaryExpression,
488
568
  quoteString,
489
569
  removeParentPointers
490
570
  };
@@ -1033,6 +1113,7 @@ ${input.slice(result.pos)}
1033
1113
  OperatorDeclaration,
1034
1114
  OperatorSignature,
1035
1115
  AmpersandBlockRHS,
1116
+ AmpersandBlockRHSBody,
1036
1117
  AmpersandUnaryPrefix,
1037
1118
  ThinArrowFunction,
1038
1119
  Arrow,
@@ -1107,6 +1188,7 @@ ${input.slice(result.pos)}
1107
1188
  Xor,
1108
1189
  Xnor,
1109
1190
  UnaryOp,
1191
+ AwaitOp,
1110
1192
  ModuleItem,
1111
1193
  StatementListItem,
1112
1194
  PostfixedStatement,
@@ -1786,7 +1868,8 @@ ${input.slice(result.pos)}
1786
1868
  type: "BlockStatement",
1787
1869
  expressions: statements,
1788
1870
  children: [statements],
1789
- bare: true
1871
+ bare: true,
1872
+ root: true
1790
1873
  });
1791
1874
  return $0;
1792
1875
  });
@@ -2245,7 +2328,7 @@ ${input.slice(result.pos)}
2245
2328
  return result;
2246
2329
  }
2247
2330
  }
2248
- var ArgumentsWithTrailingMemberExpressions$0 = $TS($S(Arguments, TrailingMemberExpressions), function($skip, $loc, $0, $1, $2) {
2331
+ var ArgumentsWithTrailingMemberExpressions$0 = $TS($S(Arguments, AllowedTrailingMemberExpressions), function($skip, $loc, $0, $1, $2) {
2249
2332
  var args = $1;
2250
2333
  var trailing = $2;
2251
2334
  const call = {
@@ -2649,7 +2732,7 @@ ${input.slice(result.pos)}
2649
2732
  var pre = $1;
2650
2733
  var exp = $2;
2651
2734
  var post = $3;
2652
- return module.processUnaryExpression(pre, exp, post);
2735
+ return processUnaryExpression(pre, exp, post);
2653
2736
  });
2654
2737
  var UnaryExpression$1 = $TS($S(CoffeeDoEnabled, Do, __, $C($S(LeftHandSideExpression, $N($S(__, AssignmentOpSymbol))), ArrowFunction, ExtendedExpression)), function($skip, $loc, $0, $1, $2, $3, $4) {
2655
2738
  var ws = $3;
@@ -6263,7 +6346,34 @@ ${input.slice(result.pos)}
6263
6346
  return result;
6264
6347
  }
6265
6348
  }
6266
- var AmpersandBlockRHS$0 = $TS($S($E($S($N(_), $P(CallExpressionRest))), $E($S($N($EXPECT($R3, fail, "AmpersandBlockRHS /[&]/")), $P(BinaryOpRHS)))), function($skip, $loc, $0, $1, $2) {
6349
+ var AmpersandBlockRHS$0 = $TS($S(ForbidTrailingMemberProperty, $E(AmpersandBlockRHSBody), RestoreTrailingMemberProperty), function($skip, $loc, $0, $1, $2, $3) {
6350
+ if (!$2)
6351
+ return $skip;
6352
+ return $2;
6353
+ });
6354
+ function AmpersandBlockRHS(state) {
6355
+ let eventData;
6356
+ if (state.events) {
6357
+ const result = state.events.enter?.("AmpersandBlockRHS", state);
6358
+ if (result) {
6359
+ if (result.cache)
6360
+ return result.cache;
6361
+ eventData = result.data;
6362
+ }
6363
+ }
6364
+ if (state.tokenize) {
6365
+ const result = $TOKEN("AmpersandBlockRHS", state, AmpersandBlockRHS$0(state));
6366
+ if (state.events)
6367
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
6368
+ return result;
6369
+ } else {
6370
+ const result = AmpersandBlockRHS$0(state);
6371
+ if (state.events)
6372
+ state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
6373
+ return result;
6374
+ }
6375
+ }
6376
+ var AmpersandBlockRHSBody$0 = $TS($S($E($S($N(_), $P(CallExpressionRest))), $E($S($N($EXPECT($R3, fail, "AmpersandBlockRHSBody /[&]/")), $P(BinaryOpRHS)))), function($skip, $loc, $0, $1, $2) {
6267
6377
  var callExpRest = $1;
6268
6378
  var binopRHS = $2;
6269
6379
  if (!callExpRest && !binopRHS)
@@ -6290,10 +6400,10 @@ ${input.slice(result.pos)}
6290
6400
  }
6291
6401
  return exp;
6292
6402
  });
6293
- function AmpersandBlockRHS(state) {
6403
+ function AmpersandBlockRHSBody(state) {
6294
6404
  let eventData;
6295
6405
  if (state.events) {
6296
- const result = state.events.enter?.("AmpersandBlockRHS", state);
6406
+ const result = state.events.enter?.("AmpersandBlockRHSBody", state);
6297
6407
  if (result) {
6298
6408
  if (result.cache)
6299
6409
  return result.cache;
@@ -6301,14 +6411,14 @@ ${input.slice(result.pos)}
6301
6411
  }
6302
6412
  }
6303
6413
  if (state.tokenize) {
6304
- const result = $TOKEN("AmpersandBlockRHS", state, AmpersandBlockRHS$0(state));
6414
+ const result = $TOKEN("AmpersandBlockRHSBody", state, AmpersandBlockRHSBody$0(state));
6305
6415
  if (state.events)
6306
- state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
6416
+ state.events.exit?.("AmpersandBlockRHSBody", state, result, eventData);
6307
6417
  return result;
6308
6418
  } else {
6309
- const result = AmpersandBlockRHS$0(state);
6419
+ const result = AmpersandBlockRHSBody$0(state);
6310
6420
  if (state.events)
6311
- state.events.exit?.("AmpersandBlockRHS", state, result, eventData);
6421
+ state.events.exit?.("AmpersandBlockRHSBody", state, result, eventData);
6312
6422
  return result;
6313
6423
  }
6314
6424
  }
@@ -6890,17 +7000,10 @@ ${input.slice(result.pos)}
6890
7000
  if (!statements.length)
6891
7001
  return $skip;
6892
7002
  statements = statements.flat();
6893
- const first = statements[0];
6894
- const ws = first[0];
6895
- const indent = ws.at(-1);
6896
- statements = [
6897
- [indent, ...first.slice(1)],
6898
- ...statements.slice(1)
6899
- ];
6900
7003
  return {
6901
7004
  type: "BlockStatement",
6902
7005
  expressions: statements,
6903
- children: [ws.slice(0, -1), statements],
7006
+ children: [statements],
6904
7007
  bare: true
6905
7008
  };
6906
7009
  });
@@ -9040,8 +9143,9 @@ ${input.slice(result.pos)}
9040
9143
  var UnaryOp$0 = $TR($EXPECT($R9, fail, "UnaryOp /(?!\\+\\+|--)[!~+-](?!\\s|[!~+-]*&)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
9041
9144
  return { $loc, token: $0 };
9042
9145
  });
9043
- var UnaryOp$1 = $S($C(Await, Delete, Void, Typeof), __);
9044
- var UnaryOp$2 = Not;
9146
+ var UnaryOp$1 = AwaitOp;
9147
+ var UnaryOp$2 = $S($C(Delete, Void, Typeof), $E(_));
9148
+ var UnaryOp$3 = Not;
9045
9149
  function UnaryOp(state) {
9046
9150
  let eventData;
9047
9151
  if (state.events) {
@@ -9053,17 +9157,52 @@ ${input.slice(result.pos)}
9053
9157
  }
9054
9158
  }
9055
9159
  if (state.tokenize) {
9056
- const result = $TOKEN("UnaryOp", state, UnaryOp$0(state) || UnaryOp$1(state) || UnaryOp$2(state));
9160
+ const result = $TOKEN("UnaryOp", state, UnaryOp$0(state) || UnaryOp$1(state) || UnaryOp$2(state) || UnaryOp$3(state));
9057
9161
  if (state.events)
9058
9162
  state.events.exit?.("UnaryOp", state, result, eventData);
9059
9163
  return result;
9060
9164
  } else {
9061
- const result = UnaryOp$0(state) || UnaryOp$1(state) || UnaryOp$2(state);
9165
+ const result = UnaryOp$0(state) || UnaryOp$1(state) || UnaryOp$2(state) || UnaryOp$3(state);
9062
9166
  if (state.events)
9063
9167
  state.events.exit?.("UnaryOp", state, result, eventData);
9064
9168
  return result;
9065
9169
  }
9066
9170
  }
9171
+ var AwaitOp$0 = $TS($S(Await, $E($S(Dot, IdentifierName)), $C(_, $Y(OpenParen))), function($skip, $loc, $0, $1, $2, $3) {
9172
+ var a = $1;
9173
+ var op = $2;
9174
+ var ws = $3;
9175
+ if (op) {
9176
+ return {
9177
+ ...a,
9178
+ op,
9179
+ children: [a, ...ws || []]
9180
+ };
9181
+ }
9182
+ return [a, ...ws || []];
9183
+ });
9184
+ function AwaitOp(state) {
9185
+ let eventData;
9186
+ if (state.events) {
9187
+ const result = state.events.enter?.("AwaitOp", state);
9188
+ if (result) {
9189
+ if (result.cache)
9190
+ return result.cache;
9191
+ eventData = result.data;
9192
+ }
9193
+ }
9194
+ if (state.tokenize) {
9195
+ const result = $TOKEN("AwaitOp", state, AwaitOp$0(state));
9196
+ if (state.events)
9197
+ state.events.exit?.("AwaitOp", state, result, eventData);
9198
+ return result;
9199
+ } else {
9200
+ const result = AwaitOp$0(state);
9201
+ if (state.events)
9202
+ state.events.exit?.("AwaitOp", state, result, eventData);
9203
+ return result;
9204
+ }
9205
+ }
9067
9206
  var ModuleItem$0 = ImportDeclaration;
9068
9207
  var ModuleItem$1 = ExportDeclaration;
9069
9208
  var ModuleItem$2 = StatementListItem;
@@ -10099,13 +10238,12 @@ ${input.slice(result.pos)}
10099
10238
  });
10100
10239
  var ForStatementControl$1 = $TS($S(CoffeeForLoopsEnabled, CoffeeForStatementParameters, $E(WhenCondition)), function($skip, $loc, $0, $1, $2, $3) {
10101
10240
  if ($3) {
10102
- const indent = module.currentIndent.token + " ";
10103
- const block = "continue\n";
10241
+ const block = "continue;";
10104
10242
  $2 = {
10105
10243
  ...$2,
10106
10244
  blockPrefix: [
10107
10245
  ...$2.blockPrefix,
10108
- [indent, {
10246
+ ["", {
10109
10247
  type: "IfStatement",
10110
10248
  then: block,
10111
10249
  children: ["if (!(", insertTrimmingSpace($3, ""), ")) ", block]
@@ -10172,7 +10310,6 @@ ${input.slice(result.pos)}
10172
10310
  var step = $8;
10173
10311
  var close = $9;
10174
10312
  let blockPrefix = [];
10175
- const indent = module.currentIndent.token + " ";
10176
10313
  exp = insertTrimmingSpace(exp, "");
10177
10314
  declaration = insertTrimmingSpace(declaration, "");
10178
10315
  if (kind.token === "from") {
@@ -10186,14 +10323,14 @@ ${input.slice(result.pos)}
10186
10323
  }
10187
10324
  if (declaration.own) {
10188
10325
  const hasPropRef = module.getRef("hasProp");
10189
- blockPrefix.push([indent, "if (!", hasPropRef, ".call(", exp, ", ", declaration, ")) continue\n"]);
10326
+ blockPrefix.push(["", "if (!", hasPropRef, ".call(", exp, ", ", declaration, ")) continue", ";"]);
10190
10327
  }
10191
10328
  if (index) {
10192
- blockPrefix.push([indent, {
10329
+ blockPrefix.push(["", {
10193
10330
  type: "AssignmentExpression",
10194
10331
  children: [index, " = ", exp, "[", declaration, "]"],
10195
10332
  names: index.names
10196
- }, ";\n"]);
10333
+ }, ";"]);
10197
10334
  }
10198
10335
  kind.token = "in";
10199
10336
  } else if (kind.token === "in") {
@@ -10229,11 +10366,11 @@ ${input.slice(result.pos)}
10229
10366
  assignmentNames.push(...index.names);
10230
10367
  }
10231
10368
  const expRefDec = expRef !== exp ? [expRef, " = ", insertTrimmingSpace(exp, ""), ", "] : [];
10232
- blockPrefix.push([indent, {
10369
+ blockPrefix.push(["", {
10233
10370
  type: "AssignmentExpression",
10234
- children: [varRef, " = ", expRef, "[", indexAssignment, counterRef, "]\n"],
10371
+ children: [varRef, " = ", expRef, "[", indexAssignment, counterRef, "]"],
10235
10372
  names: assignmentNames
10236
- }]);
10373
+ }, ";"]);
10237
10374
  declaration = {
10238
10375
  type: "Declaration",
10239
10376
  children: ["let ", ...expRefDec, counterRef, " = 0, ", lenRef, " = ", expRef, ".length"],
@@ -11152,12 +11289,15 @@ ${input.slice(result.pos)}
11152
11289
  type: "Ref",
11153
11290
  base: "ref"
11154
11291
  };
11155
- const { binding, initializer } = dec;
11292
+ const { binding, initializer, splices, thisAssignments } = dec;
11156
11293
  const initCondition = {
11157
11294
  type: "AssignmentExpression",
11158
11295
  children: [ref, " ", initializer],
11159
11296
  hoistDec: [["", ["let ", ref], ";"]],
11160
- blockPrefix: [["", [binding, "= ", ref], ";\n"]]
11297
+ blockPrefix: [
11298
+ ["", [binding, "= ", ref, ...splices], ";"],
11299
+ ...thisAssignments
11300
+ ]
11161
11301
  };
11162
11302
  return initCondition;
11163
11303
  });
@@ -12552,7 +12692,20 @@ ${input.slice(result.pos)}
12552
12692
  }
12553
12693
  var Declaration$0 = HoistableDeclaration;
12554
12694
  var Declaration$1 = ClassDeclaration;
12555
- var Declaration$2 = LexicalDeclaration;
12695
+ var Declaration$2 = $TV(LexicalDeclaration, function($skip, $loc, $0, $1) {
12696
+ var d = $0;
12697
+ if (d.thisAssignments?.length)
12698
+ return {
12699
+ ...d,
12700
+ children: [...d.children, ...d.splices, ";", ...d.thisAssignments]
12701
+ };
12702
+ if (d.splices?.length)
12703
+ return {
12704
+ ...d,
12705
+ children: [...d.children, ...d.splices]
12706
+ };
12707
+ return d;
12708
+ });
12556
12709
  var Declaration$3 = TypeDeclaration;
12557
12710
  var Declaration$4 = EnumDeclaration;
12558
12711
  var Declaration$5 = OperatorDeclaration;
@@ -12602,12 +12755,21 @@ ${input.slice(result.pos)}
12602
12755
  }
12603
12756
  }
12604
12757
  var LexicalDeclaration$0 = $TS($S(LetOrConst, LexicalBinding, $Q($S(__, Comma, LexicalBinding))), function($skip, $loc, $0, $1, $2, $3) {
12758
+ var d = $1;
12605
12759
  var binding = $2;
12606
12760
  var tail = $3;
12761
+ const { splices, thisAssignments } = binding;
12607
12762
  return {
12608
12763
  type: "Declaration",
12609
12764
  children: $0,
12610
- names: [...binding.names].concat(tail.flatMap(([, , b]) => b.names))
12765
+ names: [...binding.names].concat(tail.flatMap(([, , b]) => b.names)),
12766
+ binding: {
12767
+ ...binding.binding,
12768
+ children: [d, ...binding.binding.children]
12769
+ },
12770
+ initializer: binding.initializer,
12771
+ splices,
12772
+ thisAssignments
12611
12773
  };
12612
12774
  });
12613
12775
  var LexicalDeclaration$1 = $TS($S(InsertConst, $C(BindingPattern, BindingIdentifier), $E(TypeSuffix), __, ConstAssignment, ExtendedExpression), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6) {
@@ -12694,25 +12856,51 @@ ${input.slice(result.pos)}
12694
12856
  return result;
12695
12857
  }
12696
12858
  }
12697
- var LexicalBinding$0 = $TS($S(BindingPattern, $E(TypeSuffix), Initializer), function($skip, $loc, $0, $1, $2, $3) {
12698
- const children = [...$1.children];
12699
- if ($2)
12700
- children.push($2);
12701
- children.push($3);
12859
+ var LexicalBinding$0 = $TS($S(BindingPattern, $E(TypeSuffix), $E(_), Initializer), function($skip, $loc, $0, $1, $2, $3, $4) {
12860
+ var binding = $1;
12861
+ var suffix = $2;
12862
+ var ws = $3;
12863
+ var initializer = $4;
12864
+ const bindingChildren = [...binding.children];
12865
+ if (suffix)
12866
+ bindingChildren.push(suffix);
12867
+ if (ws)
12868
+ bindingChildren.push(...ws);
12869
+ binding = {
12870
+ ...binding,
12871
+ children: bindingChildren
12872
+ };
12873
+ const [splices, thisAssignments] = gatherBindingCode(binding.children);
12702
12874
  return {
12703
- children,
12704
- names: $1.names
12875
+ children: [binding, initializer],
12876
+ names: binding.names,
12877
+ binding,
12878
+ initializer,
12879
+ splices: splices.map((s) => [",", s]),
12880
+ thisAssignments: thisAssignments.map((s) => ["", s, ";"])
12705
12881
  };
12706
12882
  });
12707
- var LexicalBinding$1 = $TS($S(BindingIdentifier, $E(TypeSuffix), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3) {
12708
- const children = [...$1.children];
12709
- if ($2)
12710
- children.push($2);
12711
- if ($3)
12712
- children.push($3);
12883
+ var LexicalBinding$1 = $TS($S(BindingIdentifier, $E(TypeSuffix), $E(_), $E(Initializer)), function($skip, $loc, $0, $1, $2, $3, $4) {
12884
+ var binding = $1;
12885
+ var suffix = $2;
12886
+ var ws = $3;
12887
+ var initializer = $4;
12888
+ const bindingChildren = [...binding.children];
12889
+ if (suffix)
12890
+ bindingChildren.push(suffix);
12891
+ if (ws)
12892
+ bindingChildren.push(...ws);
12893
+ binding = {
12894
+ ...binding,
12895
+ children: bindingChildren
12896
+ };
12713
12897
  return {
12714
- children,
12715
- names: $1.names
12898
+ children: [binding, initializer],
12899
+ names: binding.names,
12900
+ binding,
12901
+ initializer,
12902
+ splices: [],
12903
+ thisAssignments: []
12716
12904
  };
12717
12905
  });
12718
12906
  function LexicalBinding(state) {
@@ -13869,7 +14057,7 @@ ${input.slice(result.pos)}
13869
14057
  }
13870
14058
  }
13871
14059
  var JSSingleLineComment$0 = $TR($EXPECT($R41, fail, "JSSingleLineComment /\\/\\/(?!\\/)[^\\r\\n]*/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13872
- return { $loc, token: $0 };
14060
+ return { type: "Comment", $loc, token: $0 };
13873
14061
  });
13874
14062
  function JSSingleLineComment(state) {
13875
14063
  let eventData;
@@ -13918,7 +14106,7 @@ ${input.slice(result.pos)}
13918
14106
  }
13919
14107
  }
13920
14108
  var JSMultiLineComment$0 = $TV($TEXT($S($EXPECT($L94, fail, 'JSMultiLineComment "/*"'), $Q($S($N($EXPECT($L95, fail, 'JSMultiLineComment "*/"')), $EXPECT($R42, fail, "JSMultiLineComment /./"))), $EXPECT($L95, fail, 'JSMultiLineComment "*/"'))), function($skip, $loc, $0, $1) {
13921
- return { $loc, token: $1 };
14109
+ return { type: "Comment", $loc, token: $1 };
13922
14110
  });
13923
14111
  function JSMultiLineComment(state) {
13924
14112
  let eventData;
@@ -13943,7 +14131,7 @@ ${input.slice(result.pos)}
13943
14131
  }
13944
14132
  }
13945
14133
  var CoffeeSingleLineComment$0 = $TR($EXPECT($R43, fail, "CoffeeSingleLineComment /#(?!##(?!#))([^\\r\\n]*)/"), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
13946
- return { $loc, token: `//${$1}` };
14134
+ return { type: "Comment", $loc, token: `//${$1}` };
13947
14135
  });
13948
14136
  function CoffeeSingleLineComment(state) {
13949
14137
  let eventData;
@@ -13969,7 +14157,7 @@ ${input.slice(result.pos)}
13969
14157
  }
13970
14158
  var CoffeeMultiLineComment$0 = $TS($S(CoffeeHereCommentStart, $TEXT($EXPECT($R44, fail, "CoffeeMultiLineComment /[^]*?###/"))), function($skip, $loc, $0, $1, $2) {
13971
14159
  $2 = $2.slice(0, $2.length - 3).replace(/\*\//g, "* /");
13972
- return { $loc, token: `/*${$2}*/` };
14160
+ return { type: "Comment", $loc, token: `/*${$2}*/` };
13973
14161
  });
13974
14162
  function CoffeeMultiLineComment(state) {
13975
14163
  let eventData;
@@ -17271,7 +17459,7 @@ ${input.slice(result.pos)}
17271
17459
  var pre = $1;
17272
17460
  var exp = $2;
17273
17461
  var post = $3;
17274
- return module.processUnaryExpression(pre, exp, post);
17462
+ return processUnaryExpression(pre, exp, post);
17275
17463
  });
17276
17464
  function InlineJSXUnaryExpression(state) {
17277
17465
  let eventData;
@@ -21161,60 +21349,6 @@ ${input.slice(result.pos)}
21161
21349
  }
21162
21350
  return node;
21163
21351
  };
21164
- module.processUnaryExpression = (pre, exp, post) => {
21165
- if (post?.token === "?") {
21166
- post = {
21167
- $loc: post.$loc,
21168
- token: " != null"
21169
- };
21170
- switch (exp.type) {
21171
- case "Identifier":
21172
- case "Literal":
21173
- return {
21174
- ...exp,
21175
- children: [...pre, ...exp.children, post]
21176
- };
21177
- default:
21178
- const expression = {
21179
- ...exp,
21180
- children: [...pre, "(", exp.children, ")", post]
21181
- };
21182
- return {
21183
- type: "ParenthesizedExpression",
21184
- children: ["(", expression, ")"],
21185
- expression
21186
- };
21187
- }
21188
- }
21189
- if (exp.type === "Literal") {
21190
- if (pre.length === 1 && pre[0].token === "-") {
21191
- const children = [pre[0], ...exp.children];
21192
- if (post)
21193
- exp.children.push(post);
21194
- return {
21195
- type: "Literal",
21196
- children,
21197
- raw: `-${exp.raw}`
21198
- };
21199
- }
21200
- }
21201
- if (exp.children) {
21202
- const children = [...pre, ...exp.children];
21203
- if (post)
21204
- children.push(post);
21205
- return Object.assign({}, exp, { children });
21206
- } else if (Array.isArray(exp)) {
21207
- const children = [...pre, ...exp];
21208
- if (post)
21209
- children.push(post);
21210
- return { children };
21211
- } else {
21212
- const children = [...pre, exp];
21213
- if (post)
21214
- children.push(post);
21215
- return { children };
21216
- }
21217
- };
21218
21352
  module.needsRef = function(expression, base = "ref") {
21219
21353
  switch (expression.type) {
21220
21354
  case "Ref":
@@ -21481,7 +21615,10 @@ ${input.slice(result.pos)}
21481
21615
  if (exp.else)
21482
21616
  insertReturn(exp.else[2]);
21483
21617
  else
21484
- exp.children.push(["\n", indent, wrapWithReturn()]);
21618
+ exp.children.push(["", {
21619
+ type: "ReturnStatement",
21620
+ children: [";return"]
21621
+ }]);
21485
21622
  return;
21486
21623
  case "PatternMatchingStatement":
21487
21624
  insertReturn(exp.children[0][0]);
@@ -21890,11 +22027,15 @@ ${input.slice(result.pos)}
21890
22027
  const [splices, thisAssignments] = gatherBindingCode(parameters, {
21891
22028
  injectParamProps: f.name === "constructor"
21892
22029
  });
22030
+ const delimiter = {
22031
+ type: "SemicolonDelimiter",
22032
+ children: [";"]
22033
+ };
21893
22034
  const prefix = splices.map((s) => ["let ", s]).concat(thisAssignments).map(
21894
22035
  (s) => s.type ? {
21895
22036
  ...s,
21896
- children: [indent, ...s.children, ";\n"]
21897
- } : [indent, s, ";\n"]
22037
+ children: [indent, ...s.children, delimiter]
22038
+ } : [indent, s, delimiter]
21898
22039
  );
21899
22040
  expressions.unshift(...prefix);
21900
22041
  }
@@ -21953,9 +22094,10 @@ ${input.slice(result.pos)}
21953
22094
  getIndent(block.expressions[0]),
21954
22095
  {
21955
22096
  type: "Declaration",
21956
- children: ["let ", ref, returnType, ";\n"],
22097
+ children: ["let ", ref, returnType],
21957
22098
  names: []
21958
- }
22099
+ },
22100
+ ";"
21959
22101
  ]);
21960
22102
  }
21961
22103
  gatherRecursiveWithinFunction(
@@ -21967,7 +22109,7 @@ ${input.slice(result.pos)}
21967
22109
  });
21968
22110
  if (block.children.at(-2)?.type !== "ReturnStatement") {
21969
22111
  block.expressions.push([
21970
- ["\n", getIndent(block.expressions.at(-1))],
22112
+ [getIndent(block.expressions.at(-1))],
21971
22113
  {
21972
22114
  type: "ReturnStatement",
21973
22115
  expression: ref,
@@ -22451,11 +22593,11 @@ ${input.slice(result.pos)}
22451
22593
  let [splices, thisAssignments] = gatherBindingCode(pattern);
22452
22594
  const patternBindings = nonMatcherBindings(pattern);
22453
22595
  splices = splices.map((s2) => [", ", nonMatcherBindings(s2)]);
22454
- thisAssignments = thisAssignments.map((a) => [indent, a, ";\n"]);
22596
+ thisAssignments = thisAssignments.map((a) => [indent, a, ";"]);
22455
22597
  const duplicateDeclarations = aggregateDuplicateBindings([patternBindings, splices]);
22456
- prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";\n"]);
22598
+ prefix.push([indent, "const ", patternBindings, " = ", ref, splices, ";"]);
22457
22599
  prefix.push(...thisAssignments);
22458
- prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";\n"]));
22600
+ prefix.push(...duplicateDeclarations.map((d) => [indent, d, ";"]));
22459
22601
  break;
22460
22602
  }
22461
22603
  }
@@ -22610,6 +22752,11 @@ ${input.slice(result.pos)}
22610
22752
  });
22611
22753
  }
22612
22754
  module.processProgram = function(root) {
22755
+ assert.equal(module.forbidClassImplicitCall.length, 1, "forbidClassImplicitCall");
22756
+ assert.equal(module.forbidIndentedApplication.length, 1, "forbidIndentedApplication");
22757
+ assert.equal(module.forbidTrailingMemberProperty.length, 1, "forbidTrailingMemberProperty");
22758
+ assert.equal(module.forbidMultiLineImplicitObjectLiteral.length, 1, "forbidMultiLineImplicitObjectLiteral");
22759
+ assert.equal(module.JSXTagStack.length, 0, "JSXTagStack should be empty");
22613
22760
  addParentPointers(root);
22614
22761
  const { expressions: statements } = root;
22615
22762
  processPipelineExpressions(statements);
@@ -22703,7 +22850,11 @@ ${input.slice(result.pos)}
22703
22850
  });
22704
22851
  if (varIds.length) {
22705
22852
  const indent = getIndent(statements[0]);
22706
- statements.unshift([indent, "var ", varIds.join(", "), "\n"]);
22853
+ let delimiter = ";";
22854
+ if (statements[0][1]?.parent?.root) {
22855
+ delimiter = ";\n";
22856
+ }
22857
+ statements.unshift([indent, "var ", varIds.join(", "), delimiter]);
22707
22858
  }
22708
22859
  scopes.pop();
22709
22860
  }
@@ -23141,9 +23292,17 @@ ${input.slice(result.pos)}
23141
23292
  processCoffeeInterpolation,
23142
23293
  processConstAssignmentDeclaration,
23143
23294
  processLetAssignmentDeclaration,
23295
+ processUnaryExpression,
23144
23296
  quoteString,
23145
23297
  removeParentPointers
23146
23298
  } = require_lib();
23299
+ var assert = {
23300
+ equal(a, b, msg) {
23301
+ if (a !== b) {
23302
+ throw new Error(`Assertion failed [${msg}]: ${a} !== ${b}`);
23303
+ }
23304
+ }
23305
+ };
23147
23306
  }
23148
23307
  });
23149
23308
 
@@ -23580,7 +23739,7 @@ ${input.slice(result.pos)}
23580
23739
  var uncacheable;
23581
23740
  ({ parse } = import_parser.default);
23582
23741
  ({ SourceMap: SourceMap2, base64Encode: base64Encode2 } = util_exports);
23583
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23742
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidTrailingMemberProperty", "FunctionDeclaration", "FunctionExpression", "HoistableDeclaration", "ImplicitArguments", "ImplicitInlineObjectPropertyDelimiter", "ImplicitNestedBlock", "IndentedApplicationAllowed", "IndentedFurther", "IndentedJSXChildExpression", "InlineObjectLiteral", "InsertIndent", "JSXChild", "JSXChildren", "JSXElement", "JSXFragment", "JSXImplicitFragment", "JSXMixedChildren", "JSXNested", "JSXNestedChildren", "JSXOptionalClosingElement", "JSXOptionalClosingFragment", "JSXTag", "LeftHandSideExpression", "MemberExpression", "MemberExpressionRest", "Nested", "NestedBindingElement", "NestedBindingElements", "NestedBlockExpression", "NestedBlockExpression", "NestedBlockStatement", "NestedBlockStatements", "NestedClassSignatureElement", "NestedClassSignatureElements", "NestedDeclareElement", "NestedDeclareElements", "NestedElement", "NestedElementList", "NestedImplicitObjectLiteral", "NestedImplicitPropertyDefinition", "NestedImplicitPropertyDefinitions", "NestedInterfaceProperty", "NestedJSXChildExpression", "NestedModuleItem", "NestedModuleItems", "NestedObject", "NestedPropertyDefinitions", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23584
23743
  var compile = function(src, options) {
23585
23744
  var ast, code, events, filename, ref, result, sm, srcMapJSON;
23586
23745
  if (!options) {