@danielx/civet 0.6.1 → 0.6.2

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
@@ -31,6 +31,18 @@ var Civet = (() => {
31
31
  var require_lib = __commonJS({
32
32
  "source/lib.js"(exports, module) {
33
33
  "use strict";
34
+ function aliasBinding(p, ref) {
35
+ if (p.type === "Identifier") {
36
+ p.children[0] = ref;
37
+ } else if (p.type === "BindingRestElement") {
38
+ aliasBinding(p.binding, ref);
39
+ } else if (p.value?.type === "Identifier") {
40
+ aliasBinding(p.value, ref);
41
+ } else {
42
+ p.value = ref;
43
+ p.children.push(": ", ref);
44
+ }
45
+ }
34
46
  function blockWithPrefix(prefixStatements, block) {
35
47
  if (prefixStatements && prefixStatements.length) {
36
48
  const indent = getIndent(block.expressions[0]);
@@ -608,6 +620,7 @@ var Civet = (() => {
608
620
  };
609
621
  }
610
622
  module.exports = {
623
+ aliasBinding,
611
624
  blockWithPrefix,
612
625
  clone,
613
626
  convertMethodToFunction,
@@ -1298,6 +1311,8 @@ ${input.slice(result.pos)}
1298
1311
  NestedCaseClauses,
1299
1312
  NestedCaseClause,
1300
1313
  CaseClause,
1314
+ PatternExpressionList,
1315
+ ConditionFragment,
1301
1316
  CaseExpressionList,
1302
1317
  ImpliedColon,
1303
1318
  TryStatement,
@@ -1601,6 +1616,7 @@ ${input.slice(result.pos)}
1601
1616
  ImportType,
1602
1617
  TypeTuple,
1603
1618
  TypeList,
1619
+ TypeElement,
1604
1620
  NestedTypeList,
1605
1621
  NestedType,
1606
1622
  TypeConditional,
@@ -4893,13 +4909,8 @@ ${input.slice(result.pos)}
4893
4909
  var close = $7;
4894
4910
  const names = pes.flatMap((p) => p.names);
4895
4911
  if (rest) {
4896
- let restIdentifier;
4897
- if (rest.binding.ref) {
4898
- restIdentifier = rest.binding.ref;
4899
- } else {
4900
- names.push(...rest.names);
4901
- restIdentifier = rest.names[0];
4902
- }
4912
+ const restIdentifier = rest.binding.ref || rest.binding;
4913
+ names.push(...rest.names || []);
4903
4914
  let blockPrefix;
4904
4915
  if (after.length) {
4905
4916
  blockPrefix = {
@@ -4957,7 +4968,7 @@ ${input.slice(result.pos)}
4957
4968
  type: "FunctionRestParameter",
4958
4969
  children: $0,
4959
4970
  names: id.names,
4960
- binding: id
4971
+ binding: id.binding
4961
4972
  };
4962
4973
  });
4963
4974
  function FunctionRestParameter(state) {
@@ -5721,8 +5732,11 @@ ${input.slice(result.pos)}
5721
5732
  var dots = $2;
5722
5733
  var binding = $3;
5723
5734
  return {
5724
- ...binding,
5725
- children: [...ws || [], dots, ...binding.children],
5735
+ type: "BindingRestElement",
5736
+ children: [...ws || [], dots, binding],
5737
+ binding,
5738
+ name: binding.name,
5739
+ names: binding.names,
5726
5740
  rest: true
5727
5741
  };
5728
5742
  });
@@ -5731,8 +5745,11 @@ ${input.slice(result.pos)}
5731
5745
  var binding = $2;
5732
5746
  var dots = $3;
5733
5747
  return {
5734
- ...binding,
5735
- children: [...ws || [], dots, ...binding.children],
5748
+ type: "BindingRestElement",
5749
+ children: [...ws || [], dots, binding],
5750
+ binding,
5751
+ name: binding.name,
5752
+ names: binding.names,
5736
5753
  rest: true
5737
5754
  };
5738
5755
  });
@@ -10610,33 +10627,20 @@ ${input.slice(result.pos)}
10610
10627
  return result;
10611
10628
  }
10612
10629
  }
10613
- var CaseClause$0 = $TS($S(BindingPattern, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10614
- var pattern = $1;
10615
- var block = $2;
10616
- return {
10617
- type: "PatternClause",
10618
- children: $0,
10619
- block,
10620
- pattern
10621
- };
10622
- });
10623
- var CaseClause$1 = $TS($S($P(SingleLineBinaryOpRHS), $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10624
- var pattern = $1;
10630
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10631
+ var patterns = $1;
10625
10632
  var block = $2;
10626
10633
  return {
10627
10634
  type: "PatternClause",
10628
10635
  children: $0,
10629
10636
  block,
10630
- pattern: {
10631
- type: "ConditionFragment",
10632
- children: pattern
10633
- }
10637
+ patterns
10634
10638
  };
10635
10639
  });
10636
- var CaseClause$2 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10640
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10637
10641
  return { "type": "CaseClause", "children": value };
10638
10642
  });
10639
- var CaseClause$3 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10643
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10640
10644
  var cases = $2;
10641
10645
  var block = $4;
10642
10646
  var b = $5;
@@ -10648,7 +10652,7 @@ ${input.slice(result.pos)}
10648
10652
  children: $0
10649
10653
  };
10650
10654
  });
10651
- var CaseClause$4 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10655
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10652
10656
  var block = $3;
10653
10657
  return {
10654
10658
  type: "DefaultClause",
@@ -10656,7 +10660,7 @@ ${input.slice(result.pos)}
10656
10660
  children: $0
10657
10661
  };
10658
10662
  });
10659
- var CaseClause$5 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10663
+ var CaseClause$4 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10660
10664
  var block = $3;
10661
10665
  $1.token = "default";
10662
10666
  return {
@@ -10676,17 +10680,74 @@ ${input.slice(result.pos)}
10676
10680
  }
10677
10681
  }
10678
10682
  if (state.tokenize) {
10679
- const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state));
10683
+ const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state));
10680
10684
  if (state.events)
10681
10685
  state.events.exit?.("CaseClause", state, result, eventData);
10682
10686
  return result;
10683
10687
  } else {
10684
- const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state);
10688
+ const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state);
10685
10689
  if (state.events)
10686
10690
  state.events.exit?.("CaseClause", state, result, eventData);
10687
10691
  return result;
10688
10692
  }
10689
10693
  }
10694
+ var PatternExpressionList$0 = $TS($S(ConditionFragment, $Q($S($E(_), Comma, $E(_), ConditionFragment))), function($skip, $loc, $0, $1, $2) {
10695
+ var first = $1;
10696
+ var rest = $2;
10697
+ return [first, ...rest.map(([, , , p]) => p)];
10698
+ });
10699
+ function PatternExpressionList(state) {
10700
+ let eventData;
10701
+ if (state.events) {
10702
+ const result = state.events.enter?.("PatternExpressionList", state);
10703
+ if (result) {
10704
+ if (result.cache)
10705
+ return result.cache;
10706
+ eventData = result.data;
10707
+ }
10708
+ }
10709
+ if (state.tokenize) {
10710
+ const result = $TOKEN("PatternExpressionList", state, PatternExpressionList$0(state));
10711
+ if (state.events)
10712
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10713
+ return result;
10714
+ } else {
10715
+ const result = PatternExpressionList$0(state);
10716
+ if (state.events)
10717
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10718
+ return result;
10719
+ }
10720
+ }
10721
+ var ConditionFragment$0 = BindingPattern;
10722
+ var ConditionFragment$1 = $TV($P(SingleLineBinaryOpRHS), function($skip, $loc, $0, $1) {
10723
+ var pattern = $0;
10724
+ return {
10725
+ type: "ConditionFragment",
10726
+ children: pattern
10727
+ };
10728
+ });
10729
+ function ConditionFragment(state) {
10730
+ let eventData;
10731
+ if (state.events) {
10732
+ const result = state.events.enter?.("ConditionFragment", state);
10733
+ if (result) {
10734
+ if (result.cache)
10735
+ return result.cache;
10736
+ eventData = result.data;
10737
+ }
10738
+ }
10739
+ if (state.tokenize) {
10740
+ const result = $TOKEN("ConditionFragment", state, ConditionFragment$0(state) || ConditionFragment$1(state));
10741
+ if (state.events)
10742
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10743
+ return result;
10744
+ } else {
10745
+ const result = ConditionFragment$0(state) || ConditionFragment$1(state);
10746
+ if (state.events)
10747
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10748
+ return result;
10749
+ }
10750
+ }
10690
10751
  var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithIndentedApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithIndentedApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
10691
10752
  var first = $2;
10692
10753
  var rest = $3;
@@ -19183,7 +19244,7 @@ ${input.slice(result.pos)}
19183
19244
  return result;
19184
19245
  }
19185
19246
  }
19186
- var TypeList$0 = $S(Type, $Q($S(__, Comma, Type)));
19247
+ var TypeList$0 = $S(TypeElement, $Q($S(__, Comma, TypeElement)));
19187
19248
  function TypeList(state) {
19188
19249
  let eventData;
19189
19250
  if (state.events) {
@@ -19206,6 +19267,36 @@ ${input.slice(result.pos)}
19206
19267
  return result;
19207
19268
  }
19208
19269
  }
19270
+ var TypeElement$0 = $S($S(__, DotDotDot, __), Type);
19271
+ var TypeElement$1 = $TS($S(Type, $E($S($E(_), DotDotDot))), function($skip, $loc, $0, $1, $2) {
19272
+ var type = $1;
19273
+ var dots = $2;
19274
+ if (!dots)
19275
+ return type;
19276
+ return [dots, type];
19277
+ });
19278
+ function TypeElement(state) {
19279
+ let eventData;
19280
+ if (state.events) {
19281
+ const result = state.events.enter?.("TypeElement", state);
19282
+ if (result) {
19283
+ if (result.cache)
19284
+ return result.cache;
19285
+ eventData = result.data;
19286
+ }
19287
+ }
19288
+ if (state.tokenize) {
19289
+ const result = $TOKEN("TypeElement", state, TypeElement$0(state) || TypeElement$1(state));
19290
+ if (state.events)
19291
+ state.events.exit?.("TypeElement", state, result, eventData);
19292
+ return result;
19293
+ } else {
19294
+ const result = TypeElement$0(state) || TypeElement$1(state);
19295
+ if (state.events)
19296
+ state.events.exit?.("TypeElement", state, result, eventData);
19297
+ return result;
19298
+ }
19299
+ }
19209
19300
  var NestedTypeList$0 = $TS($S(PushIndent, $Q(NestedType), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
19210
19301
  var types = $2;
19211
19302
  if (types.length)
@@ -21795,8 +21886,8 @@ ${input.slice(result.pos)}
21795
21886
  module.adjustBindingElements = function(elements) {
21796
21887
  const names = elements.flatMap((p) => p.names || []), { length } = elements;
21797
21888
  let blockPrefix, restIndex = -1, restCount = 0;
21798
- elements.forEach(({ rest }, i) => {
21799
- if (rest) {
21889
+ elements.forEach(({ type }, i) => {
21890
+ if (type === "BindingRestElement") {
21800
21891
  if (restIndex < 0)
21801
21892
  restIndex = i;
21802
21893
  restCount++;
@@ -21812,13 +21903,8 @@ ${input.slice(result.pos)}
21812
21903
  } else if (restCount === 1) {
21813
21904
  const rest = elements[restIndex];
21814
21905
  const after = elements.slice(restIndex + 1);
21815
- let restIdentifier;
21816
- if (rest.ref) {
21817
- restIdentifier = rest.ref;
21818
- } else {
21819
- restIdentifier = rest.names[0];
21820
- names.push(...rest.names);
21821
- }
21906
+ const restIdentifier = rest.binding.ref || rest.binding;
21907
+ names.push(...rest.names || []);
21822
21908
  if (after.length) {
21823
21909
  blockPrefix = {
21824
21910
  type: "PostRestBindingElements",
@@ -22292,7 +22378,11 @@ ${input.slice(result.pos)}
22292
22378
  }
22293
22379
  }
22294
22380
  function elideMatchersFromArrayBindings(elements) {
22295
- return elements.map(({ children: [ws, e, sep] }) => {
22381
+ return elements.map((el) => {
22382
+ if (el.type === "BindingRestElement") {
22383
+ return ["", el, void 0];
22384
+ }
22385
+ const { children: [ws, e, sep] } = el;
22296
22386
  switch (e.type) {
22297
22387
  case "Literal":
22298
22388
  case "RegularExpressionLiteral":
@@ -22339,8 +22429,15 @@ ${input.slice(result.pos)}
22339
22429
  }
22340
22430
  function nonMatcherBindings(pattern) {
22341
22431
  switch (pattern.type) {
22342
- case "ArrayBindingPattern":
22343
- return ["[", elideMatchersFromArrayBindings(pattern.elements), "]"];
22432
+ case "ArrayBindingPattern": {
22433
+ const elements = elideMatchersFromArrayBindings(pattern.elements);
22434
+ const children = ["[", elements, "]"];
22435
+ return {
22436
+ ...pattern,
22437
+ children,
22438
+ elements
22439
+ };
22440
+ }
22344
22441
  case "PostRestBindingElements": {
22345
22442
  const els = elideMatchersFromArrayBindings(pattern.children[1]);
22346
22443
  return {
@@ -22360,11 +22457,25 @@ ${input.slice(result.pos)}
22360
22457
  }
22361
22458
  function aggregateDuplicateBindings(bindings) {
22362
22459
  const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
22460
+ const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
22461
+ arrayBindings.forEach((a) => {
22462
+ const { elements } = a;
22463
+ elements.forEach((element) => {
22464
+ if (Array.isArray(element)) {
22465
+ const [, e] = element;
22466
+ if (e.type === "Identifier") {
22467
+ props.push(e);
22468
+ } else if (e.type === "BindingRestElement") {
22469
+ props.push(e);
22470
+ }
22471
+ }
22472
+ });
22473
+ });
22363
22474
  const declarations = [];
22364
22475
  const propsGroupedByName = /* @__PURE__ */ new Map();
22365
22476
  for (const p of props) {
22366
22477
  const { name, value } = p;
22367
- const key = value?.name || name.name;
22478
+ const key = value?.name || name?.name || name;
22368
22479
  if (propsGroupedByName.has(key)) {
22369
22480
  propsGroupedByName.get(key).push(p);
22370
22481
  } else {
@@ -22384,7 +22495,7 @@ ${input.slice(result.pos)}
22384
22495
  base: `_${key}`,
22385
22496
  id: key
22386
22497
  };
22387
- p.children.push(": ", ref);
22498
+ aliasBinding(p, ref);
22388
22499
  });
22389
22500
  return;
22390
22501
  }
@@ -22396,7 +22507,7 @@ ${input.slice(result.pos)}
22396
22507
  base: key,
22397
22508
  id: key
22398
22509
  };
22399
- p.children.push(": ", ref);
22510
+ aliasBinding(p, ref);
22400
22511
  return ref;
22401
22512
  });
22402
22513
  declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
@@ -22437,18 +22548,28 @@ ${input.slice(result.pos)}
22437
22548
  prev.push(c.block);
22438
22549
  return;
22439
22550
  }
22440
- let { pattern, block } = c;
22551
+ let { patterns, block } = c;
22552
+ let pattern = patterns[0];
22441
22553
  const indent = block.expressions?.[0]?.[0] || "";
22442
- const conditions = [];
22443
- getPatternConditions(pattern, ref, conditions);
22444
- const condition = {
22445
- type: "ParenthesizedExpression",
22446
- children: ["(", conditions.map((c2, i2) => {
22447
- if (i2 === 0)
22554
+ const alternativeConditions = patterns.map((pattern2, i2) => {
22555
+ const conditions = [];
22556
+ getPatternConditions(pattern2, ref, conditions);
22557
+ return conditions;
22558
+ });
22559
+ const conditionExpression = alternativeConditions.map((conditions, i2) => {
22560
+ const conditionArray = conditions.map((c2, i3) => {
22561
+ if (i3 === 0)
22448
22562
  return c2;
22449
22563
  return [" && ", ...c2];
22450
- }), ")"],
22451
- expression: conditions
22564
+ });
22565
+ if (i2 === 0)
22566
+ return conditionArray;
22567
+ return [" || ", ...conditionArray];
22568
+ });
22569
+ const condition = {
22570
+ type: "ParenthesizedExpression",
22571
+ children: ["(", conditionExpression, ")"],
22572
+ expression: conditionExpression
22452
22573
  };
22453
22574
  const prefix = [];
22454
22575
  switch (pattern.type) {
@@ -23162,6 +23283,7 @@ ${input.slice(result.pos)}
23162
23283
  exports.parse = parse2;
23163
23284
  exports.default = { parse: parse2 };
23164
23285
  var {
23286
+ aliasBinding,
23165
23287
  blockWithPrefix,
23166
23288
  clone,
23167
23289
  convertMethodToFunction,
@@ -23633,7 +23755,7 @@ ${input.slice(result.pos)}
23633
23755
  var uncacheable;
23634
23756
  ({ parse } = import_parser.default);
23635
23757
  ({ SourceMap: SourceMap2 } = util_exports);
23636
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23758
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "ConditionFragment", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PatternExpressionList", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23637
23759
  var compile = function(src, options) {
23638
23760
  var ast, code, events, filename, ref, result, sm;
23639
23761
  if (!options) {
package/dist/main.js CHANGED
@@ -30,6 +30,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
30
30
  var require_lib = __commonJS({
31
31
  "source/lib.js"(exports, module2) {
32
32
  "use strict";
33
+ function aliasBinding(p, ref) {
34
+ if (p.type === "Identifier") {
35
+ p.children[0] = ref;
36
+ } else if (p.type === "BindingRestElement") {
37
+ aliasBinding(p.binding, ref);
38
+ } else if (p.value?.type === "Identifier") {
39
+ aliasBinding(p.value, ref);
40
+ } else {
41
+ p.value = ref;
42
+ p.children.push(": ", ref);
43
+ }
44
+ }
33
45
  function blockWithPrefix(prefixStatements, block) {
34
46
  if (prefixStatements && prefixStatements.length) {
35
47
  const indent = getIndent(block.expressions[0]);
@@ -607,6 +619,7 @@ var require_lib = __commonJS({
607
619
  };
608
620
  }
609
621
  module2.exports = {
622
+ aliasBinding,
610
623
  blockWithPrefix,
611
624
  clone,
612
625
  convertMethodToFunction,
@@ -1297,6 +1310,8 @@ ${input.slice(result.pos)}
1297
1310
  NestedCaseClauses,
1298
1311
  NestedCaseClause,
1299
1312
  CaseClause,
1313
+ PatternExpressionList,
1314
+ ConditionFragment,
1300
1315
  CaseExpressionList,
1301
1316
  ImpliedColon,
1302
1317
  TryStatement,
@@ -1600,6 +1615,7 @@ ${input.slice(result.pos)}
1600
1615
  ImportType,
1601
1616
  TypeTuple,
1602
1617
  TypeList,
1618
+ TypeElement,
1603
1619
  NestedTypeList,
1604
1620
  NestedType,
1605
1621
  TypeConditional,
@@ -4892,13 +4908,8 @@ ${input.slice(result.pos)}
4892
4908
  var close = $7;
4893
4909
  const names = pes.flatMap((p) => p.names);
4894
4910
  if (rest) {
4895
- let restIdentifier;
4896
- if (rest.binding.ref) {
4897
- restIdentifier = rest.binding.ref;
4898
- } else {
4899
- names.push(...rest.names);
4900
- restIdentifier = rest.names[0];
4901
- }
4911
+ const restIdentifier = rest.binding.ref || rest.binding;
4912
+ names.push(...rest.names || []);
4902
4913
  let blockPrefix;
4903
4914
  if (after.length) {
4904
4915
  blockPrefix = {
@@ -4956,7 +4967,7 @@ ${input.slice(result.pos)}
4956
4967
  type: "FunctionRestParameter",
4957
4968
  children: $0,
4958
4969
  names: id.names,
4959
- binding: id
4970
+ binding: id.binding
4960
4971
  };
4961
4972
  });
4962
4973
  function FunctionRestParameter(state) {
@@ -5720,8 +5731,11 @@ ${input.slice(result.pos)}
5720
5731
  var dots = $2;
5721
5732
  var binding = $3;
5722
5733
  return {
5723
- ...binding,
5724
- children: [...ws || [], dots, ...binding.children],
5734
+ type: "BindingRestElement",
5735
+ children: [...ws || [], dots, binding],
5736
+ binding,
5737
+ name: binding.name,
5738
+ names: binding.names,
5725
5739
  rest: true
5726
5740
  };
5727
5741
  });
@@ -5730,8 +5744,11 @@ ${input.slice(result.pos)}
5730
5744
  var binding = $2;
5731
5745
  var dots = $3;
5732
5746
  return {
5733
- ...binding,
5734
- children: [...ws || [], dots, ...binding.children],
5747
+ type: "BindingRestElement",
5748
+ children: [...ws || [], dots, binding],
5749
+ binding,
5750
+ name: binding.name,
5751
+ names: binding.names,
5735
5752
  rest: true
5736
5753
  };
5737
5754
  });
@@ -10609,33 +10626,20 @@ ${input.slice(result.pos)}
10609
10626
  return result;
10610
10627
  }
10611
10628
  }
10612
- var CaseClause$0 = $TS($S(BindingPattern, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10613
- var pattern = $1;
10614
- var block = $2;
10615
- return {
10616
- type: "PatternClause",
10617
- children: $0,
10618
- block,
10619
- pattern
10620
- };
10621
- });
10622
- var CaseClause$1 = $TS($S($P(SingleLineBinaryOpRHS), $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10623
- var pattern = $1;
10629
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10630
+ var patterns = $1;
10624
10631
  var block = $2;
10625
10632
  return {
10626
10633
  type: "PatternClause",
10627
10634
  children: $0,
10628
10635
  block,
10629
- pattern: {
10630
- type: "ConditionFragment",
10631
- children: pattern
10632
- }
10636
+ patterns
10633
10637
  };
10634
10638
  });
10635
- var CaseClause$2 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10639
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10636
10640
  return { "type": "CaseClause", "children": value };
10637
10641
  });
10638
- var CaseClause$3 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10642
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10639
10643
  var cases = $2;
10640
10644
  var block = $4;
10641
10645
  var b = $5;
@@ -10647,7 +10651,7 @@ ${input.slice(result.pos)}
10647
10651
  children: $0
10648
10652
  };
10649
10653
  });
10650
- var CaseClause$4 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10654
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10651
10655
  var block = $3;
10652
10656
  return {
10653
10657
  type: "DefaultClause",
@@ -10655,7 +10659,7 @@ ${input.slice(result.pos)}
10655
10659
  children: $0
10656
10660
  };
10657
10661
  });
10658
- var CaseClause$5 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10662
+ var CaseClause$4 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10659
10663
  var block = $3;
10660
10664
  $1.token = "default";
10661
10665
  return {
@@ -10675,17 +10679,74 @@ ${input.slice(result.pos)}
10675
10679
  }
10676
10680
  }
10677
10681
  if (state.tokenize) {
10678
- const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state));
10682
+ const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state));
10679
10683
  if (state.events)
10680
10684
  state.events.exit?.("CaseClause", state, result, eventData);
10681
10685
  return result;
10682
10686
  } else {
10683
- const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state);
10687
+ const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state);
10684
10688
  if (state.events)
10685
10689
  state.events.exit?.("CaseClause", state, result, eventData);
10686
10690
  return result;
10687
10691
  }
10688
10692
  }
10693
+ var PatternExpressionList$0 = $TS($S(ConditionFragment, $Q($S($E(_), Comma, $E(_), ConditionFragment))), function($skip, $loc, $0, $1, $2) {
10694
+ var first = $1;
10695
+ var rest = $2;
10696
+ return [first, ...rest.map(([, , , p]) => p)];
10697
+ });
10698
+ function PatternExpressionList(state) {
10699
+ let eventData;
10700
+ if (state.events) {
10701
+ const result = state.events.enter?.("PatternExpressionList", state);
10702
+ if (result) {
10703
+ if (result.cache)
10704
+ return result.cache;
10705
+ eventData = result.data;
10706
+ }
10707
+ }
10708
+ if (state.tokenize) {
10709
+ const result = $TOKEN("PatternExpressionList", state, PatternExpressionList$0(state));
10710
+ if (state.events)
10711
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10712
+ return result;
10713
+ } else {
10714
+ const result = PatternExpressionList$0(state);
10715
+ if (state.events)
10716
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10717
+ return result;
10718
+ }
10719
+ }
10720
+ var ConditionFragment$0 = BindingPattern;
10721
+ var ConditionFragment$1 = $TV($P(SingleLineBinaryOpRHS), function($skip, $loc, $0, $1) {
10722
+ var pattern = $0;
10723
+ return {
10724
+ type: "ConditionFragment",
10725
+ children: pattern
10726
+ };
10727
+ });
10728
+ function ConditionFragment(state) {
10729
+ let eventData;
10730
+ if (state.events) {
10731
+ const result = state.events.enter?.("ConditionFragment", state);
10732
+ if (result) {
10733
+ if (result.cache)
10734
+ return result.cache;
10735
+ eventData = result.data;
10736
+ }
10737
+ }
10738
+ if (state.tokenize) {
10739
+ const result = $TOKEN("ConditionFragment", state, ConditionFragment$0(state) || ConditionFragment$1(state));
10740
+ if (state.events)
10741
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10742
+ return result;
10743
+ } else {
10744
+ const result = ConditionFragment$0(state) || ConditionFragment$1(state);
10745
+ if (state.events)
10746
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10747
+ return result;
10748
+ }
10749
+ }
10689
10750
  var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithIndentedApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithIndentedApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
10690
10751
  var first = $2;
10691
10752
  var rest = $3;
@@ -19182,7 +19243,7 @@ ${input.slice(result.pos)}
19182
19243
  return result;
19183
19244
  }
19184
19245
  }
19185
- var TypeList$0 = $S(Type, $Q($S(__, Comma, Type)));
19246
+ var TypeList$0 = $S(TypeElement, $Q($S(__, Comma, TypeElement)));
19186
19247
  function TypeList(state) {
19187
19248
  let eventData;
19188
19249
  if (state.events) {
@@ -19205,6 +19266,36 @@ ${input.slice(result.pos)}
19205
19266
  return result;
19206
19267
  }
19207
19268
  }
19269
+ var TypeElement$0 = $S($S(__, DotDotDot, __), Type);
19270
+ var TypeElement$1 = $TS($S(Type, $E($S($E(_), DotDotDot))), function($skip, $loc, $0, $1, $2) {
19271
+ var type = $1;
19272
+ var dots = $2;
19273
+ if (!dots)
19274
+ return type;
19275
+ return [dots, type];
19276
+ });
19277
+ function TypeElement(state) {
19278
+ let eventData;
19279
+ if (state.events) {
19280
+ const result = state.events.enter?.("TypeElement", state);
19281
+ if (result) {
19282
+ if (result.cache)
19283
+ return result.cache;
19284
+ eventData = result.data;
19285
+ }
19286
+ }
19287
+ if (state.tokenize) {
19288
+ const result = $TOKEN("TypeElement", state, TypeElement$0(state) || TypeElement$1(state));
19289
+ if (state.events)
19290
+ state.events.exit?.("TypeElement", state, result, eventData);
19291
+ return result;
19292
+ } else {
19293
+ const result = TypeElement$0(state) || TypeElement$1(state);
19294
+ if (state.events)
19295
+ state.events.exit?.("TypeElement", state, result, eventData);
19296
+ return result;
19297
+ }
19298
+ }
19208
19299
  var NestedTypeList$0 = $TS($S(PushIndent, $Q(NestedType), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
19209
19300
  var types = $2;
19210
19301
  if (types.length)
@@ -21794,8 +21885,8 @@ ${input.slice(result.pos)}
21794
21885
  module2.adjustBindingElements = function(elements) {
21795
21886
  const names = elements.flatMap((p) => p.names || []), { length } = elements;
21796
21887
  let blockPrefix, restIndex = -1, restCount = 0;
21797
- elements.forEach(({ rest }, i) => {
21798
- if (rest) {
21888
+ elements.forEach(({ type }, i) => {
21889
+ if (type === "BindingRestElement") {
21799
21890
  if (restIndex < 0)
21800
21891
  restIndex = i;
21801
21892
  restCount++;
@@ -21811,13 +21902,8 @@ ${input.slice(result.pos)}
21811
21902
  } else if (restCount === 1) {
21812
21903
  const rest = elements[restIndex];
21813
21904
  const after = elements.slice(restIndex + 1);
21814
- let restIdentifier;
21815
- if (rest.ref) {
21816
- restIdentifier = rest.ref;
21817
- } else {
21818
- restIdentifier = rest.names[0];
21819
- names.push(...rest.names);
21820
- }
21905
+ const restIdentifier = rest.binding.ref || rest.binding;
21906
+ names.push(...rest.names || []);
21821
21907
  if (after.length) {
21822
21908
  blockPrefix = {
21823
21909
  type: "PostRestBindingElements",
@@ -22291,7 +22377,11 @@ ${input.slice(result.pos)}
22291
22377
  }
22292
22378
  }
22293
22379
  function elideMatchersFromArrayBindings(elements) {
22294
- return elements.map(({ children: [ws, e, sep] }) => {
22380
+ return elements.map((el) => {
22381
+ if (el.type === "BindingRestElement") {
22382
+ return ["", el, void 0];
22383
+ }
22384
+ const { children: [ws, e, sep] } = el;
22295
22385
  switch (e.type) {
22296
22386
  case "Literal":
22297
22387
  case "RegularExpressionLiteral":
@@ -22338,8 +22428,15 @@ ${input.slice(result.pos)}
22338
22428
  }
22339
22429
  function nonMatcherBindings(pattern) {
22340
22430
  switch (pattern.type) {
22341
- case "ArrayBindingPattern":
22342
- return ["[", elideMatchersFromArrayBindings(pattern.elements), "]"];
22431
+ case "ArrayBindingPattern": {
22432
+ const elements = elideMatchersFromArrayBindings(pattern.elements);
22433
+ const children = ["[", elements, "]"];
22434
+ return {
22435
+ ...pattern,
22436
+ children,
22437
+ elements
22438
+ };
22439
+ }
22343
22440
  case "PostRestBindingElements": {
22344
22441
  const els = elideMatchersFromArrayBindings(pattern.children[1]);
22345
22442
  return {
@@ -22359,11 +22456,25 @@ ${input.slice(result.pos)}
22359
22456
  }
22360
22457
  function aggregateDuplicateBindings(bindings) {
22361
22458
  const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
22459
+ const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
22460
+ arrayBindings.forEach((a) => {
22461
+ const { elements } = a;
22462
+ elements.forEach((element) => {
22463
+ if (Array.isArray(element)) {
22464
+ const [, e] = element;
22465
+ if (e.type === "Identifier") {
22466
+ props.push(e);
22467
+ } else if (e.type === "BindingRestElement") {
22468
+ props.push(e);
22469
+ }
22470
+ }
22471
+ });
22472
+ });
22362
22473
  const declarations = [];
22363
22474
  const propsGroupedByName = /* @__PURE__ */ new Map();
22364
22475
  for (const p of props) {
22365
22476
  const { name, value } = p;
22366
- const key = value?.name || name.name;
22477
+ const key = value?.name || name?.name || name;
22367
22478
  if (propsGroupedByName.has(key)) {
22368
22479
  propsGroupedByName.get(key).push(p);
22369
22480
  } else {
@@ -22383,7 +22494,7 @@ ${input.slice(result.pos)}
22383
22494
  base: `_${key}`,
22384
22495
  id: key
22385
22496
  };
22386
- p.children.push(": ", ref);
22497
+ aliasBinding(p, ref);
22387
22498
  });
22388
22499
  return;
22389
22500
  }
@@ -22395,7 +22506,7 @@ ${input.slice(result.pos)}
22395
22506
  base: key,
22396
22507
  id: key
22397
22508
  };
22398
- p.children.push(": ", ref);
22509
+ aliasBinding(p, ref);
22399
22510
  return ref;
22400
22511
  });
22401
22512
  declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
@@ -22436,18 +22547,28 @@ ${input.slice(result.pos)}
22436
22547
  prev.push(c.block);
22437
22548
  return;
22438
22549
  }
22439
- let { pattern, block } = c;
22550
+ let { patterns, block } = c;
22551
+ let pattern = patterns[0];
22440
22552
  const indent = block.expressions?.[0]?.[0] || "";
22441
- const conditions = [];
22442
- getPatternConditions(pattern, ref, conditions);
22443
- const condition = {
22444
- type: "ParenthesizedExpression",
22445
- children: ["(", conditions.map((c2, i2) => {
22446
- if (i2 === 0)
22553
+ const alternativeConditions = patterns.map((pattern2, i2) => {
22554
+ const conditions = [];
22555
+ getPatternConditions(pattern2, ref, conditions);
22556
+ return conditions;
22557
+ });
22558
+ const conditionExpression = alternativeConditions.map((conditions, i2) => {
22559
+ const conditionArray = conditions.map((c2, i3) => {
22560
+ if (i3 === 0)
22447
22561
  return c2;
22448
22562
  return [" && ", ...c2];
22449
- }), ")"],
22450
- expression: conditions
22563
+ });
22564
+ if (i2 === 0)
22565
+ return conditionArray;
22566
+ return [" || ", ...conditionArray];
22567
+ });
22568
+ const condition = {
22569
+ type: "ParenthesizedExpression",
22570
+ children: ["(", conditionExpression, ")"],
22571
+ expression: conditionExpression
22451
22572
  };
22452
22573
  const prefix = [];
22453
22574
  switch (pattern.type) {
@@ -23161,6 +23282,7 @@ ${input.slice(result.pos)}
23161
23282
  exports.parse = parse2;
23162
23283
  exports.default = { parse: parse2 };
23163
23284
  var {
23285
+ aliasBinding,
23164
23286
  blockWithPrefix,
23165
23287
  clone,
23166
23288
  convertMethodToFunction,
@@ -23633,7 +23755,7 @@ var parse;
23633
23755
  var uncacheable;
23634
23756
  ({ parse } = import_parser.default);
23635
23757
  ({ SourceMap: SourceMap2 } = util_exports);
23636
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23758
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "ConditionFragment", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PatternExpressionList", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23637
23759
  var compile = function(src, options) {
23638
23760
  var ast, code, events, filename, ref, result, sm;
23639
23761
  if (!options) {
package/dist/main.mjs CHANGED
@@ -28,6 +28,18 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var require_lib = __commonJS({
29
29
  "source/lib.js"(exports, module) {
30
30
  "use strict";
31
+ function aliasBinding(p, ref) {
32
+ if (p.type === "Identifier") {
33
+ p.children[0] = ref;
34
+ } else if (p.type === "BindingRestElement") {
35
+ aliasBinding(p.binding, ref);
36
+ } else if (p.value?.type === "Identifier") {
37
+ aliasBinding(p.value, ref);
38
+ } else {
39
+ p.value = ref;
40
+ p.children.push(": ", ref);
41
+ }
42
+ }
31
43
  function blockWithPrefix(prefixStatements, block) {
32
44
  if (prefixStatements && prefixStatements.length) {
33
45
  const indent = getIndent(block.expressions[0]);
@@ -605,6 +617,7 @@ var require_lib = __commonJS({
605
617
  };
606
618
  }
607
619
  module.exports = {
620
+ aliasBinding,
608
621
  blockWithPrefix,
609
622
  clone,
610
623
  convertMethodToFunction,
@@ -1295,6 +1308,8 @@ ${input.slice(result.pos)}
1295
1308
  NestedCaseClauses,
1296
1309
  NestedCaseClause,
1297
1310
  CaseClause,
1311
+ PatternExpressionList,
1312
+ ConditionFragment,
1298
1313
  CaseExpressionList,
1299
1314
  ImpliedColon,
1300
1315
  TryStatement,
@@ -1598,6 +1613,7 @@ ${input.slice(result.pos)}
1598
1613
  ImportType,
1599
1614
  TypeTuple,
1600
1615
  TypeList,
1616
+ TypeElement,
1601
1617
  NestedTypeList,
1602
1618
  NestedType,
1603
1619
  TypeConditional,
@@ -4890,13 +4906,8 @@ ${input.slice(result.pos)}
4890
4906
  var close = $7;
4891
4907
  const names = pes.flatMap((p) => p.names);
4892
4908
  if (rest) {
4893
- let restIdentifier;
4894
- if (rest.binding.ref) {
4895
- restIdentifier = rest.binding.ref;
4896
- } else {
4897
- names.push(...rest.names);
4898
- restIdentifier = rest.names[0];
4899
- }
4909
+ const restIdentifier = rest.binding.ref || rest.binding;
4910
+ names.push(...rest.names || []);
4900
4911
  let blockPrefix;
4901
4912
  if (after.length) {
4902
4913
  blockPrefix = {
@@ -4954,7 +4965,7 @@ ${input.slice(result.pos)}
4954
4965
  type: "FunctionRestParameter",
4955
4966
  children: $0,
4956
4967
  names: id.names,
4957
- binding: id
4968
+ binding: id.binding
4958
4969
  };
4959
4970
  });
4960
4971
  function FunctionRestParameter(state) {
@@ -5718,8 +5729,11 @@ ${input.slice(result.pos)}
5718
5729
  var dots = $2;
5719
5730
  var binding = $3;
5720
5731
  return {
5721
- ...binding,
5722
- children: [...ws || [], dots, ...binding.children],
5732
+ type: "BindingRestElement",
5733
+ children: [...ws || [], dots, binding],
5734
+ binding,
5735
+ name: binding.name,
5736
+ names: binding.names,
5723
5737
  rest: true
5724
5738
  };
5725
5739
  });
@@ -5728,8 +5742,11 @@ ${input.slice(result.pos)}
5728
5742
  var binding = $2;
5729
5743
  var dots = $3;
5730
5744
  return {
5731
- ...binding,
5732
- children: [...ws || [], dots, ...binding.children],
5745
+ type: "BindingRestElement",
5746
+ children: [...ws || [], dots, binding],
5747
+ binding,
5748
+ name: binding.name,
5749
+ names: binding.names,
5733
5750
  rest: true
5734
5751
  };
5735
5752
  });
@@ -10607,33 +10624,20 @@ ${input.slice(result.pos)}
10607
10624
  return result;
10608
10625
  }
10609
10626
  }
10610
- var CaseClause$0 = $TS($S(BindingPattern, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10611
- var pattern = $1;
10612
- var block = $2;
10613
- return {
10614
- type: "PatternClause",
10615
- children: $0,
10616
- block,
10617
- pattern
10618
- };
10619
- });
10620
- var CaseClause$1 = $TS($S($P(SingleLineBinaryOpRHS), $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10621
- var pattern = $1;
10627
+ var CaseClause$0 = $TS($S(PatternExpressionList, $C(ThenClause, NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2) {
10628
+ var patterns = $1;
10622
10629
  var block = $2;
10623
10630
  return {
10624
10631
  type: "PatternClause",
10625
10632
  children: $0,
10626
10633
  block,
10627
- pattern: {
10628
- type: "ConditionFragment",
10629
- children: pattern
10630
- }
10634
+ patterns
10631
10635
  };
10632
10636
  });
10633
- var CaseClause$2 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10637
+ var CaseClause$1 = $T($S(Case, CaseExpressionList, $C(NestedBlockStatements, EmptyBareBlock)), function(value) {
10634
10638
  return { "type": "CaseClause", "children": value };
10635
10639
  });
10636
- var CaseClause$3 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10640
+ var CaseClause$2 = $TS($S(When, CaseExpressionList, InsertOpenBrace, $C(ThenClause, NestedBlockStatements, EmptyBareBlock), InsertBreak, InsertNewline, InsertIndent, InsertCloseBrace), function($skip, $loc, $0, $1, $2, $3, $4, $5, $6, $7, $8) {
10637
10641
  var cases = $2;
10638
10642
  var block = $4;
10639
10643
  var b = $5;
@@ -10645,7 +10649,7 @@ ${input.slice(result.pos)}
10645
10649
  children: $0
10646
10650
  };
10647
10651
  });
10648
- var CaseClause$4 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10652
+ var CaseClause$3 = $TS($S(Default, ImpliedColon, $C(NestedBlockStatements, EmptyBareBlock)), function($skip, $loc, $0, $1, $2, $3) {
10649
10653
  var block = $3;
10650
10654
  return {
10651
10655
  type: "DefaultClause",
@@ -10653,7 +10657,7 @@ ${input.slice(result.pos)}
10653
10657
  children: $0
10654
10658
  };
10655
10659
  });
10656
- var CaseClause$5 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10660
+ var CaseClause$4 = $TS($S(Else, ImpliedColon, $C(ThenClause, BracedBlock, EmptyBlock)), function($skip, $loc, $0, $1, $2, $3) {
10657
10661
  var block = $3;
10658
10662
  $1.token = "default";
10659
10663
  return {
@@ -10673,17 +10677,74 @@ ${input.slice(result.pos)}
10673
10677
  }
10674
10678
  }
10675
10679
  if (state.tokenize) {
10676
- const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state));
10680
+ const result = $TOKEN("CaseClause", state, CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state));
10677
10681
  if (state.events)
10678
10682
  state.events.exit?.("CaseClause", state, result, eventData);
10679
10683
  return result;
10680
10684
  } else {
10681
- const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state) || CaseClause$5(state);
10685
+ const result = CaseClause$0(state) || CaseClause$1(state) || CaseClause$2(state) || CaseClause$3(state) || CaseClause$4(state);
10682
10686
  if (state.events)
10683
10687
  state.events.exit?.("CaseClause", state, result, eventData);
10684
10688
  return result;
10685
10689
  }
10686
10690
  }
10691
+ var PatternExpressionList$0 = $TS($S(ConditionFragment, $Q($S($E(_), Comma, $E(_), ConditionFragment))), function($skip, $loc, $0, $1, $2) {
10692
+ var first = $1;
10693
+ var rest = $2;
10694
+ return [first, ...rest.map(([, , , p]) => p)];
10695
+ });
10696
+ function PatternExpressionList(state) {
10697
+ let eventData;
10698
+ if (state.events) {
10699
+ const result = state.events.enter?.("PatternExpressionList", state);
10700
+ if (result) {
10701
+ if (result.cache)
10702
+ return result.cache;
10703
+ eventData = result.data;
10704
+ }
10705
+ }
10706
+ if (state.tokenize) {
10707
+ const result = $TOKEN("PatternExpressionList", state, PatternExpressionList$0(state));
10708
+ if (state.events)
10709
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10710
+ return result;
10711
+ } else {
10712
+ const result = PatternExpressionList$0(state);
10713
+ if (state.events)
10714
+ state.events.exit?.("PatternExpressionList", state, result, eventData);
10715
+ return result;
10716
+ }
10717
+ }
10718
+ var ConditionFragment$0 = BindingPattern;
10719
+ var ConditionFragment$1 = $TV($P(SingleLineBinaryOpRHS), function($skip, $loc, $0, $1) {
10720
+ var pattern = $0;
10721
+ return {
10722
+ type: "ConditionFragment",
10723
+ children: pattern
10724
+ };
10725
+ });
10726
+ function ConditionFragment(state) {
10727
+ let eventData;
10728
+ if (state.events) {
10729
+ const result = state.events.enter?.("ConditionFragment", state);
10730
+ if (result) {
10731
+ if (result.cache)
10732
+ return result.cache;
10733
+ eventData = result.data;
10734
+ }
10735
+ }
10736
+ if (state.tokenize) {
10737
+ const result = $TOKEN("ConditionFragment", state, ConditionFragment$0(state) || ConditionFragment$1(state));
10738
+ if (state.events)
10739
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10740
+ return result;
10741
+ } else {
10742
+ const result = ConditionFragment$0(state) || ConditionFragment$1(state);
10743
+ if (state.events)
10744
+ state.events.exit?.("ConditionFragment", state, result, eventData);
10745
+ return result;
10746
+ }
10747
+ }
10687
10748
  var CaseExpressionList$0 = $TS($S(ForbidMultiLineImplicitObjectLiteral, $E($S($Q(_), ExpressionWithIndentedApplicationForbidden, ImpliedColon)), $Q($S(__, Comma, ExpressionWithIndentedApplicationForbidden, ImpliedColon)), RestoreMultiLineImplicitObjectLiteral), function($skip, $loc, $0, $1, $2, $3, $4) {
10688
10749
  var first = $2;
10689
10750
  var rest = $3;
@@ -19180,7 +19241,7 @@ ${input.slice(result.pos)}
19180
19241
  return result;
19181
19242
  }
19182
19243
  }
19183
- var TypeList$0 = $S(Type, $Q($S(__, Comma, Type)));
19244
+ var TypeList$0 = $S(TypeElement, $Q($S(__, Comma, TypeElement)));
19184
19245
  function TypeList(state) {
19185
19246
  let eventData;
19186
19247
  if (state.events) {
@@ -19203,6 +19264,36 @@ ${input.slice(result.pos)}
19203
19264
  return result;
19204
19265
  }
19205
19266
  }
19267
+ var TypeElement$0 = $S($S(__, DotDotDot, __), Type);
19268
+ var TypeElement$1 = $TS($S(Type, $E($S($E(_), DotDotDot))), function($skip, $loc, $0, $1, $2) {
19269
+ var type = $1;
19270
+ var dots = $2;
19271
+ if (!dots)
19272
+ return type;
19273
+ return [dots, type];
19274
+ });
19275
+ function TypeElement(state) {
19276
+ let eventData;
19277
+ if (state.events) {
19278
+ const result = state.events.enter?.("TypeElement", state);
19279
+ if (result) {
19280
+ if (result.cache)
19281
+ return result.cache;
19282
+ eventData = result.data;
19283
+ }
19284
+ }
19285
+ if (state.tokenize) {
19286
+ const result = $TOKEN("TypeElement", state, TypeElement$0(state) || TypeElement$1(state));
19287
+ if (state.events)
19288
+ state.events.exit?.("TypeElement", state, result, eventData);
19289
+ return result;
19290
+ } else {
19291
+ const result = TypeElement$0(state) || TypeElement$1(state);
19292
+ if (state.events)
19293
+ state.events.exit?.("TypeElement", state, result, eventData);
19294
+ return result;
19295
+ }
19296
+ }
19206
19297
  var NestedTypeList$0 = $TS($S(PushIndent, $Q(NestedType), PopIndent), function($skip, $loc, $0, $1, $2, $3) {
19207
19298
  var types = $2;
19208
19299
  if (types.length)
@@ -21792,8 +21883,8 @@ ${input.slice(result.pos)}
21792
21883
  module.adjustBindingElements = function(elements) {
21793
21884
  const names = elements.flatMap((p) => p.names || []), { length } = elements;
21794
21885
  let blockPrefix, restIndex = -1, restCount = 0;
21795
- elements.forEach(({ rest }, i) => {
21796
- if (rest) {
21886
+ elements.forEach(({ type }, i) => {
21887
+ if (type === "BindingRestElement") {
21797
21888
  if (restIndex < 0)
21798
21889
  restIndex = i;
21799
21890
  restCount++;
@@ -21809,13 +21900,8 @@ ${input.slice(result.pos)}
21809
21900
  } else if (restCount === 1) {
21810
21901
  const rest = elements[restIndex];
21811
21902
  const after = elements.slice(restIndex + 1);
21812
- let restIdentifier;
21813
- if (rest.ref) {
21814
- restIdentifier = rest.ref;
21815
- } else {
21816
- restIdentifier = rest.names[0];
21817
- names.push(...rest.names);
21818
- }
21903
+ const restIdentifier = rest.binding.ref || rest.binding;
21904
+ names.push(...rest.names || []);
21819
21905
  if (after.length) {
21820
21906
  blockPrefix = {
21821
21907
  type: "PostRestBindingElements",
@@ -22289,7 +22375,11 @@ ${input.slice(result.pos)}
22289
22375
  }
22290
22376
  }
22291
22377
  function elideMatchersFromArrayBindings(elements) {
22292
- return elements.map(({ children: [ws, e, sep] }) => {
22378
+ return elements.map((el) => {
22379
+ if (el.type === "BindingRestElement") {
22380
+ return ["", el, void 0];
22381
+ }
22382
+ const { children: [ws, e, sep] } = el;
22293
22383
  switch (e.type) {
22294
22384
  case "Literal":
22295
22385
  case "RegularExpressionLiteral":
@@ -22336,8 +22426,15 @@ ${input.slice(result.pos)}
22336
22426
  }
22337
22427
  function nonMatcherBindings(pattern) {
22338
22428
  switch (pattern.type) {
22339
- case "ArrayBindingPattern":
22340
- return ["[", elideMatchersFromArrayBindings(pattern.elements), "]"];
22429
+ case "ArrayBindingPattern": {
22430
+ const elements = elideMatchersFromArrayBindings(pattern.elements);
22431
+ const children = ["[", elements, "]"];
22432
+ return {
22433
+ ...pattern,
22434
+ children,
22435
+ elements
22436
+ };
22437
+ }
22341
22438
  case "PostRestBindingElements": {
22342
22439
  const els = elideMatchersFromArrayBindings(pattern.children[1]);
22343
22440
  return {
@@ -22357,11 +22454,25 @@ ${input.slice(result.pos)}
22357
22454
  }
22358
22455
  function aggregateDuplicateBindings(bindings) {
22359
22456
  const props = gatherRecursiveAll(bindings, (n) => n.type === "BindingProperty");
22457
+ const arrayBindings = gatherRecursiveAll(bindings, (n) => n.type === "ArrayBindingPattern");
22458
+ arrayBindings.forEach((a) => {
22459
+ const { elements } = a;
22460
+ elements.forEach((element) => {
22461
+ if (Array.isArray(element)) {
22462
+ const [, e] = element;
22463
+ if (e.type === "Identifier") {
22464
+ props.push(e);
22465
+ } else if (e.type === "BindingRestElement") {
22466
+ props.push(e);
22467
+ }
22468
+ }
22469
+ });
22470
+ });
22360
22471
  const declarations = [];
22361
22472
  const propsGroupedByName = /* @__PURE__ */ new Map();
22362
22473
  for (const p of props) {
22363
22474
  const { name, value } = p;
22364
- const key = value?.name || name.name;
22475
+ const key = value?.name || name?.name || name;
22365
22476
  if (propsGroupedByName.has(key)) {
22366
22477
  propsGroupedByName.get(key).push(p);
22367
22478
  } else {
@@ -22381,7 +22492,7 @@ ${input.slice(result.pos)}
22381
22492
  base: `_${key}`,
22382
22493
  id: key
22383
22494
  };
22384
- p.children.push(": ", ref);
22495
+ aliasBinding(p, ref);
22385
22496
  });
22386
22497
  return;
22387
22498
  }
@@ -22393,7 +22504,7 @@ ${input.slice(result.pos)}
22393
22504
  base: key,
22394
22505
  id: key
22395
22506
  };
22396
- p.children.push(": ", ref);
22507
+ aliasBinding(p, ref);
22397
22508
  return ref;
22398
22509
  });
22399
22510
  declarations.push(["const ", key, " = [", ...refs.map((r, i) => {
@@ -22434,18 +22545,28 @@ ${input.slice(result.pos)}
22434
22545
  prev.push(c.block);
22435
22546
  return;
22436
22547
  }
22437
- let { pattern, block } = c;
22548
+ let { patterns, block } = c;
22549
+ let pattern = patterns[0];
22438
22550
  const indent = block.expressions?.[0]?.[0] || "";
22439
- const conditions = [];
22440
- getPatternConditions(pattern, ref, conditions);
22441
- const condition = {
22442
- type: "ParenthesizedExpression",
22443
- children: ["(", conditions.map((c2, i2) => {
22444
- if (i2 === 0)
22551
+ const alternativeConditions = patterns.map((pattern2, i2) => {
22552
+ const conditions = [];
22553
+ getPatternConditions(pattern2, ref, conditions);
22554
+ return conditions;
22555
+ });
22556
+ const conditionExpression = alternativeConditions.map((conditions, i2) => {
22557
+ const conditionArray = conditions.map((c2, i3) => {
22558
+ if (i3 === 0)
22445
22559
  return c2;
22446
22560
  return [" && ", ...c2];
22447
- }), ")"],
22448
- expression: conditions
22561
+ });
22562
+ if (i2 === 0)
22563
+ return conditionArray;
22564
+ return [" || ", ...conditionArray];
22565
+ });
22566
+ const condition = {
22567
+ type: "ParenthesizedExpression",
22568
+ children: ["(", conditionExpression, ")"],
22569
+ expression: conditionExpression
22449
22570
  };
22450
22571
  const prefix = [];
22451
22572
  switch (pattern.type) {
@@ -23159,6 +23280,7 @@ ${input.slice(result.pos)}
23159
23280
  exports.parse = parse2;
23160
23281
  exports.default = { parse: parse2 };
23161
23282
  var {
23283
+ aliasBinding,
23162
23284
  blockWithPrefix,
23163
23285
  clone,
23164
23286
  convertMethodToFunction,
@@ -23621,7 +23743,7 @@ var parse;
23621
23743
  var uncacheable;
23622
23744
  ({ parse } = import_parser.default);
23623
23745
  ({ SourceMap: SourceMap2 } = util_exports);
23624
- uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23746
+ uncacheable = /* @__PURE__ */ new Set(["ActualAssignment", "AllowAll", "AllowClassImplicitCall", "AllowIndentedApplication", "AllowMultiLineImplicitObjectLiteral", "AllowNewlineBinaryOp", "AllowTrailingMemberProperty", "AllowedTrailingMemberExpressions", "ApplicationStart", "Arguments", "ArgumentsWithTrailingMemberExpressions", "ArrowFunction", "ArrowFunctionTail", "AssignmentExpression", "AssignmentExpressionTail", "BinaryOpExpression", "BinaryOpRHS", "BracedBlock", "BracedObjectLiteralContent", "BracedOrEmptyBlock", "CallExpression", "CallExpressionRest", "ClassImplicitCallForbidden", "CoffeeCommentEnabled", "CommaDelimiter", "ConditionalExpression", "ConditionFragment", "Declaration", "Debugger", "Dedented", "ElementListWithIndentedApplicationForbidden", "ElseClause", "Expression", "ExpressionStatement", "ExpressionWithIndentedApplicationForbidden", "ExtendedExpression", "FatArrowBody", "ForbidClassImplicitCall", "ForbidIndentedApplication", "ForbidMultiLineImplicitObjectLiteral", "ForbidNewlineBinaryOp", "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", "NestedNonAssignmentExtendedExpression", "NestedObject", "NestedPropertyDefinitions", "NewlineBinaryOpAllowed", "NonSingleBracedBlock", "NotDedented", "ObjectLiteral", "PatternExpressionList", "PopIndent", "PopJSXStack", "PostfixedExpression", "PostfixedStatement", "PrimaryExpression", "PushIndent", "PushJSXOpeningElement", "PushJSXOpeningFragment", "RestoreAll", "RestoreClassImplicitCall", "RestoreMultiLineImplicitObjectLiteral", "RestoreIndentedApplication", "RestoreTrailingMemberProperty", "RestoreNewlineBinaryOp", "RHS", "Samedent", "ShortCircuitExpression", "SingleLineAssignmentExpression", "SingleLineBinaryOpRHS", "SingleLineComment", "SingleLineStatements", "SnugNamedProperty", "Statement", "StatementListItem", "SuffixedExpression", "SuffixedStatement", "ThinArrowFunction", "TrackIndented", "TrailingMemberExpressions", "TrailingMemberPropertyAllowed", "TypedJSXElement", "TypedJSXFragment", "UnaryExpression", "UpdateExpression"]);
23625
23747
  var compile = function(src, options) {
23626
23748
  var ast, code, events, filename, ref, result, sm;
23627
23749
  if (!options) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielx/civet",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "description": "CoffeeScript style syntax for TypeScript",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/main.mjs",